1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Configurable Reports
|
|
|
19 |
* A Moodle block for creating customizable reports
|
|
|
20 |
* @package blocks
|
|
|
21 |
* @author: Juan leyva <http://www.twitter.com/jleyvadelgado>
|
|
|
22 |
* @date: 2009
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
// Based on Custom SQL Reports Plugin
|
|
|
26 |
// See http://moodle.org/mod/data/view.php?d=13&rid=2884.
|
|
|
27 |
|
|
|
28 |
if (!defined('MOODLE_INTERNAL')) {
|
|
|
29 |
// It must be included from a Moodle page.
|
|
|
30 |
die('Direct access to this script is forbidden.');
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
require_once($CFG->libdir.'/formslib.php');
|
|
|
34 |
|
|
|
35 |
class timeline_form extends moodleform {
|
|
|
36 |
public function definition() {
|
|
|
37 |
global $DB, $CFG;
|
|
|
38 |
|
|
|
39 |
$mform =& $this->_form;
|
|
|
40 |
|
|
|
41 |
$options = array(
|
|
|
42 |
'previous' => get_string('previousdays', 'block_configurable_reports'),
|
|
|
43 |
'fixeddate' => get_string('fixeddate', 'block_configurable_reports')
|
|
|
44 |
);
|
|
|
45 |
$mform->addElement('select', 'timemode', get_string('timemode', 'block_configurable_reports'), $options);
|
|
|
46 |
$mform->setDefault('timemode', 'previous');
|
|
|
47 |
|
|
|
48 |
$mform->addElement('text', 'previousstart', get_string('previousstart', 'block_configurable_reports'));
|
|
|
49 |
$mform->setDefault('previousstart', 1);
|
|
|
50 |
$mform->setType('previousstart', PARAM_INT);
|
|
|
51 |
$mform->addRule('previousstart', null, 'numeric', null, 'client');
|
|
|
52 |
$mform->disabledIf('previousstart', 'timemode', 'eq', 'fixeddate');
|
|
|
53 |
|
|
|
54 |
$mform->addElement('text', 'previousend', get_string('previousend', 'block_configurable_reports'));
|
|
|
55 |
$mform->setDefault('previousend', 0);
|
|
|
56 |
$mform->setType('previousend', PARAM_INT);
|
|
|
57 |
$mform->addRule('previousend', null, 'numeric', null, 'client');
|
|
|
58 |
$mform->disabledIf('previousend', 'timemode', 'eq', 'fixeddate');
|
|
|
59 |
|
|
|
60 |
$mform->addElement('checkbox', 'forcemidnight', get_string('forcemidnight', 'block_configurable_reports'));
|
|
|
61 |
$mform->disabledIf('forcemidnight', 'timemode', 'eq', 'fixeddate');
|
|
|
62 |
|
|
|
63 |
$mform->addElement('date_time_selector', 'starttime', get_string('starttime', 'block_configurable_reports'));
|
|
|
64 |
$mform->setDefault('starttime', time() - 3600 * 48);
|
|
|
65 |
$mform->disabledIf('starttime', 'timemode', 'eq', 'previous');
|
|
|
66 |
|
|
|
67 |
$mform->addElement('date_time_selector', 'endtime', get_string('endtime', 'block_configurable_reports'));
|
|
|
68 |
$mform->setDefault('endtime', time() + 3600 * 24);
|
|
|
69 |
$mform->disabledIf('endtime', 'timemode', 'eq', 'previous');
|
|
|
70 |
|
|
|
71 |
$mform->addElement('text', 'interval', get_string('timeinterval', 'block_configurable_reports'));
|
|
|
72 |
$mform->setDefault('interval', 1);
|
|
|
73 |
$mform->setType('interval', PARAM_INT);
|
|
|
74 |
$mform->addRule('interval', null, 'numeric', null, 'client');
|
|
|
75 |
$mform->addRule('interval', null, 'nonzero', null, 'client');
|
|
|
76 |
|
|
|
77 |
$orderingstr = get_string('ordering', 'block_configurable_reports');
|
|
|
78 |
$mform->addElement('select', 'ordering', $orderingstr, array('asc' => 'ASC', 'desc' => 'DESC'));
|
|
|
79 |
|
|
|
80 |
$this->add_action_buttons();
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
public function validation($data, $files) {
|
|
|
84 |
global $DB, $CFG, $db, $USER;
|
|
|
85 |
|
|
|
86 |
$errors = parent::validation($data, $files);
|
|
|
87 |
|
|
|
88 |
return $errors;
|
|
|
89 |
}
|
|
|
90 |
}
|