From 02fd4f532a273b3c950747bb932a34562c2829b3 Mon Sep 17 00:00:00 2001 From: icewing Date: Thu, 27 Mar 2008 12:46:37 +0000 Subject: Marcus Povey * Add / update meta from array git-svn-id: https://code.elgg.org/elgg/trunk@273 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/metadata.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 4fccbabfe..4744f6f6f 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -250,6 +250,23 @@ return update_data("UPDATE {$CONFIG->dbprefix}metadata set value_id='$value', value_type='$value_type', access_id=$access_id, owner_guid=$owner_guid where id=$id and name_id='$name' and (access_id in {$access} or (access_id = 0 and owner_guid = {$_SESSION['id']}))"); } + /** + * This function creates metadata from an associative array of "key => value" pairs. + * + * @param int $entity_guid + * @param string $name_and_values + * @param string $value_type + * @param int $owner_guid + * @param int $access_id + * @param bool $allow_multiple + */ + function create_metadata_from_array($entity_guid, array $name_and_values, $value_type, $owner_guid, $access_id = 0, $allow_multiple = false) + { + foreach ($name_and_values as $k => $v) + if (!create_metadata($entity_guid, $k, $v, $value_type, $owner_guid, $access_id, $allow_multiple)) return false; + + return true; + } /** * Delete an item of metadata, where the current user has access. -- cgit v1.2.3