本文整理汇总了PHP中UserStatus::isAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP UserStatus::isAdmin方法的具体用法?PHP UserStatus::isAdmin怎么用?PHP UserStatus::isAdmin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserStatus
的用法示例。
在下文中一共展示了UserStatus::isAdmin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'bed_structure')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to remove a bed.');
}
PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
$viewCmd = CommandFactory::getCommand('EditRoomView');
$viewCmd->setRoomId($context->get('roomId'));
$bedId = $context->get('bedId');
$roomId = $context->get('roomId');
if (!isset($roomId)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'Missing room ID.');
$viewCmd->redirect();
}
if (!isset($bedId)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'Missing bed ID.');
$viewCmd->redirect();
}
# Try to delete the bed
try {
HMS_Bed::deleteBed($bedId);
} catch (Exception $e) {
NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error deleting the bed: ' . $e->getMessage());
$viewCmd->redirect();
}
NQ::simple('hms', hms\NotificationView::SUCCESS, 'Bed successfully deleted.');
$viewCmd->redirect();
}
示例2: __construct
public function __construct()
{
parent::__construct();
// Check permissions
if (UserStatus::isAdmin()) {
if (Current_User::allow('hms', 'learning_community_maintenance')) {
$this->addCommandByName('Add/Edit Communities', 'ShowEditRlc');
}
if (Current_User::allow('hms', 'view_rlc_applications')) {
$this->addCommandByName('Assign Applicants to RLCs', 'ShowAssignRlcApplicants');
$this->addCommandByName('View Denied Applications', 'ShowDeniedRlcApplicants');
}
if (Current_User::allow('hms', 'learning_community_maintenance')) {
$this->addCommandByName('Send RLC Email Invites', 'ShowSendRlcInvites');
}
if (Current_User::allow('hms', 'view_rlc_members')) {
$this->addCommandByName('View RLC Members by RLC', 'ShowSearchByRlc');
$this->addCommandByName('View RLC Assignments', 'ViewRlcAssignments');
}
if (Current_User::allow('hms', 'email_rlc_rejections')) {
// Using JSConfirm, ask user if the _really_ want to send the emails
$onConfirmCmd = CommandFactory::getCommand('SendRlcRejectionEmails');
$cmd = CommandFactory::getCommand('JSConfirm');
$cmd->setLink('Send RLC Rejection Emails');
$cmd->setTitle('Send RLC Rejection Emails');
$cmd->setQuestion('Send notification emails to denied RLC applicants for selected term?');
$cmd->setOnConfirmCommand($onConfirmCmd);
$this->addCommand('Send RLC Rejection Emails', $cmd);
}
}
}
示例3: __construct
public function __construct()
{
parent::__construct();
// Check permissions
if (UserStatus::isAdmin()) {
if (Current_User::allow('hms', 'hall_view')) {
$residenceHallCmd = CommandFactory::getCommand('SelectResidenceHall');
$residenceHallCmd->setTitle('Edit a Residence Hall');
$residenceHallCmd->setOnSelectCmd(CommandFactory::getCommand('EditResidenceHallView'));
$this->addCommand('Edit a residence hall', $residenceHallCmd);
}
if (Current_User::allow('hms', 'floor_view')) {
$floorCmd = CommandFactory::getCommand('SelectFloor');
$floorCmd->setTitle('Edit a Floor');
$floorCmd->setOnSelectCmd(CommandFactory::getCommand('EditFloorView'));
$this->addCommand('Edit a floor', $floorCmd);
}
if (Current_User::allow('hms', 'room_view')) {
$roomCmd = CommandFactory::getCommand('SelectRoom');
$roomCmd->setTitle('Edit a Room');
$roomCmd->setOnSelectCmd(CommandFactory::getCommand('EditRoomView'));
$this->addCommand('Edit a room', $roomCmd);
}
if (Current_User::allow('hms', 'bed_view')) {
$bedCmd = CommandFactory::getCommand('SelectBed');
$bedCmd->setTitle('Edit a Bed');
$bedCmd->setOnSelectCmd(CommandFactory::getCommand('EditBedView'));
$this->addCommand('Edit a bed', $bedCmd);
}
}
}
示例4: getHMS
public static function getHMS()
{
$rh = getallheaders();
if (isset(HMSFactory::$hms)) {
return HMSFactory::$hms;
} else {
if (isset($_REQUEST['ajax']) || !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' || isset($_REQUEST['callback']) || array_key_exists('Accept', $rh) && stripos($rh['Accept'], 'application/json') !== FALSE) {
PHPWS_Core::initModClass('hms', 'AjaxHMS.php');
HMSFactory::$hms = new AjaxHMS();
} else {
if (UserStatus::isAdmin()) {
PHPWS_Core::initModClass('hms', 'AdminHMS.php');
HMSFactory::$hms = new AdminHMS();
} else {
if (UserStatus::isUser()) {
PHPWS_Core::initModClass('hms', 'UserHMS.php');
HMSFactory::$hms = new UserHMS();
} else {
// Guest
PHPWS_Core::initModClass('hms', 'GuestHMS.php');
HMSFactory::$hms = new GuestHMS();
}
}
}
}
return HMSFactory::$hms;
}
示例5: execute
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'search')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to lookup student names!');
}
$student = null;
$error = new JsonError(403);
$username = $context->get('username');
$banner_id = (int) $context->get('banner_id');
try {
if ($banner_id) {
$student = StudentFactory::getStudentByBannerID($banner_id, Term::getSelectedTerm());
} elseif (!empty($username)) {
$student = StudentFactory::getStudentByUsername($username, Term::getSelectedTerm());
} else {
$error->setMessage('Did not receive Banner ID or user name.');
$context->setContent(json_encode($error));
}
$student->gender_string = HMS_Util::formatGender($student->gender);
$context->setContent(json_encode($student));
} catch (\StudentNotFoundException $e) {
$error->setMessage($e->getMessage());
$context->setContent(json_encode($error));
}
}
示例6: execute
function execute(CommandContext $context)
{
if (!\UserStatus::isAdmin()) {
header('Location: ./?action=ShowGuestHome');
}
$image_url = "https://placeholdit.imgix.net/~text?txtsize=33&txt=250%C3%97150&w=250&h=150";
if ($_FILES['event_image']['size'] > 0 and $_FILES['event_image']['size'] < 2097152) {
$tempFile = $_FILES['event_image']['tmp_name'];
$targetPath = PHPWS_SOURCE_DIR . "mod/events/images/";
$targetFile = $targetPath . $_FILES['event_image']['name'];
$image_url = "mod/events/images/" . $_FILES['event_image']['name'];
move_uploaded_file($tempFile, $targetFile);
}
var_dump($_POST);
var_dump($context);
exit;
$event_name = $context->get('event_name');
$event_location = $context->get('event_location');
$event_date = strtotime($context->get('event_date')) + 86399;
$ticket_prices = $context->get('ticket_prices');
$ticket_location = $context->get('ticket_location');
$open_time = $context->get('open_time');
$start_time = $context->get('start_time');
$event_restrictions = $context->get('event_restrictions');
$artist_details = $context->get('event_details');
$db = \Database::getDB();
$pdo = $db->getPDO();
$query = "INSERT INTO events_events (id, eventname, eventlocation, eventdate, ticketprices, ticketlocation, opentime, starttime, eventrestrictions, artistdetails, imageurl)\n\t\t\t\t\tVALUES (nextval('events_seq'), :event_name, :event_location, :event_date, :ticket_prices, :ticket_location, :open_time, :start_time, :event_restrictions, :artist_details, :image_url)";
$sth = $pdo->prepare($query);
$sth->execute(array('event_name' => $event_name, 'event_location' => $event_location, 'event_date' => $event_date, 'ticket_prices' => $ticket_prices, 'ticket_location' => $ticket_location, 'open_time' => $open_time, 'start_time' => $start_time, 'event_restrictions' => $event_restrictions, 'artist_details' => $artist_details, 'image_url' => $image_url));
header('Location: ./?action=ShowAdminHome');
}
示例7: execute
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'floor_view')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to edit floors.');
}
// Check for a hall ID
$floorId = $context->get('floor');
if (!isset($floorId)) {
throw new InvalidArgumentException('Missing floor ID.');
}
PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
PHPWS_Core::initModClass('hms', 'HMS_Floor.php');
PHPWS_Core::initModClass('hms', 'FloorView.php');
$floor = new HMS_Floor($floorId);
if ($floor->term != Term::getSelectedTerm()) {
$floorCmd = CommandFactory::getCommand('SelectFloor');
$floorCmd->setTitle('Edit a Floor');
$floorCmd->setOnSelectCmd(CommandFactory::getCommand('EditFloorView'));
$floorCmd->redirect();
}
$hall = $floor->get_parent();
$floorView = new FloorView($hall, $floor);
$context->setContent($floorView->show());
}
示例8: execute
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'assign_by_floor')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to assign students by floor.');
}
$username = $context->get('username');
$banner_id = (int) $context->get('banner_id');
$reason = $context->get('reason');
$meal_plan = $context->get('meal_plan');
$bed_id = $context->get('bed_id');
$term = Term::getSelectedTerm();
try {
if ($banner_id) {
$student = StudentFactory::getStudentByBannerID($banner_id, Term::getSelectedTerm());
} elseif (!empty($username)) {
$student = StudentFactory::getStudentByUsername($username, Term::getSelectedTerm());
} else {
$context->setContent(json_encode(array('status' => 'failure', 'message' => 'Did not receive Banner ID or user name.')));
return;
}
try {
HMS_Assignment::assignStudent($student, $term, null, $bed_id, $meal_plan, null, null, $reason);
} catch (AssignmentException $e) {
$context->setContent(json_encode(array('status' => 'failure', 'message' => $e->getMessage())));
return;
}
$message = $student->first_name . ' ' . $student->last_name;
$context->setContent(json_encode(array('status' => 'success', 'message' => $message, 'student' => $student)));
} catch (\StudentNotFoundException $e) {
$context->setContent(json_encode(array('status' => 'failure', 'message' => $e->getMessage())));
}
}
示例9: execute
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'roommate_maintenance')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to create/edit roommate groups.');
}
PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
$id = $context->get('id');
if (is_null($id)) {
throw new InvalidArgumentException('Missing roommate group id.');
}
$viewCmd = CommandFactory::getCommand('EditRoommateGroupsView');
try {
$roommate = new HMS_Roommate($id);
$roommate->delete();
} catch (Exception $e) {
NQ::simple('hms', hms\NotificationView::SUCCESS, 'Error deleting roommate group: ' . $e->getMessage());
$viewCmd->redirect();
}
// Log the success
$notes = "{$roommate->getRequestor()} requested {$roommate->getRequestee()}";
HMS_Activity_Log::log_activity($roommate->getRequestor(), ACTIVITY_ADMIN_REMOVED_ROOMMATE, UserStatus::getUsername(), $notes);
HMS_Activity_Log::log_activity($roommate->getRequestee(), ACTIVITY_ADMIN_REMOVED_ROOMMATE, UserStatus::getUsername(), $notes);
NQ::simple('hms', hms\NotificationView::SUCCESS, 'Roommate group successfully deleted.');
$viewCmd->redirect();
}
示例10: getStudentById
public function getStudentById($id, $term)
{
// Sanity checking on the Banner ID
$id = trim($id);
if (!isset($id) || empty($id) || $id == '') {
throw new InvalidArgumentException('Missing Banner id. Please enter a valid Banner ID (nine digits).');
}
if (strlen($id) > 9 || strlen($id) < 9 || !preg_match("/^[0-9]{9}\$/", $id)) {
throw new InvalidArgumentException('That was not a valid Banner ID. Please enter a valid Banner ID (nine digits).');
}
$student = new Student();
$soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER);
$soapData = $soap->getStudentProfile($id, $term);
if ($soapData->error_num == 1101 && $soapData->error_desc == 'LookupStudentID') {
PHPWS_Core::initModClass('hms', 'exception/StudentNotFoundException.php');
throw new StudentNotFoundException('No matching student found.');
} elseif (isset($soapData->error_num) && $soapData->error_num > 0) {
//test($soapData,1);
throw new SOAPException("Error while accessing SOAP interface: {$soapData->error_desc} ({$soapData->error_num})", $soapData->error_num, 'getStudentProfile', array($id, $term));
}
SOAPDataProvider::plugSOAPData($student, $soapData);
//SOAPDataProvider::applyExceptions($student);
require_once PHPWS_SOURCE_DIR . SOAP_DATA_OVERRIDE_PATH;
$dataOverride = new SOAPDataOverride();
$dataOverride->applyExceptions($student);
$student->setDataSource(get_class($this));
return $student;
}
示例11: execute
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'view_activity_log')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to view the activity log.');
}
PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
PHPWS_Core::initModClass('hms', 'ActivityLogView.php');
$actee = $context->get('actee');
$actor = $context->get('actor');
$notes = $context->get('notes');
$exact = $context->get('exact');
$begin = $context->get('begin');
$end = $context->get('end');
if (!is_null($begin) && !is_null($end) && $end <= $begin) {
unset($_REQUEST['begin_year'], $_REQUEST['begin_month'], $_REQUEST['begin_day'], $_REQUEST['end_year'], $_REQUEST['end_month'], $_REQUEST['end_day']);
$begin = null;
$end = null;
NQ::simple('hms', hms\NotificationView::WARNING, 'Invalid date range. The search results will not be filtered by date.');
}
$activityMap = HMS_Activity_Log::getActivityMapping();
$activities = array();
foreach ($activityMap as $i => $t) {
$act = $context->get("a{$i}");
if (!is_null($act)) {
$activities[] = $i;
}
}
$activityLogView = new ActivityLogView($actee, $actor, $notes, $exact, $begin, $end, $activities);
$context->setContent($activityLogView->show());
}
示例12: show
public function show()
{
PHPWS_Core::initModClass('hms', 'HMS_Learning_Community.php');
PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
Layout::addPageTitle("RLC Application Review");
$tags = array();
if (UserStatus::isAdmin()) {
$menuCmd = CommandFactory::getCommand('ShowAssignRlcApplicants');
$tags['MENU_LINK'] = $menuCmd->getURI();
} else {
$menuCmd = CommandFactory::getCommand('ShowStudentMenu');
$tags['MENU_LINK'] = $menuCmd->getURI();
}
$tags['FULL_NAME'] = $this->student->getFullName();
$tags['STUDENT_TYPE'] = $this->student->getPrintableType();
$tags['TERM'] = Term::toString($this->application->getTerm());
$appType = $this->application->getApplicationType();
if ($appType == RLC_APP_FRESHMEN) {
$tags['APPLICATION_TYPE'] = 'Freshmen';
} else {
if ($appType == RLC_APP_RETURNING) {
$tags['APPLICATION_TYPE'] = 'Re-application';
}
}
$rlcs = HMS_Learning_Community::getRlcList();
$tags['FIRST_CHOICE'] = $rlcs[$this->application->rlc_first_choice_id];
if (isset($this->application->rlc_second_choice_id)) {
$tags['SECOND_CHOICE'] = $rlcs[$this->application->rlc_second_choice_id];
}
if (isset($this->application->rlc_third_choice_id)) {
$tags['THIRD_CHOICE'] = $rlcs[$this->application->rlc_third_choice_id];
}
$tags['WHY_SPECIFIC'] = $this->application->why_specific_communities;
$tags['STRENGTHS_AND_WEAKNESSES'] = $this->application->strengths_weaknesses;
$tags['WHY_FIRST_CHOICE'] = $this->application->rlc_question_0;
if (isset($this->application->rlc_second_choice_id)) {
$tags['WHY_SECOND_CHOICE'] = $this->application->rlc_question_1;
}
if (isset($this->application->rlc_second_choice_id)) {
$tags['WHY_THIRD_CHOICE'] = $this->application->rlc_question_2;
}
// If this application is denied and the person logged in is an admin, show a warning
if ($this->application->isDenied() && UserStatus::isAdmin()) {
NQ::simple('hms', hms\NotificationView::WARNING, 'This application has been denied.');
}
// Show options depending of status of application.
if (UserStatus::isAdmin() && Current_User::allow('hms', 'approve_rlc_applications')) {
if (!$this->application->denied && !HMS_RLC_Assignment::checkForAssignment($this->student->getUsername(), Term::getSelectedTerm())) {
// Approve application for the community selected from dropdown
$approvalForm = $this->getApprovalForm();
$approvalForm->mergeTemplate($tags);
$tags = $approvalForm->getTemplate();
// Deny application
$tags['DENY_APP'] = $this->getDenialLink();
}
}
return PHPWS_Template::process($tags, 'hms', 'student/rlc_application.tpl');
}
示例13: execute
/**
* @see Command::execute()
*/
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'hall_attributes')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to edit halls.');
}
// Make sure a hall ID was set
$hallId = $context->get('hallId');
if (is_null($hallId)) {
throw new InvalidArgumentException('Missing hall ID.');
}
$viewCmd = CommandFactory::getCommand('EditResidenceHallView');
$viewCmd->setHallId($hallId);
PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
// Create the hall object given the hall id
$hall = new HMS_Residence_Hall($hallId);
if (!$hall) {
NQ::simple('hms', hms\NotificationView::ERROR, 'Invalid hall.');
$viewCmd->redirect();
}
if ($context->get('tab') == 'settings') {
// Compare the hall's gender and the gender the user selected
// If they're not equal, call 'can_change_gender' public function
if ($hall->gender_type != $_REQUEST['gender_type']) {
if (!$hall->can_change_gender($_REQUEST['gender_type'])) {
NQ::simple('hms', hms\NotificationView::ERROR, 'Incompatible gender detected. No changes were made.');
$viewCmd->redirect();
}
}
// Grab all the input from the form and save the hall
$hall->hall_name = $context->get('hall_name');
$hall->gender_type = $context->get('gender_type');
// Set the defaults for the check boxes
$context->setDefault('air_conditioned', 0);
$context->setDefault('is_online', 0);
$context->setDefault('meal_plan_required', 0);
$context->setDefault('assignment_notifications', 0);
$hall->air_conditioned = $context->get('air_conditioned');
$hall->is_online = $context->get('is_online');
$hall->meal_plan_required = $context->get('meal_plan_required');
$hall->assignment_notifications = $context->get('assignment_notifications');
$hall->setPackageDeskId($context->get('package_desk'));
} else {
if ($context->get('tab') == 'images') {
$hall->exterior_image_id = $context->get('exterior_image_id');
$hall->other_image_id = $context->get('other_image_id');
$hall->map_image_id = $context->get('map_image_id');
$hall->room_plan_image_id = $context->get('room_plan_image_id');
}
}
$result = $hall->save();
if (!$result || PHPWS_Error::logIfError($result)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'There was a problem saving the Residence Hall. No changes were made.');
$viewCmd->redirect();
}
NQ::simple('hms', hms\NotificationView::SUCCESS, 'The Residence hall was updated successfully.');
$viewCmd->redirect();
}
示例14: execute
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'edit_terms')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to edit terms.');
}
$view = new CreateTermView();
$context->setContent($view->show());
}
示例15: execute
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'learning_community_maintenance')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to edit RLCs.');
}
$view = new EditRlcView();
$context->setContent($view->show());
}