aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/annotations.php
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-06-17 17:03:14 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-06-17 17:03:14 +0000
commitfcc0303d1329c65c4c3fe4faf3a8a2921c2a15e3 (patch)
treec0253b5e3502020990dd20c6c9343f109761e6ac /engine/lib/annotations.php
parentd57dc52041c5fdb5b4bec42d58a9791b84686d1f (diff)
downloadelgg-fcc0303d1329c65c4c3fe4faf3a8a2921c2a15e3.tar.gz
elgg-fcc0303d1329c65c4c3fe4faf3a8a2921c2a15e3.tar.bz2
Closes #719: More options on annotation count functions.
git-svn-id: https://code.elgg.org/elgg/trunk@3343 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/annotations.php')
-rw-r--r--engine/lib/annotations.php33
1 files changed, 21 insertions, 12 deletions
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