コード例 #1
0
 /**
  * Register action : create a new account
  * @access public
  * @return void
  */
 public function register()
 {
     $this->form = new UserCreateForm();
     if ($this->request->is_post()) {
         if (!$this->form->is_valid($this->params['account'])) {
             $this->flash['error'] = __('Fail to create account : Check data.');
             return;
         }
         $this->user = new User($this->form->cleaned_data);
         if (!$this->user->save()) {
             $this->form->errors = new SFormErrors($this->user->errors);
             $this->flash['error'] = __('Fail to create account : Check data.');
             return;
         }
         $logger = new SLogger('../log/account.log');
         $logger->info("{$this->user->login} ({$this->user->id}) signup");
         $this->session['user'] = $this->user;
         $mailer = new ApplicationMailer();
         $mailer->send_signup_notification($this->user);
         $this->redirect_to(home_url());
     }
 }
コード例 #2
0
 /**
  * Lost action : if user has lost his password
  * @access public
  * @return void
  */
 public function lost()
 {
     $this->form = new LostLoginForm();
     $req = new SRequestParams();
     if ($this->request->is_post()) {
         if ($this->form->is_valid($this->params['user'])) {
             try {
                 $user = User::$objects->get('email = ?', array($this->params['user']['email']));
                 $mailer = new ApplicationMailer();
                 $mailer->send_password_reminder($user);
                 $logger = new SLogger('../log/account.log');
                 $logger->info("{$user->login} ({$user->id}) password reminder sent to <{$user->email}>");
                 $this->flash['notice'] = __('Password reminder has been sent to you by email');
                 $this->redirect_to_login();
                 return;
             } catch (SRecordNotFound $e) {
                 $this->flash['error'] = __('This email address is not registered');
                 $this->form->errors = new SFormErrors(array('email' => __('Email not found')));
                 return;
             }
         }
         $this->flash['error'] = __('You have to give a valid registered email address.');
     }
 }
コード例 #3
0
ファイル: logger.php プロジェクト: BackupTheBerlios/stato-svn
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         switch (APP_MODE) {
             case 'dev':
                 $filename = 'development.log';
                 break;
             case 'prod':
                 $filename = 'production.log';
                 break;
             case 'test':
                 $filename = 'test.log';
                 break;
         }
         if (!file_exists($path = ROOT_DIR . '/log/' . $filename)) {
             throw new SException('Log file does not exist');
         }
         self::$instance = new SLogger($path);
     }
     return self::$instance;
 }
コード例 #4
0
 public function __construct()
 {
     $this->view = new SActionView($this);
     $this->session = new SSession();
     $this->flash = new SFlash($this->session);
     $this->logger = SLogger::getInstance();
     $this->pageCacheDir = ROOT_DIR . '/public/cache';
 }
コード例 #5
0
 public function send(SMail $mail)
 {
     SLogger::get_instance()->log($mail->__toString());
 }