From fbb50b517f38682ce0f95ccc5a73604969463e4b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 7 Nov 2016 17:02:55 +0100 Subject: [PATCH] Bug 17578: GetMemberDetails - Remove authflags - 1 GetMemberDetails create a authflags key, but this key is only used from 2 different places. One is a very simple script, which does not seem very usefull C4/SIP/interactive_members_dump.pl. I propose to simply remove it. The other one is the member-flags.pl script. What is done in this one is a bit weird since we a doing twice the same query (it was not highlighted before this patch). We will need to fix that later. At the moment the goal it to remove the GetMemberDetails subroutine without introducing any regressions (and so without adding big changes) Test plan: Select/unselect permissions for a patron, save and edit again. The behavior of the permission checkboxes should be ok Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens Signed-off-by: Kyle M Hall --- C4/Members.pm | 18 +----------------- members/member-flags.pl | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 141a20c7be..9a3a5794a3 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -146,12 +146,6 @@ with a true value. See patronflags for more details. -C<$borrower-E{authflags}> is a hash giving more detailed information -about the top-level permissions flags set for the borrower. For example, -if a user has the "editcatalogue" permission, -C<$borrower-E{authflags}-E{editcatalogue}> will exist and have -the value "1". - =cut sub GetMemberDetails { @@ -194,17 +188,7 @@ sub GetMemberDetails { $borrower->{'amountoutstanding'} = $amount; # FIXME - patronflags calls GetMemberAccountRecords... just have patronflags return $amount my $flags = patronflags( $borrower); - my $accessflagshash; - - $sth = $dbh->prepare("select bit,flag from userflags"); - $sth->execute; - while ( my ( $bit, $flag ) = $sth->fetchrow ) { - if ( $borrower->{'flags'} && $borrower->{'flags'} & 2**$bit ) { - $accessflagshash->{$flag} = 1; - } - } $borrower->{'flags'} = $flags; - $borrower->{'authflags'} = $accessflagshash; $borrower->{'is_expired'} = 0; $borrower->{'is_expired'} = 1 if @@ -213,7 +197,7 @@ sub GetMemberDetails { Date_to_Days( Today() ) > Date_to_Days( split /-/, $borrower->{'dateexpiry'} ); - return ($borrower); #, $flags, $accessflagshash); + return ($borrower); } =head2 patronflags diff --git a/members/member-flags.pl b/members/member-flags.pl index 1d73f3808b..26fba762b8 100755 --- a/members/member-flags.pl +++ b/members/member-flags.pl @@ -24,7 +24,7 @@ my $input = new CGI; my $flagsrequired = { permissions => 1 }; my $member=$input->param('member'); -my $bor = GetMemberDetails( $member,''); +my $bor = GetMember( borrowernumber => $member ); if( $bor->{'category_type'} eq 'S' ) { $flagsrequired->{'staffaccess'} = 1; } @@ -85,15 +85,25 @@ if ($input->param('newflags')) { print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member"); } else { -# my ($bor,$flags,$accessflags)=GetMemberDetails($member,''); + my $flags = $bor->{'flags'}; - my $accessflags = $bor->{'authflags'}; - my $dbh=C4::Context->dbh(); + my $accessflags; + my $dbh = C4::Context->dbh(); + # FIXME This needs to be improved to avoid doing the same query + my $sth = $dbh->prepare("select bit,flag from userflags"); + $sth->execute; + while ( my ( $bit, $flag ) = $sth->fetchrow ) { + if ( $bor->{flags} && $bor->{flags} & 2**$bit ) { + $accessflags->{$flag} = 1; + } + } + my $all_perms = get_all_subpermissions(); my $user_perms = get_user_subpermissions($bor->{'userid'}); - my $sth=$dbh->prepare("SELECT bit, flag FROM userflags ORDER BY bit"); + $sth = $dbh->prepare("SELECT bit, flag FROM userflags ORDER BY bit"); $sth->execute; my @loop; + while (my ($bit, $flag) = $sth->fetchrow) { my $checked=''; if ($accessflags->{$flag}) { -- 2.39.5