Merged in qronald/processmaker/HOR-311 (pull request #3769)

HOR-311
This commit is contained in:
Julio Cesar Laura Avendaño
2016-03-01 19:09:13 -04:00

View File

@@ -3080,64 +3080,6 @@ function PMFDynaFormFields($dynUid, $appUid = false, $delIndex = 0)
return $fields;
}
/**
* @method
* This function determines if the domain of the passed email addres is hosted in
* a gmail server.
* This function test just the domain, so there isn't any validation related to the
* email address existence or validity.
* @param string | $email | emailAddress that will be examined to determine if it is hosted in Gmail
* @return boolean | $result | true if the emailAddress domain is hosted in gmail, false otherwise
* */
function isEmailAddressHostedInGmail($email) {
$g = new G();
if ($g->emailAddress($email) === false) {
throw new Exception ('the passed email address is not valid.');
}
$result = FALSE;
//the accepted domains for a gemail server are:
$gmailDomainsRegExp = "/gmail\.com|googlemail\.com/";
if (preg_match($gmailDomainsRegExp, $email) == 1) {
$result = TRUE;
} else {
$domainName = preg_split('/@/', $email)[1];
foreach(getNamedServerMXRecord($domainName) as $emailServer) {
if (preg_match($gmailDomainsRegExp, $emailServer) == 1) {
$result = TRUE;
}
}
}
return $result;
}
/**
* @method
* Returns an array with the Mail Exchanger info of a Named Domain
* a gmail server.
* This function test just the domain, so there isn't any validation related to the
* email address existence or validity.
* @param string | $domainName | Domain Name e.g. processmaker.com
* @return array | $result | array
* */
function getNamedServerMXRecord($domainName) {
//in some windows distributions getmxxr does not exist, so if this happens, a wrapper function
//is created.
if (!function_exists('getmxrr')) {
function getmxrr($hostname, &$mxhosts, &$mxweight=false) {
return win_getmxrr($hostname, $mxhosts, $mxweight);
}
}
$mailExchangerHosts = array();
getmxrr($domainName, $mailExchangerHosts);
return $mailExchangerHosts;
}
/**
* @method
* Return the task title of the specified task uid | If not found returns false