mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-65782 roles: allow several roles with user/frontpage archetype
This commit is contained in:
parent
29c395187f
commit
5ecbc5d9f7
5 changed files with 8 additions and 13 deletions
|
@ -58,7 +58,7 @@ if (!during_initial_install()) { //do not use during installation
|
||||||
foreach ($roles as $role) {
|
foreach ($roles as $role) {
|
||||||
if (empty($role->archetype) or $role->archetype === 'guest' or $role->archetype === 'frontpage' or $role->archetype === 'student') {
|
if (empty($role->archetype) or $role->archetype === 'guest' or $role->archetype === 'frontpage' or $role->archetype === 'student') {
|
||||||
$options[$role->id] = $role->localname;
|
$options[$role->id] = $role->localname;
|
||||||
if ($role->archetype === 'frontpage') {
|
if ($role->archetype === 'frontpage' && !$defaultfrontpageroleid) {
|
||||||
$defaultfrontpageroleid = $role->id;
|
$defaultfrontpageroleid = $role->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
* Setup function- we will create a course and add an assign instance to it.
|
* Setup function- we will create a course and add an assign instance to it.
|
||||||
*/
|
*/
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
global $DB;
|
global $DB, $CFG;
|
||||||
|
|
||||||
$this->resetAfterTest(true);
|
$this->resetAfterTest(true);
|
||||||
|
|
||||||
|
@ -91,9 +91,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||||
$catcontext = context_coursecat::instance($category->id);
|
$catcontext = context_coursecat::instance($category->id);
|
||||||
|
|
||||||
// Fetching default authenticated user role.
|
// Fetching default authenticated user role.
|
||||||
$userroles = get_archetype_roles('user');
|
$authrole = $DB->get_record('role', array('id' => $CFG->defaultuserroleid));
|
||||||
$this->assertCount(1, $userroles);
|
|
||||||
$authrole = array_pop($userroles);
|
|
||||||
|
|
||||||
// Reset all default authenticated users permissions.
|
// Reset all default authenticated users permissions.
|
||||||
unassign_capability('moodle/competency:competencygrade', $authrole->id);
|
unassign_capability('moodle/competency:competencygrade', $authrole->id);
|
||||||
|
|
|
@ -522,6 +522,7 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
|
||||||
* Search cohorts.
|
* Search cohorts.
|
||||||
*/
|
*/
|
||||||
public function test_search_cohorts() {
|
public function test_search_cohorts() {
|
||||||
|
global $DB, $CFG;
|
||||||
$this->resetAfterTest(true);
|
$this->resetAfterTest(true);
|
||||||
|
|
||||||
$creator = $this->getDataGenerator()->create_user();
|
$creator = $this->getDataGenerator()->create_user();
|
||||||
|
@ -537,9 +538,7 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
|
||||||
$coursecontext = context_course::instance($course->id);
|
$coursecontext = context_course::instance($course->id);
|
||||||
|
|
||||||
// Fetching default authenticated user role.
|
// Fetching default authenticated user role.
|
||||||
$userroles = get_archetype_roles('user');
|
$authrole = $DB->get_record('role', array('id' => $CFG->defaultuserroleid));
|
||||||
$this->assertCount(1, $userroles);
|
|
||||||
$authrole = array_pop($userroles);
|
|
||||||
|
|
||||||
// Reset all default authenticated users permissions.
|
// Reset all default authenticated users permissions.
|
||||||
unassign_capability('moodle/cohort:manage', $authrole->id);
|
unassign_capability('moodle/cohort:manage', $authrole->id);
|
||||||
|
|
|
@ -97,7 +97,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
|
||||||
* Setup function- we will create a course and add an assign instance to it.
|
* Setup function- we will create a course and add an assign instance to it.
|
||||||
*/
|
*/
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
global $DB;
|
global $DB, $CFG;
|
||||||
|
|
||||||
$this->resetAfterTest(true);
|
$this->resetAfterTest(true);
|
||||||
|
|
||||||
|
@ -114,9 +114,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
|
||||||
$othercatcontext = context_coursecat::instance($othercategory->id);
|
$othercatcontext = context_coursecat::instance($othercategory->id);
|
||||||
|
|
||||||
// Fetching default authenticated user role.
|
// Fetching default authenticated user role.
|
||||||
$userroles = get_archetype_roles('user');
|
$authrole = $DB->get_record('role', array('id' => $CFG->defaultuserroleid));
|
||||||
$this->assertCount(1, $userroles);
|
|
||||||
$authrole = array_pop($userroles);
|
|
||||||
|
|
||||||
// Reset all default authenticated users permissions.
|
// Reset all default authenticated users permissions.
|
||||||
unassign_capability('moodle/competency:competencygrade', $authrole->id);
|
unassign_capability('moodle/competency:competencygrade', $authrole->id);
|
||||||
|
|
|
@ -2576,7 +2576,7 @@ class core_competency_privacy_testcase extends provider_testcase {
|
||||||
*/
|
*/
|
||||||
protected function allow_anyone_to_comment_anywhere() {
|
protected function allow_anyone_to_comment_anywhere() {
|
||||||
global $DB;
|
global $DB;
|
||||||
$roleid = $DB->get_field('role', 'id', ['archetype' => 'user'], MUST_EXIST);
|
$roleid = $DB->get_field('role', 'id', ['shortname' => 'user'], MUST_EXIST);
|
||||||
assign_capability('moodle/competency:plancomment', CAP_ALLOW, $roleid, SYSCONTEXTID, true);
|
assign_capability('moodle/competency:plancomment', CAP_ALLOW, $roleid, SYSCONTEXTID, true);
|
||||||
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $roleid, SYSCONTEXTID, true);
|
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $roleid, SYSCONTEXTID, true);
|
||||||
assign_capability('moodle/competency:planmanagedraft', CAP_ALLOW, $roleid, SYSCONTEXTID, true);
|
assign_capability('moodle/competency:planmanagedraft', CAP_ALLOW, $roleid, SYSCONTEXTID, true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue