--- loncom/interface/lonuserutils.pm 2010/11/14 22:41:53 1.97.2.23
+++ loncom/interface/lonuserutils.pm 2009/10/30 03:57:35 1.101
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.97.2.23 2010/11/14 22:41:53 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.101 2009/10/30 03:57:35 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') {
@@ -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'};
@@ -276,7 +271,7 @@ 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');
@@ -296,8 +291,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 +305,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 +328,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 +361,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 +382,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 +528,6 @@ END
if (message!='') {
message+='\\n';
}
- message+='$alert{'section'}';
}
if (foundemail==0) {
if (message!='') {
@@ -588,46 +581,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) {
@@ -899,7 +826,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(
@@ -968,7 +895,7 @@ sub print_upload_manager_footer {
.'';
if ($context eq 'course') {
$Str .= '
'
- .&mt('Note: This operation may be time consuming when adding several users.')
+ .&mt('Note: For large courses, this operation may be time consuming.')
.'
';
}
$Str .= '
=0) {
@@ -1246,7 +1172,7 @@ sub default_role_selector {
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(
@@ -1272,16 +1198,16 @@ sub default_role_selector {
$options .= ' ';
}
my $courseform = &Apache::loncommon::selectcourse_link
- ('studentform','dccourse','dcdomain','coursedesc',"$env{'request.role.domain'}",undef,'Course/Community');
+ ('studentform','dccourse','dcdomain','coursedesc',"$env{'request.role.domain'}",undef,'Course');
$cb_jscript =
- &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'currsec','studentform','courserole','Course/Community');
+ &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'currsec','studentform');
$coursepick = &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
'
'.&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 {
@@ -1634,7 +1525,7 @@ sub print_userlist {
}
} elsif (($env{'form.roletype'} eq 'course') ||
($env{'form.roletype'} eq 'community')) {
- if (($env{'form.coursepick'}) && (!$clearcoursepick)) {
+ if ($env{'form.coursepick'}) {
my %courses = &process_coursepick();
my %allusers;
my $hidepriv = 1;
@@ -1791,7 +1682,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 +1693,7 @@ sub section_group_filter {
}
if (@options > 0) {
my $currsel;
- $markup = ''."\n";
- $output .= (' 'x3).''
- .''
- .' ';
+ $output .= (' 'x3).'';
}
}
return $output;
@@ -1872,8 +1761,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 +1811,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 +1926,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'});
@@ -2231,12 +2114,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 +2210,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 +2221,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') {
@@ -2378,19 +2250,14 @@ END
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.'
');
}
my ($output,$actionselect,%canchange,%canchangesec);
if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {
if ($permission->{'cusr'}) {
- unless (($context eq 'domain') &&
- (($setting eq 'course') || ($setting eq 'community'))) {
- $actionselect =
- &select_actions($context,$setting,$statusmode,$formname);
- }
+ $actionselect = &select_actions($context,$setting,$statusmode,$formname);
}
$r->print(<
@@ -2401,7 +2268,7 @@ END
END
if ($actionselect) {
$output .= <<"END";
-