Changeset 670 for trunk/app/controllers/recovers_controller.php
- Timestamp:
- 07/23/08 01:12:58 (4 months ago)
- Files:
-
- 1 modified
-
trunk/app/controllers/recovers_controller.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/recovers_controller.php
r540 r670 22 22 public function recover() 23 23 { 24 $this->pageTitle = 'Recover password :: Karamelo E-learning on Web 2.0';24 $this->pageTitle = __('Recover password', true); 25 25 26 26 $this->Portal->statics(); // Using Portal component … … 35 35 $this->Sanitize->clean($this->data["User"]); 36 36 37 if ( !empty( $this->data["User"] ) ) 38 {37 if ( !empty( $this->data["User"] ) ): 38 39 39 $user_id = $this->Recover->User->field('id', array('email' => $this->data['User']['email'], 'active'=>1)); 40 40 41 if ($user_id == null) 42 { 41 if ($user_id == null): 43 42 $this->set('error_message', "Error: email <b>" . $this->data["User"]["email"] . "</b> does not exist on database"); 43 44 44 $this->render('check', 'ajax'); 45 } 46 else // email exist 47 { 45 else: // email exist 46 48 47 $this->data['Recover']['user_id'] = $user_id; //the user id 49 48 50 49 $this->data['Recover']['random'] = $this->Adds->genPassword(20); 51 50 52 $this->Recover->create(); 53 54 if ( $this->Recover->save($this->data['Recover']) ) 55 { 56 if ( $this->_sendNewUserPwd($this->data['User']['email'], $this->data['Recover']['random']) ) 57 { 58 $this->set('message', "Success. An email has been sent to: <b>".$this->data["User"]["email"]) . "</b>"; 51 if ( $this->Recover->save($this->data) ): 52 if ( $this->_sendNewUserPwd($this->data['User']['email'], $this->data['Recover']['random']) ): 53 $this->set('message', "Success. An email has been sent to: <b>".$this->data["User"]["email"]) . "</b>"; 59 54 60 $this->render('check', 'ajax');61 } 62 } 63 } 64 }55 $this->render('check', 'ajax'); 56 endif; 57 endif; 58 endif; 59 endif; 65 60 } 66 61 67 62 public function newpwd($random = null) 68 63 { 69 if ( $random == null ) 70 { 64 if ( $random == null ): 71 65 redirect('/'); 72 }66 endif; 73 67 74 68 $this->layout = 'popup'; 75 69 76 $this->pageTitle = 'Karamelo New Password';70 $this->pageTitle = __('Karamelo New Password', true); 77 71 78 72 $conditions = array("random" => $random); … … 82 76 $data = $this->Recover->find($conditions, $fields); 83 77 84 if ( $data == null ) 85 { 86 $this->redirect('/'); 87 } 88 else 89 { 90 $this->data["User"]["id"] = $data["Recover"]["user_id"]; 91 $pwd = $this->genPwd(8); 92 $this->data["User"]["passwd"] = $pwd; 78 if ( $data == null ): 79 $this->redirect('/'); 80 else: 81 82 $this->data['User']['id'] = $data['Recover']['user_id']; 83 $pwd = $this->Adds->genPassword(8); 84 $this->data['User']['pwd'] = $this->Auth->password($pwd); 93 85 94 if ( $this->Recover->User->save($this->data["User"]) ) 95 { 86 if ( $this->Recover->User->save($this->data) ): 96 87 $this->set('pwd', $pwd); 97 88 98 $this->Recover->del($data[ "Recover"]["user_id"]); //del the row99 }100 }89 $this->Recover->del($data['Recover']['user_id']); //del the row 90 endif; 91 endif; 101 92 } 102 93 … … 115 106 $this->set('random', $random); 116 107 //Do not pass any args to send() 117 if ( $this->Email->send() ) 118 { 119 return true; 120 } 121 else 122 { 108 if ( $this->Email->send() ): 109 return true; 110 else: 123 111 return false; 124 }112 endif; 125 113 } 126 114 }
