]> dev.renevier.net Git - syj.git/blob - application/models/Pending/ResetPassword.php
build process raise an exception when install file contains an invalide filename
[syj.git] / application / models / Pending / ResetPassword.php
1 <?php
2 /*  This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
3     and is published under the AGPL license. */
4
5 class Syj_Model_Pending_ResetPassword extends Syj_Model_Pending
6 {
7     protected $_action = 'reset_password';
8     protected $_newpwd;
9     protected function _run() {
10         $this->_newpwd = pwdgen\PwdGenerator::generate();
11         $this->_user->password = sha1($this->_newpwd);
12         $userMapper = new Syj_Model_UserMapper();
13         $userMapper->save($this->_user);
14         return true;
15     }
16     public function _notify() {
17         switch ($this->_notifications_number) {
18             case 0:
19                 $subject = $this->translate("[SYJ] Reset your password", $this->_user->lang);
20                 $text = $this->translate("Hi %user%,
21
22 Someone, probably you, has asked to reset your password. If you want to reset
23 your password, please follow this link:
24 %hashurl%
25
26 If you do not not confirm within 2 days, your password will not be reset.
27
28 Please do not reply this email. If you need to contact us, please use the form
29 contact at %contacturl%
30
31 Thanks,
32
33 Syj team", $this->_user->lang);
34             break;
35         }
36
37         $text = str_replace('%user%', $this->_user->pseudo, $text);
38         $text = str_replace('%hashurl%', $this->getHashUrl(), $text);
39         $text = str_replace('%contacturl%', $this->getContactUrl(), $text);
40
41         return $this->_sendMail($subject, $text);
42     }
43     protected function _cancel() {
44         return true;
45     }
46
47     public function getNewpwd() {
48         return $this->_newpwd;
49     }
50 }