fix unknow preferences on new install, thanks @Gvx-, closes #6
parent
60018a94bf
commit
3776b5d1b8
20
index.php
20
index.php
|
@ -88,18 +88,21 @@ class index
|
|||
{
|
||||
try {
|
||||
if (!empty($this->type)) {
|
||||
$preferences = unserialize($this->core->blog->settings->improve->preferences);
|
||||
$preferences = $this->core->blog->settings->improve->preferences;
|
||||
if (is_string($preferences)) {
|
||||
$preferences = unserialize($preferences);
|
||||
if (is_array($preferences)) {
|
||||
return array_key_exists($this->type, $preferences) ? $preferences[$this->type] : [];
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
private function setPreferences(): void
|
||||
private function setPreferences(): bool
|
||||
{
|
||||
if (!empty($_POST['save_preferences'])) {
|
||||
$preferences[$this->type] = [];
|
||||
|
@ -112,7 +115,11 @@ class index
|
|||
}
|
||||
$this->core->blog->settings->improve->put('preferences', serialize($preferences), 'string', null, true, true);
|
||||
dcPage::addSuccessNotice(__('Configuration successfully updated'));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function comboModules(): array
|
||||
|
@ -143,6 +150,8 @@ class index
|
|||
|
||||
private function doAction(): void
|
||||
{
|
||||
$done = $this->setPreferences();
|
||||
|
||||
if (!empty($_POST['fix'])) {
|
||||
if (empty($_POST['actions'])) {
|
||||
dcPage::addWarningNotice(__('No action selected'));
|
||||
|
@ -170,12 +179,17 @@ class index
|
|||
}
|
||||
dcPage::addNotice($notice['type'], sprintf($notice['msg'], $this->module, $time));
|
||||
|
||||
$this->core->adminurl->redirect('admin.plugin.improve', ['type' => $this->type, 'module' => $this->module, 'upd' => $log_id]);
|
||||
$done = true;
|
||||
} catch (Exception $e) {
|
||||
$this->core->error->add($e->getMessage());
|
||||
$done = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($done) {
|
||||
$this->core->adminurl->redirect('admin.plugin.improve', ['type' => $this->type, 'module' => $this->module, 'upd' => $log_id]);
|
||||
}
|
||||
}
|
||||
|
||||
private function displayPage(): void
|
||||
|
|
Loading…
Reference in New Issue