-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlib.php
160 lines (122 loc) · 3.77 KB
/
lib.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
defined('MOODLE_INTERNAL') || die();
define ('ADMIN_USER','ppollet');
/**
* log a description and a value to a file in moodledata directory
*/
function local_pp_error_log ($intro,$ex) {
global $CFG;
if (is_object($ex) || is_array($ex)){
$info=print_r((array)$ex,true);
}else $info=$ex."\n";
error_log (time().' : ' .$intro.' : '.$info,3,$CFG->dataroot.'/pp_debug_errors.log' );
}
/**
* user login via CAS
*
* @param object $user full $user object just extracted from DB in mdl_user
*/
function local_cas_user_login_handler($user) {
global $DB,$CFG,$USER;
local_pp_error_log ("processing CAS user login local event@insalyon eventdata is ",$user);
// global USER is not completed yet at this stage ...
// local_pp_error_log ("processing CAS user login local event@insalyon USER is ",$USER);
return true; //important
}
/**
* course created event handler
*
* @param object $course full $course object just inserted in DB
*/
function local_course_created($course) {
global $DB,$CFG,$USER;
local_pp_error_log ("processing course created local event@insalyon",$course);
return true; //important
}
/**
* course created event handler
*
* @param object $course full $course object just inserted in DB
*/
function local_course_updated($course) {
global $DB,$CFG,$USER;
local_pp_error_log ("processing course updated local event@insalyon",$course);
return true; //important
}
/**
* role asiigned event handler
*
* @param object $ra full object just updated in DB
*/
function local_role_assigned($ra) {
global $DB,$CFG,$USER;
local_pp_error_log ("processing role assigned local event@insalyon",$ra);
return true; //important
}
/**
* role unsiigned event handler
*
* @param object $ra full object just updated in DB
*/
function local_role_unassigned($ra) {
global $DB,$CFG,$USER;
local_pp_error_log ("processing role unassigned local event@insalyon",$ra);
return true; //important
}
/**
* user enrolled event handler
*
* @param object $ue full object just updated in DB
*/
function local_user_enrolled($ue) {
global $DB,$CFG,$USER;
local_pp_error_log ("processing user enrolled local event@insalyon",$ue);
return true; //important
}
/**
* user unenrolled event handler
*
* @param object $ue full object just updated in DB
*/
function local_user_unenrolled($ue) {
global $DB,$CFG,$USER;
local_pp_error_log ("processing user unenrolled local event@insalyon",$ue);
return true; //important
}
/**
* user enrol updated event handler
*
* @param object $ue full object just updated in DB
*/
function local_user_enrol_modified($ue) {
global $DB,$CFG,$USER;
local_pp_error_log ("processing user enrol modified local event@insalyon",$ue);
return true; //important
}
/**
* group created local event handler
* automatically create a grouping with the very same name
* @param unknown_type $eventdata
*/
function local_groups_group_created_handler($eventdata) {
global $CFG;
local_pp_error_log ("processing group created local event@insalyon",$eventdata);
//Moodle 1.9x has enablegroupings as an experimental option , not 2.x
if($CFG->version < 2011112900 && !$CFG->enablegroupings) {
return true; //ignore
}
$data = new stdClass();
$data->courseid = $eventdata->courseid;
$data->name = $eventdata->name;
$data->description = $eventdata->description;
$data->timecreated = $eventdata->timecreated;
$data->timemodified = $eventdata->timemodified;
if(!($id = groups_create_grouping($data))) {
return false; //event stays in queue
}
if(!groups_assign_grouping($id, $eventdata->id)) {
return false; //event stays in queue
}
return true;
}
?>