From 3b3798f2511bf5f41f37f04846b1037e1e22c7a5 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Wed, 14 Dec 2011 12:17:05 +0900 Subject: [PATCH] Issue #1025582 by sun: Added Custom db_select() 'conditions' parameter for menu_build_tree(). --- core/includes/menu.inc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/includes/menu.inc b/core/includes/menu.inc index aeb0d8a837e..83f25f124e9 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1339,6 +1339,8 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = * Defaults to 1, which is the default to build a whole tree for a menu, i.e. * excluding menu container itself. * - max_depth: The maximum depth of menu links in the resulting tree. + * - conditions: An associative array of custom database select query + * condition key/value pairs; see _menu_build_tree() for the actual query. * * @return * A fully built menu tree. @@ -1422,6 +1424,12 @@ function _menu_build_tree($menu_name, array $parameters = array()) { if (isset($parameters['max_depth'])) { $query->condition('ml.depth', $parameters['max_depth'], '<='); } + // Add custom query conditions, if any were passed. + if (isset($parameters['conditions'])) { + foreach ($parameters['conditions'] as $column => $value) { + $query->condition($column, $value); + } + } // Build an ordered array of links using the query result object. $links = array();