aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-09 16:24:00 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-09 16:24:00 +0000
commiteb4558217ba8a82bf6fc38262163d372f47cead2 (patch)
tree70c9e61bc820915a6a95271f6e03f69d2a2578dd
parent4f5271d975e7d07a2a3a654377a72c2e0f854b40 (diff)
downloadelgg-eb4558217ba8a82bf6fc38262163d372f47cead2.tar.gz
elgg-eb4558217ba8a82bf6fc38262163d372f47cead2.tar.bz2
Refs #1411. Added ability to specify annotation time_created lower and upper. Deprecated remaining get/list_entities_from/by_annotation*() functions.
git-svn-id: http://code.elgg.org/elgg/trunk@7580 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/annotations.php154
1 files changed, 120 insertions, 34 deletions
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index e19287245..72e43fa5c 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -372,6 +372,9 @@ function elgg_get_entities_from_annotations(array $options = array()) {
'annotation_case_sensitive' => TRUE,
'order_by_annotation' => array(),
+ 'annotation_created_time_lower' => ELGG_ENTITIES_ANY_VALUE,
+ 'annotation_created_time_upper' => ELGG_ENTITIES_ANY_VALUE,
+
'annotation_owner_guids' => ELGG_ENTITIES_ANY_VALUE,
'order_by' => 'maxtime desc',
@@ -394,6 +397,13 @@ function elgg_get_entities_from_annotations(array $options = array()) {
$options['selects'][] = "max(n_table.time_created) as maxtime";
$options['group_by'] = 'n_table.entity_guid';
+ $time_wheres = elgg_get_entity_time_where_sql('a', $options['annotation_created_time_upper'],
+ $options['annotation_created_time_lower']);
+
+ if ($time_wheres) {
+ $options['wheres'] = array_merge($options['wheres'], $time_wheres);
+ }
+
return elgg_get_entities_from_metadata($options);
}
@@ -427,12 +437,6 @@ $count = false, $timelower = 0, $timeupper = 0) {
$options = array();
- $options['annotation_names'] = $name;
-
- if ($value) {
- $options['annotation_values'] = $value;
- }
-
if ($entity_type) {
$options['types'] = $entity_type;
}
@@ -441,6 +445,12 @@ $count = false, $timelower = 0, $timeupper = 0) {
$options['subtypes'] = $entity_subtype;
}
+ $options['annotation_names'] = $name;
+
+ if ($value) {
+ $options['annotation_values'] = $value;
+ }
+
if ($owner_guid) {
if (is_array($owner_guid)) {
$options['annotation_owner_guids'] = $owner_guid;
@@ -469,6 +479,14 @@ $count = false, $timelower = 0, $timeupper = 0) {
$options['count'] = $count;
}
+ if ($timelower) {
+ $options['annotation_created_time_lower'] = $timelower;
+ }
+
+ if ($timeupper) {
+ $options['annotation_created_time_upper'] = $timeupper;
+ }
+
return elgg_get_entities_from_annotations($options);
}
@@ -857,8 +875,6 @@ $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
$options['calculation'] = $sum;
- $options['annotation_names'] = $name;
-
if ($entity_type) {
$options['types'] = $entity_type;
}
@@ -867,6 +883,8 @@ $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
$options['subtypes'] = $entity_subtype;
}
+ $options['annotation_names'] = $name;
+
if ($mdname) {
$options['metadata_names'] = $mdname;
}
@@ -875,11 +893,12 @@ $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
$options['metadata_values'] = $mdvalue;
}
+ // original function rewrote this to container guid.
if ($owner_guid) {
if (is_array($owner_guid)) {
- $options['owner_guids'] = $owner_guid;
+ $options['container_guids'] = $owner_guid;
} else {
- $options['owner_guid'] = $owner_guid;
+ $options['container_guid'] = $owner_guid;
}
}
@@ -923,8 +942,6 @@ $count = false) {
$options['calculation'] = 'sum';
- $options['annotation_names'] = $name;
-
if ($entity_type) {
$options['types'] = $entity_type;
}
@@ -933,6 +950,8 @@ $count = false) {
$options['subtypes'] = $entity_subtype;
}
+ $options['annotation_names'] = $name;
+
if ($mdname) {
$options['metadata_names'] = $mdname;
}
@@ -960,8 +979,21 @@ $count = false) {
}
/**
+ * List entities from an annotation calculation.
+ *
+ * @see elgg_get_entities_from_annotation_calculation()
+ *
+ * @param array $options An options array.
+ */
+function elgg_list_entities_from_annotation_calculation($options) {
+ return elgg_list_entities($options, 'elgg_get_entities_from_annotation_calculation');
+}
+
+/**
* Lists entities by the totals of a particular kind of annotation
*
+ * @deprecated 1.8 Use elgg_list_entities_from_annotation_calculation()
+ *
* @param string $entity_type Type of entity.
* @param string $entity_subtype Subtype of entity.
* @param string $name Name of annotation.
@@ -979,21 +1011,44 @@ $count = false) {
function list_entities_from_annotation_count($entity_type = "", $entity_subtype = "", $name = "",
$limit = 10, $owner_guid = 0, $group_guid = 0, $asc = false, $fullview = true,
$listtypetoggle = false, $pagination = true, $orderdir = 'desc') {
- if ($asc) {
- $asc = "asc";
- } else {
- $asc = "desc";
+
+ $msg = 'list_entities_from_annotation_count() is deprecated by elgg_list_entities_from_annotation_calculation().';
+
+ elgg_deprecated_notice($msg, 1.8);
+
+ $options = array();
+
+ $options['calculation'] = 'sum';
+
+ if ($entity_type) {
+ $options['types'] = $entity_type;
}
- $offset = (int) get_input("offset", 0);
- $count = get_entities_from_annotation_count($entity_type, $entity_subtype, $name,
- '', '', $owner_guid, $limit, $offset, $orderdir, true);
+ if ($entity_subtype) {
+ $options['subtypes'] = $entity_subtype;
+ }
- $entities = get_entities_from_annotation_count($entity_type, $entity_subtype, $name,
- '', '', $owner_guid, $limit, $offset, $orderdir, false);
+ $options['annotation_names'] = $name;
- return elgg_view_entity_list($entities, $count, $offset, $limit,
- $fullview, $listtypetoggle, $pagination);
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['owner_guids'] = $owner_guid;
+ } else {
+ $options['owner_guid'] = $owner_guid;
+ }
+ }
+
+ $options['full_view'] = $fullview;
+
+ $options['list_type_toggle'] = $listtypetoggle;
+
+ $options['pagination'] = $pagination;
+
+ $options['limit'] = $limit;
+
+ $options['order_by'] = "calculated $orderdir";
+
+ return elgg_get_entities_from_annotation_calculation($options);
}
/**
@@ -1020,20 +1075,51 @@ function list_entities_from_annotation_count_by_metadata($entity_type = "", $ent
$name = "", $mdname = '', $mdvalue = '', $limit = 10, $owner_guid = 0, $group_guid = 0,
$asc = false, $fullview = true, $listtypetoggle = false, $pagination = true, $orderdir = 'desc') {
- if ($asc) {
- $asc = "asc";
- } else {
- $asc = "desc";
+ $msg = 'list_entities_from_annotation_count_by_metadata() is deprecated by elgg_list_entities_from_annotation_calculation().';
+
+ elgg_deprecated_notice($msg, 1.8);
+
+ $options = array();
+
+ $options['calculation'] = 'sum';
+
+ if ($entity_type) {
+ $options['types'] = $entity_type;
}
- $offset = (int) get_input("offset", 0);
- $count = get_entities_from_annotation_count($entity_type, $entity_subtype, $name, $mdname,
- $mdvalue, $owner_guid, $limit, $offset, $orderdir, true);
- $entities = get_entities_from_annotation_count($entity_type, $entity_subtype, $name, $mdname,
- $mdvalue, $owner_guid, $limit, $offset, $orderdir, false);
+ if ($entity_subtype) {
+ $options['subtypes'] = $entity_subtype;
+ }
+
+ $options['annotation_names'] = $name;
- return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview,
- $listtypetoggle, $pagination);
+ if ($mdname) {
+ $options['metadata_name'] = $mdname;
+ }
+
+ if ($mdvalue) {
+ $options['metadata_value'] = $mdvalue;
+ }
+
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['owner_guids'] = $owner_guid;
+ } else {
+ $options['owner_guid'] = $owner_guid;
+ }
+ }
+
+ $options['full_view'] = $fullview;
+
+ $options['list_type_toggle'] = $listtypetoggle;
+
+ $options['pagination'] = $pagination;
+
+ $options['limit'] = $limit;
+
+ $options['order_by'] = "calculated $orderdir";
+
+ return elgg_get_entities_from_annotation_calculation($options);
}
/**