当前位置: 首页>>代码示例>>PHP>>正文


PHP Current_User::allow方法代码示例

本文整理汇总了PHP中Current_User::allow方法的典型用法代码示例。如果您正苦于以下问题:PHP Current_User::allow方法的具体用法?PHP Current_User::allow怎么用?PHP Current_User::allow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Current_User的用法示例。


在下文中一共展示了Current_User::allow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'room_structure')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to add a room.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php');
     PHPWS_Core::initModClass('hms', 'HMS_Floor.php');
     PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     PHPWS_Core::initModClass('hms', 'HMS_Util.php');
     PHPWS_Core::initModClass('hms', 'AddRoomView.php');
     $floor_id = $context->get('floor');
     $tpl = array();
     # Setup the title and color of the title bar
     $tpl['TITLE'] = 'Add Room';
     # Check to make sure we have a floor and hall.
     $floor = new HMS_Floor($floor_id);
     if (!$floor) {
         $tpl['ERROR_MSG'] = 'There was an error getting the floor object. Please contact ESS.';
         return PHPWS_Template::process($tpl, 'hms', 'admin/add_room.tpl');
     }
     $hall = $floor->get_parent();
     if (!$hall) {
         $tpl['ERROR_MSG'] = 'There was an error getting the hall object. Please contact ESS.';
         return PHPWS_Template::process($tpl, 'hms', 'admin/add_room.tpl');
     }
     # Check Permissions
     if (!Current_User::allow('hms', 'room_structure')) {
         HMS_Floor::show_edit_floor($floor_id, NULL, 'You do not have permission to add rooms.');
     }
     $view = new AddRoomView($floor);
     $context->setContent($view->show());
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:34,代码来源:ShowAddRoomCommand.php

示例2: 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();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:29,代码来源:DeleteBedCommand.php

示例3: __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);
         }
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:31,代码来源:RLCMenu.php

示例4: execute

 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'edit_role_members')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit role members.');
     }
     $username = $context->get('username');
     $role_id = $context->get('role');
     $classname = $context->get('class');
     $instance = $context->get('instance');
     if (is_null($username) || is_null($role_id)) {
         echo json_encode(false);
         exit;
     }
     $role = new HMS_Role();
     $role->id = $role_id;
     if ($role->load()) {
         try {
             $role->addUser($username, $classname, $instance);
             echo json_encode('true');
             exit;
         } catch (Exception $e) {
             echo json_encode($e->getMessage());
             exit;
         }
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:27,代码来源:RoleAddUserCommand.php

示例5: __construct

 public function __construct()
 {
     parent::__construct();
     // Check-in
     if (Current_User::allow('hms', 'checkin')) {
         $this->addCommandByName('Check-in', 'ShowCheckinStart');
     }
     // Check-out
     if (Current_User::allow('hms', 'checkin')) {
         $this->addCommandByName('Check-out', 'ShowCheckoutStart');
     }
     // Room Damage Assessment
     if (Current_User::allow('hms', 'damage_assessment')) {
         $this->addCommandByName('Damage Assessment', 'ShowRoomDamageAssessment');
     }
     // Room Damage Notifications
     if (Current_User::allow('hms', 'damage_notification')) {
         $this->addCommandByName('Send Room Damage Notices', 'SendRoomDamageNotifications');
         $cmd = CommandFactory::getCommand('JSConfirm');
         $cmd->setLink('Send Room Damage Notices');
         $cmd->setTitle('Send Room Damage Notices');
         $cmd->setQuestion('Send room damage notification emails for the selected term?');
         $cmd->setOnConfirmCommand(CommandFactory::getCommand('SendRoomDamageNotifications'));
         $this->addCommand('Send Room Damage Notices', $cmd);
     }
     /*
     if (UserStatus::isAdmin()) {
     
         if(Current_User::allow('hms', 'package_desk')){
             $this->addCommandByName('Package Desk', 'ShowPackageDeskMenu');
         }
     }
     */
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:34,代码来源:ServiceDeskMenu.php

示例6: __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);
         }
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:31,代码来源:ResidenceHallMenu.php

示例7: 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())));
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:33,代码来源:JSONAssignStudentCommand.php

示例8: 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));
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:26,代码来源:JSONGetStudentCommand.php

示例9: 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());
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:31,代码来源:ShowActivityLogCommand.php

示例10: show

 public function show()
 {
     Layout::addPageTitle("Hall Notification Edit");
     $tpl = array();
     $submitCmd = CommandFactory::getCommand('ReviewHallNotificationMessage');
     $form = new PHPWS_Form('email_content');
     $submitCmd->initForm($form);
     if (Current_User::allow('hms', 'anonymous_notifications')) {
         $form->addCheck('anonymous');
         $form->setMatch('anonymous', $this->anonymous);
         $form->setLabel('anonymous', 'Send Anonymously');
     }
     $form->addText('subject', !is_null($this->subject) ? $this->subject : '');
     $form->setLabel('subject', 'Subject');
     $form->addCssClass('subject', 'form-control');
     $form->setSize('subject', 35);
     $form->setExtra('subject', 'autofocus');
     $form->addTextarea('body', !is_null($this->body) ? $this->body : '');
     $form->addCssClass('body', 'form-control');
     $form->setLabel('body', 'Message:');
     if (!empty($this->halls)) {
         $form->addHidden('hall', $this->halls);
     }
     if (!empty($this->floors)) {
         $form->addHidden('floor', $this->floors);
     }
     return PHPWS_Template::process($form->getTemplate(), 'hms', 'admin/hall_notification_email_page.tpl');
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:28,代码来源:ShowHallNotificationEditView.php

示例11: execute

 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'approve_rlc_applications')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to approve RLC applications.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Assignment.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     # Foreach rlc assignment made
     # $app_id is the 'id' column in the 'learning_community_applications' table, tells which student we're assigning
     # $rlc_id is the 'id' column in the 'learning_communitites' table, and refers to the RLC selected for the student
     foreach ($_REQUEST['final_rlc'] as $app_id => $rlc_id) {
         if ($rlc_id <= 0) {
             continue;
         }
         $app = HMS_RLC_Application::getApplicationById($app_id);
         $student = StudentFactory::getStudentByUsername($app->username, $app->term);
         # Insert a new assignment in the 'learning_community_assignment' table
         $assign = new HMS_RLC_Assignment();
         $assign->rlc_id = $rlc_id;
         $assign->gender = $student->getGender();
         $assign->assigned_by = UserStatus::getUsername();
         $assign->application_id = $app->id;
         $assign->state = 'new';
         $assign->save();
         # Log the assignment
         PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
         HMS_Activity_Log::log_activity($app->username, ACTIVITY_ASSIGN_TO_RLC, UserStatus::getUsername(), "New Assignment");
     }
     // Show a success message
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Successfully assigned RLC applicant(s).');
     $context->goBack();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:34,代码来源:AssignRlcApplicantsCommand.php

示例12: 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();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:26,代码来源:DeleteRoommateGroupCommand.php

示例13: showFP

function showFP()
{
    $db = new PHPWS_DB('ps_page');
    $db->addWhere('front_page', 1);
    if ($db->isTableColumn('deleted')) {
        $db->addWhere('deleted', 0);
    }
    Key::restrictView($db, 'pagesmith');
    $db->loadClass('pagesmith', 'PS_Page.php');
    $result = $db->getObjects('PS_Page');
    if (!PHPWS_Error::logIfError($result) && !empty($result)) {
        PHPWS_Core::initModClass('pagesmith', 'PageSmith.php');
        foreach ($result as $page) {
            $content = $page->view();
            if ($content && !PHPWS_Error::logIfError($content)) {
                if (Current_User::allow('pagesmith', 'edit_page', $page->id)) {
                    $content .= sprintf('<p class="pagesmith-edit">%s</p>', $page->editLink());
                }
                Layout::add($content, 'pagesmith', 'view_' . $page->id, TRUE);
            }
        }
    } else {
        return null;
    }
}
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:25,代码来源:runtime.php

示例14: execute

 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'edit_role_members')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to edit role members.');
     }
     $username = $context->get('username');
     $rolename = $context->get('role');
     $class = $context->get('className');
     $instance = $context->get('instance');
     if (is_null($username) || is_null($rolename)) {
         echo json_encode(false);
         exit;
     }
     $db = new PHPWS_DB('hms_role');
     $db->addWhere('name', $rolename);
     $result = $db->select('row');
     if (PHPWS_Error::logIfError($result) || is_null($result['id'])) {
         echo json_encode(false);
         exit;
     }
     $role_id = $result['id'];
     $role = new HMS_Role();
     $role->id = $role_id;
     if ($role->load()) {
         echo json_encode($role->removeUser($username, $class, $instance));
         exit;
     }
     echo json_encode(false);
     exit;
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:31,代码来源:RoleRemoveUserCommand.php

示例15: execute

 public function execute(CommandContext $context)
 {
     // Check permissions
     if (!Current_User::allow('hms', 'checkin')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to checkin students.');
     }
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_Assignment.php');
     $bannerId = $context->get('banner_id');
     $hallId = $context->get('residence_hall_hidden');
     $errorCmd = CommandFactory::getCommand('ShowCheckoutStart');
     // TODO
     if (!isset($bannerId) || is_null($bannerId) || $bannerId == '') {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Missing Banner ID.');
         $errorCmd->redirect();
     }
     if (!isset($hallId)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Missing residence hall ID.');
         $errorCmd->redirect();
     }
     // Everything checks out, so redirect to the form
     $cmd = CommandFactory::getCommand('ShowCheckoutForm');
     // TODO
     $cmd->setBannerId($bannerId);
     $cmd->setHallId($hallId);
     $cmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:28,代码来源:StartCheckoutSubmitCommand.php


注:本文中的Current_User::allow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。