本文整理汇总了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('/');
}
}
示例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);
}
}
示例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)) {
//.........这里部分代码省略.........
示例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;
}
}
}
}
示例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);
}