Try to give better scores to the different tokens of a name (Closes #1276)
[platal.git] / classes / address.php
index 36eac5b..08c313c 100644 (file)
@@ -102,21 +102,19 @@ class Address
             }
         }
 
-        if ($this->type == self::LINK_PROFILE) {
-            if (!is_null($this->flags)) {
-                $this->flags = new PlFlagSet($this->flags);
-            } else {
-                static $flags = array('current', 'temporary', 'secondary', 'mail');
-
-                $this->flags = new PlFlagSet();
-                foreach ($flags as $flag) {
-                    if (!is_null($this->$flag) && ($this->$flag == 1 || $this->$flag == 'on')) {
-                        $this->flags->addFlag($flag, 1);
-                        $this->$flag = null;
-                    }
-                    $this->flags->addFlag('cedex', (strpos(strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"),
-                                                                                   array('', "\n"), $this->text)), 'CEDEX')) !== false);
+        if (!is_null($this->flags)) {
+            $this->flags = new PlFlagSet($this->flags);
+        } else {
+            static $flags = array('current', 'temporary', 'secondary', 'mail');
+
+            $this->flags = new PlFlagSet();
+            foreach ($flags as $flag) {
+                if (!is_null($this->$flag) && ($this->$flag == 1 || $this->$flag == 'on')) {
+                    $this->flags->addFlag($flag, 1);
+                    $this->$flag = null;
                 }
+                $this->flags->addFlag('cedex', (strpos(strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"),
+                                                                               array('', "\n"), $this->text)), 'CEDEX')) !== false);
             }
         }
     }
@@ -166,6 +164,9 @@ class Address
                 $mailer->send();
             }
         }
+        if ($this->countryId == '') {
+            $this->countryId = null;
+        }
         $this->geocodeChosen = null;
         $this->phones = Phone::formatFormArray($this->phones, $this->error);
         return !$this->error;