From d2dccd91d09583d9a82026a7a98d78fa59ba5a72 Mon Sep 17 00:00:00 2001 From: shish Date: Tue, 20 May 2008 03:10:25 +0000 Subject: [PATCH] and 2.1... git-svn-id: file:///home/shish/svn/shimmie2/branches/branch_2.1@872 7f39781d-f577-437e-ae19-be835c7a54ca --- core/database.class.php | 2 +- core/util.inc.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/database.class.php b/core/database.class.php index 8ac5309f..48805ae9 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -250,7 +250,7 @@ class Database { $tags = array_map(array($this, 'resolve_alias'), $tags); $tags = array_map(array($this, 'sanitise'), $tags); - $tags = array_unique($tags); // remove any duplicate tags + $tags = array_iunique($tags); // remove any duplicate tags // delete old $this->delete_tags_from_image($image_id); diff --git a/core/util.inc.php b/core/util.inc.php index 6ef44206..37ced395 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -327,6 +327,23 @@ function array_add($array, $element) { return $array; } +// case insensetive uniqueness +function array_iunique($array) { + $ok = array(); + foreach($array as $element) { + $found = false; + foreach($ok as $existing) { + if(strtolower($element) == strtolower($existing)) { + $found = true; break; + } + } + if(!$found) { + $ok[] = $element; + } + } + return $ok; +} + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Event API *