Merge branch 'platal-1.0.0'
[platal.git] / classes / address.php
index 16ecd80..0eac92c 100644 (file)
@@ -135,7 +135,7 @@ class Address
 
     public function hasFlag($flag)
     {
-        return $this->flags->hasFlag($flag);
+        return ($this->flags != null && $this->flags->hasFlag($flag));
     }
 
     public function format(array $format = array())
@@ -150,7 +150,6 @@ class Address
             return true;
         }
 
-        require_once 'geocoding.inc.php';
         if ($format['requireGeocoding'] || $this->changed == 1) {
             $gmapsGeocoder = new GMapsGeocoder();
             $gmapsGeocoder->getGeocodedAddress($this);
@@ -167,6 +166,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;
@@ -257,7 +259,6 @@ class Address
 
         $this->format();
         if (!$this->isEmpty()) {
-            require_once 'geocoding.inc.php';
             foreach ($areas as $area) {
                 Geocoder::getAreaId($this, $area);
             }