mirror of
https://github.com/moodle/moodle.git
synced 2025-02-25 04:23:22 +01:00
Merge branch 'MDL-81942' of https://github.com/paulholden/moodle
This commit is contained in:
commit
b1b3f409fc
@ -84,6 +84,7 @@ Feature: Enable the course_list block on the frontpage and view it's contents
|
||||
And I add the "Courses" block
|
||||
And I log out
|
||||
When I log in as "guest"
|
||||
And I am on site homepage
|
||||
Then I should see "Category 1" in the "Course categories" "block"
|
||||
And I should see "Category A" in the "Course categories" "block"
|
||||
And I should see "Category B" in the "Course categories" "block"
|
||||
|
@ -177,7 +177,7 @@ Feature: Expand the courses nodes within the navigation block
|
||||
Scenario: As guest I expand the courses and category nodes to see courses.
|
||||
When I log in as "guest"
|
||||
And I am on site homepage
|
||||
And I should see "Home" in the "Navigation" "block"
|
||||
And I should see "Site home" in the "Navigation" "block"
|
||||
And I should see "Courses" in the "Navigation" "block"
|
||||
And I expand "Courses" node
|
||||
And I should see "cat1" in the "Navigation" "block"
|
||||
|
@ -10081,18 +10081,18 @@ function mnet_get_idp_jump_url($user) {
|
||||
function get_home_page() {
|
||||
global $CFG;
|
||||
|
||||
if (isloggedin() && !isguestuser() && !empty($CFG->defaulthomepage)) {
|
||||
if (isloggedin() && !empty($CFG->defaulthomepage)) {
|
||||
// If dashboard is disabled, home will be set to default page.
|
||||
$defaultpage = get_default_home_page();
|
||||
if ($CFG->defaulthomepage == HOMEPAGE_MY) {
|
||||
if ($CFG->defaulthomepage == HOMEPAGE_MY && (!isguestuser() || !empty($CFG->allowguestmymoodle))) {
|
||||
if (!empty($CFG->enabledashboard)) {
|
||||
return HOMEPAGE_MY;
|
||||
} else {
|
||||
return $defaultpage;
|
||||
}
|
||||
} else if ($CFG->defaulthomepage == HOMEPAGE_MYCOURSES) {
|
||||
} else if ($CFG->defaulthomepage == HOMEPAGE_MYCOURSES && !isguestuser()) {
|
||||
return HOMEPAGE_MYCOURSES;
|
||||
} else {
|
||||
} else if ($CFG->defaulthomepage == HOMEPAGE_USER && !isguestuser()) {
|
||||
$userhomepage = (int) get_user_preferences('user_home_page_preference', $defaultpage);
|
||||
if (empty($CFG->enabledashboard) && $userhomepage == HOMEPAGE_MY) {
|
||||
// If the user was using the dashboard but it's disabled, return the default home page.
|
||||
|
@ -5164,13 +5164,20 @@ EOT;
|
||||
* @dataProvider get_home_page_provider
|
||||
* @param string $user Whether the user is logged, guest or not logged.
|
||||
* @param int $expected Expected value after calling the get_home_page method.
|
||||
* @param int $defaulthomepage The $CFG->defaulthomepage setting value.
|
||||
* @param int $enabledashboard Whether the dashboard should be enabled or not.
|
||||
* @param int $userpreference User preference for the home page setting.
|
||||
* @param int|null $defaulthomepage The $CFG->defaulthomepage setting value.
|
||||
* @param int|null $enabledashboard Whether the dashboard should be enabled or not.
|
||||
* @param int|null $userpreference User preference for the home page setting.
|
||||
* $param int|null $allowguestmymoodle The $CFG->allowguestmymoodle setting value.
|
||||
* @covers ::get_home_page
|
||||
*/
|
||||
public function test_get_home_page(string $user, int $expected, ?int $defaulthomepage = null, ?int $enabledashboard = null,
|
||||
?int $userpreference = null): void {
|
||||
public function test_get_home_page(
|
||||
string $user,
|
||||
int $expected,
|
||||
?int $defaulthomepage = null,
|
||||
?int $enabledashboard = null,
|
||||
?int $userpreference = null,
|
||||
?int $allowguestmymoodle = null,
|
||||
): void {
|
||||
global $CFG, $USER;
|
||||
|
||||
$this->resetAfterTest();
|
||||
@ -5187,6 +5194,9 @@ EOT;
|
||||
if (isset($enabledashboard)) {
|
||||
$CFG->enabledashboard = $enabledashboard;
|
||||
}
|
||||
if (isset($allowguestmymoodle)) {
|
||||
$CFG->allowguestmymoodle = $allowguestmymoodle;
|
||||
}
|
||||
|
||||
if ($USER) {
|
||||
set_user_preferences(['user_home_page_preference' => $userpreference], $USER->id);
|
||||
@ -5201,21 +5211,37 @@ EOT;
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_home_page_provider(): array {
|
||||
public static function get_home_page_provider(): array {
|
||||
return [
|
||||
'No logged user' => [
|
||||
'user' => 'nologged',
|
||||
'expected' => HOMEPAGE_SITE,
|
||||
],
|
||||
'Guest user' => [
|
||||
'Guest user. Dashboard set as default home page and enabled for guests' => [
|
||||
'user' => 'guest',
|
||||
'expected' => HOMEPAGE_MY,
|
||||
],
|
||||
'Guest user. Dashboard set as default home page but disabled for guests' => [
|
||||
'user' => 'guest',
|
||||
'expected' => HOMEPAGE_SITE,
|
||||
'defaulthomepage' => HOMEPAGE_MY,
|
||||
'enabledashboard' => 1,
|
||||
'userpreference' => null,
|
||||
'allowguestmymoodle' => 0,
|
||||
],
|
||||
'Guest user. My courses set as default home page' => [
|
||||
'user' => 'guest',
|
||||
'expected' => HOMEPAGE_SITE,
|
||||
'defaulthomepage' => HOMEPAGE_MYCOURSES,
|
||||
],
|
||||
'Guest user. User preference set as default page' => [
|
||||
'user' => 'guest',
|
||||
'expected' => HOMEPAGE_SITE,
|
||||
'defaulthomepage' => HOMEPAGE_USER,
|
||||
],
|
||||
'Logged user. Dashboard set as default home page and enabled' => [
|
||||
'user' => 'logged',
|
||||
'expected' => HOMEPAGE_MY,
|
||||
'defaulthomepage' => HOMEPAGE_MY,
|
||||
'enabledashboard' => 1,
|
||||
],
|
||||
'Logged user. Dashboard set as default home page but disabled' => [
|
||||
'user' => 'logged',
|
||||
|
@ -36,13 +36,11 @@ Feature: Contact site support method and availability can be customised
|
||||
When I am on site homepage
|
||||
Then I should not see "Contact site support" in the "page-footer" "region"
|
||||
And I am on the "user > Contact Site Support" page
|
||||
And I should see "Acceptance test site" in the "page-header" "region"
|
||||
And I should not see "Contact site support" in the "page-header" "region"
|
||||
# Confirm someone logged in as guest cannot see the option or directly access the page.
|
||||
And I log in as "guest"
|
||||
And I should not see "Contact site support" in the "page-footer" "region"
|
||||
And I am on the "user > Contact Site Support" page
|
||||
And I should see "Acceptance test site" in the "page-header" "region"
|
||||
And I should not see "Contact site support" in the "page-header" "region"
|
||||
And I log out
|
||||
# Confirm logged in user has access to the contact form.
|
||||
|
Loading…
x
Reference in New Issue
Block a user