Merge branch 'master' of bitbucket.org:colosa/processmaker into CONSOLIDATED

This commit is contained in:
Brayan Pereyra
2015-03-23 14:45:52 -04:00
543 changed files with 41770 additions and 1325 deletions

View File

@@ -0,0 +1,65 @@
<?php
namespace ProcessMaker\BusinessModel;
/**
* Description of ActionsByEmailService
*
*/
class ActionsByEmail
{
public function saveConfiguration($params)
{
if (\PMLicensedFeatures
::getSingleton()
->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=')) {
$feature = $params['ActionsByEmail'];
switch ($feature['type']) {
case 'configuration':
require_once 'classes/model/AbeConfiguration.php';
$abeConfigurationInstance = new \AbeConfiguration();
$noteValues = json_decode($feature['fields']['ABE_CASE_NOTE_IN_RESPONSE']);
foreach ($noteValues as $value) {
$feature['fields']['ABE_CASE_NOTE_IN_RESPONSE'] = $value;
}
$abeConfigurationInstance->createOrUpdate($feature['fields']);
break;
default:
break;
}
}
}
public function loadConfiguration($params)
{
if ($params['type'] != 'activity'
|| !\PMLicensedFeatures
::getSingleton()
->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0='))
{
return false;
}
require_once 'classes/model/AbeConfiguration.php';
$criteria = new \Criteria();
$criteria->add(\AbeConfigurationPeer::PRO_UID, $params['PRO_UID']);
$criteria->add(\AbeConfigurationPeer::TAS_UID, $params['TAS_UID']);
$result = \AbeConfigurationPeer::doSelectRS($criteria);
$result->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$result->next();
$configuration = array();
if ($configuration = $result->getRow()) {
$configuration['ABE_EMAIL_FIELD_VALUE'] = $configuration['ABE_EMAIL_FIELD'];
$configuration['ABE_ACTION_FIELD_VALUE'] = $configuration['ABE_ACTION_FIELD'];
$configuration['ABE_CASE_NOTE_IN_RESPONSE'] = $configuration['ABE_CASE_NOTE_IN_RESPONSE'] ? '["1"]' : '[]';
}
$configuration['feature'] = 'ActionsByEmail';
$configuration['prefix'] = 'abe';
$configuration['PRO_UID'] = $params['PRO_UID'];
$configuration['TAS_UID'] = $params['TAS_UID'];
$configuration['SYS_LANG'] = SYS_LANG;
return $configuration;
}
}

View File

@@ -1991,7 +1991,7 @@ class Cases
}
//Element origin and dest
$messageEventTaskRelation = new \ProcessMaker\BusinessModel\MessageEventTaskRelation();
$elementTaskRelation = new \ProcessMaker\BusinessModel\ElementTaskRelation();
$arrayElement = array(
"elementOrigin" => array("uid" => $elementOriginUid, "type" => "bpmnActivity"),
@@ -1999,16 +1999,17 @@ class Cases
);
foreach ($arrayElement as $key => $value) {
$arrayMessageEventTaskRelationData = $messageEventTaskRelation->getMessageEventTaskRelationWhere(
$arrayElementTaskRelationData = $elementTaskRelation->getElementTaskRelationWhere(
array(
\MessageEventTaskRelationPeer::PRJ_UID => $arrayApplicationData["PRO_UID"],
\MessageEventTaskRelationPeer::TAS_UID => $arrayElement[$key]["uid"]
\ElementTaskRelationPeer::PRJ_UID => $arrayApplicationData["PRO_UID"],
\ElementTaskRelationPeer::ELEMENT_TYPE => "bpmnEvent",
\ElementTaskRelationPeer::TAS_UID => $arrayElement[$key]["uid"]
),
true
);
if (!is_null($arrayMessageEventTaskRelationData)) {
$arrayElement[$key]["uid"] = $arrayMessageEventTaskRelationData["EVN_UID"];
if (!is_null($arrayElementTaskRelationData)) {
$arrayElement[$key]["uid"] = $arrayElementTaskRelationData["ELEMENT_UID"];
$arrayElement[$key]["type"] = "bpmnEvent";
}
}

View File

@@ -11,6 +11,65 @@ use \DepartmentPeer;
*/
class Department
{
/**
* Verify if exists the title of a Department
*
* @param string $departmentTitle Title
* @param string $departmentUidExclude Unique id of Department to exclude
*
* return bool Return true if exists the title of a Department, false otherwise
*/
public function existsTitle($departmentTitle, $departmentUidExclude = "")
{
try {
$delimiter = \DBAdapter::getStringDelimiter();
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\DepartmentPeer::DEP_UID);
$criteria->addAlias("CT", \ContentPeer::TABLE_NAME);
$arrayCondition = array();
$arrayCondition[] = array(\DepartmentPeer::DEP_UID, "CT.CON_ID", \Criteria::EQUAL);
$arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "DEPO_TITLE" . $delimiter, \Criteria::EQUAL);
$arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
$criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
if ($departmentUidExclude != "") {
$criteria->add(\DepartmentPeer::DEP_UID, $departmentUidExclude, \Criteria::NOT_EQUAL);
}
$criteria->add("CT.CON_VALUE", $departmentTitle, \Criteria::EQUAL);
$rsCriteria = \DepartmentPeer::doSelectRS($criteria);
return ($rsCriteria->next())? true : false;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if exists the title of a Department
*
* @param string $departmentTitle Title
* @param string $fieldNameForException Field name for the exception
* @param string $departmentUidExclude Unique id of Department to exclude
*
* return void Throw exception if exists the title of a Department
*/
public function throwExceptionIfExistsTitle($departmentTitle, $fieldNameForException, $departmentUidExclude = "")
{
try {
if ($this->existsTitle($departmentTitle, $departmentUidExclude)) {
throw new \Exception(\G::LoadTranslation("ID_DEPARTMENT_TITLE_ALREADY_EXISTS", array($fieldNameForException, $departmentTitle)));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get list for Departments
*
@@ -76,9 +135,24 @@ class Department
*
* @return array
*/
public function getAvailableUser($dep_uid)
public function getAvailableUser($dep_uid, $start = 0, $limit = 0, $search = '')
{
$dep_uid = Validator::depUid($dep_uid);
$start = (int)$start;
$start = abs($start);
if ($start != 0) {
$start+1;
}
$limit = (int)$limit;
$limit = abs($limit);
if ($limit == 0) {
$limit = 25;
} else {
$limit = (int)$limit;
}
$oCriteria = new \Criteria( 'workflow' );
$oCriteria->addSelectColumn( UsersPeer::USR_UID );
$oCriteria->addSelectColumn( UsersPeer::USR_USERNAME );
@@ -88,6 +162,13 @@ class Department
$oCriteria->add( UsersPeer::DEP_UID, '' );
$oCriteria->add( UsersPeer::USR_STATUS, 'CLOSED', \Criteria::NOT_EQUAL );
$oCriteria->setLimit( $limit );
$oCriteria->setOffset( $start );
if ($search != '') {
$oCriteria->add( $oCriteria->getNewCriterion( UsersPeer::USR_USERNAME, '%' . $search . '%', \Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( UsersPeer::USR_FIRSTNAME, '%' . $search . '%', \Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( UsersPeer::USR_LASTNAME, '%' . $search . '%', \Criteria::LIKE ) ) ) );
}
$oDataset = UsersPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
$aUsers = array ();
@@ -99,25 +180,63 @@ class Department
}
/**
* Put Assign User
* Assign User to Department
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @param string $departmentUid Unique id of Department
* @param array $arrayData Data
*
* @return void
* return array Return data of the User assigned to Department
*/
public function assignUser($dep_uid, $usr_uid)
public function assignUser($departmentUid, array $arrayData)
{
$dep_uid = Validator::depUid($dep_uid);
$usr_uid = Validator::usrUid($usr_uid);
try {
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$validator = new \ProcessMaker\BusinessModel\Validator();
$dep = new \Department();
$dep->load($dep_uid);
$dep_manager = $dep->getDepManager();
$manager = ($dep_manager == '') ? true : false;
$dep->addUserToDepartment( $dep_uid, $usr_uid, $manager, false );
$dep->updateDepartmentManager( $dep_uid );
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
//Set data
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
unset($arrayData["DEP_UID"]);
//Set variables
$arrayUserFieldDefinition = array(
"DEP_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "departmentUid"),
"USR_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUid")
);
$arrayUserFieldNameForException = array(
"departmentUid" => strtolower("DEP_UID"),
"userUid" => strtolower("USR_UID")
);
//Verify data
$departmentUid = \ProcessMaker\BusinessModel\Validator::depUid($departmentUid);
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $arrayUserFieldDefinition, $arrayUserFieldNameForException, true);
$process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $arrayUserFieldNameForException["userUid"]);
//Assign User
$department = new \Department();
$department->load($departmentUid);
$department->addUserToDepartment($departmentUid, $arrayData["USR_UID"], ($department->getDepManager() == "")? true : false, false);
$department->updateDepartmentManager($departmentUid);
//Return
$arrayData = array_merge(array("DEP_UID" => $departmentUid), $arrayData);
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
return $arrayData;
} catch (\Exception $e) {
throw $e;
}
}
/**
@@ -160,11 +279,26 @@ class Department
$dep_uid = Validator::depUid($dep_uid);
$usr_uid = Validator::usrUid($usr_uid);
$oCriteria = new \Criteria( 'workflow' );
$oCriteria->addSelectColumn( DepartmentPeer::DEP_UID );
$oCriteria->add( DepartmentPeer::DEP_MANAGER, $usr_uid, \Criteria::EQUAL );
$oDataset = DepartmentPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
if ($oDataset->next()) {
throw (new \Exception(\G::LoadTranslation("ID_DEPARTMENT_MANAGER_EXIST", array('usr_uid',$usr_uid))));
}
$editDepartment['DEP_UID'] = $dep_uid;
$editDepartment['DEP_MANAGER'] = $usr_uid;
$oDept = new \Department();
$oDept->update( $editDepartment );
$oDept->updateDepartmentManager( $dep_uid );
$oDept = new \Department();
$oDept->load($dep_uid);
$oDept->addUserToDepartment($dep_uid, $usr_uid, ($oDept->getDepManager() == "")? true : false, false);
$oDept->updateDepartmentManager($dep_uid);
}
/**
@@ -208,6 +342,10 @@ class Department
$node['DEP_MANAGER_LASTNAME'] = '';
}
$criteria = new \Criteria();
$criteria->add(UsersPeer::DEP_UID, $dep_uid, \Criteria::EQUAL );
$node['DEP_MEMBERS'] = UsersPeer::doCount($criteria);
$criteriaCount = new \Criteria( 'workflow' );
$criteriaCount->clearSelectColumns();
$criteriaCount->addSelectColumn( 'COUNT(*)' );
@@ -239,6 +377,11 @@ class Department
Validator::isBoolean($create, '$create');
$dep_data = array_change_key_case($dep_data, CASE_UPPER);
if ($create) {
unset($dep_data["DEP_UID"]);
}
$oDepartment = new \Department();
if (isset($dep_data['DEP_UID']) && $dep_data['DEP_UID'] != '') {
Validator::depUid($dep_data['DEP_UID']);
@@ -254,18 +397,21 @@ class Department
}
if (!$create) {
$dep_data['DEPO_TITLE'] = $dep_data['DEP_TITLE'];
if (isset($dep_data['DEP_TITLE'])) {
Validator::depTitle($dep_data['DEP_TITLE'], $dep_data['DEP_UID']);
if (isset($dep_data["DEP_TITLE"])) {
$this->throwExceptionIfExistsTitle($dep_data["DEP_TITLE"], strtolower("DEP_TITLE"), $dep_data["DEP_UID"]);
$dep_data["DEPO_TITLE"] = $dep_data["DEP_TITLE"];
}
$oDepartment->update($dep_data);
$oDepartment->updateDepartmentManager($dep_data['DEP_UID']);
} else {
if (isset($dep_data['DEP_TITLE'])) {
Validator::depTitle($dep_data['DEP_TITLE']);
$this->throwExceptionIfExistsTitle($dep_data["DEP_TITLE"], strtolower("DEP_TITLE"));
} else {
throw (new \Exception(\G::LoadTranslation("ID_FIELD_REQUIRED", array('dep_title'))));
}
$dep_uid = $oDepartment->create($dep_data);
$response = $this->getDepartment($dep_uid);
return $response;

View File

@@ -1,14 +1,15 @@
<?php
namespace ProcessMaker\BusinessModel;
class MessageEventTaskRelation
class ElementTaskRelation
{
private $arrayFieldDefinition = array(
"MSGETR_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "messageEventTaskRelationUid"),
"ETR_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "elementTaskRelationUid"),
"PRJ_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "projectUid"),
"EVN_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "eventUid"),
"TAS_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "taskUid")
"PRJ_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "projectUid"),
"ELEMENT_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "elementUid"),
"ELEMENT_TYPE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "elementType"),
"TAS_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "taskUid")
);
private $formatFieldNameInUppercase = true;
@@ -84,16 +85,16 @@ class MessageEventTaskRelation
}
/**
* Verify if exists the Message-Event-Task-Relation
* Verify if exists the Element-Task-Relation
*
* @param string $messageEventTaskRelationUid Unique id of Message-Event-Task-Relation
* @param string $elementTaskRelationUid Unique id of Element-Task-Relation
*
* return bool Return true if exists the Message-Event-Task-Relation, false otherwise
* return bool Return true if exists the Element-Task-Relation, false otherwise
*/
public function exists($messageEventTaskRelationUid)
public function exists($elementTaskRelationUid)
{
try {
$obj = \MessageEventTaskRelationPeer::retrieveByPK($messageEventTaskRelationUid);
$obj = \ElementTaskRelationPeer::retrieveByPK($elementTaskRelationUid);
return (!is_null($obj))? true : false;
} catch (\Exception $e) {
@@ -102,18 +103,18 @@ class MessageEventTaskRelation
}
/**
* Verify if does not exists the Message-Event-Task-Relation
* Verify if does not exists the Element-Task-Relation
*
* @param string $messageEventTaskRelationUid Unique id of Message-Event-Task-Relation
* @param string $fieldNameForException Field name for the exception
* @param string $elementTaskRelationUid Unique id of Element-Task-Relation
* @param string $fieldNameForException Field name for the exception
*
* return void Throw exception if does not exists the Message-Event-Task-Relation
* return void Throw exception if does not exists the Element-Task-Relation
*/
public function throwExceptionIfNotExistsMessageEventTaskRelation($messageEventTaskRelationUid, $fieldNameForException)
public function throwExceptionIfNotExistsElementTaskRelation($elementTaskRelationUid, $fieldNameForException)
{
try {
if (!$this->exists($messageEventTaskRelationUid)) {
throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_TASK_RELATION_DOES_NOT_EXIST", array($fieldNameForException, $messageEventTaskRelationUid)));
if (!$this->exists($elementTaskRelationUid)) {
throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_TASK_RELATION_DOES_NOT_EXIST", array($fieldNameForException, $elementTaskRelationUid)));
}
} catch (\Exception $e) {
throw $e;
@@ -123,20 +124,20 @@ class MessageEventTaskRelation
/**
* Validate the data if they are invalid (INSERT and UPDATE)
*
* @param string $messageEventTaskRelationUid Unique id of Message-Event-Task-Relation
* @param string $projectUid Unique id of Project
* @param array $arrayData Data
* @param string $elementTaskRelationUid Unique id of Element-Task-Relation
* @param string $projectUid Unique id of Project
* @param array $arrayData Data
*
* return void Throw exception if data has an invalid value
*/
public function throwExceptionIfDataIsInvalid($messageEventTaskRelationUid, $projectUid, array $arrayData)
public function throwExceptionIfDataIsInvalid($elementTaskRelationUid, $projectUid, array $arrayData)
{
try {
//Set variables
$arrayMessageEventTaskRelationData = ($messageEventTaskRelationUid == "")? array() : $this->getMessageEventTaskRelation($messageEventTaskRelationUid, true);
$flagInsert = ($messageEventTaskRelationUid == "")? true : false;
$arrayElementTaskRelationData = ($elementTaskRelationUid == "")? array() : $this->getElementTaskRelation($elementTaskRelationUid, true);
$flagInsert = ($elementTaskRelationUid == "")? true : false;
$arrayFinalData = array_merge($arrayMessageEventTaskRelationData, $arrayData);
$arrayFinalData = array_merge($arrayElementTaskRelationData, $arrayData);
//Verify data - Field definition
$process = new \ProcessMaker\BusinessModel\Process();
@@ -148,12 +149,12 @@ class MessageEventTaskRelation
}
/**
* Create Message-Event-Task-Relation for a Project
* Create Element-Task-Relation for a Project
*
* @param string $projectUid Unique id of Project
* @param array $arrayData Data
*
* return array Return data of the new Message-Event-Task-Relation created
* return array Return data of the new Element-Task-Relation created
*/
public function create($projectUid, array $arrayData)
{
@@ -168,7 +169,7 @@ class MessageEventTaskRelation
//Set data
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
unset($arrayData["MSGETR_UID"]);
unset($arrayData["ETR_UID"]);
unset($arrayData["PRJ_UID"]);
//Verify data
@@ -180,28 +181,28 @@ class MessageEventTaskRelation
$cnn = \Propel::getConnection("workflow");
try {
$messageEventTaskRelation = new \MessageEventTaskRelation();
$elementTaskRelation = new \ElementTaskRelation();
$messageEventTaskRelationUid = \ProcessMaker\Util\Common::generateUID();
$elementTaskRelationUid = \ProcessMaker\Util\Common::generateUID();
$messageEventTaskRelation->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
$elementTaskRelation->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
$messageEventTaskRelation->setMsgetrUid($messageEventTaskRelationUid);
$messageEventTaskRelation->setPrjUid($projectUid);
$elementTaskRelation->setEtrUid($elementTaskRelationUid);
$elementTaskRelation->setPrjUid($projectUid);
if ($messageEventTaskRelation->validate()) {
if ($elementTaskRelation->validate()) {
$cnn->begin();
$result = $messageEventTaskRelation->save();
$result = $elementTaskRelation->save();
$cnn->commit();
//Return
return $this->getMessageEventTaskRelation($messageEventTaskRelationUid);
return $this->getElementTaskRelation($elementTaskRelationUid);
} else {
$msg = "";
foreach ($messageEventTaskRelation->getValidationFailures() as $validationFailure) {
foreach ($elementTaskRelation->getValidationFailures() as $validationFailure) {
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
}
@@ -218,7 +219,7 @@ class MessageEventTaskRelation
}
/**
* Delete Message-Event-Task-Relation
* Delete Element-Task-Relation
*
* @param array $arrayCondition Conditions
*
@@ -238,26 +239,27 @@ class MessageEventTaskRelation
}
}
$result = \MessageEventTaskRelationPeer::doDelete($criteria);
$result = \ElementTaskRelationPeer::doDelete($criteria);
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get criteria for Message-Event-Task-Relation
* Get criteria for Element-Task-Relation
*
* return object
*/
public function getMessageEventTaskRelationCriteria()
public function getElementTaskRelationCriteria()
{
try {
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\MessageEventTaskRelationPeer::MSGETR_UID);
$criteria->addSelectColumn(\MessageEventTaskRelationPeer::PRJ_UID);
$criteria->addSelectColumn(\MessageEventTaskRelationPeer::EVN_UID);
$criteria->addSelectColumn(\MessageEventTaskRelationPeer::TAS_UID);
$criteria->addSelectColumn(\ElementTaskRelationPeer::ETR_UID);
$criteria->addSelectColumn(\ElementTaskRelationPeer::PRJ_UID);
$criteria->addSelectColumn(\ElementTaskRelationPeer::ELEMENT_UID);
$criteria->addSelectColumn(\ElementTaskRelationPeer::ELEMENT_TYPE);
$criteria->addSelectColumn(\ElementTaskRelationPeer::TAS_UID);
return $criteria;
} catch (\Exception $e) {
@@ -266,19 +268,20 @@ class MessageEventTaskRelation
}
/**
* Get data of a Message-Event-Task-Relation from a record
* Get data of a Element-Task-Relation from a record
*
* @param array $record Record
*
* return array Return an array with data Message-Event-Task-Relation
* return array Return an array with data Element-Task-Relation
*/
public function getMessageEventTaskRelationDataFromRecord(array $record)
public function getElementTaskRelationDataFromRecord(array $record)
{
try {
return array(
$this->getFieldNameByFormatFieldName("MSGETR_UID") => $record["MSGETR_UID"],
$this->getFieldNameByFormatFieldName("EVN_UID") => $record["EVN_UID"],
$this->getFieldNameByFormatFieldName("TAS_UID") => $record["TAS_UID"]
$this->getFieldNameByFormatFieldName("ETR_UID") => $record["ETR_UID"],
$this->getFieldNameByFormatFieldName("ELEMENT_UID") => $record["ELEMENT_UID"],
$this->getFieldNameByFormatFieldName("ELEMENT_TYPE") => $record["ELEMENT_TYPE"],
$this->getFieldNameByFormatFieldName("TAS_UID") => $record["TAS_UID"]
);
} catch (\Exception $e) {
throw $e;
@@ -286,25 +289,25 @@ class MessageEventTaskRelation
}
/**
* Get data of a Message-Event-Task-Relation
* Get data of a Element-Task-Relation
*
* @param string $messageEventTaskRelationUid Unique id of Message-Event-Task-Relation
* @param bool $flagGetRecord Value that set the getting
* @param string $elementTaskRelationUid Unique id of Element-Task-Relation
* @param bool $flagGetRecord Value that set the getting
*
* return array Return an array with data of a Message-Event-Task-Relation
* return array Return an array with data of a Element-Task-Relation
*/
public function getMessageEventTaskRelation($messageEventTaskRelationUid, $flagGetRecord = false)
public function getElementTaskRelation($elementTaskRelationUid, $flagGetRecord = false)
{
try {
//Verify data
$this->throwExceptionIfNotExistsMessageEventTaskRelation($messageEventTaskRelationUid, $this->arrayFieldNameForException["messageEventTaskRelationUid"]);
$this->throwExceptionIfNotExistsElementTaskRelation($elementTaskRelationUid, $this->arrayFieldNameForException["elementTaskRelationUid"]);
//Get data
$criteria = $this->getMessageEventTaskRelationCriteria();
$criteria = $this->getElementTaskRelationCriteria();
$criteria->add(\MessageEventTaskRelationPeer::MSGETR_UID, $messageEventTaskRelationUid, \Criteria::EQUAL);
$criteria->add(\ElementTaskRelationPeer::ETR_UID, $elementTaskRelationUid, \Criteria::EQUAL);
$rsCriteria = \MessageEventTaskRelationPeer::doSelectRS($criteria);
$rsCriteria = \ElementTaskRelationPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteria->next();
@@ -312,25 +315,25 @@ class MessageEventTaskRelation
$row = $rsCriteria->getRow();
//Return
return (!$flagGetRecord)? $this->getMessageEventTaskRelationDataFromRecord($row) : $row;
return (!$flagGetRecord)? $this->getElementTaskRelationDataFromRecord($row) : $row;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get data of a Message-Event-Task-Relation
* Get data of a Element-Task-Relation
*
* @param array $arrayCondition Conditions
* @param bool $flagGetRecord Value that set the getting
*
* return array Return an array with data of a Message-Event-Task-Relation, otherwise null
* return array Return an array with data of a Element-Task-Relation, otherwise null
*/
public function getMessageEventTaskRelationWhere(array $arrayCondition, $flagGetRecord = false)
public function getElementTaskRelationWhere(array $arrayCondition, $flagGetRecord = false)
{
try {
//Get data
$criteria = $this->getMessageEventTaskRelationCriteria();
$criteria = $this->getElementTaskRelationCriteria();
foreach ($arrayCondition as $key => $value) {
if (is_array($value)) {
@@ -340,14 +343,14 @@ class MessageEventTaskRelation
}
}
$rsCriteria = \MessageEventTaskRelationPeer::doSelectRS($criteria);
$rsCriteria = \ElementTaskRelationPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
if ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
//Return
return (!$flagGetRecord)? $this->getMessageEventTaskRelationDataFromRecord($row) : $row;
return (!$flagGetRecord)? $this->getElementTaskRelationDataFromRecord($row) : $row;
} else {
//Return
return null;

View File

@@ -403,8 +403,8 @@ class Light
//$app_uid = \G::getPathFromUID($oAppDocument->Fields['APP_UID']);
$file = \G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid);
$realPath = PATH_DOCUMENT . $app_uid . '/' . $file[0] . $file[1] . '_' . $iDocVersion . '.' . $ext;
$realPath1 = PATH_DOCUMENT . $app_uid . '/' . $file[0] . $file[1] . '.' . $ext;
$realPath = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '_' . $iDocVersion . '.' . $ext;
$realPath1 = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '.' . $ext;
$width = isset($fileData['width']) ? $fileData['width']:null;
$height = isset($fileData['height']) ? $fileData['height']:null;
@@ -604,15 +604,18 @@ class Light
*/
public function getInformation($userUid, $type, $app_uid)
{
$response = array();
switch ($type) {
case 'unassigned':
case 'paused':
case 'participated':
$oCase = new \Cases();
$iDelIndex = $oCase->getCurrentDelegationCase( $app_uid );
$aFields = $oCase->loadCase( $app_uid, $iDelIndex );
$this->getInfoResume($userUid, $aFields, $type);
$response = $this->getInfoResume($userUid, $aFields, $type);
break;
}
return $response;
}
/**
@@ -662,9 +665,149 @@ class Light
$Fields['TAS_TITLE'] = $aTask['TAS_TITLE'];
}
require_once(PATH_GULLIVER .'../thirdparty/smarty/libs/Smarty.class.php');
$G_PUBLISH = new \Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_Resume.xml', '', $Fields, '' );
$G_PUBLISH->RenderContent();
// require_once(PATH_GULLIVER .'../thirdparty/smarty/libs/Smarty.class.php');
// $G_PUBLISH = new \Publisher();
// $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_Resume.xml', '', $Fields, '' );
// $G_PUBLISH->RenderContent();
return $Fields;
}
/**
* first step for upload file
* create uid app_document for upload file
*
* @param $userUid
* @param $Fields
* @param $type
* @throws \Exception
*/
public function postUidUploadFiles($userUid, $app_uid, $request_data)
{
$response = array();
if (count( $request_data ) > 0) {
foreach ($request_data as $k => $file) {
$indocUid = null;
$fieldName = null;
$oCase = new \Cases();
$DEL_INDEX = $oCase->getCurrentDelegation( $app_uid, $userUid );
$aFields = array (
"APP_UID" => $app_uid,
"DEL_INDEX" => $DEL_INDEX,
"USR_UID" => $userUid,
"DOC_UID" => - 1,
"APP_DOC_TYPE" => "ATTACHED",
"APP_DOC_CREATE_DATE" => date( "Y-m-d H:i:s" ),
"APP_DOC_COMMENT" => "",
"APP_DOC_TITLE" => "",
"APP_DOC_FILENAME" => $file['name'],
"APP_DOC_FIELDNAME" => $fieldName
);
$oAppDocument = new \AppDocument();
$oAppDocument->create( $aFields );
$response[$k]['docVersion'] = $iDocVersion = $oAppDocument->getDocVersion();
$response[$k]['appDocUid'] = $sAppDocUid = $oAppDocument->getAppDocUid();
}
}
return $response;
}
/**
* second step for upload file
* upload file in foler app_uid
*
* @param $userUid
* @param $Fields
* @param $type
* @throws \Exception
*/
public function documentUploadFiles($userUid, $app_uid, $app_doc_uid, $request_data)
{
$response = array("status" => "fail");
if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) {
$arrayField = array ();
$arrayFileName = array ();
$arrayFileTmpName = array ();
$arrayFileError = array ();
$i = 0;
foreach ($_FILES["form"]["name"] as $fieldIndex => $fieldValue) {
if (is_array( $fieldValue )) {
foreach ($fieldValue as $index => $value) {
if (is_array( $value )) {
foreach ($value as $grdFieldIndex => $grdFieldValue) {
$arrayField[$i]["grdName"] = $fieldIndex;
$arrayField[$i]["grdFieldName"] = $grdFieldIndex;
$arrayField[$i]["index"] = $index;
$arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex][$index][$grdFieldIndex];
$arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex][$index][$grdFieldIndex];
$arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex][$index][$grdFieldIndex];
$i = $i + 1;
}
}
}
} else {
$arrayField[$i] = $fieldIndex;
$arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex];
$arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex];
$arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex];
$i = $i + 1;
}
}
if (count( $arrayField ) > 0) {
for ($i = 0; $i <= count( $arrayField ) - 1; $i ++) {
if ($arrayFileError[$i] == 0) {
$indocUid = null;
$fieldName = null;
$fileSizeByField = 0;
$oAppDocument = new \AppDocument();
$aAux = $oAppDocument->load($app_doc_uid);
$iDocVersion = $oAppDocument->getDocVersion();
$sAppDocUid = $oAppDocument->getAppDocUid();
$aInfo = pathinfo( $oAppDocument->getAppDocFilename() );
$sExtension = ((isset( $aInfo["extension"] )) ? $aInfo["extension"] : "");
$pathUID = G::getPathFromUID($app_uid);
$sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP;
$sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
G::uploadFile( $arrayFileTmpName[$i], $sPathName, $sFileName );
$response = array("status" => "ok");
}
}
}
}
return $response;
}
/**
* claim case
*
* @param $userUid
* @param $Fields
* @param $type
* @throws \Exception
*/
public function claimCaseUser($userUid, $sAppUid)
{
$response = array("status" => "fail");
$oCase = new \Cases();
$iDelIndex = $oCase->getCurrentDelegation( $sAppUid, $userUid );
$oAppDelegation = new \AppDelegation();
$aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex );
//if there are no user in the delegation row, this case is still in selfservice
if ($aDelegation['USR_UID'] == "") {
$oCase->setCatchUser( $sAppUid,$iDelIndex, $userUid );
$response = array("status" => "ok");
} else {
//G::SendMessageText( G::LoadTranslation( 'ID_CASE_ALREADY_DERIVATED' ), 'error' );
}
return $response;
}
}

View File

@@ -1,6 +1,8 @@
<?php
namespace ProcessMaker\BusinessModel;
use \G;
use \Criteria;
use \UsersPeer;
/**
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
@@ -174,10 +176,52 @@ class Lists {
$filtersData['date_to'] = $filters["dateTo"];
$response['filters'] = $filtersData;
$response['data'] = $result;
$filtersData['action'] = $filters["action"];
$response['totalCount'] = $list->countTotal($userUid, $filtersData);
} else {
$response = $result;
}
return $response;
}
/**
* Get counters for lists
*
* @access public
* @param array $userId, User Uid
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function getCounters($userId)
{
$criteria = new Criteria();
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_INBOX);
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_DRAFT);
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_CANCELLED);
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_PARTICIPATED);
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_PAUSED);
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_COMPLETED);
$criteria->add( UsersPeer::USR_UID, $userId, Criteria::EQUAL );
$dataset = UsersPeer::doSelectRS($criteria);
$dataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$dataset->next();
$aRow = $dataset->getRow();
$oAppCache = new \AppCacheView();
$totalUnassigned = $oAppCache->getListCounters('selfservice', $userId, false);
$response = array(
array('count' => $aRow['USR_TOTAL_INBOX'], 'item' => 'CASES_INBOX'),
array('count' => $aRow['USR_TOTAL_DRAFT'], 'item' => 'CASES_DRAFT'),
array('count' => $aRow['USR_TOTAL_CANCELLED'], 'item' => 'CASES_CANCELLED'),
array('count' => $aRow['USR_TOTAL_PARTICIPATED'], 'item' => 'CASES_SENT'),
array('count' => $aRow['USR_TOTAL_PAUSED'], 'item' => 'CASES_PAUSED'),
array('count' => $aRow['USR_TOTAL_COMPLETED'], 'item' => 'CASES_COMPLETED'),
array('count' => $totalUnassigned, 'item' => 'CASES_SELFSERVICE')
);
return $response;
}
}

View File

@@ -340,7 +340,7 @@ class MessageApplication
$criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_USR_UID);
$criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_VARIABLES);
$criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_CORRELATION);
$criteria->addSelectColumn(\MessageEventTaskRelationPeer::TAS_UID);
$criteria->addSelectColumn(\ElementTaskRelationPeer::TAS_UID);
$arrayEventType = array("START", "INTERMEDIATE");
$arrayEventMarker = array("MESSAGECATCH");
@@ -351,7 +351,8 @@ class MessageApplication
$criteria->addJoin(\MessageApplicationPeer::EVN_UID_CATCH, \MessageEventDefinitionPeer::EVN_UID, \Criteria::INNER_JOIN);
$criteria->addJoin(\MessageApplicationPeer::EVN_UID_CATCH, \MessageEventTaskRelationPeer::EVN_UID, \Criteria::INNER_JOIN);
$criteria->addJoin(\MessageApplicationPeer::EVN_UID_CATCH, \ElementTaskRelationPeer::ELEMENT_UID, \Criteria::INNER_JOIN);
$criteria->add(\ElementTaskRelationPeer::ELEMENT_TYPE, "bpmnEvent", \Criteria::EQUAL);
if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["messageApplicationStatus"]) && trim($arrayFilterData["messageApplicationStatus"]) != "") {
$criteria->add(\MessageApplicationPeer::MSGAPP_STATUS, $arrayFilterData["messageApplicationStatus"], \Criteria::EQUAL);

View File

@@ -169,6 +169,10 @@ class Process
public function throwExceptionIfDataNotMetFieldDefinition($arrayData, $arrayFieldDefinition, $arrayFieldNameForException, $flagValidateRequired = true)
{
try {
\G::LoadSystem('inputfilter');
$filter = new \InputFilter();
if ($flagValidateRequired) {
foreach ($arrayFieldDefinition as $key => $value) {
$fieldName = $key;
@@ -187,6 +191,7 @@ class Process
foreach ($arrayData as $key => $value) {
$fieldName = $key;
$fieldValue = $value;
if (isset($arrayFieldDefinition[$fieldName])) {
$fieldNameAux = (isset($arrayFieldNameForException[$arrayFieldDefinition[$fieldName]["fieldNameAux"]]))? $arrayFieldNameForException[$arrayFieldDefinition[$fieldName]["fieldNameAux"]] : "";
@@ -281,6 +286,7 @@ class Process
}
if (is_string($fieldValue) && trim($fieldValue) . "" != "") {
$fieldValue = $filter->validateInput($fieldValue);
eval("\$arrayAux = $fieldValue;");
}

View File

@@ -215,7 +215,7 @@ class User
if ($form['USR_REPLACED_BY'] != '') {
$oReplacedBy = \UsersPeer::retrieveByPK($form['USR_REPLACED_BY']);
if (is_null($oReplacedBy)) {
throw new \Exception('usr_replaced_by:'.$form['USR_REPLACED_BY'].' '.\G::LoadTranslation('ID_AUTHENTICATION_SOURCE_INVALID'));
throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_EXIST", array(strtolower("USR_REPLACED_BY"), $form["USR_REPLACED_BY"])));
}
}
}

View File

@@ -35,47 +35,6 @@ class Validator
return $dep_uid;
}
/**
* Validate dep_title
* @var string $dep_title. Name or Title for Departament
* @var string $dep_uid. Uid for Departament
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return array
*
* @url GET
*/
static public function depTitle($dep_title, $dep_uid = '')
{
$dep_title = trim($dep_title);
if ($dep_title == '') {
throw (new \Exception(\G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array('dep_title',''))));
}
$oCriteria = new \Criteria( 'workflow' );
$oCriteria->clearSelectColumns();
$oCriteria->addSelectColumn( \ContentPeer::CON_CATEGORY );
$oCriteria->addSelectColumn( \ContentPeer::CON_VALUE );
$oCriteria->addSelectColumn( \DepartmentPeer::DEP_PARENT );
$oCriteria->add( \ContentPeer::CON_CATEGORY, 'DEPO_TITLE' );
$oCriteria->addJoin( \ContentPeer::CON_ID, \DepartmentPeer::DEP_UID, \Criteria::LEFT_JOIN );
$oCriteria->add( \ContentPeer::CON_VALUE, $dep_title );
$oCriteria->add( \ContentPeer::CON_LANG, SYS_LANG );
if ($dep_uid != '') {
$oCriteria->add( \ContentPeer::CON_ID, $dep_uid, \Criteria::NOT_EQUAL );
}
$oDataset = \DepartmentPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
if ($oDataset->next()) {
throw (new \Exception(\G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array('dep_title',$dep_title))));
}
return $dep_title;
}
/**
* Validate dep_status
* @var string $dep_uid. Uid for Departament

View File

@@ -398,7 +398,7 @@ class WebEntry
$fileContent .= "G::LoadClass('pmDynaform');\n";
$fileContent .= "\$a = new pmDynaform('".$arrayWebEntryData["DYN_UID"]."', array());\n";
$fileContent .= "\$a = new pmDynaform(array('CURRENT_DYNAFORM'=>'" . $arrayWebEntryData["DYN_UID"] . "'));\n";
$fileContent .= "if(\$a->isResponsive()){";
$fileContent .= "\$a->printWebEntry('".$fileName."Post.php');";
$fileContent .= "}else {";

View File

@@ -288,7 +288,7 @@ class WebEntryEvent
throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_EXIST", array($this->arrayFieldNameForException["eventUid"], $arrayData["EVN_UID"])));
}
if ($obj->getEvnType() != "START") {
if (($obj->getEvnType() != "START") || ($obj->getEvnType() == "START" && $obj->getEvnMarker() != "EMPTY")) {
throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_IS_START_EVENT", array($this->arrayFieldNameForException["eventUid"], $arrayData["EVN_UID"])));
}
}