function mass_contact_role_admin_edit in Mass Contact 7
Creates a form element for Category add/edit page.
Parameters
array $recipients: The list of items for this category. For this plugin implementation, it is an array of role IDs.
Return value
array The form snippet.
1 string reference to 'mass_contact_role_admin_edit'
- mass_contact_role.inc in plugins/
mass_contact_role.inc
File
- plugins/
mass_contact_role.inc, line 120
Code
function mass_contact_role_admin_edit(array $recipients) {
$selected_roles = array();
if (isset($recipients['mass_contact_role']) && !empty($recipients['mass_contact_role'])) {
$selected_roles = $recipients['mass_contact_role'];
}
// Get a list of all roles, except for the anonymous user role.
$allroles = db_select('role', 'r')
->fields('r', array(
'rid',
'name',
))
->condition('rid', 1, '>')
->orderBy('name', 'ASC')
->execute();
// Cycle through each role, adding it to the array to include in the selction
// list.
foreach ($allroles as $role) {
$rolesarray[$role->rid] = $role->name;
}
// Create a set of checkboxes, including each role.
$form_element = array(
'#type' => 'checkboxes',
'#title' => t('User roles to include'),
'#options' => $rolesarray,
'#default_value' => $selected_roles,
'#description' => t('These roles will be added to the mailing list. Note: if you check "authenticated user", other roles will not be added, as they will receive the email anyway.'),
);
return $form_element;
}