--- loncom/interface/longroup.pm 2010/11/13 04:45:17 1.27 +++ loncom/interface/longroup.pm 2016/02/26 21:44:39 1.30 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # accessor routines used to provide information about course groups # -# $Id: longroup.pm,v 1.27 2010/11/13 04:45:17 raeburn Exp $ +# $Id: longroup.pm,v 1.30 2016/02/26 21:44:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -218,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. @@ -252,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'}; @@ -291,12 +288,8 @@ sub group_changes { } if (@changegroups > 0) { my %currpriv; - my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1}); - my %roleshash = &Apache::lonnet::dump('roles',$udom,$uname,$cid,undef,$extra); - if (my $tmp = &Apache::lonnet::error(%roleshash)) { - &Apache::lonnet::logthis('Error retrieving roles: '.$tmp. - ' for '.$uname.':'.$udom); - } else { + my %roleshash = &Apache::lonnet::dump('roles',$udom,$uname,$cid); + if (keys(%roleshash) > 0) { my $group_privs = ''; foreach my $group (@changegroups) { if ($chgtype eq 'add') { @@ -690,23 +683,130 @@ sub get_group_bbinfo { ############################################### sub get_group_link { - my ($cdom,$cnum,$group,$navmap) = @_; + my ($cdom,$cnum,$group,$navmap,$view_permission,$refarg) = @_; if (ref($navmap)) { - my $symb = 'uploaded/'.$cdom.'/'.$cnum.'/group_folder_'.$group.'.sequence___1___adm/'.$cdom.'/'.$cnum.'/'.$group.'/smppg'; + my $map = "uploaded/$cdom/$cnum/group_folder_"."$group.sequence"; + my $mapres = $navmap->getResourceByUrl("/$map"); + my $hidden; + if (ref($mapres)) { + if ((!$viewpermission) && ($mapres->randomout())) { + $hidden = 1; + } + } + my $url = "adm/$cdom/$cnum/$group/smppg"; + my $idx = '1'; + my $symb = $map.'___'.$idx.'___'.$url; my $res = $navmap->getBySymb($symb); + $url = "/$url"; + $map = "/$map"; my $link; if (ref($res)) { - $link = $res->link(); - $link .= (($link=~/\?/)?'&':'?').'symb='.$res->shown_symb(); + if ((!$view_permission) && ($res->randomout())) { + $hidden = 1; + } else { + $hidden = 0; + if ($refarg) { + $link = $url.'?'.$refarg; + } else { + $link = $res->link(); + $link .= (($link=~/\?/)?'&':'?').'symb='.$res->shown_symb(); + } + } + } elsif (&Apache::lonnet::is_on_map($url)) { + unless ($hidden) { + $link = $url; + if ($refarg) { + $link = $url.'?'.$refarg; + } + } + } + if (wantarray) { + return ($link,$hidden); } else { - $link = '/adm/'.$cdom.'/'.$cnum.'/'.$group.'/smppg'; + return $link; } - return $link; } return; } ############################################### +sub display_group_links { + my ($r,$target,$group,$context,$refarg,$numtoolsref,$hidehdr,%groupinfo) = @_; + my @available = (); + my %menu = (); + %{$menu{'email'}} = ( + text => 'Group Message', + href => '/adm/email?compose=group&group='.$group. + $refarg, + ); + %{$menu{'discussion'}} = ( + text => 'Discussion Boards', + href => '/adm/groupboards?group='.$group.$refarg, + ); + %{$menu{'chat'}} = ( + text => 'Group Chat Room', + href => "javascript:group_chat('$group')", + ); + %{$menu{'files'}} = ( + text => 'Group Portfolio', + href => '/adm/coursegrp_portfolio?group='.$group. + $refarg, + ); + %{$menu{'roster'}} = ( + text => 'Membership Roster', + href => '/adm/grouproster?group='.$group.$refarg, + ); + foreach my $tool (sort(keys(%menu))) { + if ($groupinfo{functions}{$tool} eq 'on') { + push(@available,$tool); + } + } + my $output = ''; + if (ref($numtoolsref) eq 'SCALAR') { + $$numtoolsref = scalar(@available); + } + if (@available > 0) { + if ($target eq 'tex') { + $output = ''; + } else { + $output = &Apache::loncommon::start_data_table(); + } + foreach my $tool (@available) { + if ($target eq 'tex') { + $output .= ''; + } else { + $output .= &Apache::loncommon::start_data_table_row() + .'' + .&Apache::loncommon::end_data_table_row(); + } + } + if ($target eq 'tex') { + $output .= '
'.&mt($menu{$tool}{text}).'
' + .&mt($menu{$tool}{text}).'
'; + } else { + $output .= &Apache::loncommon::end_data_table(); + } + if ($target eq 'tex') { + $output = &Apache::lonxml::xmlparse($r,'tex',&mt('Available functions').'

'.$output); + } else { + unless ($hidehdr) { + $output = '

'.&mt('Available Group Tools').'

'.$output; + } + } + } else { + if ($context eq 'edit') { + $output = &mt('No group functionality.'); + } else { + $output = &mt('No group functionality (e.g., e-mail, discussion, chat room or file upload) is currently available to you in this group: [_1].', + ''.&unescape($groupinfo{'description'}).''); + } + if ($target eq 'tex') { + $output = &Apache::lonxml::xmlparse($r,'tex',$output); + } + } + return $output; +} + 1; 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.