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


PHP Captcha::verify方法代码示例

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


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

示例1: newPost

 public function newPost($request, $response)
 {
     /*{{{*/
     $verifyOk = Captcha::verify($request->verifyStr, XIpLocation::getIp(), 'article', $request->article_id, $request->token);
     DBC::requireTrue($verifyOk, "您输入的验证码有误!");
     //禁用词检查
     $title = $request->title;
     $result = DoctorClient::getInstance()->getProfanityCheck($title);
     DBC::requireFalse($result['CODE'] < 0, "文章 评论添加失败");
     DBC::requireFalse($result['CODE'] == 2, "文章 评论添加成功");
     $title = $result['CONTENT'];
     $content = htmlspecialchars($request->getRequest('content'), ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
     $result = DoctorClient::getInstance()->getProfanityCheck($content);
     DBC::requireFalse($result['CODE'] < 0, "文章 评论添加失败");
     DBC::requireFalse($result['CODE'] == 2, "文章 评论添加成功");
     $content = $result['CONTENT'];
     $article = DAL::get()->find('article', $request->article_id);
     $feilds = array();
     $feilds['ip'] = XIpLocation::getIp();
     $feilds['ipLocation'] = XIpLocation::getLocationArea();
     $userId = $this->user->isNull() == false ? $this->user->id : '';
     $comment = ArticleClient::getInstance()->addComment($article, $userId, $title, $content, $feilds);
     squid::clean($article->getUrl(), true);
     $this->message('您发表的评论已经提交,待网站审核通过后即可展示。', $response);
 }
开发者ID:sdgdsffdsfff,项目名称:hdf-client,代码行数:25,代码来源:articlecommentcontroller.php

示例2: _check_form

 /**
  * Kontrolliert das Formular auf Standarteinträge, richtige Mailmuster und Captcha-Wort.
  * Ist alles ordnungsgemäss, wird true zurückgegeben, sonst false. Bei false finden sich die Mängel
  * in $answer.
  *
  * @param array[reference] $answer Antowrt
  * @return boolean Erfolg
  */
 private function _check_form(&$answer)
 {
     $mail_vars = $this->_configvars['Mail'];
     $error_vars = $this->_configvars['Error'];
     /* Formularcheck vorbereiten */
     $formcheck = new Formularcheck();
     $val = array($this->_gpc['POST']['title'], $this->_gpc['POST']['content'], $this->_gpc['POST']['name'], $this->_gpc['POST']['email']);
     $std = array($mail_vars['entry_title'], $mail_vars['entry_content'], $mail_vars['entry_name'], $mail_vars['entry_email']);
     $err = array($error_vars['title_error'], $error_vars['content_error'], $error_vars['name_error'], $error_vars['email_error']);
     $rtn_arr = $formcheck->field_check_arr($val, $std);
     //Fehlerarray durchgehen
     foreach ($rtn_arr as $key => $value) {
         if ($value == false) {
             $answer[] = $err[$key];
         }
     }
     //Email-Adresse auf Gültigkeit prüfen
     if ($this->_gpc['POST']['email'] != "" && $formcheck->mailcheck($this->_gpc['POST']['email']) > 0) {
         $answer[] = $error_vars['email_checkfailed'];
     }
     //Captcha-Image prüfen
     if (!$this->_captcha->verify($this->_gpc['POST']['captcha_word'])) {
         $answer[] = $error_vars['captcha_error'] . "<br />";
     }
     if (empty($answer)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:BackupTheBerlios,项目名称:jclubcms,代码行数:38,代码来源:mailmodule.class.php

示例3: execute

 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     $requestId = $context->get('requestId');
     $errorCmd = CommandFactory::getCommand('LotteryShowDenyRoommateRequest');
     $errorCmd->setRequestId($requestId);
     # Confirm the captcha
     PHPWS_Core::initCoreClass('Captcha.php');
     $captcha = Captcha::verify(TRUE);
     if ($captcha === FALSE) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'The words you entered were incorrect. Please try again.');
         $errorCmd->redirect();
     }
     # Get the roommate request
     $request = HMS_Lottery::get_lottery_roommate_invite_by_id($context->get('requestId'));
     # Make sure that the logged in user is the same as the confirming the request
     if (UserStatus::getUsername() != $request['asu_username']) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Invalid roommate request. You can not confirm that roommate request.');
         $errorCmd->redirect();
     }
     # Deny the roommate requst
     try {
         HMS_Lottery::denyRoommateRequest($requestId);
     } catch (Exception $e) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error denying the roommate request. Please contact University Housing.');
         $errorCmd->redirect();
     }
     # Log that it happened
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_ROOMMATE_DENIED, UserStatus::getUsername(), 'Captcha words: ' . $captcha);
     # Success
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'The roommate request was successfully declined.');
     $successCmd = CommandFactory::getCommand('ShowStudentMenu');
     $successCmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:35,代码来源:LotteryDenyRoommateRequestCommand.php

示例4: _check_form

 /**
  * Kontrolliert das Formular auf Standarteinträge, richtige Mailmuster und Captcha-Wort.
  * Ist alles ordnungsgemäss, wird true zurückgegeben, sonst false. Bei false finden sich die Mängel
  * in $answer.
  *
  * @param array[reference] $answer Antwort
  * @param array $blacklist Array der Schlüssel, die nicht geprüft werden sollen
  * @return boolean Erfolg
  */
 private function _check_form(&$answer, $blacklist = array())
 {
     $gbook_vars = $this->_configvars['Gbook'];
     $error_vars = $this->_configvars['Error'];
     /* Formularcheck vorbereiten */
     //$formcheck = new Formularcheck();
     /*Formulardaten */
     if (!in_array('title', $blacklist)) {
         /* Titel z.B. bei Kommentar nicht vorhanden */
         $val['title'] = $this->_gpc['POST']['title'];
     }
     $val = array('content' => $this->_gpc['POST']['content'], 'name' => $this->_gpc['POST']['name'], 'email' => $this->_gpc['POST']['email'], 'hp' => $this->_gpc['POST']['hp']);
     /* Standart-Strings*/
     $std = array('title' => $gbook_vars['entry_title'], 'content' => $gbook_vars['entry_content'], 'name' => $gbook_vars['entry_name'], 'email' => $gbook_vars['entry_email'], 'hp' => $gbook_vars['entry_hp']);
     /* Error-Strings */
     $err = array('title' => $error_vars['title_error'], 'content' => $error_vars['content_error'], 'name' => $error_vars['name_error'], 'email' => $error_vars['email_error']);
     /* Unerwünschte Schlüssel nicht kontrollieren und speichern */
     if (!empty($blacklist) && is_array($blacklist)) {
         foreach ($blacklist as $value) {
             /* Nur löschen, wenn Variable existiert */
             if (isset($val[$value])) {
                 unset($val[$value]);
             }
             if (isset($std[$value])) {
                 unset($std[$value]);
             }
             if (isset($err[$value])) {
                 unset($err[$value]);
             }
         }
     }
     $rtn_arr = $this->_msbox->formCheck($val, $std);
     /* Fehlerarray durchgehen */
     foreach ($rtn_arr as $key => $value) {
         if ($value == MSGBOX_FORMCHECK_NONE) {
             $answer[] = $err[$key];
         }
         if ($value == MSGBOX_FORMCHECK_INVALID && ($key = 'email')) {
             $answer[] = $error_vars['email_checkfailed'];
         } elseif ($key == 'hp') {
             /* Wenn die hp falsch ist, gibt es kein Fehler */
             $val[$key] = $rtn_arr[$key];
         }
     }
     /* Captcha-Image prüfen */
     if (!$this->_captcha->verify($this->_gpc['POST']['captcha_word'])) {
         $answer[] = $error_vars['captcha_error'] . "<br />";
     }
     if (empty($answer)) {
         if (!in_array('title', $blacklist)) {
             $answer['title'] = $this->_gpc['POST']['title'];
         }
         /*Wenn keine Fehler aufgetaucht sind, werden die Einträge zurückgegeben*/
         $answer += array('content' => $val['content'], 'name' => $val['name'], 'time' => 'gbook_time', 'email' => $val['email'], 'hp' => $val['hp']);
         return true;
     } else {
         return false;
     }
 }
开发者ID:BackupTheBerlios,项目名称:jclubcms,代码行数:68,代码来源:gbook.class.php

示例5: execute

 public function execute(CommandContext $context)
 {
     PHPWS_Core::initModClass('hms', 'HousingApplication.php');
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcMembershipFactory.php');
     PHPWS_Core::initModClass('hms', 'RlcAssignmentSelfAssignedState.php');
     $requestId = $context->get('requestId');
     $mealPlan = $context->get('mealPlan');
     $errorCmd = CommandFactory::getCommand('LotteryShowConfirmRoommateRequest');
     $errorCmd->setRequestId($requestId);
     $errorCmd->setMealPlan($mealPlan);
     // Confirm the captcha
     PHPWS_Core::initCoreClass('Captcha.php');
     $captcha = Captcha::verify(TRUE);
     if ($captcha === FALSE) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'The words you entered were incorrect. Please try again.');
         $errorCmd->redirect();
     }
     // Check for a meal plan
     if (!isset($mealPlan) || $mealPlan == '') {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Please choose a meal plan.');
         $errorCmd->redirect();
     }
     $term = PHPWS_Settings::get('hms', 'lottery_term');
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     // Update the meal plan field on the application
     $app = HousingApplication::getApplicationByUser(UserStatus::getUsername(), $term);
     $app->setMealPlan($mealPlan);
     try {
         $app->save();
     } catch (Exception $e) {
         PHPWS_Error::log('hms', $e->getMessage());
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error confirming your roommate invitation. Please contact University Housing.');
         $errorCmd->redirect();
     }
     // Try to actually make the assignment
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     try {
         HMS_Lottery::confirm_roommate_request(UserStatus::getUsername(), $requestId, $mealPlan);
     } catch (Exception $e) {
         PHPWS_Error::log('hms', $e->getMessage());
         NQ::simple('hms', hms\NotificationView::ERROR, 'Sorry, there was an error confirming your roommate invitation. Please contact University Housing.');
         $errorCmd->redirect();
     }
     # Log the fact that the roommate was accepted and successfully assigned
     HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_LOTTERY_CONFIRMED_ROOMMATE, UserStatus::getUsername(), "Captcha: \"{$captcha}\"");
     // Check for an RLC membership and update status if necessary
     // If this student was an RLC self-select, update the RLC memberhsip state
     $rlcAssignment = RlcMembershipFactory::getMembership($student, $term);
     if ($rlcAssignment != null && $rlcAssignment->getStateName() == 'selfselect-invite') {
         $rlcAssignment->changeState(new RlcAssignmentSelfAssignedState($rlcAssignment));
     }
     $invite = HMS_Lottery::get_lottery_roommate_invite_by_id($requestId);
     $successCmd = CommandFactory::getCommand('LotteryShowConfirmedRoommateThanks');
     $successCmd->setRequestId($requestId);
     $successCmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:57,代码来源:LotteryConfirmRoommateRequestCommand.php

示例6: execute

 public function execute(&$value, &$error)
 {
     $g = new Captcha(sfContext::getInstance()->getUser()->getAttribute('captcha'));
     if ($g->verify($value)) {
         return true;
     }
     $error = $this->getParameter('error', sfConfig::get('app_captcha_error', 'You should specify valid Turing number'));
     return false;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:9,代码来源:captchaValidator.class.php

示例7: execute

 public function execute(&$value, &$error)
 {
     $user = sfContext::getInstance()->getUser();
     $g = new Captcha($user->getAttribute('captcha'));
     if ($g->verify($value)) {
         return true;
     }
     // captcha validation failure => we generate another one
     $g = new Captcha();
     $user->setAttribute('captcha', $g->generate());
     $error = $this->getParameter('error');
     return false;
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:13,代码来源:MyCaptchaValidator.class.php

示例8: forgotProcess

function forgotProcess()
{
    $valid = Validator::make(array('send.email' => 'email|slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request");
    }
    if (!Captcha::verify()) {
        throw new Exception("Wrong captcha characters.");
    }
    $email = Request::get('send.email');
    try {
        Users::forgotPassword($email);
    } catch (Exception $e) {
        throw new Exception($e->getMessage());
    }
}
开发者ID:neworldwebsites,项目名称:noblessecms,代码行数:16,代码来源:forgotpass.php

示例9: 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

示例10: newPost

	public function newPost($request, $response){
        $verifyStr = $request->verifystr;
        $verifyOk = Captcha::verify($verifyStr, XIpLocation::getIp(), 'article', $request->article_id, $request->token);
        if($verifyOk == false)
        {
            $this->message('您输入的验证码有误!', $response);
            return false;
        }

		//禁用词检查
		$title = $request->title;
		$result = DoctorClient::getInstance()->getProfanityCheck($request->title);
		if ($result['CODE'] < 0) {
			$this->message('文章 评论添加失败', $response);
			return false;
		}
		if ($result['CODE'] == 2) {
			//提示发表成功,但是数据没有入库
			$this->message('文章 评论添加成功', $response);
			return true;
		}
		$title = $result['CONTENT'];
		
		$content = htmlspecialchars($request->getRequest('content'), ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
		$result = DoctorClient::getInstance()->getProfanityCheck($content);
		if ($result['CODE'] < 0) {
			$this->message('文章 评论添加失败', $response);
			return false;
		}
		if ($result['CODE'] == 2) {
			//提示发表成功,但是数据没有入库
			$this->message('文章 评论添加成功', $response);
			return true;
		}
		$content = $result['CONTENT'];
		
		$article = DAL::get()->find('article', $request->article_id);
		$feilds = array();
		$feilds['ip'] = XIpLocation::getIp();
		$feilds['ipLocation'] = XIpLocation::getLocationArea();
		$userId = ($this->_newUser->isNull() == false) ? $this->_newUser->id : '';
		$comment = ArticleClient::getInstance()->addComment($article, $userId, $title, $content, $feilds);
        squid::clean($article->getUrl(), true);

		$this->message('您发表的评论已经提交,待网站审核通过后即可展示。', $response);
	}
开发者ID:sdgdsffdsfff,项目名称:hdf-client,代码行数:46,代码来源:articlecommentcontroller.php

示例11: execute

 public function execute(CommandContext $context)
 {
     // Get input
     $requestId = $context->get('requestId');
     $participantId = $context->get('participantId');
     // Command for showing the request, redirected to on success/error
     $cmd = CommandFactory::getCommand('ShowManageRoomChange');
     $cmd->setRequestId($requestId);
     // Load the request
     $request = RoomChangeRequestFactory::getRequestById($requestId);
     // Load the participant
     $participant = RoomChangeParticipantFactory::getParticipantById($participantId);
     // Load the Student
     $student = StudentFactory::getStudentByBannerId($participant->getBannerId(), $request->getTerm());
     // Check permissions. Must be the participant or an admin
     if (UserStatus::getUsername() != $student->getUsername() && !Current_User::allow('hms', 'admin_approve_room_change')) {
         throw new PermissionException('You do not have permission to appove this room change.');
     }
     // Check for CAPTCHA if this is the student; admins don't need a CAPTCHA
     $captchaResult = Captcha::verify(true);
     if (UserStatus::getUsername() == $student->getUsername() && $captchaResult === false) {
         // Failed the captcha
         NQ::simple('hms', hms\NotificationView::ERROR, "You didn't type the magic words correctly. Please try again.");
         $cmd = CommandFactory::getCommand('ShowRoomChangeRequestApproval');
         $cmd->redirect();
     }
     // If there was a captcha, then log the activity
     if ($captchaResult !== false) {
         HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_ROOM_CHANGE_AGREED, UserStatus::getUsername(FALSE), 'Request id: ' . $requestId . ' Captcha: ' . $captchaResult);
     }
     // Transition to StudentApproved state
     $participant->transitionTo(new ParticipantStateStudentApproved($participant, time(), null, UserStatus::getUsername()));
     // If all students have approved, notify RDs
     if ($request->isApprovedByAllParticipants()) {
         HMS_Email::sendRoomChangeCurrRDNotice($request);
     }
     // If the student is logged in, redirect to the main menu, other wise go back to the room change management view
     if (UserStatus::getUsername() == $student->getUsername()) {
         NQ::simple('hms', hms\NotificationView::SUCCESS, 'You have agreed to the room change request. You will be notified by email when the reqeust is approved or denied.');
         $menuCmd = CommandFactory::getCommand('ShowStudentMenu');
         $menuCmd->redirect();
     } else {
         $cmd->redirect();
     }
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:45,代码来源:RoomChangeStudentApproveCommand.php

示例12: loginProcess

function loginProcess()
{
    $valid = Validator::make(array('send.username' => 'min:3|slashes', 'send.password' => 'min:3|slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request");
    }
    if (!Captcha::verify()) {
        throw new Exception("Wrong captcha characters.");
    }
    $username = Request::get('send.username');
    $password = Request::get('send.password');
    try {
        Users::makeLogin($username, $password);
    } catch (Exception $e) {
        throw new Exception($e->getMessage());
    }
    Redirect::to(ADMINCP_URL);
}
开发者ID:neworldwebsites,项目名称:noblessecms,代码行数:18,代码来源:login.php

示例13: registerAction

 public function registerAction()
 {
     Request::ajax();
     $message = ErMessenger::getInstance();
     $request = new Request();
     $request->initRequest();
     $post = $request->getPost();
     if (isset($post)) {
         if (!empty($post['email']) && !empty($post['password']) && !empty($post['pass_confirm']) && !empty($post['captcha'])) {
             $userMapper = new UserMapper();
             $user = $userMapper->getUserByEmail($post["email"]);
             if (!$user) {
                 if (Captcha::verify()) {
                     $givenEmail = $this->clearStr($post['email']);
                     $givenPassword = $this->clearStr($post["password"]);
                     if (filter_var($givenEmail, FILTER_VALIDATE_EMAIL)) {
                         $user = new User();
                         $userMapper = new UserMapper();
                         $user->email = $givenEmail;
                         $user->crdate = date("Y-m-d");
                         $user->access = 'ps';
                         $user->userstatus = 1;
                         $user->userpassword = hash("md5", $givenPassword);
                         if ($userMapper->insertNewUser($user)) {
                             $message->setSucceedMessage('201', 'index/index');
                             ErSession::saveToSession('user', $user->email);
                             if ($user->username != null) {
                                 ErSession::saveToSession('username', $user->username);
                             }
                         } else {
                             $message->setErrMessage('101', 'user/signup');
                         }
                     } else {
                         $message->setErrMessage('103', 'user/signup');
                     }
                 } else {
                     $message->setErrMessage('104', 'user/signup');
                 }
             } else {
                 $message->setErrMessage('102', 'user/signup');
             }
         }
     }
 }
开发者ID:G-Grand,项目名称:webosen2014_diplom,代码行数:44,代码来源:UserController.php

示例14: execute

 public function execute(CommandContext $context)
 {
     // Get input
     $requestId = $context->get('requestId');
     $participantId = $context->get('participantId');
     // Load the request
     $request = RoomChangeRequestFactory::getRequestById($requestId);
     // Load the participant
     $participant = RoomChangeParticipantFactory::getParticipantById($participantId);
     // Load the Student
     $student = StudentFactory::getStudentByBannerId($participant->getBannerId(), $request->getTerm());
     // Check permissions. Must be the participant or an admin
     if (UserStatus::getUsername() != $student->getUsername() && !Current_User::allow('hms', 'admin_approve_room_change')) {
         throw new PermissionException('You do not have permission to decline this room change.');
     }
     // Check for CAPTCHA if this is the student; admins don't need a CAPTCHA
     $captchaResult = Captcha::verify(true);
     if ($captchaResult === false) {
         // Failed the captcha
         NQ::simple('hms', hms\NotificationView::ERROR, "You didn't type the magic words correctly. Please try again.");
         $cmd = CommandFactory::getCommand('ShowRoomChangeRequestApproval');
         $cmd->redirect();
     }
     HMS_Activity_Log::log_activity(UserStatus::getUsername(), ACTIVITY_ROOM_CHANGE_DECLINE, UserStatus::getUsername(FALSE), 'Request id: ' . $requestId . ' Captcha: ' . $captchaResult);
     // Transition request to cancelled status
     $request->transitionTo(new RoomChangeStateCancelled($request, time(), null, UserStatus::getUsername()));
     // Transition all participants to cancelled
     // TODO... Do this in the cancelled transition?
     $participants = $request->getParticipants();
     foreach ($participants as $p) {
         $p->transitionTo(new ParticipantStateCancelled($p, time(), null, UserStatus::getUsername()));
     }
     // TODO Notify everyone that the request was cancelled
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'You have declined the room change request.');
     $menuCmd = CommandFactory::getCommand('ShowStudentMenu');
     $menuCmd->redirect();
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:37,代码来源:RoomChangeStudentDeclineCommand.php

示例15: 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


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