Example #1
0
 public function profile()
 {
     $this->load->library('form_validation');
     $text = '';
     $this->form_validation->set_rules('avatar_usage', '', 'trim|required');
     if ($this->form_validation->run()) {
         $status = $this->users_global->setAvatarSetting($this->input->post('facebook_profile'), $this->input->post('google_profile'), $this->input->post('twitter_profile'), $this->input->post('avatar_usage'), 'avatar_file');
         if ($status['error'] > 0) {
             $text = '&info=' . translate('Fields succefully updated, error occured during file upload, please check file weight and try again.');
         }
     }
     $this->load->library('form_validation');
     if ($this->input->post('user_name') || $this->input->post('user_surname') || $this->input->post('user_state') || $this->input->post('user_town') || $this->input->post('bio')) {
         set_user_meta('name', $this->input->post('user_name'));
         set_user_meta('surname', $this->input->post('user_surname'));
         set_user_meta('state', $this->input->post('user_state'));
         set_user_meta('town', $this->input->post('user_town'));
         set_user_meta('bio', $this->input->post('bio'));
         $this->url->redirect($this->url->site_url() . '?notice=profile-updated' . $text);
     }
     if ($this->input->post('dashboard_theme') || $this->input->post('user_oldpass') || $this->input->post('user_newpass') || $this->input->post('user_confirmnewpass')) {
         if ($this->input->post('user_oldpass')) {
             $info = '';
             if ($this->input->post('user_newpass') == $this->input->post('user_confirmnewpass')) {
                 $result = current_user()->updainitsword($this->input->post('user_oldpass'), $this->input->post('user_newpass'));
                 if ($result) {
                     $info = '&info=' . __('Password has been changed');
                 } else {
                     $info = '&info=' . __('Error occured while changing password. Check if your old password doesn\'t match the new one');
                 }
             } else {
                 $info = '&info=' . __('Error occured while changing password. The new password and the confirmation doesn\'t match.');
             }
         }
         set_user_meta('dashboard_theme', between(0, 6, $dashboard_theme = $this->input->post('dashboard_theme')) ? $dashboard_theme : 0);
         $this->url->redirect($this->url->site_url() . '?notice=profile-updated' . $info);
     }
     // Admin Widget Section
     if (riake('widget_action', $_POST) || riake('widget_namespace', $_POST)) {
         $this->users_global->setAdminWidgets($_POST);
         $this->url->redirect(array('admin', 'profile?notice=done'));
     }
     if ($this->input->post('reset_account')) {
         current_user()->reset();
         $this->url->redirect(array('admin', 'profile?notice=user-meta-has-been-reset'));
     }
     set_page('title', riake('site_name', $this->options) . ' | ' . ucfirst(current_user('PSEUDO')) . ' » ' . translate('My Profile'));
     set_page('description', translate('My Profile'));
     $this->load->the_view('admin/profile/body');
 }
 /**
  *	resetUserWidgetInterface : Reorganise les widgets sur le tableau de bord
  **/
 public function resetUserWidgetInterface()
 {
     // Suppression préalable
     set_user_meta('widget_0', array());
     set_user_meta('widget_1', array());
     set_user_meta('widget_2', array());
     // Boucle la !!!
     for ($i = 0; $i < 3; $i++) {
         // -=-=-=-=-=-=-=-=-=-=-=-=-=-=
         if (array_key_exists('widget_' . $i, $_POST)) {
             $values = array();
             if (is_array($_POST['widget_' . $i])) {
                 $values = array_values($_POST['widget_' . $i]);
             }
             set_user_meta('widget_' . $i, $values);
         }
     }
 }