Add js language support
This commit is contained in:
@@ -14,6 +14,7 @@ class Auth extends CI_Controller {
|
||||
parent::__construct();
|
||||
$this->load->library('access');
|
||||
$this->load->library('form_validation');
|
||||
$this->load->model('user');
|
||||
}
|
||||
|
||||
//redirect if needed, otherwise display the user list
|
||||
@@ -116,53 +117,28 @@ class Auth extends CI_Controller {
|
||||
$this->load->view('auth/register_success', $this->data);
|
||||
}
|
||||
|
||||
//change password
|
||||
public function change_password() {
|
||||
$this->form_validation->set_rules('old', 'Old password', 'required');
|
||||
$this->form_validation->set_rules('new', 'New Password', 'required|min_length[' . $this->config->item('min_password_length', 'access') . ']|max_length[' . $this->config->item('max_password_length', 'access') . ']|matches[new_confirm]');
|
||||
$this->form_validation->set_rules('new_confirm', 'Confirm New Password', 'required');
|
||||
|
||||
public function settings() {
|
||||
if (!$this->access->loggedIn()) {
|
||||
redirect('auth/login', 'refresh');
|
||||
}
|
||||
$user = $this->access->get_user($this->session->userdata('user_id'));
|
||||
|
||||
if ($this->form_validation->run() == false) { //display the form
|
||||
//set the flash data error message if there is one
|
||||
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
|
||||
// validate form
|
||||
$this->form_validation->set_rules('new_password', 'New Password', 'min_length[' . $this->config->item('min_password_length', 'auth') . ']|max_length[' . $this->config->item('max_password_length', 'auth') . ']|matches[new_password_confirm]');
|
||||
|
||||
$this->data['old_password'] = array('name' => 'old',
|
||||
'id' => 'old',
|
||||
'type' => 'password'
|
||||
);
|
||||
$this->data['new_password'] = array('name' => 'new',
|
||||
'id' => 'new',
|
||||
'type' => 'password'
|
||||
);
|
||||
$this->data['new_password_confirm'] = array('name' => 'new_confirm',
|
||||
'id' => 'new_confirm',
|
||||
'type' => 'password'
|
||||
);
|
||||
$this->data['user_id'] = array('name' => 'user_id',
|
||||
'id' => 'user_id',
|
||||
'type' => 'hidden',
|
||||
'value' => $user->id
|
||||
);
|
||||
if ($this->form_validation->run() == true) {
|
||||
// change password if needed
|
||||
if ($this->input->post('new_password') != '') {
|
||||
$username = $this->session->userdata('username');
|
||||
$change = $this->access->changePassword($username, $this->input->post('old_password'), $this->input->post('new_password'));
|
||||
|
||||
//render
|
||||
$this->load->view('auth/change_password', $this->data);
|
||||
} else {
|
||||
$username = $this->session->userdata('username');
|
||||
|
||||
$change = $this->access->change_password($username, $this->input->post('old'), $this->input->post('new'));
|
||||
|
||||
if ($change) { //if the password was successfully changed
|
||||
$this->session->set_flashdata('message', $this->access->messages());
|
||||
$this->logout();
|
||||
} else {
|
||||
$this->session->set_flashdata('message', $this->access->errors());
|
||||
redirect('auth/change_password', 'refresh');
|
||||
if ($change) {
|
||||
$this->logout();
|
||||
}
|
||||
}
|
||||
echo "{success: true}";
|
||||
} else {
|
||||
echo validation_errors();
|
||||
$user = $this->access->getCurrentUser();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,6 +180,9 @@ class Auth extends CI_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function test() {
|
||||
echo "{xtype: 'form', title: 'Bla'}";
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file auth.php */
|
||||
|
||||
@@ -232,6 +232,15 @@ class Access {
|
||||
return $userGroup == $checkGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current logged in user.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getCurrentUser() {
|
||||
return $this->ci->user->getUserByID($this->ci->session->userdata('user_id'))->row();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the profile of the current user.
|
||||
*
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
var BASE_URL = '<?=site_url('/');?>';
|
||||
var BASE_PATH = '<?=base_url();?>';
|
||||
</script>
|
||||
<?=script_tag('assets/js/language/' . $this->config->item('language') . '.js');?>
|
||||
<?=script_tag('assets/js/common.js');?>
|
||||
</head>
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
var BASE_URL = '<?=site_url('/');?>';
|
||||
var BASE_PATH = '<?=base_url();?>';
|
||||
</script>
|
||||
<?=script_tag('assets/js/language/' . $this->config->item('language') . '.js');?>
|
||||
<?=script_tag('assets/js/common.js');?>
|
||||
</head>
|
||||
|
||||
@@ -22,7 +23,7 @@
|
||||
<div id="header">
|
||||
<?=img(array('src' => 'assets/images/logo.png', 'style' => 'margin-left: 5px'));?>
|
||||
<div style="float: right; margin-top: 15px; margin-right: 10px; color: #ccc;">
|
||||
<?=anchor('auth/settings', "Einstellungen", array('style' => 'padding: 5px;'));?> |
|
||||
<a href="javascript:settings.show()" style="padding: 5px">Einstellungen</a>
|
||||
<?=anchor('auth/logout', "Logout", array('style' => 'padding: 5px;'));?>
|
||||
</div>
|
||||
<?=img(array('src' => 'assets/images/lang_' . $this->config->item('lang_selected') . '.png', 'style' => 'float: right; margin-top: 18px; margin-right: 5px;'));?>
|
||||
|
||||
@@ -87,7 +87,7 @@ var layoutMain = new Ext.Viewport({
|
||||
|
||||
function logout() {
|
||||
Ext.Ajax.request({
|
||||
url: BASE_URL + 'auth/do_logout',
|
||||
url: BASE_URL + 'auth/logout',
|
||||
method: 'post',
|
||||
success: function(xhr) {
|
||||
window.location = BASE_URL + 'auth/login';
|
||||
|
||||
Reference in New Issue
Block a user