Bug 17578: GetMemberDetails - Remove authflags - 1
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 7 Nov 2016 16:02:55 +0000 (17:02 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 16 Dec 2016 13:12:41 +0000 (13:12 +0000)
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 <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Members.pm
members/member-flags.pl

index 141a20c..9a3a579 100644 (file)
@@ -146,12 +146,6 @@ with a true value.
 
 See patronflags for more details.
 
-C<$borrower-E<gt>{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<gt>{authflags}-E<gt>{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
index 1d73f38..26fba76 100755 (executable)
@@ -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}) {