--- loncom/interface/loncreateuser.pm 2010/10/08 01:59:39 1.351 +++ loncom/interface/loncreateuser.pm 2013/07/19 18:24:17 1.381 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.351 2010/10/08 01:59:39 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.381 2013/07/19 18:24:17 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -111,77 +111,53 @@ sub initialize_authen_forms { sub auth_abbrev { my %abv_auth = ( - krb5 => 'krb', - krb4 => 'krb', - internal => 'int', - localuth => 'loc', - unix => 'fsys', + krb5 => 'krb', + krb4 => 'krb', + internal => 'int', + localauth => 'loc', + unix => 'fsys', ); return %abv_auth; } # ==================================================== -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 +165,71 @@ 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". + ' '.$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"; + } + } $output .= &Apache::loncommon::end_data_table(); return $output; } @@ -223,6 +241,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)", 'portfolio' => "Personal User Portfolio", 'avai' => "Available", 'cusa' => "availability", @@ -232,6 +251,7 @@ sub build_tools_display { 'official' => 'Can request creation of official courses', 'unofficial' => 'Can request creation of unofficial courses', 'community' => 'Can request creation of communities', + 'requestauthor' => 'Can request author space', ); if ($context eq 'requestcourses') { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, @@ -246,10 +266,21 @@ sub build_tools_display { %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain); $isadv = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain); + } elsif ($context eq 'requestauthor') { + %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, + 'requestauthor'); + @usertools = ('requestauthor'); + @options =('norequest','approval','automatic'); + %reqtitles = &requestauthor_titles(); + %reqdisplay = &requestauthor_display(); + $colspan = ' colspan="2"'; + %domconfig = + &Apache::lonnet::get_dom('configuration',['requestauthor'],$ccdomain); } else { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, - 'tools.aboutme','tools.portfolio','tools.blog'); - @usertools = ('aboutme','blog','portfolio'); + 'tools.aboutme','tools.portfolio','tools.blog', + 'tools.webdav'); + @usertools = ('aboutme','blog','webdav','portfolio'); } foreach my $item (@usertools) { my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off, @@ -259,7 +290,12 @@ sub build_tools_display { $curr_access = &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef, $context); - if ($userenv{$context.'.'.$item} ne '') { + if ($context eq 'requestauthor') { + if ($userenv{$context} ne '') { + $cust_on = ' checked="checked" '; + $cust_off = ''; + } + } elsif ($userenv{$context.'.'.$item} ne '') { $cust_on = ' checked="checked" '; $cust_off = ''; } @@ -269,6 +305,12 @@ sub build_tools_display { } else { $custom_access = &mt('Currently from custom setting.'); } + } elsif ($context eq 'requestauthor') { + if ($userenv{$context} eq '') { + $custom_access = &mt('Currently from default setting.'); + } else { + $custom_access = &mt('Currently from custom setting.'); + } } else { if ($userenv{$context.'.'.$item} eq '') { $custom_access = @@ -290,15 +332,27 @@ sub build_tools_display { ' '.$lt{$item}.''."\n". ' '."\n". &Apache::loncommon::start_data_table_row()."\n"; - if ($context eq 'requestcourses') { + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { my ($curroption,$currlimit); - if ($userenv{$context.'.'.$item} ne '') { - $curroption = $userenv{$context.'.'.$item}; + my $envkey = $context.'.'.$item; + if ($context eq 'requestauthor') { + $envkey = $context; + } + if ($userenv{$envkey} ne '') { + $curroption = $userenv{$envkey}; } else { my (@inststatuses); - $curroption = - &Apache::loncoursequeueadmin::get_processtype($ccuname,$ccdomain,$isadv,$ccdomain, - $item,\@inststatuses,\%domconfig); + if ($context eq 'requestcourses') { + $curroption = + &Apache::loncoursequeueadmin::get_processtype('course',$ccuname,$ccdomain, + $isadv,$ccdomain,$item, + \@inststatuses,\%domconfig); + } else { + $curroption = + &Apache::loncoursequeueadmin::get_processtype('requestauthor',$ccuname,$ccdomain, + $isadv,$ccdomain,undef, + \@inststatuses,\%domconfig); + } } if (!$curroption) { $curroption = 'norequest'; @@ -336,28 +390,36 @@ sub build_tools_display { $checked = ' checked="checked"'; } } + my $name = 'crsreq_'.$item; + if ($context eq 'requestauthor') { + $name = $item; + } $custdisp .= ' '; if ($option eq 'autolimit') { - $custdisp .= '
'. $reqtitles{'unlimited'}; - } else { - $custdisp .= ''; - } - $custdisp .= ''; + } else { + $custdisp .= ''; + } + $custdisp .= ''; } $custdisp .= ''; $custradio = ''.&mt('Custom setting').'
'.$custdisp; } else { $currdisp = ($curr_access?&mt('Yes'):&mt('No')); + my $name = $context.'_'.$item; + if ($context eq 'requestauthor') { + $name = $context; + } $custdisp = '  '; $custradio = (' 'x2).'--'.$lt{'cusa'}.': '.$custdisp. ''; @@ -453,6 +515,17 @@ sub coursereq_externaluser { return $output; } +sub domainrole_req { + my ($ccuname,$ccdomain) = @_; + return '

'. + &mt('User Can Request Assignment of Domain Roles?'). + '

'."\n". + &Apache::loncommon::start_data_table(). + &build_tools_display($ccuname,$ccdomain, + 'requestauthor'). + &Apache::loncommon::end_data_table(); +} + sub courserequest_titles { my %titles = &Apache::lonlocal::texthash ( official => 'Official', @@ -476,6 +549,80 @@ sub courserequest_display { return %titles; } +sub requestauthor_titles { + my %titles = &Apache::lonlocal::texthash ( + norequest => 'Not allowed', + approval => 'Approval by Dom. Coord.', + automatic => 'Automatic approval', + ); + return %titles; + +} + +sub requestauthor_display { + my %titles = &Apache::lonlocal::texthash ( + approval => 'Yes, need approval', + automatic => 'Yes, automatic approval', + norequest => 'No', + ); + return %titles; +} + +sub curr_requestauthor { + my ($uname,$udom,$isadv,$inststatuses,$domconfig) = @_; + return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH')); + if ($uname eq '' || $udom eq '') { + $uname = $env{'user.name'}; + $udom = $env{'user.domain'}; + $isadv = $env{'user.adv'}; + } + my (%userenv,%settings,$val); + my @options = ('automatic','approval'); + %userenv = + &Apache::lonnet::userenvironment($udom,$uname,'requestauthor','inststatus'); + if ($userenv{'requestauthor'}) { + $val = $userenv{'requestauthor'}; + @{$inststatuses} = ('_custom_'); + } else { + my %alltasks; + if (ref($domconfig->{'requestauthor'}) eq 'HASH') { + %settings = %{$domconfig->{'requestauthor'}}; + if (($isadv) && ($settings{'_LC_adv'} ne '')) { + $val = $settings{'_LC_adv'}; + @{$inststatuses} = ('_LC_adv_'); + } else { + if ($userenv{'inststatus'} ne '') { + @{$inststatuses} = split(',',$userenv{'inststatus'}); + } else { + @{$inststatuses} = ('default'); + } + foreach my $status (@{$inststatuses}) { + if (exists($settings{$status})) { + my $value = $settings{$status}; + next unless ($value); + unless (exists($alltasks{$value})) { + if (ref($alltasks{$value}) eq 'ARRAY') { + unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) { + push(@{$alltasks{$value}},$status); + } + } else { + @{$alltasks{$value}} = ($status); + } + } + } + } + foreach my $option (@options) { + if ($alltasks{$option}) { + $val = $option; + last; + } + } + } + } + } + return $val; +} + # =================================================================== Phase one sub print_username_entry_form { @@ -638,7 +785,6 @@ END sub entry_form { my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype) = @_; - my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); my ($usertype,$inexact); if (ref($srch) eq 'HASH') { if (($srch->{'srchin'} eq 'dom') && @@ -646,9 +792,10 @@ sub entry_form { ($srch->{'srchtype'} eq 'exact') && ($srch->{'srchdomain'} ne '') && ($srch->{'srchterm'} ne '')) { + my (%curr_rules,%got_rules); my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($srch->{'srchdomain'},'username'); - $usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules); + $usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules,\%curr_rules,\%got_rules); } else { $inexact = 1; } @@ -742,19 +889,13 @@ sub user_modification_js { '."\n"; - my $brcrum = [{href => "javascript:backPage(document.customresult,'pickrole','')", - text => "Pick custom role", - faq => 282, - bug => 'Instructor Interface',}, - {href => "javascript:backPage(document.customresult,'selected_custom_edit','')", - text => "Edit custom role", - faq => 282, - bug => 'Instructor Interface',}, - {href => "javascript:backPage(document.customresult,'set_custom_roles','')", - text => "Result", - faq => 282, - bug => 'Instructor Interface', - help => 'Course_Editing_Custom_Roles'}, - ]; - my $args = { bread_crumbs => $brcrum, + push(@{$brcrum}, + {href => "javascript:backPage(document.customresult,'pickrole','')", + text => "Pick custom role", + faq => 282, + bug => 'Instructor Interface',}, + {href => "javascript:backPage(document.customresult,'selected_custom_edit','')", + text => "Edit custom role", + faq => 282, + bug => 'Instructor Interface',}, + {href => "javascript:backPage(document.customresult,'set_custom_roles','')", + text => "Result", + faq => 282, + bug => 'Instructor Interface', + help => 'Course_Editing_Custom_Roles'}, + ); + my $args = { bread_crumbs => $brcrum, bread_crumbs_component => 'User Management'}; $r->print(&Apache::loncommon::start_page('Save Custom Role',$jscript,$args)); @@ -4000,8 +4320,13 @@ sub set_custom_role { $env{'user.name'}, $rolename,undef,undef,undef,$context)); } - $r->print('

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

'); - $r->print(&Apache::lonhtmlcommon::echo_form_input([]).'
'); + $r->print( + '

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

' + .'
' + .&Apache::lonhtmlcommon::echo_form_input([]).'
' + ); } # ================================================================ Main Handler @@ -4021,6 +4346,7 @@ sub handler { } else { $context = 'domain'; } + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['action','state','callingform','roletype','showrole','bulkaction','popup','phase', 'username','domain','srchterm','srchdomain','srchin','srchby','srchtype']); @@ -4039,6 +4365,10 @@ sub handler { my ($permission,$allowed) = &Apache::lonuserutils::get_permission($context,$crstype); if (!$allowed) { + if ($context eq 'course') { + $r->internal_redirect('/adm/viewclasslist'); + return OK; + } $env{'user.error.msg'}= "/adm/createuser:cst:0:0:Cannot create/modify user data ". "or view user status."; @@ -4048,6 +4378,16 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; + my $showcredits; + if ((($context eq 'course') && ($crstype eq 'Course')) || + ($context eq 'domain')) { + my %domdefaults = + &Apache::lonnet::get_domain_defaults($env{'request.role.domain'}); + if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) { + $showcredits = 1; + } + } + # Main switch on form.action and form.state, as appropriate if (! exists($env{'form.action'})) { $args = {bread_crumbs => $brcrum, @@ -4070,11 +4410,12 @@ sub handler { if (! exists($env{'form.state'})) { &Apache::lonuserutils::print_first_users_upload_form($r,$context); } elsif ($env{'form.state'} eq 'got_file') { - &Apache::lonuserutils::print_upload_manager_form($r,$context, - $permission,$crstype); + &Apache::lonuserutils::print_upload_manager_form($r,$context,$permission, + $crstype,$showcredits); } elsif ($env{'form.state'} eq 'enrolling') { if ($env{'form.datatoken'}) { - &Apache::lonuserutils::upfile_drop_add($r,$context,$permission); + &Apache::lonuserutils::upfile_drop_add($r,$context,$permission, + $showcredits); } } else { &Apache::lonuserutils::print_first_users_upload_form($r,$context); @@ -4093,15 +4434,21 @@ sub handler { if ($env{'form.phase'} eq 'createnewuser') { my $response; if ($env{'form.srchterm'} !~ /^$match_username$/) { - my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @'); + my $response = + '' + .&mt('You must specify a valid username. Only the following are allowed:' + .' letters numbers - . @') + .''; $env{'form.phase'} = ''; - &print_username_entry_form($r,$context,$response,$srch,undef,$crstype,$brcrum); + &print_username_entry_form($r,$context,$response,$srch,undef, + $crstype,$brcrum,$showcredits); } else { my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'}); my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'}); &print_user_modification_page($r,$ccuname,$ccdomain, $srch,$response,$context, - $permission,$crstype,$brcrum); + $permission,$crstype,$brcrum, + $showcredits); } } elsif ($env{'form.phase'} eq 'get_user_info') { my ($currstate,$response,$forcenewuser,$results) = @@ -4146,7 +4493,7 @@ sub handler { $brcrum); } } elsif ($env{'form.phase'} eq 'update_user_data') { - &update_user_data($r,$context,$crstype,$brcrum); + &update_user_data($r,$context,$crstype,$brcrum,$showcredits); } else { &print_username_entry_form($r,$context,undef,$srch,undef,$crstype, $brcrum); @@ -4157,6 +4504,32 @@ sub handler { } else { &custom_role_editor($r,$brcrum); } + } elsif (($env{'form.action'} eq 'processauthorreq') && + ($permission->{'cusr'}) && + (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) { + push(@{$brcrum}, + {href => '/adm/createuser?action=processauthorreq', + text => 'Authoring space requests', + help => 'Domain_Role_Approvals'}); + $bread_crumbs_component = 'Authoring requests'; + if ($env{'form.state'} eq 'done') { + push(@{$brcrum}, + {href => '/adm/createuser?action=authorreqqueue', + text => 'Result', + help => 'Domain_Role_Approvals'}); + $bread_crumbs_component = 'Authoring request result'; + } + $args = { bread_crumbs => $brcrum, + bread_crumbs_component => $bread_crumbs_component}; + $r->print(&header(undef,$args)); + if (!exists($env{'form.state'})) { + $r->print(&Apache::loncoursequeueadmin::display_queued_requests('requestauthor', + $env{'request.role.domain'})); + } elsif ($env{'form.state'} eq 'done') { + $r->print('

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

'."\n"); + $r->print(&Apache::loncoursequeueadmin::update_request_queue('requestauthor', + $env{'request.role.domain'})); + } } elsif (($env{'form.action'} eq 'listusers') && ($permission->{'view'} || $permission->{'cusr'})) { if ($env{'form.phase'} eq 'bulkchange') { @@ -4188,6 +4561,7 @@ sub handler { bread_crumbs_component => $bread_crumbs_component}; my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles); my $formname = 'studentform'; + my $hidecall = "hide_searching();"; if (($context eq 'domain') && (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community'))) { if ($env{'form.roletype'} eq 'course') { @@ -4204,19 +4578,26 @@ sub handler { ); $jscript = &Apache::lonhtmlcommon::set_form_elements(\%elements); } - $jscript .= &verify_user_display(); + $jscript .= &verify_user_display($context)."\n". + &Apache::loncommon::check_uncheck_jscript(); my $js = &add_script($jscript).$cb_jscript; my $loadcode = &Apache::lonuserutils::course_selector_loadcode($formname); if ($loadcode ne '') { - $args->{add_entries} = {onload => $loadcode}; + $args->{add_entries} = {onload => "$loadcode;$hidecall"}; + } else { + $args->{add_entries} = {onload => $hidecall}; } $r->print(&header($js,$args)); } else { - $r->print(&header(&add_script(&verify_user_display()),$args)); + $args->{add_entries} = {onload => $hidecall}; + $jscript = &verify_user_display($context). + &Apache::loncommon::check_uncheck_jscript(); + $r->print(&header(&add_script($jscript),$args)); } &Apache::lonuserutils::print_userlist($r,undef,$permission,$context, - $formname,$totcodes,$codetitles,$idlist,$idlist_titles); + $formname,$totcodes,$codetitles,$idlist,$idlist_titles, + $showcredits); } } elsif ($env{'form.action'} eq 'drop' && $permission->{'cusr'}) { my $brtext; @@ -4247,8 +4628,8 @@ sub handler { } elsif ($env{'form.action'} eq 'dateselect') { if ($permission->{'cusr'}) { $r->print(&header(undef,{'no_nav_bar' => 1}). - &Apache::lonuserutils::date_section_selector($context, - $permission,$crstype)); + &Apache::lonuserutils::date_section_selector($context,$permission, + $crstype,$showcredits)); } else { $r->print(&header(undef,{'no_nav_bar' => 1}). ''.&mt('You do not have permission to modify dates or sections for users').''); @@ -4304,10 +4685,14 @@ sub handler { $cdom,$cnum,$coursedesc)); } } elsif ($env{'form.action'} eq 'changelogs') { + my $helpitem; + if ($context eq 'course') { + $helpitem = 'Course_User_Logs'; + } push (@{$brcrum}, {href => '/adm/createuser?action=changelogs', text => 'User Management Logs', - help => 'Course_User_Logs'}); + help => $helpitem}); $bread_crumbs_component = 'User Changes'; $args = { bread_crumbs => $brcrum, bread_crumbs_component => $bread_crumbs_component}; @@ -4345,14 +4730,122 @@ sub add_script { } sub verify_user_display { + my ($context) = @_; + my %lt = &Apache::lonlocal::texthash ( + course => 'course(s): description, section(s), status', + community => 'community(s): description, section(s), status', + author => 'author', + ); + my $photos; + if (($context eq 'course') && $env{'request.course.id'}) { + $photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}; + } my $output = <<"END"; +function hide_searching() { + if (document.getElementById('searching')) { + document.getElementById('searching').style.display = 'none'; + } + return; +} + function display_update() { document.studentform.action.value = 'listusers'; document.studentform.phase.value = 'display'; document.studentform.submit(); } +function updateCols(caller) { + var context = '$context'; + var photos = '$photos'; + if (caller == 'Status') { + if ((context == 'domain') && + ((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; + document.getElementById('showcolstatus').disabled = 'disabled'; + document.getElementById('showcolstart').checked = false; + document.getElementById('showcolend').checked = false; + } else { + if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') { + document.getElementById('showcolstatus').checked = true; + document.getElementById('showcolstatus').disabled = ''; + document.getElementById('showcolstart').checked = true; + document.getElementById('showcolend').checked = true; + } else { + document.getElementById('showcolstatus').checked = false; + document.getElementById('showcolstatus').disabled = 'disabled'; + document.getElementById('showcolstart').checked = false; + document.getElementById('showcolend').checked = false; + } + } + } + if (caller == 'output') { + if (photos == 1) { + if (document.getElementById('showcolphoto')) { + var photoitem = document.getElementById('showcolphoto'); + if (document.studentform.output.options[document.studentform.output.selectedIndex].value == 'html') { + photoitem.checked = true; + photoitem.disabled = ''; + } else { + photoitem.checked = false; + photoitem.disabled = 'disabled'; + } + } + } + } + if (caller == 'showrole') { + if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') || + (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'cr')) { + document.getElementById('showcolrole').checked = true; + document.getElementById('showcolrole').disabled = ''; + } else { + document.getElementById('showcolrole').checked = false; + document.getElementById('showcolrole').disabled = 'disabled'; + } + if (context == 'domain') { + 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; + document.getElementById('showcolstatus').disabled = 'disabled'; + document.getElementById('showcolstart').checked = false; + document.getElementById('showcolend').checked = false; + } else { + if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') { + document.getElementById('showcolstatus').checked = true; + document.getElementById('showcolstatus').disabled = ''; + document.getElementById('showcolstart').checked = true; + document.getElementById('showcolend').checked = true; + } + } + if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'domain') { + document.getElementById('showcolextent').disabled = 'disabled'; + document.getElementById('showcolextent').checked = 'false'; + document.getElementById('showextent').style.display='none'; + document.getElementById('showcoltextextent').innerHTML = ''; + } else { + document.getElementById('showextent').style.display='block'; + document.getElementById('showextent').style.textAlign='left'; + document.getElementById('showextent').style.textFace='normal'; + if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'author') { + document.getElementById('showcolextent').disabled = ''; + document.getElementById('showcolextent').checked = 'true'; + document.getElementById('showcoltextextent').innerHTML="$lt{'author'}"; + } else { + document.getElementById('showcolextent').disabled = ''; + document.getElementById('showcolextent').checked = 'true'; + if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community') { + document.getElementById('showcoltextextent').innerHTML="$lt{'community'}"; + } else { + document.getElementById('showcoltextextent').innerHTML="$lt{'course'}"; + } + } + } + } + } + return; +} + END return $output; @@ -4383,12 +4876,12 @@ sub print_main_menu { course => { upload => 'Upload a File of Course Users', singleuser => 'Add/Modify a Course User', - listusers => 'Manage Course Users', + listusers => 'List and Modify Multiple Course Users', }, community => { upload => 'Upload a File of Community Users', singleuser => 'Add/Modify a Community User', - listusers => 'Manage Community Users', + listusers => 'List and Modify Multiple Community Users', }, ); my %linktitles = ( @@ -4459,6 +4952,22 @@ sub print_main_menu { permission => $permission->{'custom'}, linktitle => 'Configure a custom role.', }, + { + linktext => 'Authoring Space Requests', + icon => 'selfenrl-queue.png', + #help => 'Domain_Role_Approvals', + url => '/adm/createuser?action=processauthorreq', + permission => $permission->{'cusr'}, + linktitle => 'Approve or reject author role requests', + }, + { + linktext => 'Change Log', + icon => 'document-properties.png', + #help => 'Course_User_Logs', + url => '/adm/createuser?action=changelogs', + permission => $permission->{'cusr'}, + linktitle => 'View change log.', + }, ); }elsif ($context eq 'course'){ @@ -4575,8 +5084,19 @@ sub print_main_menu { }, ); } - }; -return Apache::lonhtmlcommon::generate_menu(@menu); + } elsif ($context eq 'author') { + push(@{ $menu[2]->{items} }, #Category: Administration + { + linktext => 'Change Log', + icon => 'document-properties.png', + #help => 'Course_User_Logs', + url => '/adm/createuser?action=changelogs', + permission => $permission->{'cusr'}, + linktitle => 'View change log.', + }, + ); + } + return Apache::lonhtmlcommon::generate_menu(@menu); # { text => 'View Log-in History', # help => 'Course_User_Logins', # action => 'logins', @@ -5266,18 +5786,35 @@ sub selfenroll_date_forms { sub print_userchangelogs_display { my ($r,$context,$permission) = @_; - my $formname = 'roleslog'; - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $crstype = &Apache::loncommon::course_type(); - my %roleslog=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum); + my $formname = 'rolelog'; + my ($username,$domain,$crstype,%roleslog); + if ($context eq 'domain') { + $domain = $env{'request.role.domain'}; + %roleslog=&Apache::lonnet::dump_dom('nohist_rolelog',$domain); + } else { + if ($context eq 'course') { + $domain = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $username = $env{'course.'.$env{'request.course.id'}.'.num'}; + $crstype = &Apache::loncommon::course_type(); + my %saveable_parameters = ('show' => 'scalar',); + &Apache::loncommon::store_course_settings('roles_log', + \%saveable_parameters); + &Apache::loncommon::restore_course_settings('roles_log', + \%saveable_parameters); + } elsif ($context eq 'author') { + $domain = $env{'user.domain'}; + if ($env{'request.role'} =~ m{^au\./\Q$domain\E/$}) { + $username = $env{'user.name'}; + } else { + undef($domain); + } + } + if ($domain ne '' && $username ne '') { + %roleslog=&Apache::lonnet::dump('nohist_rolelog',$domain,$username); + } + } if ((keys(%roleslog))[0]=~/^error\:/) { undef(%roleslog); } - my %saveable_parameters = ('show' => 'scalar',); - &Apache::loncommon::store_course_settings('roles_log', - \%saveable_parameters); - &Apache::loncommon::restore_course_settings('roles_log', - \%saveable_parameters); # set defaults my $now = time(); my $defstart = $now - (7*24*3600); #7 days ago @@ -5319,7 +5856,8 @@ sub print_userchangelogs_display { # Form Header $r->print('
'. - &role_display_filter($formname,$cdom,$cnum,\%curr,$version,$crstype)); + &role_display_filter($context,$formname,$domain,$username,\%curr, + $version,$crstype)); # Create navigation my ($nav_script,$nav_links) = &userlogdisplay_nav($formname,\%curr,$more_records); @@ -5332,9 +5870,13 @@ sub print_userchangelogs_display { .''.&mt('When').'' .''.&mt('Who made the change').'' .''.&mt('Changed User').'' - .''.&mt('Role').'' - .''.&mt('Section').'' - .''.&mt('Context').'' + .''.&mt('Role').''; + + if ($context eq 'course') { + $tableheader .= ''.&mt('Section').''; + } + $tableheader .= + ''.&mt('Context').'' .''.&mt('Start').'' .''.&mt('End').'' .&Apache::loncommon::end_data_table_header_row(); @@ -5403,7 +5945,7 @@ sub print_userchangelogs_display { if ($roleslog{$id}{'logentry'}{'selfenroll'}) { $chgcontext = 'selfenroll'; } - my %lt = &rolechg_contexts($crstype); + my %lt = &rolechg_contexts($context,$crstype); if ($chgcontext ne '' && $lt{$chgcontext} ne '') { $chgcontext = $lt{$chgcontext}; } @@ -5413,9 +5955,12 @@ sub print_userchangelogs_display { .''.&Apache::lonlocal::locallocaltime($roleslog{$id}{'exe_time'}).'' .''.$whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}}.'' .''.$changed{$roleslog{$id}{'uname'}.':'.$roleslog{$id}{'udom'}}.'' - .''.&Apache::lonnet::plaintext($roleslog{$id}{'logentry'}{'role'},$crstype).'' - .''.$sec.'' - .''.$chgcontext.'' + .''.&Apache::lonnet::plaintext($roleslog{$id}{'logentry'}{'role'},$crstype).''); + if ($context eq 'course') { + $r->print(''.$sec.''); + } + $r->print( + ''.$chgcontext.'' .''.$rolestart.'' .''.$roleend.'' .&Apache::loncommon::end_data_table_row()."\n"); @@ -5483,9 +6028,11 @@ ENDSCRIPT } sub role_display_filter { - my ($formname,$cdom,$cnum,$curr,$version,$crstype) = @_; - my $context = 'course'; - my $lctype = lc($crstype); + my ($context,$formname,$cdom,$cnum,$curr,$version,$crstype) = @_; + my $lctype; + if ($context eq 'course') { + $lctype = lc($crstype); + } my $nolink = 1; my $output = ''."\n"; } else { $row .= ''."\n"; + 'name="sec_'.$protectedcourse.'_'.$role.'" />'."\n"; } } $row .= <'. ''. ''; - my $courseform=''.&Apache::loncommon::selectcourse_link - ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Course/Community','crstype').''; - my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu','role','Course/Community Browser'); + my $courseform=&Apache::loncommon::selectcourse_link + ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Select','crstype'); + my $credit_elem; + if ($showcredits) { + $credit_elem = 'credits'; + } + my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu','role','Course/Community Browser',$credit_elem); my %lt=&Apache::lonlocal::texthash( 'rol' => "Role", 'grs' => "Section", @@ -6216,15 +6814,20 @@ sub course_level_dc { 'sta' => "Start", 'end' => "End", 'ssd' => "Set Start Date", - 'sed' => "Set End Date" + 'sed' => "Set End Date", + 'scc' => "Course/Community", + 'crd' => "Credits", ); my $header = '

'.&mt('Course/Community Level').'

'. &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). - '
'. + ''."\n". + ''."\n". + ''."\n". &Apache::loncommon::end_data_table_header_row(); my $otheritems = &Apache::loncommon::start_data_table_row()."\n". - ''."\n". + ''."\n". ''. - '
'. ''.&mt('Changes/page:').'
'. @@ -5500,7 +6047,7 @@ sub role_display_filter { &Apache::lonhtmlcommon::date_setter($formname,'rolelog_end_date', $curr->{'rolelog_end_date'},undef, undef,undef,undef,undef,undef,undef,$nolink); - my %lt = &rolechg_contexts($crstype); + my %lt = &rolechg_contexts($context,$crstype); $output .= '
'.&mt('Window during which changes occurred:').'
'. ''. @@ -5514,7 +6061,7 @@ sub role_display_filter { $output .= ' selected="selected"'; } $output .= '>'.&mt('Any').''."\n"; - my @roles = &Apache::lonuserutils::course_roles($context,undef,1,$lctype); + my @roles = &Apache::lonuserutils::roles_by_context($context,1,$crstype); foreach my $role (@roles) { my $plrole; if ($role eq 'cr') { @@ -5532,13 +6079,23 @@ sub role_display_filter { ''. ' -'. +''."\n". +''."\n". +''."\n". +''. &Apache::loncommon::end_data_table_header_row(). $table. &Apache::loncommon::end_data_table(); @@ -6152,12 +6737,21 @@ $table. } sub course_level_row { - my ($protectedcourse,$role,$area,$domain,$plrole,$sections_count,$lt) = @_; + my ($protectedcourse,$role,$area,$domain,$plrole,$sections_count, + $lt,$defaultcredits,$crstype) = @_; + my $creditem; my $row = &Apache::loncommon::start_data_table_row(). ' '."\n". ' '."\n". ' '."\n"; + if (($role eq 'st') && ($crstype eq 'Course')) { + $row .= + ''; + } else { + $row .= ''; + } if (($role eq 'cc') || ($role eq 'co')) { $row .= ''; } elsif ($env{'request.course.sec'} ne '') { @@ -6183,7 +6777,7 @@ sub course_level_row { '
'.&mt('After:'). ''.$startform.'
  '. &mt('Context:').'
'.$lt{'act'}.''.$lt{'rol'}.''.$lt{'ext'}.''.$lt{'grs'}.''.$lt{'sta'}.''.$lt{'end'}.''.$lt{'act'}.''.$lt{'rol'}.''.$lt{'ext'}.''.$lt{'crd'}.''.$lt{'grs'}.''.$lt{'sta'}.''.$lt{'end'}.''.$plrole.''.$area.'
Domain: '.$domain.'
  
'.$courseform.''.$lt{'rol'}.''.$lt{'grs'}.''.$lt{'sta'}.''.$lt{'end'}.''.$lt{'scc'}.''.$lt{'rol'}.''.$lt{'grs'}.''.$lt{'crd'}.''.$lt{'sta'}.''.$lt{'end'}.'

'. + $courseform.(' ' x4).'

'. ''. '
'; + ''."\n"; + if ($showcredits) { + $otheritems .= '
'."\n". + ''."\n"; + } $otheritems .= <
print('
'.$visactions->{'miss'}.'
'.$visactions->{'yous'}. + $r->print('
'.$visactions->{'miss'}.'
'.$visactions->{'yous'}. '
'); if (ref($vismsgs) eq 'ARRAY') { $r->print('
'.$visactions->{'take'}.'
    '); @@ -6620,21 +7227,6 @@ sub get_selfenroll_titles { return (\@row,\%lt); } -sub is_courseowner { - my ($thiscourse,$courseowner) = @_; - if ($courseowner eq '') { - if ($env{'request.course.id'} eq $thiscourse) { - $courseowner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'}; - } - } - if ($courseowner ne '') { - if ($courseowner eq $env{'user.name'}.':'.$env{'user.domain'}) { - return 1; - } - } - return; -} - #---------------------------------------------- end functions for &phase_two #--------------------------------- functions for &phase_two and &phase_three