');
+ my ($fixedauth,$varauth,$authmsg);
+ if ($rulematch) {
+ if (ref($rules) eq 'HASH') {
+ if (ref($rules->{$rulematch}) eq 'HASH') {
+ my $authtype = $rules->{$rulematch}{'authtype'};
+ if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) {
+ $r->print(&set_login($ccdomain));
+ } else {
+ my $authparm = $rules->{$rulematch}{'authparm'};
+ if ($authtype =~ /^krb(4|5)$/) {
+ my $ver = $1;
+ if ($authparm ne '') {
+ $fixedauth = <<"KERB";
+
+
+
+KERB
+ $authmsg = $rules->{$rulematch}{'authmsg'};
+ }
+ } else {
+ $fixedauth =
+''."\n";
+ if ($rules->{$rulematch}{'authparmfixed'}) {
+ $fixedauth .=
+''."\n";
+ } else {
+ $varauth =
+''."\n";
+ }
+ }
+ }
+ } else {
+ $r->print(&set_login($ccdomain));
+ }
+ }
+ if ($authmsg) {
+ $r->print(<print(&set_login($ccdomain));
+ }
+ $r->print(<
$portfolioform
-ENDNEWUSER
+ENDPORT
} else { # user already exists
my %lt=&Apache::lonlocal::texthash(
- 'cup' => "Change User Privileges",
- 'usr' => "User",
+ 'cup' => "Change User Privileges for",
'id' => "in domain",
'fn' => "first name",
'mn' => "middle name",
@@ -863,9 +849,8 @@ ENDNEWUSER
$r->print(<$lt{'cup'}
$forminfo
-
$lt{'usr'} "$ccuname" $lt{'id'} "$ccdomain"
+
$lt{'cup'} "$ccuname" $lt{'id'} "$ccdomain"
ENDCHANGEUSER
# Get the users information
my %userenv =
@@ -880,7 +865,7 @@ ENDCHANGEUSER
'
'.$lt{'fn'}.'
'.$lt{'mn'}.'
'.$lt{'ln'}.'
'.$lt{'gen'}.'
'.$lt{'email'}.'
'.
&Apache::loncommon::end_data_table_header_row().
&Apache::loncommon::start_data_table_row());
- foreach my $item ('firstname','middlename','lastname','generation','permenanentemail') {
+ foreach my $item ('firstname','middlename','lastname','generation','permanentemail') {
if (&Apache::lonnet::allowed('mau',$ccdomain)) {
$r->print(<<"END");
@@ -1086,24 +1071,24 @@ END
$currentauth=~/^krb(4|5):(.*)/;
my $krbdefdom=$2;
my %param = ( formname => 'document.cu',
- kerb_def_dom => $krbdefdom
+ kerb_def_dom => $krbdefdom,
+ domain => $ccdomain,
+ curr_authtype => $currentauth,
);
$loginscript = &Apache::loncommon::authform_header(%param);
}
# Check for a bad authentication type
- unless ($currentauth=~/^krb(4|5):/ or
- $currentauth=~/^unix:/ or
- $currentauth=~/^internal:/ or
- $currentauth=~/^localauth:/
- ) { # bad authentication scheme
+ if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) {
+ # bad authentication scheme
if (&Apache::lonnet::allowed('mau',$ccdomain)) {
- &initialize_authen_forms();
+ &initialize_authen_forms($ccdomain);
my %lt=&Apache::lonlocal::texthash(
'err' => "ERROR",
'uuas' => "This user has an unrecognized authentication scheme",
'sldb' => "Please specify login data below",
'ld' => "Login Data"
);
+ my $choices = &set_login($ccdomain);
$r->print(<
$lt{'ccld'}
-
$generalrule
-
$authformnop
-
$authformcurrent
-
$lt{'enld'}
-$authform_other
+
$authformnop
ENDOTHERAUTHS
+ if ($can_modify) {
+ $r->print('
'.$authformcurrent.'
');
+ } else {
+ $r->print(' ('.$authformcurrent.')');
+ }
+ if ($authform_other ne '') {
+ $r->print('
'.$lt{'enld'}.'
'."\n".
+ $authform_other);
+ }
} else {
if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
my %lt=&Apache::lonlocal::texthash(
@@ -1190,11 +1157,22 @@ $lt{'yodo'} $lt{'ifch'}: $ccdomain
ENDNOPRIV
}
}
- if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
- # Current user has quota modification privileges
- $r->print(&portfolio_quota($ccuname,$ccdomain));
- }
} ## End of "check for bad authentication type" logic
+ if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
+ # Current user has quota modification privileges
+ $r->print(&portfolio_quota($ccuname,$ccdomain));
+ } elsif (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
+ my %lt=&Apache::lonlocal::texthash(
+ 'dska' => "Disk space allocated to user's portfolio files",
+ '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",
+ );
+ $r->print(<
+
$lt{'dska'}
+$lt{'youd'} $lt{'ichr'}: $ccdomain
+ENDNOPORTPRIV
+ }
} ## End of new user/old user logic
$r->print('
\n"
+ }
+ if ($can_assign{'loc'}) {
+ $show_override_msg = 1;
+ }
+ }
+ if ($show_override_msg) {
+ $authformcurrent.= ' '.
+ &mt('will override current values').
+ ' ';
+ }
+ return ($authformcurrent,$authform_other,$show_override_msg);
+}
+
# ================================================================= Phase Three
sub update_user_data {
my ($r) = @_;
@@ -1330,7 +1388,7 @@ sub update_user_data {
$r->print(&Apache::loncommon::start_page($title,$jscript));
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:backPage(document.userupdate)",
- text=>"User/custom role search",
+ text=>"User modify/custom role edit",
faq=>282,bug=>'Instructor Interface',});
if ($env{'form.prevphase'} eq 'userpicked') {
&Apache::lonhtmlcommon::add_breadcrumb
@@ -1407,15 +1465,13 @@ sub update_user_data {
$r->print($error.&mt('Invalid login mode or password').$end);
return;
}
+
+
+ $r->print('
'.&mt('User [_1] in domain [_2]',
+ $env{'form.ccuname'}, $env{'form.ccdomain'}).'
');
+
if ($env{'form.makeuser'}) {
- # Create a new user
- my %lt=&Apache::lonlocal::texthash(
- 'cru' => "Creating user",
- 'id' => "in domain"
- );
- $r->print(<$lt{'cru'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"
-ENDNEWUSERHEAD
+ $r->print('
'.&mt('Creating new account.').'
');
# Check for the authentication mode and password
if (! $amode || ! $genpwd) {
$r->print($error.&mt('Invalid login mode or password').$end);
@@ -1438,7 +1494,7 @@ ENDNEWUSERHEAD
($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cstid'},
$amode,$genpwd,$env{'form.cfirst'},
$env{'form.cmiddle'},$env{'form.clast'},$env{'form.cgen'},
- undef,$desiredhost
+ undef,$desiredhost,$env{'form.cemail'}
);
$r->print(&mt('Generating user').': '.$result);
my $home = &Apache::lonnet::homeserver($env{'form.ccuname'},
@@ -1448,13 +1504,6 @@ ENDNEWUSERHEAD
} elsif (($env{'form.login'} ne 'nochange') &&
($env{'form.login'} ne '' )) {
# Modify user privileges
- my %lt=&Apache::lonlocal::texthash(
- 'usr' => "User",
- 'id' => "in domain"
- );
- $r->print(<$lt{'usr'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"
-ENDMODIFYUSERHEAD
if (! $amode || ! $genpwd) {
$r->print($error.'Invalid login mode or password'.$end);
return;
@@ -1552,7 +1601,7 @@ ENDMODIFYUSERHEAD
$changeHash{'middlename'} = $env{'form.cmiddlename'};
$changeHash{'lastname'} = $env{'form.clastname'};
$changeHash{'generation'} = $env{'form.cgeneration'};
- $changeHash{'permanentemail'} = $env{'form.permanentemail'};
+ $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
my $putresult = &Apache::lonnet::put
('environment',\%changeHash,
$env{'form.ccdomain'},$env{'form.ccuname'});
@@ -1577,7 +1626,8 @@ ENDMODIFYUSERHEAD
$lt{'mddl'}
$lt{'lst'}
$lt{'gen'}
-
$lt{'disk'}
+
$lt{'mail'}
+
$lt{'disk'}
$lt{'prvs'}
$userenv{'firstname'}
$userenv{'middlename'}
@@ -1618,16 +1668,11 @@ END
# They did not want to change the users name but we can
# still tell them what the name is
my %lt=&Apache::lonlocal::texthash(
- 'usr' => "User",
- 'id' => "in domain",
- 'gen' => "Generation",
'mail' => "Permanent e-mail",
'disk' => "Disk space allocated to user's portfolio files",
);
$r->print(<<"END");
-
';
+ }
}
}
- return ($state,$response,$forcenewuser,\%srch_results);
+ return ($currstate,$response,$forcenewuser,\%srch_results);
}
sub directorysrch_check {
@@ -2422,13 +2557,14 @@ sub directorysrch_check {
my $response;
my %dom_inst_srch = &Apache::lonnet::get_dom('configuration',
['directorysrch'],$srch->{'srchdomain'});
+ my $showdom = &display_domain_info($srch->{'srchdomain'});
if (ref($dom_inst_srch{'directorysrch'}) eq 'HASH') {
if (!$dom_inst_srch{'directorysrch'}{'available'}) {
- return &mt('Directory search unavailable in domain: [_1]',$srch->{'srchdomain'});
+ return &mt('Institutional directory search is not available in domain: [_1]',$showdom);
}
if ($dom_inst_srch{'directorysrch'}{'localonly'}) {
if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) {
- return &mt('Directory search in domain: [_1] is only allowed for users with a current role in the domain.',$srch->{'srchdomain'});
+ return &mt('Institutional directory search in domain: [_1] is only allowed for users with a current role in the domain.',$showdom);
}
my @usertypes = split(/:/,$env{'environment.inststatus'});
if (!@usertypes) {
@@ -2449,82 +2585,101 @@ sub directorysrch_check {
push (@longtypes,$insttypes->{$item});
}
my $insttype_str = join(', ',@longtypes);
- return &mt('Directory search in domain: [_1] is unavailable to your user type: ',$srch->{'srchdomain'}).$insttype_str;
+ return &mt('Institutional directory search in domain: [_1] is not available to your user type: ',$showdom).$insttype_str;
}
} else {
$can_search = 1;
}
} else {
- return &mt('Directory search has not been configured for domain: [_1]',$srch->{'srchdomain'});
+ return &mt('Institutional directory search has not been configured for domain: [_1]',$showdom);
}
my %longtext = &Apache::lonlocal::texthash (
- uname => 'username',
+ uname => 'username',
lastfirst => 'last name, first name',
- lastname => 'last name',
- contains => 'is contained in',
- exact => 'as exact match to'
+ lastname => 'last name',
+ contains => 'contains',
+ exact => 'as exact match to',
+ begins => 'begins with',
);
if ($can_search) {
if (ref($dom_inst_srch{'directorysrch'}{'searchby'}) eq 'ARRAY') {
if (!grep(/^\Q$srch->{'srchby'}\E$/,@{$dom_inst_srch{'directorysrch'}{'searchby'}})) {
- return &mt('Directory search in domain: [_1] is not available for searching by [_2]',$srch->{'srchdomain'},$longtext{$srch->{'srchby'}});
+ return &mt('Institutional directory search in domain: [_1] is not available for searching by "[_2]"',$showdom,$longtext{$srch->{'srchby'}});
}
} else {
- return &mt('Directory search in domain: [_1] is not available.', $srch->{'srchdomain'});
+ return &mt('Institutional directory search in domain: [_1] is not available.', $showdom);
}
}
if ($can_search) {
- if (($dom_inst_srch{'directorysrch'}{'searchtypes'} eq 'specify') ||
- ($dom_inst_srch{'directorysrch'}{'searchtypes'} eq $srch->{'srchtype'})) {
- return 'ok';
- } else {
- return &mt('Directory search in domain [_1] is not available for the requested search type: [_2]',$srch->{'srchdomain'},$longtext{$srch->{'srchtype'}});
+ if (ref($dom_inst_srch{'directorysrch'}{'searchtypes'}) eq 'ARRAY') {
+ if (grep(/^\Q$srch->{'srchtype'}\E/,@{$dom_inst_srch{'directorysrch'}{'searchtypes'}})) {
+ return 'ok';
+ } else {
+ return &mt('Institutional directory search in domain [_1] is not available for the requested search type: "[_2]"',$showdom,$longtext{$srch->{'srchtype'}});
+ }
+ } else {
+ if ((($dom_inst_srch{'directorysrch'}{'searchtypes'} eq 'specify') &&
+ ($srch->{'srchtype'} eq 'exact' || $srch->{'srchtype'} eq 'contains')) ||
+ ($dom_inst_srch{'directorysrch'}{'searchtypes'} eq $srch->{'srchtype'})) {
+ return 'ok';
+ } else {
+ return &mt('Institutional directory search in domain [_1] is not available for the requested search type: "[_2]"',$showdom,$longtext{$srch->{'srchtype'}});
+ }
}
}
}
-
sub get_courseusers {
my %advhash;
+ my $classlist = &Apache::loncoursedata::get_classlist();
my %coursepersonnel=&Apache::lonnet::get_course_adv_roles();
foreach my $role (sort(keys(%coursepersonnel))) {
foreach my $user (split(/\,/,$coursepersonnel{$role})) {
- $advhash{$user} = '';
+ if (!exists($classlist->{$user})) {
+ $classlist->{$user} = [];
+ }
}
}
- my $classlist = &Apache::loncoursedata::get_classlist();
- my %combined = (%advhash, %{$classlist});
- return %combined;
+ return $classlist;
}
sub build_search_response {
my ($srch,%srch_results) = @_;
- my ($state,$response,$forcenewuser);
+ my ($currstate,$response,$forcenewuser);
my %names = (
'uname' => 'username',
'lastname' => 'last name',
'lastfirst' => 'last name, first name',
'crs' => 'this course',
- 'dom' => 'this domain',
- 'instd' => "your institution's directory",
+ 'dom' => 'LON-CAPA domain: ',
+ 'instd' => 'the institutional directory for domain: ',
);
my %single = (
+ begins => 'A match',
contains => 'A match',
- exact => 'An exact match',
+ exact => 'An exact match',
);
my %nomatch = (
+ begins => 'No match',
contains => 'No match',
- exact => 'No exact match',
+ exact => 'No exact match',
);
if (keys(%srch_results) > 1) {
- $state = 'select';
+ $currstate = 'select';
} else {
if (keys(%srch_results) == 1) {
- $state = 'modify';
- $response = &mt("$single{$srch->{'srchtype'}} was found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
+ $currstate = 'modify';
+ $response = &mt("$single{$srch->{'srchtype'}} was found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
+ if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') {
+ $response .= &display_domain_info($srch->{'srchdomain'});
+ }
} else {
- $response = &mt("$nomatch{$srch->{'srchtype'}} found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
+ $response = ''.&mt("$nomatch{$srch->{'srchtype'}} found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}",$srch->{'srchterm'});
+ if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') {
+ $response .= &display_domain_info($srch->{'srchdomain'});
+ }
+ $response .= '';
if ($srch->{'srchin'} ne 'alc') {
$forcenewuser = 1;
my $cansrchinst = 0;
@@ -2536,21 +2691,36 @@ sub build_search_response {
}
}
}
- if (($srch->{'srchby'} eq 'lastfirst') ||
- ($srch->{'srchby'} eq 'lastname')) {
- if ($srch->{'srchin'} eq 'crs') {
- $response .= ' '.&mt('You may want to broaden your search to the whole domain.');
- } elsif ($srch->{'srchin'} eq 'dom') {
- if ($cansrchinst) {
- $response .= ' '.&mt('You may want to broaden your search to a search of the institutional directory for this domain.');
- }
+ if ((($srch->{'srchby'} eq 'lastfirst') ||
+ ($srch->{'srchby'} eq 'lastname')) &&
+ ($srch->{'srchin'} eq 'dom')) {
+ if ($cansrchinst) {
+ $response .= ' '.&mt('You may want to broaden your search to a search of the institutional directory for the domain.');
}
}
- $response .= ' '.&mt("To add as a new user:").'
'.&mt("Enter the proposed username in the 'Search for' box").'
'.&mt("Set 'Make new user if no match found' to Yes").'
'.&mt("Click 'Search'").'
'.&mt("Note: you can only create new users in the domain of your current role -".$env{'request.role.domain'}).'
';
+ if ($srch->{'srchin'} eq 'crs') {
+ $response .= ' '.&mt('You may want to broaden your search to the selected LON-CAPA domain.');
+ }
}
+ if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) {
+ my $showdom = &display_domain_info($env{'request.role.domain'});
+ $response .= '
'.&mt("To add a new user (you can only create new users in your current role's domain - [_1]):",$env{'request.role.domain'}).'
'.&mt("Set 'Domain/institution to search' to: [_1]",$showdom).'
'.&mt("Set 'Search criteria' to: 'username is ...... in selected LON-CAPA domain'").'