- Timestamp:
- 04/05/10 15:30:21 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/workflow/branches/993/inc/class.WorkflowObjects.inc.php
r2372 r2418 13 13 * Provê objetos de multipropósito do Workflow 14 14 * @author Sidnei Augusto Drovetto Jr. - drovetto@gmail.com 15 * @author Pedro Eugenio Rocha - pedro.eugenio.rocha@gmail.com 15 16 * @version 1.0 16 17 * @package Workflow … … 23 24 * @access private 24 25 */ 25 private $cache ;26 private $cache = array(); 26 27 27 28 /** 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.. 38 30 * Monta o ambiente requerido pelos métodos (somente se for necessário) 39 31 * @param bool $requireGalaxia Indica que os métodos da engine Galaxia são necessários … … 68 60 $this->assureEnvironment(); 69 61 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 80 62 /* check if all configuration is OK */ 81 63 $dedicatedDB = true; 82 foreach ($dbConfigValues as $configName => $configValue)83 if (empty($configValue) && ($configName != 'workflow_database_password'))84 $dedicatedDB = false;85 64 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? */ 86 74 if ($dedicatedDB) 87 75 { … … 91 79 $this->cache['DBGalaxia']->Halt_On_Error = 'no'; 92 80 $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') 99 87 ); 100 88 Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBGalaxia']); … … 120 108 $this->assureEnvironment(false); 121 109 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 else134 return false;135 }136 137 110 /* connect to the database */ 138 111 $this->cache['DBExpresso'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); … … 140 113 $this->cache['DBExpresso']->Halt_On_Error = 'no'; 141 114 $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') 148 121 ); 149 122 Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBExpresso']); … … 166 139 $this->assureEnvironment(); 167 140 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 178 141 /* connect to the database */ 179 142 $this->cache['DBWorkflow'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); … … 181 144 $this->cache['DBWorkflow']->Halt_On_Error = 'no'; 182 145 $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') 189 152 ); 190 153 Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBWorkflow']); … … 207 170 $this->assureEnvironment(); 208 171 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'); 218 176 219 177 /* connect to the LDAP server */ 220 $this->cache['ldap'] = ldap_connect($ldap ConfigValues['ldap_host']);178 $this->cache['ldap'] = ldap_connect($ldapHost); 221 179 222 180 /* configure the connection */ 223 181 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); 225 183 226 184 /* 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 ); 229 191 } 230 192
Note: See TracChangeset
for help on using the changeset viewer.