From c3951bbde67bb99da420af481b4b78c380e8fff5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Thu, 10 Mar 2011 13:20:29 +0100 Subject: [PATCH] Fixes entreprises requests. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- modules/profile/jobs.inc.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/profile/jobs.inc.php b/modules/profile/jobs.inc.php index ea6d5ed..b343ade 100644 --- a/modules/profile/jobs.inc.php +++ b/modules/profile/jobs.inc.php @@ -172,11 +172,7 @@ class ProfileSettingJob implements ProfileSetting WHERE name = {?}", $job['name']); if ($res->numRows() != 1) { - $req = new EntrReq(S::user(), $page->profile, $jobid, $job['name'], $job['hq_acronym'], $job['hq_url'], - $job['hq_email'], $job['hq_fixed'], $job['hq_fax'], $job['hq_address']); - $req->submit(); $job['jobid'] = null; - sleep(1); } else { $job['jobid'] = $res->fetchOneCell(); } @@ -259,6 +255,7 @@ class ProfileSettingJob implements ProfileSetting public function save(ProfilePage $page, $field, $value) { + $deletePrivate = S::user()->isMe($page->owner) || S::admin(); XDB::execute('DELETE FROM pj, pjt USING profile_job AS pj @@ -267,6 +264,10 @@ class ProfileSettingJob implements ProfileSetting $page->pid()); Address::deleteAddresses($page->pid(), Address::LINK_JOB, null, null, $deletePrivate); Phone::deletePhones($page->pid(), Phone::LINK_JOB, null, $deletePrivate); + $previous_requests = EntrReq::get_typed_requests($page->pid(), 'entreprise'); + foreach ($previous_requests as $request) { + $request->clean(); + } $terms_values = array(); foreach ($value as $id => &$job) { if (($job['pub'] != 'private' || $deletePrivate) && (isset($job['name']) && $job['name'])) { @@ -282,6 +283,10 @@ class ProfileSettingJob implements ProfileSetting VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?})', $page->pid(), $id, $job['description'], $job['w_email'], $job['w_url'], $job['pub'], $job['w_email_pub']); + $request = new EntrReq(S::user(), $page->profile, $id, $job['name'], $job['hq_acronym'], $job['hq_url'], + $job['hq_email'], $job['hq_fixed'], $job['hq_fax'], $job['hq_address']); + $request->submit(); + sleep(1); } $address = new Address(array_merge($job['w_address'], array('pid' => $page->pid(), -- 2.1.4