Commit e0249bdf authored by Doris Tam's avatar Doris Tam 🌷 Committed by Robert Lyon
Browse files

Bug 1396897: Greying out "send now" after the message if there has been a message sent before

Change-Id: I6c4ff3a560fdbebadbdfc42cd13674ab0ba66196
(cherry picked from commit 1541562f)
parent 9fb33fae
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -209,6 +209,7 @@ $editform = array(
            'type'         => 'switchbox',
            'title'        => get_string('sendnow', 'interaction.forum'),
            'description'  => get_string('sendnowdescription', 'interaction.forum', get_config_plugin('interaction', 'forum', 'postdelay')),
            'disabled'     => isset($post) && !empty($post->sent),
            'defaultvalue' => false,
        ),
        'submitpost'   => array(
@@ -235,6 +236,10 @@ if ((!$moderator && !$admintutor && !group_sendnow($parent->group)) || get_confi
    unset($editform['elements']['sendnow']);
}

if (isset($post) && (!empty($post->sent) || !user_can_edit_post($post->poster, $post->ctime))) {
    unset($editform['elements']['sendnow']);
}

$editform = pieform($editform);

function editpost_validate(Pieform $form, $values) {
+5 −0
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@ $editform = array(
            'type'         => 'switchbox',
            'title'        => get_string('sendnow', 'interaction.forum'),
            'description'  => get_string('sendnowdescription', 'interaction.forum', get_config_plugin('interaction', 'forum', 'postdelay')),
            'disabled'     => isset($topic) && !empty($topic->sent),
            'defaultvalue' => false,
        ),
        'submitpost'   => array(
@@ -219,6 +220,10 @@ if (!$moderator) {
    unset($editform['elements']['closed']);
}

if (isset($topic) && (!empty($topic->sent) || !user_can_edit_post($topic->poster, $topic->ctime))) {
    unset($editform['elements']['sendnow']);
}

$editform = pieform($editform);

function addtopic_validate(Pieform $form, $values) {
+53 −0
Original line number Diff line number Diff line
@javascript @core
Feature: Disabled the "Send Message Now" option when the time expired to edit forum posts
As a student
So I can edit messages later without notifying all the subscribed users

Background:
 Given the following "users" exist:
 | username | password | email | firstname | lastname | institution | authname | role |
 | UserA | Kupuh1pa! | UserA@example.org | Angela | User |  | admin | staff |
 | UserB | Kupuh1pa! | UserB@example.org | Bob | User |  | internal | member |
 | UserC | Kupuh1pa! | UserC@example.org | Cecilia | User |  | internal | member |

 And the following "groups" exist:
 | name | owner | description | grouptype | open | invitefriends | editroles | submittableto | allowarchives | members | staff |
 | GroupA | UserA | GroupA owned by UserA | standard | ON | OFF | all | ON | OFF | UserB, UserA | UserA |
 | GroupC | UserC | GroupC owned by UserC | standard | ON | OFF | all | OFF | OFF | UserC | UserC |

 # Admin user change 30 minute time expiry to 1 minutes
 Given I log in as "admin" with password "Kupuh1pa!"
 And I choose "Plugin administration" in "Extensions" from administration menu
 And I scroll to the center of id "interaction.installed"
 And I click on "Configuration for interaction forum"
 And I should see "Post delay"
 And I fill in "Post delay" with "1"
 And I press "Save"
 Then I log out

Scenario:  Checking the "Send Message Now" forum post option is disabled after time expired to send it (Bug 1396897)
 Given I log in as "UserA" with password "Kupuh1pa!"
 # Navigate to the Forums page
 And I choose "Groups" in "Engage" from main menu
 And I should see "GroupA"
 And I follow "GroupA"
 And I follow "Forums"

 # Create new topic
 When I follow "General discussion"
 And I follow "New topic"
 And I set the following fields to these values:
 | Subject | Testing subject 1 |
 | Message | message for testing subject 1 |
 # Checking "Send message now" switchbox is off by default
 And the "edittopic_sendnow" checkbox should not be checked
 # Turning the checkbox to send now
 And I enable the switch "Send message now"
 Then I press "Post"
 # Verifying post has been created
 And I follow "Forums"
 And I follow "General discussion"

 # Checking the send message is disabled once a message has sent
 Then I follow "Edit topic"
 Then I should not see "Send message now"