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


PHP validate::setFieldError方法代码示例

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


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

示例1: _doLogin

 protected function _doLogin()
 {
     $rules = array('email' => array('label' => __('email', 'users'), 'rules' => array('trim', 'required', 'max_length' => 255, 'callback__is_valid_login')), 'password' => array('label' => __('password', 'users'), 'rules' => array('trim', 'required', 'min_length' => 4, 'max_length' => 128)), 'remember' => array('label' => __('remember_me', 'users')));
     if (uri::segment(4) == 'license' && !input::demo(0, '', false)) {
         $rules['license'] = array('label' => __('license_new', 'system_license'), 'rules' => array('trim', 'required', 'callback__is_valid_license'));
     }
     validate::setRules($rules);
     if (!validate::run()) {
         return false;
     }
     if (!($user = $this->users_model->getUser(input::post('email'), false, false))) {
         validate::setFieldError('email', __((strpos(input::post('email'), '@') === false ? 'username' : 'email') . '_invalid', 'users_signup'));
         return false;
     }
     if (!$this->users_model->verifyPassword(input::post('password'), $user['password'], $user['user_id'])) {
         validate::setFieldError('password', __('password_invalid', 'users_signup'));
         return false;
     }
     if (uri::segment(4) == 'license' && !input::demo(0, '', false)) {
         $access = $this->users_model->getPermissions($user['group_id'], 'system', 'license_manage');
         if ($access) {
             loader::model('system/license');
             $this->license_model->changeLicense(input::post('license'));
         }
     }
     $this->users_model->login($user['user_id'], input::post('remember'), $user);
     if (uri::segment(4) == 'license') {
         router::redirect('cp/help/license');
     } else {
         router::redirect('cp');
     }
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:32,代码来源:users.php

示例2: _savePage

 protected function _savePage($pageID, $parentID, $page, $fields, $options, $trail)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Extra rules
     $rules = array();
     foreach ($options as $option) {
         if (isset($option['rules'])) {
             $rules[$option['keyword']] = array('label' => $option['name'], 'rules' => $option['rules']);
         }
     }
     $rules['keyword'] = array('label' => __('keyword', 'system'), 'rules' => array('trim', 'required', 'max_length' => 128, 'callback__is_valid_keyword' => array($parentID, $pageID)));
     // Validate form values
     if (!$this->fields_model->validateValues($fields, $rules)) {
         return false;
     }
     // Did keyword change?
     if ($pageID && $page['system'] && strcmp($page['keyword'], input::post('keyword'))) {
         validate::setFieldError('keyword', __('page_system_rename', 'pages'));
         return false;
     }
     // Extras
     $extra = array();
     $extra['parent_id'] = $parentID;
     $extra['location'] = ($trail ? implode('/', $trail) . '/' : '') . input::post('keyword');
     $extra['keyword'] = input::post('keyword');
     $extra['file_name'] = input::post('file_name');
     $extra['comments'] = config::item('page_comments', 'pages') ? (int) input::post('comments') : 1;
     $extra['likes'] = config::item('page_rating', 'pages') == 'likes' ? (int) input::post('likes') : 1;
     $extra['votes'] = config::item('page_rating', 'pages') == 'stars' ? (int) input::post('votes') : 1;
     $extra['trail'] = (int) input::post('trail');
     $extra['active'] = (int) input::post('active');
     // Save page
     if (!($pageID = $this->pages_model->savePageData($pageID, $parentID, $page, $fields, $extra))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('page_saved', 'pages'));
     router::redirect('cp/content/pages/edit/' . $parentID . '/' . $pageID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:45,代码来源:pages.php

示例3: _resendHash

 protected function _resendHash()
 {
     // Create rules
     $rules = array('email' => array('label' => 'email', 'rules' => array('trim', 'required', 'max_length' => 255, 'valid_email')));
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Does user exist?
     if (!($user = $this->users_model->getUser(input::post('email')))) {
         validate::setFieldError('email', __('email_invalid', 'users_signup'));
         return false;
     }
     // Is user's email already verified?
     if ($user['verified']) {
         view::setError(__('user_already_verified', 'users_signup'));
         return false;
     }
     // Loader
     loader::library('email');
     loader::model('system/requests');
     // Is this a recent request?
     if ($this->requests_model->isRecentRequest('signup', $user['user_id'], 0, 5)) {
         // Success
         view::setError(__('request_recent_sendhash', 'users_signup'));
         return false;
     }
     // Save resend hash request
     $hash = $this->requests_model->saveRequest('signup', $user['user_id']);
     $user['security_hash'] = $hash;
     $user['activation_link'] = config::siteURL('users/signup/confirm/' . $user['user_id'] . '/' . $hash);
     // Send activation email
     $this->email->sendTemplate('users_account_confirm', $user['email'], $user, $user['language_id']);
     // Success
     view::setInfo(__('confirm_email', 'users_signup'));
     router::redirect('users/login/index/verify');
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:39,代码来源:login.php

示例4: _saveField

 protected function _saveField($plugin, $table, $categoryID, $fieldID, $fieldOld, $configs, $hidden)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Rules array
     $rules = array();
     // Data array
     $inputData = array('keyword', 'type', 'style', 'class', 'required', 'system', 'multilang');
     // Name
     foreach (config::item('languages', 'core', 'keywords') as $languageID => $lang) {
         $rules['name_' . $lang] = array('label' => __('name', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'required', 'max_length' => 255));
         $rules['vname_' . $lang] = array('label' => __('name_view', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'max_length' => 255));
         $rules['sname_' . $lang] = array('label' => __('name_search', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'max_length' => 255));
         $rules['validate_error_' . $lang] = array('label' => __('validate_error', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'max_length' => 255));
         $inputData[] = 'name_' . $lang;
         $inputData[] = 'vname_' . $lang;
         $inputData[] = 'sname_' . $lang;
         $inputData[] = 'validate_error_' . $lang;
     }
     // Keyword
     $rules['keyword'] = array('label' => __('keyword', 'system'), 'rules' => array('trim', 'required', 'alpha_dash', 'max_length' => 128, 'callback__is_unique_keyword' => array($plugin, $categoryID, $fieldID), 'callback__is_system_field' => array($fieldID ? $fieldOld['keyword'] : '', $fieldID ? $fieldOld['system'] : '')));
     // Type
     $rules['type'] = array('label' => __('field_type', 'system_fields'), 'rules' => array('required', 'callback__is_system_field' => array($fieldID ? $fieldOld['type'] : '', $fieldID ? $fieldOld['system'] : '')));
     // Style value
     $rules['style'] = array('label' => __('style', 'system_fields'), 'rules' => array('trim'));
     // Class value
     $rules['class'] = array('label' => __('class', 'system_fields'), 'rules' => array('trim'));
     // Required
     $rules['required'] = array('label' => __('required', 'system_fields'), 'rules' => array('intval'));
     // Regular expression
     $rules['validate'] = array('label' => __('validate', 'system_fields'), 'rules' => array('trim'));
     $inputData[] = 'validate';
     // Configuration array
     $inputConfig = array();
     foreach (array('custom', input::post('type')) as $conf) {
         if (isset($configs[$conf])) {
             foreach ($configs[$conf] as $option) {
                 $rules['config_' . $conf . '_' . $option['keyword']] = array('label' => utf8::strtolower($option['label']), 'rules' => isset($option['rules']) ? $option['rules'] : array());
                 $inputConfig[$option['keyword']] = 'config_' . $conf . '_' . $option['keyword'];
             }
         }
     }
     // Add items rules
     $items = array();
     $oldItems = $fieldID ? $fieldOld['items'] : array();
     if ($this->fields_model->isMultiValue(input::post('type'))) {
         $itemsPost = input::post('items');
         $sitemsPost = input::post('sitems');
         foreach (config::item('languages', 'core', 'keywords') as $languageID => $lang) {
             $orderID = 1;
             if (isset($itemsPost[$lang]) && is_array($itemsPost[$lang])) {
                 foreach ($itemsPost[$lang] as $itemID => $itemName) {
                     // Trim name
                     $itemName = utf8::trim($itemName);
                     // Assign item data
                     $items[$itemID]['order_id'] = $orderID;
                     $items[$itemID]['name_' . $lang] = $itemName;
                     $items[$itemID]['sname_' . $lang] = $sitemsPost[$lang][$itemID];
                     $orderID++;
                     // Add rule
                     $rules['items[' . $lang . '][' . $itemID . ']'] = array();
                     if ($itemName == '') {
                         validate::setRule('items', '', '');
                         validate::setFieldError('items', __('empty_item', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''));
                     }
                 }
             }
         }
         if (!$items) {
             validate::setRule('items', '', '');
             validate::setFieldError('items', __('no_items', 'system_fields'));
         }
         view::assign(array('field' => array('items' => $items)));
     }
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get post data
     $fieldData = input::post($inputData);
     // Default data
     $fieldData['system'] = isset($hidden['system']) ? $hidden['system'] : 0;
     $fieldData['multilang'] = isset($hidden['multilang']) ? $hidden['multilang'] : 0;
     // Get config data
     $fieldData['config'] = array();
     foreach ($inputConfig as $key => $val) {
         $fieldData['config'][$key] = input::post($val);
     }
     // Set additional config data
     $fieldData['config']['html'] = input::post('html') ? 1 : 0;
     $fieldData['config']['in_search'] = input::post('in_search') ? 1 : 0;
     $fieldData['config']['in_search_advanced'] = input::post('in_search_advanced') ? 1 : 0;
     if ($fieldData['config']['in_search'] || $fieldData['config']['in_search_advanced']) {
         $fieldData['config']['search_options'] = input::post('search_options') ? input::post('search_options') : '';
     }
     if (input::post('type') == 'checkbox' || input::post('search_options') == 'multiple') {
//.........这里部分代码省略.........
开发者ID:soremi,项目名称:tutornavi,代码行数:101,代码来源:system.php

示例5: _uploadPicture

 protected function _uploadPicture()
 {
     // Create rules
     $rules = array('file' => array('label' => __('file_select', 'system_files'), 'rules' => array('required_file' => 'file')));
     // Assign rules
     validate::setRules($rules);
     // Validate form values
     if (!validate::run()) {
         return false;
     }
     // Thumbnails config
     $thumbs = array(array('suffix' => 'x'), array('dimensions' => config::item('picture_dimensions', 'users'), 'method' => 'preserve', 'suffix' => ''), array('dimensions' => config::item('picture_dimensions_p', 'users'), 'method' => 'crop', 'suffix' => 'p'), array('dimensions' => config::item('picture_dimensions_l', 'users'), 'method' => 'crop', 'suffix' => 'l'), array('dimensions' => config::item('picture_dimensions_t', 'users'), 'method' => 'crop', 'suffix' => 't'));
     // Upload picture
     if (!($fileID = $this->storage_model->upload('user', session::item('user_id'), 'file', 'jpg|jpeg|gif|png', config::item('picture_max_size', 'users'), config::item('picture_dimensions_max', 'users'), $thumbs))) {
         if (input::isAjaxRequest()) {
             view::ajaxError(config::item('devmode', 'system') ? $this->storage_model->getError() : __('file_upload_error', 'system_files'));
         } else {
             validate::setFieldError('file', config::item('devmode', 'system') ? $this->storage_model->getError() : __('file_upload_error', 'system_files'));
         }
         return false;
     }
     // Delete old picture if it exists
     if (session::item('picture_id')) {
         // Delete picture
         $this->users_model->deletePicture(session::item('user_id'), session::item('picture_id'), false);
     }
     // Save new picture ID
     if (!$this->users_model->savePicture(session::item('user_id'), $fileID)) {
         if (input::isAjaxRequest()) {
             view::ajaxError(__('save_error', 'system'));
         } else {
             validate::setFieldError('file', __('save_error', 'system'));
             return false;
         }
     }
     // Was this an ajax request?
     if (input::isAjaxRequest()) {
         view::ajaxResponse(array('redirect' => html_helper::siteURL(session::item('slug'))));
     }
     // Success
     view::setInfo(__('picture_uploaded', 'users_picture'));
     router::redirect(session::item('slug'));
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:43,代码来源:profile.php

示例6: _uploadPicture

 protected function _uploadPicture($adID, $ad)
 {
     // Create rules
     $rules = array('file' => array('label' => __('file_select', 'system_files'), 'rules' => array('required_file' => 'file')));
     // Assign rules
     validate::setRules($rules);
     // Validate form values
     if (!validate::run()) {
         return false;
     }
     // Thumbnails config
     $thumbs = array(array('suffix' => 'x'), array('dimensions' => config::item('picture_dimensions', 'classifieds'), 'method' => 'preserve', 'suffix' => ''), array('dimensions' => config::item('picture_dimensions_t', 'classifieds'), 'method' => 'crop', 'suffix' => 't'));
     // Upload picture
     if (!($fileID = $this->storage_model->upload('classified_picture', session::item('user_id'), 'file', 'jpg|jpeg|gif|png', config::item('picture_max_size', 'classifieds'), config::item('picture_dimensions_max', 'classifieds'), $thumbs))) {
         if (input::isAjaxRequest()) {
             view::ajaxError(config::item('devmode', 'system') ? $this->storage_model->getError() : __('file_upload_error', 'system_files'));
         } else {
             validate::setFieldError('file', config::item('devmode', 'system') ? $this->storage_model->getError() : __('file_upload_error', 'system_files'));
             return false;
         }
     }
     // Extras
     $extra = array();
     // Save picture file
     if (!($pictureID = $this->classifieds_pictures_model->savePictureFile($fileID, $adID, $ad, $extra))) {
         if (input::isAjaxRequest()) {
             view::ajaxError(__('save_error', 'system'));
         } else {
             validate::setFieldError('file', __('save_error', 'system'));
             return false;
         }
     }
     // Update current album counters
     $ad[session::permission('pictures_approve', 'classifieds') ? 'total_pictures' : 'total_pictures_i']++;
     // Update album's modification date
     $this->classifieds_model->updateModifyDate($adID);
     // Was this an ajax request?
     if (input::isAjaxRequest()) {
         //view::ajaxResponse(__('picture_uploaded', 'pictures'));
         view::ajaxResponse(array('redirect' => html_helper::siteURL('classifieds/pictures/index/' . $adID)));
     }
     // Success
     view::setInfo(__('picture_uploaded', 'classifieds'));
     router::redirect('classifieds/pictures/index/' . $adID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:45,代码来源:pictures.php

示例7: _createUser

 protected function _createUser()
 {
     // Verify email and username one more time
     if (!$this->_is_unique_email(session::item('account', 'signup', 'email'))) {
         view::setError(__('email_duplicate', 'users_signup'));
         router::redirect('users/signup');
     } elseif (config::item('user_username', 'users') && !$this->_is_valid_username(session::item('account', 'signup', 'username'))) {
         view::setError(__('duplicate_username', 'users_signup'));
         router::redirect('users/signup');
     }
     // Get user data
     $user = array('email' => session::item('account', 'signup', 'email'), 'password' => session::item('account', 'signup', 'password') ? session::item('account', 'signup', 'password') : '', 'username' => session::item('account', 'signup', 'username'), 'type_id' => count(config::item('usertypes', 'core', 'names')) > 1 ? session::item('account', 'signup', 'type_id') : config::item('type_default_id', 'users'), 'group_id' => config::item('group_default_id', 'users'), 'verified' => config::item('signup_email_verify', 'users') && !session::item('connection', 'remote_connect') ? 0 : 1, 'active' => config::item('signup_admin_verify', 'users') ? 0 : 1, 'picture_id' => session::item('picture', 'signup', 'file_id') ? session::item('picture', 'signup', 'file_id') : 0, 'picture_active' => session::item('picture', 'signup', 'file_id') ? config::item('signup_picture_verify', 'users') ? 9 : 1 : 0, 'picture_date' => date_helper::now());
     // Set names
     $user['name1'] = session::item('profile', 'signup', 'data_' . config::item('usertypes', 'core', 'fields', $user['type_id'], 1));
     $user['name2'] = session::item('profile', 'signup', 'data_' . config::item('usertypes', 'core', 'fields', $user['type_id'], 2));
     $user['name1'] = $user['name1'] ? $user['name1'] : '';
     $user['name2'] = $user['name2'] ? $user['name2'] : '';
     // Get fields
     $fields = $this->fields_model->getFields('users', $user['type_id'], 'edit', 'in_signup');
     // Save user
     $userID = $this->users_model->saveUser(0, $user);
     // Save profile
     if (session::item('profile', 'signup')) {
         $this->users_model->saveProfile($userID, $user['type_id'], session::item('profile', 'signup'), $fields, array(), true);
     }
     // Did user upload a picture?
     if (session::item('picture', 'signup', 'file_id')) {
         // Update file's user ID
         $this->storage_model->updateUserID(session::item('picture', 'signup', 'file_id'), $userID, 5);
     }
     // Are we signing up using a third party site?
     $remoteconn = false;
     if (session::item('connection', 'remote_connect')) {
         $remoteconn = true;
         loader::library('authentication/' . session::item('connection', 'remote_connect', 'name'));
         $this->{session::item('connection', 'remote_connect', 'name')}->saveToken($userID);
         // Remove temporary session values
         session::delete('', 'remote_connect');
     }
     // Remove temporary session values
     session::delete('', 'signup');
     // Do we need to verify email address?
     if (config::item('signup_email_verify', 'users') && !$remoteconn) {
         // Get user data
         if (!($user = $this->users_model->getUser($userID))) {
             validate::setFieldError('email', __('email_invalid', 'users_signup'));
             return false;
         }
         // Save signup request
         $hash = $this->requests_model->saveRequest('signup', $userID);
         $user['security_hash'] = $hash;
         $user['activation_link'] = config::siteURL('users/signup/confirm/' . $userID . '/' . $hash);
         // Send activation email
         $this->email->sendTemplate('users_account_confirm', $user['email'], $user, $user['language_id']);
         // Success
         view::setInfo(__('confirm_email', 'users_signup'));
         router::redirect('users/login/index/verify');
     } elseif (config::item('signup_admin_verify', 'users')) {
         // Success
         view::setInfo(__('confirm_user', 'users_signup'));
         router::redirect('users/login/index/approve');
     } else {
         // Do we need to send welcome email?
         if (config::item('signup_email_welcome', 'users')) {
             // Get user data
             if (!($user = $this->users_model->getUser($userID))) {
                 validate::setFieldError('email', __('email_invalid', 'users_signup'));
                 return false;
             }
             // Send welcome email
             $this->email->sendTemplate('users_account_welcome', $user['email'], $user, $user['language_id']);
         }
         // Login user
         // $this->users_model->login($userID);
         // Success
         view::setInfo(__('user_registered', 'users_signup'));
         view::load('users/signup/registration_finish');
         // router::redirect(session::item('slug'));
     }
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:80,代码来源:signup.php


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