2006-10-01 10:05:20 +00:00
|
|
|
<?php
|
|
|
|
function module_pref_labels($link) {
|
|
|
|
|
|
|
|
$subop = $_GET["subop"];
|
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
if ($subop == "save") {
|
2008-08-07 08:06:12 +00:00
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
$id = db_escape_string($_REQUEST["id"]);
|
2009-01-18 09:54:11 +00:00
|
|
|
$caption = db_escape_string(trim($_REQUEST["value"]));
|
2008-08-07 08:06:12 +00:00
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
db_query($link, "BEGIN");
|
2008-08-06 06:47:56 +00:00
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
$result = db_query($link, "SELECT caption FROM ttrss_labels2
|
|
|
|
WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
if (db_num_rows($result) != 0) {
|
|
|
|
$old_caption = db_fetch_result($result, 0, "caption");
|
2007-05-14 08:16:48 +00:00
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
$result = db_query($link, "SELECT id FROM ttrss_labels2
|
|
|
|
WHERE caption = '$caption' AND owner_uid = ". $_SESSION["uid"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
if (db_num_rows($result) == 0) {
|
|
|
|
if ($caption) {
|
|
|
|
$result = db_query($link, "UPDATE ttrss_labels2 SET
|
|
|
|
caption = '$caption' WHERE id = '$id' AND
|
|
|
|
owner_uid = " . $_SESSION["uid"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
/* Update filters that reference label being renamed */
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
db_query($link, "UPDATE ttrss_filters SET
|
|
|
|
action_param = '$caption' WHERE action_param = '$old_caption'
|
|
|
|
AND action_id = 7
|
|
|
|
AND owner_uid = " . $_SESSION["uid"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2009-01-18 09:54:11 +00:00
|
|
|
print $_REQUEST["value"];
|
2009-01-18 10:16:02 +00:00
|
|
|
} else {
|
|
|
|
print $old_caption;
|
2009-01-18 08:28:42 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print $old_caption;
|
2006-10-01 10:05:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
db_query($link, "COMMIT");
|
2006-10-01 10:05:20 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($subop == "remove") {
|
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
$ids = split(",", db_escape_string($_GET["ids"]));
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2009-01-18 10:11:55 +00:00
|
|
|
foreach ($ids as $id) {
|
2009-01-18 14:36:50 +00:00
|
|
|
label_remove($link, $id, $_SESSION["uid"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
}
|
2009-01-18 10:11:55 +00:00
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($subop == "add") {
|
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
$caption = db_escape_string($_GET["caption"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
if ($caption) {
|
2008-05-17 03:03:03 +00:00
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
$result = db_query($link, "SELECT id FROM ttrss_labels2
|
|
|
|
WHERE caption = '$caption' AND owner_uid = ". $_SESSION["uid"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
if (db_num_rows($result) == 0) {
|
2007-03-05 13:45:34 +00:00
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
$result = db_query($link,
|
|
|
|
"INSERT INTO ttrss_labels2 (caption,owner_uid)
|
|
|
|
VALUES ('$caption', '".$_SESSION["uid"]."')");
|
|
|
|
|
|
|
|
if (db_affected_rows($link, $result) != 0) {
|
|
|
|
print T_sprintf("Created label <b>%s</b>", htmlspecialchars($caption));
|
|
|
|
}
|
|
|
|
}
|
2007-03-05 13:45:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2006-10-01 10:05:20 +00:00
|
|
|
}
|
|
|
|
|
2007-05-04 03:26:20 +00:00
|
|
|
set_pref($link, "_PREFS_ACTIVE_TAB", "labelConfig");
|
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
$sort = db_escape_string($_GET["sort"]);
|
|
|
|
|
|
|
|
if (!$sort || $sort == "undefined") {
|
2009-01-18 08:28:42 +00:00
|
|
|
$sort = "caption";
|
2006-10-01 10:05:20 +00:00
|
|
|
}
|
|
|
|
|
2008-05-17 03:07:39 +00:00
|
|
|
$label_search = db_escape_string($_GET["search"]);
|
|
|
|
|
|
|
|
if (array_key_exists("search", $_GET)) {
|
|
|
|
$_SESSION["prefs_label_search"] = $label_search;
|
|
|
|
} else {
|
|
|
|
$label_search = $_SESSION["prefs_label_search"];
|
|
|
|
}
|
|
|
|
|
|
|
|
print "<div class=\"feedEditSearch\">
|
|
|
|
<input id=\"label_search\" size=\"20\" type=\"search\"
|
2008-05-17 03:11:51 +00:00
|
|
|
onfocus=\"javascript:disableHotkeys();\"
|
|
|
|
onblur=\"javascript:enableHotkeys();\"
|
2008-05-17 03:07:39 +00:00
|
|
|
onchange=\"javascript:updateLabelList()\" value=\"$label_search\">
|
|
|
|
<input type=\"submit\" class=\"button\"
|
|
|
|
onclick=\"javascript:updateLabelList()\" value=\"".__('Search')."\">
|
|
|
|
</div>";
|
2007-03-02 19:16:45 +00:00
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
print "<div class=\"prefGenericAddBox\">";
|
|
|
|
|
|
|
|
print"<input type=\"submit\" class=\"button\"
|
|
|
|
id=\"label_create_btn\"
|
2009-01-18 08:28:42 +00:00
|
|
|
onclick=\"return addLabel()\"
|
2007-03-05 11:02:18 +00:00
|
|
|
value=\"".__('Create label')."\"></div>";
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2008-05-17 03:07:39 +00:00
|
|
|
if ($label_search) {
|
2009-01-18 08:28:42 +00:00
|
|
|
$label_search_query = "caption LIKE '%$label_search%' AND";
|
2008-05-17 03:07:39 +00:00
|
|
|
} else {
|
|
|
|
$label_search_query = "";
|
|
|
|
}
|
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
$result = db_query($link, "SELECT
|
2009-01-18 08:28:42 +00:00
|
|
|
id,caption
|
2006-10-01 10:05:20 +00:00
|
|
|
FROM
|
2009-01-18 08:28:42 +00:00
|
|
|
ttrss_labels2
|
2006-10-01 10:05:20 +00:00
|
|
|
WHERE
|
2008-05-17 03:07:39 +00:00
|
|
|
$label_search_query
|
2006-10-01 10:05:20 +00:00
|
|
|
owner_uid = ".$_SESSION["uid"]."
|
|
|
|
ORDER BY $sort");
|
|
|
|
|
|
|
|
// print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
|
|
|
|
|
|
|
|
if (db_num_rows($result) != 0) {
|
|
|
|
|
|
|
|
print "<p><table width=\"100%\" cellspacing=\"0\"
|
|
|
|
class=\"prefLabelList\" id=\"prefLabelList\">";
|
|
|
|
|
|
|
|
print "<tr><td class=\"selectPrompt\" colspan=\"8\">
|
2007-05-14 07:56:49 +00:00
|
|
|
".__('Select:')."
|
|
|
|
<a href=\"javascript:selectPrefRows('label', true)\">".__('All')."</a>,
|
|
|
|
<a href=\"javascript:selectPrefRows('label', false)\">".__('None')."</a>
|
2006-10-01 10:05:20 +00:00
|
|
|
</td</tr>";
|
|
|
|
|
2009-01-18 10:17:17 +00:00
|
|
|
/* print "<tr class=\"title\">
|
2006-10-01 10:05:20 +00:00
|
|
|
<td width=\"5%\"> </td>
|
2009-01-18 10:17:17 +00:00
|
|
|
<td width=\"95%\"><a href=\"javascript:updateLabelList('caption')\">".__('Caption')."</a></td>
|
2006-10-01 10:05:20 +00:00
|
|
|
</td>
|
2009-01-18 10:17:17 +00:00
|
|
|
</tr>"; */
|
2006-10-01 10:05:20 +00:00
|
|
|
|
|
|
|
$lnum = 0;
|
|
|
|
|
|
|
|
while ($line = db_fetch_assoc($result)) {
|
|
|
|
|
|
|
|
$class = ($lnum % 2) ? "even" : "odd";
|
|
|
|
|
|
|
|
$label_id = $line["id"];
|
2009-01-18 08:28:42 +00:00
|
|
|
$this_row_id = "id=\"LILRR-$label_id\"";
|
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
print "<tr class=\"$class\" $this_row_id>";
|
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
$line["caption"] = htmlspecialchars($line["caption"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2009-01-18 10:17:17 +00:00
|
|
|
print "<td width='5%' align='center'><input
|
2009-01-18 08:28:42 +00:00
|
|
|
onclick='toggleSelectPrefRow(this, \"label\");'
|
2006-10-01 10:05:20 +00:00
|
|
|
type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>";
|
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
print "<td><span id=\"LILT-".$line["id"]."\">" . $line["caption"] .
|
|
|
|
"</span></td>";
|
2006-10-01 10:05:20 +00:00
|
|
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
|
|
++$lnum;
|
|
|
|
}
|
2008-05-17 03:32:36 +00:00
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
print "</table>";
|
|
|
|
|
|
|
|
print "<p id=\"labelOpToolbar\">";
|
2007-03-05 11:02:18 +00:00
|
|
|
print "<input type=\"submit\" class=\"button\" disabled=\"true\"
|
|
|
|
onclick=\"javascript:removeSelectedLabels()\" value=\"".__('Remove')."\">";
|
2009-01-18 08:28:42 +00:00
|
|
|
print "</p>";
|
2006-10-01 10:05:20 +00:00
|
|
|
|
|
|
|
} else {
|
2008-05-17 03:32:36 +00:00
|
|
|
print "<p>";
|
|
|
|
if (!$label_search) {
|
|
|
|
print __('No labels defined.');
|
|
|
|
} else {
|
|
|
|
print __('No matching labels found.');
|
|
|
|
}
|
|
|
|
print "</p>";
|
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|