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
|
|
|
|
// ============================================================================
|
|
|
|
|
2018-05-20 21:48:43 +02:00
|
|
|
checkRole(array('admin'));
|
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
|
2018-05-20 21:48:43 +02:00
|
|
|
if (isset($plugins['all'][$pluginClassName])) {
|
2017-05-27 19:46:46 +02:00
|
|
|
$plugin = $plugins['all'][$pluginClassName];
|
2018-05-20 21:48:43 +02:00
|
|
|
} else {
|
2017-05-27 19:46:46 +02:00
|
|
|
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()
|
2018-05-20 21:48:43 +02:00
|
|
|
if (!method_exists($plugin, 'form')) {
|
2017-05-27 19:46:46 +02:00
|
|
|
Redirect::page('plugins');
|
2015-08-01 18:28:47 +02:00
|
|
|
}
|
|
|
|
|
2015-07-14 04:16:28 +02:00
|
|
|
// ============================================================================
|
|
|
|
// POST Method
|
|
|
|
// ============================================================================
|
|
|
|
|
2018-05-20 21:48:43 +02:00
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
2017-05-27 19:46:46 +02:00
|
|
|
// Add to syslog
|
2018-06-10 13:54:55 +02:00
|
|
|
$syslog->add(array(
|
2017-05-27 19:46:46 +02:00
|
|
|
'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
|
2018-05-20 21:48:43 +02:00
|
|
|
if ($plugin->post()) {
|
2018-08-03 19:03:09 +02:00
|
|
|
Alert::set( $language->g('The changes have been saved') );
|
2017-06-26 22:50:56 +02:00
|
|
|
Redirect::page('configure-plugin/'.$plugin->className());
|
2018-05-20 21:48:43 +02:00
|
|
|
} else {
|
2018-08-03 19:03:09 +02:00
|
|
|
Alert::set( $language->g('Complete all fields') );
|
2017-06-19 23:14:38 +02:00
|
|
|
}
|
2015-07-14 04:16:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Main after POST
|
|
|
|
// ============================================================================
|
2017-09-09 00:33:14 +02:00
|
|
|
|
|
|
|
// Title of the page
|
2018-08-03 19:03:09 +02:00
|
|
|
$layout['title'] = $language->g('Plugin').' - '.$plugin->name().' - '.$layout['title'];
|