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


PHP Validator::errors方法代码示例

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


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

示例1: throwStoreResourceFailedException

 public function throwStoreResourceFailedException($message = 'Failed to store your requested resource.', Validator $validator = null)
 {
     if ($validator instanceof Validator) {
         throw new \Dingo\Api\Exception\StoreResourceFailedException($message, $validator->errors());
     } else {
         throw new \Dingo\Api\Exception\StoreResourceFailedException($message);
     }
 }
开发者ID:muhammadshakeel,项目名称:laravel-api-boilerplate-oauth,代码行数:8,代码来源:UserRepository.php

示例2: validate

 /**
  * Validates a model
  * 
  * @param  array  	$data     
  * @param  boolean 	$isUpdate 
  * @return boolean            
  */
 public function validate($data, $isUpdate = false)
 {
     if ($isUpdate) {
         $rules = static::$updateRules;
     } else {
         $rules = static::$createRules;
     }
     if (is_null($rules)) {
         throw new \Exception(new MessageBag(['Could not find ' . ($isUpdate ? 'update' : 'create') . ' rules for ' . get_class($this)]));
     }
     $this->validation = \Validator::make($data, $rules);
     if (!$this->validation->passes()) {
         throw new ValidationException(new MessageBag($this->validation->errors()->all()));
     }
     return true;
 }
开发者ID:ddimaria,项目名称:Laravel-REST-CMS,代码行数:23,代码来源:BaseModel.php

示例3: update

 public function update($args)
 {
     if (!Token::match(Input::get('_token'))) {
         return Redirect::back();
     }
     $v = new Validator();
     $v->validate(Input::all(), ['title' => 'required|min:3', 'body' => 'required']);
     if (!$v->passed()) {
         return Redirect::back(['key' => 'errors', 'values' => $v->errors()]);
     }
     $id = $args['id'];
     $post = $this->post->update($id, ['title' => Input::get('title'), 'body' => Input::get('body')]);
     if ($post) {
         Session::flash('success', 'Successfully updated a post.');
         return Redirect::to('/');
     }
 }
开发者ID:eezhal92,项目名称:simple-mvc,代码行数:17,代码来源:PostController.php

示例4: callAction

 public function callAction()
 {
     $data = array_intersect_key($_POST, array_flip(array('phone', 'fio', 'formid')));
     // Validate data
     $validator = new Validator($data);
     $validator->rule('empty', 'formid')->message('Некорректный идентификатор формы');
     $validator->rule('required', 'phone')->message('Поле не заполнено');
     $validator->rule('phone', 'phone')->message('Некорректный номер телефона');
     if ($validator->validate()) {
         if (empty($data['fio'])) {
             $data['fio'] = 'Личный номер';
         }
         unset($data['formid']);
         // Send to subscribers
         $mailers = MSCore::db()->getCol('SELECT mail FROM `' . PRFX . 'mailer` WHERE type = ' . self::TARGET_CALL . ' OR type = 0');
         $data['date'] = date('Y-m-d H:i:s');
         MSCore::db()->insert(PRFX . 'order_call', $data);
         if (is_array($mailers) && !empty($mailers)) {
             // Send email
             $sendMail = new SendMail();
             $sendMail->init();
             $sendMail->setSubject('Обратный звонок на ' . DOMAIN);
             $sendMail->setFrom('noreply@' . DOMAIN, 'Первая кровельная');
             // Prepare body
             $message = template('email/call', array('data' => $data));
             $sendMail->setMessage($message);
             foreach ($mailers as $_email) {
                 $sendMail->setTo($_email);
                 $sendMail->send();
             }
             unset($sendMail);
         }
         $content = template('ajax/success/call');
         $this->addData(array('content' => $content));
     } else {
         $errors = $validator->errors();
         foreach ($errors as $_name => $_error) {
             if (is_array($_error)) {
                 $errors[$_name] = reset($_error);
             }
         }
         $this->errorAction(1001, 'Некорректно заполненные поля', array('errors' => $errors));
     }
 }
开发者ID:pers1307,项目名称:codeSnippets,代码行数:44,代码来源:ApiForms.php

示例5: check

 public static function check($formData, $validatorRules)
 {
     self::$errors = array();
     $formData = self::sanitizeInput($formData);
     self::$currentFormData = $formData;
     foreach ($formData as $formDataKey => $formDataValue) {
         if (isset($validatorRules[$formDataKey])) {
             $status = true;
             $rules = explode('|', $validatorRules[$formDataKey]);
             foreach ($rules as $rule) {
                 $ruleElement = explode(":", $rule);
                 $method = $ruleElement[0];
                 unset($ruleElement[0]);
                 $ruleElement = array_values($ruleElement);
                 $result = self::$method($formDataKey, $formDataValue, $ruleElement);
                 $status = $status && $result;
             }
         }
     }
 }
开发者ID:jjechev,项目名称:phpTdConvert,代码行数:20,代码来源:Validator.php

示例6: json_encode

            $update_data .= "`{$field}` = '{$insert_data[$field]}'";
        }
        if ($job_id) {
            // Update
            $where = " WHERE id = '{$job_id}' AND service_id = '{$service}'";
            updateDB($update_data, $where, 'service_packages');
            $return_data['type'] = 'update';
        } else {
            // Insert
            $insert_data['service_id'] = $service;
            $job_id = insertDB($insert_data, 'service_packages');
            $return_data['type'] = 'insert';
        }
        $return_data['id'] = $job_id;
        $return_data['name'] = $insert_data['job'];
        $return_data['status'] = 1;
        $return_data['message'] = 'Job updated successfully';
    } else {
        $messages = '';
        foreach ($v->errors() as $k => $msgs) {
            foreach ($msgs as $msg) {
                $messages .= $msg . "<br>";
            }
        }
        $return_data['message'] = $messages;
    }
} else {
    $return_data['message'] = 'An error occured';
}
echo json_encode($return_data);
exit;
开发者ID:ArpanTanna,项目名称:outsourceplatform,代码行数:31,代码来源:savejob.php

示例7: updatePref

 function updatePref($var, &$errors)
 {
     if (!$var || $errors) {
         return false;
     }
     $f = array();
     $f['helpdesk_url'] = array('type' => 'string', 'required' => 1, 'error' => 'Helpdesk URL erforderlich');
     //TODO: Add url validation
     $f['helpdesk_title'] = array('type' => 'string', 'required' => 1, 'error' => 'URL del centro de ayuda Requerida');
     $f['default_dept_id'] = array('type' => 'int', 'required' => 1, 'error' => 'Titulo Requerido');
     $f['default_email_id'] = array('type' => 'int', 'required' => 1, 'error' => 'Departamento por defecto Requerido');
     $f['default_template_id'] = array('type' => 'int', 'required' => 1, 'error' => 'Email pr defecto Requerido');
     $f['staff_session_timeout'] = array('type' => 'int', 'required' => 1, 'error' => 'Debes selecionar una Plantilla');
     $f['client_session_timeout'] = array('type' => 'int', 'required' => 1, 'error' => 'Introduzca el tiempo de inactividad en minutos');
     $f['time_format'] = array('type' => 'string', 'required' => 1, 'error' => 'Formato de hora Requerido');
     //TODO: Add date format validation
     $f['date_format'] = array('type' => 'string', 'required' => 1, 'error' => 'Formato de fecha Requerido');
     $f['datetime_format'] = array('type' => 'string', 'required' => 1, 'error' => 'Formato de fecha y hora Requerido');
     $f['daydatetime_format'] = array('type' => 'string', 'required' => 1, 'error' => 'Formato de fecha con dia y hora Requerido');
     $f['admin_email'] = array('type' => 'email', 'required' => 1, 'error' => 'Email valido Requerido');
     $f['autolock_minutes'] = array('type' => 'int', 'required' => 1, 'error' => 'Introduzca tiempo de Bloqueo en minutos');
     //TODO: check option fields for validity.
     //do the validation.
     $val = new Validator();
     $val->setFields($f);
     if (!$val->validate($var)) {
         $errors = array_merge($errors, $val->errors());
     }
     if ($var['ticket_alert_active'] && (!isset($var['ticket_alert_admin']) && !isset($var['ticket_alert_dept_manager']) && !isset($var['ticket_alert_dept_members']))) {
         $errors['ticket_alert_active'] = 'No ha selecionado un destinario';
     }
     if ($var['message_alert_active'] && (!isset($var['message_alert_laststaff']) && !isset($var['message_alert_assigned']) && !isset($var['message_alert_dept_manager']))) {
         $errors['message_alert_active'] = 'No ha selecionado un destinario';
     }
     if ($var['note_alert_active'] && (!isset($var['note_alert_laststaff']) && !isset($var['note_alert_assigned']) && !isset($var['note_alert_dept_manager']))) {
         $errors['note_alert_active'] = 'No ha selecionado un destinario';
     }
     if ($var['strip_quoted_reply'] && !$var['reply_separator']) {
         $errors['reply_separator'] = 'Separador de respuesta Requerido (?)';
     }
     if ($var['enable_captcha']) {
         if (!extension_loaded('gd')) {
             $errors['enable_captcha'] = 'La extensi&oacute;n GD es Requerida';
         } elseif (!function_exists('imagepng')) {
             $errors['enable_captcha'] = 'PNG debe ser soportado para el Capcha';
         }
     }
     if (!$errors['admin_email'] && Email::getIdByEmail($var['admin_email'])) {
         //Make sure admin email is not also a system email.
         $errors['admin_email'] = 'Esta cuenta de correo ya esta siendo utilizada como cuenta del Sistema';
     }
     if ($errors) {
         return false;
     }
     //No go!
     //We are good to go...blanket update!
     $sql = 'UPDATE ' . CONFIG_TABLE . ' SET isonline=' . db_input($var['isonline']) . ',timezone_offset=' . db_input($var['timezone_offset']) . ',enable_daylight_saving=' . db_input(isset($var['enable_daylight_saving']) ? 1 : 0) . ',staff_ip_binding=' . db_input(isset($var['staff_ip_binding']) ? 1 : 0) . ',staff_max_logins=' . db_input($var['staff_max_logins']) . ',staff_login_timeout=' . db_input($var['staff_login_timeout']) . ',staff_session_timeout=' . db_input($var['staff_session_timeout']) . ',client_max_logins=' . db_input($var['client_max_logins']) . ',client_login_timeout=' . db_input($var['client_login_timeout']) . ',client_session_timeout=' . db_input($var['client_session_timeout']) . ',max_page_size=' . db_input($var['max_page_size']) . ',log_level=' . db_input($var['log_level']) . ',log_graceperiod=' . db_input($var['log_graceperiod']) . ',max_open_tickets=' . db_input($var['max_open_tickets']) . ',autolock_minutes=' . db_input($var['autolock_minutes']) . ',overdue_grace_period=' . db_input($var['overdue_grace_period']) . ',alert_email_id=' . db_input($var['alert_email_id']) . ',default_email_id=' . db_input($var['default_email_id']) . ',default_dept_id=' . db_input($var['default_dept_id']) . ',default_priority_id=' . db_input($var['default_priority_id']) . ',default_template_id=' . db_input($var['default_template_id']) . ',default_smtp_id=' . db_input($var['default_smtp_id']) . ',spoof_default_smtp=' . db_input($var['default_smtp'] && isset($var['spoof_default_smtp']) ? 1 : 0) . ',clickable_urls=' . db_input(isset($var['clickable_urls']) ? 1 : 0) . ',allow_priority_change=' . db_input(isset($var['allow_priority_change']) ? 1 : 0) . ',use_email_priority=' . db_input(isset($var['use_email_priority']) ? 1 : 0) . ',enable_captcha=' . db_input(isset($var['enable_captcha']) ? 1 : 0) . ',enable_auto_cron=' . db_input(isset($var['enable_auto_cron']) ? 1 : 0) . ',enable_mail_fetch=' . db_input(isset($var['enable_mail_fetch']) ? 1 : 0) . ',enable_email_piping=' . db_input(isset($var['enable_email_piping']) ? 1 : 0) . ',send_sql_errors=' . db_input(isset($var['send_sql_errors']) ? 1 : 0) . ',send_login_errors=' . db_input(isset($var['send_login_errors']) ? 1 : 0) . ',save_email_headers=' . db_input(isset($var['save_email_headers']) ? 1 : 0) . ',strip_quoted_reply=' . db_input(isset($var['strip_quoted_reply']) ? 1 : 0) . ',log_ticket_activity=' . db_input(isset($var['log_ticket_activity']) ? 1 : 0) . ',ticket_autoresponder=' . db_input($var['ticket_autoresponder']) . ',message_autoresponder=' . db_input($var['message_autoresponder']) . ',ticket_notice_active=' . db_input($var['ticket_notice_active']) . ',ticket_alert_active=' . db_input($var['ticket_alert_active']) . ',ticket_alert_admin=' . db_input(isset($var['ticket_alert_admin']) ? 1 : 0) . ',ticket_alert_dept_manager=' . db_input(isset($var['ticket_alert_dept_manager']) ? 1 : 0) . ',ticket_alert_dept_members=' . db_input(isset($var['ticket_alert_dept_members']) ? 1 : 0) . ',message_alert_active=' . db_input($var['message_alert_active']) . ',message_alert_laststaff=' . db_input(isset($var['message_alert_laststaff']) ? 1 : 0) . ',message_alert_assigned=' . db_input(isset($var['message_alert_assigned']) ? 1 : 0) . ',message_alert_dept_manager=' . db_input(isset($var['message_alert_dept_manager']) ? 1 : 0) . ',note_alert_active=' . db_input($var['note_alert_active']) . ',note_alert_laststaff=' . db_input(isset($var['note_alert_laststaff']) ? 1 : 0) . ',note_alert_assigned=' . db_input(isset($var['note_alert_assigned']) ? 1 : 0) . ',note_alert_dept_manager=' . db_input(isset($var['note_alert_dept_manager']) ? 1 : 0) . ',overdue_alert_active=' . db_input($var['overdue_alert_active']) . ',overdue_alert_assigned=' . db_input(isset($var['overdue_alert_assigned']) ? 1 : 0) . ',overdue_alert_dept_manager=' . db_input(isset($var['overdue_alert_dept_manager']) ? 1 : 0) . ',overdue_alert_dept_members=' . db_input(isset($var['overdue_alert_dept_members']) ? 1 : 0) . ',auto_assign_reopened_tickets=' . db_input(isset($var['auto_assign_reopened_tickets']) ? 1 : 0) . ',show_assigned_tickets=' . db_input(isset($var['show_assigned_tickets']) ? 1 : 0) . ',show_answered_tickets=' . db_input(isset($var['show_answered_tickets']) ? 1 : 0) . ',hide_staff_name=' . db_input(isset($var['hide_staff_name']) ? 1 : 0) . ',overlimit_notice_active=' . db_input($var['overlimit_notice_active']) . ',random_ticket_ids=' . db_input($var['random_ticket_ids']) . ',time_format=' . db_input($var['time_format']) . ',date_format=' . db_input($var['date_format']) . ',datetime_format=' . db_input($var['datetime_format']) . ',daydatetime_format=' . db_input($var['daydatetime_format']) . ',reply_separator=' . db_input(trim($var['reply_separator'])) . ',admin_email=' . db_input($var['admin_email']) . ',helpdesk_title=' . db_input($var['helpdesk_title']) . ',helpdesk_url=' . db_input($var['helpdesk_url']) . ' WHERE id=' . $this->getId();
     //echo $sql;
     if (db_query($sql)) {
         if (db_affected_rows()) {
             //Something actually changed!!!!
             $this->reload();
             //Reload the new info.
             require_once INCLUDE_DIR . 'class.cron.php';
             Sys::purgeLogs();
             //Cleanup the logs --- too bad if it was a mistaken config.
             Cron::TicketMonitor();
             //Age & cleanup
         }
         return true;
     }
     return false;
 }
开发者ID:e-gob,项目名称:chilesinpapeleo-soporte,代码行数:73,代码来源:class.config.php

示例8: Validator

$errors = [];
$spam = [];
$validator = new Validator($_POST);
$validator->check('nom', 'required');
$validator->check('prénom', 'required');
$validator->check('email', 'email');
$validator->check('email', 'required');
$validator->check('tel', 'tel');
$validator->check('description', 'required');
$validator->specialcheck('arbitraryfield', 'empty');
// for select
$validator->check('pack', 'select', array_keys($pack));
$validator->check('event_type', 'select', array_keys($event));
$validator->check('background-your-choice', 'select', array_keys($backgroundchoice));
$validator->check('know_me', 'select', array_keys($know_me));
$errors = $validator->errors();
$spam = $validator->spam();
if (!empty($spam)) {
    $_SESSION['spam'] = $spam;
    // redirection
    header('Location:success.php');
} else {
    if (!empty($errors)) {
        $_SESSION['errors'] = $errors;
        $_SESSION['inputs'] = $_POST;
        // redirection
        header('Location:contact.php');
    } else {
        $_SESSION['success'] = 1;
        $email_contact = "\r\nContact: " . $_POST['email'] . "\r\n";
        $tel = "\r\nTel: " . $_POST['tel'] . "\r\n";
开发者ID:nchery,项目名称:W-B,代码行数:31,代码来源:contactform.php

示例9: update

 function update($var, &$errors)
 {
     $fields = array();
     $fields['id'] = array('type' => 'int', 'required' => 1, 'error' => _('Internal Error'));
     $fields['name'] = array('type' => 'string', 'required' => 1, 'error' => _('Name required'));
     //Notices sent to user
     $fields['ticket_autoresp_subj'] = array('type' => 'string', 'required' => 1, 'error' => _('Subject required'));
     $fields['ticket_autoresp_body'] = array('type' => 'string', 'required' => 1, 'error' => _('Template message required'));
     $fields['message_autoresp_subj'] = array('type' => 'string', 'required' => 1, 'error' => _('Subject required'));
     $fields['message_autoresp_body'] = array('type' => 'string', 'required' => 1, 'error' => _('Template message required'));
     $fields['ticket_notice_subj'] = array('type' => 'string', 'required' => 1, 'error' => _('Subject required'));
     $fields['ticket_notice_body'] = array('type' => 'string', 'required' => 1, 'error' => _('Template message required'));
     $fields['ticket_overlimit_subj'] = array('type' => 'string', 'required' => 1, 'error' => _('Subject required'));
     $fields['ticket_overlimit_body'] = array('type' => 'string', 'required' => 1, 'error' => _('Template message required'));
     $fields['ticket_reply_subj'] = array('type' => 'string', 'required' => 1, 'error' => _('Subject required'));
     $fields['ticket_reply_body'] = array('type' => 'string', 'required' => 1, 'error' => _('Template message required'));
     //Alerts sent to Staff
     $fields['ticket_alert_subj'] = array('type' => 'string', 'required' => 1, 'error' => _('Subject required'));
     $fields['ticket_alert_body'] = array('type' => 'string', 'required' => 1, 'error' => _('Template message required'));
     $fields['message_alert_subj'] = array('type' => 'string', 'required' => 1, 'error' => _('Subject required'));
     $fields['message_alert_body'] = array('type' => 'string', 'required' => 1, 'error' => _('Template message required'));
     $fields['note_alert_subj'] = array('type' => 'string', 'required' => 1, 'error' => _('Subject required'));
     $fields['note_alert_body'] = array('type' => 'string', 'required' => 1, 'error' => _('Template message required'));
     $fields['assigned_alert_subj'] = array('type' => 'string', 'required' => 1, 'error' => _('Subject required'));
     $fields['assigned_alert_body'] = array('type' => 'string', 'required' => 1, 'error' => _('Template message required'));
     $fields['ticket_overdue_subj'] = array('type' => 'string', 'required' => 1, 'error' => _('Subject required'));
     $fields['ticket_overdue_body'] = array('type' => 'string', 'required' => 1, 'error' => _('Template message required'));
     $validate = new Validator($fields);
     if (!$validate->validate($var)) {
         $errors = array_merge($errors, $validate->errors());
     }
     if (!$errors && $var['id'] && $var['id'] != $this->getId()) {
         $errors['err'] = 'Internal error. Try again';
     }
     if (!$errors['name'] && ($tid = Template::getIdByName($var['name'])) && $tid != $this->getId()) {
         $errors['name'] = 'Name already in use';
     }
     if (!$errors) {
         $sql = 'UPDATE ' . EMAIL_TEMPLATE_TABLE . ' SET updated=NOW() ' . ',name=' . db_input(Format::striptags($var['name'])) . ',notes=' . db_input(Format::striptags($var['notes'])) . ',ticket_autoresp_subj=' . db_input(Format::striptags($var['ticket_autoresp_subj'])) . ',ticket_autoresp_body=' . db_input(Format::striptags($var['ticket_autoresp_body'])) . ',message_autoresp_subj=' . db_input(Format::striptags($var['message_autoresp_subj'])) . ',message_autoresp_body=' . db_input(Format::striptags($var['message_autoresp_body'])) . ',ticket_notice_subj=' . db_input(Format::striptags($var['ticket_notice_subj'])) . ',ticket_notice_body=' . db_input(Format::striptags($var['ticket_notice_body'])) . ',ticket_alert_subj=' . db_input(Format::striptags($var['ticket_alert_subj'])) . ',ticket_alert_body=' . db_input(Format::striptags($var['ticket_alert_body'])) . ',message_alert_subj=' . db_input(Format::striptags($var['message_alert_subj'])) . ',message_alert_body=' . db_input(Format::striptags($var['message_alert_body'])) . ',note_alert_subj=' . db_input(Format::striptags($var['note_alert_subj'])) . ',note_alert_body=' . db_input(Format::striptags($var['note_alert_body'])) . ',assigned_alert_subj=' . db_input(Format::striptags($var['assigned_alert_subj'])) . ',assigned_alert_body=' . db_input(Format::striptags($var['assigned_alert_body'])) . ',ticket_overdue_subj=' . db_input(Format::striptags($var['ticket_overdue_subj'])) . ',ticket_overdue_body=' . db_input(Format::striptags($var['ticket_overdue_body'])) . ',ticket_overlimit_subj=' . db_input(Format::striptags($var['ticket_overlimit_subj'])) . ',ticket_overlimit_body=' . db_input(Format::striptags($var['ticket_overlimit_body'])) . ',ticket_reply_subj=' . db_input(Format::striptags($var['ticket_reply_subj'])) . ',ticket_reply_body=' . db_input(Format::striptags($var['ticket_reply_body'])) . ' WHERE tpl_id=' . db_input($this->getId());
         if (!db_query($sql) || !db_affected_rows()) {
             $errors['err'] = _('Unable to update. Internal error occured');
         }
     }
     return $errors ? false : true;
 }
开发者ID:jahanzaibbahadur,项目名称:Katak-support,代码行数:45,代码来源:class.msgtpl.php

示例10: formatValidationErrors

 protected function formatValidationErrors(Validator $validator)
 {
     return $validator->errors()->getMessages();
 }
开发者ID:pavhov93,项目名称:blog1,代码行数:4,代码来源:Controller.php

示例11: formatErrors

 /**
  * {@inheritdoc}
  */
 protected function formatErrors(Validator $validator)
 {
     return response()->json(['fail' => true, 'messages' => $validator->errors()->all()], 400);
 }
开发者ID:bluecipherz,项目名称:bczapi,代码行数:7,代码来源:Request.php

示例12: process

 function process($fields, $vars, &$errors)
 {
     $val = new Validator();
     $val->setFields($fields);
     if (!$val->validate($vars)) {
         $errors = array_merge($errors, $val->errors());
     }
     return !$errors;
 }
开发者ID:nicolap,项目名称:osTicket-1.7,代码行数:9,代码来源:class.validator.php

示例13: create

 function create($var, &$errors, $origin, $autorespond = true, $alertstaff = true)
 {
     global $cfg, $thisclient, $_FILES;
     $id = 0;
     $fields = array();
     $fields['name'] = array('type' => 'string', 'required' => 1, 'error' => 'Name required');
     $fields['email'] = array('type' => 'email', 'required' => 1, 'error' => 'Valid email required');
     $fields['subject'] = array('type' => 'string', 'required' => 1, 'error' => 'Subject required');
     $fields['message'] = array('type' => 'text', 'required' => 1, 'error' => 'Message required');
     if (strcasecmp($origin, 'web') == 0) {
         //Help topic only applicable on web tickets.
         $fields['topicId'] = array('type' => 'int', 'required' => 1, 'error' => 'Select help topic');
     } elseif (strcasecmp($origin, 'staff') == 0) {
         //tickets created by staff...e.g on callins.
         $fields['deptId'] = array('type' => 'int', 'required' => 1, 'error' => 'Dept. required');
         $fields['source'] = array('type' => 'string', 'required' => 1, 'error' => 'Indicate source');
     } else {
         //Incoming emails (PIPE or POP.
         $fields['emailId'] = array('type' => 'int', 'required' => 1, 'error' => 'Email unknown');
     }
     $fields['pri'] = array('type' => 'int', 'required' => 0, 'error' => 'Invalid Priority');
     $fields['phone'] = array('type' => 'phone', 'required' => 0, 'error' => 'Phone # required');
     $validate = new Validator($fields);
     if (!$validate->validate($var)) {
         $errors = array_merge($errors, $validate->errors());
     }
     //Make sure the email is not banned
     if (!$errors && BanList::isbanned($var['email'])) {
         $errors['err'] = 'Ticket denied Error #403';
     }
     if (!$errors && $thisclient && strcasecmp($thisclient->getEmail(), $var['email'])) {
         $errors['email'] = 'Email mismatch.';
     }
     //check attachment..if any is set ...only set on webbased tickets..
     if ($_FILES['attachment']['name'] && $cfg->allowOnlineAttachments()) {
         if (!$cfg->canUploadFileType($_FILES['attachment']['name'])) {
             $errors['attachment'] = 'Invalid file type [ ' . $_FILES['attachment']['name'] . ' ]';
         } elseif ($_FILES['attachment']['size'] > $cfg->getMaxFileSize()) {
             $errors['attachment'] = 'File is too big. Max ' . $cfg->getMaxFileSize() . ' bytes allowed';
         }
     }
     //check ticket limits..if limit set is >0
     //TODO: Base ticket limits on SLA...
     if ($var['email'] && !$errors && $cfg->getMaxOpenTickets() > 0) {
         $openTickets = Ticket::getOpenTicketsByEmail($var['email']);
         if ($openTickets >= $cfg->getMaxOpenTickets()) {
             $errors['err'] = "You've reached the maximum open tickets allowed.";
             //Send the notice only once (when the limit is reached) incase of autoresponders at client end.
             if ($cfg->getMaxOpenTickets() == $openTickets && $cfg->sendOverlimitNotice()) {
                 $sql = 'SELECT ticket_overlimit_subj,ticket_overlimit_body FROM ' . EMAIL_TEMPLATE_TABLE . ' WHERE cfg_id=' . db_input($cfg->getId()) . ' AND tpl_id=' . db_input($cfg->getDefaultTemplateId());
                 $resp = db_query($sql);
                 if (db_num_rows($resp) && (list($subj, $body) = db_fetch_row($resp))) {
                     $body = str_replace("%name", $var['name'], $body);
                     $body = str_replace("%email", $var['email'], $body);
                     $body = str_replace("%url", $cfg->getBaseUrl(), $body);
                     Misc::sendmail($var['email'], $subj, $body, $cfg->getNoReplyEmail());
                 }
             }
             //Alert admin...this might be spammy (no option to disable)...but it is helpful..I think.
             $msg = 'Support ticket request denied for ' . $var['email'] . "\n" . 'Open ticket:' . $openTickets . "\n" . 'Max Allowed:' . $cfg->getMaxOpenTickets() . "\n";
             Misc::alertAdmin('Overlimit Notice', $msg);
         }
     }
     //Any error above is fatal.
     if ($errors) {
         return 0;
     }
     // OK...just do it.
     $deptId = $var['deptId'];
     //pre-selected Dept if any.
     $priorityId = $var['pri'];
     $source = ucfirst($var['source']);
     // Intenal mapping magic...see if we need to overwrite anything
     if (isset($var['topicId']) && !$var['deptId']) {
         //Ticket created via web by user
         if ($var['topicId'] && ($topic = new Topic($var['topicId'])) && $topic->getId()) {
             $deptId = $topic->getDeptId();
             $priorityId = $priorityId ? $priorityId : $topic->getPriorityId();
             $autorespond = $topic->autoRespond();
         }
         $topic = null;
         $source = 'Web';
     } elseif ($var['emailId'] && !$var['deptId']) {
         //Emailed Tickets
         $email = new Email($var['emailId']);
         if ($email && $email->getId()) {
             $deptId = $email->getDeptId();
             $autorespond = $email->autoRespond();
             $priorityId = $priorityId ? $priorityId : $email->getPriorityId();
         }
         $email = null;
         $source = 'Email';
     } elseif ($var['deptId']) {
         //Opened by staff.
         $deptId = $var['deptId'];
         $source = ucfirst($var['source']);
     }
     //Last minute checks
     $priorityId = $priorityId ? $priorityId : $cfg->getDefaultPriorityId();
     $deptId = $deptId ? $deptId : $cfg->getDefaultDeptId();
//.........这里部分代码省略.........
开发者ID:googlecode-mirror,项目名称:barbos,代码行数:101,代码来源:class.ticket.php

示例14: updatePref

 function updatePref($var, &$errors)
 {
     if (!$var || $errors) {
         return false;
     }
     $f = array();
     $f['helpdesk_url'] = array('type' => 'string', 'required' => 1, 'error' => 'Helpdesk URl required');
     //TODO: Add url validation
     $f['helpdesk_title'] = array('type' => 'string', 'required' => 1, 'error' => 'Helpdesk title required');
     $f['default_dept'] = array('type' => 'int', 'required' => 1, 'error' => 'Default Dept. required');
     $f['default_email'] = array('type' => 'int', 'required' => 1, 'error' => 'Default email required');
     $f['default_template'] = array('type' => 'int', 'required' => 1, 'error' => 'You must select template.');
     $f['staff_session_timeout'] = array('type' => 'int', 'required' => 1, 'error' => 'Enter idle time in minutes');
     $f['client_session_timeout'] = array('type' => 'int', 'required' => 1, 'error' => 'Enter idle time in minutes');
     $f['time_format'] = array('type' => 'string', 'required' => 1, 'error' => 'Time format required');
     //TODO: Add date format validation
     $f['date_format'] = array('type' => 'string', 'required' => 1, 'error' => 'Date format required');
     $f['datetime_format'] = array('type' => 'string', 'required' => 1, 'error' => 'Datetime format required');
     $f['daydatetime_format'] = array('type' => 'string', 'required' => 1, 'error' => 'Day, Datetime format required');
     $f['noreply_email'] = array('type' => 'email', 'required' => 1, 'error' => 'Valid email required');
     $f['alert_email'] = array('type' => 'email', 'required' => 1, 'error' => 'Valid email required');
     $f['admin_email'] = array('type' => 'email', 'required' => 1, 'error' => 'Valid email required');
     $f['autolock_minutes'] = array('type' => 'int', 'required' => 1, 'error' => 'Enter lock time in minutes');
     //TODO: check option fields for validity.
     //do the validation.
     $val = new Validator();
     $val->setFields($f);
     if (!$val->validate($var)) {
         $errors = array_merge($errors, $val->errors());
     }
     if ($_POST['ticket_alert_active'] && (!isset($_POST['ticket_alert_admin']) && !isset($_POST['ticket_alert_dept_manager']) && !isset($_POST['ticket_alert_dept_members']))) {
         $errors['ticket_alert_active'] = 'No target recipient(s) selected';
     }
     if ($_POST['message_alert_active'] && (!isset($_POST['message_alert_laststaff']) && !isset($_POST['message_alert_assigned']) && !isset($_POST['message_alert_dept_manager']))) {
         $errors['message_alert_active'] = 'No target recipient(s) selected';
     }
     if ($_POST['strip_quoted_reply'] && !$_POST['reply_separator']) {
         $errors['reply_separator'] = 'Reply separator required (?)';
     }
     if ($errors) {
         return false;
     }
     //No go!
     //We are good to go...blanket update!
     $sql = 'UPDATE ' . CONFIG_TABLE . ' SET isonline=' . db_input($var['isonline']) . ',timezone_offset=' . db_input($var['timezone_offset']) . ',enable_daylight_saving=' . db_input(isset($var['enable_daylight_saving']) ? 1 : 0) . ',staff_session_timeout=' . db_input($var['staff_session_timeout']) . ',client_session_timeout=' . db_input($var['client_session_timeout']) . ',max_page_size=' . db_input($var['max_page_size']) . ',max_open_tickets=' . db_input($var['max_open_tickets']) . ',autolock_minutes=' . db_input($var['autolock_minutes']) . ',overdue_grace_period=' . db_input($var['overdue_grace_period']) . ',default_email=' . db_input($var['default_email']) . ',default_dept=' . db_input($var['default_dept']) . ',default_priority=' . db_input($var['default_priority']) . ',default_template=' . db_input($var['default_template']) . ',clickable_urls=' . db_input(isset($var['clickable_urls']) ? 1 : 0) . ',allow_priority_change=' . db_input(isset($var['allow_priority_change']) ? 1 : 0) . ',use_email_priority=' . db_input(isset($var['use_email_priority']) ? 1 : 0) . ',enable_auto_cron=' . db_input(isset($var['enable_auto_cron']) ? 1 : 0) . ',enable_pop3_fetch=' . db_input(isset($var['enable_pop3_fetch']) ? 1 : 0) . ',enable_email_piping=' . db_input(isset($var['enable_email_piping']) ? 1 : 0) . ',send_sql_errors=' . db_input(isset($var['send_sql_errors']) ? 1 : 0) . ',send_mailparse_errors=' . db_input(isset($var['send_mailparse_errors']) ? 1 : 0) . ',send_login_errors=' . db_input(isset($var['send_login_errors']) ? 1 : 0) . ',save_email_headers=' . db_input(isset($var['save_email_headers']) ? 1 : 0) . ',strip_quoted_reply=' . db_input(isset($var['strip_quoted_reply']) ? 1 : 0) . ',email_attachments=' . db_input(isset($var['email_attachments']) ? 1 : 0) . ',ticket_autoresponder=' . db_input($var['ticket_autoresponder']) . ',message_autoresponder=' . db_input($var['message_autoresponder']) . ',ticket_alert_active=' . db_input($var['ticket_alert_active']) . ',ticket_alert_admin=' . db_input(isset($var['ticket_alert_admin']) ? 1 : 0) . ',ticket_alert_dept_manager=' . db_input(isset($var['ticket_alert_dept_manager']) ? 1 : 0) . ',ticket_alert_dept_members=' . db_input(isset($var['ticket_alert_dept_members']) ? 1 : 0) . ',message_alert_active=' . db_input($var['message_alert_active']) . ',message_alert_laststaff=' . db_input(isset($var['message_alert_laststaff']) ? 1 : 0) . ',message_alert_assigned=' . db_input(isset($var['message_alert_assigned']) ? 1 : 0) . ',message_alert_dept_manager=' . db_input(isset($var['message_alert_dept_manager']) ? 1 : 0) . ',overdue_alert_active=' . db_input($var['overdue_alert_active']) . ',overdue_alert_assigned=' . db_input(isset($var['overdue_alert_assigned']) ? 1 : 0) . ',overdue_alert_dept_manager=' . db_input(isset($var['overdue_alert_dept_manager']) ? 1 : 0) . ',overdue_alert_dept_members=' . db_input(isset($var['overdue_alert_dept_members']) ? 1 : 0) . ',auto_assign_reopened_tickets=' . db_input(isset($var['auto_assign_reopened_tickets']) ? 1 : 0) . ',show_assigned_tickets=' . db_input(isset($var['show_assigned_tickets']) ? 1 : 0) . ',overlimit_notice_active=' . db_input(isset($var['overlimit_notice_active']) ? 1 : 0) . ',random_ticket_ids=' . db_input($var['random_ticket_ids']) . ',time_format=' . db_input($var['time_format']) . ',date_format=' . db_input($var['date_format']) . ',datetime_format=' . db_input($var['datetime_format']) . ',daydatetime_format=' . db_input($var['daydatetime_format']) . ',reply_separator=' . db_input($var['reply_separator']) . ',noreply_email=' . db_input($var['noreply_email']) . ',alert_email=' . db_input($var['alert_email']) . ',admin_email=' . db_input($var['admin_email']) . ',helpdesk_title=' . db_input($var['helpdesk_title']) . ',helpdesk_url=' . db_input($var['helpdesk_url']) . ' WHERE id=' . $this->getId();
     //echo $sql;
     return db_query($sql) ? TRUE : FALSE;
 }
开发者ID:googlecode-mirror,项目名称:barbos,代码行数:48,代码来源:class.config.php

示例15: each

 /**
  * Adds a nested validator.
  *
  * Nesting validators allows you to define validators for array
  * types. For example, nested validators are ideal when you want to validate many
  * similar sub-documents or complex array types.
  *
  * This method assumes that the sub-document has a 1:N relationship with the parent.
  *
  * The providers of the parent validator will be synced into the nested validator, when
  * errors are checked. This ensures that any validation rule providers connected
  * in the parent will have the same values in the nested validator when rules are evaluated.
  *
  * @param Validator $validator The nested validator.
  * @return $this
  */
 public function each(Validator $validator)
 {
     $this->add(function ($value) use($validator) {
         if (!is_array($value)) {
             return false;
         }
         $errors = [];
         foreach ($value as $i => $row) {
             $check = $validator->errors($row);
             if (!empty($check)) {
                 $errors[$i] = $check;
             }
         }
         return empty($errors) ? true : $errors;
     });
 }
开发者ID:coretyson,项目名称:coretyson,代码行数:32,代码来源:Field.php


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