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


PHP Context::addError方法代码示例

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


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

示例1: handleForm

 public function handleForm(Context $context, $action)
 {
     if ($action == "createReservation") {
         if (isset($_POST['equip_id']) && $_POST['equip_id'] != "" && (isset($_POST['start_date']) && $_POST['start_date'] != "") && (isset($_POST['length']) && $_POST['length'] != "")) {
             $equipId = $_POST['equip_id'];
             $equip = EquipmentDao::getEquipmentByID($equipId);
             if ($equip != null) {
                 if (SessionUtil::getUserlevel() >= $equip->minUserLevel) {
                     $startDate = $_POST['start_date'];
                     $endDate = DateUtil::incrementDate($startDate, $_POST['length']);
                     $reservations = ReservationDao::getReservationsForEquipmentByDate($equipId, $startDate, $endDate);
                     if (count($reservations) == 0) {
                         $user = UserDao::getUserByUsername(SessionUtil::getUsername());
                         $reservation = ReservationDao::createReservation($user->id, $equipId, $_POST['length'], $startDate, $endDate, $_POST['user_comment']);
                         EmailUtil::sendNewReservationNotices($user, $reservation);
                     } else {
                         $context->addError("Reservations already exist during selected dates ({$startDate} and {$endDate}).");
                     }
                 } else {
                     $context->addError("Cannot reserve equipment (User Level).");
                 }
             } else {
                 $context->addError("No such equipment.");
             }
         } else {
             $context->addError("Required Field Left Blank.");
         }
     } else {
         $context->addError("Incorrect Action.");
     }
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:31,代码来源:PlaceReservationHandler.php

示例2: handleForm

 public function handleForm(Context $context, $action)
 {
     //TODO: Check user level >= ADMIN
     if ($action == "savePassword") {
         if (isset($_POST['newpass']) && $_POST['newpass'] != "" && (isset($_POST['confpass']) && $_POST['confpass'] != "")) {
             $newPassword = $_POST['newpass'];
             $confirmPassword = $_POST['confpass'];
             if ($newPassword = $confirmPassword) {
                 UserDao::updateUserPassword($_POST['userid'], $newPassword);
                 $context->addMessage("Password Successfully Changed.");
             } else {
                 $context->addError("Passwords Don't Match.");
             }
         } else {
             $context->addError("Required Field Left Blank.");
         }
     } else {
         if ($action == "saveEmail") {
             if (isset($_POST['email']) && $_POST['email'] != "") {
                 $email = $_POST['email'];
                 UserDao::updateUserEmail($_POST['userid'], $email);
                 $context->addMessage("Email Successfully Changed.");
             } else {
                 $context->addError("Required Field Left Blank.");
             }
         } else {
             if ($action == "saveUserLevel") {
                 if (isset($_POST['level']) && $_POST['level'] != "") {
                     $userlevel = $_POST['level'];
                     UserDao::updateUserLevel($_POST['userid'], $userlevel);
                     $context->addMessage("User Level Successfully Changed.");
                 } else {
                     $context->addError("Required Field Left Blank.");
                 }
             } else {
                 if ($action == "saveNotes") {
                     if (isset($_POST['notes']) && $_POST['notes'] != "") {
                         $notes = $_POST['notes'];
                         UserDao::updateUserNotes($_POST['userid'], $notes);
                         $context->addMessage("Notes Successfully Changed.");
                     } else {
                         $context->addError("Required Field Left Blank.");
                     }
                 } else {
                     if ($action == "saveName") {
                         if (isset($_POST['name']) && $_POST['name'] != "") {
                             $name = $_POST['name'];
                             UserDao::updateName($_POST['userid'], $name);
                             $context->addMessage("Name Successfully Changed.");
                         } else {
                             $context->addError("Required Field Left Blank.");
                         }
                     } else {
                         $context->addError("Incorrect Action.");
                     }
                 }
             }
         }
     }
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:60,代码来源:EditUserHandler.php

示例3: handleForm

 public function handleForm(Context $context, $action)
 {
     if (UserDao::getUserByUsername(SessionUtil::getUsername())->userlevel == RES_USERLEVEL_ADMIN) {
         if ($action == "deleteWarning") {
             $warning = WarningDao::getWarningByID($_POST['warnId']);
             if ($warning != null) {
                 WarningDao::deleteWarning($warning->id);
                 $context->addMessage("Successfully deleted warning.");
             } else {
                 $context->addError("No such warning.");
             }
         } else {
             $context->addError("Incorrect Action.");
         }
     } else {
         $context->addError("Not Authorized.");
     }
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:18,代码来源:AdminWarningHandler.php

示例4: handleForm

 public function handleForm(Context $context, $action)
 {
     if ($action == "createUser") {
         if (isset($_POST['username']) && $_POST['username'] != "" && (isset($_POST['userlevel']) && $_POST['userlevel'] != "") && (isset($_POST['name']) && $_POST['name'] != "") && (isset($_POST['email']) && $_POST['email'] != "")) {
             $password = "";
             if (Config::login_type == LOGIN_TYPE_DB) {
                 $password = CryptoUtil::generatePassword(9, 4);
             }
             UserDao::createUser($_POST['username'], $_POST['name'], $_POST['email'], $_POST['userlevel'], $password);
             $message = "Created User -- Username: " . $_POST['username'];
             if (Config::login_type == LOGIN_TYPE_DB) {
                 $message .= " Password: " . $password;
             }
             $context->addMessage($message);
         } else {
             $context->addError("Required Field Left Blank.");
         }
     } else {
         $context->addError("Incorrect Action.");
     }
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:21,代码来源:CreateUserHandler.php

示例5: handleForm

 public function handleForm(Context $context, $action)
 {
     if ($action == "client") {
         if ($_POST['name'] != "" && $_POST['username'] != "" && $_POST['password'] != "" && $_POST['repeatpassword'] != "" && $_POST['email'] != "" && $_POST['phone'] != "" && $_POST['address'] != "") {
             if ($_POST['password'] == $_POST['repeatpassword']) {
                 if (LoginDao::usernameFree($_POST['username'])) {
                     $newLogin = LoginDao::createLogin($_POST['username'], $_POST['password'], Login::CLIENT);
                     $newClient = ClientDao::createClient($newLogin, $_POST['name'], $_POST['email'], $_POST['phone'], $_POST['address']);
                     SessionUtil::login($newLogin);
                     $context->setPageID("home");
                 } else {
                     $context->addError("Username already taken.");
                 }
             } else {
                 $context->addError("Passwords don't match.");
             }
         } else {
             $context->addError("Required field left blank.");
         }
     } else {
         $context->addError("Incorrect Action.");
     }
 }
开发者ID:ramielrowe,项目名称:RU-Ad-System,代码行数:23,代码来源:RegisterHandler.php

示例6: handleForm

 public function handleForm(Context $context, $action)
 {
     if (UserDao::getUserByUsername(SessionUtil::getUsername())->userlevel == RES_USERLEVEL_ADMIN) {
         if ($action == "createWarning") {
             if (isset($_POST['userId']) && $_POST['userId'] != "" && (isset($_POST['reason']) && $_POST['reason'] != "") && (isset($_POST['type']) && $_POST['type'] != "")) {
                 $user = UserDao::getUserByID($_POST['userId']);
                 if ($user != null) {
                     $warning = WarningDao::warnUser($_POST['userId'], $_POST['reason'], $_POST['type']);
                     EmailUtil::sendWarningNoticeToUser($warning);
                     $context->addMessage("Successfully warned " . $user);
                 } else {
                     $context->addError("No such user.");
                 }
             } else {
                 $context->addError("Required field left blank.");
             }
         } else {
             $context->addError("Incorrect Action.");
         }
     } else {
         $context->addError("Not Authorized.");
     }
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:23,代码来源:WarnUserHandler.php

示例7: handleForm

 public function handleForm(Context $context, $action)
 {
     if ($action == "delete") {
         if (SessionUtil::getUserlevel() == RES_USERLEVEL_ADMIN) {
             ReservationDao::deleteReservation($_POST['resid']);
         } else {
             $context->addError("Action Not Allowed (Userlevel)");
         }
     } else {
         if ($action == "checkin") {
             if (SessionUtil::getUserlevel() >= RES_USERLEVEL_LEADER) {
                 ReservationDao::updateReservationStatus($_POST['resid'], RES_STATUS_CHECKED_IN, false);
             } else {
                 $context->addError("Action Not Allowed (Userlevel)");
             }
         } else {
             if ($action == "checkout") {
                 if (SessionUtil::getUserlevel() >= RES_USERLEVEL_LEADER) {
                     ReservationDao::updateReservationStatus($_POST['resid'], RES_STATUS_CHECKED_OUT, false);
                 } else {
                     $context->addError("Action Not Allowed (Userlevel)");
                 }
             } else {
                 if ($action == "updateStatus") {
                     if (SessionUtil::getUserlevel() == RES_USERLEVEL_ADMIN) {
                         ReservationDao::updateReservationStatus($_POST['resid'], $_POST['status'], true);
                     } else {
                         $context->addError("Action Not Allowed (Userlevel)");
                     }
                 } else {
                     $context->addError("Incorrect Action.");
                 }
             }
         }
     }
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:36,代码来源:ViewReservationHandler.php

示例8: saveSampleImage

 public function saveSampleImage(Context $context, $file, $username)
 {
     $type = $file['type'];
     $size = $file['size'];
     if ($type == "image/gif" || $type == "image/jpeg" || $type == "image/jpeg" || $type == "image/pjpeg" || $type == "image/png") {
         if ($size < 20000000) {
             $filename = explode('.', $file['name']);
             $newFilename = "./ad_images/ar" . $username . "t" . time() . "." . $filename[count($filename) - 1];
             $success = move_uploaded_file($file['tmp_name'], $newFilename);
             if (!$success) {
                 $context->addError("Error Uploading File.");
                 return "";
             } else {
                 return $newFilename;
             }
         } else {
             $context->addError("File Size Too Large.");
             return "";
         }
     } else {
         $context->addError("Unrecognized File Type.");
         return "";
     }
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:24,代码来源:CreateAdHandler.php

示例9: saveSampleImage

 public function saveSampleImage(Context $context, $file, $clientId)
 {
     $type = $file['type'];
     $size = $file['size'];
     if ($type == "image/gif" || $type == "image/jpeg" || $type == "image/pjpeg" || $type == "image/png") {
         if ($size < 20000000) {
             $filename = explode('.', $file['name']);
             $newFilename = "./uploads/" . "c" . $clientId . "t" . time() . "." . $filename[count($filename) - 1];
             $success = move_uploaded_file($file['tmp_name'], $newFilename);
             if (!$success) {
                 $context->addError("Error Uploading File.");
                 return "";
             } else {
                 return $newFilename;
             }
         } else {
             $context->addError("File Size Too Large.");
             return "";
         }
     } else {
         if ($type == "application/pdf" || $type == "image/psd" || ($type = "image/photoshop" || ($type = "image/x-photoshop" || ($type = "image/vnd.adobe.photoshop")))) {
             $filename = explode('.', $file['name']);
             $newFilename = "./uploads/" . "c" . $clientId . "t" . time() . "." . $filename[count($filename) - 1];
             $success = move_uploaded_file($file['tmp_name'], $newFilename);
             if (!$success) {
                 $context->addError("Error Uploading File.");
                 return "";
             } else {
                 return $newFilename;
             }
         } else {
             $context->addError("Unrecognized File Type.");
             return "";
         }
     }
 }
开发者ID:ramielrowe,项目名称:RU-Ad-System,代码行数:36,代码来源:CreateInsertionHandler.php

示例10: handleForm

 public function handleForm(Context $context, $action)
 {
     if ($action == "changePassword") {
         if ($_POST['password'] != "" && $_POST['repeatpassword'] != "") {
             $sessionLogin = LoginDao::getLoginByUsername(SessionUtil::getUsername());
             if ($_POST['password'] == $_POST['repeatpassword']) {
                 LoginDao::updateUserPassword($sessionLogin, $_POST['password']);
             } else {
                 $context->addError("Passwords don't match.");
             }
         } else {
             $context->addError("Required field left blank.");
         }
     } else {
         if ($action == "updateAccount") {
             if ($_POST['name'] != "" && $_POST['email'] != "" && $_POST['phone'] != "") {
                 $sessionLogin = LoginDao::getLoginByUsername(SessionUtil::getUsername());
                 if ($sessionLogin->getType() == Login::ADREP) {
                     $adrep = AdRepDao::getAdRepByLogin($sessionLogin);
                     AdRepDao::updateAdRep($adrep, $_POST['name'], $_POST['email'], $_POST['phone']);
                 } else {
                     if ($sessionLogin->getType() == Login::CLIENT) {
                         if ($_POST['address'] != "") {
                             $client = ClientDao::getClientByLogin($sessionLogin);
                             ClientDao::updateClient($client, $_POST['name'], $_POST['email'], $_POST['phone'], $_POST['address']);
                         } else {
                             $context->addError("Required field left blank.");
                         }
                     } else {
                         $context->addError("Unknown Account Type.");
                     }
                 }
             } else {
                 $context->addError("Required field left blank.");
             }
         } else {
             $context->addError("Incorrect Action.");
         }
     }
 }
开发者ID:ramielrowe,项目名称:RU-Ad-System,代码行数:40,代码来源:MyAccountHandler.php


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