aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/annotations.php
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-07-29 11:42:02 -0300
committerSilvio Rhatto <rhatto@riseup.net>2013-07-29 11:42:02 -0300
commitbb3c9a26bb75c76c5934d327548bf08606467b9f (patch)
tree26760aa866799fc70683ef6845bf54fb17bdc955 /engine/lib/annotations.php
parent2feedf39f6484879333a7b77fdc3c184150db8c7 (diff)
parent398572fd96c72b363fd5a252fb9cbe1cecab1e04 (diff)
downloadelgg-bb3c9a26bb75c76c5934d327548bf08606467b9f.tar.gz
elgg-bb3c9a26bb75c76c5934d327548bf08606467b9f.tar.bz2
Merge branch 'floxglove-3' into saravea
Conflicts: .gitmodules
Diffstat (limited to 'engine/lib/annotations.php')
-rw-r--r--engine/lib/annotations.php49
1 files changed, 37 insertions, 12 deletions
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index 3b9f84703..bd5ea1a1f 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -17,6 +17,7 @@
*/
function row_to_elggannotation($row) {
if (!($row instanceof stdClass)) {
+ // @todo should throw in this case?
return $row;
}
@@ -30,7 +31,7 @@ function row_to_elggannotation($row) {
*
* @param int $id The id of the annotation object being retrieved.
*
- * @return false|ElggAnnotation
+ * @return ElggAnnotation|false
*/
function elgg_get_annotation_from_id($id) {
return elgg_get_metastring_based_object_from_id($id, 'annotations');
@@ -195,10 +196,22 @@ function update_annotation($annotation_id, $name, $value, $value_type, $owner_gu
* for the proper use of the "calculation" option.
*
*
- * @return mixed
+ * @return ElggAnnotation[]|mixed
* @since 1.8.0
*/
function elgg_get_annotations(array $options = array()) {
+
+ // @todo remove support for count shortcut - see #4393
+ if (isset($options['__egefac']) && $options['__egefac']) {
+ unset($options['__egefac']);
+ } else {
+ // support shortcut of 'count' => true for 'annotation_calculation' => 'count'
+ if (isset($options['count']) && $options['count']) {
+ $options['annotation_calculation'] = 'count';
+ unset($options['count']);
+ }
+ }
+
$options['metastring_type'] = 'annotations';
return elgg_get_metastring_based_objects($options);
}
@@ -424,6 +437,10 @@ function elgg_get_entities_from_annotation_calculation($options) {
$options['callback'] = 'entity_row_to_elggstar';
+ // see #4393
+ // @todo remove after the 'count' shortcut is removed from elgg_get_annotations()
+ $options['__egefac'] = true;
+
return elgg_get_annotations($options);
}
@@ -441,19 +458,20 @@ function elgg_list_entities_from_annotation_calculation($options) {
}
/**
- * Handler called by trigger_plugin_hook on the "export" event.
+ * Export the annotations for the specified entity
*
* @param string $hook 'export'
- * @param string $entity_type 'all'
+ * @param string $type 'all'
* @param mixed $returnvalue Default return value
- * @param mixed $params List of params to export
+ * @param mixed $params Parameters determining what annotations to export
*
* @elgg_plugin_hook export all
*
- * @return mixed
+ * @return array
+ * @throws InvalidParameterException
* @access private
*/
-function export_annotation_plugin_hook($hook, $entity_type, $returnvalue, $params) {
+function export_annotation_plugin_hook($hook, $type, $returnvalue, $params) {
// Sanity check values
if ((!is_array($params)) && (!isset($params['guid']))) {
throw new InvalidParameterException(elgg_echo('InvalidParameterException:GUIDNotForExport'));
@@ -464,12 +482,12 @@ function export_annotation_plugin_hook($hook, $entity_type, $returnvalue, $param
}
$guid = (int)$params['guid'];
- $name = $params['name'];
+ $options = array('guid' => $guid, 'limit' => 0);
+ if (isset($params['name'])) {
+ $options['annotation_name'] = $params['name'];
+ }
- $result = elgg_get_annotations(array(
- 'guid' => $guid,
- 'limit' => 0
- ));
+ $result = elgg_get_annotations($options);
if ($result) {
foreach ($result as $r) {
@@ -541,6 +559,7 @@ function elgg_comment_url_handler(ElggAnnotation $comment) {
if ($entity) {
return $entity->getURL() . '#item-annotation-' . $comment->id;
}
+ return "";
}
/**
@@ -557,6 +576,12 @@ function elgg_register_annotation_url_handler($extender_name = "all", $function_
/**
* Register annotation unit tests
+ *
+ * @param string $hook
+ * @param string $type
+ * @param array $value
+ * @param array $params
+ * @return array
* @access private
*/
function annotations_test($hook, $type, $value, $params) {