--- loncom/interface/longroup.pm 2006/12/04 14:59:56 1.14 +++ loncom/interface/longroup.pm 2009/01/27 15:59:30 1.18 @@ -58,6 +58,7 @@ can be sent to &get_group_settings() to Side effects: None. + =cut ############################################### @@ -89,6 +90,8 @@ sub coursegroups { ############################################### +=pod + =item get_group_settings Uses TokeParser to extract group information from the @@ -196,6 +199,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 @@ -211,7 +216,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 @@ -224,7 +233,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) { @@ -336,7 +345,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}; @@ -405,7 +414,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} = @@ -443,8 +453,8 @@ sub get_tool_privs { my ($gpterm) = @_; my $toolprivs = { email => { - sgm => 'Send '.$gpterm.' mail', - sgb => 'Broadcast mail', + sgm => 'Send '.$gpterm.' message', + sgb => 'Broadcast message', }, discussion => { cgb => 'Create boards', @@ -633,38 +643,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); }