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


PHP Application_Model_User::save方法代码示例

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


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

示例1: addUserPrivilegeAction

 public function addUserPrivilegeAction()
 {
     $request = $this->getRequest();
     $form = new Application_Form_UserPrivilege();
     if ($request->isPost()) {
         $options = $request->getPost();
         if ($form->isValid($options)) {
             //$options['status']='active';
             $model = new Application_Model_User($options);
             $id = $model->save();
             if ($id) {
                 /*---------  Upload image START -------------------------*/
                 $model->uploadProfilePicture($id, $options);
                 /*---------  Upload image END -------------------------*/
                 $this->_flashMessenger->addMessage(array('success' => 'User added successfully!'));
                 $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/admin/user/add-new-user'));
             } else {
                 $this->_flashMessenger->addMessage(array('error' => 'Failed to add user!'));
                 $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/admin/user/add-new-user'));
             }
             $form->reset();
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
开发者ID:riteshsahu1981,项目名称:Weadvance,代码行数:28,代码来源:UserPrivilegeController.php

示例2: recoverPassword

 public function recoverPassword(Application_Model_User $user)
 {
     $new_password = $this->passwordGenerator();
     $user->setPassword(md5($new_password));
     $user->save();
     $options['email'] = $user->getEmail();
     $options['password'] = $new_password;
     $options['firstName'] = $user->getFirstName();
     $options['lastName'] = $user->getLastName();
     $Mail = new Base_Mail();
     $Mail->sendForgotMail($options);
 }
开发者ID:riteshsahu1981,项目名称:we,代码行数:12,代码来源:Auth.php

示例3: addUserAction

 public function addUserAction()
 {
     global $CC_CONFIG;
     $request = $this->getRequest();
     $baseUrl = $request->getBaseUrl();
     $js_files = array('/js/datatables/js/jquery.dataTables.js?', '/js/datatables/plugin/dataTables.pluginAPI.js?', '/js/airtime/user/user.js?');
     foreach ($js_files as $js) {
         $this->view->headScript()->appendFile($baseUrl . $js . $CC_CONFIG['airtime_version'], 'text/javascript');
     }
     $this->view->headLink()->appendStylesheet($baseUrl . '/css/users.css?' . $CC_CONFIG['airtime_version']);
     $form = new Application_Form_AddUser();
     $this->view->successMessage = "";
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $formdata = $form->getValues();
             if (isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1 && $formdata['login'] == 'admin' && $formdata['user_id'] != 0) {
                 $this->view->successMessage = "<div class='errors'>Specific action is not allowed in demo version!</div>";
             } elseif ($form->validateLogin($formdata)) {
                 $user = new Application_Model_User($formdata['user_id']);
                 $user->setFirstName($formdata['first_name']);
                 $user->setLastName($formdata['last_name']);
                 $user->setLogin($formdata['login']);
                 // We don't allow 6 x's as a password.
                 // The reason is because we that as a password placeholder
                 // on the client side.
                 if ($formdata['password'] != "xxxxxx") {
                     $user->setPassword($formdata['password']);
                 }
                 $user->setType($formdata['type']);
                 $user->setEmail($formdata['email']);
                 $user->setCellPhone($formdata['cell_phone']);
                 $user->setSkype($formdata['skype']);
                 $user->setJabber($formdata['jabber']);
                 $user->save();
                 $form->reset();
                 if (strlen($formdata['user_id']) == 0) {
                     $this->view->successMessage = "<div class='success'>User added successfully!</div>";
                 } else {
                     $this->view->successMessage = "<div class='success'>User updated successfully!</div>";
                 }
             }
         }
     }
     $this->view->form = $form;
 }
开发者ID:nidzix,项目名称:Airtime,代码行数:45,代码来源:UserController.php

示例4: editUserAction

 public function editUserAction()
 {
     $request = $this->getRequest();
     $form = new Application_Form_EditUser();
     if ($request->isPost()) {
         $formData = $request->getPost();
         if ($form->isValid($formData) && $form->validateLogin($formData['cu_login'], $formData['cu_user_id'])) {
             $user = new Application_Model_User($formData['cu_user_id']);
             $user->setFirstName($formData['cu_first_name']);
             $user->setLastName($formData['cu_last_name']);
             // We don't allow 6 x's as a password.
             // The reason is because we use that as a password placeholder
             // on the client side.
             if ($formData['cu_password'] != "xxxxxx") {
                 $user->setPassword($formData['cu_password']);
             }
             $user->setEmail($formData['cu_email']);
             $user->setCellPhone($formData['cu_cell_phone']);
             $user->setSkype($formData['cu_skype']);
             $user->setJabber($formData['cu_jabber']);
             $user->save();
             Application_Model_Preference::SetUserLocale($formData['cu_locale']);
             Application_Model_Preference::SetUserTimezone($formData['cu_timezone']);
             //configure localization with new locale setting
             Application_Model_Locale::configureLocalization($formData['cu_locale']);
             //reinitialize form so language gets translated
             $form = new Application_Form_EditUser();
             $this->view->successMessage = "<div class='success'>" . _("Settings updated successfully!") . "</div>";
         }
         $this->view->form = $form;
         $this->view->html = $this->view->render('user/edit-user.phtml');
     }
     $this->view->form = $form;
     $this->view->html = $this->view->render('user/edit-user.phtml');
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:35,代码来源:UserController.php

示例5: connectYourAccountAction

 public function connectYourAccountAction()
 {
     //get referer sender user Id from session
     $usersNs = new Zend_Session_Namespace("app");
     $sender_id = $usersNs->sender_id;
     //echo "sssss=".$sender_id;
     $facebook = $this->view->facebook();
     $session = $facebook->getSession();
     //echo "<pre>";
     //print_r($session);
     if (!$session) {
         $this->_helper->redirector("register", "index", "default");
     }
     $uid = $facebook->getUser();
     $me = $facebook->api('/me');
     //echo "<pre>";
     //print_r($me);
     //exit;
     $params['email'] = $me['email'];
     $arrBday = explode("/", $me['birthday']);
     $params['year'] = $arrBday[2];
     $params['month'] = $arrBday[0];
     $params['day'] = $arrBday[1];
     $params['firstName'] = $me['first_name'];
     $params['lastName'] = $me['last_name'];
     if (isset($me['gender']) && $me['gender'] != "") {
         $params['sex'] = $me['gender'];
     }
     $form = new Application_Form_Register();
     $form->populate($params);
     $elements = $form->getElements();
     $form->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
     }
     $this->view->fbmsg = $this->_getParam("fbmsg");
     $this->view->form = $form;
     $this->view->successMsg = "";
     $this->view->sender = $this->_getParam('sender');
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getPost();
         $params['firstName'] = $me['first_name'];
         $params['lastName'] = $me['last_name'];
         if (isset($me['gender']) && $me['gender'] != "") {
             $params['sex'] = $me['gender'];
         }
         if ($form->isValid($params)) {
             $params['facebookId'] = $uid;
             $params['dob'] = $params['year'] . "-" . $params['month'] . "-" . $params['day'];
             $params['status'] = 'inactive';
             $params['userLevelId'] = 1;
             $password = $params['password'];
             $params['password'] = md5($params['password']);
             $params['status'] = "active";
             /*----find gapper id ---*/
             $gapper_id = 0;
             if ($params['gapperOrFriend'] == "friend") {
                 $gapperM = new Application_Model_User();
                 $gapper = $gapperM->getDataByUsername($params['usernameOfGapper']);
                 if (false !== $gapper) {
                     $gapper_id = $gapper->getId();
                 }
             }
             $params['gapperId'] = $gapper_id;
             /*----------------------*/
             $user = new Application_Model_User($params);
             $user_id = $user->save();
             if ($user_id > 0) {
                 //If user has checked Newsletter, then insert in subscribe table
                 if ($params['newsletter'] == "yes") {
                     $user->newsletterSubscribe($user_id);
                 }
                 /*---- default permission settings ----*/
                 $user->setDefaultPermissions($user_id);
                 $user->setDefaultJournal($user_id);
                 /*-------------------------------------------*/
                 /*---------add a friend -------------*/
                 //$sender_id = base64_decode($this->_getParam('sender'));
                 //$senderM=new Application_Model_Friend();
                 //$senderM->addAsFriend($sender_id,$user_id);
                 $sender_id = $usersNs->sender_id;
                 if ($sender_id > 0) {
                     $senderM = new Application_Model_Friend();
                     $senderM->addAsFriend($sender_id, $user_id);
                     $senderM->addAsFriend($user_id, $sender_id);
                 }
                 /*-------------------------------------*/
                 $params['activate_link'] = Zend_Registry::get('siteurl') . "/index/activate/id/" . base64_encode($user_id);
                 $params['password'] = $password;
                 $usersNs->registration_id = $user_id;
                 //$mail=new Base_Mail();
                 //$mail->sendRegistrationMail($params);
                 $usersNs = new Zend_Session_Namespace("app");
                 $usersNs->facebookId = $uid;
                 $this->_helper->redirector('invite', 'index', "default");
             }
         }
     }
 }
开发者ID:riteshsahu1981,项目名称:we,代码行数:99,代码来源:IndexController.php

示例6: doFacebookLogin

 public function doFacebookLogin()
 {
     $view = new Zend_view();
     $view->addHelperPath('Base/View/Helper/', 'Base_View_Helper');
     $facebook = $view->facebook();
     $session = $facebook->getSession();
     if ($session) {
         try {
             $Auth = new Base_Auth_Auth();
             $uid = $facebook->getUser();
             $user = new Application_Model_User();
             $where = "facebook_id='{$uid}'";
             $user = $user->fetchRow($where);
             if (false === $user) {
                 //create new user
                 $me = $facebook->api('/me');
                 $password = md5($Auth->passwordGenerator());
                 $user = new Application_Model_User();
                 if ($me['email'] != "") {
                     $where = "email='{$me['email']}'";
                     $user = $user->fetchRow($where);
                     if (false === $user) {
                         //insertex
                         $user = new Application_Model_User();
                         $user->setEmail($me['email']);
                         $user->setUsername($me['id']);
                         $user->setPassword($password);
                         $user->setfirstName($me['first_name']);
                         $user->setLastName($me['last_name']);
                         $user->setSex($me['gender']);
                         $user->setGapperOrFriend('gapper');
                         $user->setFacebookId($me['id']);
                         $user->setStatus('active');
                         $user->setDob('0000-00-00');
                         $user->setUserLevelId(1);
                     } else {
                         //update
                         $user->setFacebookId($me['id']);
                     }
                 } else {
                     $user = new Application_Model_User();
                     $user->setEmail($me['email']);
                     $user->setUsername($me['id']);
                     $user->setPassword($password);
                     $user->setfirstName($me['first_name']);
                     $user->setLastName($me['last_name']);
                     $user->setSex($me['gender']);
                     $user->setGapperOrFriend('gapper');
                     $user->setFacebookId($me['id']);
                     $user->setStatus('active');
                     $user->setDob('0000-00-00');
                     $user->setUserLevelId(1);
                 }
                 $user_id = $user->save();
                 if ($user_id > 0) {
                     $user->setDefaultPermissions($user_id);
                     if ($params['email'] != "") {
                         //send registration mail
                     }
                 }
             }
             //--do login --
             $params['email'] = $user->getEmail();
             //$params['username']=$user->getUsername();
             $params['password'] = $user->getPassword();
             $params['md5'] = "false";
             $Auth->doLogout();
             $loginStatus = true;
             if ($params['email'] != "") {
                 $loginStatus = $Auth->doLogin($params, 'email');
             } else {
                 $params['email'] = $user->getUsername();
                 $loginStatus = $Auth->doLogin($params, 'username');
             }
             if ($user->getEmail() == "" || is_null($user->getEmail())) {
                 //echo "<a href='/gapper/update-your-email' >Click here</a>";
                 //$this->_helper->redirector('update-your-email','gapper');
                 $result['email'] = "no";
                 return $result;
             }
             if ($loginStatus) {
                 $result['email'] = "ok";
                 return $result;
                 //echo "<a href='/gapper/where-i-am' >Click here</a>";
                 //$this->_helper->redirector('where-i-am','gapper');
             } else {
                 if ($user->getStatus() == "inactive") {
                     exit("Please activate your account. <br><a href='#' onclick='window.close();'>Close</a>");
                 } else {
                     if ($user->getStatus() == "deleted") {
                         exit("Your account status is deleted. Please contact administrator.");
                     } else {
                         exit("error while login");
                     }
                 }
             }
         } catch (FacebookApiException $e) {
             error_log($e);
         }
     }
//.........这里部分代码省略.........
开发者ID:riteshsahu1981,项目名称:we,代码行数:101,代码来源:User.php

示例7: addNewEmployeeAction

 public function addNewEmployeeAction()
 {
     $request = $this->getRequest();
     $form = new Application_Form_User();
     if ($request->isPost()) {
         $options = $request->getPost();
         $form->getElement('email')->addValidators(array(array('Db_NoRecordExists', false, array('table' => 'user', 'field' => 'email', 'messages' => 'Email already exists, Please choose another email address.'))));
         if ($form->isValid($options)) {
             //$options['status']='active';
             $options['password'] = md5($options['password']);
             $model = new Application_Model_User($options);
             $id = $model->save();
             if ($id) {
                 /*---------  Upload image START -------------------------*/
                 $model->uploadProfilePicture($id, $options);
                 /*---------  Upload image END -------------------------*/
                 $this->_flashMessenger->addMessage(array('success' => 'Employee added successfully!'));
                 $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/hr/add-new-employee'));
             } else {
                 $this->_flashMessenger->addMessage(array('error' => 'Failed to add employee!'));
                 $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/hr/add-new-employee'));
             }
             $form->reset();
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
开发者ID:riteshsahu1981,项目名称:we,代码行数:30,代码来源:HrController.php

示例8: importEmployee

 public function importEmployee($options, $targetPath)
 {
     include_once LIBRARY_PATH . "/Base/Excel/PHPExcel.php";
     $objPHPExcel = new PHPExcel();
     $objPHPExcel = PHPExcel_IOFactory::load($targetPath);
     foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
         if ($worksheet->getTitle() == "user") {
             $rowctr = 0;
             $insertctr = 0;
             $updatectr = 0;
             foreach ($worksheet->getRowIterator() as $row) {
                 if ($row->getRowIndex() != 1) {
                     $options['employeeCode'] = $worksheet->getCell("A" . $row->getRowIndex())->getCalculatedValue();
                     $options['email'] = $worksheet->getCell("B" . $row->getRowIndex())->getCalculatedValue();
                     $options['username'] = $worksheet->getCell("C" . $row->getRowIndex())->getCalculatedValue();
                     //$options['password']=$worksheet->getCell("D".$row->getRowIndex())->getCalculatedValue();
                     $options['firstName'] = $worksheet->getCell("E" . $row->getRowIndex())->getCalculatedValue();
                     $options['middleName'] = $worksheet->getCell("F" . $row->getRowIndex())->getCalculatedValue();
                     $options['lastName'] = $worksheet->getCell("G" . $row->getRowIndex())->getCalculatedValue();
                     $options['dob'] = $worksheet->getCell("H" . $row->getRowIndex())->getCalculatedValue();
                     $options['sex'] = $worksheet->getCell("I" . $row->getRowIndex())->getCalculatedValue();
                     $options['mobile'] = $worksheet->getCell("J" . $row->getRowIndex())->getCalculatedValue();
                     $options['contactNo'] = $worksheet->getCell("K" . $row->getRowIndex())->getCalculatedValue();
                     $options['extensionNo'] = $worksheet->getCell("L" . $row->getRowIndex())->getCalculatedValue();
                     $options['skype'] = $worksheet->getCell("M" . $row->getRowIndex())->getCalculatedValue();
                     $options['doj'] = $worksheet->getCell("N" . $row->getRowIndex())->getCalculatedValue();
                     $options['marriageAnniversary'] = $worksheet->getCell("O" . $row->getRowIndex())->getCalculatedValue();
                     $options['fatherName'] = $worksheet->getCell("P" . $row->getRowIndex())->getCalculatedValue();
                     $options['correspondenceAddress'] = $worksheet->getCell("Q" . $row->getRowIndex())->getCalculatedValue();
                     $options['pan'] = $worksheet->getCell("R" . $row->getRowIndex())->getCalculatedValue();
                     $options['designationId'] = $worksheet->getCell("S" . $row->getRowIndex())->getCalculatedValue();
                     $options['departmentId'] = $worksheet->getCell("T" . $row->getRowIndex())->getCalculatedValue();
                     $options['status'] = 'active';
                     if ($options['designationId'] == "") {
                         $options['designationId'] = '15';
                     }
                     //other
                     if ($options['departmentId'] == "") {
                         $options['departmentId'] = '10';
                     }
                     //other
                     if ($options['employeeCode'] == "53") {
                         $options['userLevelId'] = '2';
                         //super admin
                         $options['password'] = "2e355c62e2700da907332157c85b44d4";
                     } elseif ($options['employeeCode'] == "2") {
                         $options['userLevelId'] = '3';
                         //hr
                         $options['username'] = $options['email'];
                     } elseif ($options['employeeCode'] == "5") {
                         $options['userLevelId'] = '4';
                         //pm
                         $options['username'] = $options['email'];
                     } else {
                         $options['userLevelId'] = '1';
                         //employee
                         $options['username'] = $options['email'];
                     }
                     $user = new Application_Model_User();
                     $user = $user->fetchRow("employee_code='{$options['employeeCode']}'");
                     if (false === $user) {
                         //insert
                         $user = new Application_Model_User($options);
                         if ($user->save() > 0) {
                             $insertctr++;
                         }
                     } else {
                         //update
                         $user->setOptions($options);
                         if ($user->save()) {
                             $updatectr++;
                         }
                     }
                     $rowctr++;
                 }
             }
             //end of row iterator foreach
         }
         // If worksheet = Sheet1
     }
     // end of worksheet iterator foreach
     return $rowctr;
 }
开发者ID:riteshsahu1981,项目名称:we,代码行数:83,代码来源:User.php

示例9: addAction

 public function addAction()
 {
     $request = $this->getRequest();
     $form = new Admin_Form_User();
     $options = $request->getPost();
     if ($request->isPost()) {
         /*---- email validation ----*/
         $form->getElement('email')->addValidators(array(array('Db_NoRecordExists', false, array('table' => 'user', 'field' => 'email', 'messages' => 'Email already exists, Please choose another email address.'))));
         /*-------------------------*/
         if ($form->isValid($options)) {
             $model = new Application_Model_User();
             $options['dob'] = $options['year'] . "-" . $options['month'] . "-" . $options['day'];
             $options['status'] = 'active';
             $options['password'] = md5($options['password']);
             $options['preferredLanguage'] = 'English';
             //$options['userLevelId']	=$options['userLevelId'];
             //$model->setOptions($options);
             // $id=$model->save();
             /*---------  Upload image START -------------------------*/
             $upload = new Zend_File_Transfer_Adapter_Http();
             if ($upload->isValid('image')) {
                 $upload->setDestination("media/picture/profile/");
                 try {
                     $upload->receive('image');
                 } catch (Zend_File_Transfer_Exception $e) {
                     $msg = $e->getMessage();
                 }
                 $upload->setOptions(array('useByteString' => false));
                 $file_name = $upload->getFileName('image');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "profile_" . $id . ".{$ext}";
                 $targetPath = 'media/picture/profile/' . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $options['image'] = $target_file_name;
                 /*--- Generate Thumbnail ---*/
                 $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                 $thumb->resize(100, 100);
                 $thumb->save($targetPath = 'media/picture/profile/thumb_' . $target_file_name);
                 $model->setOptions($options);
                 $model->setId($id);
                 $id = $model->save();
             }
             /*---------  Upload image END -------------------------*/
             //$options['dob'] = $options['year']."-".$options['month']."-".$options['day'];
             //$model->setOptions($options);
             //$model->save();
             $user = new Application_Model_User($options);
             $user_id = $user->save();
             if ($user_id > 0) {
                 /*---- default permission settings ----*/
                 $user->setDefaultPermissions($user_id);
                 $user->setDefaultJournal($user_id);
             }
             $this->view->msg = "'User has been inserted successfully!";
             $form->reset();
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
开发者ID:riteshsahu1981,项目名称:we,代码行数:64,代码来源:UserController.php


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