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

(-)a/C4/Letters.pm (-2 / +8 lines)
Lines 783-794 sub _parseletter_sth { Link Here
783
    ($table eq 'aqorders'     )    ? "SELECT * FROM $table WHERE    ordernumber = ?"                                  :
783
    ($table eq 'aqorders'     )    ? "SELECT * FROM $table WHERE    ordernumber = ?"                                  :
784
    ($table eq 'aqbasket'     )    ? "SELECT * FROM $table WHERE       basketno = ?"                                  :
784
    ($table eq 'aqbasket'     )    ? "SELECT * FROM $table WHERE       basketno = ?"                                  :
785
    ($table eq 'illrequests'  )    ? "SELECT * FROM $table WHERE  illrequest_id = ?"                                  :
785
    ($table eq 'illrequests'  )    ? "SELECT * FROM $table WHERE  illrequest_id = ?"                                  :
786
    ($table eq 'opac_news'    )    ? "SELECT * FROM $table WHERE          idnew = ?"                                  :
787
    ($table eq 'article_requests') ? "SELECT * FROM $table WHERE             id = ?"                                  :
786
    ($table eq 'article_requests') ? "SELECT * FROM $table WHERE             id = ?"                                  :
788
    ($table eq 'borrower_modifications') ? "SELECT * FROM $table WHERE verification_token = ?" :
787
    ($table eq 'borrower_modifications') ? "SELECT * FROM $table WHERE verification_token = ?" :
789
    ($table eq 'subscription') ? "SELECT * FROM $table WHERE subscriptionid = ?" :
788
    ($table eq 'subscription') ? "SELECT * FROM $table WHERE subscriptionid = ?" :
790
    ($table eq 'serial') ? "SELECT * FROM $table WHERE serialid = ?" :
789
    ($table eq 'serial') ? "SELECT * FROM $table WHERE serialid = ?" :
791
    ($table eq 'problem_reports') ? "SELECT * FROM $table WHERE reportid = ?" :
790
    ($table eq 'problem_reports') ? "SELECT * FROM $table WHERE reportid = ?" :
791
    ($table eq 'additional_contents' || $table eq 'opac_news') ? "SELECT * FROM additional_contents WHERE idnew = ?" :
792
    undef ;
792
    undef ;
793
    unless ($query) {
793
    unless ($query) {
794
        warn "ERROR: No _parseletter_sth query for table '$table'";
794
        warn "ERROR: No _parseletter_sth query for table '$table'";
Lines 1642-1649 sub _get_tt_params { Link Here
1642
            plural   => 'items',
1642
            plural   => 'items',
1643
            pk       => 'itemnumber',
1643
            pk       => 'itemnumber',
1644
        },
1644
        },
1645
        additional_contents => {
1646
            module   => 'Koha::AdditionalContents',
1647
            singular => 'additional_content',
1648
            plural   => 'additional_contents',
1649
            pk       => 'idnew',
1650
        },
1645
        opac_news => {
1651
        opac_news => {
1646
            module   => 'Koha::News',
1652
            module   => 'Koha::AdditionalContents',
1647
            singular => 'news',
1653
            singular => 'news',
1648
            plural   => 'news',
1654
            plural   => 'news',
1649
            pk       => 'idnew',
1655
            pk       => 'idnew',
(-)a/C4/Members.pm (-7 / +12 lines)
Lines 40-46 use Koha::AuthUtils qw(hash_password); Link Here
40
use Koha::Database;
40
use Koha::Database;
41
use Koha::Holds;
41
use Koha::Holds;
42
use Koha::List::Patron;
42
use Koha::List::Patron;
43
use Koha::News;
43
use Koha::AdditionalContents;
44
use Koha::Patrons;
44
use Koha::Patrons;
45
use Koha::Patron::Categories;
45
use Koha::Patron::Categories;
46
46
Lines 496-502 sub GetBorrowersToExpunge { Link Here
496
      </overdue>
496
      </overdue>
497
497
498
      <news>
498
      <news>
499
         <<opac_news.*>>
499
         <<additional_contents.*>>
500
      </news>
500
      </news>
501
501
502
  ISSUEQSLIP:
502
  ISSUEQSLIP:
Lines 588-597 sub IssueSlip { Link Here
588
                issues      => $all,
588
                issues      => $all,
589
            };
589
            };
590
        }
590
        }
591
        my $news = Koha::News->search_for_display({
591
        my $news = Koha::AdditionalContents->search_for_display(
592
                location => 'slip',
592
            {
593
                category   => 'news',
594
                location   => 'slip',
595
                lang       => $patron->lang,
593
                library_id => $branch,
596
                library_id => $branch,
594
            });
597
            }
598
        );
595
        my @news;
599
        my @news;
596
        while ( my $n = $news->next ) {
600
        while ( my $n = $news->next ) {
597
            my $all = $n->unblessed_all_relateds;
601
            my $all = $n->unblessed_all_relateds;
Lines 603-609 sub IssueSlip { Link Here
603
            $all->{timestamp} = $published_on_dt;
607
            $all->{timestamp} = $published_on_dt;
604
608
605
            push @news, {
609
            push @news, {
606
                opac_news => $all,
610
                additional_contents => $all,
607
            };
611
            };
608
        }
612
        }
609
        $letter_code = 'ISSUESLIP';
613
        $letter_code = 'ISSUESLIP';
Lines 615-621 sub IssueSlip { Link Here
615
        %loops = (
619
        %loops = (
616
            issues => [ map { $_->{issues}{itemnumber} } @checkouts ],
620
            issues => [ map { $_->{issues}{itemnumber} } @checkouts ],
617
            overdues   => [ map { $_->{issues}{itemnumber} } @overdues ],
621
            overdues   => [ map { $_->{issues}{itemnumber} } @overdues ],
618
            opac_news => [ map { $_->{opac_news}{idnew} } @news ],
622
            opac_news => [ map { $_->{additional_contents}{idnew} } @news ],
623
            additional_contents => [ map { $_->{additional_contents}{idnew} } @news ],
619
        );
624
        );
620
    }
625
    }
621
626
(-)a/Koha/NewsItem.pm (-10 / +8 lines)
Lines 1-4 Link Here
1
package Koha::NewsItem;
1
package Koha::AdditionalContent;
2
2
3
# Copyright ByWater Solutions 2015
3
# Copyright ByWater Solutions 2015
4
#
4
#
Lines 30-38 use base qw(Koha::Object); Link Here
30
30
31
=head1 NAME
31
=head1 NAME
32
32
33
Koha::NewsItem - Koha News Item object class
33
Koha::AdditionalContent - Koha Additional content object class
34
35
Koha::NewsItem represents a single piece of news from the opac_news table
36
34
37
=head1 API
35
=head1 API
38
36
Lines 42-50 Koha::NewsItem represents a single piece of news from the opac_news table Link Here
42
40
43
=head3 author
41
=head3 author
44
42
45
    $newsitem->author;
43
    $additional_content->author;
46
44
47
Return the Koha::Patron object for the patron who authored this news item
45
Return the Koha::Patron object for the patron who authored this additional content
48
46
49
=cut
47
=cut
50
48
Lines 57-65 sub author { Link Here
57
55
58
=head3 is_expired
56
=head3 is_expired
59
57
60
my $is_expired = $news_item->is_expired;
58
my $is_expired = $additional_content->is_expired;
61
59
62
Returns 1 if the news item is expired or 0;
60
Returns 1 if the additional content is expired or 0;
63
61
64
=cut
62
=cut
65
63
Lines 73-79 sub is_expired { Link Here
73
71
74
=head3 library
72
=head3 library
75
73
76
my $library = $news_item->library;
74
my $library = $additional_content->library;
77
75
78
Returns Koha::Library object or undef
76
Returns Koha::Library object or undef
79
77
Lines 93-99 sub library { Link Here
93
=cut
91
=cut
94
92
95
sub _type {
93
sub _type {
96
    return 'OpacNews';
94
    return 'AdditionalContent';
97
}
95
}
98
96
99
=head1 AUTHOR
97
=head1 AUTHOR
(-)a/Koha/AdditionalContents.pm (+133 lines)
Line 0 Link Here
1
package Koha::AdditionalContents;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Koha::Database;
23
use Koha::Exceptions;
24
use Koha::AdditionalContent;
25
26
use base qw(Koha::Objects);
27
28
=head1 NAME
29
30
Koha::AdditionalContents - Koha Additional content object set class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 search_for_display
39
40
my $contents = Koha::AdditionalContents->search_for_display({
41
    category => 'news', # news or html_customizations
42
    location => 'slip',
43
    lang => 'es-ES',
44
    library_id => $branchcode
45
})
46
47
Return Koha::AdditionalContents set for display to user
48
49
You can limit the results by location, language and library by optional params
50
51
library_id should be valid branchcode of defined library
52
53
location is one of this:
54
- slip - for ISSUESLIP notice
55
- staff_only - for intranet
56
- opac_only - for OPAC
57
- staff_and_opac - for intranet and online catalogue
58
- OpacNavRight - Right column in the online catalogue
59
- opacheader
60
- OpacCustomSearch
61
- OpacMainUserBlock
62
- opaccredits
63
- OpacLoginInstructions
64
- OpacSuggestionInstructions
65
66
=cut
67
68
sub search_for_display {
69
    my ( $self, $params ) = @_;
70
71
    my $search_params;
72
    $search_params->{location} = $params->{location};
73
    $search_params->{branchcode} = [ $params->{library_id}, undef ] if $params->{library_id};
74
    $search_params->{published_on} = { '<=' => \'NOW()' };
75
    $search_params->{-or} = [ expirationdate => { '>=' => \'NOW()' },
76
                              expirationdate => undef ];
77
78
    if ( $params->{lang} ) {
79
        # FIXME I am failing to translate the following query
80
        # SELECT   a1.category,   a1.code,   COALESCE(a2.title, a1.title)
81
        # FROM additional_contents a1
82
        # LEFT JOIN additional_contents a2 on a1.code=a2.code AND a2.lang="es-ES"
83
        # WHERE a1.lang = 'default';
84
85
        # So we are retrieving the code with a translated content, then the other ones
86
        my $translated_contents =
87
          $self->SUPER::search( { %$search_params, lang => $params->{lang} } );
88
        my $default_contents = $self->SUPER::search(
89
            {
90
                %$search_params,
91
                lang => 'default',
92
                code =>
93
                  { '-not_in' => [ $translated_contents->get_column('code') ] }
94
            }
95
        );
96
97
        return $self->SUPER::search(
98
            {
99
                idnew => [
100
                    $translated_contents->get_column('idnew'),
101
                    $default_contents->get_column('idnew')
102
                ]
103
            },
104
            { order_by => 'number' }
105
        );
106
    }
107
108
    return $self->SUPER::search({%$search_params, lang => 'default'}, { order_by => 'number'});
109
}
110
111
=head3 _type
112
113
=cut
114
115
sub _type {
116
    return 'AdditionalContent';
117
}
118
119
=head3 object_class
120
121
=cut
122
123
sub object_class {
124
    return 'Koha::AdditionalContent';
125
}
126
127
=head1 AUTHOR
128
129
Kyle M Hall <kyle@bywatersolutions.com>
130
131
=cut
132
133
1;
(-)a/Koha/Manual.pm (-1 / +1 lines)
Lines 215-221 our $mapping = { Link Here
215
    'tools/holidays'                           => '/tools.html#calendar',
215
    'tools/holidays'                           => '/tools.html#calendar',
216
    'tools/import_borrowers'                   => '/tools.html#patron-import',
216
    'tools/import_borrowers'                   => '/tools.html#patron-import',
217
    'tools/inventory'                          => '/tools.html#inventory-stocktaking',
217
    'tools/inventory'                          => '/tools.html#inventory-stocktaking',
218
    'tools/koha-news'                          => '/tools.html#news',
218
    'tools/additional-contents'                => '/tools.html#news', # FIXME Needs a change to the manual
219
    'tools/letter'                             => '/tools.html#notices-slips',
219
    'tools/letter'                             => '/tools.html#notices-slips',
220
    'tools/manage-marc-import'                 => '/tools.html#staged-marc-record-management',
220
    'tools/manage-marc-import'                 => '/tools.html#staged-marc-record-management',
221
    'tools/marc_modification_templates'        => '/tools.html#marc-modification-templates',
221
    'tools/marc_modification_templates'        => '/tools.html#marc-modification-templates',
(-)a/Koha/News.pm (-115 lines)
Lines 1-115 Link Here
1
package Koha::News;
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
use Koha::Exceptions;
26
use Koha::NewsItem;
27
28
use base qw(Koha::Objects);
29
30
=head1 NAME
31
32
Koha::News - Koha News object set class
33
34
=head1 API
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 search_for_display
41
42
my $news = Koha::News->search_for_display({
43
    location => 'slip',
44
    lang => 'en',
45
    library_id => $branchcode
46
})
47
48
Return Koha::News set for display to user
49
50
You can limit the results by location, language and library by optional params
51
52
library_id should be valid branchcode of defined library
53
54
type is one of this:
55
- slip - for ISSUESLIP notice
56
- koha - for intranet
57
- opac - for online catalogue
58
- OpacNavRight - Right column in the online catalogue
59
- OpacLoginInstructions
60
- OpacMainUserBlock
61
- OpacCustomSearch
62
- opacheader
63
- opaccredits
64
65
lang is language code - it is used only when type is opac or any of OPAC locations
66
67
=cut
68
69
sub search_for_display {
70
    my ( $self, $params ) = @_;
71
72
    my $search_params;
73
    if ($params->{location} ) {
74
        if ( $params->{location} eq 'slip' || $params->{location} eq 'koha') {
75
            $search_params->{lang} = [ $params->{location}, '' ];
76
        } elsif ( $params->{location} eq 'opac' && $params->{lang} ) {
77
            $search_params->{lang} = [ $params->{lang}, '' ];
78
        } elsif ( $params->{lang} ) {
79
            $search_params->{lang} = $params->{location} . '_' . $params->{lang};
80
        } else {
81
            Koha::Exceptions::BadParameter->throw("The location ($params->{location}) and lang ($params->{lang}) parameters combination is not valid");
82
        }
83
    }
84
85
    $search_params->{branchcode} = [ $params->{library_id}, undef ] if $params->{library_id};
86
    $search_params->{published_on} = { '<=' => \'NOW()' };
87
    $search_params->{-or} = [ expirationdate => { '>=' => \'NOW()' },
88
                              expirationdate => undef ];
89
90
    return $self->SUPER::search($search_params, { order_by => 'number' });
91
}
92
93
=head3 _type
94
95
=cut
96
97
sub _type {
98
    return 'OpacNews';
99
}
100
101
=head3 object_class
102
103
=cut
104
105
sub object_class {
106
    return 'Koha::NewsItem';
107
}
108
109
=head1 AUTHOR
110
111
Kyle M Hall <kyle@bywatersolutions.com>
112
113
=cut
114
115
1;
(-)a/Koha/Template/Plugin/KohaNews.pm (-20 / +21 lines)
Lines 1-4 Link Here
1
package Koha::Template::Plugin::KohaNews;
1
package Koha::Template::Plugin::AdditionalContents;
2
2
3
# Copyright ByWater Solutions 2012
3
# Copyright ByWater Solutions 2012
4
# Copyright BibLibre 2014
4
# Copyright BibLibre 2014
Lines 26-56 use base qw( Template::Plugin ); Link Here
26
26
27
use C4::Koha;
27
use C4::Koha;
28
use C4::Context;
28
use C4::Context;
29
use Koha::News;
29
use Koha::AdditionalContents;
30
30
31
sub get {
31
sub get {
32
    my ( $self, $params ) = @_;
32
    my ( $self, $params ) = @_;
33
33
34
    my $display_location = $params->{location};
34
    my $category   = $params->{category};
35
    my $location   = $params->{location};
35
    my $blocktitle = $params->{blocktitle};
36
    my $blocktitle = $params->{blocktitle};
36
    my $lang = $params->{lang} || 'en';
37
    my $lang       = $params->{lang} || 'default';
37
    my $library = $params->{library};
38
    my $library    = $params->{library};
38
39
39
    my $content = Koha::News->search_for_display({
40
    my $content = Koha::AdditionalContents->search_for_display(
40
            location => $display_location,
41
        {
41
            lang => $lang,
42
            category   => $category,
43
            location   => $location,
44
            lang       => $lang,
42
            library_id => $library,
45
            library_id => $library,
43
    });
46
        }
44
47
    );
45
48
46
    if( $content->count ){
49
    if ( $content->count ) {
47
        return {
50
        return {
48
            content => $content,
51
            content    => $content,
49
            location => $display_location,
52
            location   => $location,
50
            blocktitle => $blocktitle
53
            blocktitle => $blocktitle
51
        };
54
        };
52
    } else {
53
        return;
54
    }
55
    }
55
}
56
}
56
57
Lines 58-77 sub get { Link Here
58
59
59
=head1 NAME
60
=head1 NAME
60
61
61
Koha::Template::Plugin::KohaNews - TT Plugin for displaying Koha news
62
Koha::Template::Plugin::AdditionalContents - TT Plugin for displaying additional contents
62
63
63
=head1 SYNOPSIS
64
=head1 SYNOPSIS
64
65
65
[% USE KohaNews %]
66
[% USE AdditionalContents %]
66
67
67
[% KohaNews.get() %]
68
[% AdditionalContents.get() %]
68
69
69
=head1 ROUTINES
70
=head1 ROUTINES
70
71
71
=head2 get
72
=head2 get
72
73
73
In a template, you can get the all categories with
74
In a template, you can get the all categories with
74
the following TT code: [% KohaNews.get() %]
75
the following TT code: [% AdditionalContents.get() %]
75
76
76
=head1 AUTHOR
77
=head1 AUTHOR
77
78
(-)a/installer/data/mysql/atomicupdate/bug_24387.perl (+139 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
4
    if( TableExists('opac_news') ) {
5
        $dbh->do(q|
6
            ALTER TABLE opac_news RENAME additional_contents
7
        |);
8
    }
9
10
    if ( foreign_key_exists('additional_contents', 'opac_news_branchcode_ibfk') ) {
11
12
        $dbh->do(q|
13
            ALTER TABLE additional_contents
14
            DROP KEY borrowernumber_fk,
15
            DROP KEY opac_news_branchcode_ibfk,
16
            DROP FOREIGN KEY borrowernumber_fk,
17
            DROP FOREIGN KEY opac_news_branchcode_ibfk
18
        |);
19
20
        $dbh->do(q|
21
            ALTER TABLE additional_contents
22
            ADD CONSTRAINT  additional_contents_borrowernumber_fk
23
                FOREIGN KEY (borrowernumber)
24
                REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE
25
        |);
26
27
        $dbh->do(q|
28
            ALTER TABLE additional_contents
29
            ADD CONSTRAINT  additional_contents_branchcode_ibfk
30
                FOREIGN KEY (branchcode)
31
                REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
32
        |);
33
    }
34
35
    $dbh->do(q|
36
        UPDATE letter
37
        SET content = REGEXP_REPLACE(content, '<<\\\\s*opac_news\.', '<<additional_contents.')
38
    |);
39
    $dbh->do(q|
40
        UPDATE letter
41
        SET content = REGEXP_REPLACE(content, '\\\\[%\\\\s*opac_news\.', '[% additional_contents.')
42
    |);
43
44
    $dbh->do(q|
45
        UPDATE systempreferences
46
        SET variable="AdditionalContentsEditor"
47
        WHERE variable="NewsToolEditor"
48
    |);
49
50
    $dbh->do(q|
51
        UPDATE permissions
52
        SET code="edit_additional_contents"
53
        WHERE code="edit_news"
54
    |);
55
56
    unless ( column_exists('additional_contents', 'category' ) ) {
57
        $dbh->do(q|
58
            ALTER TABLE additional_contents
59
            ADD COLUMN `category` VARCHAR(20) NOT NULL COMMENT 'category for the additional content'
60
            AFTER `idnew`
61
        |);
62
    }
63
    unless ( column_exists('additional_contents', 'location' ) ) {
64
        $dbh->do(q|
65
            ALTER TABLE additional_contents
66
            ADD COLUMN `location` VARCHAR(255) NOT NULL COMMENT 'location of the additional content'
67
            AFTER `category`
68
        |);
69
    }
70
71
    unless ( column_exists('additional_contents', 'code' ) ) {
72
        $dbh->do(q|
73
            ALTER TABLE additional_contents
74
            ADD COLUMN `code` VARCHAR(100) NOT NULL COMMENT 'code to group content per lang'
75
            AFTER `category`
76
        |);
77
    }
78
79
    my $contents = $dbh->selectall_arrayref(q|SELECT * FROM additional_contents|, { Slice => {} });
80
    for my $c ( @$contents ) {
81
        my ( $category, $location, $new_lang );
82
        if ( $c->{lang} eq '' ) {
83
            $category = 'news';
84
            $location = 'staff_and_opac';
85
            $new_lang = 'default';
86
        } elsif ( $c->{lang} eq 'koha' ) {
87
            $category = 'news';
88
            $location = 'staff_only';
89
            $new_lang = 'default';
90
        } elsif ( $c->{lang} eq 'slip' ) {
91
            $category = 'news';
92
            $location = 'slip';
93
            $new_lang = 'default';
94
        } elsif ( $c->{lang} =~ m|_| ) {
95
            ( $location, $new_lang ) = split '_', $c->{lang};
96
            $category = 'html_customizations'
97
        } else {
98
            $category = 'news';
99
            $location = 'opac_only';
100
            $new_lang = $c->{lang};
101
        }
102
103
        die "There is something wrong here, we didn't find a valid category for idnew=" . $c->{idnew} unless $category;
104
105
        # Now this is getting weird
106
        # We are adding an extra news with the same code when the lang is not "default" (/"en")
107
108
        $new_lang = "default" if $new_lang eq 'en'; # Assume that "en" is "default"
109
110
        my $sth_update = $dbh->prepare(q|
111
            UPDATE additional_contents
112
            SET category=?, location=?, lang=?
113
            WHERE idnew=?
114
        |);
115
116
        my $parent_idnew;
117
        if ( $new_lang ne 'default' ) {
118
            $dbh->do(q|
119
                INSERT INTO additional_contents(category, code, location, branchcode, title, content, lang, published_on, updated_on, expirationdate, number, borrowernumber)
120
                VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
121
            |, undef, $category, 'tmp_code', $location, $c->{branchcode}, $c->{title}, $c->{content}, 'default', $c->{published_on}, $c->{updated_on}, $c->{expirationdate}, $c->{number}, $c->{borrowernumber});
122
123
            $parent_idnew = $dbh->last_insert_id(undef, undef, 'additional_contents', undef);
124
        }
125
        $sth_update->execute($category, $location, $new_lang, $c->{idnew});
126
127
        my $idnew = $parent_idnew || $c->{idnew};
128
        my $code = ( grep {$_ eq $location} qw( staff_and_opac staff_only opac_only slip ) ) ? "${location}_$idnew" : "News_$idnew";
129
        $dbh->do(q|UPDATE additional_contents SET code=? WHERE idnew = ?|, undef, $code, $idnew) if $parent_idnew;
130
        $dbh->do(q|UPDATE additional_contents SET code=? WHERE idnew = ?|, undef, $code, $idnew);
131
    }
132
133
    $dbh->do(q|
134
        ALTER TABLE additional_contents
135
        ADD UNIQUE KEY additional_contents_uniq (`category`,`code`,`branchcode`,`lang`)
136
    |);
137
138
    NewVersion( $DBversion, 24387, "Rename opac_news with additional_contents");
139
}
(-)a/installer/data/mysql/en/mandatory/sample_notices.yml (-3 / +3 lines)
Lines 524-532 tables: Link Here
524
            - "<h4 style=\"text-align: center; font-style:italic;\">News</h4>"
524
            - "<h4 style=\"text-align: center; font-style:italic;\">News</h4>"
525
            - "<news>"
525
            - "<news>"
526
            - "<div class=\"newsitem\">"
526
            - "<div class=\"newsitem\">"
527
            - "<h5 style=\"margin-bottom: 1px; margin-top: 1px\"><b><<opac_news.title>></b></h5>"
527
            - "<h5 style=\"margin-bottom: 1px; margin-top: 1px\"><b><<additional_contents.title>></b></h5>"
528
            - "<p style=\"margin-bottom: 1px; margin-top: 1px\"><<opac_news.content>></p>"
528
            - "<p style=\"margin-bottom: 1px; margin-top: 1px\"><<additional_contents.content>></p>"
529
            - "<p class=\"newsfooter\" style=\"font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px\">Posted on <<opac_news.published_on>></p>"
529
            - "<p class=\"newsfooter\" style=\"font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px\">Posted on <<additional_contents.published_on>></p>"
530
            - "<hr />"
530
            - "<hr />"
531
            - "</div>"
531
            - "</div>"
532
            - "</news>"
532
            - "</news>"
(-)a/installer/data/mysql/en/optional/sample_news.yml (-1 / +1 lines)
Lines 21-27 description: Link Here
21
  - "Sample news items"
21
  - "Sample news items"
22
22
23
tables:
23
tables:
24
  - opac_news:
24
  - additional_contents:
25
      translatable: [ title, content ]
25
      translatable: [ title, content ]
26
      multiline: [ content ]
26
      multiline: [ content ]
27
      rows:
27
      rows:
(-)a/installer/data/mysql/fr-CA/facultatif/sample_news.sql (-1 / +1 lines)
Line 1 Link Here
1
INSERT INTO `opac_news` (`title`, `content`, `lang`, `published_on`, `expirationdate`, `number`) VALUES ('Bienvenue dans Koha !','Bienvenue dans Koha, la toute nouvelle version du système intégré de gestion de bibliothèque (SIGB) open source de référence. Développé initialement en Nouvelle Zélande et déployé pour la première fois en janvier 2000, Koha est un projet international soutenu par des sociétés de services en logiciels libres et par des bibliothécaires du monde entier.','koha','2008-01-14 03:25:58','2099-01-10',1),('Et maintenant ?','Félicitations ! vous avez désormais une version opérationnelle de Koha. Et maintenant, que faire ?\r\n<ul>\r\n<li><a href=\"http://koha-community.org/documentation/\">lisez la documentation de Koha ;</a></li>\r\n<li><a href=\"http://wiki.koha-community.org\">lisez et participez au Wiki de Koha ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">abonnez-vous aux listes de discussion ;</a></li>\r\n<li><a href=\"http://bugs.koha-community.org\">signalez des bugs ;</a></li>\r\n<li><a href=\"https://wiki.koha-community.org/wiki/Version_Control_Using_Git\">proposez des correctifs et des  améliorations ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">discutez avec les utilisateurs et les développeurs de Koha.</a></li>\r\n</ul>\r\n','koha','2008-01-14 03:34:45','2099-01-10',2);
1
INSERT INTO `additional_contents` (`title`, `content`, `lang`, `published_on`, `expirationdate`, `number`) VALUES ('Bienvenue dans Koha !','Bienvenue dans Koha, la toute nouvelle version du système intégré de gestion de bibliothèque (SIGB) open source de référence. Développé initialement en Nouvelle Zélande et déployé pour la première fois en janvier 2000, Koha est un projet international soutenu par des sociétés de services en logiciels libres et par des bibliothécaires du monde entier.','koha','2008-01-14 03:25:58','2099-01-10',1),('Et maintenant ?','Félicitations ! vous avez désormais une version opérationnelle de Koha. Et maintenant, que faire ?\r\n<ul>\r\n<li><a href=\"http://koha-community.org/documentation/\">lisez la documentation de Koha ;</a></li>\r\n<li><a href=\"http://wiki.koha-community.org\">lisez et participez au Wiki de Koha ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">abonnez-vous aux listes de discussion ;</a></li>\r\n<li><a href=\"http://bugs.koha-community.org\">signalez des bugs ;</a></li>\r\n<li><a href=\"https://wiki.koha-community.org/wiki/Version_Control_Using_Git\">proposez des correctifs et des  améliorations ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">discutez avec les utilisateurs et les développeurs de Koha.</a></li>\r\n</ul>\r\n','koha','2008-01-14 03:34:45','2099-01-10',2);
(-)a/installer/data/mysql/fr-CA/obligatoire/sample_notices.sql (-1 / +1 lines)
Lines 4-10 INSERT INTO `letter` (module, code, branchcode, name, is_html, title, content, m Link Here
4
('circulation','DUE','','Document à rendre aujourd\'hui',0,'Document à rendre aujourd\'hui','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nLe prêt de ce document arrive à expiration aujourd\'hui.\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)\r\n\r\nMerci de nous le retourner.\r\n\r\n<<branches.branchname>>','email'),
4
('circulation','DUE','','Document à rendre aujourd\'hui',0,'Document à rendre aujourd\'hui','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nLe prêt de ce document arrive à expiration aujourd\'hui.\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)\r\n\r\nMerci de nous le retourner.\r\n\r\n<<branches.branchname>>','email'),
5
('circulation','DUEDGST','','Document à rendre aujourd\'hui (Résumé)',0,'Document à rendre aujourd\'hui','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nVous avez <<count>> document(s) dont le prêt arrive à expiration.\r\n\r\nMerci de nous le(s) retourner rapidement.\r\n\r\n<<branches.branchname>>','email'),
5
('circulation','DUEDGST','','Document à rendre aujourd\'hui (Résumé)',0,'Document à rendre aujourd\'hui','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nVous avez <<count>> document(s) dont le prêt arrive à expiration.\r\n\r\nMerci de nous le(s) retourner rapidement.\r\n\r\n<<branches.branchname>>','email'),
6
('circulation','ISSUEQSLIP','','Ticket rapide de prêts',1,'Ticket rapide de prêts','<h3><<branches.branchname>></h3>\r\nEmprunté par <<borrowers.firstname>> <<borrowers.surname>> <br />\r\n(<<borrowers.cardnumber>>) <br />\r\n\r\n<<today>><br />\r\n\r\n<h4>Emprunté(s) aujourd\'hui</h4>\r\n<checkedout>\r\n<p>\r\n<<biblio.title>><br />\r\nCode-barres : <<items.barcode>><br />\r\nDate de retour : <<issues.date_due>><br />\r\n</p>\r\n</checkedout>','email'),
6
('circulation','ISSUEQSLIP','','Ticket rapide de prêts',1,'Ticket rapide de prêts','<h3><<branches.branchname>></h3>\r\nEmprunté par <<borrowers.firstname>> <<borrowers.surname>> <br />\r\n(<<borrowers.cardnumber>>) <br />\r\n\r\n<<today>><br />\r\n\r\n<h4>Emprunté(s) aujourd\'hui</h4>\r\n<checkedout>\r\n<p>\r\n<<biblio.title>><br />\r\nCode-barres : <<items.barcode>><br />\r\nDate de retour : <<issues.date_due>><br />\r\n</p>\r\n</checkedout>','email'),
7
('circulation','ISSUESLIP','','Ticket de prêts',1,'Ticket de prêts','<h3><<branches.branchname>></h3>\r\nEmprunté par <<borrowers.firstname>> <<borrowers.surname>> <br />\r\n(<<borrowers.cardnumber>>) <br />\r\n\r\n<<today>><br />\r\n\r\n<h4>Emprunté(s) aujourd\'hui</h4>\r\n<checkedout>\r\n<p>\r\n<<biblio.title>> <br />\r\nCode-barres : <<items.barcode>><br />\r\nDate de retour : <<issues.date_due>><br />\r\n</p>\r\n</checkedout>\r\n\r\n<h4>Retards</h4>\r\n<overdue>\r\n<p>\r\n<<biblio.title>> <br />\r\nCode-barres : <<items.barcode>><br />\r\nDate de retour : <<issues.date_due>><br />\r\n</p>\r\n</overdue>\r\n\r\n<hr>\r\n\r\n<h4 style=\"text-align: center; font-style:italic;\">Nouvelles</h4>\r\n<news>\r\n<div class=\"newsitem\">\r\n<h5 style=\"margin-bottom: 1px; margin-top: 1px\"><b><<opac_news.title>></b></h5>\r\n<p style=\"margin-bottom: 1px; margin-top: 1px\"><<opac_news.content>></p>\r\n<p class=\"newsfooter\" style=\"font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px\">Publiée le <<opac_news.published_on>></p>\r\n<hr />\r\n</div>\r\n</news>','email'),
7
('circulation','ISSUESLIP','','Ticket de prêts',1,'Ticket de prêts','<h3><<branches.branchname>></h3>\r\nEmprunté par <<borrowers.firstname>> <<borrowers.surname>> <br />\r\n(<<borrowers.cardnumber>>) <br />\r\n\r\n<<today>><br />\r\n\r\n<h4>Emprunté(s) aujourd\'hui</h4>\r\n<checkedout>\r\n<p>\r\n<<biblio.title>> <br />\r\nCode-barres : <<items.barcode>><br />\r\nDate de retour : <<issues.date_due>><br />\r\n</p>\r\n</checkedout>\r\n\r\n<h4>Retards</h4>\r\n<overdue>\r\n<p>\r\n<<biblio.title>> <br />\r\nCode-barres : <<items.barcode>><br />\r\nDate de retour : <<issues.date_due>><br />\r\n</p>\r\n</overdue>\r\n\r\n<hr>\r\n\r\n<h4 style=\"text-align: center; font-style:italic;\">Nouvelles</h4>\r\n<news>\r\n<div class=\"newsitem\">\r\n<h5 style=\"margin-bottom: 1px; margin-top: 1px\"><b><<additional_contents.title>></b></h5>\r\n<p style=\"margin-bottom: 1px; margin-top: 1px\"><<additional_contents.content>></p>\r\n<p class=\"newsfooter\" style=\"font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px\">Publiée le <<additional_contents.published_on>></p>\r\n<hr />\r\n</div>\r\n</news>','email'),
8
('circulation','ODUE','','Document(s) en retard',0,'Document(s) en retard','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nSelon nos informations, vous avez au moins un document en retard. Merci de retourner ou renouveller ce ou ces documents dans votre bibliothèque le plus rapidement possible.\r\n\r\n<<branches.branchname>>\r\n<<branches.branchaddress1>>\r\n<<branches.branchaddress2>> <<branches.branchaddress3>>\r\nTél : <<branches.branchphone>>\r\nFax : <<branches.branchfax>>\r\nCourriel : <<branches.branchemail>>\r\n\r\nSi vous avez le mot de passe de votre compte lecteur, vous pouvez renouveler directement en ligne. Sinon, merci de nous contacter.\r\n\r\nLe ou les documents suivants sont en retard :\r\n\r\n<item>\"<<biblio.title>>\" par <<biblio.author>>, <<items.itemcallnumber>>, code-barres : <<items.barcode>> Amende : <<items.fine>></item>\r\n\r\nMerci de votre attention.\r\n\r\n<<branches.branchname>>','email'),
8
('circulation','ODUE','','Document(s) en retard',0,'Document(s) en retard','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nSelon nos informations, vous avez au moins un document en retard. Merci de retourner ou renouveller ce ou ces documents dans votre bibliothèque le plus rapidement possible.\r\n\r\n<<branches.branchname>>\r\n<<branches.branchaddress1>>\r\n<<branches.branchaddress2>> <<branches.branchaddress3>>\r\nTél : <<branches.branchphone>>\r\nFax : <<branches.branchfax>>\r\nCourriel : <<branches.branchemail>>\r\n\r\nSi vous avez le mot de passe de votre compte lecteur, vous pouvez renouveler directement en ligne. Sinon, merci de nous contacter.\r\n\r\nLe ou les documents suivants sont en retard :\r\n\r\n<item>\"<<biblio.title>>\" par <<biblio.author>>, <<items.itemcallnumber>>, code-barres : <<items.barcode>> Amende : <<items.fine>></item>\r\n\r\nMerci de votre attention.\r\n\r\n<<branches.branchname>>','email'),
9
('circulation','PREDUE','','Document à rendre bientôt',0,'Document à rendre bientôt','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nNous souhaitons vous informer que le prêt de ce document arrive bientôt à expiration :\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)\r\n\r\nMerci.\r\n\r\n<<branches.branchname>>','email'),
9
('circulation','PREDUE','','Document à rendre bientôt',0,'Document à rendre bientôt','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nNous souhaitons vous informer que le prêt de ce document arrive bientôt à expiration :\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)\r\n\r\nMerci.\r\n\r\n<<branches.branchname>>','email'),
10
('circulation','PREDUEDGST','','Document à rendre bientôt (Résumé)',0,'Document(s) à rendre bientôt','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nVous avez <<count>> document(s) dont le prêt arrive bientôt à expiration.\r\n\r\n<<branches.branchname>>','email'),
10
('circulation','PREDUEDGST','','Document à rendre bientôt (Résumé)',0,'Document(s) à rendre bientôt','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nVous avez <<count>> document(s) dont le prêt arrive bientôt à expiration.\r\n\r\n<<branches.branchname>>','email'),
(-)a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql (-3 / +3 lines)
Lines 98-106 Retour le : <<issues.date_due>><br /> Link Here
98
<h4 style="text-align: center; font-style:italic;">Nouvelles</h4>
98
<h4 style="text-align: center; font-style:italic;">Nouvelles</h4>
99
<news>
99
<news>
100
<div class="newsitem">
100
<div class="newsitem">
101
<h5 style="margin-bottom: 1px; margin-top: 1px"><b><<opac_news.title>></b></h5>
101
<h5 style="margin-bottom: 1px; margin-top: 1px"><b><<additional_contents.title>></b></h5>
102
<p style="margin-bottom: 1px; margin-top: 1px"><<opac_news.content>></p>
102
<p style="margin-bottom: 1px; margin-top: 1px"><<additional_contents.content>></p>
103
<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on <<opac_news.published_on>></p>
103
<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on <<additional_contents.published_on>></p>
104
<hr />
104
<hr />
105
</div>
105
</div>
106
</news>', 1),
106
</news>', 1),
(-)a/installer/data/mysql/fr-FR/2-Optionel/sample_news.sql (-1 / +1 lines)
Line 1 Link Here
1
INSERT INTO `opac_news` (`title`, `content`, `lang`, `published_on`, `expirationdate`, `number`) VALUES ('Bienvenue dans Koha !','Bienvenue dans Koha, la toute nouvelle version du système intégré de gestion de bibliothèque (SIGB) open source de référence. Développé initialement en Nouvelle Zélande et déployé pour la première fois en janvier 2000, Koha est un projet international soutenu par des sociétés de services en logiciels libres et par des bibliothécaires du monde entier.','koha','2008-01-14 03:25:58','2099-01-10',1),('Et maintenant ?','Félicitations ! vous avez désormais une version opérationnelle de Koha. Et maintenant, que faire ?\r\n<ul>\r\n<li><a href=\"http://koha-community.org/documentation/\">lisez la documentation de Koha ;</a></li>\r\n<li><a href=\"http://wiki.koha-community.org\">lisez et participez au Wiki de Koha ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">abonnez-vous aux listes de discussion ;</a></li>\r\n<li><a href=\"http://bugs.koha-community.org\">signalez des bugs ;</a></li>\r\n<li><a href=\"https://wiki.koha-community.org/wiki/Version_Control_Using_Git\">proposez des correctifs et des  améliorations ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">discutez avec les utilisateurs et les développeurs de Koha.</a></li>\r\n</ul>\r\n','koha','2008-01-14 03:34:45','2099-01-10',2);
1
INSERT INTO `additional_contents` (`title`, `content`, `lang`, `published_on`, `expirationdate`, `number`) VALUES ('Bienvenue dans Koha !','Bienvenue dans Koha, la toute nouvelle version du système intégré de gestion de bibliothèque (SIGB) open source de référence. Développé initialement en Nouvelle Zélande et déployé pour la première fois en janvier 2000, Koha est un projet international soutenu par des sociétés de services en logiciels libres et par des bibliothécaires du monde entier.','koha','2008-01-14 03:25:58','2099-01-10',1),('Et maintenant ?','Félicitations ! vous avez désormais une version opérationnelle de Koha. Et maintenant, que faire ?\r\n<ul>\r\n<li><a href=\"http://koha-community.org/documentation/\">lisez la documentation de Koha ;</a></li>\r\n<li><a href=\"http://wiki.koha-community.org\">lisez et participez au Wiki de Koha ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">abonnez-vous aux listes de discussion ;</a></li>\r\n<li><a href=\"http://bugs.koha-community.org\">signalez des bugs ;</a></li>\r\n<li><a href=\"https://wiki.koha-community.org/wiki/Version_Control_Using_Git\">proposez des correctifs et des  améliorations ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">discutez avec les utilisateurs et les développeurs de Koha.</a></li>\r\n</ul>\r\n','koha','2008-01-14 03:34:45','2099-01-10',2);
(-)a/installer/data/mysql/kohastructure.sql (-14 / +18 lines)
Lines 3898-3925 CREATE TABLE `old_reserves` ( Link Here
3898
/*!40101 SET character_set_client = @saved_cs_client */;
3898
/*!40101 SET character_set_client = @saved_cs_client */;
3899
3899
3900
--
3900
--
3901
-- Table structure for table `opac_news`
3901
-- Table structure for table `additional_contents`
3902
--
3902
--
3903
3903
3904
DROP TABLE IF EXISTS `opac_news`;
3904
DROP TABLE IF EXISTS `additional_contents`;
3905
/*!40101 SET @saved_cs_client     = @@character_set_client */;
3905
/*!40101 SET @saved_cs_client     = @@character_set_client */;
3906
/*!40101 SET character_set_client = utf8 */;
3906
/*!40101 SET character_set_client = utf8 */;
3907
CREATE TABLE `opac_news` (
3907
CREATE TABLE `additional_contents` (
3908
  `idnew` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for the news article',
3908
  `idnew` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for the additional content',
3909
  `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'branch code users to create branch specific news, NULL is every branch.',
3909
  `category` varchar(20) NOT NULL COMMENT 'category for the additional content',
3910
  `title` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'title of the news article',
3910
  `code` varchar(20) NOT NULL COMMENT 'code to group content per lang',
3911
  `content` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the body of your news article',
3911
  `location` varchar(255) NOT NULL COMMENT 'location of the additional content',
3912
  `lang` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'location for the article (koha is the staff interface, slip is the circulation receipt and language codes are for the opac)',
3912
  `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'branch code users to create branch specific additional content, NULL is every branch.',
3913
  `title` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'title of the additional content',
3914
  `content` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the body of your additional content',
3915
  `lang` varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'location for the additional content(koha is the staff interface, slip is the circulation receipt and language codes are for the opac)',
3913
  `published_on` date DEFAULT NULL COMMENT 'publication date',
3916
  `published_on` date DEFAULT NULL COMMENT 'publication date',
3914
  `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification',
3917
  `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification',
3915
  `expirationdate` date DEFAULT NULL COMMENT 'date the article is set to expire or no longer be visible',
3918
  `expirationdate` date DEFAULT NULL COMMENT 'date the additional content is set to expire or no longer be visible',
3916
  `number` int(11) DEFAULT NULL COMMENT 'the order in which this article appears in that specific location',
3919
  `number` int(11) DEFAULT NULL COMMENT 'the order in which this additional content appears in that specific location',
3917
  `borrowernumber` int(11) DEFAULT NULL COMMENT 'The user who created the news article',
3920
  `borrowernumber` int(11) DEFAULT NULL COMMENT 'The user who created the additional content',
3918
  PRIMARY KEY (`idnew`),
3921
  PRIMARY KEY (`idnew`),
3919
  KEY `borrowernumber_fk` (`borrowernumber`),
3922
  UNIQUE KEY `additional_contents_uniq` (`category`,`code`,`branchcode`,`lang`),
3920
  KEY `opac_news_branchcode_ibfk` (`branchcode`),
3923
  KEY `additional_contents_borrowernumber_fk` (`borrowernumber`),
3924
  KEY `additional_contents_branchcode_ibfk` (`branchcode`),
3921
  CONSTRAINT `borrowernumber_fk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
3925
  CONSTRAINT `borrowernumber_fk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
3922
  CONSTRAINT `opac_news_branchcode_ibfk` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
3926
  CONSTRAINT `additional_contents_branchcode_ibfk` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
3923
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3927
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3924
/*!40101 SET character_set_client = @saved_cs_client */;
3928
/*!40101 SET character_set_client = @saved_cs_client */;
3925
3929
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 / +1 lines)
Lines 9-14 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
9
('AcquisitionLog','0',NULL,'If ON, log acquisitions activity','YesNo'),
9
('AcquisitionLog','0',NULL,'If ON, log acquisitions activity','YesNo'),
10
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: their own only, any within their branch, or all','Choice'),
10
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: their own only, any within their branch, or all','Choice'),
11
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
11
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
12
('AdditionalContentsEditor','tinymce','tinymce|codemirror','Choose tool for editing News.', 'Choice'),
12
('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'),
13
('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'),
13
('AddressForFailedOverdueNotices', '', NULL, 'Destination email for failed overdue notices. If left empty then it will fallback to the first defined address in the following list: Library ReplyTo, Library Email, ReplytoDefault and KohaAdminEmailAddress', 'free'),
14
('AddressForFailedOverdueNotices', '', NULL, 'Destination email for failed overdue notices. If left empty then it will fallback to the first defined address in the following list: Library ReplyTo, Library Email, ReplytoDefault and KohaAdminEmailAddress', 'free'),
14
('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'),
15
('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'),
Lines 349-355 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
349
('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''),
350
('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''),
350
('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'),
351
('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'),
351
('NewsLog','0',NULL,'If ON, log OPAC news changes','YesNo'),
352
('NewsLog','0',NULL,'If ON, log OPAC news changes','YesNo'),
352
('NewsToolEditor','tinymce','tinymce|codemirror','Choose tool for editing News.', 'Choice'),
353
('noissuescharge','5','','Define maximum amount withstanding before checkouts are blocked','Integer'),
353
('noissuescharge','5','','Define maximum amount withstanding before checkouts are blocked','Integer'),
354
('NoIssuesChargeGuarantees','','','Define maximum amount withstanding before checkouts are blocked','Integer'),
354
('NoIssuesChargeGuarantees','','','Define maximum amount withstanding before checkouts are blocked','Integer'),
355
('NoIssuesChargeGuarantorsWithGuarantees','','','Define maximum amount withstanding before checkouts are blocked including guarantors and their other guarantees','Integer'),
355
('NoIssuesChargeGuarantorsWithGuarantees','','','Define maximum amount withstanding before checkouts are blocked including guarantors and their other guarantees','Integer'),
(-)a/installer/data/mysql/mandatory/userpermissions.sql (-1 / +1 lines)
Lines 74-80 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
74
   (11, 'merge_invoices', 'Merge invoices'),
74
   (11, 'merge_invoices', 'Merge invoices'),
75
   (11, 'delete_baskets', 'Delete baskets'),
75
   (11, 'delete_baskets', 'Delete baskets'),
76
   (12, 'suggestions_manage', 'Manage purchase suggestions'),
76
   (12, 'suggestions_manage', 'Manage purchase suggestions'),
77
   (13, 'edit_news', 'Write news for the OPAC and staff interfaces'),
77
   (13, 'edit_additional_contents', 'Write additional contents for the OPAC and staff interfaces (news and HTML customizations)'),
78
   (13, 'label_creator', 'Create printable labels and barcodes from catalog and patron data'),
78
   (13, 'label_creator', 'Create printable labels and barcodes from catalog and patron data'),
79
   (13, 'edit_calendar', 'Define days when the library is closed'),
79
   (13, 'edit_calendar', 'Define days when the library is closed'),
80
   (13, 'moderate_comments', 'Moderate patron comments'),
80
   (13, 'moderate_comments', 'Moderate patron comments'),
(-)a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql (-3 / +3 lines)
Lines 118-126 Innleveringsfrist: <<issues.date_due>><br /> Link Here
118
<h4 style="text-align: center; font-style:italic;">Nyheter</h4>
118
<h4 style="text-align: center; font-style:italic;">Nyheter</h4>
119
<news>
119
<news>
120
<div class="newsitem">
120
<div class="newsitem">
121
<h5 style="margin-bottom: 1px; margin-top: 1px"><b><<opac_news.title>></b></h5>
121
<h5 style="margin-bottom: 1px; margin-top: 1px"><b><<additional_contents.title>></b></h5>
122
<p style="margin-bottom: 1px; margin-top: 1px"><<opac_news.content>></p>
122
<p style="margin-bottom: 1px; margin-top: 1px"><<additional_contents.content>></p>
123
<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Publisert <<opac_news.published_on>></p>
123
<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Publisert <<additional_contents.published_on>></p>
124
<hr />
124
<hr />
125
</div>
125
</div>
126
</news>', 1),
126
</news>', 1),
(-)a/installer/data/mysql/nb-NO/2-Valgfritt/sample_news.sql (-1 / +1 lines)
Lines 1-2 Link Here
1
INSERT INTO `opac_news` (`title`, `content`, `lang`, `published_on`, `expirationdate`, `number`) VALUES ('Velkommen til Koha!','Velkommen til Koha. Koha er et biblioteksystem rikt på funksjoner. Koha ble opprinnelig utviklet i New Zealand av Katipo Communications Ltd og først tatt i bruk i januar 2000 av Horowhenua Library Trust. I dag vedlikeholdes Koha av et verdensomspennende fellesskap av bibliotek og leverandører.','koha',DATE_SUB(NOW(), INTERVAL 1 DAY),'2099-01-10',1),
1
INSERT INTO `additional_contents` (`title`, `content`, `lang`, `published_on`, `expirationdate`, `number`) VALUES ('Velkommen til Koha!','Velkommen til Koha. Koha er et biblioteksystem rikt på funksjoner. Koha ble opprinnelig utviklet i New Zealand av Katipo Communications Ltd og først tatt i bruk i januar 2000 av Horowhenua Library Trust. I dag vedlikeholdes Koha av et verdensomspennende fellesskap av bibliotek og leverandører.','koha',DATE_SUB(NOW(), INTERVAL 1 DAY),'2099-01-10',1),
2
('Hva nå?','Hva kan du gjøre nå som du har installert Koha? Her er noen forslag:\r\n<ul>\r\n<li><a href=\"http://koha-community.org/documentation/\">Les dokumentasjon</a></li>\r\n<li><a href=\"http://wiki.koha-community.org\">Les eller bidra til Koha sin wiki</a></li>\r\n<li><a href=\"http://koha-community.org/get-involved/\">Les og delta i diskusjoner</a></li>\r\n<li><a href=\"http://bugs.koha-community.org\">Meld fra om feil og mangler</a></li>\r\n<li><a href=\"http://wiki.koha-community.org/wiki/Version_Control_Using_Git\">Send inn feilrettinger med Git (versjonskontrollsystem)</a></li>\r\n<li><a href=\"http://koha-community.org/get-involved/irc/\">Chat med Koha-brukere og -utviklere</a></li>\r\n</ul>\r\n','koha',DATE_SUB(NOW(), INTERVAL 1 DAY),'2099-01-10',2);
2
('Hva nå?','Hva kan du gjøre nå som du har installert Koha? Her er noen forslag:\r\n<ul>\r\n<li><a href=\"http://koha-community.org/documentation/\">Les dokumentasjon</a></li>\r\n<li><a href=\"http://wiki.koha-community.org\">Les eller bidra til Koha sin wiki</a></li>\r\n<li><a href=\"http://koha-community.org/get-involved/\">Les og delta i diskusjoner</a></li>\r\n<li><a href=\"http://bugs.koha-community.org\">Meld fra om feil og mangler</a></li>\r\n<li><a href=\"http://wiki.koha-community.org/wiki/Version_Control_Using_Git\">Send inn feilrettinger med Git (versjonskontrollsystem)</a></li>\r\n<li><a href=\"http://koha-community.org/get-involved/irc/\">Chat med Koha-brukere og -utviklere</a></li>\r\n</ul>\r\n','koha',DATE_SUB(NOW(), INTERVAL 1 DAY),'2099-01-10',2);
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc (-3 / +3 lines)
Lines 445-453 Link Here
445
            Define days when the library is closed
445
            Define days when the library is closed
446
        </span>
446
        </span>
447
        <span class="permissioncode">([% name | html %])</span>
447
        <span class="permissioncode">([% name | html %])</span>
448
    [%- CASE 'edit_news' -%]
448
    [%- CASE 'edit_additional_contents' -%]
449
        <span class="sub_permission edit_news_subpermission">
449
        <span class="sub_permission edit_additional_contents_subpermission">
450
            Write news for the OPAC and staff interfaces
450
            Write additional contents for the OPAC and staff interfaces (news and HTML customizations)
451
        </span>
451
        </span>
452
        <span class="permissioncode">([% name | html %])</span>
452
        <span class="permissioncode">([% name | html %])</span>
453
    [%- CASE 'edit_notice_status_triggers' -%]
453
    [%- CASE 'edit_notice_status_triggers' -%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc (-3 / +4 lines)
Lines 94-100 Link Here
94
    [% END %]
94
    [% END %]
95
</ul>
95
</ul>
96
[% END %]
96
[% END %]
97
[% IF ( CAN_user_tools_edit_calendar || CAN_user_tools_manage_csv_profiles || CAN_user_tools_view_system_logs || CAN_user_tools_edit_news  || CAN_user_tools_schedule_tasks || CAN_user_tools_edit_quotes || ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool )  || CAN_user_tools_upload_general_files || CAN_user_tools_access_files ) %]
97
[% IF ( CAN_user_tools_edit_calendar || CAN_user_tools_manage_csv_profiles || CAN_user_tools_view_system_logs || CAN_user_tools_edit_additional_contents  || CAN_user_tools_schedule_tasks || CAN_user_tools_edit_quotes || ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool )  || CAN_user_tools_upload_general_files || CAN_user_tools_access_files ) %]
98
<h5>Additional tools</h5>
98
<h5>Additional tools</h5>
99
<ul>
99
<ul>
100
    [% IF ( CAN_user_tools_edit_calendar ) %]
100
    [% IF ( CAN_user_tools_edit_calendar ) %]
Lines 106-113 Link Here
106
    [% IF ( CAN_user_tools_view_system_logs ) %]
106
    [% IF ( CAN_user_tools_view_system_logs ) %]
107
	<li><a href="/cgi-bin/koha/tools/viewlog.pl">Log viewer</a></li>
107
	<li><a href="/cgi-bin/koha/tools/viewlog.pl">Log viewer</a></li>
108
    [% END %]
108
    [% END %]
109
    [% IF ( CAN_user_tools_edit_news ) %]
109
    [% IF ( CAN_user_tools_edit_additional_contents ) %]
110
	<li><a href="/cgi-bin/koha/tools/koha-news.pl">News</a></li>
110
    <li><a href="/cgi-bin/koha/tools/additional-contents.pl?category=news">News</a></li>
111
    <li><a href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations">HTML customizations</a></li>
111
    [% END %]
112
    [% END %]
112
    [% IF ( CAN_user_tools_schedule_tasks ) %]
113
    [% IF ( CAN_user_tools_schedule_tasks ) %]
113
	<li><a href="/cgi-bin/koha/tools/scheduler.pl">Task scheduler</a></li>
114
	<li><a href="/cgi-bin/koha/tools/scheduler.pl">Task scheduler</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref (-2 / +2 lines)
Lines 38-45 Tools: Link Here
38
                  both: "both OPAC and staff interface"
38
                  both: "both OPAC and staff interface"
39
            - "."
39
            - "."
40
        -
40
        -
41
            - By default edit news items with
41
            - By default edit additional contents and news items with
42
            - pref: NewsToolEditor
42
            - pref: AdditionalContentsEditor
43
              choices:
43
              choices:
44
                  tinymce: "a WYSIWYG editor (TinyMCE)"
44
                  tinymce: "a WYSIWYG editor (TinyMCE)"
45
                  codemirror: "a text editor (CodeMirror)"
45
                  codemirror: "a text editor (CodeMirror)"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt (-4 / +4 lines)
Lines 33-46 Link Here
33
                                <div class="newsbody">[% koha_new.content | $raw %]</div>
33
                                <div class="newsbody">[% koha_new.content | $raw %]</div>
34
                                <p class="newsfooter"> Posted on [% koha_new.published_on | $KohaDates %][% IF( show_author && koha_new.author ) %] by <span class="newsauthor">[% INCLUDE 'patron-title.inc' patron=koha_new.author %]<br />[% END %]
34
                                <p class="newsfooter"> Posted on [% koha_new.published_on | $KohaDates %][% IF( show_author && koha_new.author ) %] by <span class="newsauthor">[% INCLUDE 'patron-title.inc' patron=koha_new.author %]<br />[% END %]
35
                                    [% IF ( CAN_user_tools ) %]
35
                                    [% IF ( CAN_user_tools ) %]
36
                                        <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;id=[% koha_new.idnew | uri %]">Edit</a>
36
                                        <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&amp;id=[% koha_new.idnew | uri %]">Edit</a>
37
                                         | <a class="news_delete" href="/cgi-bin/koha/tools/koha-news.pl?op=del&amp;ids=[% koha_new.idnew | html %]">Delete</a>
37
                                         | <a class="news_delete" href="/cgi-bin/koha/tools/additional-contents.pl?op=del&amp;ids=[% koha_new.idnew | html %]">Delete</a>
38
                                         | <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form">New</a>
38
                                         | <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form">New</a>
39
                                    [% END %]
39
                                    [% END %]
40
                                </p>
40
                                </p>
41
                            </div>
41
                            </div>
42
                        [% END %]
42
                        [% END %]
43
                    </div><!-- /koha-news -->
43
                    </div><!-- /additional-contents -->
44
                [% END %]
44
                [% END %]
45
                [% IF ( daily_quote ) %]
45
                [% IF ( daily_quote ) %]
46
                    <div id="area-news">
46
                    <div id="area-news">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt (+602 lines)
Line 0 Link Here
1
[% USE raw %]
2
[% USE Asset %]
3
[% USE Koha %]
4
[% USE KohaDates %]
5
[% USE Branches %]
6
[% SET footerjs = 1 %]
7
[% INCLUDE 'doc-head-open.inc' %]
8
<title>Additional contents &rsaquo; Tools &rsaquo; Koha</title>
9
[% INCLUDE 'doc-head-close.inc' %]
10
[% UNLESS ( wysiwyg ) %]
11
    [% Asset.css("lib/codemirror/codemirror.css") | $raw %]
12
    [% Asset.css("lib/codemirror/lint.min.css") | $raw %]
13
    <style>
14
        .CodeMirror {
15
            resize: vertical;
16
            z-index: 0;
17
        }
18
    </style>
19
[% END %]
20
</head>
21
22
<body id="tools_additional-contents" class="tools">
23
[% INCLUDE 'header.inc' %]
24
[% INCLUDE 'cat-search.inc' %]
25
26
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
27
    <ol>
28
        <li>
29
            <a href="/cgi-bin/koha/mainpage.pl">Home</a>
30
        </li>
31
        <li>
32
            <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
33
        </li>
34
35
        [% IF op == 'add_form' %]
36
            <li>
37
                <a href="/cgi-bin/koha/tools/additional-contents.pl">Additional contents</a>
38
            </li>
39
            <li>
40
                <a href="#" aria-current="page">
41
                    [% IF additional_content.idnew %]
42
                        Modify additional content
43
                    [% ELSE %]
44
                        Add additional content
45
                    [% END %]
46
                </a>
47
            </li>
48
        [% ELSE %]
49
            <li>
50
                <a href="#" aria-current="page">
51
                    Additional contents
52
                    ([% IF category == 'news' %]News[% ELSE %]HTML customizations[% END %])
53
                </a>
54
            </li>
55
        [% END %]
56
    </ol>
57
</nav>
58
59
[% IF op == 'add_form' %]
60
<div class="main container-fluid">
61
    <div class="row">
62
        <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
63
[% ELSE %]
64
<div class="main container-fluid">
65
    <div class="row">
66
        <div class="col-sm-10 col-sm-push-2">
67
[% END %]
68
69
<main>
70
71
    [% FOR m IN messages %]
72
        <div class="dialog [% m.type | html %]">
73
            [% SWITCH m.code %]
74
            [% CASE 'error_on_update' %]
75
                An error occurred when updating this content. Perhaps it already exists.
76
            [% CASE 'error_on_insert' %]
77
                An error occurred when adding this content. Check the logs
78
            [% CASE 'error_on_delete' %]
79
                An error occurred when deleting this content. Check the logs.
80
            [% CASE 'success_on_update' %]
81
                Content updated successfully.
82
            [% CASE 'success_on_insert' %]
83
                Content added successfully.
84
            [% CASE 'success_on_delete' %]
85
                Content deleted successfully.
86
            [% CASE %]
87
                [% m.code | html %]
88
            [% END %]
89
        </div>
90
    [% END %]
91
92
    [% IF op == 'add_form' %]
93
        [% PROCESS add_form %]
94
    [% ELSE %]
95
        [% PROCESS list %]
96
    [% END %]
97
98
</main>
99
100
        [% IF op != 'add_form' %]
101
            </div> <!-- /.col-sm-10.col-sm-push-2 -->
102
103
            <div class="col-sm-2 col-sm-pull-10">
104
                <aside>
105
106
                    <div id="news-filter">
107
                        <form action="/cgi-bin/koha/tools/additional-contents.pl" method="get">
108
                            <h4>Filter</h4>
109
                            <fieldset class="brief">
110
                                <ol>
111
                                    <li>
112
                                        <label for="news_keyword">Keyword:</label>
113
                                        <input type="text" name="news_keyword" id="news_keyword" />
114
                                    </li>
115
                                    <li>
116
                                        <label for="news_display_location">Display location:</label>
117
                                        <select name="news_display_location" id="news_display_location">
118
                                            <option value="">All</option>
119
                                            [% PROCESS locations_options category => category %]
120
                                        </select>
121
                                    </li>
122
                                    <li>
123
                                        <label for="news_library">Library: </label>
124
                                        <select id="news_library" name="news_library">
125
                                            <option value=""></option>
126
                                            <option value="">All libraries</option>
127
                                            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
128
                                        </select>
129
                                    </li>
130
                                    <li>
131
                                        <label>
132
                                            <input type="checkbox" name="show_expired" id="show_expired" /> Show expired
133
                                        </label>
134
                                    </li>
135
                                </ol>
136
                            </fieldset>
137
                        </form>
138
                    </div>
139
140
                    [% INCLUDE 'tools-menu.inc' %]
141
                </aside>
142
            </div> <!-- /.col-sm-2.col-sm-pull-10 -->
143
        [% END %]
144
    </div> <!-- /.row -->
145
</div> <!-- /.main.container-fluid -->
146
147
[% BLOCK add_form %]
148
    [% IF additional_content %]
149
        <h1>Modify an additional content</h1>
150
    [% ELSE %]
151
        <h1>New additional content ([% IF category == 'news' %]News[% ELSE %]HTML customizations[% END %])</h1>
152
    [% END %]
153
154
    <div id="toolbar" class="btn-toolbar">
155
        <div class="btn-group">
156
            <button class="btn btn-default" id="submit_form"><i class="fa fa-save"></i> Save</button>
157
        </div>
158
        <a class="btn btn-default cancel" href="/cgi-bin/koha/tools/additional-contents.pl"><i class="fa fa-remove"></i> Cancel</a>
159
    </div>
160
161
    <form id="add_additional_content" method="post" action="/cgi-bin/koha/tools/additional-contents.pl" class="validate">
162
        <input type="hidden" name="op" value="add_validate" />
163
        <input type="hidden" name="id" value="[% additional_content.idnew | html %]" />
164
        <input type="hidden" name="category" value="[% category | html %]" />
165
        <fieldset class="rows">
166
            <ol>
167
                <li>
168
                    [% IF additional_content %]
169
                        <span class="label">Code:</span> [% additional_content.code | html %]
170
                        <input type="hidden" id="code" name="code" value="[% additional_content.code | html %]" />
171
                    [% ELSE %]
172
                        <label for="code" class="required">Code:</label>
173
                        <input type="text" id="code" name="code" size="20" maxlength="20" value="" required="required"/>
174
                        <span class="required">Required</span>
175
                    [% END %]
176
                </li>
177
                <li>
178
                    <label for="location">Display location:</label>
179
                    <select id="location" name="location">
180
                        [% PROCESS locations_options location => additional_content.location %]
181
                    </select>
182
                </li>
183
                <li>
184
                    <label for="branchcode">Library: </label>
185
                    <select id="branchcode" name="branchcode">
186
                        [% IF additional_content.branchcode == '' %]
187
                            <option value="" selected="selected">All libraries</option>
188
                        [% ELSE %]
189
                            <option value="">All libraries</option>
190
                        [% END %]
191
                        [% PROCESS options_for_libraries libraries => Branches.all( selected => additional_content.branchcode, unfiltered => 1, ) %]
192
                    </select>
193
                </li>
194
                [% UNLESS languages.size %]
195
                    <li>
196
                        <label for="title" class="required">Title: </label>
197
                        <input id="title" size="30" type="text" name="title" value="[% additional_content.title | html %]" required="required" class="required" /> <span class="required">Required</span>
198
                    </li>
199
                [% END %]
200
                <li>
201
                    <label for="from">Publication date: </label>
202
                    <input id="from" type="text" name="published_on" size="15" value="[% additional_content.published_on | html %]" class="datepickerfrom" />
203
                    <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
204
                </li>
205
                <li>
206
                    <label for="to">Expiration date: </label>
207
                    <input id="to" type="text" name="expirationdate" size="15" value="[% additional_content.expirationdate | html %]" class="datepickerto" />
208
                    <div class="hint">
209
                        [% INCLUDE 'date-format.inc' %]
210
                        [% IF category == 'news' %]
211
                            <br>News will still be accessible by direct URL if expired.
212
                        [% END %]
213
                    </div>
214
                </li>
215
                <li>
216
                    <label for="number">Appear in position: </label>
217
                    [% IF ( additional_content.number ) %]
218
                        <input id="number" size="3" name="number" type="text" value="[% additional_content.number | html %]" />
219
                    [% ELSE %]
220
                        <input id="number" size="3" name="number" type="text" />
221
                    [% END %]
222
                </li>
223
            </ol>
224
        </fieldset>
225
226
        [% IF languages.size %]
227
            <div style="clear:both"></div>
228
            <div id="tabs">
229
                <ul>
230
                    [% FOR language IN languages %]
231
                        [% IF language.lang == 'default' %]
232
                            <li><a href="#lang_default">Default</a></li>
233
                        [% ELSE %]
234
                            <li><a href="#lang_[% language.lang | uri %]">[% language.description %]</a></li>
235
                        [% END %]
236
                    [% END %]
237
                </ul>
238
239
                [% FOR language IN languages %]
240
                    <div id="lang_[% language.lang | uri %]" class="lang" data-lang="[% language.description | html %]">
241
                        <div style="clear:both;">
242
243
                            <fieldset>[%# FIXME We should remove list-style:none; and use class="rows" here but it does not work. Owen please help! %]
244
                                <ol>
245
                                    <li style="list-style: none;">
246
                                        <label for="title_[% language.lang | html %]">Title: </label>
247
                                        <input id="title_[% language.lang| html %]" size="30" type="text" name="title" value="[% translated_contents.item(language.lang).title | html %]"></span>
248
                                    </li>
249
                                    <li style="list-style: none;">
250
                                        <label for="content_[% language.lang | html %]">Content: </label>
251
                                        <textarea name="content" id="content_[% language.lang | html %]"  cols="75" rows="10">[% translated_contents.item(language.lang).content | html %]</textarea>
252
                                        <input type="hidden" name="lang" value="[% language.lang %]" />
253
                                    </li>
254
                                </ol>
255
                            </fieldset>
256
                        </div>
257
                    </div>
258
                [% END %]
259
            </div>
260
        [% ELSE %]
261
            <div id="lang_default">
262
                <div style="clear:both;">
263
                    <textarea name="content" id="content_default"  cols="75" rows="10">[% additional_content.content | html %]</textarea>
264
                </div>
265
            </div>
266
        [% END %]
267
    </form>
268
[% END %]
269
270
[% BLOCK list %]
271
272
    <div id="toolbar" class="btn-toolbar">
273
        <a class="btn btn-default" id="newentry" href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&category=[% category | html %]"><i class="fa fa-plus"></i> New entry</a>
274
    </div>
275
276
    <h2>Additional contents ([% IF category == 'news' %]News[% ELSE %]HTML customizations[% END %])</h2>
277
    [% IF category == 'news' %]
278
        See <a href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations">HTML customizations</a>
279
    [% ELSE %]
280
        See <a href="/cgi-bin/koha/tools/additional-contents.pl?category=news">News</a>
281
    [% END %]
282
283
    [% IF additional_contents.count %]
284
        <form id="del_form" method="post" action="/cgi-bin/koha/tools/additional-contents.pl">
285
            <table id="table_additional_contents">
286
                <thead>
287
                    <tr>
288
                        <th class="NoSort">&nbsp;</th>
289
                        <th>Location</th>
290
                        <th>Library</th>
291
                        <th>Number</th>
292
                        <th>Publication date</th>
293
                        <th>Expiration date</th>
294
                        <th class="anti-the">Title</th>
295
                        <th>Author</th>
296
                        <th class="anti-the">News</th>
297
                        <th class="NoSort noExport">Actions</th>
298
                    </tr>
299
                </thead>
300
                <tbody>
301
                    [% FOREACH c IN additional_contents%]
302
                        [% IF ( c.is_expired ) %]<tr class="expired">[% ELSE %]<tr>[% END %]
303
                        <td>
304
                            <input type="checkbox" name="ids" value="[% c.idnew | html %]" />
305
                        </td>
306
                        <td>
307
                            [% IF c.category == 'news' %]
308
                                [% IF c.location == 'staff_and_opac' %]All
309
                                [% ELSIF c.location == 'staff_only' %]Librarian interface
310
                                [% ELSIF c.location == 'opac_only' %]OPAC
311
                                [% ELSIF c.location == 'slip' %]Slip
312
                                [% ELSE %]Unknown ('[% location %]')
313
                                [% END %]
314
                            [% ELSE %]
315
                                [% c.location %]
316
                            [% END %]
317
                        </td>
318
                        <td>
319
                            [% IF ( c.branchcode == "" ) -%]
320
                            All libraries
321
                            [% ELSE %][% c.library.branchname | html %]
322
                            [% END %]
323
                        </td>
324
                        <td>[% c.number | html %]</td>
325
                        <td data-order="[% c.published_on | html %]">[% c.published_on | $KohaDates %]</td>
326
                        <td data-order="[% c.expirationdate | html %]">[% c.expirationdate | $KohaDates %] [% IF ( c.is_expired ) %](<span class="expired">expired</span>)[% END %]</td>
327
                        <td>[% c.title | html %]</td>
328
                        <td>[% IF ( c.author) %][% INCLUDE 'patron-title.inc' patron=c.author %][% END %]</td>
329
                        <td>
330
                            <div class="btn-group">
331
                                <a class="preview_news btn btn-default btn-xs" data-number="[% loop.count | html %]"><i class="fa fa-eye" aria-hidden="true"></i> Preview content</a>
332
                            </div>
333
                            <div id="contentModal[% loop.count | html %]" class="modal" tabindex="-1" role="dialog" data-number="[% loop.count | html %]">
334
                                <div class="modal-dialog" role="document">
335
                                    <div class="modal-content modal-lg">
336
                                        <div class="modal-header">
337
                                            <h5 class="modal-title">Preview of: "[% c.title | html %]"</h5>
338
                                        </div>
339
                                    <div class="modal-body">
340
                                        [% c.content | $raw %]
341
                                    </div>
342
                                    <div class="modal-footer">
343
                                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
344
                                    </div>
345
                                </div>
346
                            </div>
347
                        </td>
348
                        <td class="actions">
349
                            [% IF ( wysiwyg ) %]
350
                                [% SET editmode = "wysiwyg" %]
351
                            [% ELSE %]
352
                                [% SET editmode = "text" %]
353
                            [% END %]
354
                            <div class="btn-group dropup">
355
                                <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&amp;id=[% c.idnew | uri %]&editmode=[% editmode | uri %]" class="btn btn-default btn-xs"> <i class="fa fa-pencil"></i> Edit</a><button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
356
                                    <span class="caret"></span>
357
                                </button>
358
                                <ul class="dropdown-menu pull-right">
359
                                    <li>
360
                                        [% IF ( wysiwyg ) %]
361
                                            <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&amp;id=[% c.idnew | uri %]&editmode=text"><i class="fa fa-pencil"></i> Edit with text editor</a>
362
                                        [% ELSE %]
363
                                            <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&amp;id=[% c.idnew | uri %]&editmode=wysiwyg"><i class="fa fa-pencil"></i> Edit with WYSIWYG editor</a>
364
                                        [% END %]
365
                                    </li>
366
                                </ul>
367
                            </div>
368
                            <div class="btn-group">
369
                                <a href="/cgi-bin/koha/tools/additional-contents.pl?op=del&amp;ids=[% c.idnew | uri %]" class="delete_news btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
370
                            </div>
371
                        </td>
372
                    </tr>
373
                    [% END %]
374
                </tbody>
375
            </table>
376
            <input type="hidden" name="op" value="del" />
377
            <fieldset class="action"><input type="submit" class="button" value="Delete selected" /></fieldset>
378
        </form>
379
    [% ELSE %]
380
        <div class="dialog message">There are no additional contents.</div>
381
    [% END %]
382
[% END %]
383
384
[% BLOCK locations_options %]
385
    [% IF category == 'news' %]
386
        [% IF location == "staff_and_opac" %]
387
            <option value="staff_and_opac" selected="selected">Librarian and OPAC interfaces</option>
388
        [% ELSE %]
389
            <option value="staff_and_opac">Librarian and OPAC interfaces</option>
390
        [% END %]
391
392
        [% IF location == "staff_only" %]
393
            <option value="staff_only" selected="selected">Librarian interface</option>
394
        [% ELSE %]
395
            <option value="staff_only">Librarian interface</option>
396
        [% END %]
397
398
        [% IF location == "opac_only" %]
399
            <option value="opac_only" selected="selected">OPAC</option>
400
        [% ELSE %]
401
            <option value="opac_only">OPAC</option>
402
        [% END %]
403
404
        [% IF location == "slip" %]
405
            <option value="slip" selected="selected">Slip</option>
406
        [% ELSE %]
407
            <option value="slip">Slip</option>
408
        [% END %]
409
    [% ELSE %]
410
        [% FOREACH l IN [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacSuggestionInstructions'] %]
411
            [% IF l == location %]
412
                <option value="[% l | html %]" selected="selected">[% l | html %]</option>
413
            [% ELSE %]
414
                <option value="[% l | html %]">[% l | html %]</option>
415
            [% END %]
416
        [% END %]
417
    [% END %]
418
[% END %]
419
420
[% MACRO jsinclude BLOCK %]
421
    [% INCLUDE 'calendar.inc' %]
422
    [% Asset.js("js/tools-menu.js") | $raw %]
423
    [% Asset.js("lib/hc-sticky.js") | $raw %]
424
    [% IF additional_contents.count %]
425
        [% INCLUDE 'datatables.inc' %]
426
        <script>
427
            $('.preview_news').click( function() {
428
                modalNumber = $(this).attr('data-number');
429
                $('.modal[data-number="'+modalNumber+'"]').modal('show');
430
            })
431
            function Checkbox(){
432
                var form = document.getElementById('del_form');
433
                var inputs = form.getElementsByTagName('input');
434
                var checked = false;
435
                for (var i=0; i<inputs.length; i++) {
436
                    if (inputs[i].type == 'checkbox' && inputs[i].name == 'ids') {
437
                        checked = inputs[i].checked;
438
                        if (checked) return true;
439
                    }
440
                }
441
            }
442
443
            function filterDataTable( table, column, term ){
444
                if( column ){
445
                    table.column( column ).search( term ).draw();
446
                } else {
447
                    table.search( term ).draw();
448
                }
449
                clearFilter( term );
450
            }
451
452
            function clearFilter( term ){
453
                if( term == "" ){
454
                    $(".dt_button_clear_filter").addClass("disabled");
455
                } else {
456
                    $(".dt_button_clear_filter").removeClass("disabled");
457
                }
458
            }
459
460
            /* Custom table search configuration: If a table row
461
               has an "expired" class, hide it UNLESS the
462
               show_expired checkbox is checked */
463
            $.fn.dataTable.ext.search.push(
464
                function( settings, searchData, index, rowData, counter ) {
465
                    var row = $(settings.aoData[index].nTr);
466
                    if( row.hasClass("expired") && !$("#show_expired").prop("checked") ){
467
                        return false;
468
                    } else {
469
                        return true;
470
                    }
471
                }
472
            );
473
474
            $(document).ready(function() {
475
476
                var table = $("#table_additional_contents").DataTable($.extend(true, {}, dataTablesDefaults, {
477
                    "order": [[ 4, "desc" ]],
478
                    "aoColumnDefs": [
479
                        { "sortable": false, "searchable": false, 'targets': [ 'NoSort' ] },
480
                        { "type": "anti-the", "targets": [ "anti-the" ] }
481
                    ],
482
                    "sPaginationType": "full_numbers"
483
                }));
484
485
                $(".delete_news").on("click", function(){
486
                    return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") );
487
                });
488
489
                $("#del_form").on("submit",function(){
490
                    if ( Checkbox() ) {
491
                        return confirmDelete( _("Are you sure you want to delete the selected news?") );
492
                    } else {
493
                        alert(_("Please select a news item to delete."));
494
                        return false;
495
                    }
496
                });
497
498
                $("#show_expired").on("change", function(){
499
                    /* redraw the DataTable according to the custom search function */
500
                    table.draw();
501
                });
502
503
                table.on( 'search.dt', function () {
504
                    var term = table.search();
505
                    $("#news_keyword").val( term );
506
                });
507
508
                $("#news_keyword").on("keyup", function(){
509
                    var term = $(this).val();
510
                    filterDataTable( table, null, term );
511
                });
512
513
                $("#news_display_location").on("change", function(){
514
                    var term = $(this).val();
515
                    filterDataTable( table, 1, term );
516
                });
517
518
                $("#news_library").on("change", function(){
519
                    // Table must be filtered by the <option>'s text, not its value
520
                    var opt = $(this).find("option:selected").text();
521
                    filterDataTable( table, 2, opt );
522
                });
523
524
                $(".dt_button_clear_filter").on("click", function(){
525
                    table.search('').columns().search('').draw();
526
                    $("#news-filter select").each(function(){
527
                        $(this).val("");
528
                    });
529
                });
530
            });
531
        </script>
532
    [% ELSE %]
533
        <script>
534
            $(document).ready(function() {
535
                $("#tabs").tabs();
536
                $("#add_additional_content").validate({
537
                    submitHandler: function(form){
538
                        if ( ! $("#title_default").val().length > 0 ) {
539
                            alert(__("Please specify a title for 'Default'"));
540
                            return false;
541
                        }
542
543
                        form.submit();
544
                    }
545
                });
546
547
                $("#submit_form").on("click",function(){
548
                    $("#add_additional_content").submit();
549
                });
550
551
                Sticky = $("#toolbar");
552
                Sticky.hcSticky({
553
                    stickTo: ".main",
554
                    stickyClass: "floating"
555
                });
556
557
            });
558
        </script>
559
    [% END %]
560
    [% UNLESS ( wysiwyg ) %]
561
        [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
562
        [% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %]
563
        [% Asset.js( "lib/codemirror/lint.min.js" ) | $raw %]
564
        [% Asset.js( "lib/linters/htmlhint.min.js" ) | $raw %]
565
        [% Asset.js( "lib/codemirror/html-lint.min.js" ) | $raw %]
566
        <script>
567
            var editor = CodeMirror.fromTextArea(document.getElementById('content'), {
568
                lineNumbers: true,
569
                lineWrapping: true,
570
                lint: true,
571
                mode: "text/html",
572
                gutters: ["CodeMirror-lint-markers"],
573
                viewportMargin: Infinity,
574
            });
575
        </script>
576
    [% ELSE %]
577
        [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %]
578
        [% INCLUDE 'str/tinymce_i18n.inc' %]
579
        <script>
580
            tinyMCE.init({
581
                verify_html: false,
582
                force_br_newlines : false,
583
                force_p_newlines : false,
584
                forced_root_block : '',
585
                branding : false,
586
                relative_urls : false,
587
                content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
588
                menubar : "file edit view insert format tools table",
589
                mode : "specific_textareas",
590
                plugins : "autoresize table hr link image charmap lists code emoticons",
591
                extended_valid_elements:"style,link[href|rel]",
592
                custom_elements:"style,link,~link",
593
                toolbar : [
594
                    "formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr",
595
                    "table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code visualaid help"
596
                ],
597
            });
598
        </script>
599
    [% END # /UNLESS wysiwyg %]
600
[% END %]
601
602
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt (-475 lines)
Lines 1-475 Link Here
1
[% USE raw %]
2
[% USE Asset %]
3
[% USE Koha %]
4
[% USE KohaDates %]
5
[% USE Branches %]
6
[% SET footerjs = 1 %]
7
[% INCLUDE 'doc-head-open.inc' %]
8
<title>News &rsaquo; Tools &rsaquo; Koha</title>
9
[% INCLUDE 'doc-head-close.inc' %]
10
[% UNLESS ( wysiwyg ) %]
11
    [% Asset.css("lib/codemirror/codemirror.css") | $raw %]
12
    [% Asset.css("lib/codemirror/lint.min.css") | $raw %]
13
    <style>
14
        .CodeMirror {
15
            resize: vertical;
16
            z-index: 0;
17
        }
18
    </style>
19
[% END %]
20
</head>
21
22
<body id="tools_koha-news" class="tools">
23
[% INCLUDE 'header.inc' %]
24
[% INCLUDE 'cat-search.inc' %]
25
26
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
27
    <ol>
28
        <li>
29
            <a href="/cgi-bin/koha/mainpage.pl">Home</a>
30
        </li>
31
        <li>
32
            <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
33
        </li>
34
35
        [% IF ( add_form ) %]
36
            <li>
37
                <a href="/cgi-bin/koha/tools/koha-news.pl">News</a>
38
            </li>
39
            <li>
40
                <a href="#" aria-current="page">
41
                    [% IF ( id ) %]
42
                        Edit news item
43
                    [% ELSE %]
44
                        Add news item
45
                    [% END %]
46
                </a>
47
            </li>
48
        [% ELSE %]
49
            <li>
50
                <a href="#" aria-current="page">
51
                    News
52
                </a>
53
            </li>
54
        [% END %]
55
    </ol>
56
</nav>
57
58
[% IF ( add_form ) %]
59
    <div class="main container-fluid">
60
        <div class="row">
61
            <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
62
[% ELSE %]
63
    <div class="main container-fluid">
64
        <div class="row">
65
            <div class="col-sm-10 col-sm-push-2">
66
[% END %]
67
                <main>
68
69
[% UNLESS ( add_form ) %]
70
    [% IF error_message == 'title_missing' %]
71
        <div class="dialog alert">Error: Required news title missing!</div>
72
    [% END %]
73
<h2>News</h2>
74
<div id="toolbar" class="btn-toolbar">
75
    <a class="btn btn-default" id="newentry" href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;lang=[% lang | html %]"><i class="fa fa-plus"></i> New entry</a>
76
</div>
77
[% END %]
78
79
[% IF ( add_form ) %]
80
    [% IF ( op == 'add' ) %]
81
        [% default_lang = lang %]
82
    [% ELSE %]
83
        [% default_lang = new_detail.lang %]
84
    [% END %]
85
        <form name="add_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl" >
86
            <input type="hidden" name="op" value="[% op | html %]" />
87
            <input type="hidden" name="id" value="[% id | html %]" />
88
			<fieldset class="rows">
89
            <legend>OPAC and Koha news</legend>
90
           <ol> <li>
91
            <label for="lang">Display location:</label>
92
            <select id="lang" name="lang">
93
                [% PROCESS lang_locations language => default_lang %]
94
            </select>
95
            </li>
96
            <li>
97
                <label for="branch">Library: </label>
98
                <select id="branch" name="branch">
99
                    [% IF ( new_detail.branchcode == '' ) %]
100
                        <option value="" selected="selected">All libraries</option>
101
                    [% ELSE %]
102
                        <option value=""         >All libraries</option>
103
                    [% END %]
104
                    [% PROCESS options_for_libraries libraries => Branches.all( selected => new_detail.branchcode, unfiltered => 1, ) %]
105
                </select>
106
            </li>
107
            <li>
108
                <label for="title" class="required">Title: </label>
109
                <input id="title" size="30" type="text" name="title" value="[% new_detail.title | html %]" required="required" class="required" /> <span class="required">Required</span>
110
            </li>
111
            <li>
112
                <label for="from">Publication date: </label>
113
                <input id="from" type="text" name="published_on" size="15" value="[% new_detail.published_on | html %]" class="datepickerfrom" />
114
				<div class="hint">[% INCLUDE 'date-format.inc' %]</div>
115
            </li>
116
            <li>
117
                <label for="to">Expiration date: </label>
118
                <input id="to" type="text" name="expirationdate" size="15" value="[% new_detail.expirationdate | html %]" class="datepickerto" />
119
                <div class="hint">
120
                    [% INCLUDE 'date-format.inc' %]
121
                    <br>News will still be accessible by direct URL if expired.
122
                </div>
123
            </li>
124
            <li>
125
                <label for="number">Appear in position: </label>
126
                [% IF ( new_detail.number ) %]
127
                    <input id="number" size="3" name="number" type="text" value="[% new_detail.number | html %]" />
128
                [% ELSE %]
129
                    <input id="number" size="3" name="number" type="text" />
130
                [% END %]
131
            </li>
132
            <li><label for="content">News: </label>
133
            <textarea name="content" id="content"  cols="75" rows="10">[% new_detail.content | html %]</textarea>
134
            </li>
135
            </ol>
136
			</fieldset>
137
  
138
                <fieldset class="action"><input class="button" type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/tools/koha-news.pl">Cancel</a></fieldset>
139
        </form>
140
    [% ELSE %]
141
        [% IF ( opac_news.count ) %]
142
        <form id="del_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl">
143
                <table id="newst">
144
                   <thead> <tr>
145
                        <th class="NoSort">&nbsp;</th>
146
                        <th>Location</th>
147
                        <th>Library</th>
148
                        <th>Number</th>
149
                        <th>Publication date</th>
150
                        <th>Expiration date</th>
151
                        <th class="anti-the">Title</th>
152
                        <th>Author</th>
153
                        <th class="anti-the">News</th>
154
                        <th class="NoSort noExport">Actions</th>
155
                    </tr></thead>
156
                    <tbody>[% FOREACH opac_new IN opac_news %]
157
                         [% IF ( opac_new.is_expired ) %]
158
                            <tr class="expired">
159
                            [% ELSE %]
160
                            <tr>
161
                            [% END %]
162
                            <td>
163
                                <input type="checkbox" name="ids" value="[% opac_new.idnew | html %]" />
164
                            </td>
165
                            <td>[% SWITCH opac_new.lang %]
166
                                [%   CASE "koha" %]
167
                                    Librarian interface (koha)
168
                                [%   CASE "slip" %]
169
                                    Slip
170
                                [%   CASE "" %]
171
                                    All
172
                                [%   CASE %]
173
                                    OPAC ([% opac_new.lang | html %])
174
                                [% END %]
175
                             </td>
176
                            <td>[% IF ( opac_new.branchcode == "" ) -%]
177
                                All libraries
178
                                [% ELSE %][% opac_new.library.branchname | html %]
179
                                [% END %]</td>
180
                            <td>[% opac_new.number | html %]</td>
181
                            <td data-order="[% opac_new.published_on | html %]">[% opac_new.published_on | $KohaDates %]</td>
182
                            <td data-order="[% opac_new.expirationdate | html %]">[% opac_new.expirationdate | $KohaDates %] [% IF ( opac_new.is_expired ) %](<span class="expired">expired</span>)[% END %]</td>
183
                            <td>[% opac_new.title | html %]</td>
184
                            <td>[% IF ( opac_new.author) %][% INCLUDE 'patron-title.inc' patron=opac_new.author %][% END %]</td>
185
                            <td>
186
                                <div class="btn-group">
187
                                    <a class="preview_news btn btn-default btn-xs" data-number="[% loop.count | html %]"><i class="fa fa-eye" aria-hidden="true"></i> Preview content</a>
188
                                </div>
189
                                <div id="contentModal[% loop.count | html %]" class="modal" tabindex="-1" role="dialog" data-number="[% loop.count | html %]">
190
                                    <div class="modal-dialog" role="document">
191
                                        <div class="modal-content modal-lg">
192
                                            <div class="modal-header">
193
                                                <h5 class="modal-title">Preview of: "[% opac_new.title | html %]"</h5>
194
                                            </div>
195
                                        <div class="modal-body">
196
                                            [% opac_new.content | $raw %]
197
                                        </div>
198
                                        <div class="modal-footer">
199
                                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
200
                                        </div>
201
                                    </div>
202
                                </div>
203
                            </td>
204
                            <td class="actions">
205
                                [% IF ( wysiwyg ) %]
206
                                    [% SET editmode = "wysiwyg" %]
207
                                [% ELSE %]
208
                                    [% SET editmode = "text" %]
209
                                [% END %]
210
                                <div class="btn-group dropup">
211
                                    <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;id=[% opac_new.idnew | uri %]&editmode=[% editmode | uri %]" class="btn btn-default btn-xs"> <i class="fa fa-pencil"></i> Edit</a><button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
212
                                        <span class="caret"></span>
213
                                    </button>
214
                                    <ul class="dropdown-menu pull-right">
215
                                        <li>
216
                                            [% IF ( wysiwyg ) %]
217
                                                <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;id=[% opac_new.idnew | uri %]&editmode=text"><i class="fa fa-pencil"></i> Edit with text editor</a>
218
                                            [% ELSE %]
219
                                                <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;id=[% opac_new.idnew | uri %]&editmode=wysiwyg"><i class="fa fa-pencil"></i> Edit with WYSIWYG editor</a>
220
                                            [% END %]
221
                                        </li>
222
                                    </ul>
223
                                </div>
224
                                <div class="btn-group">
225
                                    <a href="/cgi-bin/koha/tools/koha-news.pl?op=del&amp;ids=[% opac_new.idnew | uri %]" class="delete_news btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
226
                                </div>
227
                            </td>
228
                        </tr>
229
                    [% END %]</tbody>
230
                </table>
231
                <input type="hidden" name="op" value="del" />
232
                <fieldset class="action"><input type="submit" class="button" value="Delete selected" /></fieldset>
233
            </form>
234
        [% ELSE %]
235
            <div class="dialog message">There are no news items.</div>
236
        [% END %]
237
    [% END %]
238
239
                </main>
240
            [% UNLESS ( add_form ) %]
241
                </div> <!-- /.col-sm-10.col-sm-push-2 -->
242
243
                <div class="col-sm-2 col-sm-pull-10">
244
                    <aside>
245
246
                        <div id="news-filter">
247
                            <form action="/cgi-bin/koha/tools/koha-news.pl" method="get">
248
                                <h4>Filter</h4>
249
                                <fieldset class="brief">
250
                                    <ol>
251
                                        <li>
252
                                            <label for="news_keyword">Keyword:</label>
253
                                            <input type="text" name="news_keyword" id="news_keyword" />
254
                                        </li>
255
                                        <li>
256
                                            <label for="news_display_location">Display location:</label>
257
                                            <select name="news_display_location" id="news_display_location">
258
                                                [% PROCESS lang_locations %]
259
                                            </select>
260
                                        </li>
261
                                        <li>
262
                                            <label for="news_library">Library: </label>
263
                                            <select id="news_library" name="news_library">
264
                                                <option value=""></option>
265
                                                <option value="">All libraries</option>
266
                                                [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
267
                                            </select>
268
                                        </li>
269
                                        <li>
270
                                            <label>
271
                                                <input type="checkbox" name="show_expired" id="show_expired" /> Show expired
272
                                            </label>
273
                                        </li>
274
                                    </ol>
275
                                </fieldset>
276
                            </form>
277
                        </div>
278
279
                        [% INCLUDE 'tools-menu.inc' %]
280
                    </aside>
281
                </div> <!-- /.col-sm-2.col-sm-pull-10 -->
282
            [% END %]
283
        </div> <!-- /.row -->
284
    </div> <!-- /.main.container-fluid -->
285
286
287
[% MACRO jsinclude BLOCK %]
288
    [% INCLUDE 'calendar.inc' %]
289
    [% Asset.js("js/tools-menu.js") | $raw %]
290
    [% IF ( opac_news.count ) %]
291
        [% INCLUDE 'datatables.inc' %]
292
        <script>
293
            $('.preview_news').click( function() {
294
                modalNumber = $(this).attr('data-number');
295
                $('.modal[data-number="'+modalNumber+'"]').modal('show');
296
            })
297
            function Checkbox(){
298
                var form = document.getElementById('del_form');
299
                var inputs = form.getElementsByTagName('input');
300
                var checked = false;
301
                for (var i=0; i<inputs.length; i++) {
302
                    if (inputs[i].type == 'checkbox' && inputs[i].name == 'ids') {
303
                        checked = inputs[i].checked;
304
                        if (checked) return true;
305
                    }
306
                }
307
            }
308
309
            function filterDataTable( table, column, term ){
310
                if( column ){
311
                    table.column( column ).search( term ).draw();
312
                } else {
313
                    table.search( term ).draw();
314
                }
315
                clearFilter( term );
316
            }
317
318
            function clearFilter( term ){
319
                if( term == "" ){
320
                    $(".dt_button_clear_filter").addClass("disabled");
321
                } else {
322
                    $(".dt_button_clear_filter").removeClass("disabled");
323
                }
324
            }
325
326
            /* Custom table search configuration: If a table row
327
               has an "expired" class, hide it UNLESS the
328
               show_expired checkbox is checked */
329
            $.fn.dataTable.ext.search.push(
330
                function( settings, searchData, index, rowData, counter ) {
331
                    var row = $(settings.aoData[index].nTr);
332
                    if( row.hasClass("expired") && !$("#show_expired").prop("checked") ){
333
                        return false;
334
                    } else {
335
                        return true;
336
                    }
337
                }
338
            );
339
340
            $(document).ready(function() {
341
                var newst = $("#newst").DataTable($.extend(true, {}, dataTablesDefaults, {
342
                    "order": [[ 4, "desc" ]],
343
                    "aoColumnDefs": [
344
                        { "sortable": false, "searchable": false, 'targets': [ 'NoSort' ] },
345
                        { "type": "anti-the", "targets": [ "anti-the" ] }
346
                    ],
347
                    "sPaginationType": "full_numbers"
348
                }));
349
350
                $(".delete_news").on("click", function(){
351
                    return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") );
352
                });
353
354
                $("#del_form").on("submit",function(){
355
                    if ( Checkbox() ) {
356
                        return confirmDelete( _("Are you sure you want to delete the selected news?") );
357
                    } else {
358
                        alert(_("Please select a news item to delete."));
359
                        return false;
360
                    }
361
                });
362
363
                $("#show_expired").on("change", function(){
364
                    /* redraw the DataTable according to the custom search function */
365
                    newst.draw();
366
                });
367
368
                newst.on( 'search.dt', function () {
369
                    var term = newst.search();
370
                    $("#news_keyword").val( term );
371
                });
372
373
                $("#news_keyword").on("keyup", function(){
374
                    var term = $(this).val();
375
                    filterDataTable( newst, null, term );
376
                });
377
378
                $("#news_display_location").on("change", function(){
379
                    var term = $(this).val();
380
                    filterDataTable( newst, 1, term );
381
                });
382
383
                $("#news_library").on("change", function(){
384
                    // Table must be filtered by the <option>'s text, not its value
385
                    var opt = $(this).find("option:selected").text();
386
                    filterDataTable( newst, 2, opt );
387
                });
388
389
                $(".dt_button_clear_filter").on("click", function(){
390
                    newst.search('').columns().search('').draw();
391
                    $("#news-filter select").each(function(){
392
                        $(this).val("");
393
                    });
394
                });
395
            });
396
        </script>
397
    [% END %]
398
    [% UNLESS ( wysiwyg ) %]
399
        [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
400
        [% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %]
401
        [% Asset.js( "lib/codemirror/lint.min.js" ) | $raw %]
402
        [% Asset.js( "lib/linters/htmlhint.min.js" ) | $raw %]
403
        [% Asset.js( "lib/codemirror/html-lint.min.js" ) | $raw %]
404
        <script>
405
            var editor = CodeMirror.fromTextArea(document.getElementById('content'), {
406
                lineNumbers: true,
407
                lineWrapping: true,
408
                lint: true,
409
                mode: "text/html",
410
                gutters: ["CodeMirror-lint-markers"],
411
                viewportMargin: Infinity,
412
            });
413
        </script>
414
    [% ELSE %]
415
        [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %]
416
        [% INCLUDE 'str/tinymce_i18n.inc' %]
417
        <script>
418
            tinyMCE.init({
419
                verify_html: false,
420
                force_br_newlines : false,
421
                force_p_newlines : false,
422
                forced_root_block : '',
423
                branding : false,
424
                relative_urls : false,
425
                content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
426
                menubar : "file edit view insert format tools table",
427
                mode : "specific_textareas",
428
                plugins : "autoresize table hr link image charmap lists code emoticons",
429
                extended_valid_elements:"style,link[href|rel]",
430
                custom_elements:"style,link,~link",
431
                toolbar : [
432
                    "formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr",
433
                    "table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code visualaid help"
434
                ],
435
            });
436
        </script>
437
    [% END # /IF NewsToolEditor %]
438
[% END %]
439
440
[% BLOCK lang_locations %]
441
    [% IF ( language == "" ) %]
442
        <option value="" selected="selected"></option>
443
    [% ELSE %]
444
        <option value="">All</option>
445
    [% END %]
446
    [% IF ( language == "koha" ) %]
447
        <option value="koha" selected="selected">Librarian interface</option>
448
    [% ELSE %]
449
        <option value="koha">Librarian interface</option>
450
    [% END %]
451
    [% IF ( language == "slip" ) %]
452
        <option value="slip" selected="selected">Slip</option>
453
    [% ELSE %]
454
        <option value="slip">Slip</option>
455
    [% END %]
456
    [% FOREACH lang_lis IN lang_list %]
457
        <optgroup label="[% lang_lis.language | html %]">
458
            [% FOREACH location IN [ '', 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacSuggestionInstructions'] %]
459
                [% IF ( location == '' ) %]
460
                    [% SET location_lang = lang_lis.language %]
461
                    [% location = BLOCK %]OPAC news[% END %]
462
                [% ELSE %]
463
                    [% SET location_lang = location _ "_" _ lang_lis.language %]
464
                [% END %]
465
                [% IF ( location_lang == language ) %]
466
                    <option value="[% location_lang | html %]" selected="selected">[% location | html %] ([% lang_lis.language | html %])</option>
467
                [% ELSE %]
468
                    <option value="[% location_lang | html %]">[% location | html %] ([% lang_lis.language | html %])</option>
469
                [% END %]
470
            [% END %]
471
        </optgroup>
472
    [% END %]
473
[% END %]
474
475
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (-3 / +6 lines)
Lines 93-99 Link Here
93
93
94
94
95
<div class="col-sm-4 col-sm-push-4">
95
<div class="col-sm-4 col-sm-push-4">
96
[% IF ( CAN_user_tools_edit_calendar || CAN_user_tools_manage_csv_profiles || CAN_user_tools_view_system_logs || CAN_user_tools_edit_news  || CAN_user_tools_schedule_tasks || CAN_user_tools_edit_quotes || ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool )  || CAN_user_tools_upload_general_files || CAN_user_tools_access_files ) %]
96
[% IF ( CAN_user_tools_edit_calendar || CAN_user_tools_manage_csv_profiles || CAN_user_tools_view_system_logs || CAN_user_tools_edit_additional_contents  || CAN_user_tools_schedule_tasks || CAN_user_tools_edit_quotes || ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool )  || CAN_user_tools_upload_general_files || CAN_user_tools_access_files ) %]
97
<h3>Additional tools</h3>
97
<h3>Additional tools</h3>
98
[% END %]
98
[% END %]
99
<dl>
99
<dl>
Lines 112-120 Link Here
112
    <dd>Browse the system logs</dd>
112
    <dd>Browse the system logs</dd>
113
    [% END %]
113
    [% END %]
114
114
115
    [% IF ( CAN_user_tools_edit_news ) %]
115
    [% IF ( CAN_user_tools_edit_additional_contents ) %]
116
    <dt><a href="/cgi-bin/koha/tools/koha-news.pl">News</a></dt>
116
    <dt><a href="/cgi-bin/koha/tools/additional-contents.pl?category=news">News</a></dt>
117
    <dd>Write news for the OPAC and staff interfaces</dd>
117
    <dd>Write news for the OPAC and staff interfaces</dd>
118
119
    <dt><a href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations">HTML customizations</a></dt>
120
    <dd>Write HTML customizations</dd>
118
    [% END %]
121
    [% END %]
119
122
120
    [% IF ( CAN_user_tools_schedule_tasks ) %]
123
    [% IF ( CAN_user_tools_schedule_tasks ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sci.inc (-2 / +2 lines)
Lines 1-9 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE KohaNews %]
3
[% USE AdditionalContents %]
4
[% PROCESS 'html_helpers.inc' %]
4
[% PROCESS 'html_helpers.inc' %]
5
[% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
5
[% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
6
[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
6
[% SET OpacHeader = AdditionalContents.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
7
7
8
<div id="wrapper">
8
<div id="wrapper">
9
    <div id="header-region" class="noprint">
9
    <div id="header-region" class="noprint">
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco.inc (-2 / +2 lines)
Lines 1-9 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE KohaNews %]
3
[% USE AdditionalContents %]
4
[% PROCESS 'html_helpers.inc' %]
4
[% PROCESS 'html_helpers.inc' %]
5
[% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
5
[% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
6
[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
6
[% SET OpacHeader = AdditionalContents.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
7
7
8
<div id="wrapper">
8
<div id="wrapper">
9
    <div id="header-region" class="noprint">
9
    <div id="header-region" class="noprint">
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc (-4 / +4 lines)
Lines 2-13 Link Here
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE Branches %]
3
[% USE Branches %]
4
[% USE Categories %]
4
[% USE Categories %]
5
[% USE KohaNews %]
5
[% USE AdditionalContents %]
6
[% PROCESS 'html_helpers.inc' %]
6
[% PROCESS 'html_helpers.inc' %]
7
[% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
7
[% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
8
[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
8
[% SET OpacHeader = AdditionalContents.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
9
[% SET OpacCustomSearch = KohaNews.get( location => "OpacCustomSearch", lang => lang, library => branchcode, blocktitle => 0 ) %]
9
[% SET OpacCustomSearch = AdditionalContents.get( location => "OpacCustomSearch", lang => lang, library => branchcode, blocktitle => 0 ) %]
10
[% SET OpacLoginInstructions = KohaNews.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %]
10
[% SET OpacLoginInstructions = AdditionalContents.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %]
11
11
12
<div id="wrapper">
12
<div id="wrapper">
13
    <div id="header-region" class="noprint">
13
    <div id="header-region" class="noprint">
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (-2 / +2 lines)
Lines 1-9 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE KohaNews %]
3
[% USE AdditionalContents %]
4
[%- USE KohaPlugins -%]
4
[%- USE KohaPlugins -%]
5
[% USE Asset %]
5
[% USE Asset %]
6
[% SET opaccredits = KohaNews.get( location => "opaccredits", lang => lang, library => branchcode ) %]
6
[% SET opaccredits = AdditionalContents.get( location => "opaccredits", lang => lang, library => branchcode ) %]
7
[% PROCESS 'html_helpers.inc' %]
7
[% PROCESS 'html_helpers.inc' %]
8
[% UNLESS ( is_popup ) %]
8
[% UNLESS ( is_popup ) %]
9
        [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
9
        [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/maintenance.tt (-2 / +2 lines)
Lines 1-8 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE KohaNews %]
3
[% USE AdditionalContents %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
5
[% SET OpacHeader = AdditionalContents.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
6
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
6
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
7
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
8
[% BLOCK cssinclude %]
8
[% BLOCK cssinclude %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt (-2 / +2 lines)
Lines 1-9 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE Categories %]
3
[% USE Categories %]
4
[% USE KohaNews %]
4
[% USE AdditionalContents %]
5
[% PROCESS 'html_helpers.inc' %]
5
[% PROCESS 'html_helpers.inc' %]
6
[% SET OpacLoginInstructions = KohaNews.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %]
6
[% SET OpacLoginInstructions = AdditionalContents.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %]
7
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
8
<title>
8
<title>
9
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
9
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt (-4 / +4 lines)
Lines 4-14 Link Here
4
[% USE Branches %]
4
[% USE Branches %]
5
[% USE Categories %]
5
[% USE Categories %]
6
[% USE Price %]
6
[% USE Price %]
7
[% USE KohaNews %]
7
[% USE AdditionalContents %]
8
[% PROCESS 'i18n.inc' %]
8
[% PROCESS 'i18n.inc' %]
9
[% SET OpacNavRight = KohaNews.get( location => "OpacNavRight", lang => lang, library => branchcode ) %]
9
[% SET OpacNavRight = AdditionalContents.get( location => "OpacNavRight", lang => lang, library => branchcode ) %]
10
[% SET OpacMainUserBlock = KohaNews.get( location => "OpacMainUserBlock", lang => lang, library => branchcode ) %]
10
[% SET OpacMainUserBlock = AdditionalContents.get( location => "OpacMainUserBlock", lang => lang, library => branchcode ) %]
11
[% SET OpacLoginInstructions = KohaNews.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %]
11
[% SET OpacLoginInstructions = AdditionalContents.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %]
12
[% INCLUDE 'doc-head-open.inc' %]
12
[% INCLUDE 'doc-head-open.inc' %]
13
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
13
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
14
[% INCLUDE 'doc-head-close.inc' %]
14
[% INCLUDE 'doc-head-close.inc' %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt (-2 / +2 lines)
Lines 1-7 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE KohaNews %]
3
[% USE AdditionalContents %]
4
[% SET OpacNavRight = KohaNews.get( location => "OpacNavRight", lang => news_lang, library => branchcode ) %]
4
[% SET OpacNavRight = AdditionalContents.get( location => "OpacNavRight", lang => news_lang, library => branchcode ) %]
5
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
6
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
7
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-2 / +2 lines)
Lines 4-11 Link Here
4
[% USE Branches %]
4
[% USE Branches %]
5
[% USE AuthorisedValues %]
5
[% USE AuthorisedValues %]
6
[% USE KohaDates %]
6
[% USE KohaDates %]
7
[% USE KohaNews %]
7
[% USE AdditionalContents %]
8
[% SET opacsuggestion = KohaNews.get( location => "OpacSuggestioninstructions", lang => lang, library => Branches.GetLoggedInBranchcode ) %]
8
[% SET opacsuggestion = AdditionalContents.get( location => "OpacSuggestioninstructions", lang => lang, library => Branches.GetLoggedInBranchcode ) %]
9
[% INCLUDE 'doc-head-open.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
10
<title>[% IF ( op_add ) %]Enter a new purchase suggestion[% END %]
10
<title>[% IF ( op_add ) %]Enter a new purchase suggestion[% END %]
11
[% IF ( op_else ) %]Purchase Suggestions[% END %] &rsaquo;
11
[% IF ( op_else ) %]Purchase Suggestions[% END %] &rsaquo;
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sci/sci-main.tt (-1 / +1 lines)
Lines 3-9 Link Here
3
[%# Includes %]
3
[%# Includes %]
4
[% USE Koha %]
4
[% USE Koha %]
5
[% USE KohaDates %]
5
[% USE KohaDates %]
6
[% USE KohaNews %]
6
[% USE AdditionalContents %]
7
[%# Helper template functions %]
7
[%# Helper template functions %]
8
[% BLOCK error_message %]
8
[% BLOCK error_message %]
9
    [% IF messages.BadBarcode %]
9
    [% IF messages.BadBarcode %]
(-)a/mainpage.pl (-4 / +8 lines)
Lines 25-31 use C4::Output; Link Here
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Koha;
26
use C4::Koha;
27
use C4::Tags qw/get_count_by_tag_status/;
27
use C4::Tags qw/get_count_by_tag_status/;
28
use Koha::News;
28
use Koha::AdditionalContents;
29
use Koha::Patron::Modifications;
29
use Koha::Patron::Modifications;
30
use Koha::Patron::Discharge;
30
use Koha::Patron::Discharge;
31
use Koha::Reviews;
31
use Koha::Reviews;
Lines 49-58 my $homebranch; Link Here
49
if (C4::Context->userenv) {
49
if (C4::Context->userenv) {
50
    $homebranch = C4::Context->userenv->{'branch'};
50
    $homebranch = C4::Context->userenv->{'branch'};
51
}
51
}
52
my $koha_news = Koha::News->search_for_display({
52
my $koha_news = Koha::AdditionalContents->search_for_display(
53
        location => 'koha',
53
    {
54
        category   => 'news',
55
        location   => [ 'staff_only', 'staff_and_opac' ],
56
        lang       => $template->lang,
54
        library_id => $homebranch
57
        library_id => $homebranch
55
    });
58
    }
59
);
56
60
57
$template->param(
61
$template->param(
58
    koha_news   => $koha_news,
62
    koha_news   => $koha_news,
(-)a/opac/opac-main.pl (-6 / +9 lines)
Lines 28-34 use C4::Members; Link Here
28
use C4::Overdues;
28
use C4::Overdues;
29
use Koha::Checkouts;
29
use Koha::Checkouts;
30
use Koha::Holds;
30
use Koha::Holds;
31
use Koha::News;
31
use Koha::AdditionalContents;
32
use Koha::Patron::Messages;
32
use Koha::Patron::Messages;
33
33
34
my $input = CGI->new;
34
my $input = CGI->new;
Lines 63-80 my $news_id = $input->param('news_id'); Link Here
63
my $koha_news;
63
my $koha_news;
64
64
65
if (defined $news_id){
65
if (defined $news_id){
66
    $koha_news = Koha::News->search({ idnew => $news_id, lang => { '!=', 'koha' } }); # get news that is not staff-only news
66
    $koha_news = Koha::AdditionalContents->search({ idnew => $news_id, location => ['opac_only', 'staff_and_opac'] }); # get news that is not staff-only news
67
    if ( $koha_news->count > 0){
67
    if ( $koha_news->count > 0){
68
        $template->param( news_item => $koha_news->next );
68
        $template->param( news_item => $koha_news->next );
69
    } else {
69
    } else {
70
        $template->param( single_news_error => 1 );
70
        $template->param( single_news_error => 1 );
71
    }
71
    }
72
} else {
72
} else {
73
    $koha_news = Koha::News->search_for_display({
73
    $koha_news = Koha::AdditionalContents->search_for_display(
74
            location => 'opac',
74
        {
75
            lang => $template->lang,
75
            category   => 'news',
76
            location   => ['opac_only', 'staff_and_opac'],
77
            lang       => $template->lang,
76
            library_id => $homebranch,
78
            library_id => $homebranch,
77
        });
79
        }
80
    );
78
}
81
}
79
82
80
# For dashboard
83
# For dashboard
(-)a/opac/opac-news-rss.pl (-5 / +8 lines)
Lines 23-29 use CGI; Link Here
23
use C4::Auth;    # get_template_and_user
23
use C4::Auth;    # get_template_and_user
24
use C4::Output;
24
use C4::Output;
25
use C4::Languages qw(getTranslatedLanguages accept_language);
25
use C4::Languages qw(getTranslatedLanguages accept_language);
26
use Koha::News;
26
use Koha::AdditionalContents;
27
27
28
my $input = CGI->new;
28
my $input = CGI->new;
29
my $dbh   = C4::Context->dbh;
29
my $dbh   = C4::Context->dbh;
Lines 43-53 my ($theme, $news_lang, $availablethemes) = C4::Templates::themelanguage(C4::Con Link Here
43
43
44
my $branchcode = $input->param('branchcode');
44
my $branchcode = $input->param('branchcode');
45
45
46
my $koha_news = Koha::News->search_for_display({
46
my $koha_news = Koha::AdditionalContents->search_for_display(
47
        location => 'opac',
47
    {
48
        lang => $news_lang,
48
        category   => 'news',
49
        location   => ['opac_only', 'staff_and_opac'],
50
        lang       => $news_lang,
49
        library_id => $branchcode,
51
        library_id => $branchcode,
50
    });
52
    }
53
);
51
54
52
$template->param( koha_news => $koha_news );
55
$template->param( koha_news => $koha_news );
53
56
(-)a/svc/letters/preview (-1 lines)
Lines 64-70 if ( $content =~ m/[^\n]*<<.*>>[^\n]*/so ) { Link Here
64
        borrowers              => 'borrower',
64
        borrowers              => 'borrower',
65
        branches               => 'branch',
65
        branches               => 'branch',
66
        items                  => 'item',
66
        items                  => 'item',
67
        opac_news              => 'news',
68
        aqorders               => 'orders',
67
        aqorders               => 'orders',
69
        reserves               => 'hold',
68
        reserves               => 'hold',
70
        serial                 => 'serial',
69
        serial                 => 'serial',
(-)a/t/db_dependent/Auth/haspermission.t (-12 / +12 lines)
Lines 141-153 subtest 'hashref top level AND tests' => sub { Link Here
141
    is( $r, 0, 'Borrower2/serials granular * should fail' );
141
    is( $r, 0, 'Borrower2/serials granular * should fail' );
142
142
143
    # Check granular permission with one or more specific subperms
143
    # Check granular permission with one or more specific subperms
144
    $r = haspermission( $borr1->{userid}, { tools => 'edit_news' } );
144
    $r = haspermission( $borr1->{userid}, { tools => 'edit_additional_contents' } );
145
    is( ref($r), 'HASH', 'Superlibrarian/tools edit_news' );
145
    is( ref($r), 'HASH', 'Superlibrarian/tools edit_additional_contents' );
146
    $r = haspermission( $borr2->{userid}, { acquisition => 'budget_manage' } );
146
    $r = haspermission( $borr2->{userid}, { acquisition => 'budget_manage' } );
147
    is( ref($r), 'HASH', 'Borrower2/acq budget_manage' );
147
    is( ref($r), 'HASH', 'Borrower2/acq budget_manage' );
148
    $r = haspermission( $borr2->{userid},
148
    $r = haspermission( $borr2->{userid},
149
        { acquisition => 'budget_manage', tools => 'edit_news' } );
149
        { acquisition => 'budget_manage', tools => 'edit_additional_contents' } );
150
    is( $r, 0, 'Borrower2 (/acquisition|budget_manage AND /tools|edit_news) should fail' );
150
    is( $r, 0, 'Borrower2 (/acquisition|budget_manage AND /tools|edit_additional_contents) should fail' );
151
    $r = haspermission(
151
    $r = haspermission(
152
        $borr2->{userid},
152
        $borr2->{userid},
153
        {
153
        {
Lines 173-190 subtest 'hashref top level AND tests' => sub { Link Here
173
        {
173
        {
174
            tools => {
174
            tools => {
175
                'upload_local_cover_images'  => 1,
175
                'upload_local_cover_images'  => 1,
176
                'edit_news' => 1
176
                'edit_additional_contents' => 1
177
            },
177
            },
178
        }
178
        }
179
    );
179
    );
180
    is( $r, 0, 'Borrower2 (/tools|upload_local_cover_image AND /tools|edit_news) granular' );
180
    is( $r, 0, 'Borrower2 (/tools|upload_local_cover_image AND /tools|edit_additional_contents) granular' );
181
    $r = haspermission(
181
    $r = haspermission(
182
        $borr2->{userid},
182
        $borr2->{userid},
183
        {
183
        {
184
            tools => [ 'upload_local_cover_images', 'edit_news'],
184
            tools => [ 'upload_local_cover_images', 'edit_additional_contents'],
185
        }
185
        }
186
    );
186
    );
187
    is( ref($r), 'HASH', 'Borrower2 (/tools|upload_local_cover_image OR /tools|edit_news) granular' );
187
    is( ref($r), 'HASH', 'Borrower2 (/tools|upload_local_cover_image OR /tools|edit_additional_contents) granular' );
188
};
188
};
189
189
190
subtest 'arrayref top level OR tests' => sub {
190
subtest 'arrayref top level OR tests' => sub {
Lines 219-237 subtest 'arrayref top level OR tests' => sub { Link Here
219
    is( $r, 0, 'Borrower2/serials granular * should fail' );
219
    is( $r, 0, 'Borrower2/serials granular * should fail' );
220
220
221
    # Check granular permission with one or more specific subperms
221
    # Check granular permission with one or more specific subperms
222
    $r = haspermission( $borr1->{userid}, [ { tools => 'edit_news' } ] );
222
    $r = haspermission( $borr1->{userid}, [ { tools => 'edit_additional_contents' } ] );
223
    is( ref($r), 'HASH', 'Superlibrarian/tools edit_news' );
223
    is( ref($r), 'HASH', 'Superlibrarian/tools edit_additional_contents' );
224
    $r =
224
    $r =
225
      haspermission( $borr2->{userid}, [ { acquisition => 'budget_manage' } ] );
225
      haspermission( $borr2->{userid}, [ { acquisition => 'budget_manage' } ] );
226
    is( ref($r), 'HASH', 'Borrower2/acq budget_manage' );
226
    is( ref($r), 'HASH', 'Borrower2/acq budget_manage' );
227
    $r = haspermission( $borr2->{userid},
227
    $r = haspermission( $borr2->{userid},
228
        [ { acquisition => 'budget_manage'}, { tools => 'edit_news' } ] );
228
        [ { acquisition => 'budget_manage'}, { tools => 'edit_additional_contents' } ] );
229
    is( ref($r), 'HASH', 'Borrower2/two granular OR should pass' );
229
    is( ref($r), 'HASH', 'Borrower2/two granular OR should pass' );
230
    $r = haspermission(
230
    $r = haspermission(
231
        $borr2->{userid},
231
        $borr2->{userid},
232
        [
232
        [
233
            { tools => ['upload_local_cover_images'] },
233
            { tools => ['upload_local_cover_images'] },
234
            { tools => ['edit_news'] }
234
            { tools => ['edit_additional_contents'] }
235
        ]
235
        ]
236
    );
236
    );
237
    is( ref($r), 'HASH', 'Borrower2/tools granular OR subperms' );
237
    is( ref($r), 'HASH', 'Borrower2/tools granular OR subperms' );
(-)a/t/db_dependent/Koha/News.t (-67 / +44 lines)
Lines 22-28 use Modern::Perl; Link Here
22
use Test::More tests => 5;
22
use Test::More tests => 5;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use Koha::News;
25
use Koha::AdditionalContents;
26
use Koha::Database;
26
use Koha::Database;
27
use Koha::DateUtils;
27
use Koha::DateUtils;
28
28
Lines 31-64 use t::lib::TestBuilder; Link Here
31
my $schema = Koha::Database->new->schema;
31
my $schema = Koha::Database->new->schema;
32
my $builder = t::lib::TestBuilder->new;
32
my $builder = t::lib::TestBuilder->new;
33
33
34
subtest 'Koha::News basic test' => sub {
34
subtest 'Koha::AdditionalContents basic test' => sub {
35
35
36
    plan tests => 5;
36
    plan tests => 5;
37
37
38
    $schema->storage->txn_begin;
38
    $schema->storage->txn_begin;
39
39
40
    my $library = $builder->build({ source => 'Branch'});
40
    my $library = $builder->build({ source => 'Branch'});
41
    my $nb_of_news = Koha::News->search->count;
41
    my $nb_of_news = Koha::AdditionalContents->search->count;
42
    my $new_news_item_1 = Koha::NewsItem->new({
42
    my $new_news_item_1 = Koha::AdditionalContent->new({
43
        branchcode => $library->{branchcode},
43
        branchcode => $library->{branchcode},
44
        title => 'a news',
44
        title => 'a news',
45
        content => 'content for news 1',
45
        content => 'content for news 1',
46
    })->store;
46
    })->store;
47
    my $new_news_item_2 = Koha::NewsItem->new({
47
    my $new_news_item_2 = Koha::AdditionalContent->new({
48
        branchcode => $library->{branchcode},
48
        branchcode => $library->{branchcode},
49
        title => 'another news',
49
        title => 'another news',
50
        content => 'content for news 2',
50
        content => 'content for news 2',
51
    })->store;
51
    })->store;
52
52
53
    like( $new_news_item_1->idnew, qr|^\d+$|, 'Adding a new news_item should have set the idnew');
53
    like( $new_news_item_1->idnew, qr|^\d+$|, 'Adding a new news_item should have set the idnew');
54
    is( Koha::News->search->count, $nb_of_news + 2, 'The 2 news should have been added' );
54
    is( Koha::AdditionalContents->search->count, $nb_of_news + 2, 'The 2 news should have been added' );
55
55
56
    my $retrieved_news_item_1 = Koha::News->find( $new_news_item_1->idnew );
56
    my $retrieved_news_item_1 = Koha::AdditionalContents->find( $new_news_item_1->idnew );
57
    is( $retrieved_news_item_1->title, $new_news_item_1->title, 'Find a news_item by id should return the correct news_item' );
57
    is( $retrieved_news_item_1->title, $new_news_item_1->title, 'Find a news_item by id should return the correct news_item' );
58
    is( $retrieved_news_item_1->content, $new_news_item_1->content, 'The content method return the content of the news');
58
    is( $retrieved_news_item_1->content, $new_news_item_1->content, 'The content method return the content of the news');
59
59
60
    $retrieved_news_item_1->delete;
60
    $retrieved_news_item_1->delete;
61
    is( Koha::News->search->count, $nb_of_news + 1, 'Delete should have deleted the news_item' );
61
    is( Koha::AdditionalContents->search->count, $nb_of_news + 1, 'Delete should have deleted the news_item' );
62
62
63
    $schema->storage->txn_rollback;
63
    $schema->storage->txn_rollback;
64
};
64
};
Lines 73-91 subtest '->is_expired' => sub { Link Here
73
    my $yesterday = dt_from_string->add( days => -1 );
73
    my $yesterday = dt_from_string->add( days => -1 );
74
    my $tomorrow = dt_from_string->add( days => 1 );
74
    my $tomorrow = dt_from_string->add( days => 1 );
75
    my $new_today = $builder->build_object({
75
    my $new_today = $builder->build_object({
76
        class => 'Koha::News',
76
        class => 'Koha::AdditionalContents',
77
        value => {
77
        value => {
78
            expirationdate => $today,
78
            expirationdate => $today,
79
        }
79
        }
80
    });
80
    });
81
    my $new_expired = $builder->build_object({
81
    my $new_expired = $builder->build_object({
82
        class => 'Koha::News',
82
        class => 'Koha::AdditionalContents',
83
        value => {
83
        value => {
84
            expirationdate => $yesterday,
84
            expirationdate => $yesterday,
85
        }
85
        }
86
    });
86
    });
87
    my $new_not_expired = $builder->build_object({
87
    my $new_not_expired = $builder->build_object({
88
        class => 'Koha::News',
88
        class => 'Koha::AdditionalContents',
89
        value => {
89
        value => {
90
            expirationdate => $tomorrow,
90
            expirationdate => $tomorrow,
91
        }
91
        }
Lines 107-119 subtest '->library' => sub { Link Here
107
    my $library = $builder->build_object({ class => 'Koha::Libraries' });
107
    my $library = $builder->build_object({ class => 'Koha::Libraries' });
108
108
109
    my $new_with_library = $builder->build_object({
109
    my $new_with_library = $builder->build_object({
110
        class => 'Koha::News',
110
        class => 'Koha::AdditionalContents',
111
        value => {
111
        value => {
112
            branchcode => $library->branchcode
112
            branchcode => $library->branchcode
113
        }
113
        }
114
    });
114
    });
115
    my $new_without_library = $builder->build_object({
115
    my $new_without_library = $builder->build_object({
116
        class => 'Koha::News',
116
        class => 'Koha::AdditionalContents',
117
        value => {
117
        value => {
118
            branchcode => undef
118
            branchcode => undef
119
        }
119
        }
Lines 130-143 subtest '->library' => sub { Link Here
130
subtest '->author' => sub {
130
subtest '->author' => sub {
131
    plan tests => 3;
131
    plan tests => 3;
132
132
133
    my $news_item = $builder->build_object({ class => 'Koha::News' });
133
    my $news_item = $builder->build_object({ class => 'Koha::AdditionalContents' });
134
    my $author = $news_item->author;
134
    my $author = $news_item->author;
135
    is( ref($author), 'Koha::Patron', 'Koha::NewsItem->author returns a Koha::Patron object' );
135
    is( ref($author), 'Koha::Patron', 'Koha::AdditionalContent->author returns a Koha::Patron object' );
136
136
137
    $author->delete;
137
    $author->delete;
138
138
139
    $news_item = Koha::News->find($news_item->idnew);
139
    $news_item = Koha::AdditionalContents->find($news_item->idnew);
140
    is( ref($news_item), 'Koha::NewsItem', 'News are not deleted alongwith the author' );
140
    is( ref($news_item), 'Koha::AdditionalContent', 'News are not deleted alongwith the author' );
141
    is( $news_item->author, undef, '->author returns undef is the author has been deleted' );
141
    is( $news_item->author, undef, '->author returns undef is the author has been deleted' );
142
};
142
};
143
143
Lines 147-153 subtest '->search_for_display' => sub { Link Here
147
147
148
    $schema->storage->txn_begin;
148
    $schema->storage->txn_begin;
149
149
150
    Koha::News->search->delete;
150
    Koha::AdditionalContents->search->delete;
151
151
152
    my $today = dt_from_string;
152
    my $today = dt_from_string;
153
    my $yesterday = dt_from_string->add( days => -1 );
153
    my $yesterday = dt_from_string->add( days => -1 );
Lines 156-258 subtest '->search_for_display' => sub { Link Here
156
    my $library2 = $builder->build_object({ class => 'Koha::Libraries' });
156
    my $library2 = $builder->build_object({ class => 'Koha::Libraries' });
157
157
158
    my $new_expired = $builder->build_object({
158
    my $new_expired = $builder->build_object({
159
        class => 'Koha::News',
159
        class => 'Koha::AdditionalContents',
160
        value => {
160
        value => {
161
            expirationdate => $yesterday,
161
            expirationdate => $yesterday,
162
            published_on => $today,
162
            published_on => $today,
163
            lang => '',
163
            category => 'news',
164
            location => 'staff_and_opac',
165
            lang => 'default',
164
            branchcode => undef,
166
            branchcode => undef,
165
            number => 1,
167
            number => 1,
166
        }
168
        }
167
    });
169
    });
168
    my $new_not_expired = $builder->build_object({
170
    my $new_not_expired = $builder->build_object({
169
        class => 'Koha::News',
171
        class => 'Koha::AdditionalContents',
170
        value => {
172
        value => {
171
            expirationdate => $tomorrow,
173
            expirationdate => $tomorrow,
172
            published_on => $today,
174
            published_on => $today,
173
            lang => '',
175
            category => 'news',
176
            location => 'staff_and_opac',
177
            lang => 'default',
174
            branchcode => undef,
178
            branchcode => undef,
175
            number => 2,
179
            number => 2,
176
        }
180
        }
177
    });
181
    });
178
    my $new_not_active = $builder->build_object({
182
    my $new_not_active = $builder->build_object({
179
        class => 'Koha::News',
183
        class => 'Koha::AdditionalContents',
180
        value => {
184
        value => {
181
            expirationdate => $tomorrow,
185
            expirationdate => $tomorrow,
182
            published_on => $tomorrow,
186
            published_on => $tomorrow,
183
            lang => '',
187
            category => 'news',
188
            location => 'staff_and_opac',
189
            lang => 'default',
184
            branchcode => undef,
190
            branchcode => undef,
185
            number => 3,
191
            number => 3,
186
        }
192
        }
187
    });
193
    });
188
    my $new_slip= $builder->build_object({
194
    my $new_slip= $builder->build_object({
189
        class => 'Koha::News',
195
        class => 'Koha::AdditionalContents',
190
        value => {
196
        value => {
191
            expirationdate => $tomorrow,
197
            expirationdate => $tomorrow,
192
            published_on => $today,
198
            published_on => $today,
193
            lang => 'slip',
199
            category => 'news',
200
            location => 'staff_only',
201
            lang => 'default',
194
            branchcode => $library1->branchcode,
202
            branchcode => $library1->branchcode,
195
            number => 4,
203
            number => 4,
196
        }
204
        }
197
    });
205
    });
198
    my $new_intra = $builder->build_object({
206
    my $new_intra = $builder->build_object({
199
        class => 'Koha::News',
207
        class => 'Koha::AdditionalContents',
200
        value => {
208
        value => {
201
            expirationdate => $tomorrow,
209
            expirationdate => $tomorrow,
202
            published_on => $today,
210
            published_on => $today,
203
            lang => 'koha',
211
            category => 'news',
212
            location => 'staff_only',
213
            lang => 'default',
204
            branchcode => $library2->branchcode,
214
            branchcode => $library2->branchcode,
205
            number => 5,
215
            number => 5,
206
        }
216
        }
207
    });
217
    });
208
    my $new_intra2 = $builder->build_object({
218
    my $new_intra2 = $builder->build_object({
209
        class => 'Koha::News',
219
        class => 'Koha::AdditionalContents',
210
        value => {
220
        value => {
211
            expirationdate => $tomorrow,
221
            expirationdate => $tomorrow,
212
            published_on => $today,
222
            published_on => $today,
213
            lang => 'koha',
223
            category => 'news',
224
            location => 'staff_only',
225
            lang => 'default',
214
            branchcode => undef,
226
            branchcode => undef,
215
            number => 5,
227
            number => 5,
216
        }
228
        }
217
    });
229
    });
218
    my $news = Koha::News->search_for_display;
230
    my $news = Koha::AdditionalContents->search_for_display;
219
231
220
    is($news->count, 4, 'Active and not expired news');
232
    # FIXME Rewrite tests here
221
    is($news->next->number, 2, 'News items are returned in correct order');
222
223
    $news = Koha::News->search_for_display({ location => 'slip'});
224
    is($news->count, 2, 'Slip and "all" locations returned');
225
226
    $news = Koha::News->search_for_display({ location => 'koha'});
227
    is($news->count, 3, 'Intranet and "all"');
228
229
    $new_not_expired->lang('OpacNavRight_en')->store;
230
    $news = Koha::News->search_for_display({ location => 'OpacNavRight', lang => 'en'});
231
    is($news->count, 1, 'OpacNavRight');
232
    is($news->next->idnew, $new_not_expired->idnew, 'Returned the right new item');
233
234
    $new_intra->lang('')->store;
235
    $news = Koha::News->search_for_display({ location => 'opac', lang => 'en'});
236
    is($news->count, 1, 'Only opac news are returned');
237
    $new_not_expired->lang('en')->store;
238
    $news = Koha::News->search_for_display({ location => 'opac', lang => 'en'});
239
    is($news->count, 2, 'Opac en and all is returned');
240
241
    $news = Koha::News->search_for_display({ library_id => $library1->branchcode });
242
    is($news->count, 3, 'Filtering by library returns right number of news items');
243
244
    $news = Koha::News->search_for_display({ library_id => $library2->branchcode});
245
    is($news->count, 3, 'Filtering by library returns right number of news items');
246
247
    $new_intra->branchcode($library1->branchcode)->store;
248
    $news = Koha::News->search_for_display({ library_id => $library2->branchcode});
249
    is($news->count, 2, 'Filtering by library returns right number of news items');
250
251
    $news = Koha::News->search_for_display({ location => 'NonExistantType', lang => 'en'});
252
    is($news->count, 0, 'Non-existant location is searched, but should not find any item');
253
254
    throws_ok { Koha::News->search_for_display({ location => 'opac'}) } 'Koha::Exceptions::BadParameter',
255
        'Exception raised when location is opac and no language given';
256
233
257
    $schema->storage->txn_rollback;
234
    $schema->storage->txn_rollback;
258
};
235
};
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-13 / +24 lines)
Lines 39-45 use Koha::Biblio; Link Here
39
use Koha::Biblioitem;
39
use Koha::Biblioitem;
40
use Koha::Item;
40
use Koha::Item;
41
use Koha::Hold;
41
use Koha::Hold;
42
use Koha::NewsItem;
42
use Koha::AdditionalContent;
43
use Koha::Serial;
43
use Koha::Serial;
44
use Koha::Subscription;
44
use Koha::Subscription;
45
use Koha::Suggestion;
45
use Koha::Suggestion;
Lines 78-84 my $hold = $builder->build_object( Link Here
78
78
79
my $news = $builder->build_object(
79
my $news = $builder->build_object(
80
    {
80
    {
81
        class => 'Koha::News',
81
        class => 'Koha::AdditionalContents',
82
        value => { title => 'a news title', content => 'a news content' }
82
        value => { title => 'a news title', content => 'a news content' }
83
    }
83
    }
84
);
84
);
Lines 178-190 $prepared_letter = GetPreparedLetter( Link Here
178
is( $prepared_letter->{content}, $item->id(), 'Item object used correctly for content' );
178
is( $prepared_letter->{content}, $item->id(), 'Item object used correctly for content' );
179
is( $prepared_letter->{title}, $item->barcode, 'Item object used correctly for title' );
179
is( $prepared_letter->{title}, $item->barcode, 'Item object used correctly for title' );
180
180
181
$sth->execute( "TEST_NEWS", "[% news.id %]", "[% news.id %]" );
181
$sth->execute( "TEST_NEWS", "[% additional_content.id %]", "[% additional_content.id %]" );
182
$prepared_letter = GetPreparedLetter(
182
$prepared_letter = GetPreparedLetter(
183
    (
183
    (
184
        module      => 'test',
184
        module      => 'test',
185
        letter_code => 'TEST_NEWS',
185
        letter_code => 'TEST_NEWS',
186
        tables      => {
186
        tables      => {
187
            opac_news => $news->id()
187
            additional_contents => $news->id()
188
        },
188
        },
189
    )
189
    )
190
);
190
);
Lines 621-628 EOF Link Here
621
        is( $tt_letter_for_item2->{content}, $letter_for_item2->{content}, );
621
        is( $tt_letter_for_item2->{content}, $letter_for_item2->{content}, );
622
    };
622
    };
623
623
624
    subtest 'ISSUESLIP|checkedout|repeat' => sub {
624
    subtest 'ISSUESLIP|checkedout|repeat|news' => sub {
625
        plan tests => 2;
625
        plan tests => 3;
626
626
627
        my $code = 'ISSUESLIP';
627
        my $code = 'ISSUESLIP';
628
        my $now = dt_from_string;
628
        my $now = dt_from_string;
Lines 630-637 EOF Link Here
630
630
631
        my $branchcode = $library->{branchcode};
631
        my $branchcode = $library->{branchcode};
632
632
633
        Koha::News->delete;
633
        Koha::AdditionalContents->delete;
634
        my $news_item = Koha::NewsItem->new({ branchcode => $branchcode, title => "A wonderful news", content => "This is the wonderful news." })->store;
634
        my $news_item = Koha::AdditionalContent->new(
635
            {
636
                branchcode      => $branchcode,
637
                title           => "A wonderful news",
638
                content         => "This is the wonderful news.",
639
                lang            => "slip",
640
                expiration_date => undef,
641
                published_on    => $one_minute_ago
642
            }
643
        )->store;
635
644
636
        # historic syntax
645
        # historic syntax
637
        my $template = <<EOF;
646
        my $template = <<EOF;
Lines 664-672 Date due: <<issues.date_due | dateonly>><br /> Link Here
664
<h4 style="text-align: center; font-style:italic;">News</h4>
673
<h4 style="text-align: center; font-style:italic;">News</h4>
665
<news>
674
<news>
666
<div class="newsitem">
675
<div class="newsitem">
667
<h5 style="margin-bottom: 1px; margin-top: 1px"><b><<opac_news.title>></b></h5>
676
<h5 style="margin-bottom: 1px; margin-top: 1px"><b><<additional_contents.title>></b></h5>
668
<p style="margin-bottom: 1px; margin-top: 1px"><<opac_news.content>></p>
677
<p style="margin-bottom: 1px; margin-top: 1px"><<additional_contents.content>></p>
669
<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on <<opac_news.published_on>></p>
678
<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on <<additional_contents.published_on>></p>
670
<hr />
679
<hr />
671
</div>
680
</div>
672
</news>
681
</news>
Lines 722-732 Date due: [% overdue.date_due | \$KohaDates %]<br /> Link Here
722
<hr>
731
<hr>
723
732
724
<h4 style="text-align: center; font-style:italic;">News</h4>
733
<h4 style="text-align: center; font-style:italic;">News</h4>
725
[% FOREACH n IN news %]
734
[% FOREACH n IN additional_contents %]
726
<div class="newsitem">
735
<div class="newsitem">
727
<h5 style="margin-bottom: 1px; margin-top: 1px"><b>[% n.title %]</b></h5>
736
<h5 style="margin-bottom: 1px; margin-top: 1px"><b>[% n.title %]</b></h5>
728
<p style="margin-bottom: 1px; margin-top: 1px">[% n.content %]</p>
737
<p style="margin-bottom: 1px; margin-top: 1px">[% n.content %]</p>
729
<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on [% n.timestamp | \$KohaDates %]</p>
738
<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on [% n.published_on | \$KohaDates %]</p>
730
<hr />
739
<hr />
731
</div>
740
</div>
732
[% END %]
741
[% END %]
Lines 746-751 EOF Link Here
746
        # There is too many line breaks generated by the historic syntax
755
        # There is too many line breaks generated by the historic syntax
747
        $second_slip->{content} =~ s|</p>\n\n\n<p>|</p>\n\n<p>|s;
756
        $second_slip->{content} =~ s|</p>\n\n\n<p>|</p>\n\n<p>|s;
748
757
758
        my $news_item_title = $news_item->title;
759
        like( $first_slip->{content}, qr{$news_item_title} );
749
        is( $first_tt_slip->{content}, $first_slip->{content}, );
760
        is( $first_tt_slip->{content}, $first_slip->{content}, );
750
        is( $second_tt_slip->{content}, $second_slip->{content}, );
761
        is( $second_tt_slip->{content}, $second_slip->{content}, );
751
762
(-)a/tools/additional-contents.pl (+229 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Script to manage the opac news.
6
# written 11/04
7
# Casta�eda, Carlos Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina
8
# Modified to include news to KOHA intranet - tgarip@neu.edu.tr NEU library -Cyprus
9
# Copyright 2000-2002 Katipo Communications
10
# Copyright (C) 2013    Mark Tompsett
11
#
12
# Koha is free software; you can redistribute it and/or modify it
13
# under the terms of the GNU General Public License as published by
14
# the Free Software Foundation; either version 3 of the License, or
15
# (at your option) any later version.
16
#
17
# Koha is distributed in the hope that it will be useful, but
18
# WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU General Public License for more details.
21
#
22
# You should have received a copy of the GNU General Public License
23
# along with Koha; if not, see <http://www.gnu.org/licenses>.
24
25
use Modern::Perl;
26
use CGI qw ( -utf8 );
27
use C4::Auth;
28
use C4::Koha;
29
use C4::Context;
30
use C4::Output;
31
use C4::Languages qw(getTranslatedLanguages);
32
use Koha::DateUtils;
33
use Koha::AdditionalContents;
34
35
my $cgi = CGI->new;
36
37
my $op             = $cgi->param('op') || 'list';
38
my $id             = $cgi->param('id');
39
my $category       = $cgi->param('category') || 'news';
40
my $wysiwyg;
41
if( $cgi->param('editmode') ){
42
    $wysiwyg = $cgi->param('editmode') eq "wysiwyg" ? 1 : 0;
43
} else {
44
    $wysiwyg = C4::Context->preference("AdditionalContentsEditor") eq "tinymce" ? 1 : 0;
45
}
46
47
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
48
    {
49
        template_name   => "tools/additional-contents.tt",
50
        query           => $cgi,
51
        type            => "intranet",
52
        flagsrequired   => { tools => 'edit_additional_contents' },
53
    }
54
);
55
56
my @messages;
57
if ( $op eq 'add_form' ) {
58
59
    my $additional_content = Koha::AdditionalContents->find($id);
60
    my $translated_contents;
61
    if ( $additional_content ) {
62
        $translated_contents = {
63
            map { $_->lang => $_ } Koha::AdditionalContents->search(
64
                {
65
                    category   => $additional_content->category,
66
                    code       => $additional_content->code,
67
                    location   => $additional_content->location,
68
                    branchcode => $additional_content->branchcode,
69
                }
70
            )
71
        };
72
    }
73
    $template->param(
74
        additional_content => $additional_content,
75
        translated_contents => $translated_contents,
76
    );
77
}
78
elsif ( $op eq 'add_validate' ) {
79
    my $location   = $cgi->param('location');
80
    my $code       = $cgi->param('code');
81
    my $branchcode = $cgi->param('branchcode') || undef;
82
83
    my @title      = $cgi->multi_param('title');
84
    my @content    = $cgi->multi_param('content');
85
    my @lang       = $cgi->multi_param('lang');
86
87
    my $expirationdate;
88
    if ( $cgi->param('expirationdate') ) {
89
        $expirationdate = output_pref(
90
            {
91
                dt => dt_from_string( scalar $cgi->param('expirationdate') ),
92
                dateformat => 'iso',
93
                dateonly   => 1
94
            }
95
        );
96
    }
97
    my $published_on = output_pref(
98
        {
99
            dt         => dt_from_string( scalar $cgi->param('published_on') ),
100
            dateformat => 'iso',
101
            dateonly   => 1
102
        }
103
    );
104
    my $number = $cgi->param('number');
105
106
    my $success = 1;
107
    for my $lang ( @lang ) {
108
        my $title = shift @title;
109
        my $content = shift @content;
110
        my $additional_content = Koha::AdditionalContents->find(
111
            {
112
                category   => $category,
113
                code       => $code,
114
                branchcode => $branchcode,
115
                lang       => $lang,
116
            }
117
        );
118
        # Delete if title or content is empty
119
        unless ( $title and $content ) {
120
            $additional_content->delete if $additional_content;
121
            next;
122
        } elsif ( $additional_content ) {
123
            eval {
124
                $additional_content->update(
125
                    {
126
                        category       => $category,
127
                        code           => $code,
128
                        location       => $location,
129
                        branchcode     => $branchcode,
130
                        title          => $title,
131
                        content        => $content,
132
                        lang           => $lang,
133
                        expirationdate => $expirationdate,
134
                        published_on   => $published_on,
135
                        number         => $number,
136
                        borrowernumber => $borrowernumber,
137
                    }
138
                );
139
            };
140
            if ($@) {
141
                $success = 0;
142
                push @messages, { type => 'error', code => 'error_on_update' };
143
                last;
144
            }
145
        }
146
        else {
147
            my $additional_content = Koha::AdditionalContent->new(
148
                {
149
                    category       => $category,
150
                    code           => $code,
151
                    location       => $location,
152
                    branchcode     => $branchcode,
153
                    title          => $title,
154
                    content        => $content,
155
                    lang           => $lang,
156
                    expirationdate => $expirationdate,
157
                    published_on   => $published_on,
158
                    number         => $number,
159
                    borrowernumber => $borrowernumber,
160
                }
161
            )->store;
162
            eval { $additional_content->store; };
163
            if ($@) {
164
                $success = 0;
165
                push @messages, { type => 'error', code => 'error_on_insert' };
166
                last;
167
            }
168
        }
169
170
    }
171
    $op = 'list';
172
}
173
elsif ( $op eq 'delete_confirmed' ) {
174
    my @ids = $cgi->multi_param('ids');
175
    my $deleted =
176
      eval { Koha::AdditionalContents->search( { idnew => @ids } )->delete; };
177
178
    if ( $@ or not $deleted ) {
179
        push @messages, { type => 'error', code => 'error_on_delete' };
180
    }
181
    else {
182
        push @messages, { type => 'message', code => 'success_on_delete' };
183
    }
184
185
    $op = 'list';
186
}
187
188
if ( $op eq 'list' ) {
189
    my $additional_contents = Koha::AdditionalContents->search(
190
        { category => $category, lang => 'default' },
191
        { order_by => { -desc => 'published_on' } }
192
    );
193
    $template->param( additional_contents => $additional_contents );
194
}
195
196
my $translated_languages = C4::Languages::getTranslatedLanguages;
197
my @languages;
198
for my $language (@$translated_languages) {
199
    for my $sublanguage ( @{ $language->{sublanguages_loop} } ) {
200
        if ( $language->{plural} ) {
201
            push @languages,
202
              {
203
                lang        => $sublanguage->{rfc4646_subtag},
204
                description => $sublanguage->{native_description} . ' '
205
                  . $sublanguage->{region_description} . ' ('
206
                  . $sublanguage->{rfc4646_subtag} . ')',
207
              };
208
        }
209
        else {
210
            push @languages,
211
              {
212
                lang        => $sublanguage->{rfc4646_subtag},
213
                description => $sublanguage->{native_description} . ' ('
214
                  . $sublanguage->{rfc4646_subtag} . ')',
215
              };
216
        }
217
    }
218
}
219
unshift @languages, {lang => 'default'} if @languages;
220
221
$template->param(
222
    op        => $op,
223
    category  => $category,
224
    wysiwyg   => $wysiwyg,
225
    languages => \@languages,
226
);
227
228
229
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/tools/koha-news.pl (-162 lines)
Lines 1-162 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Script to manage the opac news.
6
# written 11/04
7
# Casta�eda, Carlos Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina
8
# Modified to include news to KOHA intranet - tgarip@neu.edu.tr NEU library -Cyprus
9
# Copyright 2000-2002 Katipo Communications
10
# Copyright (C) 2013    Mark Tompsett
11
#
12
# Koha is free software; you can redistribute it and/or modify it
13
# under the terms of the GNU General Public License as published by
14
# the Free Software Foundation; either version 3 of the License, or
15
# (at your option) any later version.
16
#
17
# Koha is distributed in the hope that it will be useful, but
18
# WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU General Public License for more details.
21
#
22
# You should have received a copy of the GNU General Public License
23
# along with Koha; if not, see <http://www.gnu.org/licenses>.
24
25
use Modern::Perl;
26
use CGI qw ( -utf8 );
27
use C4::Auth;
28
use C4::Koha;
29
use C4::Context;
30
use C4::Output;
31
use C4::Languages qw(getTranslatedLanguages);
32
use Date::Calc qw/Date_to_Days Today/;
33
use Koha::DateUtils;
34
use Koha::News;
35
36
my $cgi = CGI->new;
37
38
my $id             = $cgi->param('id');
39
my $title          = $cgi->param('title');
40
my $content        = $cgi->param('content');
41
my $expirationdate;
42
if ( $cgi->param('expirationdate') ) {
43
    $expirationdate = output_pref({ dt => dt_from_string( scalar $cgi->param('expirationdate') ), dateformat => 'iso', dateonly => 1 });
44
}
45
my $published_on= output_pref({ dt => dt_from_string( scalar $cgi->param('published_on') ), dateformat => 'iso', dateonly => 1 });
46
my $number         = $cgi->param('number');
47
my $lang           = $cgi->param('lang');
48
my $branchcode     = $cgi->param('branch');
49
my $error_message  = $cgi->param('error_message');
50
my $wysiwyg;
51
if( $cgi->param('editmode') ){
52
    $wysiwyg = $cgi->param('editmode') eq "wysiwyg" ? 1 : 0;
53
} else {
54
    $wysiwyg = C4::Context->preference("NewsToolEditor") eq "tinymce" ? 1 : 0;
55
}
56
57
# Foreign Key constraints work with NULL, not ''
58
# NULL = All branches.
59
$branchcode = undef if (defined($branchcode) && $branchcode eq '');
60
61
my $new_detail = Koha::News->find( $id );
62
63
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
64
    {
65
        template_name   => "tools/koha-news.tt",
66
        query           => $cgi,
67
        type            => "intranet",
68
        flagsrequired   => { tools => 'edit_news' },
69
    }
70
);
71
72
# Pass error message if there is one.
73
$template->param( error_message => $error_message ) if $error_message;
74
75
# get lang list
76
my @lang_list;
77
my $tlangs = getTranslatedLanguages() ;
78
79
foreach my $language ( @$tlangs ) {
80
    foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) {
81
        push @lang_list,
82
        {
83
            language => $sublanguage->{'rfc4646_subtag'},
84
            selected => ( $new_detail && $new_detail->lang eq $sublanguage->{'rfc4646_subtag'} ? 1 : 0 ),
85
        };
86
    }
87
}
88
89
$template->param( lang_list   => \@lang_list,
90
                  branchcode  => $branchcode );
91
92
my $op = $cgi->param('op') // '';
93
94
if ( $op eq 'add_form' ) {
95
    $template->param( add_form => 1 );
96
    if ($id) {
97
        if($new_detail->lang eq "slip"){ $template->param( slip => 1); }
98
        $template->param( 
99
            op => 'edit',
100
            id => $new_detail->idnew
101
        );
102
        $template->{VARS}->{'new_detail'} = $new_detail;
103
    }
104
    else {
105
        $template->param( op => 'add' );
106
    }
107
}
108
elsif ( $op eq 'add' ) {
109
    if ($title) {
110
        my $new = Koha::NewsItem->new({
111
            title          => $title,
112
            content        => $content,
113
            lang           => $lang,
114
            expirationdate => $expirationdate,
115
            published_on   => $published_on,
116
            number         => $number,
117
            branchcode     => $branchcode,
118
            borrowernumber => $borrowernumber,
119
        })->store;
120
        print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
121
    }
122
    else {
123
        print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl?error_message=title_missing");
124
    }
125
}
126
elsif ( $op eq 'edit' ) {
127
    my $news_item = Koha::News->find( $id );
128
    if ( $news_item ) {
129
        $news_item->set({
130
            title          => $title,
131
            content        => $content,
132
            lang           => $lang,
133
            expirationdate => $expirationdate,
134
            published_on=> $published_on,
135
            number         => $number,
136
            branchcode     => $branchcode,
137
        })->store;
138
    }
139
    print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
140
}
141
elsif ( $op eq 'del' ) {
142
    my @ids = $cgi->multi_param('ids');
143
    Koha::News->search({ idnew => @ids })->delete;
144
    print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl");
145
}
146
147
else {
148
    my $params;
149
    $params->{lang} = $lang if $lang;
150
    my $opac_news = Koha::News->search(
151
        $params,
152
        {
153
            order_by => { -desc =>  'published_on' },
154
        }
155
    );
156
    $template->param( opac_news => $opac_news );
157
}
158
$template->param(
159
    lang => $lang,
160
    wysiwyg => $wysiwyg,
161
);
162
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/tools/letter.pl (-2 / +1 lines)
Lines 249-255 sub add_form { Link Here
249
            {value => 'items.fine',    text => 'items.fine'},
249
            {value => 'items.fine',    text => 'items.fine'},
250
            add_fields('borrowers');
250
            add_fields('borrowers');
251
        if ($module eq 'circulation') {
251
        if ($module eq 'circulation') {
252
            push @{$field_selection}, add_fields('opac_news');
252
            push @{$field_selection}, add_fields('additional_contents');
253
253
254
        }
254
        }
255
255
256
- 

Return to bug 24387