Bugzilla – Attachment 117491 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: Clarify documentation and change param 'type' to 'location'
Bug-22544-Clarify-documentation-and-change-param-t.patch (text/plain), 7.38 KB, created by
Jonathan Druart
on 2021-03-02 09:52:02 UTC
(
hide
)
Description:
Bug 22544: Clarify documentation and change param 'type' to 'location'
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-03-02 09:52:02 UTC
Size:
7.38 KB
patch
obsolete
>From d2ab4186911d2cc385d6a1d1f598cf46a2bcdbac Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Mon, 18 Jan 2021 10:33:21 +0100 >Subject: [PATCH] Bug 22544: Clarify documentation and change param 'type' to > 'location' > >--- > C4/Members.pm | 2 +- > Koha/News.pm | 18 +++++++++--------- > Koha/Template/Plugin/KohaNews.pm | 2 +- > mainpage.pl | 2 +- > opac/opac-main.pl | 2 +- > opac/opac-news-rss.pl | 2 +- > t/db_dependent/Koha/News.t | 24 ++++++++++++------------ > 7 files changed, 26 insertions(+), 26 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index 5b6e826dfc..e277c590bf 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -589,7 +589,7 @@ sub IssueSlip { > }; > } > my $news = Koha::News->search_for_display({ >- type => 'slip', >+ location => 'slip', > library_id => $branch, > }); > my @news; >diff --git a/Koha/News.pm b/Koha/News.pm >index 923805fbff..379c6c80bc 100644 >--- a/Koha/News.pm >+++ b/Koha/News.pm >@@ -40,14 +40,14 @@ Koha::News - Koha News object set class > =head3 search_for_display > > my $news = Koha::News->search_for_display({ >- type => 'slip', >+ location => 'slip', > lang => 'en', > library_id => $branchcode > }) > > Return Koha::News set for display to user > >-You can limit the results by type(lang) and library by optional params >+You can limit the results by location, language and library by optional params > > library_id should be valid branchcode of defined library > >@@ -62,7 +62,7 @@ type is one of this: > - opacheader > - opaccredits > >-lang is language code - it is used only when type is opac or OpacNavRight >+lang is language code - it is used only when type is opac or any of OPAC locations > > =cut > >@@ -70,15 +70,15 @@ sub search_for_display { > my ( $self, $params ) = @_; > > my $search_params; >- if ($params->{type} ) { >- if ( $params->{type} eq 'slip' || $params->{type} eq 'koha') { >- $search_params->{lang} = [ $params->{type}, '' ]; >- } elsif ( $params->{type} eq 'opac' && $params->{lang} ) { >+ if ($params->{location} ) { >+ if ( $params->{location} eq 'slip' || $params->{location} eq 'koha') { >+ $search_params->{lang} = [ $params->{location}, '' ]; >+ } elsif ( $params->{location} eq 'opac' && $params->{lang} ) { > $search_params->{lang} = [ $params->{lang}, '' ]; > } elsif ( $params->{lang} ) { >- $search_params->{lang} = $params->{type} . '_' . $params->{lang}; >+ $search_params->{lang} = $params->{location} . '_' . $params->{lang}; > } else { >- Koha::Exceptions::BadParameter->throw("The type and lang parameters combination is not valid"); >+ Koha::Exceptions::BadParameter->throw("The location and lang parameters combination is not valid"); > } > } > >diff --git a/Koha/Template/Plugin/KohaNews.pm b/Koha/Template/Plugin/KohaNews.pm >index a82461466e..fce9d678fc 100644 >--- a/Koha/Template/Plugin/KohaNews.pm >+++ b/Koha/Template/Plugin/KohaNews.pm >@@ -37,7 +37,7 @@ sub get { > my $library = $params->{library}; > > my $content = Koha::News->search_for_display({ >- type => $display_location, >+ location => $display_location, > lang => $lang, > library_id => $library, > }); >diff --git a/mainpage.pl b/mainpage.pl >index 4c46811c77..4000324173 100755 >--- a/mainpage.pl >+++ b/mainpage.pl >@@ -50,7 +50,7 @@ if (C4::Context->userenv) { > $homebranch = C4::Context->userenv->{'branch'}; > } > my $koha_news = Koha::News->search_for_display({ >- type => 'koha', >+ location => 'koha', > library_id => $homebranch > }); > >diff --git a/opac/opac-main.pl b/opac/opac-main.pl >index 40e9466a88..d030fd0751 100755 >--- a/opac/opac-main.pl >+++ b/opac/opac-main.pl >@@ -71,7 +71,7 @@ if (defined $news_id){ > } > } else { > $koha_news = Koha::News->search_for_display({ >- type => 'opac', >+ location => 'opac', > lang => $template->lang, > library_id => $homebranch, > }); >diff --git a/opac/opac-news-rss.pl b/opac/opac-news-rss.pl >index 29b0bef5b9..58ec362f2f 100755 >--- a/opac/opac-news-rss.pl >+++ b/opac/opac-news-rss.pl >@@ -44,7 +44,7 @@ my ($theme, $news_lang, $availablethemes) = C4::Templates::themelanguage(C4::Con > my $branchcode = $input->param('branchcode'); > > my $koha_news = Koha::News->search_for_display({ >- type => 'opac', >+ location => 'opac', > lang => $news_lang, > library_id => $branchcode, > }); >diff --git a/t/db_dependent/Koha/News.t b/t/db_dependent/Koha/News.t >index d93a07d411..596a89711d 100755 >--- a/t/db_dependent/Koha/News.t >+++ b/t/db_dependent/Koha/News.t >@@ -220,22 +220,22 @@ subtest '->search_for_display' => sub { > is($news->count, 4, 'Active and not expired news'); > is($news->next->number, 2, 'News items are returned in correct order'); > >- $news = Koha::News->search_for_display({ type => 'slip'}); >- is($news->count, 2, 'Slip and all type returned'); >+ $news = Koha::News->search_for_display({ location => 'slip'}); >+ is($news->count, 2, 'Slip and "all" locations returned'); > >- $news = Koha::News->search_for_display({ type => 'koha'}); >- is($news->count, 3, 'Intranet and all'); >+ $news = Koha::News->search_for_display({ location => 'koha'}); >+ is($news->count, 3, 'Intranet and "all"'); > > $new_not_expired->lang('OpacNavRight_en')->store; >- $news = Koha::News->search_for_display({ type => 'OpacNavRight', lang => 'en'}); >+ $news = Koha::News->search_for_display({ location => 'OpacNavRight', lang => 'en'}); > is($news->count, 1, 'OpacNavRight'); > is($news->next->idnew, $new_not_expired->idnew, 'Returned the right new item'); > > $new_intra->lang('')->store; >- $news = Koha::News->search_for_display({ type => 'opac', lang => 'en'}); >- is($news->count, 1, 'Only all type is returned'); >+ $news = Koha::News->search_for_display({ location => 'opac', lang => 'en'}); >+ is($news->count, 1, 'Only opac news are returned'); > $new_not_expired->lang('en')->store; >- $news = Koha::News->search_for_display({ type => 'opac', lang => 'en'}); >+ $news = Koha::News->search_for_display({ location => 'opac', lang => 'en'}); > is($news->count, 2, 'Opac en and all is returned'); > > $news = Koha::News->search_for_display({ library_id => $library1->branchcode }); >@@ -248,11 +248,11 @@ subtest '->search_for_display' => sub { > $news = Koha::News->search_for_display({ library_id => $library2->branchcode}); > is($news->count, 2, 'Filtering by library returns right number of news items'); > >- $news = Koha::News->search_for_display({ type => 'NonExistantType', lang => 'en'}); >- is($news->count, 0, 'Non-existant type is searched, but should not find any item'); >+ $news = Koha::News->search_for_display({ location => 'NonExistantType', lang => 'en'}); >+ is($news->count, 0, 'Non-existant location is searched, but should not find any item'); > >- throws_ok { Koha::News->search_for_display({type => 'opac'}) } 'Koha::Exceptions::BadParameter', >- 'Exception raised when type is opac and no language given'; >+ throws_ok { Koha::News->search_for_display({ location => 'opac'}) } 'Koha::Exceptions::BadParameter', >+ 'Exception raised when location is opac and no language given'; > > $schema->storage->txn_rollback; > }; >-- >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