diff --git a/htdocs/admin/phenix.php b/htdocs/admin/phenix.php index e4947fb0047c1e168a52778b4ebbbfed177fa1f0..58582cb3a58d0f1c3b3077baef64bab732d0e2f1 100644 --- a/htdocs/admin/phenix.php +++ b/htdocs/admin/phenix.php @@ -54,6 +54,7 @@ if ($actionsave) $i+=dolibarr_set_const($db,'PHPPHENIX_DBNAME',trim($_POST["phpphenix_dbname"]),'chaine',0); $i+=dolibarr_set_const($db,'PHPPHENIX_USER',trim($_POST["phpphenix_user"]),'chaine',0); $i+=dolibarr_set_const($db,'PHPPHENIX_PASS',trim($_POST["phpphenix_pass"]),'chaine',0); + $i+=dolibarr_set_const($db,'PHPPHENIX_COOKIE',trim($_POST["phpphenix_cookie"]),'chaine',0); $i+=dolibarr_set_const($db,'PHPPHENIX_SYNCRO',trim($_POST["phpphenix_syncro"]),'chaine',0); $i+=dolibarr_set_const($db,'PHPPHENIX_COMPANYCREATE',trim($_POST["phpphenix_companycreate"]),'chaine',0); @@ -206,6 +207,13 @@ print '<td>'; print ' </td>'; print "</tr>"; +print "<tr class=\"pair\">"; +print "<td>".$langs->trans("PhenixCookie")."</td>"; +print "<td><input type=\"text\" class=\"flat\" name=\"phpphenix_cookie\" value=\"". ($_POST["phpphenix_cookie"]?$_POST["phpphenix_cookie"]:$conf->global->PHPPHENIX_COOKIE) . "\" size=\"30\"></td>"; +print "<td>PXlogin"; +print "</td>"; +print "</tr>"; + print "</table>"; print "<br>"; diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php index df0a043e61dbccfd22523bb46af55ff77b43d57b..b34ae04a77e766e1ebf087c952c27578a952a3d7 100644 --- a/htdocs/conf/conf.class.php +++ b/htdocs/conf/conf.class.php @@ -291,6 +291,7 @@ class Conf $this->phenix->db->user=defined('PHPPHENIX_USER')?PHPPHENIX_USER:''; $this->phenix->db->pass=defined('PHPPHENIX_PASS')?PHPPHENIX_PASS:''; $this->phenix->db->name=defined('PHPPHENIX_DBNAME')?PHPPHENIX_DBNAME:''; + $this->phenix->cookie=defined('PHPPHENIX_COOKIE')?PHPPHENIX_COOKIE:''; // Module mantis $this->mantis->enabled=defined('MAIN_MODULE_MANTIS')?MAIN_MODULE_MANTIS:0; $this->mantis->db->type=defined('PHPMANTIS_TYPE')?PHPMANTIS_TYPE:'__dolibarr_main_db_type__'; diff --git a/htdocs/lib/lib_head.js b/htdocs/lib/lib_head.js index 7314d41179fea9cc20cd69f3a9ee68ac7a248dde..c99191e7807636a5ff0cca9c245a0a649b542b04 100644 --- a/htdocs/lib/lib_head.js +++ b/htdocs/lib/lib_head.js @@ -23,6 +23,12 @@ function barcode_coder_save(formNameID) formName.submit(); } +function formSubmit(formNameID) +{ + var formName = parent.document.frames['main'].document.getElementById(formNameID); + formName.submit(); +} + /*================================================================= Purpose: Pour la fonction de saisie auto des villes Input: postalcode,objectville diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 49782b3e03630734941c865069a18d8f3f860fb6..d410b99f8153d6b02740520df496b08a0ecd5124 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -470,6 +470,15 @@ if (! isset($_SESSION["dol_login"])) $user->update_last_login_date(); } +// Module Phenix +if ($conf->phenix->enabled && $user->phenix_login != "" && $conf->phenix->cookie) +{ + // Cr�ation du cookie permettant la connexion automatique, valide jusqu'� la fermeture du browser + if (!isset($HTTP_COOKIE_VARS[$conf->phenix->cookie])) + { + setcookie($conf->phenix->cookie, $user->phenix_login.":".$user->phenix_pass_crypted.":1", 0, "/", "", 0); + } +} // Si user admin, on force droits sur les modules base if ($user->admin) diff --git a/htdocs/user.class.php b/htdocs/user.class.php index 0f0b4de79b22112be7dffc7251f481c03cb5577e..23d99caa5acf2c1d6b0a807ced947cc1086a8962 100644 --- a/htdocs/user.class.php +++ b/htdocs/user.class.php @@ -74,6 +74,8 @@ class User var $fk_member; var $webcal_login; var $phenix_login; + var $phenix_pass; + var $phenix_pass_crypted; var $datelastlogin; var $datepreviouslogin; @@ -124,7 +126,7 @@ class User // Recupere utilisateur $sql = "SELECT u.rowid, u.name, u.firstname, u.email, u.office_phone, u.office_fax, u.user_mobile,"; - $sql.= " u.admin, u.login, u.webcal_login, u.phenix_login, u.note,"; + $sql.= " u.admin, u.login, u.webcal_login, u.phenix_login, u.phenix_pass, u.note,"; $sql.= " u.pass, u.pass_crypted, u.pass_temp,"; $sql.= " u.fk_societe, u.fk_socpeople, u.fk_member, u.ldap_sid,"; $sql.= " u.statut, u.lang,"; @@ -181,11 +183,12 @@ class User $this->datelastlogin = $obj->datel; $this->datepreviouslogin = $obj->datep; - $this->webcal_login = $obj->webcal_login; - $this->phenix_login = $obj->phenix_login; - $this->societe_id = $obj->fk_societe; - $this->contact_id = $obj->fk_socpeople; - $this->fk_member = $obj->fk_member; + $this->webcal_login = $obj->webcal_login; + $this->phenix_login = $obj->phenix_login; + $this->phenix_pass_crypted = $obj->phenix_pass; + $this->societe_id = $obj->fk_societe; + $this->contact_id = $obj->fk_socpeople; + $this->fk_member = $obj->fk_member; if (! $this->lang) $this->lang='fr_FR'; @@ -933,6 +936,10 @@ class User $this->note = addslashes(trim($this->note)); $this->webcal_login = addslashes(trim($this->webcal_login)); $this->phenix_login = addslashes(trim($this->phenix_login)); + if ($this->phenix_pass != $this->phenix_pass_crypted) + { + $this->phenix_pass = md5(trim($this->phenix_pass)); + } $this->admin = $this->admin?$this->admin:0; $this->db->begin(); @@ -949,6 +956,7 @@ class User $sql.= ", email = '".$this->email."'"; $sql.= ", webcal_login = '".$this->webcal_login."'"; $sql.= ", phenix_login = '".$this->phenix_login."'"; + $sql.= ", phenix_pass = '".$this->phenix_pass."'"; $sql.= ", note = '".$this->note."'"; $sql.= " WHERE rowid = ".$this->id; @@ -956,27 +964,26 @@ class User $resql = $this->db->query($sql); if ($resql) { - $nbrowsaffected=$this->db->affected_rows($resql); - - // Mise a jour mot de passe + $nbrowsaffected=$this->db->affected_rows($resql); + + // Mise a jour mot de passe if ($this->pass) { - if ($this->pass != $this->pass_indatabase && - $this->pass != $this->pass_indatabase_crypted) + if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) { // Si mot de passe saisi et diff�rent de celui en base - $this->password($user,$this->pass,$conf->password_encrypted); - - if (! $nbrowsaffected) $nbrowsaffected++; - } - } - - if ($nbrowsaffected) - { - if ($this->fk_member && ! $nosyncmember) - { - // This user is linked with a member, so we also update members informations - // if this is an update. + $this->password($user,$this->pass,$conf->password_encrypted); + + if (! $nbrowsaffected) $nbrowsaffected++; + } + } + + if ($nbrowsaffected) + { + if ($this->fk_member && ! $nosyncmember) + { + // This user is linked with a member, so we also update members informations + // if this is an update. $adh=new Adherent($this->db); $result=$adh->fetch($this->fk_member); diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 79167dd7ffa08940e335c81992a60f4cff11530c..56a09942d380262b90cac2267e001c568e7d959d 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -152,6 +152,7 @@ if ($_POST["action"] == 'add' && $canadduser) $edituser->email = $_POST["email"]; $edituser->webcal_login = $_POST["webcal_login"]; $edituser->phenix_login = $_POST["phenix_login"]; + $edituser->phenix_pass = $_POST["phenix_pass"]; $edituser->note = $_POST["note"]; $edituser->ldap_sid = $_POST["ldap_sid"]; @@ -244,6 +245,7 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $caneditfield) $edituser->email = $_POST["email"]; $edituser->webcal_login = $_POST["webcal_login"]; $edituser->phenix_login = $_POST["phenix_login"]; + $edituser->phenix_pass = $_POST["phenix_pass"]; $ret=$edituser->update($user); if ($ret < 0) @@ -679,6 +681,8 @@ if (($action == 'create') || ($action == 'adduserldap')) { print "<tr>".'<td valign="top">'.$langs->trans("LoginPenix").'</td>'; print '<td><input size="30" type="text" name="phenix_login" value=""></td></tr>'; + print "<tr>".'<td valign="top">'.$langs->trans("PassPenix").'</td>'; + print '<td><input size="30" type="text" name="phenix_pass" value=""></td></tr>'; } print "<tr>".'<td align="center" colspan="2"><input class="button" value="'.$langs->trans("CreateUser").'" type="submit"></td></tr>'; @@ -954,6 +958,9 @@ else print '<tr><td width="25%" valign="top">'.$langs->trans("LoginPhenix").'</td>'; print '<td colspan="2">'.$fuser->phenix_login.' </td>'; print "</tr>\n"; + print '<tr><td width="25%" valign="top">'.$langs->trans("PassPhenix").'</td>'; + print '<td colspan="2">'.eregi_replace('.','*',$fuser->phenix_pass_crypted).' </td>'; + print "</tr>\n"; } // Module Adh�rent @@ -1392,6 +1399,11 @@ else if ($caneditfield) print '<input size="30" type="text" class="flat" name="phenix_login" value="'.$fuser->phenix_login.'">'; else print $fuser->phenix_login; print '</td></tr>'; + print "<tr>".'<td valign="top">'.$langs->trans("PassPhenix").'</td>'; + print '<td colspan="2">'; + if ($caneditfield) print '<input size="30" type="password" class="flat" name="phenix_pass" value="'.$fuser->phenix_pass_crypted.'">'; + else print eregi_replace('.','*',$fuser->phenix_pass_crypted); + print '</td></tr>'; } print '<tr><td align="center" colspan="3">'; diff --git a/htdocs/user/logout.php b/htdocs/user/logout.php index 3dab82222036e13f13df8bae6b0fdbfe4c69133e..9583ba199b76332381ca2d288fc73bb521ad4ff8 100644 --- a/htdocs/user/logout.php +++ b/htdocs/user/logout.php @@ -34,6 +34,12 @@ include_once("../conf/conf.php"); require_once("../master.inc.php"); require_once(PEAR_PATH."/Auth/Auth.php"); +// Module Phenix +if ($conf->phenix->enabled && $conf->phenix->cookie) +{ + // Destruction du cookie + setcookie($conf->phenix->cookie, '', 1, "/"); +} dolibarr_syslog("End session in DOLSESSID_".$dolibarr_main_db_name); diff --git a/mysql/migration/2.1.0-2.2.0.sql b/mysql/migration/2.1.0-2.2.0.sql index 3507e18d45e4c60599310c9ae03b5b5a58a6f2d7..92f7feea09af6752320a2d53b3231e27cf7f40ab 100644 --- a/mysql/migration/2.1.0-2.2.0.sql +++ b/mysql/migration/2.1.0-2.2.0.sql @@ -931,4 +931,5 @@ INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (8, 'A5', 'Format A5', '148', '210', 'mm', 1); INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (9, 'A6', 'Format A6', '105', '148', 'mm', 1); -ALTER TABLE llx_user ADD COLUMN phenix_login varchar(25) after webcal_login; \ No newline at end of file +ALTER TABLE llx_user ADD COLUMN phenix_login varchar(25) after webcal_login; +ALTER TABLE llx_user ADD COLUMN phenix_pass varchar(128) after phenix_login; \ No newline at end of file diff --git a/mysql/tables/llx_user.sql b/mysql/tables/llx_user.sql index 56e1e27137a47f6496df7c183c72ac4123a611a0..516b04ea004006480be1986c39850c5b3065ddb7 100644 --- a/mysql/tables/llx_user.sql +++ b/mysql/tables/llx_user.sql @@ -40,6 +40,7 @@ create table llx_user admin smallint DEFAULT 0, webcal_login varchar(25), phenix_login varchar(25), + phenix_pass varchar(128), module_comm smallint DEFAULT 1, module_compta smallint DEFAULT 1, fk_societe integer,