-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeslib.module
More file actions
91 lines (84 loc) · 2.08 KB
/
geslib.module
File metadata and controls
91 lines (84 loc) · 2.08 KB
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
<?php
// $Id: geslib.module
/**
* @file
* Importacion/exportacion de datos con geslib.
*/
/**
* Implements hook_init().
*/
function geslib_init() {
}
/**
* Implements hook_permission().
*/
function geslib_permission() {
return array(
'geslib report page' => array(
'title' => t('Imported Geslib items report'),
),
'geslib delete report line' => array(
'title' => t('Delete imported Geslib item'),
),
);
}
/**
* Implementation of hook_menu().
*/
function geslib_menu() {
$items = array();
# Define reports page
$items['admin/store/reports/geslib_report'] = array(
'title' => 'Imported Geslib Files Report',
'description' => 'Imported Geslib Files Report',
'page callback' => 'geslib_files_report',
'access callback' => 'user_access',
'access arguments' => array('geslib report page'),
);
# Delete log line
$items['geslib/delete_log'] = array(
'title' => 'Delete log line',
'page callback' => 'geslib_delete_log',
'page arguments' => array(2, 3),
'access callback' => 'user_access',
'access arguments' => array('geslib delete report line'),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Implements hook_theme().
*/
function geslib_theme() {
return array(
'geslib_report' => array(
'template' => 'geslib_report',
'variables' => array('items' => NULL),
),
);
}
/**
* Callback: Report imported files page
*/
function geslib_files_report() {
$items = array();
# Get all geslib logs
$results = db_query("SELECT * FROM {geslib_log} ORDER BY start_date DESC LIMIT 30");
foreach($results as $record) {
$items[] = $record;
}
return theme('geslib_report', array('items' => $items));
}
/**
* Callback: Delete log line
*/
function geslib_delete_log($log_line) {
$valor = intval($log_line);
if ($valor > 0) {
// Remove from database
$results = db_delete('geslib_log')->condition('id', $valor)->execute();
drupal_set_message("Eliminada entrada $valor del log.");
}
unset($_REQUEST['destination']);
drupal_goto('admin/store/reports/geslib_report');
}