'."\n".
+ &Apache::loncommon::end_data_table_row()."\n";
+ }
+ return $output;
+}
+
# =================================================================== Phase one
sub print_username_entry_form {
@@ -318,7 +337,7 @@ sub print_username_entry_form {
'dom' => "Domain",
'ecrp' => "Edit Custom Role Privileges",
'nr' => "Name of Role",
- 'cre' => "Custom Role Editor",
+ 'cre' => "Next",
);
$r->print($start_page."\n".$crumbs);
if ($env{'form.action'} eq 'custom') {
@@ -328,7 +347,7 @@ sub print_username_entry_form {
$lt{'ecrp'}
-$lt{'nr'}: $choice
+$choice $lt{'nr'}:
ENDCUSTOM
@@ -612,7 +631,7 @@ sub print_user_modification_page {
&Apache::lonuserutils::can_create_user($ccdomain,$context,
$usertype);
if (!$cancreate) {
- my $helplink = ' href="javascript:helpMenu('."'display'".')"';
+ my $helplink = 'javascript:helpMenu('."'display'".')';
my %usertypetext = (
official => 'institutional',
unofficial => 'non-institutional',
@@ -622,7 +641,12 @@ sub print_user_modification_page {
$response = ''.&mt('No match was found for the username ([_1]) in LON-CAPA domain: [_2]',$ccuname,$ccdomain).
' ';
}
- $response .= ''.&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.").' '.&mt('Contact the helpdesk for assistance.',$helplink).'
';
+ $response .= '
'
+ .&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.")
+ .' '
+ .&mt('Please contact the [_1]helpdesk[_2] for assistance.'
+ ,'','')
+ .'
'.
+ &Apache::loncommon::start_data_table().
+ &build_tools_display($ccuname,$ccdomain,'requestcourses').
+ &Apache::loncommon::end_data_table());
+ }
$r->print('');
my $user_auth_text = &user_authentication($ccuname,$ccdomain,$formname);
- my ($user_quota_text,$user_tools_text);
+ my ($user_quota_text,$user_tools_text,$user_reqcrs_text);
if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
(&Apache::lonnet::allowed('mut',$ccdomain))) {
# Current user has quota modification privileges
@@ -868,7 +906,7 @@ ENDNOPORTPRIV
if (&Apache::lonnet::allowed('mut',$env{'request.role.domain'})) {
my %lt=&Apache::lonlocal::texthash(
'utav' => "User Tools Availability",
- 'yodo' => "You do not have privileges to modify Portfolio, Blog or Home Page settings for this user.",
+ 'yodo' => "You do not have privileges to modify Portfolio, Blog or Personal Information Page settings for this user.",
'ifch' => "If a change is required, contact a domain coordinator for the domain",
);
$user_tools_text = <print('
';
+ }
+ return $output;
+}
+
sub selfcreate_canmodify {
my ($context,$dom,$userinfo,$inst_results,$rolesarray) = @_;
if (ref($inst_results) eq 'HASH') {
@@ -1680,8 +1801,8 @@ sub update_user_data {
}
if ( $env{'form.ccuname'} ne
&LONCAPA::clean_username($env{'form.ccuname'}) ) {
- $r->print($error.&mt('Invalid login name').'. '.
- &mt('Only letters, numbers, periods, dashes, @, and underscores are valid').'.'.
+ $r->print($error.&mt('Invalid login name.').' '.
+ &mt('Only letters, numbers, periods, dashes, @, and underscores are valid.').
$end.$rtnlink);
return;
}
@@ -1691,8 +1812,8 @@ sub update_user_data {
}
if ( $env{'form.ccdomain'} ne
&LONCAPA::clean_domain($env{'form.ccdomain'}) ) {
- $r->print($error.&mt ('Invalid domain name').'. '.
- &mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'.
+ $r->print($error.&mt('Invalid domain name.').' '.
+ &mt('Only letters, numbers, periods, dashes, and underscores are valid.').
$end.$rtnlink);
return;
}
@@ -1740,6 +1861,9 @@ sub update_user_data {
$env{'form.ccuname'}, $env{'form.ccdomain'}).'');
my (%alerts,%rulematch,%inst_results,%curr_rules);
my @usertools = ('aboutme','blog','portfolio');
+ my @requestcourses = ('official','unofficial');
+ my ($othertitle,$usertypes,$types) =
+ &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
if ($env{'form.makeuser'}) {
$r->print('
'.&mt('Creating new account.').'
');
# Check for the authentication mode and password
@@ -1813,7 +1937,20 @@ sub update_user_data {
foreach my $item (@usertools) {
if ($env{'form.custom'.$item} == 1) {
$newcustom{$item} = $env{'form.tools_'.$item};
- $changed{$item} = &tool_admin($item,$newcustom{$item},\%changeHash);
+ $changed{$item} = &tool_admin($item,$newcustom{$item},
+ \%changeHash,'tools');
+ }
+ }
+ foreach my $item (@requestcourses) {
+ $newcustom{$item} = $env{'form.requestcourses_'.$item};
+ $changed{$item} = &tool_admin($item,$newcustom{$item},
+ \%changeHash,'requestcourses');
+ }
+ if (exists($env{'form.inststatus'})) {
+ my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
+ if (@inststatuses > 0) {
+ $changeHash{'inststatus'} = join(',',@inststatuses);
+ $changed{'inststatus'} = $changeHash{'inststatus'};
}
}
if (keys(%changed)) {
@@ -1860,7 +1997,8 @@ sub update_user_data {
my %userenv = &Apache::lonnet::get
('environment',['firstname','middlename','lastname','generation',
'id','permanentemail','portfolioquota','inststatus','tools.aboutme',
- 'tools.blog','tools.portfolio'],
+ 'tools.blog','tools.portfolio','requestcourses.official',
+ 'requestcourses.unofficial'],
$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
@@ -1962,7 +2100,7 @@ sub update_user_data {
(!$forceid)) {
if ($env{'form.cid'} ne $uidhash{$env{'form.ccuname'}}) {
$env{'form.cid'} = $userenv{'id'};
- $no_forceid_alert = &mt('New Student/Employee ID does not match existing ID for this user.')
+ $no_forceid_alert = &mt('New student/employee ID does not match existing ID for this user.')
.' '
.&mt("Change is not permitted without checking the 'Force ID change' checkbox on the previous page.")
.' '."\n";
@@ -1983,19 +2121,62 @@ sub update_user_data {
}
}
}
- my ($quotachanged,$oldportfolioquota,$newportfolioquota,
- $inststatus,$oldisdefault,$newisdefault,$olddefquotatext,
- $newdefquotatext,%oldaccess,%oldaccesstext,%newaccess,%newaccesstext);
+ my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus,
+ $inststatus,$newinststatus,$oldisdefault,$newisdefault,$olddefquotatext,
+ $newdefquotatext,%oldaccess,%oldaccesstext,%newaccess,%newaccesstext,
+ $oldinststatuses,$newinststatuses);
my ($defquota,$settingstatus) =
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus);
- my ($showquota,$showtools);
+ my ($showquota,$showtools,$showrequestcourses,$showinststatus);
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
$showquota = 1;
}
if (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
$showtools = 1;
}
+ if (&Apache::lonnet::allowed('ccc',$env{'form.ccdomain'})) {
+ $showrequestcourses = 1;
+ }
+ if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
+ $showinststatus = 1;
+ }
my (%changeHash,%changed);
+ $oldinststatus = $userenv{'inststatus'};
+ if ($oldinststatus eq '') {
+ $oldinststatuses = $othertitle;
+ } else {
+ if (ref($usertypes) eq 'HASH') {
+ $oldinststatuses = join(', ',map{ $usertypes->{ &unescape($_) }; } (split(/:/,$userenv{'inststatus'})));
+ } else {
+ $oldinststatuses = join(', ',map{ &unescape($_); } (split(/:/,$userenv{'inststatus'})));
+ }
+ }
+ $changeHash{'inststatus'} = $userenv{'inststatus'};
+ my %canmodify_inststatus = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},['inststatus'],\@userroles);
+ if ($canmodify_inststatus{'inststatus'}) {
+ if (exists($env{'form.inststatus'})) {
+ my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
+ if (@inststatuses > 0) {
+ $newinststatus = join(':',map { &escape($_); } @inststatuses);
+ $changeHash{'inststatus'} = $newinststatus;
+ if ($newinststatus ne $oldinststatus) {
+ $changed{'inststatus'} = $newinststatus;
+ }
+ if (ref($usertypes) eq 'HASH') {
+ $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
+ } else {
+ $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
+ }
+ } else {
+ $newinststatus = '';
+ $changeHash{'inststatus'} = $newinststatus;
+ $newinststatuses = $othertitle;
+ if ($newinststatus ne $oldinststatus) {
+ $changed{'inststatus'} = $changeHash{'inststatus'};
+ }
+ }
+ }
+ }
$changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
if ($userenv{'portfolioquota'} ne '') {
$oldportfolioquota = $userenv{'portfolioquota'};
@@ -2012,7 +2193,7 @@ sub update_user_data {
} else {
$changed{'quota'} = "a_admin('',\%changeHash);
$newportfolioquota = $defquota;
- $newisdefault = 1;
+ $newisdefault = 1;
}
} else {
$oldisdefault = 1;
@@ -2036,74 +2217,10 @@ sub update_user_data {
if ($newisdefault) {
$newdefquotatext = &get_defaultquota_text($settingstatus);
}
-
- foreach my $tool (@usertools) {
- if ($userenv{'tools.'.$tool} ne '') {
- $oldaccess{$tool} = &mt('custom');
- if ($userenv{'tools_'.$tool}) {
- $oldaccesstext{$tool} = &mt("availability set to 'on'");
- } else {
- $oldaccesstext{$tool} = &mt("availability set to 'off'");
- }
- $changeHash{'tools.'.$tool} = $userenv{'tools.'.$tool};
- if ($env{'form.custom'.$tool} == 1) {
- if ($env{'form.tools_'.$tool} ne $userenv{'tools.'.$tool}) {
- $changed{$tool} = &tool_admin($tool,$env{'form.tools_'.$tool},
- \%changeHash);
- if ($changed{$tool}) {
- $newaccess{$tool} = &mt('custom');
- if ($env{'form.tools_'.$tool}) {
- $newaccesstext{$tool} = &mt("availability set to 'on'");
- } else {
- $newaccesstext{$tool} = &mt("availability set to 'off'");
- }
- } else {
- $newaccess{$tool} = $oldaccess{$tool};
- if ($userenv{'tools.'.$tool}) {
- $newaccesstext{$tool} = &mt("availability set to 'on'");
- } else {
- $newaccesstext{$tool} = &mt("availability set to 'off'");
- }
- }
- } else {
- $newaccess{$tool} = $oldaccess{$tool};
- $newaccesstext{$tool} = $oldaccesstext{$tool};
- }
- } else {
- $changed{$tool} = &tool_admin($tool,'',\%changeHash);
- print STDERR "for $tool - changed is $changed{$tool}\n";
- if ($changed{$tool}) {
- $newaccess{$tool} = &mt('default');
- } else {
- $newaccess{$tool} = $oldaccess{$tool};
- if ($userenv{'tools.'.$tool}) {
- $newaccesstext{$tool} = &mt("availability set to 'on'");
- } else {
- $newaccesstext{$tool} = &mt("availability set to 'off'");
- }
- }
- }
- } else {
- $oldaccess{$tool} = &mt('default');
- if ($env{'form.custom'.$tool} == 1) {
- $changed{$tool} = &tool_admin($tool,$env{'form.tools_'.$tool},
- \%changeHash);
- if ($changed{$tool}) {
- $newaccess{$tool} = &mt('custom');
- if ($env{'form.tools_'.$tool}) {
- $newaccesstext{$tool} = &mt("availability set to 'on'");
- } else {
- $newaccesstext{$tool} = &mt("availability set to 'off'");
- }
- } else {
- $newaccess{$tool} = $oldaccess{$tool};
- }
- } else {
- $newaccess{$tool} = $oldaccess{$tool};
- }
- }
- }
-
+ &tool_changes('tools',\@usertools,\%oldaccess,\%oldaccesstext,\%userenv,
+ \%changeHash,\%changed,\%newaccess,\%newaccesstext);
+ &tool_changes('requestcourses',\@requestcourses,\%oldaccess,\%oldaccesstext,
+ \%userenv, \%changeHash,\%changed,\%newaccess,\%newaccesstext);
if ($env{'form.cfirstname'} ne $userenv{'firstname'} ||
$env{'form.cmiddlename'} ne $userenv{'middlename'} ||
$env{'form.clastname'} ne $userenv{'lastname'} ||
@@ -2125,18 +2242,36 @@ sub update_user_data {
&Apache::lonnet::put('environment',\%changeHash,
$env{'form.ccdomain'},$env{'form.ccuname'});
if ($chgresult eq 'ok') {
- my %newenvhash;
- my $hashid="$env{'form.ccuname'}:$env{'form.ccdomain'}";
- foreach my $key (keys(%changed)) {
- if ($key ne 'quota') {
- &Apache::lonnet::devalidate_cache_new('usertools.'.$key,$hashid);
- $newenvhash{'environment.tools.'.$key} =
- $changeHash{'tools.'.$key};
- }
- }
if (($env{'user.name'} eq $env{'form.ccuname'}) &&
($env{'user.domain'} eq $env{'form.ccdomain'})) {
- &Apache::lonnet::appenv(\%newenvhash);
+ my %newenvhash;
+ foreach my $key (keys(%changed)) {
+ if (($key eq 'official') || ($key eq 'unofficial')) {
+ $newenvhash{'environment.requestcourses.'.$key} =
+ $changeHash{'requestcourses.'.$key};
+ if ($changeHash{'requestcourses.'.$key} ne '') {
+ $newenvhash{'environment.canrequest.'.$key} =
+ $changeHash{'requestcourses.'.$key};
+ } else {
+ $newenvhash{'environment.canrequest.'.$key} =
+ &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
+ $key,'reload','requestcourses');
+ }
+ } elsif ($key ne 'quota') {
+ $newenvhash{'environment.tools.'.$key} =
+ $changeHash{'tools.'.$key};
+ if ($changeHash{'tools.'.$key} ne '') {
+ $newenvhash{'environment.availabletools.'.$key} =
+ $changeHash{'tools.'.$key};
+ } else {
+ $newenvhash{'environment.availabletools.'.$key} =
+ &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, $key,'reload','tools');
+ }
+ }
+ }
+ if (keys(%newenvhash)) {
+ &Apache::lonnet::appenv(\%newenvhash);
+ }
}
}
}
@@ -2160,19 +2295,22 @@ sub update_user_data {
((keys(%changed) > 0) && $chgresult eq 'ok')) {
# Tell the user we changed the name
my %lt=&Apache::lonlocal::texthash(
- 'uic' => "User Information Changed",
- 'frst' => "First",
- 'mddl' => "Middle",
- 'lst' => "Last",
- 'gen' => "Generation",
- 'id' => "Student/Employee ID",
- 'mail' => "Permanent E-mail",
- 'disk' => "Disk space allocated to portfolio files",
- 'blog' => "Blog Availability",
- 'aboutme' => "Home Page Availability",
- 'portfolio' => "Portfolio Availability",
- 'prvs' => "Previous",
- 'chto' => "Changed To"
+ 'uic' => 'User Information Changed',
+ 'frst' => 'First Name',
+ 'mddl' => 'Middle Name',
+ 'lst' => 'Last Name',
+ 'gen' => 'Generation',
+ 'id' => 'Student/Employee ID',
+ 'mail' => 'Permanent e-mail address',
+ 'disk' => 'Disk space allocated to portfolio files',
+ 'blog' => 'Blog Availability',
+ 'aboutme' => 'Personal Information Page Availability',
+ 'portfolio' => 'Portfolio Availability',
+ 'official' => 'Can Request Official Courses',
+ 'unofficial' => 'Can Request Unofficial Courses',
+ 'inststatus' => "Affiliation",
+ 'prvs' => 'Previous Value:',
+ 'chto' => 'Changed To:'
);
$r->print('
'.$lt{'uic'}.'
'.
&Apache::loncommon::start_data_table().
@@ -2186,6 +2324,16 @@ sub update_user_data {
$lt{'id'}
$lt{'mail'}
END
+ if ($showinststatus) {
+ $r->print("
+
$lt{'inststatus'}
\n");
+ }
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+
$lt{$item}
\n");
+ }
+ }
if ($showquota) {
$r->print("
$lt{'disk'}
\n");
@@ -2207,6 +2355,16 @@ END
$userenv{'id'}
$userenv{'permanentemail'}
END
+ if ($showinststatus) {
+ $r->print("
+
$oldinststatuses
\n");
+ }
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+
$oldaccess{$item} $oldaccesstext{$item}
\n");
+ }
+ }
if ($showquota) {
$r->print("
$oldportfolioquota Mb $olddefquotatext
\n");
@@ -2228,6 +2386,16 @@ END
$env{'form.cid'}
$env{'form.cpermanentemail'}
END
+ if ($showinststatus) {
+ $r->print("
+
$newinststatuses
\n");
+ }
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+
$newaccess{$item} $newaccesstext{$item}
\n");
+ }
+ }
if ($showquota) {
$r->print("
$newportfolioquota Mb $newdefquotatext
\n");
@@ -2266,15 +2434,19 @@ END
$env{'form.ccdomain'}.' ');
}
} else { # End of if ($env ... ) logic
- # They did not want to change the users name, quota or tool availability,
+ # They did not want to change the users name, quota, tool availability,
+ # or ability to request creation of courses,
# but we can still tell them what the name and quota and availabilities are
my %lt=&Apache::lonlocal::texthash(
- 'id' => "Student/Employee ID",
- 'mail' => "Permanent e-mail",
- 'disk' => "Disk space allocated to user's portfolio files",
- 'blog' => "Blog Availability",
- 'aboutme' => "Home Page Availability",
- 'portfolio' => "Portfolio Availability",
+ 'id' => "Student/Employee ID",
+ 'mail' => "Permanent e-mail address",
+ 'disk' => "Disk space allocated to user's portfolio files",
+ 'blog' => "Blog Availability",
+ 'aboutme' => "Personal Information Page Availability",
+ 'portfolio' => "Portfolio Availability",
+ 'official' => "Can Request Official Courses",
+ 'unofficial' => "Can Request Unofficial Course",
+ 'inststatus' => "Affiliation",
);
$r->print(<<"END");
$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
@@ -2283,6 +2455,15 @@ END
$r->print(' ['.$lt{'mail'}.': '.
$userenv{'permanentemail'}.']');
}
+ if ($showinststatus) {
+ $r->print(' ['.$lt{'inststatus'}.': '.$oldinststatuses.']');
+ }
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print(' ['.$lt{$item}.': '.$newaccess{$item}.' '.
+ $newaccesstext{$item}.']'."\n");
+ }
+ }
if ($showtools) {
foreach my $item (@usertools) {
$r->print(' ['.$lt{$item}.': '.$newaccess{$item}.' '.
@@ -2318,8 +2499,11 @@ END
} else {
$r->print(&mt("You do not have the authority to change these fields given the user's current set of active/future [_1] roles:",$contextname));
}
- $r->print(''.$rolestr.' '.
- &mt('Contact your helpdesk for more information.',"javascript:helpMenu('display')").' ');
+ my $helplink = 'javascript:helpMenu('."'display'".')';
+ $r->print(''.$rolestr.' '
+ .&mt('Please contact your [_1]helpdesk[_2] for more information.'
+ ,'','')
+ .' ');
}
$r->print(''
.$no_forceid_alert
@@ -2361,6 +2545,83 @@ END
$r->print(&Apache::loncommon::end_page());
}
+sub tool_changes {
+ my ($context,$usertools,$oldaccess,$oldaccesstext,$userenv,$changeHash,
+ $changed,$newaccess,$newaccesstext) = @_;
+ if (!((ref($usertools) eq 'ARRAY') && (ref($oldaccess) eq 'HASH') &&
+ (ref($oldaccesstext) eq 'HASH') && (ref($userenv) eq 'HASH') &&
+ (ref($changeHash) eq 'HASH') && (ref($changed) eq 'HASH') &&
+ (ref($newaccess) eq 'HASH') && (ref($newaccesstext) eq 'HASH'))) {
+ return;
+ }
+ foreach my $tool (@{$usertools}) {
+ if ($userenv->{$context.'.'.$tool} ne '') {
+ $oldaccess->{$tool} = &mt('custom');
+ if ($userenv->{$context.'.'.$tool}) {
+ $oldaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $oldaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
+ $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};
+ if ($env{'form.custom'.$tool} == 1) {
+ if ($env{'form.'.$context.'_'.$tool} ne $userenv->{$context.'.'.$tool}) {
+ $changed->{$tool} = &tool_admin($tool,$env{'form.'.$context.'_'.$tool},
+ $changeHash,$context);
+ if ($changed->{$tool}) {
+ $newaccess->{$tool} = &mt('custom');
+ if ($env{'form.'.$context.'_'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
+ } else {
+ $newaccess->{$tool} = $oldaccess->{$tool};
+ if ($userenv->{$context.'.'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
+ }
+ } else {
+ $newaccess->{$tool} = $oldaccess->{$tool};
+ $newaccesstext->{$tool} = $oldaccesstext->{$tool};
+ }
+ } else {
+ $changed->{$tool} = &tool_admin($tool,'',$changeHash,$context);
+ if ($changed->{$tool}) {
+ $newaccess->{$tool} = &mt('default');
+ } else {
+ $newaccess->{$tool} = $oldaccess->{$tool};
+ if ($userenv->{$context.'.'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
+ }
+ }
+ } else {
+ $oldaccess->{$tool} = &mt('default');
+ if ($env{'form.custom'.$tool} == 1) {
+ $changed->{$tool} = &tool_admin($tool,$env{'form.'.$context.'_'.$tool},
+ $changeHash,$context);
+ if ($changed->{$tool}) {
+ $newaccess->{$tool} = &mt('custom');
+ if ($env{'form.'.$context.'_'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
+ } else {
+ $newaccess->{$tool} = $oldaccess->{$tool};
+ }
+ } else {
+ $newaccess->{$tool} = $oldaccess->{$tool};
+ }
+ }
+ }
+ return;
+}
+
sub update_roles {
my ($r,$context) = @_;
my $now=time;
@@ -2428,8 +2689,8 @@ sub update_roles {
if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
# Delete custom role
- $r->print(&mt('Deleting custom role [_1] by [_2]:[_3] in [_4]',
- $rolename,$rnam,$rdom,$url).': '.
+ $r->print(&mt('Deleting custom role [_1] by [_2] in [_3]',
+ $rolename,$rnam.':'.$rdom,$url).': '.
&Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
$env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
0,1,$context).' ');
@@ -2480,8 +2741,8 @@ sub update_roles {
my $result = &Apache::lonnet::assigncustomrole(
$env{'form.ccdomain'}, $env{'form.ccuname'},
$url,$rdom,$rnam,$rolename,0,$now,undef,$context);
- $r->print(&mt('Re-enabling custom role [_1] by [_2]:[_3] in [_4] : [_5]',
- $rolename,$rnam,$rdom,$url,''.$result.'').' ');
+ $r->print(&mt('Re-enabling custom role [_1] by [_2] in [_3]: [_4]',
+ $rolename,$rnam.':'.$rdom,$url,''.$result.'').' ');
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -2603,12 +2864,18 @@ sub update_roles {
$r->print('
'.&mt('[_1] may not be used as the name for a section, as it is a reserved word.',$key));
+ $r->print(&mt('[_1] may not be used as the name for a section, as it is a reserved word.',''.$key.''));
} else {
- $r->print('
'.&mt('[_1] may not be used as the name for a section, as it is the name of a course group.',$key));
+ $r->print(&mt('[_1] may not be used as the name for a section, as it is the name of a course group.',''.$key.''));
}
- $r->print(' '.&mt('Please go back and choose a different section name.').'
');
+ $r->print('
'
+ .&mt('Please [_1]go back[_2] and choose a different section name.'
+ ,'':' ').
+ ($courselevel{$priv}?'':' ').
'
'.&mt('The following enrollment requests were deleted because the user is already enrolled in the course:').'
');
+ foreach my $user (@existing) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ if (@missingreq) {
+ $r->print('
'.&mt('The following enrollment requests were ignored because the request is no longer in the enrollment queue:').'
');
+ foreach my $user (@missingreq) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ if (@invalidusers) {
+ $r->print('
'.&mt('The following enrollment requests were deleted because the requestor does not have a LON-CAPA account:').'
');
+ foreach my $user (@invalidusers) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ if (@limitexceeded) {
+ $r->print('
'.&mt('The following enrollment requests were skipped because the enrollment limit has been reached for the course:').'
');
+ foreach my $user (@limitexceeded) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ if (@enrollerrors) {
+ $r->print('
'.&mt('The following enrollment requests could not be processed because an error occurred:').'
');
+ foreach my $user (@enrollerrors) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ if (@warn_approves) {
+ $r->print('
'.&mt("For the following users, an error occurred when updating the user's own self-enroll requests record:").'
');
+ foreach my $user (@warn_approves) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ if (@warn_rejects) {
+ $r->print('
'.&mt("For the following users, an error occurred when updating the user's own self-enroll requests record:").'
');
+ foreach my $user (@warn_rejects) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ return;
+}
+
+sub get_student_counts {
+ my ($cdom,$cnum) = @_;
+ my (%idx,%stucounts);
+ my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum);
+ $idx{'type'} = &Apache::loncoursedata::CL_TYPE();
+ $idx{'status'} = &Apache::loncoursedata::CL_STATUS();
+ while (my ($student,$data) = each(%$classlist)) {
+ if (($data->[$idx{'status'}] eq 'Active') ||
+ ($data->[$idx{'status'}] eq 'Future')) {
+ if ($data->[$idx{'type'}] eq 'selfenroll') {
+ $stucounts{'selfenroll'} ++;
+ }
+ $stucounts{'allstudents'} ++;
+ }
+ }
+ return (\%stucounts,\%idx,$classlist);
+}
+
sub visible_in_cat {
my ($cdom,$cnum) = @_;
my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
@@ -3839,7 +4537,7 @@ sub visible_in_cat {
miss => 'Your course does not currently appear in the Course Catalog for this domain.',
yous => 'You should remedy this if you plan to allow self-enrollment, otherwise students will have difficulty finding your course.',
coca => 'Courses can be absent from the Catalog, because they do not have an institutional code, have no assigned category, or have been specifically excluded.',
- make => 'Make any changes to self-enrollment settings below, click "Save changes", then take action to include the course in the Catalog:',
+ make => 'Make any changes to self-enrollment settings below, click "Save", then take action to include the course in the Catalog:',
take => 'Take the following action to ensure the course appears in the Catalog:',
dc_unhide => 'Ask a domain coordinator to change the "Exclude from course catalog" setting.',
dc_addinst => 'Ask a domain coordinator to enable display the catalog of "Official courses (with institutional codes)".',
@@ -4265,7 +4963,7 @@ sub role_display_filter {
&mt('[_1]Note:[_2] Only changes made from servers running LON-CAPA 2.6.99.0 or later are displayed.');
if ($version) {
$output .= ' '.&mt('This server is version [_3].','','',$version); }
- $output .= ' ';
+ $output .= ' ';
return $output;
}
@@ -4678,7 +5376,7 @@ sub build_search_response {
.&mt("You are not authorized to create new users in your current role's domain - [_1]."
,''.$env{'request.role.domain'}.'')
.' '
- .&mt('Contact the [_1]helpdesk[_2] if you need to create a new user.'
+ .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.'
,' '
,'')
.'
';
@@ -5024,6 +5722,74 @@ sub update_selfenroll_config {
$changes{'internal.selfenroll_types'} = $selfenroll_types;
}
}
+ } elsif ($item eq 'limit') {
+ my $newlimit = $env{'form.selfenroll_limit'};
+ my $newcap = $env{'form.selfenroll_cap'};
+ $newcap =~s/\s+//g;
+ my $currlimit = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_limit'};
+ $currlimit = 'none' if ($currlimit eq '');
+ my $currcap = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_cap'};
+ if ($newlimit ne $currlimit) {
+ if ($newlimit ne 'none') {
+ if ($newcap =~ /^\d+$/) {
+ if ($newcap ne $currcap) {
+ $changes{'internal.selfenroll_cap'} = $newcap;
+ }
+ $changes{'internal.selfenroll_limit'} = $newlimit;
+ } else {
+ $warning{$item} = &mt('Maximum enrollment setting unchanged.').' '.&mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.');
+ }
+ } elsif ($currcap ne '') {
+ $changes{'internal.selfenroll_cap'} = '';
+ $changes{'internal.selfenroll_limit'} = $newlimit;
+ }
+ } elsif ($currlimit ne 'none') {
+ if ($newcap =~ /^\d+$/) {
+ if ($newcap ne $currcap) {
+ $changes{'internal.selfenroll_cap'} = $newcap;
+ }
+ } else {
+ $warning{$item} = &mt('Maximum enrollment setting unchanged.').' '.&mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.');
+ }
+ }
+ } elsif ($item eq 'approval') {
+ my (@currnotified,@newnotified);
+ my $currapproval = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_approval'};
+ my $currnotifylist = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_notifylist'};
+ if ($currnotifylist ne '') {
+ @currnotified = split(/,/,$currnotifylist);
+ @currnotified = sort(@currnotified);
+ }
+ my $newapproval = $env{'form.selfenroll_approval'};
+ @newnotified = &Apache::loncommon::get_env_multiple('form.selfenroll_notify');
+ @newnotified = sort(@newnotified);
+ if ($newapproval ne $currapproval) {
+ $changes{'internal.selfenroll_approval'} = $newapproval;
+ if (!$newapproval) {
+ if ($currnotifylist ne '') {
+ $changes{'internal.selfenroll_notifylist'} = '';
+ }
+ } else {
+ my @differences =
+ &Apache::loncommon::compare_arrays(\@currnotified,\@newnotified);
+ if (@differences > 0) {
+ if (@newnotified > 0) {
+ $changes{'internal.selfenroll_notifylist'} = join(',',@newnotified);
+ } else {
+ $changes{'internal.selfenroll_notifylist'} = join(',',@newnotified);
+ }
+ }
+ }
+ } else {
+ my @differences = &Apache::loncommon::compare_arrays(\@currnotified,\@newnotified);
+ if (@differences > 0) {
+ if (@newnotified > 0) {
+ $changes{'internal.selfenroll_notifylist'} = join(',',@newnotified);
+ } else {
+ $changes{'internal.selfenroll_notifylist'} = '';
+ }
+ }
+ }
} else {
my $curr_val =
$env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_'.$item};
@@ -5035,7 +5801,7 @@ sub update_selfenroll_config {
$warning{$item} = &mt('Section for self-enrolled users unchanged as the proposed section is a group').' '.&mt('Group names and section names must be distinct');
} elsif ($newval eq 'all') {
$newval = $curr_val;
- $warning{$item} = &mt("Section for self-enrolled users unchanged, as 'all' is a reserved section name.");
+ $warning{$item} = &mt('Section for self-enrolled users unchanged, as "all" is a reserved section name.');
}
if ($newval eq '') {
$newval = 'none';
@@ -5096,6 +5862,62 @@ sub update_selfenroll_config {
$title,$type,$newdate).'');
}
}
+ } elsif ($item eq 'limit') {
+ if ((exists($changes{'internal.selfenroll_limit'})) ||
+ (exists($changes{'internal.selfenroll_cap'}))) {
+ my ($newval,$newcap);
+ if ($changes{'internal.selfenroll_cap'} ne '') {
+ $newcap = $changes{'internal.selfenroll_cap'}
+ } else {
+ $newcap = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_cap'};
+ }
+ if ($changes{'internal.selfenroll_limit'} eq 'none') {
+ $newval = &mt('No limit');
+ } elsif ($changes{'internal.selfenroll_limit'} eq
+ 'allstudents') {
+ $newval = &mt('New self-enrollment no longer allowed when total (all students) reaches [_1].',$newcap);
+ } elsif ($changes{'internal.selfenroll_limit'} eq 'selfenrolled') {
+ $newval = &mt('New self-enrollment no longer allowed when total number of self-enrolled students reaches [_1].',$newcap);
+ } else {
+ my $currlimit = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_limit'};
+ if ($currlimit eq 'allstudents') {
+ $newval = &mt('New self-enrollment no longer allowed when total (all students) reaches [_1].',$newcap);
+ } elsif ($changes{'internal.selfenroll_limit'} eq 'selfenrolled') {
+ $newval = &mt('New self-enrollment no longer allowed when total umber of self-enrolled students reaches [_1].',$newcap);
+ }
+ }
+ $r->print('
'.&mt('"[_1]" set to "[_2]".',$title,$newval));
+ if ($newnotify) {
+ $r->print(' '.&mt('The following will be notified when an enrollment request needs approval, or has been approved: [_1].',$newnotify));
+ } else {
+ $r->print(' '.&mt('No notifications sent when an enrollment request needs approval, or has been approved.'));
+ }
+ $r->print('
'."\n");
+ }
} else {
if (exists($changes{'internal.selfenroll_'.$item})) {
my $newval = $changes{'internal.selfenroll_'.$item};
@@ -5150,13 +5972,16 @@ sub update_selfenroll_config {
}
sub get_selfenroll_titles {
- my @row = ('types','registered','enroll_dates','access_dates','section');
+ my @row = ('types','registered','enroll_dates','access_dates','section',
+ 'approval','limit');
my %lt = &Apache::lonlocal::texthash (
types => 'Users allowed to self-enroll in this course',
registered => 'Restrict self-enrollment to students officially registered for the course',
enroll_dates => 'Dates self-enrollment available',
access_dates => 'Course access dates assigned to self-enrolling users',
section => 'Section assigned to self-enrolling users',
+ approval => 'Self-enrollment requests need approval?',
+ limit => 'Enrollment limit',
);
return (\@row,\%lt);
}