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


PHP UserDB::renewMembership方法代码示例

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


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

示例1: post

 public static function post()
 {
     if (isset($_POST['save'])) {
         $page = new Page();
         $page->data['title'] = 'Gebruiker hernieuwen';
         //Validate input
         $formTopViewErrMsgs = UserDataFormTopViewValidator::validate($_POST);
         $formMiddleViewErrMsgs = UserDataFormMiddleViewValidator::validate($_POST);
         //No error means we create a user and password salt
         if (empty($formTopViewErrMsgs) && empty($formMiddleViewErrMsgs)) {
             $newUser = new User();
             $newUser->userId = $_SESSION['Stippers']['RenewUser']['user']->userId;
             $newUser->email = $_POST['email'];
             $newUser->passwordHash = $_SESSION['Stippers']['RenewUser']['user']->passwordHash;
             $newUser->firstName = ucwords($_POST['first_name']);
             $newUser->lastName = ucwords($_POST['last_name']);
             $newUser->street = ucwords($_POST['street']);
             $newUser->houseNumber = $_POST['house_number'];
             $newUser->city = ucwords($_POST['city']);
             $newUser->postalCode = $_POST['postal_code'];
             $newUser->country = ucwords($_POST['country']);
             $newUser->phone = $_POST['phone'];
             $newUser->dateOfBirth = $_POST['date_of_birth'];
             $newUser->balance = $_SESSION['Stippers']['RenewUser']['user']->balance;
             $newUser->isAdmin = $_SESSION['Stippers']['RenewUser']['user']->isAdmin;
             $newUser->isHintManager = $_SESSION['Stippers']['RenewUser']['user']->isHintManager;
             $newUser->isUserManager = $_SESSION['Stippers']['RenewUser']['user']->isUserManager;
             $newUser->isBrowserManager = $_SESSION['Stippers']['RenewUser']['user']->isBrowserManager;
             $newUser->isMoneyManager = $_SESSION['Stippers']['RenewUser']['user']->isMoneyManager;
             $newUser->creationTime = $_SESSION['Stippers']['RenewUser']['user']->creationTime;
             //Renew the user
             try {
                 UserDB::renewMembership($_SESSION['Stippers']['RenewUser']['user'], $newUser, $_POST['card_number']);
                 $page->addView('addRenewUser/renewUser/SuccessfullyRenewedView');
                 //Send welcome mail
                 try {
                     $failedEmails = Email::sendEmails('WelcomeOldMember.html', 'JH DE Stip - Welkom', EmailConfig::FROM_ADDRESS, [$newUser], null);
                     //If failedEmails is not empty the mail was not sent
                     if (!empty($failedEmails)) {
                         $page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan welkomstmail niet verzenden.';
                         $page->addView('error/ErrorMessageNoDescriptionNoLinkView');
                     }
                 } catch (Exception $ex) {
                     $page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan welkomstmail niet verzenden.';
                     $page->addView('error/ErrorMessageNoDescriptionNoLinkView');
                 }
                 //Add money to user's card
                 try {
                     $executingBrowserName = BrowserDB::getBrowserById($_SESSION['Stippers']['browser']->browserId)->name;
                     $trans = new MoneyTransaction(null, $newUser->userId, $newUser->balance, AddOrRenewUserConfig::NEW_OR_RENEWED_USER_BONUS, 0, 0, true, null, $executingBrowserName, null);
                     MoneyTransactionDB::addTransaction($newUser, $trans);
                 } catch (Exception $ex) {
                     if (isset($page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'])) {
                         $page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] .= ' Kan het saldo van het account niet verhogen, probeer dit handmatig te doen.';
                     } else {
                         $page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan het saldo van het account niet verhogen, probeer dit handmatig te doen.';
                     }
                     $page->addView('error/ErrorMessageNoDescriptionNoLinkView');
                 }
             } catch (UserDBException $ex) {
                 if ($ex->getCode() == UserDBException::USERALREADYMEMBER) {
                     $page->addView('addRenewUser/renewUser/UserAlreadyMemberView');
                 } elseif ($ex->getCode() == UserDBException::USEROUTOFDATE) {
                     $page->data['ErrorMessageWithDescriptionWithLinkView']['errorTitle'] = 'Gebruiker niet hernieuwd';
                     $page->data['ErrorMessageWithDescriptionWithLinkView']['errorDescription'] = 'Iemand anders heeft de gebruiker in tussentijd al gewijzigd.';
                     $page->data['ErrorMessageWithDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI'];
                     $page->addView('error/ErrorMessageWithDescriptionWithLinkView');
                 } else {
                     RenewUserController::buildRenewUserPage($page, true);
                     if ($ex->getCode() == UserDBException::EMAILALREADYEXISTS) {
                         $page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Dit e-mailadres is al in gebruik.</h2>';
                     } elseif ($ex->getCode() == UserDBException::CARDALREADYUSED) {
                         $page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Dit kaartnummer is al in gebruik.</h2>';
                     } else {
                         $page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Kan gebruiker niet hernieuwen, probeer het opnieuw.</h2>';
                     }
                 }
             } catch (Exception $ex) {
                 RenewUserController::buildRenewUserPage($page, true);
                 $page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Kan gebruiker niet hernieuwen, probeer het opnieuw.</h2>';
             }
         } else {
             RenewUserController::buildRenewUserPage($page, true);
             $page->data['UserDataFormTopView']['errMsgs'] = array_merge($page->data['UserDataFormTopView']['errMsgs'], $formTopViewErrMsgs);
             $page->data['UserDataFormMiddleView']['errMsgs'] = array_merge($page->data['UserDataFormMiddleView']['errMsgs'], $formMiddleViewErrMsgs);
         }
         $page->showWithMenu();
     } else {
         header('Location: renewusersearch', true, 303);
     }
 }
开发者ID:JHDeStip,项目名称:Stippers,代码行数:91,代码来源:RenewUserController.php


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