X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fsearch%2Fclasses.inc.php;h=d232f11cb2d69744460e9c10b8e400b1e3d7bb20;hb=fb813fb52d5ab65ca9a5b92b5cb9089523380d79;hp=3d9088782a6a6e987b30d5e3de866223c42979d3;hpb=aef0283bdf24c94d640a16ccac08191980ae7a25;p=platal.git diff --git a/modules/search/classes.inc.php b/modules/search/classes.inc.php index 3d90887..d232f11 100644 --- a/modules/search/classes.inc.php +++ b/modules/search/classes.inc.php @@ -1,6 +1,6 @@ value)); $r = $s = str_replace('*','%',$s); - if (S::has_perms() && strpos($s, '@') !== false) { + if (S::admin() && strpos($s, '@') !== false) { $this->email = $s; - } else if (S::has_perms() && preg_match('/[0-9]+\.([0-9]+|%)\.([0-9]+|%)\.([0-9]+|%)/', $s)) { + } else if (S::admin() && preg_match('/[0-9]+\.([0-9]+|%)\.([0-9]+|%)\.([0-9]+|%)/', $s)) { $this->ip = $s; } if ($this->email || $this->ip) { @@ -379,7 +379,7 @@ class QuickSearch extends SField $join .= "LEFT JOIN emails AS ems ON (ems.uid = u.user_id)"; } if (!empty($this->ip)) { - $join .= "INNER JOIN logger.sessions AS ls ON (ls.uid = u.user_id)\n"; + $join .= "INNER JOIN log_sessions AS ls ON (ls.uid = u.user_id)\n"; } if (!empty($this->phone)) { if (!S::logged()) { @@ -489,7 +489,7 @@ class RefSField extends SField function too_large() { - return ($this->value==''); + return ($this->value == ''); } // }}} @@ -650,7 +650,7 @@ class StringSField extends SField * imposées par l'utilisateur) */ function length() { - $cleaned = replace_accent(strtolower($this->value)); + $cleaned = strtolower(replace_accent($this->value)); $length = strlen(ereg_replace('[a-z0-9]', '', $cleaned)); return strlen($this->value) - $length; } @@ -660,7 +660,7 @@ class StringSField extends SField function too_large() { - return ($this->length()<2); + return ($this->length() < 2); } // }}} @@ -846,11 +846,14 @@ class SFieldGroup { $this->fields = $_fields; $this->and = $_and; - foreach ($this->fields as $key=>&$field) { - if (is_null($field)) { - unset($this->fields[$key]); + + $cleanFields = array(); + foreach ($this->fields as $field) { + if (!is_null($field)) { + $cleanFields[] = $field; } } + $this->fields = $cleanFields; } // }}} @@ -859,7 +862,7 @@ class SFieldGroup function too_large() { $b = true; - for ($i=0 ; $b && $ifields) ; $i++) { + for ($i = 0; $b && $i < count($this->fields); ++$i) { if (!is_null($this->fields[$i])) { $b = $b && $this->fields[$i]->too_large(); }