-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperfmon.install
102 lines (90 loc) · 2.28 KB
/
perfmon.install
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
96
97
98
99
100
101
102
<?php
/**
* @file
* Install, update and uninstall functions for the perfmon module.
*/
/**
* Implements hook_enable().
*/
function perfmon_enable() {
drupal_set_message(t('Performance Monitor module enabled. You should first set the module access permissions at !link. Be sure to grant permissions to trusted users only as this module can show senstive site information.', array('!link' => l(t('admin/people/permissions'), 'admin/people/permissions'))));
}
/**
* Implements hook_schema().
*/
function perfmon_schema() {
$schema['perfmon'] = array(
'fields' => array(
'testname' => array(
'type' => 'varchar',
'length' => 160,
'not null' => TRUE,
'default' => '',
),
'result' => array(
'type' => 'varchar',
'length' => 160,
'not null' => TRUE,
'default' => 0,
),
'lastrun' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('testname'),
);
$schema['perfmon_test'] = array(
'fields' => array(
'id' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'testname' => array(
'type' => 'varchar',
'length' => 160,
'not null' => TRUE,
'default' => 0,
),
'data' => array(
'type' => 'varchar',
'length' => 160,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('id'),
);
return $schema;
}
/**
* Implements hook_uninstall().
*/
function perfmon_uninstall() {
variable_del('perfmon_last_run');
}
/**
* Implements hook_requirements().
*/
function perfmon_requirements($phase) {
$requirements = array();
switch ($phase) {
case 'runtime':
$checks = perfmon_get_stored_results();
$t = get_t();
$url = url('admin/reports/perfmon');
if (empty($checks)) {
$severity = REQUIREMENT_WARNING;
$value = $t('The Performance monitor testlist has not been run. <a href="!url">Run the checklist</a>', array('!url' => $url));
}
$requirements['perfmon'] = array(
'title' => $t('Performance Monitor'),
'severity' => $severity,
'value' => $value,
);
break;
}
return $requirements;
}