Example #1
0
 public static function init($modelName)
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new self($modelName);
     }
     return self::$_instance;
 }
Example #2
0
 /**
  * sendResetMail
  *
  */
 public static function sendResetMail($data, $user)
 {
     $modelName = $data['model'];
     $loader = ReminderConfigLoader::init($modelName);
     $email = new CakeEmail('reminder');
     $from = $email->from();
     if (empty($from)) {
         $email->from('*****@*****.**', 'Reminder');
     }
     $subject = $loader->load('subject');
     if (empty($subject)) {
         $subject = $email->subject();
     }
     if (empty($subject)) {
         $subject = 'Reminder';
         // default
     }
     $email->subject($subject);
     $email->to($data['email']);
     $template = $loader->load('view.reset_mail');
     if (empty($template)) {
         $template = 'reset_mail';
     }
     $email->template('Reminder.' . $template);
     $email->viewVars(array('data' => $data, 'user' => $user));
     return $email->send();
 }
Example #3
0
 /**
  * findActiveReminder
  *
  */
 public function findActiveReminder($hash)
 {
     $query = array('conditions' => array('Reminder.hash' => $hash, 'expired' => null));
     $result = $this->find('first', $query);
     if (empty($result)) {
         throw new UnauthorizedException();
     }
     $modelName = $result['Reminder']['model'];
     $loader = ReminderConfigLoader::init($modelName);
     $created = $result['Reminder']['created'];
     $expire = $loader->load('expire');
     if (strtotime($created) > strtotime('+' . $expire . ' seconds')) {
         throw new UnauthorizedException();
     }
     return $result;
 }
Example #4
0
 /**
  * complete
  *
  */
 public function complete($hash)
 {
     $reminder = $this->Reminder->findReminder($hash);
     $modelName = $reminder['Reminder']['model'];
     $loader = ReminderConfigLoader::init($modelName);
     $layout = $loader->load('layout');
     $account = $this->Reminder->findAccount($reminder);
     if (empty($account)) {
         throw new NotFoundException();
     }
     $this->set(array('hash' => $hash, 'account' => $account, 'modelName' => $modelName));
     $view = $loader->load('view.complete');
     if (empty($view)) {
         $view = 'complete';
     }
     return $this->render($view, $layout);
 }