--- loncom/interface/loncoursegroups.pm 2005/10/27 23:42:17 1.2 +++ loncom/interface/loncoursegroups.pm 2009/02/25 16:39:54 1.94 @@ -1,3 +1,6 @@ +# The LearningOnline Network with CAPA +# +# $Id: loncoursegroups.pm,v 1.94 2009/02/25 16:39:54 hauer Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,153 +29,1721 @@ package Apache::loncoursegroups; use strict; use Apache::lonnet; -use Apache::loncommon; -use Apache::lonhtmlcommon; +use Apache::loncommon(); +use Apache::lonhtmlcommon(); use Apache::lonlocal; +use Apache::lonnavmaps(); +use Apache::longroup(); +use Apache::portfolio(); use Apache::Constants qw(:common :http); +use LONCAPA::map(); +use lib '/home/httpd/lib/perl/'; +use LONCAPA; sub handler { my ($r) = @_; + &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - + if ($r->header_only) { return OK; } - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['action','state']); - - $r->print(&header()); - - &Apache::lonhtmlcommon::clear_breadcrumbs(); - &Apache::lonhtmlcommon::add_breadcrumb - ({href=>"/adm/groups", - text=>"Group Management", - faq=>9,bug=>'Instructor Interface',}); # Needs to be in a course if (! ($env{'request.course.fn'})) { # Not in a course $env{'user.error.msg'}= - "/adm/groups:mdg:0:0:Cannot create, modify or delete course groups"; + "/adm/coursegroups:mdg:0:0:Cannot edit or view course groups"; return HTTP_NOT_ACCEPTABLE; } + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['action','refpage','state','groupname','branch']); + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $view_permission = - &Apache::lonnet::allowed('vcg',$env{'request.course.id'}); + &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); my $manage_permission = - &Apache::lonnet::allowed('mdg',$env{'request.course.id'}); + &Apache::lonnet::allowed('mdg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); + &Apache::lonhtmlcommon::clear_breadcrumbs(); - if (! exists($env{'form.action'})) { - $r->print(&Apache::lonhtmlcommon::breadcrumbs - (undef,'Course Group Manager')); - &print_main_menu($r,$manage_permission,$view_permission); - } elsif ($env{'form.action'} eq 'create' && $manage_permission) { + my $gpterm = &Apache::loncommon::group_term(); + my $ucgpterm = $gpterm; + $ucgpterm =~ s/^(\w)/uc($1)/e; + my $crstype = &Apache::loncommon::course_type(); + + my %functions = ( + email => 'Send Messages', + discussion => 'Discussion Boards', + chat => 'Chat Room', + files => 'File Repository', + roster => 'Membership Roster', + homepage => $ucgpterm.' home page', + ); + + my %idx = (); + $idx{id} = &Apache::loncoursedata::CL_ID(); + $idx{fullname} = &Apache::loncoursedata::CL_FULLNAME(); + $idx{udom} = &Apache::loncoursedata::CL_SDOM(); + $idx{uname} = &Apache::loncoursedata::CL_SNAME(); + $idx{section} = &Apache::loncoursedata::CL_SECTION(); + + my $action = $env{'form.action'}; + my $state = $env{'form.state'}; + if ((!defined($action)) || ($action eq 'view') || ($action eq 'modify') || ($action eq 'delete') || ($action eq 'reenable')) { + if (!defined($state)) { + $state = 'view'; + } + } + if ($action eq 'create' || $action eq 'modify' || $action eq 'view' || + $action eq 'delete' || $action eq 'reenable') { + if ($view_permission || $manage_permission) { + if ($state eq 'view') { + &print_main_menu($r,$cdom,$cnum,\%functions,\%idx, + $view_permission,$manage_permission, + $action,$state,$gpterm,$ucgpterm,$crstype); + } else { + &group_administration($r,$action,$state,$cdom,$cnum, + \%functions,\%idx,$view_permission, + $manage_permission,$gpterm,$ucgpterm, + $crstype); + } + } else { + $r->print('