'.
+ &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',
unofficial => 'Unofficial',
community => 'Communities',
+ textbook => 'Textbook',
norequest => 'Not allowed',
approval => 'Approval by Dom. Coord.',
validate => 'With validation',
@@ -467,13 +551,95 @@ 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 requestchange_display {
+ my %titles = &Apache::lonlocal::texthash (
+ approval => "availability set to 'on' (approval required)",
+ automatic => "availability set to 'on' (automatic approval)",
+ norequest => "availability set to 'off'",
+ );
+ 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,$brcrum) = @_;
my $defdom=$env{'request.role.domain'};
my $formtoset = 'crtuser';
- my $is_custom = &Apache::loncommon::needs_gci_custom();
if (exists($env{'form.startrolename'})) {
$formtoset = 'docustom';
$env{'form.rolename'} = $env{'form.startrolename'};
@@ -495,12 +661,6 @@ sub print_username_entry_form {
&& (&Apache::lonnet::allowed('mcr','/'))) {
$jscript .= &customrole_javascript();
}
- my $title = 'User Management';
- if ($context eq 'course') {
- if ($is_custom) {
- $title = 'Enrollment and Student Activity';
- }
- }
my $helpitem = 'Course_Change_Privileges';
if ($env{'form.action'} eq 'custom') {
$helpitem = 'Course_Editing_Custom_Roles';
@@ -529,7 +689,7 @@ sub print_username_entry_form {
my $args = {bread_crumbs => $brcrum,
bread_crumbs_component => 'User Management',
add_entries => \%loaditems,};
- $r->print(&Apache::loncommon::start_page($title,$jscript,$args));
+ $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',
@@ -541,6 +701,7 @@ sub print_username_entry_form {
'nr' => "role name",
'cre' => "Next",
);
+
if ($env{'form.action'} eq 'custom') {
if (&Apache::lonnet::allowed('mcr','/')) {
my $newroletext = &mt('Define new custom role:');
@@ -635,7 +796,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') &&
@@ -643,9 +803,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;
}
@@ -671,7 +832,7 @@ $userpicker
ENDBLOCK
if ($env{'form.phase'} eq '') {
my $defdom=$env{'request.role.domain'};
- my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain','',1);
+ my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
my %lt=&Apache::lonlocal::texthash(
'enro' => 'Enroll one student',
'enrm' => 'Enroll one member',
@@ -720,7 +881,7 @@ $showresponse
$lt{'usr'}:
-
+
$lt{'dom'}:
$domform
$sellink
@@ -739,19 +900,13 @@ sub user_modification_js {
-
$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain
ENDTITLE
if ($env{'form.action'} eq 'singlestudent') {
if ($crstype eq 'Community') {
- $r->print(' ('.$lt{'ame'}.')');
+ $title = &mt('Create New User [_1] in domain [_2] as a member',
+ '"'.$ccuname.'"','"'.$ccdomain.'"');
} else {
- $r->print(' ('.$lt{'ast'}.')');
+ $title = &mt('Create New User [_1] in domain [_2] as a student',
+ '"'.$ccuname.'"','"'.$ccdomain.'"');
}
+ } else {
+ $title = &mt('Create New User [_1] in domain [_2]',
+ '"'.$ccuname.'"','"'.$ccdomain.'"');
}
- $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'}))
+ && ($env{'request.role.domain'} eq $ccdomain)) {
+ $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'} = &user_quotas($ccuname,$ccdomain);
}
if (!&Apache::lonnet::allowed('mpq',$ccdomain)) {
if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
- # Get the user's portfolio information
- my %portq = &Apache::lonnet::get('environment',['portfolioquota'],
- $ccdomain,$ccuname);
my %lt=&Apache::lonlocal::texthash(
- 'dska' => "Disk space allocated to user's portfolio files",
- 'youd' => "You do not have privileges to modify the portfolio quota for this user.",
+ 'dska' => "Disk quotas for user's portfolio and Authoring Space",
+ 'youd' => "You do not have privileges to modify the portfolio and/or Authoring Space quotas 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
@@ -1289,46 +1420,43 @@ 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('
'.
+ &Apache::lonhtmlcommon::row_closure(1);
+ $rowcount ++;
+ }
+ my $submit_text = &mt('Create account');
+ $output .= &Apache::lonhtmlcommon::row_title()."\n".
+ ' '.
+ ''.
+ &Apache::lonhtmlcommon::row_closure(1);
+ }
$output .= &Apache::lonhtmlcommon::end_pick_box();
if (wantarray) {
if ($context eq 'selfcreate') {
return($output,$rowcount,$editable);
} else {
- return ($output,$showforceid);
+ return $output;
}
} else {
return $output;
@@ -2198,8 +2446,7 @@ sub get_inststatuses {
# ================================================================= Phase Three
sub update_user_data {
- my ($r,$context,$crstype,$brcrum) = @_;
- my $is_custom = &Apache::loncommon::needs_gci_custom();
+ my ($r,$context,$crstype,$brcrum,$showcredits) = @_;
my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
$env{'form.ccdomain'});
# Error messages
@@ -2224,16 +2471,23 @@ sub update_user_data {
'// ]]>'."\n".
''."\n";
my %breadcrumb_text = &singleuser_breadcrumb($crstype);
+ push (@{$brcrum},
+ {href => "javascript:backPage(document.userupdate)",
+ text => $breadcrumb_text{'search'},
+ faq => 282,
+ bug => 'Instructor Interface',}
+ );
+ if ($env{'form.prevphase'} eq 'userpicked') {
+ 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';
}
- my $bread_crumbs_component = 'User Management';
- if ($context eq 'course') {
- if ($is_custom) {
- $bread_crumbs_component = 'Enrollment and Student Activity';
- }
- }
push(@{$brcrum},
{href => "javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')",
text => $breadcrumb_text{'modify'},
@@ -2244,13 +2498,12 @@ sub update_user_data {
faq => 282,
bug => 'Instructor Interface',
help => $helpitem});
- my $args = {bread_crumbs => $brcrum,
- bread_crumbs_component => $bread_crumbs_component};
+ 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'} ) {
@@ -2281,9 +2534,12 @@ sub update_user_data {
if (! exists($env{'form.makeuser'})) {
# Modifying an existing user, so check the validity of the name
if ($uhome eq 'no_host') {
- $r->print($error.&mt('Unable to determine home server for ').
- $env{'form.ccuname'}.&mt(' in domain ').
- $env{'form.ccdomain'}.'.');
+ $r->print(
+ $error
+ .'
'
+ .&mt('Unable to determine home server for [_1] in domain [_2].',
+ '"'.$env{'form.ccuname'}.'"','"'.$env{'form.ccdomain'}.'"')
+ .'
');
return;
}
}
@@ -2311,17 +2567,25 @@ 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'}).'
');
+ $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 @usertools = ('aboutme','blog','portfolio');
- my @requestcourses = ('official','unofficial','community');
+ my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
+ my @usertools = ('aboutme','blog','webdav','portfolio');
+ my @requestcourses = ('official','unofficial','community','textbook');
+ my @requestauthor = ('requestauthor');
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
+ my %canmodify_status =
+ &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},
+ ['inststatus']);
if ($env{'form.makeuser'}) {
$r->print('
'.&mt('Creating new account.').'
');
# Check for the authentication mode and password
@@ -2371,6 +2635,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'},
@@ -2381,49 +2646,63 @@ sub update_user_data {
$r->print(&mt('Generating user').': '.$result);
$uhome = &Apache::lonnet::homeserver($env{'form.ccuname'},
$env{'form.ccdomain'});
- my (%changeHash,%newcustom,%changed);
+ my (%changeHash,%newcustom,%changed,%changedinfo);
if ($uhome ne 'no_host') {
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newcustom{'quota'} = 0;
- } else {
- $newcustom{'quota'} = $env{'form.portfolioquota'};
- $newcustom{'quota'} =~ s/[^\d\.]//g;
+ if ($context eq 'domain') {
+ foreach my $name ('portfolio','author') {
+ if ($env{'form.custom_'.$name.'quota'} == 1) {
+ if ($env{'form.'.$name.'quota'} eq '') {
+ $newcustom{$name.'quota'} = 0;
+ } else {
+ $newcustom{$name.'quota'} = $env{'form.'.$name.'quota'};
+ $newcustom{$name.'quota'} =~ s/[^\d\.]//g;
+ }
+ if ("a_admin($newcustom{$name.'quota'},\%changeHash,$name)) {
+ $changed{$name.'quota'} = 1;
+ }
+ }
}
- $changed{'quota'} = "a_admin($newcustom{'quota'},\%changeHash);
- }
- foreach my $item (@usertools) {
- if ($env{'form.custom'.$item} == 1) {
- $newcustom{$item} = $env{'form.tools_'.$item};
- $changed{$item} = &tool_admin($item,$newcustom{$item},
- \%changeHash,'tools');
+ foreach my $item (@usertools) {
+ if ($env{'form.custom'.$item} == 1) {
+ $newcustom{$item} = $env{'form.tools_'.$item};
+ $changed{$item} = &tool_admin($item,$newcustom{$item},
+ \%changeHash,'tools');
+ }
}
- }
- foreach my $item (@requestcourses) {
- $newcustom{$item} = $env{'form.crsreq_'.$item};
- if ($env{'form.crsreq_'.$item} eq 'autolimit') {
- $newcustom{$item} .= '=';
- unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) {
- $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
+ foreach my $item (@requestcourses) {
+ if ($env{'form.custom'.$item} == 1) {
+ $newcustom{$item} = $env{'form.crsreq_'.$item};
+ if ($env{'form.crsreq_'.$item} eq 'autolimit') {
+ $newcustom{$item} .= '=';
+ $env{'form.crsreq_'.$item.'_limit'} =~ s/\D+//g;
+ if ($env{'form.crsreq_'.$item.'_limit'}) {
+ $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
+ }
+ }
+ $changed{$item} = &tool_admin($item,$newcustom{$item},
+ \%changeHash,'requestcourses');
}
}
- $changed{$item} = &tool_admin($item,$newcustom{$item},
- \%changeHash,'requestcourses');
- }
- if (exists($env{'form.inststatus'})) {
- my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
- if (@inststatuses > 0) {
- $changeHash{'inststatus'} = join(',',@inststatuses);
- $changed{'inststatus'} = $changeHash{'inststatus'};
+ if ($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'})) {
+ my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
+ if (@inststatuses > 0) {
+ $changeHash{'inststatus'} = join(',',@inststatuses);
+ $changed{'inststatus'} = $changeHash{'inststatus'};
+ }
}
}
if (keys(%changed)) {
- $changeHash{'firstname'} = $env{'form.cfirstname'};
- $changeHash{'middlename'} = $env{'form.cmiddlename'};
- $changeHash{'lastname'} = $env{'form.clastname'};
- $changeHash{'generation'} = $env{'form.cgeneration'};
- $changeHash{'id'} = $env{'form.cid'};
- $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
+ foreach my $item (@userinfo) {
+ $changeHash{$item} = $env{'form.c'.$item};
+ }
my $chgresult =
&Apache::lonnet::put('environment',\%changeHash,
$env{'form.ccdomain'},$env{'form.ccuname'});
@@ -2438,7 +2717,7 @@ sub update_user_data {
$r->print($error.'Invalid login mode or password'.$end.$rtnlink);
return;
}
- # Only allow authentification modification if the person has authority
+ # Only allow authentication modification if the person has authority
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
$r->print('Modifying authentication: '.
&Apache::lonnet::modifyuserauth(
@@ -2448,24 +2727,32 @@ sub update_user_data {
($env{'form.ccuname'},$env{'form.ccdomain'}));
} else {
# Okay, this is a non-fatal error.
- $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);
+ $r->print($error.&mt('You do not have the authority to modify this users authentication 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,$crstype,$namechanged);
+ my (@userroles,%userupdate,$cnum,$cdom,$defaultcredits,%namechanged);
if ($context eq 'course') {
- ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity();
+ ($cnum,$cdom) =
+ &Apache::lonuserutils::get_course_identity();
$crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum);
+ if ($showcredits) {
+ $defaultcredits = &Apache::lonuserutils::get_defaultcredits($cdom,$cnum);
+ }
}
if (! $env{'form.makeuser'} ) {
# Check for need to change
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',
+ 'id','permanentemail','portfolioquota','authorquota','inststatus',
+ 'tools.aboutme','tools.blog','tools.webdav','tools.portfolio',
+ 'requestcourses.official','requestcourses.unofficial',
+ 'requestcourses.community','requestcourses.textbook',
'reqcrsotherdom.official','reqcrsotherdom.unofficial',
- 'reqcrsotherdom.community'],
+ 'reqcrsotherdom.community','reqcrsotherdom.textbook',
+ 'requestauthor'],
$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
@@ -2542,7 +2829,6 @@ sub update_user_data {
push(@longroles,&Apache::lonnet::plaintext($role,$crstype));
}
}
- my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
my %canmodify = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},\@userinfo,\@userroles);
foreach my $item (@userinfo) {
# Strip leading and trailing whitespace
@@ -2588,41 +2874,54 @@ sub update_user_data {
}
}
}
- my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus,
- $inststatus,$newinststatus,$oldisdefault,$newisdefault,$olddefquotatext,
- $newdefquotatext,%oldaccess,%oldaccesstext,%newaccess,%newaccesstext,
- $oldinststatuses,$newinststatuses);
- my ($defquota,$settingstatus) =
- &Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus);
- my ($showquota,$showtools,$showrequestcourses,$showinststatus,$showreqotherdom);
+ my (%quotachanged,%oldquota,%newquota,%olddefquota,%newdefquota,
+ $oldinststatus,$newinststatus,%oldisdefault,%newisdefault,%oldsettings,
+ %oldsettingstext,%newsettings,%newsettingstext,@disporder,
+ %oldsettingstatus,%newsettingstatus);
+ @disporder = ('inststatus');
+ if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) {
+ push(@disporder,'requestcourses','requestauthor');
+ } else {
+ push(@disporder,'reqcrsotherdom');
+ }
+ push(@disporder,('quota','tools'));
+ $oldinststatus = $userenv{'inststatus'};
+ foreach my $name ('portfolio','author') {
+ ($olddefquota{$name},$oldsettingstatus{$name}) =
+ &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus,$name);
+ ($newdefquota{$name},$newsettingstatus{$name}) = ($olddefquota{$name},$oldsettingstatus{$name});
+ }
+ my %canshow;
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
- $showquota = 1;
+ $canshow{'quota'} = 1;
}
if (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
- $showtools = 1;
+ $canshow{'tools'} = 1;
}
if (&Apache::lonnet::allowed('ccc',$env{'form.ccdomain'})) {
- $showrequestcourses = 1;
+ $canshow{'requestcourses'} = 1;
} elsif (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
- $showreqotherdom = 1;
+ $canshow{'reqcrsotherdom'} = 1;
}
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
- $showinststatus = 1;
+ $canshow{'inststatus'} = 1;
+ }
+ if (&Apache::lonnet::allowed('cau',$env{'form.ccdomain'})) {
+ $canshow{'requestauthor'} = 1;
}
my (%changeHash,%changed);
- $oldinststatus = $userenv{'inststatus'};
if ($oldinststatus eq '') {
- $oldinststatuses = $othertitle;
+ $oldsettings{'inststatus'} = $othertitle;
} else {
if (ref($usertypes) eq 'HASH') {
- $oldinststatuses = join(', ',map{ $usertypes->{ &unescape($_) }; } (split(/:/,$userenv{'inststatus'})));
+ $oldsettings{'inststatus'} = join(', ',map{ $usertypes->{ &unescape($_) }; } (split(/:/,$userenv{'inststatus'})));
} else {
- $oldinststatuses = join(', ',map{ &unescape($_); } (split(/:/,$userenv{'inststatus'})));
+ $oldsettings{'inststatus'} = join(', ',map{ &unescape($_); } (split(/:/,$userenv{'inststatus'})));
}
}
$changeHash{'inststatus'} = $userenv{'inststatus'};
- my %canmodify_inststatus = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},['inststatus'],\@userroles);
- if ($canmodify_inststatus{'inststatus'}) {
+ if ($canmodify_status{'inststatus'}) {
+ $canshow{'inststatus'} = 1;
if (exists($env{'form.inststatus'})) {
my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
if (@inststatuses > 0) {
@@ -2630,86 +2929,110 @@ sub update_user_data {
$changeHash{'inststatus'} = $newinststatus;
if ($newinststatus ne $oldinststatus) {
$changed{'inststatus'} = $newinststatus;
+ foreach my $name ('portfolio','author') {
+ ($newdefquota{$name},$newsettingstatus{$name}) =
+ &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus,$name);
+ }
}
if (ref($usertypes) eq 'HASH') {
- $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
+ $newsettings{'inststatus'} = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
} else {
- $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
+ $newsettings{'inststatus'} = join(', ',@inststatuses);
+ }
+ }
+ } else {
+ $newinststatus = '';
+ $changeHash{'inststatus'} = $newinststatus;
+ $newsettings{'inststatus'} = $othertitle;
+ if ($newinststatus ne $oldinststatus) {
+ $changed{'inststatus'} = $changeHash{'inststatus'};
+ foreach my $name ('portfolio','author') {
+ ($newdefquota{$name},$newsettingstatus{$name}) =
+ &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus,$name);
+ }
+ }
+ }
+ } elsif ($context ne 'selfcreate') {
+ $canshow{'inststatus'} = 1;
+ $newsettings{'inststatus'} = $oldsettings{'inststatus'};
+ }
+ foreach my $name ('portfolio','author') {
+ $changeHash{$name.'quota'} = $userenv{$name.'quota'};
+ }
+ if ($context eq 'domain') {
+ foreach my $name ('portfolio','author') {
+ if ($userenv{$name.'quota'} ne '') {
+ $oldquota{$name} = $userenv{$name.'quota'};
+ if ($env{'form.custom_'.$name.'quota'} == 1) {
+ if ($env{'form.'.$name.'quota'} eq '') {
+ $newquota{$name} = 0;
+ } else {
+ $newquota{$name} = $env{'form.'.$name.'quota'};
+ $newquota{$name} =~ s/[^\d\.]//g;
+ }
+ if ($newquota{$name} != $oldquota{$name}) {
+ if ("a_admin($newquota{$name},\%changeHash,$name)) {
+ $changed{$name.'quota'} = 1;
+ }
+ }
+ } else {
+ if ("a_admin('',\%changeHash,$name)) {
+ $changed{$name.'quota'} = 1;
+ $newquota{$name} = $newdefquota{$name};
+ $newisdefault{$name} = 1;
+ }
}
} else {
- $newinststatus = '';
- $changeHash{'inststatus'} = $newinststatus;
- $newinststatuses = $othertitle;
- if ($newinststatus ne $oldinststatus) {
- $changed{'inststatus'} = $changeHash{'inststatus'};
+ $oldisdefault{$name} = 1;
+ $oldquota{$name} = $olddefquota{$name};
+ if ($env{'form.custom_'.$name.'quota'} == 1) {
+ if ($env{'form.'.$name.'quota'} eq '') {
+ $newquota{$name} = 0;
+ } else {
+ $newquota{$name} = $env{'form.'.$name.'quota'};
+ $newquota{$name} =~ s/[^\d\.]//g;
+ }
+ if ("a_admin($newquota{$name},\%changeHash,$name)) {
+ $changed{$name.'quota'} = 1;
+ }
+ } else {
+ $newquota{$name} = $newdefquota{$name};
+ $newisdefault{$name} = 1;
}
}
+ if ($oldisdefault{$name}) {
+ $oldsettingstext{'quota'}{$name} = &get_defaultquota_text($oldsettingstatus{$name});
+ } else {
+ $oldsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$oldquota{$name});
+ }
+ if ($newisdefault{$name}) {
+ $newsettingstext{'quota'}{$name} = &get_defaultquota_text($newsettingstatus{$name});
+ } else {
+ $newsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$newquota{$name});
+ }
+ }
+ &tool_changes('tools',\@usertools,\%oldsettings,\%oldsettingstext,\%userenv,
+ \%changeHash,\%changed,\%newsettings,\%newsettingstext);
+ 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);
}
}
- $changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
- if ($userenv{'portfolioquota'} ne '') {
- $oldportfolioquota = $userenv{'portfolioquota'};
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newportfolioquota = 0;
- } else {
- $newportfolioquota = $env{'form.portfolioquota'};
- $newportfolioquota =~ s/[^\d\.]//g;
- }
- if ($newportfolioquota != $oldportfolioquota) {
- $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash);
- }
- } else {
- $changed{'quota'} = "a_admin('',\%changeHash);
- $newportfolioquota = $defquota;
- $newisdefault = 1;
- }
- } else {
- $oldisdefault = 1;
- $oldportfolioquota = $defquota;
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newportfolioquota = 0;
- } else {
- $newportfolioquota = $env{'form.portfolioquota'};
- $newportfolioquota =~ s/[^\d\.]//g;
- }
- $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash);
- } else {
- $newportfolioquota = $defquota;
- $newisdefault = 1;
- }
- }
- if ($oldisdefault) {
- $olddefquotatext = &get_defaultquota_text($settingstatus);
- }
- if ($newisdefault) {
- $newdefquotatext = &get_defaultquota_text($settingstatus);
- }
- &tool_changes('tools',\@usertools,\%oldaccess,\%oldaccesstext,\%userenv,
- \%changeHash,\%changed,\%newaccess,\%newaccesstext);
- if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
- &tool_changes('requestcourses',\@requestcourses,\%oldaccess,\%oldaccesstext,
- \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext);
- } else {
- &tool_changes('reqcrsotherdom',\@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'} ||
- $env{'form.cgeneration'} ne $userenv{'generation'} ||
- $env{'form.cid'} ne $userenv{'id'} ||
- $env{'form.cpermanentemail'} ne $userenv{'permanentemail'} ) {
- $namechanged = 1;
- }
- if (($namechanged) || (keys(%changed) > 0)) {
- $changeHash{'firstname'} = $env{'form.cfirstname'};
- $changeHash{'middlename'} = $env{'form.cmiddlename'};
- $changeHash{'lastname'} = $env{'form.clastname'};
- $changeHash{'generation'} = $env{'form.cgeneration'};
- $changeHash{'id'} = $env{'form.cid'};
- $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
+ foreach my $item (@userinfo) {
+ if ($env{'form.c'.$item} ne $userenv{$item}) {
+ $namechanged{$item} = 1;
+ }
+ }
+ foreach my $name ('portfolio','author') {
+ $oldsettings{'quota'}{$name} = &mt('[_1] MB',$oldquota{$name});
+ $newsettings{'quota'}{$name} = &mt('[_1] MB',$newquota{$name});
+ }
+ if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) {
my ($chgresult,$namechgresult);
if (keys(%changed) > 0) {
$chgresult =
@@ -2724,14 +3047,22 @@ sub update_user_data {
|| ($key eq 'community')) {
$newenvhash{'environment.requestcourses.'.$key} =
$changeHash{'requestcourses.'.$key};
- if ($changeHash{'requestcourses.'.$key} ne '') {
- $newenvhash{'environment.canrequest.'.$key} =
- $changeHash{'requestcourses.'.$key};
+ 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};
@@ -2741,7 +3072,7 @@ sub update_user_data {
} else {
$newenvhash{'environment.availabletools.'.$key} =
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
- $key,'reload','tools');
+ $key,'reload','tools');
}
}
}
@@ -2751,14 +3082,17 @@ sub update_user_data {
}
}
}
- if ($namechanged) {
- # Make the change
+ if (keys(%namechanged) > 0) {
+ foreach my $field (@userinfo) {
+ $changeHash{$field} = $env{'form.c'.$field};
+ }
+# Make the change
$namechgresult =
&Apache::lonnet::modifyuser($env{'form.ccdomain'},
$env{'form.ccuname'},$changeHash{'id'},undef,undef,
$changeHash{'firstname'},$changeHash{'middlename'},
$changeHash{'lastname'},$changeHash{'generation'},
- $changeHash{'id'},undef,$changeHash{'permanentemail'});
+ $changeHash{'id'},undef,$changeHash{'permanentemail'},undef,\@userinfo);
%userupdate = (
lastname => $env{'form.clastname'},
middlename => $env{'form.cmiddlename'},
@@ -2767,139 +3101,13 @@ sub update_user_data {
id => $env{'form.cid'},
);
}
- if (($namechanged && $namechgresult eq 'ok') ||
+ if (((keys(%namechanged) > 0) && $namechgresult eq 'ok') ||
((keys(%changed) > 0) && $chgresult eq 'ok')) {
# Tell the user we changed the name
- my %lt=&Apache::lonlocal::texthash(
- 'uic' => 'User Information Changed',
- 'frst' => 'First Name',
- 'mddl' => 'Middle Name',
- 'lst' => 'Last Name',
- 'gen' => 'Generation',
- 'id' => 'Student/Employee ID',
- 'mail' => 'Permanent e-mail address',
- 'disk' => 'Disk space allocated to portfolio files',
- 'blog' => 'Blog Availability',
- 'aboutme' => 'Personal Information Page Availability',
- 'portfolio' => 'Portfolio Availability',
- 'official' => 'Can Request Official Courses',
- 'unofficial' => 'Can Request Unofficial Courses',
- 'community' => 'Can Request Communities',
- 'inststatus' => "Affiliation",
- 'prvs' => 'Previous Value:',
- 'chto' => 'Changed To:'
- );
- $r->print('
'
+ .&mt('Unable to successfully change environment for [_1] in domain [_2].',
+ '"'.$env{'form.ccuname'}.'"',
+ '"'.$env{'form.ccdomain'}.'"')
+ .'
');
}
- } else { # End of if ($env ... ) logic
+ } else { # End of if ($env ... ) logic
# 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 address",
- 'disk' => "Disk space allocated to user's portfolio files",
- 'blog' => "Blog Availability",
- 'aboutme' => "Personal Information Page Availability",
- 'portfolio' => "Portfolio Availability",
- 'official' => "Can Request Official Courses",
- 'unofficial' => "Can Request Unofficial Courses",
- 'community' => "Can Request Communities",
- 'inststatus' => "Affiliation",
- );
- $r->print(<<"END");
-
');
+ &display_userinfo($r,undef,\@disporder,\%canshow,\@requestcourses,
+ \@usertools,\@requestauthor,\%userenv,\%changed,\%namechanged,\%oldsettings,
+ \%oldsettingstext,\%newsettings,\%newsettingstext);
}
if (@mod_disallowed) {
my ($rolestr,$contextname);
@@ -2982,9 +3152,9 @@ END
$rolestr = &mt('No roles');
}
if ($context eq 'course') {
- $contextname = &mt('course');
+ $contextname = 'course';
} elsif ($context eq 'author') {
- $contextname = &mt('co-author');
+ $contextname = 'co-author';
}
$r->print(&mt('The following fields were not updated: ').'
');
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
@@ -2993,9 +3163,9 @@ END
}
$r->print('
');
if (@mod_disallowed == 1) {
- $r->print(&mt("You do not have the authority to change this field given the user's current set of active/future [_1] roles:",$contextname));
+ $r->print(&mt("You do not have the authority to change this field given the user's current set of active/future $contextname roles:"));
} else {
- $r->print(&mt("You do not have the authority to change these fields given the user's current set of active/future [_1] roles:",$contextname));
+ $r->print(&mt("You do not have the authority to change these fields given the user's current set of active/future $contextname roles:"));
}
my $helplink = 'javascript:helpMenu('."'display'".')';
$r->print(''.$rolestr.' '
@@ -3008,18 +3178,21 @@ END
.&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('
');
+ }
+ return;
+}
+
sub tool_changes {
my ($context,$usertools,$oldaccess,$oldaccesstext,$userenv,$changeHash,
$changed,$newaccess,$newaccesstext) = @_;
@@ -3056,20 +3363,20 @@ sub tool_changes {
(ref($newaccess) eq 'HASH') && (ref($newaccesstext) eq 'HASH'))) {
return;
}
+ my %reqdisplay = &requestchange_display();
if ($context eq 'reqcrsotherdom') {
my @options = ('approval','validate','autolimit');
my $optregex = join('|',@options);
- my %reqdisplay = &courserequest_display();
my $cdom = $env{'request.role.domain'};
foreach my $tool (@{$usertools}) {
- $oldaccesstext->{$tool} = &mt('No');
+ $oldaccesstext->{$tool} = &mt("availability set to 'off'");
$newaccesstext->{$tool} = $oldaccesstext->{$tool};
$changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};
- my $newop;
+ my ($newop,$limit);
if ($env{'form.'.$context.'_'.$tool}) {
$newop = $env{'form.'.$context.'_'.$tool};
if ($newop eq 'autolimit') {
- my $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
+ $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
$limit =~ s/\D+//g;
$newop .= '='.$limit;
}
@@ -3079,7 +3386,15 @@ sub tool_changes {
$changed->{$tool}=&tool_admin($tool,$cdom.':'.$newop,
$changeHash,$context);
if ($changed->{$tool}) {
- $newaccesstext->{$tool} = &mt('Yes');
+ if ($newop =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } else {
+ $newaccesstext->{$tool} = $reqdisplay{$newop};
+ }
} else {
$newaccesstext->{$tool} = $oldaccesstext->{$tool};
}
@@ -3090,8 +3405,17 @@ sub tool_changes {
my $changedoms;
foreach my $req (@curr) {
if ($req =~ /^\Q$cdom\E\:($optregex\=?\d*)$/) {
- $oldaccesstext->{$tool} = &mt('Yes');
my $oldop = $1;
+ if ($oldop =~ /^autolimit=(\d*)/) {
+ my $limit = $1;
+ if ($limit) {
+ $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } else {
+ $oldaccesstext->{$tool} = $reqdisplay{$oldop};
+ }
if ($oldop ne $newop) {
$changedoms = 1;
foreach my $item (@curr) {
@@ -3125,15 +3449,15 @@ sub tool_changes {
my $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
$limit =~ s/\D+//g;
if ($limit) {
- $newaccesstext->{$tool} = &mt('Yes, up to limit of [quant,_1,request] per user.',$limit);
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
} else {
- $newaccesstext->{$tool} = &mt('Yes, processed automatically');
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
}
} else {
$newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}};
}
} else {
- $newaccesstext->{$tool} = &mt('No');
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
}
}
}
@@ -3142,40 +3466,89 @@ sub tool_changes {
return;
}
foreach my $tool (@{$usertools}) {
- my $newval;
+ my ($newval,$limit,$envkey);
+ $envkey = $context.'.'.$tool;
if ($context eq 'requestcourses') {
$newval = $env{'form.crsreq_'.$tool};
if ($newval eq 'autolimit') {
- $newval .= '='.$env{'form.crsreq_'.$tool.'_limit'};
- }
+ $limit = $env{'form.crsreq_'.$tool.'_limit'};
+ $limit =~ s/\D+//g;
+ $newval .= '='.$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}) {
- $oldaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($userenv->{$envkey} =~ /^autolimit=(\d*)$/) {
+ my $currlimit = $1;
+ if ($currlimit eq '') {
+ $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ } else {
+ $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$currlimit);
+ }
+ } elsif ($userenv->{$envkey}) {
+ $oldaccesstext->{$tool} = $reqdisplay{$userenv->{$envkey}};
+ } else {
+ $oldaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $oldaccesstext->{$tool} = &mt("availability set to 'off'");
+ 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}) {
$newaccess->{$tool} = &mt('custom');
- if ($newval) {
- $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($newval =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } elsif ($newval) {
+ $newaccesstext->{$tool} = $reqdisplay{$newval};
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($newval) {
+ $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'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($newval =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } elsif ($newval) {
+ $newaccesstext->{$tool} = $reqdisplay{$newval};
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($userenv->{$context.'.'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
}
}
} else {
@@ -3188,10 +3561,24 @@ sub tool_changes {
$newaccess->{$tool} = &mt('default');
} else {
$newaccess->{$tool} = $oldaccess->{$tool};
- if ($userenv->{$context.'.'.$tool}) {
- $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($newval =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } elsif ($newval) {
+ $newaccesstext->{$tool} = $reqdisplay{$newval};
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($userenv->{$context.'.'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
}
}
}
@@ -3202,10 +3589,24 @@ sub tool_changes {
$context);
if ($changed->{$tool}) {
$newaccess->{$tool} = &mt('custom');
- if ($newval) {
- $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($newval =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } elsif ($newval) {
+ $newaccesstext->{$tool} = $reqdisplay{$newval};
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($newval) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
}
} else {
$newaccess->{$tool} = $oldaccess->{$tool};
@@ -3219,7 +3620,7 @@ sub tool_changes {
}
sub update_roles {
- my ($r,$context) = @_;
+ my ($r,$context,$showcredits) = @_;
my $now=time;
my @rolechanges;
my %disallowed;
@@ -3236,14 +3637,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);
@@ -3251,11 +3658,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');
}
@@ -3269,14 +3680,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);
@@ -3285,11 +3703,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');
}
@@ -3305,27 +3729,38 @@ sub update_roles {
my $output;
if ($role eq 'st') {
if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
- my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
+ my ($cdom,$cnum,$csec) = ($1,$2,$3);
+ my $credits;
+ if ($showcredits) {
+ my $defaultcredits =
+ &Apache::lonuserutils::get_defaultcredits($cdom,$cnum);
+ $credits = &get_user_credits($defaultcredits,$cdom,$cnum);
+ }
+ my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$cdom,$cnum,$csec,$context,$credits);
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {
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);
@@ -3337,8 +3772,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');
}
@@ -3395,8 +3835,20 @@ sub update_roles {
# split multiple sections
my %sections = ();
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
+ my $credits;
+ if ($three eq 'st') {
+ if ($showcredits) {
+ my $defaultcredits =
+ &Apache::lonuserutils::get_defaultcredits($one,$two);
+ $credits = $env{'form.credits_'.$one.'_'.$two.'_'.$three};
+ $credits =~ s/[^\d\.]//g;
+ if ($credits eq $defaultcredits) {
+ undef($credits);
+ }
+ }
+ }
if ($num_sections == 0) {
- $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
} else {
my %curr_groups =
&Apache::longroup::coursegroups($one,$two);
@@ -3410,13 +3862,13 @@ sub update_roles {
next;
}
my $securl = $url.'/'.$sec;
- $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context,$credits));
} else {
$emptysec = 1;
}
}
if ($emptysec) {
- $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
}
}
if (!grep(/^\Q$three\E$/,@rolechanges)) {
@@ -3476,15 +3928,38 @@ 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'));
+ $r->print('
'.&mt('No roles to modify').'
');
}
return @rolechanges;
}
+sub get_user_credits {
+ my ($uname,$udom,$defaultcredits,$cdom,$cnum) = @_;
+ if ($cdom eq '' || $cnum eq '') {
+ return unless ($env{'request.course.id'});
+ $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ }
+ my $credits;
+ my %currhash =
+ &Apache::lonnet::get('classlist',[$uname.':'.$udom],$cdom,$cnum);
+ if (keys(%currhash) > 0) {
+ my @items = split(/:/,$currhash{$uname.':'.$udom});
+ my $crdidx = &Apache::loncoursedata::CL_CREDITS() - 3;
+ $credits = $items[$crdidx];
+ $credits =~ s/[^\d\.]//g;
+ }
+ if ($credits eq $defaultcredits) {
+ undef($credits);
+ }
+ return $credits;
+}
+
sub enroll_single_student {
- my ($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype) = @_;
+ my ($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype,
+ $showcredits,$defaultcredits) = @_;
$r->print('
');
if ($crstype eq 'Community') {
$r->print(&mt('Enrolling Member'));
@@ -3496,6 +3971,17 @@ sub enroll_single_student {
# Remove non alphanumeric values from section
$env{'form.sections'}=~s/\W//g;
+ my $credits;
+ if (($showcredits) && ($env{'form.credits'} ne '')) {
+ $credits = $env{'form.credits'};
+ $credits =~ s/[^\d\.]//g;
+ if ($credits ne '') {
+ if ($credits eq $defaultcredits) {
+ undef($credits);
+ }
+ }
+ }
+
# Clean out any old student roles the user has in this class.
&Apache::lonuserutils::modifystudent($env{'form.ccdomain'},
$env{'form.ccuname'},$env{'request.course.id'},undef,$uhome);
@@ -3505,9 +3991,10 @@ sub enroll_single_student {
$env{'form.ccuname'},$env{'form.cid'},$env{'form.cfirstname'},
$env{'form.cmiddlename'},$env{'form.clastname'},
$env{'form.generation'},$env{'form.sections'},$enddate,
- $startdate,'manual',undef,$env{'request.course.id'},'',$context);
+ $startdate,'manual',undef,$env{'request.course.id'},'',$context,
+ $credits);
if ($enroll_result =~ /^ok/) {
- $r->print(&mt('[_1] enrolled',$env{'form.ccuname'}.':'.$env{'form.ccdomain'}));
+ $r->print(&mt('[_1] enrolled',''.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.''));
if ($env{'form.sections'} ne '') {
$r->print(' '.&mt('in section [_1]',$env{'form.sections'}));
}
@@ -3524,11 +4011,11 @@ sub enroll_single_student {
}
$r->print('. '.$showstart.'; '.$showend);
if ($startdate <= $now && !$newuser) {
- $r->print('
');
+ $r->print('
');
if ($crstype eq 'Community') {
- $r->print(&mt('If the member is currently logged-in to LON-CAPA, the new role will be available when the member next logs in.'));
+ $r->print(&mt('If the member is currently logged-in to LON-CAPA, the new role can be displayed by using the "Check for changes" link on the Roles/Courses page.'));
} else {
- $r->print(&mt('If the student is currently logged-in to LON-CAPA, the new role will be available when the student next logs in.'));
+ $r->print(&mt('If the student is currently logged-in to LON-CAPA, the new role can be displayed by using the "Check for changes" link on the Roles/Courses page.'));
}
$r->print('
');
}
@@ -3542,14 +4029,14 @@ sub get_defaultquota_text {
my ($settingstatus) = @_;
my $defquotatext;
if ($settingstatus eq '') {
- $defquotatext = &mt('(default)');
+ $defquotatext = &mt('default');
} else {
my ($usertypes,$order) =
&Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'});
if ($usertypes->{$settingstatus} eq '') {
- $defquotatext = &mt('(default)');
+ $defquotatext = &mt('default');
} else {
- $defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus});
+ $defquotatext = &mt('default for [_1]',$usertypes->{$settingstatus});
}
}
return $defquotatext;
@@ -3558,7 +4045,7 @@ sub get_defaultquota_text {
sub update_result_form {
my ($uhome) = @_;
my $outcome =
- ''."\n";
+ '';
return $outcome;
}
sub quota_admin {
- my ($setquota,$changeHash) = @_;
+ my ($setquota,$changeHash,$name) = @_;
my $quotachanged;
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
# Current user has quota modification privileges
if (ref($changeHash) eq 'HASH') {
$quotachanged = 1;
- $changeHash->{'portfolioquota'} = $setquota;
+ $changeHash->{$name.'quota'} = $setquota;
}
}
return $quotachanged;
@@ -3604,6 +4091,10 @@ sub tool_admin {
if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
$canchange = 1;
}
+ } elsif ($context eq 'requestauthor') {
+ if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) {
+ $canchange = 1;
+ }
} elsif (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
# Current user has quota modification privileges
$canchange = 1;
@@ -3612,7 +4103,11 @@ sub tool_admin {
if ($canchange) {
if (ref($changeHash) eq 'HASH') {
$toolchanged = 1;
- $changeHash->{$context.'.'.$tool} = $settool;
+ if ($tool eq 'requestauthor') {
+ $changeHash->{$context} = $settool;
+ } else {
+ $changeHash->{$context.'.'.$tool} = $settool;
+ }
}
}
return $toolchanged;
@@ -3677,13 +4172,7 @@ sub custom_role_editor {
&print_username_entry_form($r,undef,undef,undef,undef,$crstype,$brcrum);
return;
}
- my $is_custom = &Apache::loncommon::needs_gci_custom();
- my $title = 'User Management';
- if ($context eq 'course') {
- if ($is_custom) {
- $title = 'Enrollment and Student Activity';
- }
- }
+
# ------------------------------------------------------- What can be assigned?
my %full=();
my %courselevel=();
@@ -3692,6 +4181,7 @@ sub custom_role_editor {
my $dompriv='';
my $coursepriv='';
my $body_top;
+ my $newrole;
my ($rdummy,$roledef)=
&Apache::lonnet::get('roles',["rolesdef_$rolename"]);
# ------------------------------------------------------- Does this role exist?
@@ -3704,6 +4194,7 @@ sub custom_role_editor {
$syspriv =~ s/bre\&S//;
}
} else {
+ $newrole = 1;
$body_top .= &mt('New Role').' "';
$roledef='';
}
@@ -3830,7 +4321,7 @@ sub custom_role_editor {
$r->print(' ');
$r->print(<
+');
+ $result =
+ &Apache::lonnet::assigncustomrole(
+ $env{'user.domain'},$env{'user.name'},
+ $url,
+ $env{'user.domain'},$env{'user.name'},
+ $rolename,undef,undef,undef,$context);
+ if ($result ne 'ok') {
+ $errmsg = ': '.$result;
+ }
+ $message .=
+ ' '
+ .&Apache::lonhtmlcommon::confirm_success(
+ &mt('Assigning Role to Self').$errmsg, ($result eq 'ok' ? 0 : 1));
+ }
+ $r->print(
+ &Apache::loncommon::confirmwrapper($message)
+ .' '
+ .&Apache::lonhtmlcommon::actionbox([
+ ''
+ .&mt('Create or edit another custom role')
+ .''])
+ .''
+ );
}
# ================================================================ Main Handler
@@ -4055,9 +4563,29 @@ sub handler {
} else {
$context = 'domain';
}
- my ($permission,$allowed) =
+
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['action','state','callingform','roletype','showrole','bulkaction','popup','phase',
+ 'username','domain','srchterm','srchdomain','srchin','srchby','srchtype','queue']);
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ my $args;
+ my $brcrum = [];
+ my $bread_crumbs_component = 'User Management';
+ if (($env{'form.action'} ne 'dateselect') && ($env{'form.action'} ne 'displayuserreq')) {
+ $brcrum = [{href=>"/adm/createuser",
+ text=>"User Management",
+ help=>'Course_Create_Class_List,Course_Change_Privileges,Course_View_Class_List,Course_Editing_Custom_Roles,Course_Add_Student,Course_Drop_Student,Course_Automated_Enrollment,Course_Self_Enrollment,Course_Manage_Group'}
+ ];
+ }
+ #SD Following files not added to help, because the corresponding .tex-files seem to
+ #be missing: Course_Approve_Selfenroll,Course_User_Logs,
+ my ($permission,$allowed) =
&Apache::lonuserutils::get_permission($context,$crstype);
if (!$allowed) {
+ if ($context eq 'course') {
+ $r->internal_redirect('/adm/viewclasslist');
+ return OK;
+ }
$env{'user.error.msg'}=
"/adm/createuser:cst:0:0:Cannot create/modify user data ".
"or view user status.";
@@ -4067,89 +4595,48 @@ sub handler {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
- my $title = 'User Management';
- my $is_custom = &Apache::loncommon::needs_gci_custom();
- if ($context eq 'course') {
- if ($is_custom) {
- $title = 'Enrollment and Student Activity';
+ my $showcredits;
+ if ((($context eq 'course') && ($crstype eq 'Course')) ||
+ ($context eq 'domain')) {
+ my %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'request.role.domain'});
+ if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) {
+ $showcredits = 1;
}
}
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['action','state','callingform','roletype','showrole','bulkaction','popup','phase',
- 'username','domain','srchterm','srchdomain','srchin','srchby','srchtype']);
- &Apache::lonhtmlcommon::clear_breadcrumbs();
- my $args;
- my $brcrum = [];
- my $bread_crumbs_component = $title;
- if ($env{'form.context'} eq 'requestcrs') {
- my $reqstate = 'uploadroster';
- if ($env{'form.state'} eq 'enrolling') {
- $reqstate = 'enrolling';
- }
- unless (&Apache::lonrequestcourse::generate_page($r,'new',$reqstate)) {
- return OK;
- }
- } elsif ($env{'form.action'} ne 'dateselect') {
- $brcrum = [{href=>"/adm/createuser",
- text=>$title,
- help=>'Course_Create_Class_List,Course_Change_Privileges,Course_View_Class_List,Course_Editing_Custom_Roles,Course_Add_Student,Course_Drop_Student,Course_Automated_Enrollment,Course_Self_Enrollment,Course_Manage_Group'}
- ];
- }
- #SD Following files not added to help, because the corresponding .tex-files seem to
- #be missing: Course_Approve_Selfenroll,Course_User_Logs,
# Main switch on form.action and form.state, as appropriate
if (! exists($env{'form.action'})) {
$args = {bread_crumbs => $brcrum,
- bread_crumbs_component => $bread_crumbs_component};
+ bread_crumbs_component => $bread_crumbs_component};
$r->print(&header(undef,$args));
$r->print(&print_main_menu($permission,$context,$crstype));
} elsif ($env{'form.action'} eq 'upload' && $permission->{'cusr'}) {
- unless ($env{'form.context'} eq 'requestcrs') {
- push(@{$brcrum},
- { href => '/adm/createuser?action=upload&state=',
- text => 'Upload Users List',
- help => 'Course_Create_Class_List',
- });
- $bread_crumbs_component = 'Upload Users List';
- $args = {bread_crumbs => $brcrum,
- bread_crumbs_component => $bread_crumbs_component};
- $r->print(&header(undef,$args));
- }
- unless (($env{'form.context'} eq 'requestcrs') && ($env{'form.state'} eq 'enrolling')) {
- $r->print('');
} elsif ((($env{'form.action'} eq 'singleuser') || ($env{'form.action'}
eq 'singlestudent')) && ($permission->{'cusr'})) {
my $phase = $env{'form.phase'};
@@ -4164,15 +4651,21 @@ sub handler {
if ($env{'form.phase'} eq 'createnewuser') {
my $response;
if ($env{'form.srchterm'} !~ /^$match_username$/) {
- my $response = '
'.&mt('You must specify a valid username. Only the following are allowed: letters numbers - . @').'
';
+ my $response =
+ ''
+ .&mt('You must specify a valid username. Only the following are allowed:'
+ .' letters numbers - . @')
+ .'';
$env{'form.phase'} = '';
- &print_username_entry_form($r,$context,$response,$srch,undef,$crstype,$brcrum);
+ &print_username_entry_form($r,$context,$response,$srch,undef,
+ $crstype,$brcrum,$showcredits);
} else {
my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'});
my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'});
&print_user_modification_page($r,$ccuname,$ccdomain,
$srch,$response,$context,
- $permission,$crstype);
+ $permission,$crstype,$brcrum,
+ $showcredits);
}
} elsif ($env{'form.phase'} eq 'get_user_info') {
my ($currstate,$response,$forcenewuser,$results) =
@@ -4182,7 +4675,8 @@ sub handler {
}
if ($currstate eq 'select') {
&print_user_selection_page($r,$response,$srch,$results,
- \@search,$context,undef,$crstype);
+ \@search,$context,undef,$crstype,
+ $brcrum);
} elsif ($currstate eq 'modify') {
my ($ccuname,$ccdomain);
if (($srch->{'srchby'} eq 'uname') &&
@@ -4212,12 +4706,14 @@ sub handler {
my $ccuname = &LONCAPA::clean_username($env{'form.seluname'});
my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'});
&print_user_modification_page($r,$ccuname,$ccdomain,$srch,'',
- $context,$permission,$crstype,$brcrum);
+ $context,$permission,$crstype,
+ $brcrum);
}
} elsif ($env{'form.phase'} eq 'update_user_data') {
- &update_user_data($r,$context,$crstype,$brcrum);
+ &update_user_data($r,$context,$crstype,$brcrum,$showcredits);
} else {
- &print_username_entry_form($r,$context,undef,$srch,undef,$crstype,$brcrum);
+ &print_username_entry_form($r,$context,undef,$srch,undef,$crstype,
+ $brcrum);
}
} elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) {
if ($env{'form.phase'} eq 'set_custom_roles') {
@@ -4225,6 +4721,151 @@ sub handler {
} else {
&custom_role_editor($r,$brcrum);
}
+ } elsif (($env{'form.action'} eq 'processauthorreq') &&
+ ($permission->{'cusr'}) &&
+ (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) {
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=processauthorreq',
+ text => 'Authoring Space requests',
+ help => 'Domain_Role_Approvals'});
+ $bread_crumbs_component = 'Authoring requests';
+ if ($env{'form.state'} eq 'done') {
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=authorreqqueue',
+ text => 'Result',
+ help => 'Domain_Role_Approvals'});
+ $bread_crumbs_component = 'Authoring request result';
+ }
+ $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ my $js = &usernamerequest_javascript();
+ $r->print(&header(&add_script($js),$args));
+ if (!exists($env{'form.state'})) {
+ $r->print(&Apache::loncoursequeueadmin::display_queued_requests('requestauthor',
+ $env{'request.role.domain'}));
+ } elsif ($env{'form.state'} eq 'done') {
+ $r->print('