Ignore:
Timestamp:
04/05/10 15:30:21 (14 years ago)
Author:
pedroerp
Message:

Ticket #993 - Versão inicial da classe 'Settings' e substituicao de chamadas 'read_repository'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/workflow/branches/993/inc/class.WorkflowObjects.inc.php

    r2372 r2418  
    1313 * Provê objetos de multipropósito do Workflow 
    1414 * @author Sidnei Augusto Drovetto Jr. - drovetto@gmail.com 
     15 * @author Pedro Eugenio Rocha - pedro.eugenio.rocha@gmail.com 
    1516 * @version 1.0 
    1617 * @package Workflow 
     
    2324         * @access private 
    2425         */ 
    25         private $cache; 
     26        private $cache = array(); 
    2627 
    2728        /** 
    28          * Construtor da classe 
    29          * @return object 
    30          * @access public 
    31          */ 
    32         function WorkflowObjects() 
    33         { 
    34                 $this->cache = array(); 
    35         } 
    36  
    37         /** 
     29         * TODO We should remove this method.. 
    3830         * Monta o ambiente requerido pelos métodos (somente se for necessário) 
    3931         * @param bool $requireGalaxia Indica que os métodos da engine Galaxia são necessários 
     
    6860                        $this->assureEnvironment(); 
    6961 
    70                         /* load the configuration required to establish a connection to the Galaxia database */ 
    71                         $dbConfigValues = galaxia_get_config_values(array( 
    72                                 'workflow_database_name' => '', 
    73                                 'workflow_database_host' => '', 
    74                                 'workflow_database_port' => '', 
    75                                 'workflow_database_user' => '', 
    76                                 'workflow_database_password' => '', 
    77                                 'workflow_database_type' => '' 
    78                         )); 
    79  
    8062                        /* check if all configuration is OK */ 
    8163                        $dedicatedDB = true; 
    82                         foreach ($dbConfigValues as $configName => $configValue) 
    83                                 if (empty($configValue) && ($configName != 'workflow_database_password')) 
    84                                         $dedicatedDB = false; 
    8564 
     65                        /* if any parameter is not set, then we will return expresso database */ 
     66                        if ((Settings::get('workflow', 'galaxia', 'db', 'name') == '') or 
     67                                (Settings::get('workflow', 'galaxia', 'db', 'host') == '') or 
     68                                (Settings::get('workflow', 'galaxia', 'db', 'port') == '') or 
     69                                (Settings::get('workflow', 'galaxia', 'db', 'user') == '') or 
     70                                (Settings::get('workflow', 'galaxia', 'db', 'type') == '')) 
     71                                $dedicatedDB = false; 
     72 
     73                        /* should we connect to a dedicated database? */ 
    8674                        if ($dedicatedDB) 
    8775                        { 
     
    9179                                $this->cache['DBGalaxia']->Halt_On_Error = 'no'; 
    9280                                $this->cache['DBGalaxia']->connect( 
    93                                         $dbConfigValues['workflow_database_name'], 
    94                                         $dbConfigValues['workflow_database_host'], 
    95                                         $dbConfigValues['workflow_database_port'], 
    96                                         $dbConfigValues['workflow_database_user'], 
    97                                         $dbConfigValues['workflow_database_password'], 
    98                                         $dbConfigValues['workflow_database_type'] 
     81                                        Settings::get('workflow', 'galaxia', 'db', 'name'), 
     82                                        Settings::get('workflow', 'galaxia', 'db', 'host'), 
     83                                        Settings::get('workflow', 'galaxia', 'db', 'port'), 
     84                                        Settings::get('workflow', 'galaxia', 'db', 'user'), 
     85                                        Settings::get('workflow', 'galaxia', 'db', 'password'), 
     86                                        Settings::get('workflow', 'galaxia', 'db', 'type') 
    9987                                ); 
    10088                                Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBGalaxia']); 
     
    120108                        $this->assureEnvironment(false); 
    121109 
    122                         /* check where the connection parameters are */ 
    123                         $connectionInfo = (isset($GLOBALS['phpgw_info']['server']['db_name'])) ? 
    124                                 $GLOBALS['phpgw_info']['server'] : 
    125                                 $_SESSION['phpgw_info']['workflow']['server']; 
    126  
    127                         /* the information was not found. Try to load the environment */ 
    128                         if (!isset($connectionInfo['db_name'])) 
    129                         { 
    130                                 Factory::getInstance('WorkflowMacro')->prepareEnvironment(); 
    131                                 if (isset($GLOBALS['phpgw_info']['server'])) 
    132                                         $connectionInfo = $GLOBALS['phpgw_info']['server']; 
    133                                 else 
    134                                         return false; 
    135                         } 
    136  
    137110                        /* connect to the database */ 
    138111                        $this->cache['DBExpresso'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); 
     
    140113                        $this->cache['DBExpresso']->Halt_On_Error = 'no'; 
    141114                        $this->cache['DBExpresso']->connect( 
    142                                 $connectionInfo['db_name'], 
    143                                 $connectionInfo['db_host'], 
    144                                 $connectionInfo['db_port'], 
    145                                 $connectionInfo['db_user'], 
    146                                 $connectionInfo['db_pass'], 
    147                                 $connectionInfo['db_type'] 
     115                                Settings::get('expresso', 'db', 'name'), 
     116                                Settings::get('expresso', 'db', 'host'), 
     117                                Settings::get('expresso', 'db', 'port'), 
     118                                Settings::get('expresso', 'db', 'user'), 
     119                                Settings::get('expresso', 'db', 'password'), 
     120                                Settings::get('expresso', 'db', 'type') 
    148121                        ); 
    149122                        Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBExpresso']); 
     
    166139                        $this->assureEnvironment(); 
    167140 
    168                         /* load the configuration required to establish a connection to the Galaxia database */ 
    169                         $dbConfigValues = galaxia_get_config_values(array( 
    170                                 'database_name' => '', 
    171                                 'database_host' => '', 
    172                                 'database_port' => '', 
    173                                 'database_admin_user' => '', 
    174                                 'database_admin_password' => '', 
    175                                 'database_type' => '' 
    176                         )); 
    177  
    178141                        /* connect to the database */ 
    179142                        $this->cache['DBWorkflow'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); 
     
    181144                        $this->cache['DBWorkflow']->Halt_On_Error = 'no'; 
    182145                        $this->cache['DBWorkflow']->connect( 
    183                                 $dbConfigValues['database_name'], 
    184                                 $dbConfigValues['database_host'], 
    185                                 $dbConfigValues['database_port'], 
    186                                 $dbConfigValues['database_admin_user'], 
    187                                 $dbConfigValues['database_admin_password'], 
    188                                 $dbConfigValues['database_type'] 
     146                                Settings::get('workflow', 'db', 'name'), 
     147                                Settings::get('workflow', 'db', 'host'), 
     148                                Settings::get('workflow', 'db', 'port'), 
     149                                Settings::get('workflow', 'db', 'admin_user'), 
     150                                Settings::get('workflow', 'db', 'admin_password'), 
     151                                Settings::get('workflow', 'db', 'type') 
    189152                        ); 
    190153                        Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBWorkflow']); 
     
    207170                        $this->assureEnvironment(); 
    208171 
    209                         /* check where the connection parameters are */ 
    210                         $connectionInfo = (isset($GLOBALS['phpgw_info']['server']['ldap_host'])) ? 
    211                                 $GLOBALS['phpgw_info']['server'] : 
    212                                 $_SESSION['phpgw_info']['workflow']['server']; 
    213  
    214                         /* load required information */ 
    215                         $ldapConfigValues = galaxia_get_config_values(array('ldap_host' => '', 'ldap_user' => '', 'ldap_password'=> '', 'ldap_follow_referrals' => '')); 
    216                         if (empty($ldapConfigValues['ldap_host'])) 
    217                                 $ldapConfigValues['ldap_host'] = $connectionInfo['ldap_host']; 
     172                        /* which ldap host to connect? */ 
     173                        $ldapHost = Settings::get('workflow', 'ldap', 'host'); 
     174                        if (empty($ldapHost)) 
     175                                $ldapHost = Settings::get('expresso', 'ldap', 'host'); 
    218176 
    219177                        /* connect to the LDAP server */ 
    220                         $this->cache['ldap'] = ldap_connect($ldapConfigValues['ldap_host']); 
     178                        $this->cache['ldap'] = ldap_connect($ldapHost); 
    221179 
    222180                        /* configure the connection */ 
    223181                        ldap_set_option($this->cache['ldap'], LDAP_OPT_PROTOCOL_VERSION, 3); 
    224                         ldap_set_option($this->cache['ldap'], LDAP_OPT_REFERRALS, ($ldapConfigValues['ldap_follow_referrals'] == 1) ? 1 : 0); 
     182                        ldap_set_option($this->cache['ldap'], LDAP_OPT_REFERRALS, (Settings::get('workflow', 'ldap', 'follow_referrals') == 1) ? 1 : 0); 
    225183 
    226184                        /* if  username and password are available, bind the connection */ 
    227                         if ((!empty($ldapConfigValues['ldap_user'])) && (!empty($ldapConfigValues['ldap_password']))) 
    228                                 ldap_bind($this->cache['ldap'], $ldapConfigValues['ldap_user'], $ldapConfigValues['ldap_password']); 
     185                        if ((Settings::get('workflow', 'ldap', 'user') != '') and 
     186                                (Settings::get('workflow', 'ldap', 'password') != '')) 
     187                                ldap_bind(      $this->cache['ldap'], 
     188                                                        Settings::get('workflow', 'ldap', 'user'), 
     189                                                        Settings::get('workflow', 'ldap', 'password') 
     190                                                        ); 
    229191                } 
    230192 
Note: See TracChangeset for help on using the changeset viewer.