2015-11-07 01:23:50 +01:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Functions
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Main before POST
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// POST Method
|
|
|
|
// ============================================================================
|
|
|
|
|
2018-05-15 20:12:15 +02:00
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
|
|
if (changeUserPassword(array(
|
|
|
|
'username'=>$_POST['username'],
|
|
|
|
'newPassword'=>$_POST['newPassword'],
|
|
|
|
'confirmPassword'=>$_POST['confirmPassword']
|
|
|
|
))) {
|
2017-06-05 22:36:09 +02:00
|
|
|
Redirect::page('users');
|
2015-11-07 01:23:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Main after POST
|
|
|
|
// ============================================================================
|
|
|
|
|
2018-05-15 20:12:15 +02:00
|
|
|
// Prevent non-administrators to change other users
|
|
|
|
if ($Login->role()!=='admin') {
|
2015-11-07 01:23:50 +01:00
|
|
|
$layout['parameters'] = $Login->username();
|
|
|
|
}
|
|
|
|
|
2018-05-15 20:12:15 +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-11-07 01:23:50 +01:00
|
|
|
}
|
|
|
|
|
2017-09-09 00:33:14 +02:00
|
|
|
// Title of the page
|
2018-05-15 20:12:15 +02:00
|
|
|
$layout['title'] = $Language->g('Change password').' - '.$layout['title'];
|