');
&mapping_options($r,$action,$formname,$page,$tabcol,$sectioncount,
$states,$stored,$navbuttons,4,5,$rowColor1,
- $rowColor2);
+ $rowColor2,$gpterm,$ucgpterm,$crstype);
$nexttext = $$navbuttons{'mose'};
}
$prevtext = $$navbuttons{'gtpp'};
@@ -1162,18 +1229,25 @@ sub general_settings_form {
}
sub groupsettings_options {
- my ($r,$tabcol,$functions,$action,$formname,$stored,$image) = @_;
+ my ($r,$tabcol,$functions,$action,$formname,$stored,$image,$gpterm,
+ $ucgpterm,$crstype) = @_;
my %lt = &Apache::lonlocal::texthash(
- 'gdat' => 'Group open and close dates',
- 'sten' => 'Set a start date/time and end date/time for the group',
- 'gfun' => 'Group functionality',
- 'gnde' => 'Group name, description and available functionality',
+ 'gdat' => "$ucgpterm open and close dates",
+ 'sten' => "Set a start date/time and end date/time for the $gpterm",
+ 'gfun' => "$ucgpterm functionality",
+ 'gnde' => "$ucgpterm name, description and available functionality",
'desc' => 'Description',
'func' => 'Functionality',
- 'gnam' => 'Group Name',
- 'doyo' => 'Do you want to assign different functionality '.
- 'to different group members?',
+ 'gnam' => "$ucgpterm Name",
+ 'doyo' => "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;
&topic_bar($r,$tabcol,$image,$lt{'gnde'});
$r->print('
@@ -1234,8 +1308,8 @@ END
-
Granularity:
-
'.$lt{'doyo'}.' ');
+
'.&mt('Granularity:').'
+
'.$lt{'doyo'}.' ');
if ($action eq 'modify') {
$r->print(' ('.&mt('Currently set to "[_1]"',
$$stored{'granularity'}).')');
@@ -1243,6 +1317,30 @@ END
$r->print('
+
+
'.&mt('Disk quota: ').'
');
+ if ($action eq 'create') {
+ $r->print(&mt('If you enable the file repository for the [_1], allocate a disk quota.',$gpterm));
+ } else {
+ $r->print(&mt('Quota allocated to file repository:'));
+ }
+ $r->print(' Mb');
+ if ($action eq 'create') {
+ $r->print(' '.
+ &mt('A total of [_1] Mb is shared between all [_2]s in the '.
+ '[_3], and [_4] Mb are currently unallocated.',$crsquota,
+ $gpterm,lc($crstype),$freespace));
+ } else {
+ $r->print(' ('.&mt('The quota is currently [_1] Mb',
+ $$stored{'quota'}).').');
+
+ $r->print(' '.&mt('The quota can be increased to [_1] Mb, '.
+ 'by adding all unallocated space for [_2]s in the [_3].',
+ $maxposs,$gpterm,lc($crstype)));
+ }
+ $r->print('
+
+
@@ -1251,20 +1349,21 @@ END
}
sub membership_options {
- my ($r,$action,$state,$tabcol,$sectioncount,$image) = @_;
+ my ($r,$action,$state,$tabcol,$sectioncount,$image,$gpterm,$ucgpterm) = @_;
+ my $crstype = &Apache::loncommon::course_type();
my %lt = &Apache::lonlocal::texthash(
'pipa' => 'Pick parameters to generate membership list',
- 'gmem' => 'Group membership options',
+ 'gmem' => "$ucgpterm membership options",
'picr' => 'Pick the criteria to use to build a list of '.
- 'course users from which you will select ',
- 'meof' => 'members of the new group.',
- 'admg' => 'additional members of the group.',
- 'ifno' => 'If you do not wish to add members when you first '.
- 'create the group, do not make any selections.',
- 'asub' => 'A subsequent step will also allow you to specify automatic adding/dropping of group members triggered by specified role and section changes.',
+ lc($crstype).' users from which you will select ',
+ 'meof' => "members of the new $gpterm.",
+ 'admg' => "additional members of the $gpterm.",
+ 'ifno' => "If you do not wish to add members when you first ".
+ "create the $gpterm, do not make any selections.",
+ 'asub' => "A subsequent step will also allow you to specify automatic adding/dropping of $gpterm members triggered by specified role and section changes.",
'acty' => 'Access types',
- 'coro' => 'Course roles',
- 'cose' => 'Course sections',
+ 'coro' => $crstype.' roles',
+ 'cose' => $crstype.' sections',
);
my %status_types = (
active => &mt('Currently has access'),
@@ -1307,8 +1406,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('
');
@@ -1330,11 +1429,11 @@ sub sections_selection {
}
foreach my $sec (@{$sections}) {
if ($sec eq 'all') {
- $section_sel .= ' all sections'."\n";
+ $section_sel .= ' '."\n";
} elsif ($sec eq 'none') {
- $section_sel .= ' no section'."\n";
+ $section_sel .= ' '."\n";
} else {
- $section_sel .= ' '.$sec."\n";
+ $section_sel .= ' \n";
}
}
my $output = '
@@ -1345,9 +1444,9 @@ sub sections_selection {
}
sub access_date_settings {
- my ($r,$tabcol,$action,$formname,$stored,$image) = @_;
+ my ($r,$tabcol,$action,$formname,$stored,$image,$gpterm,$ucgpterm) = @_;
my %lt = &Apache::lonlocal::texthash(
- 'sten' => 'Default start and end dates for group access',
+ 'sten' => "Default start and end dates for $gpterm access",
);
my $starttime = time;
my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
@@ -1377,16 +1476,17 @@ sub access_date_settings {
sub choose_members_form {
my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$groupname,$description,
- $granularity,$startdate,$enddate,$tools,$fixedprivs,$toolprivs,
+ $granularity,$quota,$startdate,$enddate,$tools,$fixedprivs,$toolprivs,
$functions,$users,$userdata,$idx,$stored,$states,$navbuttons,
- $rowColor1,$rowColor2) = @_;
+ $rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype) = @_;
my @regexps = ('user_','userpriv_','sec_');
my %origmembers;
$r->print(&Apache::lonhtmlcommon::echo_form_input(
['origin','action','state','page','member','specificity','branch',
'defpriv','autorole','autoadd','autodrop','sortby','togglefunc'],
\@regexps));
- my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum);
+ my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum,$gpterm,
+ $ucgpterm,$crstype);
$r->print('
@@ -1407,8 +1507,8 @@ sub choose_members_form {
if ($action eq 'create') {
&print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2,
$functions,$startdate,$enddate,$groupname,
- $description,$granularity,\@available,
- \@unavailable);
+ $description,$granularity,$quota,\@available,
+ \@unavailable,$gpterm,$ucgpterm);
$specimg = 4;
$memimg = 5;
} else {
@@ -1430,11 +1530,11 @@ sub choose_members_form {
}
&privilege_specificity($r,$tabcol,$rowColor1,$rowColor2,$action,
$specimg,$tools,$stored,$toolprivs,
- $fixedprivs,\@available,$formname);
+ $fixedprivs,\@available,$formname,$gpterm,$ucgpterm);
my $newusers = &pick_new_members($r,$action,$formname,$tabcol,$rowColor1,
$rowColor2,\@available,$idx,$stored,
$memimg,$users,$userdata,$granularity,
- \%origmembers);
+ \%origmembers,$gpterm,$ucgpterm);
if ($newusers || $action eq 'create') {
&display_navbuttons($r,$formname,$$states{$action}[$page-1],
$$navbuttons{'gtps'},$$states{$action}[$page+1],
@@ -1487,17 +1587,19 @@ sub check_tools {
sub print_current_settings {
my ($r,$action,$tabcol,$rowColor1,$rowColor2,$functions,$startdate,$enddate,
- $groupname,$description,$granularity,$available,$unavailable) =@_;
+ $groupname,$description,$granularity,$quota,$available,$unavailable,
+ $gpterm,$ucgpterm) = @_;
my %lt = &Apache::lonlocal::texthash(
- grna => 'Group Name',
+ grna => "$ucgpterm Name",
desc => 'Description',
- grfn => 'Group Functions',
+ grfn => "$ucgpterm Functions",
gran => 'Granularity',
+ quot => 'File quota',
dfac => 'Default access dates',
- ygrs => 'Your group selections',
- tfwa => 'The following settings will apply to the group:',
- difn => 'Different functionality for different users:',
+ ygrs => "Your $gpterm selections",
+ tfwa => "The following settings will apply to the $gpterm:",
+ difn => 'Different functionality for different members:',
stda => 'Start date',
enda => 'End date:',
);
@@ -1528,6 +1630,7 @@ sub print_current_settings {
'.$lt{'desc'}.'
'.$lt{'grfn'}.'
'.$lt{'gran'}.'
+
'.$lt{'quot'}.'
'.$lt{'dfac'}.'
@@ -1574,7 +1677,8 @@ sub print_current_settings {
$r->print(<<"END");
$lt{'difn'}
- $granularity
+ $granularity
+
$quota Mb
$lt{'stda'} $showstart $lt{'enda'} $showend
@@ -1590,16 +1694,17 @@ END
sub pick_new_members {
my ($r,$action,$formname,$tabcol,$rowColor1,$rowColor2,$available,$idx,
- $stored,$img,$users,$userdata,$granularity,$origmembers) = @_;
+ $stored,$img,$users,$userdata,$granularity,$origmembers,$gpterm,
+ $ucgpterm) = @_;
my %lt = &Apache::lonlocal::texthash(
- 'gpme' => 'Group membership',
+ 'gpme' => "$ucgpterm membership",
'addm' => 'Add members',
'setf' => 'Set functionality',
'func' => 'Functionality',
'nome' => 'No members to add at this time.',
- 'nnew' => 'There are no users to add as new members, as all users'.
- ' matching the specified type(s), role(s), and/or '.
- 'section(s) are already affiliated with this group.',
+ 'nnew' => "There are no users to add as new members, as all users".
+ " matching the specified type(s), role(s), and/or ".
+ "section(s) are already affiliated with this $gpterm.",
'yoma' => 'You may need to use the '."'".'modify existing, past or '.
'future members'."'".' page if you need to re-enable '.
'or activate access for previous or future members.',
@@ -1665,6 +1770,7 @@ sub pick_new_members {
');
@@ -1693,6 +1799,8 @@ sub pick_new_members {
push(@{$Sortby{$members{$user}[$$idx{udom}]}},$user);
} elsif ($env{'form.sortby'} eq 'id') {
push(@{$Sortby{$members{$user}[$$idx{id}]}},$user);
+ } elsif ($env{'form.sortby'} eq 'section') {
+ push(@{$Sortby{$members{$user}[$$idx{section}]}},$user);
} else {
push(@{$Sortby{$members{$user}[$$idx{fullname}]}},$user);
}
@@ -1710,10 +1818,12 @@ sub pick_new_members {
my $fullname = $members{$user}[$$idx{fullname}];
my $udom = $members{$user}[$$idx{udom}];
my $uname = $members{$user}[$$idx{uname}];
+ my $section = $members{$user}[$$idx{section}];
$r->print('
'.
$fullname.'
'.$uname.'
'.
- $udom.'
'.$id.'
');
+ $udom.'
'.$id.'
'.
+ '
'.$section.'
');
if (@{$available} > 0) {
$r->print('
'.
' ');
@@ -1756,7 +1866,7 @@ sub pick_new_members {
sub privilege_specificity {
my ($r,$tabcol,$rowColor1,$rowColor2,$action,$img,$tools,$stored,
- $toolprivs,$fixedprivs,$available,$formname) = @_;
+ $toolprivs,$fixedprivs,$available,$formname,$gpterm,$ucgpterm) = @_;
my %lt = &Apache::lonlocal::texthash (
'uprv' => 'User privileges',
'frty' => 'For each type of functionality you have chosen to include, '.
@@ -1771,19 +1881,19 @@ sub privilege_specificity {
'privileges which apply to members with access to that '.
'functionality, and may also include additional privileges '.
'which can be set for specific members.',
- 'cutg' => 'Currently the group is configured ',
- 'sdif' => 'so different group members can receive different privileges.',
- 'sall' => 'so all group members will receive the same privileges.',
- 'algm' => 'All group members will receive the same privileges.',
- 'smgp' => 'Some group members will receive different privileges from '.
- 'others.',
- 'thwi' => 'These will be the privileges all group members receive, '.
- 'if you selected the first option above.',
- 'thes' => 'These will be the privileges given to members assigned '.
- 'in the future, including via automatic group assignment '.
- 'for specific sections/roles ',
- 'asyo' => 'As you have chosen not to include any functionality in the '.
- 'group, no default user privileges settings need to be set.',
+ 'cutg' => "Currently the $gpterm is configured ",
+ 'sdif' => "so different $gpterm members can receive different privileges.",
+ 'sall' => "so all $gpterm members will receive the same privileges.",
+ 'algm' => "All $gpterm members will receive the same privileges.",
+ 'smgp' => "Some $gpterm members will receive different privileges from ".
+ "others.",
+ 'thwi' => "These will be the privileges all $gpterm members receive, ".
+ "if you selected the first option above.",
+ 'thes' => "These will be the privileges given to members assigned ".
+ "in the future, including via automatic $gpterm assignment ".
+ "for specific sections/roles ",
+ 'asyo' => "As you have chosen not to include any functionality in the ".
+ "$gpterm, no default user privileges settings need to be set.",
'plin' => 'Please indicate which optional privileges members '.
'will receive by default.',
'oppr' => 'Optional privileges',
@@ -2048,11 +2158,11 @@ sub display_defprivs {
sub change_members_form {
my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$groupname,$description,
$startdate,$enddate,$tools,$fixedprivs,$functions,$users,$userdata,
- $granularity,$specificity,$idx,$states,$navbuttons,$rowColor1,
- $rowColor2) = @_;
+ $granularity,$quota,$specificity,$idx,$states,$navbuttons,$rowColor1,
+ $rowColor2,$gpterm,$ucgpterm) = @_;
my %lt = &Apache::lonlocal::texthash(
- grse => 'Group settings',
- mogm => 'Modify group membership',
+ grse => "$ucgpterm settings",
+ mogm => "Modify $gpterm membership",
);
my @regexps = ('user_','userpriv_');
$r->print(&Apache::lonhtmlcommon::echo_form_input(
@@ -2077,7 +2187,8 @@ sub change_members_form {
');
&print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2,
$functions,$startdate,$enddate,$groupname,
- $description,$granularity,\@available,\@unavailable);
+ $description,$granularity,$quota,\@available,
+ \@unavailable,$gpterm,$ucgpterm);
$r->print('
');
&topic_bar($r,$tabcol,2,$lt{'mogm'});
@@ -2122,7 +2233,7 @@ sub current_membership {
my $addtools = 0;
my $num_reenable = 0;
my $num_activate = 0;
- my $num_expire - 0;
+ my $num_expire = 0;
foreach my $key (sort(keys(%membership))) {
if ($key =~ /^\Q$groupname\E:([^:]+):([^:]+)$/) {
my $uname = $1;
@@ -2419,13 +2530,13 @@ sub change_privs_form {
my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$startdate,$enddate,
$tools,$functions,$toolprivs,$fixedprivs,$userdata,$usertools,
$memchg,$idx,$states,$stored,$sectioncount,$navbuttons,$rowColor1,
- $rowColor2) = @_;
+ $rowColor2,$gpterm,$ucgpterm) = @_;
my @regexps = ('userpriv_');
my $nexttext;
my %lt = &Apache::lonlocal::texthash(
'tode' => 'To be deleted',
'toex' => 'To be expired',
- 'nome' => 'No members to be deleted or expired from the group.',
+ 'nome' => "No members to be deleted or expired from the $gpterm.",
);
$r->print(&Apache::lonhtmlcommon::echo_form_input(
['origin','action','state','page','sortby'],\@regexps));
@@ -2464,12 +2575,13 @@ sub change_privs_form {
'
');
}
- &topic_bar($r,$tabcol,4,&mt('Group member privileges'));
+ &topic_bar($r,$tabcol,4,&mt('[_1] member privileges',$ucgpterm));
my $numchgs = &member_privileges_form($r,$tabcol,$action,$formname,$tools,
$toolprivs,$fixedprivs,$userdata,
$usertools,$idx,$memchg,$states,
- $stored,$rowColor1,$rowColor2);
+ $stored,$rowColor1,$rowColor2,
+ $gpterm);
$r->print('
');
my $prevtext = $$navbuttons{'gtps'};
if ($numchgs || $exp_or_del) {
@@ -2484,8 +2596,8 @@ sub change_privs_form {
sub add_members_form {
my ($r,$tabcol,$action,$formname,$page,$startdate,$enddate,$groupname,
- $description,$granularity,$sectioncount,$tools,$functions,$stored,
- $states,$navbuttons,$rowColor1,$rowColor2) = @_;
+ $description,$granularity,$quota,$sectioncount,$tools,$functions,
+ $stored,$states,$navbuttons,$rowColor1,$rowColor2,$gpterm,$ucgpterm)=@_;
$r->print('
');
- &membership_options($r,$action,$formname,$tabcol,$sectioncount,1);
+ &membership_options($r,$action,$formname,$tabcol,$sectioncount,1,$gpterm,
+ $ucgpterm);
my $nexttext = $$navbuttons{'gtns'};
my $prevtext = $$navbuttons{'gtpp'};
&display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext,
@@ -2518,7 +2632,8 @@ sub add_members_form {
sub choose_privs_form {
my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$startdate,$enddate,
$tools,$functions,$toolprivs,$fixedprivs,$userdata,$usertools,$idx,
- $states,$stored,$sectioncount,$navbuttons,$rowColor1,$rowColor2) = @_;
+ $states,$stored,$sectioncount,$navbuttons,$rowColor1,$rowColor2,
+ $gpterm,$ucgpterm,$crstype) = @_;
my @regexps = ('userpriv_');
my $nexttext;
@@ -2536,11 +2651,11 @@ sub choose_privs_form {
}
$r->print('
');
- &topic_bar($r,$tabcol,6,&mt('Group member privileges'));
+ &topic_bar($r,$tabcol,6,&mt('[_1] member privileges',$ucgpterm));
&member_privileges_form($r,$tabcol,$action,$formname,$tools,$toolprivs,
$fixedprivs,$userdata,$usertools,$idx,undef,
- $states,$stored,$rowColor1,$rowColor2);
+ $states,$stored,$rowColor1,$rowColor2,$gpterm);
$r->print('
');
if ($action eq 'create') {
@@ -2549,7 +2664,7 @@ sub choose_privs_form {
my $img2 = 8;
&mapping_options($r,$action,$formname,$page,$tabcol,$sectioncount,
$states,$stored,$navbuttons,$img1,$img2,
- $rowColor1,$rowColor2);
+ $rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype);
}
}
my $prevtext = $$navbuttons{'gtps'};
@@ -2619,7 +2734,8 @@ function uncheckAllTools(formname) {
sub member_privileges_form {
my ($r,$tabcol,$action,$formname,$tools,$toolprivs,$fixedprivs,$userdata,
- $usertools,$idx,$memchg,$states,$stored,$rowColor1,$rowColor2) = @_;
+ $usertools,$idx,$memchg,$states,$stored,$rowColor1,$rowColor2,
+ $gpterm) = @_;
my %lt = &Apache::lonlocal::texthash(
'addp' => 'Additional privileges',
'fixp' => 'Fixed privileges',
@@ -2628,15 +2744,15 @@ sub member_privileges_form {
'forf' => 'For the functionality you have chosen to include '.
'there are no optional privileges to set besides '.
'the standard privileges.',
- 'algr' => 'All group members will receive the same privileges.',
- 'asno' => 'As no group members are being added, '.
- 'there are no specific user privileges to set.',
- 'asng' => 'As no group tools will be made available to users, '.
- 'there are no specific user privileges to set.',
- 'nogm' => 'No group member privileges to display or set, '.
- 'as you have not indicated that you will be activating,'.
- ' re-enabling, changing privileges, or adding/removing '.
- 'functionality for any current members ',
+ 'algr' => "All $gpterm members will receive the same privileges.",
+ 'asno' => "As no $gpterm members are being added, ".
+ "there are no specific user privileges to set.",
+ 'asng' => "As no $gpterm tools will be made available to users, ".
+ "there are no specific user privileges to set.",
+ 'nogm' => "No $gpterm member privileges to display or set, ".
+ "as you have not indicated that you will be activating,".
+ " re-enabling, changing privileges, or adding/removing ".
+ "functionality for any current members ",
'full' => 'Fullname',
'user' => 'Username',
'doma' => 'Domain',
@@ -2795,12 +2911,14 @@ sub process_request {
my ($r,$cdom,$cnum,$tabcol,$action,$state,$page,$groupname,$description,
$specificity,$userdata,$startdate,$enddate,$tools,$functions,$toolprivs,
$usertools,$idx,$types,$roles,$sections,$states,$navbuttons,$memchg,
- $sectioncount,$stored,$rowColor1,$rowColor2) = @_;
+ $sectioncount,$stored,$rowColor1,$rowColor2,$gpterm,$ucgpterm,
+ $crstype) = @_;
$r->print(&Apache::lonhtmlcommon::echo_form_input(
['origin','action','state','page','sortby']));
- my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum);
+ my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum,$gpterm,
+ $ucgpterm,$crstype);
if ($earlyout) {
$r->print('
@@ -2846,13 +2964,15 @@ sub process_request {
$description,$startdate,$enddate,
$specificity,$functions,$tools,
$sectioncount,$roles,$types,$sections,
- \@defprivs,$stored);
+ \@defprivs,$stored,$gpterm,$ucgpterm,
+ $crstype);
}
if (($action eq 'create' && $outcome eq 'ok') || (($action eq 'modify') &&
(($state eq 'memresult') || ($state eq 'addresult')))) {
&process_membership($r,$cdom,$cnum,$action,$state,$groupname,$tools,
$enddate,$startdate,$userdata,$idx,$toolprivs,
- $usertools,$specificity,\@defprivs,$memchg);
+ $usertools,$specificity,\@defprivs,$memchg,$gpterm,
+ $ucgpterm);
}
return;
}
@@ -2860,7 +2980,7 @@ sub process_request {
sub write_group_data {
my ($r,$cdom,$cnum,$action,$state,$groupname,$description,$startdate,
$enddate,$specificity,$functions,$tools,$sectioncount,$roles,$types,
- $sections,$defprivs,$stored) = @_;
+ $sections,$defprivs,$stored,$gpterm,$ucgpterm,$crstype) = @_;
my $now = time;
my $creation = $now;
my $creator = $env{'user.name'}.':'.$env{'user.domain'};
@@ -2871,7 +2991,7 @@ sub write_group_data {
my $esc_description = &escape($description);
my @single_attributes = ('description','functions','startdate','enddate',
'creation','modified','creator','granularity',
- 'specificity','autoadd','autodrop');
+ 'specificity','autoadd','autodrop','quota');
my @mult_attributes = ('roles','types','sectionpick','defpriv');
my %groupinfo = (
@@ -2885,6 +3005,7 @@ sub write_group_data {
specificity => $specificity,
autoadd => $env{'form.autoadd'},
autodrop => $env{'form.autodrop'},
+ quota => $env{'form.quota'},
);
foreach my $func (keys(%{$functions})) {
my $status;
@@ -2932,28 +3053,34 @@ sub write_group_data {
if ($result eq 'ok') {
if ($action eq 'create') {
- my $put_result = &create_homepage($cdom,$cnum,$groupname,
- \%groupinfo,$tools);
- $r->print('Group '.$groupname.' was created. ');
+ my $result = &add_group_folder($cdom,$cnum,$now,$groupname,$action,
+ $description,$tools,\%groupinfo,
+ $gpterm,$ucgpterm,$crstype);
+ if ($result ne 'ok') {
+ $r->print(&mt('A problem occurred when creating folders for the new [_1]. [_2].',$gpterm,$result));
+ }
+ $r->print(&mt('[_1] [_2] was created. ',$ucgpterm,$groupname));
} else {
- $r->print('Group '.$groupname.' was updated. ');
+ $r->print(&mt('[_1] [_2] was updated. ',$ucgpterm,$groupname));
}
} else {
my %actiontype = (
'create' => 'creating',
'modify' => 'modifying',
);
- &Apache::lonnet::logthis('Failed to store group '.$groupname.
- 'in course: '.$cnum.' in domain: '.$cdom);
- $r->print(&mt('An error occurred when [_1] the new group. '.
- 'Please try again.',$actiontype{$action}));
+ &Apache::lonnet::logthis("Failed to store $gpterm $groupname ".
+ 'in '.lc($crstype).': '.$cnum.
+ ' in domain: '.$cdom);
+ $r->print(&mt('An error occurred when [_1] the new [_2]. '.
+ 'Please try again.',$actiontype{$action},$gpterm));
}
return $result;
}
sub process_membership {
my ($r,$cdom,$cnum,$action,$state,$groupname,$tools,$enddate,$startdate,
- $userdata,$idx,$toolprivs,$usertools,$specificity,$defprivs,$memchg)=@_;
+ $userdata,$idx,$toolprivs,$usertools,$specificity,$defprivs,$memchg,
+ $gpterm,$ucgpterm)=@_;
my %usersettings = ();
my %added= ();
my %failed = ();
@@ -3150,30 +3277,32 @@ sub process_membership {
$r->print(' ');
}
if ($roster_result eq 'ok') {
- $r->print(' '.&mt('Group membership list updated.'));
+ $r->print(' '.&mt('[_1] membership list updated.',$ucgpterm));
+ $r->print('
'.&mt("For full access to all of [_1]'s privileges, users will need to log out and log back in.",$groupname).'
');
} else {
- $r->print(' '.&mt('An error occurred while updating the group membership list -').$roster_result.' ');
+ $r->print(' '.&mt('An error occurred while updating the [_1] membership list -',$gpterm).$roster_result.' ');
}
return;
}
sub mapping_options {
my ($r,$action,$formname,$page,$tabcol,$sectioncount,$states,$stored,
- $navbuttons,$img1,$img2,$rowColor1,$rowColor2) = @_;
+ $navbuttons,$img1,$img2,$rowColor1,$rowColor2,$gpterm,$ucgpterm,
+ $crstype) = @_;
my %lt = &Apache::lonlocal::texthash(
- 'auto' => 'Settings for automatic group enrollment',
- 'gmma' => 'Group membership mapping to specific sections/roles',
- 'endi' => 'Enable/disable automatic group enrollment for '.
- 'users in specified roles and sections',
- 'adds' => 'If automatic group enrollment is enabled, when a user is assigned a course-wide or section-specific role, he/she will automatically be added as a member of the group, with start and end access dates defined by the default dates set for the group, unless he/she is already a group member, with access dates that permit either current or future group access.',
- 'drops' => "If automatic group disenrollment is enabled, when a user's role is expired, access to the group will be terminated unless the user continues to have other course-wide or section-specific active or future roles which receive automatic membership in the group.",
- 'pirs' => 'Pick roles and sections for automatic group enrollment',
+ 'auto' => "Settings for automatic $gpterm enrollment",
+ 'gmma' => "$ucgpterm membership mapping to specific sections/roles",
+ 'endi' => "Enable/disable automatic $gpterm enrollment for ".
+ "users in specified roles and sections",
+ 'adds' => "If automatic $gpterm enrollment is enabled, when a user is assigned a ".lc($crstype)."-wide or section-specific role, he/she will automatically be added as a member of the $gpterm, with start and end access dates defined by the default dates set for the $gpterm, unless he/she is already a $gpterm member, with access dates that permit either current or future $gpterm access.",
+ 'drops' => "If automatic $gpterm disenrollment is enabled, when a user's role is expired, access to the $gpterm will be terminated unless the user continues to have other ".lc($crstype)."-wide or section-specific active or future roles which receive automatic membership in the $gpterm.",
+ 'pirs' => "Pick roles and sections for automatic $gpterm enrollment",
'curr' => 'Currently set to',
'on' => 'on',
'off' => 'off',
- 'auad' => 'Automatically enable group membership when roles are added?',
- 'auex' => 'Automatically expire group membership when roles are removed?',
- 'mapr' => 'Mapping of roles and sections affected by automatic group enrollment/disenrollment follows scheme chosen below.',
+ 'auad' => "Automatically enable $gpterm membership when roles are added?",
+ 'auex' => "Automatically expire $gpterm membership when roles are removed?",
+ 'mapr' => "Mapping of roles and sections affected by automatic $gpterm enrollment/disenrollment follows scheme chosen below.",
);
&automapping($r,$action,$tabcol,$stored,\%lt,$img1);
$r->print('
@@ -3181,7 +3310,7 @@ sub mapping_options {
');
&mapping_settings($r,$tabcol,$rowColor1,$rowColor2,$sectioncount,\%lt,
- $stored,$img2);
+ $stored,$img2,$crstype);
return;
}
@@ -3241,7 +3370,8 @@ sub automapping {
}
sub mapping_settings {
- my ($r,$tabcol,$rowColor1,$rowColor2,$sectioncount,$lt,$stored,$image) = @_;
+ my ($r,$tabcol,$rowColor1,$rowColor2,$sectioncount,$lt,$stored,$image,
+ $crstype) = @_;
my @sections = keys(%{$sectioncount});
if (@sections > 0) {
@sections = sort {$a cmp $b} @sections;
@@ -3267,7 +3397,7 @@ sub mapping_settings {
my $rowNum = 0;
my $rowColor;
foreach my $role (@roles) {
- my $plrole=&Apache::lonnet::plaintext($role);
+ my $plrole=&Apache::lonnet::plaintext($role,$crstype);
my $sections_sel;
if (@sections > 0) {
if ($role eq 'cc') {
@@ -3327,10 +3457,10 @@ sub my_custom_roles {
}
sub modify_menu {
- my ($r,$groupname,$page) = @_;
+ my ($r,$groupname,$page,$gpterm) = @_;
my @menu =
(
- { text => 'Modify default group settings',
+ { text => "Modify default $gpterm settings",
help => 'Course_Modify_Group',
state => 'change_settings',
branch => 'settings',
@@ -3341,7 +3471,7 @@ sub modify_menu {
state => 'change_members',
branch => 'members',
},
- { text => 'Add member(s) to the group',
+ { text => "Add member(s) to the $gpterm",
help => 'Course_Group_Add_Members',
state => 'add_members',
branch => 'adds',
@@ -3454,8 +3584,159 @@ sub date_setting_table {
return ($start_table, $end_table);
}
+sub add_group_folder {
+ my ($cdom,$cnum,$now,$groupname,$action,$description,$tools,$groupinfo,
+ $gpterm,$ucgpterm,$crstype) = @_;
+ if ($cdom eq '' || $cnum eq '') {
+ return &mt('Error: invalid course domain or number - group folder creation failed');
+ }
+ my ($outcome,$allgrpsmap,$grpmap,$boardsmap,$grppage);
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
+ $allgrpsmap = $crspath.'default_0.sequence';
+ my $topmap = $navmap->getResourceByUrl($allgrpsmap);
+ undef($navmap);
+ if ($action eq 'create') {
+ # check if default_0.sequence exists.
+ if (!$topmap) {
+ my $grpstitle = &mt('[_1] [_2]',$crstype,$ucgpterm);
+ my $topmap_url = '/'.$env{'course.'.$env{'request.course.id'}.'.url'};
+ $topmap_url =~ s|/+|/|g;
+ if ($topmap_url =~ m|^/uploaded|) {
+ $outcome = &map_updater($cdom,$cnum,'default_0.sequence',
+ 'toplevelgroup',$grpstitle,$topmap_url);
+ if ($outcome ne 'ok') {
+ return $outcome;
+ }
+ } else {
+ $outcome = &mt('Non-standard course - group folder not added.');
+ return $outcome;
+ }
+ }
+ my $grpfolder = &mt('[_1] Folder -',$ucgpterm,).$description;
+ $grppage='/adm/'.$cdom.'/'.$cnum.'/'.$groupname.'/grppg';
+ my $grptitle = &mt('Group homepage').' - '.$description;
+ my ($seqid,$discussions,$disctitle);
+ my $outcome = &map_updater($cdom,$cnum,'default_'.$now.'.sequence',
+ 'grpseq',$grpfolder,$allgrpsmap,$grppage,
+ $grptitle);
+ if ($outcome ne 'ok') {
+ return $outcome;
+ }
+ my $pageout = &create_homepage($cdom,$cnum,$groupname,$groupinfo,
+ $tools,$gpterm,$ucgpterm,$now);
+ # Link to folder for bulletin boards
+ $grpmap = $crspath.'default_'.$now.'.sequence';
+ if (grep/^discussion$/,@{$tools}) {
+ $seqid = $now + 1;
+ $disctitle = &mt('Discussion Boards');
+ my $outcome = &map_updater($cdom,$cnum,'default_'.$seqid.
+ '.sequence','bbseq',$disctitle,$grpmap);
+ if ($outcome ne 'ok') {
+ return $outcome;
+ }
+ $boardsmap = $crspath.'default_'.$seqid.'.sequence';
+ }
+ } else {
+ #modify group folder if status of discussions tools is changed
+ }
+ my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
+ $navmap = Apache::lonnavmaps::navmap->new();
+ # modify parameters
+ my $parm_result;
+ if ($action eq 'create') {
+ if ($allgrpsmap) {
+ $parm_result .= &parm_setter($navmap,$cdom,$allgrpsmap,$groupname);
+ }
+ if ($grpmap) {
+ $parm_result .= &parm_setter($navmap,$cdom,$grpmap,$groupname);
+ }
+ if ($grppage) {
+ $parm_result .= &parm_setter($navmap,$cdom,$grppage,$groupname);
+ }
+ if ($boardsmap) {
+ $parm_result .= &parm_setter($navmap,$cdom,$boardsmap,$groupname);
+ }
+ }
+ if ($parm_result) {
+ return $parm_result;
+ } else {
+ return 'ok';
+ }
+}
+
+sub map_updater {
+ my ($cdom,$cnum,$newfile,$itemname,$itemtitle,$parentmap,$startsrc,
+ $starttitle,$endsrc,$endtitle) = @_;
+ my $outcome;
+ $env{'form.'.$itemname} = &new_map($startsrc,$starttitle,$endsrc,
+ $endtitle);
+ my $newmapurl=&Apache::lonnet::finishuserfileupload($cnum,$cdom,$itemname,
+ $newfile);
+ if ($newmapurl !~ m|^/uploaded|) {
+ $outcome = "Error uploading new folder ($newfile): $newmapurl";
+ return $outcome;
+ }
+ my ($errtext,$fatal)=&Apache::lonratedt::mapread($parentmap);
+ if ($fatal) {
+ $outcome = "Error reading contents of parent folder ($parentmap): $errtext\n";
+ return $outcome;
+ } else {
+ my $newidx=&Apache::lonratedt::getresidx($newmapurl);
+ $Apache::lonratedt::resources[$newidx] = $itemtitle.':'.$newmapurl.
+ ':false:normal:res';
+ $Apache::lonratedt::order[1+$#Apache::lonratedt::order]=$newidx;
+ my ($outtext,$errtext) = &Apache::lonratedt::storemap($parentmap,1);
+ if ($errtext) {
+ $outcome = "Error storing updated parent folder ($parentmap): $errtext\n";
+ return $outcome;
+ }
+ }
+ return 'ok';
+}
+
+sub new_map {
+ my ($startsrc,$starttitle,$endsrc,$endtitle) = @_;
+ my $newmapstr = '
+
+';
+ return $newmapstr;
+}
+
+sub parm_setter {
+ my ($navmap,$cdom,$url,$groupname) = @_;
+ my %parmresult;
+ my %hide_settings = (
+ 'course' => {
+ 'num' => 13,
+ 'set' => 'yes',
+ },
+ 'group' => {
+ 'num' => 5,
+ 'set' => 'no',
+ 'extra' => $groupname,
+ },
+ );
+ my $res = $navmap->getResourceByUrl($url);
+ my $symb = $res->symb();
+ foreach my $level (keys(%hide_settings)) {
+ $parmresult{$level} = &Apache::lonparmset::storeparm_by_symb($symb,
+ '0_hiddenresource',
+ $hide_settings{$level}{'num'},
+ $hide_settings{$level}{'set'},
+ 'string_yesno',undef,$cdom,
+ undef,undef,
+ $hide_settings{$level}{'extra'});
+ }
+ return %parmresult;
+}
+
sub create_homepage {
- my ($cdom,$cnum,$name,$groupinfo,$tools) = @_;
+ my ($cdom,$cnum,$name,$groupinfo,$tools,$gpterm,$ucgpterm,$now) = @_;
my $functionality = join(',',@{$tools});
my $content = &unescape($$groupinfo{description});
$content=~s/\s+$//s;
@@ -3464,11 +3745,11 @@ sub create_homepage {
$content=&Apache::lonfeedback::clear_out_html($content,1);
my %pageinfo = (
- 'aaa_title' => 'Group: '.$name,
+ 'aaa_title' => "$ucgpterm: $name",
'abb_links' => $functionality,
'bbb_content' => $content,
'ccc_webreferences' => '',
- 'uploaded.lastmodified' => time,
+ 'uploaded.lastmodified' => $now,
);
my $putresult = &Apache::lonnet::put('grppage_'.$name,\%pageinfo,$cdom,$cnum);
return $putresult;
@@ -3510,22 +3791,22 @@ function toggleTools(field,caller) {
}
sub validate_groupname {
- my ($groupname,$action,$cdom,$cnum) = @_;
+ my ($groupname,$action,$cdom,$cnum,$gpterm,$ucgpterm,$crstype) = @_;
my %sectioncount = &Apache::loncommon::get_sections($cdom,$cnum);
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
my %lt = &Apache::lonlocal::texthash (
- igna => 'Invalid group name',
- tgne => 'The group name entered ',
- grna => 'Group names and section names used in a course '.
- 'must be unique.',
- isno => 'is not a valid name.',
- gnmo => 'Group names may only contain letters, numbers '.
- 'or underscores.',
- cnnb => 'can not be used as it is the name of ',
- inth => ' in this course.',
- thgr => '- does not correspond to the name of an existing'.
- ' group ',
+ igna => "Invalid $gpterm name",
+ tgne => "The $gpterm name entered ",
+ grna => "$ucgpterm names and section names used in a ".
+ "$crstype must be unique.",
+ isno => "is not a valid name.",
+ gnmo => "$ucgpterm names may only contain letters, ".
+ "numbers or underscores.",
+ cnnb => "can not be used as it is the name of ",
+ inth => " in this $crstype",
+ thgr => "- does not correspond to the name of an ".
+ "existing $gpterm",
);
my $exitmsg = ''.$lt{'igna'}.'