From d469782cfbddc9d113dcc2893510c0d0afbd8f47 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Tue, 7 Sep 2021 08:48:58 +0200 Subject: [PATCH] move settings to config file --- _config.php | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ index.php | 44 ------------------------------------ 2 files changed, 65 insertions(+), 44 deletions(-) create mode 100644 _config.php diff --git a/_config.php b/_config.php new file mode 100644 index 0000000..647f8e6 --- /dev/null +++ b/_config.php @@ -0,0 +1,65 @@ +auth->isSuperAdmin()) { + return null; +} +if (!empty($_POST['save'])) { + try { + $core->blog->settings->dcAdvancedCleaner->dropEvery( + 'dcAdvancedCleaner_behavior_active' + ); + $core->blog->settings->dcAdvancedCleaner->put( + 'dcAdvancedCleaner_behavior_active', + !empty($_POST['behavior_active']), + 'boolean', + null, + true, + true + ); + $core->blog->settings->dcAdvancedCleaner->dropEvery( + 'dcAdvancedCleaner_dcproperty_hide' + ); + $core->blog->settings->dcAdvancedCleaner->put( + 'dcAdvancedCleaner_dcproperty_hide', + !empty($_POST['dcproperty_hide']), + 'boolean', + null, + true, + true + ); + dcPage::addSuccessNotice( + __('Configuration successfully updated.') + ); + $core->adminurl->redirect( + 'admin.plugins', + [ + 'module' => 'dcAdvancedCleaner', + 'conf' => 1, + 'redir' => empty($_REQUEST['redir']) ? $list->getURL() . '#plugins' : $_REQUEST['redir'] + ] + ); + } + catch(Exception $e) { + $core->error->add($e->getMessage()); + } +} +echo ' +

+

' . __('Enable actions set in _uninstall.php files.') . '

+

+

' . +__('Prevent from deleting Dotclear important properties.') . '

'; \ No newline at end of file diff --git a/index.php b/index.php index 3707a02..81461d0 100644 --- a/index.php +++ b/index.php @@ -168,20 +168,6 @@ $combo_type = [ 'versions' => ['delete'] ]; -# This plugin settings -if ($tab == 'dcac' && $action == 'dcadvancedcleaner_settings') { - try { - $s->put('dcAdvancedCleaner_behavior_active', isset($_POST['dcadvancedcleaner_behavior_active']), 'boolean'); - $s->put('dcAdvancedCleaner_dcproperty_hide', isset($_POST['dcadvancedcleaner_dcproperty_hide']), 'boolean'); - - dcPage::addSuccessNotice(__('Settings successfuly updated')); - $core->adminurl->redirect('admin.plugin.dcAdvancedCleaner', ['tab' => 'dcac', 'part' => '']); - } - catch(Exception $e) { - $core->error->add($e->getMessage()); - } -} - # Actions if ($tab == 'lists' && !empty($entries) && isset($combo_type[$type]) @@ -241,36 +227,6 @@ echo ''; # --BEHAVIOR-- dcAdvancedCleanerAdminTabs $core->callBehavior('dcAdvancedCleanerAdminTabs', $core, $core->adminurl->get('admin.plugin.dcAdvancedCleaner', ['tab' => $tab, 'part' => $part])); -echo ' -
-
' . __('This plugin settings') . ' -
-

-

' . __('Enable actions set in _uninstall.php files.') . '

-

-

' . __('Prevent from deleting Dotclear important properties.') . '

-

' . -form::hidden(['p'],'dcAdvancedCleaner') . -form::hidden(['tab'],'dcac') . -form::hidden(['part'],'') . -form::hidden(['action'], 'dcadvancedcleaner_settings') . -$core->formNonce() . '

-
-
-
'; - dcPage::helpBlock('dcAdvancedCleaner'); echo ''; \ No newline at end of file