Merge remote-tracking branch 'origin/feature/HOR-3559' into feature/HOR-3629

This commit is contained in:
Ronald Quenta
2017-08-10 08:18:12 -04:00
13 changed files with 378 additions and 204 deletions

View File

@@ -52,58 +52,43 @@ class Common
}
$files = glob("$path/$singlePattern", $flags);
$dirs = glob("$path/*", GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
$dirs = glob("$path/*", GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT);
if(is_array($dirs)){
if (is_array($dirs)) {
foreach ($dirs as $dir) {
$files = array_merge($files, self::rglob("$dir/$singlePattern", $flags));
}
}
if ($onlyFiles) {
$files = array_filter($files, function($v) { return is_dir($v) ? false : true;});
$files = array_filter($files, function ($v) {
return is_dir($v) ? false : true;
});
}
return $files;
}
/**
* Returns the last version given a pattern of file name
*
* @param string $pattern a valid pattern for glob(...) native function
* @param int $flag php flags for glob(...) native function
* @return int|string
*
* Example:
* - Given the following files inside a directory:
* /example/path/myApplication-v1.tar
* /example/path/myApplication-v2.tar
* /example/path/myApplication-v3.tar
* /example/path/myApplication-v5.tar
* /example/path/myApplication-v7.tar
*
* $lastVer = ProcessMaker\Util\Common::getLastVersion("/example/path/myApplication-*.tar");
*
* It will returns: 7
* This method get the last version of file when exists a special characters
* @param $pattern
* @param $extension
* @param int $flag
* @return int
*/
public static function getLastVersion($pattern, $flag = 0)
public static function getLastVersionSpecialCharacters($dir, $pattern, $extension, $flag = 0)
{
$files = glob($pattern, $flag);
$files = glob($dir . quotemeta($pattern) . "-*." . $extension, $flag);
$maxVersion = 0;
$pattern = str_replace("*", '([0-9\.]+)', basename($pattern));
$pattern = preg_quote(basename($pattern)) . '-([0-9\.]+)pmx';
foreach ($files as $file) {
$filename = basename($file);
if (preg_match('/'.$pattern.'/', $filename, $match)) {
if (preg_match('/' . $pattern . '/', $filename, $match)) {
if ($maxVersion < $match[1]) {
$maxVersion = $match[1];
}
}
}
return $maxVersion;
}
@@ -141,8 +126,8 @@ class Common
}
while ($parent_folder_path = array_pop($folder_path)) {
if (! @is_dir($parent_folder_path)) {
if (! @mkdir($parent_folder_path, $rights)) {
if (!@is_dir($parent_folder_path)) {
if (!@mkdir($parent_folder_path, $rights)) {
umask($oldumask);
}
}

View File

@@ -35,6 +35,8 @@
/**
* require_once pakeFunction.php
*/
require_once( PATH_THIRDPARTY . 'pake' . PATH_SEP . 'pakeFunction.php');
require_once( PATH_THIRDPARTY . 'pake' . PATH_SEP . 'pakeGetopt.class.php');
require_once( PATH_CORE . 'config' . PATH_SEP . 'environments.php');
// trap -V before pake

View File

@@ -638,7 +638,7 @@ class G
* @param string $strSkin
* @return void
*/
public function RenderPage ($strTemplate = "default", $strSkin = SYS_SKIN, $objContent = null, $layout = '')
public static function RenderPage ($strTemplate = "default", $strSkin = SYS_SKIN, $objContent = null, $layout = '')
{
global $G_CONTENT;
global $G_TEMPLATE;
@@ -3238,20 +3238,34 @@ class G
* @param (array) additional characteres map
*
*/
public function inflect ($string, $replacement = '_', $map = array())
public function inflect($string, $replacement = '_', $map = array())
{
if (is_array( $replacement )) {
if (is_array($replacement)) {
$map = $replacement;
$replacement = '_';
}
$quotedReplacement = preg_quote( $replacement, '/' );
$quotedReplacement = preg_quote($replacement, '/');
$default = array ('/à|á|å|â/' => 'a','/è|é|ê|ẽ|ë/' => 'e','/ì|í|î/' => 'i','/ò|ó|ô|ø/' => 'o','/ù|ú|ů|û/' => 'u','/ç/' => 'c','/ñ/' => 'n','/ä|æ/' => 'ae','/ö/' => 'oe','/ü/' => 'ue','/Ä/' => 'Ae','/Ü/' => 'Ue','/Ö/' => 'Oe','/ß/' => 'ss','/\.|\,|\:|\-|\\|\//' => " ",'/\\s+/' => $replacement
);
$default = array('/à|á|å|â/' => 'a',
'/è|é|ê|ẽ|ë/' => 'e',
'/ì|í|î/' => 'i',
'/ò|ó|ô|ø/' => 'o',
'/ù|ú|ů|û/' => 'u',
'/ç/' => 'c',
'/ñ/' => 'n',
'/ä|æ/' => 'ae',
'/ö/' => 'oe',
'/ü/' => 'ue',
'/Ä/' => 'Ae',
'/Ü/' => 'Ue',
'/Ö/' => 'Oe',
'/ß/' => 'ss',
'/[\.|\,|\+|\"|\:|\;|\-|\\|\/]/' => " ",
'/\\s+/' => $replacement);
$map = array_merge( $default, $map );
return preg_replace( array_keys( $map ), array_values( $map ), $string );
$map = array_merge($default, $map);
return preg_replace(array_keys($map), array_values($map), $string);
}
/**
@@ -5736,7 +5750,7 @@ class G
*
* @return showRes($string)
*/
public function outRes ($sInfVar)
public static function outRes ($sInfVar)
{
echo $sInfVar;
}

View File

@@ -20,7 +20,7 @@ class PMException extends Exception
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
}
public function registerErrorLog($error, $token){
public static function registerErrorLog($error, $token){
$ws = (defined("SYS_SYS"))? SYS_SYS : "Wokspace Undefined";
Bootstrap::registerMonolog('ExceptionCron', 400, $error->getMessage(), array('token'=>$token), $ws, 'processmaker.log');
}

View File

@@ -155,6 +155,23 @@ class RBAC
'emailsAjax.php' => array(
'MessageList' => array('PM_SETUP', 'PM_SETUP_LOGS'),
'updateStatusMessage' => array('PM_SETUP', 'PM_SETUP_LOGS'),
),
'processCategory_Ajax.php' => array(
'processCategoryList' => array('PM_SETUP', 'PM_SETUP_PROCESS_CATEGORIES'),
'updatePageSize' => array('PM_SETUP', 'PM_SETUP_PROCESS_CATEGORIES'),
'checkCategoryName' => array('PM_SETUP', 'PM_SETUP_PROCESS_CATEGORIES'),
'saveNewCategory' => array('PM_SETUP', 'PM_SETUP_PROCESS_CATEGORIES'),
'checkEditCategoryName' => array('PM_SETUP', 'PM_SETUP_PROCESS_CATEGORIES'),
'updateCategory' => array('PM_SETUP', 'PM_SETUP_PROCESS_CATEGORIES'),
'canDeleteCategory' => array('PM_SETUP', 'PM_SETUP_PROCESS_CATEGORIES'),
'deleteCategory' => array('PM_SETUP', 'PM_SETUP_PROCESS_CATEGORIES')
),
'emailServerAjax.php' => array(
'INS' => array('PM_SETUP'),
'UPD' => array('PM_SETUP'),
'DEL' => array('PM_SETUP'),
'LST' => array('PM_SETUP'),
'TEST' => array('PM_SETUP')
)
);
}

View File

@@ -1,8 +1,8 @@
<?php
$option = (isset($_POST["option"]))? $_POST["option"] : "";
$response = array();
$RBAC->allows(basename(__FILE__), $option);
switch ($option) {
case "INS":
$arrayData = array();

View File

@@ -21,14 +21,18 @@
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
if ($RBAC->userCanAccess( 'PM_SETUP' ) != 1 && $RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) {
G::SendTemporalMessage( 'krlos', 'error', 'labels' );
die();
use ProcessMaker\Exception\RBACException;
/** @var RBAC $RBAC */
global $RBAC;
if ($RBAC->userCanAccess('PM_SETUP') != 1 && $RBAC->userCanAccess('PM_SETUP_PROCESS_CATEGORIES') != 1) {
throw new RBACException('ID_USER_HAVENT_RIGHTS_PAGE', -1);
}
$c = new Configurations();
$configPage = $c->getConfiguration( 'processCategoryList', 'pageSize', '', $_SESSION['USER_LOGGED'] );
$Config['pageSize'] = isset( $configPage['pageSize'] ) ? $configPage['pageSize'] : 20;
$configPage = $c->getConfiguration('processCategoryList', 'pageSize', '', $_SESSION['USER_LOGGED']);
$Config['pageSize'] = isset($configPage['pageSize']) ? $configPage['pageSize'] : 20;
$G_MAIN_MENU = 'workflow';
$G_SUB_MENU = 'processCategory';
@@ -37,9 +41,9 @@ $G_ID_SUB_MENU_SELECTED = '';
$G_PUBLISH = new Publisher();
$oHeadPublisher = & headPublisher::getSingleton();
$oHeadPublisher->addExtJsScript( 'processCategory/processCategoryList', false ); //adding a javascript file .js
$oHeadPublisher->addContent( 'processCategory/processCategoryList' ); //adding a html file .html.
$oHeadPublisher->assign( 'FORMATS', $c->getFormats() );
$oHeadPublisher->assign( 'CONFIG', $Config );
G::RenderPage( 'publish', 'extJs' );
$oHeadPublisher = &headPublisher::getSingleton();
$oHeadPublisher->addExtJsScript('processCategory/processCategoryList', false); //adding a javascript file .js
$oHeadPublisher->addContent('processCategory/processCategoryList'); //adding a html file .html.
$oHeadPublisher->assign('FORMATS', $c->getFormats());
$oHeadPublisher->assign('CONFIG', $Config);
G::RenderPage('publish', 'extJs');

View File

@@ -22,37 +22,56 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
if (isset( $_REQUEST['action'] )) {
use ProcessMaker\Exception\RBACException;
/** @var RBAC $RBAC */
global $RBAC;
switch ($RBAC->userCanAccess('PM_LOGIN')) {
case -2:
throw new RBACException('ID_USER_HAVENT_RIGHTS_SYSTEM', -2);
break;
case -1:
throw new RBACException('ID_USER_HAVENT_RIGHTS_PAGE', -1);
break;
}
$RBAC->allows(basename(__FILE__), $_REQUEST['action']);
if (isset($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'processCategoryList':
$co = new Configurations();
$config = $co->getConfiguration( 'processCategoryList', 'pageSize', '', $_SESSION['USER_LOGGED'] );
$limit_size = isset( $config['pageSize'] ) ? $config['pageSize'] : 20;
$config = $co->getConfiguration('processCategoryList', 'pageSize', '', $_SESSION['USER_LOGGED']);
$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
$start = isset( $_POST['start'] ) ? $_POST['start'] : 0;
$limit = isset( $_POST['limit'] ) ? $_POST['limit'] : $limit_size;
$filter = isset( $_REQUEST['textFilter'] ) ? $_REQUEST['textFilter'] : '';
$dir = isset( $_POST['dir'] ) ? $_POST['dir'] : 'ASC';
$sort = isset( $_POST['sort'] ) ? $_POST['sort'] : 'CATEGORY_NAME';
$start = isset($_POST['start']) ? $_POST['start'] : 0;
$limit = isset($_POST['limit']) ? $_POST['limit'] : $limit_size;
$filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : '';
$dir = isset($_POST['dir']) ? $_POST['dir'] : 'ASC';
$sort = isset($_POST['sort']) ? $_POST['sort'] : 'CATEGORY_NAME';
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( 'COUNT(*) AS CNT' );
$oCriteria->add( ProcessCategoryPeer::CATEGORY_UID, '', Criteria::NOT_EQUAL );
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn('COUNT(*) AS CNT');
$oCriteria->add(ProcessCategoryPeer::CATEGORY_UID, '', Criteria::NOT_EQUAL);
if ($filter != '') {
$oCriteria->add( ProcessCategoryPeer::CATEGORY_NAME, '%' . $filter . '%', Criteria::LIKE );
$oCriteria->add(ProcessCategoryPeer::CATEGORY_NAME, '%' . $filter . '%', Criteria::LIKE);
}
$oDat = ProcessCategoryPeer::doSelectRS( $oCriteria );
$oDat->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDat = ProcessCategoryPeer::doSelectRS($oCriteria);
$oDat->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDat->next();
$row = $oDat->getRow();
$total_categories = $row['CNT'];
$oCriteria->clear();
$oCriteria->addSelectColumn( ProcessCategoryPeer::CATEGORY_UID );
$oCriteria->addSelectColumn( ProcessCategoryPeer::CATEGORY_NAME );
$oCriteria->add( ProcessCategoryPeer::CATEGORY_UID, '', Criteria::NOT_EQUAL );
$oCriteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_UID);
$oCriteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME);
$oCriteria->add(ProcessCategoryPeer::CATEGORY_UID, '', Criteria::NOT_EQUAL);
if ($filter != '') {
$oCriteria->add( ProcessCategoryPeer::CATEGORY_NAME, '%' . $filter . '%', Criteria::LIKE );
$oCriteria->add(ProcessCategoryPeer::CATEGORY_NAME, '%' . $filter . '%', Criteria::LIKE);
}
//SQL Injection via 'sort' parameter
if (!in_array($sort, array_merge(ProcessCategoryPeer::getFieldNames(BasePeer::TYPE_FIELDNAME), ['TOTAL_PROCESSES']))) {
throw new Exception(G::LoadTranslation('ID_INVALID_VALUE_FOR', array('$sort')));
}
if ($dir == "DESC") {
@@ -61,119 +80,113 @@ if (isset( $_REQUEST['action'] )) {
$oCriteria->addAscendingOrderByColumn($sort);
}
$oCriteria->setLimit( $limit );
$oCriteria->setOffset( $start );
$oDataset = ProcessCategoryPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oCriteria->setLimit($limit);
$oCriteria->setOffset($start);
$oDataset = ProcessCategoryPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$proc = new Process();
$aProcess = $proc->getAllProcessesByCategory();
$result = "";
$aCat = array ();
$result = [];
$aCat = array();
while ($oDataset->next()) {
$aCat[] = $oDataset->getRow();
$index = sizeof( $aCat ) - 1;
$aCat[$index]['TOTAL_PROCESSES'] = isset( $aProcess[$aCat[$index]['CATEGORY_UID']] ) ? $aProcess[$aCat[$index]['CATEGORY_UID']] : 0;
$index = sizeof($aCat) - 1;
$aCat[$index]['TOTAL_PROCESSES'] = isset($aProcess[$aCat[$index]['CATEGORY_UID']]) ? $aProcess[$aCat[$index]['CATEGORY_UID']] : 0;
}
$result['data'] = $aCat;
$result['totalCount'] = $total_categories;
echo G::json_encode( $result );
echo G::json_encode($result);
break;
case 'updatePageSize':
$c = new Configurations();
$arr['pageSize'] = $_REQUEST['size'];
$arr['dateSave'] = date( 'Y-m-d H:i:s' );
$config = Array ();
$arr['dateSave'] = date('Y-m-d H:i:s');
$config = Array();
$config[] = $arr;
$c->aConfig = $config;
$c->saveConfig( 'processCategoryList', 'pageSize', '', $_SESSION['USER_LOGGED'] );
$c->saveConfig('processCategoryList', 'pageSize', '', $_SESSION['USER_LOGGED']);
echo '{success: true}';
break;
case 'checkCategoryName':
require_once 'classes/model/ProcessCategory.php';
$catName = $_REQUEST['cat_name'];
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( ProcessCategoryPeer::CATEGORY_NAME );
$oCriteria->add( ProcessCategoryPeer::CATEGORY_NAME, $catName );
$oDataset = ProcessCategoryPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME);
$oCriteria->add(ProcessCategoryPeer::CATEGORY_NAME, $catName);
$oDataset = ProcessCategoryPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$row = $oDataset->getRow();
$response = isset( $row['CATEGORY_NAME'] ) ? 'false' : 'true';
$response = isset($row['CATEGORY_NAME']) ? 'false' : 'true';
echo $response;
break;
case 'saveNewCategory':
try {
require_once 'classes/model/ProcessCategory.php';
$catName = trim( $_REQUEST['category'] );
$catName = trim($_REQUEST['category']);
$pcat = new ProcessCategory();
$pcat->setNew( true );
$pcat->setCategoryUid( G::GenerateUniqueID() );
$pcat->setCategoryName( $catName );
$pcat->setNew(true);
$pcat->setCategoryUid(G::GenerateUniqueID());
$pcat->setCategoryName($catName);
$pcat->save();
G::auditLog("CreateCategory", "Category Name: ".$catName);
G::auditLog("CreateCategory", "Category Name: " . $catName);
echo '{success: true}';
} catch (Exception $ex) {
$varEcho = '{success: false, error: ' . $ex->getMessage() . '}';
G::outRes( $varEcho );
G::outRes($varEcho);
}
break;
case 'checkEditCategoryName':
require_once 'classes/model/ProcessCategory.php';
$catUID = $_REQUEST['cat_uid'];
$catName = $_REQUEST['cat_name'];
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( ProcessCategoryPeer::CATEGORY_NAME );
$oCriteria->add( ProcessCategoryPeer::CATEGORY_NAME, $catName );
$oCriteria->add( ProcessCategoryPeer::CATEGORY_UID, $catUID, Criteria::NOT_EQUAL );
$oDataset = ProcessCategoryPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME);
$oCriteria->add(ProcessCategoryPeer::CATEGORY_NAME, $catName);
$oCriteria->add(ProcessCategoryPeer::CATEGORY_UID, $catUID, Criteria::NOT_EQUAL);
$oDataset = ProcessCategoryPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$row = $oDataset->getRow();
$response = isset( $row['CATEGORY_NAME'] ) ? 'false' : 'true';
$response = isset($row['CATEGORY_NAME']) ? 'false' : 'true';
echo $response;
break;
case 'updateCategory':
try {
require_once 'classes/model/ProcessCategory.php';
$catUID = $_REQUEST['cat_uid'];
$catName = trim( $_REQUEST['category'] );
$catName = trim($_REQUEST['category']);
$pcat = new ProcessCategory();
$pcat->setNew( false );
$pcat->setCategoryUid( $catUID );
$pcat->setCategoryName( $catName );
$pcat->setNew(false);
$pcat->setCategoryUid($catUID);
$pcat->setCategoryName($catName);
$pcat->save();
g::auditLog("UpdateCategory", "Category Name: ".$catName." Category ID: (".$catUID.") ");
g::auditLog("UpdateCategory", "Category Name: " . $catName . " Category ID: (" . $catUID . ") ");
echo '{success: true}';
} catch (Exception $ex) {
$varEcho = '{success: false, error: ' . $ex->getMessage() . '}';
G::outRes( $varEcho );
G::outRes($varEcho);
}
break;
case 'canDeleteCategory':
require_once 'classes/model/Process.php';
$proc = new Process();
$aProcess = $proc->getAllProcessesByCategory();
$catUID = $_REQUEST['CAT_UID'];
$response = isset( $aProcess[$catUID] ) ? 'false' : 'true';
$response = isset($aProcess[$catUID]) ? 'false' : 'true';
echo $response;
break;
case 'deleteCategory':
try {
require_once 'classes/model/ProcessCategory.php';
$catUID = $_REQUEST['cat_uid'];
$cat = new ProcessCategory();
$cat->setCategoryUid( $catUID );
$catName = $cat->loadByCategoryId( $catUID );
$cat->setCategoryUid($catUID);
$catName = $cat->loadByCategoryId($catUID);
$cat->delete();
G::auditLog("DeleteCategory", "Category Name: ".$catName." Category ID: (".$catUID.") ");
G::auditLog("DeleteCategory", "Category Name: " . $catName . " Category ID: (" . $catUID . ") ");
$varEcho = '{success: true}';
G::outRes( $varEcho );
G::outRes($varEcho);
} catch (Exception $ex) {
$token = strtotime("now");
PMException::registerErrorLog($ex, $token);
$resJson = '{success: false, error: ' . G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)) . '}';
G::outRes( $resJson );
G::outRes($resJson);
}
break;
default:

View File

@@ -21,6 +21,7 @@
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
use ProcessMaker\Util\Common;
$response = new StdClass();
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
@@ -42,7 +43,7 @@ try {
$projectName = $exporter->getProjectName();
$getProjectName = $exporter->truncateName($projectName, false);
$version = ProcessMaker\Util\Common::getLastVersion($outputDir . $getProjectName . "-*.pmx") + 1;
$version = Common::getLastVersionSpecialCharacters($outputDir, $getProjectName, "pmx") + 1;
$outputFilename = sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
$outputFilename = $exporter->saveExport($outputDir . $outputFilename);
/*----------------------------------********---------------------------------*/

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)
{
@@ -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

@@ -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

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