[LON-CAPA-cvs] cvs: loncom / lond /interface domainprefs.pm
raeburn
raeburn at source.lon-capa.org
Sun Mar 19 23:19:44 EDT 2017
raeburn Mon Mar 20 03:19:44 2017 EDT
Modified files:
/loncom lond
/loncom/interface domainprefs.pm
Log:
- If LON-CAPA Directory searches are disabled for other domains, enforce
that on the lond side, in case user session is hosted on a 2.11.1 (or earlier)
- Expire 60 minutes caches of 'usersessions' and 'directorysrch' settings
(used by lond) on domain's servers when domain configuration changes.
Index: loncom/lond
diff -u loncom/lond:1.533 loncom/lond:1.534
--- loncom/lond:1.533 Mon Mar 13 18:30:02 2017
+++ loncom/lond Mon Mar 20 03:19:37 2017
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.533 2017/03/13 18:30:02 raeburn Exp $
+# $Id: lond,v 1.534 2017/03/20 03:19:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -65,7 +65,7 @@
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.533 $'; #' stupid emacs
+my $VERSION='$Revision: 1.534 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -3973,6 +3973,37 @@
my ($query,$arg1,$arg2,$arg3)=split(/\:/,$tail);
$query=~s/\n*$//g;
+ if (($query eq 'usersearch') || ($query eq 'instdirsearch')) {
+ my $usersearchconf = &get_usersearch_config($currentdomainid,'directorysrch');
+ my $earlyout;
+ if (ref($usersearchconf) eq 'HASH') {
+ if ($currentdomainid eq $clienthomedom) {
+ if ($query eq 'usersearch') {
+ if ($usersearchconf->{'lcavailable'} eq '0') {
+ $earlyout = 1;
+ }
+ } else {
+ if ($usersearchconf->{'available'} eq '0') {
+ $earlyout = 1;
+ }
+ }
+ } else {
+ if ($query eq 'usersearch') {
+ if ($usersearchconf->{'lclocalonly'}) {
+ $earlyout = 1;
+ }
+ } else {
+ if ($usersearchconf->{'localonly'}) {
+ $earlyout = 1;
+ }
+ }
+ }
+ }
+ if ($earlyout) {
+ &Reply($client, "query_not_authorized\n");
+ return 1;
+ }
+ }
&Reply($client, "". &sql_reply("$clientname\&$query".
"\&$arg1"."\&$arg2"."\&$arg3")."\n",
$userinput);
@@ -8267,6 +8298,19 @@
return;
}
+sub get_usersearch_config {
+ my ($dom,$name) = @_;
+ my ($usersearchconf,$cached)=&Apache::lonnet::is_cached_new($name,$dom);
+ if (defined($cached)) {
+ return $usersearchconf;
+ } else {
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['directorysrch'],$dom);
+ &Apache::lonnet::do_cache_new($name,$dom,$domconfig{'directorysrch'},600);
+ return $domconfig{'directorysrch'};
+ }
+ return;
+}
+
sub get_prohibited {
my ($dom) = @_;
my $name = 'trust';
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.294 loncom/interface/domainprefs.pm:1.295
--- loncom/interface/domainprefs.pm:1.294 Mon Mar 13 18:30:07 2017
+++ loncom/interface/domainprefs.pm Mon Mar 20 03:19:43 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.294 2017/03/13 18:30:07 raeburn Exp $
+# $Id: domainprefs.pm,v 1.295 2017/03/20 03:19:43 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -677,7 +677,7 @@
} elsif ($action eq 'autocreate') {
$output = &modify_autocreate($dom,%domconfig);
} elsif ($action eq 'directorysrch') {
- $output = &modify_directorysrch($dom,%domconfig);
+ $output = &modify_directorysrch($dom,$lastactref,%domconfig);
} elsif ($action eq 'usercreation') {
$output = &modify_usercreation($dom,%domconfig);
} elsif ($action eq 'selfcreation') {
@@ -4261,7 +4261,7 @@
foreach my $type (@types) {
$datatable .= '<td align="center">'.&mt($type).'<br />'.
'<input type="text" name="mysqltables_'.$type.'"'.
- ' value="'.$currmysql{$type}.'" size="5" /></td>';
+ ' value="'.$currmysql{$type}.'" size="8" /></td>';
}
$datatable .= '</tr></table></td></tr>'."\n";
$itemcount ++;
@@ -10333,7 +10333,7 @@
}
sub modify_directorysrch {
- my ($dom,%domconfig) = @_;
+ my ($dom,$lastactref,%domconfig) = @_;
my ($resulttext,%changes);
my %currdirsrch;
if (ref($domconfig{'directorysrch'}) eq 'HASH') {
@@ -10527,6 +10527,10 @@
$resulttext .= '<li>'.&mt($title{'searchtypes'}.' set to: "[_1]"',$chgtext).'</li>';
}
$resulttext .= '</ul>';
+ &Apache::lonnet::do_cache_new('directorysrch',$dom,$dirsrch_hash{'directorysrch'},3600);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'directorysrch'} = 1;
+ }
} else {
$resulttext = &mt('No changes made to directory search settings');
}
@@ -13806,8 +13810,10 @@
}
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ &Apache::lonnet::do_cache_new('usersessions',$dom,$defaultshash{'usersessions'},3600);
if (ref($lastactref) eq 'HASH') {
$lastactref->{'domdefaults'} = 1;
+ $lastactref->{'usersessions'} = 1;
}
if (keys(%changes) > 0) {
my %lt = &usersession_titles();
@@ -15183,7 +15189,7 @@
my %servers = &Apache::lonnet::internet_dom_servers($dom);
my %thismachine;
map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
- my @posscached = ('domainconfig','domdefaults','ltitools');
+ my @posscached = ('domainconfig','domdefaults','ltitools','usersessions','directorysrch');
if (keys(%servers)) {
foreach my $server (keys(%servers)) {
next if ($thismachine{$server});
More information about the LON-CAPA-cvs
mailing list