All Data Structures Namespaces Files Functions Variables
Admin Class Reference
Inheritance diagram for Admin:

## 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.

{
$this->lastConnect = new \DateTime();
$this->lastConnectIp = \Tools\Context::getContext()->ip;
parent::__construct($id);
}
Entity\ModelBase\$id
$id
Definition: ModelBase.php:11
Tools\Context\getContext
static getContext()
Definition: Context.php:164

## Member Function Documentation

__set | ( |  | $key,
|  |  | $value
| ) |  |

Definition at line 54 of file Admin.php.

{
if ($key == "password")
return $this->setPassword($value);
return parent::__set($key, $value);
}
Entity\Admin\setPassword
setPassword($value)
Definition: Admin.php:49

checkPassword | ( |  | $value | ) |

Definition at line 44 of file Admin.php.

{
return password_verify($value, $this->password);
}

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.

{
$dbPrefix = $this->getDbPrefix();
$result = self::$dbo->exec("CREATE TABLE IF NOT EXISTS `{$dbPrefix}admin` (
`id` INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`email` VARCHAR(128) NOT NULL UNIQUE,
`password` VARCHAR(64),
`role` VARCHAR(8) NOT NULL DEFAULT '00000',
`lastConnect` DATETIME NOT NULL,
`lastConnectIp` VARCHAR(42) NOT NULL
)");
if ($result === false)
throw new \Exception(get_class().": ".self::$dbo->errorInfo()[2]);
return true;
}
Entity\ModelBase\getDbPrefix
static getDbPrefix()
Definition: ModelBase.php:42

setPassword | ( |  | $value | ) |

Definition at line 49 of file Admin.php.

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

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

- core/models/Admin.php