當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HTTPRequest::valid方法代碼示例

本文整理匯總了PHP中HTTPRequest::valid方法的典型用法代碼示例。如果您正苦於以下問題:PHP HTTPRequest::valid方法的具體用法?PHP HTTPRequest::valid怎麽用?PHP HTTPRequest::valid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在HTTPRequest的用法示例。


在下文中一共展示了HTTPRequest::valid方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: route

 public function route(HTTPRequest $request, Layout $response)
 {
     $valid_route = new Valid_WhiteList('func', $this->routes);
     $valid_route->required();
     if ($request->valid($valid_route)) {
         $route = $request->get('func');
         $controller = new OpenId_LoginController($this->logger, new OpenId_AccountManager(new Openid_Dao(), UserManager::instance()), $request, $response);
         $controller->{$route}();
     } else {
         $response->addFeedback(Feedback::ERROR, 'Invalid request for ' . __CLASS__);
         $response->redirect('/');
     }
 }
開發者ID:pombredanne,項目名稱:tuleap,代碼行數:13,代碼來源:OpenIdRouter.class.php

示例2: validateReminderId

 /**
  * Validate date Reminder Id.
  *
  * @param HTTPRequest $request HTTP request
  *
  * @return Integer
  */
 public function validateReminderId(HTTPRequest $request)
 {
     $validReminderId = new Valid_UInt('reminder_id');
     $validReminderId->required();
     if ($request->valid($validReminderId)) {
         return $request->get('reminder_id');
     } else {
         $errorMessage = $GLOBALS['Language']->getText('project_admin_utils', 'tracker_date_reminder_invalid_reminder', array($request->get('reminder_id')));
         throw new Tracker_DateReminderException($errorMessage);
     }
 }
開發者ID:nterray,項目名稱:tuleap,代碼行數:18,代碼來源:Tracker_DateReminderRenderer.class.php

示例3: validateRequest

 /**
  * Validate request values
  *
  * @param HTTPRequest $request request containing form values
  *
  * @return Array
  */
 function validateRequest($request)
 {
     $status = true;
     $invalid = array();
     $valid = new Valid_String('request_summary');
     $valid->required();
     $summary = trim($request->get('request_summary'));
     if ($request->valid($valid) && strlen($summary) < self::MAX_SUMMARY_LENGTH && $summary != '') {
         $params['summary'] = $summary;
     } else {
         $status = false;
         $invalid[] = $GLOBALS['Language']->getText('plugin_requesthelp', 'summary');
     }
     $valid = new Valid_Text('request_description');
     $valid->required();
     $description = trim($request->get('request_description'));
     $defaultDescription = $GLOBALS['Language']->getText('plugin_requesthelp', 'requesthelp_default_description');
     if ($request->valid($valid) && strlen($description) < self::MAX_DESCRIPTION_LENGTH && $description != '' && $description != $defaultDescription) {
         $params['description'] = $description;
     } else {
         $status = false;
         $invalid[] = 'Description';
     }
     $valid = new Valid_UInt('type');
     $valid->required();
     if ($request->valid($valid)) {
         $requestType = $request->get('type');
         $params['type'] = $requestType;
         switch ($requestType) {
             case RequestHelp::TYPE_SUPPORT:
                 $params['text_type'] = $this->_getPluginProperty('support_request');
                 break;
             case RequestHelp::TYPE_ENHANCEMENT:
                 $params['text_type'] = $this->_getPluginProperty('enhancement_request');
                 break;
             default:
                 $status = false;
                 $invalid[] = 'Type';
                 break;
         }
     } else {
         $status = false;
         $invalid[] = 'Type';
     }
     $valid = new Valid_UInt('severity');
     $valid->required();
     if ($request->valid($valid)) {
         $severity = $request->get('severity');
         $params['severity'] = $severity;
         switch ($severity) {
             case RequestHelp::SEVERITY_MINOR:
                 $params['text_severity'] = 'Minor';
                 break;
             case RequestHelp::SEVERITY_SERIOUS:
                 $params['text_severity'] = 'Serious';
                 break;
             case RequestHelp::SEVERITY_CRITICAL:
                 $params['text_severity'] = 'Critical';
                 break;
             default:
                 $status = false;
                 $invalid[] = $GLOBALS['Language']->getText('plugin_requesthelp', 'severity');
                 break;
         }
     } else {
         $status = false;
         $invalid[] = $GLOBALS['Language']->getText('plugin_requesthelp', 'severity');
     }
     $cc = array();
     $mails = array_map('trim', preg_split('/[,;]/', $request->get('cc')));
     $rule = new Rule_Email();
     $um = $this->_getUserManager();
     $invalidCc = array();
     foreach ($mails as $mail) {
         if ($rule->isValid($mail)) {
             $cc[] = $mail;
         } else {
             if (trim($mail) != '') {
                 $user = $um->findUser($mail);
                 if ($user) {
                     $mail = $user->getUserName();
                     if ($mail) {
                         $cc[] = $mail;
                     } else {
                         $invalidCc[] = $mail;
                     }
                 } else {
                     $invalidCc[] = $mail;
                 }
             }
         }
     }
     if (!empty($invalidCc)) {
//.........這裏部分代碼省略.........
開發者ID:rinodung,項目名稱:tuleap,代碼行數:101,代碼來源:RequestHelpActions.class.php

示例4: processEditMonitoringAction

 /**
  * Process the monitoring request
  *
  * @param HTTPRequest $request      HTTP request
  * @param PFUser        $currentUser  Current user
  * @param Integer     $groupId      Id of the project
  * @param Integer     $fileModuleId Id of the package
  * @param UserManager $um           UserManager instance
  * @param UserHelper  $userHelper   UserHelper instance
  *
  * @return String
  */
 public function processEditMonitoringAction($request, $currentUser, $groupId, $fileModuleId, $um, $userHelper)
 {
     $frspf = new FRSPackageFactory();
     $package = $frspf->getFRSPackageFromDb($fileModuleId);
     if ($frspf->userCanAdmin($currentUser, $groupId)) {
         if ($request->valid(new Valid_WhiteList('action', array('add_monitoring', 'delete_monitoring')))) {
             $action = $request->get('action');
             switch ($action) {
                 case 'add_monitoring':
                     $users = array_map('trim', preg_split('/[,;]/', $request->get('listeners_to_add')));
                     foreach ($users as $userName) {
                         if (!empty($userName)) {
                             $user = $um->findUser($userName);
                             $this->addUserMonitoring($user, $groupId, $fileModuleId, $package, $frspf, $userHelper);
                         }
                     }
                     break;
                 case 'delete_monitoring':
                     $users = $request->get('delete_user');
                     $this->stopMonitoringForUsers($users, $groupId, $fileModuleId, $package, $um, $userHelper);
                     break;
                 default:
                     break;
             }
         }
     }
 }
開發者ID:pombredanne,項目名稱:tuleap,代碼行數:39,代碼來源:FileModuleMonitorFactory.class.php

示例5: scindReminderNotifiedPeople

 /**
  * Scind the notified people for tracker reminder into dedicated arrays.
  * At least one list should be not empty
  *
  * @param HTTPRequest $request HTTP request
  *
  * @return Array
  */
 public function scindReminderNotifiedPeople(HTTPRequest $request)
 {
     $vArray = new Valid_Array('reminder_notified');
     $notified = $roles = $ugroups = array();
     if ($request->valid($vArray)) {
         $people = $request->get('reminder_notified');
         if ($people) {
             foreach ($people as $value) {
                 if ($value[0] == "r") {
                     $roles[] = substr($value, 2);
                 } else {
                     $ugroups[] = substr($value, 2);
                 }
             }
         }
         if (!empty($ugroups) || !empty($roles)) {
             $notified[] = $ugroups;
             $notified[] = $roles;
             return $notified;
         }
     }
     $errorMessage = $GLOBALS['Language']->getText('project_admin_utils', 'tracker_date_reminder_empty_people_param');
     throw new Tracker_DateReminderException($errorMessage);
 }
開發者ID:pombredanne,項目名稱:tuleap,代碼行數:32,代碼來源:Tracker_DateReminderRenderer.class.php


注:本文中的HTTPRequest::valid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。