--- loncom/interface/loncreateuser.pm 2010/06/09 11:56:02 1.344
+++ loncom/interface/loncreateuser.pm 2012/12/20 16:22:59 1.368
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.344 2010/06/09 11:56:02 bisitz Exp $
+# $Id: loncreateuser.pm,v 1.368 2012/12/20 16:22:59 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 .= ' ';
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 = ' ';
$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,10 +531,84 @@ 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 {
- my ($r,$context,$response,$srch,$forcenewuser,$crstype) = @_;
+ my ($r,$context,$response,$srch,$forcenewuser,$crstype,$brcrum) = @_;
my $defdom=$env{'request.role.domain'};
my $formtoset = 'crtuser';
if (exists($env{'form.startrolename'})) {
@@ -503,31 +632,36 @@ sub print_username_entry_form {
&& (&Apache::lonnet::allowed('mcr','/'))) {
$jscript .= &customrole_javascript();
}
- my %loaditems = (
- 'onload' => "javascript:setFormElements(document.$formtoset)",
- );
- my %breadcrumb_text = &singleuser_breadcrumb($crstype);
- my $start_page =
- &Apache::loncommon::start_page('User Management',
- $jscript,{'add_entries' => \%loaditems,});
- if ($env{'form.action'} eq 'custom') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.crtuser)",
- text=>"Pick custom role",});
- } else {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.crtuser)",
- text=>$breadcrumb_text{'search'},
- faq=>282,bug=>'Instructor Interface',});
- }
my $helpitem = 'Course_Change_Privileges';
if ($env{'form.action'} eq 'custom') {
$helpitem = 'Course_Editing_Custom_Roles';
} elsif ($env{'form.action'} eq 'singlestudent') {
$helpitem = 'Course_Add_Student';
}
- my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management',
- $helpitem);
+ my %breadcrumb_text = &singleuser_breadcrumb($crstype);
+ if ($env{'form.action'} eq 'custom') {
+ push(@{$brcrum},
+ {href=>"javascript:backPage(document.crtuser)",
+ text=>"Pick custom role",
+ help => $helpitem,}
+ );
+ } else {
+ push (@{$brcrum},
+ {href => "javascript:backPage(document.crtuser)",
+ text => $breadcrumb_text{'search'},
+ help => $helpitem,
+ faq => 282,
+ bug => 'Instructor Interface',}
+ );
+ }
+ my %loaditems = (
+ 'onload' => "javascript:setFormElements(document.$formtoset)",
+ );
+ my $args = {bread_crumbs => $brcrum,
+ bread_crumbs_component => 'User Management',
+ add_entries => \%loaditems,};
+ $r->print(&Apache::loncommon::start_page('User Management',$jscript,$args));
+
my %lt=&Apache::lonlocal::texthash(
'srst' => 'Search for a user and enroll as a student',
'srme' => 'Search for a user and enroll as a member',
@@ -538,7 +672,7 @@ sub print_username_entry_form {
'nr' => "role name",
'cre' => "Next",
);
- $r->print($start_page."\n".$crumbs);
+
if ($env{'form.action'} eq 'custom') {
if (&Apache::lonnet::allowed('mcr','/')) {
my $newroletext = &mt('Define new custom role:');
@@ -591,7 +725,6 @@ sub print_username_entry_form {
}
$r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype));
}
- $r->print(&Apache::loncommon::end_page());
}
sub customrole_javascript {
@@ -634,7 +767,6 @@ END
sub entry_form {
my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype) = @_;
- my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
my ($usertype,$inexact);
if (ref($srch) eq 'HASH') {
if (($srch->{'srchin'} eq 'dom') &&
@@ -642,9 +774,10 @@ sub entry_form {
($srch->{'srchtype'} eq 'exact') &&
($srch->{'srchdomain'} ne '') &&
($srch->{'srchterm'} ne '')) {
+ my (%curr_rules,%got_rules);
my ($rules,$ruleorder) =
&Apache::lonnet::inst_userrules($srch->{'srchdomain'},'username');
- $usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules);
+ $usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules,\%curr_rules,\%got_rules);
} else {
$inexact = 1;
}
@@ -738,19 +871,13 @@ sub user_modification_js {
'."\n";
my %breadcrumb_text = &singleuser_breadcrumb($crstype);
- my $args;
- if ($env{'form.popup'}) {
- $args->{'no_nav_bar'} = 1;
- } else {
- $args = undef;
- }
- $r->print(&Apache::loncommon::start_page($title,$jscript,$args));
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.userupdate)",
- text=>$breadcrumb_text{'search'},
- faq=>282,bug=>'Instructor Interface',});
+ push (@{$brcrum},
+ {href => "javascript:backPage(document.userupdate)",
+ text => $breadcrumb_text{'search'},
+ faq => 282,
+ bug => 'Instructor Interface',}
+ );
if ($env{'form.prevphase'} eq 'userpicked') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.userupdate,'get_user_info','select')",
- text=>$breadcrumb_text{'userpicked'},
- faq=>282,bug=>'Instructor Interface',});
- }
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')",
- text=>$breadcrumb_text{'modify'},
- faq=>282,bug=>'Instructor Interface',},
- {href=>"/adm/createuser",
- text=>"Result",
- faq=>282,bug=>'Instructor Interface',});
+ push(@{$brcrum},
+ {href => "javascript:backPage(document.userupdate,'get_user_info','select')",
+ text => $breadcrumb_text{'userpicked'},
+ faq => 282,
+ bug => 'Instructor Interface',});
+ }
my $helpitem = 'Course_Change_Privileges';
if ($env{'form.action'} eq 'singlestudent') {
$helpitem = 'Course_Add_Student';
}
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management',
- $helpitem));
+ push(@{$brcrum},
+ {href => "javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')",
+ text => $breadcrumb_text{'modify'},
+ faq => 282,
+ bug => 'Instructor Interface',},
+ {href => "/adm/createuser",
+ text => "Result",
+ faq => 282,
+ bug => 'Instructor Interface',
+ help => $helpitem});
+ my $args = {bread_crumbs => $brcrum,
+ bread_crumbs_component => 'User Management'};
+ if ($env{'form.popup'}) {
+ $args->{'no_nav_bar'} = 1;
+ }
+ $r->print(&Apache::loncommon::start_page($title,$jscript,$args));
$r->print(&update_result_form($uhome));
# Check Inputs
if (! $env{'form.ccuname'} ) {
@@ -2291,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 =
@@ -2357,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'},
@@ -2399,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'})) {
@@ -2440,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') {
@@ -2454,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) {
@@ -2585,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');
}
@@ -2609,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;
@@ -2698,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);
@@ -2725,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};
@@ -2740,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');
}
}
}
@@ -2773,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'}) {
@@ -2806,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) {
@@ -2843,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('');
@@ -2874,22 +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').'']));
}
}
- $r->print(&Apache::loncommon::end_page());
}
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,11 +3072,13 @@ 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:'
@@ -2920,70 +3086,36 @@ sub display_userinfo {
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(''.$title.''.
+ &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.'';
@@ -2992,6 +3124,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.'';
@@ -2999,17 +3133,19 @@ 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().'
');
}
- $r->print(&Apache::loncommon::end_data_table().'
');
return;
}
@@ -3108,25 +3244,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}) {
@@ -3202,14 +3342,15 @@ 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), '"'.&cid_to_cname($scope).'"
'),
+ $result ne "ok"));
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);
@@ -3217,11 +3358,10 @@ 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).
- '
');
+ $r->print(&Apache::lonhtmlcommon::confirm_success(
+ &mt('Revoking custom role [_1] by [_2]:[_3] in [_4]',$4,$3,$2,'"'.&cid_to_cname($1).'"
'),
+ &Apache::lonnet::revokecustomrole($env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context) ne 'ok'));
+
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3235,8 +3375,10 @@ 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),'"'.&cid_to_cname($scope).'"
'),$result ne 'ok'));
+
if ($role eq 'st') {
my $result =
&Apache::lonuserutils::classlist_drop($scope,
@@ -3251,11 +3393,12 @@ 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).': '.
+ $r->print(&confirm_success(&mt('Deleting custom role [_1] by [_2] in [_3]',
+ $rolename,$rnam.':'.$rdom,'"'.&cid_to_cname($1).'"').'
'));
&Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
$env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
- 0,1,$context).'
');
+ 0,1,$context);
+
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3279,18 +3422,16 @@ sub update_roles {
$output = "Error: $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),
+ '"'.&cid_to_cname($url).'"',&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),'"'.&cid_to_cname($url).'"').'
',$result ne "ok");
}
$r->print($output);
if (!grep(/^\Q$role\E$/,@rolechanges)) {
@@ -3303,8 +3444,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] 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,'"'.&cid_to_cname($1).'"').'
'),$result ne "ok");
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3442,7 +3583,7 @@ sub update_roles {
}
} # End of foreach (keys(%env))
# Flush the course logs so reverse user roles immediately updated
- &Apache::lonnet::flushcourselogs();
+ $r->register_cleanup(\&Apache::lonnet::flushcourselogs);
if (@rolechanges == 0) {
$r->print(&mt('No roles to modify'));
}
@@ -3524,7 +3665,7 @@ sub get_defaultquota_text {
sub update_result_form {
my ($uhome) = @_;
my $outcome =
- ''."\n";
+ '