Merge branch 'master' of bitbucket.org:colosa/processmaker into PM-1227
This commit is contained in:
@@ -5,21 +5,16 @@ class EmailServer
|
||||
{
|
||||
private $arrayFieldDefinition = array(
|
||||
"MESS_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "emailServerUid"),
|
||||
|
||||
"MESS_ENGINE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("PHPMAILER", "MAIL"), "fieldNameAux" => "emailServerEngine"),
|
||||
"MESS_SERVER" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "emailServerServer"),
|
||||
"MESS_PORT" => array("type" => "int", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "emailServerPort"),
|
||||
|
||||
"MESS_RAUTH" => array("type" => "int", "required" => false, "empty" => false, "defaultValues" => array(0, 1), "fieldNameAux" => "emailServerRauth"),
|
||||
|
||||
"MESS_ACCOUNT" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "emailServerUserName"),
|
||||
"MESS_PASSWORD" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "emailServerPassword"),
|
||||
"MESS_FROM_MAIL" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "emailServerFromMail"),
|
||||
"MESS_FROM_NAME" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "emailServerFromName"),
|
||||
"SMTPSECURE" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("No", "tls", "ssl"), "fieldNameAux" => "emailServerSecureConnection"),
|
||||
|
||||
"MESS_TRY_SEND_INMEDIATLY" => array("type" => "int", "required" => false, "empty" => false, "defaultValues" => array(0, 1), "fieldNameAux" => "emailServerSendTestMail"),
|
||||
|
||||
"MAIL_TO" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "emailServerMailTo"),
|
||||
"MESS_DEFAULT" => array("type" => "int", "required" => false, "empty" => false, "defaultValues" => array(0, 1), "fieldNameAux" => "emailServerDefault")
|
||||
);
|
||||
@@ -732,6 +727,80 @@ class EmailServer
|
||||
//Create
|
||||
$cnn = \Propel::getConnection("workflow");
|
||||
|
||||
try {
|
||||
$emailServer = new \EmailServer();
|
||||
|
||||
$passwd = $arrayData["MESS_PASSWORD"];
|
||||
$passwdDec = \G::decrypt($passwd, "EMAILENCRYPT");
|
||||
$auxPass = explode("hash:", $passwdDec);
|
||||
|
||||
if (count($auxPass) > 1) {
|
||||
if (count($auxPass) == 2) {
|
||||
$passwd = $auxPass[1];
|
||||
} else {
|
||||
array_shift($auxPass);
|
||||
$passwd = implode("", $auxPass);
|
||||
}
|
||||
}
|
||||
|
||||
$arrayData["MESS_PASSWORD"] = $passwd;
|
||||
|
||||
if ($arrayData["MESS_PASSWORD"] != "") {
|
||||
$arrayData["MESS_PASSWORD"] = "hash:" . $arrayData["MESS_PASSWORD"];
|
||||
$arrayData["MESS_PASSWORD"] = \G::encrypt($arrayData["MESS_PASSWORD"], "EMAILENCRYPT");
|
||||
}
|
||||
|
||||
$emailServer->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
$emailServerUid = \ProcessMaker\Util\Common::generateUID();
|
||||
|
||||
$emailServer->setMessUid($emailServerUid);
|
||||
|
||||
if ($emailServer->validate()) {
|
||||
$cnn->begin();
|
||||
|
||||
$result = $emailServer->save();
|
||||
|
||||
$cnn->commit();
|
||||
|
||||
if (isset($arrayData["MESS_DEFAULT"]) && (int)($arrayData["MESS_DEFAULT"]) == 1) {
|
||||
$this->setEmailServerDefaultByUid($emailServerUid);
|
||||
}
|
||||
|
||||
//Return
|
||||
return $this->getEmailServer($emailServerUid);
|
||||
} else {
|
||||
$msg = "";
|
||||
|
||||
foreach ($emailServer->getValidationFailures() as $validationFailure) {
|
||||
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
|
||||
}
|
||||
|
||||
throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$cnn->rollback();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Email Server by data
|
||||
*
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the new Email Server created
|
||||
*/
|
||||
public function create2(array $arrayData)
|
||||
{
|
||||
try {
|
||||
//Create
|
||||
$cnn = \Propel::getConnection("workflow");
|
||||
|
||||
try {
|
||||
$emailServer = new \EmailServer();
|
||||
|
||||
@@ -804,6 +873,27 @@ class EmailServer
|
||||
|
||||
try {
|
||||
$emailServer = \EmailServerPeer::retrieveByPK($emailServerUid);
|
||||
|
||||
$passwd = $arrayData["MESS_PASSWORD"];
|
||||
$passwdDec = \G::decrypt($passwd, "EMAILENCRYPT");
|
||||
$auxPass = explode("hash:", $passwdDec);
|
||||
|
||||
if (count($auxPass) > 1) {
|
||||
if (count($auxPass) == 2) {
|
||||
$passwd = $auxPass[1];
|
||||
} else {
|
||||
array_shift($auxPass);
|
||||
$passwd = implode("", $auxPass);
|
||||
}
|
||||
}
|
||||
|
||||
$arrayData["MESS_PASSWORD"] = $passwd;
|
||||
|
||||
if ($arrayData["MESS_PASSWORD"] != "") {
|
||||
$arrayData["MESS_PASSWORD"] = "hash:" . $arrayData["MESS_PASSWORD"];
|
||||
$arrayData["MESS_PASSWORD"] = \G::encrypt($arrayData["MESS_PASSWORD"], "EMAILENCRYPT");
|
||||
}
|
||||
|
||||
$emailServer->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
if ($emailServer->validate()) {
|
||||
@@ -1056,6 +1146,21 @@ class EmailServer
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$passwd = $row["MESS_PASSWORD"];
|
||||
$passwdDec = \G::decrypt($passwd, "EMAILENCRYPT");
|
||||
$auxPass = explode("hash:", $passwdDec);
|
||||
|
||||
if (count($auxPass) > 1) {
|
||||
if (count($auxPass) == 2) {
|
||||
$passwd = $auxPass[1];
|
||||
} else {
|
||||
array_shift($auxPass);
|
||||
$passwd = implode("", $auxPass);
|
||||
}
|
||||
}
|
||||
|
||||
$row["MESS_PASSWORD"] = $passwd;
|
||||
|
||||
$arrayEmailServer[] = $this->getEmailServerDataFromRecord($row);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user