MDL-41285 blocks: capabilities to view structural changes in recent activities
This commit is contained in:
@@ -127,6 +127,13 @@ class block_recent_activity extends block_base {
|
||||
protected function get_structural_changes() {
|
||||
global $DB;
|
||||
$course = $this->page->course;
|
||||
$context = context_course::instance($course->id);
|
||||
$canviewdeleted = has_capability('block/recent_activity:viewdeletemodule', $context);
|
||||
$canviewupdated = has_capability('block/recent_activity:viewaddupdatemodule', $context);
|
||||
if (!$canviewdeleted && !$canviewupdated) {
|
||||
return;
|
||||
}
|
||||
|
||||
$timestart = $this->get_timestart();
|
||||
$changelist = array();
|
||||
// The following query will retrieve the latest action for each course module in the specified course.
|
||||
@@ -154,7 +161,7 @@ class block_recent_activity extends block_base {
|
||||
if ($wasdeleted && $wascreated) {
|
||||
// Activity was created and deleted within this interval. Do not show it.
|
||||
continue;
|
||||
} else if ($wasdeleted) {
|
||||
} else if ($wasdeleted && $canviewdeleted) {
|
||||
if (plugin_supports('mod', $log->modname, FEATURE_NO_VIEW_LINK, false)) {
|
||||
// Better to call cm_info::has_view() because it can be dynamic.
|
||||
// But there is no instance of cm_info now.
|
||||
@@ -168,7 +175,7 @@ class block_recent_activity extends block_base {
|
||||
'modfullname' => $modnames[$log->modname]
|
||||
));
|
||||
|
||||
} else if (!$wasdeleted && isset($modinfo->cms[$log->cmid])) {
|
||||
} else if (!$wasdeleted && isset($modinfo->cms[$log->cmid]) && $canviewupdated) {
|
||||
// Module was either added or updated during this interval and it currently exists.
|
||||
// If module was both added and updated show only "add" action.
|
||||
$cm = $modinfo->cms[$log->cmid];
|
||||
|
||||
@@ -38,4 +38,20 @@ $capabilities = array(
|
||||
|
||||
'clonepermissionsfrom' => 'moodle/site:manageblocks'
|
||||
),
|
||||
|
||||
'block/recent_activity:viewaddupdatemodule' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'user' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'block/recent_activity:viewdeletemodule' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'user' => CAP_ALLOW
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -25,3 +25,5 @@
|
||||
|
||||
$string['pluginname'] = 'Recent activity';
|
||||
$string['recent_activity:addinstance'] = 'Add a new recent activity block';
|
||||
$string['recent_activity:viewaddupdatemodule'] = 'View added and updated modules in recent activity block';
|
||||
$string['recent_activity:viewdeletemodule'] = 'View deleted modules in recent activity block';
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2014012000; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2014012001; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2013110500; // Requires this Moodle version
|
||||
$plugin->component = 'block_recent_activity'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->cron = 24*3600; // Cron interval 1 day.
|
||||
Reference in New Issue
Block a user