1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Variable API module - Admin UI
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/**
|
8 |
|
|
* Implements hook_menu().
|
9 |
|
|
*/
|
10 |
|
|
function variable_admin_menu() {
|
11 |
|
|
$items['admin/config/system/variable'] = array(
|
12 |
|
|
'title' => 'Variables',
|
13 |
|
|
'description' => 'Variable settings for mixed modules.',
|
14 |
|
|
'page callback' => 'variable_admin_page_group',
|
15 |
|
|
'file' => 'variable_admin.inc',
|
16 |
|
|
'access arguments' => array('administer site configuration'),
|
17 |
|
|
);
|
18 |
|
|
$items['admin/config/system/variable/group'] = array(
|
19 |
|
|
'title' => 'Groups',
|
20 |
|
|
'description' => 'Variables per group.',
|
21 |
|
|
'type' => MENU_DEFAULT_LOCAL_TASK,
|
22 |
|
|
);
|
23 |
|
|
$items['admin/config/system/variable/module'] = array(
|
24 |
|
|
'title' => 'Modules',
|
25 |
|
|
'description' => 'Variables per module.',
|
26 |
|
|
'page callback' => 'variable_admin_page_module',
|
27 |
|
|
'file' => 'variable_admin.inc',
|
28 |
|
|
'access arguments' => array('administer site configuration'),
|
29 |
|
|
'type' => MENU_LOCAL_TASK,
|
30 |
|
|
);
|
31 |
|
|
$items['admin/config/system/variable/edit/%'] = array(
|
32 |
|
|
'title' => 'Edit variable',
|
33 |
|
|
'page callback' => 'drupal_get_form',
|
34 |
|
|
'page arguments' => array('variable_edit_form', 5),
|
35 |
|
|
'access callback' => 'variable_access',
|
36 |
|
|
'access arguments' => array(5),
|
37 |
|
|
);
|
38 |
|
|
if (module_exists('variable_realm')) {
|
39 |
|
|
$items['admin/config/system/variable/realm'] = array(
|
40 |
|
|
'title' => 'Realms',
|
41 |
|
|
'description' => 'Configure realms.',
|
42 |
|
|
'page callback' => 'drupal_get_form',
|
43 |
|
|
'page arguments' => array('variable_admin_realm_overview'),
|
44 |
|
|
'file' => 'variable_admin.inc',
|
45 |
|
|
'access arguments' => array('administer site configuration'),
|
46 |
|
|
'type' => MENU_LOCAL_TASK,
|
47 |
|
|
);
|
48 |
|
|
$items['admin/config/system/variable/realm/overview'] = array(
|
49 |
|
|
'title' => 'Overview',
|
50 |
|
|
'description' => 'Configure realms.',
|
51 |
|
|
'type' => MENU_DEFAULT_LOCAL_TASK,
|
52 |
|
|
'weight' => -10
|
53 |
|
|
);
|
54 |
|
|
$weight = 0;
|
55 |
|
|
foreach (variable_realm_list_all() as $realm => $controller) {
|
56 |
|
|
$items['admin/config/system/variable/realm/' . $realm] = array(
|
57 |
|
|
'title callback' => 'variable_admin_realm_title',
|
58 |
|
|
'title arguments' => array($realm),
|
59 |
|
|
'description' => 'Configure realm variables.',
|
60 |
|
|
'page callback' => 'variable_admin_realm_info',
|
61 |
|
|
'page arguments' => array($realm),
|
62 |
|
|
'access callback' => 'variable_admin_realm_access',
|
63 |
|
|
'access arguments' => array($realm),
|
64 |
|
|
'file' => 'variable_admin.inc',
|
65 |
|
|
'type' => MENU_LOCAL_TASK,
|
66 |
|
|
'weight' => $weight++,
|
67 |
|
|
);
|
68 |
|
|
}
|
69 |
|
|
$items['admin/config/system/variable/realm/%/edit'] = array(
|
70 |
|
|
'title' => 'Edit',
|
71 |
|
|
'description' => 'Edit realm variables.',
|
72 |
|
|
'page callback' => 'variable_admin_realm_edit',
|
73 |
|
|
'page arguments' => array(5),
|
74 |
|
|
'access callback' => 'variable_admin_realm_access',
|
75 |
|
|
'access arguments' => array(5, 'select'),
|
76 |
|
|
'file' => 'variable_admin.inc',
|
77 |
|
|
);
|
78 |
|
|
$items['admin/config/system/variable/realm/%/configure'] = array(
|
79 |
|
|
'title' => 'Configure',
|
80 |
|
|
'description' => 'Configure realm variables.',
|
81 |
|
|
'page callback' => 'drupal_get_form',
|
82 |
|
|
'page arguments' => array('variable_realm_select_variables_form', 5),
|
83 |
|
|
'access callback' => 'variable_admin_realm_access',
|
84 |
|
|
'access arguments' => array(5, 'select'),
|
85 |
|
|
'file' => 'variable_realm.form.inc',
|
86 |
|
|
'file path' => drupal_get_path('module', 'variable_realm'),
|
87 |
|
|
);
|
88 |
|
|
}
|
89 |
|
|
return $items;
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
/**
|
93 |
|
|
* Check permission for administering realm
|
94 |
|
|
*/
|
95 |
|
|
function variable_admin_realm_access($realm_name, $property = 'title') {
|
96 |
|
|
if ($info = variable_realm_info($realm_name)) {
|
97 |
|
|
return !empty($info[$property]) && user_access('administer site configuration');
|
98 |
|
|
}
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
/**
|
102 |
|
|
* Retrieve title of given realm.
|
103 |
|
|
*/
|
104 |
|
|
function variable_admin_realm_title($realm) {
|
105 |
|
|
$info = variable_realm_info($realm);
|
106 |
|
|
return isset($info['title']) ? $info['title'] : $realm;
|
107 |
|
|
} |