--- loncom/lonnet/perl/lonnet.pm 2012/11/08 18:37:52 1.1194 +++ loncom/lonnet/perl/lonnet.pm 2012/11/09 17:27:18 1.1195 @@ -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.1195 2012/11/09 17:27:18 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2800,7 +2800,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 +2832,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 +12257,16 @@ 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 +12469,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 +12629,36 @@ 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 the current user should be able to edit a particular resource, +when viewing in course context. +(a) When viewing resource used to determine if "Edit" item is included in + Functions. +(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 -- + $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. + +=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