--- loncom/interface/loncreateuser.pm 2012/06/01 11:39:24 1.361 +++ loncom/interface/loncreateuser.pm 2012/08/21 15:43:27 1.365 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.361 2012/06/01 11:39:24 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.365 2012/08/21 15:43:27 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -233,6 +233,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, @@ -247,6 +248,16 @@ 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', @@ -261,7 +272,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 = ''; } @@ -271,6 +287,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 = @@ -292,15 +314,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'; @@ -338,28 +372,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. ''; @@ -455,6 +497,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', @@ -478,6 +531,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 { @@ -939,7 +1066,7 @@ sub print_user_modification_page { &Apache::lonnet::inst_userrules($ccdomain,'username'); $usertype = &Apache::lonuserutils::check_usertype($ccdomain,$ccuname,$rules, - \%curr_rules,\%got_rules); + \%curr_rules,\%got_rules); my $cancreate = &Apache::lonuserutils::can_create_user($ccdomain,$context, $usertype); @@ -951,7 +1078,9 @@ sub print_user_modification_page { ); my $response; if ($env{'form.origform'} eq 'crtusername') { - $response = ''.&mt('No match found for the username [_1] in LON-CAPA domain: [_2]',''.$ccuname.'',$ccdomain). + $response = ''. + &mt('No match found for the username [_1] in LON-CAPA domain: [_2]', + ''.$ccuname.'',$ccdomain). '
'; } $response .= '

' @@ -1068,12 +1197,15 @@ ENDFORMINFO } } if ($newuser) { - my $portfolioform; + my ($portfolioform,$domroleform); if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) || (&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) { # Current user has quota or user tools modification privileges $portfolioform = '
'.&portfolio_quota($ccuname,$ccdomain); } + if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) { + $domroleform = '
'.&domainrole_req($ccuname,$ccdomain); + } &initialize_authen_forms($ccdomain,$formname); my %lt=&Apache::lonlocal::texthash( 'cnu' => 'Create New User', @@ -1119,7 +1251,8 @@ $lt{'hs'}: $home_server_pick $r->print($home_server_pick); } if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { - $r->print('

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

'. + $r->print('

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

'. &Apache::loncommon::start_data_table(). &build_tools_display($ccuname,$ccdomain, 'requestcourses'). @@ -1183,7 +1316,7 @@ ENDAUTH } else { $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); } - $r->print($portfolioform); + $r->print($portfolioform.$domroleform); if ($env{'form.action'} eq 'singlestudent') { $r->print(&date_sections_select($context,$newuser,$formname, $permission)); @@ -1217,10 +1350,10 @@ ENDCHANGEUSER $inst_results{$ccuname.':'.$ccdomain}); $r->print($personal_table); if ($showforceid) { - $r->print(&Apache::lonuserutils::forceid_change($context)); + $r->print(''.&Apache::lonuserutils::forceid_change($context).'
'); } if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { - $r->print('

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

'. + $r->print('

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

'. &Apache::loncommon::start_data_table()); if ($env{'request.role.domain'} eq $ccdomain) { $r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses')); @@ -1231,12 +1364,19 @@ ENDCHANGEUSER $r->print(&Apache::loncommon::end_data_table()); } $r->print(''); - my $user_auth_text = &user_authentication($ccuname,$ccdomain,$formname); - my ($user_quota_text,$user_tools_text,$user_reqcrs_text); + my @order = ('auth','quota','tools','requestauthor'); + my %user_text; + my ($isadv,$isauthor) = + &Apache::lonnet::is_advanced_user($ccuname,$ccdomain); + if ((!$isauthor) && + (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) { + $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain); + } + $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname); if ((&Apache::lonnet::allowed('mpq',$ccdomain)) || (&Apache::lonnet::allowed('mut',$ccdomain))) { # Current user has quota modification privileges - $user_quota_text = &portfolio_quota($ccuname,$ccdomain); + $user_text{'quota'} = &portfolio_quota($ccuname,$ccdomain); } if (!&Apache::lonnet::allowed('mpq',$ccdomain)) { if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) { @@ -1248,7 +1388,7 @@ ENDCHANGEUSER 'youd' => "You do not have privileges to modify the portfolio quota for this user.", 'ichr' => "If a change is required, contact a domain coordinator for the domain", ); - $user_quota_text = <$lt{'dska'} $lt{'youd'} $lt{'ichr'}: $ccdomain ENDNOPORTPRIV @@ -1261,43 +1401,31 @@ ENDNOPORTPRIV 'yodo' => "You do not have privileges to modify Portfolio, Blog, WebDAV, or Personal Information Page settings for this user.", 'ifch' => "If a change is required, contact a domain coordinator for the domain", ); - $user_tools_text = <$lt{'utav'} $lt{'yodo'} $lt{'ifch'}: $ccdomain ENDNOTOOLSPRIV } } - if ($user_auth_text ne '') { - $r->print('
'.$user_auth_text); - if ($user_quota_text ne '') { - $r->print($user_quota_text); - } - if ($user_tools_text ne '') { - $r->print($user_tools_text); - } - if ($env{'form.action'} eq 'singlestudent') { - $r->print(&date_sections_select($context,$newuser,$formname)); - } - } elsif ($user_quota_text ne '') { - $r->print('
'.$user_quota_text); - if ($user_tools_text ne '') { - $r->print($user_tools_text); - } - if ($env{'form.action'} eq 'singlestudent') { - $r->print(&date_sections_select($context,$newuser,$formname)); - } - } elsif ($user_tools_text ne '') { - $r->print('
'.$user_tools_text); - if ($env{'form.action'} eq 'singlestudent') { - $r->print(&date_sections_select($context,$newuser,$formname)); - } - } else { - if ($env{'form.action'} eq 'singlestudent') { - $r->print('
'. - &date_sections_select($context,$newuser,$formname)); + my $gotdiv = 0; + foreach my $item (@order) { + if ($user_text{$item} ne '') { + unless ($gotdiv) { + $r->print('
'); + $gotdiv = 1; + } + $r->print('
'.$user_text{$item}); } } - $r->print('
'); + if ($env{'form.action'} eq 'singlestudent') { + unless ($gotdiv) { + $r->print('
'); + } + $r->print(&date_sections_select($context,$newuser,$formname)); + } + if ($gotdiv) { + $r->print('
'); + } if ($env{'form.action'} ne 'singlestudent') { &display_existing_roles($r,$ccuname,$ccdomain,\%inccourses,$context, $roledom,$crstype); @@ -1523,7 +1651,7 @@ sub display_existing_roles { $allowed=1; } unless ($allowed) { - my $isowner = &is_courseowner($cid,$coursedata{'internal.courseowner'}); + my $isowner = &Apache::lonuserutils::is_courseowner($cid,$coursedata{'internal.courseowner'}); if ($isowner) { if (($role_code eq 'co') && ($class eq 'Community')) { $allowed = 1; @@ -1573,7 +1701,7 @@ sub display_existing_roles { $allowed=1; } } - if ($role_code eq 'ca' || $role_code eq 'au') { + if ($role_code eq 'ca' || $role_code eq 'au' || $role_code eq 'aa') { $class='Construction Space'; } elsif ($role_code eq 'su') { $class='System'; @@ -2316,6 +2444,7 @@ sub update_user_data { my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); my @usertools = ('aboutme','blog','webdav','portfolio'); my @requestcourses = ('official','unofficial','community'); + my @requestauthor = ('requestauthor'); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'}); my %canmodify_status = @@ -2412,6 +2541,12 @@ sub update_user_data { \%changeHash,'requestcourses'); } } + if ($env{'form.customrequestauthor'} == 1) { + $newcustom{'requestauthor'} = $env{'form.requestauthor'}; + $changed{'requestauthor'} = &tool_admin('requestauthor', + $newcustom{'requestauthor'}, + \%changeHash,'requestauthor'); + } } if ($canmodify_status{'inststatus'}) { if (exists($env{'form.inststatus'})) { @@ -2470,7 +2605,8 @@ sub update_user_data { 'tools.blog','tools.webdav','tools.portfolio', 'requestcourses.official','requestcourses.unofficial', 'requestcourses.community','reqcrsotherdom.official', - 'reqcrsotherdom.unofficial','reqcrsotherdom.community'], + 'reqcrsotherdom.unofficial','reqcrsotherdom.community', + 'requestauthor'], $env{'form.ccdomain'},$env{'form.ccuname'}); my ($tmp) = keys(%userenv); if ($tmp =~ /^(con_lost|error)/i) { @@ -2598,7 +2734,7 @@ sub update_user_data { $olddefquota,$oldsettingstatus,$newdefquota,$newsettingstatus); @disporder = ('inststatus'); if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) { - push(@disporder,'requestcourses'); + push(@disporder,'requestcourses','requestauthor'); } else { push(@disporder,'reqcrsotherdom'); } @@ -2622,6 +2758,9 @@ sub update_user_data { if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) { $canshow{'inststatus'} = 1; } + if (&Apache::lonnet::allowed('cau',$env{'form.ccdomain'})) { + $canshow{'requestauthor'} = 1; + } my (%changeHash,%changed); if ($oldinststatus eq '') { $oldsettings{'inststatus'} = $othertitle; @@ -2711,6 +2850,7 @@ sub update_user_data { if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) { &tool_changes('requestcourses',\@requestcourses,\%oldsettings,\%oldsettingstext, \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext); + &tool_changes('requestauthor',\@requestauthor,\%oldsettings,\%oldsettingstext,\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext); } else { &tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext, \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext); @@ -2738,13 +2878,22 @@ sub update_user_data { || ($key eq 'community')) { $newenvhash{'environment.requestcourses.'.$key} = $changeHash{'requestcourses.'.$key}; - if ($changeHash{'requestcourses.'.$key} ne '') { + if ($changeHash{'requestcourses.'.$key}) { $newenvhash{'environment.canrequest.'.$key} = 1; } else { $newenvhash{'environment.canrequest.'.$key} = &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, $key,'reload','requestcourses'); } + } elsif ($key eq 'requestauthor') { + $newenvhash{'environment.'.$key} = $changeHash{$key}; + if ($changeHash{$key}) { + $newenvhash{'environment.canrequest.author'} = 1; + } else { + $newenvhash{'environment.canrequest.author'} = + &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, + $key,'reload','requestauthor'); + } } elsif ($key ne 'quota') { $newenvhash{'environment.tools.'.$key} = $changeHash{'tools.'.$key}; @@ -2786,7 +2935,7 @@ sub update_user_data { ((keys(%changed) > 0) && $chgresult eq 'ok')) { # Tell the user we changed the name &display_userinfo($r,1,\@disporder,\%canshow,\@requestcourses, - \@usertools,\%userenv,\%changed,\%namechanged, + \@usertools,\@requestauthor,\%userenv,\%changed,\%namechanged, \%oldsettings, \%oldsettingstext,\%newsettings, \%newsettingstext); if ($env{'form.cid'} ne $userenv{'id'}) { @@ -2819,7 +2968,7 @@ sub update_user_data { # or ability to request creation of courses, # but we can still tell them what the name and quota and availabilities are &display_userinfo($r,undef,\@disporder,\%canshow,\@requestcourses, - \@usertools,\%userenv,\%changed,\%namechanged,\%oldsettings, + \@usertools,\@requestauthor,\%userenv,\%changed,\%namechanged,\%oldsettings, \%oldsettingstext,\%newsettings,\%newsettingstext); } if (@mod_disallowed) { @@ -2896,12 +3045,13 @@ sub update_user_data { } sub display_userinfo { - my ($r,$changed,$order,$canshow,$requestcourses,$usertools,$userenv, - $changedhash,$namechangedhash,$oldsetting,$oldsettingtext, + my ($r,$changed,$order,$canshow,$requestcourses,$usertools,$requestauthor, + $userenv,$changedhash,$namechangedhash,$oldsetting,$oldsettingtext, $newsetting,$newsettingtext) = @_; return unless (ref($order) eq 'ARRAY' && ref($canshow) eq 'HASH' && ref($requestcourses) eq 'ARRAY' && + ref($requestauthor) eq 'ARRAY' && ref($usertools) eq 'ARRAY' && ref($userenv) eq 'HASH' && ref($changedhash) eq 'HASH' && @@ -2926,6 +3076,7 @@ sub display_userinfo { 'official' => 'Can Request Official Courses', 'unofficial' => 'Can Request Unofficial Courses', 'community' => 'Can Request Communities', + 'requestauthor' => 'Can Request Author Role', 'inststatus' => "Affiliation", 'prvs' => 'Previous Value:', 'chto' => 'Changed To:' @@ -3121,25 +3272,29 @@ sub tool_changes { return; } foreach my $tool (@{$usertools}) { - my $newval; + my ($newval,$envkey); + $envkey = $context.'.'.$tool; if ($context eq 'requestcourses') { $newval = $env{'form.crsreq_'.$tool}; if ($newval eq 'autolimit') { $newval .= '='.$env{'form.crsreq_'.$tool.'_limit'}; } + } elsif ($context eq 'requestauthor') { + $newval = $env{'form.'.$context}; + $envkey = $context; } else { $newval = $env{'form.'.$context.'_'.$tool}; } - if ($userenv->{$context.'.'.$tool} ne '') { + if ($userenv->{$envkey} ne '') { $oldaccess->{$tool} = &mt('custom'); - if ($userenv->{$context.'.'.$tool}) { + if ($userenv->{$envkey}) { $oldaccesstext->{$tool} = &mt("availability set to 'on'"); } else { $oldaccesstext->{$tool} = &mt("availability set to 'off'"); } - $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool}; + $changeHash->{$envkey} = $userenv->{$envkey}; if ($env{'form.custom'.$tool} == 1) { - if ($newval ne $userenv->{$context.'.'.$tool}) { + if ($newval ne $userenv->{$envkey}) { $changed->{$tool} = &tool_admin($tool,$newval,$changeHash, $context); if ($changed->{$tool}) { @@ -3583,6 +3738,10 @@ sub tool_admin { if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { $canchange = 1; } + } elsif ($context eq 'requestauthor') { + if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) { + $canchange = 1; + } } elsif (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) { # Current user has quota modification privileges $canchange = 1; @@ -3591,7 +3750,11 @@ sub tool_admin { if ($canchange) { if (ref($changeHash) eq 'HASH') { $toolchanged = 1; - $changeHash->{$context.'.'.$tool} = $settool; + if ($tool eq 'requestauthor') { + $changeHash->{$context} = $settool; + } else { + $changeHash->{$context.'.'.$tool} = $settool; + } } } return $toolchanged; @@ -4160,6 +4323,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') { @@ -4191,6 +4380,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') { @@ -4207,16 +4397,22 @@ 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); @@ -4307,10 +4503,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}; @@ -4348,14 +4548,68 @@ sub add_script { } sub verify_user_display { + my ($context) = @_; + 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 (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.getElementById('showcolrole').checked = true; + document.getElementById('showcolrole').disabled = ''; + } else { + document.getElementById('showcolrole').checked = false; + document.getElementById('showcolrole').disabled = 'disabled'; + } + } + return; +} + END return $output; @@ -4462,6 +4716,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'){ @@ -4578,8 +4848,17 @@ sub print_main_menu { }, ); } - }; -return Apache::lonhtmlcommon::generate_menu(@menu); + } elsif ($context eq 'author') { + { + 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', @@ -5269,18 +5548,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 @@ -5322,7 +5618,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); @@ -5335,9 +5632,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(); @@ -5406,7 +5707,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}; } @@ -5416,9 +5717,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"); @@ -5486,9 +5790,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 = '
'. ''.&mt('Changes/page:').'
'. @@ -5503,7 +5809,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:').'
'. ''. @@ -5517,7 +5823,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') { @@ -5535,13 +5841,23 @@ sub role_display_filter { ''. '
'.&mt('After:'). ''.$startform.'
  '. &mt('Context:').'