Bug 15632: Koha::Patron::Messages - Remove DeleteMessage
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 20 Jan 2016 17:57:55 +0000 (17:57 +0000)
committerBrendan A Gallagher <brendan@bywatersolutions.com>
Thu, 3 Mar 2016 21:22:13 +0000 (21:22 +0000)
The DeleteMessage just deleted and logged if needed.
This is now be done by Koha::Patron::Message->delete.

Test plan:
1/ Go on the "check out" page of a patron
2/ Delete some messages

Signed-off-by: Marc VĂ©ron <veron@veron.ch>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
C4/Members.pm
circ/del_message.pl

index 6d23a4c..49baae3 100644 (file)
@@ -96,7 +96,6 @@ BEGIN {
         &GetExpiryDate
         &GetUpcomingMembershipExpires
 
-        &DeleteMessage
         &GetMessages
         &GetMessagesCount
 
@@ -2206,29 +2205,6 @@ sub GetMessagesCount {
     return $count;
 }
 
-
-
-=head2 DeleteMessage
-
-  DeleteMessage( $message_id );
-
-=cut
-
-sub DeleteMessage {
-    my ( $message_id ) = @_;
-
-    my $dbh = C4::Context->dbh;
-    my $query = "SELECT * FROM messages WHERE message_id = ?";
-    my $sth = $dbh->prepare($query);
-    $sth->execute( $message_id );
-    my $message = $sth->fetchrow_hashref();
-
-    $query = "DELETE FROM messages WHERE message_id = ?";
-    $sth = $dbh->prepare($query);
-    $sth->execute( $message_id );
-    logaction("MEMBERS", "DELCIRCMESSAGE", $message->{'borrowernumber'}, $message->{'message'}) if C4::Context->preference("BorrowersLog");
-}
-
 =head2 IssueSlip
 
   IssueSlip($branchcode, $borrowernumber, $quickslip)
index 6b8d560..ccce661 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
-use warnings;
+use Modern::Perl;
 
 use CGI qw ( -utf8 );
 
-use C4::Context;
 use C4::Auth;
 use C4::Output;
-use C4::Members;
-use C4::Accounts;
-use C4::Stats;
-use C4::Koha;
-use C4::Overdues;
-use C4::Branch;    # GetBranches
+use Koha::Patron::Messages;
 
 my $input = new CGI;
 
@@ -47,7 +40,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
 my $borrowernumber = $input->param('borrowernumber');
 my $message_id     = $input->param('message_id');
 
-DeleteMessage($message_id);
+my $message = Koha::Patron::Messages->find($message_id);
+$message->delete if $message;
 
 print $input->redirect(
     "/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");