Esempio n. 1
0
 /**
  * Récupération de l'employé par identifiant (et mot de passe facultatif)
  *
  * @param $email
  * @param string $passwd Password is also checked if specified
  * @return User instance
  */
 public function getByEmail($email, $passwd = null)
 {
     if (!Validate::isEmail($email) || $passwd != null && !Validate::isPasswd($passwd)) {
         die(Tools::displayError());
     }
     $passwd = trim($passwd);
     $query = DbQuery::get()->select('*')->from('user')->where('login = "******"');
     if ($passwd) {
         $query->where('password = "******"');
     }
     $result = Db::getInstance()->getRow($query);
     if (!$result) {
         return false;
     }
     $this->id = $result['id_user'];
     foreach ($result as $key => $value) {
         if (property_exists($this, $key)) {
             $this->{$key} = $value;
         }
     }
     return $this;
 }