Remove Address::updateGeocoding unused parameter
[platal.git] / include / validations / address.inc.php
index 349674a..12b2779 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2011 Polytechnique.org                              *
+ *  Copyright (C) 2003-2014 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -26,10 +26,11 @@ class AddressReq extends ProfileValidate
     // {{{ properties
 
     // Address primary field that are not in its formatted array.
-    public $pid;
-    public $jobid;
-    public $groupid;
-    public $type;
+    public $key_pid;
+    public $key_jobid;
+    public $key_groupid;
+    public $key_type;
+    public $key_id;
 
     // We need the text given by the user, and the toy version to try to improve
     // the geocoding.
@@ -43,17 +44,17 @@ class AddressReq extends ProfileValidate
     // }}}
     // {{{ constructor
 
-    public function __construct(User $_user, Profile $_profile, $_text, $_pid, $_jobid, $_groupid, $_type, $_stamp = 0)
+    public function __construct(User $_user, array $_address, $_pid, $_jobid, $_groupid, $_type, $_id, $_stamp = 0)
     {
+        $_profile = Profile::get($_pid);
         parent::__construct($_user, $_profile, false, 'address', $_stamp);
         $this->key_pid = $_pid;
         $this->key_jobid = $_jobid;
         $this->key_groupid = $_groupid;
         $this->key_type = $_type;
-        $this->given_text = $_text;
-        $address = new Address(array('changed' => 1, 'text' => $_text));
-        $address->format();
-        $this->address = $address->toFormArray();
+        $this->key_id = $_id;
+        $this->given_text = $_address['text'];
+        $this->address = $_address;
     }
 
     // }}}
@@ -103,7 +104,7 @@ class AddressReq extends ProfileValidate
     protected function _mail_body($isok)
     {
         if ($isok) {
-            return "  Nous avons réussit à mieux localiser l'adresse.";
+            return "  Nous avons réussi à mieux localiser l'adresse suivante :\n{$this->given_text}.";
         } else {
             return "  L'adresse est suffisemment bien localisée pour les besoins du site (recherche avancée, planisphère), nous avons donc choisi de ne pas la modifier.";
         }
@@ -115,16 +116,17 @@ class AddressReq extends ProfileValidate
     public function commit()
     {
         $this->address = array_merge($this->address, array(
-            'pid' => $this->key_pid,
-            'jobid' => $this->key_jobid,
+            'pid'     => $this->key_pid,
+            'jobid'   => $this->key_jobid,
             'groupid' => $this->key_groupid,
-            'type' => $this->key_type
+            'type'    => $this->key_type,
+            'id'      => $this->key_id
         ));
         $this->address['text'] = ($this->modified ? $this->toy_text : $this->given_text);;
         $this->address['changed'] = 0;
         $address = new Address($this->address);
         $address->format();
-        $address->updateGeocoding($this->given_text);
+        $address->updateGeocoding();
 
         return true;
     }
@@ -132,12 +134,12 @@ class AddressReq extends ProfileValidate
     // }}}
     // {{{ function get_request()
 
-    static public function get_request($pid, $jobid, $groupid, $type, $address)
+    static public function get_request($pid, $jobid, $groupid, $type, $id)
     {
         $reqs = parent::get_typed_requests($pid, 'address');
         foreach ($reqs as &$req) {
             if ($req->key_pid == $pid && $req->key_jobid == $jobid && $req->key_groupid == $groupid
-                && $req->key_type == $type && $req->address['text'] == $address) {
+                && $req->key_type == $type && $req->key_id == $id) {
                 return $req;
             }
         }
@@ -153,14 +155,7 @@ class AddressReq extends ProfileValidate
         $requests = parent::get_all_typed_requests('address');
         foreach ($requests as &$req) {
             if ($req->key_pid == $pid && $req->key_jobid == $jobid && $req->key_groupid == $groupid && $req->key_type == $type) {
-                $count = XDB::fetchOneCell('SELECT  COUNT(*)
-                                              FROM  profile_addresses
-                                             WHERE  pid = {?} AND jobid = {?} AND groupid = {?}
-                                                    AND type = {?} AND text = {?}',
-                                           $pid, $jobid, $groupid, $type, $req->address['text']);
-                if ($count == 0) {
-                    $req->clean();
-                }
+                $req->clean();
             }
         }
     }
@@ -170,5 +165,5 @@ class AddressReq extends ProfileValidate
 
 // }}}
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
 ?>