[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/C4 Acquisition.pm,1.9.2.6,1.9.2.7 Auth.pm,1.36.2.3,
From: |
Henri-Damien LAURENT |
Subject: |
[Koha-cvs] CVS: koha/C4 Acquisition.pm,1.9.2.6,1.9.2.7 Auth.pm,1.36.2.3,1.36.2.4 Context.pm,1.18.2.2,1.18.2.3 Suggestions.pm,1.4.2.1,1.4.2.2 |
Date: |
Fri, 26 Aug 2005 05:21:52 -0700 |
Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24682/C4
Modified Files:
Tag: rel_2_2
Acquisition.pm Auth.pm Context.pm Suggestions.pm
Log Message:
Commiting all that allows Branch Independancy management :
* in acquisition module, an order can be modified/recieved/closed only by a
librarian from the same branch than the librarian that created the basket.
* in catalogue module, an item can be modified/deleted/created only by a
librarian from the same branch as item owner branch
* in members module, a member can be created/modified only by a librarian from
the branch of the member.
Modifying Context.pm :
Adding userenv context variable.
Is set during checkauth or get_template_and_user
Modifying Auth.pm function checkauth : setting userenv context variable
Modifying Acquisition.pm:
* histsearch
* branches
* bookfunds
* getsupplierlistwithlateorders
* getlateorders
* getallorders
* getorders
Add a branch criterium if IndependantBranches is set.
Modifiying Suggestion.pm:
* searchsuggestions Will look first for th Librarian Branch and restrict
search to suggestion made by users from this branch
* countsuggestions Will look first for th Librarian Branch and restrict
search to suggestion made by users from this branch
File Modifiying :
* admin/aqbudget.pl adding a branch selection for budget.
* parameters/aqbudget.tmpl
* admin/aqbookfund.pl adding a branch selection for bookfund
* parameters/aqookfund.tmpl
And adding branch selection to members and items changes.
WARNING: bibid are still used in additem, unlike in HEAD... Shall be soon fixed.
Index: Acquisition.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Acquisition.pm,v
retrieving revision 1.9.2.6
retrieving revision 1.9.2.7
diff -C2 -r1.9.2.6 -r1.9.2.7
*** Acquisition.pm 28 Jun 2005 10:21:29 -0000 1.9.2.6
--- Acquisition.pm 26 Aug 2005 12:21:49 -0000 1.9.2.7
***************
*** 57,60 ****
--- 57,62 ----
&modorder &getsingleorder &invoice &receiveorder
&updaterecorder &newordernum
+ &getsupplierlistwithlateorders
+ &getlateorders
&bookfunds &curconvert &getcurrencies &bookfundbreakdown
***************
*** 392,403 ****
my ($supplierid)address@hidden;
my $dbh = C4::Context->dbh;
! my $sth=$dbh->prepare("Select
count(*),authorisedby,creationdate,aqbasket.basketno,
! closedate,surname,firstname
! from aqorders
! left join aqbasket on aqbasket.basketno=aqorders.basketno
! left join borrowers on
aqbasket.authorisedby=borrowers.borrowernumber
! where booksellerid=? and (quantity > quantityreceived or
! quantityreceived is NULL) and datecancellationprinted is NULL
! group by basketno order by aqbasket.basketno");
$sth->execute($supplierid);
my @results = ();
--- 394,413 ----
my ($supplierid)address@hidden;
my $dbh = C4::Context->dbh;
! my $strsth ="Select
count(*),authorisedby,creationdate,aqbasket.basketno,
! closedate,surname,firstname,aqorders.title
! from aqorders
! left join aqbasket on aqbasket.basketno=aqorders.basketno
! left join borrowers on aqbasket.authorisedby=borrowers.borrowernumber
! where booksellerid=? and (quantity > quantityreceived or
! quantityreceived is NULL) and datecancellationprinted is NULL ";
!
! if (C4::Context->preference("IndependantBranches")) {
! my $userenv = C4::Context->userenv;
! unless ($userenv->{flags} == 1){
! $strsth .= " and (borrowers.branchcode =
'".$userenv->{branch}."' or borrowers.branchcode ='')";
! }
! }
! $strsth.=" group by basketno order by aqbasket.basketno";
! my $sth=$dbh->prepare($strsth);
$sth->execute($supplierid);
my @results = ();
***************
*** 478,494 ****
sub getallorders {
#gets all orders from a certain supplier, orders them alphabetically
! my ($supid)address@hidden;
my $dbh = C4::Context->dbh;
my @results = ();
! my $sth=$dbh->prepare("Select * from aqorders,biblio,biblioitems,aqbasket
where aqbasket.basketno=aqorders.basketno
! and booksellerid=?
! and (cancelledby is NULL or cancelledby = '')
! and (quantityreceived < quantity or quantityreceived is NULL)
! and biblio.biblionumber=aqorders.biblionumber and
biblioitems.biblioitemnumber=
! aqorders.biblioitemnumber
! group by aqorders.biblioitemnumber
! order by
! biblio.title");
! $sth->execute($supid);
while (my $data=$sth->fetchrow_hashref){
push(@results,$data);
--- 488,511 ----
sub getallorders {
#gets all orders from a certain supplier, orders them alphabetically
! my ($supplierid)address@hidden;
my $dbh = C4::Context->dbh;
my @results = ();
! my $strsth ="Select
count(*),authorisedby,creationdate,aqbasket.basketno,
! closedate,surname,firstname,aqorders.title
! from aqorders
! left join aqbasket on aqbasket.basketno=aqorders.basketno
! left join borrowers on aqbasket.authorisedby=borrowers.borrowernumber
! where booksellerid=? and (quantity > quantityreceived or
! quantityreceived is NULL) and datecancellationprinted is NULL ";
!
! if (C4::Context->preference("IndependantBranches")) {
! my $userenv = C4::Context->userenv;
! unless ($userenv->{flags} == 1){
! $strsth .= " and (borrowers.branchcode =
'".$userenv->{branch}."' or borrowers.branchcode ='')";
! }
! }
! $strsth.=" group by basketno order by aqbasket.basketno";
! my $sth=$dbh->prepare($strsth);
! $sth->execute($supplierid);
while (my $data=$sth->fetchrow_hashref){
push(@results,$data);
***************
*** 497,500 ****
--- 514,629 ----
return(scalar(@results),@results);
}
+ =item getsupplierlistwithlateorders
+
+ %results = &getsupplierlistwithlateorders;
+
+ Searches for suppliers with late orders.
+
+ =cut
+ #'
+ sub getsupplierlistwithlateorders {
+ my $delay=shift;
+ my $dbh = C4::Context->dbh;
+ #FIXME NOT quite sure that this operation is valid for DBMs different from
Mysql, HOPING so
+ #should be tested with other DBMs
+
+ my $strsth;
+ my $dbdriver = C4::Context->config("db_scheme")||"mysql";
+ if ($dbdriver eq "mysql"){
+ $strsth="SELECT DISTINCT aqbasket.booksellerid,
aqbooksellers.name
+ FROM aqorders, aqbasket
+ LEFT JOIN aqbooksellers ON
aqbasket.booksellerid = aqbooksellers.id
+ WHERE aqorders.basketno =
aqbasket.basketno AND
+ (closedate < DATE_SUB(CURDATE(
),INTERVAL $delay DAY) AND (datereceived = '' or datereceived is null))
+ ";
+ }else {
+ $strsth="SELECT DISTINCT aqbasket.booksellerid,
aqbooksellers.name
+ FROM aqorders, aqbasket
+ LEFT JOIN aqbooksellers ON aqbasket.aqbooksellerid =
aqbooksellers.id
+ WHERE aqorders.basketno = aqbasket.basketno AND
+ (closedate < (CURDATE( )-(INTERVAL $delay DAY))) AND
(datereceived = '' or datereceived is null))
+ ";
+ }
+ # warn "C4::Acquisition getsupplierlistwithlateorders : ".$strsth;
+ my $sth = $dbh->prepare($strsth);
+ $sth->execute;
+ my %supplierlist;
+ while (my ($id,$name) = $sth->fetchrow) {
+ $supplierlist{$id} = $name;
+ }
+ return %supplierlist;
+ }
+
+ =item getlateorders
+
+ %results = &getlateorders;
+
+ Searches for suppliers with late orders.
+
+ =cut
+ #'
+ sub getlateorders {
+ my $delay=shift;
+ my $supplierid = shift;
+ my $branch = shift;
+
+ my $dbh = C4::Context->dbh;
+ #BEWARE, order of parenthesis and LEFT JOIN is important for speed
+ my $strsth;
+ my $dbdriver = C4::Context->config("db_scheme")||"mysql";
+ # warn " $dbdriver";
+ if ($dbdriver eq "mysql"){
+ $strsth ="SELECT aqbasket.basketno,
+ DATE(aqbasket.closedate) as orderdate,
aqorders.quantity, aqorders.rrp as unitpricesupplier,aqorders.ecost as
unitpricelib,
+ aqorders.quantity * aqorders.rrp as
subtotal, aqbookfund.bookfundname as budget, borrowers.branchcode as branch,
+ aqbooksellers.name as supplier,
+ biblio.title, biblio.author,
biblioitems.publishercode as publisher, biblioitems.publicationyear,
+ DATEDIFF(CURDATE( ),closedate) AS
latesince
+ FROM
+ (( (
+ (aqorders LEFT
JOIN biblio on biblio.biblionumber = aqorders.biblionumber) LEFT JOIN
biblioitems on biblioitems.biblionumber=biblio.biblionumber
+ ) LEFT JOIN
aqorderbreakdown on aqorders.ordernumber = aqorderbreakdown.ordernumber
+ ) LEFT JOIN aqbookfund on
aqorderbreakdown.bookfundid = aqbookfund.bookfundid
+ ),(aqbasket LEFT JOIN borrowers
on aqbasket.authorisedby = borrowers.borrowernumber) LEFT JOIN aqbooksellers ON
aqbasket.booksellerid = aqbooksellers.id
+ WHERE aqorders.basketno =
aqbasket.basketno AND (closedate < DATE_SUB(CURDATE( ),INTERVAL $delay DAY))
+ AND ((datereceived = '' OR datereceived
is null) OR (aqorders.quantityreceived < aqorders.quantity) ) ";
+ $strsth .= " AND aqbasket.booksellerid = $supplierid " if
($supplierid);
+ $strsth .= " AND borrowers.branchcode like \'".$branch."\'" if
($branch);
+ $strsth .= " AND borrowers.branchcode like
\'".C4::Context->userenv->{branch}."\'" if
(C4::Context->preference("IndependantBranches") &&
C4::Context->userenv->{flags}!=1);
+ $strsth .= " ORDER BY latesince,basketno,borrowers.branchcode,
supplier";
+ } else {
+ $strsth ="SELECT aqbasket.basketno,
+ DATE(aqbasket.closedate) as orderdate,
+ aqorders.quantity, aqorders.rrp as
unitpricesupplier,aqorders.ecost as unitpricelib, aqorders.quantity *
aqorders.rrp as subtotal
+ aqbookfund.bookfundname as budget,
borrowers.branchcode as branch,
+ aqbooksellers.name as supplier,
+ biblio.title, biblio.author,
biblioitems.publishercode as publisher, biblioitems.publicationyear,
+ (CURDATE - closedate) AS latesince
+ FROM
+ (( (
+ (aqorders LEFT
JOIN biblio on biblio.biblionumber = aqorders.biblionumber) LEFT JOIN
biblioitems on biblioitems.biblionumber=biblio.biblionumber
+ ) LEFT JOIN
aqorderbreakdown on aqorders.ordernumber = aqorderbreakdown.ordernumber
+ ) LEFT JOIN aqbookfund on
aqorderbreakdown.bookfundid = aqbookfund.bookfundid
+ ),(aqbasket LEFT JOIN borrowers
on aqbasket.authorisedby = borrowers.borrowernumber) LEFT JOIN aqbooksellers ON
aqbasket.booksellerid = aqbooksellers.id
+ WHERE aqorders.basketno =
aqbasket.basketno AND (closedate < (CURDATE -(INTERVAL $delay DAY))
+ AND ((datereceived = '' OR datereceived
is null) OR (aqorders.quantityreceived < aqorders.quantity) ) ";
+ $strsth .= " AND aqbasket.booksellerid = $supplierid " if
($supplierid);
+ $strsth .= " AND borrowers.branchcode like \'".$branch."\'" if
($branch);
+ $strsth .= " AND borrowers.branchcode like
\'".C4::Context->userenv->{branch}."\'" if
(C4::Context->preference("IndependantBranches") &&
C4::Context->userenv->{flags}!=1);
+ $strsth .= " ORDER BY latesince,basketno,borrowers.branchcode,
supplier";
+ }
+ # warn "C4::Acquisition : getlateorders SQL:".$strsth;
+ my $sth = $dbh->prepare($strsth);
+ $sth->execute;
+ my @results;
+ my $hilighted = 1;
+ while (my $data = $sth->fetchrow_hashref) {
+ $data->{hilighted}=$hilighted if ($hilighted>0);
+ push @results, $data;
+ $hilighted= -$hilighted;
+ }
+ $sth->finish;
+ return(scalar(@results),@results);
+ }
# FIXME - Never used
***************
*** 600,606 ****
my ($title,$author,$name,$from_placed_on,$to_placed_on)address@hidden;
my $dbh= C4::Context->dbh;
! my $query = "select
biblio.title,aqorders.basketno,name,aqbasket.creationdate,aqorders.datereceived,
aqorders.quantity, aqorders.ecost from aqorders,aqbasket,aqbooksellers,biblio
! where aqorders.basketno=aqbasket.basketno and
aqbasket.booksellerid=aqbooksellers.id and
! biblio.biblionumber=aqorders.biblionumber";
$query .= " and biblio.title like ".$dbh->quote("%".$title."%") if
$title;
$query .= " and biblio.author like ".$dbh->quote("%".$author."%") if
$author;
--- 729,737 ----
my ($title,$author,$name,$from_placed_on,$to_placed_on)address@hidden;
my $dbh= C4::Context->dbh;
! my $query = "select
biblio.title,aqorders.basketno,name,aqbasket.creationdate,aqorders.datereceived,
aqorders.quantity, aqorders.ecost from aqorders,aqbasket,aqbooksellers,biblio";
!
! $query .= ",borrowers " if
(C4::Context->preference("IndependantBranches"));
! $query .=" where aqorders.basketno=aqbasket.basketno and
aqbasket.booksellerid=aqbooksellers.id and
biblio.biblionumber=aqorders.biblionumber ";
! $query .= " and aqbasket.authorisedby=borrowers.borrowernumber" if
(C4::Context->preference("IndependantBranches"));
$query .= " and biblio.title like ".$dbh->quote("%".$title."%") if
$title;
$query .= " and biblio.author like ".$dbh->quote("%".$author."%") if
$author;
***************
*** 608,611 ****
--- 739,748 ----
$query .= " and creationdate >" .$dbh->quote($from_placed_on) if
$from_placed_on;
$query .= " and creationdate<".$dbh->quote($to_placed_on) if
$to_placed_on;
+ if (C4::Context->preference("IndependantBranches")) {
+ my $userenv = C4::Context->userenv;
+ unless ($userenv->{flags} == 1){
+ $query .= " and (borrowers.branchcode =
'".$userenv->{branch}."' or borrowers.branchcode ='')";
+ }
+ }
warn "C4:Acquisition : ".$query;
my $sth = $dbh->prepare($query);
***************
*** 669,676 ****
sub bookfunds {
my $dbh = C4::Context->dbh;
! my $sth=$dbh->prepare("Select * from aqbookfund,aqbudget where
aqbookfund.bookfundid
! =aqbudget.bookfundid
! group by aqbookfund.bookfundid order by bookfundname");
! $sth->execute;
my @results = ();
while (my $data=$sth->fetchrow_hashref){
--- 806,828 ----
sub bookfunds {
my $dbh = C4::Context->dbh;
! my $userenv = C4::Context->userenv;
! my $branch = $userenv->{branch};
! my $strsth;
!
! if (!($branch eq '')) {
! $strsth="Select * from aqbookfund,aqbudget where aqbookfund.bookfundid
! =aqbudget.bookfundid and (aqbookfund.branchcode is null or
aqbookfund.branchcode='' or aqbookfund.branchcode= ? )
! group by aqbookfund.bookfundid order by bookfundname";
! } else {
! $strsth="Select * from aqbookfund,aqbudget where aqbookfund.bookfundid
! =aqbudget.bookfundid
! group by aqbookfund.bookfundid order by bookfundname";
! }
! my $sth=$dbh->prepare($strsth);
! if (!($branch eq '')){
! $sth->execute($branch);
! } else {
! $sth->execute;
! }
my @results = ();
while (my $data=$sth->fetchrow_hashref){
***************
*** 850,854 ****
sub branches {
my $dbh = C4::Context->dbh;
! my $sth = $dbh->prepare("Select * from branches order by branchname");
my @results = ();
--- 1002,1015 ----
sub branches {
my $dbh = C4::Context->dbh;
! my $sth;
! if (C4::Context->preference("IndependantBranches") &&
(C4::Context->userenv->{flags}!=1)){
! my $strsth ="Select * from branches ";
! $strsth.= " WHERE branchcode =
".$dbh->quote(C4::Context->userenv->{branch});
! $strsth.= " order by branchname";
! warn "C4::Acquisition->branches : ".$strsth;
! $sth=$dbh->prepare($strsth);
! } else {
! $sth = $dbh->prepare("Select * from branches order by branchname");
! }
my @results = ();
Index: Auth.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Auth.pm,v
retrieving revision 1.36.2.3
retrieving revision 1.36.2.4
diff -C2 -r1.36.2.3 -r1.36.2.4
*** Auth.pm 17 Jun 2005 12:31:43 -0000 1.36.2.3
--- Auth.pm 26 Aug 2005 12:21:49 -0000 1.36.2.4
***************
*** 286,290 ****
my $loggedin = 0;
my %info;
! my ($userid, $cookie, $sessionID, $flags);
my $logout = $query->param('logout.x');
if ($userid = $ENV{'REMOTE_USER'}) {
--- 286,290 ----
my $loggedin = 0;
my %info;
! my ($userid, $cookie, $sessionID, $flags,$envcookie);
my $logout = $query->param('logout.x');
if ($userid = $ENV{'REMOTE_USER'}) {
***************
*** 295,299 ****
--- 295,313 ----
$loggedin = 1;
} elsif ($sessionID=$query->cookie('sessionID')) {
+ C4::Context->_new_userenv($sessionID);
+ if (my %hash=$query->cookie('userenv')){
+ C4::Context::set_userenv(
+ $hash{number},
+ $hash{id},
+ $hash{cardnumber},
+ $hash{firstname},
+ $hash{surname},
+ $hash{branch},
+ $hash{flags},
+ $hash{emailaddress},
+ );
+ }
my ($ip , $lasttime);
+
($userid, $ip, $lasttime) = $dbh->selectrow_array(
"SELECT userid,ip,lasttime FROM sessions WHERE
sessionid=?",
***************
*** 302,305 ****
--- 316,320 ----
# voluntary logout the user
$dbh->do("DELETE FROM sessions WHERE sessionID=?", undef,
$sessionID);
+ C4::Context->_unset_userenv($sessionID);
$sessionID = undef;
$userid = undef;
***************
*** 310,349 ****
}
if ($userid) {
! if ($lasttime<time()-$timeout) {
! # timed logout
! $info{'timed_out'} = 1;
! $dbh->do("DELETE FROM sessions WHERE sessionID=?",
undef, $sessionID);
! $userid = undef;
! $sessionID = undef;
! open L, ">>/tmp/sessionlog";
! my $time=localtime(time());
! printf L "%20s from %16s logged out at %30s
(inactivity).\n", $userid, $ip, $time;
! close L;
! } elsif ($ip ne $ENV{'REMOTE_ADDR'}) {
! # Different ip than originally logged in from
! $info{'oldip'} = $ip;
! $info{'newip'} = $ENV{'REMOTE_ADDR'};
! $info{'different_ip'} = 1;
! $dbh->do("DELETE FROM sessions WHERE sessionID=?",
undef, $sessionID);
! $sessionID = undef;
! $userid = undef;
! open L, ">>/tmp/sessionlog";
! my $time=localtime(time());
! printf L "%20s from logged out at %30s (ip changed from
%16s to %16s).\n", $userid, $time, $ip, $info{'newip'};
! close L;
! } else {
! $cookie=$query->cookie(-name => 'sessionID',
! -value => $sessionID,
! -expires => '');
! $dbh->do("UPDATE sessions SET lasttime=? WHERE
sessionID=?",
! undef, (time(), $sessionID));
! $flags = haspermission($dbh, $userid, $flagsrequired);
! if ($flags) {
! $loggedin = 1;
} else {
! $info{'nopermission'} = 1;
}
}
- }
}
unless ($userid) {
--- 325,366 ----
}
if ($userid) {
! if ($lasttime<time()-$timeout) {
! # timed logout
! $info{'timed_out'} = 1;
! $dbh->do("DELETE FROM sessions WHERE
sessionID=?", undef, $sessionID);
! C4::Context->_unset_userenv($sessionID);
! $userid = undef;
! $sessionID = undef;
! open L, ">>/tmp/sessionlog";
! my $time=localtime(time());
! printf L "%20s from %16s logged out at %30s
(inactivity).\n", $userid, $ip, $time;
! close L;
! } elsif ($ip ne $ENV{'REMOTE_ADDR'}) {
! # Different ip than originally logged in from
! $info{'oldip'} = $ip;
! $info{'newip'} = $ENV{'REMOTE_ADDR'};
! $info{'different_ip'} = 1;
! $dbh->do("DELETE FROM sessions WHERE
sessionID=?", undef, $sessionID);
! C4::Context->_unset_userenv($sessionID);
! $sessionID = undef;
! $userid = undef;
! open L, ">>/tmp/sessionlog";
! my $time=localtime(time());
! printf L "%20s from logged out at %30s (ip
changed from %16s to %16s).\n", $userid, $time, $ip, $info{'newip'};
! close L;
} else {
! $cookie=$query->cookie(-name => 'sessionID',
! -value => $sessionID,
! -expires => '');
! $dbh->do("UPDATE sessions SET lasttime=? WHERE
sessionID=?",
! undef, (time(), $sessionID));
! $flags = haspermission($dbh, $userid,
$flagsrequired);
! if ($flags) {
! $loggedin = 1;
! } else {
! $info{'nopermission'} = 1;
! }
}
}
}
unless ($userid) {
***************
*** 351,376 ****
$userid=$query->param('userid');
my $password=$query->param('password');
my ($return, $cardnumber) = checkpw($dbh,$userid,$password);
if ($return) {
! $dbh->do("DELETE FROM sessions WHERE sessionID=? AND userid=?",
! undef, ($sessionID, $userid));
! $dbh->do("INSERT INTO sessions (sessionID, userid, ip,lasttime)
VALUES (?, ?, ?, ?)",
! undef, ($sessionID, $userid, $ENV{'REMOTE_ADDR'},
time()));
! open L, ">>/tmp/sessionlog";
! my $time=localtime(time());
! printf L "%20s from %16s logged in at %30s.\n", $userid,
$ENV{'REMOTE_ADDR'}, $time;
! close L;
! $cookie=$query->cookie(-name => 'sessionID',
! -value => $sessionID,
! -expires => '');
! if ($flags = haspermission($dbh, $userid, $flagsrequired)) {
! $loggedin = 1;
! } else {
! $info{'nopermission'} = 1;
! }
} else {
! if ($userid) {
! $info{'invalid_username_or_password'} = 1;
! }
}
}
--- 368,429 ----
$userid=$query->param('userid');
my $password=$query->param('password');
+ C4::Context->_new_userenv($sessionID);
my ($return, $cardnumber) = checkpw($dbh,$userid,$password);
if ($return) {
! $dbh->do("DELETE FROM sessions WHERE sessionID=? AND
userid=?",
! undef, ($sessionID, $userid));
! $dbh->do("INSERT INTO sessions (sessionID, userid,
ip,lasttime) VALUES (?, ?, ?, ?)",
! undef, ($sessionID, $userid,
$ENV{'REMOTE_ADDR'}, time()));
! open L, ">>/tmp/sessionlog";
! my $time=localtime(time());
! printf L "%20s from %16s logged in at %30s.\n",
$userid, $ENV{'REMOTE_ADDR'}, $time;
! close L;
! $cookie=$query->cookie(-name => 'sessionID',
! -value => $sessionID,
! -expires => '');
! if ($flags = haspermission($dbh, $userid,
$flagsrequired)) {
! $loggedin = 1;
! } else {
! $info{'nopermission'} = 1;
! C4::Context->_unset_userenv($sessionID);
! }
! if ($return == 1){
! my $sth=$dbh->prepare(
! "select
cardnumber,borrowernumber,userid,firstname,surname,flags,branchcode,emailaddress
! from borrowers where userid=?"
! );
! $sth->execute($userid);
! my
($cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress)
= $sth->fetchrow;
! my $hash = C4::Context::set_userenv(
! $bornum,
! $userid,
! $cardnumber,
! $firstname,
! $surname,
! $branchcode,
! $userflags,
! $emailaddress,
! );
! $envcookie=$query->cookie(-name => 'userenv',
! -value => $hash,
! -expires => '');
! } elsif ($return == 2) {
! #We suppose the user is the superlibrarian
! my $hash = C4::Context::set_userenv(
! 0,0,
! C4::Context->config('user'),
! C4::Context->config('user'),
! C4::Context->config('user'),
! "",1,'address@hidden'
! );
! $envcookie=$query->cookie(-name => 'userenv',
! -value => $hash,
! -expires => '');
! }
} else {
! if ($userid) {
! $info{'invalid_username_or_password'} = 1;
! C4::Context->_unset_userenv($sessionID);
! }
}
}
***************
*** 384,388 ****
-expires => '');
}
! return ($userid, $cookie, $sessionID, $flags);
}
# else we have a problem...
--- 437,445 ----
-expires => '');
}
! if ($envcookie){
! return ($userid, [$cookie,$envcookie], $sessionID,
$flags)
! } else {
! return ($userid, $cookie, $sessionID, $flags);
! }
}
# else we have a problem...
Index: Context.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Context.pm,v
retrieving revision 1.18.2.2
retrieving revision 1.18.2.3
diff -C2 -r1.18.2.2 -r1.18.2.3
*** Context.pm 2 Aug 2005 09:01:52 -0000 1.18.2.2
--- Context.pm 26 Aug 2005 12:21:49 -0000 1.18.2.3
***************
*** 233,236 ****
--- 233,238 ----
$self->{"stopwords"} = undef; # stopwords list
$self->{"marcfromkohafield"} = undef; # the hash with relations between
koha table fields and MARC field/subfield
+ $self->{"userenv"} = undef; # User env
+ $self->{"activeuser"} = undef; # current active user
bless $self, $class;
***************
*** 599,602 ****
--- 601,690 ----
}
+ =item userenv
+
+ C4::Context->userenv;
+
+ Builds a hash for user environment variables.
+
+ This hash shall be cached for future use: if you call
+ C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB
access
+
+ set_userenv is called in Auth.pm
+
+ =cut
+ #'
+ sub userenv
+ {
+ my $var = $context->{"activeuser"};
+ return $context->{"userenv"}->{$var} if (defined
$context->{"userenv"}->{$var});
+ warn "NO CONTEXT for $var";
+ }
+
+ =item set_userenv
+
+ C4::Context->set_userenv($usernum, $userid, $usercnum, $userfirstname,
$usersurname, $userbranch, $userflags, $emailaddress);
+
+ Informs a hash for user environment variables.
+
+ This hash shall be cached for future use: if you call
+ C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB
access
+
+ set_userenv is called in Auth.pm
+
+ =cut
+ #'
+ sub set_userenv{
+ my ($usernum, $userid, $usercnum, $userfirstname, $usersurname,
$userbranch, $userflags, $emailaddress)= @_;
+ my $var=$context->{"activeuser"};
+ my $cell = {
+ "number" => $usernum,
+ "id" => $userid,
+ "cardnumber" => $usercnum,
+ # "firstname" => $userfirstname,
+ # "surname" => $usersurname,
+ #possibly a law problem
+ "branch" => $userbranch,
+ "flags" => $userflags,
+ "emailaddress" => $emailaddress,
+ };
+ $context->{userenv}->{$var} = $cell;
+ return $cell;
+ }
+
+ =item _new_userenv
+
+ C4::Context->_new_userenv($session);
+
+ Builds a hash for user environment variables.
+
+ This hash shall be cached for future use: if you call
+ C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB
access
+
+ _new_userenv is called in Auth.pm
+
+ =cut
+ #'
+ sub _new_userenv
+ {
+ shift;
+ my ($sessionID)= @_;
+ $context->{"activeuser"}=$sessionID;
+ }
+
+ =item _unset_userenv
+
+ C4::Context->_unset_userenv;
+
+ Destroys the hash for activeuser user environment variables.
+
+ =cut
+ #'
+
+ sub _unset_userenv
+ {
+ my ($sessionID)= @_;
+ undef $context->{"activeuser"} if ($context->{"activeuser"} eq
$sessionID);
+ }
+
Index: Suggestions.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Suggestions.pm,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -C2 -r1.4.2.1 -r1.4.2.2
*** Suggestions.pm 18 Mar 2005 09:37:56 -0000 1.4.2.1
--- Suggestions.pm 26 Aug 2005 12:21:49 -0000 1.4.2.2
***************
*** 109,112 ****
--- 109,119 ----
$query .= " and status=?";
}
+ if (C4::Context->preference("IndependantBranches")) {
+ my $userenv = C4::Context->userenv;
+ unless ($userenv->{flags} == 1){
+ push @sql_params,$userenv->{branch};
+ $query .= " and (U1.branchcode = ? or U1.branchcode
='')";
+ }
+ }
if ($suggestedbyme) {
if ($suggestedbyme eq -1) {
***************
*** 166,171 ****
my ($status) = @_;
my $dbh = C4::Context->dbh;
! my $sth = $dbh->prepare("select count(*) from suggestions where
status=?");
! $sth->execute($status);
my ($result) = $sth->fetchrow;
return $result;
--- 173,190 ----
my ($status) = @_;
my $dbh = C4::Context->dbh;
! my $sth;
! if (C4::Context->preference("IndependantBranches")){
! my $userenv = C4::Context->userenv;
! if ($userenv->{flags} == 1){
! $sth = $dbh->prepare("select count(*) from suggestions
where status=?");
! $sth->execute($status);
! } else {
! $sth = $dbh->prepare("select count(*) from
suggestions,borrowers where status=? and
borrowers.borrowernumber=suggestions.suggestedby and (borrowers.branchcode=''
or borrowers.branchcode =?)");
! $sth->execute($status,$userenv->{branch});
! }
! } else {
! $sth = $dbh->prepare("select count(*) from suggestions where
status=?");
! $sth->execute($status);
! }
my ($result) = $sth->fetchrow;
return $result;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/C4 Acquisition.pm,1.9.2.6,1.9.2.7 Auth.pm,1.36.2.3,1.36.2.4 Context.pm,1.18.2.2,1.18.2.3 Suggestions.pm,1.4.2.1,1.4.2.2,
Henri-Damien LAURENT <=
- Prev by Date:
[Koha-cvs] CVS: koha/members deletemem.pl,1.4,1.4.2.1 memberentry.pl,1.5.2.5,1.5.2.6 moremember.pl,1.5.2.4,1.5.2.5
- Next by Date:
[Koha-cvs] CVS: koha/acqui basket.pl,1.24.2.5,1.24.2.6 newbiblio.pl,1.21.2.1,1.21.2.2
- Previous by thread:
[Koha-cvs] CVS: koha/members deletemem.pl,1.4,1.4.2.1 memberentry.pl,1.5.2.5,1.5.2.6 moremember.pl,1.5.2.4,1.5.2.5
- Next by thread:
[Koha-cvs] CVS: koha/acqui basket.pl,1.24.2.5,1.24.2.6 newbiblio.pl,1.21.2.1,1.21.2.2
- Index(es):