--- loncom/interface/lonsimplepage.pm 2006/07/08 01:12:53 1.44 +++ loncom/interface/lonsimplepage.pm 2007/05/02 01:33:49 1.50 @@ -1,7 +1,7 @@ # The LearningOnline Network # Simple Page Editor # -# $Id: lonsimplepage.pm,v 1.44 2006/07/08 01:12:53 raeburn Exp $ +# $Id: lonsimplepage.pm,v 1.50 2007/05/02 01:33:49 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,6 +38,7 @@ use Apache::lonlocal; use Apache::lonprintout; use Apache::lonxml; use Apache::longroup; +use HTML::Entities(); use LONCAPA; sub handler { @@ -50,7 +51,7 @@ sub handler { if ($target eq 'tex') { $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'})); } - my (undef,undef,$udom,$uname,$marker,$caller)=split(/\//,$r->uri); + my (undef,undef,$udom,$uname,$marker)=split(/\//,$r->uri); # Is this even in a course? unless ($env{'request.course.id'}) { if ($target ne 'tex') { @@ -63,10 +64,8 @@ sub handler { my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $grp_view_permission = &Apache::lonnet::allowed('vcg', - $env{'request.course.id'}); - my ($namespace,$group,$grp_desc); - + my ($namespace,$group,$group_desc,$group_home_view,$group_home_edit, + $group_view_perm,$group_edit_perm); my %curr_group = (); my %groupinfo = (); if ($dom && $crs && ($udom eq $dom) && ($uname eq $crs)) { @@ -79,7 +78,7 @@ sub handler { } %groupinfo = &Apache::longroup::get_group_settings($curr_groups{$group}); - $grp_desc = &unescape($groupinfo{'description'}); + $group_desc = &unescape($groupinfo{'description'}); $namespace = 'grppage_'.$group; } else { $marker=~s/\D//g; @@ -97,7 +96,7 @@ sub handler { 'bbb_content' => 'Content', 'ccc_webreferences' => 'Web References'); if ($group ne '') { - $syllabusfields{'abb_links'} = &mt('Functionality'); + $syllabusfields{'abb_links'} = &mt('Available Group Tools'); } @@ -111,6 +110,10 @@ sub handler { my $forceedit=''; if ($env{'form.forceedit'}) { $forceedit='edit'; } + my $refarg; + if ($env{'form.ref'}) { + $refarg = '&ref='.$env{'form.ref'}; + } my %syllabus=&Apache::lonnet::dump($namespace,$dom,$crs); @@ -131,20 +134,29 @@ sub handler { } if ($group ne '') { - if (($grp_view_permission) || - (&Apache::longroup::check_group_access($caller))) { - if ((!&Apache::lonnet::allowed('vgh', - $env{'request.course.id'}.'/'.$marker)) - && (!&Apache::lonnet::allowed('mdg', - $env{'request.course.id'}.'/'.$marker))) { - if ($env{'form.ref'} eq 'grouplist') { - my $gpterm = &Apache::loncommon::group_term(); - my $ucgpterm = $gpterm; - $ucgpterm =~ s/^(\w)/uc($1)/e; - $r->print(&grouppage_breadcrumbs($dom,$crs,$group,$gpterm, - $ucgpterm,$grp_desc)); + my $group_view_perm = + &Apache::lonnet::allowed('vcg',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); + $group_edit_perm = + &Apache::lonnet::allowed('mdg',$env{'request.course.id'}. + ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); + $group_home_view = &Apache::lonnet::allowed('vgh', + $env{'request.course.id'}.'/'.$group); + $group_home_edit = &Apache::lonnet::allowed('mgh', + $env{'request.course.id'}.'/'.$group); + if ($group_view_perm || $group_edit_perm || $group_home_view || + $group_home_edit || &Apache::longroup::check_group_access($group)) { + if (($env{'form.ref'} eq 'grouplist') && ($target ne 'tex')) { + $r->print(&grouppage_breadcrumbs($dom,$crs,$group,$group_desc)); + } + if ((!$group_home_edit) && (!$group_home_view) && + (!$group_view_perm) && (!$group_edit_perm)) { + &display_group_links($r,$target,$group,'view',$refarg,%groupinfo); + if ($env{'form.grade_target'} ne 'tex') { + $r->print(&Apache::loncommon::end_page()); + } else { + $r->print('\end{document}'); } - &display_group_links($r,$target,$marker,'view',%groupinfo); return OK; } } else { @@ -158,14 +170,21 @@ sub handler { } return OK; } + my ($blocked,$blocktext) = + &Apache::loncommon::blocking_status('groups'); + if ($blocked) { + $r->print($blocktext); + $r->print(&Apache::loncommon::end_page()); + return OK; + } } my $allowed; + if ($group ne '') { - $allowed = &Apache::lonnet::allowed('mdg',$env{'request.course.id'}); + $allowed = $group_edit_perm; if (!$allowed) { - $allowed = &Apache::lonnet::allowed('mgh',$env{'request.course.id'}. - '/'.$marker); + $allowed = $group_home_edit; } } else { $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); @@ -176,13 +195,25 @@ sub handler { } if ($forcestudent or $target eq 'tex') { $allowed=0; } - + if ($allowed) { $r->print('
'.
- &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes','Help with filling in text boxes').'
'.&mt('Show Student View').''.
+ &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes','Help with filling in text boxes').'
'.&mt('Show Student View').''.
&Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'