@@ -152,9 +152,9 @@ function loadFormDef($file, $module = '') {
152152 $ wb = $ app ->functions ->array_merge ($ wb_global , $ wb );
153153 }
154154 if (isset ($ wb_global )) unset($ wb_global );
155-
155+
156156 $ this ->wordbook = $ wb ;
157-
157+
158158 $ app ->plugin ->raiseEvent ($ _SESSION ['s ' ]['module ' ]['name ' ].': ' .$ app ->tform ->formDef ['name ' ] . ':on_after_formdef ' , $ this );
159159
160160 $ this ->dateformat = $ app ->lng ('conf_format_dateshort ' );
@@ -323,7 +323,7 @@ function table_auth_sql($matches){
323323 return $this->getAuthSQL('r', $matches[1]);
324324 }
325325 */
326-
326+
327327 /**
328328 * Get the key => value array of a form filled from a datasource definitiom
329329 *
@@ -339,12 +339,12 @@ function getDatasourceData($field, $record) {
339339 function applyValueLimit ($ limit , $ values , $ current_value = '' ) {
340340
341341 global $ app ;
342-
342+
343343 // we mas have multiple limits, therefore we explode by ; first
344344 // Example: "system:sites:web_php_options;client:web_php_options"
345345 $ limits = explode ('; ' ,$ limit );
346-
347-
346+
347+
348348 foreach ($ limits as $ limit ) {
349349
350350 $ limit_parts = explode (': ' , $ limit );
@@ -399,7 +399,7 @@ function applyValueLimit($limit, $values, $current_value = '') {
399399 $ tmp_key = $ limit_parts [2 ];
400400 $ allowed = $ allowed = explode (', ' ,$ tmp_conf [$ tmp_key ]);
401401 }
402-
402+
403403 // add the current value to the allowed array
404404 $ allowed [] = $ current_value ;
405405
@@ -438,7 +438,7 @@ function getHTML($record, $tab, $action = 'NEW') {
438438 $ csrf_token = $ app ->auth ->csrf_token_get ($ this ->formDef ['name ' ]);
439439 $ _csrf_id = $ csrf_token ['csrf_id ' ];
440440 $ _csrf_value = $ csrf_token ['csrf_key ' ];
441-
441+
442442 $ this ->formDef ['tabs ' ][$ tab ]['fields ' ]['_csrf_id ' ] = array (
443443 'datatype ' => 'VARCHAR ' ,
444444 'formtype ' => 'TEXT ' ,
@@ -454,7 +454,7 @@ function getHTML($record, $tab, $action = 'NEW') {
454454 $ record ['_csrf_id ' ] = $ _csrf_id ;
455455 $ record ['_csrf_key ' ] = $ _csrf_value ;
456456 /* CSRF PROTECTION */
457-
457+
458458 $ new_record = array ();
459459 if ($ action == 'EDIT ' ) {
460460 $ record = $ this ->decode ($ record , $ tab );
@@ -589,7 +589,7 @@ function getHTML($record, $tab, $action = 'NEW') {
589589
590590 $ new_record [$ key ] = $ this ->_getDateHTML ($ key , $ dt_value );
591591 break ;
592-
592+
593593 default :
594594 if (isset ($ record [$ key ])) {
595595 $ new_record [$ key ] = $ app ->functions ->htmlentities ($ record [$ key ]);
@@ -701,7 +701,7 @@ function getHTML($record, $tab, $action = 'NEW') {
701701
702702 $ new_record [$ key ] = $ this ->_getDateTimeHTML ($ key , $ dt_value , $ display_seconds );
703703 break ;
704-
704+
705705 case 'DATE ' :
706706 $ dt_value = (isset ($ field ['default ' ])) ? $ field ['default ' ] : 0 ;
707707
@@ -750,7 +750,7 @@ protected function _encode($record, $tab, $dbencode = true, $api = false) {
750750 unset($ _POST );
751751 unset($ record );
752752 }
753-
753+
754754 if (isset ($ _SESSION ['_csrf_timeout ' ]) && is_array ($ _SESSION ['_csrf_timeout ' ])) {
755755 $ to_unset = array ();
756756 foreach ($ _SESSION ['_csrf_timeout ' ] as $ _csrf_id => $ timeout ) {
@@ -767,7 +767,7 @@ protected function _encode($record, $tab, $dbencode = true, $api = false) {
767767 }
768768 /* CSRF PROTECTION */
769769 }
770-
770+
771771 $ new_record = array ();
772772 if (is_array ($ record )) {
773773 foreach ($ fields as $ key => $ field ) {
@@ -1065,6 +1065,29 @@ function validateField($field_name, $field_value, $validators) {
10651065 }
10661066 unset($ error );
10671067 break ;
1068+ case 'ISEMAILADDRESS ' :
1069+ $ error = false ;
1070+ if ($ validator ['allowempty ' ] != 'y ' ) $ validator ['allowempty ' ] = 'n ' ;
1071+ if ($ validator ['allowempty ' ] == 'y ' && $ field_value == '' ) {
1072+ //* Do nothing
1073+ } else {
1074+ if (function_exists ('filter_var ' )) {
1075+ if (filter_var ($ field_value , FILTER_VALIDATE_EMAIL ) === false ) {
1076+ $ error = true ;
1077+ }
1078+ if ($ error ) {
1079+ $ errmsg = $ validator ['errmsg ' ];
1080+ if (isset ($ this ->wordbook [$ errmsg ])) {
1081+ $ this ->errorMessage .= $ this ->wordbook [$ errmsg ]."<br /> \r\n" ;
1082+ } else {
1083+ $ this ->errorMessage .= $ errmsg ."<br /> \r\n" ;
1084+ }
1085+ }
1086+
1087+ } else $ this ->errorMessage .= "function filter_var missing <br /> \r\n" ;
1088+ }
1089+ unset($ error );
1090+ break ;
10681091 case 'ISINT ' :
10691092 if (function_exists ('filter_var ' ) && $ field_value < PHP_INT_MAX ) {
10701093 //if($field_value != '' && filter_var($field_value, FILTER_VALIDATE_INT, array("options" => array('min_range'=>0))) === false) {
@@ -1198,7 +1221,7 @@ function validateField($field_name, $field_value, $validators) {
11981221 }
11991222 }
12001223 break ;
1201-
1224+
12021225 case 'ISDATETIME ' :
12031226 /* Checks a datetime value against the date format of the current language */
12041227 if ($ validator ['allowempty ' ] != 'y ' ) $ validator ['allowempty ' ] = 'n ' ;
@@ -1216,7 +1239,7 @@ function validateField($field_name, $field_value, $validators) {
12161239 }
12171240 }
12181241 break ;
1219-
1242+
12201243 case 'RANGE ' :
12211244 //* Checks if the value is within the given range or above / below a value
12221245 //* Range examples: < 10 = ":10", between 2 and 10 = "2:10", above 5 = "5:".
@@ -1281,7 +1304,7 @@ protected function _getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $
12811304 $ sql_update = '' ;
12821305
12831306 $ record = $ this ->encode ($ record , $ tab , true );
1284-
1307+
12851308 if (($ this ->primary_id_override > 0 )) {
12861309 $ sql_insert_key .= '` ' .$ this ->formDef ["db_table_idx " ].'`, ' ;
12871310 $ sql_insert_val .= $ this ->primary_id_override .", " ;
0 commit comments