mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-65093 core_message: dont show users with cap as blocked
It is possible that before this patch the user blocked a teacher from messaging them, even though this would have no effect. It is also possible for a user to block a user, then that user gets 'promoted' to a teacher role and the block becoming ineffective. In these cases we dont show the user's status as blocked.
This commit is contained in:
parent
90403c5d9d
commit
66fffdbce5
@ -583,7 +583,10 @@ class helper {
|
||||
|
||||
// Set contact and blocked status indicators.
|
||||
$data->iscontact = ($member->contactid) ? true : false;
|
||||
$data->isblocked = ($member->blockedid) ? true : false;
|
||||
|
||||
// We don't want that a user has been blocked if they can message the user anyways.
|
||||
$canmessageifblocked = api::can_send_message($referenceuserid, $member->id, true);
|
||||
$data->isblocked = ($member->blockedid && !$canmessageifblocked) ? true : false;
|
||||
|
||||
$data->isdeleted = ($member->deleted) ? true : false;
|
||||
|
||||
@ -594,9 +597,9 @@ class helper {
|
||||
$privacysetting = api::get_user_privacy_messaging_preference($member->id);
|
||||
$data->requirescontact = $privacysetting == api::MESSAGE_PRIVACY_ONLYCONTACTS;
|
||||
|
||||
// Here we check that if the sender wanted to block the recipient, the recipient would
|
||||
// still be able to message them regardless.
|
||||
$data->canmessageevenifblocked = api::can_send_message($referenceuserid, $member->id, true);
|
||||
// Here we check that if the sender wanted to block the recipient, the
|
||||
// recipient would still be able to message them regardless.
|
||||
$data->canmessageevenifblocked = !$data->isdeleted && $canmessageifblocked;
|
||||
$data->canmessage = !$data->isdeleted && api::can_send_message($member->id, $referenceuserid);
|
||||
}
|
||||
|
||||
|
@ -41,3 +41,27 @@ Feature: To be able to block users that we are able to or to see a message if we
|
||||
And I open contact menu
|
||||
When I click on "Block" "link" in the "[data-region='header-container']" "css_element"
|
||||
Then I should see "You are unable to block Teacher 1"
|
||||
|
||||
Scenario: Block a user who then gets an elevated role
|
||||
Given I log in as "student1"
|
||||
And I select "Student 2" user in messaging
|
||||
And I open contact menu
|
||||
And I click on "Block" "link" in the "[data-region='header-container']" "css_element"
|
||||
And I click on "Block" "button" in the "[data-region='confirm-dialogue']" "css_element"
|
||||
And I log out
|
||||
And I log in as "admin"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to course participants
|
||||
And I click on "Unenrol" "icon" in the "student2" "table_row"
|
||||
And I click on "Unenrol" "button" in the "Unenrol" "dialogue"
|
||||
And I enrol "Student 2" user as "Teacher"
|
||||
And I log out
|
||||
And I log in as "student2"
|
||||
And I select "Student 1" user in messaging
|
||||
And I should not see "You are unable to message this user"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I select "Student 2" user in messaging
|
||||
And I open contact menu
|
||||
When I click on "Block" "link" in the "[data-region='header-container']" "css_element"
|
||||
Then I should see "You are unable to block Student 2"
|
||||
|
Loading…
x
Reference in New Issue
Block a user