diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-03-27 12:46:37 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-03-27 12:46:37 +0000 |
commit | 02fd4f532a273b3c950747bb932a34562c2829b3 (patch) | |
tree | 99544da8a4f5bc54bd66cb8f8efc2b01951c88e9 | |
parent | 3ac6a9c4d812f629d237ec793bf398eba615f209 (diff) | |
download | elgg-02fd4f532a273b3c950747bb932a34562c2829b3.tar.gz elgg-02fd4f532a273b3c950747bb932a34562c2829b3.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* Add / update meta from array
git-svn-id: https://code.elgg.org/elgg/trunk@273 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/metadata.php | 17 |
1 files changed, 17 insertions, 0 deletions
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. |