2015-05-05 03:00:01 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
2015-05-15 00:07:45 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Functions
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-08-03 02:49:12 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Main before POST
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-05-15 00:07:45 +02:00
|
|
|
// ============================================================================
|
|
|
|
// POST Method
|
|
|
|
// ============================================================================
|
|
|
|
|
2018-04-27 20:36:43 +02:00
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
2017-06-28 00:31:40 +02:00
|
|
|
// Prevent non-administrators to change other users
|
2018-07-14 15:17:06 +02:00
|
|
|
if ($login->role()!=='admin') {
|
|
|
|
$_POST['username'] = $login->username();
|
2015-05-15 00:07:45 +02:00
|
|
|
unset($_POST['role']);
|
|
|
|
}
|
|
|
|
|
2018-05-14 00:00:10 +02:00
|
|
|
if (isset($_POST['deleteUserAndDeleteContent'])) {
|
|
|
|
$_POST['deleteContent'] = true;
|
|
|
|
deleteUser($_POST);
|
|
|
|
} elseif (isset($_POST['deleteUserAndKeepContent'])) {
|
|
|
|
$_POST['deleteContent'] = false;
|
|
|
|
deleteUser($_POST);
|
|
|
|
} elseif (isset($_POST['disableUser'])) {
|
|
|
|
disableUser(array('username'=>$_POST['username']));
|
|
|
|
} else {
|
2015-07-22 05:15:02 +02:00
|
|
|
editUser($_POST);
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
2017-06-28 00:31:40 +02:00
|
|
|
|
|
|
|
Alert::set($Language->g('The changes have been saved'));
|
2018-05-14 00:00:10 +02:00
|
|
|
Redirect::page('users');
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
2015-08-03 02:49:12 +02:00
|
|
|
// Main after POST
|
2015-05-15 00:07:45 +02:00
|
|
|
// ============================================================================
|
|
|
|
|
2017-06-28 00:31:40 +02:00
|
|
|
// Prevent non-administrators to change other users
|
2018-07-14 15:17:06 +02:00
|
|
|
if ($login->role()!=='admin') {
|
|
|
|
$layout['parameters'] = $login->username();
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
|
|
|
|
2018-05-14 00:00:10 +02:00
|
|
|
// Get the user to edit
|
|
|
|
$user = $dbUsers->get($layout['parameters']);
|
|
|
|
if ($user===false) {
|
2017-06-05 22:36:09 +02:00
|
|
|
Redirect::page('users');
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
2017-09-09 00:33:14 +02:00
|
|
|
|
|
|
|
// Title of the page
|
2018-05-14 00:00:10 +02:00
|
|
|
$layout['title'] = $Language->g('Edit user').' - '.$layout['title'];
|