cache['DBGalaxia'])) { /* make sure the environment is set */ $this->assureEnvironment(); /* check if all configuration is OK */ $dedicatedDB = true; /* if any parameter is not set, then we will return expresso database */ if ((Settings::get('workflow', 'galaxia', 'db', 'name') == '') or (Settings::get('workflow', 'galaxia', 'db', 'host') == '') or (Settings::get('workflow', 'galaxia', 'db', 'port') == '') or (Settings::get('workflow', 'galaxia', 'db', 'user') == '') or (Settings::get('workflow', 'galaxia', 'db', 'type') == '')) $dedicatedDB = false; /* should we connect to a dedicated database? */ if ($dedicatedDB) { /* connect to the database */ $this->cache['DBGalaxia'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); $this->cache['DBGalaxia']->disconnect(); /* for some reason it won't connect to the desired database unless we disconnect it first */ $this->cache['DBGalaxia']->Halt_On_Error = 'no'; $this->cache['DBGalaxia']->connect( Settings::get('workflow', 'galaxia', 'db', 'name'), Settings::get('workflow', 'galaxia', 'db', 'host'), Settings::get('workflow', 'galaxia', 'db', 'port'), Settings::get('workflow', 'galaxia', 'db', 'user'), Settings::get('workflow', 'galaxia', 'db', 'password'), Settings::get('workflow', 'galaxia', 'db', 'type') ); Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBGalaxia']); $this->cache['DBGalaxia']->Link_ID = Factory::newInstance('WorkflowWatcher', $this->cache['DBGalaxia']->Link_ID); } else $this->cache['DBGalaxia'] = &$this->getDBExpresso(); } return $this->cache['DBGalaxia']; } /** * Retorna uma conexão com o banco de dados do Expresso (eGroupWare) * @return object O objeto de acesso a banco de dados, já conectado * @access public */ function &getDBExpresso() { if (!isset($this->cache['DBExpresso'])) { /* make sure the environment is set */ $this->assureEnvironment(false); /* connect to the database */ $this->cache['DBExpresso'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); $this->cache['DBExpresso']->disconnect(); /* for some reason it won't connect to the desired database unless we disconnect it first */ $this->cache['DBExpresso']->Halt_On_Error = 'no'; $this->cache['DBExpresso']->connect( Settings::get('expresso', 'db', 'name'), Settings::get('expresso', 'db', 'host'), Settings::get('expresso', 'db', 'port'), Settings::get('expresso', 'db', 'user'), Settings::get('expresso', 'db', 'password'), Settings::get('expresso', 'db', 'type') ); Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBExpresso']); $this->cache['DBExpresso']->Link_ID = Factory::newInstance('WorkflowWatcher', $this->cache['DBExpresso']->Link_ID); } return $this->cache['DBExpresso']; } /** * Retorna uma conexão com o banco de dados do Workflow * @return object O objeto de acesso a banco de dados, já conectado * @access public */ function &getDBWorkflow() { if (!isset($this->cache['DBWorkflow'])) { /* make sure the environment is set */ $this->assureEnvironment(); /* connect to the database */ $this->cache['DBWorkflow'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); $this->cache['DBWorkflow']->disconnect(); /* for some reason it won't connect to the desired database unless we disconnect it first */ $this->cache['DBWorkflow']->Halt_On_Error = 'no'; $this->cache['DBWorkflow']->connect( Settings::get('workflow', 'db', 'name'), Settings::get('workflow', 'db', 'host'), Settings::get('workflow', 'db', 'port'), Settings::get('workflow', 'db', 'admin_user'), Settings::get('workflow', 'db', 'admin_password'), Settings::get('workflow', 'db', 'type') ); Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBWorkflow']); $this->cache['DBWorkflow']->Link_ID = Factory::newInstance('WorkflowWatcher', $this->cache['DBWorkflow']->Link_ID); } return $this->cache['DBWorkflow']; } /** * Retorna um recurso de LDAP * @return resource O recurso LDAP * @access public */ function &getLDAP() { if (!isset($this->cache['ldap'])) { /* make sure the environment is set */ $this->assureEnvironment(); /* which ldap host to connect? */ $ldapHost = Settings::get('workflow', 'ldap', 'host'); if (empty($ldapHost)) $ldapHost = Settings::get('expresso', 'ldap', 'host'); /* connect to the LDAP server */ $this->cache['ldap'] = ldap_connect($ldapHost); /* configure the connection */ ldap_set_option($this->cache['ldap'], LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($this->cache['ldap'], LDAP_OPT_REFERRALS, (Settings::get('workflow', 'ldap', 'follow_referrals') == 1) ? 1 : 0); /* if username and password are available, bind the connection */ if ((Settings::get('workflow', 'ldap', 'user') != '') and (Settings::get('workflow', 'ldap', 'password') != '')) ldap_bind( $this->cache['ldap'], Settings::get('workflow', 'ldap', 'user'), Settings::get('workflow', 'ldap', 'password') ); } return $this->cache['ldap']; } } ?>