DrupalBin
Submit Code
About
Recent Posts
Code
Fix for Fix for Code
Fix for Code
Code
Node type whitelist
an axe coach accessories
coach purses married
Fix for de las ghd alturas
de las ghd alturas
Code
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
taxonomy
test
theme
views
more tags
Home
Fix for Module for setting a separate permission for theme management
View
Fix
October 20, 2009 - 9:40am — Anonymous
<?php
// $Id$
/*
* Created by Greg Harvey on 20 Oct 2009
*
* http://www.drupaler.co.uk
*/
/**
* Implementation of hook_perm().
*
* Provide a new permission for theme admin access.
*/
function
access_theme_settings_perm
(
)
{
return
array
(
'administer default theme settings'
,
)
;
}
/**
* Implementation of hook_menu_alter().
*
* Altering the theme settings menu items so they have
* their own permission.
*/
function
access_theme_settings_menu_alter
(
&
$items
)
{
// Get the full system file path to the include file.
$file
=
'./'
.
drupal_get_path
(
'module'
,
'system'
)
.
'/system.admin.inc'
;
$file
=
realpath
(
$file
)
;
// Re-define all theme admin menu items using the old access argument.
// We need to rebuild totally - for some reason hook_menu() "forgets"
// values set in system.module.
$items
[
'admin/build/themes'
]
=
array
(
'title'
=
>
'Themes'
,
'description'
=
>
'Change which theme your site uses or allows users to set.'
,
'page callback'
=
>
'drupal_get_form'
,
'page arguments'
=
>
array
(
'system_themes_form'
,
NULL
)
,
'access arguments'
=
>
array
(
'administer default theme settings'
)
,
'file'
=
>
$file
,
)
;
$items
[
'admin/build/themes/settings'
]
=
array
(
'title'
=
>
'Configure'
,
'page arguments'
=
>
array
(
'system_theme_settings'
)
,
'access arguments'
=
>
array
(
'administer default theme settings'
)
,
'type'
=
>
MENU_LOCAL_TASK
,
)
;
foreach
(
list_themes
(
)
as
$theme
)
{
$items
[
'admin/build/themes/settings/'
.
$theme
-
>
name
]
=
array
(
'title'
=
>
$theme
-
>
info
[
'name'
]
,
'page arguments'
=
>
array
(
'system_theme_settings'
,
$theme
-
>
name
)
,
'type'
=
>
MENU_LOCAL_TASK
,
'access callback'
=
>
'_access_theme_settings_themes_access'
,
'access arguments'
=
>
array
(
$theme
)
,
)
;
}
}
/**
* Menu item access callback - only admin or enabled themes can be accessed.
*
* Overrides _system_themes_access().
*/
function
_access_theme_settings_themes_access
(
$theme
)
{
return
user_access
(
'administer default theme settings'
)
&&
(
$theme
-
>
status
||
$theme
-
>
name
==
variable_get
(
'admin_theme'
,
'0'
)
)
;
}
6.x
admin
drupal
module
themes
Submit Fix
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
<?php // $Id$ /* * Created by Greg Harvey on 20 Oct 2009 * * http://www.drupaler.co.uk */ /** * Implementation of hook_perm(). * * Provide a new permission for theme admin access. */ function access_theme_settings_perm() { return array( 'administer default theme settings', ); } /** * Implementation of hook_menu_alter(). * * Altering the theme settings menu items so they have * their own permission. */ function access_theme_settings_menu_alter(&$items) { // Get the full system file path to the include file. $file = './' . drupal_get_path('module', 'system') . '/system.admin.inc'; $file = realpath($file); // Re-define all theme admin menu items using the old access argument. // We need to rebuild totally - for some reason hook_menu() "forgets" // values set in system.module. $items['admin/build/themes'] = array( 'title' => 'Themes', 'description' => 'Change which theme your site uses or allows users to set.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_themes_form', NULL), 'access arguments' => array('administer default theme settings'), 'file' => $file, ); $items['admin/build/themes/settings'] = array( 'title' => 'Configure', 'page arguments' => array('system_theme_settings'), 'access arguments' => array('administer default theme settings'), 'type' => MENU_LOCAL_TASK, ); foreach (list_themes() as $theme) { $items['admin/build/themes/settings/'. $theme->name] = array( 'title' => $theme->info['name'], 'page arguments' => array('system_theme_settings', $theme->name), 'type' => MENU_LOCAL_TASK, 'access callback' => '_access_theme_settings_themes_access', 'access arguments' => array($theme), ); } } /** * Menu item access callback - only admin or enabled themes can be accessed. * * Overrides _system_themes_access(). */ function _access_theme_settings_themes_access($theme) { return user_access('administer default theme settings') && ($theme->status || $theme->name == variable_get('admin_theme', '0')); }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp phps
.