bludit/bl-kernel/admin/controllers/configure-plugin.php

56 lines
1.8 KiB
PHP
Raw Normal View History

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
// ============================================================================
$plugin = false;
2015-07-28 03:01:52 +02:00
$pluginClassName = $layout['parameters'];
2015-07-14 04:16:28 +02:00
// Check if the plugin exists
2018-05-20 21:48:43 +02:00
if (isset($plugins['all'][$pluginClassName])) {
$plugin = $plugins['all'][$pluginClassName];
2018-05-20 21:48:43 +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()
2018-05-20 21:48:43 +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
// ============================================================================
2018-05-20 21:48:43 +02:00
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'plugin-configured',
'notes'=>$plugin->name()
));
// Call the method post of the plugin
2018-05-20 21:48:43 +02:00
if ($plugin->post()) {
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 {
Alert::set( $Language->g('Complete all fields') );
}
2015-07-14 04:16:28 +02:00
}
// ============================================================================
// Main after POST
// ============================================================================
// Title of the page
2018-05-20 21:48:43 +02:00
$layout['title'] = $Language->g('Plugin').' - '.$plugin->name().' - '.$layout['title'];