Bugzilla – Attachment 58846 Details for
Bug 17855
New onboarding tool feature to guide users through setting up Koha, and minor web installer UI improvements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17855 - Removed html regex on patron password fields. Ran perltidy to indent and space code appropriately. Ran git bz configuration commands to remove whitespace. Removed unnecissary uses in the summary.pl script
Bug-17855---Removed-html-regex-on-patron-password-.patch (text/plain), 72.06 KB, created by
Alex Buckley
on 2017-01-11 20:38:20 UTC
(
hide
)
Description:
Bug 17855 - Removed html regex on patron password fields. Ran perltidy to indent and space code appropriately. Ran git bz configuration commands to remove whitespace. Removed unnecissary uses in the summary.pl script
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2017-01-11 20:38:20 UTC
Size:
72.06 KB
patch
obsolete
>From 38eb503169991df54a80ac3d8ad7bae5f7bed037 Mon Sep 17 00:00:00 2001 >From: "@alexbuckley" <alexbuckley@catalyst.net.nz> >Date: Wed, 11 Jan 2017 20:29:28 +0000 >Subject: [PATCH] Bug 17855 - Removed html regex on patron password fields. Ran > perltidy to indent and space code appropriately. Ran git bz configuration > commands to remove whitespace. Removed unnecissary uses in the summary.pl > script > >These changes are based on feedback from testing. > >Test plan: >1. Go through the web installer and onboarding tool as outlined in this >guide: >https://koha-community.org/manual/installation/html/ >--- > installer/install.pl | 364 +++++---- > installer/onboarding.pl | 848 +++++++++++---------- > .../prog/en/modules/onboarding/onboardingstep1.tt | 1 - > .../prog/en/modules/onboarding/onboardingstep3.tt | 14 +- > .../prog/en/modules/onboarding/onboardingstep4.tt | 5 +- > koha-tmpl/intranet-tmpl/prog/en/modules/summary.tt | 9 +- > summary.pl | 20 +- > 7 files changed, 687 insertions(+), 574 deletions(-) > >diff --git a/installer/install.pl b/installer/install.pl >index 800e867..c31bd2a 100755 >--- a/installer/install.pl >+++ b/installer/install.pl >@@ -1,21 +1,21 @@ > #!/usr/bin/perl > > # This file is part of Koha. >-# # >-# # Copyright (C) YEAR YOURNAME-OR-YOUREMPLOYER >-# # >-# # 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, see <http://www.gnu.org/licenses>. >+# >+# Copyright (C) YEAR YOURNAME-OR-YOUREMPLOYER >+# >+# 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, see <http://www.gnu.org/licenses>. > > use strict; > use warnings; >@@ -57,10 +57,11 @@ if ( defined($language) ) { > my $installer = C4::Installer->new(); > my %info; > $info{'dbname'} = C4::Context->config("database"); >-$info{'dbms'} = >- ( C4::Context->config("db_scheme") >+$info{'dbms'} = ( >+ C4::Context->config("db_scheme") > ? C4::Context->config("db_scheme") >- : "mysql" ); >+ : "mysql" >+); > $info{'hostname'} = C4::Context->config("hostname"); > $info{'port'} = C4::Context->config("port"); > $info{'user'} = C4::Context->config("user"); >@@ -72,12 +73,14 @@ my $dbh = DBI->connect( > ); > > if ( $step && $step == 1 ) { >+ > #First Step (for both fresh installations and upgrades) > #Checking ALL perl Modules and services needed are installed. > #Whenever there is an error, adding a report to the page > my $op = $query->param('op') || 'noop'; >- $template->param( language => 1 ); >- $template->param( 'checkmodule' => 1 ); # we start with the assumption that there are no problems and set this to 0 if there are >+ $template->param( language => 1 ); >+ $template->param( 'checkmodule' => 1 ) >+ ; # we start with the assumption that there are no problems and set this to 0 if there are > > unless ( $] >= 5.010000 ) { # Bug 7375 > $template->param( problems => 1, perlversion => 1, checkmodule => 0 ); >@@ -87,11 +90,11 @@ if ( $step && $step == 1 ) { > $perl_modules->version_info; > > my $modules = $perl_modules->get_attr('missing_pm'); >- if (scalar(@$modules)) { >- my @components = (); >+ if ( scalar(@$modules) ) { >+ my @components = (); > my $checkmodule = 1; > foreach (@$modules) { >- my ($module, $stats) = each %$_; >+ my ( $module, $stats ) = each %$_; > $checkmodule = 0 if $stats->{'required'}; > push( > @components, >@@ -103,14 +106,18 @@ if ( $step && $step == 1 ) { > } > ); > } >- @components = sort {$a->{'name'} cmp $b->{'name'}} @components; >- $template->param( missing_modules => \@components, checkmodule => $checkmodule, op => $op ); >+ @components = sort { $a->{'name'} cmp $b->{'name'} } @components; >+ $template->param( >+ missing_modules => \@components, >+ checkmodule => $checkmodule, >+ op => $op >+ ); > } > } > elsif ( $step && $step == 2 ) { >-# >-#STEP 2 Check Database connection and access >-# >+ >+ #STEP 2 Check Database connection and access >+ > $template->param(%info); > my $checkdb = $query->param("checkdb"); > $template->param( 'dbconnection' => $checkdb ); >@@ -135,7 +142,9 @@ elsif ( $step && $step == 2 ) { > my $grantaccess; > while ( my ($line) = $rq->fetchrow ) { > my $dbname = $info{dbname}; >- if ( $line =~ m/^GRANT (.*?) ON `$dbname`\.\*/ || index( $line, '*.*' ) > 0 ) { >+ if ( $line =~ m/^GRANT (.*?) ON `$dbname`\.\*/ >+ || index( $line, '*.*' ) > 0 ) >+ { > $grantaccess = 1 > if ( > index( $line, 'ALL PRIVILEGES' ) > 0 >@@ -170,23 +179,28 @@ elsif ( $step && $step == 2 ) { > } > } > $template->param( "checkgrantaccess" => $grantaccess ); >- } # End mysql connect check... >+ } # End mysql connect check... >+ >+ elsif ( $info{dbms} eq "Pg" ) { > >- elsif ( $info{dbms} eq "Pg" ) { >- # Check if database has been created... >- my $rv = $dbh->do( "SELECT * FROM pg_catalog.pg_database WHERE datname = \'$info{dbname}\';" ); >- if ( $rv == 1 ) { >- $template->param( 'checkdatabasecreated' => 1 ); >- } >+ # Check if database has been created... >+ my $rv = $dbh->do( >+"SELECT * FROM pg_catalog.pg_database WHERE datname = \'$info{dbname}\';" >+ ); >+ if ( $rv == 1 ) { >+ $template->param( 'checkdatabasecreated' => 1 ); >+ } > >- # Check if user has all necessary grants on this database... >- my $rq = $dbh->do( "SELECT u.usesuper >+ # Check if user has all necessary grants on this database... >+ my $rq = $dbh->do( >+ "SELECT u.usesuper > FROM pg_catalog.pg_user as u >- WHERE u.usename = \'$info{user}\';" ); >- if ( $rq == 1 ) { >- $template->param( "checkgrantaccess" => 1 ); >- } >- } # End Pg connect check... >+ WHERE u.usename = \'$info{user}\';" >+ ); >+ if ( $rq == 1 ) { >+ $template->param( "checkgrantaccess" => 1 ); >+ } >+ } # End Pg connect check... > } > else { > $template->param( "error" => DBI::err, "message" => DBI::errstr ); >@@ -194,11 +208,9 @@ elsif ( $step && $step == 2 ) { > } > } > elsif ( $step && $step == 3 ) { >-# >-# >-# STEP 3 : database setup >-# >-# >+ >+ # STEP 3 : database setup >+ > my $op = $query->param('op'); > if ( $op && $op eq 'finished' ) { > # >@@ -210,19 +222,20 @@ elsif ( $step && $step == 3 ) { > elsif ( $op && $op eq 'finish' ) { > $installer->set_version_syspref(); > >- # Installation is finished. >- # We just deny anybody access to install >- # And we redirect people to mainpage. >- # The installer will have to relogin since we do not pass cookie to redirection. >+# Installation is finished. >+# We just deny anybody access to install >+# And we redirect people to mainpage. >+# The installer will have to relogin since we do not pass cookie to redirection. > $template->param( "$op" => 1 ); > } > > elsif ( $op && $op eq 'addframeworks' ) { >- # >- # 1ST install, 3rd sub-step : insert the SQL files the user has selected >- # > >- my ($fwk_language, $list) = $installer->load_sql_in_order($all_languages, $query->param('framework')); >+ # 1ST install, 3rd sub-step : insert the SQL files the user has selected >+ >+ my ( $fwk_language, $list ) = >+ $installer->load_sql_in_order( $all_languages, >+ $query->param('framework') ); > $template->param( > "fwklanguage" => $fwk_language, > "list" => $list >@@ -232,45 +245,49 @@ elsif ( $step && $step == 3 ) { > $template->param( "$op" => 1 ); > } > elsif ( $op && $op eq 'selectframeworks' ) { >- # >- # >- # 1ST install, 2nd sub-step : show the user the sql datas he can insert in the database. >- # >- # >- # (note that the term "selectframeworks is not correct. The user can select various files, not only frameworks) >- >- #Framework Selection >- #sql data for import are supposed to be located in installer/data/<language>/<level> >- # Where <language> is en|fr or any international abbreviation (provided language hash is updated... This will be a problem with internationlisation.) >- # Where <level> is a category of requirement : required, recommended optional >- # level should contain : >- # SQL File for import With a readable name. >- # txt File that explains what this SQL File is meant for. >- # Could be VERY useful to have A Big file for a kind of library. >- # But could also be useful to have some Authorised values data set prepared here. >- # Framework Selection is achieved through checking boxes. >+# >+# >+# 1ST install, 2nd sub-step : show the user the sql datas he can insert in the database. >+# >+# >+# (note that the term "selectframeworks is not correct. The user can select various files, not only frameworks) >+ >+#Framework Selection >+#sql data for import are supposed to be located in installer/data/<language>/<level> >+# Where <language> is en|fr or any international abbreviation (provided language hash is updated... This will be a problem with internationlisation.) >+# Where <level> is a category of requirement : required, recommended optional >+# level should contain : >+# SQL File for import With a readable name. >+# txt File that explains what this SQL File is meant for. >+# Could be VERY useful to have A Big file for a kind of library. >+# But could also be useful to have some Authorised values data set prepared here. >+# Framework Selection is achieved through checking boxes. > my $langchoice = $query->param('fwklanguage'); > $langchoice = $query->cookie('KohaOpacLanguage') unless ($langchoice); >- $langchoice =~ s/[^a-zA-Z_-]*//g; >+ $langchoice =~ s/[^a-zA-Z_-]*//g; > my $marcflavour = $query->param('marcflavour'); >- if ($marcflavour){ >+ if ($marcflavour) { > $installer->set_marcflavour_syspref($marcflavour); >- }; >- $marcflavour = C4::Context->preference('marcflavour') unless ($marcflavour); >+ } >+ $marcflavour = C4::Context->preference('marcflavour') >+ unless ($marcflavour); >+ > #Insert into database the selected marcflavour > undef $/; >- my ($marc_defaulted_to_en, $fwklist) = $installer->marc_framework_sql_list($langchoice, $marcflavour); >- $template->param('en_marc_frameworks' => $marc_defaulted_to_en); >- $template->param( "frameworksloop" => $fwklist ); >- $template->param( "marcflavour" => ucfirst($marcflavour)); >- >- my ($sample_defaulted_to_en, $levellist) = $installer->sample_data_sql_list($langchoice); >- $template->param( "en_sample_data" => $sample_defaulted_to_en); >- $template->param( "levelloop" => $levellist ); >- $template->param( "$op" => 1 ); >+ my ( $marc_defaulted_to_en, $fwklist ) = >+ $installer->marc_framework_sql_list( $langchoice, $marcflavour ); >+ $template->param( 'en_marc_frameworks' => $marc_defaulted_to_en ); >+ $template->param( "frameworksloop" => $fwklist ); >+ $template->param( "marcflavour" => ucfirst($marcflavour) ); >+ >+ my ( $sample_defaulted_to_en, $levellist ) = >+ $installer->sample_data_sql_list($langchoice); >+ $template->param( "en_sample_data" => $sample_defaulted_to_en ); >+ $template->param( "levelloop" => $levellist ); >+ $template->param( "$op" => 1 ); > > my $setup = $query->param('setup'); >- $template->param( "setup"=> $setup ); >+ $template->param( "setup" => $setup ); > > } > elsif ( $op && $op eq 'choosemarc' ) { >@@ -280,47 +297,55 @@ elsif ( $step && $step == 3 ) { > # > # > >- #Choose Marc Flavour >- #sql data are supposed to be located in installer/data/<dbms>/<language>/marcflavour/marcflavourname >- # Where <dbms> is database type according to DBD syntax >- # Where <language> is en|fr or any international abbreviation (provided language hash is updated... This will be a problem with internationlisation.) >- # Where <level> is a category of requirement : required, recommended optional >- # level should contain : >- # SQL File for import With a readable name. >- # txt File taht explains what this SQL File is meant for. >- # Could be VERY useful to have A Big file for a kind of library. >- # But could also be useful to have some Authorised values data set prepared here. >- # Marcflavour Selection is achieved through radiobuttons. >+#Choose Marc Flavour >+#sql data are supposed to be located in installer/data/<dbms>/<language>/marcflavour/marcflavourname >+# Where <dbms> is database type according to DBD syntax >+# Where <language> is en|fr or any international abbreviation (provided language hash is updated... This will be a problem with internationlisation.) >+# Where <level> is a category of requirement : required, recommended optional >+# level should contain : >+# SQL File for import With a readable name. >+# txt File taht explains what this SQL File is meant for. >+# Could be VERY useful to have A Big file for a kind of library. >+# But could also be useful to have some Authorised values data set prepared here. >+# Marcflavour Selection is achieved through radiobuttons. > my $langchoice = $query->param('fwklanguage'); > > $langchoice = $query->cookie('KohaOpacLanguage') unless ($langchoice); >- $langchoice =~ s/[^a-zA-Z_-]*//g; >+ $langchoice =~ s/[^a-zA-Z_-]*//g; > my $dir = >- C4::Context->config('intranetdir') . "/installer/data/$info{dbms}/$langchoice/marcflavour"; >- unless (opendir( MYDIR, $dir )) { >- if ($langchoice eq 'en') { >+ C4::Context->config('intranetdir') >+ . "/installer/data/$info{dbms}/$langchoice/marcflavour"; >+ unless ( opendir( MYDIR, $dir ) ) { >+ if ( $langchoice eq 'en' ) { > warn "cannot open MARC frameworks directory $dir"; >- } else { >+ } >+ else { > # if no translated MARC framework is available, > # default to English >- $dir = C4::Context->config('intranetdir') . "/installer/data/$info{dbms}/en/marcflavour"; >- opendir(MYDIR, $dir) or warn "cannot open English MARC frameworks directory $dir"; >+ $dir = C4::Context->config('intranetdir') >+ . "/installer/data/$info{dbms}/en/marcflavour"; >+ opendir( MYDIR, $dir ) >+ or warn "cannot open English MARC frameworks directory $dir"; > } > } > my @listdir = grep { !/^\./ && -d "$dir/$_" } readdir(MYDIR); > closedir MYDIR; >- my $marcflavour=C4::Context->preference("marcflavour"); >+ my $marcflavour = C4::Context->preference("marcflavour"); > my @flavourlist; > foreach my $marc (@listdir) { >- my %cell=( >- "label"=> ucfirst($marc), >- "code"=>uc($marc), >- "checked"=> defined($marcflavour) ? uc($marc) eq $marcflavour : 0); >+ my %cell = ( >+ "label" => ucfirst($marc), >+ "code" => uc($marc), >+ "checked" => defined($marcflavour) >+ ? uc($marc) eq $marcflavour >+ : 0 >+ ); >+ > # $cell{"description"}= do { local $/ = undef; open INPUT "<$dir/$marc.txt"||"";<INPUT> }; > push @flavourlist, \%cell; > } > $template->param( "flavourloop" => \@flavourlist ); >- $template->param( "$op" => 1 ); >+ $template->param( "$op" => 1 ); > } > elsif ( $op && $op eq 'importdatastructure' ) { > # >@@ -340,7 +365,7 @@ elsif ( $step && $step == 3 ) { > # > #Do updatedatabase And report > >- if ( ! defined $ENV{PERL5LIB} ) { >+ if ( !defined $ENV{PERL5LIB} ) { > my $find = "C4/Context.pm"; > my $path = $INC{$find}; > $path =~ s/\Q$find\E//; >@@ -348,59 +373,76 @@ elsif ( $step && $step == 3 ) { > warn "# plack? inserted PERL5LIB $ENV{PERL5LIB}\n"; > } > >- my $now = POSIX::strftime( "%Y-%m-%dT%H:%M:%S", localtime() ); >- my $logdir = C4::Context->config('logdir'); >- my $dbversion = C4::Context->preference('Version'); >+ my $now = POSIX::strftime( "%Y-%m-%dT%H:%M:%S", localtime() ); >+ my $logdir = C4::Context->config('logdir'); >+ my $dbversion = C4::Context->preference('Version'); > my $kohaversion = Koha::version; > $kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/; > > my $filename_suffix = join '_', $now, $dbversion, $kohaversion; >- my ( $logfilepath, $logfilepath_errors ) = ( chk_log($logdir, "updatedatabase_$filename_suffix"), chk_log($logdir, "updatedatabase-error_$filename_suffix") ); >+ my ( $logfilepath, $logfilepath_errors ) = ( >+ chk_log( $logdir, "updatedatabase_$filename_suffix" ), >+ chk_log( $logdir, "updatedatabase-error_$filename_suffix" ) >+ ); > >- my $cmd = C4::Context->config("intranetdir") . "/installer/data/$info{dbms}/updatedatabase.pl >> $logfilepath 2>> $logfilepath_errors"; >+ my $cmd = C4::Context->config("intranetdir") >+ . "/installer/data/$info{dbms}/updatedatabase.pl >> $logfilepath 2>> $logfilepath_errors"; > > system($cmd ); > > my $fh; >- open( $fh, "<", $logfilepath ) or die "Cannot open log file $logfilepath: $!"; >+ open( $fh, "<", $logfilepath ) >+ or die "Cannot open log file $logfilepath: $!"; > my @report = <$fh>; > close $fh; > if (@report) { >- $template->param( update_report => [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ] ); >+ $template->param( update_report => >+ [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ] >+ ); > $template->param( has_update_succeeds => 1 ); >- } else { >- eval{ `rm $logfilepath` }; > } >- open( $fh, "<", $logfilepath_errors ) or die "Cannot open log file $logfilepath_errors: $!"; >+ else { >+ eval { `rm $logfilepath` }; >+ } >+ open( $fh, "<", $logfilepath_errors ) >+ or die "Cannot open log file $logfilepath_errors: $!"; > @report = <$fh>; > close $fh; > if (@report) { >- $template->param( update_errors => [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ] ); >+ $template->param( update_errors => >+ [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ] >+ ); > $template->param( has_update_errors => 1 ); >- warn "The following errors were returned while attempting to run the updatedatabase.pl script:\n"; >+ warn >+"The following errors were returned while attempting to run the updatedatabase.pl script:\n"; > foreach my $line (@report) { warn "$line\n"; } >- } else { >- eval{ `rm $logfilepath_errors` }; >+ } >+ else { >+ eval { `rm $logfilepath_errors` }; > } > $template->param( $op => 1 ); > } > else { >- # >- # check whether it's a 1st install or an update >- # >- #Check if there are enough tables. >- # Paul has cleaned up tables so reduced the count >- #I put it there because it implied a data import if condition was not satisfied. >+# >+# check whether it's a 1st install or an update >+# >+#Check if there are enough tables. >+# Paul has cleaned up tables so reduced the count >+#I put it there because it implied a data import if condition was not satisfied. > my $dbh = DBI->connect( >- "DBI:$info{dbms}:dbname=$info{dbname};host=$info{hostname}" >- . ( $info{port} ? ";port=$info{port}" : "" ), >- $info{'user'}, $info{'password'} >+ "DBI:$info{dbms}:dbname=$info{dbname};host=$info{hostname}" >+ . ( $info{port} ? ";port=$info{port}" : "" ), >+ $info{'user'}, $info{'password'} > ); >- my $rq; >- if ( $info{dbms} eq 'mysql' ) { $rq = $dbh->prepare( "SHOW TABLES" ); } >- elsif ( $info{dbms} eq 'Pg' ) { $rq = $dbh->prepare( "SELECT * >+ my $rq; >+ if ( $info{dbms} eq 'mysql' ) { $rq = $dbh->prepare("SHOW TABLES"); } >+ elsif ( $info{dbms} eq 'Pg' ) { >+ $rq = $dbh->prepare( >+ "SELECT * > FROM information_schema.tables >- WHERE table_schema='public' and table_type='BASE TABLE';" ); } >+ WHERE table_schema='public' and table_type='BASE TABLE';" >+ ); >+ } > $rq->execute; > my $data = $rq->fetchall_arrayref( {} ); > my $count = scalar(@$data); >@@ -411,23 +453,24 @@ elsif ( $step && $step == 3 ) { > $template->param( "count" => $count, "proposeimport" => 1 ); > } > else { >- # >- # we have tables, propose to select files to upload or updatedatabase >- # >+ # >+ # we have tables, propose to select files to upload or updatedatabase >+ # > $template->param( "count" => $count, "default" => 1 ); >- # >- # 1st part of step 3 : check if there is a databaseversion systempreference >- # if there is, then we just need to upgrade >- # if there is none, then we need to install the database >- # >- if (C4::Context->preference('Version')) { >+ # >+ # 1st part of step 3 : check if there is a databaseversion systempreference >+ # if there is, then we just need to upgrade >+ # if there is none, then we need to install the database >+ # >+ if ( C4::Context->preference('Version') ) { > my $dbversion = C4::Context->preference('Version'); > $dbversion =~ /(.*)\.(..)(..)(...)/; > $dbversion = "$1.$2.$3.$4"; >- $template->param("upgrading" => 1, >- "dbversion" => $dbversion, >- "kohaversion" => Koha::version(), >- ); >+ $template->param( >+ "upgrading" => 1, >+ "dbversion" => $dbversion, >+ "kohaversion" => Koha::version(), >+ ); > } > } > } >@@ -445,7 +488,8 @@ else { > if ( $rq->execute ) { > my ($version) = $rq->fetchrow; > if ($version) { >- print $query->redirect("/cgi-bin/koha/installer/install.pl?step=3"); >+ print $query->redirect( >+ "/cgi-bin/koha/installer/install.pl?step=3"); > exit; > } > } >@@ -453,13 +497,15 @@ else { > } > output_html_with_http_headers $query, $cookie, $template->output; > >-sub chk_log { #returns a logfile in $dir or - if that failed - in temp dir >- my ($dir, $name) = @_; >- my $fn=$dir.'/'.$name.'.log'; >- if( ! open my $fh, '>', $fn ) { >- $name.= '_XXXX'; >+sub chk_log { #returns a logfile in $dir or - if that failed - in temp dir >+ my ( $dir, $name ) = @_; >+ my $fn = $dir . '/' . $name . '.log'; >+ if ( !open my $fh, '>', $fn ) { >+ $name .= '_XXXX'; > require File::Temp; >- ($fh, $fn)= File::Temp::tempfile( $name, TMPDIR => 1, SUFFIX => '.log'); >+ ( $fh, $fn ) = >+ File::Temp::tempfile( $name, TMPDIR => 1, SUFFIX => '.log' ); >+ > #if this should not work, let croak take over > } > return $fn; >diff --git a/installer/onboarding.pl b/installer/onboarding.pl >index 0dbdc27..c6195a2 100755 >--- a/installer/onboarding.pl >+++ b/installer/onboarding.pl >@@ -1,29 +1,25 @@ > #!/usr/bin/perl > > # This file is part of Koha. >-# # >-# # Copyright (C) YEAR YOURNAME-OR-YOUREMPLOYER >-# # >-# # 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, see <http://www.gnu.org/licenses>. >- >+# >+# Copyright (C) YEAR YOURNAME-OR-YOUREMPLOYER >+# >+# 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, see <http://www.gnu.org/licenses>. > > #Recommended pragmas >-use strict; >-use warnings; >-use diagnostics; >- > use Modern::Perl; >+use diagnostics; > use C4::InstallAuth; > use CGI qw ( -utf8 ); > use List::MoreUtils qw/uniq/; >@@ -39,7 +35,7 @@ use C4::Members::Attributes; > use C4::Members::AttributeTypes; > use C4::Log; > use C4::Letters; >-use C4::Form::MessagingPreferences; >+use C4::Form::MessagingPreferences; > use Koha::AuthorisedValues; > use Koha::Patron::Debarments; > use Koha::Cities; >@@ -60,449 +56,510 @@ use Koha::IssuingRule; > use Koha::IssuingRules; > > #Setting variables >-my $input = new CGI; >-my $query = new CGI; >-my $step = $query->param('step'); >+my $input = new CGI; >+my $step = $input->param('step'); > > #Getting the appropriate template to display to the user >-my ( $template, $loggedinuser, $cookie) = C4::InstallAuth::get_template_and_user( >- { >- template_name => "/onboarding/onboardingstep" . ( $step ? $step : 0 ) . ".tt", >- query => $query, >- type => "intranet", >+my ( $template, $loggedinuser, $cookie ) = >+ C4::InstallAuth::get_template_and_user( >+ { >+ template_name => "/onboarding/onboardingstep" >+ . ( $step ? $step : 0 ) . ".tt", >+ query => $input, >+ type => "intranet", > authnotrequired => 0, > debug => 1, > } >-); >+ ); > > #Check database connection > my %info; > $info{'dbname'} = C4::Context->config("database"); >-$info{'dbms'} = >-( C4::Context->config("db_scheme") >+$info{'dbms'} = ( >+ C4::Context->config("db_scheme") > ? C4::Context->config("db_scheme") >- : "mysql" ); >+ : "mysql" >+); > > $info{'hostname'} = C4::Context->config("hostname"); > $info{'port'} = C4::Context->config("port"); > $info{'user'} = C4::Context->config("user"); > $info{'password'} = C4::Context->config("pass"); > my $dbh = DBI->connect( >- "DBI:$info{dbms}:dbname=$info{dbname};host=$info{hostname}" >- . ( $info{port} ? ";port=$info{port}" : "" ), >- $info{'user'}, $info{'password'} >+ "DBI:$info{dbms}:dbname=$info{dbname};host=$info{hostname}" >+ . ( $info{port} ? ";port=$info{port}" : "" ), >+ $info{'user'}, $info{'password'} > ); > >- > #Store the value of the template input name='op' in the variable $op so we can check if the user has pressed the button with the name="op" and value="finish" meaning the user has finished the onboarding tool. >-my $op = $query->param('op'); >-$template->param('op'=>$op); >-if ( $op && $op eq 'finish' ) { #If the value of $op equals 'finish' then redirect user to /cgi-bin/koha/mainpage.pl >- print $query->redirect("/cgi-bin/koha/mainpage.pl"); >+my $op = $input->param('op'); >+$template->param( 'op' => $op ); >+if ( $op && $op eq 'finish' ) >+{ #If the value of $op equals 'finish' then redirect user to /cgi-bin/koha/mainpage.pl >+ print $input->redirect("/cgi-bin/koha/mainpage.pl"); > exit; > } > >- > #Store the value of the template input name='start' in the variable $start so we can check if the user has pressed this button and started the onboarding tool process >-my $start = $query->param('start'); >-$template->param('start'=>$start); >- >-if ( $start && $start eq 'Start setting up my Koha' ){ >- my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); >- $template->param(libraries => $libraries, >- group_types => [ >- { categorytype => 'searchdomain', >- categories => [ Koha::LibraryCategories->search( { categorytype => 'searchdomain' } ) ], >- }, >- { categorytype => 'properties', >- categories => [ Koha::LibraryCategories->search( { categorytype => 'properties' } ) ], >- }, >- ] >- ); >+my $start = $input->param('start'); >+$template->param( 'start' => $start ); > >+if ( $start && $start eq 'Start setting up my Koha' ) { >+ my $libraries = >+ Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); >+ $template->param( >+ libraries => $libraries, >+ group_types => [ >+ { >+ categorytype => 'searchdomain', >+ categories => [ >+ Koha::LibraryCategories->search( >+ { categorytype => 'searchdomain' } >+ ) >+ ], >+ }, >+ { >+ categorytype => 'properties', >+ categories => [ >+ Koha::LibraryCategories->search( >+ { categorytype => 'properties' } >+ ) >+ ], >+ }, >+ ] >+ ); >+} >+elsif ( $start && $start eq 'Add a patron category' ) { > >-}elsif ( $start && $start eq 'Add a patron category' ){ > #Select all the patron category records in the categories database table and give them to the template > my $categories = Koha::Patron::Categories->search(); >- $template->param( >- categories => $categories, >- ); >+ $template->param( categories => $categories, ); > >+#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1 >+} >+elsif ( $start && $start eq 'Add an item type' ) { > >-#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1 >-}elsif ( $step && $step == 1 ) { >- my $createlibrary = $query->param('createlibrary'); #Store the inputted library branch code and name in $createlibrary variable >- $template->param('createlibrary'=>$createlibrary); # Hand the library values back to the template in the createlibrary variable >+ my $itemtypes = Koha::ItemTypes->search(); >+ $template->param( itemtypes => $itemtypes, ); >+} >+elsif ( $step && $step == 1 ) { >+ my $createlibrary = $input->param('createlibrary'); #Store the inputted library branch code and name in $createlibrary variable >+ $template->param( 'createlibrary' => $createlibrary ); # Hand the library values back to the template in the createlibrary variable > > #store inputted parameters in variables >- my $branchcode = $input->param('branchcode'); >+ my $branchcode = $input->param('branchcode'); > $branchcode = uc($branchcode); >- my $categorycode = $input->param('categorycode'); >- my $op = $input->param('op') || 'list'; >+ my $categorycode = $input->param('categorycode'); >+ my $op = $input->param('op') || 'list'; > my $message; > my $library; > > #Take the text 'branchname' and store it in the @fields array > my @fields = qw( >- branchname >+ branchname > ); > >- $template->param('branchcode'=>$branchcode); >- $branchcode =~ s|\s||g; # Use a regular expression to check the value of the inputted branchcode >+ $template->param( 'branchcode' => $branchcode ); >+ $branchcode =~ s|\s||g; # Use a regular expression to check the value of the inputted branchcode > >- #Create a new library object and store the branchcode and @fields array values in this new library object >+#Create a new library object and store the branchcode and @fields array values in this new library object > my $library = Koha::Library->new( >- { branchcode => $branchcode, >+ { >+ branchcode => $branchcode, > ( map { $_ => scalar $input->param($_) || undef } @fields ) > } > ); > > eval { $library->store; }; #Use the eval{} function to store the library object >- if($library){ >- $message = 'success_on_insert'; >- }else{ >- $message = 'error_on_insert'; >+ if ($library) { >+ $message = 'success_on_insert'; > } >- >- $template->param('message' => $message); >- >+ else { >+ $message = 'error_on_insert'; >+ } >+ $template->param( 'message' => $message ); > > #Check if the $step variable equals 2 i.e. the user has clicked to create a patron category in the create patron category screen 1 >-}elsif ( $step && $step == 2 ){ >- my $createcat = $query->param('createcat'); #Store the inputted category code and name in $createcat >- $template->param('createcat'=>$createcat); >- >- #Initialising values >- my $searchfield = $input->param('description') // q||; >- my $categorycode = $input->param('categorycode'); >- my $op = $input->param('op') // 'list'; >- my $message; >- my $category; >- $template->param('categorycode' =>$categorycode); >- >- my ( $template, $loggedinuser, $cookie ) = C4::InstallAuth::get_template_and_user( >- { >- template_name => "/onboarding/onboardingstep2.tt", >- query => $input, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => { parameters => 'parameters_remaining_permissions' }, >- debug => 1, >+} >+elsif ( $step && $step == 2 ) { >+ my $createcat = $input->param('createcat'); #Store the inputted category code and name in $createcat >+ $template->param( 'createcat' => $createcat ); >+ >+ #Initialising values >+ my $searchfield = $input->param('description') // q||; >+ my $categorycode = $input->param('categorycode'); >+ my $op = $input->param('op') // 'list'; >+ my $message; >+ my $category; >+ $template->param( 'categorycode' => $categorycode ); >+ >+ my ( $template, $loggedinuser, $cookie ) = >+ C4::InstallAuth::get_template_and_user( >+ { >+ template_name => "/onboarding/onboardingstep2.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => >+ { parameters => 'parameters_remaining_permissions' }, >+ debug => 1, > } >- ); >- >+ ); >+ > #Once the user submits the page, this code validates the input and adds it >- #to the database as a new patron category >+ #to the database as a new patron category > $categorycode = $input->param('categorycode'); >- my $description = $input->param('description'); >+ my $description = $input->param('description'); > my $overduenoticerequired = $input->param('overduenoticerequired'); >- my $category_type = $input->param('category_type'); >- my $default_privacy = $input->param('default_privacy'); >- my $enrolmentperiod = $input->param('enrolmentperiod'); >- my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef; >+ my $category_type = $input->param('category_type'); >+ my $default_privacy = $input->param('default_privacy'); >+ my $enrolmentperiod = $input->param('enrolmentperiod'); >+ my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef; > > #Converts the string into a date format >- if ( $enrolmentperioddate) { >- $enrolmentperioddate = output_pref( >- { >- dt => dt_from_string($enrolmentperioddate), >- dateformat => 'iso', >- dateonly => 1, >- } >- ); >+ if ($enrolmentperioddate) { >+ $enrolmentperioddate = output_pref( >+ { >+ dt => dt_from_string($enrolmentperioddate), >+ dateformat => 'iso', >+ dateonly => 1, >+ } >+ ); >+ } >+ >+ #Adds a new patron category to the database >+ $category = Koha::Patron::Category->new( >+ { >+ categorycode => $categorycode, >+ description => $description, >+ overduenoticerequired => $overduenoticerequired, >+ category_type => $category_type, >+ default_privacy => $default_privacy, >+ enrolmentperiod => $enrolmentperiod, >+ enrolmentperioddate => $enrolmentperioddate, > } >+ ); > >-#Adds a new patron category to the database >- $category = Koha::Patron::Category->new({ >- categorycode=> $categorycode, >- description => $description, >- overduenoticerequired => $overduenoticerequired, >- category_type=> $category_type, >- default_privacy => $default_privacy, >- enrolmentperiod => $enrolmentperiod, >- enrolmentperioddate => $enrolmentperioddate, >- }); >- >- eval { >- $category->store; >- }; >+ eval { $category->store; }; > >-#Error messages >- if($category){ >- $message = 'success_on_insert'; >- }else{ >- $message = 'error_on_insert'; >- } >+ #Error messages >+ if ($category) { >+ $message = 'success_on_insert'; >+ } >+ else { >+ $message = 'error_on_insert'; >+ } > >- $template->param('message' => $message); >+ $template->param( 'message' => $message ); > >-#Create a patron >-}elsif ( $step && $step == 3 ){ >- my $firstpassword = $input->param('password'); >+ #Create a patron >+} >+elsif ( $step && $step == 3 ) { >+ my $firstpassword = $input->param('password'); > my $secondpassword = $input->param('password2'); > > #Find all library records in the database and hand them to the template to display in the library dropdown box >- my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); >- $template->param(libraries => $libraries, >- group_types => [ >- { categorytype => 'searchdomain', >- categories => [ Koha::LibraryCategories->search( { categorytype => 'searchdomain' } ) ], >- }, >- { categorytype => 'properties', >- categories => [ Koha::LibraryCategories->search( { categorytype => 'properties' } ) ], >- }, >- ] >+ my $libraries = >+ Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); >+ $template->param( >+ libraries => $libraries, >+ group_types => [ >+ { >+ categorytype => 'searchdomain', >+ categories => [ >+ Koha::LibraryCategories->search( >+ { categorytype => 'searchdomain' } >+ ) >+ ], >+ }, >+ { >+ categorytype => 'properties', >+ categories => [ >+ Koha::LibraryCategories->search( >+ { categorytype => 'properties' } >+ ) >+ ], >+ }, >+ ] > ); > > #Find all patron categories in the database and hand them to the template to display in the patron category dropdown box >- my $categories= Koha::Patron::Categories->search(); >- $template->param( >- categories => $categories, >- ); >+ my $categories = Koha::Patron::Categories->search(); >+ $template->param( categories => $categories, ); > > #Incrementing the highest existing patron cardnumber to prevent duplicate cardnumber entry >- my $exisiting_cardnumber = my $sth_search = $dbh->prepare("SELECT MAX(cardnumber) FROM borrowers"); >+ my $exisiting_cardnumber = my $sth_search = >+ $dbh->prepare("SELECT MAX(cardnumber) FROM borrowers"); > my $new_cardnumber = $exisiting_cardnumber + 1; > warn $new_cardnumber; >- $template->param("newcardnumber" => $new_cardnumber); >- >- >+ $template->param( "newcardnumber" => $new_cardnumber ); > > my $op = $input->param('op') // 'list'; > my $minpw = C4::Context->preference("minPasswordLength"); >- $template->param("minPasswordLength" => $minpw); >- >+ $template->param( "minPasswordLength" => $minpw ); > my @messages; > my @errors; >- my $nok = $input->param('nok'); >- my $firstpassword = $input->param('password'); >+ my $nok = $input->param('nok'); >+ my $firstpassword = $input->param('password'); > my $secondpassword = $input->param('password2'); >- my $cardnumber= $input->param('cardnumber'); >- my $borrowernumber= $input->param('borrowernumber'); >- my $userid=$input->param('userid'); >- >-#If the entered cardnumber causes an error hand this error to the @errors array >- if(my $error_code = checkcardnumber($cardnumber, $borrowernumber)){ >- push @errors, $error_code == 1 >- ? 'ERROR_cardnumber_already_exists' >- :$error_code == 2 >- ? 'ERROR_cardnumber_length' >- :() >+ my $cardnumber = $input->param('cardnumber'); >+ my $borrowernumber = $input->param('borrowernumber'); >+ my $userid = $input->param('userid'); >+ >+ #If the entered cardnumber causes an error hand this error to the @errors array >+ if ( my $error_code = checkcardnumber( $cardnumber, $borrowernumber ) ) { >+ push @errors, >+ $error_code == 1 ? 'ERROR_cardnumber_already_exists' >+ : $error_code == 2 ? 'ERROR_cardnumber_length' >+ : (); > } > >-#If the entered password causes an error hand this error to the @errors array >- push @errors, "ERROR_password_mismatch" if $firstpassword ne $secondpassword; >- push @errors, "ERROR_short_password" if ($firstpassword && $minpw && $firstpassword ne '****' && (length($firstpassword) < $minpw)); >+ #If the entered password causes an error hand this error to the @errors array >+ push @errors, "ERROR_password_mismatch" >+ if $firstpassword ne $secondpassword; >+ push @errors, "ERROR_short_password" >+ if ( $firstpassword >+ && $minpw >+ && $firstpassword ne '****' >+ && ( length($firstpassword) < $minpw ) ); > >- >-#Passing errors to template >- $nok = $nok || scalar(@errors); >+ #Passing errors to template >+ $nok = $nok || scalar(@errors); > > #If errors have been generated from the users inputted cardnumber or password then display the error and do not insert the patron into the borrowers table >- if($nok){ >- foreach my $error (@errors){ >- if ($error eq 'ERROR_password_mismatch'){ >- $template->param(errorpasswordmismatch => 1); >- } >- if ($error eq 'ERROR_login_exist'){ >- $template->param(errorloginexists =>1); >- } >- if ($error eq 'ERROR_cardnumber_already_exists'){ >- $template->param(errorcardnumberexists => 1); >- } >- if ($error eq 'ERROR_cardnumber_length'){ >- $template->param(errorcardnumberlength => 1); >- } >- if ($error eq 'ERROR_short_password'){ >- $template->param(errorshortpassword => 1); >- } >- } >- $template->param('nok' => 1); >+ if ($nok) { >+ foreach my $error (@errors) { >+ if ( $error eq 'ERROR_password_mismatch' ) { >+ $template->param( errorpasswordmismatch => 1 ); >+ } >+ if ( $error eq 'ERROR_login_exist' ) { >+ $template->param( errorloginexists => 1 ); >+ } >+ if ( $error eq 'ERROR_cardnumber_already_exists' ) { >+ $template->param( errorcardnumberexists => 1 ); >+ } >+ if ( $error eq 'ERROR_cardnumber_length' ) { >+ $template->param( errorcardnumberlength => 1 ); >+ } >+ if ( $error eq 'ERROR_short_password' ) { >+ $template->param( errorshortpassword => 1 ); >+ } >+ } >+ $template->param( 'nok' => 1 ); > > #Else if no errors have been caused by the users inputted card number or password then insert the patron into the borrowers table >- }else{ >- my ($template, $loggedinuser, $cookie)= C4::InstallAuth::get_template_and_user({ >- template_name => "/onboarding/onboardingstep3.tt", >- query => $input, >- type => "intranet", >+ } >+ else { >+ my ( $template, $loggedinuser, $cookie ) = >+ C4::InstallAuth::get_template_and_user( >+ { >+ template_name => "/onboarding/onboardingstep3.tt", >+ query => $input, >+ type => "intranet", > authnotrequired => 0, >- flagsrequired => {borrowers => 1}, >- debug => 1, >- }); >- >- if($op eq 'add_validate'){ >- my %newdata; >- >-#Store the template form values in the newdata hash >- $newdata{borrowernumber} = $input->param('borrowernumber'); >- $newdata{surname} = $input->param('surname'); >- $newdata{firstname} = $input->param('firstname'); >- $newdata{cardnumber} = $input->param('cardnumber'); >- $newdata{branchcode} = $input->param('libraries'); >- $newdata{categorycode} = $input->param('categorycode_entry'); >- $newdata{userid} = $input->param('userid'); >- $newdata{password} = $input->param('password'); >- $newdata{password2} = $input->param('password2'); >- $newdata{dateexpiry} = '12/10/2016'; >- $newdata{privacy} = "default"; >- >+ flagsrequired => { borrowers => 1 }, >+ debug => 1, >+ } >+ ); >+ >+ if ( $op eq 'add_validate' ) { >+ my %newdata; >+ >+ #Store the template form values in the newdata hash >+ $newdata{borrowernumber} = $input->param('borrowernumber'); >+ $newdata{surname} = $input->param('surname'); >+ $newdata{firstname} = $input->param('firstname'); >+ $newdata{cardnumber} = $input->param('cardnumber'); >+ $newdata{branchcode} = $input->param('libraries'); >+ $newdata{categorycode} = $input->param('categorycode_entry'); >+ $newdata{userid} = $input->param('userid'); >+ $newdata{password} = $input->param('password'); >+ $newdata{password2} = $input->param('password2'); >+ $newdata{dateexpiry} = '12/10/2016'; >+ $newdata{privacy} = "default"; > > #Hand the newdata hash to the AddMember subroutine in the C4::Members module and it creates a patron and hands back a borrowernumber which is being stored >- my $borrowernumber = &AddMember(%newdata); >+ my $borrowernumber = &AddMember(%newdata); > > #Create a hash named member2 and fill it with the borrowernumber of the borrower that has just been created >- my %member2; >- $member2{'borrowernumber'}=$borrowernumber; >+ my %member2; >+ $member2{'borrowernumber'} = $borrowernumber; > > #Perform data validation on the flag that has been handed to onboarding.pl by the template >- my $flag = $input->param('flag'); >- if ($input->param('newflags')) { >- my $dbh=C4::Context->dbh(); >- my @perms = $input->multi_param('flag'); >- my %all_module_perms = (); >- my %sub_perms = (); >- foreach my $perm (@perms) { >- if ($perm !~ /:/) { >- $all_module_perms{$perm} = 1; >- } else { >- my ($module, $sub_perm) = split /:/, $perm, 2; >+ my $flag = $input->param('flag'); >+ if ( $input->param('newflags') ) { >+ my $dbh = C4::Context->dbh(); >+ my @perms = $input->multi_param('flag'); >+ my %all_module_perms = (); >+ my %sub_perms = (); >+ foreach my $perm (@perms) { >+ if ( $perm !~ /:/ ) { >+ $all_module_perms{$perm} = 1; >+ } >+ else { >+ my ( $module, $sub_perm ) = split /:/, $perm, 2; > push @{ $sub_perms{$module} }, $sub_perm; >- } >- } >- >- # construct flags >- my $module_flags = 0; >- my $sth=$dbh->prepare("SELECT bit,flag FROM userflags ORDER BY bit"); >- $sth->execute(); >- while (my ($bit, $flag) = $sth->fetchrow_array) { >- if (exists $all_module_perms{$flag}) { >- $module_flags += 2**$bit; >- } >- } >+ } >+ } >+ >+ # construct flags >+ my $module_flags = 0; >+ my $sth = >+ $dbh->prepare("SELECT bit,flag FROM userflags ORDER BY bit"); >+ $sth->execute(); >+ while ( my ( $bit, $flag ) = $sth->fetchrow_array ) { >+ if ( exists $all_module_perms{$flag} ) { >+ $module_flags += 2**$bit; >+ } >+ } > > #Set the superlibrarian permission of the newly created patron to superlibrarian >- $sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?"); >- $sth->execute($module_flags, $borrowernumber); >- >- >- #Error handling checking if the patron was created successfully >- if(!$borrowernumber){ >- push @messages, {type=> 'error', code => 'error_on_insert'}; >- }else{ >- push @messages, {type=> 'message', code => 'success_on_insert'}; >- } >- } >+ $sth = $dbh->prepare( >+ "UPDATE borrowers SET flags=? WHERE borrowernumber=?"); >+ $sth->execute( $module_flags, $borrowernumber ); >+ >+ #Error handling checking if the patron was created successfully >+ if ( !$borrowernumber ) { >+ push @messages, >+ { type => 'error', code => 'error_on_insert' }; >+ } >+ else { >+ push @messages, >+ { type => 'message', code => 'success_on_insert' }; >+ } >+ } > } > } >- >- }elsif ( $step && $step == 4){ >+} >+elsif ( $step && $step == 4 ) { > my $createitemtype = $input->param('createitemtype'); >- $template->param('createitemtype'=> $createitemtype ); >- >- >- my( $template, $borrowernumber, $cookie) = C4::InstallAuth::get_template_and_user( >- { template_name => "/onboarding/onboardingstep4.tt", >- query => $input, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => { parameters => 'parameters_remaining_permissions'}, >- debug => 1, >- } >- ); >+ $template->param( 'createitemtype' => $createitemtype ); >+ >+ my ( $template, $borrowernumber, $cookie ) = >+ C4::InstallAuth::get_template_and_user( >+ { >+ template_name => "/onboarding/onboardingstep4.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => >+ { parameters => 'parameters_remaining_permissions' }, >+ debug => 1, >+ } >+ ); > >- if($op eq 'add_validate'){ >- my $description = $input->param('description'); >+ if ( $op eq 'add_validate' ) { >+ my $description = $input->param('description'); > my $itemtype_code = $input->param('itemtype'); > $itemtype_code = uc($itemtype_code); >- #Create a new itemtype object using the user inputted itemtype and description >- my $itemtype= Koha::ItemType->new( >- { itemtype => $itemtype_code, >- description => $description, >+ >+ #Create a new itemtype object using the user inputted itemtype and description >+ my $itemtype = Koha::ItemType->new( >+ { >+ itemtype => $itemtype_code, >+ description => $description, > } > ); >- >- eval{ $itemtype->store; }; >- >+ eval { $itemtype->store; }; > my $message; > > #Fill the $message variable with an error if the item type object was not successfully created and inserted into the itemtypes table >- if($itemtype){ >+ if ($itemtype) { > $message = 'success_on_insert'; >- }else{ >+ } >+ else { > $message = 'error_on_insert'; > } >- >- $template->param('message' => $message); >+ $template->param( 'message' => $message ); > } >-}elsif ( $step && $step == 5){ >+} >+elsif ( $step && $step == 5 ) { > >- #Find all the existing categories to display in a dropdown box in the template >+ #Find all the existing categories to display in a dropdown box in the template > my $categories; >- $categories= Koha::Patron::Categories->search(); >- $template->param( >- categories => $categories, >- ); >+ $categories = Koha::Patron::Categories->search(); >+ $template->param( categories => $categories, ); > >- #Find all the exisiting item types to display in a dropdown box in the template >+ #Find all the exisiting item types to display in a dropdown box in the template > my $itemtypes; >- $itemtypes= Koha::ItemTypes->search(); >- $template->param( >- itemtypes => $itemtypes, >- ); >+ $itemtypes = Koha::ItemTypes->search(); >+ $template->param( itemtypes => $itemtypes, ); > >- #Find all the exisiting libraries to display in a dropdown box in the template >- my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); >- $template->param(libraries => $libraries, >- group_types => [ >- { categorytype => 'searchdomain', >- categories => [ Koha::LibraryCategories->search( { categorytype => 'searchdomain' } ) ], >- }, >- { categorytype => 'properties', >- categories => [ Koha::LibraryCategories->search( { categorytype => 'properties' } ) ], >- }, >- ] >+ #Find all the exisiting libraries to display in a dropdown box in the template >+ my $libraries = >+ Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); >+ $template->param( >+ libraries => $libraries, >+ group_types => [ >+ { >+ categorytype => 'searchdomain', >+ categories => [ >+ Koha::LibraryCategories->search( >+ { categorytype => 'searchdomain' } >+ ) >+ ], >+ }, >+ { >+ categorytype => 'properties', >+ categories => [ >+ Koha::LibraryCategories->search( >+ { categorytype => 'properties' } >+ ) >+ ], >+ }, >+ ] > ); > > my $input = CGI->new; >- my $dbh = C4::Context->dbh; >- >- my ($template, $loggedinuser, $cookie) = C4::InstallAuth::get_template_and_user({template_name => "/onboarding/onboardingstep5.tt", >- query => $input, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => {parameters => 'manage_circ_rules'}, >- debug => 1, >- }); >+ my $dbh = C4::Context->dbh; >+ >+ my ( $template, $loggedinuser, $cookie ) = >+ C4::InstallAuth::get_template_and_user( >+ { >+ template_name => "/onboarding/onboardingstep5.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { parameters => 'manage_circ_rules' }, >+ debug => 1, >+ } >+ ); > >-#If no libraries exist then set the $branch value to * >+ #If no libraries exist then set the $branch value to * > my $branch = $input->param('branch'); >- unless ( $branch ) { >- if ( C4::Context->preference('DefaultToLoggedInLibraryCircRules') ) { >- $branch = Koha::Libraries->search->count() == 1 ? undef : C4::Context::mybranch(); >- } >- else { >- $branch = C4::Context::only_my_library() ? ( C4::Context::mybranch() || '*' ) : '*'; >- } >+ unless ($branch) { >+ if ( C4::Context->preference('DefaultToLoggedInLibraryCircRules') ) { >+ $branch = >+ Koha::Libraries->search->count() == 1 >+ ? undef >+ : C4::Context::mybranch(); >+ } >+ else { >+ $branch = >+ C4::Context::only_my_library() >+ ? ( C4::Context::mybranch() || '*' ) >+ : '*'; >+ } > } > $branch = '*' if $branch eq 'NO_LIBRARY_SET'; > my $op = $input->param('op') || q{}; > >- if($op eq 'add_validate'){ >- my $type = $input->param('type'); >- my $br = $input->param('branch'); >- my $bor = $input->param('categorycode'); >- my $itemtype = $input->param('itemtype'); >- my $maxissueqty = $input->param('maxissueqty'); >- my $issuelength = $input->param('issuelength'); >- my $lengthunit = $input->param('lengthunit'); >+ if ( $op eq 'add_validate' ) { >+ my $type = $input->param('type'); >+ my $br = $input->param('branch'); >+ my $bor = $input->param('categorycode'); >+ my $itemtype = $input->param('itemtype'); >+ my $maxissueqty = $input->param('maxissueqty'); >+ my $issuelength = $input->param('issuelength'); >+ my $lengthunit = $input->param('lengthunit'); > my $renewalsallowed = $input->param('renewalsallowed'); >- my $renewalperiod = $input->param('renewalperiod'); >- my $onshelfholds = $input->param('onshelfholds') || 0; >+ my $renewalperiod = $input->param('renewalperiod'); >+ my $onshelfholds = $input->param('onshelfholds') || 0; > $maxissueqty =~ s/\s//g; > $maxissueqty = undef if $maxissueqty !~ /^\d+/; > $issuelength = $issuelength eq q{} ? undef : $issuelength; > >- my $params ={ >+ my $params = { > branchcode => $br, > categorycode => $bor, > itemtype => $itemtype, >@@ -514,80 +571,107 @@ if ( $start && $start eq 'Start setting up my Koha' ){ > onshelfholds => $onshelfholds, > }; > >- my @messages; >+ my @messages; > > #New code from smart-rules.tt starts here. Needs to be added to library > #Allows for the 'All' option to work when selecting all libraries for a circulation rule to apply to. >- if ($branch eq "*") { >- my $sth_search = $dbh->prepare("SELECT count(*) AS total >- FROM default_circ_rules"); >- my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules >+ if ( $branch eq "*" ) { >+ my $sth_search = $dbh->prepare( >+ "SELECT count(*) AS total >+ FROM default_circ_rules" >+ ); >+ my $sth_insert = $dbh->prepare( >+ "INSERT INTO default_circ_rules > (maxissueqty, onshelfholds) >- VALUES (?, ?)"); >- my $sth_update = $dbh->prepare("UPDATE default_circ_rules >- SET maxissueqty = ?, onshelfholds = ?"); >- >- $sth_search->execute(); >- my $res = $sth_search->fetchrow_hashref(); >- if ($res->{total}) { >- $sth_update->execute($maxissueqty, $onshelfholds); >- } else { >- $sth_insert->execute($maxissueqty, $onshelfholds); >- } >- } >+ VALUES (?, ?)" >+ ); >+ my $sth_update = $dbh->prepare( >+ "UPDATE default_circ_rules >+ SET maxissueqty = ?, onshelfholds = ?" >+ ); > >+ $sth_search->execute(); >+ my $res = $sth_search->fetchrow_hashref(); >+ if ( $res->{total} ) { >+ $sth_update->execute( $maxissueqty, $onshelfholds ); >+ } >+ else { >+ $sth_insert->execute( $maxissueqty, $onshelfholds ); >+ } >+ } > > #Allows for the 'All' option to work when selecting all patron categories for a circulation rule to apply to. >- if ($bor eq "*") { >- my $sth_search = $dbh->prepare("SELECT count(*) AS total >- FROM default_circ_rules"); >- my $sth_insert = $dbh->prepare(q| >+ if ( $bor eq "*" ) { >+ my $sth_search = $dbh->prepare( >+ "SELECT count(*) AS total >+ FROM default_circ_rules" >+ ); >+ my $sth_insert = $dbh->prepare( >+ q| > INSERT INTO default_circ_rules > (maxissueqty) > VALUES (?) >- |); >- my $sth_update = $dbh->prepare(q| >+ | >+ ); >+ my $sth_update = $dbh->prepare( >+ q| > UPDATE default_circ_rules > SET maxissueqty = ? >- |); >+ | >+ ); > > $sth_search->execute(); > my $res = $sth_search->fetchrow_hashref(); >- if ($res->{total}) { >+ if ( $res->{total} ) { > $sth_update->execute($maxissueqty); >- } else { >+ } >+ else { > $sth_insert->execute($maxissueqty); > } > } >+ > #Allows for the 'All' option to work when selecting all itemtypes for a circulation rule to apply to >- if ($itemtype eq "*") { >- my $sth_search = $dbh->prepare("SELECT count(*) AS total >+ if ( $itemtype eq "*" ) { >+ my $sth_search = $dbh->prepare( >+ "SELECT count(*) AS total > FROM default_branch_circ_rules >- WHERE branchcode = ?"); >- my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules >+ WHERE branchcode = ?" >+ ); >+ my $sth_insert = $dbh->prepare( >+ "INSERT INTO default_branch_circ_rules > (branchcode, onshelfholds) >- VALUES (?, ?)"); >- my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules >+ VALUES (?, ?)" >+ ); >+ my $sth_update = $dbh->prepare( >+ "UPDATE default_branch_circ_rules > SET onshelfholds = ? >- WHERE branchcode = ?"); >+ WHERE branchcode = ?" >+ ); > $sth_search->execute($branch); > my $res = $sth_search->fetchrow_hashref(); >- if ($res->{total}) { >- $sth_update->execute($onshelfholds, $branch); >- } else { >- $sth_insert->execute($branch, $onshelfholds); >+ if ( $res->{total} ) { >+ $sth_update->execute( $onshelfholds, $branch ); >+ } >+ else { >+ $sth_insert->execute( $branch, $onshelfholds ); > } > } >-#End new code > >- my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br }); >- if($issuingrule){ >- $issuingrule->set($params)->store(); >- push @messages, {type=> 'error', code => 'error_on_insert'};#Stops crash of the onboarding tool if someone makes a circulation rule with the same item type, library and patron categroy as an exisiting circulation rule. >+ #End new code > >- }else{ >- Koha::IssuingRule->new()->set($params)->store(); >- } >+ my $issuingrule = Koha::IssuingRules->find( >+ { categorycode => $bor, itemtype => $itemtype, branchcode => $br } >+ ); >+ if ($issuingrule) { >+ $issuingrule->set($params)->store(); >+ push @messages, >+ { type => 'error', code => 'error_on_insert' >+ }; #Stops crash of the onboarding tool if someone makes a circulation rule with the same item type, library and patron categroy as an exisiting circulation rule. >+ >+ } >+ else { >+ Koha::IssuingRule->new()->set($params)->store(); >+ } > } > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt >index 3965cd9..9de96c8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt >@@ -43,7 +43,6 @@ > </form> > > [%ELSE %] >- <!--Implement if statement to determine if library was succesfully created here....--> > <form name="retrylibrary" method="post" action="onboarding.pl"> > <input type="hidden" name="step" value="1"/> > <h1 align="left">Failed </h1> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt >index 31848b1..7f3d4df 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt >@@ -2,14 +2,12 @@ > [% USE Koha %] > [% USE KohaDates %] > [% USE Price %] >-<!--[% USE Branches %]--> > [% INCLUDE 'doc-head-open.inc' %] > [% IF ( finish ) %]<meta http-equiv="refresh" content="10; url=/cgi-bin/koha/mainpage.pl">[% END%] > [% INCLUDE 'installer-doc-head-close.inc' %] > [% INCLUDE 'calendar.inc' %] > [% INCLUDE 'datatables.inc' %] > >- > <head> > <title>Create Patron</title> > >@@ -124,12 +122,8 @@ $(document).ready(function(){ > <fieldset class="rows"> > <input type="hidden" name="step" value="3"/> > <input type="hidden" name="op" value="add_validate" /> >- <legend id="library_management_lgd">Library Management</legend> >- <p> >- Now we will create a patron with superlibrarian permissions. Login with this to access Koha as a staff member will all permissions. >- </p> >- >- <ol> >+ <legend id="library_management_lgd">Library Management</legend> >+ <ol> > <h3>Patron Identity</h3> > <li> > <label for="surname" class="required">Surname: </label> >@@ -191,12 +185,12 @@ $(document).ready(function(){ > </li> > <li> > <label for="passwordlabel" class="required">Password: </label> >- <input type="password" name="password" pattern="[A-Za-z1-9 ]+" title="Please only enter letters or numbers into this password field" id="password" size="20" value="[% member.password |html %]" class="required" required="required"> >+ <input type="password" name="password" id="password" size="20" value="[% member.password |html %]" class="required" required="required"> > <span class="required">Required</span> > </li> > <li> > <label for="password2" class="required">Confirm password: </label> >- <input type="password" id="password2" pattern="[A-Za-z1-9 ]+" title="Please only enter letters or numbers into this password field" name="password2" size="20" value="" class="required" required="required"> >+ <input type="password" id="password2" name="password2" size="20" value="" class="required" required="required"> > <span class="required">Required</span> > </li> > </ol> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt >index cc58704..9c4a73b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt >@@ -40,7 +40,10 @@ > <div> > <p> Success: New item type created!</p> > <p> To create another item type later and for more setttings <br> >- go to More->Administration->Item types >+ go to: <br><br> >+ More->Administration->Item types <br> >+ or<br> >+ Administration->Item types > </div> > Next up: > <input type="submit" value="Add a circulation rule"/> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/summary.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/summary.tt >index 53a749e..3358fb1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/summary.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/summary.tt >@@ -16,11 +16,13 @@ > <fieldset style="font-size:120%"> > <h2>Library</h2> > <p> To add another library and for more settings, go to </br> >- More > Administration > Libraries and Groups </p> >+ More > Administration > Libraries and groups </p> OR<br> >+ Administration->Libraries and groups > > <h2>Patron Category</h2> > <p>To add another patron category and for more settings, go to</br> >- More > Administration > Patrons and Circulation > Patron Categories</p> >+ More > Administration > Patron Categories</p> OR <br> >+ Administration->Patron categories > > <h2>Patron</h2> > <p>To create another patron, go to Patrons > New Patron. To set the </br> >@@ -28,7 +30,8 @@ > > <h2>Item Type</h2> > <p>To create another item type and for more settings, go to</br> >- More > Administration > Item types </p> >+ More > Administration > Item types </p> OR <br> >+ Administration->Item types > > <h2>Circulation Rule</h2> > <p>To create another circulation rule, go to </br> >diff --git a/summary.pl b/summary.pl >index 992e487..1d7d677 100755 >--- a/summary.pl >+++ b/summary.pl >@@ -21,26 +21,10 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >- >-use CGI qw ( -utf8 ); >-use List::MoreUtils qw/ any /; >-use LWP::Simple; >-use XML::Simple; >-use Config; >- >-use C4::Output; > use C4::Auth; >+use C4::Output; > use C4::Context; >-use C4::Installer; >- >-use Koha; >-use Koha::Acquisition::Currencies; >-use Koha::Patrons; >-use Koha::Caches; >-use Koha::Config::SysPrefs; >-use C4::Members::Statistics; >- >-#use Smart::Comments '####'; >+use C4::Koha; > > my $query = new CGI; > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >-- >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 17855
:
58657
|
58658
|
58659
|
58660
|
58661
|
58662
|
58663
|
58664
|
58665
|
58666
|
58667
|
58668
|
58669
|
58781
|
58782
|
58783
|
58784
|
58785
|
58792
|
58793
|
58794
|
58846
|
58860
|
58861
|
58862
|
58886
|
58892
|
58893
|
58894
|
58895
|
58896
|
58897
|
58898
|
58899
|
58900
|
58901
|
58902
|
58903
|
58904
|
58905
|
58906
|
58907
|
59037
|
59051
|
59140
|
59141
|
59174
|
59188
|
59277
|
59279
|
59280
|
59281
|
59628
|
59703
|
59705
|
59706
|
59707
|
59708
|
59709
|
59710
|
59711
|
59712
|
59742
|
59826
|
59830
|
59840
|
59841
|
59842
|
59856
|
59857
|
60092
|
61667
|
61668
|
61986
|
62186
|
62191
|
62192
|
62193
|
62220
|
62221
|
62222
|
62223
|
62231
|
62233
|
62234
|
62235
|
62236
|
62237
|
62238
|
62239
|
62240
|
62241
|
62242
|
62243
|
62251
|
62252
|
62253
|
62254
|
62255
|
62256
|
62257
|
62258
|
62259
|
62260
|
62261
|
62262
|
62263
|
62281
|
62282
|
62283
|
62284
|
62285
|
62286
|
62287
|
62288
|
62668
|
62669
|
62670
|
62671
|
62672
|
62673
|
62674
|
62675