Example #1
0
 protected function testAction()
 {
     $translate = $this->application->getBootstrap()->getResource('translate');
     $view = $this->application->getBootstrap()->getResource('view');
     $view->setScriptPath(APPLICATION_PATH . '/views/scripts');
     $u = new User();
     $u_row = $u->findOne($_SERVER['argv'][6]);
     $mailer = new Logic_Mailer($view, $translate);
     $mailer->userPass('asdf', $u_row);
 }
Example #2
0
 /**
  *  Metoda do resetowanie hasla uzytkownika
  * @param integer $id - id uzytkownika
  */
 public function _resetPassword($id)
 {
     try {
         $user = new User();
         $pass = Base_PasswordGenerator::generate();
         $config = Zend_Registry::get('config');
         $timeOffset = $config['login']['dafault']['freeDaysOffset'];
         if (!empty($timeOffset) && $timeOffset == 1) {
             $offset = $timeOffset . ' day';
         } elseif (!empty($timeOffset) && $timeOffset > 1) {
             $offset = $timeOffset . ' days';
         }
         $date = new DateTime(date('c'));
         $date->modify($offset);
         $values['password'] = $pass['hashed'];
         $values['tmp_password'] = true;
         $values['valid_until'] = $date->format('c');
         $userRow = $user->findOne($id);
         // $resetPassEvent = new Logger_Event_Logic('editUser','Zresetowanie hasła użytkownika '.$userRow['login']);
         $userRow->setFromArray($values);
         // $changes = $userRow->getUpdatedFields();
         // $resetPassEvent->addItem('Zmiana daty', $changes, null); */
         $userRow->save();
         unset($values['valid_until']);
         $userPassword = new UserPassword();
         $select = $userPassword->select()->where('id_user = ?', $id)->where('ghost = false')->setIntegrityCheck(false);
         $dataArray = $userPassword->fetchAll($select);
         $dataArray = $dataArray->toArray();
         foreach ($dataArray as $key => $value) {
             $passRow = $userPassword->findOne($value['id']);
             $passRow->setFromArray(array('ghost' => true));
             $changes = $passRow->getUpdatedFields();
             //                $resetPassEvent->addItem('Dezaktywacja poprzedniego hasła', $changes, null);
             $passRow->save();
         }
         $values['id_user'] = $id;
         $rowPassword = $userPassword->createRow($values);
         $params = $rowPassword->getUpdatedFieldsOnlyNew();
         //            $resetPassEvent->addItem('Wprowadzenie nowego hasła', null, $params);
         $rowPassword->save();
         //            $this->logEvent($resetPassEvent);
         $mailer = new Logic_Mailer(Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view'), $translate);
         $user_row = $user->findOne($id);
         $mailer->userPass($pass['clean'], $user_row);
         // $logger = Zend_Registry::get('logger');
         // $logger['messages']['User'][$id] = 'Password was reset.';
         // Zend_Registry::set('logger', $logger);
     } catch (Exception $e) {
         // $logger = Zend_Registry::get('logger');
         // $logger['messages']['User'][$id] = 'Faile while password reset.';
         // Zend_Registry::set('logger', $logger);
         throw $e;
     }
 }