本文整理汇总了PHP中Model_Users::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Users::getById方法的具体用法?PHP Model_Users::getById怎么用?PHP Model_Users::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Users
的用法示例。
在下文中一共展示了Model_Users::getById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: delete_index
public function delete_index($id_user)
{
if ($this->_currentUser->getId() === $id_user) {
$this->response->error('Vous ne pouvez pas vous supprimer vous-même !', 403);
return;
}
$user = Model_Users::getById($id_user);
if ($user) {
$user->remove();
}
$this->get_index();
}
示例3: _showAuthor
protected function _showAuthor($id_author)
{
$author = Model_Users::getById($id_author);
if (empty($author)) {
$this->response->error('L\'utilisateur demandé n\'existe pas ou plus.', 404);
return;
}
$canReadUnpublished = $this->_currentUser->hasPermission(Model_Groups::PERM_READ_UNPUBLISHED_ARTICLES);
if ($canReadUnpublished) {
$articles = $author->getArticles();
} else {
$articles = $author->getPublishedArticles();
}
if ($articles->count() === 0) {
$tpl_articles = Eliya\Tpl::get('authors/no_articles');
} else {
$tpl_articles = Eliya\Tpl::get('common/articles/list', ['articles' => $articles]);
}
$this->response->set(Eliya\Tpl::get('authors/details', ['author' => $author, 'tpl_articles' => $tpl_articles]));
}