[LON-CAPA-cvs] cvs: loncom /auth publiccheck.pm /interface lonaboutme.pm portfolio.pm /lonnet/perl lonnet.pm

raeburn raeburn at source.lon-capa.org
Thu Dec 28 10:57:28 EST 2023


raeburn		Thu Dec 28 15:57:28 2023 EDT

  Modified files:              
    /loncom/interface	portfolio.pm lonaboutme.pm 
    /loncom/auth	publiccheck.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Portfolio shareability setting in domain defaults (by affiliation), with
    possible override for an individual user taken into account.
  
  
-------------- next part --------------
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.266 loncom/interface/portfolio.pm:1.267
--- loncom/interface/portfolio.pm:1.266	Sun Sep 18 22:33:45 2022
+++ loncom/interface/portfolio.pm	Thu Dec 28 15:57:27 2023
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # portfolio browser
 #
-# $Id: portfolio.pm,v 1.266 2022/09/18 22:33:45 raeburn Exp $
+# $Id: portfolio.pm,v 1.267 2023/12/28 15:57:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -267,13 +267,16 @@
 
 sub display_directory {
     my ($r,$url,$current_path,$is_empty,$dir_list,$group,$can_upload,
-        $can_modify,$can_delete,$can_setacl)=@_;
+        $can_modify,$can_delete,$can_setacl,$can_viewacl)=@_;
     my $iconpath= $r->dir_config('lonIconsURL') . "/";
     my $select_mode;
     my $checked_files;
     my $port_path = &get_port_path();
     my ($uname,$udom) = &get_name_dom($group);
-    my $access_admin_text = &mt('View Status');
+    my $access_admin_text;
+    if ($can_viewacl) {
+        $access_admin_text = &mt('View Status');
+    }
     if ($can_setacl) {
         $access_admin_text = &mt('View/Change Status');
     }
@@ -514,7 +517,7 @@
 		    }
 		}
                 &display_directory_line($r,$select_mode, $filename, $mtime, $size, $css_class, $line, 
-                                        \%access_controls, $curr_access,$now, $version_flag, $href_location, 
+                                        \%access_controls, $curr_access, $now, $version_flag, $href_location, 
                                         $url, $current_path, $access_admin_text);
 		if ($show_versions) {
 		    foreach my $dir_line (@{ $versioned{$fullpath} }) {
@@ -887,7 +890,7 @@
 }
 
 sub display_access {
-    my ($r,$url,$group,$can_setacl,$port_path,$action) = @_;
+    my ($r,$url,$group,$can_setacl,$can_viewacl,$port_path,$action) = @_;
     my ($uname,$udom) = &get_name_dom($group);
     my $file_name = $env{'form.currentpath'}.$env{'form.access'};
     $file_name = &prepend_group($file_name);
@@ -938,13 +941,21 @@
                         'cancel' => &mt('Return to directory'),
                       };
         &close_form($r,$url,$button_text);
-    } else {
+    } elsif ($can_viewacl) {
         $r->print($header);
         if ($aclcount) {  
             $r->print($info);
         }
         &view_access_settings($r,$url,$access_controls{$file_name},$aclcount);
+    } else {
+        $r->print($header);
+        $r->print(&mt('You do not have sufficient privileges to view access controls').'<br />');
     }
+    my %anchor_fields = (
+        'currentpath' => $env{'form.currentpath'}
+    );
+    $r->print('<br />'.&make_anchor($url, \%anchor_fields, &mt('Return to directory')));
+    return;
 }
 
 sub explain_conditionals {
@@ -2515,6 +2526,7 @@
                       delete => 'delete files',
                       rename => 'rename files',
                       setacl => 'set access controls for files',
+                      viewacl => 'view access controls for files',
     );
     my $escpath = &HTML::Entities::encode($env{'form.currentpath'},'&<>"');
     my $rtnlink = '<a href="'.$url;
@@ -2670,7 +2682,7 @@
         $url = $1.$2;
         $caller = $2;
     }
-    my ($can_modify,$can_delete,$can_upload,$can_setacl);
+    my ($can_modify,$can_delete,$can_upload,$can_setacl,$can_viewacl);
     if ($caller eq 'coursegrp_portfolio') {
     #  Needs to be in a course
         if (! ($env{'request.course.fn'})) {
@@ -2714,6 +2726,7 @@
             $can_delete = 1;
             $can_upload = 1;
             $can_setacl = 1;
+            $can_viewacl = 1;
         } else {
             if (&Apache::lonnet::allowed('agf',$env{'request.course.id'}.'/'.$group)) {
                 $can_setacl = 1;
@@ -2727,6 +2740,9 @@
             if (&Apache::lonnet::allowed('dgf',$env{'request.course.id'}.'/'.$group)) {
                 $can_delete = 1;
             }
+            if (&Apache::lonnet::allowed('rgf',$env{'request.course.id'}.'/'.$group)) {
+                $can_viewacl = 1;
+            }
         }
     } else {
         ($uname,$udom) = &get_name_dom();
@@ -2735,7 +2751,11 @@
         $can_modify = 1;
         $can_delete = 1;
         $can_upload = 1;
-        $can_setacl = 1;
+        if (&Apache::lonnet::usertools_access('','','portaccess',
+                                              undef,'tools')) {
+            $can_viewacl = 1;
+            $can_setacl = 1;
+        }
     }
 
     my $port_path = &get_port_path();
@@ -2916,10 +2936,14 @@
         }
     } elsif ($env{'form.access'}) {
         $env{'form.selectfile'} = $env{'form.access'};
-        if (!defined($env{'form.action'})) { 
+        if (!defined($env{'form.action'})) {
             $env{'form.action'} = 'chgaccess';
         }
-        &display_access($r,$url,$group,$can_setacl,$port_path,$env{'form.action'});
+        if (($can_viewacl) || ($can_setacl)) {
+            &display_access($r,$url,$group,$can_setacl,$can_viewacl,$port_path,$env{'form.action'});
+        } else {
+            &missing_priv($r,$url,'viewacl');
+        }
     } elsif (($env{'form.action'} eq 'chgaccess') || 
              ($env{'form.action'} eq 'chgconditions')) {
         if ($can_setacl) {
@@ -2993,7 +3017,8 @@
 	&display_common($r,$url,$current_path,$is_empty,$dirlistref,
 			$can_upload,$group);
         &display_directory($r,$url,$current_path,$is_empty,$dirlistref,$group,
-                           $can_upload,$can_modify,$can_delete,$can_setacl);
+                           $can_upload,$can_modify,$can_delete,$can_setacl,
+                           $can_viewacl);
     }
     $r->print(&Apache::loncommon::end_page());
     return OK;
Index: loncom/interface/lonaboutme.pm
diff -u loncom/interface/lonaboutme.pm:1.167 loncom/interface/lonaboutme.pm:1.168
--- loncom/interface/lonaboutme.pm:1.167	Thu Dec 28 03:33:15 2023
+++ loncom/interface/lonaboutme.pm	Thu Dec 28 15:57:27 2023
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Personal Information Page
 #
-# $Id: lonaboutme.pm,v 1.167 2023/12/28 03:33:15 raeburn Exp $
+# $Id: lonaboutme.pm,v 1.168 2023/12/28 15:57:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -639,6 +639,10 @@
                        withoutpass => 0,
                        both        => 0,
                      };
+    unless (($is_course) ||
+            (&Apache::lonnet::usertools_access($cnum,$cdom,'portaccess',undef,'tools'))) {
+        return $filecounts;
+    }
     my $current_permissions =
     &Apache::lonnet::get_portfile_permissions($cdom,$cnum);
     my %access_controls =
@@ -697,10 +701,11 @@
     my ($r,$cdom,$cnum,$portaccess,$is_course,$filecounts,$mode,$access_info,
         $allfileshash,$group) = @_;
     my $clientip = &Apache::lonnet::get_requestor_ip($r);
+    my $usercanshare = &Apache::lonnet::usertools_access($cnum,$cdom,'portaccess',undef,'tools');
     foreach my $filename (sort(keys(%{$access_info}))) {
         my $access_status =
            &Apache::lonnet::get_portfolio_access($cdom,$cnum,$filename,$group,$clientip,
-                                                 $access_info->{$filename});
+                                                 $access_info->{$filename},\$usercanshare);
         if ($portaccess eq 'both') {
             if (($access_status ne 'ok') &&
                 ($access_status !~  /^[^:]+:guest_/)) {
Index: loncom/auth/publiccheck.pm
diff -u loncom/auth/publiccheck.pm:1.27 loncom/auth/publiccheck.pm:1.28
--- loncom/auth/publiccheck.pm:1.27	Fri Dec 18 15:23:03 2020
+++ loncom/auth/publiccheck.pm	Thu Dec 28 15:57:28 2023
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Cookie Based Access Handler
 #
-# $Id: publiccheck.pm,v 1.27 2020/12/18 15:23:03 raeburn Exp $
+# $Id: publiccheck.pm,v 1.28 2023/12/28 15:57:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -105,11 +105,16 @@
     my ($r,$udom,$unum,$file_name,$group) = @_;
     my $current_perms = &Apache::lonnet::get_portfile_permissions($udom,$unum);
     my %access_controls = &Apache::lonnet::get_access_controls($current_perms,$group,$file_name);
+    return unless (ref($access_controls{$file_name}) eq 'HASH');
     my $access = '';
     my $now = time;
     my $clientip = &Apache::lonnet::get_requestor_ip($r);
+    my $portaccess = &Apache::lonnet::usertools_access($unum,$udom,'portaccess',undef,'tools');
     foreach my $key (keys(%{$access_controls{$file_name}})) {
         my ($num,$scope,$end,$start) = ($key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/);
+        if (!$portaccess) {
+            next unless ($scope eq 'ip');
+        }
         if ($start > $now) {
             next;
         }
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1520 loncom/lonnet/perl/lonnet.pm:1.1521
--- loncom/lonnet/perl/lonnet.pm:1.1520	Sat Dec 23 02:17:39 2023
+++ loncom/lonnet/perl/lonnet.pm	Thu Dec 28 15:57:28 2023
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1520 2023/12/23 02:17:39 raeburn Exp $
+# $Id: lonnet.pm,v 1.1521 2023/12/28 15:57:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2783,7 +2783,7 @@
         } else {
             $domdefaults{'defaultquota'} = $domconfig{'quotas'};
         }
-        my @usertools = ('aboutme','blog','webdav','portfolio');
+        my @usertools = ('aboutme','blog','webdav','portfolio','portaccess');
         foreach my $item (@usertools) {
             if (ref($domconfig{'quotas'}{$item}) eq 'HASH') {
                 $domdefaults{$item} = $domconfig{'quotas'}{$item};
@@ -7988,7 +7988,7 @@
 }
 
 sub get_portfolio_access {
-    my ($udom,$unum,$file_name,$group,$clientip,$access_hash) = @_;
+    my ($udom,$unum,$file_name,$group,$clientip,$access_hash,$portaccessref) = @_;
 
     if (!ref($access_hash)) {
 	my $current_perms = &get_portfile_permissions($udom,$unum);
@@ -7997,11 +7997,19 @@
 	$access_hash = $access_controls{$file_name};
     }
 
+    my $portaccess;
+    if (ref($portaccess) eq 'SCALAR') {
+        $portaccess = $$portaccessref;
+    } else {
+        $portaccess = &usertools_access($unum,$udom,'portaccess',undef,'tools');
+    }
+
     my ($public,$guest, at domains, at users, at courses, at groups, at ips);
     my $now = time;
     if (ref($access_hash) eq 'HASH') {
         foreach my $key (keys(%{$access_hash})) {
             my ($num,$scope,$end,$start) = ($key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/);
+            next if (($scope ne 'ip') && ($portaccess == 0));
             if ($start > $now) {
                 next;
             }


More information about the LON-CAPA-cvs mailing list