Example #1
0
 /**
  * @param string $key
  * @param string $code
  * @param array $details
  * @return $this
  */
 public function add($key, $code, $details = array())
 {
     $error = $this->errors[] = Lang::_getInstance()->getError($key, $code, $details);
     switch ($this->_('verbosity')) {
         case 'die':
             die($error);
         case 'echo':
             echo $error;
         default:
     }
     return $this;
 }
Example #2
0
 private function autoload()
 {
     foreach (Config::_getInstance()->getValue('helper', 'Loader') as $helper) {
         include_once HELPER_PATH . "{$helper}.php";
     }
     foreach (Config::_getInstance()->getValue('lang', 'Loader') as $lang) {
         Lang::_getInstance()->load($lang);
     }
     foreach (Config::_getInstance()->getValue('config', 'Loader') as $config) {
         Config::_getInstance()->load($config);
     }
 }
Example #3
0
 /**
  * @param string $content
  * @return $this
  */
 public function restorePassword($content = null)
 {
     $t = Token::_getInstance();
     if (!is_null($content)) {
         $t->_get(array('Content' => $content, 'Type' => 'restorePassword'))->_eq()->__($this->_('token', false));
         if ($this->countErrors() || is_null($this->_('token'))) {
             return $this->addError('password restoration', 0);
         }
         $this->_get($this->_('token')['UserID']);
         if (!input('json')) {
             return $this;
         }
         if ($this->_upsert(array('Email' => $this->_result['Email'], 'Password' => PasswordHash::_getInstance()->create_hash(input('password')), 'FirstName' => $this->_result['FirstName'], 'LastName' => $this->_result['LastName'], 'RoleID' => $this->_result['RoleID']))->countErrors()) {
             return $this;
         }
         $t->_drop();
         return $this->result(Lang::_getInstance()->getValue('passwordReset', 'User'));
     }
     if (!input('json')) {
         return $this->result(array());
     }
     $email = input('email');
     if ($this->_get(array('Email' => $email, 'Active' => true))->_eq()->countErrors() || empty($this->_result)) {
         return $this->addError('password restoration', 1);
     }
     $t->_upsert(array('Content' => $t->_generate(), 'Type' => 'restorePassword', 'UserID' => $this->_result['ID']))->__($this->_('token', false));
     Email::_getInstance()->send($email, 'restorePassword', array('token' => $this->_('token')['Content']));
     if ($this->countErrors()) {
         $t->_drop();
         return $this;
     }
     return $this->result(Lang::_getInstance()->getValue('passwordRestorationSent', 'User'));
 }
Example #4
0
 /**
  * @param array $data
  * @return $this
  */
 private function restorePassword($data = array())
 {
     $this->subject = Lang::_getInstance()->getValue('passwordRestorationSubject', 'User');
     $this->message = Lang::_getInstance()->getValue('passwordRestorationBody', 'User', array($data['token']));
     return $this;
 }
Example #5
0
 protected function __init()
 {
     Lang::_getInstance()->load($this->_('type', get_class($this)));
     return $this;
 }
Example #6
0
/**
 * @param string $key
 * @param string|array $type
 * @param array $args
 */
function lang($key, $type = null, $args = array())
{
    echo Lang::_getInstance()->getValue($key, $type, $args);
}