ecom
E-commerce cms
 All Data Structures Namespaces Files Functions Variables
Public Member Functions
Admin Class Reference
Inheritance diagram for Admin:
ModelBase

Public Member Functions

 install ()
 
 __construct ($id=null)
 
 checkPassword ($value)
 
 setPassword ($value)
 
 __set ($key, $value)
 
- Public Member Functions inherited from ModelBase
 __construct ($id=null)
 
 getTableName ()
 
 getMeta ($lang=null)
 
 __get ($key)
 
 __set ($key, $value)
 
 save ()
 
 delete ()
 
 selects ($criteria=null, $orderBy=null)
 
 selectById ($id)
 

Additional Inherited Members

- Static Public Member Functions inherited from ModelBase
static init ($config=null)
 
static getDbPrefix ()
 
static setup ()
 
- Protected Member Functions inherited from ModelBase
 install ()
 
- Static Protected Attributes inherited from ModelBase
static $dbo = null
 

Detailed Description

Definition at line 5 of file Admin.php.

Constructor & Destructor Documentation

__construct (   $id = null)

Definition at line 37 of file Admin.php.

38  {
39  $this->lastConnect = new \DateTime();
40  $this->lastConnectIp = \Tools\Context::getContext()->ip;
41  parent::__construct($id);
42  }
static getContext()
Definition: Context.php:164

Member Function Documentation

__set (   $key,
  $value 
)

Definition at line 54 of file Admin.php.

55  {
56  if ($key == "password")
57  return $this->setPassword($value);
58  return parent::__set($key, $value);
59  }
setPassword($value)
Definition: Admin.php:49
checkPassword (   $value)

Definition at line 44 of file Admin.php.

45  {
46  return password_verify($value, $this->password);
47  }
install ( )

Role -> 0 : no access -> 1 : read access -> 2 : +write access -> 3 : +delete /disable access

[0] -> admin (add user, change site configuration) [1] -> cms (add / modify / delete pages) [2] -> products [3] -> orders [4] -> translations

'*' Is the site admin, have all rights and no one can change this role

Definition at line 21 of file Admin.php.

22  {
23  $dbPrefix = $this->getDbPrefix();
24  $result = self::$dbo->exec("CREATE TABLE IF NOT EXISTS `{$dbPrefix}admin` (
25  `id` INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
26  `email` VARCHAR(128) NOT NULL UNIQUE,
27  `password` VARCHAR(64),
28  `role` VARCHAR(8) NOT NULL DEFAULT '00000',
29  `lastConnect` DATETIME NOT NULL,
30  `lastConnectIp` VARCHAR(42) NOT NULL
31  )");
32  if ($result === false)
33  throw new \Exception(get_class().": ".self::$dbo->errorInfo()[2]);
34  return true;
35  }
static getDbPrefix()
Definition: ModelBase.php:42
setPassword (   $value)

Definition at line 49 of file Admin.php.

50  {
51  parent::__set("password", password_hash($value, PASSWORD_BCRYPT));
52  }

The documentation for this class was generated from the following file: