PM 940 "ProcessMaker-MA "Email Server (endpoints)"" SOLVED
> Se agregado el Frontend para el modulo Email Server.
This commit is contained in:
22
workflow/engine/methods/emailServer/emailServer.php
Normal file
22
workflow/engine/methods/emailServer/emailServer.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
global $RBAC;
|
||||
|
||||
if ($RBAC->userCanAccess("PM_SETUP") != 1) {
|
||||
G::SendTemporalMessage("ID_USER_HAVENT_RIGHTS_PAGE", "error", "labels");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//Data
|
||||
$configuration = new Configurations();
|
||||
$arrayConfigPage = $configuration->getConfiguration("emailServerList", "pageSize", null, $_SESSION["USER_LOGGED"]);
|
||||
|
||||
$arrayConfig = array();
|
||||
$arrayConfig["pageSize"] = (isset($arrayConfigPage["pageSize"]))? $arrayConfigPage["pageSize"] : 20;
|
||||
|
||||
$headPublisher = &headPublisher::getSingleton();
|
||||
$headPublisher->addContent("emailServer/emailServer"); //Adding a HTML file
|
||||
$headPublisher->addExtJsScript("emailServer/emailServer", false); //Adding a JavaScript file
|
||||
$headPublisher->assign("CONFIG", $arrayConfig);
|
||||
|
||||
G::RenderPage("publish", "extJs");
|
||||
|
||||
205
workflow/engine/methods/emailServer/emailServerAjax.php
Normal file
205
workflow/engine/methods/emailServer/emailServerAjax.php
Normal file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
$option = (isset($_POST["option"]))? $_POST["option"] : "";
|
||||
|
||||
$response = array();
|
||||
|
||||
switch ($option) {
|
||||
case "INS":
|
||||
$arrayData = array();
|
||||
|
||||
$server = "";
|
||||
$port = "";
|
||||
$reqAuthentication = 0;
|
||||
$password = "";
|
||||
$smtpSecure = "";
|
||||
|
||||
$cboEmailEngine = $_POST["cboEmailEngine"];
|
||||
$accountFrom = (isset($_POST["accountFrom"]))? $_POST["accountFrom"] : "";
|
||||
$fromName = $_POST["fromName"];
|
||||
$fromMail = $_POST["fromMail"];
|
||||
$sendTestMail = (int)($_POST["sendTestMail"]);
|
||||
$mailTo = ($sendTestMail == 1)? $_POST["mailTo"] : "";
|
||||
$emailServerDefault = (int)($_POST["emailServerDefault"]);
|
||||
|
||||
if ($cboEmailEngine == "PHPMAILER") {
|
||||
$server = $_POST["server"];
|
||||
$port = (int)($_POST["port"]);
|
||||
$reqAuthentication = (int)($_POST["reqAuthentication"]);
|
||||
$password = ($reqAuthentication == 1)? $_POST["password"] : "";
|
||||
$smtpSecure = $_POST["smtpSecure"];
|
||||
}
|
||||
|
||||
try {
|
||||
$arrayData = array(
|
||||
"MESS_ENGINE" => $cboEmailEngine,
|
||||
"MESS_SERVER" => $server,
|
||||
"MESS_PORT" => $port,
|
||||
"MESS_RAUTH" => $reqAuthentication,
|
||||
"MESS_ACCOUNT" => $accountFrom,
|
||||
"MESS_PASSWORD" => $password,
|
||||
"MESS_FROM_MAIL" => $fromMail,
|
||||
"MESS_FROM_NAME" => $fromName,
|
||||
"SMTPSECURE" => $smtpSecure,
|
||||
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
||||
"MAIL_TO" => $mailTo,
|
||||
"MESS_DEFAULT" => $emailServerDefault
|
||||
);
|
||||
|
||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
||||
|
||||
$arrayEmailServerData = $emailSever->create($arrayData);
|
||||
|
||||
$response["status"] = "OK";
|
||||
$response["data"] = $arrayEmailServerData;
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["message"] = $e->getMessage();
|
||||
}
|
||||
break;
|
||||
case "UPD":
|
||||
$arrayData = array();
|
||||
|
||||
$emailServerUid = $_POST["emailServerUid"];
|
||||
|
||||
$server = "";
|
||||
$port = "";
|
||||
$reqAuthentication = 0;
|
||||
$password = "";
|
||||
$smtpSecure = "";
|
||||
|
||||
$cboEmailEngine = $_POST["cboEmailEngine"];
|
||||
$accountFrom = (isset($_POST["accountFrom"]))? $_POST["accountFrom"] : "";
|
||||
$fromName = $_POST["fromName"];
|
||||
$fromMail = $_POST["fromMail"];
|
||||
$sendTestMail = (int)($_POST["sendTestMail"]);
|
||||
$mailTo = ($sendTestMail == 1)? $_POST["mailTo"] : "";
|
||||
$emailServerDefault = (int)($_POST["emailServerDefault"]);
|
||||
|
||||
if ($cboEmailEngine == "PHPMAILER") {
|
||||
$server = $_POST["server"];
|
||||
$port = (int)($_POST["port"]);
|
||||
$reqAuthentication = (int)($_POST["reqAuthentication"]);
|
||||
$password = ($reqAuthentication == 1)? $_POST["password"] : "";
|
||||
$smtpSecure = $_POST["smtpSecure"];
|
||||
}
|
||||
|
||||
try {
|
||||
$arrayData = array(
|
||||
"MESS_ENGINE" => $cboEmailEngine,
|
||||
"MESS_SERVER" => $server,
|
||||
"MESS_PORT" => $port,
|
||||
"MESS_RAUTH" => $reqAuthentication,
|
||||
"MESS_ACCOUNT" => $accountFrom,
|
||||
"MESS_PASSWORD" => $password,
|
||||
"MESS_FROM_MAIL" => $fromMail,
|
||||
"MESS_FROM_NAME" => $fromName,
|
||||
"SMTPSECURE" => $smtpSecure,
|
||||
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
||||
"MAIL_TO" => $mailTo,
|
||||
"MESS_DEFAULT" => $emailServerDefault
|
||||
);
|
||||
|
||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
||||
|
||||
$arrayEmailServerData = $emailSever->update($emailServerUid, $arrayData);
|
||||
|
||||
$response["status"] = "OK";
|
||||
$response["data"] = $arrayEmailServerData;
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["message"] = $e->getMessage();
|
||||
}
|
||||
|
||||
break;
|
||||
case "DEL":
|
||||
$emailServerUid = $_POST["emailServerUid"];
|
||||
|
||||
try {
|
||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
||||
|
||||
$result = $emailSever->delete($emailServerUid);
|
||||
|
||||
$response["status"] = "OK";
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["message"] = $e->getMessage();
|
||||
}
|
||||
break;
|
||||
case "LST":
|
||||
$pageSize = $_POST["pageSize"];
|
||||
$search = $_POST["search"];
|
||||
|
||||
$sortField = (isset($_POST["sort"]))? $_POST["sort"]: "";
|
||||
$sortDir = (isset($_POST["dir"]))? $_POST["dir"]: "";
|
||||
$start = (isset($_POST["start"]))? $_POST["start"]: 0;
|
||||
$limit = (isset($_POST["limit"]))? $_POST["limit"]: $pageSize;
|
||||
|
||||
try {
|
||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
||||
|
||||
$result = $emailSever->getEmailServers(array("filter" => $search), $sortField, $sortDir, $start, $limit);
|
||||
|
||||
$response["status"] = "OK";
|
||||
$response["success"] = true;
|
||||
$response["resultTotal"] = $result["total"];
|
||||
$response["resultRoot"] = $result["data"];
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["message"] = $e->getMessage();
|
||||
}
|
||||
break;
|
||||
case "TEST":
|
||||
$arrayData = array();
|
||||
|
||||
$server = "";
|
||||
$port = "";
|
||||
$reqAuthentication = 0;
|
||||
$password = "";
|
||||
$smtpSecure = "";
|
||||
|
||||
$cboEmailEngine = $_POST["cboEmailEngine"];
|
||||
$accountFrom = (isset($_POST["accountFrom"]))? $_POST["accountFrom"] : "";
|
||||
$fromName = $_POST["fromName"];
|
||||
$fromMail = $_POST["fromMail"];
|
||||
$sendTestMail = (int)($_POST["sendTestMail"]);
|
||||
$mailTo = ($sendTestMail == 1)? $_POST["mailTo"] : "";
|
||||
$emailServerDefault = (int)($_POST["emailServerDefault"]);
|
||||
|
||||
if ($cboEmailEngine == "PHPMAILER") {
|
||||
$server = $_POST["server"];
|
||||
$port = (int)($_POST["port"]);
|
||||
$reqAuthentication = (int)($_POST["reqAuthentication"]);
|
||||
$password = ($reqAuthentication == 1)? $_POST["password"] : "";
|
||||
$smtpSecure = $_POST["smtpSecure"];
|
||||
}
|
||||
|
||||
try {
|
||||
$arrayData = array(
|
||||
"MESS_ENGINE" => $cboEmailEngine,
|
||||
"MESS_SERVER" => $server,
|
||||
"MESS_PORT" => $port,
|
||||
"MESS_RAUTH" => $reqAuthentication,
|
||||
"MESS_ACCOUNT" => $accountFrom,
|
||||
"MESS_PASSWORD" => $password,
|
||||
"MESS_FROM_MAIL" => $fromMail,
|
||||
"MESS_FROM_NAME" => $fromName,
|
||||
"SMTPSECURE" => $smtpSecure,
|
||||
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
||||
"MAIL_TO" => $mailTo,
|
||||
"MESS_DEFAULT" => $emailServerDefault
|
||||
);
|
||||
|
||||
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
|
||||
|
||||
$arrayEmailServerData = $emailSever->testConnection($arrayData);
|
||||
|
||||
$response["data"] = $arrayEmailServerData;
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["message"] = $e->getMessage();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
echo G::json_encode($response);
|
||||
|
||||
Reference in New Issue
Block a user