--- loncom/interface/loncreateuser.pm 2017/01/21 23:30:18 1.406.2.9 +++ loncom/interface/loncreateuser.pm 2016/11/11 14:39:23 1.420 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.406.2.9 2017/01/21 23:30:18 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.420 2016/11/11 14:39:23 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); @@ -531,12 +536,91 @@ sub domainrole_req { &Apache::loncommon::end_data_table(); } +sub domadhocroles { + my ($ccuname,$ccdomain) = @_; + my $confname = &Apache::lonnet::get_domainconfiguser($env{'request.role.domain'}); + my %existing=&Apache::lonnet::dump('roles',$env{'request.role.domain'}, + $confname,'rolesdef_'); + my ($output,$canmodify); + if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) { + $canmodify = 1; + } + if (keys(%existing) > 0) { + my @current; + my $curradhoc = 'adhocroles.'.$env{'request.role.domain'}; + my %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,$curradhoc); + if ($userenv{$curradhoc}) { + @current = split(/,/,$userenv{$curradhoc}); + } + if (!$canmodify && !@current) { + return; + } + my %customroles; + foreach my $key (keys(%existing)) { + if ($key=~/^rolesdef\_(\w+)$/) { + my $rolename = $1; + my %privs; + ($privs{'system'},$privs{'domain'},$privs{'course'}) = split(/\_/,$existing{$key}); + $customroles{$rolename} = \%privs; + } + } + $output = '

'. + &mt('Ad Hoc Course Roles Selectable via Helpdesk Role'). + '

'."\n". + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(); + if ($canmodify) { + $output .= ''.&mt('Action').''; + } + $output .= ''.&mt('Role').''. + ''.&mt('Privileges in Course').''. + &Apache::loncommon::end_data_table_header_row(); + foreach my $key (sort(keys(%customroles))) { + next if ((!$canmodify) && (!grep(/^\Q$key\E$/,@current))); + $output .= &Apache::loncommon::start_data_table_row(); + if ($canmodify) { + if (grep(/^\Q$key\E$/,@current)) { + $output .= ''. + ''; + } else { + $output .= ''. + ''; + } + } + $output .= ''.$key.''; + foreach my $level ('course','domain','system') { + if ($customroles{$key}{$level}) { + my $suffix; + if (($level eq 'domain') || ($level eq 'system')) { + $suffix = ' ('.&mt($level).')'; + } + my @privs = split(/:/,$customroles{$key}{$level}); + foreach my $item (@privs) { + next if ($item eq ''); + my ($priv,$cond) = split(/\&/,$item); + $output .= &Apache::lonnet::plaintext($priv,'Course').$suffix.'
'; + } + } + } + $output .= ''. + &Apache::loncommon::end_data_table_row(); + } + $output .= &Apache::loncommon::end_data_table(); + } + return $output; +} + sub courserequest_titles { my %titles = &Apache::lonlocal::texthash ( official => 'Official', unofficial => 'Unofficial', community => 'Communities', textbook => 'Textbook', + placement => 'Placement Tests', norequest => 'Not allowed', approval => 'Approval by Dom. Coord.', validate => 'With validation', @@ -673,7 +757,7 @@ sub print_username_entry_form { } elsif ($env{'form.action'} eq 'accesslogs') { $helpitem = 'Domain_User_Access_Logs'; } - my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$defdom); + my %breadcrumb_text = &singleuser_breadcrumb($crstype); if ($env{'form.action'} eq 'custom') { push(@{$brcrum}, {href=>"javascript:backPage(document.crtuser)", @@ -701,7 +785,6 @@ sub print_username_entry_form { 'srst' => 'Search for a user and enroll as a student', 'srme' => 'Search for a user and enroll as a member', 'srad' => 'Search for a user and modify/add user information or roles', - 'srvu' => 'Search for a user and view user information and roles', 'srva' => 'Search for a user and view access log information', 'usr' => "Username", 'dom' => "Domain", @@ -757,9 +840,6 @@ sub print_username_entry_form { } } elsif ($env{'form.action'} eq 'accesslogs') { $actiontext = $lt{'srva'}; - } elsif (($env{'form.action'} eq 'singleuser') && - ($context eq 'domain') && (!&Apache::lonnet::allowed('mau',$defdom))) { - $actiontext = $lt{'srvu'}; } $r->print("

$actiontext

"); if ($env{'form.origform'} ne 'crtusername') { @@ -853,9 +933,7 @@ ENDBLOCK } else { $output = '

'.$userpicker.'

'; } - if (($env{'form.phase'} eq '') && ($env{'form.action'} ne 'accesslogs') && - (!(($env{'form.action'} eq 'singleuser') && ($context eq 'domain') && - (!&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))))) { + if (($env{'form.phase'} eq '') && ($env{'form.action'} ne 'accesslogs')) { my $defdom=$env{'request.role.domain'}; my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain'); my %lt=&Apache::lonlocal::texthash( @@ -972,9 +1050,7 @@ ENDSCRIPT 'stusrch' => "User Search to enroll student", 'memsrch' => "User Search to enroll member", 'srcva' => "Search for a user and view access log information", - 'usrvu' => "User Search to view user roles", 'usel' => "Select a user to add/modify roles", - 'suvr' => "Select a user to view roles", 'stusel' => "Select a user to enroll as a student", 'memsel' => "Select a user to enroll as a member", 'vacsel' => "Select a user to view access log", @@ -987,7 +1063,7 @@ ENDSCRIPT if ($context eq 'requestcrs') { $r->print('
'); } else { - my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$srch->{'srchdomain'}); + my %breadcrumb_text = &singleuser_breadcrumb($crstype); my $helpitem; if ($env{'form.action'} eq 'singleuser') { $helpitem = 'Course_Change_Privileges'; @@ -1007,19 +1083,9 @@ ENDSCRIPT ); $r->print(&Apache::loncommon::start_page('User Management',$jscript,{bread_crumbs => $brcrum})); if ($env{'form.action'} eq 'singleuser') { - my $readonly; - if (($context eq 'domain') && (!&Apache::lonnet::allowed('mau',$srch->{'srchdomain'}))) { - $readonly = 1; - $r->print("$lt{'usrvu'}
"); - } else { - $r->print("$lt{'usrch'}
"); - } + $r->print("$lt{'usrch'}
"); $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context,undef,$crstype)); - if ($readonly) { - $r->print('

'.$lt{'suvr'}.'

'); - } else { - $r->print('

'.$lt{'usel'}.'

'); - } + $r->print('

'.$lt{'usel'}.'

'); } elsif ($env{'form.action'} eq 'singlestudent') { $r->print($jscript.""); if ($crstype eq 'Community') { @@ -1213,7 +1279,7 @@ sub print_user_modification_page { my $js = &validation_javascript($context,$ccdomain,$pjump_def,$crstype, $groupslist,$newuser,$formname,\%loaditem); - my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$ccdomain); + my %breadcrumb_text = &singleuser_breadcrumb($crstype); my $helpitem = 'Course_Change_Privileges'; if ($env{'form.action'} eq 'singlestudent') { $helpitem = 'Course_Add_Student'; @@ -1279,7 +1345,7 @@ ENDFORMINFO } my $title = ''; if ($newuser) { - my ($portfolioform,$domroleform); + my ($portfolioform,$domroleform,$adhocroleform); 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 @@ -1289,6 +1355,12 @@ ENDFORMINFO ($ccdomain eq $env{'request.role.domain'})) { $domroleform = '
'.&domainrole_req($ccuname,$ccdomain); } + if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) { + $adhocroleform = &domadhocroles($ccuname,$ccdomain); + if ($adhocroleform) { + $adhocroleform = '
'.$adhocroleform; + } + } &initialize_authen_forms($ccdomain,$formname); my %lt=&Apache::lonlocal::texthash( 'lg' => 'Login Data', @@ -1399,7 +1471,7 @@ ENDAUTH } else { $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); } - $r->print($portfolioform.$domroleform); + $r->print($portfolioform.$domroleform.$adhocroleform); if ($env{'form.action'} eq 'singlestudent') { $r->print(&date_sections_select($context,$newuser,$formname, $permission,$crstype,$ccuname, @@ -1429,7 +1501,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()); @@ -1442,16 +1514,20 @@ ENDAUTH $r->print(&Apache::loncommon::end_data_table()); } $r->print('
'); - my @order = ('auth','quota','tools','requestauthor'); + my @order = ('auth','quota','tools','requestauthor','adhocroles'); my %user_text; my ($isadv,$isauthor) = &Apache::lonnet::is_advanced_user($ccdomain,$ccuname); 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); } + if ((&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) || + (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) { + $user_text{'adhocroles'} = &domadhocroles($ccuname,$ccdomain); + } $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname); if ((&Apache::lonnet::allowed('mpq',$ccdomain)) || (&Apache::lonnet::allowed('mut',$ccdomain)) || @@ -1520,7 +1596,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, @@ -1578,7 +1654,7 @@ ENDNOTOOLSPRIV } sub singleuser_breadcrumb { - my ($crstype,$context,$domain) = @_; + my ($crstype) = @_; my %breadcrumb_text; if ($env{'form.action'} eq 'singlestudent') { if ($crstype eq 'Community') { @@ -1586,21 +1662,16 @@ sub singleuser_breadcrumb { } else { $breadcrumb_text{'search'} = 'Enroll a student'; } - $breadcrumb_text{'userpicked'} = 'Select a user'; - $breadcrumb_text{'modify'} = 'Set section/dates'; + $breadcrumb_text{'userpicked'} = 'Select a user', + $breadcrumb_text{'modify'} = 'Set section/dates', } elsif ($env{'form.action'} eq 'accesslogs') { $breadcrumb_text{'search'} = 'View access logs for a user'; - $breadcrumb_text{'userpicked'} = 'Select a user'; - $breadcrumb_text{'activity'} = 'Activity'; - } elsif (($env{'form.action'} eq 'singleuser') && ($context eq 'domain') && - (!&Apache::lonnet::allowed('mau',$domain))) { - $breadcrumb_text{'search'} = "View user's roles"; - $breadcrumb_text{'userpicked'} = 'Select a user'; - $breadcrumb_text{'modify'} = 'User roles'; + $breadcrumb_text{'userpicked'} = 'Select a user', + $breadcrumb_text{'activity'} = 'Activity', } else { $breadcrumb_text{'search'} = 'Create/modify a user'; - $breadcrumb_text{'userpicked'} = 'Select a user'; - $breadcrumb_text{'modify'} = 'Set user role'; + $breadcrumb_text{'userpicked'} = 'Select a user', + $breadcrumb_text{'modify'} = 'Set user role', } return %breadcrumb_text; } @@ -1754,7 +1825,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)= @@ -1765,12 +1836,11 @@ sub display_existing_roles { my $class='Unknown'; my $credits=''; my $csec; - if ($area =~ m{^/($match_domain)/($match_courseid)}) { + if ($area =~ m{^/($match_domain)/($match_courseid)} ) { $class='Course'; my ($coursedom,$coursedir) = ($1,$2); my $cid = $1.'_'.$2; # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3). - next if ($envkey =~ m{^/$match_domain/$match_courseid/[A-Za-z0-9]+_gr$}); my %coursedata= &Apache::lonnet::coursedescription($cid); if ($coursedir =~ /^$match_community$/) { @@ -1899,7 +1969,7 @@ sub display_existing_roles { } else { $row.=' '; } - $row.= ''; + $row.= ''; } my $plaintext=''; if (!$croletitle) { @@ -1931,7 +2001,7 @@ sub display_existing_roles { } else { if ($context eq 'domain') { if ((&Apache::lonnet::allowed('vur',$ccdomain)) && - ($envkey=~m{^/$ccdomain/})) { + ($area=~m{^/$ccdomain/})) { $rolepriv{$envkey}='view'; } } elsif ($context eq 'course') { @@ -2168,6 +2238,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); @@ -2211,7 +2282,7 @@ ENDBADAUTH $result = &mt('Currently Kerberos authenticated, Version [_1].',$krbver); } else { $result = &mt('Currently Kerberos authenticated with domain [_1] Version [_2].', - $krbrealm,$krbver); + $krbver,$krbrealm); } } elsif ($currentauth =~ /^internal:/) { $result = &mt('Currently internally authenticated.'); @@ -2617,7 +2688,7 @@ sub update_user_data { $jsback."\n". '// ]]>'."\n". ''."\n"; - my %breadcrumb_text = &singleuser_breadcrumb($crstype,$context,$env{'form.ccdomain'}); + my %breadcrumb_text = &singleuser_breadcrumb($crstype); push (@{$brcrum}, {href => "javascript:backPage(document.userupdate)", text => $breadcrumb_text{'search'}, @@ -2726,7 +2797,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'}); @@ -2836,6 +2907,12 @@ sub update_user_data { $newcustom{'requestauthor'}, \%changeHash,'requestauthor'); } + if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) { + my @adds = &Apache::loncommon::get_env_multiple('form.adhocroleadd'); + if (&adhocrole_changes(\%changeHash)) { + $changed{'adhocroles.'.$env{'request.role.domain'}} = $changeHash{'adhocroles.'.$env{'request.role.domain'}}; + } + } } if ($canmodify_status{'inststatus'}) { if (exists($env{'form.inststatus'})) { @@ -2899,7 +2976,8 @@ sub update_user_data { 'requestcourses.community','requestcourses.textbook', 'reqcrsotherdom.official','reqcrsotherdom.unofficial', 'reqcrsotherdom.community','reqcrsotherdom.textbook', - 'requestauthor'], + 'reqcrsotherdom.placement','requestauthor', + 'adhocroles.'.$env{'request.role.domain'}], $env{'form.ccdomain'},$env{'form.ccuname'}); my ($tmp) = keys(%userenv); if ($tmp =~ /^(con_lost|error)/i) { @@ -3038,6 +3116,7 @@ sub update_user_data { &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus,$name); ($newdefquota{$name},$newsettingstatus{$name}) = ($olddefquota{$name},$oldsettingstatus{$name}); } + push(@disporder,'adhocroles'); my %canshow; if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) { $canshow{'quota'} = 1; @@ -3056,6 +3135,9 @@ sub update_user_data { if (&Apache::lonnet::allowed('cau',$env{'form.ccdomain'})) { $canshow{'requestauthor'} = 1; } + if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) { + $canshow{'adhocroles'} = 1; + } my (%changeHash,%changed); if ($oldinststatus eq '') { $oldsettings{'inststatus'} = $othertitle; @@ -3169,6 +3251,14 @@ sub update_user_data { &tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext, \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext); } + if ($userenv{'adhocroles.'.$env{'request.role.domain'}}) { + $changeHash{'adhocroles.'.$env{'request.role.domain'}} = $userenv{'adhocroles.'.$env{'request.role.domain'}}; + } + if (&adhocrole_changes(\%changeHash,\%userenv)) { + $changed{'adhocroles'} = 1; + $oldsettings{'adhocroles'} = $userenv{'adhocroles.'.$env{'request.role.domain'}}; + $newsettings{'adhocroles'} = $changeHash{'adhocroles.'.$env{'request.role.domain'}}; + } } foreach my $item (@userinfo) { if ($env{'form.c'.$item} ne $userenv{$item}) { @@ -3190,8 +3280,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}) { @@ -3210,6 +3301,9 @@ sub update_user_data { &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, $key,'reload','requestauthor'); } + } elsif ($key eq 'adhocroles') { + $newenvhash{'adhocroles.'.$env{'request.role.domain'}} = + $changeHash{'adhocroles.'.$env{'request.role.domain'}}; } elsif ($key ne 'quota') { $newenvhash{'environment.tools.'.$key} = $changeHash{'tools.'.$key}; @@ -3257,7 +3351,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,7 +3494,9 @@ 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', + 'adhocroles' => 'Ad Hoc Roles Selectable via Helpdesk Role', 'inststatus' => "Affiliation", 'prvs' => 'Previous Value:', 'chto' => 'Changed To:' @@ -3766,6 +3862,70 @@ sub tool_changes { return; } +sub adhocrole_changes { + my ($changehashref,$userenv) = @_; + my @adds = &Apache::loncommon::get_env_multiple('form.adhocroleadd'); + my @dels = &Apache::loncommon::get_env_multiple('form.adhocroledel'); + my (@saved,@added,@alladhoc,$changed); + my $adhoc_key = 'adhocroles.'.$env{'request.role.domain'}; + if (!$env{'form.makeuser'}) { + if (ref($userenv) eq 'HASH') { + my @current; + if ($userenv->{$adhoc_key}) { + @current = split(/,/,$userenv->{$adhoc_key}); + if (@dels) { + foreach my $curr (@current) { + next if ($curr eq ''); + unless (grep(/\Q$curr\E$/,@dels)) { + push(@saved,$curr); + } + } + $changed = 1; + } else { + @saved = @current; + } + } + } + } + if (@adds) { + my $confname = &Apache::lonnet::get_domainconfiguser($env{'request.role.domain'}); + my %existing=&Apache::lonnet::dump('roles',$env{'request.role.domain'}, + $confname,'rolesdef_'); + foreach my $poss (@adds) { + if (exists($existing{'rolesdef_'.$poss})) { + push(@added,$poss); + $changed = 1; + } + } + } + if (@added) { + if (@saved) { + foreach my $add (@added) { + unless (grep(/^\Q$add\E$/,@saved)) { + push(@alladhoc,$add); + } + } + } else { + push(@alladhoc,@added); + } + } + if (@saved) { + push(@alladhoc,@saved); + } + if (@alladhoc) { + my $adhocstr = join(',',sort(@alladhoc)); + $changehashref->{$adhoc_key} = $adhocstr; + } elsif (@dels) { + &Apache::lonnet::del('environment',[$adhoc_key],$env{'form.ccdomain'},$env{'form.ccuname'}); + delete($changehashref->{$adhoc_key}); + if (($env{'form.ccdomain'} eq $env{'user.domain'}) && + ($env{'form.ccuname'} eq $env{'user.name'})) { + &Apache::lonnet::delenv($adhoc_key); + } + } + return $changed; +} + sub update_roles { my ($r,$context,$showcredits) = @_; my $now=time; @@ -4375,7 +4535,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 +5176,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); @@ -5283,9 +5442,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'}) { @@ -5346,7 +5505,7 @@ sub print_main_menu { { linktext => 'User Access Log', icon => 'document-properties.png', - #help => 'Domain_User_Access_Logs', + #help => 'User_Access_Logs', url => '/adm/createuser?action=accesslogs', permission => $permission->{'activity'}, linktitle => 'View user access log.', @@ -5403,6 +5562,7 @@ sub print_main_menu { groups => 'Community Groups', }, ); + $linktext{'Placement'} = $linktext{'Course'}; my %linktitle = ( 'Course' => { @@ -5417,6 +5577,8 @@ sub print_main_menu { }, ); + $linktitle{'Placement'} = $linktitle{'Course'}; + push(@{ $menu[0]->{items} }, #Category: Single Users { linktext => $linktext{$crstype}{'single'}, @@ -6028,7 +6190,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'}; } @@ -6156,8 +6318,8 @@ ENDSCRIPT .&mt('Save').'" onclick="validate_types(this.form);" />'; } $output .= '' - .''."\n" - .$additional.''; + .''."\n" + .$additional.''; $r->print($output); return; } @@ -6562,7 +6724,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); @@ -6651,7 +6813,7 @@ sub print_useraccesslogs_display { my $form = 'document.accesslog'; # set breadcrumbs - my %breadcrumb_text = &singleuser_breadcrumb('','domain',$udom); + my %breadcrumb_text = &singleuser_breadcrumb(); push (@{$brcrum}, {href => "javascript:backPage($form)", text => $breadcrumb_text{'search'}}); @@ -6671,13 +6833,10 @@ sub print_useraccesslogs_display { push(@{$brcrum}, {href => '/adm/createuser?action=accesslogs', text => 'User access logs', - help => 'Domain_User_Access_Logs'}); + help => 'User_Access_Logs'}); my $bread_crumbs_component = 'User Access Logs'; my $args = { bread_crumbs => $brcrum, bread_crumbs_component => 'User Management'}; - if ($env{'form.popup'}) { - $args->{'no_nav_bar'} = 1; - } # set javascript my ($jsback,$elements) = &crumb_utilities(); @@ -6883,10 +7042,6 @@ ENDSCRIPT .'

'); } - if ($env{'form.popup'} == 1) { - $r->print(''."\n"); - } - # Form Footer $r->print( '' @@ -7606,20 +7761,18 @@ sub build_search_response { .&mt("Click 'Search'") .'
'; } else { - unless (($context eq 'domain') && ($env{'form.action'} eq 'singleuser')) { - my $helplink = ' href="javascript:helpMenu('."'display'".')"'; - $response .= '

'; - if ($context eq 'requestcrs') { - $response .= &mt("You are not authorized to define new users in the new course's domain - [_1].",$targetdom); - } else { - $response .= &mt("You are not authorized to create new users in your current role's domain - [_1].",$targetdom); - } - $response .= '
' - .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.' - ,' ' - ,'') - .'
'; + my $helplink = ' href="javascript:helpMenu('."'display'".')"'; + $response .= '

'; + if ($context eq 'requestcrs') { + $response .= &mt("You are not authorized to define new users in the new course's domain - [_1].",$targetdom); + } else { + $response .= &mt("You are not authorized to create new users in your current role's domain - [_1].",$targetdom); } + $response .= '
' + .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.' + ,' ' + ,'') + .'
'; } } }