variable_realm_admin.module in Variable 7
Variable Realms Admin module
File
variable_realm_admin/variable_realm_admin.moduleView source
<?php
/**
* @file
* Variable Realms Admin module
*/
/**
* Implements hook_menu().
*/
function variable_realm_admin_menu() {
$items['admin/config/system/variable/realm'] = array(
'title' => 'Realms',
'description' => 'Configure realms.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'variable_realm_admin_realm_overview',
),
'file' => 'variable_realm_admin.pages.inc',
'access arguments' => array(
'administer site configuration',
),
'type' => MENU_LOCAL_TASK,
);
$items['admin/config/system/variable/realm/overview'] = array(
'title' => 'Overview',
'description' => 'Configure realms.',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$weight = 0;
foreach (variable_realm_list() as $realm => $title) {
$items['admin/config/system/variable/realm/' . $realm] = array(
'title callback' => 'variable_realm_admin_realm_title',
'title arguments' => array(
$realm,
),
'description' => 'Configure realm variables.',
'page callback' => 'variable_realm_admin_realm_info',
'page arguments' => array(
$realm,
),
'access callback' => 'variable_realm_admin_access',
'access arguments' => array(
$realm,
),
'file' => 'variable_realm_admin.pages.inc',
'type' => MENU_LOCAL_TASK,
'weight' => $weight++,
);
}
$items['admin/config/system/variable/realm/%/edit'] = array(
'title' => 'Edit',
'description' => 'Edit realm variables.',
'page callback' => 'variable_realm_admin_realm_edit',
'page arguments' => array(
5,
),
'access callback' => 'variable_realm_admin_access',
'access arguments' => array(
5,
'select',
),
'file' => 'variable_realm_admin.pages.inc',
);
$items['admin/config/system/variable/realm/%/configure'] = array(
'title' => 'Configure',
'description' => 'Configure realm variables.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'variable_realm_select_variables_form',
5,
),
'access callback' => 'variable_realm_admin_access',
'access arguments' => array(
5,
'select',
),
'file' => 'variable_realm.form.inc',
'file path' => drupal_get_path('module', 'variable_realm'),
);
return $items;
}
/**
* Check permission for administering realm
*/
function variable_realm_admin_access($realm_name, $property = 'title') {
if ($info = variable_realm_info($realm_name)) {
return !empty($info[$property]) && user_access('administer site configuration');
}
}
/**
* Retrieve title of given realm.
*/
function variable_realm_admin_realm_title($realm) {
$info = variable_realm_info($realm);
return isset($info['title']) ? $info['title'] : $realm;
}
Functions
Name | Description |
---|---|
variable_realm_admin_access | Check permission for administering realm |
variable_realm_admin_menu | Implements hook_menu(). |
variable_realm_admin_realm_title | Retrieve title of given realm. |