- Timestamp:
- 07/23/08 01:12:58 (4 months ago)
- Location:
- trunk/app
- Files:
-
- 3 modified
-
controllers/recovers_controller.php (modified) (4 diffs)
-
controllers/users_controller.php (modified) (2 diffs)
-
views/recovers/newpwd.ctp (modified) (1 diff)
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 } -
trunk/app/controllers/users_controller.php
r637 r670 281 281 282 282 /** Check Passwd **/ 283 if (strlen($this->data['User']['pwd']) < 6) 284 { 283 if (strlen($this->data['User']['pwd']) < 6): 285 284 $message['pwd_wrong'] = 'The password have less than 6 characters '; 286 } 287 288 if (strpos($this->data['User']['username'], ' ')) // no spaces 289 { 285 endif; 286 287 if (strpos($this->data['User']['username'], ' ')): // no spaces 290 288 $message['username_spaces'] = 'Your username should not contain spaces'; 291 }289 endif; 292 290 293 291 /** username check **/ 294 if (strlen($this->data['User']['username']) < 5) 295 { 292 if (strlen($this->data['User']['username']) < 5): 296 293 $message['pwd_username'] = "The username has less than 5 characters "; 297 }294 endif; 298 295 299 296 /** name check **/ 300 if (strlen($this->data['User']['name']) < 5) 301 { 297 if (strlen($this->data['User']['name']) < 5): 302 298 $message['pwd_username'] = "The name is too short"; 303 } 304 305 if (strpos($this->data['User']['pwd'], ' ')) // pwd too short 306 { 299 endif; 300 301 if (strpos($this->data['User']['pwd'], ' ')): // pwd no spaces 307 302 $message['username_spaces'] = "Your password should not contain spaces"; 308 }303 endif; 309 304 310 305 /** description check **/ 311 if (strlen($this->data['User']['description']) < 5) 312 { 306 if (strlen($this->data['User']['description']) < 5): 313 307 $message['description_too_short'] = "C'mon pal, talk us about you!"; 314 }308 endif; 315 309 316 310 /** email check **/ 317 if ($this->Adds->validEmail($this->data['User']['email']) === false) 318 { 311 if ($this->Adds->validEmail($this->data['User']['email']) === false): 319 312 $message['pwd_username'] = "Typed email is invalid"; 320 }313 endif; 321 314 322 315 /** Check the user **/ 323 316 $username = $this->User->field('username', array('username' => $this->data['User']['username'])); 324 317 325 if ($username != null) 326 { 318 if ($username != null): 327 319 $message['username_exist'] = 'The username already exist '; 328 }320 endif; 329 321 330 322 /** Check the email **/ 331 323 $email = $this->User->field('email', array('email' => $this->data['User']['email'])); 332 324 333 if ($email != null) 334 { 325 if ($email != null): 335 326 $message['email_exist'] = 'The email already exist '; 336 }327 endif; 337 328 338 329 // get the secret code for teachers registration process 339 330 $code = $this->User->Group->field('code', array('id'=>$this->data['User']['group_id'])); 340 331 341 if ( $this->data['User']['code'] != $code ) 342 { 332 if ( $this->data['User']['code'] != $code ): 343 333 $message['wrong_code'] = "The code is incorrect, please put in contact with your school webmaster."; 344 } 345 346 if ( count($message) > 1 ) 347 { 334 endif; 335 336 if ( count($message) > 1 ): 348 337 $this->set('message', $message); 349 338 $this->render('validate', 'ajax'); //if error exist, stop here 350 351 } 352 else 353 { 339 else: 354 340 $this->data['User']['active'] = 0; 355 341 $this->data['User']['name_blog'] = $this->data['User']['username'].'\'s corner'; 356 $this->User->create(); 357 //exit(var_dump($this->data["User"])); 358 if ($this->User->save($this->data['User'])) 359 { 342 343 if ($this->User->save($this->data)): 360 344 $this->data['Confirm']['user_id'] = $this->User->getLastInsertID(); // the user id 361 345 $this->data['Confirm']['secret'] = $this->Adds->genPassword(14); // secret confirm ID … … 364 348 365 349 // put the user in confirm model, this is, waiting for user confirmation trough email 366 if ($this->User->Confirm->save($this->data["Confirm"])) 367 { 350 if ($this->User->Confirm->save($this->data['Confirm'])): 368 351 //Send the confirmation email 369 if ( $this-> _sendNewUserPwd($this->data['User']['email'], $this->data['Confirm']['secret']) ) 370 { 352 if ( $this->_sendNewUserPwd($this->data['User']['email'], $this->data['Confirm']['secret']) ): 371 353 $msg = "<h2>You have been registered!</h2> <p>A confirmation email has been sent to: ".$this->data['User']['email']; 372 354 $msg .= " In order to complete the registration process, please click on the link contained on the email.</p>"; 373 $this->set('message', array( "Suceess"=>$msg));355 $this->set('message', array('Sucess'=>$msg)); 374 356 $this->set('ok', true); 375 357 $this->render('validate', 'ajax'); 376 } 377 } 378 } 379 else 380 { 358 endif; 359 endif; 360 else: 381 361 $this->set('message', array("Error"=>"Error, something is wrong in save method")); 382 362 $this->render('validate', 'ajax'); 383 } 384 }363 endif; 364 endif; 385 365 } 386 366 } -
trunk/app/views/recovers/newpwd.ctp
r339 r670 1 <div style="width: 50%;margin:0 auto 0 auto;border:1px dotted orange;padding:15px">1 <div style="width:80%;margin:0 auto 0 auto;border:1px dotted orange;padding:8px"> 2 2 <?php 3 3 4 if ( isset($error) ) 5 { 4 if ( isset($error) ): 6 5 echo '<span style="color:red;padding:7px;">Error: no such key.</span>'; 7 } 6 endif; 8 7 9 if ( isset($pwd) ) 10 { 11 echo '<span style="color:blue;padding:7px;">Your new passwdord is <b>' . $pwd . '</b>, don\'t lose! ;-)</span> <br />'; 8 if ( isset($pwd) ): 9 echo '<span style="color:blue;padding:7px;">'.__('Your new password is', true). ' <b>' . $pwd . '</b>,'. __('do not forget', true).'! ;-)</span> <br />'; 12 10 13 11 echo $html->link('login', '/users/login'); 14 } 12 endif; 15 13 ?> 16 14 </div>
