--- loncom/interface/lonuserutils.pm 2007/12/21 20:34:26 1.21 +++ loncom/interface/lonuserutils.pm 2007/12/22 03:38:26 1.24 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.21 2007/12/21 20:34:26 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.24 2007/12/22 03:38:26 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -68,7 +68,8 @@ sub modifystudent { my $reply=&Apache::lonnet::modifystudent # dom name id mode pass f m l g ($udom,$unam,'', '', '',undef,undef,undef,undef, - $section,time,undef,undef,$desiredhost); + $section,time,undef,undef,$desiredhost,'','manual', + '',$courseid); $result .= $reply.':'; } } @@ -126,6 +127,7 @@ sub modifyuserrole { $email,$role,$start,$end); if ($userresult eq 'ok') { if ($role ne '') { + $role =~ s/_/\//g; $roleresult = &Apache::lonnet::assignrole($udom,$uname,$scope, $role,$end,$start); } @@ -145,7 +147,7 @@ sub propagate_id_change { one_time => 1, ); foreach my $item (keys(%roleshash)) { - my ($cnum,$cdom,$role) = split(/:/,$item); + my ($cnum,$cdom,$role) = split(/:/,$item,-1); my ($start,$end) = split(/:/,$roleshash{$item}); if (&Apache::lonnet::is_course($cdom,$cnum)) { my $result = &update_classlist($cdom,$cnum,$udom,$uname,$user); @@ -265,7 +267,7 @@ sub hidden_input { } sub print_upload_manager_header { - my ($r,$datatoken,$distotal,$krbdefdom,$context)=@_; + my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission)=@_; my $javascript; # if (! exists($env{'form.upfile_associate'})) { @@ -295,9 +297,14 @@ sub print_upload_manager_header { $password_choice = 'int'; } # + my $groupslist; + if ($context eq 'course') { + $groupslist = &get_groupslist(); + } my $javascript_validations = - &javascript_validations('auth',$krbdefdom,$password_choice,undef, - $env{'request.role.domain'}); + &javascript_validations('upload',$krbdefdom,$password_choice,undef, + $env{'request.role.domain'},$context, + $permission,$groupslist); my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':''); $r->print(&mt('Total number of records found in file: <b>[_1]</b>.',$distotal). "<br />\n"); @@ -324,27 +331,52 @@ sub print_upload_manager_header { ############################################################### ############################################################### sub javascript_validations { - my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain)=@_; - my $authheader; - if ($mode eq 'auth') { - my %param = ( formname => 'studentform', - kerb_def_dom => $krbdefdom, - curr_authtype => $curr_authtype); - $authheader = &Apache::loncommon::authform_header(%param); - } elsif ($mode eq 'createcourse') { - my %param = ( formname => 'ccrs', - kerb_def_dom => $krbdefdom, - curr_authtype => $curr_authtype ); - $authheader = &Apache::loncommon::authform_header(%param); - } elsif ($mode eq 'modifycourse') { - my %param = ( formname => 'cmod', + my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain, + $context,$permission,$groupslist)=@_; + + my %param = ( kerb_def_dom => $krbdefdom, - mode => 'modifycourse', curr_authtype => $curr_authtype, - curr_autharg => $curr_authfield ); - $authheader = &Apache::loncommon::authform_header(%param); + ); + if ($mode eq 'createuser') { + $param{'formname'} = 'cu'; + } elsif ($mode eq 'upload') { + $param{'formname'} = 'studentform'; + } elsif ($mode eq 'singlestudent') { + $param{'formname'} = 'cu'; + } elsif ($mode eq 'createcourse') { + $param{'formname'} = 'ccrs'; + } elsif ($mode eq 'modifycourse') { + $param{'formname'} = 'cmod'; + $param{'mode'} = 'modifycourse', + $param{'curr_autharg'} = $curr_authfield; } + my ($setsection_call,$setsections_js); + my $finish = " vf.submit();\n"; + if ($mode eq 'upload') { + if (($context eq 'course') || ($context eq 'domain')) { + if ($context eq 'course') { + if ($env{'request.course.sec'} eq '') { + $setsection_call = 'setSections(document.'.$param{'formname'}.');'; + $setsections_js = + &setsections_javascript($param{'formname'},$groupslist, + $mode); + } else { + $setsection_call = "'ok'"; + } + } elsif ($context eq 'domain') { + $setsection_call = 'setCourse()'; + $setsections_js = &dc_setcourse_js($param{'formname'},$mode); + } + $finish = " var checkSec = $setsection_call\n". + " if (checkSec == 'ok') {\n". + " vf.submit();\n". + " }\n"; + } + } + my $authheader = &Apache::loncommon::authform_header(%param); + my %alert = &Apache::lonlocal::texthash (username => 'You need to specify the username field.', authen => 'You must choose an authentication type.', @@ -358,8 +390,9 @@ sub javascript_validations { continue => 'Continue adding users?', ); -# my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); my $function_name =(<<END); +$setsections_js + function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail) { END my ($authnum,%can_assign) = &Apache::loncommon::get_assignable_auth($domain); @@ -479,21 +512,21 @@ END message+= '\\n$alert{'continue'}'; if (confirm(message)) { vf.state.value='enrolling'; - vf.submit(); + $finish } } else { vf.state.value='enrolling'; - vf.submit(); + $finish } } END } my $result = $function_name; - if ( ($mode eq 'auth') || ($mode eq 'createcourse') || ($mode eq 'modifycourse') ) { + if ( ($mode eq 'upload') || ($mode eq 'createcourse') || ($mode eq 'modifycourse') ) { $result .= $auth_checks; } $result .= $optional_checks."\n".$section_checks; - if ( ($mode eq 'auth') || ($mode eq 'createcourse') || ($mode eq 'modifycourse') ) { + if ( ($mode eq 'upload') || ($mode eq 'createcourse') || ($mode eq 'modifycourse') ) { $result .= $authheader; } return $result; @@ -654,18 +687,12 @@ ENDPICK ############################################################### ############################################################### sub print_upload_manager_footer { - my ($r,$i,$keyfields,$defdom,$today,$halfyear,$context)=@_; - my $formname; - if ($context eq 'course') { - $formname = 'document.studentform'; - } elsif ($context eq 'author') { - $formname = 'document.studentform'; - } elsif ($context eq 'domain') { - $formname = 'document.studentform'; - } + my ($r,$i,$keyfields,$defdom,$today,$halfyear,$context,$permission) = @_; + my $form = 'document.studentform'; + my $formname = 'studentform'; my ($krbdef,$krbdefdom) = &Apache::loncommon::get_kerberos_defaults($defdom); - my %param = ( formname => $formname, + my %param = ( formname => $form, kerb_def_dom => $krbdefdom, kerb_def_auth => $krbdef ); @@ -677,8 +704,8 @@ sub print_upload_manager_footer { my $krbform = &Apache::loncommon::authform_kerberos(%param); my $intform = &Apache::loncommon::authform_internal(%param); my $locform = &Apache::loncommon::authform_local(%param); - my $date_table = &date_setting_table(undef,undef,$context); - + my $date_table = &date_setting_table(undef,undef,$context,undef, + $formname,$permission); my $Str = "\n".'<div class="LC_left_float">'; $Str .= &hidden_input('nfields',$i); $Str .= &hidden_input('keyfields',$keyfields); @@ -719,21 +746,22 @@ sub print_upload_manager_footer { $Str .= '<br /><br /><b>'.&mt('Default role and/or section')."</b><br />\n". &mt('Role and/or section for users without one in the uploaded file.'); } - $Str .= '<br /><br />'; - my ($options,$cb_script,$coursepick) = &default_role_selector($context,'defaultrole',1); - if ($context eq 'domain') { - $Str .= '<span class="LC_role_level">'.&mt('Domain Level').'</span><br />'.$options.'<br /><br /><span class="LC_role_level">'.&mt('Course Level').'</span><br />'.$cb_script.$coursepick; - } elsif ($context eq 'author') { - $Str .= $options; + $Str .= '<br />'; + if (($context eq 'domain') || ($context eq 'author')) { + my ($options,$cb_script,$coursepick) = &default_role_selector($context,1); + if ($context eq 'domain') { + $Str .= '<span class="LC_role_level">'.&mt('Domain Level').'</span><br />'.$options.'<br /><br /><span class="LC_role_level">'.&mt('Course Level').'</span><br />'.$cb_script.$coursepick; + } elsif ($context eq 'author') { + $Str .= $options; + } } else { - $Str .= '<table><tr><td><span class="LC_nobreak"<b>'.&mt('role').': </b>'. - $options.'</span></td><td> </td><td><span class="LC_nobreak">'. - '<b>'.&mt('section').': </b><input type="text" name="section" value="" size="12" /></span></td></tr></table>'; - } - if ($context eq 'course') { - $Str .= "<h3>".&mt('Full Update')."</h3>\n". - '<label><input type="checkbox" name="fullup" value="yes">'. - ' '.&mt('Full update (also print list of users not enrolled anymore)'). + my ($cnum,$cdom) = &get_course_identity(); + my $rowtitle = &mt('section'); + my $secbox = §ion_picker($cdom,$cnum,'Any',$rowtitle, + $permission,$context,'upload'); + $Str .= $secbox."<h3>".&mt('Full Update')."</h3>\n". + '<p><label><input type="checkbox" name="fullup" value="yes">'. + ' '.&mt('Display students with current/future access, who are not in the uploaded file.').'<br />'.&mt('Students selected from this list can be dropped.'); "</label></p>\n"; } if ($context eq 'course' || $context eq 'domain') { @@ -815,7 +843,8 @@ sub print_upload_manager_form { my ($krbdef,$krbdefdom) = &Apache::loncommon::get_kerberos_defaults($defdom); # - &print_upload_manager_header($r,$datatoken,$distotal,$krbdefdom,$context); + &print_upload_manager_header($r,$datatoken,$distotal,$krbdefdom,$context, + $permission); my $i; my $keyfields; if ($total>=0) { @@ -849,11 +878,14 @@ sub print_upload_manager_form { } $r->print('</div>'); &print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear, - $context); + $context,$permission); } sub setup_date_selectors { - my ($starttime,$endtime,$mode,$nolink) = @_; + my ($starttime,$endtime,$mode,$nolink,$formname) = @_; + if ($formname eq '') { + $formname = 'studentform'; + } if (! defined($starttime)) { $starttime = time; unless ($mode eq 'create_enrolldates' || $mode eq 'create_defaultdates') { @@ -876,11 +908,11 @@ sub setup_date_selectors { } my $startdateform = - &Apache::lonhtmlcommon::date_setter('studentform','startdate',$starttime, + &Apache::lonhtmlcommon::date_setter($formname,'startdate',$starttime, undef,undef,undef,undef,undef,undef,undef,$nolink); my $enddateform = - &Apache::lonhtmlcommon::date_setter('studentform','enddate',$endtime, + &Apache::lonhtmlcommon::date_setter($formname,'enddate',$endtime, undef,undef,undef,undef,undef,undef,undef,$nolink); if ($mode eq 'create_enrolldates') { @@ -913,24 +945,27 @@ sub get_dates_from_form { } sub date_setting_table { - my ($starttime,$endtime,$mode,$bulkaction) = @_; + my ($starttime,$endtime,$mode,$bulkaction,$formname,$permission) = @_; my $nolink; if ($bulkaction) { $nolink = 1; } my ($startform,$endform) = - &setup_date_selectors($starttime,$endtime,$mode,$nolink); + &setup_date_selectors($starttime,$endtime,$mode,$nolink,$formname); my $dateDefault; if ($mode eq 'create_enrolldates' || $mode eq 'create_defaultdates') { $dateDefault = ' '; } elsif ($mode ne 'author' && $mode ne 'domain') { if (($bulkaction eq 'reenable') || ($bulkaction eq 'activate') || - ($bulkaction eq 'chgdates')) { - $dateDefault = '<span class="LC_nobreak">'. - '<label><input type="checkbox" name="makedatesdefault" /> '. - &mt('make these dates the default for future enrollment'). - '</label></span>'; + ($bulkaction eq 'chgdates') || + ($env{'form.action'} eq 'upload')) { + if ($env{'request.course.sec'} eq '') { + $dateDefault = '<span class="LC_nobreak">'. + '<label><input type="checkbox" name="makedatesdefault" /> '. + &mt('make these dates the default access dates for future student enrollment'). + '</label></span>'; + } } } my $perpetual = '<span class="LC_nobreak"><label><input type="checkbox" name="no_end_date"'; @@ -950,7 +985,7 @@ sub date_setting_table { 'LC_oddrow_value')."\n". $endform.' '.$perpetual. &Apache::lonhtmlcommon::row_closure(1). - &Apache::lonhtmlcommon::end_pick_box().'<br />'; + &Apache::lonhtmlcommon::end_pick_box(); if ($dateDefault) { $result .= $dateDefault.'<br />'."\n"; } @@ -1011,33 +1046,36 @@ sub default_role_selector { $options .= ' <option value="'.$role.'">'.$plrole.'</option>'; } my $courseform = &Apache::loncommon::selectcourse_link - ('studentform','defaultcourse','defaultdomain','defaultdesc',"$env{'request.role.domain'}",undef,'Course'); + ('studentform','dccourse','dcdomain','coursedesc',"$env{'request.role.domain'}",undef,'Course'); $cb_jscript = - &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'defaultsec','studentform'); + &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'currsec','studentform'); $coursepick = &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). '<th>'.$courseform.'</th><th>'.$lt{'rol'}.'</th>'. '<th>'.$lt{'grs'}.'</th>'. &Apache::loncommon::end_data_table_header_row(). &Apache::loncommon::start_data_table_row()."\n". - '<td><input type="text" name="defaultdesc" value="" onFocus="this.blur();opencrsbrowser('."'studentform','defcourse','defdomain','coursedesc',''".')" /></td>'."\n". + '<td><input type="text" name="coursedesc" value="" onFocus="this.blur();opencrsbrowser('."'studentform','dccourse','dcdomain','coursedesc',''".')" /></td>'."\n". '<td><select name="courserole">'."\n". &default_course_roles($context,$checkpriv,%customroles)."\n". '</select></td><td>'. '<table class="LC_createuser">'. '<tr class="LC_section_row"><td valign"top">'. - $lt{'exs'}.'<br /><select name="defaultsec">'. + $lt{'exs'}.'<br /><select name="currsec">'. ' <option value=""><--'.&mt('Pick course first'). '</select></td>'. '<td> </td>'. '<td valign="top">'.$lt{'new'}.'<br />'. '<input type="text" name="newsec" value="" size="5" />'. - '<input type="hidden" name="groups" value="" /></td>'. - '</tr></table></td>'. + '<input type="hidden" name="groups" value="" />'. + '<input type="hidden" name="sections" value="" />'. + '<input type="hidden" name="origdom" value="'. + $env{'request.role.domain'}.'" />'. + '<input type="hidden" name="dccourse" value="" />'. + '<input type="hidden" name="dcdomain" value="" />'. + '</td></tr></table></td>'. &Apache::loncommon::end_data_table_row(). - &Apache::loncommon::end_data_table()."\n". - '<input type="hidden" name="defaultcourse" value="" />'. - '<input type="hidden" name="defaultdomain" value="" />'; + &Apache::loncommon::end_data_table()."\n"; } $options .= '</select>'; return ($options,$cb_jscript,$coursepick); @@ -1049,15 +1087,18 @@ sub default_course_roles { my $custom = 1; my @roles = &course_roles($context,$checkpriv,$custom); foreach my $role (@roles) { - my $plrole=&Apache::lonnet::plaintext($role); - $output .= ' <option value="'.$role.'">'.$plrole.'</option>'; + if ($role ne 'cr') { + my $plrole=&Apache::lonnet::plaintext($role); + $output .= ' <option value="'.$role.'">'.$plrole.'</option>'; + } } if (keys(%customroles) > 0) { - my %customroles = &my_custom_roles(); - foreach my $cust (sort(keys(%customroles))) { - my $custrole='cr_cr_'.$env{'user.domain'}. - '_'.$env{'user.name'}.'_'.$cust; - $output .= ' <option value="'.$custrole.'">'.$cust.'</option>'; + if (grep(/^cr$/,@roles)) { + foreach my $cust (sort(keys(%customroles))) { + my $custrole='cr_'.$env{'user.domain'}. + '_'.$env{'user.name'}.'_'.$cust; + $output .= ' <option value="'.$custrole.'">'.$cust.'</option>'; + } } } return $output; @@ -1108,10 +1149,10 @@ sub course_roles { if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'})) { push(@roles,$role); } else { - if ($role ne 'cc' && $env{'request.course.section'} ne '') { - if (!&Apache::lonnet::allowed('c'.$role, + if ($role ne 'cc' && $env{'request.course.sec'} ne '') { + if (&Apache::lonnet::allowed('c'.$role, $env{'request.course.id'}.'/'. - $env{'request.course.section'})) { + $env{'request.course.sec'})) { push(@roles,$role); } } @@ -1236,15 +1277,15 @@ sub print_userlist { if ($role eq $env{'form.showrole'}) { $roleselected = ' selected="selected" '; } - my $plrole=&Apache::lonnet::plaintext($role); + my $plrole; + if ($role eq 'cr') { + $plrole = &mt('Custom role'); + } else { + $plrole=&Apache::lonnet::plaintext($role); + } $role_select .= '<option value="'.$role.'"'.$roleselected.'>'.$plrole.'</option>'; } - $roleselected = ''; - if ($env{'form.showrole'} eq 'cr') { - $roleselected = ' selected="selected" '; - } - $role_select .= '<option value="cr"'.$roleselected.'>'.&mt('Custom role').'</option>'. - '</select>'; + $role_select .= '</select>'; $r->print('<label>'.&mt('Role: [_1]',$role_select).'</label>'); } if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) { @@ -1275,9 +1316,11 @@ sub print_userlist { if ($context eq 'course') { my $classlist = &Apache::loncoursedata::get_classlist(); my $secidx = &Apache::loncoursedata::CL_SECTION(); + my $viewablesec = &viewable_section($permission); foreach my $student (keys(%{$classlist})) { - if (exists($permission->{'view_section'})) { - if ($classlist->{$student}[$secidx] ne $permission->{'view_section'}) { + my $section = $classlist->{$student}[$secidx]; + if ($viewablesec ne '') { + if ($section ne $viewablesec) { next; } else { $userlist{$student} = $classlist->{$student}; @@ -1286,7 +1329,7 @@ sub print_userlist { $userlist{$student} = $classlist->{$student}; } } - my $cid =$env{'request.course.id'}; + my $cid = $env{'request.course.id'}; my ($cnum,$cdom) = &get_course_identity($cid); my $showroles; if ($env{'form.showrole'} ne 'Any') { @@ -1294,8 +1337,9 @@ sub print_userlist { } else { $showroles = undef; } + my $withsec = 1; my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef, - \@statuses,$showroles); + \@statuses,$showroles,undef,$withsec); &gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo, \%advrolehash,$permission); } else { @@ -1327,12 +1371,12 @@ sub print_userlist { } else { my @possroles; if ($env{'form.showrole'} eq 'Any') { - my @possroles = &roles_by_context($context); + @possroles = &roles_by_context('author'); } else { @possroles = ($env{'form.showrole'}); } foreach my $author (sort(keys(%{$dom_roles{$key}}))) { - my ($role,$authorname,$authordom) = split(/:/,$author); + my ($role,$authorname,$authordom) = split(/:/,$author,-1); my $extent = '/'.$authordom.'/'.$authorname; %{$coauthors{$extent}} = &Apache::lonnet::get_my_roles($authorname, @@ -1348,8 +1392,6 @@ sub print_userlist { my %courses = &process_coursepick(); my %allusers; foreach my $cid (keys(%courses)) { - my %coursehash = - &Apache::lonnet::coursedescription($cid,{'one_time' => 1}); my ($cnum,$cdom,$cdesc) = &get_course_identity($cid); next if ($cnum eq '' || $cdom eq ''); my $custom = 1; @@ -1357,7 +1399,6 @@ sub print_userlist { %statushash); if ($env{'form.showrole'} eq 'Any') { @roles = &course_roles($context,undef,$custom); - unshift(@roles,'cr'); } else { @roles = ($env{'form.showrole'}); } @@ -1433,19 +1474,30 @@ sub list_submit_button { sub gather_userinfo { my ($context,$format,$userlist,$indexhash,$userinfo,$rolehash,$permission) = @_; foreach my $item (keys(%{$rolehash})) { - @{$userlist->{$item}} = (); my %userdata; - if ($context eq 'author' || $context eq 'course') { + if ($context eq 'author') { ($userdata{'username'},$userdata{'domain'},$userdata{'role'}) = split(/:/,$item); ($userdata{'start'},$userdata{'end'})=split(/:/,$rolehash->{$item}); - &build_user_record(\%userdata,$userinfo,$indexhash,$item,$userlist); + &build_user_record($context,\%userdata,$userinfo,$indexhash, + $item,$userlist); + } elsif ($context eq 'course') { + my $viewablesec = &viewable_section($permission); + ($userdata{'username'},$userdata{'domain'},$userdata{'role'}, + $userdata{'section'}) = split(/:/,$item,-1); + ($userdata{'start'},$userdata{'end'})=split(/:/,$rolehash->{$item}); + if (($viewablesec ne '') && ($userdata{'section'} ne '')) { + next if ($viewablesec ne $userdata{'section'}); + } + &build_user_record($context,\%userdata,$userinfo,$indexhash, + $item,$userlist); } elsif ($context eq 'domain') { if ($env{'form.roletype'} eq 'domain') { ($userdata{'role'},$userdata{'username'},$userdata{'domain'}) = split(/:/,$item); ($userdata{'end'},$userdata{'start'})=split(/:/,$rolehash->{$item}); - &build_user_record(\%userdata,$userinfo,$indexhash,$item,$userlist); + &build_user_record($context,\%userdata,$userinfo,$indexhash, + $item,$userlist); } elsif ($env{'form.roletype'} eq 'author') { if (ref($rolehash->{$item}) eq 'HASH') { $userdata{'extent'} = $item; @@ -1454,7 +1506,8 @@ sub gather_userinfo { ($userdata{'start'},$userdata{'end'}) = split(/:/,$rolehash->{$item}{$key}); my $uniqid = $key.':'.$item; - &build_user_record(\%userdata,$userinfo,$indexhash,$uniqid,$userlist); + &build_user_record($context,\%userdata,$userinfo,$indexhash, + $uniqid,$userlist); } } } elsif ($env{'form.roletype'} eq 'course') { @@ -1469,13 +1522,14 @@ sub gather_userinfo { my $space = ', '; if ($format eq 'html' || $format eq 'view') { $spanstart = '<span class="LC_nobreak">'; - if ($permission->{'cusr'}) { - if ($numcids > 1) { - $spanstart .= '<input type="radio" name="'.$item.'" value="'.$cid.'" />'; - } else { - $spanstart .= '<input type="hidden" name="'.$item.'" value="'.$cid.'" />'; - } - } + # FIXME: actions on courses disabled for now +# if ($permission->{'cusr'}) { +# if ($numcids > 1) { +# $spanstart .= '<input type="radio" name="'.$item.'" value="'.$cid.'" />'; +# } else { +# $spanstart .= '<input type="hidden" name="'.$item.'" value="'.$cid.'" />'; +# } +# } $spanend = '</span><br />'; $space = ', '; } @@ -1489,7 +1543,8 @@ sub gather_userinfo { } } } - &build_user_record(\%userdata,$userinfo,$indexhash,$item,$userlist); + &build_user_record($context,\%userdata,$userinfo,$indexhash, + $item,$userlist); } } } @@ -1497,14 +1552,15 @@ sub gather_userinfo { } sub build_user_record { - my ($userdata,$userinfo,$indexhash,$record_key,$userlist) = @_; + my ($context,$userdata,$userinfo,$indexhash,$record_key,$userlist) = @_; next if ($userdata->{'start'} eq '-1' && $userdata->{'end'} eq '-1'); - &process_date_info($userdata); + if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) { + &process_date_info($userdata); + } my $username = $userdata->{'username'}; my $domain = $userdata->{'domain'}; if (ref($userinfo->{$username.':'.$domain}) eq 'HASH') { - $userdata->{'fullname'} = - $userinfo->{$username.':'.$domain}{'fullname'}; + $userdata->{'fullname'} = $userinfo->{$username.':'.$domain}{'fullname'}; $userdata->{'id'} = $userinfo->{$username.':'.$domain}{'id'}; } else { &aggregate_user_info($domain,$username,$userinfo); @@ -1754,10 +1810,10 @@ sub show_users_list { if (!grep(/^\Q$sortby\E$/,@sortable)) { $sortby = 'username'; } - my $setting = $env{'form.roleaction'}; + my $setting = $env{'form.roletype'}; my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers); if ($context eq 'course') { - $cid=$env{'request.course.id'}; + $cid = $env{'request.course.id'}; ($cnum,$cdom) = &get_course_identity($cid); ($classgroups) = &Apache::loncoursedata::get_group_memberships( $userlist,$keylist,$cdom,$cnum); @@ -1923,7 +1979,7 @@ END my $results_description; if ($mode ne 'autoenroll') { $results_description = &results_header_row($rolefilter,$statusmode, - $context,$permission); + $context,$permission,$mode); $r->print('<b>'.$results_description.'</b><br />'); } my ($output,$actionselect); @@ -2318,6 +2374,10 @@ sub select_actions { chgsec => "Change section associated with user roles", ); my ($output,$options,%choices); + # FIXME Disable actions for now for roletype=course in domain context + if ($context eq 'domain' && $setting eq 'course') { + return; + } if ($statusmode eq 'Any') { $options .= ' <option value="chgdates">'.$lt{'chgdates'}.'</option>'; @@ -2579,13 +2639,15 @@ sub section_picker { } sub results_header_row { - my ($rolefilter,$statusmode,$context,$permission) = @_; + my ($rolefilter,$statusmode,$context,$permission,$mode) = @_; my ($description,$showfilter); if ($rolefilter ne 'Any') { $showfilter = $rolefilter; } if ($context eq 'course') { - $description = &mt('Course - ').$env{'course.'.$env{'request.course.id'}.'.description'}.': '; + if ($mode eq 'csv' || $mode eq 'excel') { + $description = &mt('Course - ').$env{'course.'.$env{'request.course.id'}.'.description'}.': '; + } if ($statusmode eq 'Expired') { $description .= &mt('Users in course with expired [_1] roles',$showfilter); } elsif ($statusmode eq 'Future') { @@ -2685,6 +2747,20 @@ sub results_header_row { } return $description; } + +sub viewable_section { + my ($permission) = @_; + my $viewablesec; + if (ref($permission) eq 'HASH') { + if (exists($permission->{'view_section'})) { + $viewablesec = $permission->{'view_section'}; + } elsif (exists($permission->{'cusr_section'})) { + $viewablesec = $permission->{'cusr_section'}; + } + } + return $viewablesec; +} + ################################################# #################################################