Example #1
0
 function panel()
 {
     $this->load->model('user');
     $this->load->model('script');
     $this->load->library('facebook');
     if ($signedUp = $this->session->flashdata('signedUp')) {
         $this->session->keep_flashdata('signedUp');
         $viewData['signedUp'] = $signedUp;
     }
     if ($this->input->post('changePassword')) {
         if ($this->_checkToken()) {
             $this->load->library('validation');
             $rules['currentPassword'] = '******';
             $rules['newPassword'] = '******';
             $rules['newPasswordRepeat'] = 'required|matches[newPassword]';
             $fields['currentPassword'] = '******';
             $fields['newPassword'] = '******';
             $fields['newPasswordRepeat'] = 'new password repeated';
             $this->validation->set_rules($rules);
             $this->validation->set_fields($fields);
             if ($this->validation->run() === true) {
                 $user = new User();
                 $user->setKey($this->_getUser());
                 $user->retrieve();
                 if ($user->get('password') === $user->makePass($this->input->post('currentPassword'))) {
                     $user->set('password', $user->makePass($this->input->post('newPassword')));
                     $viewData['checkpoints'][] = 'You have successfully changed your password.';
                     $user->update();
                 } else {
                     $viewData['errors'][] = 'You did not enter your current password correctly.';
                 }
             }
         }
     }
     $viewData['token'] = $this->_token();
     $user = new User();
     $script = new Script();
     $user->retrieve($this->session->userdata('email'));
     if ($user->getType() === User::FB_CONNECT) {
         $viewData['email'] = false;
         $viewData['UID'] = $user->getKey();
         $viewData['name'] = $user->name();
         $viewData['institution'] = $user->institution();
         if (!($subject = $user->subject())) {
             $subject = 'Not specified on Facebook';
         }
         $viewData['subject'] = $subject;
         $viewData['fbEmail'] = $user->get('fbEmail');
     } else {
         $viewData['email'] = $user->getKey();
         $viewData['name'] = $user->get('name');
         $user->get('subject') ? $viewData['subject'] = $user->get('subject') : ($viewData['subject'] = 'Not specified');
         $viewData['institution'] = $user->get('institution');
     }
     //$viewData['messages'][] = 'We are on day '.ceil((time() - 1229536800)/86400).' of the Exambuff pilot. Thanks for taking part!';
     $this->_template('user/panel', 'Your account', 'my-account', $viewData);
 }
Example #2
0
 /**
  * Sets up the usersign up form and validation rules. On submission creates a user and an
  * activation object stores them, and calls emailActivation.
  *
  */
 function index()
 {
     $this->load->helper('url');
     if ($this->session->userdata('email')) {
         redirect('/user/login');
     }
     $this->load->helper('url');
     $this->load->library('validation');
     // set rules
     $rules['name'] = 'required|callback_alphaAndWhiteSpace|max_length[64]|min_length[1]';
     $rules['email'] = 'required|valid_email|max_length[60]';
     $rules['password'] = '******';
     $rules['repeatPassword'] = '******';
     $rules['subject'] = 'callback_alphaAndWhiteSpace|max_length[40]';
     $rules['institution'] = 'callback_alphaAndWhiteSpace|max_length[50]';
     $fields['name'] = 'Name';
     $fields['email'] = 'Email';
     $fields['password'] = '******';
     $fields['repeatPassword'] = '******';
     $fields['subject'] = 'Subject';
     $fields['institution'] = 'Institution';
     $this->validation->set_message('alphaAndWhiteSpace', '%s contains invalid characters. Please enter only letters and spaces.');
     $this->validation->set_rules($rules);
     $this->validation->set_fields($fields);
     // validate
     if ($this->validation->run() == TRUE) {
         $this->lang->load('usersignup');
         if ($this->_checkToken()) {
             $this->load->model('user');
             $user = new User();
             $user->buildFromPost();
             if ($user->create()) {
                 $this->load->model('activator');
                 $this->activator->generateKey();
                 $this->activator->set('email', $user->getKey());
                 $this->activator->create();
                 $fullName = explode(' ', $user->get('name'));
                 $name = $fullName[0];
                 $this->emailActivation($user->getKey(), $name, $this->activator->getKey());
                 redirect('/user/signup/signedup');
             } else {
                 // something has gone wrong with creating a new user - very likely they already exsist
                 $viewData['errors'][] = $this->lang->line('emailUsed');
             }
         }
     }
     $token = $this->_token();
     $viewData['token'] = $token;
     $viewData['formAction'] = 'user/signup';
     $this->load->view('html_head.php');
     $this->load->view('page_head.php', array('userAuth' => @$this->session->userdata('email'), 'markerAuth' => @$this->session->userdata('markerEmail'), 'site_pages' => $this->config->item('site_pages'), 'bodyId' => 'sign-up-login'));
     $this->load->view('forms/user_sign_up', $viewData);
     $this->load->view('footer', array('site_pages' => $this->config->item('site_pages')));
 }
Example #3
0
 /**
  * Stores new account
  *
  */
 public function store()
 {
     $user = new User();
     $user->first_name = Input::get('first_name');
     $user->last_name = Input::get('last_name');
     $user->username = Input::get('username');
     $user->email = Input::get('email');
     $user->password = Input::get('password');
     User::setRules('store');
     // Hacky workaround for: https://github.com/laravelbook/ardent/issues/152
     if (app()->env === 'testing') {
         unset(User::$rules['password_confirmation']);
         unset(User::$rules['password']);
     } else {
         $user->password_confirmation = Input::get('password_confirmation');
     }
     $user->save();
     if ($user->getKey()) {
         $notice = Lang::get('confide::confide.alerts.account_created') . ' ' . Lang::get('confide::confide.alerts.instructions_sent');
         $user->roles()->sync([6]);
         // Redirect with success message, You may replace "Lang::get(..." for your custom message.
         return Redirect::action('AuthController@login')->with('notice', $notice);
     } else {
         // Get validation errors (see Ardent package)
         $error = $user->errors()->all(':message');
         return Redirect::action('AuthController@create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
Example #4
0
 /**
  * calculate statistics
  *
  * @param User $user
  * @return mixed
  */
 private function evalStatistics(User $user)
 {
     if (!isset($this->statistics[$user->getKey()])) {
         $totalPrice = 0;
         $orderCount = 0;
         $orders = Order::query()->whereUserId($user->getKey())->get();
         foreach ($orders as $order) {
             if ($order->delivery->store == $this) {
                 $totalPrice += $order->dish->price;
                 $orderCount++;
             }
         }
         $this->statistics[$user->getKey()] = ['spend' => $totalPrice, 'ordersCount' => $orderCount];
     }
     return $this->statistics[$user->getKey()];
 }
Example #5
0
 /**
  * Returns the nodes view
  *
  * @return string
  */
 public function getNodesView()
 {
     return $this->getView('partials.navigation.nodes', [], ['reactor.views.navigation.nodes'], $this->user->getKey());
 }