');
$rowNum ++;
}
}
@@ -364,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'};
@@ -434,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 =
(
@@ -682,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;
@@ -753,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('
@@ -1344,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();
@@ -1367,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});
@@ -1402,8 +1420,8 @@ sub membership_options {
$r->print(&Apache::lonhtmlcommon::role_select_row(\@roles));
if (@sections > 0) {
@sections = sort {$a cmp $b} @sections;
- unshift(@sections,'all'); # Put 'all' at the front of the list
unshift(@sections,'none'); # Put 'no sections' next
+ unshift(@sections,'all'); # Put 'all' at the front of the list
$r->print('