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


PHP NQ::Simple方法代码示例

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


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

示例1: execute

 public function execute(CommandContext $context)
 {
     $id = $context->get('roommateId');
     if (is_null($id)) {
         throw new InvalidArgumentException('Must set roommateId');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $roommate = new HMS_Roommate($id);
     if ($roommate->id == 0) {
         throw new InvalidArgumentException('Invalid roommateId ' . $id);
     }
     if (UserStatus::getUsername() != $roommate->requestee) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException("{$username} tried to reject roommate pairing {$roommate->id}");
     }
     $requestor = StudentFactory::getStudentByUsername($roommate->requestor, $roommate->term);
     $name = $requestor->getFullName();
     $username = $requestor->getUsername();
     $roommate->delete();
     HMS_Activity_Log::log_activity($roommate->requestor, ACTIVITY_REJECTED_AS_ROOMMATE, $roommate->requestee, "{$roommate->requestee} rejected {$roommate->requestor}'s request");
     HMS_Activity_Log::log_activity($roommate->requestee, ACTIVITY_REJECTED_AS_ROOMMATE, $roommate->requestor, "{$roommate->requestee} rejected {$roommate->requestor}'s request");
     // Email both parties
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     HMS_Email::send_reject_emails($roommate);
     NQ::Simple('hms', hms\NotificationView::SUCCESS, "<b>You rejected the roommate request from {$name}.</b>  If this was an error, you may re-request using their username, <b>{$username}</b>.");
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:28,代码来源:RoommateRejectCommand.php

示例2: execute

 public function execute(CommandContext $context)
 {
     $id = $context->get('roommateId');
     if (is_null($id)) {
         throw new InvalidArgumentException('Must set roommateId');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $roommate = new HMS_Roommate($id);
     if ($roommate->id == 0) {
         throw new InvalidArgumentException('Invalid roommateId ' . $id);
     }
     $username = UserStatus::getUsername();
     if ($username != $roommate->requestor) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException("{$username} tried to break roommate pairing {$roommate->id}");
     }
     $roommate->delete();
     $other = StudentFactory::getStudentByUsername($roommate->get_other_guy($username), $roommate->term);
     HMS_Activity_Log::log_activity($other->getUsername(), ACTIVITY_STUDENT_CANCELLED_ROOMMATE_REQUEST, $username, "{$username} cancelled roommate request");
     HMS_Activity_Log::log_activity($username, ACTIVITY_STUDENT_CANCELLED_ROOMMATE_REQUEST, $other->getUsername(), "{$username} cancelled roommate request");
     // Email both parties
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     HMS_Email::send_cancel_emails($roommate);
     $name = $other->getFullName();
     NQ::Simple('hms', hms\NotificationView::SUCCESS, "You have cancelled your roommate request for {$name}.");
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:28,代码来源:RoommateRequestCancelCommand.php

示例3: execute

 public function execute(CommandContext $context)
 {
     $id = $context->get('roommateId');
     if (is_null($id)) {
         throw new InvalidArgumentException('Must set roommateId');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $roommate = new HMS_Roommate($id);
     if ($roommate->id == 0) {
         throw new InvalidArgumentException('Invalid roommateId ' . $id);
     }
     $username = UserStatus::getUsername();
     if ($username != $roommate->requestee) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException("{$username} tried to confirm roommate pairing {$roommate->id}");
     }
     $err = CommandFactory::getCommand('ShowRoommateConfirmAccept');
     $err->setRoommateId($id);
     PHPWS_Core::initCoreClass('Captcha.php');
     $verified = Captcha::verify(TRUE);
     if ($verified === FALSE || is_null($verified)) {
         NQ::Simple('hms', hms\NotificationView::ERROR, 'Sorry, please try again.');
         $err->redirect();
     }
     try {
         $roommate->confirm();
     } catch (RoommateCompatibilityException $rce) {
         NQ::simple('hms', hms\NotificationView::WARNING, $rce->getMessage());
         $err->redirect();
     }
     $roommate->save();
     HMS_Activity_Log::log_activity($roommate->requestor, ACTIVITY_ACCEPTED_AS_ROOMMATE, $roommate->requestee, "{$roommate->requestee} accepted request, CAPTCHA: {$verified}");
     HMS_Activity_Log::log_activity($roommate->requestee, ACTIVITY_ACCEPTED_AS_ROOMMATE, $roommate->requestor, "{$roommate->requestee} accepted request, CAPTCHA: {$verified}");
     // Email both parties
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     HMS_Email::send_confirm_emails($roommate);
     // Remove any other requests for the requestor
     HMS_Roommate::removeOutstandingRequests($roommate->requestor, $roommate->term);
     // Remove any other requests for the requestee
     HMS_Roommate::removeOutstandingRequests($roommate->requestee, $roommate->term);
     $requestor = StudentFactory::getStudentByUsername($roommate->requestor, $roommate->term);
     $name = $requestor->getFullName();
     NQ::Simple('hms', hms\NotificationView::SUCCESS, "You and {$name} are confirmed as roommates.");
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:46,代码来源:RoommateAcceptCommand.php

示例4: process

 public function process()
 {
     // This hack is the most awful hack ever.  Fix phpWebSite so that
     // user logins are logged separately.
     if (Current_User::isLogged() && !isset($_SESSION['HMS_LOGGED_THE_LOGIN'])) {
         $username = strtolower(Current_User::getUsername());
         HMS_Activity_Log::log_activity($username, ACTIVITY_LOGIN, $username, NULL);
         $_SESSION['HMS_LOGGED_THE_LOGIN'] = $username;
     }
     if (!Current_User::isLogged() && $this->context->get('action') != 'ShowFrontPage') {
         NQ::simple('hms', hms\NotificationView::ERROR, 'You must be logged in to do that.');
         $action = 'ShowFrontPage';
     } else {
         $action = $this->context->get('action');
     }
     $cmd = CommandFactory::getCommand($action);
     if (HMS_DEBUG) {
         $cmd->execute($this->context);
     } else {
         try {
             $cmd->execute($this->context);
         } catch (PermissionException $p) {
             NQ::Simple('hms', hms\NotificationView::ERROR, 'You do not have permission to perform that action. If you believe this is an error, please contact University Housing.');
             $nv = new hms\NotificationView();
             $nv->popNotifications();
             Layout::add($nv->show());
         } catch (Exception $e) {
             try {
                 $message = $this->formatException($e);
                 NQ::Simple('hms', hms\NotificationView::ERROR, 'An internal error has occurred, and the authorities have been notified.  We apologize for the inconvenience.');
                 $this->emailError($message);
                 $nv = new hms\NotificationView();
                 $nv->popNotifications();
                 Layout::add($nv->show());
             } catch (Exception $e) {
                 $message2 = $this->formatException($e);
                 echo "HMS has experienced a major internal error.  Attempting to email an admin and then exit.";
                 $message = "Something terrible has happened, and the exception catch-all threw an exception.\n\nThe first exception was:\n\n{$message}\n\nThe second exception was:\n\n{$message2}";
                 mail(FROM_ADDRESS, 'A Major HMS Error Has Occurred', $message);
                 exit;
             }
         }
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:44,代码来源:HMS.php

示例5: execute

 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'banner_queue')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to enable/disable the Banner queue.');
     }
     if (is_null($this->term)) {
         $this->term = $context->get('term');
     }
     $term = $this->term;
     if (is_null($term)) {
         throw new InvalidArgumentException('No term was specified to DisableBannerQueue');
     }
     $term = new Term($term);
     if (!$term->getBannerQueue()) {
         NQ::Simple('hms', hms\NotificationView::ERROR, 'The Banner Queue is not enabled for ' . Term::toString($term->term) . '.');
     } else {
         if ($term->getQueueCount() < 1) {
             NQ::Simple('hms', hms\NotificationView::WARNING, 'The Banner Queue was already empty for ' . Term::toString($term->term) . '.');
             $term->setBannerQueue(FALSE);
             $term->save();
             NQ::Simple('hms', hms\NotificationView::SUCCESS, 'Banner Queue has been disabled for ' . Term::toString($term->term) . '.');
         } else {
             PHPWS_Core::initModClass('hms', 'BannerQueue.php');
             $result = BannerQueue::processAll($term->term);
             if ($result === TRUE) {
                 NQ::Simple('hms', hms\NotificationView::SUCCESS, 'Banner Queue has been processed for ' . Term::toString($term->term) . '.');
                 $term->setBannerQueue(FALSE);
                 $term->save();
                 NQ::Simple('hms', hms\NotificationView::SUCCESS, 'Banner Queue has been disabled for ' . Term::toString($term->term) . '.');
             } else {
                 // TODO: This is just awful.
                 $text = 'The following failures occurred reporting to Banner:<br /><br /><ul>';
                 foreach ($result as $error) {
                     $text .= "<li>{$error['username']}: ({$error['code']}) - {$error['message']}</li>";
                 }
                 $text .= '</ul>The queue was not disabled.';
                 NQ::Simple('hms', hms\NotificationView::ERROR, $text);
             }
         }
     }
     $cmd = CommandFactory::getCommand('ShowEditTerm');
     $cmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:44,代码来源:ProcessBannerQueueCommand.php

示例6: execute

 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'banner_queue')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to enable/disable the Banner queue.');
     }
     if (is_null($this->term)) {
         $this->term = $context->get('term');
     }
     $term = $this->term;
     if (is_null($term)) {
         throw new InvalidArgumentException('No term was specified to DisableBannerQueue');
     }
     $term = new Term($term);
     $term->setBannerQueue(TRUE);
     $term->save();
     NQ::Simple('hms', hms\NotificationView::SUCCESS, 'Banner Queue has been enabled for ' . Term::toString($term->term) . '.');
     CommandContext::goBack();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:19,代码来源:EnableBannerQueueCommand.php

示例7: execute

 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'email_rlc_rejections')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to send RLC rejections.');
     }
     PHPWS_Core::initModClass('hms', 'HMS_RLC_Application.php');
     PHPWS_Core::initModClass('hms', 'Term.php');
     $term = Term::getSelectedTerm();
     $deniedApps = HMS_RLC_Application::getNonNotifiedDeniedApplicantsByTerm($term);
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     $email = new HMS_Email();
     foreach ($deniedApps as $app) {
         $student = StudentFactory::getStudentByUsername($app['username'], $term);
         $email->sendRlcApplicationRejected($student, $term);
         $application = HMS_RLC_Application::getApplicationById($app['id']);
         $application->setDeniedEmailSent(1);
         $application->save();
     }
     NQ::Simple('hms', hms\NotificationView::SUCCESS, 'RLC rejection emails sent.');
     $context->goBack();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:22,代码来源:SendRlcRejectionEmailsCommand.php

示例8: execute

 public function execute(CommandContext $context)
 {
     $id = $context->get('roommateId');
     if (is_null($id)) {
         throw new InvalidArgumentException('Must set roommateId');
     }
     PHPWS_Core::initModClass('hms', 'HMS_Roommate.php');
     $roommate = new HMS_Roommate($id);
     if ($roommate->id == 0) {
         throw new InvalidArgumentException('Invalid roommateId ' . $id);
     }
     $username = UserStatus::getUsername();
     if ($username != $roommate->requestor && $username != $roommate->requestee) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException("{$username} tried to break roommate pairing {$roommate->id}");
     }
     $err = CommandFactory::getCommand('ShowRoommateBreak');
     $err->setRoommateId($id);
     PHPWS_Core::initCoreClass('Captcha.php');
     $verified = Captcha::verify(TRUE);
     if ($verified === FALSE || is_null($verified)) {
         NQ::Simple('hms', hms\NotificationView::ERROR, 'Sorry, please try again.');
         $err->redirect();
     }
     $roommate->delete();
     $other = StudentFactory::getStudentByUsername($roommate->get_other_guy($username), $roommate->term);
     HMS_Activity_Log::log_activity($other->getUsername(), ACTIVITY_STUDENT_BROKE_ROOMMATE, $username, "{$username} broke pairing, CAPTCHA: {$verified}");
     HMS_Activity_Log::log_activity($username, ACTIVITY_STUDENT_BROKE_ROOMMATE, $other->getUsername(), "{$username} broke pairing, CAPTCHA: {$verified}");
     // Email both parties
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     HMS_Email::send_break_emails($roommate, $username);
     $name = $other->getFullName();
     NQ::Simple('hms', hms\NotificationView::SUCCESS, "You have removed your roommate request for {$name}.");
     $cmd = CommandFactory::getCommand('ShowStudentMenu');
     $cmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:36,代码来源:RoommateBreakCommand.php


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