--- loncom/interface/longroup.pm 2008/05/01 16:26:29 1.16 +++ loncom/interface/longroup.pm 2012/12/18 15:26:03 1.29 @@ -1,6 +1,8 @@ # The LearningOnline Network with CAPA # accessor routines used to provide information about course groups # +# $Id: longroup.pm,v 1.29 2012/12/18 15:26:03 raeburn Exp $ +# # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). @@ -28,6 +30,8 @@ package Apache::longroup; use strict; use Apache::lonnet; +use Apache::lonlocal; +use LONCAPA; ############################################### =pod @@ -214,7 +218,7 @@ for the course is included amongst the u and would trigger membership in teh same group(s) If role is being added, will add any group memberships specified -for auto-group population, unless use is already a group member. +for auto-group population, unless user is already a group member. Uses default group privileges and default start and end group access times. @@ -248,9 +252,6 @@ sub group_changes { } else { $cid = $url; } - my $courseid = $cid; - $courseid =~ s|^/||; - $courseid =~ s|/|_|; my %crshash=&Apache::lonnet::coursedescription($cid); $cdom = $crshash{'domain'}; $cnum = $crshash{'num'}; @@ -288,10 +289,7 @@ sub group_changes { if (@changegroups > 0) { my %currpriv; my %roleshash = &Apache::lonnet::dump('roles',$udom,$uname,$cid); - if (my $tmp = &Apache::lonnet::error(%roleshash)) { - &Apache::lonnet::logthis('Error retrieving roles: '.$tmp. - ' for '.$uname.':'.$udom); - } else { + if (keys(%roleshash) > 0) { my $group_privs = ''; foreach my $group (@changegroups) { if ($chgtype eq 'add') { @@ -437,12 +435,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; } @@ -452,9 +450,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', @@ -464,7 +462,7 @@ sub get_tool_privs { vgb => 'View boards', }, chat => { - pgc => 'Chat', + pgc => 'Chat Room', }, files => { rgf => 'Retrieve', @@ -643,42 +641,65 @@ 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); } ############################################### + +sub get_group_link { + my ($cdom,$cnum,$group,$navmap) = @_; + if (ref($navmap)) { + my $symb = 'uploaded/'.$cdom.'/'.$cnum.'/group_folder_'.$group.'.sequence___1___adm/'.$cdom.'/'.$cnum.'/'.$group.'/smppg'; + my $res = $navmap->getBySymb($symb); + my $link; + if (ref($res)) { + $link = $res->link(); + $link .= (($link=~/\?/)?'&':'?').'symb='.$res->shown_symb(); + } else { + $link = '/adm/'.$cdom.'/'.$cnum.'/'.$group.'/smppg'; + } + return $link; + } + return; +} + +############################################### 1;