Permalink
Browse files

MDL-32477 allow cloning of plugin permissions from core

Please note it is discouraged to clone from different plugin type because the upgrade order is not guaranteed.
  • Loading branch information...
1 parent 93fb7b5 commit 804feede10391412fd38769116436f74de89fcae @skodak skodak committed Apr 19, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/accesslib.php
View
@@ -2484,6 +2484,7 @@ function update_capabilities($component = 'moodle') {
}
}
// Add new capabilities to the stored definition.
+ $existingcaps = $DB->get_records_menu('capabilities', array(), 'id', 'id, name');
foreach ($newcaps as $capname => $capdef) {
$capability = new stdClass();
$capability->name = $capname;
@@ -2494,7 +2495,7 @@ function update_capabilities($component = 'moodle') {
$DB->insert_record('capabilities', $capability, false);
- if (isset($capdef['clonepermissionsfrom']) && in_array($capdef['clonepermissionsfrom'], $storedcaps)){
+ if (isset($capdef['clonepermissionsfrom']) && in_array($capdef['clonepermissionsfrom'], $existingcaps)){
if ($rolecapabilities = $DB->get_records('role_capabilities', array('capability'=>$capdef['clonepermissionsfrom']))){
foreach ($rolecapabilities as $rolecapability){
//assign_capability will update rather than insert if capability exists

0 comments on commit 804feed

Please sign in to comment.