function workbench_email_scheme_menu_get_parents in Workbench Email 7.3
Function to get all the parents of the workbench access's section.
Parameters
array $sections: The available sections.
Return value
mixed The available sections.
1 call to workbench_email_scheme_menu_get_parents()
- workbench_email_get_workbench_access_editors in ./
workbench_email.module - Get all the editors of workbench access section.
File
- ./
workbench_email.module, line 900 - Code for the Workbench Email Module.
Code
function workbench_email_scheme_menu_get_parents($sections) {
// Get the menu parent items.
$query = db_select('menu_links', 'm');
$query
->fields('m', array(
'plid',
'menu_name',
));
for ($i = 1; $i <= 9; $i++) {
$query
->fields('m', array(
'p' . $i,
));
}
if (count($sections) > 1) {
$query
->condition('mlid', array_keys($sections), 'IN');
}
else {
if (!is_array($sections)) {
$sections = array(
$sections => $sections,
);
}
$query
->condition('mlid', $sections, 'IN');
}
$result = $query
->execute();
foreach ($result as $record) {
$menu_name = $record->menu_name;
// Add all the parents to $sections.
for ($i = 1; $i <= 9; $i++) {
$p = 'p' . $i;
$parent = $record->{$p};
if ($parent == '0') {
break;
}
if (!in_array($parent, $sections)) {
$sections[$parent] = $parent;
}
}
// Add the menu's name to $sections.
if (!in_array($menu_name, $sections)) {
$sections[$menu_name] = $menu_name;
}
}
return $sections;
}