From: Stéphane Jacob Date: Sat, 3 Jul 2010 10:01:27 +0000 (+0200) Subject: Fixes entreprise validation when user only indicated the entreprise name. X-Git-Tag: xorg/1.0.1~15^2~65 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=a38c0777574136ec77014e87a762d581a9f57386;p=platal.git Fixes entreprise validation when user only indicated the entreprise name. Signed-off-by: Stéphane Jacob --- diff --git a/include/validations/entreprises.inc.php b/include/validations/entreprises.inc.php index 6734855..cff4801 100644 --- a/include/validations/entreprises.inc.php +++ b/include/validations/entreprises.inc.php @@ -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; } // }}}