Skip to content

Commit

Permalink
MDL-65782 roles: allow several roles with user/frontpage archetype
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Jun 4, 2019
1 parent 29c3951 commit 5ecbc5d
Showing 5 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion admin/settings/frontpage.php
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@
foreach ($roles as $role) {
if (empty($role->archetype) or $role->archetype === 'guest' or $role->archetype === 'frontpage' or $role->archetype === 'student') {
$options[$role->id] = $role->localname;
if ($role->archetype === 'frontpage') {
if ($role->archetype === 'frontpage' && !$defaultfrontpageroleid) {
$defaultfrontpageroleid = $role->id;
}
}
6 changes: 2 additions & 4 deletions admin/tool/lp/tests/externallib_test.php
Original file line number Diff line number Diff line change
@@ -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.
*/
protected function setUp() {
global $DB;
global $DB, $CFG;

$this->resetAfterTest(true);

@@ -91,9 +91,7 @@ protected function setUp() {
$catcontext = context_coursecat::instance($category->id);

// Fetching default authenticated user role.
$userroles = get_archetype_roles('user');
$this->assertCount(1, $userroles);
$authrole = array_pop($userroles);
$authrole = $DB->get_record('role', array('id' => $CFG->defaultuserroleid));

// Reset all default authenticated users permissions.
unassign_capability('moodle/competency:competencygrade', $authrole->id);
5 changes: 2 additions & 3 deletions cohort/tests/externallib_test.php
Original file line number Diff line number Diff line change
@@ -522,6 +522,7 @@ public function test_delete_cohort_members() {
* Search cohorts.
*/
public function test_search_cohorts() {
global $DB, $CFG;
$this->resetAfterTest(true);

$creator = $this->getDataGenerator()->create_user();
@@ -537,9 +538,7 @@ public function test_search_cohorts() {
$coursecontext = context_course::instance($course->id);

// Fetching default authenticated user role.
$userroles = get_archetype_roles('user');
$this->assertCount(1, $userroles);
$authrole = array_pop($userroles);
$authrole = $DB->get_record('role', array('id' => $CFG->defaultuserroleid));

// Reset all default authenticated users permissions.
unassign_capability('moodle/cohort:manage', $authrole->id);
6 changes: 2 additions & 4 deletions competency/tests/external_test.php
Original file line number Diff line number Diff line change
@@ -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.
*/
protected function setUp() {
global $DB;
global $DB, $CFG;

$this->resetAfterTest(true);

@@ -114,9 +114,7 @@ protected function setUp() {
$othercatcontext = context_coursecat::instance($othercategory->id);

// Fetching default authenticated user role.
$userroles = get_archetype_roles('user');
$this->assertCount(1, $userroles);
$authrole = array_pop($userroles);
$authrole = $DB->get_record('role', array('id' => $CFG->defaultuserroleid));

// Reset all default authenticated users permissions.
unassign_capability('moodle/competency:competencygrade', $authrole->id);
2 changes: 1 addition & 1 deletion competency/tests/privacy_test.php
Original file line number Diff line number Diff line change
@@ -2576,7 +2576,7 @@ public function test_export_data_for_user_about_their_user_evidence() {
*/
protected function allow_anyone_to_comment_anywhere() {
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:planmanage', CAP_ALLOW, $roleid, SYSCONTEXTID, true);
assign_capability('moodle/competency:planmanagedraft', CAP_ALLOW, $roleid, SYSCONTEXTID, true);

0 comments on commit 5ecbc5d

Please sign in to comment.