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-05-05 03:00:01 +02:00
|
|
|
function editUser($args)
|
|
|
|
{
|
|
|
|
global $dbUsers;
|
|
|
|
|
|
|
|
if(isset($args['password']))
|
|
|
|
{
|
2015-05-31 03:06:55 +02:00
|
|
|
if( ($args['password']===$args['confirm-password']) && !Text::isEmpty($args['password']) ) {
|
2015-05-05 03:00:01 +02:00
|
|
|
return $dbUsers->set($args);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Alert::set('Passwords are differents.');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $dbUsers->set($args);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-05-15 00:07:45 +02:00
|
|
|
// ============================================================================
|
|
|
|
// POST Method
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-05-05 03:00:01 +02:00
|
|
|
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|
|
|
{
|
2015-05-15 00:07:45 +02:00
|
|
|
|
|
|
|
if($Login->role()!=='admin')
|
|
|
|
{
|
|
|
|
$_POST['username'] = $Login->username();
|
|
|
|
unset($_POST['role']);
|
|
|
|
}
|
|
|
|
|
2015-05-05 03:00:01 +02:00
|
|
|
if( editUser($_POST) ) {
|
|
|
|
Alert::set('User saved successfuly.');
|
|
|
|
}
|
2015-05-15 00:07:45 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Main
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
if($Login->role()!=='admin') {
|
|
|
|
$layout['parameters'] = $Login->username();
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$_user = $dbUsers->get($layout['parameters']);
|
|
|
|
|
|
|
|
// If the user doesn't exist, redirect to the users list.
|
2015-05-15 00:07:45 +02:00
|
|
|
if($_user===false) {
|
|
|
|
Redirect::page('admin', 'users');
|
|
|
|
}
|
|
|
|
|
2015-05-31 03:06:55 +02:00
|
|
|
$_user['username'] = $layout['parameters'];
|