From 0bd1f30c8c4f151eaed1a6e1e56a8c78d28c0b4b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Dec 2017 14:26:39 -0300 Subject: [PATCH] Bug 19855: Remove $type from the alerts It looks like this feature has never been finished. It has been developed with more flexibility in mind, but only 'issue' is used for this parameter. Apparently it could have been 'virtual', for virtual shelves. Let remove this parameter and clean the code a bit. TODO: Remove the DB column Signed-off-by: Kyle M Hall Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- C4/Letters.pm | 32 ++++++++----------- .../en/modules/opac-alert-subscribe.tt | 2 -- .../bootstrap/en/modules/opac-detail.tt | 4 +-- .../en/modules/opac-serial-issues.tt | 4 +-- opac/opac-alert-subscribe.pl | 28 +++++++--------- opac/opac-detail.pl | 2 +- opac/opac-serial-issues.pl | 4 +-- serials/viewalerts.pl | 2 +- t/db_dependent/Letters.t | 16 ++++------ 9 files changed, 39 insertions(+), 55 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index ed27b1f516..6bc03823a2 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -266,24 +266,23 @@ sub DelLetter { , undef, $branchcode, $module, $code, ( $mtt ? $mtt : () ), ( $lang ? $lang : () ) ); } -=head2 addalert ($borrowernumber, $type, $externalid) +=head2 addalert ($borrowernumber, $subscriptionid) parameters : - $borrowernumber : the number of the borrower subscribing to the alert - - $type : the type of alert. - - $externalid : the primary key of the object to put alert on. For issues, the alert is made on subscriptionid. - + - $subscriptionid + create an alert and return the alertid (primary key) =cut sub addalert { - my ( $borrowernumber, $type, $externalid ) = @_; + my ( $borrowernumber, $subscriptionid) = @_; my $dbh = C4::Context->dbh; my $sth = $dbh->prepare( - "insert into alert (borrowernumber, type, externalid) values (?,?,?)"); - $sth->execute( $borrowernumber, $type, $externalid ); + "insert into alert (borrowernumber, externalid) values (?,?)"); + $sth->execute( $borrowernumber, $subscriptionid ); # get the alert number newly created and return it my $alertid = $dbh->{'mysql_insertid'}; @@ -305,18 +304,17 @@ sub delalert { $sth->execute($alertid); } -=head2 getalert ([$borrowernumber], [$type], [$externalid]) +=head2 getalert ([$borrowernumber], [$subscriptionid]) parameters : - $borrowernumber : the number of the borrower subscribing to the alert - - $type : the type of alert. - - $externalid : the primary key of the object to put alert on. For issues, the alert is made on subscriptionid. - all parameters NON mandatory. If a parameter is omitted, the query is done without the corresponding parameter. For example, without $externalid, returns all alerts for a borrower on a topic. + - $subscriptionid + all parameters NON mandatory. If a parameter is omitted, the query is done without the corresponding parameter. For example, without $subscriptionid, returns all alerts for a borrower on a topic. =cut sub getalert { - my ( $borrowernumber, $type, $externalid ) = @_; + my ( $borrowernumber, $subscriptionid ) = @_; my $dbh = C4::Context->dbh; my $query = "SELECT a.*, b.branchcode FROM alert a JOIN borrowers b USING(borrowernumber) WHERE 1"; my @bind; @@ -324,13 +322,9 @@ sub getalert { $query .= " AND borrowernumber=?"; push @bind, $borrowernumber; } - if ($type) { - $query .= " AND type=?"; - push @bind, $type; - } - if ($externalid) { + if ($subscriptionid) { $query .= " AND externalid=?"; - push @bind, $externalid; + push @bind, $subscriptionid; } my $sth = $dbh->prepare($query); $sth->execute(@bind); @@ -386,7 +380,7 @@ sub SendAlerts { my %letter; # find the list of borrowers to alert - my $alerts = getalert( '', 'issue', $subscriptionid ); + my $alerts = getalert( '', $subscriptionid ); foreach (@$alerts) { my $patron = Koha::Patrons->find( $_->{borrowernumber} ); next unless $patron; # Just in case diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-alert-subscribe.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-alert-subscribe.tt index 83408b7da5..adba9f3306 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-alert-subscribe.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-alert-subscribe.tt @@ -25,7 +25,6 @@

[% bibliotitle %]

[% IF ( notes ) %]

[% notes %]

[% END %] - @@ -40,7 +39,6 @@

[% bibliotitle %]

[% IF ( notes ) %]

[% notes %]

[% END %] - diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 21c6ccd2c1..26fed4e9ce 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -834,9 +834,9 @@ [% IF ( subscription.letter ) %]