Ejemplo n.º 1
0
 function index()
 {
     if ($this->input->post('emails')) {
         $this->load->library('validation');
         $rules['emails'] = 'valid_emails|required';
         $fields['emails'] = 'referree emails';
         $this->validation->set_fields($fields);
         $this->validation->set_rules($rules);
         $this->validation->set_message('valid_emails', 'All email addresses entered into %s must be valid, seperated by commas');
         if ($this->validation->run() === TRUE) {
             $emails = explode(',', $this->input->post('emails'));
             $this->load->model('referral');
             foreach ($emails as $email) {
                 $referral = new Referral();
                 $referral->set('user', $this->_getUser());
                 $referral->set('referee', trim($email));
                 $referral->set('ipRequested', @$_SERVER['REMOTE_ADDR']);
                 if ($referral->create()) {
                     $viewData['checkpoints'][] = "You have successfully sent a referral email to {$email}.";
                 } else {
                     $viewData['errors'][] = "A referral email has already been sent to {$email}.";
                 }
             }
         }
     }
     if ($this->validation->error_string) {
         $viewData['errors'][] = $this->validation->error_string;
     }
     $viewData['token'] = $this->_token();
     $this->load->library('templatedata');
     $templateData = new TemplateData();
     $templateData->setHead('Refer a friend and get cash back');
     $templateData->setView($viewData);
     $this->_template('user/referral', $templateData);
 }
Ejemplo n.º 2
0
 /**
  * Loads standard Exambuff template, either using title, and bodyid or a complete TemplateData object passed as the second arg.
  * @param $view Name of view required
  * @param $title String || $templateData TemplateData - either title string or complete TemplateData object
  * @param $bodyID String
  * @param $viewData array
  */
 function _template($view, $title = null, $bodyID = null, $viewData = null)
 {
     if (get_class(func_get_arg(1)) === 'TemplateData') {
         $templateData = $title;
     } else {
         $this->load->library('templatedata');
         $templateData = new TemplateData();
         $templateData->setHead($title);
         $templateData->setPage($bodyID);
         $templateData->setView($viewData);
     }
     if ($templateData->page) {
         $templateData->setPage(array_merge($templateData->page, array('userAuth' => @$this->session->userdata('email'), 'markerAuth' => @$this->session->userdata('markerEmail'))));
     } else {
         $templateData->setPage(array('userAuth' => @$this->session->userdata('email'), 'markerAuth' => @$this->session->userdata('markerEmail')));
     }
     $templateData->setFooter($templateData->footer + $this->_fbToken());
     $this->load->view('html_head.php', $templateData->head);
     $this->load->view('page_head.php', $templateData->page);
     $this->load->view($view, $templateData->view);
     $this->load->view('footer', $templateData->footer);
 }
Ejemplo n.º 3
0
 public function forgottenPassword()
 {
     $this->load->library('templatedata');
     $viewData['formAction'] = $this->_selfURL . '/forgottenpassword';
     if ($this->input->post('resetPass')) {
         $rules['email'] = 'required|valid_email';
         $fields['email'] = 'email';
         $this->validation->set_rules($rules);
         $this->validation->set_fields($fields);
         if ($this->validation->run() === true) {
             if ($this->_checkToken()) {
                 // store all flavours of user model in $this->user - so marker, control etc will all
                 // go under $this->user, as they all implement the same interface
                 $this->load->model($this->_userModel, 'user');
                 $this->user->setKey($this->input->post('email'));
                 if ($this->user->retrieve()) {
                     $emailData['resetKey'] = $this->user->createPasswordResetKey();
                     $emailData['resetURL'] = $this->_selfURL . '/reset/';
                     $msg = $this->load->view('email/password_reset', $emailData, true);
                     $subject = 'You requested a password reset';
                     $pass = '******';
                     $sender = '*****@*****.**';
                     $this->load->library('swiftwrap');
                     $this->swiftwrap->email($sender, $pass, $this->input->post('email'), $subject, $msg);
                 }
                 $viewData['checkpoints'][] = 'Please check your email: you have been sent an email explaining how to generate a new password.';
             } else {
                 $viewData['errors'][] = 'Your form submission was invalid. Please retry';
             }
         }
     }
     $viewData['token'] = $this->_token();
     $templateData = new TemplateData();
     $templateData->setHead('Reset your password');
     $templateData->setView($viewData);
     $this->_template('forms/password_reset', $templateData);
 }