From a naming perspective
'type' => MENU_CONTAINER_ITEM
'type' => MENU_DEPENDS_ON_CHILDREN
The first is a much better "type" then "depends on children" which seems more like an additional descriptive attribute.
+1 for container item to solve this.
Guess I'll just mark fixed unless anyone says otherwise.
Documentation added: http://drupal.org/node/224333#system_admin_menu_block_access
I am not sure that is an issue since technically there is a menu item under "Administration". When help module is disabled the Administration menu item still displays. I attempted to add the check the the root "admin" item, but it causes an issue, possibly due to excessive looping.
Not sure we want to deal with that issue or perhaps save for follup patch. Either way this patch contains admin/international alteration.
Rework of #23 (no longer applied and outdated).
- Make use of
drupal_static()
. - Implement callback for
admin/development
. - Updated test for
admin/development
.
Hmmmm...two interesting things:
- The notice only comes up once...at least for me.
- Adding debug code it becomes clear that user_access() returns TRUE, but the $content is empty.
It would seem the issue is in the existing code not the new code, but yet it works without the new code....
When I run the site as anonymous I get:
error PHP Fatal error: require_once(): Failed opening required './includes/database/mysql/query.inc' (include_path='.:/usr/share/php5:/usr/share/php5/PEAR') in .../drupal-7/includes/bootstrap.inc on line 1399, referer: http://drupal-7.dev.loc/
Still applies after dbtng.
Ran entire test suite with all passes.
After applying the above patches and then applying this one tests pass.
Adds test and changes access callback name per #4 and #5.
@icouto: Depends on what this is considered. If this is considered a bug/or necessary feature then it most likely will be. It would be useful as SimpleTest 6.x-2.x would use this and I'm sure there are others, not to mention default use-cases as per #3.
The test needs assertLink and assertNoLink:
#297894: Add assertLink and assertNoLink to SimpleTest β
which requires:
#297869: Add xpath method to Simpletest and refactor existing tests β
Will need those to get in first, but we can still review this patch. (although you will need to apply those.)
After patches applies test passes.
Working on writing the test, and a few cleanup items along with it.
The code in #2 uses system_admin_menu_block()
which does allot of extra stuff then is necessary to determine if there are children. Plus _system_settings_access
doesn't seem like the right name for the access callback for two reasons.
1) It could be used by contrib, no need for private declaration (_).
2) It relates to other items besides settings.
In my attempt at this in #263616: Move SimpleTest out of "Site building" β I used the following code:
function system_admin_menu_block_page_access($path, $string) {
if (user_access($string)) {
$count = db_result(db_query("SELECT COUNT(mlid)
FROM {menu_links}
WHERE plid = (
SELECT mlid
FROM {menu_links}
WHERE link_path
LIKE '%s'
)", $path));
return ($count > 0);
}
return FALSE;
}
Which alleviates the call to the other function.
Should think about the name of the function. The reasoning behind my choice is that the items that only display a list of children use system_admin_menu_block_page
so it would only seem nature that system_admin_menu_block_page_access
would be used for them.