diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-14 03:40:59 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-14 03:40:59 +0000 |
commit | c9d4cf5b0b0f5ad3056cd4d6dc744a8b4890fb4e (patch) | |
tree | 832898dc37e4678a4d77a9338cd46c4feb6bba64 /engine/lib | |
parent | 8e065905e4172d0ccd01266c6f8e58a65803d011 (diff) | |
download | elgg-c9d4cf5b0b0f5ad3056cd4d6dc744a8b4890fb4e.tar.gz elgg-c9d4cf5b0b0f5ad3056cd4d6dc744a8b4890fb4e.tar.bz2 |
Updated trunk to use new annotation functions. Added checks for annotations_* options vs annotation_* options because it's so easy to confuse.
git-svn-id: http://code.elgg.org/elgg/trunk@8223 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/annotations.php | 26 | ||||
-rw-r--r-- | engine/lib/metadata.php | 16 | ||||
-rw-r--r-- | engine/lib/metastrings.php | 9 |
3 files changed, 40 insertions, 11 deletions
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index c37596ea8..0235476f2 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -32,7 +32,21 @@ function row_to_elggannotation($row) { * @return false|ElggAnnotation */ function elgg_get_annotation_from_id($id) { - return elgg_get_metastring_based_object_by_id($id, 'annotations'); + return elgg_get_metastring_based_object_from_id($id, 'annotations'); +} + +/** + * Deletes an annotation using its ID. + * + * @param int $id The annotation ID to delete. + * @return bool + */ +function elgg_delete_annotation_by_id($id) { + $annotation = elgg_get_annotation_from_id($id); + if (!$annotation) { + return false; + } + return $annotation->delete(); } /** @@ -88,12 +102,12 @@ $owner_guid, $access_id = ACCESS_PRIVATE) { ($entity_guid,'$name',$value,'$value_type', $owner_guid, $time, $access_id)"); if ($result !== false) { - $obj = get_annotation($result); + $obj = elgg_get_annotation_from_id($result); if (elgg_trigger_event('create', 'annotation', $obj)) { return $result; } else { // plugin returned false to reject annotation - delete_annotation($result); + elgg_delete_annotation_by_id($result); return FALSE; } } @@ -148,12 +162,12 @@ function update_annotation($annotation_id, $name, $value, $value_type, $owner_gu where id=$annotation_id and name_id='$name' and $access"); if ($result !== false) { - $obj = get_annotation($annotation_id); + $obj = elgg_get_annotation_from_id($annotation_id); if (elgg_trigger_event('update', 'annotation', $obj)) { return true; } else { // @todo add plugin hook that sends old and new annotation information before db access - delete_annotation($annotation_id); + elgg_delete_annotation_by_id($annotation_id); } } @@ -470,7 +484,7 @@ function export_annotation_plugin_hook($hook, $entity_type, $returnvalue, $param function get_annotation_url($id) { $id = (int)$id; - if ($extender = get_annotation($id)) { + if ($extender = elgg_get_annotation_from_id($id)) { return get_extender_url($extender); } return false; diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 08c87ae67..c05e0b161 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -32,7 +32,21 @@ function row_to_elggmetadata($row) { * @return false|ElggMetadata */ function elgg_get_metadata_from_id($id) { - return elgg_get_metastring_based_object_by_id($id, 'metadata'); + return elgg_get_metastring_based_object_from_id($id, 'metadata'); +} + +/** + * Deletes metadata using its ID. + * + * @param int $id The metadata ID to delete. + * @return bool + */ +function elgg_delete_metadata_by_id($id) { + $metadata = elgg_get_metadata_from_id($id); + if (!$metadata) { + return false; + } + return $metadata->delete(); } /** diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index 6376ac09b..8c702239b 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -585,7 +585,8 @@ function elgg_normalize_metastrings_options(array $options = array()) { $options['metastring_type'] = $type; - $prefixes = array('metadata_', 'annotation_'); + // support annotation_ and annotations_ because they're way too easy to confuse + $prefixes = array('metadata_', 'annotation_', 'annotations_'); // map the metadata_* options to metastring_* options $map = array( @@ -632,7 +633,7 @@ function elgg_set_metastring_based_object_enabled_by_id($id, $enabled, $type) { $id = (int)$id; $db_prefix = elgg_get_config('dbprefix'); - $object = elgg_get_metastring_based_object_by_id($id, $type); + $object = elgg_get_metastring_based_object_from_id($id, $type); switch($type) { case 'annotation': @@ -702,7 +703,7 @@ function elgg_batch_metastring_based_objects(array $options, $callback) { * @since 1.8 * @access private */ -function elgg_get_metastring_based_object_by_id($id, $type) { +function elgg_get_metastring_based_object_from_id($id, $type) { $id = (int)$id; if (!$id) { return false; @@ -750,7 +751,7 @@ function elgg_delete_metastring_based_object_by_id($id, $type) { return false; } - $obj = elgg_get_metastring_based_object_by_id($id, $type); + $obj = elgg_get_metastring_based_object_from_id($id, $type); $table = $db_prefix . $type; if ($obj) { |