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

(-)a/installer/data/mysql/atomicupdate/bug_17960.perl (+18 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
4
    if ( column_exists('opac_news', 'new' ) ) {
5
        $dbh->do(q|ALTER TABLE opac_news CHANGE COLUMN new content text NOT NULL|);
6
    }
7
8
    my ( $used_in_templates ) = $dbh->selectrow_array(q|
9
        SELECT COUNT(*) FROM letter WHERE content LIKE "%<<opac_news.new>>%";
10
    |);
11
    if ( $used_in_templates ) {
12
        print "WARNING - It seems that you are using the opac_news.new column in your notice templates\n";
13
        print "Since it has now been renamed with opac_news.content, you should update them.\n";
14
    }
15
16
    SetVersion( $DBversion );
17
    print "Upgrade to $DBversion done (Bug 17960 - Rename opac_news with opac_news.content)\n";
18
}
(-)a/installer/data/mysql/kohastructure.sql (-1 / +1 lines)
Lines 1834-1840 CREATE TABLE `opac_news` ( -- data from the news tool Link Here
1834
  `idnew` int(10) unsigned NOT NULL auto_increment, -- unique identifier for the news article
1834
  `idnew` int(10) unsigned NOT NULL auto_increment, -- unique identifier for the news article
1835
  `branchcode` varchar(10) default NULL, -- branch code users to create branch specific news, NULL is every branch.
1835
  `branchcode` varchar(10) default NULL, -- branch code users to create branch specific news, NULL is every branch.
1836
  `title` varchar(250) NOT NULL default '', -- title of the news article
1836
  `title` varchar(250) NOT NULL default '', -- title of the news article
1837
  `new` text NOT NULL, -- the body of your news article
1837
  `content` text NOT NULL, -- the body of your news article
1838
  `lang` varchar(25) NOT NULL default '', -- location for the article (koha is the staff client, slip is the circulation receipt and language codes are for the opac)
1838
  `lang` varchar(25) NOT NULL default '', -- location for the article (koha is the staff client, slip is the circulation receipt and language codes are for the opac)
1839
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, -- pulibcation date and time
1839
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, -- pulibcation date and time
1840
  `expirationdate` date default NULL, -- date the article is set to expire or no longer be visible
1840
  `expirationdate` date default NULL, -- date the article is set to expire or no longer be visible
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt (-3 / +3 lines)
Lines 161-168 Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div> Link Here
161
                    <input id="number" size="3" name="number" type="text" />
161
                    <input id="number" size="3" name="number" type="text" />
162
                [% END %]
162
                [% END %]
163
            </li>
163
            </li>
164
            <li><label for="new">News: </label>
164
            <li><label for="content">News: </label>
165
            <textarea name="new" id="new"  cols="75" rows="10">[% new_detail.new %]</textarea>
165
            <textarea name="content" id="content"  cols="75" rows="10">[% new_detail.content %]</textarea>
166
            </li>
166
            </li>
167
            </ol>
167
            </ol>
168
			</fieldset>
168
			</fieldset>
Lines 254-260 Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div> Link Here
254
                            <td>[% opac_new.title %]</td>
254
                            <td>[% opac_new.title %]</td>
255
                            <td>[% opac_new.author_title %] [% opac_new.author_firstname %] [% opac_new.author_surname %]</td>
255
                            <td>[% opac_new.author_title %] [% opac_new.author_firstname %] [% opac_new.author_surname %]</td>
256
                           <td>
256
                           <td>
257
                                [% opac_new.new %]
257
                                [% opac_new.content %]
258
                            </td>
258
                            </td>
259
                            <td class="actions">
259
                            <td class="actions">
260
                                <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;id=[% opac_new.idnew %]" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
260
                                <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;id=[% opac_new.idnew %]" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-news-rss.tt (-1 / +1 lines)
Lines 8-14 Link Here
8
      [% FOREACH newsitem IN koha_news %]
8
      [% FOREACH newsitem IN koha_news %]
9
      <item>
9
      <item>
10
        <title>[% newsitem.title |html %]</title>
10
        <title>[% newsitem.title |html %]</title>
11
        <description>[% newsitem.new |html %]</description>
11
        <description>[% newsitem.content |html %]</description>
12
        <guid>[% OPACBaseURL %]/cgi-bin/koha/opac-main.pl#newsitem[% newsitem.idnew |html %]</guid>
12
        <guid>[% OPACBaseURL %]/cgi-bin/koha/opac-main.pl#newsitem[% newsitem.idnew |html %]</guid>
13
      </item>
13
      </item>
14
      [% END %]
14
      [% END %]
(-)a/t/db_dependent/Koha/News.t (-1 / +1 lines)
Lines 47-53 is( Koha::News->search->count, $nb_of_news + 2, 'The 2 news should have been add Link Here
47
47
48
my $retrieved_news_item_1 = Koha::News->find( $new_news_item_1->idnew );
48
my $retrieved_news_item_1 = Koha::News->find( $new_news_item_1->idnew );
49
is( $retrieved_news_item_1->title, $new_news_item_1->title, 'Find a news_item by id should return the correct news_item' );
49
is( $retrieved_news_item_1->title, $new_news_item_1->title, 'Find a news_item by id should return the correct news_item' );
50
is( $retrieved_news_item_1->new, $new_news_item_1->new, 'This test is failing because ->new is not a valid accessor');
50
is( $retrieved_news_item_1->content, $new_news_item_1->content, 'The content method return the content of the news');
51
51
52
$retrieved_news_item_1->delete;
52
$retrieved_news_item_1->delete;
53
is( Koha::News->search->count, $nb_of_news + 1, 'Delete should have deleted the news_item' );
53
is( Koha::News->search->count, $nb_of_news + 1, 'Delete should have deleted the news_item' );
(-)a/t/db_dependent/NewsChannels.t (-6 / +6 lines)
Lines 72-78 my ( $title1, $new1, $lang1, $expirationdate1, $number1 ) = Link Here
72
  ( 'News Title', '<p>We have some exciting news!</p>', q{}, '2999-12-30', 1 );
72
  ( 'News Title', '<p>We have some exciting news!</p>', q{}, '2999-12-30', 1 );
73
my $href_entry1 = {
73
my $href_entry1 = {
74
    title          => $title1,
74
    title          => $title1,
75
    new            => $new1,
75
    content        => $new1,
76
    lang           => $lang1,
76
    lang           => $lang1,
77
    expirationdate => $expirationdate1,
77
    expirationdate => $expirationdate1,
78
    timestamp      => $timestamp1,
78
    timestamp      => $timestamp1,
Lines 87-93 my ( $title2, $new2, $lang2, $expirationdate2, $number2 ) = Link Here
87
  ( 'News Title2', '<p>We have some exciting news!</p>', q{}, '2999-12-31', 1 );
87
  ( 'News Title2', '<p>We have some exciting news!</p>', q{}, '2999-12-31', 1 );
88
my $href_entry2 = {
88
my $href_entry2 = {
89
    title          => $title2,
89
    title          => $title2,
90
    new            => $new2,
90
    content        => $new2,
91
    lang           => $lang2,
91
    lang           => $lang2,
92
    expirationdate => $expirationdate2,
92
    expirationdate => $expirationdate2,
93
    timestamp      => $timestamp2,
93
    timestamp      => $timestamp2,
Lines 102-108 my ( $title3, $new3, $lang3, $number3 ) = Link Here
102
  ( 'News Title3', '<p>News without expiration date</p>', q{}, 1 );
102
  ( 'News Title3', '<p>News without expiration date</p>', q{}, 1 );
103
my $href_entry3 = {
103
my $href_entry3 = {
104
    title          => $title3,
104
    title          => $title3,
105
    new            => $new3,
105
    content        => $new3,
106
    lang           => $lang3,
106
    lang           => $lang3,
107
    timestamp      => $timestamp3,
107
    timestamp      => $timestamp3,
108
    number         => $number3,
108
    number         => $number3,
Lines 130-136 $rv = upd_opac_new(); # intentionally bad parmeters Link Here
130
is( $rv, 0, 'Correctly failed on no parameter!' );
130
is( $rv, 0, 'Correctly failed on no parameter!' );
131
131
132
$new2                 = '<p>Update! There is no news!</p>';
132
$new2                 = '<p>Update! There is no news!</p>';
133
$href_entry2->{new}   = $new2;
133
$href_entry2->{content}   = $new2;
134
$href_entry2->{idnew} = $idnew2;
134
$href_entry2->{idnew} = $idnew2;
135
$rv                   = upd_opac_new($href_entry2);
135
$rv                   = upd_opac_new($href_entry2);
136
is( $rv, 1, 'Successfully updated second dummy news item!' );
136
is( $rv, 1, 'Successfully updated second dummy news item!' );
Lines 145-151 is_deeply( Link Here
145
    get_opac_new($idnew1),
145
    get_opac_new($idnew1),
146
    {
146
    {
147
        title          => $title1,
147
        title          => $title1,
148
        new            => $new1,
148
        content        => $new1,
149
        lang           => $lang1,
149
        lang           => $lang1,
150
        expirationdate => $expirationdate1,
150
        expirationdate => $expirationdate1,
151
        timestamp      => $timestamp1,
151
        timestamp      => $timestamp1,
Lines 168-174 is_deeply( Link Here
168
    get_opac_new($idnew2),
168
    get_opac_new($idnew2),
169
    {  
169
    {  
170
        title          => $title2,
170
        title          => $title2,
171
        new            => $new2,
171
        content        => $new2,
172
        lang           => $lang2,
172
        lang           => $lang2,
173
        expirationdate => $expirationdate2,
173
        expirationdate => $expirationdate2,
174
        timestamp      => $timestamp2,
174
        timestamp      => $timestamp2,
(-)a/tools/koha-news.pl (-4 / +3 lines)
Lines 38-44 my $cgi = new CGI; Link Here
38
38
39
my $id             = $cgi->param('id');
39
my $id             = $cgi->param('id');
40
my $title          = $cgi->param('title');
40
my $title          = $cgi->param('title');
41
my $new            = $cgi->param('new');
41
my $content        = $cgi->param('content');
42
my $expirationdate;
42
my $expirationdate;
43
if ( $cgi->param('expirationdate') ) {
43
if ( $cgi->param('expirationdate') ) {
44
    $expirationdate = output_pref({ dt => dt_from_string( scalar $cgi->param('expirationdate') ), dateformat => 'iso', dateonly => 1 });
44
    $expirationdate = output_pref({ dt => dt_from_string( scalar $cgi->param('expirationdate') ), dateformat => 'iso', dateonly => 1 });
Lines 107-113 elsif ( $op eq 'add' ) { Link Here
107
        add_opac_new(
107
        add_opac_new(
108
            {
108
            {
109
                title          => $title,
109
                title          => $title,
110
                new            => $new,
110
                content        => $content,
111
                lang           => $lang,
111
                lang           => $lang,
112
                expirationdate => $expirationdate,
112
                expirationdate => $expirationdate,
113
                timestamp      => $timestamp,
113
                timestamp      => $timestamp,
Lines 127-133 elsif ( $op eq 'edit' ) { Link Here
127
        {
127
        {
128
            idnew          => $id,
128
            idnew          => $id,
129
            title          => $title,
129
            title          => $title,
130
            new            => $new,
130
            content        => $content,
131
            lang           => $lang,
131
            lang           => $lang,
132
            expirationdate => $expirationdate,
132
            expirationdate => $expirationdate,
133
            timestamp      => $timestamp,
133
            timestamp      => $timestamp,
134
- 

Return to bug 17960