]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Closes #719: More options on annotation count functions.
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 17 Jun 2009 17:03:14 +0000 (17:03 +0000)
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 17 Jun 2009 17:03:14 +0000 (17:03 +0000)
git-svn-id: https://code.elgg.org/elgg/trunk@3343 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/annotations.php

index df0f2a043717cf1a874a6b1b61e35d8822ea4955..309d475d7d55abb28c5c49958049209e699fecbd 100644 (file)
         * @param $entity_subtype string\r
         * @param $name string\r
         */\r
-       function get_annotations_sum($entity_guid, $entity_type = "", $entity_subtype = "", $name = "")\r
+       function get_annotations_sum($entity_guid, $entity_type = "", $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0)\r
        {\r
-               return __get_annotations_calculate_x("sum", $entity_guid, $entity_type, $entity_subtype, $name);\r
+               return __get_annotations_calculate_x("sum", $entity_guid, $entity_type, $entity_subtype, $name, $value, $value_type, $owner_guid);\r
        }\r
        \r
        /**\r
         * @param $entity_subtype string\r
         * @param $name string\r
         */\r
-       function get_annotations_max($entity_guid, $entity_type = "", $entity_subtype = "", $name = "")\r
+       function get_annotations_max($entity_guid, $entity_type = "", $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0)\r
        {\r
-               return __get_annotations_calculate_x("max", $entity_guid, $entity_type, $entity_subtype, $name);\r
+               return __get_annotations_calculate_x("max", $entity_guid, $entity_type, $entity_subtype, $name, $value, $value_type, $owner_guid);\r
        }\r
        \r
        /**\r
         * @param $entity_subtype string\r
         * @param $name string\r
         */\r
-       function get_annotations_min($entity_guid, $entity_type = "", $entity_subtype = "", $name = "")\r
+       function get_annotations_min($entity_guid, $entity_type = "", $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0)\r
        {\r
-               return __get_annotations_calculate_x("min", $entity_guid, $entity_type, $entity_subtype, $name);\r
+               return __get_annotations_calculate_x("min", $entity_guid, $entity_type, $entity_subtype, $name, $value, $value_type, $owner_guid);\r
        }\r
        \r
        /**\r
         * @param $entity_subtype string\r
         * @param $name string\r
         */\r
-       function get_annotations_avg($entity_guid, $entity_type = "", $entity_subtype = "", $name = "")\r
+       function get_annotations_avg($entity_guid, $entity_type = "", $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0)\r
        {\r
-               return __get_annotations_calculate_x("avg", $entity_guid, $entity_type, $entity_subtype, $name);\r
+               return __get_annotations_calculate_x("avg", $entity_guid, $entity_type, $entity_subtype, $name, $value, $value_type, $owner_guid);\r
        }\r
        \r
        /**\r
         */\r
        function count_annotations($entity_guid = 0, $entity_type = "", $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0)\r
        {\r
-               return __get_annotations_calculate_x("count", $entity_guid, $entity_type, $entity_subtype, $name);\r
+               return __get_annotations_calculate_x("count", $entity_guid, $entity_type, $entity_subtype, $name, $value, $value_type, $owner_guid);\r
        }\r
        \r
        /**\r
         * @param $entity_subtype string\r
         * @param $name string\r
         */\r
-       function __get_annotations_calculate_x($sum = "avg", $entity_guid, $entity_type = "", $entity_subtype = "", $name = "")\r
+       function __get_annotations_calculate_x($sum = "avg", $entity_guid, $entity_type = "", $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0)\r
        {\r
                global $CONFIG;\r
                \r
                $entity_guid = (int)$entity_guid;\r
                $entity_type = sanitise_string($entity_type);\r
                $entity_subtype = get_subtype_id($entity_type, $entity_subtype);\r
-               if ($name != '') $name = get_metastring_id($name);\r
+               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;\r
                \r
                // if (empty($name)) return 0;\r
                \r
                if ($entity_subtype)\r
                        $where[] = "e.subtype=$entity_subtype";\r
                if ($name!="")\r
-                       $where[] = "a.name_id='$name'";\r
+                       $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'";\r
                        \r
                if ($sum != "count")\r
                        $where[] = "a.value_type='integer'"; // Limit on integer types\r