From 2cff5e764203b9ac5ff8d6a83868edd98f59854b Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Wed, 22 Feb 2012 18:12:04 +0100 Subject: [PATCH] Bug 5877 QA follow-up * removing tabs as indenter * adding fieldnames in INSERT clause * updating FSF address * removing ` in SQL table creation (mysql-ism) * use strict & use warning added & no error in logs checked Note that process_koc.pl and updatedatabase are not related to this bug, but the FSF address was wrong, I fixed it as well --- C4/Circulation.pm | 55 +++++++++++++------------- installer/data/mysql/updatedatabase.pl | 8 ++-- offline_circ/list.pl | 27 +++++++------ offline_circ/process.pl | 9 +++-- offline_circ/process_koc.pl | 6 +-- offline_circ/service.pl | 25 ++++++------ 6 files changed, 70 insertions(+), 60 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index d44e862dee..1a156d9354 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3037,51 +3037,50 @@ sub LostItem{ } sub GetOfflineOperations { - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE branchcode=? ORDER BY timestamp"); - $sth->execute(C4::Context->userenv->{'branch'}); - my $results = $sth->fetchall_arrayref({}); - $sth->finish; - return $results; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE branchcode=? ORDER BY timestamp"); + $sth->execute(C4::Context->userenv->{'branch'}); + my $results = $sth->fetchall_arrayref({}); + $sth->finish; + return $results; } sub GetOfflineOperation { - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE operationid=?"); - $sth->execute( shift ); - my $result = $sth->fetchrow_hashref; - $sth->finish; - return $result; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE operationid=?"); + $sth->execute( shift ); + my $result = $sth->fetchrow_hashref; + $sth->finish; + return $result; } sub AddOfflineOperation { - my $dbh = C4::Context->dbh; - warn Data::Dumper::Dumper(@_); - my $sth = $dbh->prepare("INSERT INTO pending_offline_operations VALUES('',?,?,?,?,?,?)"); - $sth->execute( @_ ); - return "Added."; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("INSERT INTO pending_offline_operations (userid, branchcode, timestamp, action, barcode, cardnumber) VALUES(?,?,?,?,?,?)"); + $sth->execute( @_ ); + return "Added."; } sub DeleteOfflineOperation { - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("DELETE FROM pending_offline_operations WHERE operationid=?"); - $sth->execute( shift ); - return "Deleted."; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("DELETE FROM pending_offline_operations WHERE operationid=?"); + $sth->execute( shift ); + return "Deleted."; } sub ProcessOfflineOperation { - my $operation = shift; + my $operation = shift; my $report; - if ( $operation->{action} eq 'return' ) { + if ( $operation->{action} eq 'return' ) { $report = ProcessOfflineReturn( $operation ); - } elsif ( $operation->{action} eq 'issue' ) { - $report = ProcessOfflineIssue( $operation ); - } + } elsif ( $operation->{action} eq 'issue' ) { + $report = ProcessOfflineIssue( $operation ); + } - DeleteOfflineOperation( $operation->{operationid} ) if $operation->{operationid}; + DeleteOfflineOperation( $operation->{operationid} ) if $operation->{operationid}; - return $report; + return $report; } sub ProcessOfflineReturn { diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index cd1aa15fb5..1fb812d3a7 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -15,9 +15,9 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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. # # Bugs/ToDo: @@ -4721,7 +4721,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $DBversion = "3.07.00.XXX"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { - $dbh->do("CREATE TABLE `pending_offline_operations` ( `operationid` int(11) NOT NULL AUTO_INCREMENT, `userid` varchar(30) NOT NULL, `branchcode` varchar(10) NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `action` varchar(10) NOT NULL, `barcode` varchar(20) NOT NULL, `cardnumber` varchar(16) DEFAULT NULL, PRIMARY KEY (`operationid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"); + $dbh->do("CREATE TABLE pending_offline_operations ( operationid int(11) NOT NULL AUTO_INCREMENT, userid varchar(30) NOT NULL, branchcode varchar(10) NOT NULL, timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, action varchar(10) NOT NULL, barcode varchar(20) NOT NULL, cardnumber varchar(16) DEFAULT NULL, PRIMARY KEY (operationid) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"); print "Upgrade to $DBversion done ( adding offline operations table )\n"; SetVersion($DBversion); } diff --git a/offline_circ/list.pl b/offline_circ/list.pl index 72d6dae892..de129ff172 100755 --- a/offline_circ/list.pl +++ b/offline_circ/list.pl @@ -13,11 +13,14 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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 strict; +use warnings; + use CGI; use C4::Output; use C4::Auth; @@ -41,14 +44,16 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user({ my $operations = GetOfflineOperations; for (@$operations) { - my $biblio = GetBiblioFromItemNumber(undef, $_->{'barcode'}); - $_->{'bibliotitle'} = $biblio->{'title'}; - $_->{'biblionumber'} = $biblio->{'biblionumber'}; - my $borrower = GetMemberDetails(undef,$_->{'cardnumber'}); - $_->{'borrowernumber'} = $borrower->{'borrowernumber'}; - $_->{'borrower'} = join(' ', $borrower->{'firstname'}, $borrower->{'surname'}); - $_->{'actionissue'} = $_->{'action'} eq 'issue'; - $_->{'actionreturn'} = $_->{'action'} eq 'return'; + my $biblio = GetBiblioFromItemNumber(undef, $_->{'barcode'}); + $_->{'bibliotitle'} = $biblio->{'title'}; + $_->{'biblionumber'} = $biblio->{'biblionumber'}; + my $borrower = GetMemberDetails(undef,$_->{'cardnumber'}); + if ($borrower) { + $_->{'borrowernumber'} = $borrower->{'borrowernumber'}; + $_->{'borrower'} = ($borrower->{'firstname'}?$borrower->{'firstname'}:'').' '.$borrower->{'surname'}; + } + $_->{'actionissue'} = $_->{'action'} eq 'issue'; + $_->{'actionreturn'} = $_->{'action'} eq 'return'; } $template->param(pending_operations => $operations); diff --git a/offline_circ/process.pl b/offline_circ/process.pl index d814f7420a..86b5fdaa3b 100755 --- a/offline_circ/process.pl +++ b/offline_circ/process.pl @@ -13,11 +13,14 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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 strict; +use warnings; + use CGI; use C4::Auth; use C4::Circulation; diff --git a/offline_circ/process_koc.pl b/offline_circ/process_koc.pl index 6c48ffb4ce..736d9186ef 100755 --- a/offline_circ/process_koc.pl +++ b/offline_circ/process_koc.pl @@ -13,9 +13,9 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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 strict; diff --git a/offline_circ/service.pl b/offline_circ/service.pl index 8d1dd5ff3d..ce0ab4a6cc 100755 --- a/offline_circ/service.pl +++ b/offline_circ/service.pl @@ -13,11 +13,14 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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 strict; +use warnings; + use CGI; use C4::Auth; use C4::Circulation; @@ -30,17 +33,17 @@ my ($status, $cookie, $sessionId) = C4::Auth::check_api_auth($cgi, undef); my $result; if ($status eq 'ok') { # if authentication is ok - if ( $cgi->param('pending') eq 'true' ) { # if the 'pending' flag is true, we store the operation in the db instead of directly processing them - $result = AddOfflineOperation( - $cgi->param('userid') || '', + if ( $cgi->param('pending') eq 'true' ) { # if the 'pending' flag is true, we store the operation in the db instead of directly processing them + $result = AddOfflineOperation( + $cgi->param('userid') || '', $cgi->param('branchcode') || '', $cgi->param('timestamp') || '', $cgi->param('action') || '', $cgi->param('barcode') || '', $cgi->param('cardnumber') || '', - ); - } else { - $result = ProcessOfflineOperation( + ); + } else { + $result = ProcessOfflineOperation( { 'userid' => $cgi->param('userid'), 'branchcode' => $cgi->param('branchcode'), @@ -49,8 +52,8 @@ if ($status eq 'ok') { # if authentication is ok 'barcode' => $cgi->param('barcode'), 'cardnumber' => $cgi->param('cardnumber'), } - ); - } + ); + } } else { $result = "Authentication failed." } -- 2.39.5