本文整理匯總了PHP中UserAuth::getUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserAuth::getUser方法的具體用法?PHP UserAuth::getUser怎麽用?PHP UserAuth::getUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserAuth
的用法示例。
在下文中一共展示了UserAuth::getUser方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: bulkRoleChange
/**
* Bulk User Role Change
*
* @param string $from name of role to move from
* @param string $to name of role to move to
* @return bool
*/
public function bulkRoleChange($h, $from = '', $to = '')
{
if (!$from || !$to) {
return false;
}
// check $from and $to exist
$unique_roles = $this->getUniqueRoles($h);
if (!in_array($from, $unique_roles)) {
return false;
}
if (!in_array($to, $unique_roles)) {
return false;
}
$sql = "SELECT user_id FROM " . TABLE_USERS . " WHERE user_role = %s";
$items = $h->db->get_results($h->db->prepare($sql, $from));
if ($items) {
// Change role and permissions for each user being moved
foreach ($items as $item) {
$user = new UserAuth();
$user->getUser($h, $item->user_id);
$user->role = $to;
$new_perms = $user->getDefaultPermissions($h, $user->role);
$user->setAllPermissions($new_perms);
$user->updateUserBasic($h);
}
}
return true;
}