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

61 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
// ============================================================================
if($Login->role()!=='admin') {
2015-07-20 05:14:12 +02:00
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
Redirect::page('dashboard');
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
if( isset($plugins['all'][$pluginClassName]) ) {
$plugin = $plugins['all'][$pluginClassName];
2015-07-14 04:16:28 +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()
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' )
{
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'plugin-configured',
'notes'=>$plugin->name()
));
// Call the method post of the plugin
if( $plugin->post() ) {
// Create an alert
Alert::set( $Language->g('The changes have been saved') );
}
else {
// Create an alert
Alert::set( $Language->g('Complete all fields') );
}
2015-07-14 04:16:28 +02:00
}
// ============================================================================
// Main after POST
// ============================================================================