diff --git a/ChangeLog b/ChangeLog index cb938116f56..712a87e0ec1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,16 +9,17 @@ For users: - New: Sort list of languages in combo box. - New: EMails links are show with function dol_print_email - New: Add graph report on number of entities in product statistics page. -- Fixed: Failed to go on the future view of bank transaction if there is no +- Fix: Failed to go on the future view of bank transaction if there is no future bank transaction already wrote. -- Fixed: Bad ref in supplier list. -- Fixed: Bad link in product statistics for supplier referers. +- Fix: Bad ref in supplier list. +- Fix: Bad link in product statistics for supplier referers. - Fix: Usage of reset of cursor in personalized numbering modules for a particular month (@ option) was broken. - Can add contacts to a supplier invoice. -- Fixed: When an invoice is changed back to status draft, warehouse is increased +- Fix: When an invoice is changed back to status draft, warehouse is increased back. -- Fixed: Category of a bank transaction was not saved. +- Fix: Category of a bank transaction was not saved. +- Fix: Clicktodial plugin works correctly now For translators: - Added ca_ES language files diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 7e19f1685dc..f54de5592aa 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -741,7 +741,7 @@ function dolibarr_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$s function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ=" ") { global $conf,$user,$langs; - + // Clean phone parameter $phone = ereg_replace("[ .-]","",trim($phone)); if (empty($phone)) { return ''; } @@ -770,11 +770,13 @@ function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ= $newphone=substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); } } - + if (! empty($addlink)) { if ($conf->clicktodial->enabled) { + if (empty($user->clicktodial_loaded)) $user->fetch_clicktodial(); + if (empty($conf->global->CLICKTODIAL_URL)) $urlmask='ErrorClickToDialModuleNotConfigured'; else $urlmask=$conf->global->CLICKTODIAL_URL; $url = sprintf($urlmask, urlencode($phone), urlencode($user->clicktodial_poste), urlencode($user->clicktodial_login), urlencode($user->clicktodial_password)); diff --git a/htdocs/user.class.php b/htdocs/user.class.php index 2fddf5348e0..ce054d38520 100644 --- a/htdocs/user.class.php +++ b/htdocs/user.class.php @@ -108,7 +108,7 @@ class User extends CommonObject // Preference utilisateur $this->liste_limit = 0; - $this->clicktodial_enabled = 0; + $this->clicktodial_loaded = 0; $this->all_permissions_are_loaded = 0; $this->admin=0; @@ -116,14 +116,14 @@ class User extends CommonObject return 1; } - + /* Polymorph functions not allowed in PHP - function fetch($id) - { + function fetch($id) + { $this->id=$id; - $this->fetch(); - } - */ + $this->fetch(); + } + */ /** * \brief Charge un objet user avec toutes ces caracteristiques depuis un id ou login @@ -684,7 +684,7 @@ class User extends CommonObject $sql = "SELECT login FROM ".MAIN_DB_PREFIX."user"; $sql.= " WHERE login ='".addslashes($this->login)."'"; - + dolibarr_syslog("User::Create sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -793,7 +793,7 @@ class User extends CommonObject $this->nom = $contact->nom; $this->prenom = $contact->prenom; $this->email = $contact->email; - + if (empty($login)) $login=strtolower(substr($contact->prenom, 0, 4)) . strtolower(substr($contact->nom, 0, 4)); $this->login = $login; @@ -1264,7 +1264,7 @@ class User extends CommonObject { // If user has not defined its own language, we used current language $outputlangs=$langs; } - + // \TODO Use outputlangs to translate messages if (! $changelater) { @@ -1317,41 +1317,36 @@ class User extends CommonObject /** - * \brief Lecture des infos de click to dial + * \brief Read clicktodial information for user + * \return <0 if KO, >0 if OK */ function fetch_clicktodial() { - $sql = "SELECT login, pass, poste "; $sql.= " FROM ".MAIN_DB_PREFIX."user_clicktodial as u"; $sql.= " WHERE u.fk_user = ".$this->id; - $result = $this->db->query($sql); - - if ($result) + $resql = $this->db->query($sql); + if ($resql) { - if ($this->db->num_rows()) - { - $obj = $this->db->fetch_object(); + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->clicktodial_login = $obj->login; - $this->clicktodial_password = $obj->pass; - $this->clicktodial_poste = $obj->poste; + $this->clicktodial_login = $obj->login; + $this->clicktodial_password = $obj->pass; + $this->clicktodial_poste = $obj->poste; + } - if (strlen(trim($this->clicktodial_login)) && - strlen(trim($this->clicktodial_password)) && - strlen(trim($this->clicktodial_poste))) - { - $this->clicktodial_enabled = 1; - } - - } - - $this->db->free(); + $this->clicktodial_loaded = 1; // Data loaded (found or not) + + $this->db->free($resql); + return 1; } else { - print $this->db->error(); + $this->error=$this->db->error(); + return -1; } } diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 44f80f9cd37..1abffe63176 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2008 Laurent Destailleur + * Copyright (C) 2005-2009 Laurent Destailleur * * 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 @@ -18,10 +18,10 @@ */ /** - \file htdocs/user/clicktodial.php - \brief Page for Click to dial datas - \version $Id$ -*/ + * \file htdocs/user/clicktodial.php + * \brief Page for Click to dial datas + * \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php"); @@ -93,7 +93,6 @@ if ($_GET["id"]) print "\n"; print "
\n"; - print info_admin($langs->trans("ClickToDialUrlDesc")); if ($_GET["action"] == 'edit') { @@ -104,7 +103,9 @@ if ($_GET["id"]) if ($user->admin) { print "".'ClickToDial URL'; - print ''.$conf->global->CLICKTODIAL_URL.''; + print ''; + print $form->textwithhelp($conf->global->CLICKTODIAL_URL,$langs->trans("ClickToDialUrlDesc")); + print ''; print ''; } @@ -138,7 +139,9 @@ if ($_GET["id"]) if ($user->admin) { print "".'ClickToDial URL'; - print ''.$conf->global->CLICKTODIAL_URL.''; + print ''; + print $form->textwithhelp($conf->global->CLICKTODIAL_URL,$langs->trans("ClickToDialUrlDesc")); + print ''; print ''; } print "".'ClickToDial '.$langs->trans("Login").''; diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 0e81a81095f..b7e850cf065 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -931,19 +931,19 @@ else // Tel pro print ''.$langs->trans("PhonePro").''; - print ''.$fuser->office_phone.''; + print ''.dol_print_phone($fuser->office_phone,'',0,0,1).''; // Tel mobile print ''.$langs->trans("PhoneMobile").''; - print ''.$fuser->user_mobile.''; + print ''.dol_print_phone($fuser->user_mobile,'',0,0,1).''; // Fax print ''.$langs->trans("Fax").''; - print ''.$fuser->office_fax.''; + print ''.dol_print_phone($fuser->office_fax,'',0,0,1).''; // EMail print ''.$langs->trans("EMail").''; - print ''.$fuser->email.''; + print ''.dol_print_email($fuser->email,0,0,1).''; print "\n"; // Statut