Exemple #1
0
 function get_list($page = 1)
 {
     // Nb and Minimum
     $nb = $this->input->post('nb') ? $this->input->post('nb') : '50';
     if ($nb < 25) {
         $nb = 25;
     }
     $page = $page - 1;
     $offset = $page * $nb;
     // Send the filter elements to the view
     $this->template['filter'] = array();
     // Like conditions
     $like = array();
     foreach (array('username', 'screen_name', 'email') as $key) {
         if ($this->input->post($key)) {
             $like[$key] = $this->input->post($key);
             $this->template['filter'][$key] = $like[$key];
         }
     }
     // Where
     $where = array();
     if ($this->input->post('id_role')) {
         $this->template['filter']['id_role'] = $this->input->post('id_role');
         $where['user.id_role'] = $this->input->post('id_role');
     }
     // Order by last registered
     if ($this->input->post('registered')) {
         $where['order_by'] = 'join_date DESC';
     }
     $where = array_merge($where, array('limit' => $nb, 'offset' => $offset, 'like' => $like, 'role_level <= ' => $this->current_role['role_level']));
     // Get user list filtered on levels <= current_user level
     $this->template['users'] = $this->user_model->get_list_with_role($where);
     // Pagination
     $this->template['current_page'] = $page + 1;
     $this->template['nb'] = $nb;
     $this->template['users_count'] = $this->user_model->count($where);
     $this->template['users_pages'] = ceil($this->template['users_count'] / $nb);
     // XHR answer
     $this->output('user/list');
 }
Exemple #2
0
 /**
  * Delete
  * 
  */
 public function delete()
 {
     $id_role = $this->input->post('id_role');
     // Safe : Do not delete Role linked to users
     $nb_users = $this->user_model->count(array('user.id_role' => $id_role));
     if ($nb_users > 0) {
         $this->error(lang('ionize_message_role_no_delete_users_linked'));
     } else {
         $affected_rows = $this->role_model->delete($id_role);
         if ($affected_rows > 0) {
             // Update role list panel
             $this->_reload_role_list();
             $this->success(lang('ionize_message_role_deleted'));
         } else {
             $this->error(lang('ionize_message_role_not_deleted'));
         }
     }
 }