summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/bootstrap.inc4
-rw-r--r--includes/common.inc19
-rw-r--r--includes/locale.inc1
-rw-r--r--includes/menu.inc1390
-rw-r--r--includes/module.inc2
-rw-r--r--includes/path.inc20
-rw-r--r--install.php1
-rw-r--r--modules/aggregator/aggregator.module310
-rw-r--r--modules/block/block.module77
-rw-r--r--modules/blog/blog.module25
-rw-r--r--modules/blogapi/blogapi.module52
-rw-r--r--modules/book/book.module109
-rw-r--r--modules/comment/comment.module144
-rw-r--r--modules/contact/contact.module152
-rw-r--r--modules/drupal/drupal.module44
-rw-r--r--modules/filter/filter.module148
-rw-r--r--modules/forum/forum.module127
-rw-r--r--modules/help/help.module30
-rw-r--r--modules/legacy/legacy.module93
-rw-r--r--modules/locale/locale.module144
-rw-r--r--modules/menu/menu.module3
-rw-r--r--modules/node/node.module316
-rw-r--r--modules/path/path.module57
-rw-r--r--modules/poll/poll.module84
-rw-r--r--modules/profile/profile.module80
-rw-r--r--modules/search/search.module89
-rw-r--r--modules/statistics/statistics.module127
-rw-r--r--modules/system/system.install79
-rw-r--r--modules/system/system.module441
-rw-r--r--modules/taxonomy/taxonomy.module155
-rw-r--r--modules/throttle/throttle.module23
-rw-r--r--modules/tracker/tracker.module54
-rw-r--r--modules/upload/upload.module73
-rw-r--r--modules/user/user.module386
-rw-r--r--modules/watchdog/watchdog.module59
-rw-r--r--profiles/default/default.profile2
36 files changed, 2046 insertions, 2874 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 995b2f05f..308dafc47 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -550,7 +550,7 @@ function drupal_page_cache_header($cache) {
* Define the critical hooks that force modules to always be loaded.
*/
function bootstrap_hooks() {
- return array('init', 'exit');
+ return array('boot', 'exit');
}
/**
@@ -856,7 +856,7 @@ function _drupal_cache_init($phase) {
}
elseif (variable_get('cache', CACHE_DISABLED) == CACHE_NORMAL) {
require_once './includes/module.inc';
- bootstrap_invoke_all('init');
+ bootstrap_invoke_all('boot');
drupal_page_cache_header($cache);
bootstrap_invoke_all('exit');
exit();
diff --git a/includes/common.inc b/includes/common.inc
index 8827a732b..8811a36d8 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -2209,3 +2209,22 @@ function element_child($key) {
function element_children($element) {
return array_filter(array_keys((array) $element), 'element_child');
}
+
+/**
+ * Generate vancode.
+ *
+ * Consists of a leading character indicating length, followed by N digits
+ * with a numerical value in base 36. Vancodes can be sorted as strings
+ * without messing up numerical order.
+ *
+ * It goes:
+ * 00, 01, 02, ..., 0y, 0z,
+ * 110, 111, ... , 1zy, 1zz,
+ * 2100, 2101, ..., 2zzy, 2zzz,
+ * 31000, 31001, ...
+ */
+function int2vancode($i = 0) {
+ $num = base_convert((int)$i, 10, 36);
+ $length = strlen($num);
+ return chr($length + ord('0') - 1) . $num;
+}
diff --git a/includes/locale.inc b/includes/locale.inc
index 376dee5f1..02a4eed68 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -119,7 +119,6 @@ function _locale_admin_manage_screen_submit($form_id, $form_values) {
drupal_set_message(t('Configuration saved.'));
// Changing the locale settings impacts the interface:
- cache_clear_all('*', 'cache_menu', TRUE);
cache_clear_all('*', 'cache_page', TRUE);
return 'admin/settings/locale/language/overview';
diff --git a/includes/menu.inc b/includes/menu.inc
index 3ff61171e..8a5ac6d8c 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -172,327 +172,220 @@ define('MENU_SITE_OFFLINE', 4);
*/
/**
- * Return the menu data structure.
- *
- * The returned structure contains much information that is useful only
- * internally in the menu system. External modules are likely to need only
- * the ['visible'] element of the returned array. All menu items that are
- * accessible to the current user and not hidden will be present here, so
- * modules and themes can use this structure to build their own representations
- * of the menu.
- *
- * $menu['visible'] will contain an associative array, the keys of which
- * are menu IDs. The values of this array are themselves associative arrays,
- * with the following key-value pairs defined:
- * - 'title' - The displayed title of the menu or menu item. It will already
- * have been translated by the locale system.
- * - 'description' - The description (link title attribute) of the menu item.
- * It will already have been translated by the locale system.
- * - 'path' - The Drupal path to the menu item. A link to a particular item
- * can thus be constructed with
- * l($item['title'], $item['path'], array('title' => $item['description'])).
- * - 'children' - A linear list of the menu ID's of this item's children.
- *
- * Menu ID 0 is the "root" of the menu. The children of this item are the
- * menus themselves (they will have no associated path). Menu ID 1 will
- * always be one of these children; it is the default "Navigation" menu.
- */
-function menu_get_menu() {
- global $_menu;
- global $user;
- global $locale;
-
- if (!isset($_menu['items'])) {
- // _menu_build() may indirectly call this function, so prevent infinite loops.
- $_menu['items'] = array();
-
- $cid = "$user->uid:$locale";
- if ($cached = cache_get($cid, 'cache_menu')) {
- $_menu = unserialize($cached->data);
+ * Returns the ancestors (and relevant placeholders) for any given path.
+ *
+ * For example, the ancestors of node/12345/edit are:
+ *
+ * node/12345/edit
+ * node/12345/%
+ * node/%/edit
+ * node/%/%
+ * node/12345
+ * node/%
+ * node
+ *
+ * To generate these, we will use binary numbers. Each bit represents a
+ * part of the path. If the bit is 1, then it represents the original
+ * value while 0 means wildcard. If the path is node/12/edit/foo
+ * then the 1011 bitstring represents node/%/edit/foo where % means that
+ * any argument matches that part.
+ *
+ * @param $parts
+ * An array of path parts, for the above example
+ * array('node', '12345', 'edit').
+ * @return
+ * An array which contains the ancestors and placeholders. Placeholders
+ * simply contain as many %s as the ancestors.
+ */
+function menu_get_ancestors($parts) {
+ $n1 = count($parts);
+ $placeholders = array();
+ $ancestors = array();
+ $end = (1 << $n1) - 1;
+ $length = $n1 - 1;
+ for ($i = $end; $i > 0; $i--) {
+ $current = '';
+ $count = 0;
+ for ($j = $length; $j >= 0; $j--) {
+ if ($i & (1 << $j)) {
+ $count++;
+ $current .= $parts[$length - $j];
+ }
+ else {
+ $current .= '%';
+ }
+ if ($j) {
+ $current .= '/';
+ }
}
- else {
- _menu_build();
- // Cache the menu structure for this user, to expire after one day.
- cache_set($cid, 'cache_menu', serialize($_menu), time() + (60 * 60 * 24));
+ // If the number was like 10...0 then the next number will be 11...11,
+ // one bit less wide.
+ if ($count == 1) {
+ $length--;
}
-
- // Make sure items that cannot be cached are added.
- _menu_append_contextual_items();
-
- // Reset the cached $menu in menu_get_item().
- menu_get_item(NULL, NULL, TRUE);
+ $placeholders[] = "'%s'";
+ $ancestors[] = $current;
}
-
- return $_menu;
+ return array($ancestors, $placeholders);
}
/**
- * Return the local task tree.
+ * The menu system uses serialized arrays stored in the database for
+ * arguments. However, often these need to change according to the
+ * current path. This function unserializes such an array and does the
+ * necessary change.
*
- * Unlike the rest of the menu structure, the local task tree cannot be cached
- * nor determined too early in the page request, because the user's current
- * location may be changed by a menu_set_location() call, and the tasks shown
- * (just as the breadcrumb trail) need to reflect the changed location.
- */
-function menu_get_local_tasks() {
- global $_menu;
-
- // Don't cache the local task tree, as it varies by location and tasks are
- // allowed to be dynamically determined.
- if (!isset($_menu['local tasks'])) {
- // _menu_build_local_tasks() may indirectly call this function, so prevent
- // infinite loops.
- $_menu['local tasks'] = array();
- $pid = menu_get_active_nontask_item();
- if (!_menu_build_local_tasks($pid)) {
- // If the build returned FALSE, the tasks need not be displayed.
- $_menu['local tasks'][$pid]['children'] = array();
- }
- }
-
- return $_menu['local tasks'];
-}
-
-/**
- * Retrieves the menu item specified by $mid, or by $path if $mid is not given.
- *
- * @param $mid
- * The menu ID of the menu item to retrieve.
- * @param $path
- * The internal path of the menu item to retrieve. Defaults to NULL. Only
- * used if $mid is not set.
- * @param $reset
- * Optional flag that resets the static variable cache of the menu tree, if
- * set to TRUE. Default is FALSE.
+ * Integer values are mapped according to the $map parameter. For
+ * example, if unserialize($data) is array('node_load', 1) and $map is
+ * array('node', '12345') then 'node_load' will not be changed
+ * because it is not an integer, but 1 will as it is an integer. As
+ * $map[1] is '12345', 1 will be replaced with '12345'. So the result
+ * will be array('node_load', '12345').
*
+ * @param @data
+ * A serialized array.
+ * @param @map
+ * An array of potential replacements.
* @return
- * The menu item found in the site menu, or an empty array if none could be
- * found.
+ * The $data array unserialized and mapped.
*/
-function menu_get_item($mid, $path = NULL, $reset = FALSE) {
- static $menu;
-
- if (!isset($menu) || $reset) {
- $menu = menu_get_menu();
- }
-
- if (isset($mid)) {
- return $menu['items'][$mid];
+function menu_unserialize($data, $map) {
+ if ($data = unserialize($data)) {
+ foreach ($data as $k => $v) {
+ if (is_int($v)) {
+ $data[$k] = isset($map[$v]) ? $map[$v] : '';
+ }
+ }
+ return $data;
}
-
- if (isset($path)) {
- return $menu['items'][$menu['path index'][$path]];
+ else {
+ return array();
}
-
- return array();
}
/**
- * Retrieves the menu ID and title of all root menus.
+ * Replaces the statically cached item for a given path.
*
- * @return
- * Array containing all menus (but not menu items), in the form mid => title.
+ * @param $path
+ * The path
+ * @param $item
+ * The menu item. This is a menu entry, an associative array,
+ * with keys like title, access callback, access arguments etc.
*/
-function menu_get_root_menus() {
- $menu = menu_get_menu();
- $root_menus = array();
-
- foreach ($menu['items'][0]['children'] as $mid) {
- $root_menus[$mid] = $menu['items'][$mid]['title'];
- }
-
- return $root_menus;
+function menu_set_item($path, $item) {
+ menu_get_item($path, TRUE, $item);
}
-/**
- * Change the current menu location of the user.
- *
- * Frequently, modules may want to make a page or node act as if it were
- * in the menu tree somewhere, even though it was not registered in a
- * hook_menu() implementation. If the administrator has rearranged the menu,
- * the newly set location should respect this in the breadcrumb trail and
- * expanded/collapsed status of menu items in the tree. This function
- * allows this behavior.
- *
- * @param $location
- * An array specifying a complete or partial breadcrumb trail for the
- * new location, in the same format as the return value of hook_menu().
- * The last element of this array should be the new location itself.
- *
- * This function will set the new breadcrumb trail to the passed-in value,
- * but if any elements of this trail are visible in the site tree, the
- * trail will be "spliced in" to the existing site navigation at that point.
- */
-function menu_set_location($location) {
- global $_menu;
- $temp_id = min(array_keys($_menu['items'])) - 1;
- $prev_id = 0;
-
- // Don't allow this function to change the actual current path, just the
- // position in the menu tree.
- $location[count($location) - 1]['path'] = $_GET['q'];
-
- foreach (array_reverse($location) as $item) {
- if (isset($_menu['path index'][$item['path']])) {
- $mid = $_menu['path index'][$item['path']];
- if (isset($_menu['visible'][$mid])) {
- // Splice in the breadcrumb at this location.
- if ($prev_id) {
- $_menu['items'][$prev_id]['pid'] = $mid;
- }
- $prev_id = 0;
- break;
- }
- else {
- // A hidden item; show it, but only temporarily.
- $_menu['items'][$mid]['type'] |= MENU_VISIBLE_IN_BREADCRUMB;
- if ($prev_id) {
- $_menu['items'][$prev_id]['pid'] = $mid;
- }
- $prev_id = $mid;
+function menu_get_item($path = NULL, $execute = TRUE, $item = NULL) {
+ static $items;
+ if (!isset($path)) {
+ $path = $_GET['q'];
+ }
+ if (isset($item)) {
+ $items[$path] = $item;
+ }
+ if (!isset($items[$path])) {
+ $map = arg(NULL, $path);
+ $parts = array_slice($map, 0, 6);
+ list($ancestors, $placeholders) = menu_get_ancestors($parts);
+ if ($item = db_fetch_object(db_query_range('SELECT * FROM {menu} WHERE path IN ('. implode (',', $placeholders) .') ORDER BY fit DESC', $ancestors, 0, 1))) {
+ $item->access = _menu_access($item, $map);
+ if ($map === FALSE) {
+ $items[$path] = FALSE;
+ return FALSE;
}
- }
- else {
- $item['type'] |= MENU_VISIBLE_IN_BREADCRUMB;
- if ($prev_id) {
- $_menu['items'][$prev_id]['pid'] = $temp_id;
+ if ($execute) {
+ $item->page_arguments = array_merge(menu_unserialize($item->page_arguments, $map), array_slice($parts, $item->number_parts));
}
- $_menu['items'][$temp_id] = $item;
- $_menu['path index'][$item['path']] = $temp_id;
-
- $prev_id = $temp_id;
- $temp_id--;
}
+ $items[$path] = $item;
}
-
- if ($prev_id) {
- // Didn't find a home, so attach this to the main navigation menu.
- $_menu['items'][$prev_id]['pid'] = 1;
- }
-
- $final_item = array_pop($location);
- menu_set_active_item($final_item['path']);
+ return $items[$path];
}
/**
* Execute the handler associated with the active menu item.
- *
- * This is called early in the page request. The active menu item is at
- * this point determined exclusively by the URL. The handler that is called
- * here may, as a side effect, change the active menu item so that later
- * menu functions (that display the menus and breadcrumbs, for example)
- * act as if the user were in a different location on the site.
*/
function menu_execute_active_handler() {
- if (_menu_site_is_offline()) {
- return MENU_SITE_OFFLINE;
- }
-
- $menu = menu_get_menu();
-
- // Determine the menu item containing the callback.
- $path = $_GET['q'];
- while ($path && !isset($menu['callbacks'][$path])) {
- $path = substr($path, 0, strrpos($path, '/'));
- }
-
- if (!isset($menu['callbacks'][$path])) {
- return MENU_NOT_FOUND;
+ if ($item = menu_get_item()) {
+ return $item->access ? call_user_func_array($item->page_callback, $item->page_arguments) : MENU_ACCESS_DENIED;
}
+ return MENU_NOT_FOUND;
+}
- if (!function_exists($menu['callbacks'][$path]['callback'])) {
- return MENU_NOT_FOUND;
+function _menu_access($item, &$map) {
+ if ($item->map_callback) {
+ $map = call_user_func_array($item->map_callback, array_merge(array($map), unserialize($item->map_arguments)));
+ if ($map === FALSE) {
+ return FALSE;
+ }
}
-
- if (!_menu_item_is_accessible(menu_get_active_item())) {
- return MENU_ACCESS_DENIED;
+ $callback = $item->access_callback;
+ if (is_numeric($callback)) {
+ return $callback;
}
-
- // We found one, and are allowed to execute it.
- $arguments = isset($menu['callbacks'][$path]['callback arguments']) ? $menu['callbacks'][$path]['callback arguments'] : array();
- $arg = substr($_GET['q'], strlen($path) + 1);
- if (strlen($arg)) {
- $arguments = array_merge($arguments, explode('/', $arg));
+ $arguments = menu_unserialize($item->access_arguments, $map);
+ // As call_user_func_array is quite slow and user_access is a very common
+ // callback, it is worth making a special case for it.
+ if ($callback == 'user_access') {
+ return (count($arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]);
}
-
- return call_user_func_array($menu['callbacks'][$path]['callback'], $arguments);
+ return call_user_func_array($callback, $arguments);
}
/**
- * Returns the ID of the active menu item.
+ * Returns a rendered menu tree.
*/
-function menu_get_active_item() {
- return menu_set_active_item();
+function menu_tree() {
+ $item = menu_get_item();
+ list(, $menu) = _menu_tree(db_query('SELECT * FROM {menu} WHERE pid IN ('. $item->parents .') AND visible = 1 ORDER BY vancode'));
+ return $menu;
}
-/**
- * Sets the path of the active menu item.
- */
-function menu_set_active_item($path = NULL) {
- static $stored_mid;
-
- if (!isset($stored_mid) || isset($path)) {
- if (!isset($path)) {
- $path = $_GET['q'];
+function _menu_tree($result = NULL, $depth = 0, $link = array('link' => '', 'has_children' => FALSE)) {
+ static $original_map;
+ $remnant = array('link' => '', 'has_children' => FALSE);
+ $tree = '';
+ while ($item = db_fetch_object($result)) {
+ $map = arg(NULL, $item->path);
+ if (!_menu_access($item, $map)) {
+ continue;
}
- else {
- $_GET['q'] = $path;
+ $menu_link = array('link' => $item->menu_link, 'has_children' => $item->has_children);
+ if ($item->depth > $depth) {
+ list($remnant, $menu) = _menu_tree($result, $item->depth, $menu_link);
+ $tree .= theme('menu_tree', $link, $menu);
+ $link = $remnant;
+ $remnant = '';
}
- $menu = menu_get_menu();
-
- while ($path && !isset($menu['path index'][$path])) {
- $path = substr($path, 0, strrpos($path, '/'));
+ elseif ($item->depth == $depth) {
+ $tree .= theme('menu_link', $link);
+ $link = $menu_link;
}
- $stored_mid = isset($menu['path index'][$path]) ? $menu['path index'][$path] : 0;
-
- // Search for default local tasks to activate instead of this item.
- $continue = TRUE;
- while ($continue) {
- $continue = FALSE;
- if (isset($menu['items'][$stored_mid]['children'])) {
- foreach ($menu['items'][$stored_mid]['children'] as $cid) {
- if ($menu['items'][$cid]['type'] & MENU_LINKS_TO_PARENT) {
- $stored_mid = $cid;
- $continue = TRUE;
- }
- }
- }
+ else {
+ $remnant = $menu_link;
+ break;
}
-
- // Reset the cached $menu in menu_get_item().
- menu_get_item(NULL, NULL, TRUE);
}
-
- return $stored_mid;
+ if ($link['link']) {
+ $tree .= theme('menu_link', $link);
+ }
+ return array($remnant, $tree);
}
/**
- * Returns the ID of the current menu item or, if the current item is a
- * local task, the menu item to which this task is attached.
+ * Generate the HTML for a menu tree.
*/
-function menu_get_active_nontask_item() {
- $mid = menu_get_active_item();
-
- // Find the first non-task item:
- while ($mid) {
- $item = menu_get_item($mid);
-
- if (!($item['type'] & MENU_IS_LOCAL_TASK)) {
- return $mid;
- }
-
- $mid = $item['pid'];
- }
+function theme_menu_tree($link, $tree) {
+ $tree = '<ul class="menu">'. $tree .'</ul>';
+ return $link['link'] ? theme('menu_link', $link, $tree) : $tree;
}
/**
- * Returns the title of the active menu item.
+ * Generate the HTML for a menu link.
*/
-function menu_get_active_title() {
- if ($mid = menu_get_active_nontask_item()) {
- $item = menu_get_item($mid);
- return $item['title'];
- }
+function theme_menu_link($link, $menu = '') {
+ return '<li class="'. ($menu ? 'expanded' : ($link['has_children'] ? 'collapsed' : 'leaf')) .'">'. $link['link'] . $menu .'</li>' . "\n";
}
/**
@@ -501,8 +394,9 @@ function menu_get_active_title() {
function menu_get_active_help() {
$path = $_GET['q'];
$output = '';
+ $item = menu_get_item();
- if (!_menu_item_is_accessible(menu_get_active_item())) {
+ if (!$item->access) {
// Don't return help text for areas the user cannot access.
return;
}
@@ -510,7 +404,7 @@ function menu_get_active_help() {
foreach (module_list() as $name) {
if (module_hook($name, 'help')) {
if ($temp = module_invoke($name, 'help', $path)) {
- $output .= $temp . "\n";
+ $output .= $temp ."\n";
}
if (module_hook('help', 'page')) {
if (arg(0) == "admin") {
@@ -525,868 +419,166 @@ function menu_get_active_help() {
}
/**
- * Returns an array of rendered menu items in the active breadcrumb trail.
- */
-function menu_get_active_breadcrumb() {
-
- // No breadcrumb for the front page.
- if (drupal_is_front_page()) {
- return array();
- }
-
- // We do *not* want to use "variable_get('site_frontpage', 'node)" here
- // as that will create the link '/node'. This is unsightly and creates
- // a second URL for the homepage ('/' *and* '/node').
- $links[] = l(t('Home'), '');
-
- $trail = _menu_get_active_trail();
- foreach ($trail as $mid) {
- $item = menu_get_item($mid);
- if ($item['type'] & MENU_VISIBLE_IN_BREADCRUMB) {
- $links[] = menu_item_link($mid);
- }
- }
-
- // The last item in the trail is the page title; don't display it here.
- array_pop($links);
-
- return $links;
-}
-
-/**
- * Returns TRUE when the menu item is in the active trail.
- */
-function menu_in_active_trail($mid) {
- $trail = _menu_get_active_trail();
-
- return in_array($mid, $trail);
-}
-
-/**
- * Returns TRUE when the menu item is in the active trail within a
- * specific subsection of the menu tree.
- *
- * @param $mid
- * The menu item being considered.
- * @param $pid
- * The root of the subsection of the menu tree in which to look.
- */
-function menu_in_active_trail_in_submenu($mid, $pid) {
- $trail = _menu_get_active_trail_in_submenu($pid);
-
- if (!$trail) {
- return FALSE;
- }
-
- return in_array($mid, $trail);
-}
-
-/**
* Populate the database representation of the menu.
- *
- * This need only be called at the start of pages that modify the menu.
*/
function menu_rebuild() {
- // Clear the page cache, so that changed menus are reflected for anonymous users.
- cache_clear_all('*', 'cache_page', TRUE);
- // Also clear the menu cache.
- cache_clear_all('*', 'cache_menu', TRUE);
-
- _menu_build();
-
- if (module_exists('menu')) {
- $menu = menu_get_menu();
-
- // Fill a queue of new menu items which are modifiable.
- $new_items = array();
- foreach ($menu['items'] as $mid => $item) {
- if ($mid < 0 && ($item['type'] & MENU_MODIFIABLE_BY_ADMIN)) {
- $new_items[$mid] = $item;
- }
+ $next = array();
+ db_query('DELETE FROM {menu}');
+ $menu = module_invoke_all('menu');
+ foreach (module_implements('menu_alter') as $module) {
+ $function = $module .'_menu_alter';
+ $function($menu);
+ }
+ $mid = 1;
+ // First pass.
+ foreach ($menu as $path => $item) {
+ $item = &$menu[$path];
+ $parts = explode('/', $path, 6);
+ $number_parts = count($parts);
+ // We store the highest index of parts here to save some work in the weight
+ // calculation loop.
+ $slashes = $number_parts - 1;
+ // If there is no %, it fits maximally.
+ if (strpos($path, '%') === FALSE) {
+ $fit = (1 << $number_parts) - 1;
}
-
- $old_count = -1;
- // Save the new items updating the pids in each iteration
- while (($c = count($new_items)) && ($c != $old_count)) {
- $old_count = count($new_items);
- foreach ($new_items as $mid => $item) {
- // If the item has a valid parent, save it
- if ($item['pid'] >= 0) {
- // The new menu ID gets passed back by reference as $item['mid']
- menu_save_item($item);
- // Fix parent IDs for the children of the menu item just saved
- if ($item['children']) {
- foreach ($item['children'] as $child) {
- if (isset($new_items[$child])) {
- $new_items[$child]['pid'] = $item['mid'];
- }
- }
+ else {
+ // We need to calculate the fitness.
+ $fit = 0;
+ foreach ($parts as $k => $part) {
+ // ($part != '%') is the bit we want and we shift it to its place
+ // by shifting to left by ($slashes - $k) bits.
+ $fit |= ($part != '%') << ($slashes - $k);
+ }
+ }
+ if (!isset($item['_visible'])) {
+ $item['_visible'] = (!isset($item['type']) || ($item['type'] & MENU_VISIBLE_IN_TREE)) ? 1 : 0;
+ }
+ $depth = 1;
+ if (!isset($item['_mid'])) {
+ $item['_mid'] = $mid++;
+ }
+ $parents = array($item['_mid']);
+ for ($i = $slashes; $i; $i--) {
+ $parent_path = implode('/', array_slice($parts, 0, $i));
+ // We need to calculate depth to be able to sort. depth needs visibility.
+ if (isset($menu[$parent_path])) {
+ $parent = &$menu[$parent_path];
+ // It's possible that the parent was not processed yet.
+ if (!isset($parent['_mid'])) {
+ $parent['_mid'] = $mid++;
+ }
+ if (!isset($parent['_visible'])) {
+ $parent['_visible'] = (!isset($parent['type']) || ($parent['type'] & MENU_VISIBLE_IN_TREE)) ? 1 : 0;
+ }
+ if ($item['_visible'] && $parent['_visible']) {
+ $parent['_has_children'] = 1;
+ $depth++;
+ $parents[] = $parent['_mid'];
+ if (!isset($item['_pid'])) {
+ $item['_pid'] = $parent['_mid'];
+ $item['_visible_parent_path'] = $parent_path;
}
- // remove the item
- unset($new_items[$mid]);
}
- }
- }
- // Rebuild the menu to account for the changes.
- _menu_build();
- }
-
- // Reset the cached $menu in menu_get_item().
- menu_get_item(NULL, NULL, TRUE);
-
-}
-
-/**
- * Generate the HTML for a menu tree.
- *
- * @param $pid
- * The parent id of the menu.
- *
- * @ingroup themeable
- */
-function theme_menu_tree($pid = 1) {
- if ($tree = menu_tree($pid)) {
- return "\n<ul class=\"menu\">\n". $tree ."\n</ul>\n";
- }
-}
-
-/**
- * Returns a rendered menu tree.
- *
- * @param $pid
- * The parent id of the menu.
- */
-function menu_tree($pid = 1) {
- $menu = menu_get_menu();
- $output = '';
-
- if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) {
- foreach ($menu['visible'][$pid]['children'] as $mid) {
- $type = isset($menu['visible'][$mid]['type']) ? $menu['visible'][$mid]['type'] : NULL;
- $children = isset($menu['visible'][$mid]['children']) ? $menu['visible'][$mid]['children'] : NULL;
- $output .= theme('menu_item', $mid, menu_in_active_trail($mid) || ($type & MENU_EXPANDED) ? theme('menu_tree', $mid) : '', count($children) == 0);
- }
- }
-
- return $output;
-}
-
-/**
- * Generate the HTML output for a single menu item.
- *
- * @param $mid
- * The menu id of the item.
- * @param $children
- * A string containing any rendered child items of this menu.
- * @param $leaf
- * A boolean indicating whether this menu item is a leaf.
- *
- * @ingroup themeable
- */
-function theme_menu_item($mid, $children = '', $leaf = TRUE) {
- return '<li class="'. ($leaf ? 'leaf' : ($children ? 'expanded' : 'collapsed')) .'">'. menu_item_link($mid) . $children ."</li>\n";
-}
-
-/**
- * Generate the HTML representing a given menu item ID.
- *
- * @param $item
- * The menu item to render.
- * @param $link_item
- * The menu item which should be used to find the correct path.
- *
- * @ingroup themeable
- */
-function theme_menu_item_link($item, $link_item) {
- return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);
-}
-
-/**
- * Returns the rendered link to a menu item.
- *
- * @param $mid
- * The menu item id to render.
- * @param $theme
- * Whether to return a themed link or the link as an array
- */
-function menu_item_link($mid, $theme = TRUE) {
- $item = menu_get_item($mid);
- $link_item = $item;
- $link = '';
-
- while ($link_item['type'] & MENU_LINKS_TO_PARENT) {
- $link_item = menu_get_item($link_item['pid']);
- }
-
- if ($theme) {
- $link = theme('menu_item_link', $item, $link_item);
- }
- else {
- $link = array(
- 'title' => $item['title'],
- 'href' => $link_item['path'],
- 'attributes' => !empty($item['description']) ? array('title' => $item['description']) : array()
+ unset($parent);
+ }
+ }
+ $parents[] = 0;
+ $parents = implode(',', array_reverse($parents));
+ // Store variables and set defaults.
+ $item += array(
+ '_fit' => $fit,
+ '_number_parts' => $number_parts,
+ '_parts' => $parts,
+ '_pid' => 0,
+ '_depth' => $depth,
+ '_parents' => $parents,
+ '_has_children' => 0,
+ 'title' => '',
+ 'weight' => 0,
);
- }
-
- return $link;
-}
-
-/**
- * Returns the rendered local tasks. The default implementation renders
- * them as tabs.
- *
- * @ingroup themeable
- */
-function theme_menu_local_tasks() {
- $output = '';
-
- if ($primary = menu_primary_local_tasks()) {
- $output .= "<ul class=\"tabs primary\">\n". $primary ."</ul>\n";
- }
- if ($secondary = menu_secondary_local_tasks()) {
- $output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
- }
-
- return $output;
-}
-
-/**
- * Returns the rendered HTML of the primary local tasks.
- */
-function menu_primary_local_tasks() {
- $local_tasks = menu_get_local_tasks();
- $pid = menu_get_active_nontask_item();
- $output = '';
-
- if (count($local_tasks[$pid]['children'])) {
- foreach ($local_tasks[$pid]['children'] as $mid) {
- $output .= theme('menu_local_task', $mid, menu_in_active_trail($mid), TRUE);
- }
- }
-
- return $output;
-}
-
-/**
- * Returns the rendered HTML of the secondary local tasks.
- */
-function menu_secondary_local_tasks() {
- $local_tasks = menu_get_local_tasks();
- $pid = menu_get_active_nontask_item();
- $output = '';
-
- if (count($local_tasks[$pid]['children'])) {
- foreach ($local_tasks[$pid]['children'] as $mid) {
- if (menu_in_active_trail($mid) && count($local_tasks[$mid]['children']) > 1) {
- foreach ($local_tasks[$mid]['children'] as $cid) {
- $output .= theme('menu_local_task', $cid, menu_in_active_trail($cid), FALSE);
+ $sort[$path] = ($item['_visible'] ? $depth : $number_parts) . sprintf('%05d', $item['weight']) . $item['title'];
+ unset($item);
+ }
+ array_multisort($sort, $menu);
+ // Second pass: calculate ancestors, vancode and store into the database.
+ foreach ($menu as $path => $item) {
+ $item = &$menu[$path];
+ for ($i = $item['_number_parts'] - 1; $i; $i--) {
+ $parent_path = implode('/', array_slice($item['_parts'], 0, $i));
+ if (isset($menu[$parent_path])) {
+ $parent = $menu[$parent_path];
+ // If a callback is not found, we try to find the first parent that
+ // has this callback. When found, its callback argument will also be
+ // copied but only if there is none in the current item.
+ foreach (array('access', 'map', 'page') as $type) {
+ if (!isset($item["$type callback"]) && isset($parent["$type callback"])) {
+ $item["$type callback"] = $parent["$type callback"];
+ if (!isset($item["$type arguments"]) && isset($parent["$type arguments"])) {
+ $item["$type arguments"] = $parent["$type arguments"];
+ }
+ }
}
}
}
- }
-
- return $output;
-}
-
-/**
- * Generate the HTML representing a given menu item ID as a tab.
- *
- * @param $mid
- * The menu ID to render.
- * @param $active
- * Whether this tab or a subtab is the active menu item.
- * @param $primary
- * Whether this tab is a primary tab or a subtab.
- *
- * @ingroup themeable
- */
-function theme_menu_local_task($mid, $active, $primary) {
- if ($active) {
- return '<li class="active">'. menu_item_link($mid) ."</li>\n";
- }
- else {
- return '<li>'. menu_item_link($mid) ."</li>\n";
- }
-}
-
-/**
- * Returns an array containing the primary links.
- * Can optionally descend from the root of the Primary links menu towards the
- * current node for a specified number of levels and return that submenu.
- * Used to generate a primary/secondary menu from different levels of one menu.
- *
- * @param $start_level
- * This optional parameter can be used to retrieve a context-sensitive array
- * of links at $start_level levels deep into the Primary links menu.
- * The default is to return the top-level links.
- * @param $pid
- * The parent menu ID from which to search for children. Defaults to the
- * menu_primary_menu setting.
- * @return A nested array of links and their properties. The keys of
- * the array contain some extra encoded information about the results.
- * The format of the key is {level}-{num}{-active}.
- * level is the depth within the menu tree of this list.
- * num is the number within this array, used only to make the key unique.
- * -active is appended if this element is in the active trail.
- */
-function menu_primary_links($start_level = 1, $pid = 0) {
- if (!module_exists('menu')) {
- return NULL;
- }
- if (!$pid) {
- $pid = variable_get('menu_primary_menu', 0);
- }
- if (!$pid) {
- return NULL;
- }
-
- if ($start_level < 1) {
- $start_level = 1;
- }
-
- if ($start_level > 1) {
- $trail = _menu_get_active_trail_in_submenu($pid);
- if (!$trail) {
- return NULL;
+ if (!isset($item['access callback'])) {
+ $menu[$path]['access callback'] = isset($item['access arguments']) ? 'user_access' : 0;
}
- else {
- $pid = $trail[$start_level - 1];
+ if (!isset($item['map callback']) && isset($item['map arguments'])) {
+ $item['map callback'] = 'menu_map';
}
- }
-
- $menu = menu_get_menu();
- $links = array();
- if ($pid && is_array($menu['visible'][$pid]) && isset($menu['visible'][$pid]['children'])) {
- $count = 1;
- foreach ($menu['visible'][$pid]['children'] as $cid) {
- $index = "menu-$start_level-$count-$pid";
- if (menu_in_active_trail_in_submenu($cid, $pid)) {
- $index .= "-active";
+ foreach (array('access', 'map', 'page') as $type) {
+ if (isset($item["$type callback"]) && !isset($item["$type arguments"])) {
+ $item["$type arguments"] = array();
}
- $links[$index] = menu_item_link($cid, FALSE);
- $count++;
}
- }
-
- // Special case - provide link to admin/build/menu if primary links is empty.
- if (empty($links) && $start_level == 1 && $pid == variable_get('menu_primary_menu', 0) && user_access('administer menu')) {
- $links['1-1'] = array(
- 'title' => t('Edit primary links'),
- 'href' => 'admin/build/menu'
- );
- }
-
- return $links;
-}
-
-/**
- * Returns an array containing the secondary links.
- * Secondary links can be either a second level of the Primary links
- * menu or generated from their own menu.
- */
-function menu_secondary_links() {
- $msm = variable_get('menu_secondary_menu', 0);
- if ($msm == 0) {
- return NULL;
- }
-
- if ($msm == variable_get('menu_primary_menu', 0)) {
- return menu_primary_links(2, $msm);
- }
-
- return menu_primary_links(1, $msm);
-}
-
-/**
- * Returns the themed HTML for primary and secondary links.
- * Note that this function is overridden by most core themes because
- * those themes display links in "link | link" format, not from a list.
- * Also note that by default links rendered with this function are
- * displayed with the same CSS as is used for the local tasks.
- * If a theme wishes to render links from a ul it is expected that
- * the theme will provide suitable CSS.
- *
- * @param $links
- * An array containing links to render.
- * @return
- * A string containing the themed links.
- *
- * @ingroup themeable
- */
-function theme_menu_links($links) {
- if (!count($links)) {
- return '';
- }
- $level_tmp = explode('-', key($links));
- $level = $level_tmp[0];
- $output = "<ul class=\"links-$level\">\n";
- foreach ($links as $index => $link) {
- $output .= '<li';
- if (stristr($index, 'active')) {
- $output .= ' class="active"';
- }
- $output .= ">". l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']) ."</li>\n";
- }
- $output .= '</ul>';
-
- return $output;
-}
-
-/**
- * @} End of "defgroup menu".
- */
-
-/**
- * Returns an array with the menu items that lead to the current menu item.
- */
-function _menu_get_active_trail() {
- static $trail;
-
- if (!isset($trail)) {
- $trail = array();
-
- $mid = menu_get_active_item();
-
- // Follow the parents up the chain to get the trail.
- while ($mid && ($item = menu_get_item($mid))) {
- array_unshift($trail, $mid);
- $mid = $item['pid'];
+ if (is_bool($item['access callback'])) {
+ $item['access callback'] = intval($item['access callback']);
}
- }
- return $trail;
-}
-
-/**
- * Find the active trail through a specific subsection of the menu tree.
- *
- * @param $pid
- * The root item from which the active trail must descend.
- */
-function _menu_get_active_trail_in_submenu($pid) {
- static $trails;
-
- if (!isset($trails)) {
- // Find all menu items which point to the current node and for each
- // follow the parents up the chain to build an active trail.
- $trails = array();
- $menu = menu_get_menu();
- $path = $_GET['q'];
- $count = 0;
- while ($path && !$count) {
- foreach ($menu['items'] as $key => $item) {
- if (isset($item['path']) && $item['path'] == $path) {
- $trails[$count] = array();
- $mid = $key;
- while ($mid && $menu['items'][$mid]) {
- array_unshift($trails[$count], $mid);
- $mid = $menu['items'][$mid]['pid'];
- }
- $count ++;
- }
+ if ($item['_visible']) {
+ $prefix = isset($item['_visible_parent_path']) ? $menu[$item['_visible_parent_path']]['_prefix'] : '';
+ if (!isset($next[$prefix])) {
+ $next[$prefix] = 0;
}
- $path = substr($path, 0, strrpos($path, '/'));
+ $vancode = $prefix . int2vancode($next[$prefix]++);
+ $menu[$path]['_prefix'] = $vancode .'.';
+ $link = l($item['title'], $path, isset($item['attributes']) ? $item['attributes'] : array(), isset($item['query']) ? $item['query'] : NULL, isset($item['fragment']) ? $item['fragment'] : NULL);
}
- }
-
- if ($trails) {
- foreach ($trails as $trail) {
- $count_trail = count($trail);
- for ($i = 0; $i < $count_trail; $i++) {
- if ($trail[$i] == $pid) {
- // Return a trail from $pid down to the current page inclusive.
- for ( ; $i < $count_trail; $i++) {
- $subtrail[] = $trail[$i];
- }
- return $subtrail;
- }
- }
+ else {
+ $vancode = '';
+ $link = '';
}
+ db_query("INSERT INTO {menu} (mid, pid, path, access_callback, access_arguments, page_callback, page_arguments, map_callback, map_arguments, fit, number_parts, vancode, menu_link, visible, parents, depth, has_children) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, '%s', %d, %d)", $item['_mid'], $item['_pid'], $path, $item['access callback'], serialize($item['access arguments']), $item['page callback'], serialize($item['page arguments']), $item['map callback'], serialize($item['map arguments']), $item['_fit'], $item['_number_parts'], $vancode .'+', $link, $item['_visible'], $item['_parents'], $item['_depth'], $item['_has_children']);
+ // $item needs to be unset because of the reference above.
+ unset($item);
}
-
- return NULL;
}
-/**
- * Comparator routine for use in sorting menu items.
- */
-function _menu_sort($a, $b) {
- $menu = menu_get_menu();
-
- $a = $menu['items'][$a];
- $b = $menu['items'][$b];
-
- if ($a['weight'] < $b['weight']) {
- return -1;
- }
- elseif ($a['weight'] > $b['weight']) {
- return 1;
- }
- elseif (isset($a['title']) && isset($b['title'])) {
- return strnatcasecmp($a['title'], $b['title']);
- }
- else {
- return 1;
- }
+function menu_map($arg, $function, $index, $default = FALSE) {
+ $arg[$index] = is_numeric($arg[$index]) ? $function($arg[$index]) : $default;
+ return $arg[$index] ? $arg : FALSE;
}
-/**
- * Build the menu by querying both modules and the database.
- */
-function _menu_build() {
- global $_menu;
- global $user;
-
- // Start from a clean slate.
- $_menu = array();
-
- $_menu['path index'] = array();
- // Set up items array, including default "Navigation" menu.
- $_menu['items'] = array(
- 0 => array('path' => '', 'title' => '', 'type' => MENU_IS_ROOT),
- 1 => array('pid' => 0, 'path' => '', 'title' => t('Navigation'), 'weight' => -50, 'access' => TRUE, 'type' => MENU_IS_ROOT | MENU_VISIBLE_IN_TREE)
- );
- $_menu['callbacks'] = array();
-
- // Build a sequential list of all menu items.
- $menu_item_list = module_invoke_all('menu', TRUE);
-
- // Menu items not in the DB get temporary negative IDs.
- $temp_mid = -1;
-
- foreach ($menu_item_list as $item) {
- if (!isset($item['path'])) {
- $item['path'] = '';
- }
- if (!isset($item['type'])) {
- $item['type'] = MENU_NORMAL_ITEM;
- }
- if (!isset($item['weight'])) {
- $item['weight'] = 0;
- }
- $mid = $temp_mid;
- if (isset($_menu['path index'][$item['path']])) {
- // Newer menu items overwrite older ones.
- unset($_menu['items'][$_menu['path index'][$item['path']]]);
- }
- if (isset($item['callback'])) {
- $_menu['callbacks'][$item['path']] = array('callback' => $item['callback']);
- if (isset($item['callback arguments'])) {
- $_menu['callbacks'][$item['path']]['callback arguments'] = $item['callback arguments'];
- unset($item['callback arguments']);
- }
- unset($item['callback']);
- }
- $_menu['items'][$mid] = $item;
- $_menu['path index'][$item['path']] = $mid;
-
- $temp_mid--;
- }
-
- // Now fetch items from the DB, reassigning menu IDs as needed.
- if (module_exists('menu')) {
- $result = db_query(db_rewrite_sql('SELECT m.mid, m.* FROM {menu} m ORDER BY m.mid ASC', 'm', 'mid'));
- while ($item = db_fetch_object($result)) {
- // Handle URL aliases if entered in menu administration.
- if (!isset($_menu['path index'][$item->path])) {
- $item->path = drupal_get_normal_path($item->path);
- }
- if (isset($_menu['path index'][$item->path])) {
- // The path is already declared.
- $old_mid = $_menu['path index'][$item->path];
- if ($old_mid < 0) {
- // It had a temporary ID, so use a permanent one.
- $_menu['items'][$item->mid] = $_menu['items'][$old_mid];
- if ($_menu['items'][$item->mid]['type'] & $item->type) {
- // If the item is of the same type, delete the old item.
- unset($_menu['items'][$old_mid]);
- $_menu['path index'][$item->path] = $item->mid;
- }
- // The new menu item gets all the custom type flags from the database
- $_menu['items'][$item->mid]['type'] &= $item->type;
- }
- else {
- // It has a permanent ID. Only replace with non-custom menu items.
- if ($item->type & MENU_CREATED_BY_ADMIN) {
- $_menu['items'][$item->mid] = array('path' => $item->path);
- }
- else {
- // Leave the old item around as a shortcut to this one.
- $_menu['items'][$item->mid] = $_menu['items'][$old_mid];
- $_menu['path index'][$item->path] = $item->mid;
- }
- }
- }
- else {
- // The path was not declared, so this is a custom item or an orphaned one.
- if ($item->type & MENU_CREATED_BY_ADMIN) {
- $_menu['items'][$item->mid] = array('path' => $item->path);
- if (!empty($item->path)) {
- $_menu['path index'][$item->path] = $item->mid;
- }
- }
- }
-
- // If the administrator has changed the item, reflect the change.
- if ($item->type & MENU_MODIFIED_BY_ADMIN) {
- $_menu['items'][$item->mid]['title'] = $item->title;
- $_menu['items'][$item->mid]['description'] = $item->description;
- $_menu['items'][$item->mid]['pid'] = $item->pid;
- $_menu['items'][$item->mid]['weight'] = $item->weight;
- $_menu['items'][$item->mid]['type'] = $item->type;
- }
- }
- }
-
- // Associate parent and child menu items.
- _menu_find_parents($_menu['items']);
-
- // Prepare to display trees to the user as required.
- _menu_build_visible_tree();
+// Placeholders.
+function menu_primary_links() {
}
-/**
- * Determine whether the given menu item is accessible to the current user.
- *
- * Use this instead of just checking the "access" property of a menu item
- * to properly handle items with fall-through semantics.
- */
-function _menu_item_is_accessible($mid) {
- $menu = menu_get_menu();
-
- // Follow the path up to find the first "access" attribute.
- $path = isset($menu['items'][$mid]['path']) ? $menu['items'][$mid]['path'] : NULL;
- while ($path && (!isset($menu['path index'][$path]) || !isset($menu['items'][$menu['path index'][$path]]['access']))) {
- $path = substr($path, 0, strrpos($path, '/'));
- }
- if (empty($path)) {
- // Items without any access attribute up the chain are denied, unless they
- // were created by the admin. They most likely point to non-Drupal directories
- // or to an external URL and should be allowed.
- return $menu['items'][$mid]['type'] & MENU_CREATED_BY_ADMIN;
- }
- return $menu['items'][$menu['path index'][$path]]['access'];
+function menu_secondary_links() {
}
-/**
- * Find all visible items in the menu tree, for ease in displaying to user.
- *
- * Since this is only for display, we only need title, path, and children
- * for each item.
- */
-function _menu_build_visible_tree($pid = 0) {
- global $_menu;
-
- if (isset($_menu['items'][$pid])) {
- $parent = $_menu['items'][$pid];
-
- $children = array();
- if (isset($parent['children'])) {
- usort($parent['children'], '_menu_sort');
- foreach ($parent['children'] as $mid) {
- $children = array_merge($children, _menu_build_visible_tree($mid));
- }
- }
- $visible = ($parent['type'] & MENU_VISIBLE_IN_TREE) ||
- ($parent['type'] & MENU_VISIBLE_IF_HAS_CHILDREN && count($children) > 0);
- $allowed = _menu_item_is_accessible($pid);
-
- if (($parent['type'] & MENU_IS_ROOT) || ($visible && $allowed)) {
- $_menu['visible'][$pid] = array('title' => $parent['title'], 'path' => $parent['path'], 'children' => $children, 'type' => $parent['type']);
- foreach ($children as $mid) {
- $_menu['visible'][$mid]['pid'] = $pid;
- }
- return array($pid);
- }
- else {
- return $children;
- }
- }
-
- return array();
+function menu_primary_local_tasks() {
}
-/**
- * Account for menu items that are only defined at certain paths, so will not
- * be cached.
- *
- * We don't support the full range of menu item options for these menu items. We
- * don't support MENU_VISIBLE_IF_HAS_CHILDREN, and we require parent items to be
- * declared before their children.
- */
-function _menu_append_contextual_items() {
- global $_menu;
-
- // Build a sequential list of all menu items.
- $menu_item_list = module_invoke_all('menu', FALSE);
-
- // Menu items not in the DB get temporary negative IDs.
- $temp_mid = min(array_keys($_menu['items'])) - 1;
- $new_items = array();
-
- foreach ($menu_item_list as $item) {
- if (isset($item['callback'])) {
- $_menu['callbacks'][$item['path']] = array('callback' => $item['callback']);
- if (isset($item['callback arguments'])) {
- $_menu['callbacks'][$item['path']]['callback arguments'] = $item['callback arguments'];
- unset($item['callback arguments']);
- }
- unset($item['callback']);
- }
- if (!isset($_menu['path index'][$item['path']])) {
- if (!isset($item['path'])) {
- $item['path'] = '';
- }
- if (!isset($item['type'])) {
- $item['type'] = MENU_NORMAL_ITEM;
- }
- if (!isset($item['weight'])) {
- $item['weight'] = 0;
- }
- $_menu['items'][$temp_mid] = $item;
- $_menu['path index'][$item['path']] = $temp_mid;
- $new_items[$temp_mid] = $item;
- $temp_mid--;
- }
- else {
- $mid = $_menu['path index'][$item['path']];
- if ($_menu['items'][$mid]['type'] & MENU_CREATED_BY_ADMIN) {
- $_menu['items'][$mid]['access'] = $item['access'];
- if (isset($_menu['items'][$mid]['callback'])) {
- $_menu['items'][$mid]['callback'] = $item['callback'];
- }
- if (isset($_menu['items'][$mid]['callback arguments'])) {
- $_menu['items'][$mid]['callback arguments'] = $item['callback arguments'];
- }
- }
- if ($item['type'] & MENU_LOCAL_TASK && !($_menu['items'][$mid]['type'] & MENU_LOCAL_TASK)) {
- // A local task is in the menu table and the path is already present
- $_menu['items'][$mid]['type'] = MENU_LOCAL_TASK;
- $new_items[$mid] = $item;
- }
- }
- }
-
- // Establish parent-child relationships.
- _menu_find_parents($new_items);
-
- // Add new items to the visible tree if necessary.
- foreach ($new_items as $mid => $item) {
- $item = $_menu['items'][$mid];
- if (($item['type'] & MENU_VISIBLE_IN_TREE) && _menu_item_is_accessible($mid)) {
- $pid = $item['pid'];
- while ($pid && !isset($_menu['visible'][$pid])) {
- $pid = $_menu['items'][$pid]['pid'];
- }
- $_menu['visible'][$mid] = array('title' => $item['title'], 'path' => $item['path'], 'pid' => $pid);
- $_menu['visible'][$pid]['children'][] = $mid;
- usort($_menu['visible'][$pid]['children'], '_menu_sort');
- }
- }
+function menu_secondary_local_tasks() {
}
-/**
- * Establish parent-child relationships.
- */
-function _menu_find_parents(&$items) {
- global $_menu;
-
- foreach ($items as $mid => $item) {
- if (!isset($item['pid'])) {
- // Parent's location has not been customized, so figure it out using the path.
- $parent = $item['path'];
- if ($parent) {
- do {
- $parent = substr($parent, 0, strrpos($parent, '/'));
- }
- while ($parent && !isset($_menu['path index'][$parent]));
- }
-
- $pid = $parent ? $_menu['path index'][$parent] : 1;
- $_menu['items'][$mid]['pid'] = $pid;
- }
- else {
- $pid = $item['pid'];
- }
-
- // Don't make root a child of itself.
- if ($mid) {
- if (isset ($_menu['items'][$pid])) {
- $_menu['items'][$pid]['children'][] = $mid;
- }
- else {
- // If parent is missing, it is a menu item that used to be defined
- // but is no longer. Default to a root-level "Navigation" menu item.
- $_menu['items'][1]['children'][] = $mid;
- }
- }
- }
+function menu_set_active_item() {
}
-/**
- * Find all the items in the current local task tree.
- *
- * Since this is only for display, we only need title, path, and children
- * for each item.
- *
- * At the close of this function, $_menu['local tasks'] is populated with the
- * menu items in the local task tree.
- *
- * @return
- * TRUE if the local task tree is forked. It does not need to be displayed
- * otherwise.
- */
-function _menu_build_local_tasks($pid) {
- global $_menu;
-
- $forked = FALSE;
-
- if (isset($_menu['items'][$pid])) {
- $parent = $_menu['items'][$pid];
-
- $children = array();
- if (isset($parent['children'])) {
- foreach ($parent['children'] as $mid) {
- if (($_menu['items'][$mid]['type'] & MENU_IS_LOCAL_TASK) && _menu_item_is_accessible($mid)) {
- $children[] = $mid;
- // Beware short-circuiting || operator!
- $forked = _menu_build_local_tasks($mid) || $forked;
- }
- }
- }
- usort($children, '_menu_sort');
- $forked = $forked || count($children) > 1;
-
- $_menu['local tasks'][$pid] = array('title' => $parent['title'], 'path' => $parent['path'], 'children' => $children);
- foreach ($children as $mid) {
- $_menu['local tasks'][$mid]['pid'] = $pid;
- }
- }
-
- return $forked;
+function menu_set_location() {
}
-/**
- * Returns TRUE if the site is off-line for maintenance.
- */
-function _menu_site_is_offline() {
- // Check if site is set to off-line mode
- if (variable_get('site_offline', 0)) {
- // Check if the user has administration privileges
- if (!user_access('administer site configuration')) {
- // Check if this is an attempt to login
- if (drupal_get_normal_path($_GET['q']) != 'user') {
- return TRUE;
- }
- }
- else {
- $offline_message = t('Operating in off-line mode.');
- $messages = drupal_set_message();
- // Ensure that the off-line message is displayed only once [allowing for page redirects].
- if (!isset($messages) || !isset($messages['status']) || !in_array($offline_message, $messages['status'])) {
- drupal_set_message($offline_message);
- }
- }
- }
- return FALSE;
+function menu_get_active_breadcrumb() {
+ return array(l(t('Home'), ''));
}
+
diff --git a/includes/module.inc b/includes/module.inc
index 84cb4653e..44aba1874 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -253,7 +253,6 @@ function module_enable($module_list) {
module_list(TRUE, FALSE);
// Force to regenerate the stored list of hook implementations.
module_implements('', FALSE, TRUE);
- cache_clear_all('*', 'cache_menu', TRUE);
}
foreach ($invoke_modules as $module) {
@@ -283,7 +282,6 @@ function module_disable($module_list) {
module_list(TRUE, FALSE);
// Force to regenerate the stored list of hook implementations.
module_implements('', FALSE, TRUE);
- cache_clear_all('*', 'cache_menu', TRUE);
}
}
diff --git a/includes/path.inc b/includes/path.inc
index b911dae60..4801458db 100644
--- a/includes/path.inc
+++ b/includes/path.inc
@@ -145,16 +145,20 @@ function drupal_get_normal_path($path) {
* The component specified by $index, or FALSE if the specified component was
* not found.
*/
-function arg($index) {
- static $arguments, $q;
+function arg($index = NULL, $path = NULL) {
+ static $arguments;
- if (empty($arguments) || $q != $_GET['q']) {
- $arguments = explode('/', $_GET['q']);
- $q = $_GET['q'];
+ if (!isset($path)) {
+ $path = $_GET['q'];
}
-
- if (isset($arguments[$index])) {
- return $arguments[$index];
+ if (!isset($arguments[$path])) {
+ $arguments[$path] = explode('/', $path);
+ }
+ if (!isset($index)) {
+ return $arguments[$path];
+ }
+ if (isset($arguments[$path][$index])) {
+ return $arguments[$path][$index];
}
}
diff --git a/install.php b/install.php
index ed6279e20..aee05e3fd 100644
--- a/install.php
+++ b/install.php
@@ -533,6 +533,7 @@ function install_complete($profile) {
// Bootstrap newly installed Drupal, while preserving existing messages.
$messages = $_SESSION['messages'];
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+ menu_rebuild();
$_SESSION['messages'] = $messages;
// Build final page.
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index 15cba51ac..9f2712990 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -28,169 +28,162 @@ function aggregator_help($section) {
/**
* Implementation of hook_menu().
*/
-function aggregator_menu($may_cache) {
- $items = array();
- $edit = user_access('administer news feeds');
- $view = user_access('access news feeds');
-
- if ($may_cache) {
- $items[] = array('path' => 'admin/content/aggregator',
- 'title' => t('News aggregator'),
- 'description' => t("Configure which content your site aggregates from other sites, how often it polls them, and how they're categorized."),
- 'callback' => 'aggregator_admin_overview',
- 'access' => $edit);
- $items[] = array('path' => 'admin/content/aggregator/add/feed',
- 'title' => t('Add feed'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_form_feed'),
- 'access' => $edit,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'admin/content/aggregator/add/category',
- 'title' => t('Add category'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_form_category'),
- 'access' => $edit,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'admin/content/aggregator/remove',
- 'title' => t('Remove items'),
- 'callback' => 'aggregator_admin_remove_feed',
- 'access' => $edit,
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/content/aggregator/update',
- 'title' => t('Update items'),
- 'callback' => 'aggregator_admin_refresh_feed',
- 'access' => $edit,
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/content/aggregator/list',
- 'title' => t('List'),
+function aggregator_menu() {
+ $items['admin/content/aggregator'] = array(
+ 'title' => t('News aggregator'),
+ 'description' => t("Configure which content your site aggregates from other sites, how often it polls them, and how they're categorized."),
+ 'page callback' => 'aggregator_admin_overview',
+ 'access arguments' => array('administer news feeds'),
+ );
+ $items['admin/content/aggregator/add/feed'] = array(
+ 'title' => t('Add feed'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_feed'),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/content/aggregator/add/category'] = array(
+ 'title' => t('Add category'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_category'),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/content/aggregator/remove/%'] = array(
+ 'title' => t('Remove items'),
+ 'page callback' => 'aggregator_admin_remove_feed',
+ 'page arguments' => array(4),
+ 'map arguments' => array('aggregator_get_feed', 4),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/content/aggregator/update/%'] = array(
+ 'title' => t('Update items'),
+ 'page callback' => 'aggregator_admin_refresh_feed',
+ 'page arguments' => array(4),
+ 'map arguments' => array('aggregator_get_feed', 4),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/content/aggregator/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['admin/content/aggregator/settings'] = array(
+ 'title' => t('Settings'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_admin_settings'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 10,
+ 'access arguments' => array('administer news feeds'),
+ );
+ $items['aggregator'] = array(
+ 'title' => t('News aggregator'),
+ 'page callback' => 'aggregator_page_last',
+ 'access arguments' => array('access news feeds'),
+ 'weight' => 5,
+ );
+ $items['aggregator/sources'] = array(
+ 'title' => t('Sources'),
+ 'page callback' => 'aggregator_page_sources',
+ 'access arguments' => array('access news feeds'));
+ $items['aggregator/categories'] = array(
+ 'title' => t('Categories'),
+ 'page callback' => 'aggregator_page_categories',
+ 'access arguments' => array('access news feeds'),
+ 'type' => MENU_ITEM_GROUPING,
+ );
+ $items['aggregator/rss'] = array(
+ 'title' => t('RSS feed'),
+ 'page callback' => 'aggregator_page_rss',
+ 'access arguments' => array('access news feeds'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['aggregator/opml'] = array(
+ 'title' => t('OPML feed'),
+ 'page callback' => 'aggregator_page_opml',
+ 'access arguments' => array('access news feeds'),
+ 'type' => MENU_CALLBACK,
+ );
+ $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title');
+ while ($category = db_fetch_array($result)) {
+ $path = 'aggregator/categories/'. $category['cid'];
+ $items[$path] = array(
+ 'title' => $category['title'],
+ 'page callback' => 'aggregator_page_category',
+ 'access arguments' => array('access news feeds'),
+ );
+ $items[$path .'/view'] = array(
+ 'title' => t('View'),
'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10);
- $items[] = array('path' => 'admin/content/aggregator/settings',
- 'title' => t('Settings'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_admin_settings'),
+ 'weight' => -10,
+ );
+ $items[$path .'/categorize'] = array(
+ 'title' => t('Categorize'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_page_category'),
+ 'access arguments' => array('administer news feeds', 2),
'type' => MENU_LOCAL_TASK,
- 'weight' => 10,
- 'access' => $edit);
-
- $items[] = array('path' => 'aggregator',
- 'title' => t('News aggregator'),
- 'callback' => 'aggregator_page_last',
- 'access' => $view,
- 'weight' => 5);
- $items[] = array('path' => 'aggregator/sources',
- 'title' => t('Sources'),
- 'callback' => 'aggregator_page_sources',
- 'access' => $view);
- $items[] = array('path' => 'aggregator/categories',
- 'title' => t('Categories'),
- 'callback' => 'aggregator_page_categories',
- 'access' => $view,
- 'type' => MENU_ITEM_GROUPING);
- $items[] = array('path' => 'aggregator/rss',
- 'title' => t('RSS feed'),
- 'callback' => 'aggregator_page_rss',
- 'access' => $view,
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'aggregator/opml',
- 'title' => t('OPML feed'),
- 'callback' => 'aggregator_page_opml',
- 'access' => $view,
- 'type' => MENU_CALLBACK);
-
- $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title');
- while ($category = db_fetch_array($result)) {
- $items[] = array('path' => 'aggregator/categories/'. $category['cid'],
- 'title' => $category['title'],
- 'callback' => 'aggregator_page_category',
- 'access' => $view);
- }
- }
- else {
- // Add the CSS for this module
- // We put this in !$may_cache so it's only added once per request
- drupal_add_css(drupal_get_path('module', 'aggregator') .'/aggregator.css');
-
- if (arg(0) == 'aggregator' && is_numeric(arg(2))) {
- if (arg(1) == 'sources') {
- $feed = aggregator_get_feed(arg(2));
- if ($feed) {
- $items[] = array('path' => 'aggregator/sources/'. $feed['fid'],
- 'title' => $feed['title'],
- 'callback' => 'aggregator_page_source',
- 'access' => $view,
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'aggregator/sources/'. $feed['fid'] .'/view',
- 'title' => t('View'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10);
- $items[] = array('path' => 'aggregator/sources/'. $feed['fid'] .'/categorize',
- 'title' => t('Categorize'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_page_source'),
- 'access' => $edit,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'aggregator/sources/'. $feed['fid'] .'/configure',
- 'title' => t('Configure'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_form_feed', $feed),
- 'access' => $edit,
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 1);
- }
- }
- else if (arg(1) == 'categories') {
- $category = aggregator_get_category(arg(2));
- if ($category) {
- $items[] = array('path' => 'aggregator/categories/'. $category['cid'] .'/view',
- 'title' => t('View'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10);
- $items[] = array('path' => 'aggregator/categories/'. $category['cid'] .'/categorize',
- 'title' => t('Categorize'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_page_category'),
- 'access' => $edit,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'aggregator/categories/'. $category['cid'] .'/configure',
- 'title' => t('Configure'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_form_category', $category),
- 'access' => $edit,
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 1);
- }
- }
- }
- else if (arg(2) == 'aggregator' && is_numeric(arg(5))) {
- if (arg(4) == 'feed') {
- $feed = aggregator_get_feed(arg(5));
- if ($feed) {
- $items[] = array('path' => 'admin/content/aggregator/edit/feed/'. $feed['fid'],
- 'title' => t('Edit feed'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_form_feed', $feed),
- 'access' => $edit,
- 'type' => MENU_CALLBACK);
- }
- }
- else {
- $category = aggregator_get_category(arg(5));
- if ($category) {
- $items[] = array('path' => 'admin/content/aggregator/edit/category/'. $category['cid'],
- 'title' => t('Edit category'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_form_category', $category),
- 'access' => $edit,
- 'type' => MENU_CALLBACK);
- }
- }
- }
+ );
+ $items[$path .'/configure'] = array(
+ 'title' => t('Configure'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_category', 2),
+ 'access arguments' => array('administer news feeds', 2),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1,
+ );
}
+ $items['aggregator/sources/%'] = array(
+ 'page callback' => 'aggregator_page_source',
+ 'map arguments' => array('aggregator_get_feed', 2),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['aggregator/sources/%/view'] = array(
+ 'title' => t('View'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['aggregator/sources/%/categorize'] = array(
+ 'title' => t('Categorize'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_page_source'),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['aggregator/sources/%/configure'] = array(
+ 'title' => t('Configure'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_feed', 2),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1,
+ );
+ $items['admin/content/aggregator/edit/feed/%'] = array(
+ 'title' => t('Edit feed'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_feed', 5),
+ 'access arguments' => array('administer news feeds'),
+ 'map arguments' => array('aggregator_get_feed', 5),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/content/aggregator/edit/category/%'] = array(
+ 'title' => t('Edit category'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_category', 5),
+ 'access arguments' => array('administer news feeds'),
+ 'map arguments' => array('aggregator_get_category', 5),
+ 'type' => MENU_CALLBACK,
+ );
return $items;
}
+function aggregator_init() {
+ drupal_add_css(drupal_get_path('module', 'aggregator') .'/aggregator.css');
+}
+
function aggregator_admin_settings() {
$items = array(0 => t('none')) + drupal_map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items');
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
@@ -1005,7 +998,7 @@ function aggregator_view() {
* Menu callback; removes all items from a feed, then redirects to the overview page.
*/
function aggregator_admin_remove_feed($feed) {
- aggregator_remove(aggregator_get_feed($feed));
+ aggregator_remove($feed);
drupal_goto('admin/content/aggregator');
}
@@ -1013,7 +1006,7 @@ function aggregator_admin_remove_feed($feed) {
* Menu callback; refreshes a feed, then redirects to the overview page.
*/
function aggregator_admin_refresh_feed($feed) {
- aggregator_refresh(aggregator_get_feed($feed));
+ aggregator_refresh($feed);
drupal_goto('admin/content/aggregator');
}
@@ -1038,6 +1031,7 @@ function aggregator_page_last() {
*/
function aggregator_page_source() {
$feed = db_fetch_object(db_query('SELECT * FROM {aggregator_feed} WHERE fid = %d', arg(2)));
+ drupal_set_title($feed->title);
$info = theme('aggregator_feed', $feed);
return _aggregator_page_list('SELECT * FROM {aggregator_item} WHERE fid = '. $feed->fid .' ORDER BY timestamp DESC, iid DESC', arg(3), $info);
diff --git a/modules/block/block.module b/modules/block/block.module
index df3f54713..e7936fef9 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -58,48 +58,43 @@ function block_perm() {
/**
* Implementation of hook_menu().
*/
-function block_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- $items[] = array(
- 'path' => 'admin/build/block',
- 'title' => t('Blocks'),
- 'access' => user_access('administer blocks'),
- 'description' => t('Configure what block content appears in your site\'s sidebars and other regions.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('block_admin_display'));
- $items[] = array('path' => 'admin/build/block/list', 'title' => t('List'),
- 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
- $items[] = array('path' => 'admin/build/block/configure', 'title' => t('Configure block'),
- 'access' => user_access('administer blocks'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('block_admin_configure'),
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/build/block/delete', 'title' => t('Delete block'),
- 'access' => user_access('administer blocks'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('block_box_delete'),
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/build/block/add', 'title' => t('Add block'),
- 'access' => user_access('administer blocks'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('block_add_block_form'),
- 'type' => MENU_LOCAL_TASK);
- $default = variable_get('theme_default', 'garland');
- foreach (list_themes() as $key => $theme) {
- $items[] = array(
- 'path' => 'admin/build/block/list/'. $key,
- 'title' => t('!key settings', array('!key' => $key)),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('block_admin_display', $key),
- 'access' => user_access('administer blocks'),
- 'type' => $key == $default ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
- 'weight' => $key == $default ? -10 : 0,
- );
- }
+function block_menu() {
+ $items['admin/build/block'] = array(
+ 'title' => t('Blocks'),
+ 'description' => t('Configure what block content appears in your site\'s sidebars and other regions.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('block_admin_display'),
+ 'access arguments' => array('administer blocks'),
+ );
+ $items['admin/build/block/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['admin/build/block/configure'] = array(
+ 'title' => t('Configure block'),
+ 'page arguments' => array('block_admin_configure'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/build/block/delete'] = array(
+ 'title' => t('Delete block'),
+ 'page arguments' => array('block_box_delete'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/build/block/add'] = array(
+ 'title' => t('Add block'),
+ 'page arguments' => array('block_add_block_form'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $default = variable_get('theme_default', 'garland');
+ foreach (list_themes() as $key => $theme) {
+ $items['admin/build/block/list/'. $key] = array(
+ 'title' => t('!key settings', array('!key' => $key)),
+ 'page arguments' => array('block_admin_display', $key),
+ 'type' => $key== $default ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
+ 'weight' => $key == $default ? -10 : 0,
+ );
}
-
return $items;
}
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index 3bf271881..d3e4a49c8 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -249,19 +249,18 @@ function blog_link($type, $node = NULL, $teaser = FALSE) {
/**
* Implementation of hook_menu().
*/
-function blog_menu($may_cache) {
- global $user;
- $items = array();
-
- if ($may_cache) {
- $items[] = array('path' => 'blog', 'title' => t('Blogs'),
- 'callback' => 'blog_page',
- 'access' => user_access('access content'),
- 'type' => MENU_SUGGESTED_ITEM);
- $items[] = array('path' => 'blog/'. $user->uid, 'title' => t('My blog'),
- 'access' => user_access('edit own blog'),
- 'type' => MENU_DYNAMIC_ITEM);
- }
+function blog_menu() {
+ $items['blog'] = array(
+ 'title' => t('Blogs'),
+ 'page callback' => 'blog_page',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ );
+ $items['blog/%'] = array(
+ 'title' => t('My blog'),
+ 'page arguments' => array(1),
+ 'access arguments' => array('edit own blog'),
+ );
return $items;
}
diff --git a/modules/blogapi/blogapi.module b/modules/blogapi/blogapi.module
index 85a7cfa6e..f55b54ce3 100644
--- a/modules/blogapi/blogapi.module
+++ b/modules/blogapi/blogapi.module
@@ -551,46 +551,32 @@ function blogapi_admin_settings() {
return system_settings_form($form);
}
-function blogapi_menu($may_cache) {
- $items = array();
+function blogapi_menu() {
+ $items['blogapi/rsd'] = array(
+ 'title' => t('RSD'),
+ 'page callback' => 'blogapi_rsd',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/settings/blogapi'] = array(
+ 'title' => t('Blog APIs'),
+ 'description' => t('Configure which content types and engines external blog clients can use.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('blogapi_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'type' => MENU_NORMAL_ITEM,
+ );
+
+ return $items;
+}
+function blogapi_init() {
if (drupal_is_front_page()) {
drupal_add_link(array('rel' => 'EditURI',
'type' => 'application/rsd+xml',
'title' => t('RSD'),
'href' => url('blogapi/rsd', NULL, NULL, TRUE)));
}
-
- if ($may_cache) {
- $items[] = array(
- 'path' => 'blogapi',
- 'title' => t('RSD'),
- 'callback' => 'blogapi_blogapi',
- 'access' => user_access('access content'),
- 'type' => MENU_CALLBACK);
- $items[] = array(
- 'path' => 'admin/settings/blogapi',
- 'title' => t('Blog APIs'),
- 'description' => t('Configure which content types and engines external blog clients can use.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('blogapi_admin_settings'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_NORMAL_ITEM
- );
- }
-
- return $items;
-}
-
-function blogapi_blogapi() {
- switch (arg(1)) {
- case 'rsd':
- blogapi_rsd();
- break;
- default:
- drupal_not_found();
- break;
- }
}
function blogapi_rsd() {
diff --git a/modules/book/book.module b/modules/book/book.module
index 1d07a5f5b..8216d617a 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -85,65 +85,58 @@ function book_link($type, $node = NULL, $teaser = FALSE) {
/**
* Implementation of hook_menu().
*/
-function book_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- $items[] = array(
- 'path' => 'admin/content/book',
- 'title' => t('Books'),
- 'description' => t("Manage site's books and orphaned book pages."),
- 'callback' => 'book_admin',
- 'access' => user_access('administer nodes'));
- $items[] = array(
- 'path' => 'admin/content/book/list',
- 'title' => t('List'),
- 'type' => MENU_DEFAULT_LOCAL_TASK);
- $items[] = array(
- 'path' => 'admin/content/book/orphan',
- 'title' => t('Orphan pages'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('book_admin_orphan'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 8);
- $items[] = array(
- 'path' => 'book',
- 'title' => t('Books'),
- 'callback' => 'book_render',
- 'access' => user_access('access content'),
- 'type' => MENU_SUGGESTED_ITEM);
- $items[] = array(
- 'path' => 'book/export',
- 'callback' => 'book_export',
- 'access' => user_access('access content'),
- 'type' => MENU_CALLBACK);
- }
- else {
- // Add the CSS for this module
- // We put this in !$may_cache so it's only added once per request
- drupal_add_css(drupal_get_path('module', 'book') .'/book.css');
-
- // To avoid SQL overhead, check whether we are on a node page and whether the
- // user is allowed to outline posts in books.
- if (arg(0) == 'node' && is_numeric(arg(1)) && user_access('outline posts in books')) {
- // Only add the outline-tab for non-book pages:
- $result = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.nid = %d AND n.type != 'book'"), arg(1));
- if (db_num_rows($result) > 0) {
- $items[] = array(
- 'path' => 'node/'. arg(1) .'/outline',
- 'title' => t('Outline'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('book_outline', arg(1)),
- 'access' => user_access('outline posts in books'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2);
- }
- }
- }
+function book_menu() {
+ $items['admin/content/book'] = array(
+ 'title' => t('Books'),
+ 'description' => t("Manage site's books and orphaned book pages."),
+ 'page callback' => 'book_admin',
+ 'access arguments' => array('administer nodes'),
+ );
+ $items['admin/content/book/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ );
+ $items['admin/content/book/orphan'] = array(
+ 'title' => t('Orphan pages'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('book_admin_orphan'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 8,
+ );
+ $items['book'] = array(
+ 'title' => t('Books'),
+ 'page callback' => 'book_render',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ );
+ $items['book/export/%/%'] = array(
+ 'page callback' => 'book_export',
+ 'page arguments' => array(2, 3),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['node/%/outline'] = array(
+ 'title' => t('Outline'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('book_outline', 1),
+ 'access callback' => '_book_outline_access',
+ 'access arguments' => array(1),
+ 'map arguments' => array('node_load', 1),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ );
return $items;
}
+function _book_outline_access($node) {
+ // Only add the outline-tab for non-book pages:
+ return user_access('outline posts in books') && $node && ($node->type != 'book');
+}
+
+function book_init() {
+ drupal_add_css(drupal_get_path('module', 'book') .'/book.css');
+}
+
/**
* Implementation of hook_block().
*
@@ -256,9 +249,7 @@ function book_form(&$node) {
* Implementation of function book_outline()
* Handles all book outline operations.
*/
-function book_outline($nid) {
- $node = node_load($nid);
-
+function book_outline($node) {
$form['parent'] = array('#type' => 'select',
'#title' => t('Parent'),
'#default_value' => $node->parent,
@@ -637,7 +628,7 @@ function book_render() {
* - an integer representing the node id (nid) of the node to export
*
*/
-function book_export($type = 'html', $nid = 0) {
+function book_export($type, $nid) {
$type = drupal_strtolower($type);
$node_result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d'), $nid);
if (db_num_rows($node_result) > 0) {
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 95292e01c..8e7a2e937 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -140,70 +140,77 @@ function comment_help($section) {
}
}
+function _comment_view_access($node, $cid) {
+ return $node && $cid;
+}
+
/**
* Implementation of hook_menu().
*/
-function comment_menu($may_cache) {
- $items = array();
+function comment_menu() {
+ $items['admin/content/comment'] = array(
+ 'title' => t('Comments'),
+ 'description' => t('List and edit site comments and the comment moderation queue.'),
+ 'page callback' => 'comment_admin',
+ 'access arguments' => array('administer comments'),
+ );
- if ($may_cache) {
- $access = user_access('administer comments');
- $items[] = array(
- 'path' => 'admin/content/comment',
- 'title' => t('Comments'),
- 'description' => t('List and edit site comments and the comment moderation queue.'),
- 'callback' => 'comment_admin',
- 'access' => $access
- );
+ // Tabs:
+ $items['admin/content/comment/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
- // Tabs:
- $items[] = array('path' => 'admin/content/comment/list', 'title' => t('List'),
- 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
-
- // Subtabs:
- $items[] = array('path' => 'admin/content/comment/list/new', 'title' => t('Published comments'),
- 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
- $items[] = array('path' => 'admin/content/comment/list/approval', 'title' => t('Approval queue'),
- 'callback' => 'comment_admin',
- 'callback arguments' => array('approval'),
- 'access' => $access,
- 'type' => MENU_LOCAL_TASK);
-
- $items[] = array(
- 'path' => 'admin/content/comment/settings',
- 'title' => t('Settings'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('comment_admin_settings'),
- 'access' => $access,
- 'weight' => 10,
- 'type' => MENU_LOCAL_TASK);
-
- $items[] = array('path' => 'comment/delete', 'title' => t('Delete comment'),
- 'callback' => 'comment_delete', 'access' => $access, 'type' => MENU_CALLBACK);
-
- $access = user_access('post comments');
- $items[] = array('path' => 'comment/edit', 'title' => t('Edit comment'),
- 'callback' => 'comment_edit',
- 'access' => $access, 'type' => MENU_CALLBACK);
- }
- else {
- if (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) {
- $node = node_load(arg(2));
- if ($node->nid) {
- $items[] = array('path' => 'comment/reply', 'title' => t('Reply to comment'),
- 'callback' => 'comment_reply', 'access' => node_access('view', $node), 'type' => MENU_CALLBACK);
- }
- }
- if ((arg(0) == 'node') && is_numeric(arg(1)) && is_numeric(arg(2))) {
- $items[] = array(
- 'path' => ('node/'. arg(1) .'/'. arg(2)),
- 'title' => t('View'),
- 'callback' => 'node_page_view',
- 'callback arguments' => array(node_load(arg(1)), arg(2)),
- 'type' => MENU_CALLBACK,
- );
- }
- }
+ // Subtabs:
+ $items['admin/content/comment/list/new'] = array(
+ 'title' => t('Published comments'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['admin/content/comment/list/approval'] = array(
+ 'title' => t('Approval queue'),
+ 'page arguments' => array('approval'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+
+ $items['admin/content/comment/settings'] = array(
+ 'title' => t('Settings'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('comment_admin_settings'),
+ 'weight' => 10,
+ 'type' => MENU_LOCAL_TASK,
+ );
+
+ $items['comment/delete'] = array(
+ 'title' => t('Delete comment'),
+ 'page callback' => 'comment_delete',
+ 'access arguments' => array('administer comments'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['comment/edit'] = array(
+ 'title' => t('Edit comment'),
+ 'page callback' => 'comment_edit',
+ 'access arguments' => array('post comments'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['comment/reply'] = array(
+ 'title' => t('Reply to comment'),
+ 'page callback' => 'comment_reply',
+ 'access callback' => 'node_access',
+ 'access arguments' => array('view', 2),
+ 'map arguments' => array('node_load', 2),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['node/%/%'] = array(
+ 'title' => t('View'),
+ 'page callback' => 'node_page_view',
+ 'page arguments' => array(1, 2),
+ 'access callback' => '_comment_view_access',
+ 'access arguments' => array(1, 2),
+ 'type' => MENU_CALLBACK,
+ );
return $items;
}
@@ -1981,25 +1988,6 @@ function comment_invoke_comment(&$comment, $op) {
}
/**
- * Generate vancode.
- *
- * Consists of a leading character indicating length, followed by N digits
- * with a numerical value in base 36. Vancodes can be sorted as strings
- * without messing up numerical order.
- *
- * It goes:
- * 00, 01, 02, ..., 0y, 0z,
- * 110, 111, ... , 1zy, 1zz,
- * 2100, 2101, ..., 2zzy, 2zzz,
- * 31000, 31001, ...
- */
-function int2vancode($i = 0) {
- $num = base_convert((int)$i, 10, 36);
- $length = strlen($num);
- return chr($length + ord('0') - 1) . $num;
-}
-
-/**
* Decode vancode back to an integer.
*/
function vancode2int($c = '00') {
diff --git a/modules/contact/contact.module b/modules/contact/contact.module
index f3f9c96b4..7dcc0e894 100644
--- a/modules/contact/contact.module
+++ b/modules/contact/contact.module
@@ -40,77 +40,68 @@ function contact_perm() {
/**
* Implementation of hook_menu().
*/
-function contact_menu($may_cache) {
- $items = array();
- if ($may_cache) {
- $items[] = array('path' => 'admin/build/contact',
- 'title' => t('Contact form'),
- 'description' => t('Create a system contact form and set up categories for the form to use.'),
- 'callback' => 'contact_admin_categories',
- 'access' => user_access('administer site configuration'),
- );
- $items[] = array('path' => 'admin/build/contact/list',
- 'title' => t('List'),
- 'callback' => 'contact_admin_categories',
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- );
- $items[] = array('path' => 'admin/build/contact/add',
- 'title' => t('Add category'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('contact_admin_edit'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 1,
- );
- $items[] = array('path' => 'admin/build/contact/edit',
- 'title' => t('Edit contact category'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('contact_admin_edit'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_CALLBACK,
- );
- $items[] = array('path' => 'admin/build/contact/delete',
- 'title' => t('Delete contact'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('contact_admin_delete'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_CALLBACK,
- );
- $items[] = array('path' => 'admin/build/contact/settings',
- 'title' => t('Settings'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('contact_admin_settings'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
- );
- $items[] = array('path' => 'contact',
- 'title' => t('Contact'),
- 'callback' => 'contact_site_page',
- 'access' => user_access('access site-wide contact form'),
- 'type' => MENU_SUGGESTED_ITEM,
- );
- }
- else {
- if (arg(0) == 'user' && is_numeric(arg(1))) {
- global $user;
- $account = user_load(array('uid' => arg(1)));
- if (($user->uid != $account->uid && $account->contact) || user_access('administer users')) {
- $items[] = array('path' => 'user/'. arg(1) .'/contact',
- 'title' => t('Contact'),
- 'callback' => 'contact_user_page',
- 'type' => MENU_LOCAL_TASK,
- 'access' => $user->uid,
- 'weight' => 2,
- );
- }
- }
- }
-
+function contact_menu() {
+ $items['admin/build/contact'] = array(
+ 'title' => t('Contact form'),
+ 'description' => t('Create a system contact form and set up categories for the form to use.'),
+ 'page callback' => 'contact_admin_categories',
+ 'access arguments' => array('administer site configuration'),
+ );
+ $items['admin/build/contact/list'] = array(
+ 'title' => t('List'),
+ 'page callback' => 'contact_admin_categories',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ );
+ $items['admin/build/contact/add'] = array(
+ 'title' => t('Add category'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('contact_admin_edit'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1,
+ );
+ $items['admin/build/contact/edit'] = array(
+ 'title' => t('Edit contact category'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('contact_admin_edit'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/build/contact/delete'] = array(
+ 'title' => t('Delete contact'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('contact_admin_delete'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/build/contact/settings'] = array(
+ 'title' => t('Settings'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('contact_admin_settings'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ );
+ $items['contact'] = array(
+ 'title' => t('Contact'),
+ 'page callback' => 'contact_site_page',
+ 'access arguments' => array('access site-wide contact form'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ );
+ $items['user/%/contact'] = array(
+ 'title' => t('Contact'),
+ 'page callback' => 'contact_user_page',
+ 'page arguments' => array(1),
+ 'type' => MENU_LOCAL_TASK,
+ 'access callback' => '_contact_user_tab_access',
+ 'access arguments' => array(1),
+ 'map arguments' => array('user_load', 1),
+ 'weight' => 2,
+ );
return $items;
}
+function _contact_user_tab_access($account) {
+ global $user;
+ return $account && (($user->uid != $account->uid && $account->contact) || user_access('administer users'));
+}
+
/**
* Implementation of hook_user().
*
@@ -299,26 +290,21 @@ function contact_admin_settings() {
/**
* Personal contact page.
*/
-function contact_user_page() {
+function contact_user_page($account) {
global $user;
- if ($account = user_load(array('uid' => arg(1)))) {
- if (!valid_email_address($user->mail)) {
- $output = t('You need to provide a valid e-mail address to contact other users. Please update your <a href="@url">user information</a> and try again.', array('@url' => url("user/$user->uid/edit")));
- }
- else if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
- $output = t('You cannot contact more than %number users per hour. Please try again later.', array('%number' => variable_get('contact_hourly_threshold', 3)));
- }
- else {
- drupal_set_title(check_plain($account->name));
- $output = drupal_get_form('contact_mail_user', $account);
- }
-
- return $output;
+ if (!valid_email_address($user->mail)) {
+ $output = t('You need to provide a valid e-mail address to contact other users. Please update your <a href="@url">user information</a> and try again.', array('@url' => url("user/$user->uid/edit")));
+ }
+ else if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
+ $output = t('You cannot contact more than %number users per hour. Please try again later.', array('%number' => variable_get('contact_hourly_threshold', 3)));
}
else {
- drupal_not_found();
+ drupal_set_title(check_plain($account->name));
+ $output = drupal_get_form('contact_mail_user', $account);
}
+
+ return $output;
}
function contact_mail_user($recipient) {
diff --git a/modules/drupal/drupal.module b/modules/drupal/drupal.module
index f90703608..a70336427 100644
--- a/modules/drupal/drupal.module
+++ b/modules/drupal/drupal.module
@@ -336,28 +336,28 @@ function drupal_auth($username, $password, $server = FALSE) {
/**
* Implementation of hook_menu().
*/
-function drupal_menu($may_cache) {
- $items = array();
- if ($may_cache) {
- $items[] = array('path' => 'admin/settings/sites-registry',
- 'title' => t('Sites registry'),
- 'description' => t('Register with another Drupal site (drupal.org by default) for statistics sharing, or set up your server to be a central server for registrations.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('drupal_sites_registry_settings'),
- 'access' => user_access('administer site configuration'));
- $items[] = array('path' => 'admin/settings/distributed-authentication',
- 'title' => t('Distributed authentication'),
- 'description' => t('Allow your site to accept logins from other Drupal sites such as drupal.org.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('drupal_distributed_authentication_settings'),
- 'access' => user_access('administer site configuration'));;
-
- if (variable_get('drupal_authentication_service', 0)) {
- $items[] = array('path' => 'drupal', 'title' => t('Drupal'),
- 'callback' => 'drupal_page_help', 'access' => TRUE,
- 'type' => MENU_SUGGESTED_ITEM
- );
- }
+function drupal_menu() {
+ $items['admin/settings/sites-registry'] = array(
+ 'title' => t('Sites registry'),
+ 'description' => t('Register with another Drupal site (drupal.org by default) for statistics sharing, or set up your server to be a central server for registrations.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('drupal_sites_registry_settings'),
+ 'access arguments' => array('administer site configuration'),
+ );
+ $items['admin/settings/distributed-authentication'] = array(
+ 'title' => t('Distributed authentication'),
+ 'description' => t('Allow your site to accept logins from other Drupal sites such as drupal.org.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('drupal_distributed_authentication_settings'),
+ 'access arguments' => array('administer site configuration'),
+ );
+ if (variable_get('drupal_authentication_service', 0)) {
+ $items['drupal'] = array(
+ 'title' => t('Drupal'),
+ 'page callback' => 'drupal_page_help',
+ 'access callback' => TRUE,
+ 'type' => MENU_SUGGESTED_ITEM,
+ );
}
return $items;
}
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index aa429a0a1..0892b5541 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -50,85 +50,62 @@ function filter_help($section) {
/**
* Implementation of hook_menu().
*/
-function filter_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- $items[] = array('path' => 'admin/settings/filters',
- 'title' => t('Input formats'),
- 'description' => t('Configure how content input by users is filtered, including allowed HTML tags, PHP code tags. Also allows enabling of module-provided filters.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('filter_admin_overview'),
- 'access' => user_access('administer filters'),
- );
- $items[] = array('path' => 'admin/settings/filters/list',
- 'title' => t('List'),
- 'callback' => 'filter_admin_overview',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
-'access' => user_access('administer filters'),
- );
- $items[] = array('path' => 'admin/settings/filters/add',
- 'title' => t('Add input format'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('filter_admin_format_form'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 1,
- 'access' => user_access('administer filters'),
- );
- $items[] = array('path' => 'admin/settings/filters/delete',
- 'title' => t('Delete input format'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('filter_admin_delete'),
- 'type' => MENU_CALLBACK,
- 'access' => user_access('administer filters'),
- );
- $items[] = array('path' => 'filter/tips',
- 'title' => t('Compose tips'),
- 'callback' => 'filter_tips_long',
- 'access' => TRUE,
- 'type' => MENU_SUGGESTED_ITEM,
- );
- }
- else {
- if (arg(0) == 'admin' && arg(1) == 'settings' && arg(2) == 'filters' && is_numeric(arg(3))) {
- $formats = filter_formats();
-
- if (isset($formats[arg(3)])) {
- $items[] = array('path' => 'admin/settings/filters/'. arg(3),
- 'title' => t("!format input format", array('!format' => $formats[arg(3)]->name)),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('filter_admin_format_form', $formats[arg(3)]),
- 'type' => MENU_CALLBACK,
- 'access' => user_access('administer filters'),
- );
- $items[] = array('path' => 'admin/settings/filters/'. arg(3) .'/list',
- 'title' => t('View'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('filter_admin_format_form', $formats[arg(3)]),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => 0,
- 'access' => user_access('administer filters'),
- );
- $items[] = array('path' => 'admin/settings/filters/'. arg(3) .'/configure',
- 'title' => t('Configure'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('filter_admin_configure'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 1,
- 'access' => user_access('administer filters'),
- );
- $items[] = array('path' => 'admin/settings/filters/'. arg(3) .'/order',
- 'title' => t('Rearrange'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('filter_admin_order', 'format' => $formats[arg(3)]),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
- 'access' => user_access('administer filters'),
- );
- }
- }
- }
+function filter_menu() {
+ $items['admin/settings/filters'] = array(
+ 'title' => t('Input formats'),
+ 'description' => t('Configure how content input by users is filtered, including allowed HTML tags, PHP code tags. Also allows enabling of module-provided filters.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('filter_admin_overview'),
+ 'access arguments' => array('administer filters'),
+ );
+ $items['admin/settings/filters/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ );
+ $items['admin/settings/filters/add'] = array(
+ 'title' => t('Add input format'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('filter_admin_format_form'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1,
+ );
+ $items['admin/settings/filters/delete'] = array(
+ 'title' => t('Delete input format'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('filter_admin_delete'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['filter/tips'] = array(
+ 'title' => t('Compose tips'),
+ 'page callback' => 'filter_tips_long',
+ 'access callback' => TRUE,
+ 'type' => MENU_SUGGESTED_ITEM,
+ );
+ $items['admin/settings/filters/%'] = array(
+ 'type' => MENU_CALLBACK,
+ 'page arguments' => array('filter_admin_format_form', 3),
+ 'access arguments' => array('administer filters'),
+ 'map arguments' => array('filter_formats', 3),
+ );
+ $items['admin/settings/filters/%/list'] = array(
+ 'title' => t('View'),
+ 'page arguments' => array('filter_admin_format_form', 3),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 0,
+ );
+ $items['admin/settings/filters/%/configure'] = array(
+ 'title' => t('Configure'),
+ 'page arguments' => array('filter_admin_configure', 3),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1,
+ );
+ $items['admin/settings/filters/%/order'] = array(
+ 'title' => t('Rearrange'),
+ 'page arguments' => array('filter_admin_order', 3),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ );
return $items;
}
@@ -459,6 +436,7 @@ function filter_admin_format_form($format = NULL) {
$group = '<p>'. t('These are the guidelines that users will see for posting in this input format. They are automatically generated from the filter settings.') .'</p>';
$group .= $tiplist;
$form['tips'] = array('#value' => '<h2>'. t('Formatting guidelines') .'</h2>'. $group);
+ drupal_set_title(t("!format input format", array('!format' => $format->name)));
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
@@ -590,13 +568,11 @@ function filter_admin_order_submit($form_id, $form_values) {
/**
* Menu callback; display settings defined by filters.
*/
-function filter_admin_configure() {
- $format = arg(3);
-
- $list = filter_list_format($format);
+function filter_admin_configure($format) {
+ $list = filter_list_format($format->format);
$form = array();
foreach ($list as $filter) {
- $form_module = module_invoke($filter->module, 'filter', 'settings', $filter->delta, $format);
+ $form_module = module_invoke($filter->module, 'filter', 'settings', $filter->delta, $format->format);
if (isset($form_module) && is_array($form_module)) {
$form = array_merge($form, $form_module);
}
@@ -615,7 +591,7 @@ function filter_admin_configure() {
/**
* Retrieve a list of input formats.
*/
-function filter_formats() {
+function filter_formats($index = NULL) {
global $user;
static $formats;
@@ -644,6 +620,9 @@ function filter_formats() {
$formats[$format->format] = $format;
}
}
+ if (isset($index)) {
+ return isset($formats[$index]) ? $formats[$index] : FALSE;
+ }
return $formats;
}
@@ -862,6 +841,7 @@ function filter_access($format) {
return isset($formats[$format]);
}
}
+
/**
* @} End of "Filtering functions".
*/
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index d87de83c2..2517dd085 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -31,73 +31,72 @@ function forum_help($section) {
/**
* Implementation of hook_menu().
*/
-function forum_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- $items[] = array('path' => 'forum',
- 'title' => t('Forums'),
- 'callback' => 'forum_page',
- 'access' => user_access('access content'),
- 'type' => MENU_SUGGESTED_ITEM);
- $items[] = array('path' => 'admin/content/forum',
- 'title' => t('Forums'),
- 'description' => t('Control forums and their hierarchy and change forum settings.'),
- 'callback' => 'forum_overview',
- 'access' => user_access('administer forums'),
- 'type' => MENU_NORMAL_ITEM);
- $items[] = array('path' => 'admin/content/forum/list',
- 'title' => t('List'),
- 'access' => user_access('administer forums'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10);
- $items[] = array('path' => 'admin/content/forum/add/container',
- 'title' => t('Add container'),
- 'callback' => 'forum_form_main',
- 'callback arguments' => array('container'),
- 'access' => user_access('administer forums'),
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'admin/content/forum/add/forum',
- 'title' => t('Add forum'),
- 'callback' => 'forum_form_main',
- 'callback arguments' => array('forum'),
- 'access' => user_access('administer forums'),
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'admin/content/forum/settings',
- 'title' => t('Settings'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('forum_admin_settings'),
- 'weight' => 5,
- 'access' => user_access('administer forums'),
- 'type' => MENU_LOCAL_TASK);
- }
- elseif (is_numeric(arg(5))) {
- $term = taxonomy_get_term(arg(5));
- // Check if this is a valid term.
- if ($term) {
- $items[] = array('path' => 'admin/content/forum/edit/container',
- 'title' => t('Edit container'),
- 'callback' => 'forum_form_main',
- 'callback arguments' => array('container', (array)$term),
- 'access' => user_access('administer forums'),
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/content/forum/edit/forum',
- 'title' => t('Edit forum'),
- 'callback' => 'forum_form_main',
- 'callback arguments' => array('forum', (array)$term),
- 'access' => user_access('administer forums'),
- 'type' => MENU_CALLBACK);
- }
- }
- else {
- // Add the CSS for this module
- // We put this in !$may_cache so it's only added once per request
- drupal_add_css(drupal_get_path('module', 'forum') .'/forum.css');
- }
-
+function forum_menu() {
+ $items['node/add/forum'] = array(
+ 'title' => t('Forum topic'),
+ 'access arguments' => array('create forum topics'),
+ );
+ $items['forum'] = array(
+ 'title' => t('Forums'),
+ 'page callback' => 'forum_page',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ );
+ $items['admin/content/forum'] = array(
+ 'title' => t('Forums'),
+ 'description' => t('Control forums and their hierarchy and change forum settings.'),
+ 'page callback' => 'forum_overview',
+ 'access arguments' => array('administer forums'),
+ );
+ $items['admin/content/forum/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['admin/content/forum/add/container'] = array(
+ 'title' => t('Add container'),
+ 'page callback' => 'forum_form_main',
+ 'page arguments' => array('container'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/content/forum/add/forum'] = array(
+ 'title' => t('Add forum'),
+ 'page callback' => 'forum_form_main',
+ 'page arguments' => array('forum'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/content/forum/settings'] = array(
+ 'title' => t('Settings'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('forum_admin_settings'),
+ 'weight' => 5,
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/content/forum/edit'] = array(
+ 'page callback' => 'forum_form_main',
+ 'map arguments' => array('_forum_get_term', 5, array()),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/content/forum/edit/container/%'] = array(
+ 'title' => t('Edit container'),
+ 'page arguments' => array('container', 5),
+ );
+ $items['admin/content/forum/edit/forum/%'] = array(
+ 'title' => t('Edit forum'),
+ 'page callback' => 'forum_form_main',
+ 'page arguments' => array('forum', 5),
+ );
return $items;
}
+function forum_init() {
+ drupal_add_css(drupal_get_path('module', 'forum') .'/forum.css');
+}
+
+function _forum_get_term($tid) {
+ return (array)taxonomy_get_term($tid);
+}
+
/**
* Implementation of hook_node_info().
*/
diff --git a/modules/help/help.module b/modules/help/help.module
index 79fd232a1..399110041 100644
--- a/modules/help/help.module
+++ b/modules/help/help.module
@@ -9,24 +9,20 @@
/**
* Implementation of hook_menu().
*/
-function help_menu($may_cache) {
- $items = array();
+function help_menu() {
+ $items['admin/help'] = array(
+ 'title' => t('Help'),
+ 'page callback' => 'help_main',
+ 'access arguments' => array('access administration pages'),
+ 'weight' => 9,
+ );
- if ($may_cache) {
- $admin_access = user_access('access administration pages');
-
- $items[] = array('path' => 'admin/help', 'title' => t('Help'),
- 'callback' => 'help_main',
- 'access' => $admin_access,
- 'weight' => 9);
-
- foreach (module_implements('help', TRUE) as $module) {
- $items[] = array('path' => 'admin/help/' . $module,
- 'title' => t($module),
- 'callback' => 'help_page',
- 'type' => MENU_CALLBACK,
- 'access' => $admin_access);
- }
+ foreach (module_implements('help', TRUE) as $module) {
+ $items['admin/help/'. $module] = array(
+ 'title' => t($module),
+ 'page callback' => 'help_page',
+ 'type' => MENU_CALLBACK,
+ );
}
return $items;
diff --git a/modules/legacy/legacy.module b/modules/legacy/legacy.module
index 8355dd4d8..8f5a7b271 100644
--- a/modules/legacy/legacy.module
+++ b/modules/legacy/legacy.module
@@ -34,48 +34,65 @@ function legacy_help($section) {
*
* Registers menu paths used in earlier Drupal versions.
*/
-function legacy_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- // Map "taxonomy/page/or/52,97" to "taxonomy/term/52+97".
- $items[] = array('path' => 'taxonomy/page', 'title' => t('Taxonomy'),
- 'callback' => 'legacy_taxonomy_page',
- 'access' => TRUE, 'type' => MENU_CALLBACK);
-
- // Map "taxonomy/feed/or/52,97" to "taxonomy/term/52+97/0/feed".
- $items[] = array('path' => 'taxonomy/feed', 'title' => t('Taxonomy'),
- 'callback' => 'legacy_taxonomy_feed',
- 'access' => TRUE, 'type' => MENU_CALLBACK);
-
- // Map "blog/feed/52" to "blog/52/feed".
- $items[] = array('path' => 'blog/feed', 'title' => t('Blog'),
- 'callback' => 'legacy_blog_feed',
- 'access' => TRUE, 'type' => MENU_CALLBACK);
- }
- else {
- // Map "node/view/52" to "node/52".
- $items[] = array('path' => 'node/view', 'title' => t('View'),
- 'callback' => 'drupal_goto',
- 'callback arguments' => array('node/'. arg(2), NULL, NULL),
- 'access' => TRUE, 'type' => MENU_CALLBACK);
-
- // Map "book/view/52" to "node/52".
- $items[] = array('path' => 'book/view', 'title' => t('View'),
- 'callback' => 'drupal_goto',
- 'callback arguments' => array('node/'. arg(2), NULL, NULL),
- 'access' => TRUE, 'type' => MENU_CALLBACK);
-
- // Map "user/view/52" to "user/52".
- $items[] = array('path' => 'user/view', 'title' => t('View'),
- 'callback' => 'drupal_goto',
- 'callback arguments' => array('user/'. arg(2), NULL, NULL),
- 'access' => TRUE, 'type' => MENU_CALLBACK);
- }
+function legacy_menu() {
+ // Map "taxonomy/page/or/52,97" to "taxonomy/term/52+97".
+ $items['taxonomy/page'] = array(
+ 'title' => t('Taxonomy'),
+ 'page callback' => 'legacy_taxonomy_page',
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
+
+ // Map "taxonomy/feed/or/52,97" to "taxonomy/term/52+97/0/feed".
+ $items['taxonomy/feed'] = array(
+ 'title' => t('Taxonomy'),
+ 'page callback' => 'legacy_taxonomy_feed',
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
+
+ // Map "blog/feed/52" to "blog/52/feed".
+ $items['blog/feed'] = array(
+ 'title' => t('Blog'),
+ 'page callback' => 'legacy_blog_feed',
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
+
+ // Map "node/view/52" to "node/52".
+ $items['node/view'] = array(
+ 'title' => t('View'),
+ 'page callback' => '_legacy_goto',
+ 'page arguments' => array('node', 2),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
+
+ // Map "book/view/52" to "node/52".
+ $items['book/view'] = array(
+ 'title' => t('View'),
+ 'page callback' => '_legacy_goto',
+ 'page arguments' => array('node', 2),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
+
+ // Map "user/view/52" to "user/52".
+ $items['user/view'] = array(
+ 'title' => t('View'),
+ 'page callback' => 'drupal_goto',
+ 'page arguments' => array('user', 2),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
return $items;
}
+function _legacy_goto($type, $arg) {
+ drupal_goto("$type/$arg", NULL, NULL);
+}
+
/**
* Menu callback; redirects users to new taxonomy page paths.
*/
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index c3bf22672..7b22ca5c4 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -41,82 +41,73 @@ function locale_help($section) {
/**
* Implementation of hook_menu().
*/
-function locale_menu($may_cache) {
- $items = array();
- $access = user_access('administer locales');
-
- if ($may_cache) {
- // Main admin menu item
- $items[] = array('path' => 'admin/settings/locale',
- 'title' => t('Localization'),
- 'description' => t('Configure site localization and user interface translation.'),
- 'callback' => 'locale_admin_manage',
- 'access' => $access);
-
- // Top level tabs
- $items[] = array('path' => 'admin/settings/locale/language',
- 'title' => t('Manage languages'),
- 'access' => $access,
- 'weight' => -10,
- 'type' => MENU_DEFAULT_LOCAL_TASK);
- $items[] = array('path' => 'admin/settings/locale/string/search',
- 'title' => t('Manage strings'),
- 'callback' => 'locale_string_search',
- 'access' => $access,
- 'weight' => 10,
- 'type' => MENU_LOCAL_TASK);
-
- // Manage languages subtabs
- $items[] = array('path' => 'admin/settings/locale/language/overview',
- 'title' => t('List'),
- 'callback' => 'locale_admin_manage',
- 'access' => $access,
- 'weight' => 0,
- 'type' => MENU_DEFAULT_LOCAL_TASK);
- $items[] = array('path' => 'admin/settings/locale/language/add',
- 'title' => t('Add language'),
- 'callback' => 'locale_admin_manage_add',
- 'access' => $access,
- 'weight' => 5,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'admin/settings/locale/language/import',
- 'title' => t('Import'),
- 'callback' => 'locale_admin_import',
- 'access' => $access,
- 'weight' => 10,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'admin/settings/locale/language/export',
- 'title' => t('Export'),
- 'callback' => 'locale_admin_export',
- 'access' => $access,
- 'weight' => 20,
- 'type' => MENU_LOCAL_TASK);
-
- // Language related callbacks
- $items[] = array('path' => 'admin/settings/locale/language/delete',
- 'title' => t('Confirm'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('locale_admin_manage_delete_form'),
- 'access' => $access,
- 'type' => MENU_CALLBACK);
- }
- else {
- if (is_numeric(arg(5))) {
- // String related callbacks
- $items[] = array('path' => 'admin/settings/locale/string/edit/'. arg(5),
- 'title' => t('Edit string'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('locale_admin_string_edit', arg(5)),
- 'access' => $access,
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/settings/locale/string/delete/'. arg(5),
- 'title' => t('Delete string'),
- 'callback' => 'locale_admin_string_delete',
- 'callback arguments' => array(arg(5)),
- 'access' => $access,
- 'type' => MENU_CALLBACK);
- }
- }
+function locale_menu() {
+ // Main admin menu item
+ $items['admin/settings/locale'] = array(
+ 'title' => t('Localization'),
+ 'description' => t('Configure site localization and user interface translation.'),
+ 'page callback' => 'locale_admin_manage',
+ 'access arguments' => array('administer locales'),
+ );
+
+ // Top level tabs
+ $items['admin/settings/locale/language'] = array(
+ 'title' => t('Manage languages'),
+ 'weight' => -10,
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ );
+ $items['admin/settings/locale/string/search'] = array(
+ 'title' => t('Manage strings'),
+ 'page callback' => 'locale_string_search',
+ 'weight' => 10,
+ 'type' => MENU_LOCAL_TASK,
+ );
+
+ // Manage languages subtabs
+ $items['admin/settings/locale/language/overview'] = array(
+ 'title' => t('List'),
+ 'weight' => 0,
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ );
+ $items['admin/settings/locale/language/add'] = array(
+ 'title' => t('Add language'),
+ 'page callback' => 'locale_admin_manage_add',
+ 'weight' => 5,
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/settings/locale/language/import'] = array(
+ 'title' => t('Import'),
+ 'page callback' => 'locale_admin_import',
+ 'weight' => 10,
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/settings/locale/language/export'] = array(
+ 'title' => t('Export'),
+ 'page callback' => 'locale_admin_export',
+ 'weight' => 20,
+ 'type' => MENU_LOCAL_TASK,
+ );
+
+ // Language related callbacks
+ $items['admin/settings/locale/language/delete'] = array(
+ 'title' => t('Confirm'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('locale_admin_manage_delete_form'),
+ 'type' => MENU_CALLBACK,
+ );
+ // String related callbacks
+ $items['admin/settings/locale/string/edit/%'] = array(
+ 'title' => t('Edit string'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('locale_admin_string_edit', 5),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/settings/locale/string/delete/%'] = array(
+ 'title' => t('Delete string'),
+ 'page callback' => 'locale_admin_string_delete',
+ 'page arguments' => array(5),
+ 'type' => MENU_CALLBACK,
+ );
return $items;
}
@@ -341,7 +332,6 @@ function locale_admin_manage_delete_form_submit($form_id, $form_values) {
}
// Changing the locale settings impacts the interface:
- cache_clear_all('*', 'cache_menu', TRUE);
cache_clear_all('*', 'cache_page', TRUE);
return 'admin/settings/locale/language/overview';
diff --git a/modules/menu/menu.module b/modules/menu/menu.module
index 0c0f25699..1b5bd7a8c 100644
--- a/modules/menu/menu.module
+++ b/modules/menu/menu.module
@@ -34,7 +34,8 @@ Menu administration tabs:
/**
* Implementation of hook_menu().
*/
-function menu_menu($may_cache) {
+function menu_menu() {
+ return;
$items = array();
if ($may_cache) {
diff --git a/modules/node/node.module b/modules/node/node.module
index bab68e652..d136bde84 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1054,189 +1054,162 @@ function node_link($type, $node = NULL, $teaser = FALSE) {
return $links;
}
+function _node_revision_access($node) {
+ return (user_access('view revisions') || user_access('administer nodes')) && node_access('view', $node) && db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $node->nid)) > 1;
+}
+
/**
* Implementation of hook_menu().
*/
-function node_menu($may_cache) {
- $items = array();
- if ($may_cache) {
- $items[] = array('path' => 'admin/content',
- 'title' => t('Content management'),
- 'description' => t("Manage your site's content."),
- 'position' => 'left',
- 'weight' => -10,
- 'callback' => 'system_admin_menu_block_page',
- 'access' => user_access('administer site configuration'),
- );
-
- $items[] = array(
- 'path' => 'admin/content/node',
- 'title' => t('Content'),
- 'description' => t("View, edit, and delete your site's content."),
- 'callback' => 'node_admin_content',
- 'access' => user_access('administer nodes')
- );
+function node_menu() {
+ $items['admin/content'] = array(
+ 'title' => t('Content management'),
+ 'description' => t("Manage your site's content."),
+ 'position' => 'left',
+ 'weight' => -10,
+ 'page callback' => 'system_admin_menu_block_page',
+ 'access arguments' => array('administer site configuration'),
+ );
- $items[] = array('path' => 'admin/content/node/overview', 'title' => t('List'),
- 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
+ $items['admin/content/node'] = array(
+ 'title' => t('Content'),
+ 'description' => t("View, edit, and delete your site's content."),
+ 'page callback' => 'node_admin_content',
+ 'access arguments' => array('administer nodes'),
+ );
- if (module_exists('search')) {
- $items[] = array('path' => 'admin/content/search', 'title' => t('Search content'),
- 'description' => t('Search content by keyword.'),
- 'callback' => 'node_admin_search',
- 'access' => user_access('administer nodes'),
- 'type' => MENU_NORMAL_ITEM);
- }
+ $items['admin/content/node/overview'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
- $items[] = array(
- 'path' => 'admin/content/node-settings',
- 'title' => t('Post settings'),
- 'description' => t('Control posting behavior, such as teaser length, requiring previews before posting, and the number of posts on the front page.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('node_configure'),
- 'access' => user_access('administer nodes')
- );
- $items[] = array(
- 'path' => 'admin/content/node-settings/rebuild',
- 'title' => t('rebuild permissions'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('node_configure_rebuild_confirm'),
- 'access' => user_access('administer nodes'),
- 'type' => MENU_CALLBACK);
-
- $items[] = array(
- 'path' => 'admin/content/types',
- 'title' => t('Content types'),
- 'description' => t('Manage posts by content type, including default status, front page promotion, etc.'),
- 'callback' => 'node_overview_types',
- 'access' => user_access('administer content types'),
- );
- $items[] = array(
- 'path' => 'admin/content/types/list',
- 'title' => t('List'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10,
+ if (module_exists('search')) {
+ $items['admin/content/search'] = array(
+ 'title' => t('Search content'),
+ 'description' => t('Search content by keyword.'),
+ 'page callback' => 'node_admin_search',
+ 'access arguments' => array('administer nodes'),
);
- $items[] = array(
- 'path' => 'admin/content/types/add',
- 'title' => t('Add content type'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('node_type_form'),
- 'type' => MENU_LOCAL_TASK,
- );
- $items[] = array('path' => 'node',
- 'title' => t('Content'),
- 'callback' => 'node_page_default',
- 'access' => user_access('access content'),
- 'type' => MENU_MODIFIABLE_BY_ADMIN);
- $items[] = array('path' => 'node/add',
- 'title' => t('Create content'),
- 'callback' => 'node_add',
- 'access' => user_access('access content'),
- 'type' => MENU_ITEM_GROUPING,
- 'weight' => 1);
- $items[] = array('path' => 'rss.xml', 'title' => t('RSS feed'),
- 'callback' => 'node_feed',
- 'access' => user_access('access content'),
- 'type' => MENU_CALLBACK);
-
- foreach (node_get_types() as $type) {
- if (function_exists($type->module .'_form')) {
- $name = check_plain($type->name);
- $type_url_str = str_replace('_', '-', $type->type);
- $items[] = array(
- 'path' => 'node/add/'. $type_url_str,
- 'title' => drupal_ucfirst($name),
- 'access' => node_access('create', $type->type),
- );
- }
- }
- // Error pages must to be present in the menu cache and be accessible to
- // all. More often than not these are individual nodes.
- for ($error_code = 403; $error_code <= 404; $error_code++) {
- if (preg_match('|^node/(?P<nid>\d+)(?:/view)?$|', drupal_get_normal_path(variable_get('site_'. $error_code, '')), $matches) && ($node = node_load($matches['nid']))) {
- $items[] = array(
- 'path' => 'node/'. $node->nid,
- 'title' => t('View'),
- 'callback' => 'node_page_view',
- 'callback arguments' => array($node),
- 'access' => TRUE,
- 'type' => MENU_CALLBACK,
- );
- }
- }
}
- else {
- // Add the CSS for this module
- // We put this in !$may_cache so it's only added once per request
- drupal_add_css(drupal_get_path('module', 'node') .'/node.css');
-
- if (arg(0) == 'node' && is_numeric(arg(1))) {
- $node = node_load(arg(1));
- if ($node->nid) {
- $items[] = array('path' => 'node/'. arg(1), 'title' => t('View'),
- 'callback' => 'node_page_view',
- 'callback arguments' => array($node),
- 'access' => node_access('view', $node),
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'node/'. arg(1) .'/view', 'title' => t('View'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10);
- $items[] = array('path' => 'node/'. arg(1) .'/edit', 'title' => t('Edit'),
- 'callback' => 'node_page_edit',
- 'callback arguments' => array($node),
- 'access' => node_access('update', $node),
- 'weight' => 1,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'node/'. arg(1) .'/delete', 'title' => t('Delete'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('node_delete_confirm', $node),
- 'access' => node_access('delete', $node),
- 'weight' => 1,
- 'type' => MENU_CALLBACK);
- $revisions_access = ((user_access('view revisions') || user_access('administer nodes')) && node_access('view', $node) && db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', arg(1))) > 1);
- $items[] = array('path' => 'node/'. arg(1) .'/revisions', 'title' => t('Revisions'),
- 'callback' => 'node_revisions',
- 'access' => $revisions_access,
- 'weight' => 2,
- 'type' => MENU_LOCAL_TASK);
- }
- }
- // Content type configuration.
- if (arg(0) == 'admin' && arg(1) == 'content' && arg(2) == 'types') {
- include_once './'. drupal_get_path('module', 'node') .'/content_types.inc';
-
- if (arg(3) != NULL) {
- $type_name = arg(3);
- $type_name = !empty($type_name) ? str_replace('-', '_', $type_name) : NULL;
- $type = node_get_types('type', $type_name);
-
- if (!empty($type)) {
- $type->name = check_plain($type->name);
- $type_url_str = str_replace('_', '-', $type->type);
-
- $items[] = array(
- 'path' => 'admin/content/types/'. $type_url_str,
- 'title' => t($type->name),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('node_type_form', $type),
- 'type' => MENU_CALLBACK,
- );
- $items[] = array(
- 'path' => 'admin/content/types/'. $type_url_str .'/delete',
- 'title' => t('Delete'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('node_type_delete_confirm', $type),
- 'type' => MENU_CALLBACK,
- );
- }
- }
+ $items['admin/content/node-settings'] = array(
+ 'title' => t('Post settings'),
+ 'description' => t('Control posting behavior, such as teaser length, requiring previews before posting, and the number of posts on the front page.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('node_configure'),
+ 'access arguments' => array('administer nodes'),
+ );
+ $items['admin/content/node-settings/rebuild'] = array(
+ 'title' => t('rebuild permissions'),
+ 'page arguments' => array('node_configure_rebuild_confirm'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['admin/content/types'] = array(
+ 'title' => t('Content types'),
+ 'description' => t('Manage posts by content type, including default status, front page promotion, etc.'),
+ 'page callback' => 'node_overview_types',
+ 'access arguments' => array('administer content types'),
+ );
+ $items['admin/content/types/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['admin/content/types/add'] = array(
+ 'title' => t('Add content type'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('node_type_form'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['node'] = array(
+ 'title' => t('Content'),
+ 'page callback' => 'node_page_default',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_MODIFIABLE_BY_ADMIN,
+ );
+ $items['node/add'] = array(
+ 'title' => t('Create content'),
+ 'page callback' => 'node_add',
+ 'access callback' => 'user_access',
+ 'access arguments' => array('access content'),
+ 'weight' => 1,
+ );
+ $items['rss.xml'] = array(
+ 'title' => t('RSS feed'),
+ 'page callback' => 'node_feed',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+ foreach (node_get_types() as $type) {
+ if (function_exists($type->module .'_form')) {
+ $name = check_plain($type->name);
+ $type_url_str = str_replace('_', '-', $type->type);
+ $items['node/add/'. $type_url_str] = array(
+ 'title' => drupal_ucfirst($name),
+ 'page arguments' => array(2),
+ 'access callback' => 'node_access',
+ 'access arguments' => array('create', $type->type),
+ );
+ $items['admin/content/types/'. $type_url_str] = array(
+ 'title' => t($type->name),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('node_type_form', $type),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/content/types/'. $type_url_str .'/delete'] = array(
+ 'title' => t('Delete'),
+ 'page arguments' => array('node_type_delete_confirm', $type),
+ 'type' => MENU_CALLBACK,
+ );
+
}
}
+ $items['node/%'] = array(
+ 'title' => t('View'),
+ 'page callback' => 'node_page_view',
+ 'page arguments' => array(1),
+ 'access callback' => 'node_access',
+ 'access arguments' => array('view', 1),
+ 'map arguments' => array('node_load', 1),
+ 'type' => MENU_CALLBACK);
+ $items['node/%/view'] = array(
+ 'title' => t('View'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10);
+ $items['node/%/edit'] = array(
+ 'title' => t('Edit'),
+ 'page callback' => 'node_page_edit',
+ 'page arguments' => array(1),
+ 'access arguments' => array('update', 1),
+ 'weight' => 1,
+ 'type' => MENU_LOCAL_TASK);
+ $items['node/%/delete'] = array(
+ 'title' => t('Delete'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('node_delete_confirm', 1),
+ 'access arguments' => array('delete', 1),
+ 'weight' => 1,
+ 'type' => MENU_CALLBACK);
+ $items['node/%/revisions'] = array(
+ 'title' => t('Revisions'),
+ 'page callback' => 'node_revisions',
+ 'access callback' => '_node_revision_access',
+ 'access arguments' => array(1),
+ 'weight' => 2,
+ 'type' => MENU_LOCAL_TASK,
+ );
return $items;
}
+function node_init() {
+ if (arg(0) == 'admin' && arg(1) == 'content' && arg(2) == 'types') {
+ include_once './'. drupal_get_path('module', 'node') .'/content_types.inc';
+ }
+ drupal_add_css(drupal_get_path('module', 'node') .'/node.css');
+}
+
function node_last_changed($nid) {
$node = db_fetch_object(db_query('SELECT changed FROM {node} WHERE nid = %d', $nid));
return ($node->changed);
@@ -2636,9 +2609,12 @@ function node_search_validate($form_id, $form_values, $form) {
* @return
* TRUE if the operation may be performed.
*/
-function node_access($op, $node = NULL) {
+function node_access($op, $node) {
global $user;
+ if (!$node) {
+ return FALSE;
+ }
// Convert the node to an object if necessary:
if ($op != 'create') {
$node = (object)$node;
diff --git a/modules/path/path.module b/modules/path/path.module
index b27d5afde..b52f47254 100644
--- a/modules/path/path.module
+++ b/modules/path/path.module
@@ -35,32 +35,37 @@ function path_help($section) {
/**
* Implementation of hook_menu().
*/
-function path_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- $items[] = array('path' => 'admin/build/path', 'title' => t('URL aliases'),
- 'description' => t('Change your site\'s URL paths by aliasing them.'),
- 'callback' => 'path_admin',
- 'access' => user_access('administer url aliases'));
- $items[] = array('path' => 'admin/build/path/edit', 'title' => t('Edit alias'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('path_admin_edit'),
- 'access' => user_access('administer url aliases'),
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/build/path/delete', 'title' => t('Delete alias'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('path_admin_delete_confirm'),
- 'access' => user_access('administer url aliases'),
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/build/path/list', 'title' => t('List'),
- 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
- $items[] = array('path' => 'admin/build/path/add', 'title' => t('Add alias'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('path_admin_edit'),
- 'access' => user_access('administer url aliases'),
- 'type' => MENU_LOCAL_TASK);
- }
+function path_menu() {
+ $items['admin/build/path'] = array(
+ 'title' => t('URL aliases'),
+ 'description' => t('Change your site\'s URL paths by aliasing them.'),
+ 'page callback' => 'path_admin',
+ 'access arguments' => array('administer url aliases'),
+ );
+ $items['admin/build/path/edit'] = array(
+ 'title' => t('Edit alias'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('path_admin_edit'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/build/path/delete'] = array(
+ 'title' => t('Delete alias'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('path_admin_delete_confirm'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/build/path/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['admin/build/path/add'] = array(
+ 'title' => t('Add alias'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('path_admin_edit'),
+ 'access arguments' => array('administer url aliases'),
+ 'type' => MENU_LOCAL_TASK,
+ );
return $items;
}
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 195d3b3b8..44b1613e6 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -224,59 +224,51 @@ function poll_insert($node) {
}
}
+function _poll_menu_access($node, $perm, $inspect_allowvotes) {
+ return user_access($perm) && ($node->type == 'poll') && ($node->allowvotes || !$inspect_allowvotes);
+}
+
/**
* Implementation of hook_menu().
*/
-function poll_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- $items[] = array('path' => 'poll', 'title' => t('Polls'),
- 'callback' => 'poll_page',
- 'access' => user_access('access content'),
- 'type' => MENU_SUGGESTED_ITEM);
-
- $items[] = array('path' => 'poll/vote',
- 'title' => t('Vote'),
- 'callback' => 'poll_vote',
- 'access' => user_access('vote on polls'),
- 'type' => MENU_CALLBACK);
-
- $items[] = array('path' => 'poll/cancel',
- 'title' => t('Cancel'),
- 'callback' => 'poll_cancel',
- 'access' => user_access('cancel own vote'),
- 'type' => MENU_CALLBACK);
- }
- else {
- // Add the CSS for this module
- // We put this in !$may_cache so it's only added once per request
- drupal_add_css(drupal_get_path('module', 'poll') .'/poll.css');
-
- if (arg(0) == 'node' && is_numeric(arg(1))) {
- $node = node_load(arg(1));
- if ($node->type == 'poll') {
- $items[] = array('path' => 'node/'. arg(1) .'/votes',
- 'title' => t('Votes'),
- 'callback' => 'poll_votes',
- 'access' => user_access('inspect all votes'),
- 'weight' => 3,
- 'type' => MENU_LOCAL_TASK);
- }
- if ($node->type == 'poll' && $node->allowvotes) {
- $items[] = array('path' => 'node/'. arg(1) .'/results',
- 'title' => t('Results'),
- 'callback' => 'poll_results',
- 'access' => user_access('access content'),
- 'weight' => 3,
- 'type' => MENU_LOCAL_TASK);
- }
- }
- }
+function poll_menu() {
+ $items['poll'] = array(
+ 'title' => t('Polls'),
+ 'page callback' => 'poll_page',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ );
+ $items['poll/cancel/%'] = array(
+ 'title' => t('Cancel'),
+ 'page callback' => 'poll_cancel',
+ 'page arguments' => array(2),
+ 'access arguments' => array('cancel own vote'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['node/%/votes'] = array(
+ 'title' => t('Votes'),
+ 'page callback' => 'poll_votes',
+ 'access callback' => '_poll_menu_access',
+ 'access arguments' => array(1, 'inspect all votes', FALSE),
+ 'weight' => 3,
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['node/%/results'] = array(
+ 'title' => t('Results'),
+ 'page callback' => 'poll_results',
+ 'access callback' => '_poll_menu_access',
+ 'access arguments' => array(1, 'access content', TRUE),
+ 'weight' => 3,
+ 'type' => MENU_LOCAL_TASK,
+ );
return $items;
}
+function poll_init() {
+ drupal_add_css(drupal_get_path('module', 'poll') .'/poll.css');
+}
+
/**
* Implementation of hook_load().
*/
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index bc7eeb8d2..51f3512ab 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -54,45 +54,47 @@ function profile_help($section) {
/**
* Implementation of hook_menu().
*/
-function profile_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- $items[] = array('path' => 'profile',
- 'title' => t('User list'),
- 'callback' => 'profile_browse',
- 'access' => user_access('access user profiles'),
- 'type' => MENU_SUGGESTED_ITEM);
- $items[] = array('path' => 'admin/user/profile',
- 'title' => t('Profiles'),
- 'description' => t('Create customizable fields for your users.'),
- 'callback' => 'profile_admin_overview');
- $items[] = array('path' => 'admin/user/profile/add',
- 'title' => t('Add field'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('profile_field_form'),
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/user/profile/autocomplete',
- 'title' => t('Profile category autocomplete'),
- 'callback' => 'profile_admin_settings_autocomplete',
- 'access' => user_access('administer users'),
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/user/profile/edit',
- 'title' => t('Edit field'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('profile_field_form'),
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/user/profile/delete',
- 'title' => t('Delete field'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('profile_field_delete'),
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'profile/autocomplete', 'title' => t('Profile autocomplete'),
- 'callback' => 'profile_autocomplete',
- 'access' => 1,
- 'type' => MENU_CALLBACK);
- }
-
+function profile_menu() {
+ $items['profile'] = array(
+ 'title' => t('User list'),
+ 'page callback' => 'profile_browse',
+ 'access arguments' => array('access user profiles'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ );
+ $items['admin/user/profile'] = array(
+ 'title' => t('Profiles'),
+ 'description' => t('Create customizable fields for your users.'),
+ 'page callback' => 'profile_admin_overview',
+ );
+ $items['admin/user/profile/add'] = array(
+ 'title' => t('Add field'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('profile_field_form'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/user/profile/autocomplete'] = array(
+ 'title' => t('Profile category autocomplete'),
+ 'page callback' => 'profile_admin_settings_autocomplete',
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/user/profile/edit'] = array(
+ 'title' => t('Edit field'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('profile_field_form'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/user/profile/delete'] = array(
+ 'title' => t('Delete field'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('profile_field_delete'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['profile/autocomplete'] = array(
+ 'title' => t('Profile autocomplete'),
+ 'page callback' => 'profile_autocomplete',
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
return $items;
}
diff --git a/modules/search/search.module b/modules/search/search.module
index 99c9fe914..7e8d21d44 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -136,53 +136,62 @@ function search_block($op = 'list', $delta = 0) {
/**
* Implementation of hook_menu().
*/
-function search_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- $items[] = array('path' => 'search',
- 'title' => t('Search'),
- 'callback' => 'search_view',
- 'callback arguments' => array('node'),
- 'access' => user_access('search content'),
- 'type' => MENU_SUGGESTED_ITEM);
- $items[] = array('path' => 'admin/settings/search',
- 'title' => t('Search settings'),
- 'description' => t('Configure relevance settings for search and other indexing options'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('search_admin_settings'),
- 'access' => user_access('administer search'),
- 'type' => MENU_NORMAL_ITEM);
- $items[] = array('path' => 'admin/settings/search/wipe',
- 'title' => t('Clear index'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('search_wipe_confirm'),
- 'access' => user_access('administer search'),
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/logs/search', 'title' => t('Top search phrases'),
- 'description' => t('View most popular search phrases.'),
- 'callback' => 'watchdog_top',
- 'callback arguments' => array('search'));
+function search_menu() {
+ $items['search'] = array(
+ 'title' => t('Search'),
+ 'page callback' => 'search_view',
+ 'page arguments' => array('node'),
+ 'access arguments' => array('search content'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ );
+ $items['admin/settings/search'] = array(
+ 'title' => t('Search settings'),
+ 'description' => t('Configure relevance settings for search and other indexing options'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('search_admin_settings'),
+ 'access arguments' => array('administer search'),
+ 'type' => MENU_NORMAL_ITEM,
+ );
+ $items['admin/settings/search/wipe'] = array(
+ 'title' => t('Clear index'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('search_wipe_confirm'),
+ 'access arguments' => array('administer search'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/logs/search'] = array(
+ 'title' => t('Top search phrases'),
+ 'description' => t('View most popular search phrases.'),
+ 'page callback' => 'watchdog_top',
+ 'page arguments' => array('search'),
+ );
+
+ foreach (module_implements('search') as $name) {
+ $items['search/'. $name] = array(
+ 'page callback' => 'search_view',
+ 'page arguments' => array($name),
+ 'access callback' => FALSE,
+ 'type' => MENU_LOCAL_TASK,
+ );
}
- else if (arg(0) == 'search') {
- // To remember the user's search keywords when switching across tabs,
- // we dynamically add the keywords to the search tabs' paths.
+ return $items;
+}
+
+function search_init() {
+ // To remember the user's search keywords when switching across tabs,
+ // we dynamically add the keywords to the search tabs' paths.
+ if (arg(0) == 'search') {
$keys = search_get_keys();
$keys = strlen($keys) ? '/'. $keys : '';
foreach (module_implements('search') as $name) {
$title = module_invoke($name, 'search', 'name');
- $items[] = array('path' => 'search/'. $name . $keys, 'title' => $title,
- 'callback' => 'search_view',
- 'callback arguments' => array($name),
- // The search module only returns a title when the user is allowed to
- // access that particular search type.
- 'access' => user_access('search content') && $title,
- 'type' => MENU_LOCAL_TASK,
- );
+ $item = menu_get_item('search/'. $name);
+ $item->title = $title;
+ $item->access = user_access('search content') && $title;
+ menu_set_item('search/'. $name, $item);
+ menu_set_item('search/'. $name . $keys, $item);
}
}
-
- return $items;
}
/**
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 60fdf2662..23c29efcd 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -99,74 +99,65 @@ function statistics_link($type, $node = NULL, $teaser = FALSE) {
/**
* Implementation of hook_menu().
*/
-function statistics_menu($may_cache) {
- $items = array();
-
- $access = user_access('access statistics');
- if ($may_cache) {
- $items[] = array(
- 'path' => 'admin/logs/hits',
- 'title' => t('Recent hits'),
- 'description' => t('View pages that have recently been visited.'),
- 'callback' => 'statistics_recent_hits',
- 'access' => $access);
- $items[] = array(
- 'path' => 'admin/logs/pages',
- 'title' => t('Top pages'),
- 'description' => t('View pages that have been hit frequently.'),
- 'callback' => 'statistics_top_pages',
- 'access' => $access,
- 'weight' => 1);
- $items[] = array(
- 'path' => 'admin/logs/visitors',
- 'title' => t('Top visitors'),
- 'description' => t('View visitors that hit many pages.'),
- 'callback' => 'statistics_top_visitors',
- 'access' => $access,
- 'weight' => 2);
- $items[] = array(
- 'path' => 'admin/logs/referrers',
- 'title' => t('Top referrers'),
- 'description' => t('View top referrers.'),
- 'callback' => 'statistics_top_referrers',
- 'access' => $access);
- $items[] = array(
- 'path' => 'admin/logs/access',
- 'title' => t('Details'),
- 'description' => t('View access log.'),
- 'callback' => 'statistics_access_log',
- 'access' => $access,
- 'type' => MENU_CALLBACK);
- $items[] = array(
- 'path' => 'admin/logs/settings',
- 'title' => t('Access log settings'),
- 'description' => t('Control details about what and how your site logs.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('statistics_access_logging_settings'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => 3);
- }
- else {
- if (arg(0) == 'user' && is_numeric(arg(1)) && variable_get('statistics_enable_access_log', 0)) {
- $items[] = array(
- 'path' => 'user/'. arg(1) .'/track/navigation',
- 'title' => t('Track page visits'),
- 'callback' => 'statistics_user_tracker',
- 'access' => $access,
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2);
- }
- if (arg(0) == 'node' && is_numeric(arg(1)) && variable_get('statistics_enable_access_log', 0)) {
- $items[] = array(
- 'path' => 'node/'. arg(1) .'/track',
- 'title' => t('Track'),
- 'callback' => 'statistics_node_tracker',
- 'access' => $access,
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2);
- }
- }
+function statistics_menu() {
+ $items['admin/logs/hits'] = array(
+ 'title' => t('Recent hits'),
+ 'description' => t('View pages that have recently been visited.'),
+ 'page callback' => 'statistics_recent_hits',
+ 'access arguments' => array('access statistics'),
+ );
+ $items['admin/logs/pages'] = array(
+ 'title' => t('Top pages'),
+ 'description' => t('View pages that have been hit frequently.'),
+ 'page callback' => 'statistics_top_pages',
+ 'access arguments' => array('access statistics'),
+ 'weight' => 1,
+ );
+ $items['admin/logs/visitors'] = array(
+ 'title' => t('Top visitors'),
+ 'description' => t('View visitors that hit many pages.'),
+ 'page callback' => 'statistics_top_visitors',
+ 'access arguments' => array('access statistics'),
+ 'weight' => 2,
+ );
+ $items['admin/logs/referrers'] = array(
+ 'title' => t('Top referrers'),
+ 'description' => t('View top referrers.'),
+ 'page callback' => 'statistics_top_referrers',
+ 'access arguments' => array('access statistics'),
+ );
+ $items['admin/logs/access/%'] = array(
+ 'title' => t('Details'),
+ 'description' => t('View access log.'),
+ 'page callback' => 'statistics_access_log',
+ 'page arguments' => array(3),
+ 'access arguments' => array('access statistics'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/logs/settings'] = array(
+ 'title' => t('Access log settings'),
+ 'description' => t('Control details about what and how your site logs.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('statistics_access_logging_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'type' => MENU_NORMAL_ITEM,
+ 'weight' => 3,
+ );
+ $items['user/%/track/navigation'] = array(
+ 'title' => t('Track page visits'),
+ 'page callback' => 'statistics_user_tracker',
+ 'access arguments' => array('access statistics'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ );
+ $items['node/%/track'] = array(
+ 'title' => t('Track'),
+ 'page callback' => 'statistics_node_tracker',
+ 'access callback' => 'user_access',
+ 'access arguments' => array('access statistics'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ );
return $items;
}
diff --git a/modules/system/system.install b/modules/system/system.install
index 1b11c3914..dd56239e1 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -235,15 +235,6 @@ function system_install() {
PRIMARY KEY (cid),
INDEX expire (expire)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
- db_query("CREATE TABLE {cache_menu} (
- cid varchar(255) NOT NULL default '',
- data longblob,
- expire int NOT NULL default '0',
- created int NOT NULL default '0',
- headers text,
- PRIMARY KEY (cid),
- INDEX expire (expire)
- ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {cache_page} (
cid varchar(255) BINARY NOT NULL default '',
data longblob,
@@ -336,17 +327,29 @@ function system_install() {
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
db_query("CREATE TABLE {menu} (
- mid int unsigned NOT NULL default '0',
- pid int unsigned NOT NULL default '0',
path varchar(255) NOT NULL default '',
- title varchar(255) NOT NULL default '',
- description varchar(255) NOT NULL default '',
- weight tinyint NOT NULL default '0',
- type int unsigned NOT NULL default '0',
- PRIMARY KEY (mid)
+ access_callback varchar(255) NOT NULL default '',
+ access_arguments text,
+ page_callback varchar(255) NOT NULL default '',
+ page_arguments text,
+ map_callback varchar(255) NOT NULL default '',
+ map_arguments text,
+ fit int NOT NULL default '0',
+ number_parts int NOT NULL default '0',
+ vancode varchar(255) NOT NULL default '',
+ mid int NOT NULL default '0',
+ pid int NOT NULL default '0',
+ visible int NOT NULL default '0',
+ menu_link varchar(255) NOT NULL default '',
+ parents varchar(255) NOT NULL default '',
+ depth int NOT NULL default '0',
+ has_children int NOT NULL default '0',
+ PRIMARY KEY (path),
+ KEY vancode (vancode),
+ KEY fit (fit),
+ KEY visible (visible)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
-
db_query("CREATE TABLE {node} (
nid int unsigned NOT NULL auto_increment,
vid int unsigned NOT NULL default '0',
@@ -698,14 +701,6 @@ function system_install() {
headers text,
PRIMARY KEY (cid)
)");
- db_query("CREATE TABLE {cache_menu} (
- cid varchar(255) NOT NULL default '',
- data bytea,
- expire int NOT NULL default '0',
- created int NOT NULL default '0',
- headers text,
- PRIMARY KEY (cid)
- )");
db_query("CREATE TABLE {cache_page} (
cid varchar(255) NOT NULL default '',
data bytea,
@@ -716,7 +711,6 @@ function system_install() {
)");
db_query("CREATE INDEX {cache}_expire_idx ON {cache} (expire)");
db_query("CREATE INDEX {cache_filter}_expire_idx ON {cache_filter} (expire)");
- db_query("CREATE INDEX {cache_menu}_expire_idx ON {cache_menu} (expire)");
db_query("CREATE INDEX {cache_page}_expire_idx ON {cache_page} (expire)");
db_query("CREATE TABLE {comments} (
@@ -801,16 +795,29 @@ function system_install() {
)");
db_query("CREATE TABLE {menu} (
- mid serial CHECK (mid >= 0),
- pid int_unsigned NOT NULL default '0',
+ mid int NOT NULL default '0',
+ pid int NOT NULL default '0',
path varchar(255) NOT NULL default '',
- title varchar(255) NOT NULL default '',
- description varchar(255) NOT NULL default '',
- weight smallint NOT NULL default '0',
- type int_unsigned NOT NULL default '0',
- PRIMARY KEY (mid)
+ access_callback varchar(255) NOT NULL default '',
+ access_arguments text,
+ page_callback varchar(255) NOT NULL default '',
+ page_arguments text,
+ map_callback varchar(255) NOT NULL default '',
+ map_arguments text,
+ fit int NOT NULL default 0,
+ number_parts int NOT NULL default 0,
+ vancode varchar(255) NOT NULL default '',
+ visible int(11) NOT NULL default '0',
+ menu_link varchar(255) NOT NULL default '',
+ parents varchar(255) NOT NULL default '',
+ depth int NOT NULL default '0',
+ has_children int NOT NULL default '0',
+ PRIMARY KEY (path)
)");
- db_query("ALTER SEQUENCE {menu}_mid_seq MINVALUE 2 RESTART 2");
+
+ db_query("CREATE INDEX {menu}_vancode_idx ON {menu} (vancode)");
+ db_query("CREATE INDEX {menu}_fit_idx ON {menu} (fit)");
+ db_query("CREATE INDEX {menu}_visible_idx ON {menu} (visible)");
db_query("CREATE TABLE {node} (
nid serial CHECK (nid >= 0),
@@ -1104,10 +1111,6 @@ function system_install() {
db_query("INSERT INTO {variable} (name,value) VALUES ('filter_html_1','i:1;')");
db_query("INSERT INTO {variable} (name, value) VALUES ('node_options_forum', '%s')", 'a:1:{i:0;s:6:"status";}');
-
- db_query("INSERT INTO {menu} (mid, pid, path, title, description, weight, type) VALUES (2, 0, '', 'Primary links', '', 0, 115)");
- db_query("INSERT INTO {variable} VALUES ('menu_primary_menu', 'i:2;')");
- db_query("INSERT INTO {variable} VALUES ('menu_secondary_menu', 'i:2;')");
}
// Updates for core
diff --git a/modules/system/system.module b/modules/system/system.module
index 01636ff66..b78919f5c 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -86,240 +86,222 @@ function system_elements() {
/**
* Implementation of hook_menu().
*/
-function system_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- $items[] = array('path' => 'system/files', 'title' => t('File download'),
- 'callback' => 'file_download',
- 'access' => TRUE,
- 'type' => MENU_CALLBACK);
-
- $access = user_access('administer site configuration');
-
- $items[] = array('path' => 'admin', 'title' => t('Administer'),
- 'access' => user_access('access administration pages'),
- 'callback' => 'system_main_admin_page',
- 'weight' => 9);
- $items[] = array('path' => 'admin/compact', 'title' => t('Compact mode'),
- 'access' => user_access('access administration pages'),
- 'callback' => 'system_admin_compact_page',
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/by-task', 'title' => t('By task'),
- 'callback' => 'system_main_admin_page',
- 'type' => MENU_DEFAULT_LOCAL_TASK);
- $items[] = array('path' => 'admin/by-module', 'title' => t('By module'),
- 'callback' => 'system_admin_by_module',
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2);
-
- // menu items that are basically just menu blocks
- $items[] = array(
- 'path' => 'admin/settings',
- 'title' => t('Site configuration'),
- 'description' => t('Adjust basic site configuration options.'),
- 'position' => 'right',
- 'weight' => -5,
- 'callback' => 'system_settings_overview',
- 'access' => $access);
-
- $items[] = array('path' => 'admin/build',
- 'title' => t('Site building'),
- 'description' => t('Control how your site looks and feels.'),
- 'position' => 'right',
- 'weight' => -10,
- 'callback' => 'system_admin_menu_block_page',
- 'access' => $access);
-
- $items[] = array(
- 'path' => 'admin/settings/admin',
- 'title' => t('Administration theme'),
- 'description' => t('Settings for how your administrative pages should look.'),
- 'position' => 'left',
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_admin_theme_settings'),
- 'block callback' => 'system_admin_theme_settings',
- 'access' => $access);
-
- // Themes:
- $items[] = array(
- 'path' => 'admin/build/themes',
- 'title' => t('Themes'),
- 'description' => t('Change which theme your site uses or allows users to set.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_themes'),
- 'access' => $access);
-
- $items[] = array(
- 'path' => 'admin/build/themes/select',
- 'title' => t('List'),
- 'description' => t('Select the default theme.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_themes'),
- 'access' => $access,
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -1);
-
- $items[] = array('path' => 'admin/build/themes/settings',
- 'title' => t('Configure'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_theme_settings'),
- 'access' => $access,
- 'type' => MENU_LOCAL_TASK);
-
- // Theme configuration subtabs
- $items[] = array('path' => 'admin/build/themes/settings/global', 'title' => t('Global settings'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_theme_settings'),
- 'access' => $access,
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -1);
+function system_menu() {
+ $items['system/files'] = array(
+ 'title' => t('File download'),
+ 'page callback' => 'file_download',
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin'] = array(
+ 'title' => t('Administer'),
+ 'access arguments' => array('access administration pages'),
+ 'page callback' => 'system_main_admin_page',
+ 'weight' => 9,
+ );
+ $items['admin/compact'] = array(
+ 'title' => t('Compact mode'),
+ 'page callback' => 'system_admin_compact_page',
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/by-task'] = array(
+ 'title' => t('By task'),
+ 'page callback' => 'system_main_admin_page',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ );
+ $items['admin/by-module'] = array(
+ 'title' => t('By module'),
+ 'page callback' => 'system_admin_by_module',
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ );
+ // menu items that are basically just menu blocks
+ $items['admin/settings'] = array(
+ 'title' => t('Site configuration'),
+ 'description' => t('Adjust basic site configuration options.'),
+ 'position' => 'right',
+ 'weight' => -5,
+ 'page callback' => 'system_settings_overview',
+ 'access arguments' => array('administer site configuration'),
+ );
+ $items['admin/build'] = array(
+ 'title' => t('Site building'),
+ 'description' => t('Control how your site looks and feels.'),
+ 'position' => 'right',
+ 'weight' => -10,
+ 'page callback' => 'system_admin_menu_block_page',
+ 'access arguments' => array('administer site configuration'),
+ );
+ $items['admin/settings/admin'] = array(
+ 'title' => t('Administration theme'),
+ 'description' => t('Settings for how your administrative pages should look.'),
+ 'position' => 'left',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('system_admin_theme_settings'),
+ 'block callback' => 'system_admin_theme_settings',
+ );
+ // Themes:
+ $items['admin/build/themes'] = array(
+ 'title' => t('Themes'),
+ 'description' => t('Change which theme your site uses or allows users to set.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('system_themes'),
+ );
+ $items['admin/build/themes/select'] = array(
+ 'title' => t('List'),
+ 'description' => t('Select the default theme.'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -1,
+ );
+ $items['admin/build/themes/settings'] = array(
+ 'title' => t('Configure'),
+ 'page arguments' => array('system_theme_settings'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ // Theme configuration subtabs
+ $items['admin/build/themes/settings/global'] = array(
+ 'title' => t('Global settings'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -1,
+ );
- foreach (list_themes() as $theme) {
- if ($theme->status) {
- $items[] = array('path' => 'admin/build/themes/settings/'. $theme->name, 'title' => $theme->name,
- 'callback' => 'drupal_get_form', 'callback arguments' => array('system_theme_settings', $theme->name),
- 'access' => $access, 'type' => MENU_LOCAL_TASK);
- }
+ foreach (list_themes() as $theme) {
+ if ($theme->status) {
+ $items['admin/build/themes/settings/'. $theme->name] = array(
+ 'title' => $theme->name,
+ 'page arguments' => array('system_theme_settings', $theme->name),
+ 'type' => MENU_LOCAL_TASK,
+ );
}
-
- // Modules:
- $items[] = array('path' => 'admin/build/modules',
- 'title' => t('Modules'),
- 'description' => t('Enable or disable add-on modules for your site.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_modules'),
- 'access' => $access);
- $items[] = array('path' => 'admin/build/modules/list',
- 'title' => t('List'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'access' => $access);
- $items[] = array('path' => 'admin/build/modules/list/confirm',
- 'title' => t('List'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_modules'),
- 'type' => MENU_CALLBACK,
- 'access' => $access);
- $items[] = array('path' => 'admin/build/modules/uninstall',
- 'title' => t('Uninstall'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_modules_uninstall'),
- 'type' => MENU_LOCAL_TASK,
- 'access' => $access);
- $items[] = array('path' => 'admin/build/modules/uninstall/confirm',
- 'title' => t('Uninstall'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_modules_uninstall'),
- 'type' => MENU_CALLBACK,
- 'access' => $access);
-
- // Settings:
- $items[] = array(
- 'path' => 'admin/settings/site-information',
- 'title' => t('Site information'),
- 'description' => t('Change basic site information, such as the site name, slogan, e-mail address, mission, front page and more.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_site_information_settings'));
- $items[] = array(
- 'path' => 'admin/settings/error-reporting',
- 'title' => t('Error reporting'),
- 'description' => t('Control how Drupal deals with errors including 403/404 errors as well as PHP error reporting.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_error_reporting_settings'));
- $items[] = array(
- 'path' => 'admin/settings/performance',
- 'title' => t('Performance'),
- 'description' => t('Enable or disable page caching for anonymous users, and enable or disable CSS preprocessor.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_performance_settings'));
- $items[] = array(
- 'path' => 'admin/settings/file-system',
- 'title' => t('File system'),
- 'description' => t('Tell Drupal where to store uploaded files and how they are accessed.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_file_system_settings'));
- $items[] = array(
- 'path' => 'admin/settings/image-toolkit',
- 'title' => t('Image toolkit'),
- 'description' => t('Choose which image toolkit to use if you have installed optional toolkits.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_image_toolkit_settings'));
- $items[] = array(
- 'path' => 'admin/content/rss-publishing',
- 'title' => t('RSS publishing'),
- 'description' => t('Configure the number of items per feed and whether feeds should be titles/teasers/full-text.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_rss_feeds_settings'));
- $items[] = array(
- 'path' => 'admin/settings/date-time',
- 'title' => t('Date and time'),
- 'description' => t("Settings for how Drupal displays date and time, as well as the system's default timezone."),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_date_time_settings'));
- $items[] = array(
- 'path' => 'admin/settings/site-maintenance',
- 'title' => t('Site maintenance'),
- 'description' => t('Take the site off-line for maintenance or bring it back online.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_site_maintenance_settings'));
- $items[] = array(
- 'path' => 'admin/settings/clean-urls',
- 'title' => t('Clean URLs'),
- 'description' => t('Enable or disable clean URLs for your site.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_clean_url_settings'));
-
-
- // Logs:
- $items[] = array(
- 'path' => 'admin/logs',
- 'title' => t('Logs'),
- 'description' => t('View system logs and other status information.'),
- 'callback' => 'system_admin_menu_block_page',
- 'weight' => 5,
- 'position' => 'left');
- $items[] = array(
- 'path' => 'admin/logs/status',
- 'title' => t('Status report'),
- 'description' => t("Get a status report about your site's operation and any detected problems."),
- 'callback' => 'system_status',
- 'weight' => 10,
- 'access' => $access);
- $items[] = array(
- 'path' => 'admin/logs/status/run-cron',
- 'title' => t('Run cron'),
- 'callback' => 'system_run_cron',
- 'type' => MENU_CALLBACK);
- $items[] = array(
- 'path' => 'admin/logs/status/php',
- 'title' => t('PHP'),
- 'callback' => 'system_php',
- 'type' => MENU_CALLBACK);
- $items[] = array(
- 'path' => 'admin/logs/status/sql',
- 'title' => t('SQL'),
- 'callback' => 'system_sql',
- 'type' => MENU_CALLBACK);
}
- else {
- /**
- * Use the administrative theme if the user is looking at a page in the admin/* path.
- */
- if (arg(0) == 'admin') {
- global $custom_theme;
- $custom_theme = variable_get('admin_theme', '0');
- drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
- }
- // Add the CSS for this module. We put this in !$may_cache so it is only
- // added once per request.
- drupal_add_css(drupal_get_path('module', 'system') .'/defaults.css', 'module');
- drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'module');
- }
+ // Modules:
+ $items['admin/build/modules'] = array(
+ 'title' => t('Modules'),
+ 'description' => t('Enable or disable add-on modules for your site.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('system_modules'),
+ );
+ $items['admin/build/modules/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ );
+ $items['admin/build/modules/list/confirm'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/build/modules/uninstall'] = array(
+ 'title' => t('Uninstall'),
+ 'page arguments' => array('system_modules_uninstall'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/build/modules/uninstall/confirm'] = array(
+ 'title' => t('Uninstall'),
+ 'type' => MENU_CALLBACK,
+ );
+ // Settings:
+ $items['admin/settings/site-information'] = array(
+ 'title' => t('Site information'),
+ 'description' => t('Change basic site information, such as the site name, slogan, e-mail address, mission, front page and more.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('system_site_information_settings'),
+ );
+ $items['admin/settings/error-reporting'] = array(
+ 'title' => t('Error reporting'),
+ 'description' => t('Control how Drupal deals with errors including 403/404 errors as well as PHP error reporting.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('system_error_reporting_settings'),
+ );
+ $items['admin/settings/performance'] = array(
+ 'title' => t('Performance'),
+ 'description' => t('Enable or disable page caching for anonymous users, and enable or disable CSS preprocessor.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('system_performance_settings'),
+ );
+ $items['admin/settings/file-system'] = array(
+ 'title' => t('File system'),
+ 'description' => t('Tell Drupal where to store uploaded files and how they are accessed.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('system_file_system_settings'),
+ );
+ $items['admin/settings/image-toolkit'] = array(
+ 'title' => t('Image toolkit'),
+ 'description' => t('Choose which image toolkit to use if you have installed optional toolkits.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('system_image_toolkit_settings'),
+ );
+ $items['admin/content/rss-publishing'] = array(
+ 'title' => t('RSS publishing'),
+ 'description' => t('Configure the number of items per feed and whether feeds should be titles/teasers/full-text.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('system_rss_feeds_settings'),
+ );
+ $items['admin/settings/date-time'] = array(
+ 'title' => t('Date and time'),
+ 'description' => t("Settings for how Drupal displays date and time, as well as the system's default timezone."),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('system_date_time_settings'),
+ );
+ $items['admin/settings/site-maintenance'] = array(
+ 'title' => t('Site maintenance'),
+ 'description' => t('Take the site off-line for maintenance or bring it back online.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('system_site_maintenance_settings'),
+ );
+ $items['admin/settings/clean-urls'] = array(
+ 'title' => t('Clean URLs'),
+ 'description' => t('Enable or disable clean URLs for your site.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('system_clean_url_settings'),
+ );
+
+ // Logs:
+ $items['admin/logs'] = array(
+ 'title' => t('Logs'),
+ 'description' => t('View system logs and other status information.'),
+ 'page callback' => 'system_admin_menu_block_page',
+ 'weight' => 5,
+ 'position' => 'left',
+ );
+ $items['admin/logs/status'] = array(
+ 'title' => t('Status report'),
+ 'description' => t("Get a status report about your site's operation and any detected problems."),
+ 'page callback' => 'system_status',
+ 'weight' => 10,
+ 'access arguments' => array('administer site configuration'),
+ );
+ $items['admin/logs/status/run-cron'] = array(
+ 'title' => t('Run cron'),
+ 'page callback' => 'system_run_cron',
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/logs/status/php'] = array(
+ 'title' => t('PHP'),
+ 'page callback' => 'system_php',
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/logs/status/sql'] = array(
+ 'title' => t('SQL'),
+ 'page callback' => 'system_sql',
+ 'type' => MENU_CALLBACK,
+ );
return $items;
}
+function system_init() {
+ // Use the administrative theme if the user is looking at a page in the admin/* path.
+ if (arg(0) == 'admin') {
+ global $custom_theme;
+ $custom_theme = variable_get('admin_theme', '0');
+ drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
+ }
+
+ // Add the CSS for this module.
+ drupal_add_css(drupal_get_path('module', 'system') .'/defaults.css', 'module');
+ drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'module');
+}
+
/**
* Implementation of hook_user().
*
@@ -354,6 +336,7 @@ function system_user($type, $edit, &$user, $category = NULL) {
* Provide the administration overview page.
*/
function system_main_admin_page($arg = NULL) {
+ return 'This page awaits rewrite'; // TODO: this needs to be rewritten for the new menu system.
// If we received an argument, they probably meant some other page.
// Let's 404 them since the menu system cannot be told we do not
// accept arguments.
@@ -386,6 +369,7 @@ function system_main_admin_page($arg = NULL) {
* Provide a single block on the administration overview page.
*/
function system_admin_menu_block($block) {
+ return 'This page awaits rewrite'; // TODO: this needs to be rewritten for the new menu system.
$content = array();
if (is_array($block['children'])) {
usort($block['children'], '_menu_sort');
@@ -407,6 +391,7 @@ function system_admin_menu_block($block) {
* hidden, so we supply the contents of the block.
*/
function system_admin_menu_block_page() {
+ return 'This page awaits rewrite'; // TODO: this needs to be rewritten for the new menu system.
$menu = menu_get_item(NULL, $_GET['q']);
$content = system_admin_menu_block($menu);
@@ -1890,7 +1875,7 @@ function theme_status_report(&$requirements) {
* Menu callback; displays a module's settings page.
*/
function system_settings_overview() {
-
+ return 'This page awaits rewrite'; // TODO: this needs to be rewritten for the new menu system.
// Check database setup if necessary
if (function_exists('db_check_setup') && empty($_POST)) {
db_check_setup();
@@ -2279,6 +2264,7 @@ function theme_admin_block_content($content) {
* Menu callback; prints a listing of admin tasks for each installed module.
*/
function system_admin_by_module() {
+ return 'This page awaits rewrite'; // TODO: this needs to be rewritten for the new menu system.
$modules = module_rebuild_cache();
$menu_items = array();
foreach ($modules as $file) {
@@ -2307,6 +2293,7 @@ function system_admin_by_module() {
}
function system_get_module_admin_tasks($module) {
+ return array(); // TODO: this needs to be rewritten for the new menu system.
$admin_access = user_access('administer access control');
$menu = menu_get_menu();
$admin_tasks = array();
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 51770a653..1f02f01d2 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -69,75 +69,74 @@ function taxonomy_term_path($term) {
/**
* Implementation of hook_menu().
*/
-function taxonomy_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- $items[] = array('path' => 'admin/content/taxonomy',
- 'title' => t('Categories'),
- 'description' => t('Create vocabularies and terms to categorize your content.'),
- 'callback' => 'taxonomy_overview_vocabularies',
- 'access' => user_access('administer taxonomy'));
-
- $items[] = array('path' => 'admin/content/taxonomy/list',
- 'title' => t('List'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10);
-
- $items[] = array('path' => 'admin/content/taxonomy/add/vocabulary',
- 'title' => t('Add vocabulary'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('taxonomy_form_vocabulary'),
- 'access' => user_access('administer taxonomy'),
- 'type' => MENU_LOCAL_TASK);
-
- $items[] = array('path' => 'admin/content/taxonomy/edit/vocabulary',
- 'title' => t('Edit vocabulary'),
- 'callback' => 'taxonomy_admin_vocabulary_edit',
- 'access' => user_access('administer taxonomy'),
- 'type' => MENU_CALLBACK);
-
- $items[] = array('path' => 'admin/content/taxonomy/edit/term',
- 'title' => t('Edit term'),
- 'callback' => 'taxonomy_admin_term_edit',
- 'access' => user_access('administer taxonomy'),
- 'type' => MENU_CALLBACK);
-
- $items[] = array('path' => 'taxonomy/term',
- 'title' => t('Taxonomy term'),
- 'callback' => 'taxonomy_term_page',
- 'access' => user_access('access content'),
- 'type' => MENU_CALLBACK);
-
- $items[] = array('path' => 'taxonomy/autocomplete',
- 'title' => t('Autocomplete taxonomy'),
- 'callback' => 'taxonomy_autocomplete',
- 'access' => user_access('access content'),
- 'type' => MENU_CALLBACK);
- }
- else {
- if (arg(0) == 'admin' && arg(1) == 'content' && arg(2) == 'taxonomy' && is_numeric(arg(3))) {
- $vid = arg(3);
- $items[] = array('path' => 'admin/content/taxonomy/'. $vid,
- 'title' => t('List terms'),
- 'callback' => 'taxonomy_overview_terms',
- 'callback arguments' => array($vid),
- 'access' => user_access('administer taxonomy'),
- 'type' => MENU_CALLBACK);
-
- $items[] = array('path' => 'admin/content/taxonomy/'. $vid .'/list',
- 'title' => t('List'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10);
-
- $items[] = array('path' => 'admin/content/taxonomy/'. $vid .'/add/term',
- 'title' => t('Add term'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('taxonomy_form_term', $vid),
- 'access' => user_access('administer taxonomy'),
- 'type' => MENU_LOCAL_TASK);
- }
- }
+function taxonomy_menu() {
+ $items['admin/content/taxonomy'] = array(
+ 'title' => t('Categories'),
+ 'description' => t('Create vocabularies and terms to categorize your content.'),
+ 'page callback' => 'taxonomy_overview_vocabularies',
+ 'access arguments' => array('administer taxonomy'),
+ );
+
+ $items['admin/content/taxonomy/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+
+ $items['admin/content/taxonomy/add/vocabulary'] = array(
+ 'title' => t('Add vocabulary'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('taxonomy_form_vocabulary'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+
+ $items['admin/content/taxonomy/edit/vocabulary/%'] = array(
+ 'title' => t('Edit vocabulary'),
+ 'page callback' => 'taxonomy_admin_vocabulary_edit',
+ 'page arguments' => array(5),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['admin/content/taxonomy/edit/term'] = array(
+ 'title' => t('Edit term'),
+ 'page callback' => 'taxonomy_admin_term_edit',
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['taxonomy/term'] = array(
+ 'title' => t('Taxonomy term'),
+ 'page callback' => 'taxonomy_term_page',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['taxonomy/autocomplete'] = array(
+ 'title' => t('Autocomplete taxonomy'),
+ 'page callback' => 'taxonomy_autocomplete',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/content/taxonomy/%'] = array(
+ 'title' => t('List terms'),
+ 'page callback' => 'taxonomy_overview_terms',
+ 'page arguments' => array(3),
+ 'access arguments' => array('administer taxonomy'),
+ 'map arguments' => array('taxonomy_get_vocabulary', 3),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['admin/content/taxonomy/%/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+
+ $items['admin/content/taxonomy/%/add/term'] = array(
+ 'title' => t('Add term'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('taxonomy_form_term', 3),
+ 'type' => MENU_LOCAL_TASK,
+ );
return $items;
}
@@ -173,14 +172,10 @@ function taxonomy_overview_vocabularies() {
* Display a tree of all the terms in a vocabulary, with options to edit
* each one.
*/
-function taxonomy_overview_terms($vid) {
+function taxonomy_overview_terms($vocabulary) {
$destination = drupal_get_destination();
$header = array(t('Name'), t('Operations'));
- $vocabulary = taxonomy_get_vocabulary($vid);
- if (!$vocabulary) {
- return drupal_not_found();
- }
drupal_set_title(check_plain($vocabulary->name));
$start_from = $_GET['page'] ? $_GET['page'] : 0;
@@ -374,9 +369,7 @@ function taxonomy_vocabulary_confirm_delete_submit($form_id, $form_values) {
return 'admin/content/taxonomy';
}
-function taxonomy_form_term($vocabulary_id, $edit = array()) {
- $vocabulary = taxonomy_get_vocabulary($vocabulary_id);
-
+function taxonomy_form_term($vocabulary, $edit = array()) {
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Term name'),
@@ -393,7 +386,7 @@ function taxonomy_form_term($vocabulary_id, $edit = array()) {
if ($vocabulary->hierarchy) {
$parent = array_keys(taxonomy_get_parents($edit['tid']));
- $children = taxonomy_get_tree($vocabulary_id, $edit['tid']);
+ $children = taxonomy_get_tree($vocabulary->vid, $edit['tid']);
// A term can't be the child of itself, nor of its children.
foreach ($children as $child) {
@@ -402,15 +395,15 @@ function taxonomy_form_term($vocabulary_id, $edit = array()) {
$exclude[] = $edit['tid'];
if ($vocabulary->hierarchy == 1) {
- $form['parent'] = _taxonomy_term_select(t('Parent'), 'parent', $parent, $vocabulary_id, l(t('Parent term'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 0, '<'. t('root') .'>', $exclude);
+ $form['parent'] = _taxonomy_term_select(t('Parent'), 'parent', $parent, $vocabulary->vid, l(t('Parent term'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 0, '<'. t('root') .'>', $exclude);
}
elseif ($vocabulary->hierarchy == 2) {
- $form['parent'] = _taxonomy_term_select(t('Parents'), 'parent', $parent, $vocabulary_id, l(t('Parent terms'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 1, '<'. t('root') .'>', $exclude);
+ $form['parent'] = _taxonomy_term_select(t('Parents'), 'parent', $parent, $vocabulary->vid, l(t('Parent terms'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 1, '<'. t('root') .'>', $exclude);
}
}
if ($vocabulary->relations) {
- $form['relations'] = _taxonomy_term_select(t('Related terms'), 'relations', array_keys(taxonomy_get_related($edit['tid'])), $vocabulary_id, NULL, 1, '<'. t('none') .'>', array($edit['tid']));
+ $form['relations'] = _taxonomy_term_select(t('Related terms'), 'relations', array_keys(taxonomy_get_related($edit['tid'])), $vocabulary->vid, NULL, 1, '<'. t('none') .'>', array($edit['tid']));
}
$form['synonyms'] = array(
diff --git a/modules/throttle/throttle.module b/modules/throttle/throttle.module
index 36510be63..9879fe55e 100644
--- a/modules/throttle/throttle.module
+++ b/modules/throttle/throttle.module
@@ -6,21 +6,14 @@
* Allows configuration of congestion control auto-throttle mechanism.
*/
-function throttle_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- $items[] = array(
- 'path' => 'admin/settings/throttle',
- 'description' => t('Control how your site cuts out content during heavy load.'),
- 'title' => t('Throttle'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('throttle_admin_settings'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_NORMAL_ITEM
- );
- }
-
+function throttle_menu() {
+ $items['admin/settings/throttle'] = array(
+ 'description' => t('Control how your site cuts out content during heavy load.'),
+ 'title' => t('Throttle'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('throttle_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ );
return $items;
}
diff --git a/modules/tracker/tracker.module b/modules/tracker/tracker.module
index 7f158d65b..dc9122d8e 100644
--- a/modules/tracker/tracker.module
+++ b/modules/tracker/tracker.module
@@ -22,32 +22,34 @@ function tracker_help($section) {
/**
* Implementation of hook_menu().
*/
-function tracker_menu($may_cache) {
- global $user;
- $items = array();
-
- if ($may_cache) {
- $items[] = array('path' => 'tracker', 'title' => t('Recent posts'),
- 'callback' => 'tracker_page', 'access' => user_access('access content'),
- 'weight' => 1);
-
- if ($user->uid) {
- $items[] = array('path' => 'tracker/all', 'title' => t('All recent posts'),
- 'type' => MENU_DEFAULT_LOCAL_TASK);
- $items[] = array('path' => 'tracker/'. $user->uid, 'title' => t('My recent posts'),
- 'type' => MENU_LOCAL_TASK);
- }
- }
- else {
- if (arg(0) == 'user' && is_numeric(arg(1))) {
- $items[] = array('path' => 'user/'. arg(1) .'/track', 'title' => t('Track'),
- 'callback' => 'tracker_track_user', 'access' => user_access('access content'),
- 'type' => MENU_IS_LOCAL_TASK);
- $items[] = array('path' => 'user/'. arg(1) .'/track/posts', 'title' => t('Track posts'),
- 'type' => MENU_DEFAULT_LOCAL_TASK);
- }
- }
-
+function tracker_menu() {
+ $items['tracker'] = array(
+ 'title' => t('Recent posts'),
+ 'page callback' => 'tracker_page',
+ 'access arguments' => array('access content'),
+ 'weight' => 1,
+ );
+
+ $items['tracker/all'] = array(
+ 'title' => t('All recent posts'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'access callback' => 'user_is_logged_in',
+ );
+ $items['tracker/%'] = array(
+ 'title' => t('My recent posts'),
+ 'type' => MENU_LOCAL_TASK,
+ 'access callback' => 'user_is_logged_in',
+ );
+ $items['user/%/track'] = array(
+ 'title' => t('Track'),
+ 'page callback' => 'tracker_track_user',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['user/%/track/posts'] = array(
+ 'title' => t('Track posts'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ );
return $items;
}
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index 07187ee3b..5fec76209 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -59,49 +59,44 @@ function upload_link($type, $node = NULL, $teaser = FALSE) {
/**
* Implementation of hook_menu().
*/
-function upload_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- $items[] = array(
- 'path' => 'upload/js',
- 'callback' => 'upload_js',
- 'access' => user_access('upload files'),
- 'type' => MENU_CALLBACK
- );
- $items[] = array('path' => 'admin/settings/uploads',
- 'title' => t('File uploads'),
- 'description' => t('Control how files may be attached to content.'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('upload_admin_settings'),
- 'access' => user_access('administer site configuration'),
- 'type' => MENU_NORMAL_ITEM);
- }
- else {
- // Add handlers for previewing new uploads.
- if (isset($_SESSION['file_previews'])) {
- foreach ($_SESSION['file_previews'] as $fid => $file) {
- $filename = file_create_filename($file->filename, file_create_path());
- if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
- // strip file_directory_path() from filename. @see file_create_url
- if (strpos($filename, file_directory_path()) !== FALSE) {
- $filename = trim(substr($filename, strlen(file_directory_path())), '\\/');
- }
- $filename = 'system/files/' . $filename;
- }
+function upload_menu() {
+ $items['upload/js'] = array(
+ 'page callback' => 'upload_js',
+ 'access arguments' => array('upload files'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/settings/uploads'] = array(
+ 'title' => t('File uploads'),
+ 'description' => t('Control how files may be attached to content.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('upload_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'type' => MENU_NORMAL_ITEM,
+ );
+ return $items;
+}
- $items[] = array(
- 'path' => $filename, 'title' => t('File download'),
- 'callback' => 'upload_download',
- 'access' => user_access('view uploaded files'),
- 'type' => MENU_CALLBACK
- );
- $_SESSION['file_previews'][$fid]->_filename = $filename;
+function upload_menu_alter(&$items) {
+ $items['system/files']['page callback'] = 'upload_download';
+ $items['system/files']['access arguments'] = array('view uploaded files');
+}
+
+function upload_init() {
+ if (arg(0) == 'system' && arg(1) == 'files' && isset($_SESSION['file_previews'])) {
+ $item = menu_get_item('system/files');
+ foreach ($_SESSION['file_previews'] as $fid => $file) {
+ $filename = file_create_filename($file->filename, file_create_path());
+ if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
+ // strip file_directory_path() from filename. @see file_create_url
+ if (strpos($filename, file_directory_path()) !== FALSE) {
+ $filename = trim(substr($filename, strlen(file_directory_path())), '\\/');
+ }
+ $filename = 'system/files/' . $filename;
}
+ $_SESSION['file_previews'][$fid]->_filename = $filename;
+ menu_set_item($filename, $item);
}
}
-
- return $items;
}
/**
diff --git a/modules/user/user.module b/modules/user/user.module
index 992b081aa..4f3cafefd 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -50,6 +50,10 @@ function user_load($array = array()) {
$query = array();
$params = array();
+ if (is_numeric($array)) {
+ $array = array('uid' => $array);
+ }
+
foreach ($array as $key => $value) {
if ($key == 'uid' || $key == 'status') {
$query[] = "$key = %d";
@@ -553,7 +557,7 @@ function user_block($op = 'list', $delta = 0, $edit = array()) {
return $block;
case 1:
- if ($menu = theme('menu_tree')) {
+ if ($menu = menu_tree()) {
$block['subject'] = $user->uid ? check_plain($user->name) : t('Navigation');
$block['content'] = $menu;
}
@@ -680,159 +684,247 @@ function theme_user_list($users, $title = NULL) {
return theme('item_list', $items, $title);
}
+function user_is_anonymous() {
+ return !$GLOBALS['user']->uid;
+}
+
+function user_is_logged_in() {
+ return (bool)$GLOBALS['user']->uid;
+}
+
+function user_register_access() {
+ return !$GLOBALS['user']->uid && variable_get('user_register', 1);
+}
+
+function user_view_access($account) {
+ return $account && $account->uid &&
+ (
+ // Always let users view their own profile.
+ ($GLOBALS['user']->uid == $account->uid) ||
+ // Administrators can view all accounts.
+ user_access('administer users') ||
+ // The user is not blocked and logged in at least once.
+ ($account->access && $account->status && user_access('access user profiles'))
+ );
+}
+
+function user_edit_access($uid) {
+ return ($GLOBALS['user']->uid == $uid) || array('administer users');
+}
+
+function user_load_self($arg) {
+ $arg[1] = user_load($GLOBALS['user']->uid);
+ return $arg;
+}
+
/**
* Implementation of hook_menu().
*/
-function user_menu($may_cache) {
- global $user;
+function user_menu() {
+ $items['user/autocomplete'] = array(
+ 'title' => t('User autocomplete'),
+ 'page callback' => 'user_autocomplete',
+ 'access arguments' => array('access user profiles'),
+ 'type' => MENU_CALLBACK,
+ );
- $items = array();
+ // Registration and login pages.
+ $items['user/login'] = array(
+ 'title' => t('Log in'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('user_login'),
+ 'access callback' => 'user_is_anonymous',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ );
- $admin_access = user_access('administer users');
- $access_access = user_access('administer access control');
- $view_access = user_access('access user profiles');
-
- if ($may_cache) {
- $items[] = array('path' => 'user', 'title' => t('User account'),
- 'callback' => 'drupal_get_form', 'callback arguments' => array('user_login'),
- 'access' => !$user->uid, 'type' => MENU_CALLBACK);
-
- $items[] = array('path' => 'user/autocomplete', 'title' => t('User autocomplete'),
- 'callback' => 'user_autocomplete', 'access' => $view_access, 'type' => MENU_CALLBACK);
-
- // Registration and login pages.
- $items[] = array('path' => 'user/login', 'title' => t('Log in'),
- 'callback' => 'drupal_get_form', 'callback arguments' => array('user_login'),
- 'access' => !$user->uid, 'type' => MENU_DEFAULT_LOCAL_TASK);
- $items[] = array('path' => 'user/register', 'title' => t('Create new account'),
- 'callback' => 'drupal_get_form', 'callback arguments' => array('user_register'), 'access' => !$user->uid && variable_get('user_register', 1), 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'user/password', 'title' => t('Request new password'),
- 'callback' => 'drupal_get_form', 'callback arguments' => array('user_pass'), 'access' => !$user->uid, 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'user/reset', 'title' => t('Reset password'),
- 'callback' => 'drupal_get_form', 'callback arguments' => array('user_pass_reset'), 'access' => TRUE, 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'user/help', 'title' => t('Help'),
- 'callback' => 'user_help_page', 'type' => MENU_CALLBACK);
-
- // Admin user pages
- $items[] = array('path' => 'admin/user',
- 'title' => t('User management'),
- 'description' => t('Manage your site\'s users, groups and access to site features.'),
- 'position' => 'left',
- 'callback' => 'system_admin_menu_block_page',
- 'access' => user_access('administer site configuration'),
- );
- $items[] = array('path' => 'admin/user/user', 'title' => t('Users'),
- 'description' => t('List, add, and edit users.'),
- 'callback' => 'user_admin', 'callback arguments' => array('list'), 'access' => $admin_access);
- $items[] = array('path' => 'admin/user/user/list', 'title' => t('List'),
- 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
- $items[] = array('path' => 'admin/user/user/create', 'title' => t('Add user'),
- 'callback' => 'user_admin', 'callback arguments' => array('create'), 'access' => $admin_access,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'admin/user/settings', 'title' => t('User settings'),
- 'description' => t('Configure default behavior of users, including registration requirements, e-mails, and user pictures.'),
- 'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_settings'));
-
- // Admin access pages
- $items[] = array('path' => 'admin/user/access', 'title' => t('Access control'),
- 'description' => t('Determine access to features by selecting permissions for roles.'),
- 'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_perm'), 'access' => $access_access);
- $items[] = array('path' => 'admin/user/roles', 'title' => t('Roles'),
- 'description' => t('List, edit, or add user roles.'),
- 'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_new_role'), 'access' => $access_access,
- 'type' => MENU_NORMAL_ITEM);
- $items[] = array('path' => 'admin/user/roles/edit', 'title' => t('Edit role'),
- 'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_role'), 'access' => $access_access,
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/user/rules', 'title' => t('Access rules'),
- 'description' => t('List and create rules to disallow usernames, e-mail addresses, and IP addresses.'),
- 'callback' => 'user_admin_access', 'access' => $access_access);
- $items[] = array('path' => 'admin/user/rules/list', 'title' => t('List'),
- 'access' => $access_access, 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
- $items[] = array('path' => 'admin/user/rules/add', 'title' => t('Add rule'),
- 'callback' => 'user_admin_access_add', 'access' => $access_access,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'admin/user/rules/check', 'title' => t('Check rules'),
- 'callback' => 'user_admin_access_check', 'access' => $access_access,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'admin/user/rules/edit', 'title' => t('Edit rule'),
- 'callback' => 'user_admin_access_edit', 'access' => $access_access,
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/user/rules/delete', 'title' => t('Delete rule'),
- 'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_access_delete_confirm'),
- 'access' => $access_access, 'type' => MENU_CALLBACK);
-
- if (module_exists('search')) {
- $items[] = array('path' => 'admin/user/search', 'title' => t('Search users'),
- 'description' => t('Search users by name.'),
- 'callback' => 'user_admin', 'callback arguments' => array('search'), 'access' => $admin_access,
- 'type' => MENU_NORMAL_ITEM);
- }
-
- // Your personal page
- if ($user->uid) {
- $items[] = array('path' => 'user/'. $user->uid, 'title' => t('My account'),
- 'callback' => 'user_view', 'callback arguments' => array(arg(1)), 'access' => TRUE,
- 'type' => MENU_DYNAMIC_ITEM);
- }
+ $items['user/register'] = array(
+ 'title' => t('Create new account'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('user_register'),
+ 'access callback' => 'user_register_access',
+ 'type' => MENU_LOCAL_TASK,
+ );
+
+ $items['user/password'] = array(
+ 'title' => t('Request new password'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('user_pass'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['user/reset/%/%/%'] = array(
+ 'title' => t('Reset password'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('user_pass_reset', 2, 3, 4),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
+ $items['user/help'] = array(
+ 'title' => t('Help'),
+ 'page callback' => 'user_help_page',
+ 'type' => MENU_CALLBACK,
+ );
+
+ // Admin user pages
+ $items['admin/user'] = array(
+ 'title' => t('User management'),
+ 'description' => t('Manage your site\'s users, groups and access to site features.'),
+ 'position' => 'left',
+ 'page callback' => 'system_admin_menu_block_page',
+ 'access arguments' => array('administer site configuration'),
+ );
+ $items['admin/user/user'] = array(
+ 'title' => t('Users'),
+ 'description' => t('List, add, and edit users.'),
+ 'page callback' => 'user_admin',
+ 'page arguments' => array('list'),
+ 'access arguments' => array('administer users'));
+ $items['admin/user/user/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['admin/user/user/create'] = array(
+ 'title' => t('Add user'),
+ 'page arguments' => array('create'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/user/settings'] = array(
+ 'title' => t('User settings'),
+ 'description' => t('Configure default behavior of users, including registration requirements, e-mails, and user pictures.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('user_admin_settings'),
+ );
+
+ // Admin access pages
+ $items['admin/user/access'] = array(
+ 'title' => t('Access control'),
+ 'description' => t('Determine access to features by selecting permissions for roles.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('user_admin_perm'),
+ 'access arguments' => array('administer access control'),
+ );
+ $items['admin/user/roles'] = array(
+ 'title' => t('Roles'),
+ 'description' => t('List, edit, or add user roles.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('user_admin_new_role'),
+ 'access arguments' => array('administer access control'),
+ );
+ $items['admin/user/roles/edit'] = array(
+ 'title' => t('Edit role'),
+ 'page arguments' => array('user_admin_role'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/user/rules'] = array(
+ 'title' => t('Access rules'),
+ 'description' => t('List and create rules to disallow usernames, e-mail addresses, and IP addresses.'),
+ 'page callback' => 'user_admin_access',
+ 'access arguments' => array('administer access control'),
+ );
+ $items['admin/user/rules/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['admin/user/rules/add'] = array(
+ 'title' => t('Add rule'),
+ 'page callback' => 'user_admin_access_add',
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/user/rules/check'] = array(
+ 'title' => t('Check rules'),
+ 'page callback' => 'user_admin_access_check',
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/user/rules/edit'] = array(
+ 'title' => t('Edit rule'),
+ 'page callback' => 'user_admin_access_edit',
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/user/rules/delete'] = array(
+ 'title' => t('Delete rule'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('user_admin_access_delete_confirm'),
+ 'type' => MENU_CALLBACK,
+ );
- $items[] = array('path' => 'logout', 'title' => t('Log out'),
- 'access' => $user->uid,
- 'callback' => 'user_logout',
- 'weight' => 10);
+ if (module_exists('search')) {
+ $items['admin/user/search'] = array(
+ 'title' => t('Search users'),
+ 'description' => t('Search users by name.'),
+ 'page callback' => 'user_admin',
+ 'page arguments' => array('search'),
+ 'access arguments' => array('administer users'),
+ 'type' => MENU_NORMAL_ITEM,
+ );
}
- else {
- // Add the CSS for this module. We put this in !$may_cache so it is only
- // added once per request.
- drupal_add_css(drupal_get_path('module', 'user') .'/user.css', 'module');
- if ($_GET['q'] == 'user' && $user->uid) {
- // We want to make the current user's profile accessible without knowing
- // their uid, so just linking to /user is enough.
- drupal_goto('user/'. $user->uid);
- }
-
- if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0) {
- $account = user_load(array('uid' => arg(1)));
-
- if ($user !== FALSE) {
- // Always let a user view their own account
- $view_access |= $user->uid == arg(1);
- // Only admins can view blocked accounts
- $view_access &= $account->status || $admin_access;
-
- $items[] = array('path' => 'user/'. arg(1), 'title' => t('User'),
- 'type' => MENU_CALLBACK, 'callback' => 'user_view',
- 'callback arguments' => array(arg(1)), 'access' => $view_access);
-
- $items[] = array('path' => 'user/'. arg(1) .'/view', 'title' => t('View'),
- 'access' => $view_access, 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
-
- $items[] = array('path' => 'user/'. arg(1) .'/edit', 'title' => t('Edit'),
- 'callback' => 'drupal_get_form', 'callback arguments' => array('user_edit'),
- 'access' => $admin_access || $user->uid == arg(1), 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'user/'. arg(1) .'/delete', 'title' => t('Delete'),
- 'callback' => 'user_edit', 'access' => $admin_access,
- 'type' => MENU_CALLBACK);
-
- if (arg(2) == 'edit') {
- if (($categories = _user_categories($account)) && (count($categories) > 1)) {
- foreach ($categories as $key => $category) {
- $items[] = array(
- 'path' => 'user/'. arg(1) .'/edit/'. $category['name'],
- 'title' => $category['title'],
- 'type' => $category['name'] == 'account' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
- 'weight' => $category['weight'],
- 'access' => ($admin_access || $user->uid == arg(1)));
- }
- }
- }
- }
+
+ $items['logout'] = array(
+ 'title' => t('Log out'),
+ 'access callback' => 'user_is_logged_in',
+ 'page callback' => 'user_logout',
+ 'weight' => 10,
+ );
+
+ $items['user'] = array(
+ 'title' => t('My account'),
+ 'page callback' => 'user_view',
+ 'page arguments' => array(1),
+ 'access callback' => 'user_view_access',
+ 'access arguments' => array(1),
+ 'map callback' => 'user_load_self',
+ );
+
+ $items['user/%'] = array(
+ 'title' => t('My account'),
+ 'page callback' => 'user_view',
+ 'page arguments' => array(1),
+ 'access callback' => 'user_view_access',
+ 'access arguments' => array(1),
+ 'map arguments' => array('user_load', 1),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['user/%/view'] = array(
+ 'title' => t('View'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+
+ $items['user/%/delete'] = array(
+ 'title' => t('Delete'),
+ 'page callback' => 'user_edit',
+ 'access callback' => 'user_access',
+ 'access arguments' => array('administer users'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ $items['user/%/edit'] = array(
+ 'title' => t('Edit'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('user_edit'),
+ 'access callback' => 'user_edit_access',
+ 'access arguments' => array(1),
+ 'type' => MENU_LOCAL_TASK,
+ );
+
+ if (($categories = _user_categories($account)) && (count($categories) > 1)) {
+ foreach ($categories as $key => $category) {
+ $items['user/%/edit/'. $category['name']] = array(
+ 'title' => $category['title'],
+ 'page arguments' => array('user_edit', 3),
+ 'type' => $category['name'] == 'account' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
+ 'weight' => $category['weight'],
+ );
}
}
-
return $items;
}
+function user_init() {
+ drupal_add_css(drupal_get_path('module', 'user') .'/user.css', 'module');
+}
+
/**
* Accepts an user object, $account, or a DA name and returns an associative
* array of modules and DA names. Called at external login.
@@ -1482,9 +1574,6 @@ function user_edit_submit($form_id, $form_values) {
user_module_invoke('submit', $form_values, $account, $category);
user_save($account, $form_values, $category);
- // Delete that user's menu cache:
- cache_clear_all($account->uid .':', 'cache_menu', TRUE);
-
// Clear the page cache because pages can contain usernames and/or profile information:
cache_clear_all();
@@ -1492,13 +1581,9 @@ function user_edit_submit($form_id, $form_values) {
return 'user/'. $account->uid;
}
-function user_view($uid = 0) {
+function user_view($account) {
global $user;
- $account = user_load(array('uid' => $uid));
- if ($account === FALSE || ($account->access == 0 && !user_access('administer users'))) {
- return drupal_not_found();
- }
// Retrieve and merge all profile fields:
$fields = array();
foreach (module_list() as $module) {
@@ -2114,7 +2199,6 @@ function user_admin_account_submit($form_id, $form_values) {
}
call_user_func_array($function, $args);
- cache_clear_all('*', 'cache_menu', TRUE);
drupal_set_message(t('The update has been performed.'));
}
}
diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module
index 1c92758d4..90729c402 100644
--- a/modules/watchdog/watchdog.module
+++ b/modules/watchdog/watchdog.module
@@ -30,36 +30,41 @@ function watchdog_help($section) {
/**
* Implementation of hook_menu().
*/
-function watchdog_menu($may_cache) {
- $items = array();
-
- if ($may_cache) {
- $items[] = array('path' => 'admin/logs/watchdog', 'title' => t('Recent log entries'),
- 'description' => t('View events that have recently been logged.'),
- 'callback' => 'watchdog_overview',
- 'weight' => -1);
- $items[] = array('path' => 'admin/logs/page-not-found', 'title' => t("Top 'page not found' errors"),
- 'description' => t("View 'page not found' errors (404s)."),
- 'callback' => 'watchdog_top',
- 'callback arguments' => array('page not found'));
- $items[] = array('path' => 'admin/logs/access-denied', 'title' => t("Top 'access denied' errors"),
- 'description' => t("View 'access denied' errors (403s)."),
- 'callback' => 'watchdog_top',
- 'callback arguments' => array('access denied'));
- $items[] = array('path' => 'admin/logs/event', 'title' => t('Details'),
- 'callback' => 'watchdog_event',
- 'type' => MENU_CALLBACK);
- }
- else {
- if (arg(0) == 'admin' && arg(1) == 'logs') {
- // Add the CSS for this module
- drupal_add_css(drupal_get_path('module', 'watchdog') .'/watchdog.css', 'module', 'all', FALSE);
- }
- }
-
+function watchdog_menu() {
+ $items['admin/logs/watchdog'] = array(
+ 'title' => t('Recent log entries'),
+ 'description' => t('View events that have recently been logged.'),
+ 'page callback' => 'watchdog_overview',
+ 'weight' => -1,
+ );
+ $items['admin/logs/page-not-found'] = array(
+ 'title' => t("Top 'page not found' errors"),
+ 'description' => t("View 'page not found' errors (404s)."),
+ 'page callback' => 'watchdog_top',
+ 'page arguments' => array('page not found'),
+ );
+ $items['admin/logs/access-denied'] = array(
+ 'title' => t("Top 'access denied' errors"),
+ 'description' => t("View 'access denied' errors (403s)."),
+ 'page callback' => 'watchdog_top',
+ 'page arguments' => array('access denied'),
+ );
+ $items['admin/logs/event/%'] = array(
+ 'title' => t('Details'),
+ 'page callback' => 'watchdog_event',
+ 'page arguments' => array(3),
+ 'type' => MENU_CALLBACK,
+ );
return $items;
}
+function watchdog_init() {
+ if (arg(0) == 'admin' && arg(1) == 'logs') {
+ // Add the CSS for this module
+ drupal_add_css(drupal_get_path('module', 'watchdog') .'/watchdog.css', 'module', 'all', FALSE);
+ }
+}
+
/**
* Implementation of hook_cron().
*
diff --git a/profiles/default/default.profile b/profiles/default/default.profile
index 3056a2b1c..4f1915afe 100644
--- a/profiles/default/default.profile
+++ b/profiles/default/default.profile
@@ -8,7 +8,7 @@
* An array of modules to be enabled.
*/
function default_profile_modules() {
- return array('block', 'color', 'comment', 'filter', 'help', 'menu', 'node', 'system', 'taxonomy', 'user', 'watchdog');
+ return array('block', 'color', 'comment', 'filter', 'help', 'node', 'system', 'taxonomy', 'user', 'watchdog');
}
/**