/**
* Used to update the settings on the Settings tab.
* @param array $post
*/
public function updateSettings($post)
{
$accountInfo = Core::$user->getAccount();
$accountType = $accountInfo["accountType"];
$isAnonymous = $accountInfo["isAnonymous"];
$L = Core::$language->getCurrentLanguageStrings();
if (!isset($post["consoleEventsDataTypePlugins"]) || empty($post["consoleEventsDataTypePlugins"])) {
$post["consoleEventsDataTypePlugins"] = array();
}
if (!isset($post["consoleEventsExportTypePlugins"]) || empty($post["consoleEventsExportTypePlugins"])) {
$post["consoleEventsExportTypePlugins"] = array();
}
$settings = array("consoleWarnings" => isset($post["consoleWarnings"]) ? "enabled" : "", "consoleEventsPublish" => isset($post["consoleEventsPublish"]) ? "enabled" : "", "consoleEventsSubscribe" => isset($post["consoleEventsSubscribe"]) ? "enabled" : "", "consoleCoreEvents" => isset($post["consoleCoreEvents"]) ? "enabled" : "", "consoleEventsDataTypePlugins" => implode(",", $post["consoleEventsDataTypePlugins"]), "consoleEventsExportTypePlugins" => implode(",", $post["consoleEventsExportTypePlugins"]), "theme" => $post["theme"]);
if (!$isAnonymous && $accountType == "admin") {
if (isset($post["userAccountSetup"])) {
$settings["userAccountSetup"] = $post["userAccountSetup"] == "single" ? "single" : "multiple";
}
}
$prefix = Core::getDbTablePrefix();
$errors = array();
while (list($key, $value) = each($settings)) {
$value = mysql_real_escape_string($value);
$result = Core::$db->query("\n\t\t\t\tUPDATE {$prefix}settings\n\t\t\t\tSET setting_value = '{$value}'\n\t\t\t\tWHERE setting_name = '{$key}'\n\t\t\t");
if (!$result["success"]) {
$errors[] = $result["errorMessage"];
}
}
if (count($errors) > 0) {
return array(false, implode("<br />", $errors));
} else {
return array(true, $L["notify_settings_updated"]);
}
}