Merged feature/HOR-3559 into bugfix/HOR-3639-T

This commit is contained in:
Paula Quispe
2017-08-10 14:25:35 -04:00
60 changed files with 1601 additions and 1200 deletions

View File

@@ -1,9 +1,9 @@
<?php
namespace ProcessMaker\BusinessModel;
use \G;
use \DbSource;
use \dbConnections;
use G;
use DbSource;
use DbConnections;
class DataBaseConnection
{
@@ -61,7 +61,7 @@ class DataBaseConnection
$dbs_uid = $this->validateDbsUid($dbs_uid, $pro_uid);
}
$dbs = new dbConnections($pro_uid);
$dbs = new DbConnections($pro_uid);
$oDBConnection = new DbSource();
$aFields = $oDBConnection->load($dbs_uid, $pro_uid);
if ($aFields['DBS_PORT'] == '0') {
@@ -162,7 +162,7 @@ class DataBaseConnection
if (isset($dataDBConnection['DBS_ENCODE'])) {
$encodesExists = array();
$dbs = new dbConnections();
$dbs = new DbConnections();
$dbEncodes = $dbs->getEncondeList($dataDBConnection['DBS_TYPE']);
foreach ($dbEncodes as $value) {
$encodesExists[] = $value['0'];
@@ -423,7 +423,7 @@ class DataBaseConnection
*/
public function getDbEngines ()
{
$dbs = new dbConnections();
$dbs = new DbConnections();
$dbServices = $dbs->getDbServicesAvailables();
return $dbServices;
}

View File

@@ -1,5 +1,6 @@
<?php
namespace ProcessMaker\BusinessModel;
use DynaformHandler;
class DynaForm
{
@@ -155,7 +156,7 @@ class DynaForm
while ($oDataset->next()) {
$dataForms = $oDataset->getRow();
$dynHandler = new \dynaFormHandler(PATH_DYNAFORM . $proUid . PATH_SEP . $dataForms["DYN_UID"] . ".xml");
$dynHandler = new DynaformHandler(PATH_DYNAFORM . $proUid . PATH_SEP . $dataForms["DYN_UID"] . ".xml");
$dynFields = $dynHandler->getFields();
foreach ($dynFields as $field) {
$sType = \Step::getAttribute( $field, 'type' );

View File

@@ -1,5 +1,8 @@
<?php
namespace ProcessMaker\BusinessModel;
use \G;
use \Exception;
use \Bootstrap;
class EmailServer
{
@@ -19,6 +22,8 @@ class EmailServer
"MESS_DEFAULT" => array("type" => "int", "required" => false, "empty" => false, "defaultValues" => array(0, 1), "fieldNameAux" => "emailServerDefault")
);
private $contextLog = array();
private $formatFieldNameInUppercase = true;
private $arrayFieldNameForException = array(
@@ -37,17 +42,51 @@ class EmailServer
foreach ($this->arrayFieldDefinition as $key => $value) {
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
}
} catch (\Exception $e) {
//Define the variables for the logging
global $RBAC;
$currentUser = $RBAC->aUserInfo['USER_INFO'];
$info = array(
'ip' => G::getIpAddress(),
'workspace' => (defined("SYS_SYS"))? SYS_SYS : "Workspace undefined",
'usrUid' => $currentUser['USR_UID']
);
$this->setContextLog($info);
} catch (Exception $e) {
throw $e;
}
}
/**
* Get the $contextLog value.
*
* @return string
*/
public function getContextLog()
{
return $this->contextLog;
}
/**
* Set the value of $contextLog.
*
* @param array $k
* @return void
*/
public function setContextLog($k)
{
$this->contextLog = array_merge($this->contextLog, $k);
}
/**
* Set the format of the fields name (uppercase, lowercase)
*
* @param bool $flag Value that set the format
*
* return void
* @return void
* @throws Exception
*/
public function setFormatFieldNameInUppercase($flag)
{
@@ -55,7 +94,7 @@ class EmailServer
$this->formatFieldNameInUppercase = $flag;
$this->setArrayFieldNameForException($this->arrayFieldNameForException);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -65,7 +104,8 @@ class EmailServer
*
* @param array $arrayData Data with the fields
*
* return void
* @return void
* @throws Exception
*/
public function setArrayFieldNameForException(array $arrayData)
{
@@ -73,7 +113,7 @@ class EmailServer
foreach ($arrayData as $key => $value) {
$this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value);
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -83,13 +123,14 @@ class EmailServer
*
* @param string $fieldName Field name
*
* return string Return the field name according the format
* @return string, return the field name according the format
* @throws Exception
*/
public function getFieldNameByFormatFieldName($fieldName)
{
try {
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -99,7 +140,8 @@ class EmailServer
*
* @param array $arrayData Data
*
* return array Return array with result of send test mail
* @return array, return array with result of send test mail
* @throws Exception
*/
public function sendTestMail(array $arrayData)
{
@@ -117,20 +159,20 @@ class EmailServer
"SMTPSecure" => (isset($arrayData["SMTPSecure"]))? $arrayData["SMTPSecure"] : "none"
);
$sFrom = \G::buildFrom($aConfiguration);
$sFrom = G::buildFrom($aConfiguration);
$sSubject = \G::LoadTranslation("ID_MESS_TEST_SUBJECT");
$msg = \G::LoadTranslation("ID_MESS_TEST_BODY");
$sSubject = G::LoadTranslation("ID_MESS_TEST_SUBJECT");
$msg = G::LoadTranslation("ID_MESS_TEST_BODY");
switch ($arrayData["MESS_ENGINE"]) {
case "MAIL":
$engine = \G::LoadTranslation("ID_MESS_ENGINE_TYPE_1");
$engine = G::LoadTranslation("ID_MESS_ENGINE_TYPE_1");
break;
case "PHPMAILER":
$engine = \G::LoadTranslation("ID_MESS_ENGINE_TYPE_2");
$engine = G::LoadTranslation("ID_MESS_ENGINE_TYPE_2");
break;
case "OPENMAIL":
$engine = \G::LoadTranslation("ID_MESS_ENGINE_TYPE_3");
$engine = G::LoadTranslation("ID_MESS_ENGINE_TYPE_3");
break;
}
@@ -175,7 +217,7 @@ class EmailServer
if ($oSpool->status == "sent") {
$arrayTestMailResult["status"] = true;
$arrayTestMailResult["success"] = true;
$arrayTestMailResult["msg"] = \G::LoadTranslation("ID_MAIL_TEST_SUCCESS");
$arrayTestMailResult["msg"] = G::LoadTranslation("ID_MAIL_TEST_SUCCESS");
} else {
$arrayTestMailResult["status"] = false;
$arrayTestMailResult["success"] = false;
@@ -183,7 +225,7 @@ class EmailServer
}
return $arrayTestMailResult;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -194,7 +236,8 @@ class EmailServer
* @param array $arrayData Data
* @param int $step Step
*
* return array Return array with result of test connection by step
* @return array, return array with result of test connection by step
* @throws Exception
*/
public function testConnectionByStep(array $arrayData, $step = 0)
{
@@ -208,7 +251,7 @@ class EmailServer
$eregMail = "/^[0-9a-zA-Z]+(?:[._][0-9a-zA-Z]+)*@[0-9a-zA-Z]+(?:[._-][0-9a-zA-Z]+)*\.[0-9a-zA-Z]{2,3}$/";
$arrayDataMail["FROM_EMAIL"] = ($arrayData["MESS_FROM_MAIL"] != "" && preg_match($eregMail, $arrayData["MESS_FROM_MAIL"]))? $arrayData["MESS_FROM_MAIL"] : "";
$arrayDataMail["FROM_NAME"] = ($arrayData["MESS_FROM_NAME"] != "")? $arrayData["MESS_FROM_NAME"] : \G::LoadTranslation("ID_MESS_TEST_BODY");
$arrayDataMail["FROM_NAME"] = ($arrayData["MESS_FROM_NAME"] != "")? $arrayData["MESS_FROM_NAME"] : G::LoadTranslation("ID_MESS_TEST_BODY");
$arrayDataMail["MESS_ENGINE"] = "MAIL";
$arrayDataMail["MESS_SERVER"] = "localhost";
$arrayDataMail["MESS_PORT"] = 25;
@@ -233,7 +276,7 @@ class EmailServer
);
if ($arrayTestMailResult["status"] == false) {
$arrayResult["message"] = \G::LoadTranslation("ID_SENDMAIL_NOT_INSTALLED");
$arrayResult["message"] = G::LoadTranslation("ID_SENDMAIL_NOT_INSTALLED");
}
//Return
@@ -252,7 +295,7 @@ class EmailServer
$passwdHide = "";
}
$passwdDec = \G::decrypt($passwd,"EMAILENCRYPT");
$passwdDec = G::decrypt($passwd,"EMAILENCRYPT");
$auxPass = explode("hash:", $passwdDec);
if (count($auxPass) > 1) {
@@ -378,7 +421,7 @@ class EmailServer
$eregMail = "/^[0-9a-zA-Z]+(?:[._][0-9a-zA-Z]+)*@[0-9a-zA-Z]+(?:[._-][0-9a-zA-Z]+)*\.[0-9a-zA-Z]{2,3}$/";
$arrayDataPhpMailer["FROM_EMAIL"] = ($fromMail != "" && preg_match($eregMail, $fromMail))? $fromMail : "";
$arrayDataPhpMailer["FROM_NAME"] = $arrayData["MESS_FROM_NAME"] != "" ? $arrayData["MESS_FROM_NAME"] : \G::LoadTranslation("ID_MESS_TEST_BODY");
$arrayDataPhpMailer["FROM_NAME"] = $arrayData["MESS_FROM_NAME"] != "" ? $arrayData["MESS_FROM_NAME"] : G::LoadTranslation("ID_MESS_TEST_BODY");
$arrayDataPhpMailer["MESS_ENGINE"] = "PHPMAILER";
$arrayDataPhpMailer["MESS_SERVER"] = $server;
$arrayDataPhpMailer["MESS_PORT"] = $port;
@@ -421,7 +464,7 @@ class EmailServer
//Return
return $arrayResult;
} catch (\Exception $e) {
} catch (Exception $e) {
$arrayResult = array();
$arrayResult["result"] = false;
@@ -437,7 +480,8 @@ class EmailServer
*
* @param array $arrayData Data
*
* return array Return array with result of test connection
* @return array, return array with result of test connection
* @throws Exception
*/
public function testConnection(array $arrayData)
{
@@ -467,11 +511,11 @@ class EmailServer
$arrayDataAux["MAIL_TO"] = "admin@processmaker.com";
$arrayResult[$arrayMailTestName[1]] = $this->testConnectionByStep($arrayDataAux);
$arrayResult[$arrayMailTestName[1]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_VERIFYING_MAIL");
$arrayResult[$arrayMailTestName[1]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_VERIFYING_MAIL");
if ((int)($arrayData["MESS_TRY_SEND_INMEDIATLY"]) == 1 && $arrayData['MAIL_TO'] != '') {
$arrayResult[$arrayMailTestName[2]] = $this->testConnectionByStep($arrayData);
$arrayResult[$arrayMailTestName[2]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_SENDING_EMAIL", array($arrayData["MAIL_TO"]));
$arrayResult[$arrayMailTestName[2]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_SENDING_EMAIL", array($arrayData["MAIL_TO"]));
}
break;
case "PHPMAILER":
@@ -482,19 +526,19 @@ class EmailServer
switch ($step) {
case 1:
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_RESOLVING_NAME", array($arrayData["MESS_SERVER"]));
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_RESOLVING_NAME", array($arrayData["MESS_SERVER"]));
break;
case 2:
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_CHECK_PORT", array($arrayData["MESS_PORT"]));
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_CHECK_PORT", array($arrayData["MESS_PORT"]));
break;
case 3:
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_ESTABLISHING_CON_HOST", array($arrayData["MESS_SERVER"] . ":" . $arrayData["MESS_PORT"]));
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_ESTABLISHING_CON_HOST", array($arrayData["MESS_SERVER"] . ":" . $arrayData["MESS_PORT"]));
break;
case 4:
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_LOGIN", array($arrayData["MESS_ACCOUNT"], $arrayData["MESS_SERVER"]));
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_LOGIN", array($arrayData["MESS_ACCOUNT"], $arrayData["MESS_SERVER"]));
break;
case 5:
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_SENDING_EMAIL", array($arrayData["MAIL_TO"]));
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_SENDING_EMAIL", array($arrayData["MAIL_TO"]));
break;
}
}
@@ -503,7 +547,7 @@ class EmailServer
//Result
return $arrayResult;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -513,7 +557,8 @@ class EmailServer
*
* @param string $emailServerUid Unique id of Email Server
*
* return bool Return true if is default Email Server, false otherwise
* @return bool, return true if is default Email Server, false otherwise
* @throws Exception
*/
public function checkIfIsDefault($emailServerUid)
{
@@ -530,7 +575,7 @@ class EmailServer
} else {
return false;
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -541,7 +586,8 @@ class EmailServer
* @param string $emailServerUid Unique id of Email Server
* @param array $arrayData Data
*
* return void Throw exception if data has an invalid value
* @return void Throw exception if data has an invalid value
* @throws Exception
*/
public function throwExceptionIfDataIsInvalid($emailServerUid, array $arrayData)
{
@@ -609,10 +655,10 @@ class EmailServer
}
if ($msg != "") {
throw new \Exception($msg);
throw new Exception($msg);
}
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -623,7 +669,8 @@ class EmailServer
* @param string $emailServerUid Unique id of Email Server
* @param string $fieldNameForException Field name for the exception
*
* return void Throw exception if does not exist the Email Server in table EMAIL_SERVER
* @return void Throw exception if does not exist the Email Server in table EMAIL_SERVER
* @throws Exception
*/
public function throwExceptionIfNotExistsEmailServer($emailServerUid, $fieldNameForException)
{
@@ -631,9 +678,9 @@ class EmailServer
$obj = \EmailServerPeer::retrieveByPK($emailServerUid);
if (is_null($obj)) {
throw new \Exception(\G::LoadTranslation("ID_EMAIL_SERVER_DOES_NOT_EXIST", array($fieldNameForException, $emailServerUid)));
throw new Exception(G::LoadTranslation("ID_EMAIL_SERVER_DOES_NOT_EXIST", array($fieldNameForException, $emailServerUid)));
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -644,15 +691,16 @@ class EmailServer
* @param string $emailServerUid Unique id of Email Server
* @param string $fieldNameForException Field name for the exception
*
* return void Throw exception if is default Email Server
* @return void Throw exception if is default Email Server
* @throws Exception
*/
public function throwExceptionIfIsDefault($emailServerUid, $fieldNameForException)
{
try {
if ($this->checkIfIsDefault($emailServerUid)) {
throw new \Exception(\G::LoadTranslation("ID_EMAIL_SERVER_IS_DEFAULT", array($fieldNameForException, $emailServerUid)));
throw new Exception(G::LoadTranslation("ID_EMAIL_SERVER_IS_DEFAULT", array($fieldNameForException, $emailServerUid)));
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -662,7 +710,8 @@ class EmailServer
*
* @param string $emailServerUid Unique id of Email Server
*
* return void
* @return void
* @throws Exception
*/
public function setEmailServerDefaultByUid($emailServerUid)
{
@@ -703,7 +752,8 @@ class EmailServer
*
* @param array $arrayData Data
*
* return array Return data of the new Email Server created
* @return array, data of the new Email Server created
* @throws Exception
*/
public function create(array $arrayData)
{
@@ -729,7 +779,7 @@ class EmailServer
$emailServer = new \EmailServer();
$passwd = $arrayData["MESS_PASSWORD"];
$passwdDec = \G::decrypt($passwd, "EMAILENCRYPT");
$passwdDec = G::decrypt($passwd, "EMAILENCRYPT");
$auxPass = explode("hash:", $passwdDec);
if (count($auxPass) > 1) {
@@ -745,7 +795,7 @@ class EmailServer
if ($arrayData["MESS_PASSWORD"] != "") {
$arrayData["MESS_PASSWORD"] = "hash:" . $arrayData["MESS_PASSWORD"];
$arrayData["MESS_PASSWORD"] = \G::encrypt($arrayData["MESS_PASSWORD"], "EMAILENCRYPT");
$arrayData["MESS_PASSWORD"] = G::encrypt($arrayData["MESS_PASSWORD"], "EMAILENCRYPT");
}
$emailServer->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
@@ -765,7 +815,28 @@ class EmailServer
$this->setEmailServerDefaultByUid($emailServerUid);
}
//Return
//Logging the create action
$info = array(
'action' => 'Create email server',
'messUid'=> $emailServerUid,
'engine'=> $arrayData["MESS_ENGINE"],
'server' => $arrayData["MESS_SERVER"],
'port' => $arrayData["MESS_PORT"],
'requireAuthentication' => $arrayData["MESS_RAUTH"],
'account' => $arrayData["MESS_ACCOUNT"],
'senderEmail' => $arrayData["MESS_FROM_MAIL"],
'senderName' => $arrayData["MESS_FROM_NAME"],
'useSecureConnection' => $arrayData["SMTPSECURE"],
'sendTestEmail' => $arrayData["MESS_TRY_SEND_INMEDIATLY"],
'setAsDefaultConfiguration' => $arrayData["MESS_DEFAULT"]
);
$this->setContextLog($info);
$this->syslog(
'CreateEmailServer',
200,
'New email server was created',
$this->getContextLog()
);
return $this->getEmailServer($emailServerUid);
} else {
$msg = "";
@@ -774,14 +845,14 @@ class EmailServer
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
}
throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
}
} catch (\Exception $e) {
} catch (Exception $e) {
$cnn->rollback();
throw $e;
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -791,7 +862,8 @@ class EmailServer
*
* @param array $arrayData Data
*
* return array Return data of the new Email Server created
* @return array, return data of the new Email Server created
* @throws Exception
*/
public function create2(array $arrayData)
{
@@ -828,14 +900,14 @@ class EmailServer
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
}
throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
}
} catch (\Exception $e) {
} catch (Exception $e) {
$cnn->rollback();
throw $e;
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -846,7 +918,8 @@ class EmailServer
* @param string $emailServerUid Unique id of Group
* @param array $arrayData Data
*
* return array Return data of the Email Server updated
* @return array Return data of the Email Server updated
* @throws Exception
*/
public function update($emailServerUid, $arrayData)
{
@@ -874,7 +947,7 @@ class EmailServer
if (isset($arrayData['MESS_PASSWORD'])) {
$passwd = $arrayData['MESS_PASSWORD'];
$passwdDec = \G::decrypt($passwd, 'EMAILENCRYPT');
$passwdDec = G::decrypt($passwd, 'EMAILENCRYPT');
$auxPass = explode('hash:', $passwdDec);
if (count($auxPass) > 1) {
@@ -890,7 +963,7 @@ class EmailServer
if ($arrayData['MESS_PASSWORD'] != '') {
$arrayData['MESS_PASSWORD'] = 'hash:' . $arrayData['MESS_PASSWORD'];
$arrayData['MESS_PASSWORD'] = \G::encrypt($arrayData['MESS_PASSWORD'], 'EMAILENCRYPT');
$arrayData['MESS_PASSWORD'] = G::encrypt($arrayData['MESS_PASSWORD'], 'EMAILENCRYPT');
}
}
@@ -912,6 +985,29 @@ class EmailServer
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
}
//Logging the update action
$info = array(
'action' => 'Update email server',
'messUid' => $emailServerUid,
'engine' => $arrayData["MESS_ENGINE"],
'server' => $arrayData["MESS_SERVER"],
'port' => $arrayData["MESS_PORT"],
'requireAuthentication' => $arrayData["MESS_RAUTH"],
'account' => $arrayData["MESS_ACCOUNT"],
'senderEmail' => $arrayData["MESS_FROM_MAIL"],
'senderName' => $arrayData["MESS_FROM_NAME"],
'useSecureConnection' => $arrayData["SMTPSECURE"],
'sendTestEmail' => $arrayData["MESS_TRY_SEND_INMEDIATLY"],
'setAsDefaultConfiguration' => $arrayData["MESS_DEFAULT"]
);
$this->setContextLog($info);
$this->syslog(
'UpdateEmailServer',
200,
'The email server was updated',
$this->getContextLog()
);
return $arrayData;
} else {
$msg = "";
@@ -920,14 +1016,14 @@ class EmailServer
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
}
throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
}
} catch (\Exception $e) {
} catch (Exception $e) {
$cnn->rollback();
throw $e;
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -937,22 +1033,32 @@ class EmailServer
*
* @param string $emailServerUid Unique id of Email Server
*
* return void
* @return void
* @throws Exception
*/
public function delete($emailServerUid)
{
try {
//Verify data
$this->throwExceptionIfNotExistsEmailServer($emailServerUid, $this->arrayFieldNameForException["emailServerUid"]);
$this->throwExceptionIfIsDefault($emailServerUid, $this->arrayFieldNameForException["emailServerUid"]);
$criteria = $this->getEmailServerCriteria();
$criteria->add(\EmailServerPeer::MESS_UID, $emailServerUid, \Criteria::EQUAL);
\EmailServerPeer::doDelete($criteria);
} catch (\Exception $e) {
//Logging the delete action
$info = array(
'action' => 'Delete email server',
'messUid' => $emailServerUid
);
$this->setContextLog($info);
$this->syslog(
'DeleteEmailServer',
200,
'The email server was deleted',
$this->getContextLog()
);
} catch (Exception $e) {
throw $e;
}
}
@@ -982,7 +1088,7 @@ class EmailServer
$criteria->addSelectColumn(\EmailServerPeer::MESS_DEFAULT);
return $criteria;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -992,7 +1098,8 @@ class EmailServer
*
* @param array $record Record
*
* return array Return an array with data Email Server
* @return array, return an array with data Email Server
* @throws Exception
*/
public function getEmailServerDataFromRecord(array $record)
{
@@ -1016,7 +1123,7 @@ class EmailServer
$this->getFieldNameByFormatFieldName("MESS_EXECUTE_EVERY") => '',
$this->getFieldNameByFormatFieldName("MESS_SEND_MAX") => ''
);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -1064,7 +1171,7 @@ class EmailServer
//Return
return $arrayData;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -1078,7 +1185,8 @@ class EmailServer
* @param int $start Start
* @param int $limit Limit
*
* return array Return an array with all Email Servers
* @return array, return an array with all Email Servers
* @throws Exception
*/
public function getEmailServers($arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
{
@@ -1101,10 +1209,10 @@ class EmailServer
if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") {
$criteria->add(
$criteria->getNewCriterion(\EmailServerPeer::MESS_ENGINE, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)->addOr(
$criteria->getNewCriterion(\EmailServerPeer::MESS_SERVER, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))->addOr(
$criteria->getNewCriterion(\EmailServerPeer::MESS_ACCOUNT, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))->addOr(
$criteria->getNewCriterion(\EmailServerPeer::MESS_FROM_NAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))->addOr(
$criteria->getNewCriterion(\EmailServerPeer::SMTPSECURE, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))
$criteria->getNewCriterion(\EmailServerPeer::MESS_SERVER, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))->addOr(
$criteria->getNewCriterion(\EmailServerPeer::MESS_ACCOUNT, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))->addOr(
$criteria->getNewCriterion(\EmailServerPeer::MESS_FROM_NAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))->addOr(
$criteria->getNewCriterion(\EmailServerPeer::SMTPSECURE, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))
);
}
@@ -1156,7 +1264,7 @@ class EmailServer
$row = $rsCriteria->getRow();
$passwd = $row["MESS_PASSWORD"];
$passwdDec = \G::decrypt($passwd, "EMAILENCRYPT");
$passwdDec = G::decrypt($passwd, "EMAILENCRYPT");
$auxPass = explode("hash:", $passwdDec);
if (count($auxPass) > 1) {
@@ -1181,7 +1289,7 @@ class EmailServer
"filter" => (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]))? $arrayFilterData["filter"] : "",
"data" => $arrayEmailServer
);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -1192,7 +1300,8 @@ class EmailServer
* @param string $emailServerUid Unique id of Email Server
* @param bool $flagGetRecord Value that set the getting
*
* return array Return an array with data of a Email Server
* @return array, return an array with data of a Email Server
* @throws Exception
*/
public function getEmailServer($emailServerUid, $flagGetRecord = false)
{
@@ -1224,7 +1333,7 @@ class EmailServer
//Return
return (!$flagGetRecord)? $this->getEmailServerDataFromRecord($row) : $row;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -1246,5 +1355,31 @@ class EmailServer
$rsCriteria->next();
return $rsCriteria->getRow();
}
/**
* Logging information related to the email server
* When the user create, update, delete the email server
*
* @param string $channel
* @param string $level
* @param string $message
* @param array $context
*
* @return void
* @throws Exception
*/
private function syslog(
$channel,
$level,
$message,
$context = array()
)
{
try {
Bootstrap::registerMonolog($channel, $level, $message, $context, $context['workspace'], 'processmaker.log');
} catch (Exception $e) {
throw $e;
}
}
}

View File

@@ -3,6 +3,7 @@
namespace ProcessMaker\BusinessModel\Migrator;
use ProcessMaker\Project;
use ProcessMaker\Util\Common;
class GranularExporter
{
@@ -64,7 +65,7 @@ class GranularExporter
$this->prjName = $projectData['PRJ_NAME'];
$getProjectName = $this->publisher->truncateName($projectData['PRJ_NAME'], false);
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
$version = \ProcessMaker\Util\Common::getLastVersion($outputDir . $getProjectName . "-*.pmx2") + 1;
$version = Common::getLastVersionSpecialCharacters($outputDir, $getProjectName, "pmx2") + 1;
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx2");
$bpnmDefinition = array(

View File

@@ -3,6 +3,7 @@ namespace ProcessMaker\BusinessModel;
use G;
use Criteria;
use DynaformHandler;
class Process
{
@@ -1686,7 +1687,7 @@ class Process
while ($aRow = $oDataset->getRow()) {
if (is_file(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml")) {
$dyn = new \dynaFormHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml");
$dyn = new DynaformHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml");
if ($dyn->getHeaderAttribute("type") !== "xmlform" && $dyn->getHeaderAttribute("type") !== "") {
// skip it, if that is not a xmlform
@@ -1739,7 +1740,7 @@ class Process
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
if (is_file(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml")) {
$dyn = new \dynaFormHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml");
$dyn = new DynaformHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml");
if ($dyn->getHeaderAttribute("type") === "xmlform") {
// skip it, if that is not a xmlform
@@ -1785,7 +1786,7 @@ class Process
$aMultipleSelectionFields = array("listbox", "checkgroup", "grid");
if (is_file( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'.$dynUid. '.xml' ) && filesize( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'. $dynUid .'.xml' ) > 0) {
$dyn = new \dynaFormHandler( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/' .$proUid. '/' . $dynUid .'.xml' );
$dyn = new DynaformHandler( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/' .$proUid. '/' . $dynUid .'.xml' );
$dynaformFields[] = $dyn->getFields();
$fields = $dyn->getFields();

View File

@@ -1,9 +1,10 @@
<?php
namespace ProcessMaker\BusinessModel;
use \G;
use \AdditionalTables;
use \Fields;
use G;
use AdditionalTables;
use Fields;
use DynaformHandler;
class Table
{
@@ -798,7 +799,7 @@ class Table
while ($oDataset->next()) {
$aRow = $oDataset->getRow();
if (file_exists( PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml' )) {
$dynaformHandler = new \dynaformHandler( PATH_DYNAFORM . $aRow['DYN_FILENAME'] . '.xml' );
$dynaformHandler = new DynaformHandler( PATH_DYNAFORM . $aRow['DYN_FILENAME'] . '.xml' );
$nodeFieldsList = $dynaformHandler->getFields();
foreach ($nodeFieldsList as $node) {
@@ -1052,7 +1053,7 @@ class Table
while ($oDataset->next()) {
$aRow = $oDataset->getRow();
$dynaformHandler = new \dynaformHandler( PATH_DYNAFORM . $aRow['DYN_FILENAME'] . '.xml' );
$dynaformHandler = new DynaformHandler( PATH_DYNAFORM . $aRow['DYN_FILENAME'] . '.xml' );
$nodeFieldsList = $dynaformHandler->getFields();
foreach ($nodeFieldsList as $node) {
$arrayNode = $dynaformHandler->getArray( $node );

View File

@@ -1894,7 +1894,12 @@ class Task
}
}
public function getValidateSelfService($data)
/**
* This method verify if an activity has cases
* @param $data
* @return \stdclass
*/
public function hasPendingCases($data)
{
$paused = false;
$data = array_change_key_case($data, CASE_LOWER);

File diff suppressed because it is too large Load Diff

View File

@@ -382,7 +382,7 @@ class WebEntry
$arrayUserData = $user->load($arrayWebEntryData["USR_UID"]);
$usrUsername = $arrayUserData["USR_USERNAME"];
$usrPassword = $arrayUserData["USR_PASSWORD"];
$usrPassword = $user->getUsrPassword();
$dynaForm = new \Dynaform();

View File

@@ -5,7 +5,7 @@ use ProcessMaker\Project;
class ProjectNotFound extends \RuntimeException
{
const EXCEPTION_CODE = 20;
const EXCEPTION_CODE = 400;
public function __construct(Project\Handler $obj, $uid, $message = "", \Exception $previous = null) {
$message = empty($message) ? sprintf("Project \"%s\" with UID: %s, does not exist.", get_class($obj), $uid) : $message;

View File

@@ -0,0 +1,59 @@
<?php
namespace ProcessMaker\Exception;
use G;
/**
* Class PMException
* @package ProcessMaker\Exception
*/
class RBACException extends \Exception
{
const PM_LOGIN = '../login/login';
const PM_403 = '/errors/error403.php';
/**
* RBACException constructor.
* @param string $message
* @param null $code
*/
public function __construct($message, $code=NULL)
{
parent::__construct($message, $code);
}
/**
* Displays the entire exception as a string
* @return string
*/
public function __toString()
{
switch ($this->getCode()) {
case -1:
G::SendTemporalMessage($this->getMessage(), 'error', 'labels');
$message = self::PM_LOGIN;
break;
case -2:
G::SendTemporalMessage($this->getMessage(), 'error', 'labels');
$message = self::PM_LOGIN;
break;
case 403:
$message = self::PM_403;
break;
default:
$message = self::PM_LOGIN;
break;
}
return $message;
}
/**
* Returns the path to which to redirect
* @return $this
*/
public function getPath()
{
return $this;
}
}

View File

@@ -6,6 +6,7 @@ use ProcessMaker\Project;
use ProcessMaker\Project\Adapter;
use ProcessMaker\BusinessModel\Migrator;
use ProcessMaker\BusinessModel\Migrator\ImportException;
use ProcessMaker\Util\Common;
abstract class Importer
{
@@ -771,7 +772,7 @@ abstract class Importer
$getProjectName = $exporter->truncateName($exporter->getProjectName(), false);
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
$version = \ProcessMaker\Util\Common::getLastVersion($outputDir . $getProjectName . "-*.pmx") + 1;
$version = Common::getLastVersionSpecialCharacters($outputDir, $getProjectName, "pmx") + 1;
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
$exporter->setMetadata("export_version", $version);

View File

@@ -1,39 +1,36 @@
<?php
namespace ProcessMaker\Project;
use \BpmnProject as Project;
use \BpmnProcess as Process;
use \BpmnDiagram as Diagram;
use \BasePeer;
use \BpmnActivity as Activity;
use \BpmnBound as Bound;
use \BpmnEvent as Event;
use \BpmnGateway as Gateway;
use \BpmnFlow as Flow;
use \BpmnArtifact as Artifact;
use \BpmnProjectPeer as ProjectPeer;
use \BpmnProcessPeer as ProcessPeer;
use \BpmnDiagramPeer as DiagramPeer;
use \BpmnActivityPeer as ActivityPeer;
use \BpmnBoundPeer as BoundPeer;
use \BpmnEventPeer as EventPeer;
use \BpmnGatewayPeer as GatewayPeer;
use \BpmnFlowPeer as FlowPeer;
use \BpmnArtifactPeer as ArtifactPeer;
use \BpmnParticipant as Participant;
use \BpmnParticipantPeer as ParticipantPeer;
use \BpmnBound as Bound;
use \BpmnBoundPeer as BoundPeer;
use \BpmnDiagram as Diagram;
use \BpmnDiagramPeer as DiagramPeer;
use \BpmnEvent as Event;
use \BpmnEventPeer as EventPeer;
use \BpmnFlow as Flow;
use \BpmnFlowPeer as FlowPeer;
use \BpmnGateway as Gateway;
use \BpmnGatewayPeer as GatewayPeer;
use \BpmnLaneset as Laneset;
use \BpmnLanesetPeer as LanesetPeer;
use \BpmnLane as Lane;
use \BpmnLanePeer as LanePeer;
use \BasePeer;
use \BpmnParticipant as Participant;
use \BpmnParticipantPeer as ParticipantPeer;
use \BpmnProject as Project;
use \BpmnProcess as Process;
use \BpmnProjectPeer as ProjectPeer;
use \BpmnProcessPeer as ProcessPeer;
use \Criteria as Criteria;
use \Exception;
use \G;
use \ResultSet as ResultSet;
use ProcessMaker\Util\Common;
use ProcessMaker\Exception;
use \ProcessMaker\Util\Common;
/**
* Class Bpmn
@@ -428,9 +425,12 @@ class Bpmn extends Handler
self::log("Remove Activity: $actUid");
$activity = ActivityPeer::retrieveByPK($actUid);
$activity->delete();
//TODO if the activity was removed, the related flows to that activity must be removed
if (isset($activity)) {
$activity->delete();
Flow::removeAllRelated($actUid);
} else {
throw new Exception(G::LoadTranslation("ID_ACTIVITY_DOES_NOT_EXIST", array("act_uid", $actUid)));
}
self::log("Remove Activity Success!");
} catch (\Exception $e) {
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());

View File

@@ -10,6 +10,7 @@ use \ProcessMaker\BusinessModel\Validator;
use \ProcessMaker\BusinessModel\Migrator\GranularExporter;
use \ProcessMaker\BusinessModel\Migrator\ExportObjects;
use \ProcessMaker\Util\IO\HttpStream;
use \ProcessMaker\Util\Common;
/**
* Class Project
@@ -182,7 +183,7 @@ class Project extends Api
$getProjectName = $exporter->truncateName($exporter->getProjectName(), false);
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
$version = \ProcessMaker\Util\Common::getLastVersion($outputDir . $getProjectName . "-*.pmx") + 1;
$version = Common::getLastVersionSpecialCharacters($outputDir, $getProjectName, "pmx") + 1;
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
$exporter->setMetadata("export_version", $version);

View File

@@ -1,8 +1,11 @@
<?php
namespace ProcessMaker\Services\Api\Project;
use \ProcessMaker\Services\Api;
use \Exception;
use \Luracast\Restler\RestException;
use \ProcessMaker\BusinessModel\Task;
use \ProcessMaker\Project\Adapter\BpmnWorkflow;
use \ProcessMaker\Services\Api;
/**
* Project\Activity Api Controller
@@ -136,22 +139,32 @@ class Activity extends Api
/**
* This method remove an activity and all related components
* @param string $prj_uid {@min 32} {@max 32}
* @param string $act_uid {@min 32} {@max 32}
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @return array
*
* @access protected
* @class AccessControl {@permission PM_FACTORY}
* @url DELETE /:prj_uid/activity/:act_uid
*/
public function doDeleteProjectActivity($prj_uid, $act_uid)
{
try {
$task = new \ProcessMaker\BusinessModel\Task();
$task->deleteTask($prj_uid, $act_uid);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
$task = new Task();
$task->setFormatFieldNameInUppercase(false);
$task->setArrayParamException(array("taskUid" => "act_uid"));
$response = $task->hasPendingCases(array("act_uid" => $act_uid, "case_type" => "assigned"));
if ($response->result !== false) {
$project = new BpmnWorkflow();
$prj = $project->load($prj_uid);
$prj->removeActivity($act_uid);
} else {
throw new RestException(403, $response->message);
}
} catch (Exception $e) {
$resCode = $e->getCode() == 0 ? Api::STAT_APP_EXCEPTION : $e->getCode();
throw new RestException($resCode, $e->getMessage());
}
}
@@ -215,7 +228,7 @@ class Activity extends Api
$task->setFormatFieldNameInUppercase(false);
$task->setArrayParamException(array("taskUid" => "act_uid"));
$response = $task->getValidateSelfService($request_data);
$response = $task->hasPendingCases($request_data);
return $response;
} catch (\Exception $e) {