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


PHP Model_User::save方法代码示例

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


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

示例1: process

 public function process($data)
 {
     if ($this->isValid($data) !== true) {
         throw new Exception('Form Validation Failed');
     }
     if ($this->newPassword->getValue() != $this->newPasswordConfirm->getValue()) {
         throw new Exception('Passwords don\'t match');
     }
     if ($this->_user->password != $this->currentPassword->getValue()) {
         throw new Exception('Current password is incorrect');
     }
     $this->_user->password = $this->newPassword->getValue();
     $this->_user->save();
 }
开发者ID:tests1,项目名称:zendcasts,代码行数:14,代码来源:UserChangePassword.php

示例2: action_add

 public function action_add()
 {
     $this->template->title = "Add Mahasiswa";
     if (isset($_POST['nim'])) {
         $mahasiswa = new Model_Mahasiswa();
         $user = new Model_User();
         $user->username = $_POST['nim'];
         // nimnya harus dicek dulu nih
         $user->password = $_POST['password'];
         $user->save();
         // Masukkan role user
         $user->add('roles', ORM::factory('role')->where('name', '=', 'login')->find());
         $user->add('roles', ORM::factory('role')->where('name', '=', 'mahasiswa')->find());
         $mahasiswa->nim = $_POST['nim'];
         // nimnya harus dicek dulu nih
         $mahasiswa->user_id = $user->id;
         $mahasiswa->nama = $_POST['nama'];
         $mahasiswa->tempat_lahir = $_POST['tempat_lahir'];
         $tanggal_lahir = $_POST['tahun'] . "-" . $_POST['bulan'] . "-" . $_POST['tanggal'];
         $mahasiswa->tanggal_lahir = $tanggal_lahir;
         $mahasiswa->jenis_kelamin = $_POST['jenis_kelamin'];
         $mahasiswa->email = $_POST['email'];
         $mahasiswa->alamat = $_POST['alamat'];
         $mahasiswa->no_hp = $_POST['no_hp'];
         $mahasiswa->nama_ayah = $_POST['nama_ayah'];
         $mahasiswa->telp_rumah = $_POST['telp_rumah'];
         $mahasiswa->tahun_masuk = $_POST['tahun_masuk'];
         $mahasiswa->status_kelulusan = 2;
         // belum lulus
         $mahasiswa->save();
     }
 }
开发者ID:trie0856,项目名称:sidemik,代码行数:32,代码来源:mahasiswa.php

示例3: registerAction

 public function registerAction()
 {
     $request = $this->getRequest();
     $form = new Form_User_Registration();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $model = new Model_User($form->getValues());
             $user_id = $model->save();
             $model->setId($user_id);
             $globalSession = Zend_Registry::get('dlo.session');
             $globalSession->user = $model;
             //Zend_Loader::loadClass('Zend_View');
             $view = new Zend_View();
             $view->activationLink = "http://DrivingLessonOnline.com/user/verify-email/id/" . $model->getId() . "/guid/" . hash('sha1', $model->getSalt() . $model->getId() . $model->getPassword()) . "/";
             $view->setBasePath(APPLICATION_PATH . "/views/");
             $mailBodyHtml = $view->render('Templates/Account-Activation-Email.phtml');
             //send email verification email before user can start using their account.
             $mail = new Zend_Mail();
             $mail->setBodyHtml($mailBodyHtml);
             $mail->setFrom('no.reply@DrivingLessonOnline.com', 'Registration');
             $mail->addTo($model->getEmail(), $model->getDisplayName());
             $mail->setSubject($model->getDisplayName() . ' activiate your account for Driving Lesson Online.com');
             $mail->send();
             //thank user and inform to check their email to enable their account.
             $this->_redirect('/user/registered');
         }
     }
     $this->view->form = $form;
 }
开发者ID:Zerone,项目名称:ImJob.org,代码行数:29,代码来源:UserController.php

示例4: testUserSetup

 public function testUserSetup()
 {
     $u = new Model_User();
     $u->username = 'counter1';
     $u->password = 'c1pass';
     $u->roles = array('user');
     $u->save();
     $u = new Model_User();
     $u->username = 'counter2';
     $u->password = 'c2pass';
     $u->roles = array('user');
     $u->save();
     $u = new Model_User();
     $u->username = 'counter3';
     $u->password = 'c3pass';
     $u->roles = array('user');
     $u->save();
     $u = new Model_User();
     $u->username = 'counter4';
     $u->password = 'c4pass';
     $u->roles = array('user');
     $u->save();
     $u = new Model_User();
     $u->username = 'counter5';
     $u->password = 'c5pass';
     $u->roles = array('user');
     $u->save();
     $u = new Model_User();
     $u->username = 'admin';
     $u->password = 'ping96;pong';
     $u->roles = array('admin');
     $u->save();
 }
开发者ID:kenncapara,项目名称:emaxx,代码行数:33,代码来源:UserTest.php

示例5: maskUserNamesAction

 /**
  * Maskuje nazwiska i adresy email uzytkownikow
  */
 public function maskUserNamesAction()
 {
     $oUser = new Model_User();
     $aUsers = $oUser->getAll();
     foreach ($aUsers as $aUser) {
         if (in_array($aUser['name'], array('Chodorowski', 'TestUser'))) {
             continue;
         }
         $oUser = new Model_User();
         $oUser->user_id = $aUser['user_id'];
         // pick random name
         $sName = chr(rand(65, 90));
         $sName .= chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122));
         $sName .= chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122));
         $oUser->name = $sName;
         $oUser->email = sprintf('%s.%s@catering.wsiz.wroc.pl', strtolower($aUser['fname']), strtolower($sName));
         // save
         if (!$oUser->save()) {
             break;
         }
         unset($oUser);
     }
     // foreach
     $this->indexAction('Maskowanie wykonane pomyslnie.');
 }
开发者ID:maxwroc,项目名称:PHP,代码行数:28,代码来源:Service.php

示例6: action_create

 /**
  * Create User
  * @access public
  * @param none
  * @return Response
  */
 public function action_create()
 {
     # Forge a fieldset and add all Model_User properties to it
     $fieldset = \Fieldset::forge()->add_model('Model_User');
     # Add a virtual password confirm field
     $fieldset->add_after('password_confirm', 'Retype Password', array('type' => 'password'), array(array('min_length', 5), array('match_field', 'password'), array('required')), 'password');
     # Repopulate if Save action failed
     $fieldset->repopulate();
     # Turn it into a form
     $form = $fieldset->form();
     # Add our submit button
     $form->add('submit', '', array('type' => 'submit', 'value' => 'Save', 'class' => 'btn btn-large btn-block btn-primary'));
     # Remember, this form is going to post to itself by defult
     # so we need to process the input in this same controller method
     if ($fieldset->validation()->run()) {
         $fields = $fieldset->validated();
         # Grab our input values
         # Best use a try/catch block
         # Model will throw a Orm\ValidationFailed exception if validation fails
         try {
             $user = new Model_User($fields);
             $user->save();
             Session::set_flash('success', 'Added user #' . $user->id . '.');
             Response::redirect('user');
         } catch (Exception $e) {
             Session::set_flash('error', $e->getMessage());
         }
     } else {
         Session::set_flash('error', $fieldset->validation()->show_errors());
     }
     $this->template->title = "Add User";
     $this->template->set('content', $form->build(), false);
 }
开发者ID:peteryu1,项目名称:fuel-usersapp,代码行数:39,代码来源:user.php

示例7: action_add

 public function action_add()
 {
     $this->template->title = "Add Dosen";
     if (isset($_POST['nip'])) {
         $dosen = new Model_Dosen();
         $user = new Model_User();
         $user->username = $_POST['nip'];
         $user->password = $_POST['password'];
         $user->save();
         // Masukkan role user
         $user->add('roles', ORM::factory('role')->where('name', '=', 'login')->find());
         $user->add('roles', ORM::factory('role')->where('name', '=', 'dosen')->find());
         $dosen->nip = $_POST['nip'];
         $dosen->user_id = $user->id;
         $dosen->nama = $_POST['nama'];
         $dosen->tahun_masuk = $_POST['tahun_masuk'];
         $dosen->tempat_lahir = $_POST['tempat_lahir'];
         $tanggal_lahir = $_POST['tahun'] . "-" . $_POST['bulan'] . "-" . $_POST['tanggal'];
         $dosen->tanggal_lahir = $tanggal_lahir;
         $dosen->jenis_kelamin = $_POST['jenis_kelamin'];
         $dosen->alamat = $_POST['alamat'];
         $dosen->no_hp = $_POST['no_hp'];
         $dosen->telp_rumah = $_POST['telp_rumah'];
         $dosen->email = $_POST['email'];
         $dosen->save();
     }
 }
开发者ID:trie0856,项目名称:sidemik,代码行数:27,代码来源:dosen.php

示例8: signupAction

 public function signupAction()
 {
     $this->view->title = "User Registration.";
     $this->view->headTitle($this->view->title, 'PREPEND');
     $form = new Form_Signup();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $formvalues = $form->getValues();
             $user = new Model_User();
             $db = $user->getAdapter();
             $db->beginTransaction();
             try {
                 $user->fill($formvalues);
                 $user->eStatus = 1;
                 $user->eAlerts = 1;
                 $user->eRights = 1;
                 $user->dRegDate = time();
                 // $user->sendActivationEmail();
                 $user->save();
                 $group = new Model_SubGroup();
                 $group->find('vGroupCodeId', $formvalues['iSGroupCode']);
                 $assign = new Model_SubGroupUserAssign();
                 $assign->iSGroupId = $group->iSGroupId;
                 $assign->iUserId = $user->iUserId;
                 $assign->save();
                 $db->commit();
             } catch (Exception $e) {
                 $db->rollBack();
                 echo $e->getMessage();
             }
             $this->_helper->redirector('login');
         }
     }
     $this->view->form = $form;
 }
开发者ID:redeyes1024,项目名称:medlii_mlm_client_web,代码行数:35,代码来源:UsersController.php

示例9: complete_login

 /**
  * @param Model_User $user
  *
  * @return bool
  */
 public function complete_login($user)
 {
     if ($user) {
         $user->accesstime = date('Y-m-d H:i:s');
         $user->ip = Request::$client_ip;
         $user->save();
     }
     return parent::complete_login($user);
 }
开发者ID:creat2012,项目名称:hustoj_official,代码行数:14,代码来源:Hoj.php

示例10: insert_user

 public function insert_user($cname, $ename, $email)
 {
     $user = new Model_User();
     $user->cname = $cname;
     $user->ename = $ename;
     $user->email = $email;
     $user->save();
     return $user->id;
 }
开发者ID:rh20083907,项目名称:ipublish,代码行数:9,代码来源:User.php

示例11: action_edit

 public function action_edit($id)
 {
     $this->template->title = "Ubah Password";
     $user = new Model_User($id);
     if (isset($_POST['password'])) {
         $user->password = $_POST['password'];
         $user->save();
     }
     $this->template->content->user = $user;
 }
开发者ID:trie0856,项目名称:sidemik,代码行数:10,代码来源:user.php

示例12: test_create5

 /**
  * This should not save - duplicate email
  * @expectedException        Orm\ValidationFailed
  */
 public function test_create5()
 {
     $data = array('username' => 'bitemyapple1', 'password' => 'Not7ooShA34y!', 'email' => 'someone@gmail.com', 'name' => 'Veselin', 'date_of_birth' => '1988-12-31', 'gender' => '0');
     $user = new \Model_User($data);
     try {
         $result = $user->save();
     } catch (\Exception $e) {
         throw new Orm\ValidationFailed($e->getMessage());
     }
 }
开发者ID:peteryu1,项目名称:fuel-usersapp,代码行数:14,代码来源:user.php

示例13: testCanCreateUsers

 public function testCanCreateUsers()
 {
     Model_User::create($this->username, $this->password);
     $users = Model_User::getUsers();
     $this->assertArrayHasKey($this->username, $users);
     $user = new Model_User();
     $user->username = 'myuser';
     $user->password = 'mypass';
     $user->save();
     $users = Model_User::getUsers();
     $this->assertArrayHasKey('myuser', $users);
 }
开发者ID:tests1,项目名称:zendcasts,代码行数:12,代码来源:UserTest.php

示例14: testAuthWithValidCredentials

 public function testAuthWithValidCredentials()
 {
     $u = new Model_User();
     $u->username = 'foo';
     $u->password = 'bar';
     $u->save();
     $this->request->setMethod('POST')->setPost(array('username' => 'foo', 'password' => 'bar'));
     $this->dispatch('/auth/login');
     $this->assertController('auth');
     $this->assertAction('login');
     $res = json_decode($this->getResponse()->getBody(), true);
     $this->assertTrue($res['success']);
 }
开发者ID:kenncapara,项目名称:emaxx,代码行数:13,代码来源:AuthTest.php

示例15: indexAction

 public function indexAction()
 {
     $u = new Model_User();
     $u->name = time();
     $u->save();
     if ($this->getRequest()->isPost()) {
         $newUser = new Model_User();
         $newUser->name = $this->_getParam('name');
         $newUser->email = $this->_getParam('email');
         $newUser->car_id = $this->_getParam('car_id');
         $newUser->save();
     }
 }
开发者ID:tests1,项目名称:zendcasts,代码行数:13,代码来源:IndexController.php


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