public function save($sv, $si)
 {
     global $Conf;
     $new_opts = $this->stashed_options;
     $current_opts = PaperOption::nonfixed_option_list();
     $this->option_clean_form_positions($new_opts, $current_opts);
     $newj = (object) array();
     uasort($new_opts, array("PaperOption", "compare"));
     $nextid = max($Conf->setting("next_optionid", 1), $Conf->setting("options", 1));
     foreach ($new_opts as $id => $o) {
         $newj->{$id} = $o->unparse();
         $nextid = max($nextid, $id + 1);
     }
     $sv->save("next_optionid", null);
     $sv->save("options", count($newj) ? json_encode($newj) : null);
     $deleted_ids = array();
     foreach ($current_opts as $id => $o) {
         if (!get($new_opts, $id)) {
             $deleted_ids[] = $id;
         }
     }
     if (count($deleted_ids)) {
         $Conf->qe("delete from PaperOption where optionId in (" . join(",", $deleted_ids) . ")");
     }
     // invalidate cached option list
     PaperOption::invalidate_option_list();
 }
 function invalidateCaches($caches = null)
 {
     global $OK;
     if (self::$no_invalidate_caches) {
         return;
     }
     $inserts = array();
     $removes = array();
     $time = time();
     if ($caches ? isset($caches["pc"]) : $this->setting("pc") > 0) {
         if (!$caches || $caches["pc"]) {
             $inserts[] = "('pc',{$time})";
             $this->settings["pc"] = $time;
         } else {
             $removes[] = "'pc'";
             unset($this->settings["pc"]);
         }
     }
     if (!$caches || isset($caches["paperOption"])) {
         PaperOption::invalidate_option_list();
     }
     if (!$caches || isset($caches["rf"])) {
         ReviewForm::clear_cache();
         $this->_defined_rounds = null;
     }
     $ok = true;
     if (count($inserts)) {
         $ok = $ok && $this->qe("insert into Settings (name, value) values " . join(",", $inserts) . " on duplicate key update value=values(value)") !== false;
     }
     if (count($removes)) {
         $ok = $ok && $this->qe("delete from Settings where name in (" . join(",", $removes) . ")") !== false;
     }
     return $ok;
 }