Beispiel #1
0
 protected function afterFind()
 {
     if (StringHelper::isNullOrEmpty($this->icon_src)) {
         $this->icon_src = Group::DEFAULT_IMG_PATH;
     }
     return parent::afterFind();
 }
Beispiel #2
0
 /**
  * Make sure the basics are in place in the db connection file before we actually try to connect later on.
  *
  * @throws DbConnectException
  */
 private function _validateDbConfigFile()
 {
     $messages = array();
     $databaseServerName = craft()->config->getDbItem('server');
     $databaseAuthName = craft()->config->getDbItem('user');
     $databaseName = craft()->config->getDbItem('database');
     $databasePort = craft()->config->getDbItem('port');
     $databaseCharset = craft()->config->getDbItem('charset');
     $databaseCollation = craft()->config->getDbItem('collation');
     if (StringHelper::isNullOrEmpty($databaseServerName)) {
         $messages[] = Craft::t('The database server name isn’t set in your db config file.');
     }
     if (StringHelper::isNullOrEmpty($databaseAuthName)) {
         $messages[] = Craft::t('The database user name isn’t set in your db config file.');
     }
     if (StringHelper::isNullOrEmpty($databaseName)) {
         $messages[] = Craft::t('The database name isn’t set in your db config file.');
     }
     if (StringHelper::isNullOrEmpty($databasePort)) {
         $messages[] = Craft::t('The database port isn’t set in your db config file.');
     }
     if (StringHelper::isNullOrEmpty($databaseCharset)) {
         $messages[] = Craft::t('The database charset isn’t set in your db config file.');
     }
     if (StringHelper::isNullOrEmpty($databaseCollation)) {
         $messages[] = Craft::t('The database collation isn’t set in your db config file.');
     }
     if (!empty($messages)) {
         throw new DbConnectException(Craft::t('Database configuration errors: {errors}', array('errors' => implode(PHP_EOL, $messages))));
     }
     $this->_isDbConfigValid = true;
 }
 /**
  * Sets SMTP settings on a given email.
  *
  * @param $email
  * @param $emailSettings
  *
  * @throws Exception
  * @return null
  */
 private function _setSmtpSettings(&$email, $emailSettings)
 {
     $email->isSMTP();
     if (isset($emailSettings['smtpAuth']) && $emailSettings['smtpAuth'] == 1) {
         $email->SMTPAuth = true;
         if (!isset($emailSettings['username']) && StringHelper::isNullOrEmpty($emailSettings['username']) || !isset($emailSettings['password']) && StringHelper::isNullOrEmpty($emailSettings['password'])) {
             throw new Exception(Craft::t('Username and password are required.  Check your email settings.'));
         }
         $email->Username = $emailSettings['username'];
         $email->Password = $emailSettings['password'];
     }
     if (isset($emailSettings['smtpKeepAlive']) && $emailSettings['smtpKeepAlive'] == 1) {
         $email->SMTPKeepAlive = true;
     }
     $email->SMTPSecure = $emailSettings['smtpSecureTransportType'] != 'none' ? $emailSettings['smtpSecureTransportType'] : null;
     if (!isset($emailSettings['host'])) {
         throw new Exception(Craft::t('You must specify a host name in your email settings.'));
     }
     if (!isset($emailSettings['port'])) {
         throw new Exception(Craft::t('You must specify a port in your email settings.'));
     }
     if (!isset($emailSettings['timeout'])) {
         $emailSettings['timeout'] = $this->_defaultEmailTimeout;
     }
     $email->Host = $emailSettings['host'];
     $email->Port = $emailSettings['port'];
     $email->Timeout = $emailSettings['timeout'];
 }