forked from ULCC/moodle-block_ilp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iconfile.php
65 lines (42 loc) · 1.71 KB
/
iconfile.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
<?php
/**
* Returns the icon file to be used with a report
*
* @copyright © 2011 University of London Computer Centre
* @author http://www.ulcc.ac.uk, http://moodle.ulcc.ac.uk
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package ILP
* @version 2.0
*/
//NOTE if icons are not being displayed a likely cause is output in one of the included files (within action_includes.php) check this as
//as well other factors
//require_once($path_to_config);
require_once('../../config.php');
global $USER, $CFG, $SESSION, $PARSER,$DB;
//include any neccessary files
// Meta includes
require_once($CFG->dirroot.'/blocks/ilp/actions_includes.php');
//if set get the id of the report to be edited
$report_id = $PARSER->required_param('report_id',PARAM_INT);
// instantiate the db
$dbc = new ilp_db();
$report = $dbc->get_report_by_id($report_id);
if (!empty($report)) {
if (!empty($report->binary_icon)) {
header("Content-Type: image/jpeg");
//header("Content-Length: 90000");
header("Content-Disposition: attachment; filename=icon.jpeg");
// Print data
//we have to use the raw moodle functions at this point and avoid the extra validation carried out by the sql classes
//as this breaks the export of reports
if (stripos($CFG->release,"2.") !== false) {
$generic_report = $DB->get_record('block_ilp_report',array('id'=>$report_id));
}
else {
$generic_report = get_record('block_ilp_report','id',$report_id);
}
echo $generic_report->binary_icon;
exit;
}
}
?>