From: Andrew Dolgov Date: Fri, 23 Jan 2009 06:42:37 +0000 (+0100) Subject: new function: label_create X-Git-Tag: git2svn-syncpoint-master~47 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=6b2ee18deff50122f49919f98b504dff175efd67;p=tt-rss.git new function: label_create --- diff --git a/functions.php b/functions.php index 0fb1fc28..af3dfe80 100644 --- a/functions.php +++ b/functions.php @@ -6004,6 +6004,28 @@ 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) { print "
  •   ".__("Create label...")."
  • "; diff --git a/modules/pref-labels.php b/modules/pref-labels.php index c645b12a..b09a16cf 100644 --- a/modules/pref-labels.php +++ b/modules/pref-labels.php @@ -62,19 +62,10 @@ if ($caption) { - $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"]."')"); - - if (db_affected_rows($link, $result) != 0) { - print T_sprintf("Created label %s", htmlspecialchars($caption)); - } + if (label_create($link, $caption)) { + print T_sprintf("Created label %s", htmlspecialchars($caption)); } + } return;