--- loncom/lonnet/perl/lonnet.pm 2012/11/09 17:27:18 1.1195 +++ loncom/lonnet/perl/lonnet.pm 2012/11/11 01:48:33 1.1197 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1195 2012/11/09 17:27:18 raeburn Exp $ +# $Id: lonnet.pm,v 1.1197 2012/11/11 01:48:33 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 { @@ -2689,15 +2692,15 @@ sub can_edit_resource { if ($group ne '') { # if this is a group homepage or group bulletin board, check group privs my $allowed = 0; - if ($resurl =~ m{^/adm/$cdom/$cnum/$group/smppg$}) { - if ((&Apache::lonnet::allowed('mdg',$env{'request.course.id'}. + if ($resurl =~ m{^/?adm/$cdom/$cnum/$group/smppg$}) { + if ((&allowed('mdg',$env{'request.course.id'}. ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) || (&allowed('mgh',$env{'request.course.id'}.'/'.$group)) || $crsedit) { $allowed = 1; } - } elsif ($resurl =~ m{^/adm/$cdom/$cnum/\d+/bulletinboard$}) { - unless ((&allowed(&Apache::lonnet::allowed('mdg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')))) || - (&allowed('cgb',$env{'request.course.id'}.$group)) || $crsedit) { + } elsif ($resurl =~ m{^/?adm/$cdom/$cnum/\d+/bulletinboard$}) { + if ((&allowed('mdg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) || + (&allowed('cgb',$env{'request.course.id'}.'/'.$group)) || $crsedit) { $allowed = 1; } } @@ -12260,9 +12263,10 @@ provided for types, will default to retu =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 +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. @@ -12631,22 +12635,20 @@ forcing spreadsheet to reevaluate the re =item * -can_edit_resource($file,$cnum,$cdom,$resurl,$symb,$group) - -Determine if the current user should be able to edit a particular resource, +can_edit_resource($file,$cnum,$cdom,$resurl,$symb,$group) : determine if current user can 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 -- + 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 =item *