--- loncom/interface/lonsimplepage.pm 2006/07/07 21:25:02 1.43 +++ loncom/interface/lonsimplepage.pm 2009/03/08 21:49:33 1.75 @@ -1,7 +1,7 @@ # The LearningOnline Network # Simple Page Editor # -# $Id: lonsimplepage.pm,v 1.43 2006/07/07 21:25:02 raeburn Exp $ +# $Id: lonsimplepage.pm,v 1.75 2009/03/08 21:49:33 weissno Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,6 +31,7 @@ package Apache::lonsimplepage; use strict; use Apache::Constants qw(:common); use Apache::loncommon; +use Apache::lontemplate; use Apache::lonnet; use Apache::lontexconvert; use Apache::lonfeedback; @@ -38,6 +39,28 @@ use Apache::lonlocal; use Apache::lonprintout; use Apache::lonxml; use Apache::longroup; +use HTML::Entities(); +use LONCAPA; + +sub get_db_name { + my ($url) = @_; + my ($udom,$uname,$marker)=(split(m{/},$url))[2,3,4]; + my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + + my $db_name; + + if ($dom && $crs && ($udom eq $dom) && ($uname eq $crs)) { + $marker =~ s/\W//g; + $db_name = 'grppage_'.$marker; + } else { + $marker=~s/\D//g; + $db_name = 'smppage_'.$marker; + } + return if (!defined($marker)); + + return $db_name; +} sub handler { my $r = shift; @@ -49,7 +72,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); + # Is this even in a course? unless ($env{'request.course.id'}) { if ($target ne 'tex') { @@ -60,18 +83,17 @@ sub handler { return OK; } + my $db_name = &get_db_name($r->uri); + 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 $group; - + my ($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)) { - $marker =~ s/\W//g; - $group = $marker; + if ($db_name =~ /^grppage_/) { + $group = (split(m{/},$r->uri))[4]; + $group =~ s/\W//g; my %curr_groups = &Apache::longroup::coursegroups($dom,$crs,$group); if (!%curr_groups) { &Apache::loncommon::simple_error_page($r,'','Invalid group name'); @@ -79,13 +101,10 @@ sub handler { } %groupinfo = &Apache::longroup::get_group_settings($curr_groups{$group}); - $namespace = 'grppage_'.$group; - } else { - $marker=~s/\D//g; - $namespace = 'smppage_'.$marker; + $group_desc = &unescape($groupinfo{'description'}); } - if (!$marker) { + if (!$db_name) { &Apache::loncommon::simple_error_page($r,'','Invalid call'); return OK; } @@ -96,28 +115,33 @@ sub handler { 'bbb_content' => 'Content', 'ccc_webreferences' => 'Web References'); if ($group ne '') { - $syllabusfields{'abb_links'} = &mt('Functionality'); + $syllabusfields{'abb_links'} = &mt('Available Group Tools'); } # ------------------------------------------------------------ Get query string &Apache::loncommon::get_unprocessed_cgi - ($ENV{'QUERY_STRING'},['forcestudent','forceedit','register']); + ($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 $refarg; + if ($env{'form.ref'}) { + $refarg = '&ref='.$env{'form.ref'}; + } - my %syllabus=&Apache::lonnet::dump($namespace,$dom,$crs); + my %syllabus=&Apache::lonnet::dump($db_name,$dom,$crs); # --------------------------------------- There is such a user, get environment if ($target ne 'tex') { - my $title = 'Course Page'; + my $title = 'Simple Course Page'; if ($group ne '') { - $title = 'Group Page'; + $title = 'Simple Group Page'; } my $start_page = &Apache::loncommon::start_page($title,undef, @@ -129,13 +153,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))) { - &display_group_links($r,$target,$marker,'view',%groupinfo); + 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}'); + } return OK; } } else { @@ -149,14 +189,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'}); @@ -167,124 +214,165 @@ 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_PublicView').'