--- loncom/interface/lonsimplepage.pm 2006/03/16 21:30:00 1.33 +++ loncom/interface/lonsimplepage.pm 2006/07/20 15:03:01 1.46 @@ -1,7 +1,7 @@ # The LearningOnline Network # Simple Page Editor # -# $Id: lonsimplepage.pm,v 1.33 2006/03/16 21:30:00 raeburn Exp $ +# $Id: lonsimplepage.pm,v 1.46 2006/07/20 15:03:01 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,15 +37,8 @@ use Apache::lonfeedback; use Apache::lonlocal; use Apache::lonprintout; use Apache::lonxml; - -sub error { - my ($r,$msg) = @_; - $r->print(&Apache::loncommon::endheadtag(). - &Apache::loncommon::bodytag(). - &mt($msg). - &Apache::loncommon::end_page()); - return OK; -} +use Apache::longroup; +use LONCAPA; sub handler { my $r = shift; @@ -54,45 +47,46 @@ sub handler { return OK if $r->header_only; my $target=$env{'form.grade_target'}; # ------------------------------------------------------------ Print the screen - if ($target ne 'tex') { - $r->print(&Apache::lonxml::xmlbegin(). - &Apache::loncommon::headtag()); - } else { + if ($target eq 'tex') { $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'})); } - my (undef,undef,undef,undef,$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') { - return &error($r,'Not in a course'); + &Apache::loncommon::simple_error_page($r,'','Not in a course'); } else { $r->print('\textbf{Not in a course}\end{document}'); } + return OK; } 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; - + my ($namespace,$group,$group_desc,$group_home_view,$group_home_edit, + $group_view_perm,$group_edit_perm); my %curr_group = (); my %groupinfo = (); - if ($caller eq 'grppg') { + if ($dom && $crs && ($udom eq $dom) && ($uname eq $crs)) { $marker =~ s/\W//g; - $namespace = 'grppage_'.$marker; - my %curr_groups; - if (!&Apache::loncommon::coursegroups(\%curr_groups,$dom,$crs,$marker)) { - return &error($r,'Invalid group name'); + $group = $marker; + my %curr_groups = &Apache::longroup::coursegroups($dom,$crs,$group); + if (!%curr_groups) { + &Apache::loncommon::simple_error_page($r,'','Invalid group name'); + return OK; } - %groupinfo = &Apache::loncommon::get_group_settings($curr_groups{$marker}); - } else { + %groupinfo = + &Apache::longroup::get_group_settings($curr_groups{$group}); + $group_desc = &unescape($groupinfo{'description'}); + $namespace = 'grppage_'.$group; + } else { $marker=~s/\D//g; $namespace = 'smppage_'.$marker; } if (!$marker) { - return &error($r,'Invalid call'); + &Apache::loncommon::simple_error_page($r,'','Invalid call'); + return OK; } # --------------------------------------------------------- The syllabus fields @@ -100,27 +94,25 @@ sub handler { 'aaa_title' => 'Page Title', 'bbb_content' => 'Content', 'ccc_webreferences' => 'Web References'); - if ($caller eq 'grppg') { - $syllabusfields{'abb_links'} = &mt('Functionality'); + if ($group ne '') { + $syllabusfields{'abb_links'} = &mt('Available Group Tools'); } # ------------------------------------------------------------ Get query string &Apache::loncommon::get_unprocessed_cgi - ($ENV{'QUERY_STRING'},['forcestudent','forceedit','register']); -# ----------------------------------------------------- Force menu registration - my $addentries=''; - if ($env{'form.register'}) { - $addentries=' onLoad="'.&Apache::lonmenu::loadevents(). - '" onUnload="'.&Apache::lonmenu::unloadevents().'"'; - $r->print(&Apache::lonmenu::registerurl(1)); - } + ($ENV{'QUERY_STRING'},['forcestudent','forceedit', + 'register','ref']); # --------------------------------------------------------------- Force Student my $forcestudent=''; if ($env{'form.forcestudent'} || $target eq 'tex' ) { $forcestudent='student'; }; - my $forceedit=''; - if ($env{'form.forceedit'}) { $forceedit='edit'; } + 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); @@ -128,42 +120,58 @@ sub handler { if ($target ne 'tex') { my $title = 'Course Page'; - if ($caller eq 'grppg') { + if ($group ne '') { $title = 'Group Page'; } - $r->print(&Apache::lonhtmlcommon::htmlareaheaders(). - &Apache::loncommon::endheadtag(). - &Apache::loncommon::bodytag($title,$forcestudent,$addentries, - '',$dom,$env{'form.register'})); - } - - if ($caller eq 'grppg') { - if (($grp_view_permission) || - (&Apache::loncommon::check_group_access($caller))) { - unless(&Apache::lonnet::allowed('vgh', - $env{'request.course.id'}.'/'.$marker)) { - &display_group_links($r,$target,$marker,'view',%groupinfo); + my $start_page = + &Apache::loncommon::start_page($title,undef, + {'function' => $forcestudent, + 'domain' => $dom, + 'force_register' => + $env{'form.register'},}); + $r->print($start_page); + } + + if ($group ne '') { + 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); return OK; } } else { + my $msg = + &mt('You do not currently have rights to view this group.'); if ($target ne 'tex') { - $r->print(&Apache::loncommon::endheadtag(). - &Apache::loncommon::bodytag(). - 'You do not currently have rights to view this group.'. + $r->print("
$msg
". &Apache::loncommon::end_page()); - return OK; } else { - $r->print('\textbf{You do not currently have rights to view this group}\end{document}'); + $r->print('\textbf{'.$msg.'}\end{document}'); } + return OK; } } my $allowed; - if ($caller eq 'grppg') { - $allowed = $grp_view_permission; - unless ($allowed) { - $allowed = &Apache::lonnet::allowed('mgh',$env{'request.course.id'}. - '/'.$marker); + + if ($group ne '') { + $allowed = $group_edit_perm; + if (!$allowed) { + $allowed = $group_home_edit; } } else { $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); @@ -174,13 +182,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').'