From a4340107482a45d9a1b04dbfda9a6c0578c75e59 Mon Sep 17 00:00:00 2001 From: marcus Date: Fri, 5 Jun 2009 17:43:35 +0000 Subject: Closes #639: * Metastrings can be searched either case sensitive or insensitive modes. * Tags now have case lowered in a UTF8 safe way (requires mbstring support). * Introducing mb_wrapper.php containing multibyte wrapper functions. * Version bump. * Introduces #1043 for consideration. git-svn-id: https://code.elgg.org/elgg/trunk@3322 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/metastrings.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'engine/lib/metastrings.php') diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index b37456b3a..2e308e12e 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -21,9 +21,10 @@ * Return the meta string id for a given tag, or false. * * @param string $string The value (whatever that is) to be stored + * @param bool $case_sensitive Do we want to make the query case sensitive? * @return mixed Integer tag or false. */ - function get_metastring_id($string) + function get_metastring_id($string, $case_sensitive = true) { global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE; @@ -49,7 +50,11 @@ if ($metastrings_memcache) $msfc = $metastrings_memcache->load($string); if ($msfc) return $msfc; - $row = get_data_row("SELECT * from {$CONFIG->dbprefix}metastrings where string='$string' limit 1"); + // Case sensitive + $cs = ""; + if ($case_sensitive) $cs = " BINARY "; + + $row = get_data_row("SELECT * from {$CONFIG->dbprefix}metastrings where string=$cs'$string' limit 1"); if ($row) { $METASTRINGS_CACHE[$row->id] = $row->string; // Cache it @@ -106,15 +111,16 @@ * It returns the id of the tag, whether by creating it or updating it. * * @param string $string The value (whatever that is) to be stored + * @param bool $case_sensitive Do we want to make the query case sensitive? * @return mixed Integer tag or false. */ - function add_metastring($string) + function add_metastring($string, $case_sensitive = true) { global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE; $sanstring = sanitise_string($string); - $id = get_metastring_id($string); + $id = get_metastring_id($string, $case_sensitive); if ($id) return $id; $result = insert_data("INSERT into {$CONFIG->dbprefix}metastrings (string) values ('$sanstring')"); -- cgit v1.2.3