本文整理汇总了PHP中UserStatus::isMasquerading方法的典型用法代码示例。如果您正苦于以下问题:PHP UserStatus::isMasquerading方法的具体用法?PHP UserStatus::isMasquerading怎么用?PHP UserStatus::isMasquerading使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserStatus
的用法示例。
在下文中一共展示了UserStatus::isMasquerading方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(CommandContext $context)
{
if (!Current_User::allow('hms', 'login_as_student')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to login as a student.');
}
if (!UserStatus::isMasquerading()) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You are not currently masquerading as another user.');
}
$user = UserStatus::getUsername();
UserStatus::removeMask();
$cmd = CommandFactory::getCommand('ShowStudentProfile');
$cmd->setUsername($user);
$cmd->redirect();
}
示例2: addUserStatus
private function addUserStatus()
{
// If the user is not logged in, then we have nothing to do here
if (\UserStatus::isGuest()) {
return;
}
$userTpl = array();
$userTpl['FULL_NAME'] = \UserStatus::getDisplayName();
$useDropdown = false;
if (\UserStatus::isMasquerading() && \UserStatus::isMasqueradingAsSelf()) {
// User is masquerading as student version of self
$useDropdown = true;
$userTpl['FULL_NAME'] = \UserStatus::getDisplayName() . ' (student)';
$cmd = \CommandFactory::getCommand('RemoveMaskAsSelf');
$userTpl['STUDENT_SELF_RETURN'] = $cmd->getURI();
// Link to return to admin version of self
} else {
if (\UserStatus::isMasquerading()) {
// User is masquerading as a student
$useDropdown = true;
$cmd = \CommandFactory::getCommand('RemoveMask');
$userTpl['REMOVE_MASK'] = $cmd->getURI();
$userTpl['FULL_NAME'] = '<strong class="text-danger">' . \UserStatus::getDisplayName() . '</strong>';
} else {
if (\Current_User::allow('hms', 'ra_login_as_self')) {
// User is not masquerading, but do have permission to change to student self-view
$useDropdown = true;
$studentViewCmd = \CommandFactory::getCommand('RaMasqueradeAsSelf');
$userTpl['STUDENT_VIEW_URI'] = $studentViewCmd->getURI();
}
}
}
if ($useDropdown) {
// Other options available, so we'll render a drop down
$this->tpl['USER_STATUS_DROPDOWN'] = \PHPWS_Template::process($userTpl, 'hms', 'UserStatus.tpl');
} else {
// No other options, so the user status is just the display name
$this->tpl['DISPLAY_NAME'] = \UserStatus::getDisplayName();
}
}
示例3: log_activity
/**
* Takes a username whos log the record should go in, the activity, the actor, and the notes
* and creates a new Activity_Log object and saves it to the db.
*/
public static function log_activity($userid, $activity, $actor, $notes = NULL)
{
if (UserStatus::isMasquerading()) {
$notes .= " Admin: " . UserStatus::getUsername(FALSE);
// get the *real* username
}
$activity_log = new HMS_Activity_Log(NULL, $userid, time(), $activity, $actor, $notes);
$activity_log->save();
}