diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/aggregator/aggregator.module | 8 | ||||
-rw-r--r-- | modules/node/node.module | 13 | ||||
-rw-r--r-- | modules/path/path.module | 35 | ||||
-rw-r--r-- | modules/system/system.install | 17 | ||||
-rw-r--r-- | modules/system/system.module | 65 |
5 files changed, 88 insertions, 50 deletions
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index 56add8a25..9601203ac 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -91,8 +91,7 @@ function aggregator_menu() { $items['aggregator/categories'] = array( 'title' => t('Categories'), 'page callback' => 'aggregator_page_categories', - 'access arguments' => array('access news feeds'), - 'type' => MENU_ITEM_GROUPING, + 'access callback' => '_aggregator_has_categories', ); $items['aggregator/rss'] = array( 'title' => t('RSS feed'), @@ -112,6 +111,7 @@ function aggregator_menu() { $items[$path] = array( 'title' => $category['title'], 'page callback' => 'aggregator_page_category', + 'access callback' => 'user_access', 'access arguments' => array('access news feeds'), ); $items[$path .'/view'] = array( @@ -181,6 +181,10 @@ function aggregator_init() { drupal_add_css(drupal_get_path('module', 'aggregator') .'/aggregator.css'); } +function _aggregator_has_categories() { + return user_access('access news feeds') && db_result(db_query('SELECT COUNT(*) FROM {aggregator_category}')); +} + 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'); diff --git a/modules/node/node.module b/modules/node/node.module index a0d36e0b1..8e0f698d6 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1132,8 +1132,7 @@ function node_menu() { $items['node/add'] = array( 'title' => t('Create content'), 'page callback' => 'node_add', - 'access callback' => 'user_access', - 'access arguments' => array('access content'), + 'access callback' => '_node_add_access', 'weight' => 1, ); $items['rss.xml'] = array( @@ -2090,6 +2089,16 @@ function theme_node_form($form) { return $output; } +function _node_add_access() { + $types = node_get_types(); + foreach ($types as $type) { + if (function_exists($type->module .'_form') && node_access('create', $type->type)) { + return TRUE; + } + } + return FALSE; +} + /** * Present a node submission form or a set of links to such forms. */ diff --git a/modules/path/path.module b/modules/path/path.module index 372ff5e05..e3d7932f1 100644 --- a/modules/path/path.module +++ b/modules/path/path.module @@ -135,41 +135,46 @@ function path_admin_delete($pid = 0) { function path_set_alias($path = NULL, $alias = NULL, $pid = NULL) { if ($path && !$alias) { db_query("DELETE FROM {url_alias} WHERE src = '%s'", $path); + db_query("UPDATE {menu} SET link_path = path WHERE path = '%s'", $path); drupal_clear_path_cache(); } else if (!$path && $alias) { db_query("DELETE FROM {url_alias} WHERE dst = '%s'", $alias); + db_query("UPDATE {menu} SET link_path = path WHERE link_path = '%s'", $alias); drupal_clear_path_cache(); } else if ($path && $alias) { $path = urldecode($path); $path_count = db_result(db_query("SELECT COUNT(src) FROM {url_alias} WHERE src = '%s'", $path)); $alias = urldecode($alias); + // Alias count can only be 0 or 1. $alias_count = db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s'", $alias)); - // We have an insert: - if ($path_count == 0 && $alias_count == 0) { - db_query("INSERT INTO {url_alias} (src, dst) VALUES ('%s', '%s')", $path, $alias); - drupal_clear_path_cache(); - } - else if ($path_count >= 1 && $alias_count == 0) { + if ($alias_count == 0) { if ($pid) { db_query("UPDATE {url_alias} SET dst = '%s', src = '%s' WHERE pid = %d", $alias, $path, $pid); } else { db_query("INSERT INTO {url_alias} (src, dst) VALUES ('%s', '%s')", $path, $alias); } - drupal_clear_path_cache(); } - else if ($path_count == 0 && $alias_count == 1) { - db_query("UPDATE {url_alias} SET src = '%s' WHERE dst = '%s'", $path, $alias); - drupal_clear_path_cache(); + // The alias exists. + else { + // This path has no alias yet, so we redirect the alias here. + if ($path_count == 0) { + db_query("UPDATE {url_alias} SET src = '%s' WHERE dst = '%s'", $path, $alias); + } + else { + // This will delete the path that alias was originally pointing to. + path_set_alias(NULL, $alias); + // This will remove the current aliases of the path. + path_set_alias($path); + path_set_alias($path, $alias); + } } - else if ($path_count == 1 && $alias_count == 1) { - // This will delete the path that alias was originally pointing to: - path_set_alias(NULL, $alias); - path_set_alias($path); - path_set_alias($path, $alias); + if ($alias_count == 0 || $path_count == 0) { + drupal_clear_path_cache(); + db_query("UPDATE {menu} SET link_path = '%s' WHERE path = '%s'", $alias, $path); } } } diff --git a/modules/system/system.install b/modules/system/system.install index 1b05b6b00..07e6df894 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -100,6 +100,7 @@ function system_requirements($phase) { 'value' => $t('Never run'), ); } + $requirements['cron'] += array('description' => ''); $requirements['cron']['description'] .= ' '. t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/logs/status/run-cron'))); @@ -349,6 +350,14 @@ function system_install() { title varchar(255) NOT NULL default '', parent varchar(255) NOT NULL default '', type int NOT NULL default 0, + block_callback varchar(255) NOT NULL default '', + description varchar(255) NOT NULL default '', + link_path varchar(255) NOT NULL default '', + attributes varchar(255) NOT NULL default '', + query varchar(255) NOT NULL default '', + fragment varchar(255) NOT NULL default '', + absolute INT NOT NULL default 0, + html INT NOT NULL default 0, PRIMARY KEY (path), KEY fit (fit), KEY visible (visible), @@ -824,6 +833,14 @@ function system_install() { title varchar(255) NOT NULL default '', parent varchar(255) NOT NULL default '', type int NOT NULL default 0, + block_callback varchar(255) NOT NULL default '', + description varchar(255) NOT NULL default '', + link_path varchar(255) NOT NULL default '', + attributes varchar(255) NOT NULL default '', + query varchar(255) NOT NULL default '', + fragment varchar(255) NOT NULL default '', + absolute INT NOT NULL default 0, + html INT NOT NULL default 0, PRIMARY KEY (path) )"); diff --git a/modules/system/system.module b/modules/system/system.module index 206dc69bf..a46823ece 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -336,7 +336,6 @@ 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. @@ -349,36 +348,38 @@ function system_main_admin_page($arg = NULL) { drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the <a href="@status">status report</a> for more information.', array('@status' => url('admin/logs/status'))), 'error'); } - - $menu = menu_get_item(NULL, 'admin'); - usort($menu['children'], '_menu_sort'); - foreach ($menu['children'] as $mid) { - $block = menu_get_item($mid); - if ($block['block callback'] && function_exists($block['block callback'])) { - $arguments = isset($block['block arguments']) ? $block['block arguments'] : array(); - $block['content'] .= call_user_func_array($block['block callback'], $arguments); + $map = arg(NULL); + $result = db_query("SELECT * FROM {menu} WHERE path LIKE 'admin/%%' AND depth = 2 AND visible = 1 AND path != 'admin/help' ORDER BY mleft"); + while ($item = db_fetch_object($result)) { + _menu_translate($item, $map, MENU_RENDER_LINK); + if (!$item->access) { + continue; } - $block['content'] .= theme('admin_block_content', system_admin_menu_block($block)); + $block = (array)$item; + $block['content'] = ''; + if ($item->block_callback && function_exists($item->block_callback)) { + $function = $item->block_callback; + $block['content'] .= $function(); + } + $block['content'] .= theme('admin_block_content', system_admin_menu_block($item)); $blocks[] = $block; } - return theme('admin_page', $blocks); } /** * 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. +function system_admin_menu_block($item) { + $map = arg(NULL); $content = array(); - if (is_array($block['children'])) { - usort($block['children'], '_menu_sort'); - foreach ($block['children'] as $mid) { - $item = menu_get_item($mid); - if (($item['type'] & MENU_VISIBLE_IN_TREE) && _menu_item_is_accessible($mid)) { - $content[] = $item; - } + $result = db_query('SELECT * FROM {menu} WHERE depth = %d AND %d < mleft AND mright < %d ORDER BY mleft', $item->depth + 1, $item->mleft, $item->mright); + while ($item = db_fetch_object($result)) { + _menu_translate($item, $map, MENU_RENDER_LINK); + if (!$item->access) { + continue; } + $content[] = (array)$item; } return $content; } @@ -391,9 +392,8 @@ 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); + $item = menu_get_item(); + $content = system_admin_menu_block($item); $output = theme('admin_block_content', $content); return $output; @@ -1891,14 +1891,13 @@ 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(); } - $menu = menu_get_item(NULL, 'admin/settings'); - $content = system_admin_menu_block($menu); + $item = menu_get_item('admin/settings'); + $content = system_admin_menu_block($item); $output = theme('admin_block_content', $content); @@ -2188,9 +2187,9 @@ function theme_admin_page($blocks) { foreach ($blocks as $block) { if ($block_output = theme('admin_block', $block)) { - if (!$block['position']) { + if (empty($block['position'])) { // perform automatic striping. - $block['position'] = $stripe++ % 2 ? 'left' : 'right'; + $block['position'] = ++$stripe % 2 ? 'left' : 'right'; } $container[$block['position']] .= $block_output; } @@ -2225,7 +2224,7 @@ function theme_admin_page($blocks) { */ function theme_admin_block($block) { // Don't display the block if it has no content to display. - if (!$block['content']) { + if (empty($block['content'])) { return ''; } @@ -2261,14 +2260,18 @@ function theme_admin_block_content($content) { if (system_admin_compact_mode()) { $output = '<ul class="menu">'; foreach ($content as $item) { - $output .= '<li class="leaf">'. l($item['title'], $item['path'], array('attributes' => array('title' => $item['description']))) .'</li>'; + if (empty($item['attributes'])) { + $item['attributes'] = array(); + } + $item['attributes'] += array('title' => $item['description']); + $output .= '<li class="leaf">'. l($item['title'], $item['path'], $item) .'</li>'; } $output .= '</ul>'; } else { $output = '<dl class="admin-list">'; foreach ($content as $item) { - $output .= '<dt>'. l($item['title'], $item['path']) .'</dt>'; + $output .= '<dt>'. l($item['title'], $item['path'], $item) .'</dt>'; $output .= '<dd>'. $item['description'] .'</dd>'; } $output .= '</dl>'; |