[LON-CAPA-cvs] cvs: loncom(version_2_1_X) / lonsql

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 27 Mar 2006 19:51:43 -0000


albertel		Mon Mar 27 14:51:43 2006 EDT

  Modified files:              (Branch: version_2_1_X)
    /loncom	lonsql 
  Log:
  - backport 1.73,74
  
  
Index: loncom/lonsql
diff -u loncom/lonsql:1.71.2.1 loncom/lonsql:1.71.2.2
--- loncom/lonsql:1.71.2.1	Fri Feb 10 04:50:50 2006
+++ loncom/lonsql	Mon Mar 27 14:51:42 2006
@@ -3,7 +3,7 @@
 # The LearningOnline Network
 # lonsql - LON TCP-MySQL-Server Daemon for handling database requests.
 #
-# $Id: lonsql,v 1.71.2.1 2006/02/10 09:50:50 albertel Exp $
+# $Id: lonsql,v 1.71.2.2 2006/03/27 19:51:42 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -386,6 +386,8 @@
 	    $run = $run+1;
 	    my $userinput = <$client>;
 	    chomp($userinput);
+            $userinput=~s/\:(\w+)$//;
+            my $searchdomain=$1;
             #
 	    my ($conserver,$query,
 		$arg1,$arg2,$arg3)=split(/&/,$userinput);
@@ -468,7 +470,7 @@
                 }
             } else {
                 # Do an sql query
-                $result = &do_sql_query($query,$arg1,$arg2);
+                $result = &do_sql_query($query,$arg1,$arg2,$searchdomain);
             }
             # result does not need to be escaped because it has already been
             # escaped.
@@ -519,8 +521,18 @@
 }
 
 sub do_sql_query {
-    my ($query,$custom,$customshow) = @_;
-#    &logthis('doing query '.$query);
+    my ($query,$custom,$customshow,$searchdomain) = @_;
+
+#
+# limit to searchdomain if given and table is metadata
+#
+    if (($searchdomain) && ($query=~/FROM metadata/)) {
+	$query.=' HAVING (domain="'.$searchdomain.'")';
+    }
+#    &logthis('doing query ('.$searchdomain.')'.$query);
+
+
+
     $custom     = &unescape($custom);
     $customshow = &unescape($customshow);
     #