ecom
E-commerce cms
 All Data Structures Namespaces Files Functions Variables
Public Member Functions
User Class Reference
Inheritance diagram for User:
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 User.php.

Constructor & Destructor Documentation

__construct (   $id = null)

Definition at line 28 of file User.php.

29  {
30  $this->register = $this->lastVisit = $this->lastConnect = new \DateTime();
31  $this->registerIp = $this->lastVisitIp = $this->lastConnectIp = \Tools\Context::getContext()->ip;
32  parent::__construct($id);
33  }
static getContext()
Definition: Context.php:164

Member Function Documentation

__set (   $key,
  $value 
)

Definition at line 45 of file User.php.

46  {
47  if ($key == "password")
48  return $this->setPassword($value);
49  return parent::__set($key, $value);
50  }
setPassword($value)
Definition: User.php:40
checkPassword (   $value)

Definition at line 35 of file User.php.

36  {
37  return password_verify($value, $this->password);
38  }
install ( )

Definition at line 7 of file User.php.

8  {
9  $dbPrefix = $this->getDbPrefix();
10  $result = self::$dbo->exec("CREATE TABLE IF NOT EXISTS `{$dbPrefix}user` (
11  `id` INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
12  `email` VARCHAR(128) NOT NULL UNIQUE,
13  `password` VARCHAR(64),
14  `sexe` ENUM('MALE', 'FEMALE') NULL,
15  `optin` BOOLEAN DEFAULT FALSE,
16  `register` DATETIME NOT NULL,
17  `lastConnect` DATETIME NOT NULL,
18  `lastVisit` DATETIME NOT NULL,
19  `registerIp` VARCHAR(42) NOT NULL,
20  `lastConnectIp` VARCHAR(42) NOT NULL,
21  `lastVisitIp` VARCHAR(42) NOT NULL
22  )");
23  if ($result === false)
24  throw new \Exception(get_class().": ".self::$dbo->errorInfo()[2]);
25  return true;
26  }
static getDbPrefix()
Definition: ModelBase.php:42
setPassword (   $value)

Definition at line 40 of file User.php.

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

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