'."\n".
+ &Apache::loncommon::end_data_table_row()."\n";
+ }
+ return $output;
+}
+
# =================================================================== Phase one
sub print_username_entry_form {
@@ -769,7 +789,7 @@ $lt{'hs'}: $home_server_pick
my $authtype = $rules->{$matchedrule}{'authtype'};
if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) {
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
- } else {
+ } else {
my $authparm = $rules->{$matchedrule}{'authparm'};
$authmsg = $rules->{$matchedrule}{'authmsg'};
if ($authtype =~ /^krb(4|5)$/) {
@@ -847,9 +867,15 @@ ENDCHANGEUSER
if ($showforceid) {
$r->print(&Apache::lonuserutils::forceid_change($context));
}
+ if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
+ $r->print('
'.&mt('User Can Request Creation of Courses?').'
'.
+ &Apache::loncommon::start_data_table().
+ &build_tools_display($ccuname,$ccdomain,'requestcourse').
+ &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
@@ -1687,8 +1713,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;
}
@@ -1698,8 +1724,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;
}
@@ -1747,6 +1773,7 @@ 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');
if ($env{'form.makeuser'}) {
$r->print('
'.&mt('Creating new account.').'
');
# Check for the authentication mode and password
@@ -1820,7 +1847,15 @@ 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');
+ }
+ }
+ if (&Apache::lonnet::allowed('ccc',$env{'request.domain'})) {
+ foreach my $item (@requestcourses) {
+ $newcustom{$item} = $env{'form.requestcourse_'.$item};
+ $changed{$item} = &tool_admin($item,$newcustom{$item},
+ \%changeHash,'requestcourse');
}
}
if (keys(%changed)) {
@@ -1867,7 +1902,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','requestcourse.official',
+ 'requestcourse.unofficial'],
$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
@@ -1995,13 +2031,16 @@ sub update_user_data {
$newdefquotatext,%oldaccess,%oldaccesstext,%newaccess,%newaccesstext);
my ($defquota,$settingstatus) =
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus);
- my ($showquota,$showtools);
+ my ($showquota,$showtools,$showrequestcourses);
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;
+ }
my (%changeHash,%changed);
$changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
if ($userenv{'portfolioquota'} ne '') {
@@ -2043,73 +2082,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);
- 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('requestcourse',\@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'} ||
@@ -2135,7 +2111,13 @@ sub update_user_data {
($env{'user.domain'} eq $env{'form.ccdomain'})) {
my %newenvhash;
foreach my $key (keys(%changed)) {
- if ($key ne 'quota') {
+ if (($key eq 'official') || ($key eq 'unofficial')) {
+ $newenvhash{'environment.canrequest.'.$key} =
+ $changeHash{'requestcourse.'.$key};
+ $newenvhash{'environment.canrequest.'.$key} =
+ $changeHash{'requestcourse.'.$key};
+
+ } elsif ($key ne 'quota') {
$newenvhash{'environment.tools.'.$key} =
$changeHash{'tools.'.$key};
$newenvhash{'environment.availabletools.'.$key} =
@@ -2168,19 +2150,21 @@ 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",
+ '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",
+ 'official' => "Can Request Official Courses",
+ 'unofficial' => "Can Request Unofficial Courses",
+ 'prvs' => "Previous",
+ 'chto' => "Changed To"
);
$r->print('
'.$lt{'uic'}.'
'.
&Apache::loncommon::start_data_table().
@@ -2194,6 +2178,12 @@ sub update_user_data {
$lt{'id'}
$lt{'mail'}
END
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+
$lt{$item}
\n");
+ }
+ }
if ($showquota) {
$r->print("
$lt{'disk'}
\n");
@@ -2215,6 +2205,12 @@ END
$userenv{'id'}
$userenv{'permanentemail'}
END
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+
$oldaccess{$item} $oldaccesstext{$item}
\n");
+ }
+ }
if ($showquota) {
$r->print("
$oldportfolioquota Mb $olddefquotatext
\n");
@@ -2236,6 +2232,12 @@ END
$env{'form.cid'}
$env{'form.cpermanentemail'}
END
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+
$newaccess{$item} $newaccesstext{$item}
\n");
+ }
+ }
if ($showquota) {
$r->print("
$newportfolioquota Mb $newdefquotatext
\n");
@@ -2274,15 +2276,18 @@ 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",
+ 'disk' => "Disk space allocated to user's portfolio files",
+ 'blog' => "Blog Availability",
+ 'aboutme' => "Home Page Availability",
+ 'portfolio' => "Portfolio Availability",
+ 'official' => "Can Request Official Courses",
+ 'unofficial' => "Can Request Unofficial Course",
);
$r->print(<<"END");
$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
@@ -2291,6 +2296,12 @@ END
$r->print(' ['.$lt{'mail'}.': '.
$userenv{'permanentemail'}.']');
}
+ 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}.' '.
@@ -2369,6 +2380,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->{'tools.'.$tool};
+ if ($env{'form.custom'.$tool} == 1) {
+ if ($env{'form.'.$context.'_'.$tool} ne $userenv->{'tools.'.$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;
@@ -2611,12 +2699,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.').'
'.&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};
@@ -5157,14 +5763,33 @@ sub update_selfenroll_config {
return;
}
+sub compare_arrays {
+ my ($arrayref1,$arrayref2) = @_;
+ my (@difference,%count);
+ @difference = ();
+ %count = ();
+ if ((ref($arrayref1) eq 'ARRAY') && (ref($arrayref2) eq 'ARRAY')) {
+ foreach my $element (@{$arrayref1}, @{$arrayref2}) { $count{$element}++; }
+ foreach my $element (keys(%count)) {
+ if ($count{$element} == 1) {
+ push(@difference,$element);
+ }
+ }
+ }
+ return @difference;
+}
+
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);
}