bludit/bl-kernel/admin/controllers/edit-user.php

60 lines
1.9 KiB
PHP
Raw Permalink Normal View History

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
// ============================================================================
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Prevent non-administrators to change other users
if ($login->role()!=='admin') {
$_POST['username'] = $login->username();
2015-05-15 00:07:45 +02:00
unset($_POST['role']);
}
2018-11-09 00:59:06 +01:00
if (isset($_POST['deleteUserAndDeleteContent']) && ($login->role()==='admin')) {
2018-05-14 00:00:10 +02:00
$_POST['deleteContent'] = true;
deleteUser($_POST);
2018-11-09 00:59:06 +01:00
} elseif (isset($_POST['deleteUserAndKeepContent']) && ($login->role()==='admin')) {
2018-05-14 00:00:10 +02:00
$_POST['deleteContent'] = false;
deleteUser($_POST);
2018-11-09 00:59:06 +01:00
} elseif (isset($_POST['disableUser']) && ($login->role()==='admin')) {
2018-05-14 00:00:10 +02:00
disableUser(array('username'=>$_POST['username']));
} else {
2015-07-22 05:15:02 +02:00
editUser($_POST);
2015-05-05 03:00:01 +02:00
}
Alert::set($L->g('The changes have been saved'));
2018-11-09 00:59:06 +01:00
if ($login->role()==='admin') {
Redirect::page('users');
}
Redirect::page('edit-user/'.$login->username());
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
// ============================================================================
2018-07-25 23:42:00 +02:00
$username = $layout['parameters'];
// Prevent non-administrators to change other users
if ($login->role()!=='admin') {
2018-07-25 23:42:00 +02:00
$username = $login->username();
2015-05-05 03:00:01 +02:00
}
2018-07-25 23:42:00 +02:00
try {
$user = new User($username);
} catch (Exception $e) {
Redirect::page('users');
2015-05-15 00:07:45 +02:00
}
// Title of the page
$layout['title'] = $L->g('Edit user').' - '.$layout['title'];