mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2026-01-06 03:09:14 +00:00
implement settings profiles (bump schema)
This commit is contained in:
@@ -3,6 +3,87 @@
|
||||
|
||||
$subop = $_REQUEST["subop"];
|
||||
|
||||
if ($subop == "setprofile") {
|
||||
$id = db_escape_string($_REQUEST["id"]);
|
||||
|
||||
$_SESSION["profile"] = $id;
|
||||
$_SESSION["prefs_cache"] = array();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($subop == "remprofiles") {
|
||||
$ids = split(",", db_escape_string(trim($_REQUEST["ids"])));
|
||||
|
||||
foreach ($ids as $id) {
|
||||
if ($_SESSION["profile"] != $id) {
|
||||
db_query($link, "DELETE FROM ttrss_settings_profiles WHERE id = '$id' AND
|
||||
owner_uid = " . $_SESSION["uid"]);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($subop == "addprofile") {
|
||||
$title = db_escape_string(trim($_REQUEST["title"]));
|
||||
if ($title) {
|
||||
db_query($link, "BEGIN");
|
||||
|
||||
$result = db_query($link, "SELECT id FROM ttrss_settings_profiles
|
||||
WHERE title = '$title' AND owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
if (db_num_rows($result) == 0) {
|
||||
|
||||
db_query($link, "INSERT INTO ttrss_settings_profiles (title, owner_uid)
|
||||
VALUES ('$title', ".$_SESSION["uid"] .")");
|
||||
|
||||
$result = db_query($link, "SELECT id FROM ttrss_settings_profiles WHERE
|
||||
title = '$title'");
|
||||
|
||||
if (db_num_rows($result) != 0) {
|
||||
$profile_id = db_fetch_result($result, 0, "id");
|
||||
|
||||
if ($profile_id) {
|
||||
initialize_user_prefs($link, $_SESSION["uid"], $profile_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
db_query($link, "COMMIT");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($subop == "saveprofile") {
|
||||
$id = db_escape_string($_REQUEST["id"]);
|
||||
$title = db_escape_string(trim($_REQUEST["value"]));
|
||||
|
||||
if ($id == 0) {
|
||||
print __("Default profile");
|
||||
return;
|
||||
}
|
||||
|
||||
if ($title) {
|
||||
db_query($link, "BEGIN");
|
||||
|
||||
$result = db_query($link, "SELECT id FROM ttrss_settings_profiles
|
||||
WHERE title = '$title' AND owner_uid =" . $_SESSION["uid"]);
|
||||
|
||||
if (db_num_rows($result) == 0) {
|
||||
db_query($link, "UPDATE ttrss_settings_profiles
|
||||
SET title = '$title' WHERE id = '$id' AND
|
||||
owner_uid = " . $_SESSION["uid"]);
|
||||
print $title;
|
||||
} else {
|
||||
$result = db_query($link, "SELECT title FROM ttrss_settings_profiles
|
||||
WHERE id = '$id' AND owner_uid =" . $_SESSION["uid"]);
|
||||
print db_fetch_result($result, 0, "title");
|
||||
}
|
||||
|
||||
db_query($link, "COMMIT");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($subop == "remarchive") {
|
||||
$ids = split(",", db_escape_string($_REQUEST["ids"]));
|
||||
|
||||
@@ -412,7 +493,7 @@
|
||||
|
||||
print "<rpc-reply>";
|
||||
|
||||
set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key());
|
||||
set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key(), $_SESSION["uid"]);
|
||||
|
||||
$new_link = article_publish_url($link);
|
||||
|
||||
|
||||
@@ -3,6 +3,97 @@
|
||||
$id = $_REQUEST["id"];
|
||||
$param = db_escape_string($_REQUEST["param"]);
|
||||
|
||||
if ($id == "editPrefProfiles") {
|
||||
|
||||
print "<div id=\"infoBoxTitle\">".__('Settings Profiles')."</div>";
|
||||
print "<div class=\"infoBoxContents\">";
|
||||
|
||||
print "<div><input id=\"fadd_profile\"
|
||||
onkeypress=\"return filterCR(event, addPrefProfile)\"
|
||||
size=\"40\">
|
||||
<button onclick=\"javascript:addPrefProfile()\">".
|
||||
__('Create profile')."</button></div>";
|
||||
|
||||
print "<p>";
|
||||
|
||||
$result = db_query($link, "SELECT title,id FROM ttrss_settings_profiles
|
||||
WHERE owner_uid = ".$_SESSION["uid"]."ORDER BY title");
|
||||
|
||||
print __('Select:')."
|
||||
<a href=\"javascript:selectPrefRows('fcat', true)\">".__('All')."</a>,
|
||||
<a href=\"javascript:selectPrefRows('fcat', false)\">".__('None')."</a>";
|
||||
|
||||
print "<div class=\"prefFeedCatHolder\">";
|
||||
|
||||
print "<form id=\"profile_edit_form\" onsubmit=\"return false\">";
|
||||
|
||||
print "<table width=\"100%\" class=\"prefFeedCatList\"
|
||||
cellspacing=\"0\" id=\"prefFeedCatList\">";
|
||||
|
||||
print "<tr class=\"odd\" id=\"FCATR-0\">";
|
||||
|
||||
print "<td width='5%' align='center'><input
|
||||
onclick='toggleSelectPrefRow(this, \"fcat\");'
|
||||
type=\"checkbox\" id=\"FCCHK-0\"></td>";
|
||||
|
||||
print "<td><span id=\"FCATT-0\">" .
|
||||
__("Default profile") . "</span></td>";
|
||||
|
||||
print "</tr>";
|
||||
|
||||
$lnum = 1;
|
||||
|
||||
while ($line = db_fetch_assoc($result)) {
|
||||
|
||||
$class = ($lnum % 2) ? "even" : "odd";
|
||||
|
||||
$cat_id = $line["id"];
|
||||
$this_row_id = "id=\"FCATR-$cat_id\"";
|
||||
|
||||
print "<tr class=\"$class\" $this_row_id>";
|
||||
|
||||
$edit_title = htmlspecialchars($line["title"]);
|
||||
|
||||
print "<td width='5%' align='center'><input
|
||||
onclick='toggleSelectPrefRow(this, \"fcat\");'
|
||||
type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
|
||||
|
||||
if ($_SESSION["profile"] == $line["id"]) {
|
||||
$is_active = __("(active)");
|
||||
} else {
|
||||
$is_active = "";
|
||||
}
|
||||
|
||||
print "<td><span id=\"FCATT-$cat_id\">" .
|
||||
$edit_title . "</span> $is_active</td>";
|
||||
|
||||
print "</tr>";
|
||||
|
||||
++$lnum;
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
print "</form>";
|
||||
print "</div>";
|
||||
|
||||
print "<div class='dlgButtons'>
|
||||
<div style='float : left'>
|
||||
<button onclick=\"return removeSelectedPrefProfiles()\">".
|
||||
__('Remove')."</button>
|
||||
<input class=\"button\"
|
||||
type=\"submit\" onclick=\"return activatePrefProfile()\"
|
||||
value=\"".__('Activate')."\">
|
||||
</div>";
|
||||
|
||||
print "<input class=\"button\"
|
||||
type=\"submit\" onclick=\"return closeInfoBox()\"
|
||||
value=\"".__('Close this window')."\">";
|
||||
|
||||
print "</div></div>";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($id == "pubUrl") {
|
||||
|
||||
print "<div id=\"infoBoxTitle\">".__('Published Articles')."</div>";
|
||||
@@ -185,13 +276,17 @@
|
||||
|
||||
$owner_uid = $_SESSION["uid"];
|
||||
|
||||
/* print __('Select:')."
|
||||
<a href=\"javascript:selectPrefRows('fbrowse', true)\">".__('All')."</a>,
|
||||
<a href=\"javascript:selectPrefRows('fbrowse', false)\">".__('None')."</a>"; */
|
||||
|
||||
print "<ul class='browseFeedList' id='browseFeedList'>";
|
||||
print_feed_browser($link, $search, 25);
|
||||
print "</ul>";
|
||||
|
||||
print "<div align='center'>
|
||||
<button onclick=\"feedBrowserSubscribe()\">".__('Subscribe')."</button>
|
||||
<button style='display : none' id='feed_archive_remove' onclick=\"feedArchiveRemove()\">".__('Remove from archive')."</button>
|
||||
<button style='display : none' id='feed_archive_remove' onclick=\"feedArchiveRemove()\">".__('Remove')."</button>
|
||||
<button onclick=\"closeInfoBox()\" >".__('Cancel')."</button></div>";
|
||||
|
||||
print "</div>";
|
||||
|
||||
@@ -999,7 +999,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
print "<div class=\"prefGenericAddBox\">
|
||||
print "<div>
|
||||
<input id=\"fadd_cat\"
|
||||
onkeypress=\"return filterCR(event, addFeedCat)\"
|
||||
size=\"40\">
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
$prefs_blacklist = array("HIDE_FEEDLIST", "SYNC_COUNTERS", "ENABLE_LABELS",
|
||||
"ENABLE_SEARCH_TOOLBAR", "HIDE_READ_FEEDS");
|
||||
|
||||
$profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS",
|
||||
"PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP",
|
||||
"BLACKLISTED_TAGS", "ENABLE_FEED_ICONS", "ENABLE_API_ACCESS",
|
||||
"UPDATE_POST_ON_CHECKSUM_CHANGE", "DEFAULT_UPDATE_INTERVAL",
|
||||
"MARK_UNREAD_ON_UPDATE");
|
||||
|
||||
if (FORCE_ARTICLE_PURGE != 0) {
|
||||
array_push($prefs_blacklist, "PURGE_OLD_DAYS");
|
||||
array_push($prefs_blacklist, "PURGE_UNREAD_ARTICLES");
|
||||
@@ -79,6 +85,8 @@
|
||||
|
||||
// print_r($_POST);
|
||||
|
||||
$orig_theme_id = get_pref($link, "_THEME_ID");
|
||||
|
||||
foreach (array_keys($_POST) as $pref_name) {
|
||||
|
||||
$pref_name = db_escape_string($pref_name);
|
||||
@@ -88,9 +96,23 @@
|
||||
|
||||
}
|
||||
|
||||
#return prefs_js_redirect();
|
||||
if ($orig_theme_id != get_pref($link, "_THEME_ID")) {
|
||||
|
||||
print __("The configuration was saved.");
|
||||
$result = db_query($link, "SELECT theme_path FROM ttrss_themes
|
||||
WHERE id = '".get_pref($link, "_THEME_ID")."'");
|
||||
|
||||
if (db_num_rows($result) == 1) {
|
||||
$theme_path = db_fetch_result($result, 0, "theme_path");
|
||||
} else {
|
||||
$theme_path = "";
|
||||
}
|
||||
|
||||
$_SESSION["theme"] = $theme_path;
|
||||
|
||||
print "PREFS_THEME_CHANGED";
|
||||
} else {
|
||||
print __("The configuration was saved.");
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -132,38 +154,14 @@
|
||||
|
||||
return;
|
||||
|
||||
} else if ($subop == "change-theme") {
|
||||
|
||||
$theme = db_escape_string($_POST["theme"]);
|
||||
|
||||
if ($theme == "Default") {
|
||||
$theme_qpart = 'NULL';
|
||||
} else {
|
||||
$theme_qpart = "'$theme'";
|
||||
}
|
||||
|
||||
$result = db_query($link, "SELECT id,theme_path FROM ttrss_themes
|
||||
WHERE theme_name = '$theme'");
|
||||
|
||||
if (db_num_rows($result) == 1) {
|
||||
$theme_id = db_fetch_result($result, 0, "id");
|
||||
$theme_path = db_fetch_result($result, 0, "theme_path");
|
||||
} else {
|
||||
$theme_id = "NULL";
|
||||
$theme_path = "";
|
||||
}
|
||||
|
||||
db_query($link, "UPDATE ttrss_users SET
|
||||
theme_id = $theme_id WHERE id = " . $_SESSION["uid"]);
|
||||
|
||||
$_SESSION["theme"] = $theme_path;
|
||||
|
||||
return prefs_js_redirect();
|
||||
|
||||
} else {
|
||||
|
||||
set_pref($link, "_PREFS_ACTIVE_TAB", "genConfig");
|
||||
|
||||
if ($_SESSION["profile"]) {
|
||||
print_notice("Some preferences are only available in default profile.");
|
||||
}
|
||||
|
||||
if (!SINGLE_USER_MODE) {
|
||||
|
||||
$result = db_query($link, "SELECT id FROM ttrss_users
|
||||
@@ -272,47 +270,20 @@
|
||||
|
||||
}
|
||||
|
||||
$result = db_query($link, "SELECT
|
||||
theme_id FROM ttrss_users WHERE id = " . $_SESSION["uid"]);
|
||||
|
||||
$user_theme_id = db_fetch_result($result, 0, "theme_id");
|
||||
|
||||
$result = db_query($link, "SELECT
|
||||
id,theme_name FROM ttrss_themes ORDER BY theme_name");
|
||||
|
||||
if (db_num_rows($result) > 0) {
|
||||
|
||||
print "<form action=\"backend.php\" method=\"POST\">";
|
||||
print "<table width=\"100%\" class=\"prefPrefsList\">";
|
||||
print "<tr><td colspan='3'><h3>".__("Themes")."</h3></tr></td>";
|
||||
print "<tr><td width=\"40%\">".__("Select theme")."</td>";
|
||||
print "<td><select name=\"theme\">";
|
||||
print "<option value='Default'>".__('Default')."</option>";
|
||||
print "<option disabled>--------</option>";
|
||||
|
||||
while ($line = db_fetch_assoc($result)) {
|
||||
if ($line["id"] == $user_theme_id) {
|
||||
$selected = "selected";
|
||||
} else {
|
||||
$selected = "";
|
||||
}
|
||||
print "<option $selected>" . $line["theme_name"] . "</option>";
|
||||
}
|
||||
print "</select></td></tr>";
|
||||
print "</table>";
|
||||
print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
|
||||
print "<input type=\"hidden\" name=\"subop\" value=\"change-theme\">";
|
||||
print "<p><button>".__('Change theme')."</button>";
|
||||
print "</form>";
|
||||
if ($_SESSION["profile"]) {
|
||||
initialize_user_prefs($link, $_SESSION["uid"], $_SESSION["profile"]);
|
||||
$profile_qpart = "profile = '" . $_SESSION["profile"] . "'";
|
||||
} else {
|
||||
initialize_user_prefs($link, $_SESSION["uid"]);
|
||||
$profile_qpart = "profile IS NULL";
|
||||
}
|
||||
|
||||
initialize_user_prefs($link, $_SESSION["uid"]);
|
||||
|
||||
$result = db_query($link, "SELECT
|
||||
ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name,
|
||||
section_name,def_value
|
||||
section_name,def_value,section_id
|
||||
FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs
|
||||
WHERE type_id = ttrss_prefs_types.id AND
|
||||
$profile_qpart AND
|
||||
section_id = ttrss_prefs_sections.id AND
|
||||
ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND
|
||||
short_desc != '' AND
|
||||
@@ -332,6 +303,11 @@
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($_SESSION["profile"] && in_array($line["pref_name"],
|
||||
$profile_blacklist)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($active_section != $line["section_name"]) {
|
||||
|
||||
if ($active_section != "") {
|
||||
@@ -339,10 +315,34 @@
|
||||
}
|
||||
|
||||
print "<p><table width=\"100%\" class=\"prefPrefsList\">";
|
||||
|
||||
|
||||
$active_section = $line["section_name"];
|
||||
|
||||
print "<tr><td colspan=\"3\"><h3>".__($active_section)."</h3></td></tr>";
|
||||
|
||||
if ($line["section_id"] == 2) {
|
||||
print "<tr><td width=\"40%\">".__("Select theme")."</td>";
|
||||
print "<td><select name=\"_THEME_ID\">";
|
||||
print "<option value='0'>".__('Default')."</option>";
|
||||
print "<option disabled>--------</option>";
|
||||
|
||||
$user_theme_id = get_pref($link, "_THEME_ID");
|
||||
|
||||
$tmp_result = db_query($link, "SELECT
|
||||
id,theme_name FROM ttrss_themes ORDER BY theme_name");
|
||||
|
||||
while ($tmp_line = db_fetch_assoc($tmp_result)) {
|
||||
if ($tmp_line["id"] == $user_theme_id) {
|
||||
$selected = "selected";
|
||||
} else {
|
||||
$selected = "";
|
||||
}
|
||||
print "<option value=\"".$tmp_line["id"]."\" $selected>" .
|
||||
$tmp_line["theme_name"] . "</option>";
|
||||
}
|
||||
print "</select></td></tr>";
|
||||
}
|
||||
|
||||
// print "<tr class=\"title\">
|
||||
// <td width=\"25%\">Option</td><td>Value</td></tr>";
|
||||
|
||||
@@ -398,7 +398,10 @@
|
||||
|
||||
print "<p><button onclick=\"return validatePrefsSave()\">".
|
||||
__('Save configuration')."</button> ";
|
||||
|
||||
|
||||
print "<button onclick=\"return editProfiles()\">".
|
||||
__('Manage profiles')."</button> ";
|
||||
|
||||
print "<button onclick=\"return validatePrefsReset()\">".
|
||||
__('Reset to defaults')."</button></p>";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user