2015-05-05 01:00:01 +00:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
2015-05-14 22:07:45 +00:00
|
|
|
// ============================================================================
|
|
|
|
// Functions
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-08-02 21:49:12 -03:00
|
|
|
// ============================================================================
|
|
|
|
// Main before POST
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-05-14 22:07:45 +00:00
|
|
|
// ============================================================================
|
|
|
|
// POST Method
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-05-05 01:00:01 +00:00
|
|
|
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|
|
|
{
|
2017-06-28 00:31:40 +02:00
|
|
|
// Prevent non-administrators to change other users
|
|
|
|
if($Login->role()!=='admin') {
|
2015-05-14 22:07:45 +00:00
|
|
|
$_POST['username'] = $Login->username();
|
|
|
|
unset($_POST['role']);
|
|
|
|
}
|
|
|
|
|
2015-07-22 00:15:02 -03:00
|
|
|
if(isset($_POST['delete-user-all'])) {
|
2017-06-28 00:31:40 +02:00
|
|
|
deleteUser($_POST, $deleteContent=true);
|
2015-07-22 00:15:02 -03:00
|
|
|
}
|
|
|
|
elseif(isset($_POST['delete-user-associate'])) {
|
2017-06-28 00:31:40 +02:00
|
|
|
deleteUser($_POST, $deleteContent=false);
|
2015-07-22 00:15:02 -03:00
|
|
|
}
|
2016-09-06 21:14:57 -03:00
|
|
|
elseif(isset($_POST['disable-user'])) {
|
|
|
|
disableUser($_POST['username']);
|
|
|
|
}
|
2015-10-18 19:45:58 -03:00
|
|
|
else {
|
2015-07-22 00:15:02 -03:00
|
|
|
editUser($_POST);
|
2015-05-05 01:00:01 +00:00
|
|
|
}
|
2017-06-28 00:31:40 +02:00
|
|
|
|
|
|
|
Alert::set($Language->g('The changes have been saved'));
|
2015-05-14 22:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
2015-08-02 21:49:12 -03:00
|
|
|
// Main after POST
|
2015-05-14 22:07:45 +00:00
|
|
|
// ============================================================================
|
|
|
|
|
2017-06-28 00:31:40 +02:00
|
|
|
// Prevent non-administrators to change other users
|
2015-05-14 22:07:45 +00:00
|
|
|
if($Login->role()!=='admin') {
|
|
|
|
$layout['parameters'] = $Login->username();
|
2015-05-05 01:00:01 +00:00
|
|
|
}
|
|
|
|
|
2017-06-28 00:31:40 +02:00
|
|
|
$User = $dbUsers->getUser($layout['parameters']);
|
2015-05-05 01:00:01 +00:00
|
|
|
|
|
|
|
// If the user doesn't exist, redirect to the users list.
|
2017-06-28 00:31:40 +02:00
|
|
|
if($User===false) {
|
2017-06-05 22:36:09 +02:00
|
|
|
Redirect::page('users');
|
2015-05-14 22:07:45 +00:00
|
|
|
}
|
2017-09-09 00:33:14 +02:00
|
|
|
|
|
|
|
// Title of the page
|
|
|
|
$layout['title'] .= ' - '.$Language->g('Edit user');
|