function regcode_roles_get_rules in Registration codes 7
Same name and namespace in other branches
- 6.2 regcode_roles/regcode_roles.module \regcode_roles_get_rules()
- 6 regcode_roles/regcode_roles.module \regcode_roles_get_rules()
- 7.2 regcode_roles/regcode_roles.module \regcode_roles_get_rules()
Returns rules defined, optionally filtered by tag names.
Parameters
array $tags: Optional list of tags to get the rules for.
Return value
array An array of roles, each element containing a role stdClass.
2 calls to regcode_roles_get_rules()
- regcode_roles_get_list_markup in regcode_roles/
regcode_roles.module - Return the formatted HTML list.
- regcode_roles_regcode_used in regcode_roles/
regcode_roles.module - Implements hook_regcode_used().
File
- regcode_roles/
regcode_roles.module, line 216 - Main functionality of regcode_role module.
Code
function regcode_roles_get_rules($tags = array()) {
$query = db_select('regcode_roles', 'regcode_roles');
$query
->join('role', 'role', 'regcode_roles.role_id = role.rid');
$query
->join('taxonomy_term_data', 'term_data', 'regcode_roles.term_id = term_data.tid');
$query
->fields('regcode_roles', array(
'id',
'role_id',
));
$query
->addField('term_data', 'name', 'term_name');
$query
->addField('role', 'name', 'role');
if (count($tags)) {
$query
->condition('term_data.name', $tags, 'IN');
}
// Add some extra fields if role_expire is enabled.
if (module_exists('role_expire')) {
$query
->fields('regcode_roles', array(
'expire_duration',
'expire_date',
));
}
return $query
->execute()
->fetchAll(PDO::FETCH_ASSOC);
}