本文整理汇总了PHP中UserAuth::setAllPermissions方法的典型用法代码示例。如果您正苦于以下问题:PHP UserAuth::setAllPermissions方法的具体用法?PHP UserAuth::setAllPermissions怎么用?PHP UserAuth::setAllPermissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserAuth
的用法示例。
在下文中一共展示了UserAuth::setAllPermissions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: checkEmailConfirmation
/**
* Check email confirmation code
*
* @return true;
*/
public function checkEmailConfirmation($h)
{
$user_id = $h->cage->get->getInt('id');
$conf = $h->cage->get->getAlnum('conf');
$user = new UserAuth();
$user->getUserBasic($h, $user_id);
if (!$user_id || !$conf) {
$h->messages[$h->lang['user_signin_register_emailconf_fail']] = 'red';
}
$sql = "SELECT user_email_conf FROM " . TABLE_USERS . " WHERE user_id = %d";
$user_email_conf = $h->db->get_var($h->db->prepare($sql, $user_id));
if ($conf === $user_email_conf) {
// update role:
$user->role = $h->vars['regStatus'];
$h->pluginHook('user_signin_email_conf_post_role');
// update user with new permissions:
$new_perms = $user->getDefaultPermissions($h, $user->role);
unset($new_perms['options']);
// don't need this for individual users
$user->setAllPermissions($new_perms);
$user->updatePermissions($h);
$user->updateUserBasic($h);
// set email valid to 1:
$sql = "UPDATE " . TABLE_USERS . " SET user_email_valid = %d WHERE user_id = %d";
$h->db->query($h->db->prepare($sql, 1, $user->id));
// notify chosen mods of new user by email:
if ($h->vars['useEmailNotify'] == 'checked' && file_exists(PLUGINS . 'users/libs/UserFunctions.php')) {
require_once PLUGINS . 'users/libs/UserFunctions.php';
$uf = new UserFunctions();
$uf->notifyMods($h, 'user', $user->role, $user->id);
}
$success_message = $h->lang['user_signin_register_emailconf_success'] . " <br /><b><a href='" . $h->url(array('page' => 'login')) . "'>" . $h->lang['user_signin_register_emailconf_success_login'] . "</a></b>";
$h->messages[$success_message] = 'green';
} else {
$h->messages[$h->lang['user_signin_register_emailconf_fail']] = 'red';
}
return true;
}