Skip to content

Commit

Permalink
Fixes #4272 where an array of entity types can be used, use array in …
Browse files Browse the repository at this point in the history
…config object
  • Loading branch information
cash committed Jan 25, 2012
1 parent 38679b4 commit 5a3390f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
3 changes: 3 additions & 0 deletions engine/lib/configuration.php
Expand Up @@ -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');
}
8 changes: 4 additions & 4 deletions engine/lib/entities.php
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
23 changes: 10 additions & 13 deletions engine/lib/views.php
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 5a3390f

Please sign in to comment.