Conflicts

This commit is contained in:
Paula Quispe
2019-09-12 15:10:46 -04:00
65 changed files with 1199 additions and 1622 deletions

View File

@@ -135,7 +135,20 @@ class ResponseReader
if (!empty($mail->textPlain)) {
preg_match("/{(.*)}/", $mail->textPlain, $matches);
if ($matches) {
$dataEmail = G::json_decode(Crypt::decryptString($matches[1]), true);
try {
$dataEmail = G::json_decode(Crypt::decryptString($matches[1]), true);
} catch (Exception $e) {
Bootstrap::registerMonolog(
$this->channel,
300,
G::LoadTranslation('ID_ABE_RESPONSE_CANNOT_BE_IDENTIFIED'),
[],
config("system.workspace"),
'processmaker.log'
);
$mailbox->markMailAsRead($mailId);
continue;
}
$dataAbeReq = loadAbeRequest($dataEmail['ABE_REQ_UID']);
if (config("system.workspace") === $dataEmail['workspace']
&& (array_key_exists('ABE_UID', $dataAbeReq) && $dataAbeReq['ABE_UID'] == $dataAbe['ABE_UID'])) {
@@ -149,7 +162,6 @@ class ResponseReader
throw (new Exception(G::LoadTranslation('ID_CASE_DELEGATION_ALREADY_CLOSED'), 400));
}
$this->processABE($this->case, $mail, $dataAbe);
$mailbox->markMailAsRead($mailId);
Bootstrap::registerMonolog(
$this->channel,
100, // DEBUG
@@ -174,6 +186,7 @@ class ResponseReader
'processmaker.log'
);
}
$mailbox->markMailAsRead($mailId);
}
}
}
@@ -347,7 +360,8 @@ class ResponseReader
true,
$caseInf['delIndex'],
$emailSetup,
0
0,
WsBase::MESSAGE_TYPE_ACTIONS_BY_EMAIL
);
return $result;
}

View File

@@ -11,6 +11,7 @@ use AppDelegationPeer;
use AppDocument;
use AppDocumentPeer;
use AppHistoryPeer;
use Application;
use ApplicationPeer;
use Applications;
use AppNotesPeer;
@@ -45,7 +46,6 @@ use ProcessMaker\Services\OAuth2\Server;
use ProcessMaker\Util\DateTime as UtilDateTime;
use ProcessMaker\Validation\ExceptionRestApi;
use ProcessMaker\Validation\Validator as FileValidator;
use ProcessPeer;
use ProcessUser;
use ProcessUserPeer;
@@ -3317,6 +3317,7 @@ class Cases
* @param array $objectPermissions, the permissions that we need to review
* @param boolean $objectSupervisor, if we need to get all the objects supervisor
* @param string $tasUid
*
* @return array
*/
public function userAuthorization(
@@ -3330,23 +3331,21 @@ class Cases
) {
$arrayAccess = [];
//User has participated
$participated = new ListParticipatedLast();
$listParticipated = $participated->loadList($usrUid, [], null, $appUid);
$arrayAccess['participated'] = (count($listParticipated) == 0) ? false : true;
// User has participated
$arrayAccess['participated'] = Delegation::participation($appUid, $usrUid);
//User is supervisor
// User is supervisor
$supervisor = new BmProcessSupervisor();
$isSupervisor = $supervisor->isUserProcessSupervisor($proUid, $usrUid);
$arrayAccess['supervisor'] = ($isSupervisor) ? true : false;
//If the user is supervisor we will to return the object assigned
// If the user is supervisor we will to return the object assigned
if ($isSupervisor && $objectSupervisor) {
$ps = new BmProcessSupervisor();
$arrayAccess['objectSupervisor'] = $ps->getObjectSupervisor($proUid);
}
//Roles Permissions
// Roles Permissions
if (count($rolesPermissions) > 0) {
global $RBAC;
foreach ($rolesPermissions as $value) {
@@ -3354,7 +3353,7 @@ class Cases
}
}
//Object Permissions
// Object Permissions
if (count($objectPermissions) > 0) {
$case = new ClassesCases();
foreach ($objectPermissions as $key => $value) {

View File

@@ -1,6 +1,12 @@
<?php
namespace ProcessMaker\BusinessModel;
use CodeScanner;
use Exception;
use G;
use PMLicensedFeatures;
use Triggers as ModelTriggers;
class Trigger
{
/**
@@ -134,76 +140,82 @@ class Trigger
}
/**
* Save Data for Trigger
* @var string $sProcessUID. Uid for Process
* @var string $dataTrigger. Data for Trigger
* @var string $create. Create o Update Trigger
* @var string $sTriggerUid. Uid for Trigger
* If the feature is enable and the code_scanner_scope was enable with the argument trigger, will check the code
* Review when a trigger is save or update
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @param string $proUid. Uid for Process
* @param array $dataTrigger. Data for Trigger
* @param boolean $create. Create o Update Trigger
* @param string $triggerUid. Uid for Trigger
*
* @return array
* @throws Exception
*
* @uses \ProcessMaker\Services\Api\Project\Trigger::doPostTrigger()
* @uses \ProcessMaker\Services\Api\Project\Trigger::doPutTrigger()
*/
public function saveTrigger($sProcessUID = '', $dataTrigger = array(), $create = false, $sTriggerUid = '')
public function saveTrigger($proUid = '', $dataTrigger = [], $create = false, $triggerUid = '')
{
if ( ($sProcessUID == '') || (count($dataTrigger) == 0) ) {
if ((empty($proUid)) || empty($dataTrigger)) {
return false;
}
$dataTrigger = array_change_key_case($dataTrigger, CASE_UPPER);
if ( $create && (isset($dataTrigger['TRI_UID'])) ) {
if ($create && (isset($dataTrigger['TRI_UID']))) {
unset($dataTrigger['TRI_UID']);
}
$dataTrigger= (array)$dataTrigger;
$dataTrigger = (array)$dataTrigger;
$dataTrigger['TRI_TYPE'] = 'SCRIPT';
if (isset($dataTrigger['TRI_TITLE'])) {
if (!$this->verifyNameTrigger($sProcessUID, $dataTrigger['TRI_TITLE'], $sTriggerUid)) {
throw new \Exception(\G::LoadTranslation("ID_CANT_SAVE_TRIGGER"));
if (!$this->verifyNameTrigger($proUid, $dataTrigger['TRI_TITLE'], $triggerUid)) {
throw new Exception(G::LoadTranslation("ID_CANT_SAVE_TRIGGER"));
}
}
/*----------------------------------********---------------------------------*/
if (\PMLicensedFeatures::getSingleton()->verifyfeature("B0oWlBLY3hHdWY0YUNpZEtFQm5CeTJhQlIwN3IxMEkwaG4=") &&
if (PMLicensedFeatures::getSingleton()->verifyfeature("B0oWlBLY3hHdWY0YUNpZEtFQm5CeTJhQlIwN3IxMEkwaG4=") &&
isset($dataTrigger["TRI_WEBBOT"])
) {
//Check disabled code
$cs = new \CodeScanner(config("system.workspace"));
$arrayFoundDisabledCode = $cs->checkDisabledCode("SOURCE", $dataTrigger["TRI_WEBBOT"]);
$arrayFoundDisabledCode = [];
$cs = new CodeScanner(config("system.workspace"));
if (in_array('trigger', $cs->getScope())) {
$arrayFoundDisabledCode = $cs->checkDisabledCode("SOURCE", $dataTrigger["TRI_WEBBOT"]);
}
if (!empty($arrayFoundDisabledCode)) {
$strCodeAndLine = "";
foreach ($arrayFoundDisabledCode["source"] as $key => $value) {
$strCodeAndLine .= (($strCodeAndLine != "")? ", " : "") . \G::LoadTranslation("ID_DISABLED_CODE_CODE_AND_LINE", array($key, implode(", ", $value)));
$strCodeAndLine .= (($strCodeAndLine != "") ? ", " : "") . G::LoadTranslation("ID_DISABLED_CODE_CODE_AND_LINE",
[$key, implode(", ", $value)]);
}
throw new \Exception(\G::LoadTranslation("ID_DISABLED_CODE_TRIGGER", array($strCodeAndLine)));
throw new Exception(G::LoadTranslation("ID_DISABLED_CODE_TRIGGER", [$strCodeAndLine]));
}
}
/*----------------------------------********---------------------------------*/
$dataTrigger['PRO_UID'] = $sProcessUID;
$oTrigger = new \Triggers();
$dataTrigger['PRO_UID'] = $proUid;
$trigger = new ModelTriggers();
if ($create) {
$oTrigger->create( $dataTrigger );
$dataTrigger['TRI_UID'] = $oTrigger->getTriUid();
$trigger->create($dataTrigger);
$dataTrigger['TRI_UID'] = $trigger->getTriUid();
}
$oTrigger->update( $dataTrigger );
$trigger->update($dataTrigger);
if ($create) {
$dataResp = $oTrigger->load( $dataTrigger['TRI_UID'] );
$dataResp = $trigger->load($dataTrigger['TRI_UID']);
$dataResp = array_change_key_case($dataResp, CASE_LOWER);
if (isset($dataResp['pro_uid'])) {
unset($dataResp['pro_uid']);
}
return $dataResp;
}
return array();
return [];
}
/**

View File

@@ -1,7 +1,9 @@
<?php
namespace ProcessMaker\BusinessModel;
use Criteria;
use ProcessMaker\Core\System;
use ResultSet;
use WebEntryPeer;
class WebEntry
@@ -962,31 +964,35 @@ class WebEntry
* Check the existence of a file of type web entry, returns true if it exists
* and false otherwise. Verification is done by the field WE_DATA and PRO_UID.
* The PRO_UID key and the file path are required.
* @param type $proUid
* @param type $filePath
* @return boolean
*
* @param string $proUid
* @param string $filePath
*
* @return bool
*/
public static function isWebEntry($proUid, $filePath)
{
// Validate if path file is valid
$fileName = basename($filePath);
if (empty($proUid) || empty($fileName)) {
return false;
}
// Transform the sent filename to a valid web entry filename
$fileName = trim($fileName);
$postfix = "Post.php";
$n = strlen($postfix);
$string = substr($fileName, 0, -$n);
if ($string . $postfix === $fileName) {
$fileName = $string . ".php";
}
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\WebEntryPeer::WE_DATA);
$criteria->add(\WebEntryPeer::PRO_UID, $proUid, \Criteria::EQUAL);
$criteria->add(\WebEntryPeer::WE_DATA, $fileName, \Criteria::EQUAL);
$resultSet = \WebEntryPeer::doSelectRS($criteria);
$resultSet->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$fileName = str_replace(['Post.php', 'Info.php'], '.php', $fileName);
// Search in DB the filename
$criteria = new Criteria("workflow");
$criteria->addSelectColumn(WebEntryPeer::WE_DATA);
$criteria->add(WebEntryPeer::PRO_UID, $proUid, Criteria::EQUAL);
$criteria->add(WebEntryPeer::WE_DATA, $fileName, Criteria::EQUAL);
$resultSet = WebEntryPeer::doSelectRS($criteria);
$resultSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$resultSet->next();
$row = $resultSet->getRow();
// Web entry file exists?
return isset($row["WE_DATA"]);
}

View File

@@ -54,6 +54,7 @@ class System
'error_reporting' => "",
'display_errors' => 'On',
'enable_blacklist' => 0,
'code_scanner_scope' => 'import_plugin,enable_plugin,import_process,trigger',
'system_utc_time_zone' => 0,
'server_protocol' => '',
'leave_case_warning' => 0,

View File

@@ -0,0 +1,12 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class AppThread extends Model
{
protected $table = 'APP_THREAD';
// We do not have create/update timestamps for this table
public $timestamps = false;
}

View File

@@ -563,4 +563,22 @@ class Delegation extends Model
return $arrayOpenThreads;
}
/**
* Return if the user has participation in the case
*
* @param string $appUid, Case key
* @param string $userUid, User key
*
* @return boolean
*/
public static function participation($appUid, $userUid)
{
$query = Delegation::query()->select();
$query->where('APP_UID', $appUid);
$query->where('USR_UID', $userUid);
$query->limit(1);
return ($query->count() > 0);
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class RbacRoles extends Model
{
protected $table = 'RBAC_ROLES';
public $timestamps = false;
}

View File

@@ -0,0 +1,12 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class RbacUsers extends Model
{
protected $table = 'RBAC_USERS';
public $timestamps = false;
}

View File

@@ -0,0 +1,12 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class RbacUsersRoles extends Model
{
protected $table = 'RBAC_USERS_ROLES';
public $timestamps = false;
}

View File

@@ -0,0 +1,15 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class WebEntry extends Model
{
// Set our table name
protected $table = 'WEB_ENTRY';
protected $primaryKey = 'WE_UID';
// We do not have create/update timestamps for this table
public $timestamps = false;
}