[LON-CAPA-cvs] cvs: loncom /interface lonuserutils.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Sat, 22 Dec 2007 00:39:53 -0000
This is a MIME encoded message
--raeburn1198283993
Content-Type: text/plain
raeburn Fri Dec 21 19:39:53 2007 EDT
Modified files:
/loncom/interface lonuserutils.pm
Log:
- &viewable_section() checks if display of roles in a course should be restricted to a single section, because viewer's role is sectioned.
- in &modifystudent() include courseID in args sent to lonnet::modifystudent() to permit use in domain context.
- &print_upload_manager_header() takes additional 6th arg - $permission
- retrieve groupslist used in javascript for section name checking from &get_groupslist().
- &javascript_validations() takes three additional args: $context, $permission and $groupslist.
- replace mode type of 'auth' in javascript_validations() with 'upload'.
- additional mode added - "singlestudent" for javascript for validation of a single section when enrolling a single student.
- depending on mode, javascript function verify_message(), includes different content from $setsection_call and &setsections_javascript.
- in domain mode, uses setCourse() to set form element names for addition of roles to a course
- in singlestudent mode, checks student's proposed section is valid.
- in upload mode, checks validity of proposed default section for uses in uploaded file.
- if users has section-specific 'cst' priv, enrollment is in this section.
- &print_upload_manager_footer() takes 8th arg - permission.
- &print_upload_manager_header() takes 6th arg = permission.
- &setup_date_selectors() takes 5th arg - $formname.
- &date_setting_table() used to create table for starting and ending access dates takes two additional args - $formname, $permission.
- option to make dates default added in case where access dates set for a file upload in course context.
- change names of course, domain and description for course/role/section selection box in file upload in domain context. Names now consistent with single user create/modify interface so setCourse() works both places.
- "sections" form element added for storage of aggregated section selections.
- custom role identifier in default role selector modified so custom roles for uploaded users now named correctly.
- gather all roles in a course for an uploaded user, so check if user info fields are modifiable is comprehensive.
- in filtered display of users in a course, use &viewable_section() to inhibit display of section-specific roles from other sections to a viewer with section-specific priv.
- eliminate creation of empty array - @{$userlist->{$item}} = () when building display list - was causing empty ros in data table.
--raeburn1198283993
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20071221193953.txt"
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.21 loncom/interface/lonuserutils.pm:1.22
--- loncom/interface/lonuserutils.pm:1.21 Fri Dec 21 15:34:26 2007
+++ loncom/interface/lonuserutils.pm Fri Dec 21 19:39:52 2007
@@ -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.22 2007/12/22 00:39:52 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -68,7 +68,8 @@
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 @@
$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 @@
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 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 @@
$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,26 +331,51 @@
###############################################################
###############################################################
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.',
@@ -358,8 +390,9 @@
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 @@
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 @@
###############################################################
###############################################################
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 @@
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 @@
$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 @@
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 @@
}
$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 @@
}
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 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 @@
'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 @@
$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 @@
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 @@
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 @@
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 @@
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 @@
$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 @@
} 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 @@
} 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 @@
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 @@
%statushash);
if ($env{'form.showrole'} eq 'Any') {
@roles = &course_roles($context,undef,$custom);
- unshift(@roles,'cr');
} else {
@roles = ($env{'form.showrole'});
}
@@ -1433,13 +1474,21 @@
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);
+ } 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(\%userdata,$userinfo,$indexhash,$item,$userlist);
} elsif ($context eq 'domain') {
if ($env{'form.roletype'} eq 'domain') {
($userdata{'role'},$userdata{'username'},$userdata{'domain'}) =
@@ -1754,10 +1803,10 @@
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);
@@ -2685,6 +2734,20 @@
}
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;
+}
+
#################################################
#################################################
--raeburn1198283993--