function workbench_email_get_editors in Workbench Email 7.3
Function to get all the editors of workbench access section.
Filter by the roles specified in workbench notify settings for individually editors.
Parameters
object $role: The role object.
array $sections: The available sections.
Return value
array The available editors.
1 call to workbench_email_get_editors()
- workbench_email_get_workbench_access_editors in ./
workbench_email.module - Get all the editors of workbench access section.
File
- ./
workbench_email.module, line 956 - Code for the Workbench Email Module.
Code
function workbench_email_get_editors($role, $sections) {
$editors = array();
// Get the editors individually specified in workbench access
// editoral assignments by editor. Filter by the roles specified
// in workbench notify settings.
$query = db_select('users', 'u');
$query
->fields('u', array(
'uid',
'mail',
'name',
));
$query
->join('workbench_access_user', 'w', 'u.uid = w.uid');
$query
->join('users_roles', 'r', 'u.uid = r.uid');
$query
->condition('r.rid', $role->rid);
$query
->condition('access_id', $sections, 'IN');
$query
->condition('u.status', 1);
$result = $query
->execute();
foreach ($result as $record) {
$roles = workbench_email_get_user_roles($record->uid);
$editors[$record->uid]['mail'] = $record->mail;
$editors[$record->uid]['name'] = $record->name;
$editors[$record->uid]['roles'] = $roles;
}
$section_rids = workbench_email_get_rid_for_section_id($sections);
// Short circuit if the selected sections aren't within the current role.
if (!empty($section_rids) && !in_array($role->rid, $section_rids)) {
return $editors;
}
// Get all the editors specified by their role.
$query = db_select('users', 'u');
$query
->fields('u', array(
'uid',
'mail',
'name',
));
$query
->join('users_roles', 'r', 'u.uid = r.uid');
$query
->join('workbench_access_role', 'w', 'r.rid = w.rid');
$query
->condition('access_id', $sections, 'IN');
$query
->condition('u.status', 1);
$result = $query
->execute();
foreach ($result as $record) {
$roles = workbench_email_get_user_roles($record->uid);
$editors[$record->uid]['mail'] = $record->mail;
$editors[$record->uid]['name'] = $record->name;
$editors[$record->uid]['roles'] = $roles;
}
return $editors;
}