diff --git a/application/controllers/users.php b/application/controllers/users.php index c710934..ac240b5 100644 --- a/application/controllers/users.php +++ b/application/controllers/users.php @@ -6,7 +6,7 @@ * @author Eike Foken * */ -class Users extends MY_Controller { +class Users extends CI_Controller { /** * Constructor. @@ -32,41 +32,41 @@ class Users extends MY_Controller { $config = array( array( 'field' => 'username', - 'label' => 'lang:field_username', + 'label' => _('Username'), 'rules' => 'trim|required|min_length[4]|max_length[20]|unique[users.username]', ), array( 'field' => 'password', - 'label' => 'lang:field_password', + 'label' => _('Password'), 'rules' => 'required|min_length[6]|matches[password_confirm]', ), array( 'field' => 'password_confirm', - 'label' => 'lang:field_password_confirm', + 'label' => _('Confirm password'), ), array( 'field' => 'firstname', - 'label' => 'lang:field_firstname', + 'label' => _('First name'), 'rules' => 'trim|required|max_length[50]', ), array( 'field' => 'lastname', - 'label' => 'lang:field_lastname', + 'label' => _('Last name'), 'rules' => 'trim|required|max_length[50]', ), array( 'field' => 'email', - 'label' => 'lang:field_email', + 'label' => _('Email address'), 'rules' => 'trim|required|valid_email', ), array( 'field' => 'institution', - 'label' => 'lang:field_institution', + 'label' => _('Institution'), 'rules' => 'trim|max_length[100]', ), array( 'field' => 'phone', - 'label' => 'lang:field_phone', + 'label' => _('Phone number'), 'rules' => 'trim|regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]', ) ); @@ -83,7 +83,7 @@ class Users extends MY_Controller { ); if ($this->user->register($username, $this->input->post('password'), $this->input->post('email'), $data)) { - $this->messages->add("The user '" . $username . "' was created", 'success'); + $this->messages->add(sprintf(_("The user '%s' was created"), $username), 'success'); redirect('users', 201); } } @@ -106,27 +106,27 @@ class Users extends MY_Controller { $config = array( array( 'field' => 'firstname', - 'label' => 'lang:field_firstname', + 'label' => _('First name'), 'rules' => 'trim|required|max_length[50]', ), array( 'field' => 'lastname', - 'label' => 'lang:field_lastname', + 'label' => _('Last name'), 'rules' => 'trim|required|max_length[50]', ), array( 'field' => 'email', - 'label' => 'lang:field_email', + 'label' => _('Email address'), 'rules' => 'trim|required|valid_email', ), array( 'field' => 'institution', - 'label' => 'lang:field_institution', + 'label' => _('Institution'), 'rules' => 'trim|max_length[100]', ), array( 'field' => 'phone', - 'label' => 'lang:field_phone', + 'label' => _('Phone number'), 'rules' => 'trim|regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]', ) ); @@ -142,7 +142,7 @@ class Users extends MY_Controller { ); if ($this->user->update($user['id'], $data)) { - $this->messages->add("The user '" . $user['username'] . "' was updated", 'success'); + $this->messages->add(sprintf(_("The user '%s' was updated"), $user['username']), 'success'); redirect('users', 200); } } @@ -162,8 +162,12 @@ class Users extends MY_Controller { show_404(); } else { $this->user->delete($user['id']); - $this->messages->add('The selected user was deleted', 'success'); + $this->messages->add(_("The selected user was deleted"), 'success'); redirect('users', 200); } } -} \ No newline at end of file + +} + +/* End of file users.php */ +/* Location: ./application/constrollers/users.php */ diff --git a/application/libraries/Access.php b/application/libraries/Access.php index fb70b8a..2f5dfee 100644 --- a/application/libraries/Access.php +++ b/application/libraries/Access.php @@ -52,11 +52,11 @@ class Access { */ public function changePassword($username, $old, $new) { if ($this->ci->user->changePassword($username, $old, $new)) { - $this->setMessage('password_change_successful'); + $this->setMessage(_('Password successfully changed')); return true; } - $this->setError('password_change_unsuccessful'); + $this->setError(_('Unable to change password')); return false; } @@ -86,14 +86,14 @@ class Access { $this->ci->email->message($message); if ($this->ci->email->send()) { - $this->setMessage('forgot_password_successful'); + $this->setMessage(_('Password reset email sent')); return true; } else { - $this->setError('forgot_password_unsuccessful'); + $this->setError(_('Unable to reset password')); return false; } } else { - $this->setError('forgot_password_unsuccessful'); + $this->setError(_('Unable to reset password')); return false; } } @@ -107,7 +107,7 @@ class Access { $profile = $this->ci->user->profile($code, true); // pass the code to profile if (!is_object($profile)) { - $this->setError('password_change_unsuccessful'); + $this->setError(_('Unable to change password')); return false; } @@ -131,35 +131,18 @@ class Access { $this->ci->email->message($message); if ($this->ci->email->send()) { - $this->setMessage('password_change_successful'); + $this->setMessage(_('Password successfully changed')); return true; } else { - $this->setError('password_change_unsuccessful'); + $this->setError(_('Unable to change password')); return false; } } - $this->setError('password_change_unsuccessful'); + $this->setError(_('Unable to change password')); return false; } - /** - * Registers a new user. - * - * @return integer|boolean - */ - public function register($username, $password, $email, $additionalData, $groupName = false) { - $id = $this->ci->user->register($username, $password, $email, $additionalData, $groupName); - - if ($id !== false) { - $this->setMessage('account_creation_successful'); - return $id; - } else { - $this->setError('account_creation_unsuccessful'); - return false; - } - } - /** * Logs the user in. * @@ -167,10 +150,10 @@ class Access { */ public function login($username, $password, $remember = false) { if ($this->ci->user->login($username, $password, $remember)) { - $this->setMessage('login_successful'); + $this->setMessage(_('Logged in successfully')); return true; } else { - $this->setError('login_unsuccessful'); + $this->setError(_('Incorrect username or password')); return false; } } @@ -194,7 +177,7 @@ class Access { $this->ci->session->sess_destroy(); - $this->setMessage('logout_successful'); + $this->setMessage(_('Logged out successfully')); return true; } @@ -250,36 +233,6 @@ class Access { return $this->ci->user->profile($this->ci->session->userdata('username')); } - /** - * Updates a specified user. - * - * @return boolean - */ - public function updateUser($id, $data) { - if ($this->ci->user->update($id, $data)) { - $this->setMessage('update_successful'); - return true; - } - - $this->setError('update_unsuccessful'); - return false; - } - - /** - * Deletes a specified user. - * - * @return boolean - */ - public function deleteUser($id) { - if ($this->ci->user->delete($id)) { - $this->setMessage('delete_successful'); - return true; - } - - $this->setError('delete_unsuccessful'); - return false; - } - /** * Sets a message. * @@ -298,7 +251,7 @@ class Access { public function messages() { $output = ''; foreach ($this->messages as $message) { - $output .= lang($message) . '
'; + $output .= $message . '
'; } return $output; @@ -322,7 +275,7 @@ class Access { public function errors() { $output = ''; foreach ($this->errors as $error) { - $output .= lang($error) . '
'; + $output .= $error . '
'; } return $output; diff --git a/application/models/user.php b/application/models/user.php index adc5024..4462a19 100644 --- a/application/models/user.php +++ b/application/models/user.php @@ -225,7 +225,6 @@ class User extends CI_Model { $this->access->setError('account_creation_duplicate_username'); return false; } - print_r($additionalData); // if a groupID was passed, use it if (isset($additionalData['group_id'])) { diff --git a/application/views/admin/users/create.php b/application/views/admin/users/create.php index 72fabd5..ae78c7f 100644 --- a/application/views/admin/users/create.php +++ b/application/views/admin/users/create.php @@ -3,76 +3,76 @@
-

+

-

Required information

+

  • - +
    - +
  • - +
  • - +
  • - +
  • - +
  • - +
-

Optional information

+

  • - +
  • - +
    - +
  • - +
    @@ -80,7 +80,7 @@

- Speichern +

diff --git a/application/views/admin/users/edit.php b/application/views/admin/users/edit.php index 73664d9..4bcc4f1 100644 --- a/application/views/admin/users/edit.php +++ b/application/views/admin/users/edit.php @@ -3,54 +3,54 @@
-

''

+

-

Required information

+

  • - +
  • - +
  • - +
-

Optional information

+

  • - +
  • - +
    - +
  • - +
    @@ -58,7 +58,8 @@

- Speichern + +

diff --git a/application/views/admin/users/index.php b/application/views/admin/users/index.php index 9857848..9738963 100644 --- a/application/views/admin/users/index.php +++ b/application/views/admin/users/index.php @@ -3,17 +3,17 @@
-

+

-

+

- - - + + + - +
| |
-

+