// Context part 31

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8087 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean
2011-08-17 10:07:12 +00:00
parent b8706ddd8a
commit cb3d802346
57 changed files with 200 additions and 165 deletions
+27
View File
@@ -68,6 +68,8 @@ class EmployeeCore extends ObjectModel
/** @var boolean show screencast */
public $show_screencast = 1;
public $remote_addr;
protected $fieldsRequired = array('lastname', 'firstname', 'email', 'passwd', 'id_profile', 'id_lang');
protected $fieldsSize = array('lastname' => 32, 'firstname' => 32, 'email' => 128, 'passwd' => 32, 'bo_color' => 32, 'bo_theme' => 32);
protected $fieldsValidate = array('lastname' => 'isName', 'firstname' => 'isName', 'email' => 'isEmail', 'id_lang' => 'isUnsignedInt',
@@ -209,4 +211,29 @@ class EmployeeCore extends ObjectModel
$this->passwd = Tools::encrypt($passwd);
return true;
}
/**
* Check employee informations saved into cookie and return employee validity
*
* @return boolean employee validity
*/
public function isLoggedBack()
{
/* Employee is valid only if it can be load and if cookie password is the same as database one */
return ($this->id
AND Validate::isUnsignedId($this->id)
AND Employee::checkPassword($this->id, $this->passwd)
AND (!isset($this->remote_addr) OR $this->remote_addr == ip2long(Tools::getRemoteAddr()) OR !Configuration::get('PS_COOKIE_CHECKIP'))
);
}
/**
* Logout
*/
public function logout()
{
if (isset(Context::getContext()->cookie))
Context::getContext()->cookie->logout();
$this->id = null;
}
}