--- loncom/interface/loncoursegroups.pm 2009/11/16 14:07:57 1.105 +++ loncom/interface/loncoursegroups.pm 2014/02/27 11:16:06 1.124 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursegroups.pm,v 1.105 2009/11/16 14:07:57 bisitz Exp $ +# $Id: loncoursegroups.pm,v 1.124 2014/02/27 11:16:06 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,6 +31,7 @@ use strict; use Apache::lonnet; use Apache::loncommon(); use Apache::lonhtmlcommon(); +use Apache::lonhtmlgateway; use Apache::lonlocal; use Apache::lonnavmaps(); use Apache::longroup(); @@ -135,7 +136,7 @@ function changeSort(caller) { function openGroupRoster(group,status) { var url = '/adm/grouproster?'; url += 'group='+group+'&status='+status+'&ref=popup'; - var title = 'Group Membership'; + var title = 'Group_Membership'; var options = 'scrollbars=1,resizable=1,menubar=0'; options += ',width=700,height=600'; rosterbrowser = open(url,title,options,'1'); @@ -170,7 +171,7 @@ sub display_groups { my %actionlinks = ( modify => ' ' ''. + &mt('An error occurred retrieving information about resources in the course.').'
'. + &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this page.','
',''). + ''); + return; + } if ($manage_permission) { if ($action ne 'reenable') { $r->print('
'.$lt{'crng'}.''); @@ -324,7 +333,9 @@ END $action eq 'reenable') { $link .= $group; } else { - $link .= $group.'/smppg?ref=grouplist'; + $link .= + &Apache::longroup::get_group_link($cdom,$cnum,$group,$navmap); + $link .= (($link=~/\?/)?'&':'?').'ref=grouplist'; if (exists($env{'form.refpage'})) { $link .= '&refpage='.$env{'form.refpage'}; } @@ -386,16 +397,32 @@ END $r->print('

'); my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); if (%curr_groups) { + my $navmap=Apache::lonnavmaps::navmap->new(); + if (!defined($navmap)) { + $r->print('
'. + &mt('An error occurred retrieving information about resources in the course.').'
'. + &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this page.','',''). + '
'); + return; + } foreach my $group (@coursegroups) { my %group_info = &Apache::longroup::get_group_settings( $curr_groups{$group}); my $description = &unescape( $group_info{description}); - $r->print(''.$group,'
'.$description.'

'); + my $link = + &Apache::longroup::get_group_link($cdom,$cnum,$group,$navmap). + '&ref=grouplist'; + $r->print(''.$group,'
'.$description.'

'); } } } else { - $r->print(&mt('You are not currently a member of any active '.$gpterm.'s in this '.lc($crstype).'.')); + $r->print( + '

' + .&mt('You are not currently a member of any active '.$gpterm.'s' + .' in this '.lc($crstype).'.') + .'

' + ); } } return; @@ -785,7 +812,7 @@ sub group_administration { } var maxposs = '.sprintf("%.2f",$maxposs).'; if (newquota > maxposs) { - alert("The group portfolio quota you entered for this group ("+newquota+" Mb) exceeds the maximum possible ("+maxposs+" Mb). Please enter a smaller number."); + alert("The group portfolio quota you entered for this group ("+newquota+" MB) exceeds the maximum possible ("+maxposs+" MB). Please enter a smaller number."); return; } var re_quota = '.$float_check.'; @@ -804,7 +831,7 @@ sub group_administration { } } if (warn_zero == 1) { - alert("You have indicated that the group portfolio should be enabled, but you have set the respository quota to 0 Mb.\nThis will prevent any upload of files.\nPlease set a value or disable the repository feature."); + alert("You have indicated that the group portfolio should be enabled, but you have set the respository quota to 0 MB.\nThis will prevent any upload of files.\nPlease set a value or disable the repository feature."); return; } } @@ -1210,9 +1237,9 @@ sub delete_group { if ($result eq 'ok') { my $outcome = &modify_folders($cdom,$cnum,$groupname,$crstype); if ($outcome eq '') { - $r->print('
' - .&mt('Group successfully deleted.') - .'
'); + my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Group successfully deleted.')); + $message = &Apache::loncommon::confirmwrapper($message); + $r->print($message); } else { $r->print('
'); if ($crstype eq 'Community') { @@ -1223,9 +1250,9 @@ sub delete_group { $r->print('
'); } } else { - $r->print('
' - .&mt('Group deletion failed.') - .'
'); + my $msg = &Apache::lonhtmlcommon::confirm_success(&mt('Group deletion failed.'),1); + $msg = &Apache::loncommon::confirmwrapper($msg); + $r->print($msg); } } return; @@ -1255,7 +1282,7 @@ sub reenable_folder { $LONCAPA::map::resources[$idx] = $foldertitle.':'.$mapurl. ':false:normal:res'; $LONCAPA::map::order[1+$#LONCAPA::map::order]=$idx; - my ($outtext,$errtext) = &LONCAPA::map::storemap($allgrpsmap,1); + my ($outtext,$errtext) = &LONCAPA::map::storemap($allgrpsmap,1,1); if ($errtext) { $outcome='
' .&mt('An error occurred when saving updated parent folder to group:' @@ -1320,7 +1347,7 @@ sub modify_folders { $LONCAPA::map::order[$i] = $LONCAPA::map::order[$i+1]; } $#LONCAPA::map::order--; - my ($outtext,$errtext) = &LONCAPA::map::storemap($map,1); + my ($outtext,$errtext) = &LONCAPA::map::storemap($map,1,1); if ($errtext) { $outcome='
' .&mt('An error occurred when saving updated parent folder to group:') @@ -1437,9 +1464,9 @@ $context) eq 'ok') { } my $outcome = &reenable_folder($cdom,$cnum,$groupname,$description,$crstype); if ($outcome eq '') { - $r->print('
' - .&mt('Group successfully re-enabled.') - .'
'); + my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Group successfully re-enabled.')); + $message = &Apache::loncommon::confirmwrapper($message); + $r->print($message); } else { $r->print('
'); if ($crstype eq 'Community') { @@ -1450,9 +1477,9 @@ $context) eq 'ok') { $r->print('
'); } } else { - $r->print('
' - .&mt('Re-enabling group failed.') - .'
'); + my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling group failed.'),1); + $message = &Apache::loncommon::confirmwrapper($message); + $r->print($message); } return; } @@ -1466,7 +1493,7 @@ sub header { {'add_entries' => $loaditems,}); my $output = <<"END"; $start_page -
+ END if ($action eq 'create' || $action eq 'modify') { @@ -1526,16 +1553,19 @@ sub build_members_list { sub group_files { my ($group,$portpath,$numfiles,$numdirs) = @_; my $dirptr=16384; - my @dir_list=&Apache::portfolio::get_dir_list($portpath,undef,$group); - foreach my $line (@dir_list) { - my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); - if (($filename !~ /^\.\.?$/) && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/) && ($filename ne 'no_such_dir')) { - if ($dirptr&$testdir) { - $portpath .= '/'.$filename; - $$numdirs ++; - &group_files($group,$portpath,$numfiles,$numdirs) - } else { - $$numfiles ++; + my ($dirlistref,$listerror) = + &Apache::portfolio::get_dir_list($portpath,undef,$group); + if (ref($dirlistref) eq 'ARRAY') { + foreach my $line (@{$dirlistref}) { + my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); + if (($filename !~ /^\.\.?$/) && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/) && ($filename ne 'no_such_dir')) { + if ($dirptr&$testdir) { + $portpath .= '/'.$filename; + $$numdirs ++; + &group_files($group,$portpath,$numfiles,$numdirs) + } else { + $$numfiles ++; + } } } } @@ -1727,19 +1757,19 @@ sub groupsettings_options { } else { $r->print(&mt('Quota allocated to group portfolio:')); } - $r->print(' '.&mt('[_1] Mb','')); + $r->print(' '.&mt('[_1] MB','')); if ($action eq 'create') { $r->print('
' - .&mt('A total of [_1] Mb can be divided amongst all '.$gpterm.'s in the ' - .lc($crstype).', and [_2] Mb are currently unallocated.' + .&mt('A total of [_1] MB can be divided amongst all '.$gpterm.'s in the ' + .lc($crstype).', and [_2] MB are currently unallocated.' ,$crsquota,sprintf("%.2f",$freespace)) ); } else { - $r->print('  ('.&mt('The quota is currently [_1] Mb', + $r->print('  ('.&mt('The quota is currently [_1] MB', $$stored{'quota'}).').'); $r->print('
' - .&mt('The quota can be increased to [_1] Mb, ' + .&mt('The quota can be increased to [_1] MB, ' .'by adding all unallocated space for '.$gpterm.'s in the '.lc($crstype).'.' ,sprintf("%.2f",$maxposs))); } @@ -1774,7 +1804,6 @@ sub membership_options { 'picr' => 'Pick the criteria to use to build a list of course users from which you will select members of the new group.', 'pica' => 'Pick the criteria to use to build a list of course users from which you will select additional members of the group.', 'ifno' => 'If you do not wish to add members when you first create the group, there is no need to pick any criteria.', - 'asub' => 'A subsequent step will also allow you to specify automatic adding/dropping of group members triggered by specified user role and section changes in the course.', 'acty' => 'Access types', 'coro' => 'Course roles', 'cose' => 'Course sections', @@ -1988,10 +2017,10 @@ sub print_current_settings { dfac => 'Default access dates', ygrs => "Your group selections - ", tfwa => "The following settings will apply to the group:", - difn => 'Different collaborative tools
for different members:', stda => 'Start date:', enda => 'End date:', ); + $lt{'difn'} = &mt('Different collaborative tools[_1]for different members:','
'); my $showstart = &Apache::lonlocal::locallocaltime($startdate); my $showend; if ($enddate == 0) { @@ -2041,7 +2070,7 @@ sub print_current_settings { $r->print(''); } - my $quota_text=&mt('[_1] Mb',$quota); + my $quota_text=&mt('[_1] MB',$quota); my $granu_text=&mt($granularity); $r->print(<<"END"); @@ -2231,11 +2260,12 @@ sub privilege_specificity { "for users who receive specific sections/roles in the course ", 'asyo' => "As you have chosen not to include any collaborative tools ". "in the group, no default optional privileges need to be set.", - 'plin' => 'Indicate which optional privileges members '. 'will receive by default for a specific tool.', 'oppr' => 'Optional privileges', 'defp' => 'The default privileges new members will receive are:', ); + $lt{'plin'} = &mt('Indicate which [_1]optional[_2] privileges members '. + 'will receive by default for a specific tool.','',''); if ($crstype eq 'Community') { $lt{'thes'} = &mt('These will be the privileges given to members assigned in the future via automatic group assignment for users who receive specific sections/roles in the community '); } @@ -2337,9 +2367,9 @@ sub default_privileges { &Apache::lonhtmlcommon::row_title($lt{'func'},undef, 'LC_groups_functionality')); my @tableHeader; - foreach my $key (sort(keys(%{$functions}))){ - push (@tableHeader,&mt($functions->{$key})); - } + if ((ref($functions) eq 'HASH') && (ref($tools) eq 'ARRAY')) { + @tableHeader = map { $functions->{$_}; } @{$tools}; + } $r->print(join('', @tableHeader)); $r->print(&Apache::lonhtmlcommon::row_closure(1)); my $fixed = ''; @@ -2519,6 +2549,7 @@ sub current_membership { 'actn' => 'Action?', 'name' => 'Name', 'usnm' => 'Username', + 'stid' => 'ID', 'doma' => 'Domain', 'stda' => 'Start Date', 'enda' => 'End Date', @@ -2580,7 +2611,7 @@ END $lt{'name'} $lt{'usnm'} $lt{'doma'} - ID + $lt{'ID'} $lt{'stda'} $lt{'enda'} END @@ -2704,7 +2735,10 @@ END } $r->print(&Apache::loncommon::end_data_table()); } else { - $r->print(&mt('There are no active, future or previous group members to modify.')); + $r->print( + '

' + .&mt('There are no active, future or previous group members to modify.') + .'

'); } return $numcurrent; } @@ -2772,7 +2806,7 @@ sub change_privs_form { } } if (!$exp_or_del) { - $r->print($lt{'nome'}.'
'); + $r->print('

'.$lt{'nome'}.'

'); } $r->print(&Apache::lonhtmlcommon::topic_bar(4,&mt('Setting optional privileges for specific group members'))); @@ -3168,7 +3202,7 @@ sub write_group_data { $quota = 0; $r->print('
' .&mt('The value you entered for the quota for the group portfolio in this '.$gpterm - .' contained invalid characters, so it has been set to 0 Mb. You can change this by' + .' contained invalid characters, so it has been set to 0 MB. You can change this by' .' modifying the '.$gpterm.' settings.') .'
'); } @@ -3176,7 +3210,7 @@ sub write_group_data { $quota = $maxposs; $r->print('
' .&mt('The value you entered for the quota for the group portfolio in this '.$gpterm - .' exceeded the maximum possible value, so it has been set to [_1] Mb ' + .' exceeded the maximum possible value, so it has been set to [_1] MB ' .'(the maximum possible value).',sprintf("%.2f",$maxposs)) .'
'); } @@ -3244,15 +3278,15 @@ sub write_group_data { $description,$tools,\%groupinfo, $gpterm,$ucgpterm,$crstype); if ($result eq 'ok') { - $r->print('
' - .&mt($ucgpterm.' [_1] was created.',''.$groupname.'') - .'
'); + my $msg = &Apache::lonhtmlcommon::confirm_success(&mt($ucgpterm.' [_1] was created.',''.$groupname.'')); + $msg = &Apache::loncommon::confirmwrapper($msg); + $r->print($msg); } else { - $r->print('
' - .&mt('A problem occurred when creating folders for the new '.$gpterm.' [_1]:' - ,''.$groupname.'') - .'
'.$result - .'
'); + my $msg = &Apache::lonhtmlcommon::confirm_success(&mt('A problem occurred when creating folders for the new '.$gpterm.' [_1]:' + ,''.$groupname.'') + .'
'.$result,1); + $msg = &Apache::loncommon::confirmwrapper($msg); + $r->print($msg); } } elsif ($action eq 'modify') { my (@oldtools,@newtools); @@ -3323,9 +3357,9 @@ sub write_group_data { $r->print('
'.$error.'
'); } } - $r->print('
' - .&mt($ucgpterm.' [_1] was updated.',''.$groupname.'') - .'
'); + my $message = &Apache::lonhtmlcommon::confirm_success(&mt($ucgpterm.' [_1] was updated.',''.$groupname.'')); + $message = &Apache::loncommon::confirmwrapper($message); + $r->print($message); } } else { my %actiontype = ( @@ -3335,10 +3369,10 @@ sub write_group_data { &Apache::lonnet::logthis("Failed to store $gpterm $groupname ". 'in '.lc($crstype).': '.$cnum. ' in domain: '.$cdom); - $r->print('
' - .&mt('An error occurred when [_1] the '.$gpterm.'. ' - .'Please try again.',$actiontype{$action}) - .'
'); + $r->print('

' + .&mt('An error occurred when '.$actiontype{$action}.' the '.$gpterm.'. ' + .'Please try again.') + .'print(&mt('The following users were successfully [_1]',$type)); + my $msgall =''; + foreach my $type (sort(keys(%added))) { + my $message; + my $tmsg = "The following users were successfully $type"; if (!($type eq 'deleted' || $type eq 'expired')) { - $r->print(&mt(' with the following privileges')); + $tmsg .= ' with the following privileges'; } - $r->print(':
'); + $message .= &mt($tmsg.':').'
'; foreach my $user (@{$added{$type}}) { my $privlist = ''; if (!($type eq 'deleted' || $type eq 'expired')) { @@ -3524,10 +3560,14 @@ sub process_membership { } $privlist =~ s/, $//; } - $r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.$privlist.'
'); + $message .= $$userdata{$user}[$$idx{fullname}].' - '.$user.$privlist.'
'; } - $r->print('
'); + $message .= '
'; + $message = &Apache::lonhtmlcommon::confirm_success($message); + $msgall .= $message; } + $msgall = &Apache::loncommon::confirmwrapper($msgall); + $r->print($msgall); } if ($num_fail) { foreach my $type (sort(keys(%failed))) { @@ -3540,13 +3580,15 @@ sub process_membership { } $r->print('
'); } - if (@unchanged > 0) { - $r->print(&mt('No change occurred for the following users:').'
'); - foreach my $user (sort(@unchanged)) { - $r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.'
'); - } - $r->print('
'); - } +# Is that really needed? +# +# if (@unchanged > 0) { +# $r->print(&mt('No change occurred for the following users:').'
'); +# foreach my $user (sort(@unchanged)) { +# $r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.'
'); +# } +# $r->print('
'); +# } if ($roster_result eq 'ok') { $r->print('

' .&mt($ucgpterm.' membership list updated.') @@ -3710,36 +3752,32 @@ sub standard_roles { sub modify_menu { my ($r,$groupname,$page,$gpterm) = @_; my @menu = - ( - { text => "Modify default $gpterm settings", - help => 'Course_Modify_Group', - state => 'change_settings', - branch => 'settings', + ( { categorytitle =>'Group Actions', + items => [ + + { linktext => "Modify default $gpterm settings", + url => '/adm/coursegroups?action=modify&refpage='.$env{'form.refpage'}.'&groupname='.$groupname.'&state=change_settings&branch=settings', + icon => 'grp_settings.png', + alttext => "Modify default $gpterm settings", + permission => '1', + help => 'Course_Modify_Group', }, - { text => 'Modify access, tools and/or privileges for previous, '. - 'future, or current members', + { linktext => 'Modify access, tools and privileges for members', + url => '/adm/coursegroups?action=modify&refpage='.$env{'form.refpage'}.'&groupname='.$groupname.'&state=change_members&branch=members', + icon => 'grp_tools.png', + alttext => 'Modify access, tools and privileges for members', + permission => '1', help => 'Course_Modify_Group_Membership', - state => 'change_members', - branch => 'members', }, - { text => "Add member(s) to the $gpterm", + { linktext => "Add member(s) to the $gpterm", + url => '/adm/coursegroups?action=modify&refpage='.$env{'form.refpage'}.'&groupname='.$groupname.'&state=add_members&branch=adds', + icon => 'grp_add.png', + alttext => "Add member(s) to the $gpterm", + permission => '1', help => 'Course_Group_Add_Members', - state => 'add_members', - branch => 'adds', - }, - ); - my $menu_html = ''; - foreach my $menu_item (@menu) { - $menu_html .= - '

'; - $menu_html.= &mt($menu_item->{'text'}).''; - if (exists($menu_item->{'help'})) { - $menu_html.= - &Apache::loncommon::help_open_topic($menu_item->{'help'}); - } - $menu_html.='

'.$/; - } - $r->print($menu_html); + }]} + ); + $r->print(&Apache::lonhtmlcommon::generate_menu(@menu)); return; } @@ -4007,7 +4045,7 @@ sub map_updater { $LONCAPA::map::resources[$newidx] = $itemtitle.':'.$newmapurl. ':false:normal:res'; $LONCAPA::map::order[1+$#LONCAPA::map::order]=$newidx; - my ($outtext,$errtext) = &LONCAPA::map::storemap($parentmap,1); + my ($outtext,$errtext) = &LONCAPA::map::storemap($parentmap,1,1); if ($errtext) { $outcome = '
' .&mt('Error saving updated parent folder.')." ($parentmap): $errtext" @@ -4088,10 +4126,9 @@ sub create_homepage { my ($cdom,$cnum,$name,$groupinfo,$tools,$gpterm,$ucgpterm,$now) = @_; my $functionality = join(',',@{$tools}); my $content = &unescape($$groupinfo{description}); - $content=~s/\s+$//s; - $content=~s/^\s+//s; - $content=~s/\$//s; - $content=&Apache::lonfeedback::clear_out_html($content,1); + chomp($content); + my $gateway = Apache::lonhtmlgateway->new(); + $content = $gateway->process_incoming_html($content,1); my %pageinfo = ( 'aaa_title' => "$ucgpterm: $name", @@ -4177,15 +4214,15 @@ sub validate_groupname { } if ($action eq 'create') { if (exists($curr_groups{$groupname})) { - return $exitmsg.$lt{'cnnb'}.&mt('an existing [_1]',$gpterm). + return $exitmsg.$lt{'cnnb'}.&mt("an existing $gpterm"). $lt{'inth'}.'.
'.$lt{'grna'}; } elsif (exists($deleted_groups{$groupname})) { - return $exitmsg.$lt{'cnnb'}.&mt('a [_1] which previously existed',$gpterm). + return $exitmsg.$lt{'cnnb'}.&mt("a $gpterm which previously existed"). $lt{'inth'}.'.
'.$lt{'grna'}; } } elsif ($action eq 'modify') { unless(exists($curr_groups{$groupname})) { - $earlyout = &mt('[_1] name:',$ucgpterm).' '.$groupname.$lt{'thgr'}. + $earlyout = &mt("$ucgpterm name:").' '.$groupname.$lt{'thgr'}. $lt{'inth'}; return $earlyout; } @@ -4232,3 +4269,4 @@ sub check_changes { } 1; +