--- loncom/interface/loncoursegroups.pm 2006/06/30 03:33:50 1.31 +++ loncom/interface/loncoursegroups.pm 2006/07/04 20:50:52 1.37 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursegroups.pm,v 1.31 2006/06/30 03:33:50 albertel Exp $ +# $Id: loncoursegroups.pm,v 1.37 2006/07/04 20:50:52 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -230,7 +230,10 @@ END $grp_info{$group}{'diskuse'} = sprintf("%.0f",$pct_use); } else { $grp_info{$group}{'diskuse'} = 'N/A'; - } + } + my ($groupboards,$boardshash)=&Apache::longroup::get_group_bbinfo( + $cdom,$cnum,$group); + $grp_info{$group}{'boards'} = scalar(@{$groupboards}); if ($env{'form.sortby'} eq 'groupname') { push(@{$Sortby{$group}},$group); } elsif ($env{'form.sortby'} eq 'description') { @@ -299,7 +302,7 @@ END $group.'">'.$lt{'modify'}.''; } } - $r->print(''.$link.''.$group.''.$description.''.$creator.''. &Apache::lonnavmaps::timeToHumanString($creation).''. &Apache::lonnavmaps::timeToHumanString($modified).''.$functionality.''.$quota.''.$totalmembers.''.&mt('Files: ').$totalfiles.'
'.&mt('Folders: ').$totaldirs.'
'.$boards.''.$diskuse.''); + $r->print(''.$link.''.$group.''.$description.''.$creator.''. &Apache::lonnavmaps::timeToHumanString($creation).''. &Apache::lonnavmaps::timeToHumanString($modified).''.$functionality.''.$quota.''.$totalmembers.''.&mt('Files: ').$totalfiles.'
'.&mt('Folders: ').$totaldirs.'
'.$boards.''.$diskuse.''); $rowNum ++; } } @@ -365,7 +368,7 @@ sub group_administration { my @member_changes = ('deletion','expire','activate','reenable', 'changefunc','changepriv'); my ($groupname,$description,$startdate,$enddate,$granularity,$specificity, - $quota); + $quota,$validate_script); if (defined($env{'form.groupname'})) { $groupname = $env{'form.groupname'}; @@ -435,47 +438,9 @@ sub group_administration { } } - my %toolprivs = - ( - email => { - sgm => 'Send '.$gpterm.' mail', - sgb => 'Broadcast mail', - }, - discussion => { - cgb => 'Create boards', - pgd => 'Post', - pag => 'Anon. posts', - rgi => 'Get identities', - vgb => 'View boards', - }, - chat => { - pgc => 'Chat', - }, - files => { - rgf => 'Retrieve', - ugf => 'Upload', - mgf => 'Modify', - dgf => 'Delete', - agf => 'Control Access', - }, - roster => { - vgm => 'View', - }, - homepage => { - vgh => 'View page', - mgh => 'Modify page', - }, - ); + my $toolprivs = &Apache::longroup::get_tool_privs($gpterm); - my %fixedprivs = - ( - email => {sgm => 1}, - discussion => {vgb => 1}, - chat => {pgc => 1}, - files => {rgf => 1}, - roster => {vgm => 1}, - homepage => {vgh => 1}, - ); + my $fixedprivs = &Apache::longroup::get_fixed_privs(); my %elements = ( @@ -683,8 +648,8 @@ sub group_administration { } my @currtools = (); if (@userprivs > 0) { - foreach my $tool (sort(keys(%fixedprivs))) { - foreach my $priv (keys(%{$fixedprivs{$tool}})) { + foreach my $tool (sort(keys(%{$fixedprivs}))) { + foreach my $priv (keys(%{$$fixedprivs{$tool}})) { if (grep/^$priv$/,@userprivs) { push(@currtools,$tool); last; @@ -754,19 +719,59 @@ sub group_administration { && ($specificity eq 'Yes')) { foreach my $user (sort(keys(%usertools))) { foreach my $tool (keys(%{$usertools{$user}})) { - foreach my $priv (keys(%{$toolprivs{$tool}})) { - unless (exists($fixedprivs{$tool}{$priv})) { + foreach my $priv (keys(%{$$toolprivs{$tool}})) { + unless (exists($$fixedprivs{$tool}{$priv})) { $elements{$action}{$state}{'userpriv_'.$priv} = 'checkbox'; } } } } } - + + if (($action eq 'create' && $state eq 'pick_name') || + ($action eq 'modify' && $state eq 'change_settings')) { + my ($crsquota,$freespace,$maxposs) = &get_quota_constraints($action,\%stored); + my $space_trim = '/^\s*|\s*\$/g,""'; + my $float_check = '/^([0-9]*\.?[0-9]*)$/'; + $validate_script = ' + var newquota = document.'.$state.'.quota.value; + newquota.replace('.$space_trim.'); + if (newquota == "" ) { + document.'.$state.'.quota.value = 0; + newquota = 0; + } + var maxposs = '.$maxposs.'; + if (newquota > maxposs) { + alert("The file repository 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.'; + var check_quota = newquota.match(re_quota); + if (check_quota == null) { + alert("The quota you entered contains invalid characters, the quota should only include numbers, with or without a decimal point."); + return; + } + if (newquota == 0) { + var warn_zero = 0; + for (var i=0; i "Do you want to assign different functionality ". "to different $gpterm members?", ); - my $crsquota = $env{'course.'.$env{'request.course.id'}.'.internal.coursequota'}; - if ($crsquota eq '') { - $crsquota = 20; - } - my $freespace = $crsquota - &Apache::longroup::sum_quotas(); - my $maxposs = $$stored{'quota'} + $freespace; + my ($crsquota,$freespace,$maxposs) = &get_quota_constraints($action,$stored); &topic_bar($r,$tabcol,$image,$lt{'gnde'}); $r->print(' @@ -1345,6 +1345,22 @@ END return; } +sub get_quota_constraints { + my ($action,$stored) = @_; + my ($crsquota,$freespace,$maxposs); + $crsquota = $env{'course.'.$env{'request.course.id'}.'.internal.coursequota'}; + if ($crsquota eq '') { + $crsquota = 20; + } + $freespace = $crsquota - &Apache::longroup::sum_quotas(); + if ($action eq 'create') { + $maxposs = $freespace; + } else { + $maxposs = $$stored{'quota'} + $freespace; + } + return ($crsquota,$freespace,$maxposs); +} + sub membership_options { my ($r,$action,$state,$tabcol,$sectioncount,$image,$gpterm,$ucgpterm) = @_; my $crstype = &Apache::loncommon::course_type(); @@ -1368,7 +1384,8 @@ sub membership_options { future => &mt('Will have future access'), ); - my @roles = ('st','cc','in','ta','ep','cr'); + #FIXME need to plumb around for the various cr roles defined by the user + my @roles = ('st','cc','in','ta','ep'); my @sections = keys(%{$sectioncount}); @@ -1776,7 +1793,7 @@ sub pick_new_members { if (@{$available} > 0) { if ($granularity eq 'Yes') { $r->print(' -   +   '.&mt('All:').' '); foreach my $tool (@{$available}) { $r->print('