Improve settings window and cleanup
This commit is contained in:
@@ -52,7 +52,7 @@ $autoload['packages'] = array(APPPATH.'third_party');
|
||||
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
|
||||
*/
|
||||
|
||||
$autoload['libraries'] = array('lang_detect', 'database', 'session');
|
||||
$autoload['libraries'] = array('lang_detect', 'database', 'session', 'access');
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -17,16 +17,14 @@ class Auth extends CI_Controller {
|
||||
$this->load->model('user');
|
||||
}
|
||||
|
||||
//redirect if needed, otherwise display the user list
|
||||
/**
|
||||
* Redirects the user if needed, otherwise display the layout.
|
||||
*/
|
||||
public function index() {
|
||||
if (!$this->access->loggedIn()) {
|
||||
redirect('auth/login');
|
||||
} else {
|
||||
//set the flash data error message if there is one
|
||||
$this->data['message'] = validation_errors() ? validation_errors() : $this->session->flashdata('message');
|
||||
|
||||
//$this->data['users'] = $this->access->getUsers();
|
||||
$this->load->view('index', $this->data);
|
||||
$this->load->view('index');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +33,7 @@ class Auth extends CI_Controller {
|
||||
*/
|
||||
public function login() {
|
||||
if ($this->access->loggedIn()) {
|
||||
redirect('welcome');
|
||||
redirect();
|
||||
}
|
||||
|
||||
// validate form input
|
||||
@@ -53,7 +51,7 @@ class Auth extends CI_Controller {
|
||||
$this->data['message'] = $this->access->errors();
|
||||
}
|
||||
|
||||
// output json data
|
||||
// output JSON data
|
||||
$this->output->set_content_type('application/json')
|
||||
->set_output(json_encode($this->data));
|
||||
} else {
|
||||
@@ -69,7 +67,10 @@ class Auth extends CI_Controller {
|
||||
*/
|
||||
public function logout() {
|
||||
$logout = $this->access->logout();
|
||||
redirect('auth');
|
||||
|
||||
// output JSON data
|
||||
$this->output->set_content_type('application/json')
|
||||
->set_output(json_encode(array('success' => true)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,16 +114,15 @@ class Auth extends CI_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function register_success() {
|
||||
$this->load->view('auth/register_success', $this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows users to edit their settings.
|
||||
*/
|
||||
public function settings() {
|
||||
if (!$this->access->loggedIn()) {
|
||||
redirect('auth/login', 'refresh');
|
||||
}
|
||||
|
||||
// validate form
|
||||
// validate the 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', 'access') . ']|matches[new_password_confirm]');
|
||||
|
||||
if ($this->form_validation->run() == true) {
|
||||
@@ -146,18 +146,22 @@ class Auth extends CI_Controller {
|
||||
);
|
||||
$this->access->updateUser($this->session->userdata('user_id'), $updateData);
|
||||
|
||||
echo "{success: true}";
|
||||
} else {
|
||||
$this->data['success'] = true;
|
||||
$this->data['data'] = $this->access->getCurrentUser();
|
||||
|
||||
// output json data
|
||||
// output JSON data
|
||||
$this->output->set_content_type('application/json')
|
||||
->set_output(json_encode($this->data));
|
||||
->set_output(json_encode(array('success' => true)));
|
||||
} else {
|
||||
$data['success'] = true;
|
||||
$data['data'] = $this->access->getCurrentUser();
|
||||
|
||||
// output JSON data
|
||||
$this->output->set_content_type('application/json')
|
||||
->set_output(json_encode($data));
|
||||
}
|
||||
}
|
||||
|
||||
//forgot password
|
||||
/**
|
||||
* Allows users to request a new password.
|
||||
*/
|
||||
public function forgot_password() {
|
||||
$this->form_validation->set_rules('email', 'Email Address', 'required');
|
||||
if ($this->form_validation->run() == false) {
|
||||
@@ -182,7 +186,9 @@ class Auth extends CI_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
//reset password - final step for forgotten password
|
||||
/**
|
||||
* Final step for forgotten password.
|
||||
*/
|
||||
public function reset_password($code) {
|
||||
$reset = $this->access->forgotten_password_complete($code);
|
||||
|
||||
@@ -195,9 +201,6 @@ class Auth extends CI_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function test() {
|
||||
echo "{xtype: 'form', title: 'Bla'}";
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file auth.php */
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<?=img(array('src' => 'assets/images/logo.png', 'style' => 'margin-left: 5px'));?>
|
||||
<div style="float: right; margin-top: 15px; margin-right: 10px; color: #ccc;">
|
||||
<a href="javascript:void(0);" onclick="settings.show();" style="padding: 5px">Einstellungen</a> |
|
||||
<?=anchor('auth/logout', "Logout", array('style' => 'padding: 5px;'));?>
|
||||
<a href="javascript:void(0);" onclick="logout();" style="padding: 5px">Logout</a>
|
||||
</div>
|
||||
<?=img(array('src' => 'assets/images/lang_' . $this->config->item('lang_selected') . '.png', 'style' => 'float: right; margin-top: 18px; margin-right: 5px;'));?>
|
||||
</div>
|
||||
|
||||
@@ -25,7 +25,7 @@ var projectTree = new Ext.tree.TreePanel({
|
||||
dataUrl: BASE_URL + 'projects/getAvailable',
|
||||
root: {
|
||||
nodeType: 'async',
|
||||
text: 'Projekte',
|
||||
text: "Projekte",
|
||||
expanded: true,
|
||||
id: 'projects'
|
||||
}
|
||||
@@ -48,7 +48,7 @@ var tabPanel = new Ext.TabPanel({
|
||||
id: 'tab_welcome',
|
||||
bodyStyle: 'padding: 10px',
|
||||
title: "Willkommen",
|
||||
closable: true,
|
||||
closable: true
|
||||
}]
|
||||
});
|
||||
|
||||
@@ -85,32 +85,21 @@ var layoutMain = new Ext.Viewport({
|
||||
}, layoutCenter]
|
||||
});
|
||||
|
||||
function logout() {
|
||||
Ext.Ajax.request({
|
||||
url: BASE_URL + 'auth/logout',
|
||||
method: 'post',
|
||||
success: function(xhr) {
|
||||
window.location = BASE_URL + 'auth/login';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function loadProjectInfo(n) {
|
||||
if(n.isLeaf()){
|
||||
if (n.isLeaf()) {
|
||||
Ext.Ajax.request({
|
||||
url: BASE_URL + 'projects/detail/' + n.prjId,
|
||||
method: 'get',
|
||||
success: function ( result, request ) {
|
||||
|
||||
success: function(result, request) {
|
||||
var theResponse = Ext.util.JSON.decode(result.responseText);
|
||||
|
||||
tabPanel.add({
|
||||
title: 'New Tab ',
|
||||
html: 'Lade Projekt...',
|
||||
closable:true
|
||||
title: "New Tab",
|
||||
html: "Lade Projekt...",
|
||||
closable: true
|
||||
}).show();
|
||||
},
|
||||
failure: function ( result, request ) {
|
||||
failure: function(result, request) {
|
||||
switch(result.status) {
|
||||
case 404:
|
||||
Ext.MessageBox.alert("Fehler", "Das gewünschte Projekt konnte nicht gefunden werden.");
|
||||
@@ -119,13 +108,11 @@ function loadProjectInfo(n) {
|
||||
Ext.MessageBox.alert("Fehler", "Sie besitzen nicht die nötigen Zugriffsrechte, um dieses Projekt zu lesen."
|
||||
+ "Wenden Sie sich an den Projektbesitzer, um Zugriff zu erhalten.");
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<div id="main"></div>
|
||||
|
||||
|
||||
@@ -36,3 +36,7 @@ a:hover {
|
||||
.x-tree-node-icon {
|
||||
height: 16px !important;
|
||||
}
|
||||
|
||||
.x-form-display-field {
|
||||
color: #777;
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
*
|
||||
* @class SettingsWindow
|
||||
* @extends Ext.Window
|
||||
* @author Eike Foken <kontakt@eikefoken.de>
|
||||
*/
|
||||
SettingsWindow = Ext.extend(Ext.Window, {
|
||||
title: lang['settings_window_title'],
|
||||
id: 'settings-window',
|
||||
width: 400,
|
||||
autoHeight: true,
|
||||
closeAction: 'hide',
|
||||
draggable: false,
|
||||
resizable: false,
|
||||
@@ -18,7 +18,7 @@ SettingsWindow = Ext.extend(Ext.Window, {
|
||||
xtype: 'form',
|
||||
id: 'settings-form',
|
||||
url: BASE_URL + 'auth/settings',
|
||||
method: 'POST',
|
||||
method: 'post',
|
||||
border: false,
|
||||
items: [{
|
||||
xtype: 'tabpanel',
|
||||
@@ -28,24 +28,10 @@ SettingsWindow = Ext.extend(Ext.Window, {
|
||||
layout: 'form',
|
||||
defaultType: 'textfield',
|
||||
labelWidth: 170,
|
||||
autoHeight: true,
|
||||
height: 150,
|
||||
bodyStyle: 'padding: 10px'
|
||||
},
|
||||
items: [{
|
||||
xtype: 'panel',
|
||||
id: 'password',
|
||||
title: lang['settings_window_panel_password'],
|
||||
items: [{
|
||||
fieldLabel: lang['settings_window_old_password'],
|
||||
name: 'old_password'
|
||||
}, {
|
||||
fieldLabel: lang['settings_window_new_password'],
|
||||
name: 'new_password'
|
||||
}, {
|
||||
fieldLabel: lang['settings_window_new_password_confirm'],
|
||||
name: 'new_password_confirm'
|
||||
}]
|
||||
}, {
|
||||
xtype: 'panel',
|
||||
title: lang['settings_window_panel_profile'],
|
||||
items: [{
|
||||
@@ -64,17 +50,46 @@ SettingsWindow = Ext.extend(Ext.Window, {
|
||||
fieldLabel: lang['settings_window_email'],
|
||||
name: 'email'
|
||||
}]
|
||||
}, {
|
||||
xtype: 'panel',
|
||||
id: 'password',
|
||||
title: lang['settings_window_panel_password'],
|
||||
items: [{
|
||||
fieldLabel: lang['settings_window_old_password'],
|
||||
name: 'old_password',
|
||||
inputType: 'password'
|
||||
}, {
|
||||
fieldLabel: lang['settings_window_new_password'],
|
||||
name: 'new_password',
|
||||
inputType: 'password'
|
||||
}, {
|
||||
fieldLabel: lang['settings_window_new_password_confirm'],
|
||||
name: 'new_password_confirm',
|
||||
inputType: 'password'
|
||||
}, {
|
||||
xtype: 'displayfield',
|
||||
value: lang['settings_window_password_note'],
|
||||
hideLabel: true
|
||||
}]
|
||||
}]
|
||||
}],
|
||||
buttons: [{
|
||||
text: lang['settings_window_save'],
|
||||
handler: function() {
|
||||
Ext.getCmp('settings-form').getForm().submit();
|
||||
var theForm = Ext.getCmp('settings-form').getForm();
|
||||
|
||||
if (theForm.isValid()) {
|
||||
theForm.submit({
|
||||
success: function() {
|
||||
Ext.getCmp('settings-window').hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
text: lang['settings_window_close'],
|
||||
text: lang['settings_window_cancel'],
|
||||
handler: function() {
|
||||
this.hide();
|
||||
Ext.getCmp('settings-window').hide();
|
||||
}
|
||||
}]
|
||||
}];
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*
|
||||
* @param {} title
|
||||
* @param {} message
|
||||
* @param {} icon
|
||||
*/
|
||||
var message = function(title, message, icon) {
|
||||
Ext.Msg.show({
|
||||
@@ -15,11 +16,26 @@ var message = function(title, message, icon) {
|
||||
});
|
||||
};
|
||||
|
||||
var settings = new SettingsWindow();
|
||||
/**
|
||||
* Logs the user out.
|
||||
*/
|
||||
var logout = function() {
|
||||
Ext.Ajax.request({
|
||||
url: BASE_URL + 'auth/logout',
|
||||
method: 'post',
|
||||
success: function(xhr) {
|
||||
window.location = BASE_URL + 'auth/login';
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Application main entry point
|
||||
*/
|
||||
Ext.onReady(function() {
|
||||
Ext.QuickTips.init();
|
||||
|
||||
if (typeof(SettingsWindow) == "function") {
|
||||
settings = new SettingsWindow();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
var lang = {
|
||||
settings_window_title: "Settings",
|
||||
settings_window_save: "Save",
|
||||
settings_window_close: "Close",
|
||||
settings_window_cancel: "Cancel",
|
||||
settings_window_panel_password: "Password",
|
||||
settings_window_panel_profile: "Profile",
|
||||
settings_window_old_password: "Old password",
|
||||
settings_window_old_password: "Current password",
|
||||
settings_window_new_password: "New password",
|
||||
settings_window_new_password_confirm: "Confirm new password",
|
||||
settings_window_password_note: "If you want to change your password, please fill out these fields, otherwise leave it blank.",
|
||||
settings_window_firstname: "Firstname",
|
||||
settings_window_lastname: "Lastname",
|
||||
settings_window_institution: "Company",
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
var lang = {
|
||||
settings_window_title: "Einstellungen",
|
||||
settings_window_save: "Speichern",
|
||||
settings_window_close: "Schließen",
|
||||
settings_window_cancel: "Abbrechen",
|
||||
settings_window_panel_password: "Passwort",
|
||||
settings_window_panel_profile: "Profil",
|
||||
settings_window_old_password: "Altes Passwort",
|
||||
settings_window_old_password: "Aktuelles Passwort",
|
||||
settings_window_new_password: "Neues Passwort",
|
||||
settings_window_new_password_confirm: "Neues Passwort wiederholen",
|
||||
settings_window_new_password_confirm: "Neues Passwort bestätigen",
|
||||
settings_window_password_note: "Wenn Sie Ihr Passwort ändern möchten, füllen Sie bitte die obigen Felder aus, ansonsten lassen Sie sie einfach leer.",
|
||||
settings_window_firstname: "Vorname",
|
||||
settings_window_lastname: "Nachname",
|
||||
settings_window_institution: "Institut",
|
||||
|
||||
Reference in New Issue
Block a user