View | Details | Raw Unified | Return to bug 37885
Collapse All | Expand All

(-)a/C4/Letters.pm (+6 lines)
Lines 1021-1026 sub SendQueuedMessages { Link Here
1021
    Koha::Exceptions::BadParameter->throw("Parameter message_id cannot be empty if passed.")
1021
    Koha::Exceptions::BadParameter->throw("Parameter message_id cannot be empty if passed.")
1022
        if ( exists( $params->{message_id} ) && !$params->{message_id} );
1022
        if ( exists( $params->{message_id} ) && !$params->{message_id} );
1023
1023
1024
    my $MessageQueueMode = C4::Context->preference('MessageQueueMode');
1025
1026
    return 0 unless ( $MessageQueueMode eq 'on' || $MessageQueueMode eq 'plugin' );
1027
1024
    if ( C4::Context->config("enable_plugins") ) {
1028
    if ( C4::Context->config("enable_plugins") ) {
1025
        my @plugins = Koha::Plugins->new->GetPlugins({
1029
        my @plugins = Koha::Plugins->new->GetPlugins({
1026
            method => 'before_send_messages',
1030
            method => 'before_send_messages',
Lines 1038-1043 sub SendQueuedMessages { Link Here
1038
        }
1042
        }
1039
    }
1043
    }
1040
1044
1045
    return 0 unless ( $MessageQueueMode eq 'on' );
1046
1041
    my $smtp_transports = {};
1047
    my $smtp_transports = {};
1042
1048
1043
    my $count_messages = 0;
1049
    my $count_messages = 0;
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 411-416 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
411
('MaxTotalSuggestions','',NULL,'Number of total suggestions used for time limit with NumberOfSuggestionDays','Free'),
411
('MaxTotalSuggestions','',NULL,'Number of total suggestions used for time limit with NumberOfSuggestionDays','Free'),
412
('MembershipExpiryDaysNotice','',NULL,'Send an account expiration notice that a patron\'s card is about to expire after','Integer'),
412
('MembershipExpiryDaysNotice','',NULL,'Send an account expiration notice that a patron\'s card is about to expire after','Integer'),
413
('MergeReportFields','',NULL,'Displayed fields for deleted MARC records after merge','Free'),
413
('MergeReportFields','',NULL,'Displayed fields for deleted MARC records after merge','Free'),
414
('MessageQueueMode','on','on|off|plugins','Search Engine','Choice'),
414
('minPasswordLength','8',NULL,'Specify the minimum length of a patron/staff password','free'),
415
('minPasswordLength','8',NULL,'Specify the minimum length of a patron/staff password','free'),
415
('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''),
416
('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''),
416
('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'),
417
('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (+9 lines)
Lines 301-303 Administration: Link Here
301
                "ARRAY": "Searchable array"
301
                "ARRAY": "Searchable array"
302
            - <br>ISO2709 format is recommended as it is faster and takes less space, whereas array format makes the full MARC record searchable.
302
            - <br>ISO2709 format is recommended as it is faster and takes less space, whereas array format makes the full MARC record searchable.
303
            - <br><strong>NOTE:</strong> Making the full record searchable may have a negative effect on relevance ranking of search results.
303
            - <br><strong>NOTE:</strong> Making the full record searchable may have a negative effect on relevance ranking of search results.
304
    Message processing:
305
        -
306
            - "When running the message queue processor"
307
            - pref: MessageQueueMode
308
              default: on
309
              choices:
310
                on: process all messages and plugin hooks
311
                plugins: process plugin hooks only
312
                off: process nothing
(-)a/t/db_dependent/Letters.t (-2 / +46 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use File::Basename qw(dirname);
21
use File::Basename qw(dirname);
22
use Test::More tests => 103;
22
use Test::More tests => 104;
23
23
24
use Test::MockModule;
24
use Test::MockModule;
25
use Test::Warn;
25
use Test::Warn;
Lines 1582-1584 subtest 'Quote user params in GetPreparedLetter' => sub { Link Here
1582
        $exec_time
1582
        $exec_time
1583
        );
1583
        );
1584
};
1584
};
1585
- 
1585
1586
subtest 'Test MessageQueueMode' => sub {
1587
    plan tests => 3;
1588
1589
    my $dbh = C4::Context->dbh;
1590
1591
    my $borrowernumber = Koha::Patron->new(
1592
        {
1593
            firstname    => 'Jane',
1594
            surname      => 'Smith',
1595
            categorycode => $patron_category,
1596
            branchcode   => $library->{branchcode},
1597
            dateofbirth  => $date,
1598
        }
1599
    )->store->borrowernumber;
1600
1601
    $dbh->do(q|DELETE FROM message_queue|);
1602
    $my_message = {
1603
        'letter' => {
1604
            'content'      => 'a message',
1605
            'metadata'     => 'metadata',
1606
            'code'         => 'TEST_MESSAGE',
1607
            'content_type' => 'text/plain',
1608
            'title'        => 'message title'
1609
        },
1610
        'borrowernumber'         => $borrowernumber,
1611
        'to_address'             => undef,
1612
        'message_transport_type' => 'sms',
1613
        'from_address'           => 'from@example.com'
1614
    };
1615
1616
    my $id = C4::Letters::EnqueueLetter($my_message);
1617
1618
    t::lib::Mocks::mock_preference( 'MessageQueueMode', 'off' );
1619
    C4::Letters::SendQueuedMessages();
1620
    is( Koha::Notice::Messages->find($id)->status, 'pending', 'Message is pending for off' );
1621
1622
    t::lib::Mocks::mock_preference( 'MessageQueueMode', 'plugin' );
1623
    C4::Letters::SendQueuedMessages();
1624
    is( Koha::Notice::Messages->find($id)->status, 'pending', 'Message is pending for plugin' );
1625
1626
    t::lib::Mocks::mock_preference( 'MessageQueueMode', 'on' );
1627
    C4::Letters::SendQueuedMessages();
1628
    is( Koha::Notice::Messages->find($id)->status, 'failed', 'Message is failed for on' );
1629
};

Return to bug 37885