-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchimedes.module
78 lines (75 loc) · 2.51 KB
/
archimedes.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
<?php
/**
* Implementation of hook_menu().
*/
function archimedes_menu() {
$items = array();
$items['admin/reports/archimedes'] = array(
'title' => t('Archimedes'),
'access arguments' => array('access administration pages'),
'page callback' => 'archimedes_out',
'description' => t('Administer Archimedes'),
'type' => MENU_NORMAL_ITEM,
'file' => 'archimedes.pages.inc',
);
$items['admin/reports/archimedes/data'] = array(
'title' => t('Data'),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/reports/archimedes/settings'] = array(
'title' => t('Settings'),
'page callback' => 'drupal_get_form',
'page arguments' => array('archimedes_admin'),
'access arguments' => array('access administration pages'),
'type' => MENU_LOCAL_TASK,
'file' => 'archimedes.pages.inc',
);
$items['admin/reports/archimedes/export'] = array(
'title' => t('XML Export'),
'page callback' => 'archimedes_export',
'access arguments' => array('access administration pages'),
'type' => MENU_LOCAL_TASK,
'file' => 'archimedes.pages.inc',
);
$items['admin/reports/archimedes/update'] = array(
'title' => t('Force Update'),
'access arguments' => array('access administration pages'),
'page callback' => 'archimedes_send_force',
'type' => MENU_LOCAL_TASK,
'weight' => 1,
'file' => 'archimedes.pages.inc',
);
$items['archimedes/login'] = array(
// Logic is handled in the access callback.
'access callback' => 'archimedes_request_admin_access',
'page callback' => 'page_not_found',
'type' => MENU_CALLBACK,
'file' => 'archimedes.pages.inc',
);
return $items;
}
/**
* Implements hook_cron().
*/
function archimedes_cron() {
// This logic is so that Archimedes reports will only run
// on a configured interval and not everytime cron runs.
$last_run = variable_get('archimedes_cron_last', FALSE);
$due_run = REQUEST_TIME - (variable_get('archimedes_cron_update', 1) * 86400);
if ($last_run === FALSE || $last_run < $due_run) {
require_once dirname(__FILE__) . '/archimedes.inc';
archimedes_send_report();
variable_set('archimedes_cron_last', REQUEST_TIME);
}
}
/**
* Implements hook_archimedes_id().
*
* A instance of an Archimedes report should be based
* on a single Drupal install which is the environment
* it says it is, coupled with the database credentials.
*/
function archimedes_archimedes_id() {
$environment = environment_current();
return variable_get('archimedes_common_key', '') . $environment;
}