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 @@
-
=_('Create new user');?>
+ =anchor('admin/users', _('Users'));?> » =_('Create user');?>
@@ -11,52 +11,52 @@
=_('Required information');?>
- =form_label(_('Username'), 'username');?>
- *
+ =form_label(_('Username'), 'username');?> *
- =form_error('username')?>
+ =form_error('username');?>
=_('Must be between 4 and 20 characters long');?>
- =form_label(_('Email address'), 'email');?>
- *
+ =form_label(_('Email address'), 'email');?> *
- =form_error('email')?>
+ =form_error('email');?>
- =form_label(_('Password'), 'password');?>
- *
+ =form_label(_('Password'), 'password');?> *
- =form_error('password')?>
+ =form_error('password');?>
- =form_label(_('Confirm password'), 'password_confirm');?>
- *
+ =form_label(_('Confirm password'), 'password_confirm');?> *
- =form_error('password_confirm')?>
+ =form_error('password_confirm');?>
- =form_label(_('First name'), 'firstname');?>
- *
+ =form_label(_('First name'), 'firstname');?> *
- =form_error('firstname')?>
+ =form_error('firstname');?>
- =form_label(_('Last name'), 'lastname');?>
- *
+ =form_label(_('Last name'), 'lastname');?> *
- =form_error('lastname')?>
+ =form_error('lastname');?>
+
+
+
+ =form_label(_('Group'), 'group_id');?> *
+
+ =form_dropdown('group_id', $groups, $default['id'], 'id="group_id" class="drop"');?>
@@ -66,23 +66,24 @@
=form_label(_('Institution'), 'institution');?>
- =form_error('institution')?>
+ =form_error('institution');?>
=form_label(_('Phone number'), 'phone');?>
- =form_error('phone')?>
+ =form_error('phone');?>
=('Example');?>: +49 123 456789
- =_('Save');?>
+ =_('Save');?>
+ =_('Cancel');?>
-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 @@
-
+ =anchor('admin/users', _('Users'));?> » =sprintf(_('Edit user "%s"'), $user['username']);?>
-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 @@
?>
=$user['username'];?>
- =$user['firstname'];?> =$user['lastname'];?>
- =anchor('admin/users/edit/' . $user['id'], _('Edit'));?> | =_('Delete');?>
+ =$user['firstname'] . ' ' . $user['lastname'];?>
+
+ =anchor('admin/users/edit/' . $user['id'], _('Edit'));?> |
+ =_('Delete');?>
+
-
- =_('Create new user')?>
+
=_('Actions');?>
+
+ =_('Create user');?>
+ =_('Search user');?>
+
-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;