/** * Get the db adapter for this source * * @return \Zend_Db_Adapter_Abstract */ protected function getSourceDatabase() { if (!$this->_sourceDb) { if ($dbConfig['dbname'] = $this->_sourceData['gso_ls_database']) { // Default config values from gemsDb $gemsConfig = $this->_gemsDb->getConfig(); $gemsName = $gemsConfig['dbname']; if ($dbConfig['dbname'] != $gemsName && ($adapter = $this->_sourceData['gso_ls_adapter'])) { //If upgrade has run and we have a 'charset' use it if (array_key_exists('gso_ls_charset', $this->_sourceData)) { $dbConfig['charset'] = $this->_sourceData['gso_ls_charset'] ? $this->_sourceData['gso_ls_charset'] : $gemsConfig['charset']; } $dbConfig['host'] = $this->_sourceData['gso_ls_dbhost'] ? $this->_sourceData['gso_ls_dbhost'] : $gemsConfig['host']; $dbConfig['username'] = $this->_sourceData['gso_ls_username'] ? $this->_sourceData['gso_ls_username'] : $gemsConfig['username']; $dbConfig['password'] = $this->_sourceData['gso_ls_password'] ? $this->project->decrypt($this->_sourceData['gso_ls_password'], $this->_sourceData['gso_encryption']) : $gemsConfig['password']; $this->_sourceDb = \Zend_Db::factory($adapter, $dbConfig); } } // In all other cases use $_gemsDb if (!$this->_sourceDb) { $this->_sourceDb = $this->_gemsDb; } } return $this->_sourceDb; }
/** * A ModelAbstract->setOnLoad() function that takes care of transforming a * dateformat read from the database to a \Zend_Date format * * If empty or \Zend_Db_Expression (after save) it will return just the value * currently there are no checks for a valid date format. * * @see \MUtil_Model_ModelAbstract * * @param mixed $value The value being saved * @param boolean $isNew True when a new item is being saved * @param string $name The name of the current field * @param array $context Optional, the other values being saved * @param boolean $isPost True when passing on post data * @return \MUtil_Date|\Zend_Db_Expr|string */ public function loadValue($value, $isNew = false, $name = null, array $context = array(), $isPost = false) { if ($value && !$isPost) { if ($this->valueMask) { return str_repeat('*', 8); } else { $methodField = array_search($name, $this->findValue); if (array_key_exists($methodField, $context)) { return $this->project->decrypt($value, $context[$methodField]); } } } return $value; }
/** * Returns \Zend_Mail_Transport_Abstract when something else than the default mail protocol should be used. * * @staticvar array $mailServers * @param email address $from * @return \Zend_Mail_Transport_Abstract or null */ public function checkTransport($from) { if (!array_key_exists($from, self::$mailServers)) { $sql = 'SELECT * FROM gems__mail_servers WHERE ? LIKE gms_from ORDER BY LENGTH(gms_from) DESC LIMIT 1'; // Always set cache, se we know when not to check for this row. $serverData = $this->escort->db->fetchRow($sql, $from); // \MUtil_Echo::track($serverData); if (isset($serverData['gms_server'])) { $options = array(); if (isset($serverData['gms_user'], $serverData['gms_password'])) { $options['auth'] = 'login'; $options['username'] = $serverData['gms_user']; $options['password'] = $this->project->decrypt($serverData['gms_password'], $serverData['gms_encryption']); } if (isset($serverData['gms_port'])) { $options['port'] = $serverData['gms_port']; } if (isset($serverData['gms_ssl'])) { switch ($serverData['gms_ssl']) { case self::MAIL_SSL: $options['ssl'] = 'ssl'; break; case self::MAIL_TLS: $options['ssl'] = 'tls'; break; default: // intentional fall through } } self::$mailServers[$from] = new \Zend_Mail_Transport_Smtp($serverData['gms_server'], $options); } else { self::$mailServers[$from] = $this->getDefaultTransport(); } } return self::$mailServers[$from]; }