diff --git a/db/install.php b/db/install.php index 3559219a889a609f5f2f4fdf187a8f8e3d617c5a..eb9830e7ee9a3fc9d0daf1f3605d6e63fa9e9b5c 100644 --- a/db/install.php +++ b/db/install.php @@ -11,13 +11,63 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +// +// 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; +} + function xmldb_adobeconnect_install() { global $DB; - - // The commented out code is waiting for a fix for MDL-25709 + $result = true; $timenow = time(); - $sysctx = get_context_instance(CONTEXT_SYSTEM); + $sysctx = context_system::instance(); $mrole = new stdClass(); $levels = array(CONTEXT_COURSECAT, CONTEXT_COURSE, CONTEXT_MODULE); @@ -51,11 +101,9 @@ function xmldb_adobeconnect_install() { if ($rid = create_role(get_string('adobeconnectpresenter', 'adobeconnect'), 'adobeconnectpresenter', get_string('adobeconnectpresenterdescription', 'adobeconnect'), 'adobeconnectpresenter')) { - $mrole = new stdClass(); $mrole->id = $rid; - $result = $result && assign_capability('mod/adobeconnect:meetingpresenter', CAP_ALLOW, $mrole->id, $sysctx->id); - + $result = $result && ac_assign_capability('mod/adobeconnect:meetingpresenter', CAP_ALLOW, $mrole->id, $sysctx->id); set_role_contextlevels($mrole->id, $levels); } else { $result = false; @@ -93,7 +141,7 @@ function xmldb_adobeconnect_install() { $mrole = new stdClass(); $mrole->id = $rid; - $result = $result && assign_capability('mod/adobeconnect:meetingparticipant', CAP_ALLOW, $mrole->id, $sysctx->id); + $result = $result && ac_assign_capability('mod/adobeconnect:meetingparticipant', CAP_ALLOW, $mrole->id, $sysctx->id); set_role_contextlevels($mrole->id, $levels); } else { $result = false; @@ -130,7 +178,7 @@ function xmldb_adobeconnect_install() { $mrole = new stdClass(); $mrole->id = $rid; - $result = $result && assign_capability('mod/adobeconnect:meetinghost', CAP_ALLOW, $mrole->id, $sysctx->id); + $result = $result && ac_assign_capability('mod/adobeconnect:meetinghost', CAP_ALLOW, $mrole->id, $sysctx->id); set_role_contextlevels($mrole->id, $levels); } else { $result = false; diff --git a/version.php b/version.php index 1680bcecddcb816e53a428e19cbc14e4e472429a..3a86e2acb61e2756ddc45557973864a8980c30b1 100644 --- a/version.php +++ b/version.php @@ -7,7 +7,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$plugin->version = 2018121900; // The current module version (Date: YYYYMMDDXX) +$plugin->version = 2019073000; // The current module version (Date: YYYYMMDDXX) $plugin->requires = 2014051212; // Requires this Moodle version $plugin->component = 'mod_adobeconnect'; $plugin->cron = 0; // Period for cron to check this module (secs)