-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconfig_params.php
145 lines (126 loc) · 5.47 KB
/
config_params.php
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* ELIS(TM): Enterprise Learning Intelligence Suite
* Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package local_elisreports
* @author Remote-Learner.net Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
*
*/
//define('DEBUG_BROWSER_EMBEDDED_JS', 1);
require_once(dirname(__FILE__) .'/../../config.php');
require_once($CFG->dirroot .'/local/elisreports/parameter_form.class.php');
require_once($CFG->dirroot .'/local/eliscore/lib/filtering/lib.php');
require_once($CFG->libdir .'/formslib.php');
require_once($CFG->dirroot .'/local/elisreports/lib/filtering.php');
//not using require_login here because permissions are determined
//by the reports themselves
//report shortname
$report_shortname = required_param('id', PARAM_CLEAN);
//optional action url for form
$action = optional_param('url', null, PARAM_CLEAN);
$perpage = optional_param('perpage', 25, PARAM_INT);
$PAGE->set_context(context_system::instance());
if (empty($this)) {
// Called from AJAX, set emebeddded to force formslib formcounter to 999
$PAGE->set_pagelayout('embedded');
}
//require dependencies for filters
php_report_filtering_require_dependencies();
//key report data
$instance = php_report::get_default_instance($report_shortname);
//NOTE: this is slow because it populates filter values
$filters = $instance->get_filters();
//obtain any necessary information regarding secondary filterings
$dynamic_report_filter_url = $CFG->wwwroot .'/local/elisreports/dynamicreport.php?id='. $report_shortname;
$secondary_filterings = $instance->get_secondary_filterings(
$dynamic_report_filter_url,
$report_shortname, $report_shortname);
//when set, show the cancel button
$showcancel = optional_param('showcancel', 0, PARAM_INT);
//create the form, whose contents depend on on the current report's available filters
if (!empty($filters)) {
//report has filters
$dynamic_report_filter_url = $CFG->wwwroot.'/local/elisreports/dynamicreport.php?id='.$report_shortname;
$filter_object = new php_report_default_capable_filtering($filters,
$dynamic_report_filter_url, null, $report_shortname, $report_shortname, $secondary_filterings);
$params = array('filterobject' => $filter_object,
'showcancel' => $showcancel);
$parameter_form = new parameter_form($action, $params, 'post', '', array('id' => 'php_report_filter_form'));
} else {
//report does not have filters
$params = array('showcancel' => $showcancel);
$parameter_form = new parameter_form($action, $params, 'post', '', array('id' => 'php_report_filter_form'));
}
//send report id to the form
$parameter_form->set_data(array('id' => $report_shortname, 'showcancel' => $showcancel));
//update form with current settings
php_report_filtering_update_form($report_shortname, $parameter_form);
//determine if we are resetting the form
$reset_form = optional_param('reset_form', '', PARAM_CLEAN);
if (!empty($reset_form)) {
//reset case - do not use get_data because it performs validation
$data = data_submitted();
//store form settings as report-specific user preferences
php_report_filtering_reset_form($data, $filter_object, $report_shortname, $parameter_form);
} else if ($data = $parameter_form->get_data()) {
//NOTE: this has to be checked after get_data in this case
//because get_data calls definition_after_data, which adds the cancel button
if ($parameter_form->is_cancelled()) {
//just re-display the report
$instance->main('', '', 0, $perpage, '', $report_shortname);
die;
} else if (isset($data->save_defaults)) {
//store form settings as report-specific user preferences
php_report_filtering_save_preferences($data, $filter_object, $report_shortname);
} else if (isset($data->show_report)) {
//store temporary preferences
php_report_filtering_save_preferences($data, $filter_object, $report_shortname, true);
//re-display the report
$instance->main('', '', 0, $perpage, '', $report_shortname);
die;
}
}
/**
* Displaying the form
*/
$parameter_form->display();
if (empty($this)) {
// called from AJAX ...
$jscode = '
<script type="text/javascript">
//<![CDATA[
M.form.dependencyManager = null;
//]]>
</script>
'
. $PAGE->requires->get_end_code();
if (defined('DEBUG_BROWSER_EMBEDDED_JS')) {
// Enable to test if browsers runs this Javascript code!
$jscode .= '
<script type="text/javascript">
//<![CDATA[
alert("In outer form javascript re-init code");
//]]>
</script>
';
}
// Must re-init help_icons onclick and form dependencies ...
echo $jscode;
//error_log('config_params.php (AJAX): '. $jscode);
}