function _hansel_get_rules in Hansel breadcrumbs 7
Same name and namespace in other branches
- 8 hansel.module \_hansel_get_rules()
Get all Hansel rules for a specified parent id in a list.
@access private
Parameters
int $pid Return only rules with this parent id:
Return value
array
4 calls to _hansel_get_rules()
- hansel_export_dot in export/
hansel_export.module - Generete an export to dot format for the current configuration.
- _hansel_build_config in ./
hansel.module - Build the Hansel configuration object.
- _hansel_get_rules_tree in ./
hansel.module - Get all Hansel rules in a list including depth, sorted by hierarchy, then alphabetically.
- _hansel_ui_list_rules in hansel_ui/
hansel_ui.module
File
- ./
hansel.module, line 150 - Hansel module
Code
function _hansel_get_rules($pid = 0) {
$output = array();
$sql = "SELECT r.rid, r.pid, r.name, r.crumb_action, r.crumb_action_arguments,\n rag.destination as goto_destination,\n ral.restore_original as leave_restore,\n ras.handler as switch_handler,\n ras.arguments as switch_arguments,\n CASE COALESCE(r.pid, 0) WHEN 0 THEN\n CASE r.name WHEN 'start' THEN 0 ELSE 1 END\n ELSE 1 END AS start_order\n FROM {hansel_rule} r\n LEFT JOIN {hansel_rule_action_goto} rag ON rag.rid = r.rid\n LEFT JOIN {hansel_rule_action_leave} ral ON ral.rid = r.rid\n LEFT JOIN {hansel_rule_action_switch} ras ON ras.rid = r.rid ";
if ($pid != -1) {
// Means; get all rules as a flat list
$sql .= "WHERE COALESCE(pid, 0) = :pid ";
}
$sql .= "ORDER BY start_order ASC, r.name ASC";
$res = db_query($sql, array(
':pid' => $pid,
));
while ($rec = $res
->fetchAssoc()) {
$rule = new stdClass();
$rule->rid = $rec['rid'];
$rule->pid = $rec['pid'];
$rule->name = $rec['name'];
$rule->crumb_action = $rec['crumb_action'];
if (empty($rec['crumb_action_arguments'])) {
$rule->crumb_action_arguments = array();
}
else {
$rule->crumb_action_arguments = unserialize($rec['crumb_action_arguments']);
}
if (!empty($rec['goto_destination'])) {
$rule->action = 'goto';
$rule->destination = $rec['goto_destination'];
}
elseif (!empty($rec['switch_handler'])) {
$rule->action = 'switch';
$rule->handler = $rec['switch_handler'];
if (!empty($rec['switch_arguments'])) {
$rule->arguments = unserialize($rec['switch_arguments']);
}
else {
$rule->arguments = array();
}
}
else {
$rule->action = 'leave';
$rule->restore = $rec['leave_restore'] ? TRUE : FALSE;
}
$output[$rule->rid] = $rule;
}
return $output;
}