This repository has been archived by the owner on Aug 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
whm.module
95 lines (88 loc) · 2.17 KB
/
whm.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
* @file
* Provides menus, permissions and utilities to WHM Module.
*/
_whm_include('whm.api');
/**
* Implements hook_permission().
*/
function whm_permission() {
return array(
'administer whm' => array(
'title' => t('Administer WHM module'),
'description' => t('Can access WHM administration section.'),
),
'administer whm settings' => array(
'title' => t('Administer WHM settings'),
'description' => t('Can administer WHM settings.'),
),
);
}
/**
* Implements hook_menu().
*/
function whm_menu() {
$items['admin/whm'] = array(
'title' => 'WHM',
'description' => 'Web Hosting Manager integration.',
'page callback' => 'whm_admin_root_page',
'access arguments' => array('administer whm'),
'file' => 'includes/whm.admin.inc',
'position' => 'right',
'weight' => 6,
);
$items['admin/whm/settings'] = array(
'title' => 'Settings',
'description' => 'Configure the Web Hosting Manager integration',
'page callback' => 'drupal_get_form',
'page arguments' => array('whm_admin_settings'),
'access arguments' => array('administer whm settings'),
'file' => 'includes/whm.admin.inc',
'weight' => 0,
'type' => variable_get('whm_connected') == 1 ? MENU_LOCAL_TASK : MENU_DEFAULT_LOCAL_TASK,
);
return $items;
}
/**
* Implements hook_simpletest().
*/
function whm_simpletest() {
$dir = drupal_get_path('module', 'whm') . '/tests';
$tests = file_scan_directory($dir, '\.test$');
return array_keys($tests);
}
/**
* Include .inc files as necessary.
*/
function _whm_include($includes, $module = 'whm') {
if (is_string($includes)) {
$includes = array($includes);
}
static $used = array();
foreach ($includes as $file) {
if (!isset($used[$module][$file])) {
require_once './' . drupal_get_path('module', $module) . "/includes/$file.inc";
}
$used[$module][$file] = TRUE;
}
}
/**
* Helper for dumping debug data nicely.
*/
function _whm_dump($data, $exit = TRUE) {
print '<pre>';
if (is_array($data)) {
print_r($data);
}
elseif (is_object($data)) {
var_dump($data);
}
else {
print $data;
}
print '</pre>';
if ($exit) {
exit();
}
}