bludit/admin/controllers/edit-user.php

63 lines
1.5 KiB
PHP
Raw Normal View History

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-05-05 01:00:01 +00:00
function editUser($args)
{
global $dbUsers;
2015-07-20 00:14:12 -03:00
global $Language;
2015-05-05 01:00:01 +00:00
if(isset($args['password']))
{
2015-05-30 22:06:55 -03:00
if( ($args['password']===$args['confirm-password']) && !Text::isEmpty($args['password']) ) {
2015-06-09 19:55:23 -03:00
return $dbUsers->setPassword($args);
2015-05-05 01:00:01 +00:00
}
else {
2015-07-20 00:14:12 -03:00
Alert::set($Language->g('password-does-not-match-the-confirm-password'));
2015-05-05 01:00:01 +00:00
return false;
}
}
else
{
return $dbUsers->set($args);
}
}
2015-05-14 22:07:45 +00:00
// ============================================================================
// POST Method
// ============================================================================
2015-05-05 01:00:01 +00:00
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{
2015-05-14 22:07:45 +00:00
if($Login->role()!=='admin')
{
$_POST['username'] = $Login->username();
unset($_POST['role']);
}
2015-05-05 01:00:01 +00:00
if( editUser($_POST) ) {
2015-07-20 00:14:12 -03:00
Alert::set($Language->g('the-changes-have-been-saved'));
2015-05-05 01:00:01 +00:00
}
2015-05-14 22:07:45 +00:00
}
// ============================================================================
// Main
// ============================================================================
if($Login->role()!=='admin') {
$layout['parameters'] = $Login->username();
2015-05-05 01:00:01 +00:00
}
2015-07-14 20:57:18 -03:00
$_user = $dbUsers->getDb($layout['parameters']);
2015-05-05 01:00:01 +00:00
// If the user doesn't exist, redirect to the users list.
2015-05-14 22:07:45 +00:00
if($_user===false) {
Redirect::page('admin', 'users');
}
2015-05-30 22:06:55 -03:00
$_user['username'] = $layout['parameters'];