]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Changed elgg_get_entities_from_access_id() to be closer to how other functions work.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 2 Nov 2009 21:06:37 +0000 (21:06 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 2 Nov 2009 21:06:37 +0000 (21:06 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@3613 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/access.php

index 29dbd764d219f4d38854796911d41c702bf1e9fe..4b295fd34978bea88ab6f55459c723046b644282 100644 (file)
@@ -672,11 +672,11 @@ function elgg_view_access_collections($owner_guid) {
 function get_entities_from_access_id($collection_id, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
        // log deprecated warning
        elgg_log('get_entities_from_access_id() was deprecated in 1.7 by elgg_get_entities()!', 'WARNING');
-       
+
        if (!$collection_id) {
                return FALSE;
        }
-       
+
        // build the options using given parameters
        $options = array();
        $options['limit'] = $limit;
@@ -686,11 +686,11 @@ function get_entities_from_access_id($collection_id, $entity_type = "", $entity_
        if ($entity_type) {
                $options['type'] = sanitise_string($entity_type);
        }
-       
+
        if ($entity_subtype) {
                $options['subtype'] = $entity_subtype;
        }
-       
+
        if ($site_guid) {
                $options['site_guid'] = $site_guid;
        }
@@ -705,12 +705,14 @@ function get_entities_from_access_id($collection_id, $entity_type = "", $entity_
                        $options['owner_guids'][] = $guid;
                }
        }
-       
+
        if ($site_guid) {
                $options['site_guid'] = $site_guid;
        }
 
-       return elgg_get_entities_from_access_id($collection_id, $options);
+       $options['access_id'] = $collection_id;
+
+       return elgg_get_entities_from_access_id($options);
 }
 
 /**
@@ -721,10 +723,24 @@ function get_entities_from_access_id($collection_id, $entity_type = "", $entity_
  * @return array
  * @since 1.7
  */
-function elgg_get_entities_from_access_id($collection_id, array $options=array()) {
+function elgg_get_entities_from_access_id(array $options=array()) {
        // restrict the resultset to access collection provided
-       $options['wheres'] = "e.access_id = '$collection_id'";
-       
+       if (!isset($options['access_id'])) {
+               return FALSE;
+       }
+
+       // @todo add support for an array of collection_ids
+       $where = "e.access_id = '{$options['access_id']}'";
+       if (isset($options['wheres'])) {
+               if (is_array($options['wheres'])) {
+                       $options['wheres'][] = $where;
+               } else {
+                       $options['wheres'] = array($options['wheres'], $where);
+               }
+       } else {
+               $options['wheres'] = array($where);
+       }
+
        // return entities with the desired options
        return elgg_get_entities($options);
 }