solve conflicts

This commit is contained in:
Rodrigo Quelca
2019-05-17 11:16:18 -04:00
218 changed files with 11380 additions and 9660 deletions

View File

@@ -23,9 +23,16 @@ class ActionsByEmailCoreClass extends PMPlugin
}
/**
* @param $data
* @param $dataAbe
* Send Actions By Email.
*
* @global object $RBAC
* @param object $data
* @param array $dataAbe
* @return type
* @throws Exception
*
* @see AppDelegation->createAppDelegation()
* @link https://wiki.processmaker.com/3.3/Actions_by_Email
*/
public function sendActionsByEmail($data, $dataAbe)
{
@@ -246,14 +253,22 @@ class ActionsByEmailCoreClass extends PMPlugin
$user = new Users();
$emailFrom = '';
if (!$configuration['ABE_MAILSERVER_OR_MAILCURRENT'] && $configuration['ABE_TYPE'] !== '') {
if ($data->PREVIOUS_USR_UID !== '') {
$userDetails = $user->loadDetails($data->PREVIOUS_USR_UID);
$emailFrom = ($userDetails["USR_FULLNAME"] . ' <' . $userDetails["USR_EMAIL"] . '>');
} else {
global $RBAC;
$currentUser = $RBAC->aUserInfo['USER_INFO'];
$emailFrom = ($currentUser["USR_FIRSTNAME"] . ' ' . $currentUser["USR_LASTNAME"] . ' <' . $currentUser["USR_EMAIL"] . '>');
if ($RBAC != null && is_array($RBAC->aUserInfo['USER_INFO'])) {
$currentUser = $RBAC->aUserInfo['USER_INFO'];
$emailFrom = ($currentUser["USR_FIRSTNAME"] . ' ' . $currentUser["USR_LASTNAME"] . ' <' . $currentUser["USR_EMAIL"] . '>');
} else {
$usersPeer = UsersPeer::retrieveByPK($data->USR_UID);
if (!empty($usersPeer)) {
$emailFrom = ($usersPeer->getUsrFirstname() . ' ' . $usersPeer->getUsrLastname() . ' <' . $usersPeer->getUsrEmail() . '>');
}
}
}
} else {
if (isset($emailSetup["MESS_FROM_NAME"]) && isset($emailSetup["MESS_FROM_MAIL"])) {
@@ -277,7 +292,8 @@ class ActionsByEmailCoreClass extends PMPlugin
true,
$data->DEL_INDEX,
$emailSetup,
0
0,
WsBase::MESSAGE_TYPE_ACTIONS_BY_EMAIL
);
$abeRequest['ABE_REQ_STATUS'] = ($result->status_code == 0 ? 'SENT' : 'ERROR');

View File

@@ -7,7 +7,7 @@ class Applications
/**
* This function return information by searching cases
*
* The query is related to advanced search with diferents filters
* The query is related to advanced search with different filters
* We can search by process, status of case, category of process, users, delegate date from and to
*
* @param string $userUid
@@ -17,11 +17,12 @@ class Applications
* @param integer $process the pro_id
* @param integer $status of the case
* @param string $dir if the order is DESC or ASC
* @param string $sort name of column by sort
* @param string $sort name of column by sort, can be:
* [APP_NUMBER, APP_TITLE, APP_PRO_TITLE, APP_TAS_TITLE, APP_CURRENT_USER, APP_UPDATE_DATE, DEL_DELEGATE_DATE, DEL_TASK_DUE_DATE, APP_STATUS_LABEL]
* @param string $category uid for the process
* @param date $dateFrom
* @param date $dateTo
* @param string $columnSearch name of column for a specific search
* @param string $filterBy name of column for a specific search, can be: [APP_NUMBER, APP_TITLE, TAS_TITLE]
* @return array $result result of the query
*/
public function searchAll(
@@ -36,11 +37,8 @@ class Applications
$category = null,
$dateFrom = null,
$dateTo = null,
$columnSearch = 'APP_TITLE'
$filterBy = 'APP_TITLE'
) {
//Exclude the Task Dummies in the delegations
$arrayTaskTypeToExclude = array("WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT");
//Start the connection to database
$con = Propel::getConnection(AppDelegationPeer::DATABASE_NAME);
@@ -58,7 +56,7 @@ class Applications
$category = $inputFilter->escapeUsingConnection($category, $con);
$dateFrom = $inputFilter->escapeUsingConnection($dateFrom, $con);
$dateTo = $inputFilter->escapeUsingConnection($dateTo, $con);
$columnSearch = $inputFilter->escapeUsingConnection($columnSearch, $con);
$filterBy = $inputFilter->escapeUsingConnection($filterBy, $con);
//Start the transaction
$con->begin();
@@ -101,18 +99,20 @@ class Applications
FROM APP_DELEGATION
";
$sqlData .= " LEFT JOIN APPLICATION ON (APP_DELEGATION.APP_NUMBER = APPLICATION.APP_NUMBER)";
$sqlData .= " LEFT JOIN TASK ON (APP_DELEGATION.TAS_ID = TASK.TAS_ID)";
$sqlData .= " LEFT JOIN TASK ON (APP_DELEGATION.TAS_ID = TASK.TAS_ID ";
//Exclude the Task Dummies in the delegations
$sqlData .= " AND TASK.TAS_TYPE <> 'WEBENTRYEVENT' AND TASK.TAS_TYPE <> 'END-MESSAGE-EVENT' AND TASK.TAS_TYPE <> 'START-MESSAGE-EVENT' AND TASK.TAS_TYPE <> 'INTERMEDIATE-THROW')";
$sqlData .= " LEFT JOIN USERS ON (APP_DELEGATION.USR_ID = USERS.USR_ID)";
$sqlData .= " LEFT JOIN PROCESS ON (APP_DELEGATION.PRO_ID = PROCESS.PRO_ID)";
$sqlData .= " WHERE TASK.TAS_TYPE NOT IN ('" . implode("','", $arrayTaskTypeToExclude) . "')";
$sqlData .= " WHERE 1";
switch ($status) {
case 1: //DRAFT
$sqlData .= " AND APP_DELEGATION.DEL_THREAD_STATUS='OPEN'";
$sqlData .= " AND APP_DELEGATION.DEL_THREAD_STATUS = 'OPEN'";
$sqlData .= " AND APPLICATION.APP_STATUS_ID = 1";
break;
case 2: //TO_DO
$sqlData .= " AND APP_DELEGATION.DEL_THREAD_STATUS='OPEN'";
$sqlData .= " AND APP_DELEGATION.DEL_THREAD_STATUS = 'OPEN'";
$sqlData .= " AND APPLICATION.APP_STATUS_ID = 2";
break;
case 3: //COMPLETED
@@ -148,17 +148,28 @@ class Applications
}
if (!empty($search)) {
//If the filter is related to the APP_DELEGATION table: APP_NUMBER
if ($columnSearch === 'APP_NUMBER') {
$sqlData .= " AND APP_DELEGATION.APP_NUMBER LIKE '%{$search}%' ";
}
//If the filter is related to the APPLICATION table: APP_TITLE
if ($columnSearch === 'APP_TITLE') {
$sqlData .= " AND APPLICATION.APP_TITLE LIKE '%{$search}%' ";
}
//If the filter is related to the TASK table: TAS_TITLE
if ($columnSearch === 'TAS_TITLE') {
$sqlData .= " AND TASK.TAS_TITLE LIKE '%{$search}%' ";
//Search: we need to considerate the filterBy and the sortColumn
$appColumns = ['APP_NUMBER', 'APP_TITLE'];
if (in_array($sort, $appColumns) && in_array($filterBy, $appColumns)) {
$sqlData .= " AND APP_DELEGATION.APP_NUMBER IN (";
//Sub query: get the appNumber(s) that match with the search
$sqlData .= " SELECT APPLICATION.APP_NUMBER FROM APPLICATION WHERE APPLICATION.{$filterBy} LIKE '%{$search}%'";
$sqlData .= " ORDER BY APPLICATION.{$sort} " . $dir;
//End sub query
$sqlData .= " )";
} else {
//If the filter is related to the APP_DELEGATION table: APP_NUMBER
if ($filterBy === 'APP_NUMBER') {
$sqlData .= " AND APP_DELEGATION.APP_NUMBER LIKE '%{$search}%' ";
}
//If the filter is related to the APPLICATION table: APP_TITLE
if ($filterBy === 'APP_TITLE') {
$sqlData .= " AND APPLICATION.APP_TITLE LIKE '%{$search}%' ";
}
//If the filter is related to the TASK table: TAS_TITLE
if ($filterBy === 'TAS_TITLE') {
$sqlData .= " AND TASK.TAS_TITLE LIKE '%{$search}%' ";
}
}
}
@@ -179,6 +190,7 @@ class Applications
$orderBy = 'APP_DELEGATION.APP_NUMBER ' . $dir;
break;
case 'APP_CURRENT_USER':
//@todo: this section needs to use 'User Name Display Format', currently in the extJs is defined this
//The column APP_CURRENT_USER is result of concat those fields
$orderBy = 'USR_LASTNAME ' . $dir . ' ,USR_FIRSTNAME ' . $dir;
break;
@@ -212,6 +224,7 @@ class Applications
if (isset( $row['DEL_PRIORITY'] )) {
$row['DEL_PRIORITY'] = G::LoadTranslation( "ID_PRIORITY_{$priorities[$row['DEL_PRIORITY']]}" );
}
//@todo: this section needs to use 'User Name Display Format', currently in the extJs is defined this
$row["APP_CURRENT_USER"] = $row["USR_LASTNAME"].' '.$row["USR_FIRSTNAME"];
$row["APPDELCR_APP_TAS_TITLE"] = '';
$row["USRCR_USR_UID"] = $row["USR_UID"];

View File

@@ -315,7 +315,7 @@ class Calendar extends CalendarDefinition
* @param string(32) $proUid
* @param string(32) $tasUid
*/
function Calendar ($userUid = NULL, $proUid = NULL, $tasUid = NULL)
function __construct($userUid = NULL, $proUid = NULL, $tasUid = NULL)
{
$this->userUid = $userUid;
$this->proUid = $proUid;

File diff suppressed because it is too large Load Diff

View File

@@ -194,7 +194,7 @@ class DbConnections
$conf = Propel::getConfiguration();
// Iterate through the datasources of configuration, and only care about workflow, rbac or rp. Remove anything else.
foreach ($conf['datasources'] as $key => $val) {
if (!in_array($key, ['workflow', 'rbac', 'rp'])) {
if (!in_array($key, ['workflow', 'rbac', 'rp', 'dbarray'])) {
unset($conf['datasources'][$key]);
}
}

View File

@@ -663,14 +663,19 @@ class Derivation
/**
* Execute Event
*
* @param string $dummyTaskUid Unique id of Element Origin (unique id of Task) This is the nextTask
* @param array $applicationData Case data
* @param bool $flagEventExecuteBeforeGateway Execute event before gateway
* @param bool $flagEventExecuteAfterGateway Execute event after gateway
* @param string $dummyTaskUid Unique id of Element Origin (unique id of Task) This is the nextTask
* @param array $applicationData Case data
* @param bool $flagEventExecuteBeforeGateway Execute event before gateway
* @param bool $flagEventExecuteAfterGateway Execute event after gateway
* @param int $taskId
*
* @return void
* @see Derivation->derivate()
* @see Derivation->doRouteWithoutThread()
* @see Derivation->finishProcess()
* @see Derivation->finishTask()
*/
private function executeEvent($dummyTaskUid, array $applicationData, $flagEventExecuteBeforeGateway = true, $flagEventExecuteAfterGateway = true, $elementOriUid='')
private function executeEvent($dummyTaskUid, array $applicationData, $flagEventExecuteBeforeGateway = true, $flagEventExecuteAfterGateway = true, $elementOriUid='',$tasId = 0)
{
try {
//Verify if the Project is BPMN
@@ -743,7 +748,7 @@ class Derivation
if (preg_match("/^(?:END|INTERMEDIATE)$/", $event->getEvnType()) && $event->getEvnMarker() === 'EMAIL') {
//Email-Event throw
$result = $emailEvent->sendEmail($applicationData["APP_UID"], $applicationData["PRO_UID"], $value['uid'], $applicationData);
$result = $emailEvent->sendEmail($applicationData["APP_UID"], $applicationData["PRO_UID"], $value['uid'], $applicationData, $tasId);
$aContext['envUid'] = $value['uid'];
$aContext['envType'] = $event->getEvnType();
@@ -845,7 +850,8 @@ class Derivation
return $arrayDerivationResult;
}
/** Route the case
/**
* Route the case
* If need to create another thread we can execute the doDerivate
*
* @param array $currentDelegation
@@ -853,7 +859,11 @@ class Derivation
* @param bool $removeList
*
* @return void
* @throws /Exception
* @throws Exception
*
* @see beforeDerivate()
* @see doDerivation()
* @see verifyIsCaseChild()
*/
function derivate(array $currentDelegation, array $nextDelegations, $removeList = true)
{
@@ -1026,7 +1036,8 @@ class Derivation
$appFields,
true,
true,
$currentDelegation["TAS_UID"]
$currentDelegation["TAS_UID"],
!empty($nextDel["TAS_ID"]) ? $nextDel["TAS_ID"] : 0
);
//Route the case
@@ -1049,6 +1060,9 @@ class Derivation
break;
default:
$iNewDelIndex = $this->doDerivation($currentDelegation, $nextDel, $appFields, $aSP);
//Load Case Data again because the information could be change in method "doDerivation"
$verifyApplication = $this->case->loadCase($currentDelegation['APP_UID']);
$appFields['APP_DATA'] = $verifyApplication['APP_DATA'];
//When the users route the case in the same time
if($iNewDelIndex !== 0){
$arrayDerivationResult[] = [
@@ -1869,7 +1883,15 @@ class Derivation
if (preg_match("/^(?:END-MESSAGE-EVENT|END-EMAIL-EVENT)$/", $taskDummy->getTasType())
&& $multiInstanceCompleted && $executeEvent
) {
$this->executeEvent($nextDel["TAS_UID_DUMMY"], $appFields, $flagFirstIteration, true);
$nextDel["TAS_ID"] = $taskDummy->getTasId();
$this->executeEvent(
$nextDel["TAS_UID_DUMMY"],
$appFields,
$flagFirstIteration,
true,
'',
!empty($nextDel["TAS_ID"]) ? $nextDel["TAS_ID"] : 0
);
}
}
$aContext['action'] = 'finish-task';
@@ -1896,12 +1918,27 @@ class Derivation
$nextDel['ROU_CONDITION'] = '';
}
//Execute the Intermediate Event After the End of Process
$this->executeEvent($nextDel["TAS_UID"], $appFields, true, true);
$this->executeEvent(
$nextDel["TAS_UID"],
$appFields,
true,
true,
'',
!empty($nextDel["TAS_ID"]) ? $nextDel["TAS_ID"] : 0
);
if (isset($nextDel["TAS_UID_DUMMY"]) ) {
$taskDummy = TaskPeer::retrieveByPK($nextDel["TAS_UID_DUMMY"]);
if (preg_match("/^(?:END-MESSAGE-EVENT|END-EMAIL-EVENT)$/", $taskDummy->getTasType())) {
$nextDel["TAS_ID"] = $taskDummy->getTasId();
//Throw Events
$this->executeEvent($nextDel["TAS_UID_DUMMY"], $appFields, $flagFirstIteration, true);
$this->executeEvent(
$nextDel["TAS_UID_DUMMY"],
$appFields,
$flagFirstIteration,
true,
'',
!empty($nextDel["TAS_ID"]) ? $nextDel["TAS_ID"] : 0
);
}
}
$aContext['action'] = 'end-process';
@@ -2223,7 +2260,14 @@ class Derivation
//If the all Siblings are done execute the events
if (sizeof($arraySiblings) === 0 && !$flagTypeMultipleInstance) {
//Throw Events
$this->executeEvent($nextDel["TAS_UID"], $appFields, $flagFirstIteration, false);
$this->executeEvent(
$nextDel["TAS_UID"],
$appFields,
$flagFirstIteration,
false,
'',
!empty($nextDel["TAS_ID"]) ? $nextDel["TAS_ID"] : 0
);
}
//Close thread
$this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );

View File

@@ -74,6 +74,44 @@ class Groups
}
}
/**
* Get the IDs of the active groups for an user
*
* @param string $usrUid
*
* @return array
* @throws Exception
*/
public function getActiveGroupsForAnUserById($usrUid)
{
try {
$criteria = new Criteria();
$criteria->addSelectColumn(GroupUserPeer::GRP_ID);
$criteria->addJoin(GroupUserPeer::GRP_ID, GroupwfPeer::GRP_ID, Criteria::LEFT_JOIN);
//@todo: we need to add a new column GROUP_USER.USR_ID
$criteria->add(GroupUserPeer::USR_UID, $usrUid);
//@todo: we need to add a new column GROUPWF.GRP_STATUS_ID
$criteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
$dataset = GroupUserPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataset->next();
//If the user does not relate with any group we will to return a default value for avoiding problems with the IN
$groups = [-1];
$row = $dataset->getRow();
while (is_array($row)) {
$groups[] = $row['GRP_ID'];
$dataset->next();
$row = $dataset->getRow();
}
return $groups;
} catch (Exception $error) {
throw ($error);
}
}
/**
* Set a user to group
*

View File

@@ -27,12 +27,18 @@ class license_application extends Padl
*
* @access public
* @param $use_mcrypt boolean Determines if mcrypt encryption is used or not (defaults to true,
* however if mcrypt is not available, it is set to false)
* however if mcrypt is not available, it is set to false)
* @param $use_time boolean Sets if time binding should be used in the key (defaults to true)
* @param $use_server boolean Sets if server binding should be used in the key (defaults to true)
* @param $allow_local boolean Sets if server binding is in use then localhost servers are valid (defaults to false)
* */
public function license_application($license_path = 'license.dat', $use_mcrypt = true, $use_time = true, $use_server = true, $allow_local = false, $challenge = false)
*
* @see PmLicenseManager::__construct()
* @see PmLicenseManager::installLicense()
* @see PmLicenseManager::validateLicense()
* @link https://wiki.processmaker.com/3.2/Enterprise_Manager_Tool#Importing_a_License
* @link https://wiki.processmaker.com/3.2/Upgrading_ProcessMaker#Activating_the_License
*/
public function __construct($license_path = 'license.dat', $use_mcrypt = true, $use_time = true, $use_server = true, $allow_local = false, $challenge = false)
{
//Check to see if the class has been secured
if (isset($_SESSION)) {
@@ -145,15 +151,15 @@ class license_application extends Padl
*
* @access private
* @return string config file data
* */
* @see _get_ip_address()
* @see _get_mac_address()
*/
public function _get_config()
{
# check to see if the class has been secured
$this->_check_secure();
if (ini_get('safe_mode')) {
# returns invalid because server is in safe mode thus not allowing
# sbin reads but will still allow it to open. a bit weird that one.
return 'SAFE_MODE';
if (!$this->USE_SERVER) {
return 'NOT_USE_SERVER_CONFIG';
}
# if anyone has any clues for windows environments
# or other server types let me know
@@ -198,15 +204,17 @@ class license_application extends Padl
* @return array IP Address(s) if found (Note one machine may have more than one ip)
* @return string ERROR_OPEN means config can't be found and thus not opened
* @return string IP_404 means ip adress doesn't exist in the config file and can't be found in the $_SERVER
* @return string SAFE_MODE means server is in safe mode so config can't be read
* */
* @return string NOT_USE_SERVER_CONFIG the server configuration is not used in license validation.
*
* @see set_server_vars()
*/
public function _get_ip_address()
{
$ips = array();
# get the cofig file
$conf = $this->_get_config();
# if the conf has returned and error return it
if ($conf != 'SAFE_MODE' && $conf != 'ERROR_OPEN') {
if ($conf != 'NOT_USE_SERVER_CONFIG' && $conf != 'ERROR_OPEN') {
# if anyone has any clues for windows environments
# or other server types let me know
$os = strtolower(PHP_OS);
@@ -266,7 +274,7 @@ class license_application extends Padl
return $ips;
}
# failed to find an ip check for conf error or return 404
if ($conf == 'SAFE_MODE' || $conf == 'ERROR_OPEN') {
if ($conf == 'NOT_USE_SERVER_CONFIG' || $conf == 'ERROR_OPEN') {
return $conf;
}
return 'IP_404';
@@ -283,8 +291,10 @@ class license_application extends Padl
* @return string Mac address if found
* @return string ERROR_OPEN means config can't be found and thus not opened
* @return string MAC_404 means mac adress doesn't exist in the config file
* @return string SAFE_MODE means server is in safe mode so config can't be read
* */
* @return string NOT_USE_SERVER_CONFIG the server configuration is not used in license validation.
*
* @see __construct()
*/
public function _get_mac_address()
{
# open the config file

View File

@@ -253,14 +253,7 @@ class Net
break;
case 'mssql':
//todo
if (!extension_loaded('sqlsrv')) {
if ($this->db_instance != "") {
$link = @mssql_connect($this->ip . "\\" . $this->db_instance, $this->db_user, $this->db_passwd);
} else {
$port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":" . $this->db_port;
$link = @mssql_connect($this->ip . $port, $this->db_user, $this->db_passwd);
}
} else {
if (extension_loaded('sqlsrv')) {
if ($this->db_instance != "") {
$server = $this->ip . "\\" . $this->db_instance;
} else {
@@ -274,6 +267,13 @@ class Net
'Database' => $this->db_sourcename
];
$link = @sqlsrv_connect($server, $opt);
} else {
if ($this->db_instance != "") {
$link = @mssql_connect($this->ip . "\\" . $this->db_instance, $this->db_user, $this->db_passwd);
} else {
$port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":" . $this->db_port;
$link = @mssql_connect($this->ip . $port, $this->db_user, $this->db_passwd);
}
}
if ($link) {
@@ -397,14 +397,7 @@ class Net
}
break;
case 'mssql':
if (!extension_loaded('sqlsrv')) {
if ($this->db_instance != "") {
$link = @mssql_connect($this->ip . "\\" . $this->db_instance, $this->db_user, $this->db_passwd);
} else {
$port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":" . $this->db_port;
$link = @mssql_connect($this->ip . $port, $this->db_user, $this->db_passwd);
}
} else {
if (extension_loaded('sqlsrv')) {
if ($this->db_instance != "") {
$server = $this->ip . "\\" . $this->db_instance;
} else {
@@ -418,6 +411,13 @@ class Net
'Database' => $this->db_sourcename
];
$link = $db = @sqlsrv_connect($server, $opt);
} else {
if ($this->db_instance != "") {
$link = @mssql_connect($this->ip . "\\" . $this->db_instance, $this->db_user, $this->db_passwd);
} else {
$port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":" . $this->db_port;
$link = @mssql_connect($this->ip . $port, $this->db_user, $this->db_passwd);
}
}
if ($link) {
if (!extension_loaded('sqlsrv')) {

View File

@@ -4,6 +4,7 @@ use ProcessMaker\Core\System;
use ProcessMaker\BusinessModel\DynaForm\SuggestTrait;
use ProcessMaker\BusinessModel\Cases;
use ProcessMaker\BusinessModel\DynaForm\ValidatorFactory;
use ProcessMaker\Model\Dynaform as ModelDynaform;
/**
* Implementing pmDynaform library in the running case.
@@ -64,6 +65,9 @@ class PmDynaform
$this->jsonReplace($json, $field->id, "id", $field);
}
$this->record["DYN_CONTENT"] = G::json_encode($json);
//to do, this line should be removed. Related to PMC-196.
$this->record['DYN_CONTENT'] = G::fixStringCorrupted($this->record['DYN_CONTENT']);
}
}
@@ -75,6 +79,14 @@ class PmDynaform
return $titleDynaform;
}
/**
* Get a dynaform.
* @return array|null
* @see ConsolidatedCases->processConsolidated()
* @see workflow/engine/methods/cases/caseConsolidated.php
* @see ProcessMaker\BusinessModel\Cases->getCaseVariables()
* @see PmDynaform->__construct()
*/
public function getDynaform()
{
if (!isset($this->fields["CURRENT_DYNAFORM"])) {
@@ -83,22 +95,21 @@ class PmDynaform
if ($this->record != null) {
return $this->record;
}
$a = new Criteria("workflow");
$a->addSelectColumn(DynaformPeer::DYN_VERSION);
$a->addSelectColumn(DynaformPeer::DYN_LABEL);
$a->addSelectColumn(DynaformPeer::DYN_CONTENT);
$a->addSelectColumn(DynaformPeer::PRO_UID);
$a->addSelectColumn(DynaformPeer::DYN_UID);
$a->add(DynaformPeer::DYN_UID, $this->fields["CURRENT_DYNAFORM"], Criteria::EQUAL);
$ds = DynaformPeer::doSelectRS($a);
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$ds->next();
$row = $ds->getRow();
$this->record = isset($row) ? $row : null;
$this->langs = ($this->record["DYN_LABEL"] !== "" && $this->record["DYN_LABEL"] !== null) ? G::json_decode($this->record["DYN_LABEL"]) : null;
$dynaform = ModelDynaform::getByDynUid($this->fields["CURRENT_DYNAFORM"]);
if (empty($dynaform)) {
$this->langs = null;
return null;
}
$this->langs = empty($dynaform->DYN_LABEL) ? null : G::json_decode($dynaform->DYN_LABEL);
$this->record = (array) $dynaform;
return $this->record;
}
/**
* Get all dynaforms except this dynaform, related to process.
* @return array
* @see PmDynaform->__construct()
*/
public function getDynaforms()
{
if ($this->record === null) {
@@ -107,21 +118,11 @@ class PmDynaform
if ($this->records != null) {
return $this->records;
}
$a = new Criteria("workflow");
$a->addSelectColumn(DynaformPeer::DYN_UPDATE_DATE);
$a->addSelectColumn(DynaformPeer::DYN_VERSION);
$a->addSelectColumn(DynaformPeer::DYN_LABEL);
$a->addSelectColumn(DynaformPeer::DYN_CONTENT);
$a->addSelectColumn(DynaformPeer::PRO_UID);
$a->addSelectColumn(DynaformPeer::DYN_UID);
$a->add(DynaformPeer::PRO_UID, $this->record["PRO_UID"], Criteria::EQUAL);
$a->add(DynaformPeer::DYN_UID, $this->record["DYN_UID"], Criteria::NOT_EQUAL);
$ds = DynaformPeer::doSelectRS($a);
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$this->records = array();
while ($ds->next()) {
array_push($this->records, $ds->getRow());
}
$result = ModelDynaform::getByProUidExceptDynUid($this->record["PRO_UID"], $this->record["DYN_UID"]);
$result->transform(function($item) {
return (array) $item;
});
$this->records = $result->toArray();
return $this->records;
}
@@ -1129,23 +1130,7 @@ class PmDynaform
if (!isset($this->fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["PREVIOUS_STEP"])) {
$this->fields["APP_DATA"]["__DYNAFORM_OPTIONS"]["PREVIOUS_STEP"] = "";
}
$msg = "";
if (isset($_SESSION['G_MESSAGE_TYPE']) && isset($_SESSION['G_MESSAGE'])) {
$color = "green";
if ($_SESSION['G_MESSAGE_TYPE'] === "ERROR") {
$color = "red";
}
if ($_SESSION['G_MESSAGE_TYPE'] === "WARNING") {
$color = "#C3C380";
}
if ($_SESSION['G_MESSAGE_TYPE'] === "INFO") {
$color = "green";
}
$msg = "<div style='background-color:" . $color . ";color: white;padding: 1px 2px 1px 5px;' class='userGroupTitle'>" . $_SESSION['G_MESSAGE_TYPE'] . ": " . $_SESSION['G_MESSAGE'] . "</div>";
unset($_SESSION['G_MESSAGE_TYPE']);
unset($_SESSION['G_MESSAGE']);
}
$title = $msg .
$title = $this->getSessionMessage() .
"<table width='100%' align='center'>\n" .
" <tr class='userGroupTitle'>\n" .
" <td width='100%' align='center'>" . G::LoadTranslation('ID_CASE') . " #: " . $this->fields["APP_NUMBER"] . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . G::LoadTranslation('ID_TITLE') . ": " . $this->fields["APP_TITLE"] . "</td>\n" .
@@ -1196,19 +1181,8 @@ class PmDynaform
public function printEditSupervisor()
{
ob_clean();
$json = G::json_decode($this->record["DYN_CONTENT"]);
$this->jsonr($json);
$msg = "";
if (isset($_SESSION["G_MESSAGE_TYPE"]) && isset($_SESSION["G_MESSAGE"])) {
$msg = "<div style=\"margin: 1.2em; border: 1px solid #3C763D; padding: 0.5em; background: #B2D3B3;\"><strong>" . G::LoadTranslation("ID_INFO") . "</strong>: " . $_SESSION["G_MESSAGE"] . "</div>";
unset($_SESSION["G_MESSAGE_TYPE"]);
unset($_SESSION["G_MESSAGE"]);
}
$javascrip = "
<script type=\"text/javascript\">
var jsondata = " . G::json_encode($json) . ";
@@ -1231,11 +1205,9 @@ class PmDynaform
var leaveCaseWarning = " . $this->getLeaveCaseWarning() . ";
" . $this->getTheStringVariableForGoogleMaps() . "
</script>
<script type=\"text/javascript\" src=\"/jscore/cases/core/pmDynaform.js\"></script>
<div>
$msg
" . $this->getSessionMessageForSupervisor() . "
<div style=\"display: none;\">
<a id=\"dyn_forward\" href=\"javascript:;\"></a>
</div>
@@ -1320,6 +1292,7 @@ class PmDynaform
$this->getTheStringVariableForGoogleMaps() . "\n" .
"</script>\n" .
"<script type='text/javascript' src='/jscore/cases/core/pmDynaform.js'></script>\n" .
$this->getSessionMessage() .
"<div style='width:100%;padding: 0px 10px 0px 10px;margin:15px 0px 0px 0px;'>\n" .
" <a id='dyn_forward' href='' style='float:right;font-size:12px;line-height:1;margin:0px 5px 1px 0px;'>\n" .
" </a>\n" .
@@ -1356,9 +1329,20 @@ class PmDynaform
exit();
}
/**
* Print PmDynaform for Action by Email.
*
* @param array $record
* @return string
*
* @see ActionsByEmailCoreClass->sendActionsByEmail()
* @link https://wiki.processmaker.com/3.3/Actions_by_Email
*/
public function printPmDynaformAbe($record)
{
ob_clean();
if (ob_get_length() > 0) {
ob_clean();
}
$this->record = $record;
$json = G::json_decode($this->record["DYN_CONTENT"]);
$this->jsonr($json);
@@ -1576,19 +1560,27 @@ class PmDynaform
}
}
/**
* Verify the use of the variable in all the forms of the process.
*
* @param string $processUid
* @param string $variable
* @return boolean | string
*
* @see ProcessMaker\BusinessModel\Variable->delete()
* @link https://wiki.processmaker.com/3.2/Variables#Managing_Variables
*/
public function isUsed($processUid, $variable)
{
$criteria = new Criteria("workflow");
$criteria->addSelectColumn(DynaformPeer::DYN_UID);
$criteria->addSelectColumn(DynaformPeer::DYN_CONTENT);
$criteria->add(DynaformPeer::PRO_UID, $processUid, Criteria::EQUAL);
$rsCriteria = DynaformPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$aRow = $rsCriteria->getRow();
$json = G::json_decode($aRow['DYN_CONTENT']);
$result = ModelDynaform::getByProUid($processUid);
if (empty($result)) {
return false;
}
foreach ($result as $row) {
$dynaform = new PmDynaform(["CURRENT_DYNAFORM" => $row->DYN_UID]);
$json = G::json_decode($dynaform->record["DYN_CONTENT"]);
if ($this->jsoni($json, $variable)) {
return $aRow['DYN_UID'];
return $row->DYN_UID;
}
}
return false;
@@ -2224,4 +2216,53 @@ class PmDynaform
$result = 'var googleMaps = ' . G::json_encode($googleMaps) . ';';
return $result;
}
/**
* Get session message.
*
* @return string
*
* @see PmDynaform->printEdit()
* @see PmDynaform->printABE()
* @link https://wiki.processmaker.com/3.1/Multiple_File_Uploader#File_Extensions
*/
public function getSessionMessage()
{
$message = "";
if (isset($_SESSION['G_MESSAGE_TYPE']) && isset($_SESSION['G_MESSAGE'])) {
$color = "green";
if ($_SESSION['G_MESSAGE_TYPE'] === "ERROR") {
$color = "red";
}
if ($_SESSION['G_MESSAGE_TYPE'] === "WARNING") {
$color = "#C3C380";
}
if ($_SESSION['G_MESSAGE_TYPE'] === "INFO") {
$color = "green";
}
$message = "<div style='background-color:" . $color . ";color: white;padding: 1px 2px 1px 5px;' class='userGroupTitle'>" . $_SESSION['G_MESSAGE_TYPE'] . ": " . $_SESSION['G_MESSAGE'] . "</div>";
unset($_SESSION['G_MESSAGE_TYPE']);
unset($_SESSION['G_MESSAGE']);
}
return $message;
}
/**
* Get session message for supervisor.
*
* @return string
*
* @see PmDynaform->printEditSupervisor();
* @link https://wiki.processmaker.com/3.1/Multiple_File_Uploader#File_Extensions
*/
public function getSessionMessageForSupervisor()
{
$message = "";
if (isset($_SESSION["G_MESSAGE_TYPE"]) && isset($_SESSION["G_MESSAGE"])) {
$message = "<div style=\"margin: 1.2em; border: 1px solid #3C763D; padding: 0.5em; background: #B2D3B3;\"><strong>" . G::LoadTranslation("ID_INFO") . "</strong>: " . $_SESSION["G_MESSAGE"] . "</div>";
unset($_SESSION["G_MESSAGE_TYPE"]);
unset($_SESSION["G_MESSAGE"]);
}
return $message;
}
}

View File

@@ -1006,4 +1006,24 @@ class PmTable
}
return $oCriteria;
}
/**
* Get the type of the column ex: string, int, double, boolean
*
* @param string $pmTablePeer
* @param string $tableName
* @param string $columnName
*
* @return string
*/
public static function getTypeOfColumn($pmTablePeer, $tableName, $columnName)
{
try {
$type = $pmTablePeer::getMapBuilder()->getDatabaseMap()->getTable($tableName)->getColumn($columnName)->getCreoleType();
} catch (Exception $e) {
return '';
}
return $type;
}
}

View File

@@ -4211,21 +4211,37 @@ class ProcessMap
}
}
public function downloadFile($sProcessUID, $sMainDirectory, $sCurrentDirectory, $sFile)
/**
* Stream a file from "mailTemplates" or "public" directory thats belongs to a process
*
* @param string $processUid
* @param string $mainDirectory
* @param string $currentDirectory
* @param string $file
*/
public function downloadFile($processUid, $mainDirectory, $currentDirectory, $file)
{
switch ($sMainDirectory) {
// Validate directory and file requested
$filter = new InputFilter();
$currentDirectory = $filter->validatePath($currentDirectory);
$file = $filter->validatePath($file);
// Validate the main directory
switch ($mainDirectory) {
case 'mailTemplates':
$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . ($sCurrentDirectory != '' ? $sCurrentDirectory . PATH_SEP : '');
$sDirectory = PATH_DATA_MAILTEMPLATES . $processUid . PATH_SEP . ($currentDirectory != '' ? $currentDirectory . PATH_SEP : '');
break;
case 'public':
$sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP . ($sCurrentDirectory != '' ? $sCurrentDirectory . PATH_SEP : '');
$sDirectory = PATH_DATA_PUBLIC . $processUid . PATH_SEP . ($currentDirectory != '' ? $currentDirectory . PATH_SEP : '');
break;
default:
die();
break;
}
if (file_exists($sDirectory . $sFile)) {
G::streamFile($sDirectory . $sFile, true);
// Stream the file if path exists
if (file_exists($sDirectory . $file)) {
G::streamFile($sDirectory . $file, true);
}
}

View File

@@ -1029,7 +1029,7 @@ class Processes
$oData->process['PRO_DYNAFORMS']['PROCESS'] = '';
}
if ($oData->process['PRO_DYNAFORMS']['PROCESS'] != '') {
if (!empty($oData->process['PRO_DYNAFORMS']['PROCESS']) && !empty($map[$oData->process['PRO_DYNAFORMS']['PROCESS']])) {
$oData->process['PRO_DYNAFORMS']['PROCESS'] = $map[$oData->process['PRO_DYNAFORMS']['PROCESS']];
}
@@ -1994,6 +1994,13 @@ class Processes
$criteria->add(InputDocumentPeer::INP_DOC_MAX_FILESIZE, $row['INP_DOC_MAX_FILESIZE']);
$criteria->add(InputDocumentPeer::INP_DOC_MAX_FILESIZE_UNIT, $row['INP_DOC_MAX_FILESIZE_UNIT']);
BasePeer::doInsert($criteria, $con);
//Insert in CONTENT
$labels = [
'INP_DOC_TITLE' => $row['INP_DOC_TITLE'],
'INP_DOC_DESCRIPTION' => !empty($row['INP_DOC_DESCRIPTION']) ? $row['INP_DOC_DESCRIPTION'] : ''
];
$this->insertToContentTable($con, $labels, $row['INP_DOC_UID'], SYS_LANG);
}
$con->commit();
} catch (Exception $e) {
@@ -2178,6 +2185,13 @@ class Processes
$criteria->add(OutputDocumentPeer::OUT_DOC_PDF_SECURITY_PERMISSIONS, $row['OUT_DOC_PDF_SECURITY_PERMISSIONS']);
$criteria->add(OutputDocumentPeer::OUT_DOC_OPEN_TYPE, $row['OUT_DOC_OPEN_TYPE']);
BasePeer::doInsert($criteria, $con);
//Insert in CONTENT
$labels = ['OUT_DOC_TITLE' => $row['OUT_DOC_TITLE'],
'OUT_DOC_DESCRIPTION' => !empty($row['OUT_DOC_DESCRIPTION']) ? $row['OUT_DOC_DESCRIPTION'] : '',
'OUT_DOC_FILENAME' => $row['OUT_DOC_FILENAME'],
'OUT_DOC_TEMPLATE' => !empty($row['OUT_DOC_TEMPLATE']) ? $row['OUT_DOC_TEMPLATE'] : ''];
$this->insertToContentTable($con, $labels, $row['OUT_DOC_UID'], SYS_LANG);
}
$con->commit();
} catch (Exception $e) {
@@ -3104,6 +3118,13 @@ class Processes
$criteria->add(DynaformPeer::DYN_VERSION, $row['DYN_VERSION']);
$criteria->add(DynaformPeer::DYN_UPDATE_DATE, $row['DYN_UPDATE_DATE']);
BasePeer::doInsert($criteria, $con);
//Insert in CONTENT
$labels = [
'DYN_TITLE' => $row['DYN_TITLE'],
'DYN_DESCRIPTION' => !empty($row['DYN_DESCRIPTION']) ? $row['DYN_DESCRIPTION'] : ''
];
$this->insertToContentTable($con, $labels, $row['DYN_UID'], SYS_LANG);
}
$con->commit();
} catch (Exception $e) {
@@ -3249,6 +3270,13 @@ class Processes
$criteria->add(TriggersPeer::TRI_WEBBOT, $row['TRI_WEBBOT']);
$criteria->add(TriggersPeer::TRI_PARAM, $row['TRI_PARAM']);
BasePeer::doInsert($criteria, $con);
//Insert in CONTENT
$labels = [
'TRI_TITLE' => $row['TRI_TITLE'],
'TRI_DESCRIPTION' => !empty($row['TRI_DESCRIPTION']) ? $row['TRI_DESCRIPTION'] : ''
];
$this->insertToContentTable($con, $labels, $row['TRI_UID'], SYS_LANG);
}
$con->commit();
} catch (Exception $e) {
@@ -4050,6 +4078,10 @@ class Processes
$criteria->add(GroupwfPeer::GRP_LDAP_DN, $row['GRP_LDAP_DN']);
$criteria->add(GroupwfPeer::GRP_UX, $row['GRP_UX']);
BasePeer::doInsert($criteria, $con);
//Insert in CONTENT
$labels = ['GRP_TITLE' => $row['GRP_TITLE']];
$this->insertToContentTable($con, $labels, $row['GRP_UID'], SYS_LANG);
}
$con->commit();
} catch (Exception $e) {
@@ -6375,4 +6407,38 @@ class Processes
$proTitle = substr($proTitle, 0, strlen($proTitle) - $excess);
return $proTitle;
}
/**
* Delete, insert and update labels in CONTENT related to a process element
*
* @param object $connection
* @param array $conCategories
* @param string $conId
* @param string $conLang
* @param string $conParent
*/
private function insertToContentTable($connection, array $conCategories, $conId, $conLang, $conParent = '') {
//Prepare to delete labels related in CONTENT
$criteria = new Criteria(ContentPeer::DATABASE_NAME);
$criteria->addSelectColumn('*');
$criteria->add(ContentPeer::CON_CATEGORY, array_keys($conCategories), Criteria::IN);
$criteria->add(ContentPeer::CON_ID, $conId);
$criteria->add(ContentPeer::CON_LANG, $conLang);
$criteria->add(ContentPeer::CON_PARENT, $conParent);
BasePeer::doDelete($criteria, $connection);
foreach ($conCategories as $conCategory => $conValue) {
//Prepare the insert label in CONTENT
$criteria = new Criteria(ContentPeer::DATABASE_NAME);
$criteria->add(ContentPeer::CON_CATEGORY, $conCategory);
$criteria->add(ContentPeer::CON_ID, $conId);
$criteria->add(ContentPeer::CON_LANG, $conLang);
$criteria->add(ContentPeer::CON_VALUE, $conValue);
$criteria->add(ContentPeer::CON_PARENT, $conParent);
BasePeer::doInsert($criteria, $connection);
//Updating all related labels in CONTENT
Content::updateEqualValue($conCategory, $conParent, $conId, $conValue);
}
}
}

View File

@@ -15,18 +15,19 @@ use ProcessMaker\Core\System;
*/
class SpoolRun
{
public $config;
private $appUid;
private $appMsgUid;
private $warnings = []; //Array to store the warning that were throws by the class
private $exceptionCode = []; //Array to define the Exception codes
private $fileData;
private $spool_id;
public $status;
public $error;
private $ExceptionCode = Array(); //Array to define the Expetion codes
private $aWarnings = Array(); //Array to store the warning that were throws by the class
private $longMailEreg;
private $mailEreg;
private $spoolId;
public $config;
public $error;
public $status;
/**
* Class constructor - iniatilize default values
@@ -38,18 +39,58 @@ class SpoolRun
{
$this->config = array();
$this->fileData = array();
$this->spool_id = '';
$this->spoolId = '';
$this->status = 'pending';
$this->error = '';
$this->ExceptionCode['FATAL'] = 1;
$this->ExceptionCode['WARNING'] = 2;
$this->ExceptionCode['NOTICE'] = 3;
$this->exceptionCode['FATAL'] = 1;
$this->exceptionCode['WARNING'] = 2;
$this->exceptionCode['NOTICE'] = 3;
$this->longMailEreg = "/(.*)(<([\w\-\+\.']+@[\w\-_\.]+\.\w{2,5})+>)/";
$this->mailEreg = "/^([\w\-_\+\.']+@[\w\-_\.]+\.\w{2,5}+)$/";
}
/**
* Get the appUid
*
* @return string
*/
public function getAppUid()
{
return $this->appUid;
}
/**
* Set the appUid
*
* @param string $v
*/
public function setAppUid($v)
{
$this->appUid = $v;
}
/**
* Get the appMsgUid
*
* @return string
*/
public function getAppMsgUid()
{
return $this->appMsgUid;
}
/**
* Set the appMsgUid
*
* @param string $v
*/
public function setAppMsgUid($v)
{
$this->appMsgUid = $v;
}
/**
* get all files into spool in a list
*
@@ -65,7 +106,7 @@ class SpoolRun
$rs = $stmt->executeQuery();
while ($rs->next()) {
$this->spool_id = $rs->getString('APP_MSG_UID');
$this->spoolId = $rs->getString('APP_MSG_UID');
$this->fileData['subject'] = $rs->getString('APP_MSG_SUBJECT');
$this->fileData['from'] = $rs->getString('APP_MSG_FROM');
$this->fileData['to'] = $rs->getString('APP_MSG_TO');
@@ -110,7 +151,7 @@ class SpoolRun
$aData['app_msg_attach'] = serialize($attachment);
$aData['app_msg_show_message'] = (isset($aData['app_msg_show_message'])) ? $aData['app_msg_show_message'] : 1;
$aData["app_msg_error"] = (isset($aData["app_msg_error"])) ? $aData["app_msg_error"] : '';
$sUID = $this->db_insert($aData);
$sUID = $this->dbInsert($aData);
$aData['app_msg_date'] = isset($aData['app_msg_date']) ? $aData['app_msg_date'] : '';
@@ -178,7 +219,7 @@ class SpoolRun
*/
public function setData($sAppMsgUid, $sSubject, $sFrom, $sTo, $sBody, $sDate = "", $sCC = "", $sBCC = "", $sTemplate = "", $aAttachment = array(), $bContentTypeIsHtml = true, $sError = "")
{
$this->spool_id = $sAppMsgUid;
$this->spoolId = $sAppMsgUid;
$this->fileData['subject'] = $sSubject;
$this->fileData['from'] = $sFrom;
$this->fileData['to'] = $sTo;
@@ -234,17 +275,40 @@ class SpoolRun
*/
private function updateSpoolStatus()
{
$oAppMessage = AppMessagePeer::retrieveByPK($this->spool_id);
$oAppMessage = AppMessagePeer::retrieveByPK($this->spoolId);
if (is_array($this->fileData['attachments'])) {
$attachment = implode(",", $this->fileData['attachments']);
$oAppMessage->setappMsgAttach($attachment);
}
$oAppMessage->setAppMsgStatus($this->status);
$oAppMessage->setAppMsgStatusId(isset(AppMessage::$app_msg_status_values[$this->status]) ? AppMessage::$app_msg_status_values[$this->status] : 0);
$oAppMessage->setappMsgsenddate(date('Y-m-d H:i:s'));
$oAppMessage->setAppMsgSendDate(date('Y-m-d H:i:s'));
$oAppMessage->save();
}
/**
* Update the error
*
* @param string $msgError
*
* @return void
*
* @see SpoolRun::handleMail()
*/
private function updateSpoolError($msgError)
{
$appMessage = AppMessagePeer::retrieveByPK($this->spoolId);
$appMessage->setAppMsgError($msgError);
$appMessage->setAppMsgSendDate(date('Y-m-d H:i:s'));
$appMessage->save();
$context = Bootstrap::getDefaultContextLog();
$context["action"] = "Send email";
$context["appMsgUid"] = $this->getAppMsgUid();
$context["appUid"] = $this->getAppUid();
Bootstrap::registerMonolog("SendEmail", 400, $msgError, $context);
}
/**
* handle the email that was set in "TO" parameter
*
@@ -269,7 +333,7 @@ class SpoolRun
}
if (!isset($matches[3])) {
throw new Exception('Invalid email address in FROM parameter (' . $this->fileData['from'] . ')', $this->ExceptionCode['WARNING']);
throw new Exception('Invalid email address in FROM parameter (' . $this->fileData['from'] . ')', $this->exceptionCode['WARNING']);
}
$this->fileData['from_email'] = trim($matches[3]);
@@ -279,7 +343,7 @@ class SpoolRun
preg_match($ereg, $this->fileData["from"], $matches);
if (!isset($matches[0])) {
throw new Exception('Invalid email address in FROM parameter (' . $this->fileData['from'] . ')', $this->ExceptionCode['WARNING']);
throw new Exception('Invalid email address in FROM parameter (' . $this->fileData['from'] . ')', $this->exceptionCode['WARNING']);
}
$this->fileData['from_name'] = '';
@@ -305,16 +369,17 @@ class SpoolRun
}
/**
* handle all recipients to compose the mail
* Handle all recipients to compose the mail
*
* @param none
* @return boolean true or exception
* @return void
*
* @see SpoolRun::sendMail()
*/
private function handleEnvelopeTo()
{
$hold = array();
$holdcc = array();
$holdbcc = array();
$hold = [];
$holdcc = [];
$holdbcc = [];
$text = trim($this->fileData['to']);
$textcc = '';
@@ -335,10 +400,15 @@ class SpoolRun
$this->fileData['envelope_to'][] = "$val";
}
}
} elseif ($text != '') {
$this->fileData['envelope_to'][] = "$text";
} else {
$this->fileData['envelope_to'] = Array();
$this->fileData['envelope_to'] = [];
}
if (empty($this->fileData['envelope_to'])){
$this->updateSpoolError('Invalid address: ' . $text);
}
//CC
@@ -353,7 +423,7 @@ class SpoolRun
} elseif ($textcc != '') {
$this->fileData['envelope_cc'][] = "$textcc";
} else {
$this->fileData['envelope_cc'] = Array();
$this->fileData['envelope_cc'] = [];
}
//BCC
@@ -368,16 +438,19 @@ class SpoolRun
} elseif ($textbcc != '') {
$this->fileData['envelope_bcc'][] = "$textbcc";
} else {
$this->fileData['envelope_bcc'] = Array();
$this->fileData['envelope_bcc'] = [];
}
}
/**
* handle and compose the email content and parameters
* Handle and compose the email content and parameters
*
* @param none
* @return none
* @return void
*
* @throws Exception
*
* @see SpoolRun::sendMail()
*/
private function handleMail()
{
@@ -386,20 +459,18 @@ class SpoolRun
switch ($this->config['MESS_ENGINE']) {
case 'MAIL':
case 'PHPMAILER':
switch ($this->config['MESS_ENGINE']) {
case 'MAIL':
$oPHPMailer = new PHPMailer();
$oPHPMailer->Mailer = 'mail';
$phpMailer = new PHPMailer();
$phpMailer->Mailer = 'mail';
break;
case 'PHPMAILER':
$oPHPMailer = new PHPMailer(true);
$oPHPMailer->Mailer = 'smtp';
$phpMailer = new PHPMailer(true);
$phpMailer->Mailer = 'smtp';
break;
}
$oPHPMailer->SMTPAuth = (isset($this->config['SMTPAuth']) ? $this->config['SMTPAuth'] : '');
$phpMailer->SMTPAuth = (isset($this->config['SMTPAuth']) ? $this->config['SMTPAuth'] : '');
switch ($this->config['MESS_ENGINE']) {
case 'MAIL':
@@ -407,101 +478,133 @@ class SpoolRun
case 'PHPMAILER':
//Posible Options for SMTPSecure are: "", "ssl" or "tls"
if (isset($this->config['SMTPSecure']) && preg_match('/^(ssl|tls)$/', $this->config['SMTPSecure'])) {
$oPHPMailer->SMTPSecure = $this->config['SMTPSecure'];
$phpMailer->SMTPSecure = $this->config['SMTPSecure'];
}
break;
}
$systemConfiguration = System::getSystemConfiguration();
$oPHPMailer->Timeout = is_numeric($systemConfiguration['smtp_timeout']) ? $systemConfiguration['smtp_timeout'] : 20;
$oPHPMailer->CharSet = "UTF-8";
$oPHPMailer->Encoding = "8bit";
$oPHPMailer->Host = $this->config['MESS_SERVER'];
$oPHPMailer->Port = $this->config['MESS_PORT'];
$oPHPMailer->Username = $this->config['MESS_ACCOUNT'];
$oPHPMailer->Password = $this->config['MESS_PASSWORD'];
$oPHPMailer->SetFrom($this->fileData['from_email'], utf8_decode($this->fileData['from_name']));
if (isset($this->fileData['reply_to'])) {
if ($this->fileData['reply_to'] != '') {
$oPHPMailer->AddReplyTo($this->fileData['reply_to'], $this->fileData['reply_to_name']);
}
}
try {
$systemConfiguration = System::getSystemConfiguration();
$phpMailer->Timeout = is_numeric($systemConfiguration['smtp_timeout']) ? $systemConfiguration['smtp_timeout'] : 20;
$phpMailer->CharSet = "UTF-8";
$phpMailer->Encoding = "8bit";
$phpMailer->Host = $this->config['MESS_SERVER'];
$phpMailer->Port = $this->config['MESS_PORT'];
$phpMailer->Username = $this->config['MESS_ACCOUNT'];
$phpMailer->Password = $this->config['MESS_PASSWORD'];
$msSubject = $this->fileData['subject'];
if (!(mb_detect_encoding($msSubject, "UTF-8") == "UTF-8")) {
$msSubject = utf8_encode($msSubject);
}
$oPHPMailer->Subject = $msSubject;
$msBody = $this->fileData['body'];
if (!(mb_detect_encoding($msBody, "UTF-8") == "UTF-8")) {
$msBody = utf8_encode($msBody);
}
$oPHPMailer->Body = $msBody;
$attachment = @unserialize($this->fileData['attachments']);
if ($attachment === false) {
$attachment = $this->fileData['attachments'];
}
if (is_array($attachment)) {
foreach ($attachment as $key => $fileAttach) {
if (file_exists($fileAttach)) {
$oPHPMailer->AddAttachment($fileAttach, is_int($key) ? '' : $key);
//From
$phpMailer->SetFrom($this->fileData['from_email'], utf8_decode($this->fileData['from_name']));
//Reply to
if (isset($this->fileData['reply_to'])) {
if ($this->fileData['reply_to'] != '') {
$phpMailer->AddReplyTo($this->fileData['reply_to'], $this->fileData['reply_to_name']);
}
}
}
foreach ($this->fileData['envelope_to'] as $sEmail) {
if (strpos($sEmail, '<') !== false) {
preg_match($this->longMailEreg, $sEmail, $matches);
$sTo = trim($matches[3]);
$sToName = trim($matches[1]);
$oPHPMailer->AddAddress($sTo, $sToName);
} else {
$oPHPMailer->AddAddress($sEmail);
//Subject
$msSubject = $this->fileData['subject'];
if (!(mb_detect_encoding($msSubject, "UTF-8") == "UTF-8")) {
$msSubject = utf8_encode($msSubject);
}
}
//CC
foreach ($this->fileData['envelope_cc'] as $sEmail) {
if (strpos($sEmail, '<') !== false) {
preg_match($this->longMailEreg, $sEmail, $matches);
$sTo = trim($matches[3]);
$sToName = trim($matches[1]);
$oPHPMailer->AddCC($sTo, $sToName);
} else {
$oPHPMailer->AddCC($sEmail);
$phpMailer->Subject = $msSubject;
//Body
$msBody = $this->fileData['body'];
if (!(mb_detect_encoding($msBody, "UTF-8") == "UTF-8")) {
$msBody = utf8_encode($msBody);
}
}
//BCC
foreach ($this->fileData['envelope_bcc'] as $sEmail) {
if (strpos($sEmail, '<') !== false) {
preg_match($this->longMailEreg, $sEmail, $matches);
$sTo = trim($matches[3]);
$sToName = trim($matches[1]);
$oPHPMailer->AddBCC($sTo, $sToName);
} else {
$oPHPMailer->AddBCC($sEmail);
$phpMailer->Body = $msBody;
//Attachments
$attachment = @unserialize($this->fileData['attachments']);
if ($attachment === false) {
$attachment = $this->fileData['attachments'];
}
}
if (is_array($attachment)) {
foreach ($attachment as $key => $fileAttach) {
if (file_exists($fileAttach)) {
$phpMailer->AddAttachment($fileAttach, is_int($key) ? '' : $key);
}
}
}
//To
foreach ($this->fileData['envelope_to'] as $email) {
if (strpos($email, '<') !== false) {
preg_match($this->longMailEreg, $email, $matches);
$toAddress = '';
if (!empty($matches[3])) {
$toAddress = trim($matches[3]);
}
$toName = '';
if (!empty($matches[1])) {
$toName = trim($matches[1]);
}
if (!empty($toAddress)) {
$phpMailer->AddAddress($toAddress, $toName);
} else {
throw new Exception('Invalid address: ' . $email);
}
} else {
$phpMailer->AddAddress($email);
}
}
//CC
foreach ($this->fileData['envelope_cc'] as $email) {
if (strpos($email, '<') !== false) {
preg_match($this->longMailEreg, $email, $matches);
$ccAddress = '';
if (!empty($matches[3])) {
$ccAddress = trim($matches[3]);
}
$ccName = '';
if (!empty($matches[1])) {
$ccName = trim($matches[1]);
}
if (!empty($ccAddress)) {
$phpMailer->AddCC($ccAddress, $ccName);
} else {
throw new Exception('Invalid address: ' . $email);
}
} else {
$phpMailer->AddCC($email);
}
}
//BCC
foreach ($this->fileData['envelope_bcc'] as $email) {
if (strpos($email, '<') !== false) {
preg_match($this->longMailEreg, $email, $matches);
$bccAddress = '';
if (!empty($matches[3])) {
$bccAddress = trim($matches[3]);
}
$bccName = '';
if (!empty($matches[1])) {
$bccName = trim($matches[1]);
}
if (!empty($bccAddress)) {
$phpMailer->AddBCC($bccAddress, $bccName);
} else {
throw new Exception('Invalid address: ' . $email);
}
} else {
$phpMailer->AddBCC($email);
}
}
//IsHtml
$phpMailer->IsHTML($this->fileData["contentTypeIsHtml"]);
$oPHPMailer->IsHTML($this->fileData["contentTypeIsHtml"]);
if ($this->config['MESS_ENGINE'] == 'MAIL') {
$phpMailer->WordWrap = 300;
}
if ($this->config['MESS_ENGINE'] == 'MAIL') {
$oPHPMailer->WordWrap = 300;
}
if ($oPHPMailer->Send()) {
$this->error = '';
$this->status = 'sent';
} else {
$this->error = $oPHPMailer->ErrorInfo;
$this->status = 'failed';
if ($phpMailer->Send()) {
$this->error = '';
$this->status = 'sent';
} else {
$this->error = $phpMailer->ErrorInfo;
$this->status = 'failed';
$this->updateSpoolError($this->error);
}
} catch (Exception $error) {
$this->updateSpoolError($error->getMessage());
}
break;
case 'OPENMAIL':
@@ -605,8 +708,8 @@ class SpoolRun
} catch (Exception $e) {
$strAux = "Spool::resendEmails(): Using " . $configuration["MESS_ENGINE"] . " for APP_MGS_UID=" . $row["APP_MSG_UID"] . " -> With message: " . $e->getMessage();
if ($e->getCode() == $this->ExceptionCode["WARNING"]) {
array_push($this->aWarnings, $strAux);
if ($e->getCode() == $this->exceptionCode["WARNING"]) {
array_push($this->warnings, $strAux);
continue;
} else {
error_log('<400> ' . $strAux);
@@ -625,47 +728,54 @@ class SpoolRun
*/
public function getWarnings()
{
if (sizeof($this->aWarnings) != 0) {
return $this->aWarnings;
if (sizeof($this->warnings) != 0) {
return $this->warnings;
}
return false;
}
/**
* db_insert
* Insert the record in the AppMessage
*
* @param array $db_spool
* @return string $sUID;
* @param array $dbSpool
*
* @return string
*
* @see SpoolRun::create()
*/
public function db_insert($db_spool)
public function dbInsert($dbSpool)
{
$sUID = G::generateUniqueID();
$appMsgUid = G::generateUniqueID();
//Set some values for generate the log
$this->setAppMsgUid($appMsgUid);
$this->setAppUid($dbSpool['app_uid']);
//Set values for register the record
$spool = new AppMessage();
$spool->setAppMsgUid($sUID);
$spool->setMsgUid($db_spool['msg_uid']);
$spool->setAppUid($db_spool['app_uid']);
$spool->setDelIndex($db_spool['del_index']);
$spool->setAppMsgType($db_spool['app_msg_type']);
$spool->setAppMsgTypeId(isset(AppMessage::$app_msg_type_values[$db_spool['app_msg_type']]) ? AppMessage::$app_msg_type_values[$db_spool['app_msg_type']] : 0);
$spool->setAppMsgSubject($db_spool['app_msg_subject']);
$spool->setAppMsgFrom($db_spool['app_msg_from']);
$spool->setAppMsgTo($db_spool['app_msg_to']);
$spool->setAppMsgBody($db_spool['app_msg_body']);
$spool->setAppMsgUid($appMsgUid);
$spool->setMsgUid($dbSpool['msg_uid']);
$spool->setAppUid($dbSpool['app_uid']);
$spool->setDelIndex($dbSpool['del_index']);
$spool->setAppMsgType($dbSpool['app_msg_type']);
$spool->setAppMsgTypeId(isset(AppMessage::$app_msg_type_values[$dbSpool['app_msg_type']]) ? AppMessage::$app_msg_type_values[$dbSpool['app_msg_type']] : 0);
$spool->setAppMsgSubject($dbSpool['app_msg_subject']);
$spool->setAppMsgFrom($dbSpool['app_msg_from']);
$spool->setAppMsgTo($dbSpool['app_msg_to']);
$spool->setAppMsgBody($dbSpool['app_msg_body']);
$spool->setAppMsgDate(date('Y-m-d H:i:s'));
$spool->setAppMsgCc($db_spool['app_msg_cc']);
$spool->setAppMsgBcc($db_spool['app_msg_bcc']);
$spool->setappMsgAttach($db_spool['app_msg_attach']);
$spool->setAppMsgTemplate($db_spool['app_msg_template']);
$spool->setAppMsgStatus($db_spool['app_msg_status']);
$spool->setAppMsgStatusId(isset(AppMessage::$app_msg_status_values[$db_spool['app_msg_status']]) ? AppMessage::$app_msg_status_values[$db_spool['app_msg_status']] : 0);
$spool->setAppMsgCc($dbSpool['app_msg_cc']);
$spool->setAppMsgBcc($dbSpool['app_msg_bcc']);
$spool->setappMsgAttach($dbSpool['app_msg_attach']);
$spool->setAppMsgTemplate($dbSpool['app_msg_template']);
$spool->setAppMsgStatus($dbSpool['app_msg_status']);
$spool->setAppMsgStatusId(isset(AppMessage::$app_msg_status_values[$dbSpool['app_msg_status']]) ? AppMessage::$app_msg_status_values[$dbSpool['app_msg_status']] : 0);
$spool->setAppMsgSendDate(date('Y-m-d H:i:s'));
$spool->setAppMsgShowMessage($db_spool['app_msg_show_message']);
$spool->setAppMsgError($db_spool['app_msg_error']);
$spool->setAppMsgShowMessage($dbSpool['app_msg_show_message']);
$spool->setAppMsgError($dbSpool['app_msg_error']);
$appDelegation = new AppDelegation();
if (empty($db_spool['app_number'])) {
$delegationIds = $appDelegation->getColumnIds($db_spool['app_uid'], $db_spool['del_index']);
if (empty($dbSpool['app_number'])) {
$delegationIds = $appDelegation->getColumnIds($dbSpool['app_uid'], $dbSpool['del_index']);
if (is_array($delegationIds) && count($delegationIds) > 0) {
$delegationIds = array_change_key_case($delegationIds);
$appNumber = $delegationIds['app_number'];
@@ -674,19 +784,19 @@ class SpoolRun
$appNumber = 0;
}
} else {
$appNumber = $db_spool['app_number'];
$appNumber = $dbSpool['app_number'];
}
if (empty($db_spool['tas_id'])) {
if (empty($dbSpool['tas_id'])) {
$tasId = isset($delegationIds['tas_id']) ? $delegationIds['tas_id'] : 0;
} else {
$tasId = $db_spool['tas_id'];
$tasId = $dbSpool['tas_id'];
}
if (empty($db_spool['pro_id'])) {
if (empty($dbSpool['pro_id'])) {
$proId = isset($delegationIds['pro_id']) ? $delegationIds['pro_id'] : $appDelegation->getProcessId($appNumber);
} else {
$proId = $db_spool['pro_id'];
$proId = $dbSpool['pro_id'];
}
$spool->setAppNumber($appNumber);
@@ -706,6 +816,6 @@ class SpoolRun
$spool->save();
}
return $sUID;
return $appMsgUid;
}
}

View File

@@ -2,13 +2,14 @@
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Process as BmProcess;
/*----------------------------------********---------------------------------*/
use ProcessMaker\ChangeLog\ChangeLog;
/*----------------------------------********---------------------------------*/
use ProcessMaker\BusinessModel\Process as BmProcess;
use ProcessMaker\Core\Installer;
use ProcessMaker\Core\System;
use ProcessMaker\Plugins\Adapters\PluginAdapter;
use ProcessMaker\Project\Adapter\BpmnWorkflow;
use ProcessMaker\Util\FixReferencePath;
/**
@@ -2397,7 +2398,7 @@ class WorkspaceTools
return;
}
$arrayTable1 = ['ListInbox', 'ListMyInbox', 'ListCanceled', 'ListParticipatedLast', 'ListParticipatedHistory', 'ListPaused', 'ListCompleted'];
$arrayTable1 = ['ListInbox', 'ListMyInbox', 'ListCanceled', 'ListParticipatedLast', 'ListParticipatedHistory', 'ListPaused'];
$arrayTable2 = ['ListUnassigned', 'ListUnassignedGroup'];
$arrayTable = array_merge($arrayTable1, $arrayTable2);
@@ -2423,7 +2424,6 @@ class WorkspaceTools
}
if ($flagReinsert || !$flagListAll) {
$this->regenerateListCompleted($lang);
$this->regenerateListCanceled($lang);
$this->regenerateListMyInbox(); //This list require no translation
$this->regenerateListInbox(); //This list require no translation
@@ -2508,69 +2508,6 @@ class WorkspaceTools
CLI::logging("> Completed table LIST_CANCELED\n");
}
public function regenerateListCompleted($lang = 'en')
{
$this->initPropel(true);
$query = 'INSERT INTO ' . $this->dbName . '.LIST_COMPLETED
(APP_UID,
USR_UID,
TAS_UID,
PRO_UID,
APP_NUMBER,
APP_TITLE,
APP_PRO_TITLE,
APP_TAS_TITLE,
APP_CREATE_DATE,
APP_FINISH_DATE,
DEL_INDEX,
DEL_PREVIOUS_USR_UID,
DEL_CURRENT_USR_USERNAME,
DEL_CURRENT_USR_FIRSTNAME,
DEL_CURRENT_USR_LASTNAME)
SELECT
ACV.APP_UID,
ACV.USR_UID,
ACV.TAS_UID,
ACV.PRO_UID,
ACV.APP_NUMBER,
C_APP.CON_VALUE AS APP_TITLE,
C_PRO.CON_VALUE AS APP_PRO_TITLE,
C_TAS.CON_VALUE AS APP_TAS_TITLE,
ACV.APP_CREATE_DATE,
ACV.APP_FINISH_DATE,
ACV.DEL_INDEX,
PREV_AD.USR_UID AS DEL_PREVIOUS_USR_UID,
USR.USR_USERNAME AS DEL_CURRENT_USR_USERNAME,
USR.USR_FIRSTNAME AS DEL_CURRENT_USR_FIRSTNAME,
USR.USR_LASTNAME AS DEL_CURRENT_USR_LASTNAME
FROM
(' . $this->dbName . '.APP_CACHE_VIEW ACV
LEFT JOIN ' . $this->dbName . '.CONTENT C_APP ON ACV.APP_UID = C_APP.CON_ID
AND C_APP.CON_CATEGORY = \'APP_TITLE\'
AND C_APP.CON_LANG = \'' . $lang . '\'
LEFT JOIN ' . $this->dbName . '.CONTENT C_PRO ON ACV.PRO_UID = C_PRO.CON_ID
AND C_PRO.CON_CATEGORY = \'PRO_TITLE\'
AND C_PRO.CON_LANG = \'' . $lang . '\'
LEFT JOIN ' . $this->dbName . '.CONTENT C_TAS ON ACV.TAS_UID = C_TAS.CON_ID
AND C_TAS.CON_CATEGORY = \'TAS_TITLE\'
AND C_TAS.CON_LANG = \'' . $lang . '\')
LEFT JOIN
(' . $this->dbName . '.APP_DELEGATION AD
INNER JOIN ' . $this->dbName . '.APP_DELEGATION PREV_AD ON AD.APP_UID = PREV_AD.APP_UID
AND AD.DEL_PREVIOUS = PREV_AD.DEL_INDEX) ON ACV.APP_UID = AD.APP_UID
AND ACV.DEL_INDEX = AD.DEL_INDEX
LEFT JOIN
' . $this->dbName . '.USERS USR ON ACV.USR_UID = USR.USR_UID
WHERE
ACV.APP_STATUS = \'COMPLETED\'
AND ACV.DEL_LAST_INDEX = 1';
$con = Propel::getConnection("workflow");
$stmt = $con->createStatement();
$stmt->executeQuery($query);
CLI::logging("> Completed table LIST_COMPLETED\n");
}
public function regenerateListMyInbox()
{
$this->initPropel(true);
@@ -3739,53 +3676,62 @@ class WorkspaceTools
CLI::logging("|--> Clean data in table " . OauthRefreshTokensPeer::TABLE_NAME . " rows " . $refreshToken . "\n");
}
/**
* Migrate the Intermediate throw Email Event to Dummy task, specify the workspaces.
* The processes in this workspace will be updated.
*
* @param string $workspaceName
* @see workflow/engine/bin/tasks/cliWorkspaces.php::run_migrate_itee_to_dummytask()
* @see workflow/engine/classes/WorkspaceTools.php->upgradeDatabase()
* @link https://wiki.processmaker.com/3.3/processmaker_command#migrate-itee-to-dummytask
*/
public function migrateIteeToDummytask($workspaceName)
{
$this->initPropel(true);
$arraySystemConfiguration = System::getSystemConfiguration('', '', $workspaceName);
$conf = new Configurations();
\G::$sysSys = $workspaceName;
\G::$pathDataSite = PATH_DATA . "sites" . PATH_SEP . \G::$sysSys . PATH_SEP;
\G::$pathDocument = PATH_DATA . 'sites' . DIRECTORY_SEPARATOR . $workspaceName . DIRECTORY_SEPARATOR . 'files';
\G::$memcachedEnabled = $arraySystemConfiguration['memcached'];
\G::$pathDataPublic = \G::$pathDataSite . "public" . PATH_SEP;
\G::$sysSkin = $conf->getConfiguration('SKIN_CRON', '');
if (is_file(\G::$pathDataSite . PATH_SEP . ".server_info")) {
$serverInfo = file_get_contents(\G::$pathDataSite . PATH_SEP . ".server_info");
$config = System::getSystemConfiguration('', '', $workspaceName);
G::$sysSys = $workspaceName;
G::$pathDataSite = PATH_DATA . "sites" . PATH_SEP . G::$sysSys . PATH_SEP;
G::$pathDocument = PATH_DATA . 'sites' . DIRECTORY_SEPARATOR . $workspaceName . DIRECTORY_SEPARATOR . 'files';
G::$memcachedEnabled = $config['memcached'];
G::$pathDataPublic = G::$pathDataSite . "public" . PATH_SEP;
G::$sysSkin = $config['default_skin'];
if (is_file(G::$pathDataSite . PATH_SEP . ".server_info")) {
$serverInfo = file_get_contents(G::$pathDataSite . PATH_SEP . ".server_info");
$serverInfo = unserialize($serverInfo);
$envHost = $serverInfo["SERVER_NAME"];
$envPort = ($serverInfo["SERVER_PORT"] . "" != "80") ? ":" . $serverInfo["SERVER_PORT"] : "";
if (!empty($envPort) && strpos($envHost, $envPort) === false) {
$envHost = $envHost . $envPort;
}
\G::$httpHost = $envHost;
G::$httpHost = $envHost;
}
//Search All process
$oCriteria = new Criteria("workflow");
$oCriteria->addSelectColumn(ProcessPeer::PRO_UID);
$oCriteria->addSelectColumn(ProcessPeer::PRO_ITEE);
$oCriteria->add(ProcessPeer::PRO_ITEE, '0', Criteria::EQUAL);
$rsCriteria = ProcessPeer::doSelectRS($oCriteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$criteria = new Criteria("workflow");
$criteria->addSelectColumn(ProcessPeer::PRO_UID);
$criteria->addSelectColumn(ProcessPeer::PRO_ITEE);
$criteria->add(ProcessPeer::PRO_ITEE, '0', Criteria::EQUAL);
$resultSet = ProcessPeer::doSelectRS($criteria);
$resultSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$message = "-> Migrating the Intermediate Email Event \n";
CLI::logging($message);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$prj_uid = $row['PRO_UID'];
$bpmnProcess = new Process();
if ($bpmnProcess->isBpmnProcess($prj_uid)) {
$project = new \ProcessMaker\Project\Adapter\BpmnWorkflow();
$diagram = $project->getStruct($prj_uid);
$res = $project->updateFromStruct($prj_uid, $diagram);
$bpmnProcess->setProUid($prj_uid);
$oProcess = new Process();
$aProcess['PRO_UID'] = $prj_uid;
$aProcess['PRO_ITEE'] = '1';
if ($oProcess->processExists($prj_uid)) {
$oProcess->update($aProcess);
while ($resultSet->next()) {
$row = $resultSet->getRow();
$prjUid = $row['PRO_UID'];
$process = new Process();
if ($process->isBpmnProcess($prjUid)) {
$project = new BpmnWorkflow();
$diagram = $project->getStruct($prjUid);
$project->updateFromStruct($prjUid, $diagram);
$process->setProUid($prjUid);
$updateProcess = new Process();
$updateProcessData = [];
$updateProcessData['PRO_UID'] = $prjUid;
$updateProcessData['PRO_ITEE'] = '1';
if ($updateProcess->processExists($prjUid)) {
$updateProcess->update($updateProcessData);
}
$message = " Process updated " . $bpmnProcess->getProTitle() . "\n";
$message = " Process updated " . $process->getProTitle() . "\n";
CLI::logging($message);
}
}

View File

@@ -8,8 +8,19 @@ use ProcessMaker\Core\System;
class WsBase
{
const MESSAGE_TYPE_ACTIONS_BY_EMAIL = 'ACTIONS_BY_EMAIL';
const MESSAGE_TYPE_CASE_NOTE = 'CASE_NOTE';
const MESSAGE_TYPE_EMAIL_EVENT = 'EVENT';
const MESSAGE_TYPE_EXTERNAL_REGISTRATION = 'EXTERNAL_REGISTRATION';
const MESSAGE_TYPE_PM_FUNCTION = 'PM_FUNCTION';
const MESSAGE_TYPE_RETRIEVE_PASSWORD = 'RETRIEVE_PASSWORD';
const MESSAGE_TYPE_SOAP = 'SOAP';
const MESSAGE_TYPE_TASK_NOTIFICATION = 'ROUTING';
const MESSAGE_TYPE_TEST_EMAIL = 'TEST';
public $stored_system_variables; //boolean
public $wsSessionId; //web service session id, if the wsbase function is used from a WS request
private $taskId;
private $flagSameCase = true;
public function __construct($params = null)
{
@@ -22,6 +33,50 @@ class WsBase
}
}
/**
* Get the flagSameCase
*
* @return boolean
*/
public function getFlagSameCase()
{
return $this->flagSameCase;
}
/**
* Set the flagSameCase
*
* @param boolean $var
*
* @return void
*/
public function setFlagSameCase($var)
{
$this->flagSameCase = $var;
}
/**
* Get the taskId
*
* @return int
*/
public function getTaskId()
{
return $this->taskId;
}
/**
* Set the taskId
*
* @param int $taskId
*
* @return void
*/
public function setTaskId($taskId)
{
$this->taskId = $taskId;
}
/**
* function to start a web services session in ProcessMaker
*
@@ -831,6 +886,13 @@ class WsBase
* @param array $config
*
* @return $result will return an object
*
* @see ActionsByEmailCoreClass->sendActionsByEmail()
* @see workflow\engine\classes\class.pmFunctions::PMFSendMessage()
* @see workflow\engine\methods\services\soap2::sendMessage()
* @see \ProcessMaker\BusinessModel\EmailEvent->sendEmail()
* @see \ProcessMaker\BusinessModel\Pmgmail->sendEmailWithApplicationData()
*
*/
public function sendMessage(
$appUid,
@@ -845,7 +907,8 @@ class WsBase
$showMessage = true,
$delIndex = 0,
$config = [],
$gmail = 0
$gmail = 0,
$appMsgType = WsBase::MESSAGE_TYPE_PM_FUNCTION
)
{
try {
@@ -897,7 +960,7 @@ class WsBase
$spool->setConfig($setup);
$case = new Cases();
$oldFields = $case->loadCase($appUid);
$oldFields = $case->loadCase($appUid, $delIndex);
if ($gmail == 1) {
$pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP;
} else {
@@ -923,11 +986,11 @@ class WsBase
'',
$appUid,
$delIndex,
'TRIGGER',
$appMsgType,
$subject,
G::buildFrom($setup, $from),
$to,
G::replaceDataGridField(file_get_contents($fileTemplate), $fieldsCase, false),
G::replaceDataGridField(file_get_contents($fileTemplate), $fieldsCase, false, true),
$cc,
$bcc,
'',
@@ -938,7 +1001,7 @@ class WsBase
(preg_match("/^.+\.html?$/i", $fileTemplate)) ? true : false,
isset($fieldsCase['APP_NUMBER']) ? $fieldsCase['APP_NUMBER'] : 0,
isset($fieldsCase['PRO_ID']) ? $fieldsCase['PRO_ID'] : 0,
isset($fieldsCase['TAS_ID']) ? $fieldsCase['TAS_ID'] : 0
$this->getTaskId() ?$this->getTaskId():(isset($oldFields['TAS_ID'])? $oldFields['TAS_ID'] : 0)
);
$spool->create($messageArray);
@@ -1333,6 +1396,8 @@ class WsBase
$result = new WsResponse(-1, G::LoadTranslation("ID_INVALID_DATA") . " $status");
return $result;
} else {
$status == 'INACTIVE' ? $RBAC->destroySessionUser($userUid) : null;
}
}
@@ -2067,57 +2132,72 @@ class WsBase
}
/**
* creates a new case impersonating a user who has the proper privileges to create new cases
* Creates a new case impersonating a user who has the proper privileges to create new cases
*
* @param string $processId
* @param string $userId
* @param string $variables
* @param string $taskId , must be in the starting group.
* @param array $variables, that are set in the new case
* @param string $taskId, must be in the starting group.
*
* @return $result will return an object
* @return object
*
* @see PMFNewCaseImpersonate/class.pmFunctions.php on
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#PMFNewCaseImpersonate.28.29
*
* @see doPostCaseImpersonate/Api/Cases on
* @link https://wiki.processmaker.com/3.2/REST_API_Cases/Cases#New_Case_Impersonate_User:_POST_.2Fcases.2Fimpersonate
*
* @see NewCaseImpersonate/soap2.php on
* @link https://wiki.processmaker.com/3.0/ProcessMaker_WSDL_Web_Services#newCaseImpersonate.28.29
*/
public function newCaseImpersonate($processId, $userId, $variables, $taskId = '')
{
try {
if (is_array($variables)) {
if (count($variables) > 0) {
$c = count($variables);
$Fields = $variables;
} else {
if ($c == 0) {
$result = new WsResponse(10, G::loadTranslation('ID_ARRAY_VARIABLES_EMPTY'));
$g = new G();
$g->sessionVarSave();
return $result;
}
$c = count($variables);
if (is_array($variables)) {
if ($c > 0) {
$fieldsVariables = $variables;
} elseif ($c === 0) {
$result = new WsResponse(10, G::loadTranslation('ID_ARRAY_VARIABLES_EMPTY'));
$g->sessionVarRestore();
return $result;
}
} else {
$result = new WsResponse(10, G::loadTranslation('ID_VARIABLES_PARAM_NOT_ARRAY'));
$g->sessionVarRestore();
return $result;
}
$processes = new Processes();
if (!$processes->processExists($processId)) {
$result = new WsResponse(11, G::loadTranslation('ID_INVALID_PROCESS') . " " . $processId . "!!");
$g->sessionVarRestore();
return $result;
}
$user = new Users();
if (!$user->userExists($userId)) {
$result = new WsResponse(11, G::loadTranslation('ID_USER_NOT_REGISTERED') . " " . $userId . "!!");
$g->sessionVarRestore();
return $result;
} else {
$user->load($userId);
$userName = $user->getUsrUsername();
}
$oCase = new Cases();
$caseInstance = new Cases();
$numTasks = 0;
if ($taskId != '') {
$aTasks = $processes->getStartingTaskForUser($processId, null);
foreach ($aTasks as $task) {
if (!empty($taskId)) {
$startTasks = $processes->getStartingTaskForUser($processId, null);
foreach ($startTasks as $task) {
if ($task['TAS_UID'] == $taskId) {
$arrayTask[0]['TAS_UID'] = $taskId;
$numTasks = 1;
@@ -2128,38 +2208,47 @@ class WsBase
$numTasks = count($arrayTask);
}
if ($numTasks == 1) {
$case = $oCase->startCase($arrayTask[0]['TAS_UID'], $userId);
$caseId = $case['APPLICATION'];
$caseNumber = $case['CASE_NUMBER'];
if ($numTasks === 1) {
//@todo Find a better way to define session variables
$_SESSION["PROCESS"] = $processId;
$_SESSION["TASK"] = $arrayTask[0]['TAS_UID'];
$_SESSION["USER_LOGGED"] = $userId;
$_SESSION["INDEX"] = 1;
$_SESSION["USR_USERNAME"] = $userName;
$oldFields = $oCase->loadCase($caseId);
$oldFields['APP_DATA'] = array_merge($oldFields['APP_DATA'], $Fields);
$up_case = $oCase->updateCase($caseId, $oldFields);
//Create a newCase
$infoCase = $caseInstance->startCase($arrayTask[0]['TAS_UID'], $userId);
$_SESSION["APPLICATION"] = $caseId = $infoCase['APPLICATION'];
$oldFields = $caseInstance->loadCase($caseId);
//Merge the data with the $fieldsVariables that are set in the new case
$oldFields['APP_DATA'] = array_merge($oldFields['APP_DATA'], $fieldsVariables);
//Update the case
$res = $caseInstance->updateCase($caseId, $oldFields);
$result = new WsResponse(0, G::loadTranslation('ID_COMMAND_EXECUTED_SUCCESSFULLY'));
$result->caseId = $caseId;
$result->caseNumber = $caseNumber;
$result->caseNumber = $infoCase['CASE_NUMBER'];
$g->sessionVarRestore();
return $result;
} else {
if ($numTasks == 0) {
if ($numTasks === 0) {
$result = new WsResponse(12, G::loadTranslation('ID_NO_STARTING_TASK'));
$g->sessionVarRestore();
return $result;
}
if ($numTasks > 1) {
$result = new WsResponse(13, G::loadTranslation('ID_MULTIPLE_STARTING_TASKS'));
$g->sessionVarRestore();
return $result;
}
}
} catch (Exception $e) {
$result = new WsResponse(100, $e->getMessage());
$g->sessionVarRestore();
return $result;
}
@@ -2178,6 +2267,8 @@ class WsBase
* @param string $labelAssignment , label related to the triggerType
*
* @return string $varTriggers updated
*
* @see WsBase::derivateCase()
*/
public function executeTriggerFromDerivate(
$appUid,
@@ -2243,10 +2334,14 @@ class WsBase
*
* @param string $userId
* @param string $caseId
* @param string $delIndex
* @param array $tasks
* @param integer $delIndex
* @param bool $bExecuteTriggersBeforeAssignment
* @param array $tasks
*
* @return $result will return an object
*
* @see PMFDerivateCase()/class.pmFunctions.php on
* @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions/Case_Routing_Functions#PMFDerivateCase.28.29
*/
public function derivateCase($userId, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false, $tasks = [])
{
@@ -3061,6 +3156,10 @@ class WsBase
public function cancelCase($caseUid, $delIndex, $userUid)
{
$g = new G();
//We will to review if the current case in execution will be execute the same
if (isset($_SESSION["APPLICATION"]) && $_SESSION["APPLICATION"] !== $caseUid){
$this->setFlagSameCase(false);
}
try {
$g->sessionVarSave();
@@ -3086,7 +3185,7 @@ class WsBase
/** If those parameters are null we will to force the cancelCase */
if (is_null($delIndex) && is_null($userUid)) {
/*----------------------------------********---------------------------------*/
$case->cancelCase($caseUid, null, null);
$case->cancelCase($caseUid, null, null, $this->getFlagSameCase());
$result = self::messageExecuteSuccessfully();
$g->sessionVarRestore();
@@ -3123,7 +3222,7 @@ class WsBase
/** Cancel case */
$case->cancelCase($caseUid, (int)$delIndex, $userUid);
$case->cancelCase($caseUid, (int)$delIndex, $userUid, $this->getFlagSameCase());
//Define the result of the cancelCase
$result = self::messageExecuteSuccessfully();
@@ -3146,7 +3245,12 @@ class WsBase
* @param string userUid : The unique ID of the user who will pause the case.
* @param string unpauseDate : Optional parameter. The date in the format "yyyy-mm-dd" indicating when to unpause
* the case.
*
*
* @see workflow/engine/classes/class.pmFunctions.php::PMFPauseCase()
* @see workflow/engine/methods/services/soap2.php::pauseCase()
*
* @link https://wiki.processmaker.com/3.3/ProcessMaker_Functions/Case_Functions#PMFPauseCase.28.29
*
* @return $result will return an object
*/
public function pauseCase($caseUid, $delIndex, $userUid, $unpauseDate = null)
@@ -3182,6 +3286,22 @@ class WsBase
return $result;
}
//Validate if status is closed
$appDelegation = new AppDelegation();
$rows = $appDelegation->LoadParallel($caseUid, $delIndex);
if (empty($rows)) {
$result = new WsResponse(100, G::LoadTranslation('ID_CASE_DELEGATION_ALREADY_CLOSED'));
$g->sessionVarRestore();
return $result;
}
//Validate if the case is paused
$appDelay = new AppDelay();
$sw = $appDelay->isPaused($caseUid, $delIndex);
if ($sw === true) {
$result = new WsResponse(19, G::LoadTranslation('ID_CASE_IN_STATUS') . " " . AppDelay::APP_TYPE_PAUSE);
$g->sessionVarRestore();
return $result;
}
if (strlen($unpauseDate) >= 10) {
if (!preg_match("/^\d{4}-\d{2}-\d{2}| \d{2}:\d{2}:\d{2}$/", $unpauseDate)) {
$result = new WsResponse(100, G::LoadTranslation("ID_INVALID_DATA") . " $unpauseDate");

View File

@@ -28,11 +28,11 @@
//
// License: LGPL, see LICENSE
////////////////////////////////////////////////////
use ProcessMaker\BusinessModel\Cases as BusinessModelCases;
use ProcessMaker\Core\System;
use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Util\ElementTranslation;
/**
* ProcessMaker has made a number of its PHP functions available be used in triggers and conditions.
* Most of these functions are wrappers for internal functions used in Gulliver, which is the development framework
@@ -920,34 +920,34 @@ function getEmailConfiguration ()
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFSendMessage.28.29
*
* @param string(32) | $caseId | UID for case | The UID (unique identification) for a case, which is a string of 32 hexadecimal characters to identify the case.
* @param string(32) | $sFrom | Sender | The email address of the person who sends out the email.
* @param string(100) | $sTo | Recipient | The email address(es) to whom the email is sent. If multiple recipients, separate each email address with a comma.
* @param string(100) | $sCc = '' | Carbon copy recipient | The email address(es) of people who will receive carbon copies of the email.
* @param string(100) | $sBcc = ''| Carbon copy recipient | The email address(es) of people who will receive blind carbon copies of the email.
* @param string(50) | $sSubject | Subject of the email | The subject (title) of the email.
* @param string(50) | $sTemplate | Name of the template | The name of the template file in plain text or HTML format which will produce the body of the email.
* @param array | $aFields = array() | Variables for email template | Optional parameter. An associative array where the keys are the variable names and the values are the variables' values.
* @param array | $aAttachment = array() | Attachment | An Optional arrray. An array of files (full paths) to be attached to the email.
* @param string(32) | $from | Sender | The email address of the person who sends out the email.
* @param string(100) | $to | Recipient | The email address(es) to whom the email is sent. If multiple recipients, separate each email address with a comma.
* @param string(100) | $cc = '' | Carbon copy recipient | The email address(es) of people who will receive carbon copies of the email.
* @param string(100) | $bcc = ''| Carbon copy recipient | The email address(es) of people who will receive blind carbon copies of the email.
* @param string(50) | $subject | Subject of the email | The subject (title) of the email.
* @param string(50) | $template | Name of the template | The name of the template file in plain text or HTML format which will produce the body of the email.
* @param array | $emailTemplateVariables = [] | Variables for email template | Optional parameter. An associative array where the keys are the variable names and the values are the variables' values.
* @param array | $attachments = [] | Attachment | An Optional arrray. An array of files (full paths) to be attached to the email.
* @param boolean | $showMessage = true | Show message | Optional parameter. Set to TRUE to show the message in the case's message history.
* @param int | $delIndex = 0 | Delegation index of the case | Optional parameter. The delegation index of the current task in the case.
* @param string(100) | $config = '' | Email server configuration | An optional array: An array of parameters to be used in the Email sent (MESS_ENGINE, MESS_SERVER, MESS_PORT, MESS_FROM_MAIL, MESS_RAUTH, MESS_ACCOUNT, MESS_PASSWORD, and SMTPSecure) Or String: UID of Email server .
* @param array | $config = [] | Email server configuration | An optional array: An array of parameters to be used in the Email sent (MESS_ENGINE, MESS_SERVER, MESS_PORT, MESS_FROM_MAIL, MESS_RAUTH, MESS_ACCOUNT, MESS_PASSWORD, and SMTPSecure) Or String: UID of Email server .
* @return int | | result | Result of sending email
*
* @see class.pmFunctions::PMFSendMessageToGroup()
*/
//@param array | $aFields=array() | An associative array optional | Optional parameter. An associative array where the keys are the variable name and the values are the variable's value.
function PMFSendMessage(
$caseId,
$sFrom,
$sTo,
$sCc,
$sBcc,
$sSubject,
$sTemplate,
$aFields = array(),
$aAttachment = array(),
$from,
$to,
$cc,
$bcc,
$subject,
$template,
$emailTemplateVariables = [],
$attachments = [],
$showMessage = true,
$delIndex = 0,
$config = array()
$config = []
) {
ini_set ( "pcre.backtrack_limit", 1000000 );
ini_set ( 'memory_limit', '-1' );
@@ -955,28 +955,30 @@ function PMFSendMessage(
global $oPMScript;
if (isset( $oPMScript->aFields ) && is_array( $oPMScript->aFields )) {
if (is_array( $aFields )) {
$aFields = array_merge( $oPMScript->aFields, $aFields );
if (isset($oPMScript->aFields) && is_array($oPMScript->aFields)) {
if (is_array($emailTemplateVariables)) {
$emailTemplateVariables = array_merge($oPMScript->aFields, $emailTemplateVariables);
} else {
$aFields = $oPMScript->aFields;
$emailTemplateVariables = $oPMScript->aFields;
}
}
$ws = new WsBase();
$result = $ws->sendMessage(
$caseId,
$sFrom,
$sTo,
$sCc,
$sBcc,
$sSubject,
$sTemplate,
$aFields,
$aAttachment,
$from,
$to,
$cc,
$bcc,
$subject,
$template,
$emailTemplateVariables,
$attachments,
$showMessage,
$delIndex,
$config
$config,
0,
WsBase::MESSAGE_TYPE_PM_FUNCTION
);
if ($result->status_code == 0) {
@@ -2825,7 +2827,7 @@ function PMFPauseCase ($caseUid, $delIndex, $userUid, $unpauseDate = null)
{
$ws = new WsBase();
$result = $ws->pauseCase($caseUid, $delIndex, $userUid, $unpauseDate);
$result = (object) $result;
if ($result->status_code == 0) {
if (isset($_SESSION['APPLICATION']) && isset($_SESSION['INDEX'])) {
if ($_SESSION['APPLICATION'] == $caseUid && $_SESSION['INDEX'] == $delIndex) {
@@ -3470,38 +3472,26 @@ function PMFGetNextDerivationInfo($caseUid, $delIndex)
* @param string | $skin = null | Skin | The skin
*
* @return string | $url | Direct case link | Returns the direct case link, FALSE otherwise
* @link https://wiki.processmaker.com/3.2/Direct_Case_Link
*/
function PMFCaseLink($caseUid, $workspace = null, $language = null, $skin = null)
{
try {
$case = new \ProcessMaker\BusinessModel\Cases();
$case = new BusinessModelCases();
$arrayApplicationData = $case->getApplicationRecordByPk($caseUid, [], false);
if ($arrayApplicationData === false) {
return false;
}
$conf = new Configurations();
$envSkin = defined("SYS_SKIN") ? SYS_SKIN : $conf->getConfiguration('SKIN_CRON', '');
$workspace = (!empty($workspace)) ? $workspace : config("system.workspace");
$language = (!empty($language)) ? $language : SYS_LANG;
$skin = (!empty($skin)) ? $skin : $envSkin;
$workspace = !empty($workspace) ? $workspace : config("system.workspace");
$language = !empty($language) ? $language : SYS_LANG;
if (empty($skin)) {
$config = System::getSystemConfiguration();
$skin = defined("SYS_SKIN") ? SYS_SKIN : $config['default_skin'];
}
$uri = '/sys' . $workspace . '/' . $language . '/' . $skin . '/cases/opencase/' . $caseUid;
$envHost = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : SERVER_NAME;
$envProtocol = defined("REQUEST_SCHEME") && REQUEST_SCHEME === "https";
if (isset($_SERVER['SERVER_PORT'])) {
$envPort = ($_SERVER['SERVER_PORT'] != "80") ? ":" . $_SERVER['SERVER_PORT'] : "";
} else if (defined('SERVER_PORT')) {
$envPort = (SERVER_PORT . "" != "80") ? ":" . SERVER_PORT : "";
} else {
$envPort = "";
}
if (!empty($envPort) && strpos($envHost, $envPort) === false) {
$envHost = $envHost . $envPort;
}
$link = (G::is_https() || $envProtocol ? 'https://' : 'http://') . $envHost . $uri;
$link = System::getServerProtocolHost() . $uri;
return $link;
} catch (Exception $e) {
throw $e;

View File

@@ -281,15 +281,22 @@ class PMScript
self::AFTER_EXTERNAL_STEP : self::UNDEFINED_ORIGIN;
break;
case 'ASSIGN_TASK':
$stepUidObj = (int)$stepUidObj;
if ($stepUidObj === -1) {
$executedOn = $triggerType === 'BEFORE' ? self::BEFORE_ASSIGNMENT : self::UNDEFINED_ORIGIN;
} elseif ($stepUidObj === -2) {
$executedOn = $triggerType === 'BEFORE' ? self::BEFORE_ROUTING : $triggerType === 'AFTER' ?
self::AFTER_ROUTING : self::UNDEFINED_ORIGIN;
$executedOn = $triggerType === 'BEFORE' ? self::BEFORE_ROUTING : ($triggerType === 'AFTER' ?
self::AFTER_ROUTING : self::UNDEFINED_ORIGIN);
} else {
$executedOn = self::UNDEFINED_ORIGIN;
}
break;
case 'PROCESS_ACTION':
$executedOn = self::PROCESS_ACTION;
break;
case 'SCRIPT_TASK':
$executedOn = self::SCRIPT_TASK;
break;
default:
$executedOn = self::UNDEFINED_ORIGIN;
break;
@@ -304,7 +311,7 @@ class PMScript
public function executeAndCatchErrors($sScript, $sCode)
{
ob_start('handleFatalErrors');
set_error_handler('handleErrors');
set_error_handler('handleErrors', ini_get('error_reporting'));
$_SESSION['_CODE_'] = $sCode;
$_SESSION['_DATA_TRIGGER_'] = $this->dataTrigger;
$_SESSION['_DATA_TRIGGER_']['_EXECUTION_TIME_'] = microtime(true);
@@ -464,6 +471,8 @@ class PMScript
$sScript = "try {\n" . $sScript . "\n} catch (Exception \$oException) {\n " . " \$this->aFields['__ERROR__'] = utf8_encode(\$oException->getMessage());\n}";
$this->executeAndCatchErrors($sScript, $this->sScript);
//We get the affected_fields only if has the prefix
//@see https://wiki.processmaker.com/3.2/Triggers#Typing_rules_for_Case_Variables
$this->setVarsChanged($this->affected_fields);
$this->aFields["__VAR_CHANGED__"] = implode(",", $this->affected_fields);
for ($i = 0; $i < count($this->affected_fields); $i ++) {

View File

@@ -944,6 +944,8 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
*
* @param string resource path to check for locks
* @return bool true on success
* @link https://wiki.processmaker.com/index.php/WebDAV
* @deprecated
*/
public function checkLock($path)
{
@@ -959,7 +961,9 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
if ($res) {
$row = mysqli_fetch_array($res);
mysqli_free_result($res);
if (is_resource($res)) {
mysqli_free_result($res);
}
if ($row) {
$result = array("type" => "write", "scope" => $row["exclusivelock"] ? "exclusive" : "shared", "depth" => 0, "owner" => $row['owner'], "token" => $row['token'], "expires" => $row['expires']

View File

@@ -48,6 +48,17 @@ class AbeConfiguration extends BaseAbeConfiguration
}
}
/**
* Create or update.
*
* @param array $data
* @throws Exception
*
* @see Processes->createActionsByEmail()
* @see ProcessMaker\BusinessModel\ActionsByEmail->saveConfiguration()
* @see ProcessMaker\BusinessModel\ActionsByEmail->saveConfiguration2()
* @link https://wiki.processmaker.com/3.3/Actions_by_Email#Configuration
*/
public function createOrUpdate($data)
{
foreach ($data as $field => $value) {
@@ -70,6 +81,11 @@ class AbeConfiguration extends BaseAbeConfiguration
} else {
$abeConfigurationInstance = AbeConfigurationPeer::retrieveByPK($data['ABE_UID']);
}
//Only the 'FIELD' and 'LINK' types have a DYN_UID,
//the DYN_UID field is empty when the type is 'CUSTOM'.
if ($data['ABE_TYPE'] === 'CUSTOM') {
$data['DYN_UID'] = '';
}
if (isset($data['ABE_CUSTOM_GRID'])) {
$data['ABE_CUSTOM_GRID'] = serialize($data['ABE_CUSTOM_GRID']);

View File

@@ -64,6 +64,12 @@ class AppAssignSelfServiceValue extends BaseAppAssignSelfServiceValue
*
* @return void
* @throws Exception
*
* @see \Cases->removeCase()
* @see \Cases->setCatchUser()
* @see \Cases->updateCase()
*
* @link https://wiki.processmaker.com/3.2/Tasks#Self_Service_Value_Based_Assignment
*/
public function remove($applicationUid, $delIndex = 0)
{
@@ -76,18 +82,7 @@ class AppAssignSelfServiceValue extends BaseAppAssignSelfServiceValue
$criteria->add(AppAssignSelfServiceValuePeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
}
$result = AppAssignSelfServiceValuePeer::doDelete($criteria);
// Delete related rows and missing relations, criteria don't execute delete with joins
$cnn = Propel::getConnection(AppAssignSelfServiceValueGroupPeer::DATABASE_NAME);
$cnn->begin();
$stmt = $cnn->createStatement();
$rs = $stmt->executeQuery("DELETE " . AppAssignSelfServiceValueGroupPeer::TABLE_NAME . "
FROM " . AppAssignSelfServiceValueGroupPeer::TABLE_NAME . "
LEFT JOIN " . AppAssignSelfServiceValuePeer::TABLE_NAME . "
ON (" . AppAssignSelfServiceValueGroupPeer::ID . " = " . AppAssignSelfServiceValuePeer::ID . ")
WHERE " . AppAssignSelfServiceValuePeer::ID . " IS NULL");
$cnn->commit();
AppAssignSelfServiceValuePeer::doDelete($criteria);
} catch (Exception $e) {
throw $e;
}

View File

@@ -223,7 +223,6 @@ class AppDelegation extends BaseAppDelegation
try {
$res = $this->save();
} catch (PropelException $e) {
error_log($e->getMessage());
return;
}
} else {
@@ -1046,4 +1045,45 @@ class AppDelegation extends BaseAppDelegation
return $delIndex;
}
/**
* Update the priority in AppDelegation table, using the defined variable in task
*
* @param integer $delIndex
* @param string $tasUid
* @param string $appUid
* @param array $fieldAppData
*
* @return void
*
* @see Cases->update()
*
*/
public function updatePriority($delIndex, $tasUid, $appUid, $fieldAppData)
{
if (!empty($delIndex) && !empty($tasUid)) {
//Optimized code to avoid load task content row.
$criteria = new Criteria();
$criteria->clearSelectColumns();
$criteria->addSelectColumn(TaskPeer::TAS_PRIORITY_VARIABLE);
$criteria->add(TaskPeer::TAS_UID, $tasUid);
$rs = TaskPeer::doSelectRS($criteria);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rs->next();
$row = $rs->getRow();
$tasPriority = substr($row['TAS_PRIORITY_VARIABLE'], 2);
//End optimized code.
$x = $fieldAppData;
if (!empty($x[$tasPriority])) {
$array = [];
$array['APP_UID'] = $appUid;
$array['DEL_INDEX'] = $delIndex;
$array['TAS_UID'] = $tasUid;
$array['DEL_PRIORITY'] = (isset($x[$tasPriority]) ?
($x[$tasPriority] >= 1 && $x[$tasPriority] <= 5 ? $x[$tasPriority] : '3') : '3');
$this->update($array);
}
}
}
}

View File

@@ -160,7 +160,7 @@ class AppMessage extends BaseAppMessage
* @param string $appMsgTemplate,
* @param string $appMsgAttach,
* @param string $appMsgStatus,
* @param string $appMsgShowMsg,
* @param integer $appMsgShowMsg,
* @param string $appMsgError,
* @param boolean $contentTypeIsHtml
* @param integer $appNumber,
@@ -183,7 +183,7 @@ class AppMessage extends BaseAppMessage
$appMsgTemplate = '',
$appMsgAttach = '',
$appMsgStatus = 'pending',
$appMsgShowMsg = '',
$appMsgShowMsg = 1,
$appMsgError = '',
$contentTypeIsHtml = true,
$appNumber = 0,

View File

@@ -1,7 +1,7 @@
<?php
//require_once 'classes/model/om/BaseAppNotes.php';
use ProcessMaker\Core\System;
use ProcessMaker\Util\DateTime;
/**
* Skeleton subclass for representing a row from the 'APP_NOTES' table.
@@ -14,9 +14,34 @@ use ProcessMaker\Core\System;
*
* @package classes.model
*/
class AppNotes extends BaseAppNotes
{
public function getNotesList (
/**
* Get the existing case notes information from a case
*
* @param string $appUid
* @param string $usrUid
* @param string $start
* @param int $limit
* @param string $sort
* @param string $dir
* @param string $dateFrom
* @param string $dateTo
* @param string $search
*
* @return array
*
* @see \Cases->getCaseNotes()
* @see \AppProxy->getNotesList()
* @see \Home->getAppsData()
* @see workflow/engine/methods/cases/caseNotesAjax.php->getNotesList()
* @see \ProcessMaker\BusinessModel\Cases->getCaseNotes()
* @see \ProcessMaker\Services\Api\Light->doGetCaseNotes()
*
* @link https://wiki.processmaker.com/3.2/Case_Notes#Viewing_Existing_Case_Notes
*/
public function getNotesList(
$appUid,
$usrUid = '',
$start = '',
@@ -25,70 +50,71 @@ class AppNotes extends BaseAppNotes
$dir = 'DESC',
$dateFrom = '',
$dateTo = '',
$search = '')
{
$Criteria = new Criteria( 'workflow' );
$Criteria->clearSelectColumns();
$search = ''
) {
$criteria = new Criteria('workflow');
$criteria->clearSelectColumns();
$Criteria->addSelectColumn( AppNotesPeer::APP_UID );
$Criteria->addSelectColumn( AppNotesPeer::USR_UID );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_DATE );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_CONTENT );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_TYPE );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_AVAILABILITY );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_ORIGIN_OBJ );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_AFFECTED_OBJ1 );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_AFFECTED_OBJ2 );
$Criteria->addSelectColumn( AppNotesPeer::NOTE_RECIPIENTS );
$Criteria->addSelectColumn( UsersPeer::USR_USERNAME );
$Criteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
$Criteria->addSelectColumn( UsersPeer::USR_LASTNAME );
$Criteria->addSelectColumn( UsersPeer::USR_EMAIL );
$criteria->addSelectColumn(AppNotesPeer::APP_UID);
$criteria->addSelectColumn(AppNotesPeer::USR_UID);
$criteria->addSelectColumn(AppNotesPeer::NOTE_DATE);
$criteria->addSelectColumn(AppNotesPeer::NOTE_CONTENT);
$criteria->addSelectColumn(AppNotesPeer::NOTE_TYPE);
$criteria->addSelectColumn(AppNotesPeer::NOTE_AVAILABILITY);
$criteria->addSelectColumn(AppNotesPeer::NOTE_ORIGIN_OBJ);
$criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ1);
$criteria->addSelectColumn(AppNotesPeer::NOTE_AFFECTED_OBJ2);
$criteria->addSelectColumn(AppNotesPeer::NOTE_RECIPIENTS);
$criteria->addSelectColumn(UsersPeer::USR_USERNAME);
$criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
$criteria->addSelectColumn(UsersPeer::USR_LASTNAME);
$criteria->addSelectColumn(UsersPeer::USR_EMAIL);
$Criteria->addJoin( AppNotesPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN );
$criteria->addJoin(AppNotesPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
$Criteria->add( AppNotesPeer::APP_UID, $appUid, Criteria::EQUAL );
$criteria->add(AppNotesPeer::APP_UID, $appUid, Criteria::EQUAL);
if ($usrUid != '') {
$Criteria->add( AppNotesPeer::USR_UID, $usrUid, Criteria::EQUAL );
$criteria->add(AppNotesPeer::USR_UID, $usrUid, Criteria::EQUAL);
}
if ($dateFrom != '') {
$Criteria->add( AppNotesPeer::NOTE_DATE, $dateFrom, Criteria::GREATER_EQUAL );
$criteria->add(AppNotesPeer::NOTE_DATE, $dateFrom, Criteria::GREATER_EQUAL);
}
if ($dateTo != '') {
$Criteria->add( AppNotesPeer::NOTE_DATE, $dateTo, Criteria::LESS_EQUAL );
$criteria->add(AppNotesPeer::NOTE_DATE, $dateTo, Criteria::LESS_EQUAL);
}
if ($search != '') {
$Criteria->add( AppNotesPeer::NOTE_CONTENT, '%'.$search.'%', Criteria::LIKE );
$criteria->add(AppNotesPeer::NOTE_CONTENT, '%' . $search . '%', Criteria::LIKE);
}
if ($dir == 'DESC') {
$Criteria->addDescendingOrderByColumn($sort);
$criteria->addDescendingOrderByColumn($sort);
} else {
$Criteria->addAscendingOrderByColumn($sort);
$criteria->addAscendingOrderByColumn($sort);
}
$response = array ();
$totalCount = AppNotesPeer::doCount( $Criteria );
$response = [];
$totalCount = AppNotesPeer::doCount($criteria);
$response['totalCount'] = $totalCount;
$response['notes'] = array ();
$response['notes'] = [];
if ($start != '') {
$Criteria->setLimit( $limit );
$Criteria->setOffset( $start );
$criteria->setLimit($limit);
$criteria->setOffset($start);
}
$oDataset = appNotesPeer::doSelectRS( $Criteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
$dataset = AppNotesPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataset->next();
while ($aRow = $oDataset->getRow()) {
$aRow['NOTE_CONTENT'] = stripslashes($aRow['NOTE_CONTENT']);
$response['notes'][] = $aRow;
$oDataset->next();
while ($row = $dataset->getRow()) {
$row['NOTE_CONTENT'] = stripslashes($row['NOTE_CONTENT']);
$response['notes'][] = $row;
$dataset->next();
}
$result['criteria'] = $Criteria;
$result = [];
$result['criteria'] = $criteria;
$result['array'] = $response;
return $result;
@@ -154,8 +180,12 @@ class AppNotes extends BaseAppNotes
* @param string $noteRecipients
* @param string $from
* @param integer $delIndex
*
* @return void
* @throws Exception
*
* @see AppNotes->addCaseNote()
* @see AppNotes->postNewNote()
* @see workflow/engine/src/ProcessMaker/Util/helpers.php::postNote()
*/
public function sendNoteNotification ($appUid, $usrUid, $noteContent, $noteRecipients, $from = '', $delIndex = 0)
{
@@ -169,9 +199,14 @@ class AppNotes extends BaseAppNotes
$configuration['MESS_ENGINE'] = '';
}
$users = new Users();
$userInfo = $users->load($usrUid);
$authorName = ((($userInfo['USR_FIRSTNAME'] != '') || ($userInfo['USR_LASTNAME'] != '')) ? $userInfo['USR_FIRSTNAME'] . ' ' . $userInfo['USR_LASTNAME'] . ' ' : '') . '<' . $userInfo['USR_EMAIL'] . '>';
//This value can be empty when the previous task is: 'Script Task', 'Timer Event' or other without user.
if (!empty($usrUid)) {
$users = new Users();
$userInfo = $users->load($usrUid);
$authorName = ((($userInfo['USR_FIRSTNAME'] != '') || ($userInfo['USR_LASTNAME'] != '')) ? $userInfo['USR_FIRSTNAME'] . ' ' . $userInfo['USR_LASTNAME'] . ' ' : '') . '<' . $userInfo['USR_EMAIL'] . '>';
} else {
$authorName = G::LoadTranslation('UID_UNDEFINED_USER');
}
$cases = new Cases();
$fieldCase = $cases->loadCase($appUid, $delIndex);
@@ -193,7 +228,7 @@ class AppNotes extends BaseAppNotes
'',
$appUid,
$delIndex,
'DERIVATION',
WsBase::MESSAGE_TYPE_CASE_NOTE,
G::replaceDataField($configNoteNotification['subject'], $fieldCase),
G::buildFrom($configuration, $from),
$to,
@@ -203,7 +238,7 @@ class AppNotes extends BaseAppNotes
'',
'',
'pending',
'',
1,
$msgError,
true,
(isset($fieldCase['APP_NUMBER'])) ? $fieldCase['APP_NUMBER'] : 0,

View File

@@ -223,14 +223,8 @@ class Dynaform extends BaseDynaform
$description = "Create from a PM Table: " . $addTabName . ", ";
}
G::auditLog("CreateDynaform", $description . "Dynaform Title: " . $aData['DYN_TITLE'] . ", Type: " . $aData['DYN_TYPE'] . ", Description: " . $aData['DYN_DESCRIPTION'] . ", Mode: " . $mode);
$sXml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$sXml .= '<dynaForm type="' . $this->getDynType() . '" name="' . $this->getProUid() . '/' . $this->getDynUid() . '" width="500" enabletemplate="0" mode="" nextstepsave="prompt">' . "\n";
$sXml .= '</dynaForm>';
G::verifyPath(PATH_DYNAFORM . $this->getProUid(), true);
$oFile = fopen(PATH_DYNAFORM . $this->getProUid() . '/' . $this->getDynUid() . '.xml', 'w');
fwrite($oFile, $sXml);
fclose($oFile);
Form::createXMLFile($this->getProUid(), $this->getDynUid(), $this->getDynType(), PATH_DYNAFORM);
return $this->getDynUid();
} else {
$msg = '';

View File

@@ -98,13 +98,13 @@ class Groupwf extends BaseGroupwf
$this->setGrpTitle('Default Group Title');
}
if (!empty($aData['GRP_STATUS'])) {
if (!empty($data['GRP_STATUS'])) {
$this->setGrpStatus($data['GRP_STATUS']);
} else {
$this->setGrpStatus('ACTIVE');
}
if (!empty($aData['GRP_LDAP_DN'])) {
if (!empty($data['GRP_LDAP_DN'])) {
$this->setGrpLdapDn($data['GRP_LDAP_DN']);
} else {
$this->setGrpLdapDn('');

View File

@@ -13,8 +13,8 @@ require_once 'classes/model/om/BaseListCompleted.php';
* long as it does not already exist in the output directory.
*
* @package classes.model
* @deprecated Method deprecated in Release 3.3.9
*/
// @codingStandardsIgnoreStart
class ListCompleted extends BaseListCompleted implements ListInterface
{
use ListBaseTrait;

View File

@@ -1,6 +1,7 @@
<?php
require_once 'classes/model/om/BaseListParticipatedLast.php';
use ProcessMaker\BusinessModel\Cases as BmCases;
/**
@@ -536,4 +537,25 @@ class ListParticipatedLast extends BaseListParticipatedLast implements ListInter
}
BasePeer::doUpdate($criteriaWhere, $criteriaSet, $con);
}
/**
* Update the column APP_STATUS
*
* @param string $appUid
* @param string $status, can be [TO_DO, COMPLETED, etc]
*
* @return void
*
* @see Cases::updateCase()
*/
public function refreshStatus($appUid, $status = 'TO_DO')
{
//Update - WHERE
$criteriaWhere = new Criteria("workflow");
$criteriaWhere->add(ListParticipatedLastPeer::APP_UID, $appUid, Criteria::EQUAL);
//Update - SET
$criteriaSet = new Criteria("workflow");
$criteriaSet->add(ListParticipatedLastPeer::APP_STATUS, $status);
BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow"));
}
}

View File

@@ -333,18 +333,16 @@ class ListUnassigned extends BaseListUnassigned implements ListInterface
{
try {
$arrayAppAssignSelfServiceValueData = [];
$criteria = new Criteria("workflow");
$group = new Groups();
//Get the GRP_ID related to the $userUid
$arrayId = $group->getActiveGroupsForAnUserById($userUid);
$sql = "("
. AppAssignSelfServiceValueGroupPeer::ASSIGNEE_ID . " IN ("
. " SELECT " . GroupUserPeer::GRP_ID . " "
. " FROM " . GroupUserPeer::TABLE_NAME . " "
. " LEFT JOIN " . GroupwfPeer::TABLE_NAME . " ON (" . GroupUserPeer::GRP_ID . "=" . GroupwfPeer::GRP_ID . ") "
. " WHERE " . GroupUserPeer::USR_UID . "='" . $userUid . "' AND " . GroupwfPeer::GRP_STATUS . "='ACTIVE'"
. " ) AND "
. " " . AppAssignSelfServiceValueGroupPeer::ASSIGNEE_TYPE . "=2 "
. ")";
. AppAssignSelfServiceValueGroupPeer::ASSIGNEE_ID . " IN (" . implode(",", $arrayId) . ") AND "
. " " . AppAssignSelfServiceValueGroupPeer::ASSIGNEE_TYPE . " = 2 "
. ")";
$criteria->setDistinct();
$criteria->addSelectColumn(AppAssignSelfServiceValuePeer::APP_UID);

View File

@@ -130,5 +130,43 @@ class LoginLog extends BaseLoginLog
}
return $aRows;
}
/**
* Returns the last session id of a user
* @param string $userUid User uid
* @return array All session id of php
* @throws PropelException
* @throws SQLException
*/
public function getSessionsIdByUser($userUid)
{
$criteria = new Criteria();
$criteria->addSelectColumn('LOG_SID');
$criteria->add(LoginLogPeer::USR_UID, $userUid);
$criteria->add(LoginLogPeer::LOG_STATUS, 'ACTIVE');
$criteria->setDistinct();
$criteria->addDescendingOrderByColumn(LoginLogPeer::LOG_INIT_DATE);
$resultSet = LoginLogPeer::doSelectRS($criteria);
$resultSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$row = [];
while($resultSet->next()) {
$row[] = $resultSet->getRow();
}
return $row;
}
/**
* Delete all records related to a user uid
* @param string $userUid User uid
* @return int
* @throws PropelException
*/
public function removeByUser($userUid)
{
$criteria = new Criteria();
$criteria->add(LoginLogPeer::USR_UID, $userUid);
$resultSet = LoginLogPeer::doDelete($criteria);
return $resultSet;
}
}

View File

@@ -173,6 +173,20 @@ class OauthAccessTokens extends BaseOauthAccessTokens
return array("numRecTotal" => $numRecTotal, "data" => $arrayData);
}
/**
* Delete all records related to a user uid
* @param string $userUid User uid
* @return int
* @throws PropelException
*/
public function removeByUser($userUid)
{
$criteria = new Criteria();
$criteria->add(OauthAccessTokensPeer::USER_ID, $userUid);
$resultSet = OauthAccessTokensPeer::doDelete($criteria);
return $resultSet;
}
}
// OauthAccessTokens

View File

@@ -14,6 +14,19 @@ require_once 'classes/model/om/BaseOauthAuthorizationCodes.php';
*
* @package classes.model
*/
class OauthAuthorizationCodes extends BaseOauthAuthorizationCodes {
class OauthAuthorizationCodes extends BaseOauthAuthorizationCodes
{
/**
* Delete all records related to a user uid
* @param string $userUid User uid
* @return int
* @throws PropelException
*/
public function removeByUser($userUid)
{
$criteria = new Criteria();
$criteria->add(OauthAuthorizationCodesPeer::USER_ID, $userUid);
$resultSet = OauthAuthorizationCodesPeer::doDelete($criteria);
return $resultSet;
}
} // OauthAuthorizationCodes

View File

@@ -209,6 +209,19 @@ class OauthClients extends BaseOauthClients
return array("numRecTotal" => $numRecTotal, "data" => $arrayData);
}
/**
* Delete all records related to a user uid
* @param string $userUid User uid
* @return int
* @throws PropelException
*/
public function removeByUser($userUid)
{
$criteria = new Criteria();
$criteria->add(OauthClientsPeer::USR_UID, $userUid);
$resultSet = OauthClientsPeer::doDelete($criteria);
return $resultSet;
}
}
// OauthClients

View File

@@ -14,6 +14,19 @@ require_once 'classes/model/om/BaseOauthRefreshTokens.php';
*
* @package classes.model
*/
class OauthRefreshTokens extends BaseOauthRefreshTokens {
class OauthRefreshTokens extends BaseOauthRefreshTokens
{
/**
* Delete all records related to a user uid
* @param string $userUid User uid
* @return int
* @throws PropelException
*/
public function removeByUser($userUid)
{
$criteria = new Criteria();
$criteria->add(OauthRefreshTokensPeer::USER_ID, $userUid);
$resultSet = OauthRefreshTokensPeer::doDelete($criteria);
return $resultSet;
}
} // OauthRefreshTokens

View File

@@ -508,20 +508,29 @@ class OutputDocument extends BaseOutputDocument
}
}
/*
/**
* Generate the output document
* @param string $sUID
* @param array $aFields
* @param string $sPath
* @return variant
*
* @param string $outDocUid
* @param array $caseFields
* @param string $path
* @param string $filename
* @param string $content
* @param bool $landscape
* @param string $typeDocsToGen
* @param array $properties
*
* @return mixed
*
* @see workflow/engine/methods/cases/cases_Step.php
* @see workflow/engine/classes/class.pmFunctions.php:PMFGenerateOutputDocument()
*/
public function generate($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $sTypeDocToGener = 'BOTH', $aProperties = array())
public function generate($outDocUid, $caseFields, $path, $filename, $content, $landscape = false, $typeDocsToGen = 'BOTH', $properties = [])
{
if (($sUID != '') && is_array($aFields) && ($sPath != '')) {
$sContent = G::replaceDataGridField($sContent, $aFields);
if (($outDocUid != '') && is_array($caseFields) && ($path != '')) {
$content = G::replaceDataGridField($content, $caseFields, true, true);
if (strpos($sContent, '<!---{') !== false) {
if (strpos($content, '<!---{') !== false) {
$template = new Smarty();
$template->compile_dir = PATH_SMARTY_C;
$template->cache_dir = PATH_SMARTY_CACHE;
@@ -529,20 +538,20 @@ class OutputDocument extends BaseOutputDocument
$template->caching = false;
$template->left_delimiter = '<!---{';
$template->right_delimiter = '}--->';
$oFile = fopen($sPath . $sFilename . '_smarty.html', 'wb');
fwrite($oFile, $sContent);
fclose($oFile);
$template->templateFile = $sPath . $sFilename . '_smarty.html';
$fp = fopen($path . $filename . '_smarty.html', 'wb');
fwrite($fp, $content);
fclose($fp);
$template->templateFile = $path . $filename . '_smarty.html';
//assign the variables and use the template $template
$template->assign($aFields);
$sContent = $template->fetch($template->templateFile);
$template->assign($caseFields);
$content = $template->fetch($template->templateFile);
unlink($template->templateFile);
}
G::verifyPath($sPath, true);
G::verifyPath($path, true);
//Start - Create .doc
$oFile = fopen($sPath . $sFilename . '.doc', 'wb');
$fp = fopen($path . $filename . '.doc', 'wb');
$size = [];
$size["Letter"] = "216mm 279mm";
@@ -566,6 +575,7 @@ class OutputDocument extends BaseOutputDocument
$size["Screenshot800"] = "800mm 600mm";
$size["Screenshot1024"] = "1024mm 768mm";
$sizeLandscape = [];
$sizeLandscape["Letter"] = "279mm 216mm";
$sizeLandscape["Legal"] = "357mm 216mm";
$sizeLandscape["Executive"] = "267mm 184mm";
@@ -587,41 +597,41 @@ class OutputDocument extends BaseOutputDocument
$sizeLandscape["Screenshot800"] = "600mm 800mm";
$sizeLandscape["Screenshot1024"] = "768mm 1024mm";
if (!isset($aProperties['media'])) {
$aProperties['media'] = 'Letter';
if (!isset($properties['media'])) {
$properties['media'] = 'Letter';
}
if ($sLandscape) {
$media = $sizeLandscape[$aProperties['media']];
if ($landscape) {
$media = $sizeLandscape[$properties['media']];
} else {
$media = $size[$aProperties['media']];
$media = $size[$properties['media']];
}
$marginLeft = '15';
if (isset($aProperties['margins']['left'])) {
$marginLeft = $aProperties['margins']['left'];
if (isset($properties['margins']['left'])) {
$marginLeft = $properties['margins']['left'];
}
$marginRight = '15';
if (isset($aProperties['margins']['right'])) {
$marginRight = $aProperties['margins']['right'];
if (isset($properties['margins']['right'])) {
$marginRight = $properties['margins']['right'];
}
$marginTop = '15';
if (isset($aProperties['margins']['top'])) {
$marginTop = $aProperties['margins']['top'];
if (isset($properties['margins']['top'])) {
$marginTop = $properties['margins']['top'];
}
$marginBottom = '15';
if (isset($aProperties['margins']['bottom'])) {
$marginBottom = $aProperties['margins']['bottom'];
if (isset($properties['margins']['bottom'])) {
$marginBottom = $properties['margins']['bottom'];
}
fwrite($oFile, '<html xmlns:v="urn:schemas-microsoft-com:vml"
fwrite($fp, '<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
@@ -667,31 +677,31 @@ class OutputDocument extends BaseOutputDocument
<body>
<div class=WordSection1>');
fwrite($oFile, $sContent);
fwrite($oFile, "\n</div></body></html>\n\n");
fclose($oFile);
fwrite($fp, $content);
fwrite($fp, "\n</div></body></html>\n\n");
fclose($fp);
/* End - Create .doc */
if ($sTypeDocToGener == 'BOTH' || $sTypeDocToGener == 'PDF') {
$oFile = fopen($sPath . $sFilename . '.html', 'wb');
fwrite($oFile, $sContent);
fclose($oFile);
if ($typeDocsToGen == 'BOTH' || $typeDocsToGen == 'PDF') {
$fp = fopen($path . $filename . '.html', 'wb');
fwrite($fp, $content);
fclose($fp);
/* Start - Create .pdf */
if (isset($aProperties['report_generator'])) {
switch ($aProperties['report_generator']) {
if (isset($properties['report_generator'])) {
switch ($properties['report_generator']) {
case 'TCPDF':
$this->generateTcpdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
$this->generateTcpdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
break;
case 'HTML2PDF':
default:
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
break;
}
} else {
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
}
}
//end if $sTypeDocToGener
//end if $typeDocsToGen
/* End - Create .pdf */
} else {
return PEAR::raiseError(

View File

@@ -29,4 +29,20 @@ class PmoauthUserAccessTokens extends BasePmoauthUserAccessTokens
return (is_array($result) && empty($result)) ? false : $result[0];
}
/**
* Delete all records related to a user uid
*
* @param string $userUid User uid
*
* @return int
*/
public function removeByUser($userUid)
{
$criteria = new Criteria();
$criteria->add(PmoauthUserAccessTokensPeer::USER_ID, $userUid);
$resultSet = PmoauthUserAccessTokensPeer::doDelete($criteria);
return $resultSet;
}
} // PmoauthUserAccessTokens

View File

@@ -775,11 +775,22 @@ class Process extends BaseProcess
return $aProc;
}
/**
* Get the trigger configured in committing an action in cases
*
* @param string $proUid
* @param string $action
*
* @return mixed
*
* @see Cases::getExecuteTriggerProcess()
* @link https://wiki.processmaker.com/3.2/Triggers#When_action_cases
*/
public function getTriggerWebBotProcess($proUid, $action)
{
require_once("classes/model/Triggers.php");
if ((! isset($proUid) && $proUid == '') || (! isset($action) && $action == '')) {
if (empty($proUid) || empty($action)){
return false;
}
@@ -788,40 +799,41 @@ class Process extends BaseProcess
switch ($action) {
case 'CREATE':
$var = ProcessPeer::PRO_TRI_CREATE;
$columnName = ProcessPeer::PRO_TRI_CREATE;
break;
case 'OPEN':
$var = ProcessPeer::PRO_TRI_OPEN;
$columnName = ProcessPeer::PRO_TRI_OPEN;
break;
case 'DELETED':
$var = ProcessPeer::PRO_TRI_DELETED;
$columnName = ProcessPeer::PRO_TRI_DELETED;
break;
case 'CANCELED':
$var = ProcessPeer::PRO_TRI_CANCELED;
$columnName = ProcessPeer::PRO_TRI_CANCELED;
break;
case 'PAUSED':
$var = ProcessPeer::PRO_TRI_PAUSED;
$columnName = ProcessPeer::PRO_TRI_PAUSED;
break;
case 'REASSIGNED':
$var = ProcessPeer::PRO_TRI_REASSIGNED;
$columnName = ProcessPeer::PRO_TRI_REASSIGNED;
break;
case "UNPAUSE":
$var = ProcessPeer::PRO_TRI_UNPAUSED;
$columnName = ProcessPeer::PRO_TRI_UNPAUSED;
break;
}
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn($var);
$oCriteria->addSelectColumn(TriggersPeer::TRI_UID);
$oCriteria->addSelectColumn(TriggersPeer::TRI_WEBBOT);
$oCriteria->addJoin($var, TriggersPeer::TRI_UID, Criteria::LEFT_JOIN);
$oCriteria->add(ProcessPeer::PRO_UID, $proUid);
$oDataSet = ProcessPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro'));
$criteria = new Criteria('workflow');
$criteria->addSelectColumn($columnName);
$criteria->addSelectColumn(TriggersPeer::TRI_UID);
$criteria->addSelectColumn(TriggersPeer::TRI_WEBBOT);
$criteria->addSelectColumn(TriggersPeer::TRI_TITLE);
$criteria->addJoin($columnName, TriggersPeer::TRI_UID, Criteria::LEFT_JOIN);
$criteria->add(ProcessPeer::PRO_UID, $proUid);
$criteria->add($columnName, '', Criteria::NOT_EQUAL);
$dataSet = ProcessPeer::doSelectRS($criteria, Propel::getDbConnection('workflow_ro'));
$dataSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($oDataSet->next()) {
$row = $oDataSet->getRow();
$arrayWebBotTrigger = ['TRI_UID' => $row['TRI_UID'], 'TRI_WEBBOT' => $row['TRI_WEBBOT']];
if ($dataSet->next()) {
$arrayWebBotTrigger[] = $dataSet->getRow();
}
//Return

View File

@@ -20,5 +20,18 @@ require_once 'classes/model/om/BaseSession.php';
*/
class Session extends BaseSession
{
/**
* Delete all records related to a user uid
* @param string $userUid User uid
* @return int
* @throws PropelException
*/
public function removeByUser($userUid)
{
$criteria = new Criteria();
$criteria->add(SessionPeer::USR_UID, $userUid);
$resultSet = SessionPeer::doDelete($criteria);
return $resultSet;
}
}

View File

@@ -152,5 +152,29 @@ class SubApplication extends BaseSubApplication
return $result;
}
/**
* Load all cases with the same parent case
*
* @param $appUid
*
* @return array
*/
public function loadByAppUidParent($appUid)
{
$criteria = new Criteria('workflow');
$criteria->add(SubApplicationPeer::APP_PARENT, $appUid);
$dataSet = SubApplicationPeer::doSelectRS($criteria);
$dataSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$result = [];
while ($dataSet->next()) {
$result[] = $dataSet->getRow();
}
return $result;
}
}