From d26749b74c676bb96885017b19f45cf51d0b3fda Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Mon, 15 Apr 2019 11:58:58 +0800 Subject: [PATCH] MDL-65354 core: rename course:browse cap to category:browsecourses --- lang/en/deprecated.txt | 1 + lang/en/role.php | 5 ++++- lib/db/access.php | 4 ++-- lib/db/upgrade.php | 15 +++++++++++++++ lib/upgrade.txt | 3 ++- version.php | 2 +- 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lang/en/deprecated.txt b/lang/en/deprecated.txt index 2243db866db..226de83d4cf 100644 --- a/lang/en/deprecated.txt +++ b/lang/en/deprecated.txt @@ -153,3 +153,4 @@ hidedockpanel,core_block undockall,core_block undockblock,core_block undockitem,core_block +course:browse,core_role diff --git a/lang/en/role.php b/lang/en/role.php index 13b4c1bb48e..19d09113024 100644 --- a/lang/en/role.php +++ b/lang/en/role.php @@ -98,6 +98,7 @@ $string['calendar:managegroupentries'] = 'Manage group calendar entries'; $string['calendar:manageownentries'] = 'Manage own calendar entries'; $string['capabilities'] = 'Capabilities'; $string['capability'] = 'Capability'; +$string['category:viewcourselist'] = 'View list of courses you are not enrolled in'; $string['category:create'] = 'Create categories'; $string['category:delete'] = 'Delete categories'; $string['category:manage'] = 'Manage categories'; @@ -154,7 +155,6 @@ $string['confirmunassignyes'] = 'Remove'; $string['confirmunassignno'] = 'Cancel'; $string['context'] = 'Context'; $string['course:activityvisibility'] = 'Hide/show activities'; -$string['course:browse'] = 'View list of courses where user is not enrolled'; $string['course:bulkmessaging'] = 'Send a message to many people'; $string['course:create'] = 'Create courses'; $string['course:creategroupconversations'] = 'Create group conversations'; @@ -495,3 +495,6 @@ $string['privacy:metadata:role_capabilities:tableexplanation'] = 'The capabiliti $string['privacy:metadata:role_capabilities:timemodified'] = 'The date when the capability was created or modified.'; $string['privacy:metadata:role_cohortroles'] = 'Roles to cohort'; $string['course:togglecompletion'] = 'Manually mark activities as complete'; + +// Deprecated since Moodle 3.7 +$string['course:browse'] = 'View list of courses where user is not enrolled'; diff --git a/lib/db/access.php b/lib/db/access.php index bfb9dd59128..87d472e92d8 100644 --- a/lib/db/access.php +++ b/lib/db/access.php @@ -733,10 +733,10 @@ $capabilities = array( 'clonepermissionsfrom' => 'moodle/category:update' ), - 'moodle/course:browse' => array( + 'moodle/category:viewcourselist' => array( 'captype' => 'read', - 'contextlevel' => CONTEXT_COURSE, + 'contextlevel' => CONTEXT_COURSECAT, 'archetypes' => array( 'guest' => CAP_ALLOW, 'user' => CAP_ALLOW, diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 8bf80630525..b57d6da9666 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2988,5 +2988,20 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2019041000.02); } + if ($oldversion < 2019041300.01) { + $sql = "UPDATE {capabilities} + SET name = ?, + contextlevel = ? + WHERE name = ?"; + $DB->execute($sql, ['moodle/category:viewcourselist', CONTEXT_COURSECAT, 'moodle/course:browse']); + + $sql = "UPDATE {role_capabilities} + SET capability = ? + WHERE capability = ?"; + $DB->execute($sql, ['moodle/category:viewcourselist', 'moodle/course:browse']); + + // Main savepoint reached. + upgrade_main_savepoint(true, 2019041300.01); + } return true; } diff --git a/lib/upgrade.txt b/lib/upgrade.txt index f1bbeceee21..e5567cdc7ea 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -2,7 +2,8 @@ This files describes API changes in core libraries and APIs, information provided here is intended especially for developers. === 3.7 === - +* The 'moodle/course:browse' has been renamed to a more accurate name 'moodle/category:viewcourselist'. + Also the context level of that capability has changed from course to course category context. * Nodes in the navigation api can have labels for each group. See set/get_collectionlabel(). * The method core_user::is_real_user() now returns false for userid = 0 parameter * 'mform1' dependencies (in themes, js...) will stop working because a randomly generated string has been added to the id diff --git a/version.php b/version.php index 9c67dd7edb8..bad8a947b07 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2019041300.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2019041300.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes.