conflicts

This commit is contained in:
Ronald Quenta
2015-09-29 09:21:57 -04:00
44 changed files with 912 additions and 286 deletions

View File

@@ -59,6 +59,7 @@ class ActionsByEmail
$configuration['ABE_SUBJECT_FIELD'] = $configuration['ABE_SUBJECT_FIELD'];
$configuration['ABE_EMAIL_FIELD'] = $configuration['ABE_EMAIL_FIELD'];
$configuration['ABE_ACTION_FIELD'] = $configuration['ABE_ACTION_FIELD'];
$configuration['ABE_MAILSERVER_OR_MAILCURRENT'] = $configuration['ABE_MAILSERVER_OR_MAILCURRENT'];
$configuration['ABE_CASE_NOTE_IN_RESPONSE'] = $configuration['ABE_CASE_NOTE_IN_RESPONSE'] ? '["1"]' : '[]';
}
$configuration['feature'] = 'ActionsByEmail';

View File

@@ -49,16 +49,25 @@ class Cases
* Verify if does not exist the Case in table APPLICATION
*
* @param string $applicationUid Unique id of Case
* @param string $delIndex Delegation index
* @param string $fieldNameForException Field name for the exception
*
* return void Throw exception if does not exist the Case in table APPLICATION
*/
public function throwExceptionIfNotExistsCase($applicationUid, $fieldNameForException)
public function throwExceptionIfNotExistsCase($applicationUid, $delIndex, $fieldNameForException)
{
try {
$obj = \ApplicationPeer::retrieveByPK($applicationUid);
if (is_null($obj)) {
$flag = is_null($obj);
if (!$flag && $delIndex > 0) {
$obj = \AppDelegationPeer::retrieveByPK($applicationUid, $delIndex);
$flag = is_null($obj);
}
if ($flag) {
throw new \Exception(\G::LoadTranslation("ID_CASE_DOES_NOT_EXIST2", array($fieldNameForException, $applicationUid)));
}
} catch (\Exception $e) {
@@ -440,7 +449,7 @@ class Cases
\G::LoadClass("wsBase");
//Verify data
$this->throwExceptionIfNotExistsCase($applicationUid, $this->getFieldNameByFormatFieldName("APP_UID"));
$this->throwExceptionIfNotExistsCase($applicationUid, 0, $this->getFieldNameByFormatFieldName("APP_UID"));
$criteria = new \Criteria("workflow");
@@ -536,7 +545,7 @@ class Cases
{
try {
//Verify data
$this->throwExceptionIfNotExistsCase($applicationUid, $this->getFieldNameByFormatFieldName("APP_UID"));
$this->throwExceptionIfNotExistsCase($applicationUid, 0, $this->getFieldNameByFormatFieldName("APP_UID"));
$criteria = new \Criteria("workflow");
@@ -1586,6 +1595,16 @@ class Cases
Validator::isString($usr_uid, '$usr_uid');
Validator::usrUid($usr_uid, '$usr_uid');
$arrayResult = $this->getStatusInfo($app_uid);
if ($arrayResult["APP_STATUS"] == "CANCELLED") {
throw new \Exception(\G::LoadTranslation("ID_CASE_CANCELLED", array($app_uid)));
}
if ($arrayResult["APP_STATUS"] == "COMPLETED") {
throw new \Exception(\G::LoadTranslation("ID_CASE_IS_COMPLETED", array($app_uid)));
}
$appCacheView = new \AppCacheView();
$isProcessSupervisor = $appCacheView->getProUidSupervisor($usr_uid);
$criteria = new \Criteria("workflow");
@@ -1805,7 +1824,7 @@ class Cases
$arrayTask = array();
//Verify data
$this->throwExceptionIfNotExistsCase($applicationUid, $this->getFieldNameByFormatFieldName("APP_UID"));
$this->throwExceptionIfNotExistsCase($applicationUid, 0, $this->getFieldNameByFormatFieldName("APP_UID"));
//Set variables
$process = new \Process();
@@ -2363,14 +2382,16 @@ class Cases
* Get status info Case
*
* @param string $applicationUid Unique id of Case
* @param int $del_index {@min 1}
* @param string $userUid Unique id of User
*
* return array Return an array with status info Case, array empty otherwise
*/
public function getStatusInfo($applicationUid)
public function getStatusInfo($applicationUid, $delIndex = 0, $userUid = "")
{
try {
//Verify data
$this->throwExceptionIfNotExistsCase($applicationUid, $this->getFieldNameByFormatFieldName("APP_UID"));
$this->throwExceptionIfNotExistsCase($applicationUid, $delIndex, $this->getFieldNameByFormatFieldName("APP_UID"));
//Get data
//Status is PAUSED
@@ -2388,6 +2409,14 @@ class Cases
$criteria->getNewCriterion(\AppDelayPeer::APP_DISABLE_ACTION_USER, 0, \Criteria::EQUAL))
);
if ($delIndex != 0) {
$criteria->add(\AppDelayPeer::APP_DEL_INDEX, $delIndex, \Criteria::EQUAL);
}
if ($userUid != "") {
$criteria->add(\AppDelayPeer::APP_DELEGATION_USER, $userUid, \Criteria::EQUAL);
}
$rsCriteria = \AppDelayPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
@@ -2421,6 +2450,14 @@ class Cases
$criteria->getNewCriterion(\AppThreadPeer::APP_THREAD_STATUS, "OPEN"))
);
if ($delIndex != 0) {
$criteria->add(\AppDelegationPeer::DEL_INDEX, $delIndex, \Criteria::EQUAL);
}
if ($userUid != "") {
$criteria->add(\AppDelegationPeer::USR_UID, $userUid, \Criteria::EQUAL);
}
$rsCriteria = \ApplicationPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
@@ -2445,6 +2482,14 @@ class Cases
$criteria->add(\ApplicationPeer::APP_STATUS, array("CANCELLED", "COMPLETED"), \Criteria::IN);
$criteria->add(\AppDelegationPeer::DEL_LAST_INDEX, 1, \Criteria::EQUAL);
if ($delIndex != 0) {
$criteria->add(\AppDelegationPeer::DEL_INDEX, $delIndex, \Criteria::EQUAL);
}
if ($userUid != "") {
$criteria->add(\AppDelegationPeer::USR_UID, $userUid, \Criteria::EQUAL);
}
$rsCriteria = \ApplicationPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);

View File

@@ -3,6 +3,169 @@ namespace ProcessMaker\BusinessModel\Cases;
class OutputDocument
{
/**
* Check if the user has permissions
*
* @param string $applicationUid Unique id of Case
* @param string $delIndex Delegation index
* @param string $userUid Unique id of User
* @param string $appDocumentUid
*
* return void Throw exception the user does not have permission to delete
*/
public function throwExceptionIfHaventPermissionToDelete($applicationUid, $delIndex, $userUid, $appDocumentUid)
{
try {
//Verify data inbox
$case = new \ProcessMaker\BusinessModel\Cases();
$arrayResult = $case->getStatusInfo($applicationUid, $delIndex, $userUid);
$flagInbox = 1;
if (empty($arrayResult) || !preg_match("/^(?:TO_DO|DRAFT)$/", $arrayResult["APP_STATUS"])) {
$flagInbox = 0;
}
//Verify data permission
$flagPermission = 0;
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\AppDocumentPeer::DOC_UID);
$criteria->add(\AppDocumentPeer::APP_DOC_UID, $appDocumentUid, \Criteria::EQUAL);
$criteria->add(\AppDocumentPeer::APP_UID, $applicationUid, \Criteria::EQUAL);
$criteria->add(\AppDocumentPeer::APP_DOC_TYPE, "OUTPUT", \Criteria::EQUAL);
$rsCriteria = \AppDocumentPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
if ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$outputDocumentUid = $row["DOC_UID"];
$application = \ApplicationPeer::retrieveByPK($applicationUid);
//Criteria
$criteria2 = new \Criteria("workflow");
$criteria2->addSelectColumn(\ObjectPermissionPeer::OP_UID);
$criteria2->add(\ObjectPermissionPeer::PRO_UID, $application->getProUid(), \Criteria::EQUAL);
$criteria2->add(\ObjectPermissionPeer::OP_OBJ_TYPE, "OUTPUT", \Criteria::EQUAL);
$criteria2->add(
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, $outputDocumentUid, \Criteria::EQUAL)->addOr(
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "0", \Criteria::EQUAL))->addOr(
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "", \Criteria::EQUAL))
);
$criteria2->add(\ObjectPermissionPeer::OP_ACTION, "DELETE", \Criteria::EQUAL);
//User
$criteriaU = clone $criteria2;
$criteriaU->add(\ObjectPermissionPeer::OP_USER_RELATION, 1, \Criteria::EQUAL);
$criteriaU->add(\ObjectPermissionPeer::USR_UID, $userUid, \Criteria::EQUAL);
$rsCriteriaU = \ObjectPermissionPeer::doSelectRS($criteriaU);
$rsCriteriaU->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
if ($rsCriteriaU->next()) {
$flagPermission = 1;
}
//Group
if ($flagPermission == 0) {
$criteriaG = clone $criteria2;
$criteriaG->add(\ObjectPermissionPeer::OP_USER_RELATION, 2, \Criteria::EQUAL);
$criteriaG->addJoin(\ObjectPermissionPeer::USR_UID, \GroupUserPeer::GRP_UID, \Criteria::LEFT_JOIN);
$criteriaG->add(\GroupUserPeer::USR_UID, $userUid, \Criteria::EQUAL);
$rsCriteriaG = \ObjectPermissionPeer::doSelectRS($criteriaG);
$rsCriteriaG->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
if ($rsCriteriaG->next()) {
$flagPermission = 1;
}
}
}
if ($flagInbox == 1) {
if ($flagPermission == 0) {
throw new \Exception(\G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION_DELETE_OUTPUT_DOCUMENT", array($userUid)));
}
} else {
if ($flagPermission == 0) {
throw new \Exception(\G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION_DELETE_OUTPUT_DOCUMENT", array($userUid)));
}
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if does not exists the inbox
*
* @param string $applicationUid Unique id of Case
* @param string $delIndex Delegation index
* @param string $userUid Unique id of User
*
* return void Throw exception if not exists in inbox
*/
public function throwExceptionIfCaseNotIsInInbox($applicationUid, $delIndex, $userUid)
{
try {
//Verify data
$case = new \ProcessMaker\BusinessModel\Cases();
$arrayResult = $case->getStatusInfo($applicationUid, $delIndex, $userUid);
if (empty($arrayResult) || !preg_match("/^(?:TO_DO|DRAFT)$/", $arrayResult["APP_STATUS"])) {
throw new \Exception(\G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION", array($userUid)));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if not exists OuputDocument in Steps
*
* @param string $applicationUid Unique id of Case
* @param string $delIndex Delegation index
* @param string $outDocUuid
*
* return void Throw exception if not exists OuputDocument in Steps
*/
public function throwExceptionIfOuputDocumentNotExistsInSteps($applicacionUid, $delIndex, $outputDocumentUid)
{
try {
//Verify data
$appDelegation = \AppDelegationPeer::retrieveByPK($applicacionUid, $delIndex);
$taskUid = $appDelegation->getTasUid();
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\StepPeer::STEP_UID);
$criteria->add(\StepPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
$criteria->add(\StepPeer::STEP_TYPE_OBJ, "OUTPUT_DOCUMENT", \Criteria::EQUAL);
$criteria->add(\StepPeer::STEP_UID_OBJ, $outputDocumentUid, \Criteria::EQUAL);
$rsCriteria = \StepPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
if (!$rsCriteria->next()) {
throw new \Exception(\G::LoadTranslation("ID_CASES_OUTPUT_DOES_NOT_EXIST", array($outputDocumentUid)));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get data of Cases OutputDocument
*

View File

@@ -581,7 +581,10 @@ class FilesManager
try {
$oProcessFiles = \ProcessFilesPeer::retrieveByPK($prfUid);
$fcontent = file_get_contents($oProcessFiles->getPrfPath());
$sFile = end(explode("/",$oProcessFiles->getPrfPath()));
$pth = $oProcessFiles->getPrfPath();
$pth = str_replace("\\","/",$pth);
$prfPath = explode("/",$pth);
$sFile = end($prfPath);
$path = $oProcessFiles->getPrfPath();
$sPath = str_replace($sFile,'',$path);
$sSubDirectory = substr(str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID)))),0,-1);

View File

@@ -271,11 +271,23 @@ class Light
{
try {
$oCase = new \Cases();
$oUser = new \Users();
$this->lookinginforContentProcess( $proUid );
$aData = $oCase->startCase( $taskUid, $userId );
$aUserLog = $oUser->loadDetailed($userId);
$_SESSION['APPLICATION'] = $aData['APPLICATION'];
$_SESSION['INDEX'] = $aData['INDEX'];
$_SESSION['PROCESS'] = $aData['PROCESS'];
$_SESSION['TASK'] = $taskUid;
$_SESSION["USER_LOGGED"] = $userId;
$_SESSION["USR_USERNAME"] = $aUserLog['USR_USERNAME'];
$aFields = $oCase->loadCase( $aData['APPLICATION'], $aData['INDEX'] );
$oCase->updateCase( $aData['APPLICATION'], $aFields );
$response = array();
$response['caseId'] = $aData['APPLICATION'];
$response['caseIndex'] = $aData['INDEX'];
@@ -1232,6 +1244,16 @@ class Light
$fields = \System::getSysInfo();
$response['version'] = $fields['PM_VERSION'];
$conf = new \Configurations();
$confEnvironment = $conf->getFormats();
$response['environment'] = array();
if (is_array($confEnvironment)){
$response['environment']['format'] = isset($confEnvironment['format'])?$confEnvironment['format']:'';
$response['environment']['dateFormat'] = isset($confEnvironment['dateFormat'])?$confEnvironment['dateFormat']:'';
$response['environment']['casesListDateFormat'] = isset($confEnvironment['casesListDateFormat'])?$confEnvironment['casesListDateFormat']:'';
}
$Translations = new \Translation;
$translationsTable = $Translations->getTranslationEnvironments();
$languagesList = array ();