}
if (isset($_REQUEST['save'], $_REQUEST['pref'])) {
    $prefName = 'toolbar_' . $section . ($comments ? '_comments' : '');
    $tikilib->set_preference($prefName, $_REQUEST['pref']);
    $tikilib->set_preference($prefName . 'modified', 'y');
}
if (isset($_REQUEST['reset']) && $section != 'global' || isset($_REQUEST['reset_global']) && $section == 'global') {
    $prefName = 'toolbar_' . $section . ($comments ? '_comments' : '');
    $tikilib->delete_preference($prefName);
    $tikilib->set_preference($prefName . 'modified', 'n');
    $smarty->loadPlugin('smarty_function_query');
    header('location: ?' . smarty_function_query(array('_urlencode' => 'n'), $smarty));
}
if (!empty($_REQUEST['save_tool']) && !empty($_REQUEST['tool_name'])) {
    // input from the tool edit form
    Toolbar::saveTool($_REQUEST['tool_name'], $_REQUEST['tool_label'], $_REQUEST['tool_icon'], $_REQUEST['tool_token'], $_REQUEST['tool_syntax'], $_REQUEST['tool_type'], $_REQUEST['tool_plugin']);
    $smarty->loadPlugin('smarty_function_query');
    header('location: ?' . smarty_function_query(array('_urlencode' => 'n'), $smarty));
}
$current = $tikilib->get_preference('toolbar_' . $section . ($comments ? '_comments' : ''));
if (empty($current)) {
    $current = $tikilib->get_preference('toolbar_global' . ($comments ? '_comments' : ''));
    $smarty->assign('not_global', false);
} else {
    $smarty->assign('not_global', true);
}
$smarty->assign('not_default', false);
if ($section == 'global') {
    global $cachelib;
    if ($defprefs = $cachelib->getSerialized("tiki_default_preferences_cache")) {
        if ($defprefs['toolbar_global' . ($comments ? '_comments' : '')] != $current) {