--- loncom/lonnet/perl/lonnet.pm 2012/11/08 18:37:52 1.1194 +++ loncom/lonnet/perl/lonnet.pm 2012/11/10 13:58:31 1.1196 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1194 2012/11/08 18:37:52 raeburn Exp $ +# $Id: lonnet.pm,v 1.1196 2012/11/10 13:58:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2653,13 +2653,16 @@ sub allowuploaded { # (b) When displaying folder contents in course editor, used to determine if # "Edit" link will be displayed alongside resource. # -# input: 3 args -- filename (decluttered), course number and course domain. -# output: array of four scalars -- +# input: six args -- filename (decluttered), course number, course domain, +# url, symb (if registered) and group (if this is a group +# item -- e.g., bulletin board, group page etc.). +# output: array of five scalars -- # $cfile -- url for file editing if editable on current server # $home -- homeserver of resource (i.e., for author if published, # or course if uploaded.). # $switchserver -- 1 if server switch will be needed. -# $uploaded -- 1 if resource is a file uploaded to a course. +# $forceedit -- 1 if icon/link should be to go to edit mode +# $forceview -- 1 if icon/link should be to go to view mode # sub can_edit_resource { @@ -2800,7 +2803,31 @@ sub is_course_upload { } sub in_course { - my ($udom,$uname,$cdom,$cnum,$type) = @_; + my ($udom,$uname,$cdom,$cnum,$type,$hideprivileged) = @_; + if ($hideprivileged) { + my $skipuser; + if (&privileged($uname,$udom)) { + $skipuser = 1; + my %coursehash = &coursedescription($cdom.'_'.$cnum); + if ($coursehash{'nothideprivileged'}) { + foreach my $item (split(/\s*\,\s*/,$coursehash{'nothideprivileged'})) { + my $user; + if ($item =~ /:/) { + $user = $item; + } else { + $user = join(':',split(/[\@]/,$item)); + } + if ($user eq $uname.':'.$udom) { + undef($skipuser); + last; + } + } + } + if ($skipuser) { + return 0; + } + } + } $type ||= 'any'; if (!defined($cdom) || !defined($cnum)) { my $cid = $env{'request.course.id'}; @@ -2808,7 +2835,7 @@ sub in_course { $cnum = $env{'course.'.$cid.'.num'}; } my $typesref; - if ($type eq 'all') { + if (($type eq 'any') || ($type eq 'all')) { $typesref = ['active','previous','future']; } elsif ($type eq 'previous' || $type eq 'future') { $typesref = [$type]; @@ -12233,6 +12260,17 @@ of role statuses (active, future or prev to restrict the list of roles reported. If no array ref is provided for types, will default to return only active roles. +=item * + +in_course($udom,$uname,$cdom,$cnum,$type,$hideprivileged) : determine if +user: $uname:$udom has a role in the course: $cdom_$cnum. + +Additional optional arguments are: $type (if role checking is to be restricted +to certain user status types -- previous (expired roles), active (currently +available roles) or future (roles available in the future), and +$hideprivileged -- if true will not report course roles for users who +have active Domain Coordinator or Super User roles. + =back =head2 User Modification @@ -12435,7 +12473,6 @@ data base, returning a hash that is keye values that are the resource value. I believe that the timestamps and versions are also returned. - =back =head2 Course Modification @@ -12596,6 +12633,34 @@ expirespread($uname,$udom,$stype,$usymb) devalidate($symb) : devalidate temporary spreadsheet calculations, forcing spreadsheet to reevaluate the resource scores next time. +=item * + +can_edit_resource($file,$cnum,$cdom,$resurl,$symb,$group) : determine if current user can edit a particular resource, +when viewing in course context. + + input: six args -- filename (decluttered), course number, course domain, + url, symb (if registered) and group (if this is a + group item -- e.g., bulletin board, group page etc.). + + output: array of five scalars -- + $cfile -- url for file editing if editable on current server + $home -- homeserver of resource (i.e., for author if published, + or course if uploaded.). + $switchserver -- 1 if server switch will be needed. + $forceedit -- 1 if icon/link should be to go to edit mode + $forceview -- 1 if icon/link should be to go to view mode + +=item * + +is_course_upload($file,$cnum,$cdom) + +Used in course context to determine if current file was uploaded to +the course (i.e., would be found in /userfiles/docs on the course's +homeserver. + + input: 3 args -- filename (decluttered), course number and course domain. + output: boolean -- 1 if file was uploaded. + =back =head2 Storing/Retreiving Data