--- loncom/interface/loncreateuser.pm 2013/03/01 04:55:34 1.375 +++ loncom/interface/loncreateuser.pm 2016/09/27 21:47:48 1.413 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.375 2013/03/01 04:55:34 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.413 2016/09/27 21:47:48 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -122,66 +122,40 @@ sub auth_abbrev { # ==================================================== -sub portfolio_quota { +sub user_quotas { my ($ccuname,$ccdomain) = @_; my %lt = &Apache::lonlocal::texthash( 'usrt' => "User Tools", - 'disk' => "Disk space allocated to user's portfolio files", - 'cuqu' => "Current quota", 'cust' => "Custom quota", - 'defa' => "Default", 'chqu' => "Change quota", ); - my ($currquota,$quotatype,$inststatus,$defquota) = - &Apache::loncommon::get_user_quota($ccuname,$ccdomain); - my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain); - my ($longinsttype,$showquota,$custom_on,$custom_off,$defaultinfo); - if ($inststatus ne '') { - if ($usertypes->{$inststatus} ne '') { - $longinsttype = $usertypes->{$inststatus}; - } - } - $custom_on = ' '; - $custom_off = ' checked="checked" '; + my $quota_javascript = <<"END_SCRIPT"; END_SCRIPT - if ($quotatype eq 'custom') { - $custom_on = $custom_off; - $custom_off = ' '; - $showquota = $currquota; - if ($longinsttype eq '') { - $defaultinfo = &mt('For this user, the default quota would be [_1]' - .' Mb.',$defquota); - } else { - $defaultinfo = &mt("For this user, the default quota would be [_1]". - " Mb, as determined by the user's institutional". - " affiliation ([_2]).",$defquota,$longinsttype); - } - } else { - if ($longinsttype eq '') { - $defaultinfo = &mt('For this user, the default quota is [_1]' - .' Mb.',$defquota); - } else { - $defaultinfo = &mt("For this user, the default quota of [_1]". - " Mb, is determined by the user's institutional". - " affiliation ([_2]).",$defquota,$longinsttype); - } - } - + my $longinsttype; + my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain); my $output = $quota_javascript."\n". '

'.$lt{'usrt'}.'

'."\n". &Apache::loncommon::start_data_table(); @@ -189,29 +163,72 @@ END_SCRIPT if (&Apache::lonnet::allowed('mut',$ccdomain)) { $output .= &build_tools_display($ccuname,$ccdomain,'tools'); } - if (&Apache::lonnet::allowed('mpq',$ccdomain)) { - $output .= ''."\n". - ' '.$lt{'disk'}.''."\n". - ' '."\n". - &Apache::loncommon::start_data_table_row()."\n". - ' '.$lt{'cuqu'}.': '. - $currquota.' Mb.  '. - $defaultinfo.''."\n". - &Apache::loncommon::end_data_table_row()."\n". - &Apache::loncommon::start_data_table_row()."\n". - ' '.$lt{'chqu'}. - ':  '. - '  '. - ' Mb'."\n". - &Apache::loncommon::end_data_table_row()."\n"; - } + + my %titles = &Apache::lonlocal::texthash ( + portfolio => "Disk space allocated to user's portfolio files", + author => "Disk space allocated to user's Authoring Space (if role assigned)", + ); + foreach my $name ('portfolio','author') { + my ($currquota,$quotatype,$inststatus,$defquota) = + &Apache::loncommon::get_user_quota($ccuname,$ccdomain,$name); + if ($longinsttype eq '') { + if ($inststatus ne '') { + if ($usertypes->{$inststatus} ne '') { + $longinsttype = $usertypes->{$inststatus}; + } + } + } + my ($showquota,$custom_on,$custom_off,$defaultinfo); + $custom_on = ' '; + $custom_off = ' checked="checked" '; + if ($quotatype eq 'custom') { + $custom_on = $custom_off; + $custom_off = ' '; + $showquota = $currquota; + if ($longinsttype eq '') { + $defaultinfo = &mt('For this user, the default quota would be [_1]' + .' MB.',$defquota); + } else { + $defaultinfo = &mt("For this user, the default quota would be [_1]". + " MB, as determined by the user's institutional". + " affiliation ([_2]).",$defquota,$longinsttype); + } + } else { + if ($longinsttype eq '') { + $defaultinfo = &mt('For this user, the default quota is [_1]' + .' MB.',$defquota); + } else { + $defaultinfo = &mt("For this user, the default quota of [_1]". + " MB, is determined by the user's institutional". + " affiliation ([_2]).",$defquota,$longinsttype); + } + } + + if (&Apache::lonnet::allowed('mpq',$ccdomain)) { + $output .= ''."\n". + ' '.$titles{$name}.''."\n". + ' '."\n". + &Apache::loncommon::start_data_table_row()."\n". + ' '. + &mt('Current quota: [_1] MB',$currquota).'  '. + $defaultinfo.''."\n". + &Apache::loncommon::end_data_table_row()."\n". + &Apache::loncommon::start_data_table_row()."\n". + ' '.$lt{'chqu'}. + ':  '. + '  '. + ' '.&mt('MB').''."\n". + &Apache::loncommon::end_data_table_row()."\n"; + } + } $output .= &Apache::loncommon::end_data_table(); return $output; } @@ -223,7 +240,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)", + 'webdav' => "WebDAV access to Authoring Spaces (if SSL and author/co-author)", 'portfolio' => "Personal User Portfolio", 'avai' => "Available", 'cusa' => "availability", @@ -233,13 +250,16 @@ sub build_tools_display { 'official' => 'Can request creation of official courses', 'unofficial' => 'Can request creation of unofficial courses', 'community' => 'Can request creation of communities', + 'textbook' => 'Can request creation of textbook courses', + 'placement' => 'Can request creation of placement tests', 'requestauthor' => 'Can request author space', ); if ($context eq 'requestcourses') { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'requestcourses.official','requestcourses.unofficial', - 'requestcourses.community'); - @usertools = ('official','unofficial','community'); + 'requestcourses.community','requestcourses.textbook', + 'requestcourses.placement'); + @usertools = ('official','unofficial','community','textbook','placement'); @options =('norequest','approval','autolimit','validate'); %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain); %reqtitles = &courserequest_titles(); @@ -428,12 +448,15 @@ sub coursereq_externaluser { 'official' => 'Can request creation of official courses', 'unofficial' => 'Can request creation of unofficial courses', 'community' => 'Can request creation of communities', + 'textbook' => 'Can request creation of textbook courses', + 'placement' => 'Can request creation of placement tests', ); %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'reqcrsotherdom.official','reqcrsotherdom.unofficial', - 'reqcrsotherdom.community'); - @usertools = ('official','unofficial','community'); + 'reqcrsotherdom.community','reqcrsotherdom.textbook', + 'reqcrsotherdom.placement'); + @usertools = ('official','unofficial','community','textbook','placement'); @options = ('approval','validate','autolimit'); %validations = &Apache::lonnet::auto_courserequest_checks($cdom); my $optregex = join('|',@options); @@ -513,6 +536,8 @@ sub courserequest_titles { official => 'Official', unofficial => 'Unofficial', community => 'Communities', + textbook => 'Textbook', + placement => 'Placement Tests', norequest => 'Not allowed', approval => 'Approval by Dom. Coord.', validate => 'With validation', @@ -550,6 +575,15 @@ sub requestauthor_display { 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')); @@ -784,7 +818,7 @@ sub entry_form { } my $cancreate = &Apache::lonuserutils::can_create_user($dom,$context,$usertype); - my $userpicker = + my ($userpicker,$cansearch) = &Apache::loncommon::user_picker($dom,$srch,$forcenewuser, 'document.crtuser',$cancreate,$usertype); my $srchbutton = &mt('Search'); @@ -793,7 +827,9 @@ sub entry_form { } elsif ($cancreate && $responsemsg ne '' && $inexact) { $srchbutton = &mt('Search or Add New User'); } - my $output = <<"ENDBLOCK"; + my $output; + if ($cansearch) { + $output = <<"ENDBLOCK";
@@ -801,6 +837,9 @@ $userpicker
ENDBLOCK + } else { + $output = '

'.$userpicker.'

'; + } if ($env{'form.phase'} eq '') { my $defdom=$env{'request.role.domain'}; my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain'); @@ -970,7 +1009,7 @@ ENDSCRIPT $r->print(''); } } - $r->print('
'. + $r->print(''. &Apache::loncommon::start_data_table()."\n". &Apache::loncommon::start_data_table_header_row()."\n". ' '."\n"); @@ -1200,22 +1239,20 @@ ENDFORMINFO } } } + my $title = ''; if ($newuser) { my ($portfolioform,$domroleform); if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) || (&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) { # Current user has quota or user tools modification privileges - $portfolioform = '
'.&portfolio_quota($ccuname,$ccdomain); + $portfolioform = '
'.&user_quotas($ccuname,$ccdomain); } - if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) { + if ((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) && + ($ccdomain eq $env{'request.role.domain'})) { $domroleform = '
'.&domainrole_req($ccuname,$ccdomain); } &initialize_authen_forms($ccdomain,$formname); my %lt=&Apache::lonlocal::texthash( - 'cnu' => 'Create New User', - 'ast' => 'as a student', - 'ame' => 'as a member', - 'ind' => 'in domain', 'lg' => 'Login Data', 'hs' => "Home Server", ); @@ -1229,20 +1266,24 @@ $loginscript // ]]> -

$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('

'."\n".'
'); - my $personal_table = - &personal_data_display($ccuname,$ccdomain,$newuser,$context, - $inst_results{$ccuname.':'.$ccdomain}); - $r->print($personal_table); + $r->print('

'.$title.'

'."\n"); + $r->print('
'); + $r->print(&personal_data_display($ccuname,$ccdomain,$newuser,$context, + $inst_results{$ccuname.':'.$ccdomain})); + # Option to disable student/employee ID conflict checking not offerred for new users. my ($home_server_pick,$numlib) = &Apache::loncommon::home_server_form_item($ccdomain,'hserver', 'default','hide'); @@ -1328,35 +1369,23 @@ ENDAUTH } $r->print('
'); } else { # user already exists - my %lt=&Apache::lonlocal::texthash( - 'cup' => "Modify existing user: ", - 'ens' => "Enroll one student: ", - 'enm' => "Enroll one member: ", - 'id' => "in domain", - ); - $r->print(< -ENDCHANGEUSER + $r->print($start_page.$forminfo); if ($env{'form.action'} eq 'singlestudent') { if ($crstype eq 'Community') { - $r->print($lt{'enm'}); + $title = &mt('Enroll one member: [_1] in domain [_2]', + '"'.$ccuname.'"','"'.$ccdomain.'"'); } else { - $r->print($lt{'ens'}); + $title = &mt('Enroll one student: [_1] in domain [_2]', + '"'.$ccuname.'"','"'.$ccdomain.'"'); } } else { - $r->print($lt{'cup'}); - } - $r->print(' "'.$ccuname.'" '.$lt{'id'}.' "'.$ccdomain.'"'. - "\n".'
'); - my ($personal_table,$showforceid) = - &personal_data_display($ccuname,$ccdomain,$newuser,$context, - $inst_results{$ccuname.':'.$ccdomain}); - $r->print($personal_table); - if ($showforceid) { - $r->print(''.&Apache::lonuserutils::forceid_change($context).'
'); + $title = &mt('Modify existing user: [_1] in domain [_2]', + '"'.$ccuname.'"','"'.$ccdomain.'"'); } + $r->print('

'.$title.'

'."\n"); + $r->print('
'); + $r->print(&personal_data_display($ccuname,$ccdomain,$newuser,$context, + $inst_results{$ccuname.':'.$ccdomain})); if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { $r->print('

'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'

'. &Apache::loncommon::start_data_table()); @@ -1374,23 +1403,21 @@ ENDCHANGEUSER my ($isadv,$isauthor) = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain); if ((!$isauthor) && - (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) { + (&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_text{'quota'} = &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_text{'quota'} = <print('
'."\n"); } else { - $r->print('
'.&mt('Add Roles').''); + $r->print('
'. + '
'.&mt('Add Roles').''); my $addrolesdisplay = 0; if ($context eq 'domain' || $context eq 'author') { $addrolesdisplay = &new_coauthor_roles($r,$ccuname,$ccdomain); @@ -1465,27 +1493,32 @@ ENDNOTOOLSPRIV $addrolesdisplay = $add_domainroles; } $r->print(&course_level_dc($env{'request.role.domain'},$showcredits)); - $r->print('

'."\n"); + $r->print('
'. + '
'."\n"); } elsif ($context eq 'author') { if ($addrolesdisplay) { - $r->print('
print('
'. + '
print(' onclick="auth_check()" \>'."\n"); } else { $r->print('onclick="this.form.submit()" \>'."\n"); } } else { - $r->print('
'. + $r->print('
'. + ''. + '
'. &mt('Back to previous page').''); } } else { $r->print(&course_level_table(\%inccourses,$showcredits,$defaultcredits)); - $r->print('
'."\n"); + $r->print(''. + '
'."\n"); } } $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain'])); $r->print(''); - $r->print('
'); + $r->print('

'); return; } @@ -1739,7 +1772,7 @@ sub display_existing_roles { } } if ($role_code eq 'ca' || $role_code eq 'au' || $role_code eq 'aa') { - $class='Construction Space'; + $class='Authoring Space'; } elsif ($role_code eq 'su') { $class='System'; } else { @@ -1790,7 +1823,7 @@ sub display_existing_roles { } } else { $plaintext= - &mt('Customrole [_1][_2]defined by [_3]', + &mt('Custom role [_1][_2]defined by [_3]', '"'.$croletitle.'"', '
', $croleuname.':'.$croleudom); @@ -1810,7 +1843,7 @@ sub display_existing_roles { my $rolesdisplay = 0; my %output = (); - foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') { + foreach my $type ('Authoring Space','Course','Community','Domain','System','Unknown') { $output{$type} = ''; foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) { if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) { @@ -1836,11 +1869,11 @@ sub display_existing_roles { $contextrole = &mt('Existing Roles in this Course'); } } elsif ($env{'request.role'} =~ /^au\./) { - $contextrole = &mt('Existing Co-Author Roles in your Construction Space'); + $contextrole = &mt('Existing Co-Author Roles in your Authoring Space'); } else { $contextrole = &mt('Existing Roles in this Domain'); } - $r->print('
'. + $r->print('
'. '
'.$contextrole.''. &Apache::loncommon::start_data_table("LC_createuser"). &Apache::loncommon::start_data_table_header_row(). @@ -1848,7 +1881,7 @@ sub display_existing_roles { ''.$lt{'rol'}.''.$lt{'ext'}. ''.$lt{'sta'}.''.$lt{'end'}.''. &Apache::loncommon::end_data_table_header_row()); - foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') { + foreach my $type ('Authoring Space','Course','Community','Domain','System','Unknown') { if ($output{$type}) { $r->print($output{$type}."\n"); } @@ -1873,7 +1906,7 @@ sub new_coauthor_roles { my $cuname=$env{'user.name'}; my $cudom=$env{'request.role.domain'}; my %lt=&Apache::lonlocal::texthash( - 'cs' => "Construction Space", + 'cs' => "Authoring Space", 'act' => "Activate", 'rol' => "Role", 'ext' => "Extent", @@ -1924,7 +1957,7 @@ sub new_coauthor_roles { ''); } elsif (($env{'user.name'} eq $ccuname) && ($env{'user.domain'} eq $ccdomain)) { - $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Construction Space is not permitted')); + $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Authoring Space is not permitted')); } } return $addrolesdisplay;; @@ -2140,13 +2173,37 @@ sub modify_login_block { } sub personal_data_display { - my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray) = @_; - my ($output,$showforceid,%userenv,%canmodify,%canmodify_status); + my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray, + $now,$captchaform,$emailusername,$usertype) = @_; + my ($output,%userenv,%canmodify,%canmodify_status); my @userinfo = ('firstname','middlename','lastname','generation', 'permanentemail','id'); my $rowcount = 0; my $editable = 0; - %canmodify_status = + my %textboxsize = ( + firstname => '15', + middlename => '15', + lastname => '15', + generation => '5', + permanentemail => '25', + id => '15', + ); + + my %lt=&Apache::lonlocal::texthash( + 'pd' => "Personal Data", + 'firstname' => "First Name", + 'middlename' => "Middle Name", + 'lastname' => "Last Name", + 'generation' => "Generation", + 'permanentemail' => "Permanent e-mail address", + 'id' => "Student/Employee ID", + 'lg' => "Login Data", + 'inststatus' => "Affiliation", + 'email' => 'E-mail address', + 'valid' => 'Validation', + ); + + %canmodify_status = &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain, ['inststatus'],$rolesarray); if (!$newuser) { @@ -2158,31 +2215,58 @@ sub personal_data_display { &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain, \@userinfo,$rolesarray); } elsif ($context eq 'selfcreate') { - %canmodify = &selfcreate_canmodify($context,$ccdomain,\@userinfo, - $inst_results,$rolesarray); + if ($newuser eq 'email') { + if (ref($emailusername) eq 'HASH') { + if (ref($emailusername->{$usertype}) eq 'HASH') { + my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info(); + @userinfo = (); + if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) { + foreach my $field (@{$infofields}) { + if ($emailusername->{$usertype}->{$field}) { + push(@userinfo,$field); + $canmodify{$field} = 1; + unless ($textboxsize{$field}) { + $textboxsize{$field} = 25; + } + unless ($lt{$field}) { + $lt{$field} = $infotitles->{$field}; + } + if ($emailusername->{$usertype}->{$field} eq 'required') { + $lt{$field} .= '*'; + } + } + } + } + } + } + } else { + %canmodify = &selfcreate_canmodify($context,$ccdomain,\@userinfo, + $inst_results,$rolesarray); + } } - my %lt=&Apache::lonlocal::texthash( - 'pd' => "Personal Data", - 'firstname' => "First Name", - 'middlename' => "Middle Name", - 'lastname' => "Last Name", - 'generation' => "Generation", - 'permanentemail' => "Permanent e-mail address", - 'id' => "Student/Employee ID", - 'lg' => "Login Data", - 'inststatus' => "Affiliation", - ); - my %textboxsize = ( - firstname => '15', - middlename => '15', - lastname => '15', - generation => '5', - permanentemail => '25', - id => '15', - ); + my $genhelp=&Apache::loncommon::help_open_topic('Generation'); $output = '

'.$lt{'pd'}.'

'. &Apache::lonhtmlcommon::start_pick_box(); + if (($context eq 'selfcreate') && ($newuser eq 'email')) { + $output .= &Apache::lonhtmlcommon::row_title($lt{'email'}.'*',undef, + 'LC_oddrow_value')."\n". + ''; + $rowcount ++; + $output .= &Apache::lonhtmlcommon::row_closure(1); + my $upassone = ''; + my $upasstwo = ''; + $output .= &Apache::lonhtmlcommon::row_title(&mt('Password').'*', + 'LC_pick_box_title', + 'LC_oddrow_value')."\n". + $upassone."\n". + &Apache::lonhtmlcommon::row_closure(1)."\n". + &Apache::lonhtmlcommon::row_title(&mt('Confirm password').'*', + 'LC_pick_box_title', + 'LC_oddrow_value')."\n". + $upasstwo. + &Apache::lonhtmlcommon::row_closure()."\n"; + } foreach my $item (@userinfo) { my $rowtitle = $lt{$item}; my $hiderow = 0; @@ -2196,8 +2280,8 @@ sub personal_data_display { $row .= ''.$inst_results->{$item}; } else { if ($context eq 'selfcreate') { - if ($canmodify{$item}) { - $row .= ''; + if ($canmodify{$item}) { + $row .= ''; $editable ++; } else { $hiderow = 1; @@ -2208,15 +2292,15 @@ sub personal_data_display { } } else { if ($context eq 'selfcreate') { - if (($item eq 'permanentemail') && ($newuser eq 'email')) { - $row .= $ccuname; - } else { - if ($canmodify{$item}) { - $row .= ''; - $editable ++; + if ($canmodify{$item}) { + if ($newuser eq 'email') { + $row .= ''; } else { - $hiderow = 1; + $row .= ''; } + $editable ++; + } else { + $hiderow = 1; } } else { $row .= ''; @@ -2225,12 +2309,12 @@ sub personal_data_display { } else { if ($canmodify{$item}) { $row .= ''; + if (($item eq 'id') && (!$newuser)) { + $row .= '
'.&Apache::lonuserutils::forceid_change($context); + } } else { $row .= $userenv{$item}; } - if ($item eq 'id') { - $showforceid = $canmodify{$item}; - } } $row .= &Apache::lonhtmlcommon::row_closure(1); if (!$hiderow) { @@ -2265,7 +2349,7 @@ sub personal_data_display { } } if (!$hiderow) { - my $row = &Apache::lonhtmlcommon::row_title(&mt('Affliations'),undef,'LC_oddrow_value')."\n". + my $row = &Apache::lonhtmlcommon::row_title(&mt('Affiliations'),undef,'LC_oddrow_value')."\n". $shown.&Apache::lonhtmlcommon::row_closure(1); if ($context eq 'selfcreate') { $rowcount ++; @@ -2275,12 +2359,27 @@ sub personal_data_display { } } } + if (($context eq 'selfcreate') && ($newuser eq 'email')) { + if ($captchaform) { + $output .= &Apache::lonhtmlcommon::row_title($lt{'valid'}.'*', + 'LC_pick_box_title')."\n". + $captchaform."\n".'

'. + &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; @@ -2445,9 +2544,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; } } @@ -2487,7 +2589,7 @@ sub update_user_data { my (%alerts,%rulematch,%inst_results,%curr_rules); my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); my @usertools = ('aboutme','blog','webdav','portfolio'); - my @requestcourses = ('official','unofficial','community'); + my @requestcourses = ('official','unofficial','community','textbook','placement'); my @requestauthor = ('requestauthor'); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'}); @@ -2557,14 +2659,18 @@ sub update_user_data { my (%changeHash,%newcustom,%changed,%changedinfo); if ($uhome ne 'no_host') { if ($context eq 'domain') { - if ($env{'form.customquota'} == 1) { - if ($env{'form.portfolioquota'} eq '') { - $newcustom{'quota'} = 0; - } else { - $newcustom{'quota'} = $env{'form.portfolioquota'}; - $newcustom{'quota'} =~ s/[^\d\.]//g; + 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) { @@ -2578,7 +2684,8 @@ sub update_user_data { $newcustom{$item} = $env{'form.crsreq_'.$item}; if ($env{'form.crsreq_'.$item} eq 'autolimit') { $newcustom{$item} .= '='; - unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) { + $env{'form.crsreq_'.$item.'_limit'} =~ s/\D+//g; + if ($env{'form.crsreq_'.$item.'_limit'}) { $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'}; } } @@ -2620,7 +2727,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( @@ -2630,7 +2737,7 @@ 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 @@ -2649,12 +2756,13 @@ sub update_user_data { # Check for need to change my %userenv = &Apache::lonnet::get ('environment',['firstname','middlename','lastname','generation', - 'id','permanentemail','portfolioquota','inststatus','tools.aboutme', - 'tools.blog','tools.webdav','tools.portfolio', + 'id','permanentemail','portfolioquota','authorquota','inststatus', + 'tools.aboutme','tools.blog','tools.webdav','tools.portfolio', 'requestcourses.official','requestcourses.unofficial', - 'requestcourses.community','reqcrsotherdom.official', - 'reqcrsotherdom.unofficial','reqcrsotherdom.community', - 'requestauthor'], + 'requestcourses.community','requestcourses.textbook', + 'reqcrsotherdom.official','reqcrsotherdom.unofficial', + 'reqcrsotherdom.community','reqcrsotherdom.textbook', + 'reqcrsotherdom.placement','requestauthor'], $env{'form.ccdomain'},$env{'form.ccuname'}); my ($tmp) = keys(%userenv); if ($tmp =~ /^(con_lost|error)/i) { @@ -2776,10 +2884,10 @@ sub update_user_data { } } } - my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus, - $newinststatus,$oldisdefault,$newisdefault,%oldsettings, + my (%quotachanged,%oldquota,%newquota,%olddefquota,%newdefquota, + $oldinststatus,$newinststatus,%oldisdefault,%newisdefault,%oldsettings, %oldsettingstext,%newsettings,%newsettingstext,@disporder, - $olddefquota,$oldsettingstatus,$newdefquota,$newsettingstatus); + %oldsettingstatus,%newsettingstatus); @disporder = ('inststatus'); if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) { push(@disporder,'requestcourses','requestauthor'); @@ -2788,9 +2896,11 @@ sub update_user_data { } push(@disporder,('quota','tools')); $oldinststatus = $userenv{'inststatus'}; - ($olddefquota,$oldsettingstatus) = - &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus); - ($newdefquota,$newsettingstatus) = ($olddefquota,$oldsettingstatus); + 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'})) { $canshow{'quota'} = 1; @@ -2829,8 +2939,10 @@ sub update_user_data { $changeHash{'inststatus'} = $newinststatus; if ($newinststatus ne $oldinststatus) { $changed{'inststatus'} = $newinststatus; - ($newdefquota,$newsettingstatus) = - &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus); + foreach my $name ('portfolio','author') { + ($newdefquota{$name},$newsettingstatus{$name}) = + &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus,$name); + } } if (ref($usertypes) eq 'HASH') { $newsettings{'inststatus'} = join(', ',map{ $usertypes->{$_}; } (@inststatuses)); @@ -2844,61 +2956,78 @@ sub update_user_data { $newsettings{'inststatus'} = $othertitle; if ($newinststatus ne $oldinststatus) { $changed{'inststatus'} = $changeHash{'inststatus'}; - ($newdefquota,$newsettingstatus) = - &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus); + 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'}; } - $changeHash{'portfolioquota'} = $userenv{'portfolioquota'}; + foreach my $name ('portfolio','author') { + $changeHash{$name.'quota'} = $userenv{$name.'quota'}; + } if ($context eq 'domain') { - if ($userenv{'portfolioquota'} ne '') { - $oldportfolioquota = $userenv{'portfolioquota'}; - if ($env{'form.customquota'} == 1) { - if ($env{'form.portfolioquota'} eq '') { - $newportfolioquota = 0; + 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 { - $newportfolioquota = $env{'form.portfolioquota'}; - $newportfolioquota =~ s/[^\d\.]//g; - } - if ($newportfolioquota != $oldportfolioquota) { - $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash); + if ("a_admin('',\%changeHash,$name)) { + $changed{$name.'quota'} = 1; + $newquota{$name} = $newdefquota{$name}; + $newisdefault{$name} = 1; + } } } else { - $changed{'quota'} = "a_admin('',\%changeHash); - $newportfolioquota = $newdefquota; - $newisdefault = 1; - } - } else { - $oldisdefault = 1; - $oldportfolioquota = $olddefquota; - if ($env{'form.customquota'} == 1) { - if ($env{'form.portfolioquota'} eq '') { - $newportfolioquota = 0; + $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 { - $newportfolioquota = $env{'form.portfolioquota'}; - $newportfolioquota =~ s/[^\d\.]//g; + $newquota{$name} = $newdefquota{$name}; + $newisdefault{$name} = 1; } - $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash); + } + 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 { - $newportfolioquota = $newdefquota; - $newisdefault = 1; + $newsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$newquota{$name}); } } - if ($oldisdefault) { - $oldsettingstext{'quota'} = &get_defaultquota_text($oldsettingstatus); - } - if ($newisdefault) { - $newsettingstext{'quota'} = &get_defaultquota_text($newsettingstatus); - } &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); + &tool_changes('requestauthor',\@requestauthor,\%oldsettings,\%oldsettingstext, + \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext); } else { &tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext, \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext); @@ -2909,8 +3038,10 @@ sub update_user_data { $namechanged{$item} = 1; } } - $oldsettings{'quota'} = $oldportfolioquota.' Mb'; - $newsettings{'quota'} = $newportfolioquota.' Mb'; + 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) { @@ -2922,8 +3053,9 @@ sub update_user_data { ($env{'user.domain'} eq $env{'form.ccdomain'})) { my %newenvhash; foreach my $key (keys(%changed)) { - if (($key eq 'official') || ($key eq 'unofficial') - || ($key eq 'community')) { + if (($key eq 'official') || ($key eq 'unofficial') || + ($key eq 'community') || ($key eq 'textbook') || + ($key eq 'placement')) { $newenvhash{'environment.requestcourses.'.$key} = $changeHash{'requestcourses.'.$key}; if ($changeHash{'requestcourses.'.$key}) { @@ -2989,7 +3121,7 @@ sub update_user_data { \%newsettingstext); if ($env{'form.cid'} ne $userenv{'id'}) { &Apache::lonnet::idput($env{'form.ccdomain'}, - ($env{'form.ccuname'} => $env{'form.cid'})); + {$env{'form.ccuname'} => $env{'form.cid'}},$uhome,'ids'); if (($recurseid) && (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { my $idresult = @@ -3008,9 +3140,12 @@ sub update_user_data { &Apache::lonnet::appenv(\%newenvhash); } } else { # error occurred - $r->print(''.&mt('Unable to successfully change environment for').' '. - $env{'form.ccuname'}.' '.&mt('in domain').' '. - $env{'form.ccdomain'}.'
'); + $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 # They did not want to change the users name, quota, tool availability, @@ -3028,9 +3163,9 @@ sub update_user_data { $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(); @@ -3039,9 +3174,9 @@ sub update_user_data { } $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.'
' @@ -3058,13 +3193,14 @@ sub update_user_data { if ($env{'form.action'} eq 'singlestudent') { &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context, $crstype,$showcredits,$defaultcredits); - $r->print('

'); - if ($crstype eq 'Community') { - $r->print(&mt('Enroll Another Member')); - } else { - $r->print(&mt('Enroll Another Student')); - } - $r->print('

'); + my $linktext = ($crstype eq 'Community' ? + &mt('Enroll Another Member') : &mt('Enroll Another Student')); + $r->print( + &Apache::lonhtmlcommon::actionbox([ + '' + .($crstype eq 'Community' ? + &mt('Enroll Another Member') : &mt('Enroll Another Student')) + .''])); } else { my @rolechanges = &update_roles($r,$context,$showcredits); if (keys(%namechanged) > 0) { @@ -3118,7 +3254,8 @@ sub display_userinfo { 'generation' => 'Generation', 'id' => 'Student/Employee ID', 'permanentemail' => 'Permanent e-mail address', - 'quota' => 'Disk space allocated to portfolio files', + 'portfolioquota' => 'Disk space allocated to portfolio files', + 'authorquota' => 'Disk space allocated to Authoring Space', 'blog' => 'Blog Availability', 'webdav' => 'WebDAV Availability', 'aboutme' => 'Personal Information Page Availability', @@ -3126,6 +3263,8 @@ sub display_userinfo { 'official' => 'Can Request Official Courses', 'unofficial' => 'Can Request Unofficial Courses', 'community' => 'Can Request Communities', + 'textbook' => 'Can Request Textbook Courses', + 'placement' => 'Can Request Placement Tests', 'requestauthor' => 'Can Request Author Role', 'inststatus' => "Affiliation", 'prvs' => 'Previous Value:', @@ -3140,54 +3279,83 @@ sub display_userinfo { $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}; #show changes only: - unless($value eq $userenv->{$item}){ + unless ($value eq $userenv->{$item}){ $r->print(&Apache::loncommon::start_data_table_row()); - $r->print("$lt{$item}\n"); - $r->print(''.$userenv->{$item}.' '); + $r->print("".$userenv->{$item}."\n"); $r->print("$value \n"); - $r->print(&Apache::loncommon::end_data_table_row()); } } foreach my $entry (@{$order}) { - 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.''; + if ($canshow->{$entry}) { + if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom') || ($entry eq 'requestauthor')) { + my @items; + if ($entry eq 'requestauthor') { + @items = ($entry); + } else { + @items = @{$requestcourses}; + } + foreach my $item (@items) { + if (($newsetting->{$item} ne $oldsetting->{$item}) || + ($newsettingtext->{$item} ne $oldsettingtext->{$item})) { + $r->print(&Apache::loncommon::start_data_table_row()."\n"); + $r->print("$lt{$item}\n"); + $r->print("".$oldsetting->{$item}); + if ($oldsettingtext->{$item}) { + if ($oldsetting->{$item}) { + $r->print(' -- '); + } + $r->print($oldsettingtext->{$item}); + } + $r->print("\n"); + $r->print("".$newsetting->{$item}); + if ($newsettingtext->{$item}) { + if ($newsetting->{$item}) { + $r->print(' -- '); + } + $r->print($newsettingtext->{$item}); + } + $r->print("\n"); + $r->print(&Apache::loncommon::end_data_table_row()."\n"); } - $r->print("$value \n"); } } 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.''; - } - $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.''; + if ($newsetting->{$item} ne $oldsetting->{$item}) { + $r->print(&Apache::loncommon::start_data_table_row()."\n"); + $r->print("$lt{$item}\n"); + $r->print("".$oldsetting->{$item}.' '.$oldsettingtext->{$item}."\n"); + $r->print("".$newsetting->{$item}.' '.$newsettingtext->{$item}."\n"); + $r->print(&Apache::loncommon::end_data_table_row()."\n"); + } + } + } elsif ($entry eq 'quota') { + if ((ref($oldsetting->{$entry}) eq 'HASH') && (ref($oldsettingtext->{$entry}) eq 'HASH') && + (ref($newsetting->{$entry}) eq 'HASH') && (ref($newsettingtext->{$entry}) eq 'HASH')) { + foreach my $name ('portfolio','author') { + if ($newsetting->{$entry}->{$name} ne $oldsetting->{$entry}->{$name}) { + $r->print(&Apache::loncommon::start_data_table_row()."\n"); + $r->print("$lt{$name.$entry}\n"); + $r->print("".$oldsettingtext->{$entry}->{$name}."\n"); + $r->print("".$newsettingtext->{$entry}->{$name}."\n"); + $r->print(&Apache::loncommon::end_data_table_row()."\n"); + } + } + } + } else { + if ($newsetting->{$entry} ne $oldsetting->{$entry}) { + $r->print(&Apache::loncommon::start_data_table_row()."\n"); + $r->print("$lt{$entry}\n"); + $r->print("".$oldsetting->{$entry}.' '.$oldsettingtext->{$entry}."\n"); + $r->print("".$newsetting->{$entry}.' '.$newsettingtext->{$entry}."\n"); + $r->print(&Apache::loncommon::end_data_table_row()."\n"); } - $r->print("$value \n"); } - $r->print(&Apache::loncommon::end_data_table_row()); } } $r->print(&Apache::loncommon::end_data_table().'
'); @@ -3207,20 +3375,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; } @@ -3230,7 +3398,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}; } @@ -3241,8 +3417,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) { @@ -3276,15 +3461,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'"); } } } @@ -3293,12 +3478,14 @@ sub tool_changes { return; } foreach my $tool (@{$usertools}) { - my ($newval,$envkey); + 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}; @@ -3308,10 +3495,25 @@ sub tool_changes { } if ($userenv->{$envkey} ne '') { $oldaccess->{$tool} = &mt('custom'); - if ($userenv->{$envkey}) { - $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->{$envkey} = $userenv->{$envkey}; if ($env{'form.custom'.$tool} == 1) { @@ -3320,17 +3522,45 @@ 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}; - 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 { @@ -3343,10 +3573,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'"); + } } } } @@ -3357,10 +3601,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}; @@ -3379,7 +3637,7 @@ sub update_roles { my @rolechanges; my %disallowed; $r->print('

'.&mt('Modifying Roles').'

'); - foreach my $key (keys (%env)) { + foreach my $key (keys(%env)) { next if (! $env{$key}); next if ($key eq 'form.action'); # Revoke roles @@ -3561,7 +3819,7 @@ sub update_roles { } else { my %curr_groups = &Apache::longroup::coursegroups($one,$two); - foreach my $sec (sort {$a cmp $b} keys %sections) { + foreach my $sec (sort {$a cmp $b} keys(%sections)) { if (($sec eq 'none') || ($sec eq 'all') || exists($curr_groups{$sec})) { $disallowed{$sec} = $url; @@ -3607,7 +3865,7 @@ sub update_roles { my %curr_groups = &Apache::longroup::coursegroups($one,$two); my $emptysec = 0; - foreach my $sec (sort {$a cmp $b} keys %sections) { + foreach my $sec (sort {$a cmp $b} keys(%sections)) { $sec =~ s/\W//g; if ($sec ne '') { if (($sec eq 'none') || ($sec eq 'all') || @@ -3647,7 +3905,7 @@ sub update_roles { $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context)); } else { my $emptysec = 0; - foreach my $sec (sort {$a cmp $b} keys %sections) { + foreach my $sec (sort {$a cmp $b} keys(%sections)) { if ($sec ne '') { my $securl = $url.'/'.$sec; $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec,$context)); @@ -3748,7 +4006,7 @@ sub enroll_single_student { $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'})); } @@ -3765,11 +4023,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('

'); } @@ -3783,14 +4041,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; @@ -3815,20 +4073,20 @@ sub update_result_form { $outcome .= ''."\n"; } $outcome .= ''."\n". - ''."\n". - ''."\n". + ''."\n". + ''."\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; @@ -3935,6 +4193,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? @@ -3947,6 +4206,7 @@ sub custom_role_editor { $syspriv =~ s/bre\&S//; } } else { + $newrole = 1; $body_top .= &mt('New Role').' "'; $roledef=''; } @@ -4073,7 +4333,7 @@ sub custom_role_editor { $r->print('
'); $r->print(< +
ENDCCF @@ -4216,6 +4476,7 @@ sub set_custom_role { bread_crumbs_component => 'User Management'}; $r->print(&Apache::loncommon::start_page('Save Custom Role',$jscript,$args)); + my $newrole; my ($rdummy,$roledef)= &Apache::lonnet::get('roles',["rolesdef_$rolename"]); @@ -4226,6 +4487,7 @@ sub set_custom_role { } else { $r->print(&mt('New Role').' "'); $roledef=''; + $newrole = 1; } $r->print($rolename.'"'); # ------------------------------------------------------- What can be assigned? @@ -4256,21 +4518,44 @@ sub set_custom_role { $sysrole.=':'.$item; } } - $r->print('
Defining Role: '. - &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole)); + # Assign role; Compile and show result + my $errmsg; + my $result = + &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole); + if ($result ne 'ok') { + $errmsg = ': '.$result; + } + my $message = + &Apache::lonhtmlcommon::confirm_success( + &mt('Defining Role').$errmsg, ($result eq 'ok' ? 0 : 1)); if ($env{'request.course.id'}) { my $url='/'.$env{'request.course.id'}; $url=~s/\_/\//g; - $r->print('
'.&mt('Assigning Role to Self').': '. - &Apache::lonnet::assigncustomrole($env{'user.domain'}, - $env{'user.name'}, - $url, - $env{'user.domain'}, - $env{'user.name'}, - $rolename,undef,undef,undef,$context)); - } - $r->print('

'.&mt('Create or edit another custom role').'

'); - $r->print(&Apache::lonhtmlcommon::echo_form_input([]).'
'); + $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') + .'']) + .'
' + .&Apache::lonhtmlcommon::echo_form_input([]) + .'
' + ); } # ================================================================ Main Handler @@ -4293,12 +4578,12 @@ sub handler { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['action','state','callingform','roletype','showrole','bulkaction','popup','phase', - 'username','domain','srchterm','srchdomain','srchin','srchby','srchtype']); + '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') { + 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'} @@ -4453,7 +4738,7 @@ sub handler { (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) { push(@{$brcrum}, {href => '/adm/createuser?action=processauthorreq', - text => 'Authoring space requests', + text => 'Authoring Space requests', help => 'Domain_Role_Approvals'}); $bread_crumbs_component = 'Authoring requests'; if ($env{'form.state'} eq 'done') { @@ -4465,7 +4750,8 @@ sub handler { } $args = { bread_crumbs => $brcrum, bread_crumbs_component => $bread_crumbs_component}; - $r->print(&header(undef,$args)); + 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'})); @@ -4474,6 +4760,124 @@ sub handler { $r->print(&Apache::loncoursequeueadmin::update_request_queue('requestauthor', $env{'request.role.domain'})); } + } elsif (($env{'form.action'} eq 'processusernamereq') && + ($permission->{'cusr'}) && + (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) { + push(@{$brcrum}, + {href => '/adm/createuser?action=processusernamereq', + text => 'LON-CAPA account requests', + help => 'Domain_Username_Approvals'}); + $bread_crumbs_component = 'Account requests'; + if ($env{'form.state'} eq 'done') { + push(@{$brcrum}, + {href => '/adm/createuser?action=usernamereqqueue', + text => 'Result', + help => 'Domain_Username_Approvals'}); + $bread_crumbs_component = 'LON-CAPA account 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('requestusername', + $env{'request.role.domain'})); + } elsif ($env{'form.state'} eq 'done') { + $r->print('

'.&mt('LON-CAPA account request processing').'

'."\n"); + $r->print(&Apache::loncoursequeueadmin::update_request_queue('requestusername', + $env{'request.role.domain'})); + } + } elsif (($env{'form.action'} eq 'displayuserreq') && + ($permission->{'cusr'})) { + my $dom = $env{'form.domain'}; + my $uname = $env{'form.username'}; + my $warning; + if (($dom =~ /^$match_domain$/) && (&Apache::lonnet::domain($dom) ne '')) { + if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) { + if (($uname =~ /^$match_username$/) && ($env{'form.queue'} eq 'approval')) { + my $uhome = &Apache::lonnet::homeserver($uname,$dom); + if ($uhome eq 'no_host') { + my $queue = $env{'form.queue'}; + my $reqkey = &escape($uname).'_'.$queue; + my $namespace = 'usernamequeue'; + my $domconfig = &Apache::lonnet::get_domainconfiguser($dom); + my %queued = + &Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig); + unless ($queued{$reqkey}) { + $warning = &mt('No information was found for this LON-CAPA account request.'); + } + } else { + $warning = &mt('A LON-CAPA account already exists for the requested username and domain.'); + } + } else { + $warning = &mt('LON-CAPA account request status check is for an invalid username.'); + } + } else { + $warning = &mt('You do not have rights to view LON-CAPA account requests in the domain specified.'); + } + } else { + $warning = &mt('LON-CAPA account request status check is for an invalid domain.'); + } + my $args = { only_body => 1 }; + $r->print(&header(undef,$args). + '

'.&mt('LON-CAPA Account Request Details').'

'); + if ($warning ne '') { + $r->print('
'.$warning.'
'); + } else { + my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info(); + my $domconfiguser = &Apache::lonnet::get_domainconfiguser($dom); + my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); + if (ref($domconfig{'usercreation'}) eq 'HASH') { + if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') { + if (ref($domconfig{'usercreation'}{'cancreate'}{'emailusername'}) eq 'HASH') { + my %info = + &Apache::lonnet::get('nohist_requestedusernames',[$uname],$dom,$domconfiguser); + if (ref($info{$uname}) eq 'HASH') { + my $usertype = $info{$uname}{'inststatus'}; + unless ($usertype) { + $usertype = 'default'; + } + if (ref($domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$usertype}) eq 'HASH') { + if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) { + $r->print('
'.&Apache::lonhtmlcommon::start_pick_box()); + my ($num,$count,$showstatus); + $count = scalar(keys(%{$domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$usertype}})); + unless ($usertype eq 'default') { + my ($othertitle,$usertypes,$types) = + &Apache::loncommon::sorted_inst_types($dom); + if (ref($usertypes) eq 'HASH') { + if ($usertypes->{$usertype}) { + $showstatus = $usertypes->{$usertype}; + $count ++; + } + } + } + foreach my $field (@{$infofields}) { + next unless ($domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$usertype}{$field}); + next unless ($infotitles->{$field}); + $r->print(&Apache::lonhtmlcommon::row_title($infotitles->{$field}). + $info{$uname}{$field}); + $num ++; + if ($count == $num) { + $r->print(&Apache::lonhtmlcommon::row_closure(1)); + } else { + $r->print(&Apache::lonhtmlcommon::row_closure()); + } + } + if ($showstatus) { + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Status type (self-reported)')). + $showstatus. + &Apache::lonhtmlcommon::row_closure(1)); + } + $r->print(&Apache::lonhtmlcommon::end_pick_box().'
'); + } + } + } + } + } + } + $r->print(&close_popup_form()); + } } elsif (($env{'form.action'} eq 'listusers') && ($permission->{'view'} || $permission->{'cusr'})) { if ($env{'form.phase'} eq 'bulkchange') { @@ -4579,25 +4983,49 @@ sub handler { ''.&mt('You do not have permission to modify dates or sections for users').''); } } elsif ($env{'form.action'} eq 'selfenroll') { - push(@{$brcrum}, - {href => '/adm/createuser?action=selfenroll', - text => "Configure Self-enrollment", - help => 'Course_Self_Enrollment'}); - if (!exists($env{'form.state'})) { - $args = { bread_crumbs => $brcrum, - bread_crumbs_component => 'Configure Self-enrollment'}; - $r->print(&header(undef,$args)); - $r->print('

'.&mt('Self-enrollment with a student role').'

'."\n"); - &print_selfenroll_menu($r,$context,$permission); - } elsif ($env{'form.state'} eq 'done') { - push (@{$brcrum}, - {href=>'/adm/createuser?action=selfenroll', - text=>"Result"}); - $args = { bread_crumbs => $brcrum, - bread_crumbs_component => 'Self-enrollment result'}; - $r->print(&header(undef,$args)); - $r->print('

'.&mt('Self-enrollment with a student role').'

'."\n"); - &update_selfenroll_config($r,$context,$permission); + if ($permission->{selfenrolladmin}) { + my $cid = $env{'request.course.id'}; + my $cdom = $env{'course.'.$cid.'.domain'}; + my $cnum = $env{'course.'.$cid.'.num'}; + my %currsettings = ( + selfenroll_types => $env{'course.'.$cid.'.internal.selfenroll_types'}, + selfenroll_registered => $env{'course.'.$cid.'.internal.selfenroll_registered'}, + selfenroll_section => $env{'course.'.$cid.'.internal.selfenroll_section'}, + selfenroll_notifylist => $env{'course.'.$cid.'.internal.selfenroll_notifylist'}, + selfenroll_approval => $env{'course.'.$cid.'.internal.selfenroll_approval'}, + selfenroll_limit => $env{'course.'.$cid.'.internal.selfenroll_limit'}, + selfenroll_cap => $env{'course.'.$cid.'.internal.selfenroll_cap'}, + selfenroll_start_date => $env{'course.'.$cid.'.internal.selfenroll_start_date'}, + selfenroll_end_date => $env{'course.'.$cid.'.internal.selfenroll_end_date'}, + selfenroll_start_access => $env{'course.'.$cid.'.internal.selfenroll_start_access'}, + selfenroll_end_access => $env{'course.'.$cid.'.internal.selfenroll_end_access'}, + default_enrollment_start_date => $env{'course.'.$cid.'.default_enrollment_start_date'}, + default_enrollment_end_date => $env{'course.'.$cid.'.default_enrollment_end_date'}, + uniquecode => $env{'course.'.$cid.'.internal.uniquecode'}, + ); + push(@{$brcrum}, + {href => '/adm/createuser?action=selfenroll', + text => "Configure Self-enrollment", + help => 'Course_Self_Enrollment'}); + if (!exists($env{'form.state'})) { + $args = { bread_crumbs => $brcrum, + bread_crumbs_component => 'Configure Self-enrollment'}; + $r->print(&header(undef,$args)); + $r->print('

'.&mt('Self-enrollment with a student role').'

'."\n"); + &print_selfenroll_menu($r,'course',$cid,$cdom,$cnum,\%currsettings); + } elsif ($env{'form.state'} eq 'done') { + push (@{$brcrum}, + {href=>'/adm/createuser?action=selfenroll', + text=>"Result"}); + $args = { bread_crumbs => $brcrum, + bread_crumbs_component => 'Self-enrollment result'}; + $r->print(&header(undef,$args)); + $r->print('

'.&mt('Self-enrollment with a student role').'

'."\n"); + &update_selfenroll_config($r,$cid,$cdom,$cnum,$context,$crstype,\%currsettings); + } + } else { + $r->print(&header(undef,{'no_nav_bar' => 1}). + ''.&mt('You do not have permission to configure self-enrollment').''); } } elsif ($env{'form.action'} eq 'selfenrollqueue') { push(@{$brcrum}, @@ -4673,6 +5101,32 @@ sub add_script { .''."\n"; } +sub usernamerequest_javascript { + my $js = <
+ +

+END +} + sub verify_user_display { my ($context) = @_; my %lt = &Apache::lonlocal::texthash ( @@ -4748,6 +5202,7 @@ function updateCols(caller) { document.getElementById('showcolrole').disabled = 'disabled'; } if (context == 'domain') { + var quotausageshow = 0; if ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') || (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community')) { document.getElementById('showcolstatus').checked = false; @@ -4767,6 +5222,16 @@ function updateCols(caller) { document.getElementById('showcolextent').checked = 'false'; document.getElementById('showextent').style.display='none'; document.getElementById('showcoltextextent').innerHTML = ''; + if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'au') || + (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any')) { + if (document.getElementById('showcolauthorusage')) { + document.getElementById('showcolauthorusage').disabled = ''; + } + if (document.getElementById('showcolauthorquota')) { + document.getElementById('showcolauthorquota').disabled = ''; + } + quotausageshow = 1; + } } else { document.getElementById('showextent').style.display='block'; document.getElementById('showextent').style.textAlign='left'; @@ -4785,6 +5250,16 @@ function updateCols(caller) { } } } + if (quotausageshow == 0) { + if (document.getElementById('showcolauthorusage')) { + document.getElementById('showcolauthorusage').checked = false; + document.getElementById('showcolauthorusage').disabled = 'disabled'; + } + if (document.getElementById('showcolauthorquota')) { + document.getElementById('showcolauthorquota').checked = false; + document.getElementById('showcolauthorquota').disabled = 'disabled'; + } + } } } return; @@ -4905,6 +5380,14 @@ sub print_main_menu { linktitle => 'Approve or reject author role requests', }, { + linktext => 'LON-CAPA Account Requests', + icon => 'list-add.png', + #help => 'Domain_Username_Approvals', + url => '/adm/createuser?action=processusernamereq', + permission => $permission->{'cusr'}, + linktitle => 'Approve or reject LON-CAPA account requests', + }, + { linktext => 'Change Log', icon => 'document-properties.png', #help => 'Course_User_Logs', @@ -4929,6 +5412,7 @@ sub print_main_menu { groups => 'Community Groups', }, ); + $linktext{'Placement'} = $linktext{'Course'}; my %linktitle = ( 'Course' => { @@ -4943,6 +5427,8 @@ sub print_main_menu { }, ); + $linktitle{'Placement'} = $linktitle{'Course'}; + push(@{ $menu[0]->{items} }, #Category: Single Users { linktext => $linktext{$crstype}{'single'}, @@ -4992,12 +5478,12 @@ sub print_main_menu { ); if ($env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_approval'}) { push(@{ $menu[2]->{items} }, - { + { linktext => 'Enrollment Requests', icon => 'selfenrl-queue.png', #help => 'Course_Approve_Selfenroll', url => '/adm/createuser?action=selfenrollqueue', - permission => $permission->{'cusr'}, + permission => $permission->{'selfenrolladmin'}, linktitle =>'Approve or reject enrollment requests.', }, ); @@ -5023,7 +5509,7 @@ sub print_main_menu { icon => 'self_enroll.png', #help => 'Course_Self_Enrollment', url => '/adm/createuser?action=selfenroll', - permission => $permission->{'cusr'}, + permission => $permission->{'selfenrolladmin'}, linktitle => 'Configure user self-enrollment.', }, ); @@ -5060,11 +5546,11 @@ sub restore_prev_selections { } sub print_selfenroll_menu { - my ($r,$context,$permission) = @_; + my ($r,$context,$cid,$cdom,$cnum,$currsettings,$additional) = @_; my $crstype = &Apache::loncommon::course_type(); - my $formname = 'enrollstudent'; + my $formname = 'selfenroll'; my $nolink = 1; - my ($row,$lt) = &get_selfenroll_titles(); + my ($row,$lt) = &Apache::lonuserutils::get_selfenroll_titles(); my $groupslist = &Apache::lonuserutils::get_groupslist(); my $setsec_js = &Apache::lonuserutils::setsections_javascript($formname,$groupslist); @@ -5073,6 +5559,7 @@ sub print_selfenroll_menu { butn => 'but no user types have been checked.', wilf => "Please uncheck 'activate' or check at least one type.", ); + &js_escape(\%alerts); my $selfenroll_js = <<"ENDSCRIPT"; function update_types(caller,num) { var delidx = getIndexByName('selfenroll_delete'); @@ -5183,7 +5670,7 @@ function validate_types(form) { } } else { if (document.$formname.selfenroll_activate.checked) { - var num = document.enrollstudent.selfenroll_activate.value; + var num = document.$formname.selfenroll_activate.value; countfail = check_types(num,countfail,needaction) } } @@ -5230,6 +5717,26 @@ function check_types(num,countfail,needa return countfail; } +function toggleNotify() { + var selfenrollApproval = 0; + if (document.$formname.selfenroll_approval.length) { + for (var i=0; i'."\n". ''."\n". '

'.$lt->{'selfenroll'}.'

'."\n"; - my ($visible,$cansetvis,$vismsgs,$visactions) = &visible_in_cat($cdom,$cnum); - if (ref($visactions) eq 'HASH') { - if ($visible) { - $output .= '

'.$visactions->{'vis'}.'

'; + + my $visactions = &cat_visibility(); + my ($cathash,%cattype); + my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom); + if (ref($domconfig{'coursecategories'}) eq 'HASH') { + $cathash = $domconfig{'coursecategories'}{'cats'}; + $cattype{'auth'} = $domconfig{'coursecategories'}{'auth'}; + $cattype{'unauth'} = $domconfig{'coursecategories'}{'unauth'}; + if ($cattype{'auth'} eq '') { + $cattype{'auth'} = 'std'; + } + if ($cattype{'unauth'} eq '') { + $cattype{'unauth'} = 'std'; + } + } else { + $cathash = {}; + $cattype{'auth'} = 'std'; + $cattype{'unauth'} = 'std'; + } + if (($cattype{'auth'} eq 'none') && ($cattype{'unauth'} eq 'none')) { + $r->print('
'.$visactions->{'miss'}.'
'.$visactions->{'yous'}. + '
'. + '
'.$visactions->{'take'}.'
    '. + '
  • '.$visactions->{'dc_chgconf'}.'
  • '. + '
'); + } elsif (($cattype{'auth'} !~ /^(std|domonly)$/) && ($cattype{'unauth'} !~ /^(std|domonly)$/)) { + if ($currsettings->{'uniquecode'}) { + $r->print(''.$visactions->{'vis'}.''); } else { - $output .= '

'.$visactions->{'miss'}.'

' - .$visactions->{'yous'}. - '

'.$visactions->{'gen'}.'
'.$visactions->{'coca'}; - if (ref($vismsgs) eq 'ARRAY') { - $output .= '
'.$visactions->{'make'}.'

    '; - foreach my $item (@{$vismsgs}) { - $output .= '
  • '.$visactions->{$item}.'
  • '; + $r->print('
    '.$visactions->{'miss'}.'
    '.$visactions->{'yous'}. + '
    '. + '
    '.$visactions->{'take'}.'
      '. + '
    • '.$visactions->{'dc_setcode'}.'
    • '. + '

    '); + } + } else { + my ($visible,$cansetvis,$vismsgs) = &visible_in_stdcat($cdom,$cnum,\%domconfig); + if (ref($visactions) eq 'HASH') { + if ($visible) { + $output .= '

    '.$visactions->{'vis'}.'

    '; + } else { + $output .= '

    '.$visactions->{'miss'}.'

    ' + .$visactions->{'yous'}. + '

    '.$visactions->{'gen'}.'
    '.$visactions->{'coca'}; + if (ref($vismsgs) eq 'ARRAY') { + $output .= '
    '.$visactions->{'make'}.'

      '; + foreach my $item (@{$vismsgs}) { + $output .= '
    • '.$visactions->{$item}.'
    • '; + } + $output .= '
    '; } - $output .= '
'; + $output .= '

'; } - $output .= '

'; } } - $output .= '
'."\n". + my $actionhref = '/adm/createuser'; + if ($context eq 'domain') { + $actionhref = '/adm/modifycourse'; + } + + my %noedit; + unless ($context eq 'domain') { + %noedit = &get_noedit_fields($cdom,$cnum,$crstype,$row); + } + $output .= ''."\n". &Apache::lonhtmlcommon::start_pick_box(); if (ref($row) eq 'ARRAY') { foreach my $item (@{$row}) { @@ -5276,7 +5827,41 @@ ENDSCRIPT } $output .= &Apache::lonhtmlcommon::row_title($title); if ($item eq 'types') { - my $curr_types = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_types'}; + my $curr_types; + if (ref($currsettings) eq 'HASH') { + $curr_types = $currsettings->{'selfenroll_types'}; + } + if ($noedit{$item}) { + if ($curr_types eq '*') { + $output .= &mt('Any user in any domain'); + } else { + my @entries = split(/;/,$curr_types); + if (@entries > 0) { + $output .= '
    '; + foreach my $entry (@entries) { + my ($currdom,$typestr) = split(/:/,$entry); + next if ($typestr eq ''); + my $domdesc = &Apache::lonnet::domain($currdom); + my @currinsttypes = split(',',$typestr); + my ($othertitle,$usertypes,$types) = + &Apache::loncommon::sorted_inst_types($currdom); + if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) { + $usertypes->{'any'} = &mt('any user'); + if (keys(%{$usertypes}) > 0) { + $usertypes->{'other'} = &mt('other users'); + } + my @longinsttypes = map { $usertypes->{$_}; } @currinsttypes; + $output .= '
  • '.$domdesc.':'.join(', ',@longinsttypes).'
  • '; + } + } + $output .= '
'; + } else { + $output .= &mt('None'); + } + } + $output .= '
'.&mt('(Set by Domain Coordinator)'); + next; + } my $showdomdesc = 1; my $includeempty = 1; my $num = 0; @@ -5341,7 +5926,20 @@ ENDSCRIPT .&Apache::loncommon::end_data_table(); } elsif ($item eq 'registered') { my ($regon,$regoff); - if ($env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_registered'}) { + my $registered; + if (ref($currsettings) eq 'HASH') { + $registered = $currsettings->{'selfenroll_registered'}; + } + if ($noedit{$item}) { + if ($registered) { + $output .= &mt('Must be registered in course'); + } else { + $output .= &mt('No requirement'); + } + $output .= '
'.&mt('(Set by Domain Coordinator)'); + next; + } + if ($registered) { $regon = ' checked="checked" '; $regoff = ' '; } else { @@ -5354,13 +5952,22 @@ ENDSCRIPT ''. &mt('No').''; } elsif ($item eq 'enroll_dates') { - my $starttime = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_start_date'}; - my $endtime = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_end_date'}; - if ($starttime eq '') { - $starttime = $env{'course.'.$env{'request.course.id'}.'.default_enrollment_start_date'}; - } - if ($endtime eq '') { - $endtime = $env{'course.'.$env{'request.course.id'}.'.default_enrollment_end_date'}; + my ($starttime,$endtime); + if (ref($currsettings) eq 'HASH') { + $starttime = $currsettings->{'selfenroll_start_date'}; + $endtime = $currsettings->{'selfenroll_end_date'}; + if ($starttime eq '') { + $starttime = $currsettings->{'default_enrollment_start_date'}; + } + if ($endtime eq '') { + $endtime = $currsettings->{'default_enrollment_end_date'}; + } + } + if ($noedit{$item}) { + $output .= &mt('From: [_1], to: [_2]',&Apache::lonlocal::locallocaltime($starttime), + &Apache::lonlocal::locallocaltime($endtime)); + $output .= '
'.&mt('(Set by Domain Coordinator)'); + next; } my $startform = &Apache::lonhtmlcommon::date_setter($formname,'selfenroll_start_date',$starttime, @@ -5370,13 +5977,22 @@ ENDSCRIPT undef,undef,undef,undef,undef,undef,undef,$nolink); $output .= &selfenroll_date_forms($startform,$endform); } elsif ($item eq 'access_dates') { - my $starttime = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_start_access'}; - my $endtime = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_end_access'}; - if ($starttime eq '') { - $starttime = $env{'course.'.$env{'request.course.id'}.'.default_enrollment_start_date'}; - } - if ($endtime eq '') { - $endtime = $env{'course.'.$env{'request.course.id'}.'.default_enrollment_end_date'}; + my ($starttime,$endtime); + if (ref($currsettings) eq 'HASH') { + $starttime = $currsettings->{'selfenroll_start_access'}; + $endtime = $currsettings->{'selfenroll_end_access'}; + if ($starttime eq '') { + $starttime = $currsettings->{'default_enrollment_start_date'}; + } + if ($endtime eq '') { + $endtime = $currsettings->{'default_enrollment_end_date'}; + } + } + if ($noedit{$item}) { + $output .= &mt('From: [_1], to: [_2]',&Apache::lonlocal::locallocaltime($starttime), + &Apache::lonlocal::locallocaltime($endtime)); + $output .= '
'.&mt('(Set by Domain Coordinator)'); + next; } my $startform = &Apache::lonhtmlcommon::date_setter($formname,'selfenroll_start_access',$starttime, @@ -5386,7 +6002,10 @@ ENDSCRIPT undef,undef,undef,undef,undef,undef,undef,$nolink); $output .= &selfenroll_date_forms($startform,$endform); } elsif ($item eq 'section') { - my $currsec = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_section'}; + my $currsec; + if (ref($currsettings) eq 'HASH') { + $currsec = $currsettings->{'selfenroll_section'}; + } my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); my $newsecval; if ($currsec ne 'none' && $currsec ne '') { @@ -5394,6 +6013,15 @@ ENDSCRIPT $newsecval = $currsec; } } + if ($noedit{$item}) { + if ($currsec ne '') { + $output .= $currsec; + } else { + $output .= &mt('No specific section'); + } + $output .= '
'.&mt('(Set by Domain Coordinator)'); + next; + } my $sections_select = &Apache::lonuserutils::course_sections(\%sections_count,'st',$currsec); $output .= ''."\n". @@ -5403,24 +6031,29 @@ ENDSCRIPT &mt('New section').'
'."\n". ''."\n". ''."\n". - ''."\n". '
'."\n"; } elsif ($item eq 'approval') { - my ($appon,$appoff); - my $cid = $env{'request.course.id'}; - my $currnotified = $env{'course.'.$cid.'.internal.selfenroll_notifylist'}; - if ($env{'course.'.$cid.'.internal.selfenroll_approval'}) { - $appon = ' checked="checked" '; - $appoff = ' '; - } else { - $appon = ' '; - $appoff = ' checked="checked" '; + my ($currnotified,$currapproval,%appchecked); + my %selfdescs = &Apache::lonuserutils::selfenroll_default_descs(); + if (ref($currsettings) eq 'HASH') { + $currnotified = $currsettings->{'selfenroll_notifylist'}; + $currapproval = $currsettings->{'selfenroll_approval'}; + } + if ($currapproval !~ /^[012]$/) { + $currapproval = 0; + } + if ($noedit{$item}) { + $output .= $selfdescs{'approval'}{$currapproval}. + '
'.&mt('(Set by Domain Coordinator)'); + next; + } + $appchecked{$currapproval} = ' checked="checked"'; + for my $i (0..2) { + $output .= ''.(' 'x2); } - $output .= '  '; my %advhash = &Apache::lonnet::get_course_adv_roles($cid,1); my (@ccs,%notified); my $ccrole = 'cc'; @@ -5439,7 +6072,13 @@ ENDSCRIPT } } if (@ccs) { - $output .= '
'.&mt('Personnel to be notified when an enrollment request needs approval, or has been approved:').' '.&Apache::loncommon::start_data_table(). + my $style; + unless ($currapproval) { + $style = ' style="display: none;"'; + } + $output .= '
'. + &mt('Personnel to be notified when an enrollment request needs approval, or has been approved:').' '. + &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_row(); my $count = 0; my $numcols = 4; @@ -5467,14 +6106,29 @@ ENDSCRIPT } } $output .= &Apache::loncommon::end_data_table_row(). - &Apache::loncommon::end_data_table(); + &Apache::loncommon::end_data_table(). + '
'; } } elsif ($item eq 'limit') { - my ($crslimit,$selflimit,$nolimit); - my $cid = $env{'request.course.id'}; - my $currlim = $env{'course.'.$cid.'.internal.selfenroll_limit'}; - my $currcap = $env{'course.'.$cid.'.internal.selfenroll_cap'}; - $nolimit = ' checked="checked" '; + my ($crslimit,$selflimit,$nolimit,$currlim,$currcap); + if (ref($currsettings) eq 'HASH') { + $currlim = $currsettings->{'selfenroll_limit'}; + $currcap = $currsettings->{'selfenroll_cap'}; + } + if ($noedit{$item}) { + if (($currlim eq 'allstudents') || ($currlim eq 'selfenrolled')) { + if ($currlim eq 'allstudents') { + $output .= &mt('Limit by total students'); + } elsif ($currlim eq 'selfenrolled') { + $output .= &mt('Limit by total self-enrolled students'); + } + $output .= ' '.&mt('Maximum: [_1]',$currcap). + '
'.&mt('(Set by Domain Coordinator)'); + } else { + $output .= &mt('No limit').'
'.&mt('(Set by Domain Coordinator)'); + } + next; + } if ($currlim eq 'allstudents') { $crslimit = ' checked="checked" '; $selflimit = ' '; @@ -5486,6 +6140,7 @@ ENDSCRIPT } else { $crslimit = ' '; $selflimit = ' '; + $nolimit = ' checked="checked" '; } $output .= ''."\n". -''."\n". +''; + } + $result .= ''."\n". ''. &Apache::loncommon::end_data_table_header_row(). @@ -6682,14 +7413,14 @@ $table. sub course_level_row { my ($protectedcourse,$role,$area,$domain,$plrole,$sections_count, - $lt,$defaultcredits,$crstype) = @_; + $lt,$showcredits,$defaultcredits,$crstype) = @_; my $creditem; my $row = &Apache::loncommon::start_data_table_row(). ' '."\n". ' '."\n". ' '."\n"; - if (($role eq 'st') && ($crstype eq 'Course')) { + if (($showcredits) && ($role eq 'st') && ($crstype eq 'Course')) { $row .= ''; @@ -6766,28 +7497,29 @@ sub course_level_dc { &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). ''."\n". - ''."\n". - ''."\n". + ''."\n"; + $header .= ''."\n" if ($showcredits); + $header .= ''."\n". &Apache::loncommon::end_data_table_header_row(); my $otheritems = &Apache::loncommon::start_data_table_row()."\n". ''."\n". - ''."\n"; if ($showcredits) { $otheritems .= ''."\n"; } $otheritems .= <
@@ -6813,19 +7545,23 @@ ENDTIMEENTRY } sub update_selfenroll_config { - my ($r,$context,$permission) = @_; - my ($row,$lt) = &get_selfenroll_titles(); - my %curr_groups = &Apache::longroup::coursegroups(); + my ($r,$cid,$cdom,$cnum,$context,$crstype,$currsettings) = @_; + return unless (ref($currsettings) eq 'HASH'); + my ($row,$lt) = &Apache::lonuserutils::get_selfenroll_titles(); + my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); my (%changes,%warning); - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $curr_types; + my %noedit; + unless ($context eq 'domain') { + %noedit = &get_noedit_fields($cdom,$cnum,$crstype,$row); + } if (ref($row) eq 'ARRAY') { foreach my $item (@{$row}) { + next if ($noedit{$item}); if ($item eq 'enroll_dates') { my (%currenrolldate,%newenrolldate); foreach my $type ('start','end') { - $currenrolldate{$type} = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_'.$type.'_date'}; + $currenrolldate{$type} = $currsettings->{'selfenroll_'.$type.'_date'}; $newenrolldate{$type} = &Apache::lonhtmlcommon::get_date_from_form('selfenroll_'.$type.'_date'); if ($newenrolldate{$type} ne $currenrolldate{$type}) { $changes{'internal.selfenroll_'.$type.'_date'} = $newenrolldate{$type}; @@ -6834,15 +7570,14 @@ sub update_selfenroll_config { } elsif ($item eq 'access_dates') { my (%currdate,%newdate); foreach my $type ('start','end') { - $currdate{$type} = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_'.$type.'_access'}; + $currdate{$type} = $currsettings->{'selfenroll_'.$type.'_access'}; $newdate{$type} = &Apache::lonhtmlcommon::get_date_from_form('selfenroll_'.$type.'_access'); if ($newdate{$type} ne $currdate{$type}) { $changes{'internal.selfenroll_'.$type.'_access'} = $newdate{$type}; } } } elsif ($item eq 'types') { - $curr_types = - $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_'.$item}; + $curr_types = $currsettings->{'selfenroll_'.$item}; if ($env{'form.selfenroll_all'}) { if ($curr_types ne '*') { $changes{'internal.selfenroll_types'} = '*'; @@ -6911,9 +7646,9 @@ sub update_selfenroll_config { my $newlimit = $env{'form.selfenroll_limit'}; my $newcap = $env{'form.selfenroll_cap'}; $newcap =~s/\s+//g; - my $currlimit = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_limit'}; + my $currlimit = $currsettings->{'selfenroll_limit'}; $currlimit = 'none' if ($currlimit eq ''); - my $currcap = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_cap'}; + my $currcap = $currsettings->{'selfenroll_cap'}; if ($newlimit ne $currlimit) { if ($newlimit ne 'none') { if ($newcap =~ /^\d+$/) { @@ -6922,7 +7657,8 @@ sub update_selfenroll_config { } $changes{'internal.selfenroll_limit'} = $newlimit; } else { - $warning{$item} = &mt('Maximum enrollment setting unchanged.').'
'.&mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.'); + $warning{$item} = &mt('Maximum enrollment setting unchanged.').'
'. + &mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.'); } } elsif ($currcap ne '') { $changes{'internal.selfenroll_cap'} = ''; @@ -6934,13 +7670,14 @@ sub update_selfenroll_config { $changes{'internal.selfenroll_cap'} = $newcap; } } else { - $warning{$item} = &mt('Maximum enrollment setting unchanged.').'
'.&mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.'); + $warning{$item} = &mt('Maximum enrollment setting unchanged.').'
'. + &mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.'); } } } elsif ($item eq 'approval') { my (@currnotified,@newnotified); - my $currapproval = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_approval'}; - my $currnotifylist = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_notifylist'}; + my $currapproval = $currsettings->{'selfenroll_approval'}; + my $currnotifylist = $currsettings->{'selfenroll_notifylist'}; if ($currnotifylist ne '') { @currnotified = split(/,/,$currnotifylist); @currnotified = sort(@currnotified); @@ -6976,14 +7713,14 @@ sub update_selfenroll_config { } } } else { - my $curr_val = - $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_'.$item}; + my $curr_val = $currsettings->{'selfenroll_'.$item}; my $newval = $env{'form.selfenroll_'.$item}; if ($item eq 'section') { $newval = $env{'form.sections'}; if (defined($curr_groups{$newval})) { $newval = $curr_val; - $warning{$item} = &mt('Section for self-enrolled users unchanged as the proposed section is a group').'
'.&mt('Group names and section names must be distinct'); + $warning{$item} = &mt('Section for self-enrolled users unchanged as the proposed section is a group').'
'. + &mt('Group names and section names must be distinct'); } elsif ($newval eq 'all') { $newval = $curr_val; $warning{$item} = &mt('Section for self-enrolled users unchanged, as "all" is a reserved section name.'); @@ -7013,11 +7750,10 @@ sub update_selfenroll_config { my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.', $cnum,undef,undef,'Course'); my $chome = &Apache::lonnet::homeserver($cnum,$cdom); - if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') { + if (ref($crsinfo{$cid}) eq 'HASH') { foreach my $item ('selfenroll_types','selfenroll_start_date','selfenroll_end_date') { if (exists($changes{'internal.'.$item})) { - $crsinfo{$env{'request.course.id'}}{$item} = - $changes{'internal.'.$item}; + $crsinfo{$cid}{$item} = $changes{'internal.'.$item}; } } my $crsputresult = @@ -7054,7 +7790,7 @@ sub update_selfenroll_config { if ($changes{'internal.selfenroll_cap'} ne '') { $newcap = $changes{'internal.selfenroll_cap'} } else { - $newcap = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_cap'}; + $newcap = $currsettings->{'selfenroll_cap'}; } if ($changes{'internal.selfenroll_limit'} eq 'none') { $newval = &mt('No limit'); @@ -7064,7 +7800,7 @@ sub update_selfenroll_config { } elsif ($changes{'internal.selfenroll_limit'} eq 'selfenrolled') { $newval = &mt('New self-enrollment no longer allowed when total number of self-enrolled students reaches [_1].',$newcap); } else { - my $currlimit = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_limit'}; + my $currlimit = $currsettings->{'selfenroll_limit'}; if ($currlimit eq 'allstudents') { $newval = &mt('New self-enrollment no longer allowed when total (all students) reaches [_1].',$newcap); } elsif ($changes{'internal.selfenroll_limit'} eq 'selfenrolled') { @@ -7076,24 +7812,24 @@ sub update_selfenroll_config { } elsif ($item eq 'approval') { if ((exists($changes{'internal.selfenroll_approval'})) || (exists($changes{'internal.selfenroll_notifylist'}))) { + my %selfdescs = &Apache::lonuserutils::selfenroll_default_descs(); my ($newval,$newnotify); if (exists($changes{'internal.selfenroll_notifylist'})) { $newnotify = $changes{'internal.selfenroll_notifylist'}; } else { - $newnotify = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_notifylist'}; + $newnotify = $currsettings->{'selfenroll_notifylist'}; } - if ($changes{'internal.selfenroll_approval'}) { - $newval = &mt('Yes'); - } elsif ($changes{'internal.selfenroll_approval'} eq '0') { - $newval = &mt('No'); + if (exists($changes{'internal.selfenroll_approval'})) { + if ($changes{'internal.selfenroll_approval'} !~ /^[012]$/) { + $changes{'internal.selfenroll_approval'} = '0'; + } + $newval = $selfdescs{'approval'}{$changes{'internal.selfenroll_approval'}}; } else { - my $currapproval = - $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_approval'}; - if ($currapproval) { - $newval = &mt('Yes'); - } else { - $newval = &mt('No'); + my $currapproval = $currsettings->{'selfenroll_approval'}; + if ($currapproval !~ /^[012]$/) { + $currapproval = 0; } + $newval = $selfdescs{'approval'}{$currapproval}; } $r->print('
  • '.&mt('"[_1]" set to "[_2]".',$title,$newval)); if ($newnotify) { @@ -7124,13 +7860,16 @@ sub update_selfenroll_config { } } $r->print(''); - my %newenvhash; - foreach my $key (keys(%changes)) { - $newenvhash{'course.'.$env{'request.course.id'}.'.'.$key} = $changes{$key}; + if ($env{'course.'.$cid.'.description'} ne '') { + my %newenvhash; + foreach my $key (keys(%changes)) { + $newenvhash{'course.'.$cid.'.'.$key} = $changes{$key}; + } + &Apache::lonnet::appenv(\%newenvhash); } - &Apache::lonnet::appenv(\%newenvhash); } else { - $r->print(&mt('An error occurred when saving changes to self-enrollment settings in this course.').'
    '.&mt('The error was: [_1].',$putresult)); + $r->print(&mt('An error occurred when saving changes to self-enrollment settings in this course.').'
    '. + &mt('The error was: [_1].',$putresult)); } } else { $r->print(&mt('No changes were made to the existing self-enrollment settings in this course.')); @@ -7138,39 +7877,54 @@ sub update_selfenroll_config { } else { $r->print(&mt('No changes were made to the existing self-enrollment settings in this course.')); } - my ($visible,$cansetvis,$vismsgs,$visactions) = &visible_in_cat($cdom,$cnum); - if (ref($visactions) eq 'HASH') { - if (!$visible) { + my $visactions = &cat_visibility(); + my ($cathash,%cattype); + my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom); + if (ref($domconfig{'coursecategories'}) eq 'HASH') { + $cathash = $domconfig{'coursecategories'}{'cats'}; + $cattype{'auth'} = $domconfig{'coursecategories'}{'auth'}; + $cattype{'unauth'} = $domconfig{'coursecategories'}{'unauth'}; + } else { + $cathash = {}; + $cattype{'auth'} = 'std'; + $cattype{'unauth'} = 'std'; + } + if (($cattype{'auth'} eq 'none') && ($cattype{'unauth'} eq 'none')) { + $r->print('
    '.$visactions->{'miss'}.'
    '.$visactions->{'yous'}. + '
    '. + '
    '.$visactions->{'take'}.'
      '. + '
    • '.$visactions->{'dc_chgconf'}.'
    • '. + '
    '); + } elsif (($cattype{'auth'} !~ /^(std|domonly)$/) && ($cattype{'unauth'} !~ /^(std|domonly)$/)) { + if ($currsettings->{'uniquecode'}) { + $r->print(''.$visactions->{'vis'}.''); + } else { $r->print('
    '.$visactions->{'miss'}.'
    '.$visactions->{'yous'}. - '
    '); - if (ref($vismsgs) eq 'ARRAY') { - $r->print('
    '.$visactions->{'take'}.'
      '); - foreach my $item (@{$vismsgs}) { - $r->print('
    • '.$visactions->{$item}.'
    • '); + '
      '. + '
      '.$visactions->{'take'}.'
        '. + '
      • '.$visactions->{'dc_setcode'}.'
      • '. + '

      '); + } + } else { + my ($visible,$cansetvis,$vismsgs) = &visible_in_stdcat($cdom,$cnum,\%domconfig); + if (ref($visactions) eq 'HASH') { + if (!$visible) { + $r->print('
      '.$visactions->{'miss'}.'
      '.$visactions->{'yous'}. + '
      '); + if (ref($vismsgs) eq 'ARRAY') { + $r->print('
      '.$visactions->{'take'}.'
        '); + foreach my $item (@{$vismsgs}) { + $r->print('
      • '.$visactions->{$item}.'
      • '); + } + $r->print('
      '); } - $r->print('
    '); + $r->print($cansetvis); } - $r->print($cansetvis); } } return; } -sub get_selfenroll_titles { - my @row = ('types','registered','enroll_dates','access_dates','section', - 'approval','limit'); - my %lt = &Apache::lonlocal::texthash ( - types => 'Users allowed to self-enroll in this course', - registered => 'Restrict self-enrollment to students officially registered for the course', - enroll_dates => 'Dates self-enrollment available', - access_dates => 'Course access dates assigned to self-enrolling users', - section => 'Section assigned to self-enrolling users', - approval => 'Self-enrollment requests need approval?', - limit => 'Enrollment limit', - ); - return (\@row,\%lt); -} - #---------------------------------------------- end functions for &phase_two #--------------------------------- functions for &phase_two and &phase_three
  • '.$lt{'act'}.''.$lt{'rol'}.''.$lt{'ext'}.''.$lt{'crd'}.''.$lt{'ext'}.''."\n"; + if ($showcredits) { + $result .= $lt{'crd'}.''.$lt{'grs'}.''.$lt{'sta'}.''.$lt{'end'}.''.$plrole.''.$area.'
    Domain: '.$domain.'
    '.$lt{'scc'}.''.$lt{'rol'}.''.$lt{'grs'}.''.$lt{'crd'}.''.$lt{'sta'}.''.$lt{'end'}.''.$lt{'grs'}.''.$lt{'crd'}.''.$lt{'sta'}.''.$lt{'end'}.'
    '. $courseform.(' ' x4).'


    '. ''. ''. + ' '. ''. '
    '.$lt{'exs'}.'
       '.$lt{'new'}.'
    '. ''. @@ -6797,7 +7529,7 @@ sub course_level_dc { '

    '."\n". - ''."\n"; + '