2015-10-29 00:47:40 +01:00
|
|
|
<?php
|
2015-11-01 22:43:35 +01:00
|
|
|
use RedBeanPHP\Facade as RedBean;
|
|
|
|
|
2015-11-03 01:55:59 +01:00
|
|
|
class User extends DataStore {
|
|
|
|
const TABLE = 'users';
|
2015-11-01 22:43:35 +01:00
|
|
|
const PROPERTIES = array(
|
|
|
|
'user',
|
|
|
|
'password',
|
|
|
|
'admin',
|
|
|
|
);
|
|
|
|
|
|
|
|
public static function getUser($value, $property = 'id') {
|
|
|
|
if ($property === 'id') {
|
|
|
|
$mapValue = 'id=:value';
|
|
|
|
}
|
|
|
|
else if ($property === 'user') {
|
|
|
|
$mapValue = 'user=:value';
|
|
|
|
}
|
|
|
|
|
|
|
|
$user = RedBean::findOne('users', $mapValue, array(':value' => $value));
|
|
|
|
|
|
|
|
return ($user) ? new User($user) : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function deleteUser($user) {
|
2015-11-03 01:55:59 +01:00
|
|
|
parent::deleteDataStore($user);
|
2015-11-01 22:43:35 +01:00
|
|
|
}
|
|
|
|
|
2015-11-03 01:55:59 +01:00
|
|
|
public function getDefaultProperties() {
|
|
|
|
return [
|
|
|
|
'admin' => 0
|
|
|
|
];
|
2015-10-29 00:47:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function showUserDetails() {
|
|
|
|
return $this->_user;
|
|
|
|
}
|
|
|
|
}
|