From 9d54a6437b2d10470ea58a4088a86f51aa0ee918 Mon Sep 17 00:00:00 2001 From: tipaul Date: Fri, 13 Dec 2002 10:21:58 +0000 Subject: [PATCH] adding authentification with Auth.pm --- boraccount.pl | 19 ++++++++++++++----- jmemberentry.pl | 17 +++++++++++++---- mancredit.pl | 13 +++++++++++-- maninvoice.pl | 15 ++++++++++++--- member.pl | 12 ++++++++++-- memberentry.pl | 12 ++++++++++-- members-home.pl | 14 ++++++++------ moremember.pl | 12 ++++++++++-- readingrec.pl | 16 ++++++++++------ reports-home.pl | 13 ++++++++----- 10 files changed, 106 insertions(+), 37 deletions(-) diff --git a/boraccount.pl b/boraccount.pl index e1ec28e8c6..a7ab5146aa 100755 --- a/boraccount.pl +++ b/boraccount.pl @@ -24,6 +24,7 @@ # Suite 330, Boston, MA 02111-1307 USA use strict; +use C4::Auth; use C4::Output; use CGI; use C4::Search; @@ -32,8 +33,16 @@ use HTML::Template; my $input=new CGI; my $theme = $input->param('theme'); # only used if allowthemeoverride is set -my %tmpldata = pathtotemplate ( template => 'boraccount.tmpl', theme => $theme ); -my $template = HTML::Template->new(filename => $tmpldata{'path'}, die_on_bad_params => 0); +#my %tmpldata = pathtotemplate ( template => 'boraccount.tmpl', theme => $theme ); +#my $template = HTML::Template->new(filename => $tmpldata{'path'}, die_on_bad_params => 0); +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "boraccount.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); my $bornum=$input->param('bornum'); #get borrower details @@ -62,12 +71,12 @@ for (my $i=0;$i<$numaccts;$i++){ push(@accountrows, \%row); } -$template->param( startmenumember => startmenu('member'), - endmenumember => endmenu('member'), +$template->param( startmenumember => join('', startmenu('member')), + endmenumember => join('', endmenu('member')), firstname => $data->{'firstname'}, surname => $data->{'surname'}, bornum => $bornum, total => $total, accounts => \@accountrows ); -print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie),$template->output; diff --git a/jmemberentry.pl b/jmemberentry.pl index e7f949d6e7..2592574aad 100755 --- a/jmemberentry.pl +++ b/jmemberentry.pl @@ -22,6 +22,7 @@ # Suite 330, Boston, MA 02111-1307 USA use strict; +use C4::Auth; use C4::Output; use CGI; use C4::Search; @@ -29,7 +30,14 @@ use HTML::Template; my $input = new CGI; -my $template = gettemplate("members/jmemberentry.tmpl"); +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "members/jmemberentry.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); my $member=$input->param('bornum'); if ($member eq ''){ @@ -65,9 +73,10 @@ for (my $i=0;$i<3;$i++){ } -$template->param( startmenumember => startmenu('member'), +$template->param( startmenumember => join('', startmenu('member')), + endmenumember => join('', endmenu('member')), endmenumember => endmenu('member'), - member => $member, + member => $member, firstname => $data->{'firstname'}, surname => $data->{'surname'}, cardnumber => $data->{'cardnumber'}, @@ -85,4 +94,4 @@ $template->param( startmenumember => startmenu('member'), titleloop => \@titledata, cmemloop => \@cmemdata ); -print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie),$template->output; diff --git a/mancredit.pl b/mancredit.pl index afa599fa04..c8bc167568 100755 --- a/mancredit.pl +++ b/mancredit.pl @@ -22,6 +22,7 @@ # Suite 330, Boston, MA 02111-1307 USA use strict; +use C4::Auth; use C4::Output; use CGI; use HTML::Template; @@ -43,7 +44,15 @@ if ($add){ manualinvoice($bornum,$itemnum,$desc,$type,$amount); print $input->redirect("/cgi-bin/koha/moremember.pl?bornum=$bornum"); } else { - my $template = gettemplate("mancredit.tmpl"); + my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "mancredit.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); $template->param( bornum => $bornum); - print "Content-Type: text/html\n\n", $template->output; + print $input->header(-cookie => $cookie),$template->output; + } diff --git a/maninvoice.pl b/maninvoice.pl index ac323c418d..1836fdb5b2 100755 --- a/maninvoice.pl +++ b/maninvoice.pl @@ -22,6 +22,7 @@ # Suite 330, Boston, MA 02111-1307 USA use strict; +use C4::Auth; use C4::Output; use CGI; use C4::Search; @@ -43,7 +44,15 @@ if ($add){ manualinvoice($bornum,$itemnum,$desc,$type,$amount); print $input->redirect("/cgi-bin/koha/moremember.pl?bornum=$bornum"); } else { - my $template=gettemplate("maninvoice.tmpl"); - $template->param( bornum => $bornum); - print "Content-Type: text/html\n\n", $template->output; + my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "maninvoice.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); + $template->param(bornum => $bornum); + print $input->header(-cookie => $cookie),$template->output; + } diff --git a/member.pl b/member.pl index b66c165a45..fbfc688ad6 100755 --- a/member.pl +++ b/member.pl @@ -24,6 +24,7 @@ # Suite 330, Boston, MA 02111-1307 USA use strict; +use C4::Auth; use C4::Output; use CGI; use C4::Search; @@ -38,7 +39,14 @@ my $theme = $input->param('theme') || "default"; #my $template = HTML::Template->new( filename => $tmpldata{'path'}, # die_on_bad_params => 0, # loop_context_vars => 1 ); -my $template = gettemplate("members/member.tmpl"); +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "members/member.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); my $member=$input->param('member'); $member=~ s/\,//g; @@ -70,4 +78,4 @@ $template->param( startmenumember => join ('', startmenu('member')), member => $member, resultsloop => \@resultsdata ); -print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie),$template->output; diff --git a/memberentry.pl b/memberentry.pl index ad2c3bcff8..0b3e3bcdb4 100755 --- a/memberentry.pl +++ b/memberentry.pl @@ -24,6 +24,7 @@ # Suite 330, Boston, MA 02111-1307 USA use strict; +use C4::Auth; use C4::Context; use C4::Output; use CGI; @@ -33,7 +34,14 @@ use HTML::Template; my $input = new CGI; -my $template = gettemplate("members/memberentry.tmpl"); +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "members/memberentry.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); my $member=$input->param('bornum'); if ($member eq ''){ @@ -234,7 +242,7 @@ if ($delete){ cardnumber => $cardnumber, dateofbirth => $data->{'dateofbirth'}); - print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie),$template->output; } diff --git a/members-home.pl b/members-home.pl index 28eb8176bf..1b8429a617 100755 --- a/members-home.pl +++ b/members-home.pl @@ -8,11 +8,13 @@ use C4::Context; use HTML::Template; my $query = new CGI; -my $flagsrequired; -$flagsrequired->{borrowers}=1; -my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 0, $flagsrequired); - -my $template = gettemplate("members/members-home.tmpl"); -$template->param(loggedinuser => $loggedinuser); +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "members/members-home.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); print $query->header(-cookie => $cookie),$template->output; diff --git a/moremember.pl b/moremember.pl index 43b4c98afc..65c3a5763e 100755 --- a/moremember.pl +++ b/moremember.pl @@ -31,6 +31,7 @@ # Suite 330, Boston, MA 02111-1307 USA use strict; +use C4::Auth; use C4::Context; use C4::Output; use CGI; @@ -46,7 +47,14 @@ my $dbh = C4::Context->dbh; my $input = new CGI; -my $template = gettemplate("members/moremember.tmpl"); +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "members/moremember.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); my $bornum=$input->param('bornum'); @@ -195,4 +203,4 @@ $template->param(startmenumember => join('', startmenu('member')), issueloop => \@issuedata, reserveloop => \@reservedata); -print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie),$template->output; diff --git a/readingrec.pl b/readingrec.pl index 7315dc3870..2c72f2e1a7 100755 --- a/readingrec.pl +++ b/readingrec.pl @@ -23,6 +23,7 @@ # Suite 330, Boston, MA 02111-1307 USA use strict; +use C4::Auth; use C4::Output; use CGI; use C4::Search; @@ -46,11 +47,14 @@ if ($limit eq 'full'){ } my ($count,$issues)=allissues($bornum,$order2,$limit); - -#print $input->header; -#print startpage(); -#print startmenu('member'); -my $template = gettemplate("members/readingrec.tmpl"); +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "members/readingrec.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); my @loop_reading; @@ -68,7 +72,7 @@ $template->param(title => $data->{'title'}, bornum => $bornum, limit => $limit, loop_reading => \@loop_reading); -print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie),$template->output; diff --git a/reports-home.pl b/reports-home.pl index 422c1e7d8d..602df139c5 100755 --- a/reports-home.pl +++ b/reports-home.pl @@ -8,9 +8,12 @@ use C4::Context; use HTML::Template; my $query = new CGI; -my ($loggedinuser, $cookie, $sessionID) = checkauth($query); - -my $template = gettemplate("reports/reports-home.tmpl"); -$template->param(loggedinuser => $loggedinuser); - +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "reports/reports-home.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {permissions => 1}, + debug => 1, + }); print $query->header(-cookie => $cookie),$template->output; -- 2.39.5