Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 804feede10391412fd38769116436f74de89fcae 1 parent 93fb7b5
Petr Skoda skodak authored

Showing 1 changed file with 2 additions and 1 deletion. Show diff stats Hide diff stats

  1. +2 1  lib/accesslib.php
3  lib/accesslib.php
@@ -2484,6 +2484,7 @@ function update_capabilities($component = 'moodle') {
2484 2484 }
2485 2485 }
2486 2486 // Add new capabilities to the stored definition.
  2487 + $existingcaps = $DB->get_records_menu('capabilities', array(), 'id', 'id, name');
2487 2488 foreach ($newcaps as $capname => $capdef) {
2488 2489 $capability = new stdClass();
2489 2490 $capability->name = $capname;
@@ -2494,7 +2495,7 @@ function update_capabilities($component = 'moodle') {
2494 2495
2495 2496 $DB->insert_record('capabilities', $capability, false);
2496 2497
2497   - if (isset($capdef['clonepermissionsfrom']) && in_array($capdef['clonepermissionsfrom'], $storedcaps)){
  2498 + if (isset($capdef['clonepermissionsfrom']) && in_array($capdef['clonepermissionsfrom'], $existingcaps)){
2498 2499 if ($rolecapabilities = $DB->get_records('role_capabilities', array('capability'=>$capdef['clonepermissionsfrom']))){
2499 2500 foreach ($rolecapabilities as $rolecapability){
2500 2501 //assign_capability will update rather than insert if capability exists

0 comments on commit 804feed

Please sign in to comment.
Something went wrong with that request. Please try again.