Newer
Older
<?php
// This file replaces:
// * STATEMENTS section in db/install.xml
// * lib.php/modulename_install() post installation hook
// * partially defaults.php
/**
* @package mod
* @subpackage adobeconnect
* @author Akinsaya Delamarre (adelamarre@remote-learner.net)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
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
//
// DFNconf - Workaround wegen Bug MDL-65668
//
function ac_assign_capability($capability, $permission, $roleid, $contextid, $overwrite = false) {
global $USER, $DB;
if ($contextid instanceof context) {
$context = $contextid;
} else {
$context = context::instance_by_id($contextid);
}
// Capability must exist.
//if (!$capinfo = get_capability_info($capability)) {
// throw new coding_exception("Capability '{$capability}' was not found! This has to be fixed in code.");
//}
if (empty($permission) || $permission == CAP_INHERIT) { // if permission is not set
unassign_capability($capability, $roleid, $context->id);
return true;
}
$existing = $DB->get_record('role_capabilities', array('contextid'=>$context->id, 'roleid'=>$roleid, 'capability'=>$capability));
if ($existing and !$overwrite) { // We want to keep whatever is there already
return true;
}
$cap = new stdClass();
$cap->contextid = $context->id;
$cap->roleid = $roleid;
$cap->capability = $capability;
$cap->permission = $permission;
$cap->timemodified = time();
$cap->modifierid = empty($USER->id) ? 0 : $USER->id;
if ($existing) {
$cap->id = $existing->id;
$DB->update_record('role_capabilities', $cap);
} else {
if ($DB->record_exists('context', array('id'=>$context->id))) {
$DB->insert_record('role_capabilities', $cap);
}
}
// Reset any cache of this role, including MUC.
accesslib_clear_role_cache($roleid);
return true;
}
$sysctx = context_system::instance();
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
$mrole = new stdClass();
$levels = array(CONTEXT_COURSECAT, CONTEXT_COURSE, CONTEXT_MODULE);
$param = array('shortname' => 'coursecreator');
$coursecreator = $DB->get_records('role', $param, 'id ASC', 'id', 0, 1);
if (empty($coursecreator)) {
$param = array('archetype' => 'coursecreator');
$coursecreator = $DB->get_records('role', $param, 'id ASC', 'id', 0, 1);
}
$coursecreatorrid = array_shift($coursecreator);
$param = array('shortname' =>'editingteacher');
$editingteacher = $DB->get_records('role', $param, 'id ASC', 'id', 0, 1);
if (empty($editingteacher)) {
$param = array('archetype' => 'editingteacher');
$editingteacher = $DB->get_records('role', $param, 'id ASC', 'id', 0, 1);
}
$editingteacherrid = array_shift($editingteacher);
$param = array('shortname' =>'teacher');
$teacher = $DB->get_records('role', $param, 'id ASC', 'id', 0, 1);
if (empty($teacher)) {
$param = array('archetype' => 'teacher');
$teacher = $DB->get_records('role', $param, 'id ASC', 'id', 0, 1);
}
$teacherrid = array_shift($teacher);
// Fully setup the Adobe Connect Presenter role.
$param = array('shortname' => 'adobeconnectpresenter');
if (!$mrole = $DB->get_record('role', $param)) {
if ($rid = create_role(get_string('adobeconnectpresenter', 'adobeconnect'), 'adobeconnectpresenter',
get_string('adobeconnectpresenterdescription', 'adobeconnect'), 'adobeconnectpresenter')) {
$mrole = new stdClass();
$mrole->id = $rid;
$result = $result && ac_assign_capability('mod/adobeconnect:meetingpresenter', CAP_ALLOW, $mrole->id, $sysctx->id);
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
set_role_contextlevels($mrole->id, $levels);
} else {
$result = false;
}
}
if (isset($coursecreatorrid->id)) {
$param = array('allowassign' => $mrole->id, 'roleid' => $coursecreatorrid->id);
if (!$DB->get_record('role_allow_assign', $param)) {
allow_assign($coursecreatorrid->id, $mrole->id);
}
}
if (isset($editingteacherrid->id)) {
$param = array('allowassign' => $mrole->id, 'roleid' => $editingteacherrid->id);
if (!$DB->get_record('role_allow_assign', $param)) {
allow_assign($editingteacherrid->id, $mrole->id);
}
}
if (isset($teacherrid->id)) {
$param = array('allowassign' => $mrole->id, 'roleid' => $teacherrid->id);
if (!$DB->get_record('role_allow_assign', $param)) {
allow_assign($teacherrid->id, $mrole->id);
}
}
// Fully setup the Adobe Connect Participant role.
$param = array('shortname' => 'adobeconnectparticipant');
if ($result && !($mrole = $DB->get_record('role', $param))) {
if ($rid = create_role(get_string('adobeconnectparticipant', 'adobeconnect'), 'adobeconnectparticipant',
get_string('adobeconnectparticipantdescription', 'adobeconnect'), 'adobeconnectparticipant')) {
$mrole = new stdClass();
$mrole->id = $rid;
$result = $result && ac_assign_capability('mod/adobeconnect:meetingparticipant', CAP_ALLOW, $mrole->id, $sysctx->id);
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
set_role_contextlevels($mrole->id, $levels);
} else {
$result = false;
}
}
if (isset($coursecreatorrid->id)) {
$param = array('allowassign' => $mrole->id, 'roleid' => $coursecreatorrid->id);
if (!$DB->get_record('role_allow_assign', $param)) {
allow_assign($coursecreatorrid->id, $mrole->id);
}
}
if (isset($editingteacherrid->id)) {
$param = array('allowassign' => $mrole->id, 'roleid' => $editingteacherrid->id);
if (!$DB->get_record('role_allow_assign', $param)) {
allow_assign($editingteacherrid->id, $mrole->id);
}
}
if (isset($teacherrid->id)) {
$param = array('allowassign' => $mrole->id, 'roleid' => $teacherrid->id);
if (!$DB->get_record('role_allow_assign', $param)) {
allow_assign($teacherrid->id, $mrole->id);
}
}
// Fully setup the Adobe Connect Host role.
$param = array('shortname' => 'adobeconnecthost');
if ($result && !$mrole = $DB->get_record('role', $param)) {
if ($rid = create_role(get_string('adobeconnecthost', 'adobeconnect'), 'adobeconnecthost',
get_string('adobeconnecthostdescription', 'adobeconnect'), 'adobeconnecthost')) {
$mrole = new stdClass();
$mrole->id = $rid;
$result = $result && ac_assign_capability('mod/adobeconnect:meetinghost', CAP_ALLOW, $mrole->id, $sysctx->id);
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
set_role_contextlevels($mrole->id, $levels);
} else {
$result = false;
}
}
if (isset($coursecreatorrid->id)) {
$param = array('allowassign' => $mrole->id, 'roleid' => $coursecreatorrid->id);
if (!$DB->get_record('role_allow_assign', $param)) {
allow_assign($coursecreatorrid->id, $mrole->id);
}
}
if (isset($editingteacherrid->id)) {
$param = array('allowassign' => $mrole->id, 'roleid' => $editingteacherrid->id);
if (!$DB->get_record('role_allow_assign', $param)) {
allow_assign($editingteacherrid->id, $mrole->id);
}
}
if (isset($teacherrid->id)) {
$param = array('allowassign' => $mrole->id, 'roleid' => $teacherrid->id);
if (!$DB->get_record('role_allow_assign', $param)) {
allow_assign($teacherrid->id, $mrole->id);
}
}
return $result;
}