--- loncom/interface/loncreateuser.pm 2017/01/22 16:00:17 1.406.2.10 +++ loncom/interface/loncreateuser.pm 2017/01/02 19:44:06 1.428 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.406.2.10 2017/01/22 16:00:17 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.428 2017/01/02 19:44:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -252,13 +252,15 @@ sub build_tools_display { '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','requestcourses.textbook'); - @usertools = ('official','unofficial','community','textbook'); + '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(); @@ -333,6 +335,7 @@ sub build_tools_display { ' '.$lt{$item}.''."\n". ' '."\n". &Apache::loncommon::start_data_table_row()."\n"; + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { my ($curroption,$currlimit); my $envkey = $context.'.'.$item; @@ -451,12 +454,14 @@ sub coursereq_externaluser { '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','reqcrsotherdom.textbook'); - @usertools = ('official','unofficial','community','textbook'); + '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); @@ -537,6 +542,7 @@ sub courserequest_titles { unofficial => 'Unofficial', community => 'Communities', textbook => 'Textbook', + placement => 'Placement Tests', norequest => 'Not allowed', approval => 'Approval by Dom. Coord.', validate => 'With validation', @@ -854,7 +860,7 @@ ENDBLOCK $output = '

'.$userpicker.'

'; } if (($env{'form.phase'} eq '') && ($env{'form.action'} ne 'accesslogs') && - (!(($env{'form.action'} eq 'singleuser') && ($context eq 'domain') && + (!(($env{'form.action'} eq 'singleuser') && ($context eq 'domain') && (!&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))))) { my $defdom=$env{'request.role.domain'}; my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain'); @@ -1429,7 +1435,7 @@ ENDAUTH $r->print('
'); $r->print(&personal_data_display($ccuname,$ccdomain,$newuser,$context, $inst_results{$ccuname.':'.$ccdomain})); - if ((&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) || + if ((&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) || (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) { $r->print('

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

'. &Apache::loncommon::start_data_table()); @@ -1449,7 +1455,7 @@ ENDAUTH if ((!$isauthor) && ((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) || (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) && - ($env{'request.role.domain'} eq $ccdomain)) { + ($env{'request.role.domain'} eq $ccdomain)) { $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain); } $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname); @@ -1520,7 +1526,7 @@ ENDNOTOOLSPRIV } elsif (($context eq 'course') && ((&Apache::lonnet::allowed('vcl',$env{'request.course.id'})) || ($env{'request.course.sec'} && &Apache::lonnet::allowed('vcl',$env{'request.course.id'}.'/'.$env{'request.course.sec'})))) { - $statuses = ['active']; + $statuses = ['active']; } if ($env{'form.action'} ne 'singlestudent') { &display_existing_roles($r,$ccuname,$ccdomain,\%inccourses,$context, @@ -1754,7 +1760,7 @@ sub display_existing_roles { if ($active) { next unless($showall || $showactive); } else { - next unless($showall || $showexpired); + next unless($showall || $showexpired); } # Is this a custom role? Get role owner and title. my ($croleudom,$croleuname,$croletitle)= @@ -1899,7 +1905,7 @@ sub display_existing_roles { } else { $row.=' '; } - $row.= ''; + $row.= ''; } my $plaintext=''; if (!$croletitle) { @@ -2168,6 +2174,7 @@ $lt{'uuas'} ($currentauth). $lt{'adcs'}. ENDBADAUTH } } else { # Authentication type is valid + &initialize_authen_forms($ccdomain,$formname,$currentauth,'modifyuser'); my ($authformcurrent,$can_modify,@authform_others) = &modify_login_block($ccdomain,$currentauth); @@ -2726,7 +2733,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','textbook'); + my @requestcourses = ('official','unofficial','community','textbook','placement'); my @requestauthor = ('requestauthor'); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'}); @@ -2899,7 +2906,7 @@ sub update_user_data { 'requestcourses.community','requestcourses.textbook', 'reqcrsotherdom.official','reqcrsotherdom.unofficial', 'reqcrsotherdom.community','reqcrsotherdom.textbook', - 'requestauthor'], + 'reqcrsotherdom.placement','requestauthor'], $env{'form.ccdomain'},$env{'form.ccuname'}); my ($tmp) = keys(%userenv); if ($tmp =~ /^(con_lost|error)/i) { @@ -3190,8 +3197,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') || ($key eq 'textbook')) { + 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}) { @@ -3257,7 +3265,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 = @@ -3400,6 +3408,7 @@ sub display_userinfo { '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:', @@ -4375,7 +4384,7 @@ sub custom_role_editor { ); my $args = { bread_crumbs => $brcrum, bread_crumbs_component => 'User Management'}; - + $r->print(&Apache::loncommon::start_page('Custom Role Editor', $head_script,$args). $body_top); @@ -5016,13 +5025,12 @@ sub handler { } elsif ($env{'form.state'} eq 'done') { $r->print('

'.&mt('Enrollment request processing').'

'."\n"); $r->print(&Apache::loncoursequeueadmin::update_request_queue($context, - $cdom,$cnum,$coursedesc)); + $cdom,$cnum,$coursedesc)); } } else { $r->print(&header(undef,{'no_nav_bar' => 1}). ''.&mt('You do not have permission to manage self-enrollment').''); } - } elsif ($env{'form.action'} eq 'changelogs') { if ($permission->{cusr} || $permission->{view}) { &print_userchangelogs_display($r,$context,$permission,$brcrum); @@ -5037,7 +5045,7 @@ sub handler { &update_helpdeskaccess($r,$permission,$brcrum); } else { &print_helpdeskaccess_display($r,$permission,$brcrum); - } + } } else { &print_helpdeskaccess_display($r,$permission,$brcrum); } @@ -5298,9 +5306,9 @@ sub print_main_menu { ); if ($linkcontext eq 'domain') { unless ($permission->{'cusr'}) { - $links{'domain'}{'singleuser'} = 'View a User'; + $links{'domain'}{'singleuser'} = 'View a User'; $linktitles{'domain'}{'singleuser'} = 'View information about a user in the domain'; - + } } elsif ($linkcontext eq 'course') { unless ($permission->{'cusr'}) { @@ -5370,14 +5378,6 @@ sub print_main_menu { push(@{ $menu[2]->{items} }, #Category: Administration { - linktext => 'Helpdesk Access', - icon => 'helpdesk-access.png', - #help => 'Course_Helpdesk_Access', - url => '/adm/createuser?action=helpdesk', - permission => ($permission->{'owner'} || $permission->{'co-owner'}), - linktitle => 'Helpdesk access options', - }, - { linktext => 'Custom Roles', icon => 'emblem-photos.png', #help => 'Course_Editing_Custom_Roles', @@ -5426,6 +5426,7 @@ sub print_main_menu { groups => 'Community Groups', }, ); + $linktext{'Placement'} = $linktext{'Course'}; my %linktitle = ( 'Course' => { @@ -5440,6 +5441,8 @@ sub print_main_menu { }, ); + $linktitle{'Placement'} = $linktitle{'Course'}; + push(@{ $menu[0]->{items} }, #Category: Single Users { linktext => $linktext{$crstype}{'single'}, @@ -5462,7 +5465,15 @@ sub print_main_menu { }, ); push(@{ $menu[2]->{items} }, #Category: Administration - { + { + linktext => 'Helpdesk Access', + icon => 'helpdesk-access.png', + #help => 'Course_Helpdesk_Access', + url => '/adm/createuser?action=helpdesk', + permission => ($permission->{'owner'} || $permission->{'co-owner'}), + linktitle => 'Helpdesk access options', + }, + { linktext => 'Custom Roles', icon => 'emblem-photos.png', #help => 'Course_Editing_Custom_Roles', @@ -6051,7 +6062,7 @@ ENDSCRIPT } elsif ($item eq 'approval') { my ($currnotified,$currapproval,%appchecked); my %selfdescs = &Apache::lonuserutils::selfenroll_default_descs(); - if (ref($currsettings) eq 'HASH') { + if (ref($currsettings) eq 'HASH') { $currnotified = $currsettings->{'selfenroll_notifylist'}; $currapproval = $currsettings->{'selfenroll_approval'}; } @@ -6179,8 +6190,8 @@ ENDSCRIPT .&mt('Save').'" onclick="validate_types(this.form);" />'; } $output .= '' - .''."\n" - .$additional.''; + .''."\n" + .$additional.''; $r->print($output); return; } @@ -6585,7 +6596,7 @@ ENDSCRIPT } } if (($context eq 'course') && ($viewablesec ne '')) { - next if ($roleslog{$id}{'logentry'}{'section'} ne $viewablesec); + next if ($roleslog{$id}{'logentry'}{'section'} ne $viewablesec); } $count ++; next if ($count < $minshown); @@ -7190,7 +7201,7 @@ sub print_helpdeskaccess_display { my ($numstatustypes,@jsarray); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($cdom); if (ref($types) eq 'ARRAY') { - if (@{$types} > 0) { + if (@{$types} > 0) { $numstatustypes = scalar(@{$types}); push(@accesstypes,'status'); @jsarray = ('bystatus'); @@ -7240,7 +7251,7 @@ sub print_helpdeskaccess_display { $elements{$role.'_staff_inc'} = 'checkbox'; $elements{$role.'_staff_exc'} = 'checkbox'; } - $elements{$role.'_override'} = 'checkbox'; + $elements{$role.'_override'} = 'checkbox'; if (ref($settings{$role}) eq 'HASH') { if ($settings{$role}{'access'} ne '') { my $curraccess = $settings{$role}{'access'}; @@ -7304,7 +7315,7 @@ function switchRoleTab(caller,role) { } } return false; -} +} function helpdeskAccess(role) { var curraccess = null; @@ -7318,11 +7329,11 @@ function helpdeskAccess(role) { var shown = Array(); var hidden = Array(); if (curraccess == 'none') { - hidden = Array ('$hiddenstr'); + hidden = Array ('$hiddenstr'); } else { if (curraccess == 'status') { - shown = Array ('bystatus','privs'); - hidden = Array ('notinc','notexc'); + shown = Array ('bystatus','privs'); + hidden = Array ('notinc','notexc'); } else { if (curraccess == 'exc') { shown = Array ('notexc','privs'); @@ -7341,7 +7352,7 @@ function helpdeskAccess(role) { if (hidden.length > 0) { for (var i=0; i 'All', 'none' => 'None', 'status' => 'Determined based on institutional status', - 'inc' => 'Include all, but exclude specific personnel', + 'inc' => 'Include all, but exclude specific personnel', 'exc' => 'Exclude all, but include specific personnel', 'hel' => 'Helpdesk', 'rpr' => 'Role privileges', @@ -7434,8 +7445,8 @@ ENDJS my @roles_by_num = (); foreach my $item (sort {$a <=> $b } (keys(%ordered))) { push(@roles_by_num,$ordered{$item}); - } - $r->print('

'.$lt{'tfh'}.': '.join(', ',map { $description{$_}; } @roles_by_num).'.'); + } + $r->print('

'.$lt{'tfh'}.': '.join(', ',map { $description{$_}; } @roles_by_num).'.'); if ($permission->{'owner'}) { $r->print('
'.$lt{'aco'}.'

'); $r->print(''. @@ -7457,7 +7468,7 @@ ENDJS my $id; if ($count == 0) { $id=' id="LC_current_minitab"'; - $visibility{$role} = ' style="display:block"'; + $visibility{$role} = ' style="display:block"'; } else { $visibility{$role} = ' style="display:none"'; } @@ -7477,11 +7488,11 @@ ENDJS priv => 'block', ); my (%selected,$overridden,$incrscheck,$indomcheck,$indomvis,$incrsvis); - if (ref($settings{$role}) eq 'HASH') { + if (ref($settings{$role}) eq 'HASH') { if ($settings{$role}{'access'} ne '') { $indomvis = ' style="display:none"'; $incrsvis = ' style="display:block"'; - $incrscheck = ' checked="checked"'; + $incrscheck = ' checked="checked"'; if ($settings{$role}{'access'} ne 'all') { $usecheck{$settings{$role}{'access'}} = $usecheck{'all'}; delete($usecheck{'all'}); @@ -7508,7 +7519,7 @@ ENDJS } } else { $indomcheck = ' checked="checked"'; - $indomvis = ' style="display:block"'; + $indomvis = ' style="display:block"'; $incrsvis = ' style="display:none"'; } $r->print('

'. @@ -7561,9 +7572,6 @@ ENDJS &role_priv_table($role,$permission,$crstype,\%full,\%levels,\%levelscurrent,$overridden{$role}). '
'); } - if ($permission->{'owner'}) { - $r->print('

'); - } } else { $r->print(&mt('Helpdesk roles have not yet been created in this domain.')); } @@ -7708,13 +7716,13 @@ sub role_priv_table { $checked = ' checked="checked"'; } $customstatus = ''.$lt{'dis'}.''; - $ineffect = $customstatus; + $ineffect = $customstatus; } elsif ((!$levelscurrent->{'course'}{$priv}) && ($on{$priv})) { if ($permission->{'owner'}) { - $checked = ' checked="checked"'; + $checked = ' checked="checked"'; } $customstatus = ''.$lt{'ena'}.''; - $ineffect = $customstatus; + $ineffect = $customstatus; } if ($permission->{'owner'}) { $output .= ''; @@ -7729,7 +7737,7 @@ sub role_priv_table { } sub get_adhocrole_settings { - my ($cid,$accesstypes,$types,$customroles,$settings,$overridden) = @_; + my ($cid,$accesstypes,$types,$customroles,$settings,$overridden) = @_; return unless ((ref($accesstypes) eq 'ARRAY') && (ref($customroles) eq 'HASH') && (ref($settings) eq 'HASH') && (ref($overridden) eq 'HASH')); foreach my $role (split(/,/,$env{'course.'.$cid.'.internal.adhocaccess'})) { @@ -7858,7 +7866,7 @@ sub update_helpdeskaccess { push(@incrs,$role); unless ($current{'access'} eq $access) { $changed{$role}{'access'} = 1; - $storehash{'internal.adhoc.'.$role} = $access; + $storehash{'internal.adhoc.'.$role} = $access; } if ($access eq 'status') { my @statuses = &Apache::loncommon::get_env_multiple('form.'.$role.'_status'); @@ -7894,7 +7902,7 @@ sub update_helpdeskaccess { my @currstaff; foreach my $person (sort(@personnel)) { if ($domhelpdesk{$person}) { - push(@stored,$person); + push(@stored,$person); } } if (ref($current{$access}) eq 'ARRAY') { @@ -7940,7 +7948,7 @@ sub update_helpdeskaccess { &Apache::lonuserutils::custom_role_privs($customroles{$role},\%full,\%levels,\%levelscurrent); my (@updatedon,@updatedoff,@override); @override = &Apache::loncommon::get_env_multiple('form.'.$role.'_override'); - if (@override) { + if (@override) { foreach my $priv (sort(keys(%full))) { next unless ($levels{'course'}{$priv}); if (grep(/^\Q$priv\E$/,@override)) { @@ -7953,7 +7961,7 @@ sub update_helpdeskaccess { } } if (@updatedon) { - $newsettings{$role}{'on'} = join('
  • ', map { &Apache::lonnet::plaintext($_,$crstype) } (@updatedon)); + $newsettings{$role}{'on'} = join('
  • ', map { &Apache::lonnet::plaintext($_,$crstype) } (@updatedon)); } if (@updatedoff) { $newsettings{$role}{'off'} = join('
  • ', map { &Apache::lonnet::plaintext($_,$crstype) } (@updatedoff)); @@ -8061,13 +8069,13 @@ sub update_helpdeskaccess { push(@roles_by_num,$ordered{$item}); } %domusage = &domain_adhoc_access(\%changed,\%domcurrent,\@accesstypes,$usertypes,$othertitle); - $r->print(&mt('Helpdesk access settings have been changed as follows').'
    '); + $r->print(&mt('Helpdesk access settings have been changed as follows').'
    '); $r->print('
      '); foreach my $role (@roles_by_num) { next unless (ref($changed{$role}) eq 'HASH'); $r->print('
    • '.&mt('Ad hoc role').': '.$description{$role}.''. '
        '); - if ($changed{$role}{'access'} || $changed{$role}{'status'} || $changed{$role}{'inc'} || $changed{$role}{'exc'}) { + if ($changed{$role}{'access'} || $changed{$role}{'status'} || $changed{$role}{'inc'} || $changed{$role}{'exc'}) { $r->print('
      • '); if ($env{'form.'.$role.'_incrs'}) { if ($newsettings{$role}{'access'} eq 'all') { @@ -8077,7 +8085,7 @@ sub update_helpdeskaccess { } elsif ($newsettings{$role}{'access'} eq 'status') { if ($newsettings{$role}{'status'}) { my ($access,$rest) = split(/=/,$storehash{'internal.adhoc.'.$role}); - if (split(/,/,$rest) > 1) { + if (split(/,/,$rest) > 1) { $r->print(&mt('Helpdesk staff can use this role if their institutional type is one of: [_1].', $newsettings{$role}{'status'})); } else { @@ -8112,15 +8120,15 @@ sub update_helpdeskaccess { $r->print('
      • '.&mt('Privileges which are available by default for this ad hoc role, but are disabled for this specific '.lc($crstype).':'). '
        • '.$newsettings{$role}{'off'}.'
      • '); } else { - $r->print('
      • '.&mt('All privileges available by default for this ad hoc role are enabled.').'
      • '); + $r->print('
      • '.&mt('All privileges available by default for this ad hoc role are enabled.').'
      • '); } } - if ($changed{$role}{'on'}) { + if ($changed{$role}{'on'}) { if ($newsettings{$role}{'on'}) { $r->print('
      • '.&mt('Privileges which are not available by default for this ad hoc role, but are enabled for this specific '.lc($crstype).':'). '
        • '.$newsettings{$role}{'on'}.'
      • '); } else { - $r->print('
      • '.&mt('None of the privileges unavailable by default for this ad hoc role are enabled.').'
      • '); + $r->print('
      • '.&mt('None of the privileges unavailable by default for this ad hoc role are enabled.').'
      • '); } } } @@ -8129,7 +8137,7 @@ sub update_helpdeskaccess { $r->print('
      '); } } else { - $r->print(&mt('No changes made to helpdesk access settings.')); + $r->print(&mt('No changes made to helpdesk access settings.')); } } return; @@ -8608,6 +8616,7 @@ sub build_search_response { ,' ' ,'') .'
      '; + } } }