+ if (in_array($key, $allowedKeys)) {
+ $this->conf->set($key, $value);
+ }
+ }
+ $this->conf->write($this->isLoggedIn);
+ unlink($this->conf->get('resource.data_dir').'/options.php');
+ }
+
+ return true;
+ }
+
+ /**
+ * Rename tags starting with a '-' to work with tag exclusion search.
+ */
+ public function updateMethodRenameDashTags()
+ {
+ $linklist = $this->linkDB->filterSearch();
+ foreach ($linklist as $key => $link) {
+ $link['tags'] = preg_replace('/(^| )\-/', '$1', $link['tags']);
+ $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true)));
+ $this->linkDB[$key] = $link;
+ }
+ $this->linkDB->save($this->conf->get('resource.page_cache'));
+ return true;
+ }
+
+ /**
+ * Move old configuration in PHP to the new config system in JSON format.
+ *
+ * Will rename 'config.php' into 'config.save.php' and create 'config.json.php'.
+ * It will also convert legacy setting keys to the new ones.
+ */
+ public function updateMethodConfigToJson()
+ {
+ // JSON config already exists, nothing to do.
+ if ($this->conf->getConfigIO() instanceof ConfigJson) {
+ return true;
+ }
+
+ $configPhp = new ConfigPhp();
+ $configJson = new ConfigJson();
+ $oldConfig = $configPhp->read($this->conf->getConfigFile() . '.php');
+ rename($this->conf->getConfigFileExt(), $this->conf->getConfigFile() . '.save.php');
+ $this->conf->setConfigIO($configJson);
+ $this->conf->reload();
+
+ $legacyMap = array_flip(ConfigPhp::$LEGACY_KEYS_MAPPING);
+ foreach (ConfigPhp::$ROOT_KEYS as $key) {
+ $this->conf->set($legacyMap[$key], $oldConfig[$key]);
+ }
+
+ // Set sub config keys (config and plugins)
+ $subConfig = array('config', 'plugins');
+ foreach ($subConfig as $sub) {
+ foreach ($oldConfig[$sub] as $key => $value) {
+ if (isset($legacyMap[$sub .'.'. $key])) {
+ $configKey = $legacyMap[$sub .'.'. $key];
+ } else {
+ $configKey = $sub .'.'. $key;
+ }
+ $this->conf->set($configKey, $value);