Bugzilla – Attachment 48032 Details for
Bug 9021
Add SMS via email as an alternative to SMS services via SMS::Send drivers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 9021 [QA Followup] - Switch to Koha::Object(s)
SIGNED-OFF-Bug-9021-QA-Followup---Switch-to-KohaOb.patch (text/plain), 9.41 KB, created by
Mark Tompsett
on 2016-02-12 20:08:05 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 9021 [QA Followup] - Switch to Koha::Object(s)
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2016-02-12 20:08:05 UTC
Size:
9.41 KB
patch
obsolete
>From 040541afb440250156b06011969157c1ab19d8da Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 9 Feb 2016 15:45:55 +0000 >Subject: [PATCH] [SIGNED-OFF] Bug 9021 [QA Followup] - Switch to > Koha::Object(s) > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> >--- > C4/Letters.pm | 4 +- > Koha/SMS/Provider.pm | 132 +++++-------------------------------------------- > Koha/SMS/Providers.pm | 60 ++++++++++++++++++++++ > admin/sms_providers.pl | 22 +++++++-- > members/memberentry.pl | 4 +- > opac/opac-messaging.pl | 3 +- > 6 files changed, 96 insertions(+), 129 deletions(-) > create mode 100644 Koha/SMS/Providers.pm > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 99a39d4..7b3261b 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -31,7 +31,7 @@ use C4::Log; > use C4::SMS; > use C4::Debug; > use Koha::DateUtils; >-use Koha::SMS::Provider; >+use Koha::SMS::Providers; > > use Date::Calc qw( Add_Delta_Days ); > use Encode; >@@ -987,7 +987,7 @@ sub SendQueuedMessages { > elsif ( lc( $message->{'message_transport_type'} ) eq 'sms' ) { > if ( C4::Context->preference('SMSSendDriver') eq 'Email' ) { > my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); >- my $sms_provider = Koha::SMS::Provider->find( $member->{'sms_provider_id'} ); >+ my $sms_provider = Koha::SMS::Providers->find( $member->{'sms_provider_id'} ); > $message->{to_address} .= '@' . $sms_provider->domain(); > _send_message_by_email( $message, $params->{'username'}, $params->{'password'}, $params->{'method'} ); > } else { >diff --git a/Koha/SMS/Provider.pm b/Koha/SMS/Provider.pm >index 6331088..1aa70dc 100644 >--- a/Koha/SMS/Provider.pm >+++ b/Koha/SMS/Provider.pm >@@ -1,6 +1,6 @@ > package Koha::SMS::Provider; > >-# Copyright 2012 ByWater Solutions >+# Copyright ByWater Solutions 2016 > # > # This file is part of Koha. > # >@@ -17,141 +17,35 @@ package Koha::SMS::Provider; > # with Koha; if not, write to the Free Software Foundation, Inc., > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > >-=head1 NAME >- >-Koha::SMS::Provider - class to manage sms providers >- >-=head1 SYNOPSIS >- >-Object-oriented class that encapsulates sms providers in Koha. >- >-=head1 DESCRIPTION >- >-SMS::Provider data. >- >-=cut >- > use Modern::Perl; > >-use C4::Context; >- >-use base qw(Class::Accessor); >- >-__PACKAGE__->mk_accessors(qw( id name domain )); >- >-=head2 new >- >- my $provider = Koha::SMS::Provider->new($data); >- >-Create a new Koha::SMS::Provider object based on the provided record. >- >-=cut >- >-sub new { >- my $class = shift; >- my $data = shift; >- >- my $self = $class->SUPER::new($data); >- >- bless $self, $class; >- return $self; >-} >- >-=head2 store >- >- Creates or updates the object in the database >- >-=cut >- >-sub store { >- my $self = shift; >- >- if ( $self->id ) { >- return C4::Context->dbh->do( "UPDATE sms_providers SET name = ?, domain = ? WHERE id = ?", undef, ( $self->name, $self->domain, $self->id ) ); >- } else { >- return C4::Context->dbh->do( "INSERT INTO sms_providers ( name, domain ) VALUES ( ?, ? )", undef, ( $self->name, $self->domain ) ); >- } >-} >- >-=head2 delete >+use Carp; > >-=cut >+use base qw(Koha::Object); > >-sub delete { >- my $self = shift; >+=head1 NAME > >- return C4::Context->dbh->do( "DELETE FROM sms_providers WHERE id = ?", undef, ( $self->id ) ); >-} >+Koha::Biblio - Koha Biblio Object class >+Koha::SMS::Provider - Koha SMS Provider object class > >-=head2 all >+=head1 API > >- my $providers = Koha::SMS::Provider->all(); >+=head2 Class Methods > > =cut > >-sub all { >- my $class = shift; >- >- my $query = "SELECT * FROM sms_providers ORDER BY name"; >- my $sth = C4::Context->dbh->prepare($query); >- $sth->execute(); >- >- my @providers; >- while ( my $row = $sth->fetchrow_hashref() ) { >- my $p = Koha::SMS::Provider->new($row); >- push( @providers, $p ); >- } >- >- return @providers; >-} >- >-=head2 find >- >- my $provider = Koha::SMS::Provider->find( $id ); >+=head3 type > > =cut > >-sub find { >- my $class = shift; >- my $id = shift; >- >- my $query = "SELECT * FROM sms_providers WHERE ID = ?"; >- my $sth = C4::Context->dbh->prepare($query); >- $sth->execute($id); >- >- my $row = $sth->fetchrow_hashref(); >- my $p = Koha::SMS::Provider->new($row); >- >- return $p; >+sub type { >+ return 'SmsProvider'; > } > >-=head2 search >+=head1 AUTHOR > >- my @providers = Koha::SMS::Provider->search({ [name => $name], [domain => $domain] }); >+Kyle M Hall <kyle@bywatersolutions.com> > > =cut > >-sub search { >- my $class = shift; >- my $params = shift; >- >- my $query = "SELECT * FROM sms_providers WHERE "; >- >- my @params = map( $params->{$_}, keys %$params ); >- $query .= join( " AND ", map( "$_ = ?", keys %$params ) ); >- >- $query .= " ORDER BY name"; >- >- my $sth = C4::Context->dbh->prepare($query); >- $sth->execute(@params); >- >- my @providers; >- while ( my $row = $sth->fetchrow_hashref() ) { >- my $p = Koha::SMS::Provider->new($row); >- push( @providers, $p ); >- } >- >- return @providers; >-} >- > 1; >diff --git a/Koha/SMS/Providers.pm b/Koha/SMS/Providers.pm >new file mode 100644 >index 0000000..0a89878 >--- /dev/null >+++ b/Koha/SMS/Providers.pm >@@ -0,0 +1,60 @@ >+package Koha::SMS::Providers; >+ >+# Copyright ByWater Solutions 2016 >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::SMS::Provider; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::SMS::Providers - Koha SMS Provider object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub type { >+ return 'SmsProvider'; >+} >+ >+=head3 object_class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::SMS::Provider'; >+} >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >+ >+1; >diff --git a/admin/sms_providers.pl b/admin/sms_providers.pl >index bdc9349..4592acf 100755 >--- a/admin/sms_providers.pl >+++ b/admin/sms_providers.pl >@@ -26,11 +26,13 @@ use C4::Auth; > use C4::Output; > > use Koha::SMS::Provider; >+use Koha::SMS::Providers; > > my $cgi = new CGI; > > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >- { template_name => "admin/sms_providers.tt", >+ { >+ template_name => "admin/sms_providers.tt", > query => $cgi, > type => "intranet", > authnotrequired => 0, >@@ -46,13 +48,23 @@ my $domain = $cgi->param('domain'); > > if ( $op eq 'add_update' ) { > if ( $name && $domain ) { >- Koha::SMS::Provider->new( { id => $id, name => $name, domain => $domain } )->store(); >+ if ($id) { >+ my $provider = Koha::SMS::Providers->find($id); >+ $provider->set( { name => $name, domain => $domain } )->store() >+ if $provider; >+ } >+ else { >+ Koha::SMS::Provider->new( { name => $name, domain => $domain } ) >+ ->store(); >+ } > } >-} elsif ( $op eq 'delete' ) { >- Koha::SMS::Provider->find($id)->delete(); >+} >+elsif ( $op eq 'delete' ) { >+ my $provider = Koha::SMS::Providers->find($id); >+ $provider->delete() if $provider; > } > >-my @providers = Koha::SMS::Provider->all(); >+my @providers = Koha::SMS::Providers->search(); > > $template->param( providers => \@providers ); > >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 48ea65e..4951614 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -46,7 +46,7 @@ use Module::Load; > if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) { > load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber ); > } >-use Koha::SMS::Provider; >+use Koha::SMS::Providers; > > use vars qw($debug); > >@@ -70,7 +70,7 @@ my ($template, $loggedinuser, $cookie) > }); > > if ( C4::Context->preference('SMSSendDriver') eq 'Email' ) { >- my @providers = Koha::SMS::Provider->all(); >+ my @providers = Koha::SMS::Providers->search(); > $template->param( sms_providers => \@providers ); > } > >diff --git a/opac/opac-messaging.pl b/opac/opac-messaging.pl >index 6fe18a7..3ea529e 100755 >--- a/opac/opac-messaging.pl >+++ b/opac/opac-messaging.pl >@@ -31,6 +31,7 @@ use C4::Members; > use C4::Members::Messaging; > use C4::Branch; > use C4::Form::MessagingPreferences; >+use Koha::SMS::Providers; > > my $query = CGI->new(); > >@@ -70,7 +71,7 @@ $template->param( BORROWER_INFO => $borrower, > TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification") ); > > if ( C4::Context->preference("SMSSendDriver") eq 'Email' ) { >- my @providers = Koha::SMS::Provider->all(); >+ my @providers = Koha::SMS::Providers->search(); > $template->param( sms_providers => \@providers, sms_provider_id => $borrower->{'sms_provider_id'} ); > } > >-- >2.1.4
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 9021
:
13290
|
13291
|
13293
|
13294
|
14166
|
14167
|
14363
|
15685
|
15687
|
15689
|
15691
|
16628
|
17311
|
21729
|
22478
|
28488
|
29927
|
32453
|
34180
|
34181
|
35816
|
40720
|
44331
|
45152
|
46163
|
46164
|
46165
|
46168
|
46169
|
46170
|
46171
|
47128
|
47129
|
47130
|
47133
|
47134
|
47135
|
47338
|
47339
|
47814
|
47815
|
47816
|
47817
|
47818
|
47845
|
47846
|
47847
|
47848
|
47995
|
48024
|
48025
|
48026
|
48027
|
48028
|
48029
|
48030
|
48031
|
48032
|
48033
|
48034
|
48035
|
48036
|
48052
|
48053
|
48054
|
48055
|
48056
|
48057
|
48058
|
48059
|
48060
|
48061
|
48062
|
48063
|
48064
|
48065
|
48066