本文整理汇总了PHP中Model_Users::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Users::update方法的具体用法?PHP Model_Users::update怎么用?PHP Model_Users::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Users
的用法示例。
在下文中一共展示了Model_Users::update方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: put_index
public function put_index($id, $username, $email, $password = null, $id_group = null)
{
// Force to edit the current user if they don't have the proper permissions
if (!$this->_currentUser->hasPermission(Model_Groups::PERM_MANAGE_USERS)) {
$id = $this->_currentUser->getId();
}
$user = Model_Users::getById($id);
$propsUpdate = ['username' => $username, 'email' => $email];
if ($id_group !== null && !empty($id_group) && $this->_currentUser->hasPermission(Model_Groups::PERM_MANAGE_USERS)) {
$group = Model_Groups::getById($id_group);
$propsUpdate['usergroup'] = $group;
} else {
$user->load('usergroup');
}
if ($password !== null && !empty($password)) {
$propsUpdate['password'] = Library_String::hash(trim($password));
}
$user->setProps($propsUpdate);
Model_Users::update($user);
// Disconnect the user if they changed their own profile
if ($id === $this->_currentUser->getId()) {
$this->response->redirect('../login/out', 200);
} else {
$this->response->redirect('../users', 200);
}
}
示例2: indexAction
public function indexAction()
{
$form = self::getMyaccountSettingsForm();
$populateData = array();
$modelUsers = new Model_Users();
$populateData['calendarView'] = $this->user['calendarView'];
$populateData['notifications'] = $this->user['notifications'];
$form->populate($populateData);
$request = $this->getRequest();
if ($this->_getParam('method')) {
$what = null;
if ($this->_getParam('calendarview')) {
$what = 'Calendar view';
$data['calendarView'] = $this->_getParam('value');
$modelUsers->update($this->user->getId(), $data);
} elseif ($this->_getParam('notifications')) {
$what = 'Notifications';
$data['notifications'] = $this->_getParam('value');
$modelUsers->update($this->user->getId(), $data);
} elseif ($this->_getParam('password')) {
$what = 'Password';
$form->changePassword();
$request = $this->getRequest();
if ($request->isPost()) {
$post = $request->getPost();
if ($form->isValid($post)) {
$values = $form->getValues();
} else {
echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'icon' => 'error', 'message' => $this->t->_($what . ' was not updated')));
exit;
}
}
$data['password'] = $values['password'];
$modelUsers->update($this->user->getId(), $data);
}
echo Zend_Json::encode(array('success' => 1, 'title' => $this->t->_('Success Message'), 'message' => $this->t->_($what . ' was successfully updated')));
exit;
}
$this->view->formSettings = $form;
}
示例3: loginAction
public function loginAction()
{
if (vkNgine_Auth::isAuthenticated()) {
header("location:/");
exit;
}
$logger = Zend_Registry::get('logger');
$form = $this->getLoginForm();
$request = $this->getRequest();
$this->view->error = false;
if ($request->isPost()) {
if ($form->isValid($request->getPost())) {
$info = $form->getValues();
$user = null;
if (vkNgine_Public_Auth::attemptLogin($info)) {
$user = vkNgine_Auth::revalidate();
} else {
$this->view->error = true;
}
$user = vkNgine_Auth::revalidate();
$logger->log('LOGIN_REQUEST', print_r($info, true), vkNgine_Log::INFO, $user['userId']);
if ($user != null) {
$modelUsers = new Model_Users();
$modelTrafficActivity = new vkNgine_Log_Activity();
$modelTrafficLogins = new vkNgine_Log_Logins();
$modelTrafficActivity->processActivity($user, $request, 'Logged in to Site');
$modelTrafficLogins->insertTrafficLogin($user->userId, $user->type);
$config = vkNgine_Config::getSystemConfig();
Zend_Session::rememberMe($config->settings->login->remember);
$modelUsers->update($user['userId'], array('lastLogin' => date('Y-m-d H:i:s')));
echo Zend_Json::encode(array('success' => 1, 'icon' => 'success', 'href' => '/'));
exit;
} else {
echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Access denied!'), 'icon' => 'error'));
exit;
}
} else {
echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Access denied!'), 'icon' => 'error'));
exit;
}
}
$this->view->form = $form;
}
示例4: update
/**
* update an admin user
*
* @param int $userId
* @param array $data
*/
public function update($userId, $data)
{
if (!empty($data['level'])) {
$modelUsersAdmins = new Admin_Model_Users_Admins();
$modelUsersAdmins->update($userId, array('level' => $data['level']));
unset($data['level']);
}
return parent::update($userId, $data);
}
示例5: resetpasswordAction
public function resetpasswordAction()
{
if (vkNgine_Auth::isAuthenticated()) {
$this->_redirect('/admin');
exit;
}
$modelUsers = new Model_Users();
$modelUsersTokens = new Model_Users_Tokens();
$token = $this->_getParam('token');
if (!$token) {
$this->_redirect('/admin/auth/login');
}
$form = self::getResetPasswordForm();
$request = $this->getRequest();
if ($request->isPost()) {
$post = $request->getPost();
if ($form->isValid($post)) {
$values = $form->getValues();
$user = $modelUsers->fetchWithEmail($values['email']);
$token = $modelUsersTokens->fetch($user, $values['token']);
if ($token) {
$data = array('password' => $values['password']);
$modelUsers->update($user->getId(), $data);
$modelUsersTokens->delete($token['tokenId']);
echo Zend_Json::encode(array('success' => 1, 'title' => $this->t->_('Success Message'), 'message' => $this->t->_('Password was changed successfully'), 'icon' => 'success', 'href' => '/admin/auth/login'));
exit;
} else {
echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Given token was not valid'), 'icon' => 'error'));
exit;
}
} else {
echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Given token/email or password was not valid'), 'icon' => 'error'));
exit;
}
}
$this->view->form = $form->setTokenValue($token);
}
示例6: update
/**
* update a user
*
* @params int $userId
* @params array $data
*/
public function update($userId, $data)
{
// reset the admin's level
if (!empty($data['level'])) {
$modelUsersPublics = new Model_Users_Publics();
$modelUsersPublics->update($userId, array('level' => $data['level']));
unset($data['level']);
}
return parent::update($userId, $data);
}