PM 940 "ProcessMaker-MA "Email Server (endpoints)"" SOLVED

> Se agregado el Frontend para el modulo Email Server.
This commit is contained in:
Luis Fernando Saisa Lopez
2014-12-24 11:40:57 -04:00
parent cbaf50203a
commit 7977410c4a
8 changed files with 1388 additions and 9 deletions

View File

@@ -341,7 +341,7 @@ function database_upgrade($command, $args) {
$arrayData["MAIL_TO"] = $emailConfiguration["MAIL_TO"];
$arrayData["MESS_DEFAULT"] = (isset($emailConfiguration["MESS_ENABLED"]) && $emailConfiguration["MESS_ENABLED"] . "" == "1")? 1 : 0;
$emailSever = new ProcessMaker\BusinessModel\EmailServer();
$emailSever = new \ProcessMaker\BusinessModel\EmailServer();
$emailSever->create($arrayData);
}

View File

@@ -968,7 +968,7 @@ class System
public function getEmailConfiguration ()
{
$emailServer = new ProcessMaker\BusinessModel\EmailServer();
$emailServer = new \ProcessMaker\BusinessModel\EmailServer();
$arrayEmailServerDefault = $emailServer->getEmailServerDefault();

View File

@@ -36,7 +36,7 @@ if ($RBAC->userCanAccess('PM_SETUP') == 1 ) {
//settings options
// $G_TMP_MENU->AddIdRawOption('LOGO', 'uplogo', G::LoadTranslation('ID_LOGO'), 'icon-pmlogo.png', '', 'settings');
$G_TMP_MENU->AddIdRawOption('LOGO', '../admin/pmLogo', G::LoadTranslation('ID_LOGO'), 'icon-pmlogo.png','', 'settings');
$G_TMP_MENU->AddIdRawOption('EMAILS','../admin/emails', G::LoadTranslation('ID_EMAIL'), 'icon-email-settings1.png', '', 'settings');
$G_TMP_MENU->AddIdRawOption("EMAILS", "../emailServer/emailServer", G::LoadTranslation("ID_EMAIL_SERVER_TITLE"), "icon-email-settings1.png", "", "settings");
$G_TMP_MENU->AddIdRawOption('CALENDAR', 'calendarList', G::LoadTranslation('ID_CALENDAR'), 'icon-calendar.png', '', 'settings' );
//if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') == 1)
// $G_TMP_MENU->AddIdRawOption('CASES_LIST_SETUP', '../cases/casesListSetup', G::LoadTranslation('ID_CASES_LIST_SETUP'), "",'', 'settings');

View 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");

View 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);

View File

@@ -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")
);
@@ -735,6 +730,26 @@ class EmailServer
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();
@@ -804,6 +819,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 +1092,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);
}

View File

@@ -0,0 +1,2 @@
<div></div>

File diff suppressed because it is too large Load Diff