2015-07-14 04:16:28 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
2015-07-14 06:41:32 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Check role
|
|
|
|
// ============================================================================
|
|
|
|
|
2017-09-09 00:33:14 +02:00
|
|
|
if ($Login->role()!=='admin') {
|
|
|
|
Alert::set($Language->g('You do not have sufficient permissions'));
|
2017-05-27 19:46:46 +02:00
|
|
|
Redirect::page('dashboard');
|
2015-07-14 06:41:32 +02:00
|
|
|
}
|
|
|
|
|
2015-07-14 04:16:28 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Functions
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Main before POST
|
|
|
|
// ============================================================================
|
2017-05-27 19:46:46 +02:00
|
|
|
$plugin = false;
|
2015-07-28 03:01:52 +02:00
|
|
|
$pluginClassName = $layout['parameters'];
|
2015-07-14 04:16:28 +02:00
|
|
|
|
2017-05-27 19:46:46 +02:00
|
|
|
// Check if the plugin exists
|
|
|
|
if( isset($plugins['all'][$pluginClassName]) ) {
|
|
|
|
$plugin = $plugins['all'][$pluginClassName];
|
2015-07-14 04:16:28 +02:00
|
|
|
}
|
2017-05-27 19:46:46 +02:00
|
|
|
else {
|
|
|
|
Redirect::page('plugins');
|
2015-07-14 04:16:28 +02:00
|
|
|
}
|
|
|
|
|
2015-08-01 18:28:47 +02:00
|
|
|
// Check if the plugin has the method form()
|
2017-05-27 19:46:46 +02:00
|
|
|
if( !method_exists($plugin, 'form') ) {
|
|
|
|
Redirect::page('plugins');
|
2015-08-01 18:28:47 +02:00
|
|
|
}
|
|
|
|
|
2015-07-14 04:16:28 +02:00
|
|
|
// ============================================================================
|
|
|
|
// POST Method
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|
|
|
{
|
2017-05-27 19:46:46 +02:00
|
|
|
// Add to syslog
|
|
|
|
$Syslog->add(array(
|
|
|
|
'dictionaryKey'=>'plugin-configured',
|
|
|
|
'notes'=>$plugin->name()
|
|
|
|
));
|
2016-05-30 05:36:13 +02:00
|
|
|
|
2017-06-19 23:14:38 +02:00
|
|
|
// Call the method post of the plugin
|
|
|
|
if( $plugin->post() ) {
|
|
|
|
// Create an alert
|
|
|
|
Alert::set( $Language->g('The changes have been saved') );
|
2017-06-26 22:50:56 +02:00
|
|
|
Redirect::page('configure-plugin/'.$plugin->className());
|
2017-06-19 23:14:38 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Create an alert
|
|
|
|
Alert::set( $Language->g('Complete all fields') );
|
|
|
|
}
|
2015-07-14 04:16:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Main after POST
|
|
|
|
// ============================================================================
|
2017-09-09 00:33:14 +02:00
|
|
|
|
|
|
|
// Title of the page
|
|
|
|
$layout['title'] .= ' - '.$Language->g('Plugin').' - '.$plugin->name();
|