diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-12 22:39:46 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-12 22:39:46 +0000 |
commit | cc6b7d1d223241e397e0d41354924e74606eeffc (patch) | |
tree | 0ab9761a9b4db387edd3f3b17568bbee1c2b78c6 /engine | |
parent | ca9ed0b16163dcf77154c0adc702e9f4c63df13c (diff) | |
download | elgg-cc6b7d1d223241e397e0d41354924e74606eeffc.tar.gz elgg-cc6b7d1d223241e397e0d41354924e74606eeffc.tar.bz2 |
Refs #650. Replaced calls to get_annotations() by elgg_get_annotations().
git-svn-id: http://code.elgg.org/elgg/trunk@8182 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r-- | engine/classes/ElggEntity.php | 16 | ||||
-rw-r--r-- | engine/lib/annotations.php | 5 | ||||
-rw-r--r-- | engine/lib/views.php | 12 | ||||
-rw-r--r-- | engine/tests/objects/entities.php | 14 |
4 files changed, 35 insertions, 12 deletions
diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php index 8a7c45648..1154fd89a 100644 --- a/engine/classes/ElggEntity.php +++ b/engine/classes/ElggEntity.php @@ -519,13 +519,25 @@ abstract class ElggEntity extends ElggData implements * @param string $name Annotation name * @param int $limit Limit * @param int $offset Offset - * @param string $order asc or desc + * @param string $order Order by time: asc or desc * * @return array */ function getAnnotations($name, $limit = 50, $offset = 0, $order = "asc") { if ((int) ($this->guid) > 0) { - return get_annotations($this->getGUID(), "", "", $name, "", 0, $limit, $offset, $order); + + $options = array( + 'guid' => $this->guid, + 'annotation_name' => $name, + 'limit' => $limit, + 'offset' => $offset, + ); + + if ($order == 'desc') { + $options['order_by'] = 'n_table.time_created desc'; + } + + return elgg_get_annotations($options); } else { return $this->temp_annotations[$name]; } diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index a3f8f0bb9..a14853359 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -507,7 +507,10 @@ function export_annotation_plugin_hook($hook, $entity_type, $returnvalue, $param $guid = (int)$params['guid']; $name = $params['name']; - $result = get_annotations($guid); + $result = elgg_get_annotations(array( + 'guid' => $guid, + 'limit' => 0 + )); if ($result) { foreach ($result as $r) { diff --git a/engine/lib/views.php b/engine/lib/views.php index 21d606e01..d1782acc2 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -1088,13 +1088,21 @@ function elgg_view_comments($entity, $add_comment = true) { */ function elgg_view_latest_comments($owner_guid, $type = 'object', $subtype = '', $number = 4) { $title = elgg_echo('generic_comments:latest'); - $comments = get_annotations(0, $type, $subtype, 'generic_comment', '', 0, $number, 0, 'desc', 0, 0, $owner_guid); + $options = array( + 'annotation_name' => 'generic_comment', + 'owner_guid' => $owner_guid, + 'order_by' => 'n_table.time_created desc', + 'limit' => $number + + ); + $comments = elgg_get_annotations($options); + $body = elgg_view('layout/objects/list', array( 'items' => $comments, 'pagination' => false, 'list_class' => 'elgg-latest-comments', )); - + return elgg_view_module('aside', $title, $body); } diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index 590e404d8..67dd02596 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -119,18 +119,18 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->assertIdentical($annotations[0]->name, 'non_existent'); $this->assertEqual($this->entity->countAnnotations('non_existent'), 1); - $this->assertIdentical($annotations, get_annotations($this->entity->getGUID())); - $this->assertIdentical($annotations, get_annotations($this->entity->getGUID(), 'site')); - $this->assertIdentical($annotations, get_annotations($this->entity->getGUID(), 'site', 'testing')); - $this->assertIdentical(FALSE, get_annotations($this->entity->getGUID(), 'site', 'fail')); + $this->assertIdentical($annotations, elgg_get_annotations(array('guid' => $this->entity->getGUID()))); + $this->assertIdentical($annotations, elgg_get_annotations(array('guid' => $this->entity->getGUID(), 'type' => 'site'))); + $this->assertIdentical($annotations, elgg_get_annotations(array('guid' => $this->entity->getGUID(), 'type' => 'site', 'subtype' => 'testing'))); + $this->assertIdentical(FALSE, elgg_get_annotations(array('guid' => $this->entity->getGUID(), 'type' => 'site', 'subtype' => 'fail'))); // clear annotation $this->assertTrue($this->entity->clearAnnotations()); $this->assertEqual($this->entity->countAnnotations('non_existent'), 0); - $this->assertIdentical(array(), get_annotations($this->entity->getGUID())); - $this->assertIdentical(array(), get_annotations($this->entity->getGUID(), 'site')); - $this->assertIdentical(array(), get_annotations($this->entity->getGUID(), 'site', 'testing')); + $this->assertIdentical(array(), elgg_get_annotations(array('guid' => $this->entity->getGUID()))); + $this->assertIdentical(array(), elgg_get_annotations(array('guid' => $this->entity->getGUID(), 'type' => 'site'))); + $this->assertIdentical(array(), elgg_get_annotations(array('guid' => $this->entity->getGUID(), 'type' => 'site', 'subtype' => 'testing'))); // clean up $this->assertTrue($this->entity->delete()); |