aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-27 12:02:54 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-27 12:02:54 +0000
commit3ac6a9c4d812f629d237ec793bf398eba615f209 (patch)
treed24cc3a5c5df6b6adaf76d8c6dc216ad2abdb113 /engine
parent4e39b710e366484d5e892fe7acc6304317f21077 (diff)
downloadelgg-3ac6a9c4d812f629d237ec793bf398eba615f209.tar.gz
elgg-3ac6a9c4d812f629d237ec793bf398eba615f209.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Multiple meta tag support (requires db schema change) git-svn-id: https://code.elgg.org/elgg/trunk@272 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/metadata.php8
1 files changed, 5 insertions, 3 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 4d29bb7bc..4fccbabfe 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -168,8 +168,9 @@
* @param string $value_type
* @param int $owner_guid
* @param int $access_id
+ * @param bool $allow_multiple
*/
- function create_metadata($entity_guid, $name, $value, $value_type, $owner_guid, $access_id = 0)
+ function create_metadata($entity_guid, $name, $value, $value_type, $owner_guid, $access_id = 0, $allow_multiple = false)
{
global $CONFIG;
@@ -179,6 +180,7 @@
$value_type = detect_metadata_valuetype($value, sanitise_string(trim($value_type)));
$time = time();
$owner_guid = (int)$owner_guid;
+ $allow_multiple = (boolean)$allow_multiple;
if ($owner_guid==0) $owner_guid = $_SESSION['id'];
@@ -187,7 +189,7 @@
$id = false;
$existing = get_data_row("SELECT * from {$CONFIG->dbprefix}metadata WHERE entity_guid = $entity_guid and name_id=" . add_metastring($name) . " limit 1");
- if ($existing)
+ if (($existing) && (!$allow_multiple))
{
$id = $existing->id;
$result = update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id);
@@ -278,7 +280,7 @@
$entity_guid = (int)$entity_guid;
$access = get_access_list();
- return row_to_elggmetadata(get_data_row("SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}metadata m JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where m.entity_guid=$entity_guid and m.name_id='$meta_name' and (m.access_id in {$access} or (m.access_id = 0 and m.owner_guid = {$_SESSION['id']}))"));
+ return get_data("SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}metadata m JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where m.entity_guid=$entity_guid and m.name_id='$meta_name' and (m.access_id in {$access} or (m.access_id = 0 and m.owner_guid = {$_SESSION['id']}))", "row_to_elggmetadata");
}
/**