';
+ foreach my $level ('course','domain','system') {
+ if ($customroles{$key}{$level}) {
+ my $suffix;
+ if (($level eq 'domain') || ($level eq 'system')) {
+ $suffix = ' ('.&mt($level).')';
+ }
+ my @privs = split(/:/,$customroles{$key}{$level});
+ foreach my $item (@privs) {
+ next if ($item eq '');
+ my ($priv,$cond) = split(/\&/,$item);
+ $output .= &Apache::lonnet::plaintext($priv,'Course').$suffix.' ';
+ }
+ }
+ }
+ $output .= '
'.
+ &Apache::loncommon::end_data_table_row();
+ }
+ $output .= &Apache::loncommon::end_data_table();
+ }
+ return $output;
+}
+
sub courserequest_titles {
my %titles = &Apache::lonlocal::texthash (
official => 'Official',
unofficial => 'Unofficial',
community => 'Communities',
textbook => 'Textbook',
+ placement => 'Placement Tests',
norequest => 'Not allowed',
approval => 'Approval by Dom. Coord.',
validate => 'With validation',
@@ -813,7 +884,7 @@ sub entry_form {
}
my $cancreate =
&Apache::lonuserutils::can_create_user($dom,$context,$usertype);
- my $userpicker =
+ my ($userpicker,$cansearch) =
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser,
'document.crtuser',$cancreate,$usertype);
my $srchbutton = &mt('Search');
@@ -822,7 +893,9 @@ sub entry_form {
} elsif ($cancreate && $responsemsg ne '' && $inexact) {
$srchbutton = &mt('Search or Add New User');
}
- my $output = <<"ENDBLOCK";
+ my $output;
+ if ($cansearch) {
+ $output = <<"ENDBLOCK";
ENDBLOCK
+ } else {
+ $output = '
'.$userpicker.'
';
+ }
if ($env{'form.phase'} eq '') {
my $defdom=$env{'request.role.domain'};
my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
@@ -1231,7 +1307,7 @@ ENDFORMINFO
}
my $title = '';
if ($newuser) {
- my ($portfolioform,$domroleform);
+ my ($portfolioform,$domroleform,$adhocroleform);
if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) ||
(&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) {
# Current user has quota or user tools modification privileges
@@ -1241,6 +1317,12 @@ ENDFORMINFO
($ccdomain eq $env{'request.role.domain'})) {
$domroleform = ' '.&domainrole_req($ccuname,$ccdomain);
}
+ if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
+ $adhocroleform = &domadhocroles($ccuname,$ccdomain);
+ if ($adhocroleform) {
+ $adhocroleform = ' '.$adhocroleform;
+ }
+ }
&initialize_authen_forms($ccdomain,$formname);
my %lt=&Apache::lonlocal::texthash(
'lg' => 'Login Data',
@@ -1351,7 +1433,7 @@ ENDAUTH
} else {
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
}
- $r->print($portfolioform.$domroleform);
+ $r->print($portfolioform.$domroleform.$adhocroleform);
if ($env{'form.action'} eq 'singlestudent') {
$r->print(&date_sections_select($context,$newuser,$formname,
$permission,$crstype,$ccuname,
@@ -1388,7 +1470,7 @@ ENDAUTH
$r->print(&Apache::loncommon::end_data_table());
}
$r->print('');
- my @order = ('auth','quota','tools','requestauthor');
+ my @order = ('auth','quota','tools','requestauthor','adhocroles');
my %user_text;
my ($isadv,$isauthor) =
&Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
@@ -1397,6 +1479,9 @@ ENDAUTH
&& ($env{'request.role.domain'} eq $ccdomain)) {
$user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);
}
+ if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
+ $user_text{'adhocroles'} = &domadhocroles($ccuname,$ccdomain);
+ }
$user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname);
if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
(&Apache::lonnet::allowed('mut',$ccdomain))) {
@@ -2351,7 +2436,7 @@ sub personal_data_display {
}
if (($context eq 'selfcreate') && ($newuser eq 'email')) {
if ($captchaform) {
- $output .= &Apache::lonhtmlcommon::row_title($lt{'valid'},
+ $output .= &Apache::lonhtmlcommon::row_title($lt{'valid'}.'*',
'LC_pick_box_title')."\n".
$captchaform."\n".'
'.
&Apache::lonhtmlcommon::row_closure(1);
@@ -2579,7 +2664,7 @@ sub update_user_data {
my (%alerts,%rulematch,%inst_results,%curr_rules);
my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
my @usertools = ('aboutme','blog','webdav','portfolio');
- my @requestcourses = ('official','unofficial','community','textbook');
+ my @requestcourses = ('official','unofficial','community','textbook','placement');
my @requestauthor = ('requestauthor');
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
@@ -2689,6 +2774,12 @@ sub update_user_data {
$newcustom{'requestauthor'},
\%changeHash,'requestauthor');
}
+ if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
+ my @adds = &Apache::loncommon::get_env_multiple('form.adhocroleadd');
+ if (&adhocrole_changes(\%changeHash)) {
+ $changed{'adhocroles.'.$env{'request.role.domain'}} = $changeHash{'adhocroles.'.$env{'request.role.domain'}};
+ }
+ }
}
if ($canmodify_status{'inststatus'}) {
if (exists($env{'form.inststatus'})) {
@@ -2752,7 +2843,8 @@ sub update_user_data {
'requestcourses.community','requestcourses.textbook',
'reqcrsotherdom.official','reqcrsotherdom.unofficial',
'reqcrsotherdom.community','reqcrsotherdom.textbook',
- 'requestauthor'],
+ 'reqcrsotherdom.placement','requestauthor',
+ 'adhocroles.'.$env{'request.role.domain'}],
$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
@@ -2891,6 +2983,7 @@ sub update_user_data {
&Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus,$name);
($newdefquota{$name},$newsettingstatus{$name}) = ($olddefquota{$name},$oldsettingstatus{$name});
}
+ push(@disporder,'adhocroles');
my %canshow;
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
$canshow{'quota'} = 1;
@@ -2909,6 +3002,9 @@ sub update_user_data {
if (&Apache::lonnet::allowed('cau',$env{'form.ccdomain'})) {
$canshow{'requestauthor'} = 1;
}
+ if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
+ $canshow{'adhocroles'} = 1;
+ }
my (%changeHash,%changed);
if ($oldinststatus eq '') {
$oldsettings{'inststatus'} = $othertitle;
@@ -3022,6 +3118,14 @@ sub update_user_data {
&tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,
\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
}
+ if ($userenv{'adhocroles.'.$env{'request.role.domain'}}) {
+ $changeHash{'adhocroles.'.$env{'request.role.domain'}} = $userenv{'adhocroles.'.$env{'request.role.domain'}};
+ }
+ if (&adhocrole_changes(\%changeHash,\%userenv)) {
+ $changed{'adhocroles'} = 1;
+ $oldsettings{'adhocroles'} = $userenv{'adhocroles.'.$env{'request.role.domain'}};
+ $newsettings{'adhocroles'} = $changeHash{'adhocroles.'.$env{'request.role.domain'}};
+ }
}
foreach my $item (@userinfo) {
if ($env{'form.c'.$item} ne $userenv{$item}) {
@@ -3043,8 +3147,9 @@ sub update_user_data {
($env{'user.domain'} eq $env{'form.ccdomain'})) {
my %newenvhash;
foreach my $key (keys(%changed)) {
- if (($key eq 'official') || ($key eq 'unofficial')
- || ($key eq 'community') || ($key eq 'textbook')) {
+ if (($key eq 'official') || ($key eq 'unofficial') ||
+ ($key eq 'community') || ($key eq 'textbook') ||
+ ($key eq 'placement')) {
$newenvhash{'environment.requestcourses.'.$key} =
$changeHash{'requestcourses.'.$key};
if ($changeHash{'requestcourses.'.$key}) {
@@ -3063,6 +3168,9 @@ sub update_user_data {
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
$key,'reload','requestauthor');
}
+ } elsif ($key eq 'adhocroles') {
+ $newenvhash{'adhocroles.'.$env{'request.role.domain'}} =
+ $changeHash{'adhocroles.'.$env{'request.role.domain'}};
} elsif ($key ne 'quota') {
$newenvhash{'environment.tools.'.$key} =
$changeHash{'tools.'.$key};
@@ -3253,7 +3361,9 @@ sub display_userinfo {
'unofficial' => 'Can Request Unofficial Courses',
'community' => 'Can Request Communities',
'textbook' => 'Can Request Textbook Courses',
+ 'placement' => 'Can Request Placement Tests',
'requestauthor' => 'Can Request Author Role',
+ 'adhocroles' => 'Ad Hoc Roles Selectable via Helpdesk Role',
'inststatus' => "Affiliation",
'prvs' => 'Previous Value:',
'chto' => 'Changed To:'
@@ -3619,6 +3729,70 @@ sub tool_changes {
return;
}
+sub adhocrole_changes {
+ my ($changehashref,$userenv) = @_;
+ my @adds = &Apache::loncommon::get_env_multiple('form.adhocroleadd');
+ my @dels = &Apache::loncommon::get_env_multiple('form.adhocroledel');
+ my (@saved,@added,@alladhoc,$changed);
+ my $adhoc_key = 'adhocroles.'.$env{'request.role.domain'};
+ if (!$env{'form.makeuser'}) {
+ if (ref($userenv) eq 'HASH') {
+ my @current;
+ if ($userenv->{$adhoc_key}) {
+ @current = split(/,/,$userenv->{$adhoc_key});
+ if (@dels) {
+ foreach my $curr (@current) {
+ next if ($curr eq '');
+ unless (grep(/\Q$curr\E$/,@dels)) {
+ push(@saved,$curr);
+ }
+ }
+ $changed = 1;
+ } else {
+ @saved = @current;
+ }
+ }
+ }
+ }
+ if (@adds) {
+ my $confname = &Apache::lonnet::get_domainconfiguser($env{'request.role.domain'});
+ my %existing=&Apache::lonnet::dump('roles',$env{'request.role.domain'},
+ $confname,'rolesdef_');
+ foreach my $poss (@adds) {
+ if (exists($existing{'rolesdef_'.$poss})) {
+ push(@added,$poss);
+ $changed = 1;
+ }
+ }
+ }
+ if (@added) {
+ if (@saved) {
+ foreach my $add (@added) {
+ unless (grep(/^\Q$add\E$/,@saved)) {
+ push(@alladhoc,$add);
+ }
+ }
+ } else {
+ push(@alladhoc,@added);
+ }
+ }
+ if (@saved) {
+ push(@alladhoc,@saved);
+ }
+ if (@alladhoc) {
+ my $adhocstr = join(',',sort(@alladhoc));
+ $changehashref->{$adhoc_key} = $adhocstr;
+ } elsif (@dels) {
+ &Apache::lonnet::del('environment',[$adhoc_key],$env{'form.ccdomain'},$env{'form.ccuname'});
+ delete($changehashref->{$adhoc_key});
+ if (($env{'form.ccdomain'} eq $env{'user.domain'}) &&
+ ($env{'form.ccuname'} eq $env{'user.name'})) {
+ &Apache::lonnet::delenv($adhoc_key);
+ }
+ }
+ return $changed;
+}
+
sub update_roles {
my ($r,$context,$showcredits) = @_;
my $now=time;
@@ -4149,7 +4323,7 @@ sub build_roles {
# ========================================================== Custom Role Editor
sub custom_role_editor {
- my ($r,$brcrum) = @_;
+ my ($r,$brcrum,$prefix) = @_;
my $action = $env{'form.customroleaction'};
my $rolename;
if ($action eq 'new') {
@@ -4164,7 +4338,7 @@ sub custom_role_editor {
$context = 'course';
} else {
$context = 'domain';
- $crstype = $env{'form.templatecrstype'};
+ $crstype = 'course';
}
$rolename=~s/[^A-Za-z0-9]//gs;
@@ -4173,120 +4347,54 @@ sub custom_role_editor {
return;
}
-# ------------------------------------------------------- What can be assigned?
- my %full=();
- my %courselevel=();
- my %courselevelcurrent=();
- my $syspriv='';
- my $dompriv='';
- my $coursepriv='';
- my $body_top;
- my $newrole;
+ my $formname = 'form1';
+ my %privs=();
+ my $body_top = '
';
+# ------------------------------------------------------- Does this role exist?
my ($rdummy,$roledef)=
&Apache::lonnet::get('roles',["rolesdef_$rolename"]);
-# ------------------------------------------------------- Does this role exist?
- $body_top .= '
';
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
- my ($priv,$restrict)=split(/\&/,$item);
- if (!$restrict) { $restrict='F'; }
- $courselevel{$priv}=$restrict;
- if ($coursepriv=~/\:$priv/) {
- $courselevelcurrent{$priv}=1;
- }
- $full{$priv}=1;
- }
- my %domainlevel=();
- my %domainlevelcurrent=();
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
- my ($priv,$restrict)=split(/\&/,$item);
- if (!$restrict) { $restrict='F'; }
- $domainlevel{$priv}=$restrict;
- if ($dompriv=~/\:$priv/) {
- $domainlevelcurrent{$priv}=1;
- }
- $full{$priv}=1;
- }
- my %systemlevel=();
- my %systemlevelcurrent=();
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
- my ($priv,$restrict)=split(/\&/,$item);
- if (!$restrict) { $restrict='F'; }
- $systemlevel{$priv}=$restrict;
- if ($syspriv=~/\:$priv/) {
- $systemlevelcurrent{$priv}=1;
- }
- $full{$priv}=1;
- }
+
+# ------------------------------------------------------- What can be assigned?
+ my %full=();
+ my %levels=(
+ course => {},
+ domain => {},
+ system => {},
+ );
+ my %levelscurrent=(
+ course => {},
+ domain => {},
+ system => {},
+ );
+ &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent);
my ($jsback,$elements) = &crumb_utilities();
- my $button_code = "\n";
- my $head_script = "\n";
- $head_script .= ''."\n";
+ my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
+ my $head_script =
+ &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,
+ \%full,\@templateroles,$jsback);
push (@{$brcrum},
- {href => "javascript:backPage(document.form1,'pickrole','')",
+ {href => "javascript:backPage(document.$formname,'pickrole','')",
text => "Pick custom role",
faq => 282,bug=>'Instructor Interface',},
- {href => "javascript:backPage(document.form1,'','')",
+ {href => "javascript:backPage(document.$formname,'','')",
text => "Edit custom role",
faq => 282,
bug => 'Instructor Interface',
@@ -4298,57 +4406,16 @@ sub custom_role_editor {
$r->print(&Apache::loncommon::start_page('Custom Role Editor',
$head_script,$args).
$body_top);
- my %lt=&Apache::lonlocal::texthash(
- 'prv' => "Privilege",
- 'crl' => "Course Level",
- 'dml' => "Domain Level",
- 'ssl' => "System Level");
-
- $r->print('
'
- .'
');
- if ($context_code) {
- $r->print('
'
- .''
- .'
'
- );
- }
- $r->print(' ');
+ $r->print('
');
}
-# --------------------------------------------------------
-sub make_script_template {
- my ($role,$crstype) = @_;
- my %full_c=();
- my %full_d=();
- my %full_s=();
- my $return_script;
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
- my ($priv,$restrict)=split(/\&/,$item);
- $full_c{$priv}=1;
- }
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
- my ($priv,$restrict)=split(/\&/,$item);
- $full_d{$priv}=1;
- }
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
- next if (($crstype eq 'Community') && ($item eq 'bre&S'));
- my ($priv,$restrict)=split(/\&/,$item);
- $full_s{$priv}=1;
- }
- $return_script .= 'function set_'.$role.'() {'."\n";
- my @temp = split(/:/,$Apache::lonnet::pr{$role.':c'});
- my %role_c;
- foreach my $priv (@temp) {
- my ($priv_item, $dummy) = split(/\&/,$priv);
- $role_c{$priv_item} = 1;
- }
- my %role_d;
- @temp = split(/:/,$Apache::lonnet::pr{$role.':d'});
- foreach my $priv(@temp) {
- my ($priv_item, $dummy) = split(/\&/,$priv);
- $role_d{$priv_item} = 1;
- }
- my %role_s;
- @temp = split(/:/,$Apache::lonnet::pr{$role.':s'});
- foreach my $priv(@temp) {
- my ($priv_item, $dummy) = split(/\&/,$priv);
- $role_s{$priv_item} = 1;
- }
- foreach my $priv_item (keys(%full_c)) {
- my ($priv, $dummy) = split(/\&/,$priv_item);
- if ((exists($role_c{$priv})) || (exists($role_d{$priv})) ||
- (exists($role_s{$priv}))) {
- $return_script .= "document.form1.$priv"."_c.checked = true;\n";
- } else {
- $return_script .= "document.form1.$priv"."_c.checked = false;\n";
- }
- }
- foreach my $priv_item (keys(%full_d)) {
- my ($priv, $dummy) = split(/\&/,$priv_item);
- if ((exists($role_d{$priv})) || (exists($role_s{$priv}))) {
- $return_script .= "document.form1.$priv"."_d.checked = true;\n";
- } else {
- $return_script .= "document.form1.$priv"."_d.checked = false;\n";
- }
- }
- foreach my $priv_item (keys(%full_s)) {
- my ($priv, $dummy) = split(/\&/,$priv_item);
- if (exists($role_s{$priv})) {
- $return_script .= "document.form1.$priv"."_s.checked = true;\n";
- } else {
- $return_script .= "document.form1.$priv"."_s.checked = false;\n";
- }
- }
- $return_script .= '}'."\n";
- return ($return_script);
-}
-# ----------------------------------------------------------
-sub make_button_code {
- my ($role,$crstype) = @_;
- my $label = &Apache::lonnet::plaintext($role,$crstype);
- my $button_code = '';
- return ($button_code);
-}
+
# ---------------------------------------------------------- Call to definerole
sub set_custom_role {
- my ($r,$context,$brcrum) = @_;
+ my ($r,$context,$brcrum,$prefix) = @_;
my $rolename=$env{'form.rolename'};
$rolename=~s/[^A-Za-z0-9]//gs;
if (!$rolename) {
- &custom_role_editor($r,$brcrum);
+ &custom_role_editor($r,$brcrum,$prefix);
return;
}
my ($jsback,$elements) = &crumb_utilities();
@@ -4461,7 +4455,7 @@ sub set_custom_role {
help => 'Course_Editing_Custom_Roles'},
);
my $args = { bread_crumbs => $brcrum,
- bread_crumbs_component => 'User Management'};
+ bread_crumbs_component => 'User Management'};
$r->print(&Apache::loncommon::start_page('Save Custom Role',$jscript,$args));
my $newrole;
@@ -4478,38 +4472,13 @@ sub set_custom_role {
$newrole = 1;
}
$r->print($rolename.'"');
-# ------------------------------------------------------- What can be assigned?
- my $sysrole='';
- my $domrole='';
- my $courole='';
-
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
- my ($priv,$restrict)=split(/\&/,$item);
- if (!$restrict) { $restrict=''; }
- if ($env{'form.'.$priv.'_c'}) {
- $courole.=':'.$item;
- }
- }
-
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
- my ($priv,$restrict)=split(/\&/,$item);
- if (!$restrict) { $restrict=''; }
- if ($env{'form.'.$priv.'_d'}) {
- $domrole.=':'.$item;
- }
- }
+# ------------------------------------------------- Assign role and show result
- foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
- my ($priv,$restrict)=split(/\&/,$item);
- if (!$restrict) { $restrict=''; }
- if ($env{'form.'.$priv.'_s'}) {
- $sysrole.=':'.$item;
- }
- }
- # Assign role; Compile and show result
my $errmsg;
- my $result =
- &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole);
+ my %newprivs = &Apache::lonuserutils::custom_role_update($rolename,$prefix);
+ # Assign role and return result
+ my $result = &Apache::lonnet::definerole($rolename,$newprivs{'s'},$newprivs{'d'},
+ $newprivs{'c'});
if ($result ne 'ok') {
$errmsg = ': '.$result;
}
@@ -4716,10 +4685,11 @@ sub handler {
$brcrum);
}
} elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) {
+ my $prefix;
if ($env{'form.phase'} eq 'set_custom_roles') {
- &set_custom_role($r,$context,$brcrum);
+ &set_custom_role($r,$context,$brcrum,$prefix);
} else {
- &custom_role_editor($r,$brcrum);
+ &custom_role_editor($r,$brcrum,$prefix);
}
} elsif (($env{'form.action'} eq 'processauthorreq') &&
($permission->{'cusr'}) &&
@@ -5400,6 +5370,7 @@ sub print_main_menu {
groups => 'Community Groups',
},
);
+ $linktext{'Placement'} = $linktext{'Course'};
my %linktitle = (
'Course' => {
@@ -5414,6 +5385,8 @@ sub print_main_menu {
},
);
+ $linktitle{'Placement'} = $linktitle{'Course'};
+
push(@{ $menu[0]->{items} }, #Category: Single Users
{
linktext => $linktext{$crstype}{'single'},
@@ -6823,13 +6796,29 @@ sub user_search_result {
}
}
if ($response ne '') {
- $response = ''.$response.'';
+ $response = ''.$response.' ';
}
if ($srch->{'srchin'} eq 'instd') {
- my $instd_chk = &directorysrch_check($srch);
+ my $instd_chk = &instdirectorysrch_check($srch);
if ($instd_chk ne 'ok') {
- $response = ''.$instd_chk.''.
- ' '.&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').'
';
+ my $domd_chk = &domdirectorysrch_check($srch);
+ $response .= ''.$instd_chk.' ';
+ if ($domd_chk eq 'ok') {
+ $response .= &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.');
+ }
+ $response .= '
';
+ }
+ } else {
+ unless (($context eq 'requestcrs') && ($srch->{'srchtype'} eq 'exact')) {
+ my $domd_chk = &domdirectorysrch_check($srch);
+ if ($domd_chk ne 'ok') {
+ my $instd_chk = &instdirectorysrch_check($srch);
+ $response .= ''.$domd_chk.' ';
+ if ($instd_chk eq 'ok') {
+ $response .= &mt('You may want to search in the institutional directory instead of the LON-CAPA domain.');
+ }
+ $response .= '
';
+ }
}
}
if ($response ne '') {
@@ -6993,7 +6982,8 @@ sub user_search_result {
($currstate,$response,$forcenewuser) =
&build_search_response($context,$srch,%srch_results);
} else {
- my $showdom = &display_domain_info($srch->{'srchdomain'}); $response = ''.
+ my $showdom = &display_domain_info($srch->{'srchdomain'});
+ $response = ''.
&mt('Institutional directory search is not available in domain: [_1]',$showdom).
' '.
&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
@@ -7004,7 +6994,26 @@ sub user_search_result {
return ($currstate,$response,$forcenewuser,\%srch_results);
}
-sub directorysrch_check {
+sub domdirectorysrch_check {
+ my ($srch) = @_;
+ 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'}{'lcavailable'} eq '0') {
+ return &mt('LON-CAPA directory search is not available in domain: [_1]',$showdom);
+ }
+ if ($dom_inst_srch{'directorysrch'}{'lclocalonly'}) {
+ if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) {
+ return &mt('LON-CAPA directory search in domain: [_1] is only allowed for users with a current role in the domain.',$showdom);
+ }
+ }
+ }
+ return 'ok';
+}
+
+sub instdirectorysrch_check {
my ($srch) = @_;
my $can_search = 0;
my $response;