-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathactions_includes.php
52 lines (36 loc) · 1.58 KB
/
actions_includes.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
<?php
//include the moodle library
require_once($CFG->dirroot.'/lib/moodlelib.php');
//include the ilp parser class
require_once($CFG->dirroot.'/blocks/ilp/classes/ilp_parser.class.php');
//include ilp db class
require_once($CFG->dirroot.'/blocks/ilp/db/ilp_db.php');
require_once($CFG->dirroot."/blocks/ilp/classes/ilp_formslib.class.php");
//include the library file
require_once($CFG->dirroot.'/blocks/ilp/lib.php');
//include the static constants
require_once($CFG->dirroot.'/blocks/ilp/constants.php');
//if this is moodle 1.9 then require the moodle 2 emulator
if (stripos($CFG->release,"2.") === false) require_once($CFG->dirroot.'/blocks/ilp/db/moodle2_emulator.php');
//include the access checks file
require_once($CFG->dirroot.'/blocks/ilp/db/accesscheck.php');
if ($USER->id != $user_id ) {
//we only require the viewotherilp capabilty id the user is not a ilp admin
if (empty($access_ilp_admin)) require_capability('block/ilp:viewotherilp', $context);
if (!empty($course_id)) {
$currentcoursecontext = get_context_instance(CONTEXT_COURSE, $course_id);
if ($context == $currentcoursecontext) {
$dbc = new ilp_db();
$userenrolled = $dbc->get_user_by_id($user_id);
//check that the user is enrolled on the current course if not then print error
$viewilp = true;
if (stripos($CFG->release,"2.") === false) {
if(!has_capability('moodle/course:view',$context,$userenrolled->id)) $viewilp = false;
} else {
if (!is_enrolled($context,$userenrolled)) $viewilp = false;
}
if (empty($viewilp)) print_error('usernotenrolled','block_ilp');
}
}
}
?>