aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-06 15:47:36 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-06 15:47:36 +0000
commited4a86c280dbad3bc3c42bfb39c1c7bcd2889efb (patch)
tree3fe7ab136f4546991f6989d0a3b68f4bc380f78b
parentf0cc1dbedd660c3d1e3014fe5673cfb2d77622ae (diff)
downloadelgg-ed4a86c280dbad3bc3c42bfb39c1c7bcd2889efb.tar.gz
elgg-ed4a86c280dbad3bc3c42bfb39c1c7bcd2889efb.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Added count to annotations git-svn-id: https://code.elgg.org/elgg/trunk@100 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/annotations.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index 2b398fc61..da4b1e3c2 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -248,6 +248,56 @@
return update_data("UPDATE {$CONFIG->dbprefix}annotations set value='$value', value_type='$value_type', access_id=$access_id, owner_id=$owner_id where id=$annotation_id and name='$name' and (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))");
}
+
+ /**
+ * Count the number of annotations based on search parameters
+ *
+ * @param int $object_id
+ * @param string $object_type
+ * @param string $name
+ * @param mixed $value
+ * @param string $value_type
+ * @param int $owner_id
+ */
+ function count_annotations($object_id = 0, $object_type = "", $name = "", $value = "", $value_type = "", $owner_id = 0)
+ {
+ global $CONFIG;
+
+ $object_id = (int)$object_id;
+ $object_type = sanitise_string($object_type);
+ $name = sanitise_string($name);
+ $value = sanitise_string($value);
+ $value_type = sanitise_string($value_type);
+ $owner_id = (int)$owner_id;
+ $access = get_access_list();
+
+ $where = array();
+ $where_q = "";
+
+ if ($object_id != 0)
+ $where[] = "object_id=$object_id";
+
+ if ($object_type != "")
+ $where[] = "object_type='$object_type'";
+
+ if ($name != "")
+ $where[] = "name='$name'";
+
+ if ($value != "")
+ $where[] = "value='$value'";
+
+ if ($owner_id != 0)
+ $where[] = "owner_id=$owner_id";
+
+ for ($n = 0; $n < count($where); $n++)
+ $where_q .= $where[$n] ." and ";
+
+ $result = get_data_row("SELECT count(*) as count from {$CONFIG->dbprefix}annotations WHERE $where_q (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))");
+ if ($result)
+ return $result->count;
+
+ return false;
+ }
/**
* Delete a given annotation.