function getlocations_search_type_options in Get Locations 7.2
Same name and namespace in other branches
- 7 modules/getlocations_search/getlocations_search.module \getlocations_search_type_options()
Collect information about which entity_types have fields for supported module and return an array suitable for a dropdown
Return value
Array
1 call to getlocations_search_type_options()
- getlocations_search_form in modules/
getlocations_search/ getlocations_search.module - The search form
File
- modules/
getlocations_search/ getlocations_search.module, line 419 - getlocations_search.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_search_type_options() {
$module = getlocations_get_current_supported_module();
$query = db_select('field_config', 'f');
$query
->fields('i', array(
'entity_type',
));
$query
->join('field_config_instance', 'i', 'f.id=i.field_id');
$query
->condition('f.module', $module)
->condition('f.active', 1);
$rows = $query
->execute();
$opts = array();
foreach ($rows as $row) {
$found = FALSE;
$entity_type = $row->entity_type;
if ($entity_type == 'user' && getlocations_access_user_location()) {
$found = TRUE;
}
elseif ($entity_type == 'comment' && user_access('access comments')) {
$found = TRUE;
}
else {
if (getlocations_access_location()) {
$found = TRUE;
}
}
if ($found) {
$entity_get_info = entity_get_info($entity_type);
$label = isset($entity_get_info['plural label']) ? $entity_get_info['plural label'] : $entity_get_info['label'];
$opts[$entity_type] = $label;
}
}
if (count($opts) > 1) {
$opts = array(
'all' => t('Show All'),
) + $opts;
return $opts;
}
return array();
}