Add autoload for PFC_* classes
[platal.git] / include / profil.func.inc.php
index 5e084be..10b3416 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2009 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -20,7 +20,6 @@
  ***************************************************************************/
 
 
-require_once('applis.func.inc.php');
 
 function replace_ifset(&$var,$req) {
     if (Env::has($req)){
@@ -76,15 +75,15 @@ function diff_user_details(&$a, &$b, $view = 'private') { // compute $c = $a - $
 }
 
 function same_tel(&$a, &$b) {
-    $numbera = preg_replace('/[^0-9]/', '', (string) $a);
-    $numberb = preg_replace('/[^0-9]/', '', (string) $b);
+    $numbera = format_phone_number((string) $a);
+    $numberb = format_phone_number((string) $b);
     return $numbera === $numberb;
 }
 function same_address(&$a, &$b) {
     return
         (same_field($a['adr1'],$b['adr1'])) &&
-        (same_field($a['adr1'],$b['adr1'])) &&
-        (same_field($a['adr1'],$b['adr1'])) &&
+        (same_field($a['adr2'],$b['adr2'])) &&
+        (same_field($a['adr3'],$b['adr3'])) &&
         (same_field($a['postcode'],$b['postcode'])) &&
         (same_field($a['city'],$b['city'])) &&
         (same_field($a['countrytxt'],$b['countrytxt'])) &&
@@ -104,7 +103,7 @@ function same_field(&$a, &$b) {
             if (!isset($b[$val]) || !same_field($avar, $b[$val])) return false;
         return true;
     } elseif (is_string($a))
-        return (strtoupper($a) == strtoupper($b));
+        return (mb_strtoupper($a) == mb_strtoupper($b));
 }
 function diff_user_tel(&$a, &$b) {
     $c = $a;
@@ -315,14 +314,14 @@ function format_display_number($tel, &$error, $format = array('format'=>'','phon
     $ret = '';
     $tel_length = strlen($tel);
     if((!isset($format['phoneprf'])) || ($format['phoneprf'] == '')) {
-        $res = XDB::query("SELECT phoneprf, phoneformat AS format
-                             FROM geoloc_pays
-                            WHERE phoneprf = {?} OR phoneprf = {?} OR phoneprf = {?}
+        $res = XDB::query("SELECT phonePrefix AS phoneprf, phoneFormat AS format
+                             FROM geoloc_countries
+                            WHERE phonePrefix = {?} OR phonePrefix = {?} OR phonePrefix = {?}
                             LIMIT 1",
                           substr($tel, 0, 1), substr($tel, 0, 2), substr($tel, 0, 3));
         if ($res->numRows() == 0) {
             $error = true;
-            return '*+' . $tel;
+            return '+' . $tel;
         }
         $format = $res->fetchOneAssoc();
     }