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


PHP UserStatus::isUser方法代码示例

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


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

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

示例2: execute

 public function execute(CommandContext $context)
 {
     if (!UserStatus::isUser()) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to request a roommate.');
     }
     $term = $context->get('term');
     $requestee = $context->get('username');
     $requestor = UserStatus::getUsername();
     if (empty($term)) {
         throw new InvalidArgumentException('Term was not specified.');
     }
     $err = CommandFactory::getCommand('ShowRequestRoommate');
     $err->setTerm($term);
     if (empty($requestee)) {
         NQ::simple('hms', hms\NotificationView::WARNING, 'You did not enter a username.');
         $err->redirect();
     }
     if (!PHPWS_Text::isValidInput($requestee)) {
         NQ::simple('hms', hms\NotificationView::WARNING, 'You entered an invalid username.  Please use letters and numbers only.');
         $err->redirect();
     }
     // Attempt to Create Roommate Request
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $request = new HMS_Roommate();
     try {
         $request->request($requestor, $requestee, $term);
     } catch (RoommateCompatibilityException $rre) {
         NQ::simple('hms', hms\NotificationView::WARNING, $rre->getMessage());
         $err->redirect();
     }
     $request->save();
     $endTime = $request->calc_req_expiration_date();
     $expirationMsg = " expires on " . date('m/d/Y h:i:s a', $endTime);
     HMS_Activity_Log::log_activity($requestee, ACTIVITY_REQUESTED_AS_ROOMMATE, $requestor, "{$requestor} requested {$requestee}" . $expirationMsg);
     HMS_Activity_Log::log_activity($requestor, ACTIVITY_REQUESTED_AS_ROOMMATE, $requestee, "{$requestor} requested {$requestee}" . $expirationMsg);
     // Email both parties
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     HMS_Email::send_request_emails($request);
     // Notify
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $student = StudentFactory::getStudentByUsername($requestee, $term);
     $name = $student->getName();
     $fname = $student->getFirstName();
     NQ::simple('hms', hms\NotificationView::SUCCESS, "You have requested {$name} to be your roommate.  {$fname} has been emailed, and will need to log into HMS and approve your roommate request.");
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:48,代码来源:RequestRoommateCommand.php

示例3: execute

 public function execute(CommandContext $context)
 {
     if (!UserStatus::isUser()) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to request a roommate.');
     }
     $term = $context->get('term');
     if (is_null($term)) {
         throw new InvalidArgumentException('Must specify a term.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $username = UserStatus::getUsername();
     $err = CommandFactory::getCommand('ShowStudentMenu');
     // Make sure the user doesn't already have a request pending
     $result = HMS_Roommate::has_roommate_request($username, $term);
     if ($result === TRUE) {
         NQ::simple('hms', hms\NotificationView::WARNING, 'You have a pending roommate request. You can not request another roommate request until your current request is either denied or expires.');
         $err->redirect();
     }
     // Make sure the user doesn't already have a confirmed roommate
     $result = HMS_Roommate::has_confirmed_roommate($username, $term);
     if ($result === TRUE) {
         NQ::simple('hms', hms\NotificationView::WARNING, 'You already have a confirmed roommate.');
         $err->redirect();
     }
     $form = new PHPWS_Form();
     $cmd = CommandFactory::getCommand('RequestRoommate');
     $cmd->setTerm($term);
     $cmd->initForm($form);
     $form->addText('username');
     $form->addCssClass('username', 'form-control');
     $form->setExtra('username', 'autofocus');
     $form->addSubmit('submit', 'Request Roommate');
     $form->addButton('cancel', 'Cancel');
     $form->setExtra('cancel', 'onClick="document.location=\'index.php\'"');
     $tpl = $form->getTemplate();
     $context->setContent(PHPWS_Template::process($tpl, 'hms', 'student/select_roommate.tpl'));
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:38,代码来源:ShowRequestRoommateCommand.php

示例4: execute

 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'RlcApplicationReView.php');
     $application = new HMS_RLC_Application($context->get('appId'));
     if (is_null($application->username)) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'There is no RLC application available with that id.');
         $context->goBack();
     }
     // This is used both on the admin side and on the student side, so the permission check is a bit more complex
     if (UserStatus::isAdmin() && !Current_User::allow('view_rlc_applications') || UserStatus::isUser() && $application->getUsername() != UserStatus::getUsername()) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to view this RLC application.');
     }
     try {
         $student = StudentFactory::getStudentByUsername($application->username, $application->term);
     } catch (StudentNotFoundException $e) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Unknown student.');
         $context->goBack();
     }
     $view = new RlcApplicationReView($student, $application);
     $context->setContent($view->show());
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:24,代码来源:ShowRlcApplicationReViewCommand.php


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