Merge commit 'origin/fusionax' into account
[platal.git] / modules / search.php
index 06f1f8a..c76c1b5 100644 (file)
@@ -74,7 +74,7 @@ class SearchModule extends PLModule
         global $globals;
 
         $res = XDB::query("SELECT  MIN(diminutif), MAX(diminutif)
-                             FROM  groupex.asso
+                             FROM  #groupex#.asso
                             WHERE  cat = 'Promotions'");
         list($min, $max) = $res->fetchOneRow();
         $page->assign('promo_min', $min);
@@ -86,7 +86,7 @@ class SearchModule extends PLModule
                 S::logger()->log('search', 'quick=' . $quick);
             }
             $list = 'profile|prf|fiche|fic|referent|ref|mentor';
-            if (S::has_perms()) {
+            if (S::admin()) {
                 $list .= '|admin|adm|ax';
             }
             if (preg_match('/^(' . $list . '):([-a-z]+(\.[-a-z]+(\.\d{2,4})?)?)$/', replace_accent($quick), $matches)) {
@@ -155,7 +155,7 @@ class SearchModule extends PLModule
     function handler_advanced(&$page, $action = null, $subaction = null)
     {
         global $globals;
-        require_once 'geoloc.inc.php';
+        require_once 'geocoding.inc.php';
         $this->load('search.inc.php');
         $page->assign('advanced',1);
         $page->addJsLink('jquery.autocomplete.js');
@@ -173,7 +173,7 @@ class SearchModule extends PLModule
                 'binet'           => array('field' => 'id', 'table' => 'binets_def', 'text' => 'text', 'exact' => false),
                 'networking_type' => array('field' => 'network_type', 'table' => 'profile_networking_enum',
                                            'text' => 'name', 'exact' => false),
-                'groupex'         => array('field' => 'id', 'table' => 'groupex.asso',
+                'groupex'         => array('field' => 'id', 'table' => '#groupex#.asso',
                                            'text' => "(cat = 'GroupesX' OR cat = 'Institutions') AND pub = 'public' AND nom",
                                            'exact' => false),
                 'section'         => array('field' => 'id', 'table' => 'sections', 'text' => 'text', 'exact' => false),
@@ -224,7 +224,7 @@ class SearchModule extends PLModule
         //   result1|nb1
         //   result2|nb2
         //   ...
-        header('Content-Type: text/plain; charset="UTF-8"');
+        pl_content_headers("text/plain");
         $q = preg_replace(array('/\*+$/', // always look for $q*
                                 '/([\^\$\[\]])/', // escape special regexp char
                                 '/\*/'), // replace joker by regexp joker
@@ -299,8 +299,8 @@ class SearchModule extends PLModule
             $beginwith = false;
             break;
           case 'groupexTxt':
-            $db = "groupex.asso AS a INNER JOIN
-                   groupex.membres AS m ON(a.id = m.asso_id
+            $db = "#groupex#.asso AS a INNER JOIN
+                   #groupex#.membres AS m ON(a.id = m.asso_id
                                            AND (a.cat = 'GroupesX' OR a.cat = 'Institutions')
                                            AND a.pub = 'public')";
             $field='a.nom';
@@ -433,12 +433,12 @@ class SearchModule extends PLModule
             $field = 'fonction_fr';
             break;
           case 'diploma':
-            header('Content-Type: text/xml; charset="UTF-8"');
+            pl_content_headers("text/xml");
             $this->get_diplomas();
             $page->changeTpl('search/adv.grade.form.tpl', NO_SKIN);
             return;
           case 'groupex':
-            $db = 'groupex.asso';
+            $db = '#groupex#.asso';
             $where = " WHERE (cat = 'GroupesX' OR cat = 'Institutions') AND pub = 'public'";
             $field = 'nom';
             break;
@@ -474,12 +474,12 @@ class SearchModule extends PLModule
           default: exit();
         }
         if (isset($idVal)) {
-            header('Content-Type: text/plain; charset="UTF-8"');
+            pl_content_headers("text/plain");
             $result = XDB::query('SELECT '.$field.' AS field FROM '.$db.' WHERE '.$id.' = {?} LIMIT 1',$idVal);
             echo $result->fetchOneCell();
             exit();
         }
-        header('Content-Type: text/xml; charset="UTF-8"');
+        pl_content_headers("text/xml");
         $page->changeTpl('include/field.select.tpl', NO_SKIN);
         $page->assign('name', $type);
         $page->assign('list', XDB::iterator('SELECT  '.$field.' AS field,