[Koha-cvs] CVS: koha/admin branches.pl,1.13,1.14

Ambrose Li acli at users.sourceforge.net
Sun Feb 9 07:39:10 CET 2003


Update of /cvsroot/koha/koha/admin
In directory sc8-pr-cvs1:/tmp/cvs-serv7590/admin

Modified Files:
	branches.pl 
Log Message:
Use ? for variables in all SQL statements


Index: branches.pl
===================================================================
RCS file: /cvsroot/koha/koha/admin/branches.pl,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** branches.pl	9 Feb 2003 06:14:32 -0000	1.13
--- branches.pl	9 Feb 2003 06:39:07 -0000	1.14
***************
*** 3,7 ****
  
  #require '/u/acli/lib/cvs.pl';#DEBUG
! open(DEBUG,'>/tmp/koha.debug');
  
  # FIXME: individual fields in branch address need to be exported to templates,
--- 3,7 ----
  
  #require '/u/acli/lib/cvs.pl';#DEBUG
! #open(DEBUG,'>/tmp/koha.debug');
  
  # FIXME: individual fields in branch address need to be exported to templates,
***************
*** 15,18 ****
--- 15,21 ----
  #        separate templates for each individual action; need to notify
  #        translators
+ # FIXME: there are lots of error messages exported to the template; a lot
+ #        of these should be converted into exported booleans / counters etc
+ #        so that the error messages can be localized; need to notify translators
  
  # Finlay working on this file from 26-03-2002
***************
*** 169,173 ****
      my $catinfo = getcategoryinfo();
      my $catcheckbox;
!     print DEBUG "catinfo=".cvs($catinfo)."\n";
      foreach my $cat (@$catinfo) {
  	my $checked = "";
--- 172,176 ----
      my $catinfo = getcategoryinfo();
      my $catcheckbox;
! #    print DEBUG "catinfo=".cvs($catinfo)."\n";
      foreach my $cat (@$catinfo) {
  	my $checked = "";
***************
*** 203,206 ****
--- 206,210 ----
      foreach my $branch (@$branchinfo) {
  	($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
+ 	# FIXME. The $address should not be pre-composed (bug 180)
  	my $address = '';
  	$address .= $branch->{'branchaddress1'}          if ($branch->{'branchaddress1'});
***************
*** 272,290 ****
      my ($branchcode) = @_;
      my $dbh = C4::Context->dbh;
!     my $query;
      if ($branchcode) {
! 	my $bc = $dbh->quote($branchcode);
! 	$query = "Select * from branches where branchcode = $bc";
      } else {
  	$query = "Select * from branches";
      }
      my $sth = $dbh->prepare($query);
!     $sth->execute;
      my @results;
      while (my $data = $sth->fetchrow_hashref) { 
! 	my $tmp = $data->{'branchcode'}; my $brc = $dbh->quote($tmp);
! 	$query = "select categorycode from branchrelations where branchcode = $brc";
  	my $nsth = $dbh->prepare($query);
! 	$nsth->execute;
  	my @cats = ();
  	while (my ($cat) = $nsth->fetchrow_array) {
--- 276,293 ----
      my ($branchcode) = @_;
      my $dbh = C4::Context->dbh;
!     my ($query, @query_args);
      if ($branchcode) {
! 	$query = "Select * from branches where branchcode = ?";
! 	@query_args = ($branchcode);
      } else {
  	$query = "Select * from branches";
      }
      my $sth = $dbh->prepare($query);
!     $sth->execute(@query_args);
      my @results;
      while (my $data = $sth->fetchrow_hashref) { 
! 	$query = "select categorycode from branchrelations where branchcode = ?";
  	my $nsth = $dbh->prepare($query);
! 	$nsth->execute($data->{'branchcode'});;
  	my @cats = ();
  	while (my ($cat) = $nsth->fetchrow_array) {
***************
*** 304,318 ****
      my ($catcode) = @_;
      my $dbh = C4::Context->dbh;
!     my $query;
!     print DEBUG "getcategoryinfo: entry: catcode=".cvs($catcode)."\n";
      if ($catcode) {
! 	my $cc = $dbh->quote($catcode);
! 	$query = "select * from branchcategories where categorycode = $cc";
      } else {
  	$query = "Select * from branchcategories";
      }
!     print DEBUG "getcategoryinfo: query=".cvs($query)."\n";
      my $sth = $dbh->prepare($query);
!     $sth->execute;
      my @results;
      while (my $data = $sth->fetchrow_hashref) { 
--- 307,321 ----
      my ($catcode) = @_;
      my $dbh = C4::Context->dbh;
!     my ($query, @query_args);
! #    print DEBUG "getcategoryinfo: entry: catcode=".cvs($catcode)."\n";
      if ($catcode) {
! 	$query = "select * from branchcategories where categorycode = ?";
! 	@query_args = ($catcode);
      } else {
  	$query = "Select * from branchcategories";
      }
! #    print DEBUG "getcategoryinfo: query=".cvs($query)."\n";
      my $sth = $dbh->prepare($query);
!     $sth->execute(@query_args);
      my @results;
      while (my $data = $sth->fetchrow_hashref) { 
***************
*** 320,327 ****
      }
      $sth->finish;
!     print DEBUG "getcategoryinfo: exit: returning ".cvs(\@results)."\n";
      return \@results;
  }
  
  sub setbranchinfo {
  # sets the data from the editbranch form, and writes to the database...
--- 323,331 ----
      }
      $sth->finish;
! #    print DEBUG "getcategoryinfo: exit: returning ".cvs(\@results)."\n";
      return \@results;
  }
  
+ # FIXME This doesn't belong here; it should be moved into a module
  sub setbranchinfo {
  # sets the data from the editbranch form, and writes to the database...
***************
*** 369,381 ****
      my $dbh = C4::Context->dbh;
      foreach my $cat (@addcats) {
! 	my $query = "insert into branchrelations (branchcode, categorycode) values('$branchcode', '$cat')";
  	my $sth = $dbh->prepare($query);
! 	$sth->execute;
  	$sth->finish;
      }
      foreach my $cat (@removecats) {
! 	my $query = "delete from branchrelations where branchcode='$branchcode' and categorycode='$cat'";
  	my $sth = $dbh->prepare($query);
! 	$sth->execute;
  	$sth->finish;
      }
--- 373,385 ----
      my $dbh = C4::Context->dbh;
      foreach my $cat (@addcats) {
! 	my $query = "insert into branchrelations (branchcode, categorycode) values(?, ?)";
  	my $sth = $dbh->prepare($query);
! 	$sth->execute($branchcode, $cat);
  	$sth->finish;
      }
      foreach my $cat (@removecats) {
! 	my $query = "delete from branchrelations where branchcode=? and categorycode=?";
  	my $sth = $dbh->prepare($query);
! 	$sth->execute($branchcode, $cat);
  	$sth->finish;
      }
***************
*** 385,392 ****
  # delete branch...
      my ($branchcode) = @_;
!     my $query = "delete from branches where branchcode = '$branchcode'";
      my $dbh = C4::Context->dbh;
      my $sth=$dbh->prepare($query);
!     $sth->execute;
      $sth->finish;
  }
--- 389,396 ----
  # delete branch...
      my ($branchcode) = @_;
!     my $query = "delete from branches where branchcode = ?";
      my $dbh = C4::Context->dbh;
      my $sth=$dbh->prepare($query);
!     $sth->execute($branchcode);
      $sth->finish;
  }
***************
*** 396,405 ****
      my ($branchcode) = @_;
      my $dbh = C4::Context->dbh;
!     my $sth=$dbh->prepare("select count(*) from items where holdingbranch='$branchcode' or homebranch='$branchcode'");
!     $sth->execute;
      my ($total) = $sth->fetchrow_array;
      $sth->finish;
      my $message;
      if ($total) {
  	$message = "Branch cannot be deleted because there are $total items using that branch.";
      } 
--- 400,410 ----
      my ($branchcode) = @_;
      my $dbh = C4::Context->dbh;
!     my $sth=$dbh->prepare("select count(*) from items where holdingbranch=? or homebranch=?");
!     $sth->execute($branchcode, $branchcode);
      my ($total) = $sth->fetchrow_array;
      $sth->finish;
      my $message;
      if ($total) {
+ 	# FIXME: need to be replaced by an exported boolean parameter
  	$message = "Branch cannot be deleted because there are $total items using that branch.";
      } 





More information about the Koha-cvs mailing list