Merge branch 'master' of disposed.de:scattport
This commit is contained in:
@@ -13,6 +13,7 @@ class Users extends MY_Controller {
|
|||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
$this->load->library('form_validation');
|
||||||
$this->load->model('user');
|
$this->load->model('user');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,6 +29,139 @@ class Users extends MY_Controller {
|
|||||||
* Allows admins to create a new user.
|
* Allows admins to create a new user.
|
||||||
*/
|
*/
|
||||||
public function create() {
|
public function create() {
|
||||||
|
$config = array(
|
||||||
|
array(
|
||||||
|
'field' => 'username',
|
||||||
|
'label' => 'lang:field_username',
|
||||||
|
'rules' => 'trim|required|min_length[4]|max_length[20]|unique[users.username]',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'field' => 'password',
|
||||||
|
'label' => 'lang:field_password',
|
||||||
|
'rules' => 'required|min_length[6]|matches[password_confirm]',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'field' => 'password_confirm',
|
||||||
|
'label' => 'lang:field_password_confirm',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'field' => 'firstname',
|
||||||
|
'label' => 'lang:field_firstname',
|
||||||
|
'rules' => 'trim|required|max_length[50]',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'field' => 'lastname',
|
||||||
|
'label' => 'lang:field_lastname',
|
||||||
|
'rules' => 'trim|required|max_length[50]',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'field' => 'email',
|
||||||
|
'label' => 'lang:field_email',
|
||||||
|
'rules' => 'trim|required|valid_email',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'field' => 'institution',
|
||||||
|
'label' => 'lang:field_institution',
|
||||||
|
'rules' => 'trim|max_length[100]',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'field' => 'phone',
|
||||||
|
'label' => 'lang:field_phone',
|
||||||
|
'rules' => 'trim|regex_match[/^\+\d{2,4}\w\d{2,4}\w\d{3,10}+$/i]',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->form_validation->set_rules($config);
|
||||||
|
|
||||||
|
if ($this->form_validation->run() === true) {
|
||||||
|
$username = $this->input->post('username');
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'firstname' => $this->input->post('firstname'),
|
||||||
|
'lastname' => $this->input->post('lastname'),
|
||||||
|
'institution' => $this->input->post('institution'),
|
||||||
|
'phone' => $this->input->post('phone')
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($this->user->register($username, $this->input->post('password'), $this->input->post('email'), $data)) {
|
||||||
|
$this->messages->add("The user '" . $username . "' was created", 'success');
|
||||||
|
redirect('users', 201);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->load->view('admin/users/create');
|
$this->load->view('admin/users/create');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows admins to edit the specified user.
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
*/
|
||||||
|
public function edit($id = '') {
|
||||||
|
$user = $this->user->getUserByID($id);
|
||||||
|
|
||||||
|
if (!isset($user) || !is_array($user)){
|
||||||
|
show_404();
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = array(
|
||||||
|
array(
|
||||||
|
'field' => 'firstname',
|
||||||
|
'label' => 'lang:field_firstname',
|
||||||
|
'rules' => 'trim|required|max_length[50]',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'field' => 'lastname',
|
||||||
|
'label' => 'lang:field_lastname',
|
||||||
|
'rules' => 'trim|required|max_length[50]',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'field' => 'email',
|
||||||
|
'label' => 'lang:field_email',
|
||||||
|
'rules' => 'trim|required|valid_email',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'field' => 'institution',
|
||||||
|
'label' => 'lang:field_institution',
|
||||||
|
'rules' => 'trim|max_length[100]',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'field' => 'phone',
|
||||||
|
'label' => 'lang:field_phone',
|
||||||
|
//'rules' => 'trim|regex_match[/^\+\d{2,4}\w\d{2,4}\w\d{3,10}+$/i]',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->form_validation->set_rules($config);
|
||||||
|
|
||||||
|
if ($this->form_validation->run() === true) {
|
||||||
|
$data = array(
|
||||||
|
'email' => $this->input->post('email'),
|
||||||
|
'firstname' => $this->input->post('firstname'),
|
||||||
|
'lastname' => $this->input->post('lastname'),
|
||||||
|
'institution' => $this->input->post('institution'),
|
||||||
|
'phone' => $this->input->post('phone')
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($this->user->update($user['id'], $data)) {
|
||||||
|
$this->messages->add("The user '" . $user['username'] . "' was updated", 'success');
|
||||||
|
redirect('users', 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->load->view('admin/users/edit', array('user' => $user));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows admins to delete the specified user.
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
*/
|
||||||
|
public function delete($id = '') {
|
||||||
|
if (!is_array($this->user->getUserByID())) {
|
||||||
|
show_404();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->user->delete($id);
|
||||||
|
$this->messages->add('The selected user was deleted', 'success');
|
||||||
|
redirect('users', 200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ function check_login() {
|
|||||||
$public_controllers = array('auth');
|
$public_controllers = array('auth');
|
||||||
|
|
||||||
$CI = & get_instance();
|
$CI = & get_instance();
|
||||||
if (!$CI->access->loggedIn() && !in_array($CI->router->class, $public_controllers)) {
|
if (!$CI->input->is_ajax_request() && !$CI->access->loggedIn() && !in_array($CI->router->class, $public_controllers)) {
|
||||||
redirect('auth/login');
|
redirect('auth/login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$lang['unique'] = "A project with this name already exists.";
|
$lang['unique'] = "A project with this name already exists.";
|
||||||
|
$lang['required'] = "The %s field is required.";
|
||||||
|
$lang['isset'] = "The %s field must have a value.";
|
||||||
|
$lang['valid_email'] = "The %s field must contain a valid email address.";
|
||||||
|
$lang['valid_emails'] = "The %s field must contain all valid email addresses.";
|
||||||
|
$lang['valid_url'] = "The %s field must contain a valid URL.";
|
||||||
|
$lang['valid_ip'] = "The %s field must contain a valid IP.";
|
||||||
|
$lang['min_length'] = "The %s field must be at least %s characters in length.";
|
||||||
|
$lang['max_length'] = "The %s field can not exceed %s characters in length.";
|
||||||
|
$lang['exact_length'] = "The %s field must be exactly %s characters in length.";
|
||||||
|
$lang['alpha'] = "The %s field may only contain alphabetical characters.";
|
||||||
|
$lang['alpha_numeric'] = "The %s field may only contain alpha-numeric characters.";
|
||||||
|
$lang['alpha_dash'] = "The %s field may only contain alpha-numeric characters, underscores, and dashes.";
|
||||||
|
$lang['numeric'] = "The %s field must contain only numbers.";
|
||||||
|
$lang['is_numeric'] = "The %s field must contain only numeric characters.";
|
||||||
|
$lang['integer'] = "The %s field must contain an integer.";
|
||||||
|
$lang['regex_match'] = "The %s field is not in the correct format.";
|
||||||
|
$lang['matches'] = "The %s field does not match the %s field.";
|
||||||
|
$lang['is_natural'] = "The %s field must contain only positive numbers.";
|
||||||
|
$lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero.";
|
||||||
|
$lang['decimal'] = "The %s field must contain a decimal number.";
|
||||||
|
$lang['less_than'] = "The %s field must contain a number less than %s.";
|
||||||
|
$lang['greater_than'] = "The %s field must contain a number greater than %s.";
|
||||||
|
|
||||||
/* End of file projects_lang.php */
|
/* End of file projects_lang.php */
|
||||||
/* Location: ./application/language/english/form_validation_lang.php */
|
/* Location: ./application/language/english/form_validation_lang.php */
|
||||||
|
|||||||
@@ -10,6 +10,16 @@ $lang['user_create'] = "Create new user";
|
|||||||
$lang['user_delete'] = "Delete";
|
$lang['user_delete'] = "Delete";
|
||||||
|
|
||||||
$lang['create_user'] = "Create a new user";
|
$lang['create_user'] = "Create a new user";
|
||||||
|
$lang['edit_user'] = "Edit user";
|
||||||
|
|
||||||
|
$lang['field_username'] = "Username";
|
||||||
|
$lang['field_password'] = "Password";
|
||||||
|
$lang['field_password_confirm'] = "Confirm password";
|
||||||
|
$lang['field_firstname'] = "First name";
|
||||||
|
$lang['field_lastname'] = "Last name";
|
||||||
|
$lang['field_email'] = "Email address";
|
||||||
|
$lang['field_institution'] = "Institution";
|
||||||
|
$lang['field_phone'] = "Phone number";
|
||||||
|
|
||||||
/* End of file users_lang.php */
|
/* End of file users_lang.php */
|
||||||
/* Location: ./application/language/english/users_lang.php */
|
/* Location: ./application/language/english/users_lang.php */
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ class Access {
|
|||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
public function getCurrentUser() {
|
public function getCurrentUser() {
|
||||||
return $this->ci->user->getUserByID($this->ci->session->userdata('user_id'))->row_array();
|
return $this->ci->user->getUserByID($this->ci->session->userdata('user_id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ class MY_Form_validation extends CI_Form_validation {
|
|||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
|
// overwrite default error delimiters
|
||||||
|
$this->set_error_delimiters('<p class="error">', '</p>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ class MY_Session extends CI_Session {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new session.
|
* Creates a new session.
|
||||||
|
*
|
||||||
|
* @see CI_Session::sess_create()
|
||||||
*/
|
*/
|
||||||
public function sess_create() {
|
public function sess_create() {
|
||||||
$this->userdata = array(
|
$this->userdata = array(
|
||||||
@@ -45,13 +47,10 @@ class MY_Session extends CI_Session {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates an existing session.
|
* Updates an existing session.
|
||||||
|
*
|
||||||
|
* @see CI_Session::sess_update()
|
||||||
*/
|
*/
|
||||||
public function sess_update() {
|
public function sess_update() {
|
||||||
// skip the session update in case of an ajax call
|
|
||||||
if ($this->CI->input->is_ajax_request()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we only update the session every five minutes by default
|
// we only update the session every five minutes by default
|
||||||
if ($this->userdata['last_activity'] + $this->sess_time_to_update >= $this->now) {
|
if ($this->userdata['last_activity'] + $this->sess_time_to_update >= $this->now) {
|
||||||
return;
|
return;
|
||||||
@@ -84,6 +83,16 @@ class MY_Session extends CI_Session {
|
|||||||
// write the cookie
|
// write the cookie
|
||||||
$this->_set_cookie($cookieData);
|
$this->_set_cookie($cookieData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys an existing session.
|
||||||
|
*
|
||||||
|
* @see CI_Session::sess_destroy()
|
||||||
|
*/
|
||||||
|
public function sess_destroy() {
|
||||||
|
parent::sess_destroy();
|
||||||
|
$this->userdata = array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file MY_Session.php */
|
/* End of file MY_Session.php */
|
||||||
|
|||||||
@@ -9,17 +9,21 @@
|
|||||||
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
|
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
|
||||||
*
|
*
|
||||||
* @author Vijay Mahrra & Sheikh Ahmed <webmaster@designbyfail.com>
|
* @author Vijay Mahrra & Sheikh Ahmed <webmaster@designbyfail.com>
|
||||||
* @url http://www.designbyfail.com/
|
* @author Eike Foken <kontakt@eikefoken>
|
||||||
|
* @link http://www.designbyfail.com/
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
class Messages {
|
||||||
|
|
||||||
class Messages
|
|
||||||
{
|
|
||||||
var $_ci;
|
var $_ci;
|
||||||
var $_types = array('success', 'error', 'notice');
|
var $_types = array('success', 'error', 'notice');
|
||||||
|
|
||||||
function Messages($params = array())
|
/**
|
||||||
{
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
*/
|
||||||
|
public function __construct($params = array()) {
|
||||||
$this->_ci =& get_instance();
|
$this->_ci =& get_instance();
|
||||||
$this->_ci->load->library('session');
|
$this->_ci->load->library('session');
|
||||||
// check if theres already messages, if not, initialise the messages array in the session
|
// check if theres already messages, if not, initialise the messages array in the session
|
||||||
@@ -29,9 +33,10 @@ class Messages
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear all messages
|
/**
|
||||||
function clear()
|
* Clears all messages
|
||||||
{
|
*/
|
||||||
|
public function clear() {
|
||||||
$messages = array();
|
$messages = array();
|
||||||
foreach ($this->_types as $type) {
|
foreach ($this->_types as $type) {
|
||||||
$messages[$type] = array();
|
$messages[$type] = array();
|
||||||
@@ -39,9 +44,10 @@ class Messages
|
|||||||
$this->_ci->session->set_userdata('messages', $messages);
|
$this->_ci->session->set_userdata('messages', $messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a message, default type is message
|
/**
|
||||||
function add($message, $type = 'message')
|
* Adds a message (default type is 'notice').
|
||||||
{
|
*/
|
||||||
|
public function add($message, $type = 'notice') {
|
||||||
$messages = $this->_ci->session->userdata('messages');
|
$messages = $this->_ci->session->userdata('messages');
|
||||||
// handle PEAR errors gracefully
|
// handle PEAR errors gracefully
|
||||||
if (is_a($message, 'PEAR_Error')) {
|
if (is_a($message, 'PEAR_Error')) {
|
||||||
@@ -49,7 +55,7 @@ class Messages
|
|||||||
$type = 'error';
|
$type = 'error';
|
||||||
} else if (!in_array($type, $this->_types)) {
|
} else if (!in_array($type, $this->_types)) {
|
||||||
// set the type to message if the user specified a type that's unknown
|
// set the type to message if the user specified a type that's unknown
|
||||||
$type = 'message';
|
$type = 'notice';
|
||||||
}
|
}
|
||||||
// don't repeat messages!
|
// don't repeat messages!
|
||||||
if (!in_array($message, $messages[$type]) && is_string($message)) {
|
if (!in_array($message, $messages[$type]) && is_string($message)) {
|
||||||
@@ -58,9 +64,13 @@ class Messages
|
|||||||
$messages = $this->_ci->session->set_userdata('messages', $messages);
|
$messages = $this->_ci->session->set_userdata('messages', $messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return messages of given type or all types, return false if none
|
/**
|
||||||
function sum($type = null)
|
* Returns messages of given type or all types, return false if none.
|
||||||
{
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @return boolean|integer
|
||||||
|
*/
|
||||||
|
public function sum($type = null) {
|
||||||
$messages = $this->_ci->session->userdata('messages');
|
$messages = $this->_ci->session->userdata('messages');
|
||||||
if (!empty($type)) {
|
if (!empty($type)) {
|
||||||
$i = count($messages[$type]);
|
$i = count($messages[$type]);
|
||||||
@@ -70,12 +80,16 @@ class Messages
|
|||||||
foreach ($this->_types as $type) {
|
foreach ($this->_types as $type) {
|
||||||
$i += count($messages[$type]);
|
$i += count($messages[$type]);
|
||||||
}
|
}
|
||||||
return $i;
|
return $i > 0 ? $i : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return messages of given type or all types, return false if none, clearing stack
|
/**
|
||||||
function get($type = null)
|
* Returns messages of given type or all types, return false if none, clearing stack.
|
||||||
{
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function get($type = null) {
|
||||||
$messages = $this->_ci->session->userdata('messages');
|
$messages = $this->_ci->session->userdata('messages');
|
||||||
if (!empty($type)) {
|
if (!empty($type)) {
|
||||||
if (count($messages[$type]) == 0) {
|
if (count($messages[$type]) == 0) {
|
||||||
@@ -101,3 +115,6 @@ class Messages
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* End of file Messages.php */
|
||||||
|
/* Location: ./application/libraries/Messages.php */
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class User extends CI_Model {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function salt() {
|
private function salt() {
|
||||||
return substr(md5(uniqid(rand(), true)), 0, $this->saltLength);
|
return substr(sha1(uniqid(rand(), true)), 0, $this->saltLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,32 +211,37 @@ class User extends CI_Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register
|
* Registers a new user.
|
||||||
*
|
*
|
||||||
|
* @param string $username
|
||||||
|
* @param string $password
|
||||||
|
* @param string $email
|
||||||
|
* @param array $additionalData
|
||||||
|
* @param string $groupName
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function register($username, $password, $email, $additionalData = false, $groupName = false) {
|
public function register($username, $password, $email, $additionalData = array(), $groupName = '') {
|
||||||
if ($this->checkUsername($username)) {
|
if ($this->checkUsername($username)) {
|
||||||
$this->access->setError('account_creation_duplicate_username');
|
$this->access->setError('account_creation_duplicate_username');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
print_r($additionalData);
|
||||||
|
|
||||||
// if a groupID was passed, use it
|
// if a groupID was passed, use it
|
||||||
if (isset($additional_data['group_id'])) {
|
if (isset($additionalData['group_id'])) {
|
||||||
$groupID = $additional_data['group_id'];
|
$groupID = $additionalData['group_id'];
|
||||||
unset($additional_data['group_id']);
|
unset($additionalData['group_id']);
|
||||||
} else { // otherwise get default groupID
|
} else { // otherwise get default groupID
|
||||||
$groupName = !$groupName ? 'users' : $groupName;
|
$groupName = ($groupName == '') ? 'users' : $groupName;
|
||||||
$groupID = $this->db->select('id')->where('name', $groupName)->get('groups')->row()->id;
|
$groupID = $this->db->select('id')->where('name', $groupName)->get('groups')->row()->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IP Address
|
|
||||||
$ipAddress = $this->input->ip_address();
|
|
||||||
$salt = $this->storeSalt ? $this->salt() : false;
|
$salt = $this->storeSalt ? $this->salt() : false;
|
||||||
$password = $this->hashPassword($password, $salt);
|
$password = $this->hashPassword($password, $salt);
|
||||||
|
|
||||||
// Users table.
|
// users table
|
||||||
$data = array(
|
$data = array(
|
||||||
|
'id' => random_hash(16),
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
'password' => $password,
|
'password' => $password,
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
@@ -247,11 +252,11 @@ class User extends CI_Model {
|
|||||||
if ($this->storeSalt) {
|
if ($this->storeSalt) {
|
||||||
$data['salt'] = $salt;
|
$data['salt'] = $salt;
|
||||||
}
|
}
|
||||||
|
print_r($data);
|
||||||
|
|
||||||
$this->db->insert('users', $data);
|
$this->db->insert('users', array_merge($data, $additionalData));
|
||||||
$id = $this->db->insert_id();
|
|
||||||
|
|
||||||
return $this->db->affected_rows() > 0 ? $id : false;
|
return $this->db->affected_rows() > 0 ? $data['id'] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -340,20 +345,19 @@ class User extends CI_Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getUserByID
|
* Gets a user by ID.
|
||||||
*
|
*
|
||||||
* @return object
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getUserByID($id = false) {
|
public function getUserByID($id = false) {
|
||||||
// if no ID was passed use the current users ID
|
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
$id = $this->session->userdata('user_id');
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->where('users.id', $id);
|
$this->db->where('users.id', $id);
|
||||||
$this->db->limit(1);
|
$this->db->limit(1);
|
||||||
|
|
||||||
return $this->get();
|
return $this->get()->row_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -411,11 +415,11 @@ class User extends CI_Model {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function update($id, $data) {
|
public function update($id, $data) {
|
||||||
$user = $this->getUserByID($id)->row();
|
$user = $this->getUserByID($id);
|
||||||
|
|
||||||
$this->db->trans_begin();
|
$this->db->trans_begin();
|
||||||
|
|
||||||
if (array_key_exists('username', $data) && $this->checkUsername($data['username']) && $user->username !== $data['username']) {
|
if (array_key_exists('username', $data) && $this->checkUsername($data['username']) && $user['username'] !== $data['username']) {
|
||||||
$this->db->trans_rollback();
|
$this->db->trans_rollback();
|
||||||
$this->access->setError('account_creation_duplicate_username');
|
$this->access->setError('account_creation_duplicate_username');
|
||||||
return false;
|
return false;
|
||||||
@@ -423,7 +427,7 @@ class User extends CI_Model {
|
|||||||
|
|
||||||
if (array_key_exists('username', $data) || array_key_exists('password', $data) || array_key_exists('email', $data)) {
|
if (array_key_exists('username', $data) || array_key_exists('password', $data) || array_key_exists('email', $data)) {
|
||||||
if (array_key_exists('password', $data)) {
|
if (array_key_exists('password', $data)) {
|
||||||
$data['password'] = $this->hashPassword($data['password'], $user->salt);
|
$data['password'] = $this->hashPassword($data['password'], $user['salt']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->update('users', $data, array('id' => $id));
|
$this->db->update('users', $data, array('id' => $id));
|
||||||
@@ -518,16 +522,16 @@ class User extends CI_Model {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->getUserByID($id)->row();
|
$user = $this->getUserByID($id);
|
||||||
|
|
||||||
$salt = sha1($user->password);
|
$salt = sha1($user['password']);
|
||||||
|
|
||||||
$this->db->update('users', array('remember_code' => $salt), array('id' => $id));
|
$this->db->update('users', array('remember_code' => $salt), array('id' => $id));
|
||||||
|
|
||||||
if ($this->db->affected_rows() > -1) {
|
if ($this->db->affected_rows() > -1) {
|
||||||
set_cookie(array(
|
set_cookie(array(
|
||||||
'name' => 'username',
|
'name' => 'username',
|
||||||
'value' => $user->username,
|
'value' => $user['username'],
|
||||||
'expire' => $this->config->item('user_expire', 'auth'),
|
'expire' => $this->config->item('user_expire', 'auth'),
|
||||||
));
|
));
|
||||||
set_cookie(array(
|
set_cookie(array(
|
||||||
|
|||||||
@@ -11,35 +11,43 @@
|
|||||||
<h3>Required information</h3>
|
<h3>Required information</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<?=form_label("Username", 'username');?>
|
<?=form_label(lang('field_username'), 'username');?>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" name="username" id="username" class="short text" value="<?=set_value('username');?>" />
|
<input type="text" name="username" id="username" class="short text" value="<?=set_value('username');?>" />
|
||||||
<?=form_error('username')?>
|
<?=form_error('username')?>
|
||||||
</div>
|
</div>
|
||||||
|
<label class="note">Must be between 4 and 20 characters long</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<?=form_label("Password", 'password');?>
|
<?=form_label(lang('field_email'), 'email');?>
|
||||||
|
<div>
|
||||||
|
<input type="text" name="email" id="email" class="medium text" value="<?=set_value('email');?>" />
|
||||||
|
<?=form_error('email')?>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<?=form_label(lang('field_password'), 'password');?>
|
||||||
<div>
|
<div>
|
||||||
<input type="password" name="password" id="password" class="short text" />
|
<input type="password" name="password" id="password" class="short text" />
|
||||||
<?=form_error('password')?>
|
<?=form_error('password')?>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<?=form_label("Confirm password", 'password2');?>
|
<?=form_label(lang('field_password_confirm'), 'password_confirm');?>
|
||||||
<div>
|
<div>
|
||||||
<input type="password" name="password_confirm" id="password_confirm" class="short text" />
|
<input type="password" name="password_confirm" id="password_confirm" class="short text" />
|
||||||
<?=form_error('password_confirm')?>
|
<?=form_error('password_confirm')?>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<?=form_label("First name", 'firstname');?>
|
<?=form_label(lang('field_firstname'), 'firstname');?>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" name="firstname" id="firstname" class="short text" value="<?=set_value('firstname');?>" />
|
<input type="text" name="firstname" id="firstname" class="short text" value="<?=set_value('firstname');?>" />
|
||||||
<?=form_error('firstname')?>
|
<?=form_error('firstname')?>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<?=form_label("Last name", 'lastname');?>
|
<?=form_label(lang('field_lastname'), 'lastname');?>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" name="lastname" id="lastname" class="short text" value="<?=set_value('lastname');?>" />
|
<input type="text" name="lastname" id="lastname" class="short text" value="<?=set_value('lastname');?>" />
|
||||||
<?=form_error('lastname')?>
|
<?=form_error('lastname')?>
|
||||||
@@ -49,12 +57,20 @@
|
|||||||
<h3>Optional information</h3>
|
<h3>Optional information</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<?=form_label("Institution", 'institution');?>
|
<?=form_label(lang('field_institution'), 'institution');?>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" name="institution" id="institution" class="medium text" value="<?=set_value('institution');?>" />
|
<input type="text" name="institution" id="institution" class="medium text" value="<?=set_value('institution');?>" />
|
||||||
<?=form_error('institution')?>
|
<?=form_error('institution')?>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<?=form_label(lang('field_phone'), 'phone');?>
|
||||||
|
<div>
|
||||||
|
<input type="text" name="phone" id="phone" class="short text" value="<?=set_value('phone');?>" />
|
||||||
|
<?=form_error('phone')?>
|
||||||
|
</div>
|
||||||
|
<label class="note">Example: +49 123 456789</label>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<?=form_label("Language", 'language');?>
|
<?=form_label("Language", 'language');?>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
67
application/views/admin/users/edit.php
Normal file
67
application/views/admin/users/edit.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?php $this->load->view('header');?>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
<h2><?=lang('edit_user');?> '<?=$user['username'];?>'</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="box">
|
||||||
|
<form name="createUser" method="post" action="<?=site_url('users/edit/' . $user['id'])?>">
|
||||||
|
<h3>Required information</h3>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<?=form_label(lang('field_email'), 'email');?>
|
||||||
|
<div>
|
||||||
|
<input type="text" name="email" id="email" class="medium text" value="<?=set_value('email', $user['email']);?>" />
|
||||||
|
<?=form_error('email')?>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<?=form_label(lang('field_firstname'), 'firstname');?>
|
||||||
|
<div>
|
||||||
|
<input type="text" name="firstname" id="firstname" class="short text" value="<?=set_value('firstname', $user['firstname']);?>" />
|
||||||
|
<?=form_error('firstname')?>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<?=form_label(lang('field_lastname'), 'lastname');?>
|
||||||
|
<div>
|
||||||
|
<input type="text" name="lastname" id="lastname" class="short text" value="<?=set_value('lastname', $user['lastname']);?>" />
|
||||||
|
<?=form_error('lastname')?>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h3>Optional information</h3>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<?=form_label(lang('field_institution'), 'institution');?>
|
||||||
|
<div>
|
||||||
|
<input type="text" name="institution" id="institution" class="medium text" value="<?=set_value('institution', $user['institution']);?>" />
|
||||||
|
<?=form_error('institution')?>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<?=form_label(lang('field_phone'), 'phone');?>
|
||||||
|
<div>
|
||||||
|
<input type="text" name="phone" id="phone" class="short text" value="<?=set_value('phone', $user['phone']);?>" />
|
||||||
|
<?=form_error('phone')?>
|
||||||
|
</div>
|
||||||
|
<label class="note">Example: +49 123 456789</label>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<?=form_label("Language", 'language');?>
|
||||||
|
<div>
|
||||||
|
<?=form_dropdown('language', array('English'), null, 'id="language" class="drop"');?>
|
||||||
|
<?=form_error('language')?>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
<a class="button save" href="javascript:void(0);" onclick="$('form[name=createUser]').submit();">Speichern</a>
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php $this->load->view('footer');?>
|
||||||
@@ -55,11 +55,11 @@ input.medium { width: 45%;}
|
|||||||
input.long { width:70%;}
|
input.long { width:70%;}
|
||||||
input.max { width: 95%;}
|
input.max { width: 95%;}
|
||||||
|
|
||||||
.success {
|
p.success {
|
||||||
color: #008000;
|
color: #008000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error, .req {
|
p.error, p.req {
|
||||||
color: #d8122d;
|
color: #d8122d;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ p { margin: 0px 0px 20px 0px; line-height: 18px;}
|
|||||||
ul { margin: 5px 0px 15px 0px; padding: 0px;}
|
ul { margin: 5px 0px 15px 0px; padding: 0px;}
|
||||||
li { margin-left: 20px;}
|
li { margin-left: 20px;}
|
||||||
|
|
||||||
.notice {
|
div.notice {
|
||||||
margin: 0 0 15px;
|
margin: 0 0 15px;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
background: #fffbcc;
|
background: #fffbcc;
|
||||||
@@ -30,7 +30,7 @@ li { margin-left: 20px;}
|
|||||||
color: #222;
|
color: #222;
|
||||||
}
|
}
|
||||||
|
|
||||||
.success {
|
div.success {
|
||||||
margin: 0 0 15px;
|
margin: 0 0 15px;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
background: #d1ecb8;
|
background: #d1ecb8;
|
||||||
@@ -39,7 +39,7 @@ li { margin-left: 20px;}
|
|||||||
color: #222;
|
color: #222;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
div.error {
|
||||||
margin: 0 0 15px;
|
margin: 0 0 15px;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
background: #ffebe8;
|
background: #ffebe8;
|
||||||
|
|||||||
Reference in New Issue
Block a user