From fcc0303d1329c65c4c3fe4faf3a8a2921c2a15e3 Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 17 Jun 2009 17:03:14 +0000 Subject: Closes #719: More options on annotation count functions. git-svn-id: https://code.elgg.org/elgg/trunk@3343 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/annotations.php | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'engine') diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index df0f2a043..309d475d7 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -506,9 +506,9 @@ * @param $entity_subtype string * @param $name string */ - function get_annotations_sum($entity_guid, $entity_type = "", $entity_subtype = "", $name = "") + function get_annotations_sum($entity_guid, $entity_type = "", $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0) { - return __get_annotations_calculate_x("sum", $entity_guid, $entity_type, $entity_subtype, $name); + return __get_annotations_calculate_x("sum", $entity_guid, $entity_type, $entity_subtype, $name, $value, $value_type, $owner_guid); } /** @@ -519,9 +519,9 @@ * @param $entity_subtype string * @param $name string */ - function get_annotations_max($entity_guid, $entity_type = "", $entity_subtype = "", $name = "") + function get_annotations_max($entity_guid, $entity_type = "", $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0) { - return __get_annotations_calculate_x("max", $entity_guid, $entity_type, $entity_subtype, $name); + return __get_annotations_calculate_x("max", $entity_guid, $entity_type, $entity_subtype, $name, $value, $value_type, $owner_guid); } /** @@ -532,9 +532,9 @@ * @param $entity_subtype string * @param $name string */ - function get_annotations_min($entity_guid, $entity_type = "", $entity_subtype = "", $name = "") + function get_annotations_min($entity_guid, $entity_type = "", $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0) { - return __get_annotations_calculate_x("min", $entity_guid, $entity_type, $entity_subtype, $name); + return __get_annotations_calculate_x("min", $entity_guid, $entity_type, $entity_subtype, $name, $value, $value_type, $owner_guid); } /** @@ -545,9 +545,9 @@ * @param $entity_subtype string * @param $name string */ - function get_annotations_avg($entity_guid, $entity_type = "", $entity_subtype = "", $name = "") + function get_annotations_avg($entity_guid, $entity_type = "", $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0) { - return __get_annotations_calculate_x("avg", $entity_guid, $entity_type, $entity_subtype, $name); + return __get_annotations_calculate_x("avg", $entity_guid, $entity_type, $entity_subtype, $name, $value, $value_type, $owner_guid); } /** @@ -560,7 +560,7 @@ */ function count_annotations($entity_guid = 0, $entity_type = "", $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0) { - return __get_annotations_calculate_x("count", $entity_guid, $entity_type, $entity_subtype, $name); + return __get_annotations_calculate_x("count", $entity_guid, $entity_type, $entity_subtype, $name, $value, $value_type, $owner_guid); } /** @@ -572,7 +572,7 @@ * @param $entity_subtype string * @param $name string */ - function __get_annotations_calculate_x($sum = "avg", $entity_guid, $entity_type = "", $entity_subtype = "", $name = "") + function __get_annotations_calculate_x($sum = "avg", $entity_guid, $entity_type = "", $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0) { global $CONFIG; @@ -580,7 +580,10 @@ $entity_guid = (int)$entity_guid; $entity_type = sanitise_string($entity_type); $entity_subtype = get_subtype_id($entity_type, $entity_subtype); - if ($name != '') $name = get_metastring_id($name); + if ($name != '') $name = get_metastring_id($name); + if ($value != '') $value = get_metastring_id($value); + $value_type = sanitise_string($value_type); + $owner_guid = (int)$owner_guid; // if (empty($name)) return 0; @@ -593,7 +596,13 @@ if ($entity_subtype) $where[] = "e.subtype=$entity_subtype"; if ($name!="") - $where[] = "a.name_id='$name'"; + $where[] = "a.name_id='$name'"; + if ($value!="") + $where[] = "a.value_id='$value'"; + if ($value_type!="") + $where[] = "a.value_type='$value_type'"; + if ($owner_guid) + $where[] = "a.owner_guid='$owner_guid'"; if ($sum != "count") $where[] = "a.value_type='integer'"; // Limit on integer types -- cgit v1.2.3