File size: 2,764 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
 * databases.php
 *
 * ProcessMaker Open Source Edition
 * Copyright (C) 2004 - 2008 Colosa Inc.23
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 *
 */

if (defined('PATH_DB') && !empty(config("system.workspace"))) {

    if (!file_exists(PATH_DB . config("system.workspace") . '/db.php'))
        throw new Exception("Could not find db.php in current workspace " . config("system.workspace"));

    require_once(PATH_DB . config("system.workspace") . '/db.php');
    //to do: enable for other databases
    $dbType = DB_ADAPTER;
    $dsn = DB_ADAPTER . '://' . DB_USER . ':' . urlencode(DB_PASS) . '@' . DB_HOST . '/' . DB_NAME;

    //to do: enable a mechanism to select RBAC Database
    $dsnRbac = DB_ADAPTER . '://' . DB_RBAC_USER . ':' . urlencode(DB_RBAC_PASS) . '@' . DB_RBAC_HOST . '/' . DB_RBAC_NAME;

    //to do: enable a mechanism to select report Database
    $dsnReport = DB_ADAPTER . '://' . DB_REPORT_USER . ':' . urlencode(DB_REPORT_PASS) . '@' . DB_REPORT_HOST . '/' . DB_REPORT_NAME;

    switch (DB_ADAPTER) {
        case 'mysql':
            $dsn       .= '?encoding=utf8';
            $dsnRbac   .= '?encoding=utf8';
            $dsnReport .= '?encoding=utf8';
            break;
        case 'mssql':
        case 'sqlsrv':
            //$dsn       .= '?sendStringAsUnicode=false';
            //$dsnRbac   .= '?sendStringAsUnicode=false';
            //$dsnReport .= '?sendStringAsUnicode=false';
            break;
        default:
            break;
    }

    $pro ['datasources']['workflow']['connection'] = $dsn;
    $pro ['datasources']['workflow']['adapter'] = DB_ADAPTER;

    $pro ['datasources']['rbac']['connection'] = $dsnRbac;
    $pro ['datasources']['rbac']['adapter'] = DB_ADAPTER;

    $pro ['datasources']['rp']['connection'] = $dsnReport;
    $pro ['datasources']['rp']['adapter'] = DB_ADAPTER;

}

$pro ['datasources']['dbarray']['connection'] = 'dbarray://user:pass@localhost/pm_os';
$pro ['datasources']['dbarray']['adapter']    = 'dbarray';

return $pro;