new function: label_create
This commit is contained in:
parent
79c88e11a0
commit
6b2ee18def
|
@ -6004,6 +6004,28 @@
|
||||||
db_query($link, "COMMIT");
|
db_query($link, "COMMIT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function label_create($link, $caption) {
|
||||||
|
|
||||||
|
db_query($link, "BEGIN");
|
||||||
|
|
||||||
|
$result = false;
|
||||||
|
|
||||||
|
$result = db_query($link, "SELECT id FROM ttrss_labels2
|
||||||
|
WHERE caption = '$caption' AND owner_uid = ". $_SESSION["uid"]);
|
||||||
|
|
||||||
|
if (db_num_rows($result) == 0) {
|
||||||
|
$result = db_query($link,
|
||||||
|
"INSERT INTO ttrss_labels2 (caption,owner_uid)
|
||||||
|
VALUES ('$caption', '".$_SESSION["uid"]."')");
|
||||||
|
|
||||||
|
$result = db_affected_rows($link, $result) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
db_query($link, "COMMIT");
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
function print_labels_headlines_dropdown($link, $feed_id) {
|
function print_labels_headlines_dropdown($link, $feed_id) {
|
||||||
print "<li onclick=\"javascript:addLabel()\">
|
print "<li onclick=\"javascript:addLabel()\">
|
||||||
".__("Create label...")."</li>";
|
".__("Create label...")."</li>";
|
||||||
|
|
|
@ -62,19 +62,10 @@
|
||||||
|
|
||||||
if ($caption) {
|
if ($caption) {
|
||||||
|
|
||||||
$result = db_query($link, "SELECT id FROM ttrss_labels2
|
if (label_create($link, $caption)) {
|
||||||
WHERE caption = '$caption' AND owner_uid = ". $_SESSION["uid"]);
|
|
||||||
|
|
||||||
if (db_num_rows($result) == 0) {
|
|
||||||
|
|
||||||
$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));
|
print T_sprintf("Created label <b>%s</b>", htmlspecialchars($caption));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue