From 5f3749d4374c2e4b508a3ea4e3df9d67cea0078d Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 10 Dec 2002 17:35:27 +0000 Subject: [PATCH] adding authentification with Auth.pm (note : i want to stay the 1st commiter in december as in november :-) ) --- admin-home.pl | 11 ++++++++--- admin/aqbookfund.pl | 15 +++++++++++---- admin/aqbudget.pl | 14 ++++++++++++-- admin/authorised_values.pl | 12 ++++++++++-- admin/branches.pl | 14 +++++++++++--- admin/koha2marclinks.pl | 12 ++++++++++-- admin/marc_subfields_structure.pl | 12 ++++++++++-- admin/marctagstructure.pl | 13 +++++++++++-- admin/systempreferences.pl | 12 ++++++++++-- admin/thesaurus.pl | 13 +++++++++++-- catalogue-home.pl | 12 +++++++++--- mainpage.pl | 11 ++++++++--- userpage.pl | 15 ++++++++++----- 13 files changed, 131 insertions(+), 35 deletions(-) diff --git a/admin-home.pl b/admin-home.pl index 54dfeb1a1d..daa8781252 100755 --- a/admin-home.pl +++ b/admin-home.pl @@ -8,9 +8,14 @@ use C4::Database; use HTML::Template; my $query = new CGI; -my ($loggedinuser, $cookie, $sessionID) = checkauth($query); - -my $template = gettemplate("parameters/admin-home.tmpl"); +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "parameters/admin-home.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); $template->param(loggeninuser => $loggedinuser); print $query->header(-cookie => $cookie),$template->output; diff --git a/admin/aqbookfund.pl b/admin/aqbookfund.pl index 217c2f8197..882e1cabcf 100755 --- a/admin/aqbookfund.pl +++ b/admin/aqbookfund.pl @@ -39,6 +39,7 @@ use strict; use CGI; +use C4::Auth; use C4::Context; use C4::Output; use C4::Search; @@ -73,7 +74,15 @@ my $pagesize=20; my $op = $input->param('op'); $searchfield=~ s/\,//g; -my $template = gettemplate("parameters/aqbookfund.tmpl",0); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "parameters/aqbookfund.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); + if ($op) { $template->param(script_name => $script_name, $op => 1); # we show only the TMPL_VAR names $op @@ -196,6 +205,4 @@ if ($op eq 'add_form') { $template->param(bookfund => \@loop_data); } #---- END $OP eq DEFAULT - - -print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie), $template->output; diff --git a/admin/aqbudget.pl b/admin/aqbudget.pl index 0947a76149..5759516721 100755 --- a/admin/aqbudget.pl +++ b/admin/aqbudget.pl @@ -39,6 +39,7 @@ use strict; use CGI; +use C4::Auth; use C4::Context; use C4::Output; use C4::Search; @@ -75,7 +76,15 @@ my $pagesize=20; my $op = $input->param('op'); $searchfield=~ s/\,//g; -my $template = gettemplate("parameters/aqbudget.tmpl",0); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "parameters/aqbudget.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); + if ($op) { $template->param(script_name => $script_name, $op => 1); # we show only the TMPL_VAR names $op @@ -217,4 +226,5 @@ if ($op eq 'add_form') { $template->param(budget => \@loop_data); } #---- END $OP eq DEFAULT -print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie), $template->output; + diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl index baaa41ad85..2a20ea3815 100755 --- a/admin/authorised_values.pl +++ b/admin/authorised_values.pl @@ -19,6 +19,7 @@ use strict; use CGI; +use C4::Auth; use C4::Context; use C4::Output; use C4::Search; @@ -55,7 +56,14 @@ my $offset=$input->param('offset'); my $script_name="/cgi-bin/koha/admin/authorised_values.pl"; my $dbh = C4::Context->dbh; -my $template = gettemplate("parameters/authorised_values.tmpl",0); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "parameters/authorised_values.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); my $pagesize=20; my $op = $input->param('op'); @@ -180,4 +188,4 @@ if ($op eq 'add_form') { } } #---- END $OP eq DEFAULT -print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie), $template->output; diff --git a/admin/branches.pl b/admin/branches.pl index e5e9311ea5..0e7c14db2e 100755 --- a/admin/branches.pl +++ b/admin/branches.pl @@ -23,6 +23,7 @@ use strict; use CGI; +use C4::Auth; use C4::Context; use C4::Output; use HTML::Template; @@ -42,7 +43,14 @@ my $input = new CGI; my $branchcode=$input->param('branchcode'); my $op = $input->param('op'); -my $template = gettemplate("parameters/branches.tmpl",0); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "parameters/branches.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); if ($op) { $template->param(script_name => $script_name, $op => 1); # we show only the TMPL_VAR names $op @@ -53,7 +61,7 @@ $template->param(script_name => $script_name, $template->param(action => $script_name); if ($op eq 'add') { -# If the user has pressed the "add new branch" button. +# If the user has pressed the "add new branch" button. heading("Branches: Add Branch"); editbranchform(); @@ -368,4 +376,4 @@ sub checkdatabasefor { return $message; } -print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie), $template->output; diff --git a/admin/koha2marclinks.pl b/admin/koha2marclinks.pl index 102cd0e408..ed254ae9e2 100755 --- a/admin/koha2marclinks.pl +++ b/admin/koha2marclinks.pl @@ -20,6 +20,7 @@ use strict; use C4::Output; +use C4::Auth; use CGI; use C4::Search; use C4::Context; @@ -33,7 +34,14 @@ my $kohafield = $input->param('kohafield'); my $op=$input->param('op'); my $script_name = 'koha2marclinks.pl'; -my $template = gettemplate("parameters/koha2marclinks.tmpl",0); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "parameters/koha2marclinks.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); if ($op) { $template->param(script_name => $script_name, @@ -127,4 +135,4 @@ if ($op eq 'add_form') { ); } #---- END $OP eq DEFAULT -print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie), $template->output; diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl index 39c412921e..eb9a56141e 100755 --- a/admin/marc_subfields_structure.pl +++ b/admin/marc_subfields_structure.pl @@ -20,6 +20,7 @@ use strict; use C4::Output; +use C4::Auth; use CGI; use C4::Search; use C4::Context; @@ -55,7 +56,14 @@ my $reqdel="delete from marc_subfield_structure where tagfield='$tagfield' and t my $offset=$input->param('offset'); my $script_name="/cgi-bin/koha/admin/marc_subfields_structure.pl"; -my $template = gettemplate("parameters/marc_subfields_structure.tmpl",0); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "parameters/marc_subfields_structure.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); my $pagesize=30; my $op = $input->param('op'); $tagfield=~ s/\,//g; @@ -339,4 +347,4 @@ if ($op eq 'add_form') { } } #---- END $OP eq DEFAULT -print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie), $template->output; diff --git a/admin/marctagstructure.pl b/admin/marctagstructure.pl index 34c17e049f..c7d2ef31b5 100755 --- a/admin/marctagstructure.pl +++ b/admin/marctagstructure.pl @@ -20,6 +20,7 @@ use strict; use CGI; +use C4::Auth; use C4::Context; use C4::Output; use C4::Search; @@ -55,7 +56,14 @@ my $script_name="/cgi-bin/koha/admin/marctagstructure.pl"; my $dbh = C4::Context->dbh; -my $template = gettemplate("parameters/marctagstructure.tmpl",0); +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "parameters/marctagstructure.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); my $pagesize=20; my $op = $input->param('op'); $searchfield=~ s/\,//g; @@ -186,4 +194,5 @@ if ($op eq 'add_form') { } } #---- END $OP eq DEFAULT -print "Content-Type: text/html\n\n", $template->output; +$template->param(loggeninuser => $loggedinuser); +print $input->header(-cookie => $cookie), $template->output; diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl index e6eea65984..fe4210e9e0 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -39,6 +39,7 @@ use strict; use CGI; +use C4::Auth; use C4::Context; use C4::Output; use C4::Search; @@ -73,7 +74,14 @@ my $reqdel="delete from systempreferences where $pkfield='$searchfield'"; my $offset=$input->param('offset'); my $script_name="/cgi-bin/koha/admin/systempreferences.pl"; -my $template = gettemplate("parameters/systempreferences.tmpl",0); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "parameters/systempreferences.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); my $pagesize=20; my $op = $input->param('op'); $searchfield=~ s/\,//g; @@ -176,4 +184,4 @@ if ($op eq 'add_form') { } } #---- END $OP eq DEFAULT -print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie), $template->output; diff --git a/admin/thesaurus.pl b/admin/thesaurus.pl index c16ad144b5..61bf992eb7 100755 --- a/admin/thesaurus.pl +++ b/admin/thesaurus.pl @@ -19,6 +19,7 @@ use strict; use CGI; +use C4::Auth; use C4::Context; use C4::Output; use C4::Search; @@ -43,7 +44,15 @@ my $script_name="/cgi-bin/koha/admin/thesaurus.pl"; my $dbh = C4::Context->dbh; my $authoritysep = C4::Context->preference("authoritysep"); -my $template = gettemplate("parameters/thesaurus.tmpl",0); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "parameters/thesaurus.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); + my $pagesize=20; my $prevpage = $offset-$pagesize; @@ -247,4 +256,4 @@ if ($op eq 'add_form') { } } #---- END $OP eq DEFAULT -print "Content-Type: text/html\n\n", $template->output; +print $input->header(-cookie => $cookie), $template->output; diff --git a/catalogue-home.pl b/catalogue-home.pl index 0365d19f3c..df94438e7e 100755 --- a/catalogue-home.pl +++ b/catalogue-home.pl @@ -8,8 +8,14 @@ use C4::Database; use HTML::Template; my $query = new CGI; -my ($loggedinuser, $cookie, $sessionID) = checkauth($query); -my $template = gettemplate("catalogue/catalogue-home.tmpl"); +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "catalogue/catalogue-home.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); my $classlist=''; #open C, "$intranetdir/htdocs/includes/cat-class-list.inc"; @@ -18,6 +24,6 @@ my $classlist=''; #} $template->param(loggedinuser => $loggedinuser, classlist => $classlist, - opac => 0); + type => 'intranet',); print $query->header(-cookie => $cookie), $template->output; diff --git a/mainpage.pl b/mainpage.pl index 18772f3743..5a7f605641 100755 --- a/mainpage.pl +++ b/mainpage.pl @@ -8,8 +8,13 @@ use CGI; use C4::Auth; my $query = new CGI; -my ($loggedinuser, $cookie, $sessionID) = checkauth($query); - -my $template = gettemplate("intranet-main.tmpl"); +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "intranet-main.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); print $query->header(-cookie => $cookie), $template->output; diff --git a/userpage.pl b/userpage.pl index 79b08ebe6c..044d0f2e72 100755 --- a/userpage.pl +++ b/userpage.pl @@ -26,11 +26,16 @@ use CGI; use C4::Search; use C4::Auth; -my $query=new CGI; -my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 0); +my $query = new CGI; +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "user/userpage.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); -my $template = gettemplate("user/userpage.tmpl",0); - -$template->param(loggedinuser => $loggedinuser); +warn "userloggedin : $loggedinuser (".$query->param('userid')." et ".$query->param('password'); print $query->header(-cookie => $cookie), $template->output; -- 2.39.5