diff --git a/application/controllers/admin/users.php b/application/controllers/admin/users.php index 480812c..71ec46a 100644 --- a/application/controllers/admin/users.php +++ b/application/controllers/admin/users.php @@ -30,11 +30,11 @@ require_once APPPATH . 'core/Admin_Controller.php'; class Users extends Admin_Controller { /** - * Constructor. + * Calls the parent constructor. */ public function __construct() { parent::__construct(); - $this->load->model('user'); + $this->load->model('group'); $this->load->library('form_validation'); } @@ -42,8 +42,7 @@ class Users extends Admin_Controller { * Shows a list of all users. */ public function index() { - $data['users'] = $this->user->getAll(); - $this->load->view('admin/users/list', $data); + $this->load->view('admin/users/list', array('users' => $this->user->getAll())); } /** @@ -57,16 +56,25 @@ class Users extends Admin_Controller { 'firstname' => $this->input->post('firstname'), 'lastname' => $this->input->post('lastname'), 'institution' => $this->input->post('institution'), - 'phone' => $this->input->post('phone') + 'phone' => $this->input->post('phone'), + 'group_id' => $this->input->post('group_id'), ); if ($this->user->register($username, $this->input->post('password'), $this->input->post('email'), $data)) { - $this->messages->add(sprintf(_("The user '%s' has been created successfully"), $username), 'success'); redirect('admin/users', 303); + } else { + $this->messages->add(_("Something went wrong with the action you performed."), 'error'); } } - $this->load->view('admin/users/create'); + $data = array(); // empty data array + $data['groups'] = $this->group->getAll(); + + // get default group + $this->load->config('auth'); + $data['default'] = $this->group->getByName($this->config->item('default_group', 'auth')); + + $this->load->view('admin/users/create', $data); } /** @@ -87,16 +95,21 @@ class Users extends Admin_Controller { 'firstname' => $this->input->post('firstname'), 'lastname' => $this->input->post('lastname'), 'institution' => $this->input->post('institution'), - 'phone' => $this->input->post('phone') + 'phone' => $this->input->post('phone'), + 'group_id' => $this->input->post('group_id'), ); if ($this->user->update($user['id'], $data)) { - $this->messages->add(sprintf(_("The user '%s' has been updated successfully"), $user['username']), 'success'); - redirect('admin/users', 303); + $this->messages->add(sprintf(_("The user "%s" has been updated successfully."), $user['username']), 'success'); } + redirect('admin/users', 303); } - $this->load->view('admin/users/edit', array('user' => $user)); + $data = array(); // empty data array + $data['user'] = $user; + $data['groups'] = $this->group->getAll(); + + $this->load->view('admin/users/edit', $data); } /** @@ -111,7 +124,6 @@ class Users extends Admin_Controller { show_404(); } else { $this->user->delete($user['id']); - $this->messages->add(_("The selected user has been deleted successfully"), 'success'); redirect('admin/users', 303); } } diff --git a/application/models/group.php b/application/models/group.php index 0641d65..51cdccd 100644 --- a/application/models/group.php +++ b/application/models/group.php @@ -40,8 +40,12 @@ class Group extends CI_Model { * * @return array */ - public function get() { - return $this->db->get('groups')->result_array(); + public function getAll() { + $groups = array(); + foreach ($this->db->get('groups')->result_array() as $group) { + $groups[$group['id']] = $group['description']; + } + return $groups; } /** diff --git a/application/views/admin/users/create.php b/application/views/admin/users/create.php index 24bf724..a0b9a6a 100644 --- a/application/views/admin/users/create.php +++ b/application/views/admin/users/create.php @@ -3,7 +3,7 @@
-

+

»

@@ -11,52 +11,52 @@

@@ -66,23 +66,24 @@
- +
  • - +
  • - + +

    -load->view('footer');?> \ No newline at end of file +load->view('footer');?> diff --git a/application/views/admin/users/edit.php b/application/views/admin/users/edit.php index 9e4ed0b..56fb4b6 100644 --- a/application/views/admin/users/edit.php +++ b/application/views/admin/users/edit.php @@ -3,37 +3,40 @@
    -

    +

    »

    -
    +

    • - - * + *
    • - - * + *
    • - - * + *
    • +
    • + * +
      + +
      +

      @@ -54,11 +57,11 @@

    - - + +

    -load->view('footer');?> \ No newline at end of file +load->view('footer');?> diff --git a/application/views/admin/users/list.php b/application/views/admin/users/list.php index 3b73738..b247db2 100644 --- a/application/views/admin/users/list.php +++ b/application/views/admin/users/list.php @@ -22,17 +22,23 @@ ?> - - | + + + | + + - -

    +

    +

    + + +

    -load->view('footer');?> \ No newline at end of file +load->view('footer');?> diff --git a/assets/css/style.css b/assets/css/style.css index a6d3112..0e06d0d 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -585,6 +585,11 @@ a.project_rename { padding-left: 30px; } +a.user_add { + background: url(../images/icons/user--plus.png) 10px center no-repeat #f3f3f3; + padding-left: 30px; +} + a.results { background: url(../images/icons/blue-folder-open-document-text.png) 10px center no-repeat #f3f3f3; padding-left: 30px;