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


PHP PersonPeer::getByUsername方法代码示例

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


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

示例1: executeSendPassword

 /**
  * Sends new password to the requester
  * Can retrieve via Username or MemberId
  * @param sfWebRequest $request
  */
 public function executeSendPassword(sfWebRequest $request)
 {
     if ($request->isMethod('post')) {
         $request->checkCSRFProtection();
         $username = $request->getParameter('username');
         $member_id = $request->getParameter('member_id');
         if (strlen($username) > 0 || strlen($member_id) > 0) {
             $person = null;
             if ($member_id) {
                 $member = MemberPeer::retrieveByPK($member_id);
                 if ($member instanceof Member) {
                     $person = $member->getPerson();
                 }
             } elseif ($username) {
                 $person = PersonPeer::getByUsername($username);
             }
             if ($person instanceof Person) {
                 # create token for password request
                 $pr = new PasswordRequest();
                 $pr->setPerson($person);
                 $pr->setEmail($person->getEmail());
                 $pr->save();
                 if ($person->getEmail()) {
                     # send email via component
                     $this->getComponent('mail', 'sendPassword', array('person' => $person, 'token' => $pr->getToken()));
                     $this->getUser()->setFlash('success', 'Your password request has been successfully sent to your email!');
                 } else {
                     $this->getUser()->setFlash('success', 'This user doesn\'t have proper email address!');
                 }
                 # redirect to login
                 $this->redirect('secure/login');
             }
             $this->error_msg = 'Sorry! We haven\'t found any matching record!';
         } else {
             $this->error_msg = 'Please type your username OR member id!';
         }
     }
     $this->executeForgotPassword($request);
     $this->setTemplate('forgotPassword');
 }
开发者ID:yasirgit,项目名称:afids,代码行数:45,代码来源:actions.class.php

示例2: executeUpdatePassword

 public function executeUpdatePassword(sfWebRequest $request)
 {
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Member', 'Coordinator', 'Volunteer'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     $username = $this->getUser()->getUsername();
     $this->person = PersonPeer::getByUsername($username);
     if ($request->isMethod('post')) {
         if ($old_pass = $request->getParameter('old_pass')) {
             if ($this->person->isPassword($old_pass)) {
                 $required_len = sfConfig::get('app_password_minimum_length');
                 $new_pass = $request->getParameter('new_pass');
                 $confirm_pass = $request->getParameter('confirm_pass');
                 if (strlen($new_pass) >= $required_len && strlen($confirm_pass) >= $required_len) {
                     if ($new_pass == $confirm_pass) {
                         $this->person->setPassword($confirm_pass);
                         $this->person->save();
                         $this->getUser()->setFlash('success', 'Your password has been successfully changed!');
                         $this->redirect('account/index');
                     } else {
                         $this->error_msg = 'New passwords doesn\'t match!';
                     }
                 } else {
                     $this->error_msg = 'Your password must be at least ' . $required_len . ' characters!';
                 }
             } else {
                 $this->error_msg = 'Your old password is not right!';
             }
         } else {
             $this->error_msg = 'Please enter your old password!';
         }
     }
 }
开发者ID:yasirgit,项目名称:afids,代码行数:34,代码来源:actions.class.php

示例3: executeUpdatePassword

 public function executeUpdatePassword(sfWebRequest $request)
 {
     if ($this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) {
         $username = $this->getUser()->getUsername();
         $this->person = PersonPeer::getByUsername($username);
         $this->chperson = PersonPeer::retrieveByPK($request->getParameter('id'));
         $this->personId = $request->getParameter('id');
         if ($request->isMethod('post')) {
             if ($old_pass = $request->getParameter('old_pass')) {
                 if ($this->person->isPassword($old_pass)) {
                     $required_len = sfConfig::get('app_password_minimum_length');
                     $new_pass = $request->getParameter('new_pass');
                     $confirm_pass = $request->getParameter('confirm_pass');
                     if (strlen($new_pass) >= $required_len && strlen($confirm_pass) >= $required_len) {
                         if ($new_pass == $confirm_pass) {
                             $this->chperson->setPassword($confirm_pass);
                             $this->chperson->save();
                             $this->getUser()->setFlash('success', 'Your password has been successfully changed!');
                             $this->redirect('person/view?id=' . $this->chperson->getId());
                         } else {
                             $this->error_msg = 'New passwords doesn\'t match!';
                         }
                     } else {
                         $this->error_msg = 'Your password must be at least ' . $required_len . ' characters!';
                     }
                 } else {
                     $this->error_msg = 'Your old password is not right!';
                 }
             } else {
                 $this->error_msg = 'Please enter your old password!';
             }
         }
     } else {
         $this->getUser()->setFlash('warning', 'alkdjfdksjfladjkf');
     }
 }
开发者ID:yasirgit,项目名称:afids,代码行数:36,代码来源:actions.class.php


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