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


PHP UserDB::getBasicUserByCardNumber方法代码示例

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


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

示例1: post

 public static function post()
 {
     $page = new Page();
     $page->data['title'] = 'Inchecken';
     $errMsgs = CheckInFormViewValidator::validate($_POST);
     $user = null;
     if (empty($errMsgs)) {
         $checkInOk = false;
         $weeklyWinnerOk = true;
         //Get user to check in
         try {
             //Get the user who's card number for this year was entered
             $user = UserDB::getBasicUserByCardNumber($_POST['card_number']);
         } catch (Exception $ex) {
             //Check-in failed (can't get user)
             CheckInController::buildCheckInFormView($page, true);
             $page->data['CheckInFormView']['errMsgs']['global'] = '<h2 class="error_message" id="check_in_form_error_message">Kan gebruiker niet inchecken, probeer het opnieuw.</h2>';
             $page->showWithMenu();
             exit;
         }
         if (!$user) {
             //There's no user for this card
             CheckInController::buildCheckInFormView($page, true);
             $page->data['CheckInFormView']['errMsgs']['global'] = '<h2 class="error_message" id="check_in_form_error_message">Dit kaartnummer is niet gekoppeld aan een gebruiker.</h2>';
             $page->showWithMenu();
             exit;
         } else {
             //Check user in
             try {
                 $checkInOk = CheckInDB::checkIn($user->userId);
             } catch (Exception $ex) {
                 //Check-in failed (something went wrong or check-in isn't valid)
                 CheckInController::buildCheckInFormView($page, true);
                 $page->data['CheckInFormView']['errMsgs']['global'] = '<h2 class="error_message" id="check_in_form_error_message">Kan gebruiker niet inchecken, probeer het opnieuw.</h2>';
                 $page->showWithMenu();
                 exit;
             }
         }
         if (!$checkInOk) {
             //The user has already checked in
             CheckInController::buildCheckInFormView($page, true);
             $page->data['CheckInFormView']['errMsgs']['global'] = '<h2 class="error_message" id="check_in_form_error_message">Deze gebruiker is de voorbije 12 uur al ingechecked.</h2>';
             $page->showWithMenu();
             exit;
         } else {
             //Check in successful, check whether he is the winner of the week
             $isWinner = false;
             try {
                 //Check if this user is the winner of the week
                 $weeklyWinnerData = WeeklyWinnerDB::getThisWeeksWinnerData();
                 $isWinner = $weeklyWinnerData && $weeklyWinnerData->userId == $user->userId && !$weeklyWinnerData->hasCollectedPrize;
                 //If he is the winner we set in the database that the user collected his prize
                 if ($isWinner) {
                     $newWeeklyWinnerData = new WeeklyWinnerData($weeklyWinnerData->startOfWeek, $weeklyWinnerData->userId, true);
                     WeeklyWinnerDB::updateWeeklyWinnerData($weeklyWinnerData, $newWeeklyWinnerData);
                 }
             } catch (Exception $ex) {
                 $weeklyWinnerOk = false;
             }
             //If he is the winner, add the winner views and try to send an email to all usermanagers
             if ($isWinner) {
                 $page->addView('checkIn/CheckInWeeklyWinnerTitleView');
                 CheckInController::buildCheckInSuccessfulView($page, $user);
                 try {
                     $select = array('email' => true);
                     $searchFilter = array('isUserManager' => true);
                     $searchUsers = UserDB::getSearchUsers($select, $searchFilter, null);
                     $extras['common']['winnerFirstName'] = $user->firstName;
                     $extras['common']['winnerLastName'] = $user->lastName;
                     $failedAddresses = Email::sendEmails('WeeklyWinnerNotification.html', 'Winnaar van de week', EmailConfig::FROM_ADDRESS, array_column($searchUsers, 'user'), $extras);
                     if (!empty($failedAddresses)) {
                         $page->data['ErrorMessageWithDescriptionNoLinkView']['errorTitle'] = 'Kan e-mail niet versturen.';
                         $page->data['ErrorMessageWithDescriptionNoLinkView']['description'] = 'Kan geen e-mail versturen naar het bestuur om te laten weten dat je gewonnen hebt. Meld dit even aan een tapper of bestuurslid.';
                         $page->addView('error/ErrorMessageWithDescriptionNoLinkView');
                     }
                 } catch (Exception $ex) {
                     $page->data['ErrorMessageWithDescriptionNoLinkView']['errorTitle'] = 'Kan e-mail niet versturen.';
                     $page->data['ErrorMessageWithDescriptionNoLinkView']['errorDescription'] = 'Kan geen e-mail versturen naar het bestuur om te laten weten dat je gewonnen hebt. Meld dit even aan een tapper of bestuurslid.';
                     $page->addView('error/ErrorMessageWithDescriptionNoLinkView');
                 }
                 $page->addView('checkIn/CheckInWeeklyWinnerImageView');
                 $page->showWithMenu();
             } else {
                 $page->addView('checkIn/CheckInSuccessfulTitleView');
                 CheckInController::buildCheckInSuccessfulView($page, $user);
                 if (!$weeklyWinnerOk) {
                     $page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan niet controleren of je de winnaar van de week bent.';
                     $page->addView('error/ErrorMessageNoDescriptionNoLinkView');
                 } else {
                     $page->addExtraJsFile('views/checkIn/CheckInRedirector.js');
                     $page->addExtraJsFile('views/checkIn/checkInSuccessfulOnLoadHandler.js');
                 }
                 $page->showWithMenu();
             }
         }
     } else {
         //Errors in the form, retry
         CheckInController::buildCheckInFormView($page, true);
         $page->data['CheckInFormView']['errMsgs'] = array_merge($page->data['CheckInFormView']['errMsgs'], $errMsgs);
         $page->showWithMenu();
//.........这里部分代码省略.........
开发者ID:JHDeStip,项目名称:Stippers,代码行数:101,代码来源:CheckInController.php

示例2: post

 public static function post()
 {
     //Get the request body as json
     $checkInRequest = json_decode(file_get_contents('php://input'));
     //Check if the json was valid and a card number is given
     if (!$checkInRequest || !isset($checkInRequest->cardNumber)) {
         header('HTTP/1.1 400 Bad Request');
     } else {
         //Create response object
         $response = new APICheckInResponse();
         //Check if the card number is valid
         if (!CheckInController::validateCardNumber($checkInRequest->cardNumber)) {
             $response->errorCode = APICheckInResponse::MALFORMED_CARDNUMBER;
             echo json_encode($response);
             exit;
         } else {
             $user = null;
             $checkInOk = false;
             $weeklyWinnerOk = true;
             //Get user to check in
             try {
                 //Get the user who's card number for this year was entered
                 $user = UserDB::getBasicUserByCardNumber($checkInRequest->cardNumber);
             } catch (Exception $ex) {
                 $response->errorCode = APICheckInResponse::CANNOT_GET_USER_DATA;
                 echo json_encode($response);
                 exit;
             }
             if (!$user) {
                 //There's no user for this card
                 $response->errorCode = APICheckInResponse::NO_USER_FOR_CARD_NUMBER;
                 echo json_encode($response);
                 exit;
             } else {
                 //We have a user so get the names in the response
                 $response->userFirstName = $user->firstName;
                 $response->userLastName = $user->lastName;
                 //Check user in
                 try {
                     $checkInOk = CheckInDB::checkIn($user->userId);
                 } catch (Exception $ex) {
                     //Check-in failed (something went wrong or check-in isn't valid)
                     $response->errorCode = APICheckInResponse::CANNOT_CHECK_IN;
                     echo json_encode($response);
                     exit;
                 }
             }
             if (!$checkInOk) {
                 //The user has already checked in
                 $response->errorCode = APICheckInResponse::ALREADY_CHECKED_IN;
                 echo json_encode($response);
                 exit;
             } else {
                 $response->checkInSuccessful = true;
                 //Check in successful, check whether he is the winner of the week
                 $isWinner = false;
                 try {
                     //Check if this user is the winner of the week
                     $weeklyWinnerData = WeeklyWinnerDB::getThisWeeksWinnerData();
                     $isWinner = $weeklyWinnerData && $weeklyWinnerData->userId == $user->userId && !$weeklyWinnerData->hasCollectedPrize;
                     //If he is the winner we set in the database that the user collected his prize
                     if ($isWinner) {
                         $newWeeklyWinnerData = new WeeklyWinnerData($weeklyWinnerData->startOfWeek, $weeklyWinnerData->userId, true);
                         WeeklyWinnerDB::updateWeeklyWinnerData($weeklyWinnerData, $newWeeklyWinnerData);
                     }
                 } catch (Exception $ex) {
                     $response->errorCode = APICheckInResponse::CANNOT_CHECK_WEEKLY_WINNER;
                     echo json_encode($response);
                     exit;
                 }
                 $response->isWeeklyWinner = $isWinner;
                 //If he is the winner, add the winner views and try to send an email to all usermanagers
                 if ($isWinner) {
                     try {
                         $select = array('email' => true);
                         $searchFilter = array('isUserManager' => true);
                         $searchUsers = UserDB::getSearchUsers($select, $searchFilter, null);
                         $extras['common']['winnerFirstName'] = $user->firstName;
                         $extras['common']['winnerLastName'] = $user->lastName;
                         $failedAddresses = Email::sendEmails('WeeklyWinnerNotification.html', 'Winnaar van de week', EmailConfig::FROM_ADDRESS, array_column($searchUsers, 'user'), $extras);
                         if (!empty($failedAddresses)) {
                             $response->errorCode = APICheckInResponse::CANNOT_SEND_WINNER_NOTIFICATIONS;
                         }
                         echo json_encode($response);
                         exit;
                     } catch (Exception $ex) {
                         $response->errorCode = APICheckInResponse::CANNOT_SEND_WINNER_NOTIFICATIONS;
                         echo json_encode($response);
                         exit;
                     }
                 } else {
                     echo json_encode($response);
                     exit;
                 }
             }
         }
     }
 }
开发者ID:JHDeStip,项目名称:Stippers,代码行数:98,代码来源:CheckInController.php


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