Merged in victorsl/processmaker/PM-475 (pull request #1069)
16052 - Revisar problema de self-service con Value-based de grupos
This commit is contained in:
124
workflow/engine/classes/model/AppAssignSelfServiceValue.php
Normal file
124
workflow/engine/classes/model/AppAssignSelfServiceValue.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
class AppAssignSelfServiceValue extends BaseAppAssignSelfServiceValue
|
||||
{
|
||||
/**
|
||||
* Create record
|
||||
*
|
||||
* @param string $applicationUid Unique id of Case
|
||||
* @param int $delIndex Delegation index
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function create($applicationUid, $delIndex, array $arrayData)
|
||||
{
|
||||
try {
|
||||
$cnn = Propel::getConnection(AppAssignSelfServiceValuePeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$appAssignSelfServiceValue = new AppAssignSelfServiceValue();
|
||||
|
||||
$appAssignSelfServiceValue->fromArray($arrayData, BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
$appAssignSelfServiceValue->setAppUid($applicationUid);
|
||||
$appAssignSelfServiceValue->setDelIndex($delIndex);
|
||||
|
||||
if ($appAssignSelfServiceValue->validate()) {
|
||||
$cnn->begin();
|
||||
|
||||
$result = $appAssignSelfServiceValue->save();
|
||||
|
||||
$cnn->commit();
|
||||
} else {
|
||||
$msg = "";
|
||||
|
||||
foreach ($appAssignSelfServiceValue->getValidationFailures() as $validationFailure) {
|
||||
$msg .= (($msg != "")? "\n" : "") . $validationFailure->getMessage();
|
||||
}
|
||||
|
||||
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$cnn->rollback();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove record
|
||||
*
|
||||
* @param string $applicationUid Unique id of Case
|
||||
* @param int $delIndex Delegation index
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function remove($applicationUid, $delIndex = 0)
|
||||
{
|
||||
try {
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->add(AppAssignSelfServiceValuePeer::APP_UID, $applicationUid, Criteria::EQUAL);
|
||||
|
||||
if ($delIndex != 0) {
|
||||
$criteria->add(AppAssignSelfServiceValuePeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$result = AppAssignSelfServiceValuePeer::doDelete($criteria);
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate data
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function generateData()
|
||||
{
|
||||
try {
|
||||
G::LoadClass("case");
|
||||
|
||||
AppAssignSelfServiceValuePeer::doDeleteAll(); //Delete all records
|
||||
|
||||
//Generate data
|
||||
$case = new Cases();
|
||||
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(AppDelegationPeer::APP_UID);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||
$criteria->addSelectColumn(ApplicationPeer::APP_DATA);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(TaskPeer::TAS_UID);
|
||||
$criteria->addSelectColumn(TaskPeer::TAS_GROUP_VARIABLE);
|
||||
$criteria->addJoin(AppDelegationPeer::APP_UID, ApplicationPeer::APP_UID, Criteria::LEFT_JOIN);
|
||||
$criteria->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
|
||||
$criteria->add(TaskPeer::TAS_ASSIGN_TYPE, "SELF_SERVICE", Criteria::EQUAL);
|
||||
$criteria->add(TaskPeer::TAS_GROUP_VARIABLE, "", Criteria::NOT_EQUAL);
|
||||
$criteria->add(AppDelegationPeer::USR_UID, "", Criteria::EQUAL);
|
||||
$criteria->add(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN", Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = AppDelegationPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$applicationData = $case->unserializeData($row["APP_DATA"]);
|
||||
$taskGroupVariable = trim($row["TAS_GROUP_VARIABLE"], " @#");
|
||||
|
||||
if ($taskGroupVariable != "" && isset($applicationData[$taskGroupVariable]) && trim($applicationData[$taskGroupVariable]) != "") {
|
||||
$this->create($row["APP_UID"], $row["DEL_INDEX"], array("PRO_UID" => $row["PRO_UID"], "TAS_UID" => $row["TAS_UID"], "GRP_UID" => trim($applicationData[$taskGroupVariable])));
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
class AppAssignSelfServiceValuePeer extends BaseAppAssignSelfServiceValuePeer
|
||||
{
|
||||
}
|
||||
|
||||
@@ -330,61 +330,47 @@ class AppCacheView extends BaseAppCacheView
|
||||
|
||||
public function getSelfServiceCasesByEvaluate($userUid)
|
||||
{
|
||||
$cases = array();
|
||||
try {
|
||||
G::LoadClass("groups");
|
||||
|
||||
//check groups assigned to SelfService task
|
||||
G::LoadClass('groups');
|
||||
$group = new Groups();
|
||||
$aGroups = $group->getActiveGroupsForAnUser($userUid);
|
||||
$arrayApplicationUid = array();
|
||||
|
||||
$c = new Criteria();
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn(TaskPeer::TAS_UID);
|
||||
$c->addSelectColumn(TaskPeer::PRO_UID);
|
||||
$c->addSelectColumn(TaskPeer::TAS_GROUP_VARIABLE);
|
||||
$c->addJoin(TaskPeer::PRO_UID, ProcessPeer::PRO_UID, Criteria::LEFT_JOIN);
|
||||
$c->addJoin(TaskPeer::TAS_UID, TaskUserPeer::TAS_UID, Criteria::LEFT_JOIN);
|
||||
$c->add(ProcessPeer::PRO_STATUS, 'ACTIVE');
|
||||
$c->add(TaskPeer::TAS_ASSIGN_TYPE, 'SELF_SERVICE');
|
||||
$c->add(TaskPeer::TAS_GROUP_VARIABLE, '', Criteria::NOT_EQUAL);
|
||||
$rs = TaskPeer::doSelectRS($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
//Get APP_UIDs
|
||||
$group = new Groups();
|
||||
|
||||
if ($rs->getRecordCount() > 0) {
|
||||
if (!class_exists('Cases')) {
|
||||
G::loadClass('case');
|
||||
}
|
||||
$caseInstance = new Cases();
|
||||
while ($row = $rs->getRow()) {
|
||||
$tasGroupVariable = str_replace(array('@', '#'), '', $row['TAS_GROUP_VARIABLE']);
|
||||
$c2 = new Criteria();
|
||||
$c2->clearSelectColumns();
|
||||
$c2->addSelectColumn(AppDelegationPeer::APP_UID);
|
||||
$c2->addSelectColumn(ApplicationPeer::APP_DATA);
|
||||
$c2->addJoin(AppDelegationPeer::APP_UID, ApplicationPeer::APP_UID, Criteria::LEFT_JOIN);
|
||||
$c2->add(AppDelegationPeer::TAS_UID, $row['TAS_UID']);
|
||||
$c2->add(AppDelegationPeer::USR_UID, '');
|
||||
$c2->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN');
|
||||
$rs2 = AppDelegationPeer::doSelectRS($c2);
|
||||
$rs2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs2->next();
|
||||
while ($row2 = $rs2->getRow()) {
|
||||
$caseData = $caseInstance->unserializeData($row2['APP_DATA']);
|
||||
$arrayGroup = $group->getActiveGroupsForAnUser($userUid); //Get Groups of User
|
||||
|
||||
if (isset($caseData[$tasGroupVariable])) {
|
||||
if (trim($caseData[$tasGroupVariable]) != '') {
|
||||
if (in_array(trim($caseData[$tasGroupVariable]), $aGroups)) {
|
||||
$cases[] = $row2['APP_UID'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$rs2->next();
|
||||
if (count($arrayGroup) > 0) {
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->setDistinct();
|
||||
$criteria->addSelectColumn(AppAssignSelfServiceValuePeer::APP_UID);
|
||||
|
||||
$arrayCondition = array();
|
||||
$arrayCondition[] = array(AppAssignSelfServiceValuePeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::EQUAL);
|
||||
$arrayCondition[] = array(AppAssignSelfServiceValuePeer::DEL_INDEX, AppDelegationPeer::DEL_INDEX, Criteria::EQUAL);
|
||||
$arrayCondition[] = array(AppAssignSelfServiceValuePeer::TAS_UID, AppDelegationPeer::TAS_UID, Criteria::EQUAL);
|
||||
$criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
|
||||
|
||||
$criteria->add(AppDelegationPeer::USR_UID, "", Criteria::EQUAL);
|
||||
$criteria->add(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN", Criteria::EQUAL);
|
||||
$criteria->add(AppAssignSelfServiceValuePeer::GRP_UID, $arrayGroup, Criteria::IN);
|
||||
|
||||
$rsCriteria = AppAssignSelfServiceValuePeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$arrayApplicationUid[] = $row["APP_UID"];
|
||||
}
|
||||
$rs->next();
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayApplicationUid;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
return $cases;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1210,7 +1196,7 @@ class AppCacheView extends BaseAppCacheView
|
||||
$rs1 = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||
$rs1->next();
|
||||
$row = $rs1->getRow();
|
||||
|
||||
|
||||
if ($row['PRIVILEGE_TYPE'] == 'SUPER') {
|
||||
$super = G::LoadTranslation('ID_TRUE'); //true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
require_once 'propel/map/MapBuilder.php';
|
||||
include_once 'creole/CreoleTypes.php';
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'APP_ASSIGN_SELF_SERVICE_VALUE' table to 'workflow' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package workflow.classes.model.map
|
||||
*/
|
||||
class AppAssignSelfServiceValueMapBuilder
|
||||
{
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'classes.model.map.AppAssignSelfServiceValueMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('workflow');
|
||||
|
||||
$tMap = $this->dbMap->addTable('APP_ASSIGN_SELF_SERVICE_VALUE');
|
||||
$tMap->setPhpName('AppAssignSelfServiceValue');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addColumn('APP_UID', 'AppUid', 'string', CreoleTypes::VARCHAR, true, 32);
|
||||
|
||||
$tMap->addColumn('DEL_INDEX', 'DelIndex', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('PRO_UID', 'ProUid', 'string', CreoleTypes::VARCHAR, true, 32);
|
||||
|
||||
$tMap->addColumn('TAS_UID', 'TasUid', 'string', CreoleTypes::VARCHAR, true, 32);
|
||||
|
||||
$tMap->addColumn('GRP_UID', 'GrpUid', 'string', CreoleTypes::VARCHAR, true, 32);
|
||||
|
||||
} // doBuild()
|
||||
}// AppAssignSelfServiceValueMapBuilder
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user