Add js language support
This commit is contained in:
@@ -14,6 +14,7 @@ class Auth extends CI_Controller {
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->load->library('access');
|
$this->load->library('access');
|
||||||
$this->load->library('form_validation');
|
$this->load->library('form_validation');
|
||||||
|
$this->load->model('user');
|
||||||
}
|
}
|
||||||
|
|
||||||
//redirect if needed, otherwise display the user list
|
//redirect if needed, otherwise display the user list
|
||||||
@@ -116,54 +117,29 @@ class Auth extends CI_Controller {
|
|||||||
$this->load->view('auth/register_success', $this->data);
|
$this->load->view('auth/register_success', $this->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//change password
|
public function settings() {
|
||||||
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');
|
|
||||||
|
|
||||||
if (!$this->access->loggedIn()) {
|
if (!$this->access->loggedIn()) {
|
||||||
redirect('auth/login', 'refresh');
|
redirect('auth/login', 'refresh');
|
||||||
}
|
}
|
||||||
$user = $this->access->get_user($this->session->userdata('user_id'));
|
|
||||||
|
|
||||||
if ($this->form_validation->run() == false) { //display the form
|
// validate form
|
||||||
//set the flash data error message if there is one
|
$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['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
|
|
||||||
|
|
||||||
$this->data['old_password'] = array('name' => 'old',
|
if ($this->form_validation->run() == true) {
|
||||||
'id' => 'old',
|
// change password if needed
|
||||||
'type' => 'password'
|
if ($this->input->post('new_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
|
|
||||||
);
|
|
||||||
|
|
||||||
//render
|
|
||||||
$this->load->view('auth/change_password', $this->data);
|
|
||||||
} else {
|
|
||||||
$username = $this->session->userdata('username');
|
$username = $this->session->userdata('username');
|
||||||
|
$change = $this->access->changePassword($username, $this->input->post('old_password'), $this->input->post('new_password'));
|
||||||
|
|
||||||
$change = $this->access->change_password($username, $this->input->post('old'), $this->input->post('new'));
|
if ($change) {
|
||||||
|
|
||||||
if ($change) { //if the password was successfully changed
|
|
||||||
$this->session->set_flashdata('message', $this->access->messages());
|
|
||||||
$this->logout();
|
$this->logout();
|
||||||
} else {
|
|
||||||
$this->session->set_flashdata('message', $this->access->errors());
|
|
||||||
redirect('auth/change_password', 'refresh');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
echo "{success: true}";
|
||||||
|
} else {
|
||||||
|
echo validation_errors();
|
||||||
|
$user = $this->access->getCurrentUser();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//forgot password
|
//forgot password
|
||||||
@@ -204,6 +180,9 @@ class Auth extends CI_Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test() {
|
||||||
|
echo "{xtype: 'form', title: 'Bla'}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file auth.php */
|
/* End of file auth.php */
|
||||||
|
|||||||
@@ -232,6 +232,15 @@ class Access {
|
|||||||
return $userGroup == $checkGroup;
|
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.
|
* Gets the profile of the current user.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
var BASE_URL = '<?=site_url('/');?>';
|
var BASE_URL = '<?=site_url('/');?>';
|
||||||
var BASE_PATH = '<?=base_url();?>';
|
var BASE_PATH = '<?=base_url();?>';
|
||||||
</script>
|
</script>
|
||||||
|
<?=script_tag('assets/js/language/' . $this->config->item('language') . '.js');?>
|
||||||
<?=script_tag('assets/js/common.js');?>
|
<?=script_tag('assets/js/common.js');?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
var BASE_URL = '<?=site_url('/');?>';
|
var BASE_URL = '<?=site_url('/');?>';
|
||||||
var BASE_PATH = '<?=base_url();?>';
|
var BASE_PATH = '<?=base_url();?>';
|
||||||
</script>
|
</script>
|
||||||
|
<?=script_tag('assets/js/language/' . $this->config->item('language') . '.js');?>
|
||||||
<?=script_tag('assets/js/common.js');?>
|
<?=script_tag('assets/js/common.js');?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@
|
|||||||
<div id="header">
|
<div id="header">
|
||||||
<?=img(array('src' => 'assets/images/logo.png', 'style' => 'margin-left: 5px'));?>
|
<?=img(array('src' => 'assets/images/logo.png', 'style' => 'margin-left: 5px'));?>
|
||||||
<div style="float: right; margin-top: 15px; margin-right: 10px; color: #ccc;">
|
<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;'));?>
|
<?=anchor('auth/logout', "Logout", array('style' => 'padding: 5px;'));?>
|
||||||
</div>
|
</div>
|
||||||
<?=img(array('src' => 'assets/images/lang_' . $this->config->item('lang_selected') . '.png', 'style' => 'float: right; margin-top: 18px; margin-right: 5px;'));?>
|
<?=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() {
|
function logout() {
|
||||||
Ext.Ajax.request({
|
Ext.Ajax.request({
|
||||||
url: BASE_URL + 'auth/do_logout',
|
url: BASE_URL + 'auth/logout',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
success: function(xhr) {
|
success: function(xhr) {
|
||||||
window.location = BASE_URL + 'auth/login';
|
window.location = BASE_URL + 'auth/login';
|
||||||
|
|||||||
@@ -15,6 +15,92 @@ var message = function(title, message, icon) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings = new Ext.Window({
|
||||||
|
layout: 'fit',
|
||||||
|
title: lang['settings_window_title'],
|
||||||
|
id: 'settings-window',
|
||||||
|
width: 400,
|
||||||
|
height: 300,
|
||||||
|
closeAction: 'hide',
|
||||||
|
draggable: false,
|
||||||
|
resizable: false,
|
||||||
|
modal: true,
|
||||||
|
items: new Ext.FormPanel({
|
||||||
|
id: 'settings-form',
|
||||||
|
url: BASE_URL + 'auth/settings',
|
||||||
|
method: 'POST',
|
||||||
|
border: false,
|
||||||
|
items: [{
|
||||||
|
xtype: 'tabpanel',
|
||||||
|
border: false,
|
||||||
|
activeTab: 0,
|
||||||
|
defaults: {
|
||||||
|
layout: 'form',
|
||||||
|
defaultType: 'textfield',
|
||||||
|
labelWidth: 200,
|
||||||
|
autoHeight: true,
|
||||||
|
bodyStyle: 'padding: 10px'
|
||||||
|
},
|
||||||
|
items: [{
|
||||||
|
xtype: 'panel',
|
||||||
|
id: 'password',
|
||||||
|
title: "Passwort",
|
||||||
|
items: [{
|
||||||
|
fieldLabel: "Altes Passwort",
|
||||||
|
name: 'old_password'
|
||||||
|
}, {
|
||||||
|
fieldLabel: "Neues Passwort",
|
||||||
|
name: 'new_password'
|
||||||
|
}, {
|
||||||
|
fieldLabel: "Neues Passwort wiederholen",
|
||||||
|
name: 'new_password_confirm'
|
||||||
|
}]
|
||||||
|
}, {
|
||||||
|
xtype: 'panel',
|
||||||
|
title: "Profil",
|
||||||
|
items: [{
|
||||||
|
fieldLabel: "Vorname"
|
||||||
|
}, {
|
||||||
|
fieldLabel: "Nachname"
|
||||||
|
}, {
|
||||||
|
fieldLabel: "Firma"
|
||||||
|
}, {
|
||||||
|
fieldLabel: "Telefonnummer"
|
||||||
|
}, {
|
||||||
|
fieldLabel: "E-Mail-Adresse"
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}],
|
||||||
|
buttons: [{
|
||||||
|
text: lang['settings_window_save'],
|
||||||
|
handler: function() {
|
||||||
|
Ext.getCmp('settings-form').getForm().submit();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
text: lang['settings_window_close'],
|
||||||
|
handler: function() {
|
||||||
|
settings.hide();
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
/*var extender = Ext.getCmp("settings-tabs");
|
||||||
|
|
||||||
|
settings.on('beforeshow', function() {
|
||||||
|
extender.removeAll();
|
||||||
|
|
||||||
|
Ext.Ajax.request({
|
||||||
|
url : BASE_URL + 'auth/change_password',
|
||||||
|
success: function(result) {
|
||||||
|
extender.add(Ext.util.JSON.decode(result.responseText));
|
||||||
|
extender.setActiveTab(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
settings.doLayout();
|
||||||
|
});*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize tooltips.
|
* Initialize tooltips.
|
||||||
*/
|
*/
|
||||||
|
|||||||
5
assets/js/language/english.js
Normal file
5
assets/js/language/english.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
var lang = {
|
||||||
|
settings_window_title: "Settings",
|
||||||
|
settings_window_save: "Save",
|
||||||
|
settings_window_close: "Close"
|
||||||
|
};
|
||||||
5
assets/js/language/german.js
Normal file
5
assets/js/language/german.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
var lang = {
|
||||||
|
settings_window_title: "Einstellungen",
|
||||||
|
settings_window_save: "Speichern",
|
||||||
|
settings_window_close: "Schließen"
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user