aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/metastrings.php
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-06-05 17:43:35 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-06-05 17:43:35 +0000
commita4340107482a45d9a1b04dbfda9a6c0578c75e59 (patch)
treee244f172e3440d2a07b0752949c08210aec72770 /engine/lib/metastrings.php
parentc15e8643b1eb0e8821bd3fb254a16d77b50f4bdd (diff)
downloadelgg-a4340107482a45d9a1b04dbfda9a6c0578c75e59.tar.gz
elgg-a4340107482a45d9a1b04dbfda9a6c0578c75e59.tar.bz2
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
Diffstat (limited to 'engine/lib/metastrings.php')
-rw-r--r--engine/lib/metastrings.php14
1 files changed, 10 insertions, 4 deletions
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')");