Commit 023c0a7f authored by chealer's avatar chealer

[ENH] When resetting a preference, delete its record rather than setting the value to the default

parent f862a419
......@@ -323,16 +323,16 @@ class PreferencesLib
$changes = array();
foreach ( $handled as $pref ) {
if ( in_array($pref, $resets) ) {
$defaults = get_default_prefs();
$value = $defaults[$pref];
$tikilib->delete_preference($pref);
$changes[$pref] = array('type'=> 'reset');
} else {
$value = $this->formatPreference($pref, $data);
}
$realPref = in_array($pref, $user_overrider_prefs)? "site_$pref": $pref;
if ( ($old = $tikilib->get_preference($realPref) ) != $value ) {
if ($tikilib->set_preference($pref, $value)) {
$changes[$pref] = array('new'=> $value, 'old' => $old);
$realPref = in_array($pref, $user_overrider_prefs)? "site_$pref": $pref;
if ( ($old = $tikilib->get_preference($realPref) ) != $value ) {
if ($tikilib->set_preference($pref, $value)) {
$changes[$pref] = array('type'=> 'changed', 'new'=> $value, 'old' => $old);
}
}
}
}
......
......@@ -146,6 +146,8 @@ Add a value in first check when you create a new admin page. *}
{icon _id=accept alt="{tr}Enabled{/tr}" style="vertical-align: middle"}
{elseif $tikifeedback[n].st eq 2}
{icon _id=accept alt="{tr}Changed{/tr}" style="vertical-align: middle"}
{elseif $tikifeedback[n].st eq 4}
{icon _id=arrow_undo alt="{tr}Reset{/tr}" style="vertical-align: middle"}
{else}
{icon _id=information alt="{tr}Information{/tr}" style="vertical-align: middle"}
{/if}
......
......@@ -21,7 +21,7 @@ global $logslib; include_once('lib/logs/logslib.php');
*
* @param $name Name of feature
* @param $message Other message
* @param $st Type of change (0=disabled, 1=enabled, 2=changed, 3=info)
* @param $st Type of change (0=disabled, 1=enabled, 2=changed, 3=info, 4=reset)
* @param $num unknown
* @return void
*/
......@@ -164,16 +164,21 @@ if ( isset( $_REQUEST['lm_preference'] ) ) {
$changes = $prefslib->applyChanges( (array) $_REQUEST['lm_preference'], $_REQUEST );
foreach ( $changes as $pref => $val ) {
$value = $val['new'];
if ( $value == 'y' ) {
add_feedback( $pref, tr('%0 enabled', $pref), 1, 1 );
$logslib->add_action('feature', $pref, 'system', 'enabled');
} elseif ( $value == 'n' ) {
add_feedback( $pref, tr('%0 disabled', $pref), 0, 1 );
$logslib->add_action('feature', $pref, 'system', 'disabled');
if ($val['type'] == 'reset') {
add_feedback( $pref, tr('%0 reset', $pref), 4);
$logslib->add_action('feature', $pref, 'system', 'reset');
} else {
add_feedback( $pref, tr('%0 set', $pref), 1, 1 );
$logslib->add_action('feature', $pref, 'system', (is_array($val['old'])?implode($val['old'], ','):$val['old']).'=>'.(is_array($value)?implode($value, ','):$value));
$value = $val['new'];
if ( $value == 'y' ) {
add_feedback( $pref, tr('%0 enabled', $pref), 1, 1 );
$logslib->add_action('feature', $pref, 'system', 'enabled');
} elseif ( $value == 'n' ) {
add_feedback( $pref, tr('%0 disabled', $pref), 0, 1 );
$logslib->add_action('feature', $pref, 'system', 'disabled');
} else {
add_feedback( $pref, tr('%0 set', $pref), 1, 1 );
$logslib->add_action('feature', $pref, 'system', (is_array($val['old'])?implode($val['old'], ','):$val['old']).'=>'.(is_array($value)?implode($value, ','):$value));
}
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment