本文整理汇总了PHP中TaskPermission::canSudo方法的典型用法代码示例。如果您正苦于以下问题:PHP TaskPermission::canSudo方法的具体用法?PHP TaskPermission::canSudo怎么用?PHP TaskPermission::canSudo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskPermission
的用法示例。
在下文中一共展示了TaskPermission::canSudo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sign_in_as_user
public function sign_in_as_user($uID, $token = null)
{
try {
$u = new User();
$tp = new TaskPermission();
if (!$tp->canSudo()) {
throw new Exception(t('You do not have permission to perform this action.'));
}
$ui = UserInfo::getByID($uID);
if (!$ui instanceof UserInfo) {
throw new Exception(t('Invalid user ID.'));
}
$valt = Loader::helper('validation/token');
if (!$valt->validate('sudo', $token)) {
throw new Exception($valt->getErrorMessage());
}
User::loginByUserID($uID);
$this->redirect('/');
} catch (Exception $e) {
$this->set('error', $e);
$this->view();
}
}
示例2: if
<? } ?>
<? if ($uo->getUserID() != USER_SUPER_ID && $tp->canActivateUser()) { ?>
<? if ($uo->isActive()) { ?>
<? print $ih->button(t('Deactivate User'), $this->url('/dashboard/users/search?uID=' . intval($uID) . '&task=deactivate&ccm_token='.$valt->generate('user_deactivate')), 'left');?>
<? } else { ?>
<? print $ih->button(t('Activate User'), $this->url('/dashboard/users/search?uID=' . intval($uID) . '&task=activate&ccm_token='.$valt->generate('user_activate')), 'left');?>
<? } ?>
<? } ?>
<? } ?>
<?
$tp = new TaskPermission();
if ($uo->getUserID() != $u->getUserID()) {
if ($tp->canSudo()) {
$loginAsUserConfirm = t('This will end your current session and sign you in as %s', $uo->getUserName());
print $ih->button_js(t('Sign In as User'), 'loginAsUser()', 'left');?>
<script type="text/javascript">
loginAsUser = function() {
if (confirm('<?=$loginAsUserConfirm?>')) {
location.href = "<?=$this->url('/dashboard/users/search', 'sign_in_as_user', $uo->getUserID(), $valt->generate('sudo'))?>";
}
}
</script>
<? } /*else { ?>
<? print $ih->button_js(t('Sign In as User'), 'alert(\'' . t('You do not have permission to sign in as other users.') . '\')', 'left', 'ccm-button-inactive');?>