Fixes entreprise validation when user only indicated the entreprise name.
authorStéphane Jacob <sj@m4x.org>
Sat, 3 Jul 2010 10:01:27 +0000 (12:01 +0200)
committerStéphane Jacob <sj@m4x.org>
Sat, 3 Jul 2010 10:01:27 +0000 (12:01 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
include/validations/entreprises.inc.php

index 6734855..cff4801 100644 (file)
@@ -191,12 +191,17 @@ class EntrReq extends ProfileValidate
                          $this->address['east'], $this->address['west']);
         } else {
             $jobid = $res->fetchOneCell();
-            $success = true;
         }
-        return XDB::execute('UPDATE  profile_job
-                                SET  jobid = {?}
-                              WHERE  pid = {?} AND id = {?}',
-                            $jobid, $this->profile->id(), $this->id);
+        XDB::execute('UPDATE  profile_job
+                         SET  jobid = {?}
+                       WHERE  pid = {?} AND id = {?}',
+                     $jobid, $this->profile->id(), $this->id);
+        if (XDB::affectedRows() == 0) {
+            return XDB::execute('INSERT INTO  profile_job (jobid, pid, id)
+                                      VALUES  ({?}, {?}, {?})',
+                                $jobid, $this->profile->id(), $this->id);
+        }
+        return true;
     }
 
     // }}}