2015-05-05 03:00:01 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
2016-01-08 00:43:09 +01:00
|
|
|
// ============================================================================
|
|
|
|
// Check role
|
|
|
|
// ============================================================================
|
|
|
|
|
2018-05-20 21:48:43 +02:00
|
|
|
if (!checkRole(array('admin','moderator'), false)) {
|
|
|
|
$pageKey = isset($_POST['key']) ? $_POST['key'] : $layout['parameters'];
|
|
|
|
$page = buildPage($pageKey);
|
|
|
|
if (!$page || $page->username()!==$Login->username()) {
|
2018-06-10 13:54:55 +02:00
|
|
|
$syslog->add(array(
|
2018-05-20 21:48:43 +02:00
|
|
|
'dictionaryKey'=>'access-deny',
|
|
|
|
'notes'=>$Login->username()
|
|
|
|
));
|
|
|
|
Alert::set($Language->g('You do not have sufficient permissions'));
|
|
|
|
Redirect::page('dashboard');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-05 03:00:01 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Functions
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-08-03 02:49:12 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Main before POST
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-05-05 03:00:01 +02:00
|
|
|
// ============================================================================
|
|
|
|
// POST Method
|
|
|
|
// ============================================================================
|
|
|
|
|
2017-09-10 23:09:44 +02:00
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
2015-10-19 00:45:58 +02:00
|
|
|
if( isset($_POST['delete-page']) ) {
|
2017-06-23 00:41:00 +02:00
|
|
|
if( deletePage($_POST['key']) ) {
|
|
|
|
Alert::set( $Language->g('The changes have been saved') );
|
2017-10-02 22:42:18 +02:00
|
|
|
Redirect::page('content');
|
2017-06-23 00:41:00 +02:00
|
|
|
}
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
|
|
|
else {
|
2017-06-23 00:41:00 +02:00
|
|
|
$key = editPage($_POST);
|
|
|
|
if( $key!==false ) {
|
|
|
|
Alert::set( $Language->g('The changes have been saved') );
|
2017-10-02 22:42:18 +02:00
|
|
|
Redirect::page('edit-content/'.$key);
|
2017-06-23 00:41:00 +02:00
|
|
|
}
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
2017-06-23 00:41:00 +02:00
|
|
|
|
2017-10-02 22:42:18 +02:00
|
|
|
Redirect::page('content');
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
2015-08-03 02:49:12 +02:00
|
|
|
// Main after POST
|
2015-05-05 03:00:01 +02:00
|
|
|
// ============================================================================
|
2017-09-10 23:09:44 +02:00
|
|
|
$pageKey = $layout['parameters'];
|
|
|
|
$page = buildPage($pageKey);
|
|
|
|
if ($page===false) {
|
|
|
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$pageKey);
|
2017-10-02 22:42:18 +02:00
|
|
|
Redirect::page('content');
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
|
|
|
|
2017-09-09 00:33:14 +02:00
|
|
|
// Title of the page
|
2017-10-02 22:42:18 +02:00
|
|
|
$layout['title'] .= ' - '.$Language->g('Edit content').' - '.$page->title();
|