bludit/kernel/admin/controllers/settings.php

81 lines
2.3 KiB
PHP
Raw 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
// ============================================================================
// Check role
// ============================================================================
if($Login->role()!=='admin') {
2015-07-20 05:14:12 +02:00
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
2015-05-15 00:07:45 +02:00
Redirect::page('admin', 'dashboard');
}
2015-05-05 03:00:01 +02:00
// ============================================================================
// Functions
// ============================================================================
function setSettings($args)
{
global $Site;
2015-07-20 05:14:12 +02:00
global $Language;
2015-08-03 02:49:12 +02:00
2015-06-26 06:31:53 +02:00
// Add slash at the begin and end.
// This fields are in the settings->advanced mode
2015-09-18 02:37:14 +02:00
if(isset($args['form-advanced'])) {
2015-06-26 06:31:53 +02:00
$args['url'] = Text::addSlashes($args['url'],false,true);
$args['uriPost'] = Text::addSlashes($args['uriPost']);
$args['uriPage'] = Text::addSlashes($args['uriPage']);
$args['uriTag'] = Text::addSlashes($args['uriTag']);
2015-09-18 02:37:14 +02:00
if(($args['uriPost']==$args['uriPage']) || ($args['uriPost']==$args['uriTag']) || ($args['uriPage']==$args['uriTag']) )
{
$args = array();
}
2015-06-26 06:31:53 +02:00
}
2015-05-05 03:00:01 +02:00
if( $Site->set($args) ) {
2015-07-20 05:14:12 +02:00
Alert::set($Language->g('the-changes-have-been-saved'));
2015-05-05 03:00:01 +02:00
}
else {
2015-07-22 05:15:02 +02:00
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the settings.');
2015-05-05 03:00:01 +02:00
}
2015-08-05 02:12:11 +02:00
return true;
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
// ============================================================================
// POST Method
// ============================================================================
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{
setSettings($_POST);
2015-08-05 02:12:11 +02:00
Redirect::page('admin', $layout['controller']);
2015-05-05 03:00:01 +02:00
}
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
// ============================================================================
2015-07-26 05:37:51 +02:00
// Default home page
$_homePageList = array(''=>$Language->g('Show blog'));
foreach($pagesParents as $parentKey=>$pageList)
{
foreach($pageList as $Page)
{
if($parentKey!==NO_PARENT_CHAR) {
$parentTitle = $pages[$Page->parentKey()]->title().'->';
}
else {
$parentTitle = '';
}
if($Page->published()) {
$_homePageList[$Page->key()] = $Language->g('Page').': '.$parentTitle.$Page->title();
}
}
}