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


PHP Model_User::validate方法代码示例

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


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

示例1: action_repass

 public function action_repass($onepass)
 {
     if (!Model_User::count(array('where' => array('onepass' => $onepass)))) {
         Response::redirect('user/login/without');
     }
     if (Input::method() == 'POST') {
         $val = Model_User::validate('repass');
         $val->add_field('email', 'Eメール', 'required|valid_email');
         if ($val->run()) {
             $user = Model_User::find('first', array('where' => array('onepass' => $onepass)));
             $last_login = mb_substr($user['last_login'], -4);
             $reset = Input::post('reset');
             if ($last_login == $reset) {
                 $username = Input::post('username');
                 $email = Input::post('email');
                 $password = Input::post('password');
                 if ($username == $user['username'] && $email == $user['email']) {
                     $user->onepass = md5(time());
                     $user->save();
                     $auth = Auth::instance();
                     $old = $auth->reset_password($username);
                     $auth->change_password($old, $password, $username);
                     Response::redirect('user/login');
                 } else {
                     Session::set_flash('na', '<p><span class="alert-error">該当者がいません</span></p>');
                 }
             } else {
                 Session::set_flash('error', "<p>" . $val->show_errors() . "</p>");
             }
         }
         return Model_User::theme('admin/template', 'user/login/repass');
     }
 }
开发者ID:amemiya0222,项目名称:soccer_antena,代码行数:33,代码来源:login.php

示例2: action_edit

 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('user');
     if (!($user = Model_User::find($id))) {
         Session::set_flash('error', 'Could not find user #' . $id);
         Response::redirect('user');
     }
     $val = Model_User::validate('edit');
     if ($val->run()) {
         $user->id = Input::post('id');
         $user->password = Input::post('password');
         $user->name = Input::post('name');
         $user->sex = Input::post('sex');
         $user->birth_station_id = Input::post('birth_station_id');
         if ($user->save()) {
             Session::set_flash('success', 'Updated user #' . $id);
             Response::redirect('user');
         } else {
             Session::set_flash('error', 'Could not update user #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $user->id = $val->validated('id');
             $user->password = $val->validated('password');
             $user->name = $val->validated('name');
             $user->sex = $val->validated('sex');
             $user->birth_station_id = $val->validated('birth_station_id');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('user', $user, false);
     }
     $this->template->title = "Users";
     $this->template->content = View::forge('user/edit');
 }
开发者ID:NoguHiro,项目名称:metro,代码行数:34,代码来源:user.php

示例3: action_create

 public function action_create()
 {
     if (Input::method() == 'POST') {
         $val = Model_User::validate('create');
         $val->add_field('email', 'Eメール', 'required|valid_email');
         if ($val->run()) {
             $username = Input::post('username');
             $email = Input::post('email');
             $password = Input::post('password');
             $group = -1;
             //bannedの設定
             //重複の確認
             $username_count = Model_User::count(array('where' => array(array('username' => $username))));
             $email_count = Model_User::count(array('where' => array(array('email' => $email))));
             if ($username_count > 0) {
                 Session::set_flash('error', 'ユーザー名が重複しています');
                 Response::redirect('user/create');
                 //Eメールアドレスが重複していたら
             } else {
                 if ($email_count > 0) {
                     Session::set_flash('error', 'Eメールアドレスが重複しています');
                     Response::redirect('user/create');
                 }
             }
             $auth = Auth::instance();
             if ($auth->create_user($username, $password, $email, $group)) {
                 $created = Model_User::find('first', array('where' => array('email' => $email)))->created_at;
                 //メール本文の作成
                 $body = '<h2>ようこそameken.comへ</h2>';
                 $body .= '<p>ameken.comへの新規登録ありがとうございます。';
                 $body .= '登録が完全に行われるようにアクティベートをお願いします。</p>';
                 $body .= '<p>アクティベートするには下記のリンクをクリックしてください。</p';
                 $body .= '<p>' . Html::anchor('user/activate/' . $email . '/' . $created, '登録完了(アクティベート)') . '</p>';
                 $body .= '<p>48時間内にアクティベートを完了させて下さい。';
                 $body .= 'そうでなければ、登録は無効になり、再登録する必要があります。</p>';
                 $body .= '<p>あなたのお名前 :';
                 $body .= $username . '</p>';
                 $body .= '<p>あなたのEメール :';
                 $body .= $email . '</p>';
                 //Eメールのインスタンス化
                 $sendmail = Email::forge();
                 //メール情報の設定
                 $sendmail->from('amemiya@ameken.com', 'ameken.com');
                 $sendmail->to($email, $username);
                 $sendmail->subject('アクティベート');
                 $sendmail->html_body($body);
                 //メールの送信
                 $sendmail->send();
                 //登録成功のメッセージ
                 Session::set_flash('success', '<span class="btn btn-primay span8">「' . $username . '」を仮登録しました</span><br>');
                 Response::redirect('user/provisional');
             } else {
                 Session::set_flash('error', '登録されませんでした');
             }
         }
         Session::set_flash('error', $val->show_errors());
     }
     return Model_User::theme('admin/template', 'user/create');
 }
开发者ID:amemiya0222,项目名称:soccer_antena,代码行数:59,代码来源:cp_user.php

示例4: action_edit

 public function action_edit($id = null)
 {
     if (Model_User::is_current_user('teacher')) {
         Response::redirect('site/404');
     }
     $user = Model_User::find('first', ['where' => ['id' => $id]]);
     if (empty($user)) {
         Session::set_flash('error', 'User does not exist.');
         Response::redirect('site/users');
     }
     $val = Model_User::validate('edit', $user);
     // Make sure email is not overwritten
     if ($val->run()) {
         // $user->username = Input::post('username');
         if ($user->password != Input::post('password')) {
             $user->password = Auth::instance()->hash_password(Input::post('password'));
         }
         $user->group = Input::post('group');
         // $user->email = Input::post('email');
         $user->fname = Input::post('fname');
         $user->mname = Input::post('mname');
         $user->lname = Input::post('lname');
         $user->contact_num = Input::post('contact_num');
         $user->address = Input::post('address');
         $user->profile_pic = Input::post('profile_pic');
         $user->last_login = Input::post('last_login');
         $user->login_hash = Input::post('login_hash');
         $user->profile_fields = Input::post('profile_fields');
         if ($user->save()) {
             Session::set_flash('success', e('Updated user #' . $id));
             Response::redirect('site/users');
         } else {
             Session::set_flash('error', e('Could not update user #' . $id));
         }
     } else {
         if (Input::method() == 'POST') {
             // $user->username = $val->validated('username');
             $user->password = $val->validated('password');
             $user->group = $val->validated('group');
             // $user->email = $val->validated('email');
             $user->fname = $val->validated('fname');
             $user->mname = $val->validated('mname');
             $user->lname = $val->validated('lname');
             $user->contact_num = $val->validated('contact_num');
             $user->address = $val->validated('address');
             $user->profile_pic = $val->validated('profile_pic');
             $user->last_login = $val->validated('last_login');
             $user->login_hash = $val->validated('login_hash');
             $user->profile_fields = $val->validated('profile_fields');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('user', $user, false);
     }
     $this->template->title = "Users";
     $this->template->content = View::forge('site/users/edit');
 }
开发者ID:xXLXx,项目名称:ddc,代码行数:56,代码来源:users.php

示例5: action_edit

 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('user');
     $this->theme->set_template('edit');
     $this->theme->get_template()->set_global('current_menu', "Users", false);
     $this->theme->get_template()->set_global('current_menu_desc', "จัดการผู้ใช้งาน CMS ทั้งหมดในระบบ", false);
     $this->theme->get_template()->set('breadcrumb', array(array('title' => "Home", 'icon' => "fa-home", 'link' => Uri::create('home'), 'active' => false), array('title' => "Users", 'icon' => "fa-users", 'link' => Uri::create('user/index'), 'active' => false), array('title' => "Edit", 'icon' => "", 'link' => "", 'active' => true)));
     if (!($user = Model_User::find($id))) {
         Session::set_flash('error', 'Could not find user #' . $id);
         Response::redirect('user');
     }
     $val = Model_User::validate('edit');
     if (strlen(Input::post('password'))) {
         $val->add_field('password', 'Password', 'required|min_length[8]|max_length[20]');
         $val->add_field('password_re', 'Re-type Password', 'required|min_length[8]|max_length[20]');
     }
     $val->set_message('required', 'The field :label is required.');
     if ($val->run()) {
         if (strlen(Input::post('password')) && Input::post('password') != Input::post('password_re')) {
             Session::set_flash('error', 'Password is not matched.');
         } else {
             $user->username = Input::post('username');
             if (strlen(Input::post('password'))) {
                 $user->password = Auth::instance()->hash_password(Input::post('password'));
             }
             $user->group = Input::post('group');
             $user->email = Input::post('email');
             $user->profile_fields = Input::post('profile_fields');
             $user->last_login = Input::post('last_login');
             $user->login_hash = Input::post('login_hash');
             if ($user->save()) {
                 Session::set_flash('success', 'Updated user #' . $id);
                 Response::redirect('user');
             } else {
                 Session::set_flash('error', 'Could not update user #' . $id);
             }
         }
     } else {
         if (Input::method() == 'POST') {
             $user->username = $val->validated('username');
             $user->password = $val->validated('password');
             $user->email = $val->validated('email');
             $msg = '<ul>';
             foreach ($val->error() as $field => $error) {
                 $msg .= '<li>' . $error->get_message() . '</li>';
             }
             $msg .= '</ul>';
             Session::set_flash('error', $msg);
         }
         $this->theme->get_template()->set_global('user', $user, false);
     }
     $this->theme->get_template()->set_global('menu', "edit", false);
     $this->theme->set_partial('sidebar', 'common/sidebar');
     $this->theme->set_partial('left', 'user/edit');
 }
开发者ID:ksakuntanak,项目名称:buffohero_cms,代码行数:55,代码来源:user.php

示例6: action_edit

 public function action_edit($id = null)
 {
     $user = Model_User::find($id);
     $val = Model_User::validate('edit');
     if ($val->run()) {
         $user->username = Input::post('username');
         //			$user->password = Input::post('password');
         $user->email = Input::post('email');
         //			$user->last_login = Input::post('last_login');
         //			$user->login_hash = Input::post('login_hash');
         $user->group = Input::post('group');
         //			$user->profile_fields = Input::post('profile_fields');
         //			$user->guid = Input::post('guid');
         //			$user->shop_guid = Input::post('shop_guid');
         $user->description = Input::post('description');
         $user->id_number = Input::post('id_number');
         $user->employee_number = Input::post('employee_number');
         $user->date_of_birth = Input::post('date_of_birth');
         $user->user_type_id = Input::post('user_type_id');
         $user->access_options = Input::post('access_options');
         $user->phone = Input::post('phone');
         if ($user->save()) {
             Session::set_flash('success', e('Updated user #' . $id));
             Response::redirect('admin/users');
         } else {
             Session::set_flash('error', e('Could not update user #' . $id));
         }
     } else {
         if (Input::method() == 'POST') {
             $user->username = $val->validated('username');
             $user->password = $val->validated('password');
             $user->email = $val->validated('email');
             $user->last_login = $val->validated('last_login');
             $user->login_hash = $val->validated('login_hash');
             $user->group = $val->validated('group');
             $user->profile_fields = $val->validated('profile_fields');
             $user->guid = $val->validated('guid');
             $user->shop_guid = $val->validated('shop_guid');
             $user->description = $val->validated('description');
             $user->id_number = $val->validated('id_number');
             $user->employee_number = $val->validated('employee_number');
             $user->date_of_birth = $val->validated('date_of_birth');
             $user->user_type_id = $val->validated('user_type_id');
             $user->access_options = $val->validated('access_options');
             $user->phone = $val->validated('phone');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('user', $user, false);
     }
     $this->template->set_global('user_types', Model_User_Type::find('all', array('order_by' => array(array('name', 'asc')))));
     $this->template->set_global('groups', $this->get_groups());
     $this->template->title = "Users";
     $this->template->content = View::forge('admin/users/edit');
 }
开发者ID:AfterCursor,项目名称:restaurant-pos-backend,代码行数:54,代码来源:users.php

示例7: action_edit

 /**
  * Редактирование пользователя
  * 
  * @param integer $id id пользователя
  */
 public function action_edit($id = null)
 {
     is_null($id) and \Response::redirect('admin/users');
     $user = \Model_User::find($id);
     if (!empty($user)) {
         if (\Input::method() == 'POST') {
             $val = \Model_User::validate('edit');
             // Если ихменили E-Mail
             if (\Input::post('email') != $user->email) {
                 $val->add_callable(new \MyRules());
                 $val->add_field('email', 'E-Mail', 'required|max_length[255]|unique[users.email]');
                 $val->set_message('unique', 'E-Mail существует.');
             }
             if ($val->run()) {
                 try {
                     // Сбрасіваем пароль
                     $new_password = \Auth::reset_password($user->username);
                     $arr = array('email' => \Input::post('email'));
                     if (trim(\Input::post('password') != '')) {
                         $arr['old_password'] = $new_password;
                         $arr['password'] = \Input::post('password');
                     }
                     $updated = \Auth::update_user($arr, $user->username);
                     if ($updated) {
                         \Session::set_flash('success', e('Пользователь отредактирован'));
                         \Response::redirect_back('admin/users');
                     } else {
                         // oops, creating a new user failed?
                         \Session::set_flash('error', e('Не удалось отредактировать данные пользователя'));
                     }
                 } catch (\SimpleUserUpdateException $e) {
                     // Повтор е-мэил
                     if ($e->getCode() == 2) {
                         \Session::set_flash('error', e('E-Mail существует'));
                     } else {
                         \Session::set_flash('error', $e->getMessage());
                     }
                 }
             } else {
                 \Session::set_flash('error', $val->error());
             }
         }
         \View::set_global('user', $user, FALSE);
         $this->template->title = 'Пользователи';
         $this->template->content = \View::forge('users/edit');
     } else {
         \Session::set_flash('error', e('Пользователь отсутствует'));
         \Response::redirect('admin/users');
     }
 }
开发者ID:alexmon1989,项目名称:fcssadon.ru,代码行数:55,代码来源:users.php

示例8: action_edit

 public function action_edit($id = null)
 {
     if (\Fuel\Core\Input::method() == 'POST') {
         $id = \Fuel\Core\Input::post('id');
     }
     if (!($user = Model_User::find($id))) {
         \Fuel\Core\Session::set_flash('error', 'Could not find user # ' . $id);
         \Fuel\Core\Response::redirect('admin/users');
     }
     $val = Model_User::validate('edit');
     if (\Fuel\Core\Input::method() == 'POST') {
         if ($val->run()) {
             $user->username = \Fuel\Core\Input::post('username');
             $user->email = \Fuel\Core\Input::post('email');
             $user->group = \Fuel\Core\Input::post('group');
             $user->first_name = \Fuel\Core\Input::post('first_name');
             $user->last_name = \Fuel\Core\Input::post('last_name');
             $user->target_billable = \Fuel\Core\Input::post('target_billable');
             $user->target_unbillable = \Fuel\Core\Input::post('target_unbillable');
             try {
                 if ($user->save()) {
                     Session::set_flash('success', e('Updated user #' . $id));
                     Response::redirect('admin/users');
                 } else {
                     Session::set_flash('error', e('Could not update user #' . $id));
                 }
             } catch (\SimpleUserUpdateException $ex) {
                 // duplicate email address
                 if ($ex->getCode() == 2) {
                     Fuel\Core\Session::set_flash('error', 'Email already exists.');
                 } elseif ($ex->getCode() == 3) {
                     Fuel\Core\Session::set_flash('error', 'Username already exists.');
                 } else {
                     Fuel\Core\Session::set_flash('error', $ex->getMessage());
                 }
             }
         } else {
             if (Input::method() == 'POST') {
                 Session::set_flash('error', $val->error());
             }
         }
     }
     $this->template->set_global('user', $user, false);
     $this->template->set_global('val', $val, false);
     $this->template->set_global('groups', $this->get_groups_list());
     $this->template->title = "Users";
     $this->template->content = View::forge('admin/users/edit');
 }
开发者ID:AfterCursor,项目名称:itnt-time-manager,代码行数:48,代码来源:users.php

示例9: action_create

 public function action_create()
 {
     parent::has_access("add_user");
     if (Input::method() == 'POST') {
         $val = Model_User::validate('create');
         if ($val->run()) {
             $user = Model_User::forge(array('name' => Input::post('username'), 'password' => md5(Input::post('password')), 'access_level' => Input::post('access_level')));
             if ($user and $user->save()) {
                 Session::set_flash('success', 'Added user #' . $user->id . '.');
                 Response::redirect('users');
             } else {
                 Session::set_flash('error', 'Could not save user.');
             }
         } else {
             Session::set_flash('error', $val->error());
         }
     }
     $this->template->title = "Users";
     $this->template->content = View::forge('users/create');
 }
开发者ID:cloudetm,项目名称:payroll,代码行数:20,代码来源:users.php

示例10: action_register

 public function action_register()
 {
     if (Input::method() == 'POST') {
         $val = Model_User::validate('create');
         if ($val->run()) {
             $user = Model_User::forge(array('username' => Input::post('username'), 'password' => Auth::instance()->hash_password(Input::post('password')), 'group' => 1, 'email' => Input::post('email'), 'fname' => Input::post('fname'), 'mname' => Input::post('mname'), 'lname' => Input::post('lname'), 'contact_num' => Input::post('contact_num'), 'address' => Input::post('address'), 'profile_pic' => Input::post('profile_pic'), 'last_login' => Input::post('last_login'), 'login_hash' => Input::post('login_hash'), 'profile_fields' => Input::post('profile_fields')));
             Upload::process(Config::get('upload_profile_picture'));
             $user->profile = Model_Student::forge(['year_level' => 0, 'course_id' => 0]);
             if (Upload::is_valid()) {
                 Upload::save();
                 $value = Upload::get_files();
                 foreach ($value as $files) {
                     $user->profile_pic = $value[0]['saved_as'];
                 }
                 if ($user and $user->save()) {
                     Session::set_flash('success', e('Succesfully Added user #' . $user->id . '.'));
                     Response::redirect('site/login');
                 } else {
                     Session::set_flash('error', e('Could not save user.'));
                 }
             } else {
                 Session::set_flash('error', e('Uploaded photo is invalid.'));
             }
             // if ($user and $user->save())
             // {
             // 	Session::set_flash('success', e('Succesfully Added user #'.$user->id.'.'));
             // 	Response::redirect('site/login');
             // }
             // else
             // {
             // 	Session::set_flash('error', e('Could not save user.'));
             // }
         } else {
             Session::set_flash('error', $val->error());
         }
     }
     // $this->template->title = "Users";
     // $this->template->content = View::forge('admin/users/create');
     $this->template->title = 'Register';
     $this->template->content = View::forge('site/register');
 }
开发者ID:xXLXx,项目名称:ddc,代码行数:41,代码来源:site.php

示例11: saveUser

 public function saveUser(Model_User $user, View_Html $view)
 {
     if (isset($_REQUEST['save'])) {
         $errors = array();
         if ($_POST['password'] !== $_POST['checkpass']) {
             $errors['checkpass'] = _('Passwords don\'t match');
         }
         if (!isset($_POST['flags'])) {
             $_POST['flags'] = array();
         }
         $user->setData($_POST);
         $errors += $user->validate();
         if (!$errors) {
             $user->save();
             $view->redir('Admin_Group', 'default', array('id' => $user->group));
             return true;
         }
         $view->errors = $errors;
     }
     return false;
 }
开发者ID:kstep,项目名称:pnut,代码行数:21,代码来源:User.php

示例12: action_edit

 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('user');
     if (!($user = Model_User::find($id))) {
         Session::set_flash('error', 'Could not find user #' . $id);
         Response::redirect('user');
     }
     $val = Model_User::validate('edit');
     if ($val->run()) {
         $user->username = Input::post('username');
         $user->password = Input::post('password');
         $user->group_id = Input::post('group_id');
         $user->email = Input::post('email');
         $user->last_login = Input::post('last_login');
         $user->previous_login = Input::post('previous_login');
         $user->login_hash = Input::post('login_hash');
         $user->user_id = Input::post('user_id');
         if ($user->save()) {
             Session::set_flash('success', 'Updated user #' . $id);
             Response::redirect('user');
         } else {
             Session::set_flash('error', 'Could not update user #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $user->username = $val->validated('username');
             $user->password = $val->validated('password');
             $user->group_id = $val->validated('group_id');
             $user->email = $val->validated('email');
             $user->last_login = $val->validated('last_login');
             $user->previous_login = $val->validated('previous_login');
             $user->login_hash = $val->validated('login_hash');
             $user->user_id = $val->validated('user_id');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('user', $user, false);
     }
     $this->template->title = "Users";
     $this->template->content = View::forge('user/edit');
 }
开发者ID:katsuwo,项目名称:bbs,代码行数:40,代码来源:user.php

示例13: action_create

 public function action_create()
 {
     $auth = Auth::instance();
     $groupList = Config::get("cmsauth.group_list");
     $data['grouplist'] = $groupList;
     if (Input::method() == 'POST') {
         $val = Model_User::validate('create');
         if ($val->run()) {
             $ignore = array('button', 'submit', 'password', 'confirm_password', 'email', 'group');
             foreach (Input::Post() as $feild => $value) {
                 if (!in_array($feild, $ignore)) {
                     $fields[$feild] = $value;
                 }
             }
             $username = Input::post('first_name') . " " . Input::post('last_name');
             $password = Input::post('password');
             $email = Input::post('email');
             $group = Input::post('group');
             $post_data = Input::post();
             try {
                 $auth = Auth::instance();
                 $user = $auth->create_user($username, $password, $email, $group, $fields, $post_data);
                 Response::redirect("admin");
             } catch (Exception $e) {
                 $error = $e->getMessage();
                 var_dump($error);
                 die;
             }
         } else {
             $data['status'] = "fail";
             $data['msg'] = $val->show_errors();
         }
     }
     $this->template->title = "Create Users";
     $this->template->content = View::forge('admin/users/create', $data, false);
 }
开发者ID:sajans,项目名称:cms,代码行数:36,代码来源:users.php

示例14: loginAction

 public function loginAction()
 {
     $this->_helper->layout()->setLayout('redesign-2014');
     $users = new Model_User();
     $authsession = new Zend_Session_Namespace('authsession');
     $this->view->referer = isset($_GET['ref']) ? $_GET['ref'] : '';
     $validate = '';
     if ($_POST) {
         $user = isset($_POST['user']) ? $_POST['user'] : '';
         $pass = isset($_POST['pass']) ? md5($_POST['pass']) : '';
         $validate = $users->validate($user, $pass);
     }
     $referer = isset($_POST['referer']) ? $_POST['referer'] : 'profile';
     if (isset($authsession->logged_admin)) {
         $this->_redirect('/admin/settings/');
     } elseif (isset($authsession->logged_user)) {
         $this->_redirect('/' . $referer);
     }
     $this->view->loggedUser = $validate;
 }
开发者ID:BGCX067,项目名称:ezecom-svn-to-git,代码行数:20,代码来源:IndexController.php


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