--- loncom/interface/longroup.pm 2006/07/29 00:31:58 1.12 +++ loncom/interface/longroup.pm 2009/02/05 12:32:26 1.20 @@ -28,6 +28,7 @@ package Apache::longroup; use strict; use Apache::lonnet; +use Apache::lonlocal; ############################################### =pod @@ -40,14 +41,17 @@ Input: 1. Optional course domain 2. Optional course number 3. Optional group name +4. Optional namespace Course domain and number will be taken from user's environment if not supplied. Optional group name will -be passed to lonnet::get_coursegroups() as a regexp to -use in the call to the dump function. +be passed to lonnet function as a regexp to +use in the call to the dump function. Optional namespace +will determine whether information is retrieved about current +groups (default) or deleted groups (namespace = deleted_groups). Output -Returns hash of groups in the course (subject to the +Returns hash of groups in a course (subject to the optional group name filter). In the hash, the keys are group names, and their corresponding values are scalars containing group information in XML. This @@ -55,12 +59,13 @@ can be sent to &get_group_settings() to Side effects: None. + =cut ############################################### sub coursegroups { - my ($cdom,$cnum,$group) = @_; + my ($cdom,$cnum,$group,$namespace) = @_; if (!defined($cdom) || !defined($cnum)) { my $cid = $env{'request.course.id'}; @@ -69,16 +74,25 @@ sub coursegroups { $cdom = $env{'course.'.$cid.'.domain'}; $cnum = $env{'course.'.$cid.'.num'}; } - my %curr_groups = &Apache::lonnet::get_coursegroups($cdom,$cnum,$group); - if (my $tmp = &Apache::lonnet::error(%curr_groups)) { - undef(%curr_groups); - &Apache::lonnet::logthis('Error retrieving groups: '.$tmp.' in '.$cnum.':'.$cdom); + if (!defined($namespace)) { + $namespace = 'coursegroups'; + } + my %groups = &Apache::lonnet::get_coursegroups($cdom,$cnum,$group, + $namespace); + if (my $tmp = &Apache::lonnet::error(%groups)) { + undef(%groups); + &Apache::lonnet::logthis('Error retrieving groups: '.$tmp.' in '.$cnum.':'.$cdom.' - '.$namespace); + } + if (defined($groups{'group_allfolders'."\0".'locked_folder'})) { + delete($groups{'group_allfolders'."\0".'locked_folder'}); } - return %curr_groups; + return %groups; } ############################################### +=pod + =item get_group_settings Uses TokeParser to extract group information from the @@ -186,6 +200,8 @@ Input: 4. Role 5. End date of role 6. Start date of role +7. Selfenroll +8. Context Checks to see if role for which assignment is being made is in a course. If so, gathers information about auto-group population settings for @@ -201,7 +217,11 @@ and would trigger membership in teh same If role is being added, will add any group memberships specified for auto-group population, unless use is already a group member. Uses default group privileges and default start and end group access -times. +times. + +Flag for selfenroll (value of 1), and context (auto, updatenow, +automated, course, domain etc.) can be used to log the reason for +the role change. Output None @@ -214,7 +234,7 @@ or expire group membership(s) for a user =cut sub group_changes { - my ($udom,$uname,$url,$role,$origend,$origstart) = @_; + my ($udom,$uname,$url,$role,$origend,$origstart,$selfenroll,$context) = @_; my $now = time; my $chgtype; if ($origend > 0 && $origend <= $now) { @@ -326,7 +346,7 @@ sub group_changes { $add,$uname.':'.$udom, $settings{$add}{'enddate'}, $settings{$add}{'startdate'}, - $group_privs) eq 'ok') { + $group_privs,$selfenroll,$context) eq 'ok') { my %usersettings; $usersettings{$add.':'.$uname.':'.$udom} = $addgroup{$add}; @@ -395,7 +415,8 @@ sub group_changes { $cnum,$drop, $uname.':'.$udom,$now, $dropstart{$drop}, - $currpriv{$drop}) + $currpriv{$drop}, + $selfenroll,$context) eq 'ok') { my %usersettings; $usersettings{$drop.':'.$uname.':'.$udom} = @@ -417,12 +438,12 @@ sub group_changes { sub get_fixed_privs { my $fixedprivs = { - email => {sgm => 1}, - discussion => {vgb => 1}, - chat => {pgc => 1}, - files => {rgf => 1}, - roster => {vgm => 1}, - homepage => {vgh => 1}, + email => {sgm => 1}, + discussion => {vgb => 1}, + chat => {pgc => 1}, + files => {rgf => 1}, + roster => {vgm => 1}, + homepage => {vgh => 1}, }; return $fixedprivs; } @@ -432,9 +453,9 @@ sub get_fixed_privs { sub get_tool_privs { my ($gpterm) = @_; my $toolprivs = { - email => { - sgm => 'Send '.$gpterm.' mail', - sgb => 'Broadcast mail', + email => { + sgm => 'Send '.$gpterm.' message', + sgb => 'Broadcast message', }, discussion => { cgb => 'Create boards', @@ -623,38 +644,42 @@ sub get_bbfolder_url { sub get_group_bbinfo { my ($cdom,$cnum,$group,$boardurl) = @_; + my @groupboards = (); + my %boardshash = (); my $navmap = Apache::lonnavmaps::navmap->new(); - my @groupboards; - my %boardshash; - my $grpbbmap = &get_bbfolder_url($cdom,$cnum,$group); - if ($grpbbmap) { - my $bbfolderres = $navmap->getResourceByUrl($grpbbmap); - if ($bbfolderres) { - my @boards = $navmap->retrieveResources($bbfolderres,undef,0,0); - foreach my $res (@boards) { - my $url = $res->src(); - if ($url =~ m|^(/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard)|) { - if ($boardurl) { - if ($boardurl =~ /^\Q$1\E/) { - push(@groupboards,$res->symb()); - $boardshash{$res->symb()} = { + if (defined($navmap)) { + my $grpbbmap = &get_bbfolder_url($cdom,$cnum,$group); + if ($grpbbmap) { + my $bbfolderres = $navmap->getResourceByUrl($grpbbmap); + if ($bbfolderres) { + my @boards = $navmap->retrieveResources($bbfolderres,undef,0,0); + foreach my $res (@boards) { + my $url = $res->src(); + if ($url =~ m|^(/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard)|) { + if ($boardurl) { + if ($boardurl =~ /^\Q$1\E/) { + push(@groupboards,$res->symb()); + $boardshash{$res->symb()} = { title => $res->title(), url => $res->src(), - }; - last; - } - } else { - push(@groupboards,$res->symb()); - $boardshash{$res->symb()} = { + }; + last; + } + } else { + push(@groupboards,$res->symb()); + $boardshash{$res->symb()} = { title => $res->title(), url => $res->src(), - }; + }; + } } } } } + undef($navmap); + } else { + &Apache::lonnet::logthis('Retrieval of group boards failed - could not create navmap object for group: '.$group.' in course: '.$cdom.':'.$cnum); } - undef($navmap); return (\@groupboards,\%boardshash); } 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.