本文整理匯總了PHP中UserModel::load方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserModel::load方法的具體用法?PHP UserModel::load怎麽用?PHP UserModel::load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserModel
的用法示例。
在下文中一共展示了UserModel::load方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: add
function add($user_id, $cause)
{
if (strlen(trim($cause))) {
$userModel = new UserModel();
$currentUser = Project::getUser()->getDbUser();
$userModel->load($user_id);
if ($userModel->id) {
$banHistoryModel = new BanHistoryModel();
$paramModel = new ParamModel();
$n_warnings_to_ban = $paramModel->getParam("UserController", "N_WARNINGS_TO_BAN");
$t_ban_time_sec = $paramModel->getParam("UserController", "T_BAN_TIME_SEC");
$count_user_warnings = $this->getUserWarningCount($user_id);
$this->clear();
$this->user_id = (int) $user_id;
$this->cause = $cause;
$warning_id = $this->save();
if ($userModel->warnings_fromlast_ban + 1 >= $n_warnings_to_ban) {
// пора банить
$subject = "Ваш аккаун заблокирован в системе Next24.ru";
$userModel->warnings_fromlast_ban = 0;
$userModel->banned = 1;
$userModel->banned_date = time();
$banHistoryModel->ban($user_id, $currentUser->id, $warning_id, date("Y-m-d H:i:s", time() + $t_ban_time_sec));
} else {
$userModel->warnings_fromlast_ban = $userModel->warnings_fromlast_ban + 1;
$subject = "Администратор Next24.ru установил Вам предупреждение";
}
$userModel->save();
$url_referer = $_SERVER['HTTP_REFERER'];
$this->sendMessage((int) $user_id, $subject, $cause, $url_referer);
return $warning_id;
}
}
return 0;
}
示例2: setupMember
/**
* Sets up the instance for a registered member.
*/
public function setupMember()
{
$userId = $this->_session->userId;
//$this->data = $this->_model->getUserInfo($userId);
$this->_model->load($userId);
$this->data['user_logouthash'] = sha1($this->id . sha1($this->salt) . sha1($this->name) . sha1(RPG::config('cookieSalt')));
}
示例3: SaveAction
function SaveAction()
{
$request = Project::getRequest();
$user_id = (int) Project::getUser()->getDbUser()->id;
$model = new UserModel();
$model->load($request->id);
$do_save = true;
$this->_view->clearFlashMessages();
if (!strlen(trim($request->login))) {
$this->_view->addFlashMessage(FM::ERROR, "Не заполнено поле логин");
$do_save = false;
}
if ($request->unbann) {
$ban_model = new BanHistoryModel();
$ban_model->unban($request->id, $user_id);
}
if ($request->bann) {
if (strlen($request->warning)) {
$ban_date = $request->ban_date;
if (strlen($ban_date) && strtotime($ban_date) > time()) {
$warning_model = new WarningModel();
$warning_id = $warning_model->add($request->id, $request->warning);
$ban_model = new BanHistoryModel();
$ban_model->ban($request->id, $user_id, $warning_id, $request->ban_date);
} else {
$this->_view->addFlashMessage(FM::ERROR, "Неверная дата бана");
$do_save = false;
}
} else {
$this->_view->addFlashMessage(FM::ERROR, "Не заполнено предупреждение");
$do_save = false;
}
}
if ($do_save) {
$this->_view->clearFlashMessages();
$model->login = $request->login;
$model->user_type_id = $request->user_group;
if ($request->bann) {
$model->banned = 1;
$model->banned_date = strtotime($request->ban_date);
} else {
$model->banned = 0;
}
$ban_date = $request->ban_date;
if (strlen($ban_date)) {
//$ban_model = new Ban
}
$id = $model->save();
$model = new UserTypeModel();
$info = array();
$info['group_list'] = $model->loadAll();
$info['edit_controller'] = null;
$info['edit_action'] = 'Edit';
$this->makeUserList($info);
$this->_view->AjaxList($info);
}
$this->_view->ajax();
}
示例4: getLoggedInUser
/**
* If there is valid user logged in it returns a loaded instance of it
* @return UserModel If there is a valid logged in user, false otherwise
*/
public static function getLoggedInUser()
{
if (!isset($_SESSION['user_id'])) {
return false;
}
$user_id = (int) $_SESSION['user_id'];
if (!self::$__logged_user instanceof self) {
self::$__logged_user = new self($user_id);
}
if (!self::$__logged_user->isLoaded()) {
if (!self::$__logged_user->load()) {
unset($_SESSION['user_id']);
unset(self::$__logged_user);
return false;
}
}
return self::$__logged_user;
}
示例5: getUserByName
/**
* @param string $name
* @return UserModel
*/
public static function getUserByName($name)
{
$DbConnection = DbConnection::getInstance();
$Config = Config::getInstance();
$sql = "SELECT {$Config->user_table_id} FROM {$Config->user_table} WHERE name='{$name}' LIMIT 1";
if (!($user_id = $DbConnection->getOneValue($sql))) {
return false;
}
$User = new UserModel($Config->user_table, (int) $user_id);
$User->load();
return $User;
}
示例6: sendMessage
function sendMessage($form, $to, $subject, $body, $avatar = false, $allow_html = true)
{
if ($allow_html) {
$this->header = $subject;
$this->m_text = $body;
} else {
$this->header = stripslashes(htmlspecialchars($subject));
$this->m_text = stripslashes(htmlspecialchars($body));
}
$this->send_date = date("Y-m-d H:i:s");
$this->author_id = $form;
$this->recipient_id = $to;
if (!$avatar) {
$user = new UserModel();
$user->load($from);
$this->avatar_id = $user->getUserAvatar($user->id);
$this->avatar_id = $this->avatar_id['id'];
} else {
$this->avatar_id = $avatar;
}
$this->is_read = 0;
$this->is_deleted = 0;
$messageId = $this->save();
return $messageId;
}
示例7: reset
public function reset($key)
{
if (isset($key)) {
$user = UserModel::load()->get(array(array('Reset_token', '=', $key)));
if ($user) {
if ($user[0]->Status_ID == 0) {
UserModel::load()->update(array('Status_ID' => 1), $user[0]->ID);
Session::set('SUCCESS', 'User activated!');
Redirect::to($this->url);
} elseif ($user[0]->Status_ID == 1) {
Session::set('WARNING', 'User already activated!');
Redirect::to($this->url);
} elseif ($user[0]->Status_ID == 2) {
Session::set('ERRORS', 'User blocked!');
Redirect::to($this->url);
}
}
Session::set('ERRORS', 'User key invalid!');
Redirect::to($this->url);
}
}
示例8: validateAction
public function validateAction()
{
$Request = Request::getInstance();
$user_id = $Request->user_id;
$given_code = rawurldecode($Request->code);
$User = new UserModel((int) $user_id);
$User->load();
if (!$User->validateCode($given_code)) {
$this->gotoPage('/user', 'The validation code is invalid!');
}
$User->role = 'registered';
$User->save();
$this->gotoPage("/user", "Congratulations, now you are fully registered!<br/>please login");
}
示例9: testRowsCanBeRemoved2
public function testRowsCanBeRemoved2()
{
UserModel::insert('dave', array('email' => 'dave@gmail.com', 'name' => 'Dave', 'age' => 33));
$dave = UserModel::load('dave');
$this->assertEquals($dave->email, 'dave@gmail.com');
$this->assertEquals($dave->name, 'Dave');
$this->assertEquals($dave->age, 33);
$dave->delete();
$dave2 = UserModel::load('dave');
$this->assertNull($dave2);
}