]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixing list_registered_entities() from displaying things it should. You now must...
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 18 Feb 2011 22:06:26 +0000 (22:06 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 18 Feb 2011 22:06:26 +0000 (22:06 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8297 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/entities.php

index 45d4603832abb44a2595bb976f3c87e53cb85464..3bc9554fa69dc4e008cb688018a7cf225858936f 100644 (file)
@@ -2032,39 +2032,43 @@ function entities_page_handler($page) {
  * @return string A viewable list of entities
  * @since 1.7.0
  */
-function elgg_list_registered_entities($options) {
+function elgg_list_registered_entities(array $options = array()) {
        $defaults = array(
                'full_view' => TRUE,
                'allowed_types' => TRUE,
                'list_type_toggle' => FALSE,
                'pagination' => TRUE,
-               'offset' => 0
+               'offset' => 0,
+               'types' => array(),
+               'type_subtype_pairs' => array()
        );
 
        $options = array_merge($defaults, $options);
+
        //backwards compatibility
        if (isset($options['view_type_toggle'])) {
                $options['list_type_toggle'] = $options['view_type_toggle'];
        }
 
-       $typearray = array();
-
-       if ($object_types = get_registered_entity_types()) {
-               foreach ($object_types as $object_type => $subtype_array) {
-                       if (in_array($object_type, $options['allowed_types']) || $options['allowed_types'] === TRUE) {
-                               $typearray[$object_type] = array();
+       $types = get_registered_entity_types();
 
+       foreach ($types as $type => $subtype_array) {
+               if (in_array($type, $options['allowed_types']) || $options['allowed_types'] === TRUE) {
+                       // you must explicitly register types to show up in here and in search for objects
+                       if ($type == 'object') {
                                if (is_array($subtype_array) && count($subtype_array)) {
-                                       foreach ($subtype_array as $subtype) {
-                                               $typearray[$object_type][] = $subtype;
-                                       }
+                                       $options['type_subtype_pairs'][$type] = $subtype_array;
+                               }
+                       } else {
+                               if (is_array($subtype_array) && count($subtype_array)) {
+                                       $options['type_subtype_pairs'][$type] = $subtype_array;
+                               } else {
+                                       $options['type_subtype_pairs'][$type] = ELGG_ENTITIES_ANY_VALUE;
                                }
                        }
                }
        }
 
-       $options['type_subtype_pairs'] = $typearray;
-
        $count = elgg_get_entities(array_merge(array('count' => TRUE), $options));
        $entities = elgg_get_entities($options);
 
@@ -2144,7 +2148,7 @@ function update_entity_last_action($guid, $posted = NULL) {
        global $CONFIG;
        $guid = (int)$guid;
        $posted = (int)$posted;
-       
+
        if (!$posted) {
                $posted = time();
        }