diff --git a/functions.php b/functions.php index 84b863e70..5fe75c288 100644 --- a/functions.php +++ b/functions.php @@ -3039,4 +3039,14 @@ return $tags; } + function trim_value(&$value) { + $value = trim($value); + } + + function trim_array($array) { + $tmp = $array; + array_walk($tmp, 'trim_value'); + return $tmp; + } + ?> diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 3cba704e3..1a019af5b 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -210,7 +210,7 @@ $id = db_escape_string($_GET["id"]); $tags_str = db_escape_string($_GET["tags_str"]); - $tags = split(",", $tags_str); + $tags = array_unique(trim_array(split(",", $tags_str))); db_query($link, "BEGIN"); diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index a1ead2b00..40f4df8a2 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -283,9 +283,34 @@ $tags_str = join(", ", $tags); - print ""; + print "
Add existing tag: | "; + + $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags + WHERE owner_uid = '".$_SESSION["uid"]."' ORDER BY tag_name"); + + $found_tags = array(); + + array_push($found_tags, ''); + + while ($line = db_fetch_assoc($result)) { + array_push($found_tags, $line["tag_name"]); + } + + print ""; + + print_select("found_tags", '', $found_tags, "onchange=\"javascript:editTagsInsert()\""); + + print " | "; + + print "