move settings to config file

This commit is contained in:
Jean-Christian Paul Denis 2021-09-07 08:48:58 +02:00
parent 6ce6b1fdbe
commit d469782cfb
2 changed files with 65 additions and 44 deletions

65
_config.php Normal file
View File

@ -0,0 +1,65 @@
<?php
if (!defined('DC_CONTEXT_MODULE')) {
return null;
}
if (!$core->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 '
<p><label class="classic" for="behavior_active">' .
form::checkbox(
'behavior_active',
1,
$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active
) . ' ' . __('Activate behaviors') . '</label></p>
<p class="form-note">' . __('Enable actions set in _uninstall.php files.') . '</p>
<p><label class="classic" for="dcproperty_hide">' .
form::checkbox(
'dcproperty_hide',
1,
$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide
) . ' ' . __('Hide Dotclear default properties in actions tabs') . '</label></p>
<p class="form-note">' .
__('Prevent from deleting Dotclear important properties.') . '</p>';

View File

@ -168,20 +168,6 @@ $combo_type = [
'versions' => ['delete'] '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 # Actions
if ($tab == 'lists' && !empty($entries) if ($tab == 'lists' && !empty($entries)
&& isset($combo_type[$type]) && isset($combo_type[$type])
@ -241,36 +227,6 @@ echo '</div>';
# --BEHAVIOR-- dcAdvancedCleanerAdminTabs # --BEHAVIOR-- dcAdvancedCleanerAdminTabs
$core->callBehavior('dcAdvancedCleanerAdminTabs', $core, $core->adminurl->get('admin.plugin.dcAdvancedCleaner', ['tab' => $tab, 'part' => $part])); $core->callBehavior('dcAdvancedCleanerAdminTabs', $core, $core->adminurl->get('admin.plugin.dcAdvancedCleaner', ['tab' => $tab, 'part' => $part]));
echo '
<div class="multi-part" id="dcac" title="' . __('This plugin settings') . '">
<fieldset><legend>' . __('This plugin settings') . '</legend>
<form method="post" action="' . $core->adminurl->get('admin.plugin.dcAdvancedCleaner', ['tab' => 'dcac', 'part' => '']) . '">
<p><label class="classic" for="dcadvancedcleaner_behavior_active">' .
form::checkbox(
'dcadvancedcleaner_behavior_active',
1,
$s->dcAdvancedCleaner_behavior_active
) . __('Activate behaviors') . '</label></p>
<p class="form-note">' . __('Enable actions set in _uninstall.php files.') . '</p>
<p><label class="classic" for="dcadvancedcleaner_dcproperty_hide">' .
form::checkbox(
'dcadvancedcleaner_dcproperty_hide',
1,
$s->dcAdvancedCleaner_dcproperty_hide
).
__('Hide Dotclear default properties in actions tabs') . '
</label></p>
<p class="form-note">' . __('Prevent from deleting Dotclear important properties.') . '</p>
<p><input type="submit" name="submit" value="' . __('Save') . '" />' .
form::hidden(['p'],'dcAdvancedCleaner') .
form::hidden(['tab'],'dcac') .
form::hidden(['part'],'') .
form::hidden(['action'], 'dcadvancedcleaner_settings') .
$core->formNonce() . '</p>
</form>
</fieldset>
</div>';
dcPage::helpBlock('dcAdvancedCleaner'); dcPage::helpBlock('dcAdvancedCleaner');
echo '</body></html>'; echo '</body></html>';