Commit fc1363d6d6fa5d48964c81afe15d25d4adab066d

Authored by DFNVC
1 parent 834174ca83
Exists in master

Anpassung für Moodle 3.6 und 3.7 - Bug MDL-65668

Showing 2 changed files with 57 additions and 9 deletions Side-by-side Diff

... ... @@ -11,13 +11,63 @@
11 11 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
12 12 */
13 13  
  14 +//
  15 +// DFNconf - Workaround wegen Bug MDL-65668
  16 +//
  17 +function ac_assign_capability($capability, $permission, $roleid, $contextid, $overwrite = false) {
  18 + global $USER, $DB;
  19 +
  20 + if ($contextid instanceof context) {
  21 + $context = $contextid;
  22 + } else {
  23 + $context = context::instance_by_id($contextid);
  24 + }
  25 +
  26 + // Capability must exist.
  27 + //if (!$capinfo = get_capability_info($capability)) {
  28 + // throw new coding_exception("Capability '{$capability}' was not found! This has to be fixed in code.");
  29 + //}
  30 +
  31 + if (empty($permission) || $permission == CAP_INHERIT) { // if permission is not set
  32 + unassign_capability($capability, $roleid, $context->id);
  33 + return true;
  34 + }
  35 +
  36 + $existing = $DB->get_record('role_capabilities', array('contextid'=>$context->id, 'roleid'=>$roleid, 'capability'=>$capability));
  37 +
  38 + if ($existing and !$overwrite) { // We want to keep whatever is there already
  39 + return true;
  40 + }
  41 +
  42 + $cap = new stdClass();
  43 + $cap->contextid = $context->id;
  44 + $cap->roleid = $roleid;
  45 + $cap->capability = $capability;
  46 + $cap->permission = $permission;
  47 + $cap->timemodified = time();
  48 + $cap->modifierid = empty($USER->id) ? 0 : $USER->id;
  49 +
  50 + if ($existing) {
  51 + $cap->id = $existing->id;
  52 + $DB->update_record('role_capabilities', $cap);
  53 + } else {
  54 + if ($DB->record_exists('context', array('id'=>$context->id))) {
  55 + $DB->insert_record('role_capabilities', $cap);
  56 + }
  57 + }
  58 +
  59 + // Reset any cache of this role, including MUC.
  60 + accesslib_clear_role_cache($roleid);
  61 +
  62 + return true;
  63 +}
  64 +
14 65 function xmldb_adobeconnect_install() {
15 66 global $DB;
16   -
17   - // The commented out code is waiting for a fix for MDL-25709
  67 +
18 68 $result = true;
19 69 $timenow = time();
20   - $sysctx = get_context_instance(CONTEXT_SYSTEM);
  70 + $sysctx = context_system::instance();
21 71 $mrole = new stdClass();
22 72 $levels = array(CONTEXT_COURSECAT, CONTEXT_COURSE, CONTEXT_MODULE);
23 73  
... ... @@ -51,11 +101,9 @@ function xmldb_adobeconnect_install() {
51 101  
52 102 if ($rid = create_role(get_string('adobeconnectpresenter', 'adobeconnect'), 'adobeconnectpresenter',
53 103 get_string('adobeconnectpresenterdescription', 'adobeconnect'), 'adobeconnectpresenter')) {
54   -
55 104 $mrole = new stdClass();
56 105 $mrole->id = $rid;
57   - $result = $result && assign_capability('mod/adobeconnect:meetingpresenter', CAP_ALLOW, $mrole->id, $sysctx->id);
58   -
  106 + $result = $result && ac_assign_capability('mod/adobeconnect:meetingpresenter', CAP_ALLOW, $mrole->id, $sysctx->id);
59 107 set_role_contextlevels($mrole->id, $levels);
60 108 } else {
61 109 $result = false;
... ... @@ -93,7 +141,7 @@ function xmldb_adobeconnect_install() {
93 141  
94 142 $mrole = new stdClass();
95 143 $mrole->id = $rid;
96   - $result = $result && assign_capability('mod/adobeconnect:meetingparticipant', CAP_ALLOW, $mrole->id, $sysctx->id);
  144 + $result = $result && ac_assign_capability('mod/adobeconnect:meetingparticipant', CAP_ALLOW, $mrole->id, $sysctx->id);
97 145 set_role_contextlevels($mrole->id, $levels);
98 146 } else {
99 147 $result = false;
... ... @@ -130,7 +178,7 @@ function xmldb_adobeconnect_install() {
130 178  
131 179 $mrole = new stdClass();
132 180 $mrole->id = $rid;
133   - $result = $result && assign_capability('mod/adobeconnect:meetinghost', CAP_ALLOW, $mrole->id, $sysctx->id);
  181 + $result = $result && ac_assign_capability('mod/adobeconnect:meetinghost', CAP_ALLOW, $mrole->id, $sysctx->id);
134 182 set_role_contextlevels($mrole->id, $levels);
135 183 } else {
136 184 $result = false;
... ... @@ -7,7 +7,7 @@
7 7 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
8 8 */
9 9  
10   -$plugin->version = 2018121900; // The current module version (Date: YYYYMMDDXX)
  10 +$plugin->version = 2019073000; // The current module version (Date: YYYYMMDDXX)
11 11 $plugin->requires = 2014051212; // Requires this Moodle version
12 12 $plugin->component = 'mod_adobeconnect';
13 13 $plugin->cron = 0; // Period for cron to check this module (secs)