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

64 lines
1.9 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') {
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') );
2017-06-26 22:50:56 +02:00
Redirect::page('configure-plugin/'.$plugin->className());
}
else {
// Create an alert
Alert::set( $Language->g('Complete all fields') );
}
2015-07-14 04:16:28 +02:00
}
// ============================================================================
// Main after POST
// ============================================================================
// Title of the page
$layout['title'] .= ' - '.$Language->g('Plugin').' - '.$plugin->name();