diff options
Diffstat (limited to 'modules')
28 files changed, 1720 insertions, 1761 deletions
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(). * |