function pm_attributes_bydomain in Drupal PM (Project Management) 7
Provides attributes in a specified domain.
7 calls to pm_attributes_bydomain()
- pmorganization_form in pmorganization/
pmorganization.module - Implements hook_form().
- pmproject_form in pmproject/
pmproject.module - Implements hook_form().
- pmtask_form in pmtask/
pmtask.module - Implements hook_form().
- pmticket_form in pmticket/
pmticket.module - Implements hook_form().
- pm_attribute_value in ./
pm.module - Provides attribute value for a given domain and key.
File
- ./
pm.module, line 1134 - Main module file for the Project Management module.
Code
function pm_attributes_bydomain($domain) {
static $attributes_cache = array();
$attributes = array();
if (array_key_exists($domain, $attributes_cache)) {
return $attributes_cache[$domain];
}
$query = db_select('pmattribute', 'sa')
->fields('sa')
->condition('sa.isactive', 1)
->condition('sa.domain', $domain, 'LIKE')
->orderBy('weight', 'ASC')
->orderBy('avalue', 'ASC');
$result = $query
->execute();
$attributes['values'] = array();
foreach ($result as $attribute) {
// The variable is deliberately passed through t() for translatability
$attributes['values'][$attribute->akey] = t($attribute->avalue);
if ($attribute->isdefault) {
$attributes['default'] = $attribute->akey;
}
}
if (is_array($attributes['values']) && !array_key_exists('default', $attributes)) {
$v = array_flip($attributes['values']);
$attributes['default'] = array_shift($v);
}
$attributes_cache[$domain] = $attributes;
return $attributes;
}