--- loncom/interface/loncreateuser.pm 2016/10/22 17:57:54 1.406.2.5 +++ loncom/interface/loncreateuser.pm 2016/09/05 01:46:07 1.412 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.406.2.5 2016/10/22 17:57:54 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.412 2016/09/05 01:46:07 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -251,13 +251,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(); @@ -447,12 +449,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); @@ -527,78 +531,13 @@ 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; - 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}); - } - 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(). - ''.&mt('Action').''.&mt('Role').''. - ''.&mt('Privileges in Course').''. - &Apache::loncommon::end_data_table_header_row(); - foreach my $key (sort(keys(%customroles))) { - $output .= &Apache::loncommon::start_data_table_row(); - 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', @@ -732,8 +671,6 @@ sub print_username_entry_form { $helpitem = 'Course_Editing_Custom_Roles'; } elsif ($env{'form.action'} eq 'singlestudent') { $helpitem = 'Course_Add_Student'; - } elsif ($env{'form.action'} eq 'accesslogs') { - $helpitem = 'Domain_User_Access_Logs'; } my %breadcrumb_text = &singleuser_breadcrumb($crstype); if ($env{'form.action'} eq 'custom') { @@ -763,7 +700,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', - 'srva' => 'Search for a user and view access log information', 'usr' => "Username", 'dom' => "Domain", 'ecrp' => "Define or Edit Custom Role", @@ -816,17 +752,12 @@ sub print_username_entry_form { } else { $actiontext = $lt{'srst'}; } - } elsif ($env{'form.action'} eq 'accesslogs') { - $actiontext = $lt{'srva'}; } $r->print("

$actiontext

"); if ($env{'form.origform'} ne 'crtusername') { - if ($response) { - $r->print("\n
$response
". - '
'); - } + $r->print("\n".$response); } - $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype,1)); + $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype)); } } @@ -869,7 +800,7 @@ END } sub entry_form { - my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype,$fixeddom) = @_; + my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype) = @_; my ($usertype,$inexact); if (ref($srch) eq 'HASH') { if (($srch->{'srchin'} eq 'dom') && @@ -889,12 +820,10 @@ sub entry_form { &Apache::lonuserutils::can_create_user($dom,$context,$usertype); my ($userpicker,$cansearch) = &Apache::loncommon::user_picker($dom,$srch,$forcenewuser, - 'document.crtuser',$cancreate,$usertype,$context,$fixeddom); + 'document.crtuser',$cancreate,$usertype); my $srchbutton = &mt('Search'); if ($env{'form.action'} eq 'singlestudent') { $srchbutton = &mt('Search and Enroll'); - } elsif ($env{'form.action'} eq 'accesslogs') { - $srchbutton = &mt('Search'); } elsif ($cancreate && $responsemsg ne '' && $inexact) { $srchbutton = &mt('Search or Add New User'); } @@ -911,7 +840,7 @@ ENDBLOCK } else { $output = '

'.$userpicker.'

'; } - if (($env{'form.phase'} eq '') && ($env{'form.action'} ne 'accesslogs')) { + if ($env{'form.phase'} eq '') { my $defdom=$env{'request.role.domain'}; my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain'); my %lt=&Apache::lonlocal::texthash( @@ -1027,11 +956,9 @@ ENDSCRIPT 'usrch' => "User Search to add/modify roles", 'stusrch' => "User Search to enroll student", 'memsrch' => "User Search to enroll member", - 'srcva' => "Search for a user and view access log information", 'usel' => "Select a user to add/modify 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", 'username' => "username", 'domain' => "domain", 'lastname' => "last name", @@ -1080,10 +1007,6 @@ ENDSCRIPT $r->print($lt{'stusel'}); } $r->print(''); - } elsif ($env{'form.action'} eq 'accesslogs') { - $r->print("$lt{'srcva'}
"); - $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,'accesslogs',undef,undef,1)); - $r->print('

'.$lt{'vacsel'}.'

'); } } $r->print('
'. @@ -1318,7 +1241,7 @@ ENDFORMINFO } my $title = ''; if ($newuser) { - my ($portfolioform,$domroleform,$adhocroleform); + 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 @@ -1328,12 +1251,6 @@ 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', @@ -1444,7 +1361,7 @@ ENDAUTH } else { $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); } - $r->print($portfolioform.$domroleform.$adhocroleform); + $r->print($portfolioform.$domroleform); if ($env{'form.action'} eq 'singlestudent') { $r->print(&date_sections_select($context,$newuser,$formname, $permission,$crstype,$ccuname, @@ -1481,7 +1398,7 @@ ENDAUTH $r->print(&Apache::loncommon::end_data_table()); } $r->print(''); - my @order = ('auth','quota','tools','requestauthor','adhocroles'); + my @order = ('auth','quota','tools','requestauthor'); my %user_text; my ($isadv,$isauthor) = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain); @@ -1490,9 +1407,6 @@ ENDAUTH && ($env{'request.role.domain'} eq $ccdomain)) { $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain); } - if (&Apache::lonnet::allowed('cdh',$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))) { @@ -1619,10 +1533,6 @@ sub singleuser_breadcrumb { } $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', } else { $breadcrumb_text{'search'} = 'Create/modify a user'; $breadcrumb_text{'userpicked'} = 'Select a user', @@ -2679,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','textbook'); + my @requestcourses = ('official','unofficial','community','textbook','placement'); my @requestauthor = ('requestauthor'); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'}); @@ -2789,12 +2699,6 @@ 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'})) { @@ -2858,7 +2762,7 @@ sub update_user_data { 'requestcourses.community','requestcourses.textbook', 'reqcrsotherdom.official','reqcrsotherdom.unofficial', 'reqcrsotherdom.community','reqcrsotherdom.textbook', - 'requestauthor','adhocroles.'.$env{'request.role.domain'}], + 'reqcrsotherdom.placement','requestauthor'], $env{'form.ccdomain'},$env{'form.ccuname'}); my ($tmp) = keys(%userenv); if ($tmp =~ /^(con_lost|error)/i) { @@ -2997,7 +2901,6 @@ 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; @@ -3016,9 +2919,6 @@ 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; @@ -3132,14 +3032,6 @@ 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}) { @@ -3161,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') || ($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}) { @@ -3181,9 +3074,6 @@ 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}; @@ -3231,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 = @@ -3374,8 +3264,8 @@ 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:' @@ -3741,70 +3631,6 @@ 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; @@ -4335,7 +4161,7 @@ sub build_roles { # ========================================================== Custom Role Editor sub custom_role_editor { - my ($r,$brcrum,$prefix) = @_; + my ($r,$brcrum) = @_; my $action = $env{'form.customroleaction'}; my $rolename; if ($action eq 'new') { @@ -4350,7 +4176,7 @@ sub custom_role_editor { $context = 'course'; } else { $context = 'domain'; - $crstype = 'course'; + $crstype = $env{'form.templatecrstype'}; } $rolename=~s/[^A-Za-z0-9]//gs; @@ -4359,54 +4185,120 @@ sub custom_role_editor { return; } - my $formname = 'form1'; - my %privs=(); - my $body_top = '

'; -# ------------------------------------------------------- Does this role exist? +# ------------------------------------------------------- What can be assigned? + my %full=(); + my %courselevel=(); + my %courselevelcurrent=(); + my $syspriv=''; + my $dompriv=''; + my $coursepriv=''; + my $body_top; + my $newrole; my ($rdummy,$roledef)= &Apache::lonnet::get('roles',["rolesdef_$rolename"]); +# ------------------------------------------------------- Does this role exist? + $body_top .= '

'; if (($rdummy ne 'con_lost') && ($roledef ne '')) { - $body_top .= &mt('Existing Role').' "'; + $body_top .= &mt('Existing Role').' "'; # ------------------------------------------------- Get current role privileges - ($privs{'system'},$privs{'domain'},$privs{'course'})=split(/\_/,$roledef); - if ($privs{'system'} =~ /bre\&S/) { - if ($context eq 'domain') { - $crstype = 'Course'; - } elsif ($crstype eq 'Community') { - $privs{'system'} =~ s/bre\&S//; - } - } elsif ($context eq 'domain') { - $crstype = 'Course'; + ($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef); + if ($crstype eq 'Community') { + $syspriv =~ s/bre\&S//; } } else { - $body_top .= &mt('New Role').' "'; - $roledef=''; + $newrole = 1; + $body_top .= &mt('New Role').' "'; + $roledef=''; } $body_top .= $rolename.'"

'; - -# ------------------------------------------------------- What can be assigned? - my %full=(); - my %levels=( - course => {}, - domain => {}, - system => {}, - ); - my %levelscurrent=( - course => {}, - domain => {}, - system => {}, - ); - &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent); + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) { + my ($priv,$restrict)=split(/\&/,$item); + if (!$restrict) { $restrict='F'; } + $courselevel{$priv}=$restrict; + if ($coursepriv=~/\:$priv/) { + $courselevelcurrent{$priv}=1; + } + $full{$priv}=1; + } + my %domainlevel=(); + my %domainlevelcurrent=(); + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) { + my ($priv,$restrict)=split(/\&/,$item); + if (!$restrict) { $restrict='F'; } + $domainlevel{$priv}=$restrict; + if ($dompriv=~/\:$priv/) { + $domainlevelcurrent{$priv}=1; + } + $full{$priv}=1; + } + my %systemlevel=(); + my %systemlevelcurrent=(); + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) { + my ($priv,$restrict)=split(/\&/,$item); + if (!$restrict) { $restrict='F'; } + $systemlevel{$priv}=$restrict; + if ($syspriv=~/\:$priv/) { + $systemlevelcurrent{$priv}=1; + } + $full{$priv}=1; + } my ($jsback,$elements) = &crumb_utilities(); - my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype); - my $head_script = - &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname, - \%full,\@templateroles,$jsback); + my $button_code = "\n"; + my $head_script = "\n"; + $head_script .= ''."\n"; push (@{$brcrum}, - {href => "javascript:backPage(document.$formname,'pickrole','')", + {href => "javascript:backPage(document.form1,'pickrole','')", text => "Pick custom role", faq => 282,bug=>'Instructor Interface',}, - {href => "javascript:backPage(document.$formname,'','')", + {href => "javascript:backPage(document.form1,'','')", text => "Edit custom role", faq => 282, bug => 'Instructor Interface', @@ -4414,35 +4306,149 @@ 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); - $r->print(''."\n". - &Apache::lonuserutils::custom_role_header($context,$crstype, - \@templateroles,$prefix)); + my %lt=&Apache::lonlocal::texthash( + 'prv' => "Privilege", + 'crl' => "Course Level", + 'dml' => "Domain Level", + 'ssl' => "System Level"); + + $r->print('
' + .'
' + .''.&mt('Select a Template').'' + .$button_code + .'
'); + if ($context_code) { + $r->print('
' + .'
' + .''.&mt('Context').'' + .$context_code + .'' + .'
' + ); + } + $r->print('
'); $r->print(< ENDCCF - $r->print(&Apache::lonuserutils::custom_role_table($crstype,\%full,\%levels, - \%levelscurrent,$prefix)); + $r->print(&Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). +''.$lt{'prv'}.''.$lt{'crl'}.''.$lt{'dml'}. +''.$lt{'ssl'}.''. + &Apache::loncommon::end_data_table_header_row()); + foreach my $priv (sort(keys(%full))) { + my $privtext = &Apache::lonnet::plaintext($priv,$crstype); + $r->print(&Apache::loncommon::start_data_table_row(). + ''.$privtext.''. + ($courselevel{$priv}?'':' '). + ''. + ($domainlevel{$priv}?'':' '). + ''); + if ($priv eq 'bre' && $crstype eq 'Community') { + $r->print(' '); + } else { + $r->print($systemlevel{$priv}?'':' '); + } + $r->print(''. + &Apache::loncommon::end_data_table_row()); + } $r->print(&Apache::loncommon::end_data_table(). ''. ''."\n".''."\n". + '" />'."\n".''."\n". ''."\n". ''); } - +# -------------------------------------------------------- +sub make_script_template { + my ($role,$crstype) = @_; + my %full_c=(); + my %full_d=(); + my %full_s=(); + my $return_script; + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) { + my ($priv,$restrict)=split(/\&/,$item); + $full_c{$priv}=1; + } + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) { + my ($priv,$restrict)=split(/\&/,$item); + $full_d{$priv}=1; + } + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) { + next if (($crstype eq 'Community') && ($item eq 'bre&S')); + my ($priv,$restrict)=split(/\&/,$item); + $full_s{$priv}=1; + } + $return_script .= 'function set_'.$role.'() {'."\n"; + my @temp = split(/:/,$Apache::lonnet::pr{$role.':c'}); + my %role_c; + foreach my $priv (@temp) { + my ($priv_item, $dummy) = split(/\&/,$priv); + $role_c{$priv_item} = 1; + } + my %role_d; + @temp = split(/:/,$Apache::lonnet::pr{$role.':d'}); + foreach my $priv(@temp) { + my ($priv_item, $dummy) = split(/\&/,$priv); + $role_d{$priv_item} = 1; + } + my %role_s; + @temp = split(/:/,$Apache::lonnet::pr{$role.':s'}); + foreach my $priv(@temp) { + my ($priv_item, $dummy) = split(/\&/,$priv); + $role_s{$priv_item} = 1; + } + foreach my $priv_item (keys(%full_c)) { + my ($priv, $dummy) = split(/\&/,$priv_item); + if ((exists($role_c{$priv})) || (exists($role_d{$priv})) || + (exists($role_s{$priv}))) { + $return_script .= "document.form1.$priv"."_c.checked = true;\n"; + } else { + $return_script .= "document.form1.$priv"."_c.checked = false;\n"; + } + } + foreach my $priv_item (keys(%full_d)) { + my ($priv, $dummy) = split(/\&/,$priv_item); + if ((exists($role_d{$priv})) || (exists($role_s{$priv}))) { + $return_script .= "document.form1.$priv"."_d.checked = true;\n"; + } else { + $return_script .= "document.form1.$priv"."_d.checked = false;\n"; + } + } + foreach my $priv_item (keys(%full_s)) { + my ($priv, $dummy) = split(/\&/,$priv_item); + if (exists($role_s{$priv})) { + $return_script .= "document.form1.$priv"."_s.checked = true;\n"; + } else { + $return_script .= "document.form1.$priv"."_s.checked = false;\n"; + } + } + $return_script .= '}'."\n"; + return ($return_script); +} +# ---------------------------------------------------------- +sub make_button_code { + my ($role,$crstype) = @_; + my $label = &Apache::lonnet::plaintext($role,$crstype); + my $button_code = ''; + return ($button_code); +} # ---------------------------------------------------------- Call to definerole sub set_custom_role { - my ($r,$context,$brcrum,$prefix) = @_; + my ($r,$context,$brcrum) = @_; my $rolename=$env{'form.rolename'}; $rolename=~s/[^A-Za-z0-9]//gs; if (!$rolename) { - &custom_role_editor($r,$brcrum,$prefix); + &custom_role_editor($r,$brcrum); return; } my ($jsback,$elements) = &crumb_utilities(); @@ -4467,7 +4473,7 @@ sub set_custom_role { help => 'Course_Editing_Custom_Roles'}, ); my $args = { bread_crumbs => $brcrum, - bread_crumbs_component => 'User Management'}; + bread_crumbs_component => 'User Management'}; $r->print(&Apache::loncommon::start_page('Save Custom Role',$jscript,$args)); my $newrole; @@ -4484,13 +4490,38 @@ sub set_custom_role { $newrole = 1; } $r->print($rolename.'"'); -# ------------------------------------------------- Assign role and show result +# ------------------------------------------------------- What can be assigned? + my $sysrole=''; + my $domrole=''; + my $courole=''; + + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) { + my ($priv,$restrict)=split(/\&/,$item); + if (!$restrict) { $restrict=''; } + if ($env{'form.'.$priv.'_c'}) { + $courole.=':'.$item; + } + } + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) { + my ($priv,$restrict)=split(/\&/,$item); + if (!$restrict) { $restrict=''; } + if ($env{'form.'.$priv.'_d'}) { + $domrole.=':'.$item; + } + } + + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) { + my ($priv,$restrict)=split(/\&/,$item); + if (!$restrict) { $restrict=''; } + if ($env{'form.'.$priv.'_s'}) { + $sysrole.=':'.$item; + } + } + # Assign role; Compile and show result my $errmsg; - my %newprivs = &Apache::lonuserutils::custom_role_update($rolename,$prefix); - # Assign role and return result - my $result = &Apache::lonnet::definerole($rolename,$newprivs{'s'},$newprivs{'d'}, - $newprivs{'c'}); + my $result = + &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole); if ($result ne 'ok') { $errmsg = ': '.$result; } @@ -4618,9 +4649,8 @@ sub handler { } else { &Apache::lonuserutils::print_first_users_upload_form($r,$context); } - } elsif (((($env{'form.action'} eq 'singleuser') || ($env{'form.action'} - eq 'singlestudent')) && ($permission->{'cusr'})) || - (($env{'form.action'} eq 'accesslogs') && ($permission->{'activity'}))) { + } elsif ((($env{'form.action'} eq 'singleuser') || ($env{'form.action'} + eq 'singlestudent')) && ($permission->{'cusr'})) { my $phase = $env{'form.phase'}; my @search = ('srchterm','srchby','srchin','srchtype','srchdomain'); &Apache::loncreateuser::restore_prev_selections(); @@ -4629,7 +4659,7 @@ sub handler { $srch->{$item} = $env{'form.'.$item}; } if (($phase eq 'get_user_info') || ($phase eq 'userpicked') || - ($phase eq 'createnewuser') || ($phase eq 'activity')) { + ($phase eq 'createnewuser')) { if ($env{'form.phase'} eq 'createnewuser') { my $response; if ($env{'form.srchterm'} !~ /^$match_username$/) { @@ -4659,8 +4689,8 @@ sub handler { &print_user_selection_page($r,$response,$srch,$results, \@search,$context,undef,$crstype, $brcrum); - } elsif (($currstate eq 'modify') || ($env{'form.action'} eq 'accesslogs')) { - my ($ccuname,$ccdomain,$uhome); + } elsif ($currstate eq 'modify') { + my ($ccuname,$ccdomain); if (($srch->{'srchby'} eq 'uname') && ($srch->{'srchtype'} eq 'exact')) { $ccuname = $srch->{'srchterm'}; @@ -4671,32 +4701,12 @@ sub handler { } $ccuname =&LONCAPA::clean_username($ccuname); $ccdomain=&LONCAPA::clean_domain($ccdomain); - if ($env{'form.action'} eq 'accesslogs') { - my $uhome; - if (($ccuname ne '') && ($ccdomain ne '')) { - $uhome = &Apache::lonnet::homeserver($ccuname,$ccdomain); - } - if (($uhome eq '') || ($uhome eq 'no_host')) { - $env{'form.phase'} = ''; - undef($forcenewuser); - #if ($response) { - # unless ($response =~ m{\Q

\E$}) { - # $response .= '

'; - # } - #} - &print_username_entry_form($r,$context,$response,$srch, - $forcenewuser,$crstype,$brcrum); - } else { - &print_useraccesslogs_display($r,$ccuname,$ccdomain,$permission,$brcrum); - } - } else { - if ($env{'form.forcenewuser'}) { - $response = ''; - } - &print_user_modification_page($r,$ccuname,$ccdomain, - $srch,$response,$context, - $permission,$crstype,$brcrum); + if ($env{'form.forcenewuser'}) { + $response = ''; } + &print_user_modification_page($r,$ccuname,$ccdomain, + $srch,$response,$context, + $permission,$crstype,$brcrum); } elsif ($currstate eq 'query') { &print_user_query_page($r,'createuser',$brcrum); } else { @@ -4707,17 +4717,9 @@ sub handler { } elsif ($env{'form.phase'} eq 'userpicked') { my $ccuname = &LONCAPA::clean_username($env{'form.seluname'}); my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'}); - if ($env{'form.action'} eq 'accesslogs') { - &print_useraccesslogs_display($r,$ccuname,$ccdomain,$permission,$brcrum); - } else { - &print_user_modification_page($r,$ccuname,$ccdomain,$srch,'', - $context,$permission,$crstype, - $brcrum); - } - } elsif ($env{'form.action'} eq 'accesslogs') { - my $ccuname = &LONCAPA::clean_username($env{'form.accessuname'}); - my $ccdomain = &LONCAPA::clean_domain($env{'form.accessudom'}); - &print_useraccesslogs_display($r,$ccuname,$ccdomain,$permission,$brcrum); + &print_user_modification_page($r,$ccuname,$ccdomain,$srch,'', + $context,$permission,$crstype, + $brcrum); } } elsif ($env{'form.phase'} eq 'update_user_data') { &update_user_data($r,$context,$crstype,$brcrum,$showcredits); @@ -4726,11 +4728,10 @@ sub handler { $brcrum); } } elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) { - my $prefix; if ($env{'form.phase'} eq 'set_custom_roles') { - &set_custom_role($r,$context,$brcrum,$prefix); + &set_custom_role($r,$context,$brcrum); } else { - &custom_role_editor($r,$brcrum,$prefix); + &custom_role_editor($r,$brcrum); } } elsif (($env{'form.action'} eq 'processauthorreq') && ($permission->{'cusr'}) && @@ -5056,7 +5057,19 @@ sub handler { $cdom,$cnum,$coursedesc)); } } elsif ($env{'form.action'} eq 'changelogs') { - &print_userchangelogs_display($r,$context,$permission,$brcrum); + my $helpitem; + if ($context eq 'course') { + $helpitem = 'Course_User_Logs'; + } + push (@{$brcrum}, + {href => '/adm/createuser?action=changelogs', + text => 'User Management Logs', + help => $helpitem}); + $bread_crumbs_component = 'User Changes'; + $args = { bread_crumbs => $brcrum, + bread_crumbs_component => $bread_crumbs_component}; + $r->print(&header(undef,$args)); + &print_userchangelogs_display($r,$context,$permission); } else { $bread_crumbs_component = 'User Management'; $args = { bread_crumbs => $brcrum, @@ -5346,18 +5359,8 @@ sub print_main_menu { {categorytitle => 'Administration', items => [ ]}, ); - + if ($context eq 'domain'){ - push(@{ $menu[0]->{items} }, # Single Users - { - linktext => 'User Access Log', - icon => 'document-properties.png', - #help => 'User_Access_Logs', - url => '/adm/createuser?action=accesslogs', - permission => $permission->{'activity'}, - linktitle => 'View user access log.', - } - ); push(@{ $menu[2]->{items} }, #Category: Administration { @@ -5409,6 +5412,7 @@ sub print_main_menu { groups => 'Community Groups', }, ); + $linktext{'Placement'} = $linktext{'Course'}; my %linktitle = ( 'Course' => { @@ -5423,6 +5427,8 @@ sub print_main_menu { }, ); + $linktitle{'Placement'} = $linktitle{'Course'}; + push(@{ $menu[0]->{items} }, #Category: Single Users { linktext => $linktext{$crstype}{'single'}, @@ -6413,7 +6419,7 @@ sub selfenroll_date_forms { } sub print_userchangelogs_display { - my ($r,$context,$permission,$brcrum) = @_; + my ($r,$context,$permission) = @_; my $formname = 'rolelog'; my ($username,$domain,$crstype,%roleslog); if ($context eq 'domain') { @@ -6443,32 +6449,6 @@ sub print_userchangelogs_display { } if ((keys(%roleslog))[0]=~/^error\:/) { undef(%roleslog); } - my $helpitem; - if ($context eq 'course') { - $helpitem = 'Course_User_Logs'; - } - push (@{$brcrum}, - {href => '/adm/createuser?action=changelogs', - text => 'User Management Logs', - help => $helpitem}); - my $bread_crumbs_component = 'User Changes'; - my $args = { bread_crumbs => $brcrum, - bread_crumbs_component => $bread_crumbs_component}; - - # Create navigation javascript - my $jsnav = &userlogdisplay_js($formname); - - my $jscript = (< -// - -ENDSCRIPT - - # print page header - $r->print(&header($jscript,$args)); - # set defaults my $now = time(); my $defstart = $now - (7*24*3600); #7 days ago @@ -6501,9 +6481,7 @@ ENDSCRIPT my ($minshown,$maxshown); $minshown = 1; my $count = 0; - if ($curr{'show'} =~ /\D/) { - $curr{'page'} = 1; - } else { + if ($curr{'show'} ne &mt('all')) { $maxshown = $curr{'page'} * $curr{'show'}; if ($curr{'page'} > 1) { $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'}; @@ -6515,6 +6493,8 @@ ENDSCRIPT &role_display_filter($context,$formname,$domain,$username,\%curr, $version,$crstype)); + # Create navigation + my ($nav_script,$nav_links) = &userlogdisplay_nav($formname,\%curr,$more_records); my $showntableheader = 0; # Table Header @@ -6539,7 +6519,7 @@ ENDSCRIPT foreach my $id (sort { $roleslog{$b}{'exe_time'}<=>$roleslog{$a}{'exe_time'} } (keys(%roleslog))) { next if (($roleslog{$id}{'exe_time'} < $curr{'rolelog_start_date'}) || ($roleslog{$id}{'exe_time'} > $curr{'rolelog_end_date'})); - if ($curr{'show'} !~ /\D/) { + if ($curr{'show'} ne &mt('all')) { if ($count >= $curr{'page'} * $curr{'show'}) { $more_records = 1; last; @@ -6558,7 +6538,9 @@ ENDSCRIPT $count ++; next if ($count < $minshown); unless ($showntableheader) { - $r->print(&Apache::loncommon::start_data_table() + $r->print($nav_script + .$nav_links + .&Apache::loncommon::start_data_table() .$tableheader); $r->rflush(); $showntableheader = 1; @@ -6619,8 +6601,8 @@ ENDSCRIPT } if ($showntableheader) { # Table footer, if content displayed above - $r->print(&Apache::loncommon::end_data_table(). - &userlogdisplay_navlinks(\%curr,$more_records)); + $r->print(&Apache::loncommon::end_data_table() + .$nav_links); } else { # No content displayed above $r->print('

' .&mt('There are no records to display.') @@ -6636,328 +6618,15 @@ ENDSCRIPT return; } -sub print_useraccesslogs_display { - my ($r,$uname,$udom,$permission,$brcrum) = @_; - my $formname = 'accesslog'; - my $form = 'document.accesslog'; - -# set breadcrumbs - my %breadcrumb_text = &singleuser_breadcrumb(); - push (@{$brcrum}, - {href => "javascript:backPage($form)", - text => $breadcrumb_text{'search'}}); - my (@prevphases,$prevphasestr); - if ($env{'form.prevphases'}) { - @prevphases = split(/,/,$env{'form.prevphases'}); - $prevphasestr = $env{'form.prevphases'}; - } - if (($env{'form.phase'} eq 'userpicked') || (grep(/^userpicked$/,@prevphases))) { - push(@{$brcrum}, - {href => "javascript:backPage($form,'get_user_info','select')", - text => $breadcrumb_text{'userpicked'}}); - if ($env{'form.phase'} eq 'userpicked') { - $prevphasestr = 'userpicked'; - } - } - push(@{$brcrum}, - {href => '/adm/createuser?action=accesslogs', - text => 'User access logs', - help => 'User_Access_Logs'}); - my $bread_crumbs_component = 'User Access Logs'; - my $args = { bread_crumbs => $brcrum, - bread_crumbs_component => 'User Management'}; - -# set javascript - my ($jsback,$elements) = &crumb_utilities(); - my $jsnav = &userlogdisplay_js($formname); - - my $jscript = (< // - - -ENDSCRIPT - -# print page header - $r->print(&header($jscript,$args)); - -# early out unless log data can be displayed. - unless ($permission->{'activity'}) { - $r->print('

' - .&mt('You do not have rights to display user access logs.') - .'

' - .&earlyout_accesslog_form($formname,$prevphasestr,$udom)); - return; - } - - unless ($udom eq $env{'request.role.domain'}) { - $r->print('

' - .&mt("User's domain must match role's domain") - .'

' - .&earlyout_accesslog_form($formname,$prevphasestr,$udom)); - return; - } - - if (($uname eq '') || ($udom eq '')) { - $r->print('

' - .&mt('Invalid username or domain') - .'

' - .&earlyout_accesslog_form($formname,$prevphasestr,$udom)); - return; - } - -# set defaults - my $now = time(); - my $defstart = $now - (7*24*3600); - my %defaults = ( - page => '1', - show => '10', - activity => 'any', - accesslog_start_date => $defstart, - accesslog_end_date => $now, - ); - my $more_records = 0; - -# set current - my %curr; - foreach my $item ('show','page','activity') { - $curr{$item} = $env{'form.'.$item}; - } - my ($startdate,$enddate) = - &Apache::lonuserutils::get_dates_from_form('accesslog_start_date','accesslog_end_date'); - $curr{'accesslog_start_date'} = $startdate; - $curr{'accesslog_end_date'} = $enddate; - foreach my $key (keys(%defaults)) { - if ($curr{$key} eq '') { - $curr{$key} = $defaults{$key}; - } - } - my ($minshown,$maxshown); - $minshown = 1; - my $count = 0; - if ($curr{'show'} =~ /\D/) { - $curr{'page'} = 1; - } else { - $maxshown = $curr{'page'} * $curr{'show'}; - if ($curr{'page'} > 1) { - $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'}; - } - } - -# form header - $r->print('
'. - &activity_display_filter($formname,\%curr)); - - my $showntableheader = 0; - my ($nav_script,$nav_links); - -# table header - my $tableheader = - &Apache::loncommon::start_data_table_header_row() - .' ' - .''.&mt('When').'' - .''.&mt('HostID').'' - .''.&mt('Event').'' - .''.&mt('Other data').'' - .&Apache::loncommon::end_data_table_header_row(); - - my %filters=( - start => $curr{'accesslog_start_date'}, - end => $curr{'accesslog_end_date'}, - action => $curr{'activity'}, - ); - - my $reply = &Apache::lonnet::userlog_query($uname,$udom,%filters); - unless ( ($reply =~/^timeout/) || ($reply =~/^error/) ) { - my (%courses,%missing); - my @results = split(/\&/,$reply); - foreach my $item (reverse(@results)) { - my ($timestamp,$host,$event) = split(/:/,$item); - next unless ($event =~ /^(Log|Role)/); - if ($curr{'show'} !~ /\D/) { - if ($count >= $curr{'page'} * $curr{'show'}) { - $more_records = 1; - last; - } - } - $count ++; - next if ($count < $minshown); - unless ($showntableheader) { - $r->print($nav_script - .&Apache::loncommon::start_data_table() - .$tableheader); - $r->rflush(); - $showntableheader = 1; - } - my ($shown,$extra,); - my ($event,$data) = split(/\s+/,&unescape($event)); - if ($event eq 'Role') { - my ($rolecode,$extent) = split(/\./,$data,2); - next if ($extent eq ''); - my ($crstype,$desc,$info); - if ($extent =~ m{^/($match_domain)/($match_courseid)$}) { - my ($cdom,$cnum) = ($1,$2); - my $cid = $cdom.'_'.$cnum; - if (exists($courses{$cid})) { - $crstype = $courses{$cid}{'type'}; - $desc = $courses{$cid}{'description'}; - } elsif ($missing{$cid}) { - $crstype = 'Course'; - $desc = 'Course/Community'; - } else { - my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.'); - if (ref($crsinfo{$cdom.'_'.$cnum}) eq 'HASH') { - $courses{$cid} = $crsinfo{$cid}; - $crstype = $crsinfo{$cid}{'type'}; - $desc = $crsinfo{$cid}{'description'}; - } else { - $missing{$cid} = 1; - } - } - $extra = &mt($crstype).': '.$desc.''; - } elsif ($extent =~ m{^/($match_domain)/($match_username|$)}) { - my ($dom,$name) = ($1,$2); - if ($rolecode eq 'au') { - $extra = ''; - } elsif ($rolecode =~ /^(ca|aa)$/) { - $extra = &mt('Authoring Space: [_1]',$name.':'.$dom); - } elsif ($rolecode =~ /^(li|dg|dh|dc|sc)$/) { - $extra = &mt('Domain: [_1]',$dom); - } - } - my $rolename; - if ($rolecode =~ m{^cr/($match_domain)/($match_username)/(\w+)}) { - my $role = $3; - my $owner = "($2:$1)"; - if ($2 eq $1.'-domainconfig') { - $owner = '(ad hoc)'; - } - $rolename = &mt('Custom role: [_1]',$role.' '.$owner); - } else { - $rolename = &Apache::lonnet::plaintext($rolecode,$crstype); - } - $shown = &mt('Role selection: [_1]',$rolename); - } else { - $shown = &mt($event); - if ($data ne '') { - $extra = &mt('Client IP address: [_1]',$data); - } - } - $r->print( - &Apache::loncommon::start_data_table_row() - .''.$count.'' - .''.&Apache::lonlocal::locallocaltime($timestamp).'' - .''.$host.'' - .''.$shown.'' - .''.$extra.'' - .&Apache::loncommon::end_data_table_row()."\n"); - } - } - - if ($showntableheader) { # Table footer, if content displayed above - $r->print(&Apache::loncommon::end_data_table(). - &userlogdisplay_navlinks(\%curr,$more_records)); - } else { # No content displayed above - $r->print('

' - .&mt('There are no records to display.') - .'

'); - } - - # Form Footer - $r->print( - '' - .'' - .'' - .'' - .'' - .'' - .'' - .'' - .'' - .'' - .'' - .'' - .'
'); - return; -} - -sub earlyout_accesslog_form { - my ($formname,$prevphasestr,$udom) = @_; - my $srchterm = &HTML::Entities::encode($env{'form.srchterm'},'<>"&'); - return <<"END"; -
- - - - - - - - - -
-END -} - -sub activity_display_filter { - my ($formname,$curr) = @_; - my $nolink = 1; - my $output = ''; - my $startform = - &Apache::lonhtmlcommon::date_setter($formname,'accesslog_start_date', - $curr->{'accesslog_start_date'},undef, - undef,undef,undef,undef,undef,undef,$nolink); - my $endform = - &Apache::lonhtmlcommon::date_setter($formname,'accesslog_end_date', - $curr->{'accesslog_end_date'},undef, - undef,undef,undef,undef,undef,undef,$nolink); - my %lt = &Apache::lonlocal::texthash ( - activity => 'Activity', - Role => 'Role selection', - log => 'Log-in or Logout', - ); - $output .= ''. - ''. - ''. - '
'. - ''.&mt('Actions/page:').'
'. - &Apache::lonmeta::selectbox('show',$curr->{'show'},undef, - (&mt('all'),5,10,20,50,100,1000,10000)). - '
  '.&mt('Window during which actions occurred:').'
'. - ''. - ''. - '
'.&mt('After:'). - ''.$startform.'
'.&mt('Before:').''.$endform.'
'. - '
  '.&mt('Activities').'
'. - '
'; - # Update Display button - $output .= '

' - .'' - .'

'; - return $output; -} - -sub userlogdisplay_js { - my ($formname) = @_; - return <<"ENDSCRIPT"; - function chgPage(caller) { if (caller == 'previous') { document.$formname.page.value --; @@ -6968,30 +6637,28 @@ function chgPage(caller) { document.$formname.submit(); return; } +// ]]> + ENDSCRIPT -} - -sub userlogdisplay_navlinks { - my ($curr,$more_records) = @_; - return unless(ref($curr) eq 'HASH'); - # Navigation Buttons - my $nav_links = '

'; - if (($curr->{'page'} > 1) || ($more_records)) { - if (($curr->{'page'} > 1) && ($curr->{'show'} !~ /\D/)) { - $nav_links .= ' '; - } - if ($more_records) { - $nav_links .= ''; + # Navigation Buttons + $nav_links = '

'; + if (($curr->{'page'} > 1) || ($more_records)) { + if ($curr->{'page'} > 1) { + $nav_links .= ' '; + } + if ($more_records) { + $nav_links .= ''; + } } + $nav_links .= '

'; } - $nav_links .= '

'; - return $nav_links; + return ($nav_script,$nav_links); } sub role_display_filter { @@ -7171,28 +6838,28 @@ sub user_search_result { } } if ($response ne '') { - $response = ''.$response.'
'; + $response = ''.$response.''; } if ($srch->{'srchin'} eq 'instd') { my $instd_chk = &instdirectorysrch_check($srch); if ($instd_chk ne 'ok') { my $domd_chk = &domdirectorysrch_check($srch); - $response .= ''.$instd_chk.'
'; + $response = ''.$instd_chk.'
'; if ($domd_chk eq 'ok') { - $response .= &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.'); + $response = &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.'); } - $response .= '
'; + $response .= '

'; } } else { - unless (($context eq 'requestcrs') && ($srch->{'srchtype'} eq 'exact')) { + unless (($context eq 'requestcrs') && ($srch->{'srchtype'} eq 'exact')) { my $domd_chk = &domdirectorysrch_check($srch); if ($domd_chk ne 'ok') { my $instd_chk = &instdirectorysrch_check($srch); - $response .= ''.$domd_chk.'
'; + $response = ''.$domd_chk.'
'; if ($instd_chk eq 'ok') { - $response .= &mt('You may want to search in the institutional directory instead of the LON-CAPA domain.'); + $response = &mt('You may want to search in the institutional directory instead of the LON-CAPA domain.'); } - $response .= '
'; + $response .= '

'; } } } @@ -7223,9 +6890,6 @@ sub user_search_result { &build_search_response($context,$srch,%srch_results); } else { $currstate = 'modify'; - if ($env{'form.action'} eq 'accesslogs') { - $currstate = 'activity'; - } my $uname = $srch->{'srchterm'}; my $udom = $srch->{'srchdomain'}; $srch_results{$uname.':'.$udom} = @@ -7292,7 +6956,7 @@ sub user_search_result { &mt('Institutional directory search is not available in domain: [_1]',$showdom). '
'. &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.'). - '
'; + '

'; } } } else { @@ -7365,7 +7029,7 @@ sub user_search_result { &mt('Institutional directory search is not available in domain: [_1]',$showdom). '
'. &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.'). - '
'; + '

'; } } } @@ -7513,11 +7177,7 @@ sub build_search_response { $currstate = 'select'; } else { if (keys(%srch_results) == 1) { - if ($env{'form.action'} eq 'accesslogs') { - $currstate = 'activity'; - } else { - $currstate = 'modify'; - } + $currstate = 'modify'; $response = &mt("$single{$srch->{'srchtype'}} was found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'}); if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') { $response .= ': '.&display_domain_info($srch->{'srchdomain'}); @@ -7562,8 +7222,7 @@ sub build_search_response { $createdom = $env{'form.coursedom'}; } } - unless (($env{'form.action'} eq 'accesslogs') || (($srch->{'srchby'} eq 'uname') && ($srch->{'srchin'} eq 'dom') && - ($srch->{'srchtype'} eq 'exact') && ($srch->{'srchdomain'} eq $createdom))) { + if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $createdom)) { my $cancreate = &Apache::lonuserutils::can_create_user($createdom,$context); my $targetdom = ''.$createdom.''; @@ -7598,7 +7257,7 @@ sub build_search_response { .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.' ,' ' ,'') - .'
'; + .'

'; } } }