MDL-63995 blocks: Remove unused capabilities and warning.

This commit is contained in:
Dan Marsden 2019-02-26 11:00:58 +13:00
parent 3271c39c74
commit ef78cf8f42
22 changed files with 43 additions and 64 deletions

View File

@ -580,6 +580,9 @@ class block_base {
function user_can_addto($page) {
global $USER;
// List of formats this block supports.
$formats = $this->applicable_formats();
// The blocks in My Moodle are a special case and use a different capability.
if (!empty($USER->id)
&& $page->context->contextlevel == CONTEXT_USER // Page belongs to a user
@ -587,7 +590,6 @@ class block_base {
&& $page->pagetype == 'my-index') { // Ensure we are on the My Moodle page
// If the block cannot be displayed on /my it is ok if the myaddinstance capability is not defined.
$formats = $this->applicable_formats();
// Is 'my' explicitly forbidden?
// If 'all' has not been allowed, has 'my' been explicitly allowed?
if ((isset($formats['my']) && $formats['my'] == false)
@ -601,6 +603,12 @@ class block_base {
&& has_capability('moodle/my:manageblocks', $page->context);
}
}
// Check if this is a block only used on /my.
unset($formats['my']);
if (empty($formats)) {
// Block can only be added to /my - return false.
return false;
}
$capability = 'block/' . $this->name() . ':addinstance';
if ($this->has_add_block_capability($page, $capability)

View File

@ -34,17 +34,5 @@ $capabilities = array(
),
'clonepermissionsfrom' => 'moodle/my:manageblocks'
),
'block/myoverview:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
)
);

View File

@ -54,7 +54,6 @@ $string['future'] = 'Future';
$string['inprogress'] = 'In progress';
$string['lastaccessed'] = 'Last accessed';
$string['list'] = 'List';
$string['myoverview:addinstance'] = 'Add a new course overview block';
$string['myoverview:myaddinstance'] = 'Add a new course overview block to Dashboard';
$string['past'] = 'Past';
$string['pluginname'] = 'Course overview';

View File

@ -0,0 +1,5 @@
This file describes API changes in the myoverview block code.
=== 3.7 ===
* The 'block/myoverview:addinstance' capability has been removed. It has never been used in code.

View File

@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018120300; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2019022600; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2018112800; // Requires this Moodle version.
$plugin->component = 'block_myoverview'; // Full name of the plugin (used for diagnostics).

View File

@ -34,15 +34,5 @@ $capabilities = array(
),
'clonepermissionsfrom' => 'moodle/my:manageblocks'
),
'block/recentlyaccessedcourses:addinstance' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
)
);

View File

@ -22,6 +22,5 @@
*/
$string['pluginname'] = 'Recently accessed courses';
$string['privacy:metadata'] = 'The Recently accessed courses block does not store any personal data.';
$string['recentlyaccessedcourses:addinstance'] = 'Add a new Recently accessed courses block';
$string['recentlyaccessedcourses:myaddinstance'] = 'Add a new recently accessed courses block to Dashboard';
$string['nocourses'] = 'No recent courses';

View File

@ -0,0 +1,5 @@
This file describes API changes in the recentlyaccesscourses block code.
=== 3.7 ===
* The 'block/recentlyaccesscourses:addinstance' capability has been removed. It has never been used in code.

View File

@ -22,6 +22,6 @@
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018120300; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2019022600; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2018112800; // Requires this Moodle version.
$plugin->component = 'block_recentlyaccessedcourses'; // Full name of the plugin (used for diagnostics).

View File

@ -29,13 +29,5 @@ $capabilities = array(
'user' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/my:manageblocks'
),
'block/recentlyaccesseditems:addinstance' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
)
);

View File

@ -28,5 +28,4 @@ $string['privacy:metadata:block_recentlyaccesseditemstablesummary'] = 'The Recen
$string['privacy:metadata:timeaccess'] = 'The time when the user last accessed the item';
$string['privacy:metadata:userid'] = 'The ID of the user who accessed the item';
$string['privacy:recentlyaccesseditemspath'] = 'Recently accessed items';
$string['recentlyaccesseditems:addinstance'] = 'Add a new recently accessed items block';
$string['recentlyaccesseditems:myaddinstance'] = 'Add a new recently accessed items block to Dashboard';

View File

@ -0,0 +1,5 @@
This file describes API changes in the recentlyaccesseditems block code.
=== 3.7 ===
* The 'block/recentlyaccesseditems:addinstance' capability has been removed. It has never been used in code.

View File

@ -22,6 +22,6 @@
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018120301; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2019022600; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2018112800; // Requires this Moodle version.
$plugin->component = 'block_recentlyaccesseditems'; // Full name of the plugin (used for diagnostics).

View File

@ -34,15 +34,5 @@ $capabilities = array(
),
'clonepermissionsfrom' => 'moodle/my:manageblocks'
),
'block/starredcourses:addinstance' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
)
);

View File

@ -24,6 +24,5 @@
$string['pluginname'] = 'Starred courses';
$string['privacy:metadata'] = 'The starred courses block does not store any personal data.';
$string['starredcourses:addinstance'] = 'Add a new starred courses block';
$string['starredcourses:myaddinstance'] = 'Add a new starred courses block to Dashboard';
$string['nocourses'] = 'No starred courses';

View File

@ -0,0 +1,5 @@
This file describes API changes in the starredcourses block code.
=== 3.7 ===
* The 'block/starredcourses:addinstance' capability has been removed. It has never been used in code.

View File

@ -23,6 +23,6 @@
*/
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2018120300;
$plugin->version = 2019022600;
$plugin->requires = 2018112800;
$plugin->component = 'block_starredcourses';

View File

@ -34,17 +34,5 @@ $capabilities = array(
),
'clonepermissionsfrom' => 'moodle/my:manageblocks'
),
'block/timeline:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
)
);

View File

@ -32,7 +32,6 @@ $string['ariaviewselector'] = 'Sort timeline items';
$string['ariaviewselectoroption'] = '{$a} sort option';
$string['duedate'] = 'Due date';
$string['morecourses'] = 'More courses';
$string['timeline:addinstance'] = 'Add a new timeline block';
$string['timeline:myaddinstance'] = 'Add a new timeline block to Dashboard';
$string['nocoursesinprogress'] = 'No in-progress courses';
$string['noevents'] = 'No upcoming activities due';

View File

@ -0,0 +1,5 @@
This file describes API changes in the timeline block code.
=== 3.7 ===
* The 'block/timeline:addinstance' capability has been removed. It has never been used in code.

View File

@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018120300; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2019022600; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2018112800; // Requires this Moodle version.
$plugin->component = 'block_timeline'; // Full name of the plugin (used for diagnostics).

View File

@ -1,6 +1,9 @@
This files describes API changes in /blocks/* - activity modules,
information provided here is intended especially for developers.
=== 3.7 ===
* The block:addinstance capability is no longer required if the block can only be added to a dashboard.
=== 3.6 ===
* The timeline view from block_myoverview has been split out into block_timeline.