Job page should work
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 8 Sep 2007 22:33:27 +0000 (00:33 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 8 Sep 2007 22:33:27 +0000 (00:33 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
13 files changed:
include/geoloc.inc.php
modules/profile/addresses.inc.php
modules/profile/assign_emploi.inc.php [deleted file]
modules/profile/get_emploi.inc.php [deleted file]
modules/profile/jobs.inc.php
modules/profile/page.inc.php
modules/profile/update_emploi.inc.php [deleted file]
modules/profile/verif_emploi.inc.php [deleted file]
templates/profile/adresses.tpl
templates/profile/jobs.job.tpl
templates/profile/jobs.secteur.tpl
templates/profile/jobs.tpl
upgrade/0.9.15/02_entreprises.sql [new file with mode: 0644]

index de0d4d4..a1939b8 100644 (file)
@@ -225,7 +225,7 @@ function compare_addresses_text($a, $b)
         return false;
     }
     foreach ($la as $i=>$l) {
-        if (levenshtein($l, $lb[$i]) > 3) {
+        if (levenshtein(trim($l), trim($lb[$i])) > 3) {
             return false;
         }
     }
index feb3692..1edfbc1 100644 (file)
@@ -19,7 +19,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class ProfileAddress
+class ProfileAddress extends ProfileGeoloc
 {
     private $bool;
     private $pub;
@@ -32,31 +32,6 @@ class ProfileAddress
         $this->tel  = new ProfileTel();
     }
 
-    private function geolocAddress(array &$address, &$success)
-    {
-        require_once 'geoloc.inc.php';
-        $success = true;
-        unset($address['geoloc']);
-        unset($address['geoloc_cityid']);
-        if (@$address['parsevalid'] || (@$address['text'] && @$address['changed']) || !@$address['cityid']) {
-            $address = array_merge($address, empty_address());
-            $new = get_address_infos(@$address['text']);
-            if (compare_addresses_text(@$adress['text'], $geotxt = get_address_text($new))
-                || @$address['parsevalid']) {
-                $address = array_merge($address, $new);
-            } else {
-                $success = false;
-                $address = array_merge($address, cut_address(@$address['text']));
-                $address['geoloc'] = $geotxt;
-                $address['geoloc_cityid'] = $new['cityid'];
-            }
-        }
-        if (@$address['changed']) {
-            $address['datemaj'] = time();
-        }
-        $address['text'] = get_address_text($address);
-    }
-
     private function cleanAddress(ProfilePage &$page, array &$address, &$success)
     {
         if (@$address['changed']) {
@@ -76,9 +51,6 @@ class ProfileAddress
             }
             unset($tel['removed']);
         }
-        if (@$address['changed']) {
-            $address['datemaj'] = time();
-        }
         $address['secondaire'] = $this->bool->value($page, 'secondaire', $address['secondaire'], $s);
         $address['mail'] = $this->bool->value($page, 'mail', $address['mail'], $s);
         $address['temporary'] = $this->bool->value($page, 'temporary', $address['temporary'], $s);
@@ -214,7 +186,7 @@ class ProfileAddresses extends ProfilePage
                                    FIND_IN_SET('temporaire', a.statut) AS temporary,
                                    FIND_IN_SET('active', a.statut) AS current
                              FROM  adresses AS a
-                       INNER JOIN geoloc_pays AS gp ON(gp.a2 = a.country)
+                       INNER JOIN  geoloc_pays AS gp ON(gp.a2 = a.country)
                             WHERE  uid = {?} AND NOT FIND_IN_SET('pro', statut)
                          ORDER BY  adrid",
                            S::i('uid'));
diff --git a/modules/profile/assign_emploi.inc.php b/modules/profile/assign_emploi.inc.php
deleted file mode 100644 (file)
index ce9a5f4..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as pubprolished by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-$page->assign('endrid',$endrid);
-$page->assign('entreprise',$entreprise);
-$page->assign('secteur',$secteur);
-$page->assign('ss_secteur',$ss_secteur);
-$page->assign('poste',$poste);
-$page->assign('fonction',$fonction);
-$page->assign('adrpro1',$adrpro1);
-$page->assign('adrpro2',$adrpro2);
-$page->assign('adrpro3',$adrpro3);
-$page->assign('postcodepro',$postcodepro);
-$page->assign('citypro',$citypro);
-$page->assign('countrypro',$countrypro);
-$page->assign('regionpro',$regionpro);
-$page->assign('telpro',$telpro);
-$page->assign('faxpro',$faxpro);
-$page->assign('mobilepro', $mobilepro);
-$page->assign('pubpro',$pubpro);
-$page->assign('adr_pubpro',$adr_pubpro);
-$page->assign('tel_pubpro',$tel_pubpro);
-$page->assign('emailpro',$emailpro);
-$page->assign('email_pubpro',$email_pubpro);
-$page->assign('webpro',$webpro);
-$page->assign('cv',$cv);
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/modules/profile/get_emploi.inc.php b/modules/profile/get_emploi.inc.php
deleted file mode 100644 (file)
index 8397612..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once('geoloc.inc.php');
-require_once('secteur.emploi.inc.php');
-require_once('fonction.emploi.inc.php');
-
-$res = XDB::iterRow("SELECT entrid, entreprise, secteur, ss_secteur, poste, fonction,
-       adr1, adr2, adr3, postcode, city, country, region, tel, fax, mobile,
-       pub, adr_pub, tel_pub, email, email_pub, web
-        FROM entreprises
-        WHERE uid = {?} ORDER BY entrid",S::v('uid', -1));
-
-$nb_res = $res->total();
-for($i = 0; $i < $nb_res ; $i++){
-       list($endrid[$i], $entreprise[$i], $secteur[$i], $ss_secteur[$i], $poste[$i], $fonction[$i],
-                    $adrpro1[$i], $adrpro2[$i], $adrpro3[$i], $postcodeppro[$i], $citypro[$i], $countrypro[$i], $regionpro[$i],
-             $telpro[$i], $faxpro[$i], $mobilepro[$i], $pubpro[$i], $adr_pubpro[$i],
-            $tel_pubpro[$i], $emailpro[$i], $email_pubpro[$i], $webpro[$i]) = $res->next();
-}
-//limite dure a 2
-for($i = $nb_res; $i < 2 ; $i++){
-       $endrid[$i] = $i;
-       $entreprise[$i] = '';
-       $secteur[$i] = '';
-       $ss_secteur[$i] = '';
-       $poste[$i] = '';
-       $fonction[$i] = '0';
-        $adrpro1[$i] = '';
-       $adrpro2[$i] = '';
-       $adrpro3[$i] = '';
-       $postcodepro[$i] = '';
-       $citypro[$i] = '';
-       $countrypro[$i] = '00';
-       $regionpro[$i] = '';
-        $telpro[$i] = '';
-       $faxpro[$i] = '';
-       $mobilepro[$i] = '';
-       $pubpro[$i] = '';
-       $adr_pubpro[$i] = '';
-       $tel_pubpro[$i] = '';
-       $emailpro[$i] = '';
-       $email_pubpro[$i] = '';
-       $webpro[$i] = '';
-}
-
-//recuperation des donnees sur les secteurs :
-
-$res = XDB::iterRow("SELECT id, label FROM emploi_secteur");
-
-while(list($tmp_secteur_id, $tmp_secteur_label) = $res->next()){
-    $secteurs[$tmp_secteur_id] = $tmp_secteur_label;
-}
-
-//recuperation des donnees sur les fonctions :
-$res = XDB::iterRow("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) FROM fonctions_def ORDER BY id");
-
-while(list($tmp_fonction_id, $tmp_fonction_label, $tmp_fonction_titre) = $res->next()){
-    $fonctions[$tmp_fonction_id] = $tmp_fonction_label;
-    $fonctions_titre[$tmp_fonction_id] = $tmp_fonction_titre;
-}
-
-//recuperation du CV
-$res = XDB::query("SELECT cv FROM auth_user_md5 WHERE user_id = {?}", S::v('uid', -1));
-$cv = $res->fetchOneCell();
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index 05e538c..b81c8f9 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
+class ProfileJob extends ProfileGeoloc
+{
+    private $pub;
+    private $mail;
+    private $web;
+    private $tel;
+    private $checks;
+
+    public function __construct()
+    {
+        $this->pub  = new ProfilePub();
+        $this->mail = new ProfileEmail();
+        $this->web  = new ProfileWeb();
+        $this->tel  = new ProfileTel();
+        $this->checks = array('web' => array('web'),
+                              'mail' => array('email'),
+                              'tel' => array('tel', 'fax', 'mobile'),
+                              'pub' => array('pub', 'tel_pub', 'email_pub'));
+    }
+
+    private function cleanJob(ProfilePage &$page, array &$job, &$success)
+    {
+        $success = true;
+        foreach ($this->checks as $obj=>&$fields) {
+            $chk =& $this->$obj;
+            foreach ($fields as $field) {
+                $job[$field] = $chk->value($page, $field, $job[$field], $s);
+                if (!$s) {
+                    $success = false;
+                    $job[$field . '_error'] = true;
+                }
+            }
+        }
+        unset($job['removed']);
+        unset($job['new']);
+        unset($job['adr']['changed']);
+        unset($job['adr']['parsevalid']);
+        unset($job['adr']['display']);
+    }
+
+    public function value(ProfilePage &$page, $field, $value, &$success)
+    {
+        $init = false;
+        if (is_null($value)) {
+            $value = $page->values['jobs'];
+            $init = true;
+        }
+        $success = true;
+        foreach ($value as $key=>&$job) {
+            if (@$job['removed']) {
+                unset($value[$key]);
+            }
+        }
+        foreach ($value as $key=>&$job) {
+            $ls = true;
+            $this->geolocAddress($job['adr'], $s);
+            $ls = ($ls && $s);
+            $this->cleanJob($page, $job, $s);
+            $ls = ($ls && $s);
+            if (!$init) {
+                $success = ($success && $ls);
+            }
+        }
+        return $value;
+    }
+
+    public function save(ProfilePage &$page, $field, $value)
+    {
+        XDB::execute("DELETE FROM  entreprises
+                            WHERE  uid = {?}",
+                     S::i('uid'));
+        $i = 0;
+        foreach ($value as &$job) {
+            XDB::execute("INSERT INTO  entreprises (uid, entrid, entreprise, secteur, ss_secteur,
+                                                    fonction, poste, adr1, adr2, adr3, postcode,
+                                                    city, cityid, country, region, regiontxt,
+                                                    tel, fax, mobile, email, web,
+                                                    pub, adr_pub, tel_pub, email_pub)
+                               VALUES  ({?}, {?}, {?}, {?}, {?},
+                                        {?}, {?}, {?}, {?}, {?}, {?},
+                                        {?}, {?}, {?}, {?}, {?},
+                                        {?}, {?}, {?}, {?}, {?},
+                                        {?}, {?}, {?}, {?})",
+                         S::i('uid'), $i++, $job['name'], $job['secteur'], $job['ss_secteur'],
+                         $job['fonction'], $job['poste'], $job['adr']['adr1'], $job['adr']['adr2'], $job['adr']['adr3'],
+                         $job['adr']['postcode'],
+                         $job['adr']['city'], $job['adr']['cityid'], $job['adr']['country'], $job['adr']['region'], 
+                         $job['adr']['regiontxt'],
+                         $job['tel'], $job['fax'], $job['mobile'], $job['email'], $job['web'],
+                         $job['pub'], $job['adr']['pub'], $job['tel_pub'], $job['email_pub']);
+        }
+    }
+}
+
 class ProfileJobs extends ProfilePage
 {
     protected $pg_template = 'profile/jobs.tpl';
@@ -26,6 +120,79 @@ class ProfileJobs extends ProfilePage
     public function __construct(PlWizard &$wiz)
     {
         parent::__construct($wiz);
+        $this->settings['cv'] = null;
+        $this->settings['jobs'] = new ProfileJob();
+    }
+
+    protected function fetchData()
+    {
+        if (count($this->orig) > 0) {
+            $this->values = $this->orig;
+            return;
+        }
+        // Checkout the CV
+        $res = XDB::query("SELECT  cv
+                             FROM  auth_user_md5
+                            WHERE  user_id = {?}",
+                          S::i('uid'));
+        $this->values['cv'] = $res->fetchOneCell();
+
+        // Build the jobs tree
+        $res = XDB::iterRow("SELECT  e.entreprise, e.secteur, e.ss_secteur,
+                                     e.fonction, e.poste, e.adr1, e.adr2, e.adr3,
+                                     e.postcode, e.city, e.cityid, e.region, e.regiontxt,
+                                     e.country, gp.pays, gp.display,
+                                     e.tel, e.fax, e.mobile, e.email, e.web, e.pub,
+                                     e.adr_pub, e.tel_pub, e.email_pub
+                               FROM  entreprises AS e
+                         INNER JOIN  geoloc_pays AS gp ON(gp.a2 = e.country)
+                              WHERE  uid = {?} AND entreprise != ''
+                           ORDER BY  entrid", S::i('uid'));
+        $this->values['jobs'] = array();
+        while (list($name, $secteur, $ss_secteur, $fonction, $poste,
+                    $adr1, $adr2, $adr3, $postcode, $city, $cityid,
+                    $region, $regiontxt, $country, $countrytxt, $display,
+                    $tel, $fax, $mobile, $email, $web,
+                    $pub, $adr_pub, $tel_pub, $email_pub) = $res->next()) {
+            $this->values['jobs'][] = array('name'       => $name,
+                                            'secteur'    => $secteur,
+                                            'ss_secteur' => $ss_secteur,
+                                            'fonction'   => $fonction,
+                                            'poste'      => $poste,
+                                            'adr'        => array('adr1'       => $adr1,
+                                                                  'adr2'       => $adr2,
+                                                                  'adr3'       => $adr3,
+                                                                  'postcode'   => $postcode,
+                                                                  'city'       => $city,
+                                                                  'cityid'     => $cityid,
+                                                                  'region'     => $region,
+                                                                  'regiontxt'  => $regiontxt,
+                                                                  'country'    => $country,
+                                                                  'countrytxt' => $countrytxt,
+                                                                  'display'    => $display,
+                                                                  'pub'        => $adr_pub),
+                                            'tel'        => $tel,
+                                            'fax'        => $fax,
+                                            'mobile'     => $mobile,
+                                            'email'      => $email,
+                                            'web'        => $web,
+                                            'pub'        => $pub,
+                                            'adr_pub'    => $adr_pub,
+                                            'tel_pub'    => $tel_pub,
+                                            'email_pub'  => $email_pub);
+        }
+        parent::fetchData();
+    }
+
+    protected function saveData()
+    {
+        if ($this->changed['cv']) {
+            XDB::execute("UPDATE  auth_user_md5
+                             SET  cv = {?}
+                           WHERE  user_id = {?}",
+                         $this->values['cv'], S::i('uid'));
+        }
+        parent::saveData();
     }
 
     public function prepare(PlatalPage &$page)
index 6decf81..411be43 100644 (file)
@@ -50,7 +50,8 @@ class ProfileWeb extends ProfileNoSave
         if (is_null($value)) {
             return isset($page->values[$field]) ? $page->values[$field] : S::v($field);
         }
-        $success = !trim($value) || preg_match("{^(https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+$}i", $value);
+        $value = trim($value);
+        $success = empty($value) || preg_match("{^(https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+$}i", $value);
         if (!$success) {
             global $page;
             $page->trig('URL Incorrecte : une url doit commencer par http:// ou https:// ou ftp://'
@@ -60,6 +61,25 @@ class ProfileWeb extends ProfileNoSave
     }
 }
 
+class ProfileEmail extends ProfileNoSave
+{
+    public function value(ProfilePage &$page, $field, $value, &$success)
+    {
+        if (is_null($value)) {
+            return isset($page->values[$field]) ? $page->values[$field] : S::v($field);
+        }
+        $value = trim($value);
+        require_once 'xorg.misc.inc.php';
+        $success = empty($value) || isvalid_email($value);
+        if (!$success) {
+            global $page;
+            $page->trig('Adresse Email invalide');
+        }
+        return $value;
+    }
+}
+
+
 class ProfileTel extends ProfileNoSave
 {
     public function value(ProfilePage &$page, $field, $value, &$success)
@@ -105,6 +125,34 @@ class ProfileBool extends ProfileNoSave
     }
 }
 
+abstract class ProfileGeoloc implements ProfileSetting
+{
+    protected function geolocAddress(array &$address, &$success)
+    {
+        require_once 'geoloc.inc.php';
+        $success = true;
+        unset($address['geoloc']);
+        unset($address['geoloc_cityid']);
+        if (@$address['parsevalid']
+            || (@$address['text'] && @$address['changed'])
+            || (@$address['text'] && !@$address['cityid'])) {
+            $address = array_merge($address, empty_address());
+            $new = get_address_infos(@$address['text']);
+            if (compare_addresses_text(@$adress['text'], $geotxt = get_address_text($new))
+                || @$address['parsevalid']) {
+                $address = array_merge($address, $new);
+            } else {
+                $success = false;
+                $address = array_merge($address, cut_address(@$address['text']));
+                $address['geoloc'] = $geotxt;
+                $address['geoloc_cityid'] = $new['cityid'];
+            }
+        }
+        $address['text'] = get_address_text($address);
+    }
+}
+
+
 abstract class ProfilePage implements PlWizardPage
 {
     protected $wizard;
diff --git a/modules/profile/update_emploi.inc.php b/modules/profile/update_emploi.inc.php
deleted file mode 100644 (file)
index 622cbb5..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-for($i = 0; $i < 2; $i++){
-
-    XDB::execute("REPLACE INTO entreprises(uid,entrid,entreprise,secteur,ss_secteur,poste,fonction,adr1,adr2,adr3,postcode,city,country,region,tel,fax,mobile,pub, adr_pub, tel_pub, email, email_pub, web) ".
-              "VALUES ({?}, {?}, {?}, ".
-             "{?},".
-             "{?}".
-             ", {?}, {?}, ".
-             "{?}, {?}, {?}, {?}, ".
-             "{?}, {?}, ".
-             "{?}, {?}, {?}, {?}, ".
-             "{?}, {?}, {?}, ".
-             "{?}, {?}, {?})",
-             S::v('uid', -1) , $i , $entreprise[$i] ,
-             ( ($secteur[$i] == "") ? null : $secteur[$i]), //sinon un faux 0 est rentre dans la base
-             ( ($ss_secteur[$i] == "") ? null : $ss_secteur[$i]),
-             $poste[$i], $fonction[$i],
-              $adrpro1[$i], $adrpro2[$i], $adrpro3[$i], $postcodepro[$i],
-              $citypro[$i], $countrypro[$i],
-             $regionpro[$i], $telpro[$i], $faxpro[$i], $mobilepro[$i],
-             $pubpro[$i], $adr_pubpro[$i], $tel_pubpro[$i],
-             $emailpro[$i], $email_pubpro[$i], $webpro[$i]);
-}
-XDB::execute("UPDATE auth_user_md5 set cv= {?} WHERE user_id = {?}", $cv, S::v('uid', -1));
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/modules/profile/verif_emploi.inc.php b/modules/profile/verif_emploi.inc.php
deleted file mode 100644 (file)
index 7c96990..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-include_once('xorg.misc.inc.php');
-
-function set_flag_i(&$var,$var_name,$i){
-  $tab = Env::v($var_name, array());
-  if(isset($tab[$i])){
-       $var[$i] = 1;
-  }
-  else
-       $var[$i] = '0';
-}
-
-for($i = 0; $i < 2; $i++){
-replace_ifset_i($entreprise,"entreprise",$i);
-replace_ifset_i($poste,"poste",$i);
-replace_ifset_i($secteur,"secteur",$i);
-replace_ifset_i($ss_secteur,"ss_secteur",$i);
-replace_ifset_i($fonction,"fonction",$i);
-
-replace_ifset_i($adrpro1,"adrpro1",$i);
-replace_ifset_i($adrpro2,"adrpro2",$i);
-replace_ifset_i($adrpro3,"adrpro3",$i);
-replace_ifset_i($postcodepro,"postcodepro",$i);
-replace_ifset_i($citypro,"citypro",$i);
-replace_ifset_i($countrypro,"countrypro",$i);
-replace_ifset_i($regionpro,"regionpro",$i);
-replace_ifset_i($telpro,"telpro",$i);
-replace_ifset_i($faxpro,"faxpro",$i);
-replace_ifset_i($mobilepro,"mobilepro",$i);
-replace_ifset_i($pubpro,"pubpro",$i);
-replace_ifset_i($adr_pubpro,"adr_pubpro",$i);
-replace_ifset_i($tel_pubpro,"tel_pubpro",$i);
-replace_ifset_i($emailpro,"emailpro",$i);
-replace_ifset_i($email_pubpro,"email_pubpro",$i);
-replace_ifset_i($webpro,"webpro",$i);
-replace_ifset($cv,"cv");
-
-// validité de l'entreprise
-$j = $i+1;
-if (strlen(strtok($entreprise[$i],"<>{}#~;!§*`[]|%^=")) < strlen($entreprise[$i]))
-{
-    $page->trig("Le champ 'Entreprise $j' contient un caractère interdit.");
-}
-
-//validité du poste
-if (strlen(strtok($poste[$i],"<>{}~?!§*`|%$^=+")) < strlen($poste[$i]))
-{
-    $page->trig("Le champ 'Poste $j' contient un caractère interdit.");
-}
-
-// correction du champ web si vide
-if ($webpro[$i]=="http://" or $webpro[$i] == '') {
-    $webpro[$i]='';
-} elseif (!preg_match("{^(https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+$}i", $webpro[$i])) {
-    // validité de l'url donnée dans web
-    $page->trig("URL incorrecte dans le champ 'Page web', une url doit commencer par
-                    http:// ou https:// ou ftp:// et ne pas contenir de caractères interdits");
-} else {
-    $webpro[$i] = str_replace('&', '&amp;', $webpro[$i]);
-}
-
-// validité de l'e-mail
-if ($emailpro[$i]) {
-    $emailpro[$i] = strtolower(trim($emailpro[$i]));
-    if (!isvalid_email($emailpro[$i])) {
-       $page->trig("Adresse e-mail incorrecte dans le champ 'E-mail'");
-    }
-}
-
-if (strlen(strtok($adrpro1[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro1[$i]))
-    {
-      $page->trig("Le champ 'Adresse professionnelle $j - Ligne 1' contient un caractère interdit.");
-    }
-  if (strlen(strtok($adrpro2[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro2[$i]))
-    {
-      $page->trig("Le champ 'Adresse professionnelle $j - Ligne 2' contient un caractère interdit.");
-    }
-  if (strlen(strtok($adrpro3[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro3[$i]))
-    {
-      $page->trig("Le champ 'Adresse professionnelle $j - Ligne 3' contient un caractère interdit.");
-    }
-  if (strlen(strtok($postcodepro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($postcodepro[$i]))
-    {
-      $page->trig("Le champ 'Code Postal professionnel $j' contient un caractère interdit.");
-    }
-  if (strlen(strtok($citypro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($citypro[$i]))
-    {
-      $page->trig("Le champ 'Ville professionnelle $j' contient un caractère interdit.");
-    }
-  if (strlen(strtok($telpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($telpro[$i]))
-    {
-      $page->trig("Le champ 'Téléphone professionnel $j' contient un caractère interdit.");
-    }
-  if (strlen(strtok($faxpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($faxpro[$i]))
-    {
-      $page->trig("Le champ 'Fax professionnel $j' contient un caractère interdit.");
-    }
-  if (strlen(strtok($mobilepro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($mobilepro[$i]))
-    {
-      $page->trig("Le champ 'Mobile professionnel $j' contient un caractère interdit.");
-    }
-
-}
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index 5439dc0..f87b691 100644 (file)
@@ -112,7 +112,7 @@ function validGeoloc(id, pref)
   document.getElementById(id + '_geoloc').style.display = 'none';
   document.getElementById(id + '_geoloc_error').style.display = 'none';
   document.getElementById(id + '_geoloc_valid').style.display = 'none';
-  document.forms.prof_annu[pref + "[parsevalid]"] = "1";
+  document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
   document.forms.prof_annu[pref + "[text]"].value = document.forms.prof_annu[pref + "[geoloc]"].value;
   attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
               function() { document.forms.prof_annu[pref + "[text]"].blur(); });
@@ -124,7 +124,7 @@ function validAddress(id, pref)
   document.getElementById(id + '_geoloc').style.display = 'none';
   document.getElementById(id + '_geoloc_error').style.display = 'none';
   document.getElementById(id + '_geoloc_valid').style.display = 'none';
-  document.forms.prof_annu[pref + "[parsevalid]"] = "0";
+  document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
   attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
               function() { document.forms.prof_annu[pref + "[text]"].blur(); });
   document.forms.prof_annu[pref + "[text]"].className = '';
index bfdb471..ce1e07d 100644 (file)
@@ -24,7 +24,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 {/if}
 {assign var=jobid value="job_`$i`"}
-{assign var=jobpref value="job[`$i`]"}
+{assign var=jobpref value="jobs[`$i`]"}
 <div id="{$jobid}">
   <input type="hidden" name="{$jobpref}[removed]" value="0" />
   <input type="hidden" name="{$jobpref}[new]" value="{if $new}1{else}0{/if}" />
@@ -34,7 +34,7 @@
         <div style="float: right">
           <a href="javascript:restoreJob('{$jobid}', '{$jobpref}')">{icon name=arrow_refresh title="Restaure l'emploi"}</a>
         </div>
-        Restaurer l'entreprise n°{$i+1}&nbsp;:<span id="{$jobid}_grayed_name"></span>
+        Restaurer l'entreprise n°{$i+1}&nbsp;:&nbsp;<span id="{$jobid}_grayed_name"></span>
       </th>
     </tr>
   </table>
@@ -45,7 +45,8 @@
           {include file="include/flags.radio.tpl" notable=true display="div" name="`$jobpref`[pub]" value=$job.pub}
         </div>
         Entreprise n°{$i+1}&nbsp;:
-        <input type="text" size="35" maxlength="100" name="{$jobpref}[name]" value="{$job.name}" />
+        <input type="text" {if $job.name_error}class="error"{/if} size="35" maxlength="100"
+               name="{$jobpref}[name]" value="{$job.name}" />
         <a href="javascript:removeJob('{$jobid}', '{$jobpref}')">
           {icon name=cross title="Supprimer cet emploi"}
         </a>
     </tr>
     <tr>
       <td class="titre">Page Web</td>
-      <td><input type="text" size="35" maxlength="255" name="{$jobpref}[web]" value="{$job.web}" /></td>
+      <td>
+        <input type="text" size="35" maxlength="255" {if $job.web_error}class="error"{/if}
+               name="{$jobpref}[web]" value="{$job.web}" />
+      </td>
     </tr>
     <tr>
       <td class="titre">Secteur d'activité</td>
@@ -76,7 +80,8 @@
     <tr>
       <td class="titre">Poste occupé</td>
       <td>
-        <input type="text" size="35" maxlength="120" name="{$jobpref}[poste]" value="{$job.poste}" />
+        <input type="text" size="35" maxlength="120" {if $job.poste_error}class="error"{/if}
+               name="{$jobpref}[poste]" value="{$job.poste}" />
       </td>
     </tr>
     <tr>
     <tr class="pair">
       <td colspan="2">
         <span class="titre">E-mail professionnel&nbsp;:</span>
-        <input type="text" size="30" maxlength="60" name="{$jobpref}[email]" value="{$job.email}" />
+        <input type="text" size="30" maxlength="60" {if $job.email_error}class="error"{/if}
+               name="{$jobpref}[email]" value="{$job.email}" />
         <span class="flags">
           {include file="include/flags.radio.tpl" name="`$jobpref`[email_pub]" val=$job.mail_pub display="div"}
         </span>
             {include file="include/flags.radio.tpl" name="`$jobpref`[adr][pub]" val=$job.adr.pub display="div"}
           </div>
           <div style="margin-top: 20px; clear: both">
-            {include file="geoloc/form.address.tpl" name="`$jobpref`[adr]" id="`$jobpref`_adr" adr=$job.adr}
+            {include file="geoloc/form.address.tpl" name="`$jobpref`[adr]" id="`$jobid`_adr" adr=$job.adr}
           </div>
         </div>
         <div style="float: right; width: 50%">
           <table style="clear: both">
             <tr>
               <td>Bureau&nbsp;:</td>
-              <td><input type="text" size="18" maxlength="18" name="{$jobpref}[tel_office]" value="{$job.tel_office}" /></td>
+              <td>
+                <input type="text" size="18" maxlength="18" {if $job.tel_error}class="error"{/if}
+                       name="{$jobpref}[tel]" value="{$job.tel}" />
+              </td>
             </tr>
             <tr>
               <td>Fax&nbsp;:</td>
-              <td><input type="text" size="18" maxlength="18" name="{$jobpref}[tel_fax]" value="{$job.tel_fax}" /></td>
+              <td>
+                <input type="text" size="18" maxlength="18" {if $job.fax_error}class="error"{/if}
+                       name="{$jobpref}[fax]" value="{$job.fax}" /></td>
             </tr>
             <tr>
               <td>Mobile&nbsp;:</td>
-              <td><input type="text" size="18" maxlength="18" name="{$jobpref}[tel_mobile]" value="{$job.tel_mobile}" /></td>
+              <td>
+                <input type="text" size="18" maxlength="18" {if $job.mobile_error}class="error"{/if}
+                       name="{$jobpref}[mobile]" value="{$job.mobile}" />
+              </td>
             </tr>
           </table>
         </div>
index 5af83dd..dac620c 100644 (file)
@@ -21,7 +21,7 @@
 {**************************************************************************}
 
 <?xml version="1.0" encoding="utf-8"?>
-<select name="job[{$id}][ss_secteur]">
+<select name="jobs[{$id}][ss_secteur]">
   <option value=""></option>
   {iterate from=$ssecteurs item=ssecteur}
   <option value="{$ssecteur.id}" {if $ssecteur.id eq $sel}selected="selected"{/if}>{$ssecteur.label}</option>
index f0bfd77..46fe55c 100644 (file)
@@ -55,7 +55,7 @@ function makeAddJob(id)
   return function(data)
          {
            $('#add_job').before(data);
-           updateSecteur('job_' + id, 'job[' + id + ']', '');
+           updateSecteur('job_' + id, 'jobs[' + id + ']', '');
          };
 }
 
@@ -68,16 +68,39 @@ function addJob()
   $.get(platal_baseurl + 'profile/ajax/job/' + i, makeAddJob(i));
 }
 
+function validGeoloc(id, pref)
+{
+  document.getElementById(id + '_geoloc').style.display = 'none';
+  document.getElementById(id + '_geoloc_error').style.display = 'none';
+  document.getElementById(id + '_geoloc_valid').style.display = 'none';
+  document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
+  document.forms.prof_annu[pref + "[text]"].value = document.forms.prof_annu[pref + "[geoloc]"].value;
+  attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
+              function() { document.forms.prof_annu[pref + "[text]"].blur(); });
+  document.forms.prof_annu[pref + "[text]"].className = '';
+}
+
+function validAddress(id, pref)
+{
+  document.getElementById(id + '_geoloc').style.display = 'none';
+  document.getElementById(id + '_geoloc_error').style.display = 'none';
+  document.getElementById(id + '_geoloc_valid').style.display = 'none';
+  document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
+  attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
+              function() { document.forms.prof_annu[pref + "[text]"].blur(); });
+  document.forms.prof_annu[pref + "[text]"].className = '';
+}
+
 {/literal}
 //]]></script>
 
-{foreach from=$entreprises item=job key=i}
+{foreach from=$jobs item=job key=i}
 {include file="profile/jobs.job.tpl" i=$i job=$job new=false}
-<script type="text/javascript">updateSecteur({$i}, '{"job_`$i`"}', '{"job[`$i`]"}', '{$job.ss_secteur}');</script>
+<script type="text/javascript">updateSecteur({$i}, '{"job_`$i`"}', '{"jobs[`$i`]"}', '{$job.ss_secteur}');</script>
 {/foreach}
 {if $jobs|@count eq 0}
 {include file="profile/jobs.job.tpl" i=0 job=0 new=true}
-<script type="text/javascript">updateSecteur(0, 'job_0', 'job[0]', '-1');</script></script>
+<script type="text/javascript">updateSecteur(0, 'job_0', 'jobs[0]', '-1');</script></script>
 {/if}
 
 <div id="add_job" class="center">
@@ -114,7 +137,7 @@ function addJob()
       </div>
       <div style="float: right">
         <div id="cv_preview" style="display: none"></div>
-        <textarea name="cv" id="cv" rows="15" cols="55">{$cv}</textarea>
+        <textarea name="cv" {if $errors.cv}class="error"{/if} id="cv" rows="15" cols="55">{$cv}</textarea>
       </div>
     </td>
   </tr>
diff --git a/upgrade/0.9.15/02_entreprises.sql b/upgrade/0.9.15/02_entreprises.sql
new file mode 100644 (file)
index 0000000..859e9ae
--- /dev/null
@@ -0,0 +1,7 @@
+alter table entreprises add column cityid int(11) default null after city;
+alter table entreprises add column regiontxt varchar(80) not null after region;
+alter table entreprises add key cityid (cityid);
+alter table entreprises add key country (country);
+alter table entreprises add key region (region);
+
+# vim:set syntax=mysql: