function cf_settings_get_registered in Common Functionality 7.2
Obtains the registered variables based on the given conditions.
Parameters
array $conditions: (optional) An array with the following possible keys:
- id: A unique id or an array of unique ids representing regisitered
variables.
- variable_name: A string or an array of strings that are represent
the names of variables to load.
- variable_type: A numeric id or an array of numeric ids that represent the types of variables to load.
- module_name: A string or an array of strings that are represent
the modules associated with variables to load.
string|null $keyed: (optional) A string matching one of the following: 'id' When this is NULL, the default behavior is to return the array exactly as it was returned by the database call. When this is a valid string, the key names of the returned array will use the specified key name.
Return value
array An array of registered variable objects.
Related topics
4 calls to cf_settings_get_registered()
- cf_settings_administer_variables in modules/
cf_settings/ pages/ variables.admin.inc - Display the system variables registry.
- cf_settings_boot in modules/
cf_settings/ cf_settings.module - Implements hook_boot().
- cf_settings_is_registered in modules/
cf_settings/ cf_settings.module - Determine if a variable is registered or not.
- cf_settings_register in modules/
cf_settings/ cf_settings.module - Add a variable name and type to the variables registry.
File
- modules/
cf_settings/ cf_settings.module, line 304 - Common Functionality - PHP INI module.
Code
function cf_settings_get_registered($conditions = array(), $keyed = NULL) {
if (!is_array($conditions)) {
return array();
}
$query = db_select('cf_settings_register', 'csr');
$query
->fields('csr');
$query
->orderBy('id', 'ASC');
$and = NULL;
if (isset($conditions['id'])) {
if (is_null($and)) {
$and = db_and();
}
if (is_numeric($conditions['id'])) {
$and
->condition('id', $conditions['id']);
}
elseif (is_array($conditions['id']) && !empty($conditions['id'])) {
$and
->condition('id', $conditions['id'], 'IN');
}
}
if (isset($conditions['variable_name'])) {
if (is_null($and)) {
$and = db_and();
}
if (is_string($conditions['variable_name']) && !empty($conditions['variable_name'])) {
$and
->condition('variable_name', $conditions['variable_name']);
}
elseif (is_array($conditions['variable_name']) && !empty($conditions['variable_name'])) {
$and
->condition('variable_name', $conditions['variable_name'], 'IN');
}
}
if (isset($conditions['variable_type'])) {
if (is_null($and)) {
$and = db_and();
}
if (is_numeric($conditions['variable_type'])) {
$and
->condition('variable_type', $conditions['variable_type']);
}
elseif (is_array($conditions['variable_type']) && !empty($conditions['variable_type'])) {
$and
->condition('variable_type', $conditions['variable_type'], 'IN');
}
}
if (isset($conditions['module_name'])) {
if (is_null($and)) {
$and = db_and();
}
if (is_string($conditions['module_name']) && !empty($conditions['module_name'])) {
$and
->condition('module_name', $conditions['module_name']);
}
elseif (is_array($conditions['module_name']) && !empty($conditions['module_name'])) {
$and
->condition('module_name', $conditions['module_name'], 'IN');
}
}
if (!is_null($and)) {
$query
->condition($and);
}
$registered = array();
if ($keyed == 'id') {
$records = $query
->execute();
foreach ($records as $record) {
if (!is_object($record)) {
continue;
}
$registered[$record->{$keyed}] = $record;
}
}
else {
$registered = (array) $query
->execute()
->fetchAll();
}
return $registered;
}