Permalink
Browse files

MDL-28488 backup - activity duplication requires 2 capabilities in ctx

  • Loading branch information...
1 parent 22e8ad6 commit 4b5233f9c48611a188050a3bf993df715a793aed @stronk7 stronk7 committed Sep 11, 2011
Showing with 13 additions and 4 deletions.
  1. +12 −4 course/lib.php
  2. +1 −0 course/modduplicate.php
View
16 course/lib.php
@@ -3168,15 +3168,23 @@ function make_editing_buttons($mod, $absolute=false, $moveselect=true, $indent=-
$assign = '';
}
+ // Duplicate (require both target import caps to be able to duplicate, see modduplicate.php)
+ $dupecaps = array('moodle/backup:backuptargetimport', 'moodle/restore:restoretargetimport');
+ if (has_all_capabilities($dupecaps, get_context_instance(CONTEXT_COURSE, $mod->course))) {
+ $duplicatemodule = '<a class="editing_duplicate" title="'.$str->duplicate.'" href="'.$path.'/mod.php?duplicate='.$mod->id.
+ '&amp;sesskey='.$sesskey.$section.'"><img'.
+ ' src="'.$OUTPUT->pix_url('t/copy') . '" class="iconsmall" '.
+ ' alt="'.$str->duplicate.'" /></a>'."\n";
+ } else {
+ $duplicatemodule = '';
+ }
+
return '<span class="commands">'."\n".$leftright.$move.
'<a class="editing_update" title="'.$str->update.'" href="'.$path.'/mod.php?update='.$mod->id.
'&amp;sesskey='.$sesskey.$section.'"><img'.
' src="'.$OUTPUT->pix_url('t/edit') . '" class="iconsmall" '.
' alt="'.$str->update.'" /></a>'."\n".
- '<a class="editing_duplicate" title="'.$str->duplicate.'" href="'.$path.'/mod.php?duplicate='.$mod->id.
- '&amp;sesskey='.$sesskey.$section.'"><img'.
- ' src="'.$OUTPUT->pix_url('t/copy') . '" class="iconsmall" '.
- ' alt="'.$str->duplicate.'" /></a>'."\n".
+ $duplicatemodule.
'<a class="editing_delete" title="'.$str->delete.'" href="'.$path.'/mod.php?delete='.$mod->id.
'&amp;sesskey='.$sesskey.$section.'"><img'.
' src="'.$OUTPUT->pix_url('t/delete') . '" class="iconsmall" '.
View
1 course/modduplicate.php
@@ -44,6 +44,7 @@
require_login($course);
require_sesskey();
require_capability('moodle/course:manageactivities', $context);
+// Require both target import caps to be able to duplicate, see make_editing_buttons()
require_capability('moodle/backup:backuptargetimport', $context);
require_capability('moodle/restore:restoretargetimport', $context);

0 comments on commit 4b5233f

Please sign in to comment.