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 / +44 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
        firstname    => 'Jane',
1593
        surname      => 'Smith',
1594
        categorycode => $patron_category,
1595
        branchcode   => $library->{branchcode},
1596
        dateofbirth  => $date,
1597
    })->store->borrowernumber;
1598
1599
    $dbh->do(q|DELETE FROM message_queue|);
1600
    $my_message = {
1601
        'letter' => {
1602
            'content'      => 'a message',
1603
            'metadata'     => 'metadata',
1604
            'code'         => 'TEST_MESSAGE',
1605
            'content_type' => 'text/plain',
1606
            'title'        => 'message title'
1607
        },
1608
        'borrowernumber'         => $borrowernumber,
1609
        'to_address'             => undef,
1610
        'message_transport_type' => 'sms',
1611
        'from_address'           => 'from@example.com'
1612
    };
1613
1614
    my $id = C4::Letters::EnqueueLetter($my_message);
1615
1616
    t::lib::Mocks::mock_preference('MessageQueueMode', 'off');
1617
    C4::Letters::SendQueuedMessages();
1618
    is( Koha::Notice::Messages->find( $id )->status, 'pending', 'Message is pending for off' );
1619
1620
    t::lib::Mocks::mock_preference('MessageQueueMode', 'plugin');
1621
    C4::Letters::SendQueuedMessages();
1622
    is( Koha::Notice::Messages->find( $id )->status, 'pending', 'Message is pending for plugin' );
1623
1624
    t::lib::Mocks::mock_preference('MessageQueueMode', 'on');
1625
    C4::Letters::SendQueuedMessages();
1626
    is( Koha::Notice::Messages->find( $id )->status, 'failed', 'Message is failed for on' );
1627
};

Return to bug 37885