perfmon.install in Performance monitor 7
Same filename and directory in other branches
Install, update and uninstall functions for the perfmon module.
File
perfmon.installView source
<?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;
}
Functions
Name | Description |
---|---|
perfmon_enable | Implements hook_enable(). |
perfmon_requirements | Implements hook_requirements(). |
perfmon_schema | Implements hook_schema(). |
perfmon_uninstall | Implements hook_uninstall(). |