--- loncom/interface/lonuserutils.pm 2010/11/14 22:47:37 1.97.2.24
+++ loncom/interface/lonuserutils.pm 2009/09/12 17:06:16 1.100
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.97.2.24 2010/11/14 22:47:37 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.100 2009/09/12 17:06:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -47,8 +47,7 @@ sub modifystudent {
# this one. If $csec is defined, drop them from all other sections of
# this course and add them to section $csec
my ($cnum,$cdom) = &get_course_identity($courseid);
- my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1});
- my %roles = &Apache::lonnet::dump('roles',$udom,$unam,'.',undef,$extra);
+ my %roles = &Apache::lonnet::dump('roles',$udom,$unam);
my ($tmp) = keys(%roles);
# Bail out if we were unable to get the students roles
return "$1" if ($tmp =~ /^(con_lost|error|no_such_host)/i);
@@ -92,7 +91,7 @@ sub modifyuserrole {
if ($setting eq 'course' || $context eq 'course') {
$scope = '/'.$cid;
$scope =~ s/\_/\//g;
- if (($role ne 'cc') && ($role ne 'co') && ($sec ne '')) {
+ if ($role ne 'cc' && $sec ne '') {
$scope .='/'.$sec;
}
} elsif ($context eq 'domain') {
@@ -236,7 +235,7 @@ sub domain_roles_select {
# domain context
#
# Role types
- my @roletypes = ('domain','author','course','community');
+ my @roletypes = ('domain','author','course');
my %lt = &role_type_names();
#
# build up the menu information to be passed to
@@ -248,10 +247,6 @@ sub domain_roles_select {
foreach my $roletype (@roletypes) {
# set up the text for this domain
$select_menus{$roletype}->{'text'}= $lt{$roletype};
- my $crstype;
- if ($roletype eq 'community') {
- $crstype = 'Community';
- }
# we want a choice of 'default' as the default in the second menu
if ($env{'form.roletype'} ne '') {
$select_menus{$roletype}->{'default'} = $env{'form.showrole'};
@@ -266,7 +261,7 @@ sub domain_roles_select {
@roles = &construction_space_roles();
} else {
my $custom = 1;
- @roles = &course_roles('domain',undef,$custom,$roletype);
+ @roles = &course_roles('domain',undef,$custom);
}
my $order = ['Any',@roles];
$select_menus{$roletype}->{'order'} = $order;
@@ -276,15 +271,14 @@ sub domain_roles_select {
&mt('Custom role');
} else {
$select_menus{$roletype}->{'select2'}->{$role} =
- &Apache::lonnet::plaintext($role,$crstype);
+ &Apache::lonnet::plaintext($role);
}
}
$select_menus{$roletype}->{'select2'}->{'Any'} = &mt('Any');
}
my $result = &Apache::loncommon::linked_select_forms
('studentform',(' 'x3).&mt('Role: '),$env{'form.roletype'},
- 'roletype','showrole',\%select_menus,
- ['domain','author','course','community']);
+ 'roletype','showrole',\%select_menus,['domain','author','course']);
return $result;
}
@@ -296,8 +290,7 @@ sub hidden_input {
}
sub print_upload_manager_header {
- my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype,
- $can_assign)=@_;
+ my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission)=@_;
my $javascript;
#
if (! exists($env{'form.upfile_associate'})) {
@@ -311,9 +304,9 @@ sub print_upload_manager_header {
}
}
if ($env{'form.upfile_associate'} eq 'reverse') {
- $javascript=&upload_manager_javascript_reverse_associate($can_assign);
+ $javascript=&upload_manager_javascript_reverse_associate();
} else {
- $javascript=&upload_manager_javascript_forward_associate($can_assign);
+ $javascript=&upload_manager_javascript_forward_associate();
}
#
# Deal with restored settings
@@ -334,7 +327,7 @@ sub print_upload_manager_header {
my $javascript_validations =
&javascript_validations('upload',$krbdefdom,$password_choice,undef,
$env{'request.role.domain'},$context,
- $groupslist,$crstype);
+ $groupslist);
my $checked=(($env{'form.noFirstLine'})?' checked="checked"':'');
$r->print('
'
.&mt('Total number of records found in file: [_1]'
@@ -367,7 +360,7 @@ sub print_upload_manager_header {
###############################################################
sub javascript_validations {
my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain,
- $context,$groupslist,$crstype)=@_;
+ $context,$groupslist)=@_;
my %param = (
kerb_def_dom => $krbdefdom,
curr_authtype => $curr_authtype,
@@ -388,10 +381,10 @@ sub javascript_validations {
if (($context eq 'course') || ($context eq 'domain')) {
if ($context eq 'course') {
if ($env{'request.course.sec'} eq '') {
- $setsection_call = 'setSections(document.'.$param{'formname'}.",'$crstype'".');';
+ $setsection_call = 'setSections(document.'.$param{'formname'}.');';
$setsections_js =
&setsections_javascript($param{'formname'},$groupslist,
- $mode,'',$crstype);
+ $mode);
} else {
$setsection_call = "'ok'";
}
@@ -534,7 +527,6 @@ END
if (message!='') {
message+='\\n';
}
- message+='$alert{'section'}';
}
if (foundemail==0) {
if (message!='') {
@@ -588,46 +580,6 @@ END
###############################################################
###############################################################
sub upload_manager_javascript_forward_associate {
- my ($can_assign) = @_;
- my ($auth_update,$numbuttons,$argreset);
- if (ref($can_assign) eq 'HASH') {
- if ($can_assign->{'krb4'} || $can_assign->{'krb5'}) {
- $argreset .= " vf.krbarg.value='';\n";
- $numbuttons ++ ;
- }
- if ($can_assign->{'int'}) {
- $argreset .= " vf.intarg.value='';\n";
- $numbuttons ++;
- }
- if ($can_assign->{'loc'}) {
- $argreset .= " vf.locarg.value='';\n";
- $numbuttons ++;
- }
- if (!$can_assign->{'int'}) {
- my $warning = &mt('You may not specify an initial password for each user, as this is only available when new users use LON-CAPA internal authentication.\n').
- &mt('Your current role does not have rights to create users with that authentication type.');
- $auth_update = <<"END";
- // Currently the initial password field is only supported for internal auth
- // (see bug 6368).
- if (nw==9) {
- eval('vf.f'+tf+'.selectedIndex=0;')
- alert('$warning');
- }
-END
- } elsif ($numbuttons > 1) {
- $auth_update = <<"END";
- // If we set the password, make the password form below correspond to
- // the new value.
- if (nw==9) {
- changed_radio('int',document.studentform);
- set_auth_radio_buttons('int',document.studentform);
-$argreset
- }
-
-END
- }
- }
-
return(<{'krb4'} || $can_assign->{'krb5'}) {
- $argreset .= " vf.krbarg.value='';\n";
- $numbuttons ++ ;
- }
- if ($can_assign->{'int'}) {
- $argreset .= " vf.intarg.value='';\n";
- $numbuttons ++;
- }
- if ($can_assign->{'loc'}) {
- $argreset .= " vf.locarg.value='';\n";
- $numbuttons ++;
- }
- if (!$can_assign->{'int'}) {
- my $warning = &mt('You may not specify an initial password, as this is only available when new users use LON-CAPA internal authentication.\n').
- &mt('Your current role does not have rights to create users with that authentication type.');
- $auth_update = <<"END";
- // Currently the initial password field is only supported for internal auth
- // (see bug 6368).
- if (tf==8 && nw!=0) {
- eval('vf.f'+tf+'.selectedIndex=0;')
- alert('$warning');
- }
-END
- } elsif ($numbuttons > 1) {
- $auth_update = <<"END";
- // initial password specified, pick internal authentication
- if (tf==8 && nw!=0) {
- changed_radio('int',document.studentform);
- set_auth_radio_buttons('int',document.studentform);
-$argreset
- }
-
-END
- }
- }
-
return(<=2) && (tf<=5) && (nw!=0)) {
eval('vf.f1.selectedIndex=0;')
}
- $auth_update
+ // intial password specified, pick internal authentication
+ if (tf==8 && nw!=0) {
+ changed_radio('int',document.studentform);
+ set_auth_radio_buttons('int',document.studentform);
+ vf.krbarg.value='';
+ vf.intarg.value='';
+ vf.locarg.value='';
+ }
}
function clearpwd(vf) {
@@ -817,7 +743,7 @@ ENDPICK
###############################################################
###############################################################
sub print_upload_manager_footer {
- my ($r,$i,$keyfields,$defdom,$today,$halfyear,$context,$permission,$crstype) = @_;
+ my ($r,$i,$keyfields,$defdom,$today,$halfyear,$context,$permission) = @_;
my $form = 'document.studentform';
my $formname = 'studentform';
my ($krbdef,$krbdefdom) =
@@ -835,7 +761,7 @@ sub print_upload_manager_footer {
my $intform = &Apache::loncommon::authform_internal(%param);
my $locform = &Apache::loncommon::authform_local(%param);
my $date_table = &date_setting_table(undef,undef,$context,undef,
- $formname,$permission,$crstype);
+ $formname,$permission);
my $Str = "\n".'
';
$Str .= &hidden_input('nfields',$i);
@@ -899,7 +825,7 @@ sub print_upload_manager_footer {
.' '.&mt('Add a domain role').''
.' '
+ .' '.&mt('Add a course role').''
.'';
} elsif ($context eq 'author') {
$Str .= &Apache::lonhtmlcommon::row_title(
@@ -934,26 +860,15 @@ sub print_upload_manager_footer {
my ($cnum,$cdom) = &get_course_identity();
my $rowtitle = &mt('section');
my $secbox = §ion_picker($cdom,$cnum,'Any',$rowtitle,
- $permission,$context,'upload',$crstype);
+ $permission,$context,'upload');
$Str .= $secbox
.&Apache::lonhtmlcommon::row_closure();
- my %lt;
- if ($crstype eq 'Community') {
- %lt = &Apache::lonlocal::texthash (
- disp => 'Display members with current/future access who are not in the uploaded file',
- stus => 'Members selected from this list can be dropped.'
- );
- } else {
- %lt = &Apache::lonlocal::texthash (
- disp => 'Display students with current/future access who are not in the uploaded file',
- stus => 'Students selected from this list can be dropped.'
- );
- }
+
$Str .= &Apache::lonhtmlcommon::row_title(&mt('Full Update'))
- .'
');
&print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear,
- $context,$permission,$crstype);
+ $context,$permission);
}
sub setup_date_selectors {
@@ -1159,7 +1073,7 @@ sub get_dates_from_form {
}
sub date_setting_table {
- my ($starttime,$endtime,$mode,$bulkaction,$formname,$permission,$crstype) = @_;
+ my ($starttime,$endtime,$mode,$bulkaction,$formname,$permission) = @_;
my $nolink;
if ($bulkaction) {
$nolink = 1;
@@ -1176,13 +1090,9 @@ sub date_setting_table {
($env{'form.action'} eq 'upload')) {
if ($env{'request.course.sec'} eq '') {
$dateDefault = ''.
- ' ';
- if ($crstype eq 'Community') {
- $dateDefault .= &mt("make these dates the default access dates for future community enrollment");
- } else {
- $dateDefault .= &mt("make these dates the default access dates for future course enrollment");
- }
- $dateDefault .= '';
+ ' '.
+ &mt('make these dates the default access dates for future student enrollment').
+ '';
}
}
}
@@ -1211,7 +1121,7 @@ sub date_setting_table {
}
sub make_dates_default {
- my ($startdate,$enddate,$context,$crstype) = @_;
+ my ($startdate,$enddate,$context) = @_;
my $result = '';
if ($context eq 'course') {
my ($cnum,$cdom) = &get_course_identity();
@@ -1219,34 +1129,26 @@ sub make_dates_default {
{'default_enrollment_start_date'=>$startdate,
'default_enrollment_end_date' =>$enddate},$cdom,$cnum);
if ($put_result eq 'ok') {
- if ($crstype eq 'Community') {
- $result .= &mt('Set default start and end access dates for community.');
- } else {
- $result .= &mt('Set default start and end access dates for course.');
- }
- $result .= ' '."\n";
+ $result .= &mt('Set default start and end access dates for course.').
+ ' '."\n";
#
# Refresh the course environment
&Apache::lonnet::coursedescription($env{'request.course.id'},
{'freshen_cache' => 1});
} else {
- if ($crstype eq 'Community') {
- $result .= &mt('Unable to set default access dates for community');
- } else {
- $result .= &mt('Unable to set default access dates for course');
- }
- $result .= ':'.$put_result.' ';
+ $result .= &mt('Unable to set default access dates for course.').":".$put_result.
+ ' ';
}
}
return $result;
}
sub default_role_selector {
- my ($context,$checkpriv,$crstype) = @_;
+ my ($context,$checkpriv) = @_;
my %customroles;
my ($options,$coursepick,$cb_jscript);
if ($context ne 'author') {
- %customroles = &my_custom_roles($crstype);
+ %customroles = &my_custom_roles();
}
my %lt=&Apache::lonlocal::texthash(
@@ -1258,7 +1160,7 @@ sub default_role_selector {
$options = '
'.&mt('Warning: data retrieval for multiple courses can take considerable time, as this operation is not currently optimized.').''."\n");
+ if ($env{'form.coursepick'}) {
$r->print(''.&mt('Searching').' ...
');
}
} else {
@@ -1632,9 +1499,8 @@ sub print_userlist {
}
}
}
- } elsif (($env{'form.roletype'} eq 'course') ||
- ($env{'form.roletype'} eq 'community')) {
- if (($env{'form.coursepick'}) && (!$clearcoursepick)) {
+ } elsif ($env{'form.roletype'} eq 'course') {
+ if ($env{'form.coursepick'}) {
my %courses = &process_coursepick();
my %allusers;
my $hidepriv = 1;
@@ -1645,8 +1511,7 @@ sub print_userlist {
my (@roles,@sections,%access,%users,%userdata,
%statushash);
if ($env{'form.showrole'} eq 'Any') {
- @roles = &course_roles($context,undef,$custom,
- $env{'form.roletype'});
+ @roles = &course_roles($context,undef,$custom);
} else {
@roles = ($env{'form.showrole'});
}
@@ -1692,8 +1557,6 @@ sub print_userlist {
$r->print(&mt('There are no authors or co-authors to display.')."\n");
} elsif ($env{'form.roletype'} eq 'course') {
$r->print(&mt('There are no course users to display')."\n");
- } elsif ($env{'form.roletype'} eq 'community') {
- $r->print(&mt('There are no community users to display')."\n");
}
} elsif ($context eq 'course') {
$r->print(&mt('There are no course users to display.')."\n");
@@ -1736,16 +1599,7 @@ sub role_filter {
$role_select = ''."\n".
'';
- my ($roletype,$crstype);
- if ($context eq 'course') {
- $crstype = &Apache::loncommon::course_type();
- if ($crstype eq 'Community') {
- $roletype = 'community';
- } else {
- $roletype = 'course';
- }
- }
- my @poss_roles = &curr_role_permissions($context,'','',$roletype);
+ my @poss_roles = &curr_role_permissions($context);
foreach my $role (@poss_roles) {
$roleselected = '';
if ($role eq $env{'form.showrole'}) {
@@ -1755,7 +1609,7 @@ sub role_filter {
if ($role eq 'cr') {
$plrole = &mt('Custom role');
} else {
- $plrole=&Apache::lonnet::plaintext($role,$crstype);
+ $plrole=&Apache::lonnet::plaintext($role);
}
$role_select .= '';
}
@@ -1791,7 +1645,7 @@ sub section_group_filter {
$env{'form.'.$name{$item}} = 'all';
}
if ($item eq 'sec') {
- if (($env{'form.showrole'} eq 'cc') || ($env{'form.showrole'} eq 'co')) {
+ if ($env{'form.showrole'} eq 'cc') {
$env{'form.'.$name{$item}} = 'none';
}
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum);
@@ -1802,7 +1656,7 @@ sub section_group_filter {
}
if (@options > 0) {
my $currsel;
- $markup = ''."\n";
+ $markup = ''."\n";
foreach my $option ('all','none',@options) {
$currsel = '';
if ($env{'form.'.$name{$item}} eq $option) {
@@ -1817,9 +1671,7 @@ sub section_group_filter {
$markup .= ''."\n";
}
$markup .= ''."\n";
- $output .= (' 'x3).''
- .''.$title{$item}.': '.$markup.''
- .' ';
+ $output .= (' 'x3).''.$title{$item}.': '.$markup.'';
}
}
return $output;
@@ -1872,8 +1724,7 @@ sub gather_userinfo {
$indexhash,$uniqid,$userlist);
}
}
- } elsif (($env{'form.roletype'} eq 'course') ||
- ($env{'form.roletype'} eq 'community')) {
+ } elsif ($env{'form.roletype'} eq 'course') {
($userdata{'username'},$userdata{'domain'},$userdata{'role'}) =
split(/:/,$item);
if (ref($rolehash->{$item}) eq 'HASH') {
@@ -1923,8 +1774,7 @@ sub gather_userinfo {
sub build_user_record {
my ($context,$userdata,$userinfo,$indexhash,$record_key,$userlist) = @_;
next if ($userdata->{'start'} eq '-1' && $userdata->{'end'} eq '-1');
- if (!(($context eq 'domain') && (($env{'form.roletype'} eq 'course')
- && ($env{'form.roletype'} eq 'community')))) {
+ if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) {
&process_date_info($userdata);
}
my $username = $userdata->{'username'};
@@ -2039,17 +1889,13 @@ sub process_coursepick {
my $coursefilter = $env{'form.coursepick'};
my $cdom = $env{'request.role.domain'};
my %courses;
- my $crssrch = 'Course';
- if ($env{'form.roletype'} eq 'community') {
- $crssrch = 'Community';
- }
if ($coursefilter eq 'all') {
%courses = &Apache::lonnet::courseiddump($cdom,'.','.','.','.','.',
- undef,undef,$crssrch);
+ undef,undef,'Course');
} elsif ($coursefilter eq 'category') {
my $instcode = &instcode_from_coursefilter();
%courses = &Apache::lonnet::courseiddump($cdom,'.','.',$instcode,'.','.',
- undef,undef,$crssrch);
+ undef,undef,'Course');
} elsif ($coursefilter eq 'specific') {
if ($env{'form.coursetotal'} > 1) {
my @course_ids = split(/&&/,$env{'form.courselist'});
@@ -2193,10 +2039,9 @@ sub show_users_list {
$sortby = 'username';
}
my $setting = $env{'form.roletype'};
- my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers,$crstype);
+ my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers);
if ($context eq 'course') {
$cid = $env{'request.course.id'};
- $crstype = &Apache::loncommon::course_type();
($cnum,$cdom) = &get_course_identity($cid);
($classgroups) = &Apache::loncoursedata::get_group_memberships(
$userlist,$keylist,$cdom,$cnum);
@@ -2231,12 +2076,6 @@ function photowindow(photolink) {
END
}
- } elsif ($context eq 'domain') {
- if ($setting eq 'community') {
- $crstype = 'Community';
- } elsif ($setting eq 'course') {
- $crstype = 'Course';
- }
}
if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {
my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript();
@@ -2333,8 +2172,6 @@ END
);
if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
$lt{'extent'} = &mt('Course(s): description, section(s), status');
- } elsif ($context eq 'domain' && $env{'form.roletype'} eq 'community') {
- $lt{'extent'} = &mt('Communities: description, section(s), status');
} elsif ($context eq 'author') {
$lt{'extent'} = &mt('Author');
}
@@ -2346,21 +2183,18 @@ END
if ($context eq 'course') {
push(@cols,'section');
}
- if (!($context eq 'domain' && ($env{'form.roletype'} eq 'course')
- && ($env{'form.roletype'} eq 'community'))) {
+ if (!($context eq 'domain' && $env{'form.roletype'} eq 'course')) {
push(@cols,('start','end'));
}
if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') {
push(@cols,'role');
}
if ($context eq 'domain' && ($env{'form.roletype'} eq 'author' ||
- $env{'form.roletype'} eq 'course' ||
- $env{'form.roletype'} eq 'community')) {
+ $env{'form.roletype'} eq 'course')) {
push (@cols,'extent');
}
- if (($statusmode eq 'Any') &&
- (!($context eq 'domain' && (($env{'form.roletype'} eq 'course')
- || ($env{'form.roletype'} eq 'community'))))) {
+ if (($statusmode eq 'Any') &&
+ (!($context eq 'domain' && $env{'form.roletype'} eq 'course'))) {
push(@cols,'status');
}
if ($context eq 'course') {
@@ -2373,24 +2207,19 @@ END
if ($env{'form.showrole'} eq 'cr') {
$rolefilter = &mt('custom');
} elsif ($env{'form.showrole'} ne 'Any') {
- $rolefilter = &Apache::lonnet::plaintext($env{'form.showrole'},$crstype);
+ $rolefilter = &Apache::lonnet::plaintext($env{'form.showrole'});
}
my $results_description;
if ($mode ne 'autoenroll') {
$results_description = &results_header_row($rolefilter,$statusmode,
- $context,$permission,$mode,$crstype);
-
+ $context,$permission,$mode);
$r->print(''.$results_description.'