]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #4272 where an array of entity types can be used, use array in config object
authorCash Costello <cash.costello@gmail.com>
Wed, 25 Jan 2012 02:32:03 +0000 (21:32 -0500)
committerCash Costello <cash.costello@gmail.com>
Wed, 25 Jan 2012 02:44:43 +0000 (21:44 -0500)
engine/lib/configuration.php
engine/lib/entities.php
engine/lib/views.php

index 772c24930449f42a65bcb349c9bba443373c4098..7f787331f13c1995c6e15a0b9b7344fee927f3cc 100644 (file)
@@ -613,4 +613,7 @@ function _elgg_load_application_config() {
        $viewtype = get_input('view', 'default');
        $lastcached = datalist_get("simplecache_lastcached_$viewtype");
        $CONFIG->lastcache = $lastcached;
+
+       // this must be synced with the enum for the entities table
+       $CONFIG->entity_types = array('group', 'object', 'site', 'user');
 }
index 67011b802cf3855cad644dce41f3b783373e609d..2dc0eb8ae670f2a89a6436f362824bf6ce66b551 100644 (file)
@@ -960,8 +960,8 @@ function elgg_get_entity_type_subtype_where_sql($table, $types, $subtypes, $pair
                return '';
        }
 
-       // these are the only valid types for entities in elgg as defined in the DB.
-       $valid_types = array('object', 'user', 'group', 'site');
+       // these are the only valid types for entities in elgg
+       $valid_types = elgg_get_config('entity_types');
 
        // pairs override
        $wheres = array();
@@ -1965,7 +1965,7 @@ function elgg_register_entity_type($type, $subtype = null) {
        global $CONFIG;
 
        $type = strtolower($type);
-       if (!in_array($type, array('object', 'site', 'group', 'user'))) {
+       if (!in_array($type, $CONFIG->entity_types)) {
                return FALSE;
        }
 
@@ -2000,7 +2000,7 @@ function unregister_entity_type($type, $subtype) {
        global $CONFIG;
 
        $type = strtolower($type);
-       if (!in_array($type, array('object', 'site', 'group', 'user'))) {
+       if (!in_array($type, $CONFIG->entity_types)) {
                return FALSE;
        }
 
index 0a7969ae3578077a2e13790f176169b7a01780e0..4883ee7390a56e375e9585d9c7570b22315a3ee3 100644 (file)
@@ -1330,21 +1330,18 @@ function elgg_view_form($action, $form_vars = array(), $body_vars = array()) {
  * @access private
  */
 function elgg_view_list_item($item, array $vars = array()) {
+       global $CONFIG;
 
-       switch ($item->getType()) {
-               case 'user':
-               case 'object':
-               case 'group':
-               case 'site':
-                       return elgg_view_entity($item, $vars);
-               case 'annotation':
-                       return elgg_view_annotation($item, $vars);
-               case 'river':
-                       return elgg_view_river_item($item, $vars);
-               default:
-                       return false;
-                       break;
+       $type = $item->getType();
+       if (in_array($type, $CONFIG->entity_types)) {
+               return elgg_view_entity($item, $vars);
+       } else if ($type == 'annotation') {
+               return elgg_view_annotation($item, $vars);
+       } else if ($type == 'river') {
+               return elgg_view_river_item($item, $vars);
        }
+
+       return false;
 }
 
 /**