Ejemplo n.º 1
0
 /**
  * Ajout d'un User
  */
 public function add()
 {
     // Insertion en base
     $model = new User_model();
     $model->usrlbnom = $this->input->post('nom');
     $model->usrlblgn = $this->input->post('login');
     $model->usrlbpwd = $this->input->post('password');
     $model->save($this->db);
     $this->session->set_flashdata('message', formatInfo('Nouveau User ajoute'));
     // Recharge la page avec les nouvelles infos
     redirect('listusers/index');
 }
Ejemplo n.º 2
0
 /**
  * Save
  *
  */
 public function save()
 {
     if ($this->input->post('email')) {
         $id_user = $this->input->post('id_user');
         $post = $this->input->post();
         $post = array_merge($post, array('join_date' => $id_user ? $this->input->post('join_date') : date('Y-m-d H:i:s'), 'salt' => $id_user ? $this->input->post('salt') : User()->get_salt()));
         // Passwords must match
         if ($this->input->post('password') != '' && $this->input->post('password') === $this->input->post('password2')) {
             $post['password'] = User()->encrypt($this->input->post('password'), $post);
         } else {
             unset($post['password'], $post['password2']);
         }
         // New user?
         if ($id_user == false) {
             $post['id_user'] = null;
         }
         // Save
         $new_id_user = $this->user_model->save($post);
         // Send message to user if needed
         $message = $this->input->post('message');
         if (!is_null($new_id_user) && $message != '') {
             // Update
             if ($id_user) {
                 $subject = Settings::get('site_title') . ' : ' . lang('ionize_subject_your_account_has_been_updated');
                 $message_intro = lang('ionize_message_your_account_has_been_created');
             } else {
                 $subject = Settings::get('site_title') . ' : ' . lang('ionize_subject_your_account_has_been_created');
                 $message_intro = lang('ionize_message_your_account_has_been_updated');
             }
             // Group
             $user = $this->user_model->get_user(array('id_user' => $new_id_user));
             $email_data = array('message_intro' => $message_intro, 'message' => $message, 'role' => $user['role_name'], 'firstname' => $user['firstname'], 'lastname' => $user['lastname'], 'email' => $user['email'], 'username' => $post['firstname'] . ' ' . $post['lastname']);
             $this->send_email(Settings::get('site_email'), $post['email'], $subject, $email_data, 'mail/system/to_user');
         }
         // Reload user list
         if (!empty($post['from']) && $post['from'] === 'dashboard') {
             $this->_reload_dashboard();
         } else {
             $this->_reload_user_list();
         }
         // Success message
         $this->success(lang('ionize_message_user_saved'));
     }
 }
Ejemplo n.º 3
0
 public function register()
 {
     $this->load->helper('form');
     $this->load->helper('url');
     $this->load->model('user_model');
     $shops = $this->user_model->get();
     $this->load->library('form_validation');
     $this->form_validation->set_rules(array(array('field' => 'fname', 'label' => 'First Name', 'rules' => 'trim|required|alpha|min_length[3]|max_length[30]'), array('field' => 'lname', 'label' => 'Last Name', 'rules' => 'trim|required|alpha|min_length[3]|max_length[30]'), array('field' => 'email', 'label' => 'Email ID', 'rules' => 'trim|required|valid_email|is_unique[user.email]'), array('field' => 'password', 'label' => 'Password', 'rules' => 'trim|required|matches[cpassword]|md5'), array('field' => 'cpassword', 'label' => 'Confirm Password', 'rules' => 'trim|required')));
     $this->form_validation->set_error_delimiters('<div class="alert alert-error">', '</div>');
     if (!$this->form_validation->run()) {
         $this->load->view('registration_view', array());
     } else {
         //magic happens
         $this->load->model(array('user_model'));
         $user = new User_model();
         $user->fname = $this->input->post('fname');
         $user->lname = $this->input->post('lname');
         $user->username = $this->input->post('username');
         $user->email = $this->input->post('email');
         $user->pass = $this->input->post('password');
         $user->save();
         $this->load->view('registered_view', array());
     }
 }