Source for file RestorePassword.class.php

Documentation is available at RestorePassword.class.php

  1. /**
  2.  * Содержит класс RestorePassword
  3.  *
  4.  * @package energine
  5.  * @subpackage user
  6.  * @author dr.Pavka
  7.  * @copyright ColoCall 2006
  8.  * @version $Id: fsource_energine_user_modulesusercomponentsRestorePassword.class.php.html,v 1.1 2007/09/17 14:32:36 pavka Exp $
  9.  */
  10.  
  11. require_once('core/modules/share/components/DataSet.class.php');
  12. require_once('core/framework/Mail.class.php');
  13.  
  14. /**
  15.  * Форма восстановления пароля
  16.  *
  17.  * @package energine
  18.  * @subpackage user
  19.  */
  20. class RestorePassword extends DataSet {
  21.     /**
  22.      * Конструктор класса
  23.      *
  24.      * @param string $name 
  25.      * @param string $module 
  26.      * @param Document $document 
  27.      * @param array $params 
  28.      * @access public
  29.      */
  30.     public function __construct($name$moduleDocument $document,  array $params null{
  31.         parent::__construct($name$module$document,  $params);
  32.         $this->setDataSetAction('send');
  33.     }
  34.  
  35.     /**
  36.      * Переопределен параметр active
  37.      *
  38.      * @return int 
  39.      * @access protected
  40.      */
  41.  
  42.     protected function defineParams({
  43.         $result = array_merge(parent::defineParams(),
  44.         array(
  45.         'active'=>true,
  46.         ));
  47.         return $result;
  48.     }
  49.     /**
  50.      * Отправляет новый пароль на указанный email
  51.      *
  52.      * @return void 
  53.      * @access protected
  54.      */
  55.  
  56.     protected function send({
  57.         $this->document->componentManager->getComponentByName('breadCrumbs')->addCrumb();
  58.         if ($component $this->document->componentManager->getComponentByName('textBlockRestorePassword')) {
  59.              $component->disable();
  60.          }
  61.         if (!isset($_POST['u_name'])) {
  62.             $message $this->translate('ERR_NO_U_NAME');
  63.         }
  64.         else {
  65.             $uName $_POST['u_name'];
  66.             $UID simplifyDBResult($this->dbh->select('user_Users''u_id'array('u_name'=>$uName))'u_id'true);
  67.             if (!$UID{
  68.                 $message $this->translate('ERR_NO_U_NAME');
  69.             }
  70.             else {
  71.                 $password User::generatePassword();
  72.                 $this->dbh->modify(QAL::UPDATE'user_Users'array('u_password'=>sha1($password))array('u_id'=>$UID));
  73.                 $mailer new Mail();
  74.                 $mailer->setFrom($this->getConfigValue('mail.from'))->
  75.                     setSubject($this->translate('TXT_SUBJ_RESTORE_PASSWORD'))->
  76.                     setText(sprintf($this->translate('TXT_BODY_RESTORE_PASSWORD'),$password))->
  77.                     addTo($uName);
  78.                 $message $this->translate('MSG_PASSWORD_SENT');
  79.                 try {
  80.                     $mailer->send();
  81.                 }
  82.                 catch (Exception $e{
  83.                     $message $e->getMessage();
  84.                 }
  85.             }
  86.         }
  87.         $this->prepare();
  88.         $data new Data();
  89.         $messageField new Field('restore_password_result');
  90.         $messageField->setData($message);
  91.         $data->addField($messageField);
  92.         $this->setData($data);
  93.     }
  94. }

Documentation generated on Mon, 17 Sep 2007 13:31:24 +0300 by phpDocumentor 1.4.0a2