Quellcode durchsuchen

#871: eMail validation pattern was too strict: now fully configurable (globally and per attribute).

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3056 a333f486-631f-4898-b8df-5754b55c2be0
dflaven vor 11 Jahren
Ursprung
Commit
d0abc080d7
2 geänderte Dateien mit 9 neuen und 2 gelöschten Zeilen
  1. 1 2
      core/attributedef.class.inc.php
  2. 8 0
      core/config.class.inc.php

+ 1 - 2
core/attributedef.class.inc.php

@@ -2106,8 +2106,7 @@ class AttributeEmailAddress extends AttributeString
 {
 	public function GetValidationPattern()
 	{
-		// return "^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$";
-		return "^[a-zA-Z0-9._&-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]{2,}$";
+		return $this->GetOptional('validation_pattern', '^'.utils::GetConfig()->Get('email_validation_pattern').'$');
 	}
 
 	public function GetAsHTML($sValue, $oHostObject = null, $bLocalize = true)

+ 8 - 0
core/config.class.inc.php

@@ -640,6 +640,14 @@ class Config
 			'source_of_value' => '',
 			'show_in_conf_sample' => true,
 		),
+		'email_validation_pattern' => array(
+			'type' => 'string',
+			'description' => 'Regular expression to validate/detect the format of an eMail address',
+			'default' => "[a-zA-Z0-9._&'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]{2,}",
+			'value' => '',
+			'source_of_value' => '',
+			'show_in_conf_sample' => true,
+		),
 		'log_kpi_duration' => array(
 			'type' => 'integer',
 			'description' => 'Level of logging for troubleshooting performance issues (1 to enable, 2 +blame callers)',