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


PHP User_Model::validate方法代码示例

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


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

示例1: create

 public function create()
 {
     $this->template->content = new View('users/create');
     $form = new Validation($_POST);
     $form->pre_filter('trim', true);
     $form->add_rules('username', 'required')->add_rules('password', 'required')->add_rules('email', 'required', 'valid::email');
     $this->template->content->repopulate = $form;
     if ($form->validate()) {
         // Create new user
         $user = new User_Model();
         if (!$user->username_exists($this->input->post('username'))) {
             foreach ($form->as_array() as $key => $val) {
                 // Set user data
                 $user->{$key} = $val;
             }
             if ($user->validate($form->as_array())) {
                 if ($user->add(ORM::factory('role', 'login')) and $user->save()) {
                     // Redirect to the login page
                     url::redirect('login');
                 }
             }
         }
     }
     // Error
     $this->template->content->error = $form->errors('login');
 }
开发者ID:carriercomm,项目名称:billing_cart,代码行数:26,代码来源:login.php

示例2: _edit

 /**
  * Edit basic info
  */
 public function _edit()
 {
     $this->tab_id = 'profile';
     $this->history = false;
     // only owner or admin
     if ($this->member->id !== $this->user->id && !$this->visitor->logged_in('admin')) {
         url::back('members');
     }
     $form_errors = array();
     $form_values = $this->member->as_array();
     // check post
     if (request::method() == 'post') {
         $post = array_merge($this->input->post(), $_FILES);
         $extra = array();
         // location
         if (empty($post['address_street']) && empty($post['address_city'])) {
             // empty address, clear location
             $extra['latitude'] = 0;
             $extra['longitude'] = 0;
         } else {
             if ($post['address_street'] != $this->member->address_street || $post['address_city'] != $this->member->address_city) {
                 // update location
                 list($extra['latitude'], $extra['longitude']) = Gmap::address_to_ll(implode(', ', array($post['address_street'], $post['address_zip'], $post['address_city'])));
             }
         }
         if ($this->member->validate($post, true, $extra)) {
             // handle picture upload
             if (isset($post->image) && empty($post->image['error'])) {
                 $image = Image_Model::factory('members.image', $post->image, $this->member->id);
                 if ($image->id) {
                     $this->member->add($image);
                     $this->member->default_image_id = $image->id;
                     $this->member->save();
                 }
             }
             url::redirect(url::user($this->member));
         } else {
             $form_errors = $post->errors();
         }
         $form_values = arr::overwrite($form_values, $post->as_array());
     }
     // City autocomplete
     $this->_autocomplete_city('address_city');
     // Date pickers
     widget::add('footer', html::script_source("\$('input#dob').datepicker({ dateFormat: 'd.m.yy', firstDay: 1, changeFirstDay: false, showOtherMonths: true, showStatus: true, showOn: 'both', minDate: '-60Y', maxDate: 0 });"));
     if (empty($errors)) {
         widget::add('main', View::factory('member/info_edit', array('values' => $form_values, 'errors' => $form_errors)));
     } else {
         $this->_error(Kohana::lang('generic.error'), $errors);
     }
     $this->_side_views();
 }
开发者ID:anqqa,项目名称:Anqh,代码行数:55,代码来源:member.php

示例3: _join

 /**
  * Register with code
  *
  * @param  Invitation_Model  $invitation
  */
 public function _join(Invitation_Model $invitation)
 {
     $this->history = false;
     $user = new User_Model();
     $form_values = $user->as_array();
     $form_errors = array();
     // handle post
     if (request::method() == 'post') {
         $post = $this->input->post();
         $post['email'] = $invitation->email;
         $post['username_clean'] = utf8::clean($post['username']);
         if ($user->validate($post, false, null, null, array('rules' => 'register', 'callbacks' => 'register'))) {
             $invitation->delete();
             $user->add(ORM::factory('role', 'login'));
             $user->save();
             $this->visitor->login($user, $post->password);
             url::back();
         } else {
             $form_errors = $post->errors();
             $form_values = arr::overwrite($form_values, $post->as_array());
         }
     }
     widget::add('main', View::factory('member/signup', array('values' => $form_values, 'errors' => $form_errors, 'invitation' => $invitation)));
 }
开发者ID:anqqa,项目名称:Anqh,代码行数:29,代码来源:sign.php


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