Unverified Commit e3bd6073 authored by Ghada El-Zoghbi's avatar Ghada El-Zoghbi Committed by Steven Spinelli

Bug 1831835: Site admins can send messgaes to anyone

Added behat test script
Site admins can send to any user in the system
regardless of the user's notification settings.

This capability was mistakenly removed in 19.04.

Sponsored by The Australian National University

Change-Id: I36e83ea4ae1b7b8765d70e067f49522de0d0aeb9
parent f9d4f332
......@@ -1822,6 +1822,13 @@ function can_send_message($from, $to) {
if (is_object($to)) {
$to = $to->id;
}
// Site admins can send to any user in the system
// regardless of the user's notification settings.
if ($from->admin) {
return true;
}
$messagepref = get_account_preference($to, 'messages');
$cansend = false;
......
@javascript @core @core_messages
Feature: Site admin can send messages to anyone regardless of setting "Messages from other users" to "Do not allow anyone to send me messages"
Background:
Given the following "institutions" exist:
| name | displayname | registerallowed | registerconfirm |
| instone | Institution One | ON | OFF |
And the following "users" exist:
| username | password | email | firstname | lastname | institution | authname | role |
| UserA | Kupuh1pa! | UserA@example.org | Angela | User | instone | internal | admin |
| UserB | Kupuh1pa! | UserB@example.org | Bob | User | instone | internal | staff |
| UserC | Kupuh1pa! | UserC@example.org | Carol | User | instone | internal | member |
| UserD | Kupuh1pa! | UserD@example.org | Dave | User | instone | internal | member |
And the following site settings are set:
| field | value |
| isolatedinstitutions | 1 |
# user set profile setting set to "Do not allow anyone to send me messages"
Given I log in as "UserD" with password "Kupuh1pa!"
And I choose "Preferences" in "Settings" from user menu
And I set the following fields to these values:
| Do not allow anyone to send me messages | 1 |
And I press "Save"
Then I should see "Preferences saved"
And I log out
Scenario: Site admin can send messages to anyone even if
A user "Does not allow anyone to send me messages"
Given I log in as "admin" with password "Kupuh1pa!"
And I choose "User search" in "Users" from administration menu
When I follow "Dave"
Then I should see "Send message"
When I choose "People" in "Engage" from main menu
Then I should see "Send message" in the "Dave User (UserD)" row
And I log out
# Mahara member with no roles canot send messages to a user
# who "Does not allow anyone to send me messages"
Given I log in as "UserC" with password "Kupuh1pa!"
When I choose "People" in "Engage" from main menu
#Then I should not see "Send message" in the "Dave User (UserD)" row
When I follow "Dave"
Then I should not see "Send message"
And I log out
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment