mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-04 08:02:22 +01:00
New: Enhance log reports
New: Add a warning if email syntaxt is not valid Fix: Synchro of contact to a LDAP
This commit is contained in:
@@ -393,6 +393,7 @@ if ($user->rights->societe->contact->creer)
|
|||||||
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.$contact->phone_mobile.'"></td>';
|
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.$contact->phone_mobile.'"></td>';
|
||||||
print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80" value="'.$contact->fax.'"></td></tr>';
|
print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80" value="'.$contact->fax.'"></td></tr>';
|
||||||
|
|
||||||
|
// EMail
|
||||||
print '<tr><td>'.$langs->trans("EMail").'</td><td><input name="email" type="text" size="40" maxlength="80" value="'.$contact->email.'"></td>';
|
print '<tr><td>'.$langs->trans("EMail").'</td><td><input name="email" type="text" size="40" maxlength="80" value="'.$contact->email.'"></td>';
|
||||||
if ($conf->mailing->enabled)
|
if ($conf->mailing->enabled)
|
||||||
{
|
{
|
||||||
@@ -547,6 +548,7 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
|
|||||||
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td>'.dol_print_phone($contact->phone_mobile,$contact->pays_code,$contact->id,$contact->socid,'AC_TEL').'</td>';
|
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td>'.dol_print_phone($contact->phone_mobile,$contact->pays_code,$contact->id,$contact->socid,'AC_TEL').'</td>';
|
||||||
print '<td>'.$langs->trans("Fax").'</td><td>'.dol_print_phone($contact->fax,$contact->pays_code,$contact->id,$contact->socid,'AC_FAX').'</td></tr>';
|
print '<td>'.$langs->trans("Fax").'</td><td>'.dol_print_phone($contact->fax,$contact->pays_code,$contact->id,$contact->socid,'AC_FAX').'</td></tr>';
|
||||||
|
|
||||||
|
// Email
|
||||||
print '<tr><td>'.$langs->trans("EMail").'</td><td>'.dol_print_email($contact->email,$contact->id,$contact->socid,'AC_EMAIL').'</td>';
|
print '<tr><td>'.$langs->trans("EMail").'</td><td>'.dol_print_email($contact->email,$contact->id,$contact->socid,'AC_EMAIL').'</td>';
|
||||||
if ($conf->mailing->enabled)
|
if ($conf->mailing->enabled)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -206,8 +206,12 @@ function dol_syslog($message, $level=LOG_INFO)
|
|||||||
if ($message != $langs->trans($message)) $message = $langs->trans($message);
|
if ($message != $langs->trans($message)) $message = $langs->trans($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add page/script name to log message
|
||||||
|
$script=isset($_SERVER['PHP_SELF'])?basename($_SERVER['PHP_SELF'],'.php').' ':'';
|
||||||
|
$message=$script.$message;
|
||||||
|
|
||||||
// Add user to log message
|
// Add user to log message
|
||||||
$login='???';
|
$login=isset($_SERVER['USERNAME'])?$_SERVER['USERNAME']:'nologin';
|
||||||
if (is_object($user) && $user->id) $login=$user->login;
|
if (is_object($user) && $user->id) $login=$user->login;
|
||||||
$message=sprintf("%-8s",$login)." ".$message;
|
$message=sprintf("%-8s",$login)." ".$message;
|
||||||
|
|
||||||
@@ -221,15 +225,14 @@ function dol_syslog($message, $level=LOG_INFO)
|
|||||||
|
|
||||||
if ($file)
|
if ($file)
|
||||||
{
|
{
|
||||||
|
$ip=$_SERVER['COMPUTERNAME'];
|
||||||
$ip='unknown_ip';
|
|
||||||
if (! empty($_SERVER["REMOTE_ADDR"])) $ip=$_SERVER["REMOTE_ADDR"];
|
if (! empty($_SERVER["REMOTE_ADDR"])) $ip=$_SERVER["REMOTE_ADDR"];
|
||||||
|
|
||||||
$liblevelarray=array(LOG_ERR=>'ERROR',LOG_WARNING=>'WARN',LOG_INFO=>'INFO',LOG_DEBUG=>'DEBUG');
|
$liblevelarray=array(LOG_ERR=>'ERROR',LOG_WARNING=>'WARN',LOG_INFO=>'INFO',LOG_DEBUG=>'DEBUG');
|
||||||
$liblevel=$liblevelarray[$level];
|
$liblevel=$liblevelarray[$level];
|
||||||
if (! $liblevel) $liblevel='UNDEF';
|
if (! $liblevel) $liblevel='UNDEF';
|
||||||
|
|
||||||
$message=strftime("%Y-%m-%d %H:%M:%S",time())." ".sprintf("%-5s",$liblevel)." ".$ip." ".$message;
|
$message=strftime("%Y-%m-%d %H:%M:%S",time())." ".sprintf("%-5s",$liblevel)." ".sprintf("%-15s",$ip)." ".$message;
|
||||||
|
|
||||||
fwrite($file,$message."\n");
|
fwrite($file,$message."\n");
|
||||||
fclose($file);
|
fclose($file);
|
||||||
@@ -692,14 +695,14 @@ function dol_print_url($url,$target='_blank',$max=32)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Show EMail link
|
* \brief Show EMail link
|
||||||
* \param email EMail to show
|
* \param email EMail to show (only email without <Name of recipient>)
|
||||||
* \param cid Id of contact if known
|
* \param cid Id of contact if known
|
||||||
* \param socid Id of third party if known
|
* \param socid Id of third party if known
|
||||||
* \param addlink 0=no link to create action
|
* \param addlink 0=no link to create action
|
||||||
* \param max Max number of characters to show
|
* \param max Max number of characters to show
|
||||||
* \return string HTML Link
|
* \return string HTML Link
|
||||||
*/
|
*/
|
||||||
function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64)
|
function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64,$showinvalid=1)
|
||||||
{
|
{
|
||||||
global $conf,$user,$langs;
|
global $conf,$user,$langs;
|
||||||
|
|
||||||
@@ -715,6 +718,7 @@ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64)
|
|||||||
$newemail.='">';
|
$newemail.='">';
|
||||||
$newemail.=dol_trunc($email,$max);
|
$newemail.=dol_trunc($email,$max);
|
||||||
$newemail.='</a>';
|
$newemail.='</a>';
|
||||||
|
if ($showinvalid && ! isValidEmail($email)) $newemail.=img_warning($langs->trans("ErrorBadEMail",$email));
|
||||||
|
|
||||||
if (($cid || $socid) && $conf->agenda->enabled && $user->rights->agenda->myactions->create)
|
if (($cid || $socid) && $conf->agenda->enabled && $user->rights->agenda->myactions->create)
|
||||||
{
|
{
|
||||||
@@ -801,6 +805,28 @@ function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ=
|
|||||||
return $newphone;
|
return $newphone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Return true if email syntax is ok
|
||||||
|
* \param address email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
|
||||||
|
* \return boolean true if email syntax is OK, false if KO
|
||||||
|
*/
|
||||||
|
function isValidEmail($address)
|
||||||
|
{
|
||||||
|
if (eregi(".*<(.+)>", $address, $regs)) {
|
||||||
|
$address = $regs[1];
|
||||||
|
}
|
||||||
|
// 2 letters domains extensions are for countries
|
||||||
|
// 3 letters domains extensions: biz|com|edu|gov|int|mil|net|org|pro|...
|
||||||
|
if (eregi("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2,3}|asso|aero|coop|info|name)\$",$address))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a strlen call. Works even in mbstring module not enabled
|
* Make a strlen call. Works even in mbstring module not enabled
|
||||||
|
|||||||
@@ -203,27 +203,6 @@ function dol_print_object_info($object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Return true if email syntax is ok
|
|
||||||
* \param address email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
|
|
||||||
* \return boolean true if email syntax is OK, false if KO
|
|
||||||
*/
|
|
||||||
function isValidEmail($address)
|
|
||||||
{
|
|
||||||
if (eregi(".*<(.+)>", $address, $regs)) {
|
|
||||||
$address = $regs[1];
|
|
||||||
}
|
|
||||||
// 3 letters domains extensions: biz|com|edu|gov|int|mil|net|org|pro
|
|
||||||
if (eregi("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2,3}|asso|aero|coop|info|name)\$",$address))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return true if email has a domain name that can't be resolved
|
* \brief Return true if email has a domain name that can't be resolved
|
||||||
* \param mail adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
|
* \param mail adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ $path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
|
|||||||
require_once($path."../../htdocs/master.inc.php");
|
require_once($path."../../htdocs/master.inc.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/user.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/user.class.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php");
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user