--- loncom/interface/loncreateuser.pm 2012/04/25 21:22:01 1.360
+++ loncom/interface/loncreateuser.pm 2013/01/01 19:53:26 1.372
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.360 2012/04/25 21:22:01 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.372 2013/01/01 19:53:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -111,11 +111,11 @@ sub initialize_authen_forms {
sub auth_abbrev {
my %abv_auth = (
- krb5 => 'krb',
- krb4 => 'krb',
- internal => 'int',
- localuth => 'loc',
- unix => 'fsys',
+ krb5 => 'krb',
+ krb4 => 'krb',
+ internal => 'int',
+ localauth => 'loc',
+ unix => 'fsys',
);
return %abv_auth;
}
@@ -223,6 +223,7 @@ sub build_tools_display {
my %lt = &Apache::lonlocal::texthash (
'blog' => "Personal User Blog",
'aboutme' => "Personal Information Page",
+ 'webdav' => "WebDAV access to authoring spaces (if SSL and author/co-author)",
'portfolio' => "Personal User Portfolio",
'avai' => "Available",
'cusa' => "availability",
@@ -232,6 +233,7 @@ sub build_tools_display {
'official' => 'Can request creation of official courses',
'unofficial' => 'Can request creation of unofficial courses',
'community' => 'Can request creation of communities',
+ 'requestauthor' => 'Can request author space',
);
if ($context eq 'requestcourses') {
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
@@ -246,10 +248,21 @@ sub build_tools_display {
%domconfig =
&Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain);
$isadv = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
+ } elsif ($context eq 'requestauthor') {
+ %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
+ 'requestauthor');
+ @usertools = ('requestauthor');
+ @options =('norequest','approval','automatic');
+ %reqtitles = &requestauthor_titles();
+ %reqdisplay = &requestauthor_display();
+ $colspan = ' colspan="2"';
+ %domconfig =
+ &Apache::lonnet::get_dom('configuration',['requestauthor'],$ccdomain);
} else {
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
- 'tools.aboutme','tools.portfolio','tools.blog');
- @usertools = ('aboutme','blog','portfolio');
+ 'tools.aboutme','tools.portfolio','tools.blog',
+ 'tools.webdav');
+ @usertools = ('aboutme','blog','webdav','portfolio');
}
foreach my $item (@usertools) {
my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off,
@@ -259,7 +272,12 @@ sub build_tools_display {
$curr_access =
&Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef,
$context);
- if ($userenv{$context.'.'.$item} ne '') {
+ if ($context eq 'requestauthor') {
+ if ($userenv{$context} ne '') {
+ $cust_on = ' checked="checked" ';
+ $cust_off = '';
+ }
+ } elsif ($userenv{$context.'.'.$item} ne '') {
$cust_on = ' checked="checked" ';
$cust_off = '';
}
@@ -269,6 +287,12 @@ sub build_tools_display {
} else {
$custom_access = &mt('Currently from custom setting.');
}
+ } elsif ($context eq 'requestauthor') {
+ if ($userenv{$context} eq '') {
+ $custom_access = &mt('Currently from default setting.');
+ } else {
+ $custom_access = &mt('Currently from custom setting.');
+ }
} else {
if ($userenv{$context.'.'.$item} eq '') {
$custom_access =
@@ -290,15 +314,27 @@ sub build_tools_display {
'
'.$lt{$item}.' '."\n".
' '."\n".
&Apache::loncommon::start_data_table_row()."\n";
- if ($context eq 'requestcourses') {
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
my ($curroption,$currlimit);
- if ($userenv{$context.'.'.$item} ne '') {
- $curroption = $userenv{$context.'.'.$item};
+ my $envkey = $context.'.'.$item;
+ if ($context eq 'requestauthor') {
+ $envkey = $context;
+ }
+ if ($userenv{$envkey} ne '') {
+ $curroption = $userenv{$envkey};
} else {
my (@inststatuses);
- $curroption =
- &Apache::loncoursequeueadmin::get_processtype($ccuname,$ccdomain,$isadv,$ccdomain,
- $item,\@inststatuses,\%domconfig);
+ if ($context eq 'requestcourses') {
+ $curroption =
+ &Apache::loncoursequeueadmin::get_processtype('course',$ccuname,$ccdomain,
+ $isadv,$ccdomain,$item,
+ \@inststatuses,\%domconfig);
+ } else {
+ $curroption =
+ &Apache::loncoursequeueadmin::get_processtype('requestauthor',$ccuname,$ccdomain,
+ $isadv,$ccdomain,undef,
+ \@inststatuses,\%domconfig);
+ }
}
if (!$curroption) {
$curroption = 'norequest';
@@ -336,28 +372,36 @@ sub build_tools_display {
$checked = ' checked="checked"';
}
}
+ my $name = 'crsreq_'.$item;
+ if ($context eq 'requestauthor') {
+ $name = $item;
+ }
$custdisp .= ''.
- ' '.
+ ' '.
$reqtitles{$option}.' ';
if ($option eq 'autolimit') {
- $custdisp .= ' '.
$reqtitles{'unlimited'};
- } else {
- $custdisp .= '';
- }
- $custdisp .= ' ';
+ } else {
+ $custdisp .= '';
+ }
+ $custdisp .= '';
}
$custdisp .= '';
$custradio = ''.&mt('Custom setting').' '.$custdisp;
} else {
$currdisp = ($curr_access?&mt('Yes'):&mt('No'));
+ my $name = $context.'_'.$item;
+ if ($context eq 'requestauthor') {
+ $name = $context;
+ }
$custdisp = ''.
- ' '.&mt('On').' '.
- ' '.&mt('On').' '.
+ ' '.&mt('Off').' ';
$custradio = (' 'x2).'--'.$lt{'cusa'}.': '.$custdisp.
'';
@@ -453,6 +497,17 @@ sub coursereq_externaluser {
return $output;
}
+sub domainrole_req {
+ my ($ccuname,$ccdomain) = @_;
+ return ''.
+ &mt('User Can Request Assignment of Domain Roles?').
+ ' '."\n".
+ &Apache::loncommon::start_data_table().
+ &build_tools_display($ccuname,$ccdomain,
+ 'requestauthor').
+ &Apache::loncommon::end_data_table();
+}
+
sub courserequest_titles {
my %titles = &Apache::lonlocal::texthash (
official => 'Official',
@@ -476,6 +531,80 @@ sub courserequest_display {
return %titles;
}
+sub requestauthor_titles {
+ my %titles = &Apache::lonlocal::texthash (
+ norequest => 'Not allowed',
+ approval => 'Approval by Dom. Coord.',
+ automatic => 'Automatic approval',
+ );
+ return %titles;
+
+}
+
+sub requestauthor_display {
+ my %titles = &Apache::lonlocal::texthash (
+ approval => 'Yes, need approval',
+ automatic => 'Yes, automatic approval',
+ norequest => 'No',
+ );
+ return %titles;
+}
+
+sub curr_requestauthor {
+ my ($uname,$udom,$isadv,$inststatuses,$domconfig) = @_;
+ return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
+ if ($uname eq '' || $udom eq '') {
+ $uname = $env{'user.name'};
+ $udom = $env{'user.domain'};
+ $isadv = $env{'user.adv'};
+ }
+ my (%userenv,%settings,$val);
+ my @options = ('automatic','approval');
+ %userenv =
+ &Apache::lonnet::userenvironment($udom,$uname,'requestauthor','inststatus');
+ if ($userenv{'requestauthor'}) {
+ $val = $userenv{'requestauthor'};
+ @{$inststatuses} = ('_custom_');
+ } else {
+ my %alltasks;
+ if (ref($domconfig->{'requestauthor'}) eq 'HASH') {
+ %settings = %{$domconfig->{'requestauthor'}};
+ if (($isadv) && ($settings{'_LC_adv'} ne '')) {
+ $val = $settings{'_LC_adv'};
+ @{$inststatuses} = ('_LC_adv_');
+ } else {
+ if ($userenv{'inststatus'} ne '') {
+ @{$inststatuses} = split(',',$userenv{'inststatus'});
+ } else {
+ @{$inststatuses} = ('default');
+ }
+ foreach my $status (@{$inststatuses}) {
+ if (exists($settings{$status})) {
+ my $value = $settings{$status};
+ next unless ($value);
+ unless (exists($alltasks{$value})) {
+ if (ref($alltasks{$value}) eq 'ARRAY') {
+ unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) {
+ push(@{$alltasks{$value}},$status);
+ }
+ } else {
+ @{$alltasks{$value}} = ($status);
+ }
+ }
+ }
+ }
+ foreach my $option (@options) {
+ if ($alltasks{$option}) {
+ $val = $option;
+ last;
+ }
+ }
+ }
+ }
+ }
+ return $val;
+}
+
# =================================================================== Phase one
sub print_username_entry_form {
@@ -937,7 +1066,7 @@ sub print_user_modification_page {
&Apache::lonnet::inst_userrules($ccdomain,'username');
$usertype =
&Apache::lonuserutils::check_usertype($ccdomain,$ccuname,$rules,
- \%curr_rules,\%got_rules);
+ \%curr_rules,\%got_rules);
my $cancreate =
&Apache::lonuserutils::can_create_user($ccdomain,$context,
$usertype);
@@ -949,7 +1078,9 @@ sub print_user_modification_page {
);
my $response;
if ($env{'form.origform'} eq 'crtusername') {
- $response = ''.&mt('No match found for the username [_1] in LON-CAPA domain: [_2]',''.$ccuname.' ',$ccdomain).
+ $response = ''.
+ &mt('No match found for the username [_1] in LON-CAPA domain: [_2]',
+ ''.$ccuname.' ',$ccdomain).
' ';
}
$response .= ''
@@ -1066,12 +1197,15 @@ ENDFORMINFO
}
}
if ($newuser) {
- my $portfolioform;
+ my ($portfolioform,$domroleform);
if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) ||
(&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) {
# Current user has quota or user tools modification privileges
$portfolioform = ' '.&portfolio_quota($ccuname,$ccdomain);
}
+ if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) {
+ $domroleform = ' '.&domainrole_req($ccuname,$ccdomain);
+ }
&initialize_authen_forms($ccdomain,$formname);
my %lt=&Apache::lonlocal::texthash(
'cnu' => 'Create New User',
@@ -1117,7 +1251,8 @@ $lt{'hs'}: $home_server_pick
$r->print($home_server_pick);
}
if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
- $r->print('
'.&mt('User Can Request Creation of Courses/Communities in this Domain?').' '.
+ $r->print(''.
+ &mt('User Can Request Creation of Courses/Communities in this Domain?').' '.
&Apache::loncommon::start_data_table().
&build_tools_display($ccuname,$ccdomain,
'requestcourses').
@@ -1181,7 +1316,7 @@ ENDAUTH
} else {
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
}
- $r->print($portfolioform);
+ $r->print($portfolioform.$domroleform);
if ($env{'form.action'} eq 'singlestudent') {
$r->print(&date_sections_select($context,$newuser,$formname,
$permission));
@@ -1215,10 +1350,10 @@ ENDCHANGEUSER
$inst_results{$ccuname.':'.$ccdomain});
$r->print($personal_table);
if ($showforceid) {
- $r->print(&Apache::lonuserutils::forceid_change($context));
+ $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/Communities in this Domain?').' '.
+ $r->print(''.&mt('User Can Request Creation of Courses/Communities in this Domain?').' '.
&Apache::loncommon::start_data_table());
if ($env{'request.role.domain'} eq $ccdomain) {
$r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses'));
@@ -1229,12 +1364,19 @@ ENDCHANGEUSER
$r->print(&Apache::loncommon::end_data_table());
}
$r->print('');
- my $user_auth_text = &user_authentication($ccuname,$ccdomain,$formname);
- my ($user_quota_text,$user_tools_text,$user_reqcrs_text);
+ my @order = ('auth','quota','tools','requestauthor');
+ my %user_text;
+ my ($isadv,$isauthor) =
+ &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
+ if ((!$isauthor) &&
+ (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) {
+ $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);
+ }
+ $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname);
if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
(&Apache::lonnet::allowed('mut',$ccdomain))) {
# Current user has quota modification privileges
- $user_quota_text = &portfolio_quota($ccuname,$ccdomain);
+ $user_text{'quota'} = &portfolio_quota($ccuname,$ccdomain);
}
if (!&Apache::lonnet::allowed('mpq',$ccdomain)) {
if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
@@ -1246,7 +1388,7 @@ ENDCHANGEUSER
'youd' => "You do not have privileges to modify the portfolio quota for this user.",
'ichr' => "If a change is required, contact a domain coordinator for the domain",
);
- $user_quota_text = <$lt{'dska'}
$lt{'youd'} $lt{'ichr'}: $ccdomain
ENDNOPORTPRIV
@@ -1256,46 +1398,34 @@ 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 Personal Information Page settings for this user.",
+ 'yodo' => "You do not have privileges to modify Portfolio, Blog, WebDAV, or Personal Information Page settings for this user.",
'ifch' => "If a change is required, contact a domain coordinator for the domain",
);
- $user_tools_text = <$lt{'utav'}
$lt{'yodo'} $lt{'ifch'}: $ccdomain
ENDNOTOOLSPRIV
}
}
- if ($user_auth_text ne '') {
- $r->print(''.$user_auth_text);
- if ($user_quota_text ne '') {
- $r->print($user_quota_text);
- }
- if ($user_tools_text ne '') {
- $r->print($user_tools_text);
- }
- if ($env{'form.action'} eq 'singlestudent') {
- $r->print(&date_sections_select($context,$newuser,$formname));
- }
- } elsif ($user_quota_text ne '') {
- $r->print('
'.$user_quota_text);
- if ($user_tools_text ne '') {
- $r->print($user_tools_text);
- }
- if ($env{'form.action'} eq 'singlestudent') {
- $r->print(&date_sections_select($context,$newuser,$formname));
- }
- } elsif ($user_tools_text ne '') {
- $r->print('
'.$user_tools_text);
- if ($env{'form.action'} eq 'singlestudent') {
- $r->print(&date_sections_select($context,$newuser,$formname));
- }
- } else {
- if ($env{'form.action'} eq 'singlestudent') {
- $r->print('
'.
- &date_sections_select($context,$newuser,$formname));
+ my $gotdiv = 0;
+ foreach my $item (@order) {
+ if ($user_text{$item} ne '') {
+ unless ($gotdiv) {
+ $r->print('
');
+ $gotdiv = 1;
+ }
+ $r->print(' '.$user_text{$item});
}
}
- $r->print('
');
+ if ($env{'form.action'} eq 'singlestudent') {
+ unless ($gotdiv) {
+ $r->print('
');
+ }
+ $r->print(&date_sections_select($context,$newuser,$formname));
+ }
+ if ($gotdiv) {
+ $r->print('
');
+ }
if ($env{'form.action'} ne 'singlestudent') {
&display_existing_roles($r,$ccuname,$ccdomain,\%inccourses,$context,
$roledom,$crstype);
@@ -1521,7 +1651,7 @@ sub display_existing_roles {
$allowed=1;
}
unless ($allowed) {
- my $isowner = &is_courseowner($cid,$coursedata{'internal.courseowner'});
+ my $isowner = &Apache::lonuserutils::is_courseowner($cid,$coursedata{'internal.courseowner'});
if ($isowner) {
if (($role_code eq 'co') && ($class eq 'Community')) {
$allowed = 1;
@@ -1571,7 +1701,7 @@ sub display_existing_roles {
$allowed=1;
}
}
- if ($role_code eq 'ca' || $role_code eq 'au') {
+ if ($role_code eq 'ca' || $role_code eq 'au' || $role_code eq 'aa') {
$class='Construction Space';
} elsif ($role_code eq 'su') {
$class='System';
@@ -2302,18 +2432,20 @@ sub update_user_data {
# If they are creating a new user but have not specified login
# information this will be caught below.
} else {
- $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink);
- return;
+ $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink);
+ return;
}
$r->print('
'.&mt('User [_1] in domain [_2]',
- $env{'form.ccuname'}, $env{'form.ccdomain'}).' ');
- $r->print('
'.&mt('Please be patient').'
');
+ $env{'form.ccuname'}.' ('.&Apache::loncommon::plainname($env{'form.ccuname'},
+ $env{'form.ccdomain'}).')', $env{'form.ccdomain'}).'');
+ my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,2);
my (%alerts,%rulematch,%inst_results,%curr_rules);
my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
- my @usertools = ('aboutme','blog','portfolio');
+ my @usertools = ('aboutme','blog','webdav','portfolio');
my @requestcourses = ('official','unofficial','community');
+ my @requestauthor = ('requestauthor');
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
my %canmodify_status =
@@ -2368,6 +2500,7 @@ sub update_user_data {
}
}
}
+ &Apache::lonhtmlcommon::Increment_PrgWin($r, \%prog_state);
# Call modifyuser
my $result = &Apache::lonnet::modifyuser
($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cid'},
@@ -2410,6 +2543,12 @@ sub update_user_data {
\%changeHash,'requestcourses');
}
}
+ if ($env{'form.customrequestauthor'} == 1) {
+ $newcustom{'requestauthor'} = $env{'form.requestauthor'};
+ $changed{'requestauthor'} = &tool_admin('requestauthor',
+ $newcustom{'requestauthor'},
+ \%changeHash,'requestauthor');
+ }
}
if ($canmodify_status{'inststatus'}) {
if (exists($env{'form.inststatus'})) {
@@ -2451,9 +2590,8 @@ sub update_user_data {
$r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);
}
}
-
$r->rflush(); # Finish display of header before time consuming actions start
-
+ &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state);
##
my (@userroles,%userupdate,$cnum,$cdom,%namechanged);
if ($context eq 'course') {
@@ -2465,10 +2603,11 @@ sub update_user_data {
my %userenv = &Apache::lonnet::get
('environment',['firstname','middlename','lastname','generation',
'id','permanentemail','portfolioquota','inststatus','tools.aboutme',
- 'tools.blog','tools.portfolio','requestcourses.official',
- 'requestcourses.unofficial','requestcourses.community',
- 'reqcrsotherdom.official','reqcrsotherdom.unofficial',
- 'reqcrsotherdom.community'],
+ 'tools.blog','tools.webdav','tools.portfolio',
+ 'requestcourses.official','requestcourses.unofficial',
+ 'requestcourses.community','reqcrsotherdom.official',
+ 'reqcrsotherdom.unofficial','reqcrsotherdom.community',
+ 'requestauthor'],
$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
@@ -2596,7 +2735,7 @@ sub update_user_data {
$olddefquota,$oldsettingstatus,$newdefquota,$newsettingstatus);
@disporder = ('inststatus');
if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) {
- push(@disporder,'requestcourses');
+ push(@disporder,'requestcourses','requestauthor');
} else {
push(@disporder,'reqcrsotherdom');
}
@@ -2620,6 +2759,9 @@ sub update_user_data {
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
$canshow{'inststatus'} = 1;
}
+ if (&Apache::lonnet::allowed('cau',$env{'form.ccdomain'})) {
+ $canshow{'requestauthor'} = 1;
+ }
my (%changeHash,%changed);
if ($oldinststatus eq '') {
$oldsettings{'inststatus'} = $othertitle;
@@ -2709,6 +2851,7 @@ sub update_user_data {
if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
&tool_changes('requestcourses',\@requestcourses,\%oldsettings,\%oldsettingstext,
\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
+ &tool_changes('requestauthor',\@requestauthor,\%oldsettings,\%oldsettingstext,\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
} else {
&tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,
\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
@@ -2736,13 +2879,22 @@ sub update_user_data {
|| ($key eq 'community')) {
$newenvhash{'environment.requestcourses.'.$key} =
$changeHash{'requestcourses.'.$key};
- if ($changeHash{'requestcourses.'.$key} ne '') {
+ if ($changeHash{'requestcourses.'.$key}) {
$newenvhash{'environment.canrequest.'.$key} = 1;
} else {
$newenvhash{'environment.canrequest.'.$key} =
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
$key,'reload','requestcourses');
}
+ } elsif ($key eq 'requestauthor') {
+ $newenvhash{'environment.'.$key} = $changeHash{$key};
+ if ($changeHash{$key}) {
+ $newenvhash{'environment.canrequest.author'} = 1;
+ } else {
+ $newenvhash{'environment.canrequest.author'} =
+ &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
+ $key,'reload','requestauthor');
+ }
} elsif ($key ne 'quota') {
$newenvhash{'environment.tools.'.$key} =
$changeHash{'tools.'.$key};
@@ -2751,7 +2903,8 @@ sub update_user_data {
$changeHash{'tools.'.$key};
} else {
$newenvhash{'environment.availabletools.'.$key} =
- &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, $key,'reload','tools');
+ &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
+ $key,'reload','tools');
}
}
}
@@ -2784,7 +2937,7 @@ sub update_user_data {
((keys(%changed) > 0) && $chgresult eq 'ok')) {
# Tell the user we changed the name
&display_userinfo($r,1,\@disporder,\%canshow,\@requestcourses,
- \@usertools,\%userenv,\%changed,\%namechanged,
+ \@usertools,\@requestauthor,\%userenv,\%changed,\%namechanged,
\%oldsettings, \%oldsettingstext,\%newsettings,
\%newsettingstext);
if ($env{'form.cid'} ne $userenv{'id'}) {
@@ -2817,7 +2970,7 @@ sub update_user_data {
# or ability to request creation of courses,
# but we can still tell them what the name and quota and availabilities are
&display_userinfo($r,undef,\@disporder,\%canshow,\@requestcourses,
- \@usertools,\%userenv,\%changed,\%namechanged,\%oldsettings,
+ \@usertools,\@requestauthor,\%userenv,\%changed,\%namechanged,\%oldsettings,
\%oldsettingstext,\%newsettings,\%newsettingstext);
}
if (@mod_disallowed) {
@@ -2854,6 +3007,7 @@ sub update_user_data {
.&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts,\%curr_rules)
.'');
}
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
if ($env{'form.action'} eq 'singlestudent') {
&enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype);
$r->print('
');
@@ -2885,21 +3039,21 @@ sub update_user_data {
if ($env{'form.popup'}) {
$r->print(''.&mt('Close window').'
');
} else {
- $r->print(''
- .&mt('Modify this user: [_1]',''.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.' ('.$userinfo.') ').' '
- .(' 'x5).''
- .&mt('Create/Modify Another User').'
');
+ $r->print(' '.&Apache::lonhtmlcommon::actionbox([' '
+ .&mt('Modify this user: [_1]',''.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.' ('.$userinfo.') ').' ',
+ ''.&mt('Create/Modify Another User').' ']));
}
}
}
sub display_userinfo {
- my ($r,$changed,$order,$canshow,$requestcourses,$usertools,$userenv,
- $changedhash,$namechangedhash,$oldsetting,$oldsettingtext,
+ my ($r,$changed,$order,$canshow,$requestcourses,$usertools,$requestauthor,
+ $userenv,$changedhash,$namechangedhash,$oldsetting,$oldsettingtext,
$newsetting,$newsettingtext) = @_;
return unless (ref($order) eq 'ARRAY' &&
ref($canshow) eq 'HASH' &&
ref($requestcourses) eq 'ARRAY' &&
+ ref($requestauthor) eq 'ARRAY' &&
ref($usertools) eq 'ARRAY' &&
ref($userenv) eq 'HASH' &&
ref($changedhash) eq 'HASH' &&
@@ -2908,7 +3062,7 @@ sub display_userinfo {
ref($newsetting) eq 'HASH' &&
ref($newsettingtext) eq 'HASH');
my %lt=&Apache::lonlocal::texthash(
- 'ui' => 'User Information (unchanged)',
+ 'ui' => 'User Information',
'uic' => 'User Information Changed',
'firstname' => 'First Name',
'middlename' => 'Middle Name',
@@ -2918,82 +3072,48 @@ sub display_userinfo {
'permanentemail' => 'Permanent e-mail address',
'quota' => 'Disk space allocated to portfolio files',
'blog' => 'Blog Availability',
+ 'webdav' => 'WebDAV Availability',
'aboutme' => 'Personal Information Page Availability',
'portfolio' => 'Portfolio Availability',
'official' => 'Can Request Official Courses',
'unofficial' => 'Can Request Unofficial Courses',
'community' => 'Can Request Communities',
+ 'requestauthor' => 'Can Request Author Role',
'inststatus' => "Affiliation",
'prvs' => 'Previous Value:',
'chto' => 'Changed To:'
);
- my $title = $lt{'ui'};
- if ($changed) {
- $title = $lt{'uic'};
- }
- $r->print('
'.$title.' '.
- &Apache::loncommon::start_data_table().
- &Apache::loncommon::start_data_table_header_row());
if ($changed) {
+ $r->print('
'.$lt{'uic'}.' '.
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row());
$r->print("
\n");
- }
- my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
- foreach my $item (@userinfo) {
- $r->print("
$lt{$item} \n");
- }
- foreach my $entry (@{$order}) {
- if ($canshow->{$entry}) {
- if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {
- foreach my $item (@{$requestcourses}) {
- $r->print("
$lt{$item} \n");
- }
- } elsif ($entry eq 'tools') {
- foreach my $item (@{$usertools}) {
- $r->print("
$lt{$item} \n");
- }
- } else {
- $r->print("
$lt{$entry} \n");
- }
- }
- }
- $r->print(&Apache::loncommon::end_data_table_header_row().
- &Apache::loncommon::start_data_table_row());
- if ($changed) {
- $r->print('
'.$lt{'prvs'}.' '."\n");
- }
- foreach my $item (@userinfo) {
- $r->print('
'.$userenv->{$item}.' '."\n");
- }
- foreach my $entry (@{$order}) {
- if ($canshow->{$entry}) {
- if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {
- foreach my $item (@{$requestcourses}) {
- $r->print("
$oldsetting->{$item} $oldsettingtext->{$item} \n");
- }
- } elsif ($entry eq 'tools') {
- foreach my $item (@{$usertools}) {
- $r->print("
$oldsetting->{$item} $oldsettingtext->{$item} \n");
- }
- } else {
- $r->print("
$oldsetting->{$entry} $oldsettingtext->{$entry} \n");
- }
- }
- }
- $r->print(&Apache::loncommon::end_data_table_row());
- if ($changed) {
- $r->print(&Apache::loncommon::start_data_table_row().
- '
'.$lt{'chto'}.' '."\n");
+ $r->print('
'.$lt{'prvs'}.' ');
+ $r->print('
'.$lt{'chto'}.' ');
+ $r->print(&Apache::loncommon::end_data_table_header_row());
+ my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
+
+
foreach my $item (@userinfo) {
my $value = $env{'form.c'.$item};
- if ($namechangedhash->{$item}) {
- $value = '
'.$value.' ';
+ #show changes only:
+ unless($value eq $userenv->{$item}){
+ $r->print(&Apache::loncommon::start_data_table_row());
+
+ $r->print("
$lt{$item} \n");
+ $r->print('
'.$userenv->{$item}.' ');
+ $r->print("
$value \n");
+
+ $r->print(&Apache::loncommon::end_data_table_row());
}
- $r->print("
$value \n");
}
foreach my $entry (@{$order}) {
- if ($canshow->{$entry}) {
+ if ($canshow->{$entry} && ($newsetting->{$entry} ne $newsetting->{$entry})) {
+ $r->print(&Apache::loncommon::start_data_table_row());
if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {
foreach my $item (@{$requestcourses}) {
+ $r->print("
$lt{$item} \n");
+ $r->print("
$oldsetting->{$item} $oldsettingtext->{$item} \n");
my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
if ($changedhash->{$item}) {
$value = '
'.$value.' ';
@@ -3002,6 +3122,8 @@ sub display_userinfo {
}
} elsif ($entry eq 'tools') {
foreach my $item (@{$usertools}) {
+ $r->print("
$lt{$item} \n");
+ $r->print("
$oldsetting->{$item} $oldsettingtext->{$item} \n");
my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
if ($changedhash->{$item}) {
$value = '
'.$value.' ';
@@ -3009,17 +3131,22 @@ sub display_userinfo {
$r->print("
$value \n");
}
} else {
+ $r->print("
$lt{$entry} \n");
+ $r->print("
$oldsetting->{$entry} $oldsettingtext->{$entry} \n");
my $value = $newsetting->{$entry}.' '.$newsettingtext->{$entry};
if ($changedhash->{$entry}) {
$value = '
'.$value.' ';
}
$r->print("
$value \n");
}
+ $r->print(&Apache::loncommon::end_data_table_row());
}
}
- $r->print(&Apache::loncommon::end_data_table_row());
+ $r->print(&Apache::loncommon::end_data_table().'
');
+ } else {
+ $r->print('
'.$lt{'ui'}.' '.
+ '
'.&mt('No changes made to user information').'
');
}
- $r->print(&Apache::loncommon::end_data_table().'
');
return;
}
@@ -3118,25 +3245,29 @@ sub tool_changes {
return;
}
foreach my $tool (@{$usertools}) {
- my $newval;
+ my ($newval,$envkey);
+ $envkey = $context.'.'.$tool;
if ($context eq 'requestcourses') {
$newval = $env{'form.crsreq_'.$tool};
if ($newval eq 'autolimit') {
$newval .= '='.$env{'form.crsreq_'.$tool.'_limit'};
}
+ } elsif ($context eq 'requestauthor') {
+ $newval = $env{'form.'.$context};
+ $envkey = $context;
} else {
$newval = $env{'form.'.$context.'_'.$tool};
}
- if ($userenv->{$context.'.'.$tool} ne '') {
+ if ($userenv->{$envkey} ne '') {
$oldaccess->{$tool} = &mt('custom');
- if ($userenv->{$context.'.'.$tool}) {
+ if ($userenv->{$envkey}) {
$oldaccesstext->{$tool} = &mt("availability set to 'on'");
} else {
$oldaccesstext->{$tool} = &mt("availability set to 'off'");
}
- $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};
+ $changeHash->{$envkey} = $userenv->{$envkey};
if ($env{'form.custom'.$tool} == 1) {
- if ($newval ne $userenv->{$context.'.'.$tool}) {
+ if ($newval ne $userenv->{$envkey}) {
$changed->{$tool} = &tool_admin($tool,$newval,$changeHash,
$context);
if ($changed->{$tool}) {
@@ -3212,14 +3343,20 @@ sub update_roles {
&Apache::lonnet::revokerole($env{'form.ccdomain'},
$env{'form.ccuname'},
$scope,$role,'','',$context);
- $r->print(&mt('Revoking [_1] in [_2]: [_3]',
- $role,$scope,'
'.$result.' ').'
');
+ $r->print(&Apache::lonhtmlcommon::confirm_success(
+ &mt('Revoking [_1] in [_2]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($scope,$context,$role)),
+ $result ne "ok").'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if ($role eq 'st') {
my $result =
&Apache::lonuserutils::classlist_drop($scope,
$env{'form.ccuname'},$env{'form.ccdomain'},
$now);
- $r->print($result);
+ $r->print(&Apache::lonhtmlcommon::confirm_success($result));
}
if (!grep(/^\Q$role\E$/,@rolechanges)) {
push(@rolechanges,$role);
@@ -3227,11 +3364,15 @@ sub update_roles {
}
if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}s) {
# Revoke custom role
- $r->print(&mt('Revoking custom role:').
- ' '.$4.' by '.$3.':'.$2.' in '.$1.':
'.
- &Apache::lonnet::revokecustomrole($env{'form.ccdomain'},
- $env{'form.ccuname'},$1,$2,$3,$4,'','',$context).
- ' ');
+ my $result = &Apache::lonnet::revokecustomrole(
+ $env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context);
+ $r->print(&Apache::lonhtmlcommon::confirm_success(
+ &mt('Revoking custom role [_1] by [_2] in [_3]',
+ $4,$3.':'.$2,&Apache::loncommon::show_role_extent($1,$context,'cr')),
+ $result ne 'ok').'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3245,14 +3386,21 @@ sub update_roles {
$env{'form.ccuname'},
$scope,$role,$now,0,1,'',
$context);
- $r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope,
- '
'.$result.' ').'
');
+ $r->print(&Apache::lonhtmlcommon::confirm_success(
+ &mt('Deleting [_1] in [_2]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($scope,$context,$role)),
+ $result ne 'ok').'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
+
if ($role eq 'st') {
my $result =
&Apache::lonuserutils::classlist_drop($scope,
$env{'form.ccuname'},$env{'form.ccdomain'},
$now);
- $r->print($result);
+ $r->print(&Apache::lonhtmlcommon::confirm_success($result));
}
if (!grep(/^\Q$role\E$/,@rolechanges)) {
push(@rolechanges,$role);
@@ -3261,11 +3409,17 @@ 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] in [_3]',
- $rolename,$rnam.':'.$rdom,$url).':
'.
- &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
- $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
- 0,1,$context).' ');
+ my $result =
+ &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
+ $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
+ 0,1,$context);
+ $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Deleting custom role [_1] by [_2] in [_3]',
+ $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
+ $result ne "ok").'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
+
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3286,22 +3440,26 @@ sub update_roles {
if ($result eq 'refused' && $logmsg) {
$output = $logmsg;
} else {
- $output = "Error: $result\n";
+ $output = &mt('Error: [_1]',$result)."\n";
}
} else {
- $output = &mt('Assigning').' '.$role.' in '.$url.
- &mt('starting').' '.localtime($now).
- ':
'.$logmsg.'
'.
- &mt('Add to classlist').':
ok ';
+ $output = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($url,$context,'st'),
+ &Apache::lonlocal::locallocaltime($now))).'
'.$logmsg.'
';
}
}
} else {
my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
$env{'form.ccuname'},$url,$role,0,$now,'','',
$context);
- $output = &mt('Re-enabling [_1] in [_2]: [_3]',
- $role,$url,'
'.$result.' ').'
';
- }
+ $output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($url,$context,$role)),$result ne "ok").'
';
+ if ($result ne "ok") {
+ $output .= &mt('Error: [_1]',$result).'
';
+ }
+ }
$r->print($output);
if (!grep(/^\Q$role\E$/,@rolechanges)) {
push(@rolechanges,$role);
@@ -3313,8 +3471,13 @@ 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] in [_3]: [_4]',
- $rolename,$rnam.':'.$rdom,$url,'
'.$result.' ').'
');
+ $r->print(&Apache::lonhtmlcommon::confirm_success(
+ &mt('Re-enabling custom role [_1] by [_2] in [_3]',
+ $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
+ $result ne "ok").'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3454,7 +3617,7 @@ sub update_roles {
# Flush the course logs so reverse user roles immediately updated
$r->register_cleanup(\&Apache::lonnet::flushcourselogs);
if (@rolechanges == 0) {
- $r->print(&mt('No roles to modify'));
+ $r->print('
'.&mt('No roles to modify').'
');
}
return @rolechanges;
}
@@ -3534,7 +3697,7 @@ sub get_defaultquota_text {
sub update_result_form {
my ($uhome) = @_;
my $outcome =
- '
'."\n";
+ '