'."\n".
+ &Apache::loncommon::end_data_table_row()."\n";
+ }
+ return $output;
+}
+
# =================================================================== Phase one
sub print_username_entry_form {
@@ -769,7 +788,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 +866,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
@@ -1747,6 +1772,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 +1846,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 +1901,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 +2030,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 +2081,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 +2110,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 +2149,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 +2177,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 +2204,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 +2231,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 +2275,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 +2295,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 +2379,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;
@@ -2733,13 +2820,21 @@ sub quota_admin {
}
sub tool_admin {
- my ($tool,$settool,$changeHash) = @_;
- my $toolchanged;
- if (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
+ my ($tool,$settool,$changeHash,$context) = @_;
+ my $canchange = 0;
+ if ($context eq 'requestcourse') {
+ if (&Apache::lonnet::allowed('ccc',$env{'form.ccdomain'})) {
+ $canchange = 1;
+ }
+ } elsif (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
# Current user has quota modification privileges
+ $canchange = 1;
+ }
+ my $toolchanged;
+ if ($canchange) {
if (ref($changeHash) eq 'HASH') {
$toolchanged = 1;
- $changeHash->{'tools.'.$tool} = $settool;
+ $changeHash->{$context.'.'.$tool} = $settool;
}
}
return $toolchanged;