Bugzilla – Attachment 122396 Details for
Bug 22544
Move C4:NewsChannels to Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22544: Move get_opac_new to Koha namespace
Bug-22544-Move-getopacnew-to-Koha-namespace.patch (text/plain), 5.76 KB, created by
Marcel de Rooy
on 2021-06-25 07:04:46 UTC
(
hide
)
Description:
Bug 22544: Move get_opac_new to Koha namespace
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2021-06-25 07:04:46 UTC
Size:
5.76 KB
patch
obsolete
>From 27539bc96333fb681a77a7b1ec1352e78c8a1771 Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Tue, 19 Mar 2019 09:14:47 +0000 >Subject: [PATCH] Bug 22544: Move get_opac_new to Koha namespace >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/NewsChannels.pm | 19 +------------ > t/db_dependent/NewsChannels.t | 51 +---------------------------------- > tools/koha-news.pl | 9 ++++--- > 3 files changed, 7 insertions(+), 72 deletions(-) > >diff --git a/C4/NewsChannels.pm b/C4/NewsChannels.pm >index 4b3c68311f..b03bce9824 100644 >--- a/C4/NewsChannels.pm >+++ b/C4/NewsChannels.pm >@@ -30,7 +30,7 @@ BEGIN { > @ISA = qw(Exporter); > @EXPORT = qw( > &GetNewsToDisplay >- &add_opac_new &upd_opac_new &del_opac_new &get_opac_new &get_opac_news >+ &add_opac_new &upd_opac_new &del_opac_new &get_opac_news > ); > } > >@@ -145,23 +145,6 @@ sub del_opac_new { > > } > >-sub get_opac_new { >- my ($idnew) = @_; >- my $dbh = C4::Context->dbh; >- my $query = q{ >- SELECT opac_news.*,branches.branchname >- FROM opac_news LEFT JOIN branches >- ON opac_news.branchcode=branches.branchcode >- WHERE opac_news.idnew = ?; >- }; >- my $sth = $dbh->prepare($query); >- $sth->execute($idnew); >- my $data = $sth->fetchrow_hashref; >- $data->{expirationdate} = output_pref({ dt => dt_from_string( $data->{expirationdate} ), dateonly => 1 }) if ( $data->{expirationdate} ); >- $data->{published_on} = output_pref({ dt => dt_from_string( $data->{published_on} ), dateonly => 1 }); >- return $data; >-} >- > sub get_opac_news { > my ($limit, $lang, $branchcode) = @_; > my @values; >diff --git a/t/db_dependent/NewsChannels.t b/t/db_dependent/NewsChannels.t >index 9eb1489f3d..3f3c8bdea4 100755 >--- a/t/db_dependent/NewsChannels.t >+++ b/t/db_dependent/NewsChannels.t >@@ -5,7 +5,7 @@ use Koha::Database; > use Koha::DateUtils; > use Koha::Libraries; > >-use Test::More tests => 14; >+use Test::More tests => 11; > > BEGIN { > use_ok('C4::NewsChannels'); >@@ -134,55 +134,6 @@ $href_entry2->{idnew} = $idnew2; > $rv = upd_opac_new($href_entry2); > is( $rv, 1, 'Successfully updated second dummy news item!' ); > >-# Test get_opac_new (single news item) >-$timestamp1 = output_pref( { dt => dt_from_string( $timestamp1 ), dateonly => 1 } ); >-$expirationdate1 = output_pref( { dt => dt_from_string( $expirationdate1 ), dateonly => 1 } ); >-$timestamp2 = output_pref( { dt => dt_from_string( $timestamp2 ), dateonly => 1 } ); >-$expirationdate2 = output_pref( { dt => dt_from_string( $expirationdate2) , dateonly => 1 } ); >- >-my $updated_on = %{get_opac_new($idnew1)}{updated_on}; >-is_deeply( >- get_opac_new($idnew1), >- { >- title => $title1, >- content => $new1, >- lang => $lang1, >- expirationdate => $expirationdate1, >- published_on=> $timestamp1, >- number => $number1, >- borrowernumber => undef, >- idnew => $idnew1, >- branchname => "$addbra branch", >- branchcode => $addbra, >- updated_on => $updated_on, >- }, >- 'got back expected news item via get_opac_new - ID 1' >-); >- >-# Test get_opac_new (single news item) >-$updated_on = %{get_opac_new($idnew2)}{updated_on}; >-is_deeply( >- get_opac_new($idnew2), >- { >- title => $title2, >- content => $new2, >- lang => $lang2, >- expirationdate => $expirationdate2, >- published_on=> $timestamp2, >- number => $number2, >- borrowernumber => $brwrnmbr, >- idnew => $idnew2, >- branchname => "$addbra branch", >- branchcode => $addbra, >- updated_on => $updated_on, >- }, >- 'got back expected news item via get_opac_new - ID 2' >-); >- >-# Test get_opac_new (single news item without expiration date) >-my $news3 = get_opac_new($idnew3); >-is($news3->{ expirationdate }, undef, "Expiration date should be empty"); >- > # Test get_opac_news (multiple news items) > my ( $opac_news_count, $arrayref_opac_news ) = get_opac_news( 0, q{}, 'LIB1' ); > >diff --git a/tools/koha-news.pl b/tools/koha-news.pl >index 388eed03ca..2954b7de5b 100755 >--- a/tools/koha-news.pl >+++ b/tools/koha-news.pl >@@ -32,6 +32,7 @@ use C4::NewsChannels; > use C4::Languages qw(getTranslatedLanguages); > use Date::Calc qw/Date_to_Days Today/; > use Koha::DateUtils; >+use Koha::News; > > my $cgi = CGI->new; > >@@ -58,7 +59,7 @@ if( $cgi->param('editmode') ){ > # NULL = All branches. > $branchcode = undef if (defined($branchcode) && $branchcode eq ''); > >-my $new_detail = get_opac_new($id); >+my $new_detail = Koha::News->find( $id ); > > my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > { >@@ -81,7 +82,7 @@ foreach my $language ( @$tlangs ) { > push @lang_list, > { > language => $sublanguage->{'rfc4646_subtag'}, >- selected => ( $new_detail->{lang} eq $sublanguage->{'rfc4646_subtag'} ? 1 : 0 ), >+ selected => ( $new_detail && $new_detail->lang eq $sublanguage->{'rfc4646_subtag'} ? 1 : 0 ), > }; > } > } >@@ -94,10 +95,10 @@ my $op = $cgi->param('op') // ''; > if ( $op eq 'add_form' ) { > $template->param( add_form => 1 ); > if ($id) { >- if($new_detail->{lang} eq "slip"){ $template->param( slip => 1); } >+ if($new_detail->lang eq "slip"){ $template->param( slip => 1); } > $template->param( > op => 'edit', >- id => $new_detail->{'idnew'} >+ id => $new_detail->idnew > ); > $template->{VARS}->{'new_detail'} = $new_detail; > } >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22544
:
86772
|
86773
|
86774
|
86775
|
86776
|
86777
|
86780
|
86781
|
90103
|
90104
|
90105
|
90106
|
90107
|
90108
|
90109
|
90110
|
92005
|
92006
|
92007
|
92008
|
92009
|
92010
|
92011
|
92012
|
95613
|
95614
|
95615
|
95627
|
95628
|
95629
|
95630
|
95631
|
95632
|
95633
|
95634
|
99849
|
99850
|
99851
|
99852
|
99853
|
99854
|
99855
|
99856
|
99857
|
104176
|
104177
|
104178
|
104179
|
104180
|
104181
|
104182
|
104183
|
104184
|
111012
|
111013
|
111014
|
111015
|
111016
|
111017
|
111018
|
111019
|
111020
|
111021
|
111022
|
111023
|
115135
|
115136
|
115137
|
115138
|
115139
|
115140
|
115141
|
115142
|
115143
|
115144
|
115145
|
115146
|
115218
|
115296
|
115297
|
115298
|
115299
|
116933
|
116934
|
116935
|
117479
|
117480
|
117481
|
117482
|
117483
|
117484
|
117485
|
117486
|
117487
|
117488
|
117489
|
117490
|
117491
|
117492
|
117493
|
117494
|
117495
|
117496
|
117497
|
118054
|
118055
|
118056
|
118057
|
118058
|
118059
|
118060
|
118061
|
118062
|
118063
|
118064
|
118065
|
118066
|
118067
|
118068
|
118069
|
118070
|
118071
|
118072
|
118073
|
118087
|
118088
|
118089
|
118090
|
118091
|
118092
|
118093
|
118094
|
118095
|
118096
|
118097
|
118098
|
118099
|
118100
|
118101
|
118102
|
118103
|
118104
|
118105
|
118106
|
120377
|
120378
|
120379
|
120380
|
120381
|
120382
|
120383
|
120384
|
120385
|
120386
|
120387
|
120388
|
120389
|
120390
|
120391
|
120392
|
120393
|
120394
|
120395
|
120396
| 122396 |
122397
|
122398
|
122399
|
122400
|
122401
|
122402
|
122403
|
122404
|
122405
|
122406
|
122407
|
122408
|
122409
|
122410
|
122411
|
122412
|
122413
|
122414
|
122415