Commit 452f2acd authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1831835: Site admins can send messgaes to anyone Added behat test...

Merge "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."
parents 1accb9b5 e3bd6073
......@@ -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