Searching mentors in advanced search works back. (Closes #741)
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 9 Dec 2007 17:33:27 +0000 (18:33 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 9 Dec 2007 17:35:18 +0000 (18:35 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
ChangeLog
include/userset.inc.php
modules/search/classes.inc.php
modules/search/search.inc.php

index 3be860f..1cbb959 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,9 @@ Bug/Wish:
         - #729: Fix positioning of addresses on public profile             -FRU
         - #742: Sub domain was hidden when editing profile                 -FRU
 
+    * Search:
+        - #741: Mentor search in advanced search                           -FRU
+
     * XnetGrp:
         - #732: Adapt subscription text to sex                             -FRU
         - #735: Encoding of list description in member edition form        -FRU
index a0f72b1..70c965e 100644 (file)
@@ -110,7 +110,7 @@ class SearchSet extends UserSet
                                                       'u.promo DESC, NomSortKey, prenom')));
     }
 
-    private function getAdvanced()
+    private function getAdvanced($join, $where)
     {
         global $globals;
         $this->advanced = true;
index 8a27101..11202bb 100644 (file)
@@ -755,6 +755,11 @@ class SFieldGroup
     {
         $this->fields = $_fields;
         $this->and    = $_and;
+        foreach ($this->fields as $key=>&$field) {
+            if (is_null($field)) {
+                unset($this->fields[$key]);
+            }
+        }
     }
 
     // }}}
@@ -764,7 +769,9 @@ class SFieldGroup
     {
         $b = true;
         for ($i=0 ; $b && $i<count($this->fields) ; $i++) {
-            $b = $b && $this->fields[$i]->too_large();
+            if (!is_null($this->fields[$i])) {
+                $b = $b && $this->fields[$i]->too_large();
+            }
         }
         return $b;
     }
index f4de2ab..331a1a7 100644 (file)
@@ -41,6 +41,11 @@ function advancedSearchFromInput()
     $womanField      = new RefSField('woman',array('FIND_IN_SET(\'femme\',u.flags)+1'),'','','');
     $subscriberField = new RefSField('subscriber',array('!(u.perms IN (\'admin\',\'user\'))+1'),'','','');
     $aliveField      = new RefSField('alive',array('(u.deces!=0)+1'),'','','');
+    if (Env::v('only_referent') == 'on') {
+        $referentField = new RefSField('only_referent', array('"on"'), 'mentor', 'mt', 'mt.expertise != "" AND mt.uid=u.user_id');
+    } else {
+        $referentField = null;
+    }
 
     if (!Env::i('cityid')) {
         $townField      = new RefSField('city',array('ac.city'),'adresses','ac',getadr_join('ac'),false);
@@ -70,7 +75,7 @@ function advancedSearchFromInput()
 
     return array(
                 $nameField, $firstnameField, $nicknameField, $promo1Field,
-                $promo2Field, $womanField, $subscriberField, $aliveField,
+                $promo2Field, $womanField, $subscriberField, $aliveField, $referentField,
                 $townField, $countryField, $regionField, $mapField, $entrepriseField,
                 $posteField, $secteurField, $cvField, $natField, $binetField,
                 $groupexField, $sectionField, $schoolField, $diplomaField,