Merge remote branch 'upstream/master' into BUG-8038

This commit is contained in:
Marco Antonio Nina
2012-08-16 17:56:32 -04:00
22 changed files with 807 additions and 623 deletions

View File

@@ -19,7 +19,7 @@ class Applications
$type = isset($type) ? $type: 'extjs';
$dateFrom = isset($dateFrom)? $dateFrom : '';
$dateTo = isset($dateTo) ? $dateTo : '';
G::LoadClass("BasePeer" );
G::LoadClass ( 'configuration' );
require_once ( "classes/model/AppCacheView.php" );
@@ -31,7 +31,7 @@ class Applications
//$userUid = ( isset($_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] != '' ) ? $_SESSION['USER_LOGGED'] : null; <-- passed by param
$oAppCache = new AppCacheView();
//get data configuration
$conf = new Configurations();
$confCasesList = $conf->getConfiguration('casesList',($action=='search'||$action=='simple_search')?'sent':$action );
@@ -98,10 +98,20 @@ class Applications
break;
}
// $Criteria->addJoin(AppCacheViewPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
$Criteria->addJoin(AppCacheViewPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
$Criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME );
$Criteria->addSelectColumn(UsersPeer::USR_LASTNAME );
$Criteria->addAlias('CU', 'USERS');
$Criteria->addJoin(AppCacheViewPeer::USR_UID, 'CU.USR_UID', Criteria::LEFT_JOIN);
$Criteria->addAsColumn('USR_FIRSTNAME', 'CU.USR_FIRSTNAME');
$Criteria->addAsColumn('USR_LASTNAME', 'CU.USR_LASTNAME');
$Criteria->addAsColumn('USR_USERNAME', 'CU.USR_USERNAME');
// Fix for previous user
if ($action == 'todo' || $action == 'selfservice' || $action =='unassigned' || $action == 'paused' || $action == 'to_revise') {
$Criteria->addAlias('PU', 'USERS');
$Criteria->addJoin(AppCacheViewPeer::PREVIOUS_USR_UID, 'PU.USR_UID', Criteria::LEFT_JOIN);
$Criteria->addAsColumn('PREVIOUS_USR_FIRSTNAME', 'PU.USR_FIRSTNAME');
$Criteria->addAsColumn('PREVIOUS_USR_LASTNAME', 'PU.USR_LASTNAME');
$Criteria->addAsColumn('PREVIOUS_USR_USERNAME', 'PU.USR_USERNAME');
}
if ( !is_array($confCasesList) ) {
$rows = $this->getDefaultFields( $action );
@@ -155,14 +165,14 @@ class Applications
$CriteriaCount->add (AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL );
}
//add the filter
//add the filter
if ( $filter != '' ) {
switch ( $filter ) {
case 'read' :
$Criteria->add (AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL);
$CriteriaCount->add (AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL);
break;
case 'unread' :
case 'unread' :
$Criteria->add (AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL);
$CriteriaCount->add (AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL);
break;
@@ -175,7 +185,7 @@ class Applications
$CriteriaCount->add (AppCacheViewPeer::APP_STATUS, 'COMPLETED', Criteria::EQUAL);
break;
}
}
}
//add the search filter
if ( $search != '' ) {
@@ -245,7 +255,7 @@ class Applications
//here we count how many records exists for this criteria.
//BUT there are some special cases, and if we dont optimize them the server will crash.
$doCountAlreadyExecuted = false;
//case 1. when the SEARCH action is selected and none filter, search criteria is defined,
//case 1. when the SEARCH action is selected and none filter, search criteria is defined,
//we need to count using the table APPLICATION, because APP_CACHE_VIEW takes 3 seconds
if ( $action == 'search' && $filter == '' && $search == '' && $process == '' && $status == '' && $dateFrom == '' && $dateTo == '') {
@@ -282,7 +292,7 @@ class Applications
}
//add sortable options
//add sortable options
if ( $sort != '' ) {
if ( $dir == 'DESC' )
$Criteria->addDescendingOrderByColumn( $sort );
@@ -290,7 +300,7 @@ class Applications
$Criteria->addAscendingOrderByColumn( $sort );
}
//limit the results according the interface
//limit the results according the interface
$Criteria->setLimit( $limit );
$Criteria->setOffset( $start );
@@ -327,7 +337,7 @@ class Applications
$index = $start;
while($aRow = $oDataset->getRow()){
//$aRow = $oAppCache->replaceRowUserData($aRow);
/* For participated cases, we want the last step in the case, not only
* the last step this user participated. To do that we get every case
* information again for the last step. (This could be solved by a subquery,
@@ -349,14 +359,14 @@ class Applications
if (array_key_exists($col, $newData))
$aRow[$col] = $newData[$col];
}
$maxDataset->close();
}
if (!isset($aRow['APP_CURRENT_USER']))
$aRow['APP_CURRENT_USER'] = "[Unassigned]";
// replacing the status data with their respective translation
// replacing the status data with their respective translation
if( isset($aRow['APP_STATUS']) ){
$aRow['APP_STATUS'] = G::LoadTranslation("ID_{$aRow['APP_STATUS']}");
}
@@ -365,17 +375,17 @@ class Applications
if( isset($aRow['DEL_PRIORITY']) ){
$aRow['DEL_PRIORITY'] = G::LoadTranslation("ID_PRIORITY_{$aPriorities[$aRow['DEL_PRIORITY']]}");
}
$rows[] = $aRow;
$oDataset->next();
}
$result['data'] = $rows;
return $result;
}
//TODO: Encapsulates these and another default generation functions inside a class
/**
* generate all the default fields
@@ -631,7 +641,7 @@ class Applications
G::LoadClass('pmScript');
G::LoadClass('case');
$steps = Array();
$case = new Cases;
$step = new Step;
@@ -661,7 +671,7 @@ class Applications
if (trim($caseStep->getStepCondition()) != '') { // if it has a condition
$pmScript->setScript($caseStep->getStepCondition());
if (!$pmScript->evaluate()) { //evaluate
//evaluated false, jump & continue with the others steps
continue;
@@ -689,18 +699,18 @@ class Applications
$outputDoc = $appDocument->getObject($appUid, $index, $caseStep->getStepUidObj(), 'OUTPUT');
$stepItem['title'] = $oDocument->getOutDocTitle();
if ($outputDoc['APP_DOC_UID']) {
$stepItem['url'] = "cases/cases_Step?UID=$stepUid&TYPE=$stepType&POSITION=$stepPosition&ACTION=VIEW&DOC={$outputDoc['APP_DOC_UID']}";
$stepItem['url'] = "cases/cases_Step?UID=$stepUid&TYPE=$stepType&POSITION=$stepPosition&ACTION=VIEW&DOC={$outputDoc['APP_DOC_UID']}";
}
else {
$stepItem['url'] = "cases/cases_Step?UID=$stepUid&TYPE=$stepType&POSITION=$stepPosition&ACTION=GENERATE";
$stepItem['url'] = "cases/cases_Step?UID=$stepUid&TYPE=$stepType&POSITION=$stepPosition&ACTION=GENERATE";
}
break;
case 'INPUT_DOCUMENT':
$oDocument = InputDocumentPeer::retrieveByPK($stepUid);
$stepItem['title'] = $oDocument->getInpDocTitle();
$stepItem['url'] = "cases/cases_Step?UID=$stepUid&TYPE=$stepType&POSITION=$stepPosition&ACTION=ATTACH";
break;
@@ -708,11 +718,11 @@ class Applications
case 'EXTERNAL':
$stepTitle = 'unknown ' . $caseStep->getStepUidObj();
$oPluginRegistry = PMPluginRegistry::getSingleton();
$externalStep = $externalSteps[$caseStep->getStepUidObj()];
$stepItem['id'] = $externalStep->sStepId;
$stepItem['title'] = $externalStep->sStepTitle;
$stepItem['url'] = "cases/cases_Step?UID={$externalStep->sStepId}&TYPE=EXTERNAL&POSITION=$stepPosition&ACTION=EDIT";
$stepItem['url'] = "cases/cases_Step?UID={$externalStep->sStepId}&TYPE=EXTERNAL&POSITION=$stepPosition&ACTION=EDIT";
break;
}
@@ -725,8 +735,8 @@ class Applications
$stepItem['type'] = '';
$stepItem['title'] = G::LoadTranslation('ID_ASSIGN_TASK');
$stepItem['url'] = "cases/cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN";
$steps[] = $stepItem;
$steps[] = $stepItem;
return $steps;
}

View File

@@ -125,7 +125,7 @@ class Derivation
$aDerivation['NEXT_TASK']['TAS_DEF_PROC_CODE'] = '';
$aDerivation['NEXT_TASK']['TAS_PARENT'] = '';
$aDerivation['NEXT_TASK']['TAS_TRANSFER_FLY'] = '';
switch ($aDerivation['ROU_NEXT_TASK']) {
case -1: $aDerivation['NEXT_TASK']['TAS_TITLE'] = G::LoadTranslation('ID_END_OF_PROCESS');
break;
@@ -274,12 +274,10 @@ class Derivation
$oUser = UsersPeer::retrieveByPK( $row['USR_UID'] );
if( $oUser->getUsrStatus() == 'ACTIVE' ){
$users[$row['USR_UID']] = $row['USR_UID'];
} else if($oUser->getUsrStatus() == 'VACATION'){
//this a litle hook for this issue,...
//TODO if the user in getUsrReplacedBy() is not assignet to the same task,. will have problems,....
$UsrReplace = $oUser->getUsrReplacedBy();
if( trim($UsrReplace) != ''){
//$users[$UsrReplace] = $UsrReplace;
} else {
$userUID = $this->checkReplacedByUser($oUser);
if ($userUID != '') {
$users[$userUID] = $userUID;
}
}
}
@@ -321,7 +319,7 @@ class Derivation
else {
$oCriteria = new Criteria();
$oCriteria->add(UsersPeer::USR_UID, $aUsers);
if (UsersPeer::doCount($oCriteria) < 1) {
return null;
}
@@ -394,7 +392,7 @@ class Derivation
$variable = str_replace ( '@@', '', $nextAssignedTask['TAS_ASSIGN_VARIABLE'] );
if ( isset ( $AppFields['APP_DATA'][$variable] ) ) {
if ($AppFields['APP_DATA'][$variable] != '') {
$value = $AppFields['APP_DATA'][$variable];
$value = $this->checkReplacedByUser($AppFields['APP_DATA'][$variable]);
$userFields = $this->getUsersFullNameFromArray ($value);
if (is_null($userFields)) {
throw ( new Exception("Task doesn't have a valid user in variable $variable.") ) ;
@@ -419,12 +417,12 @@ class Derivation
$userFields['USR_EMAIL'] = '';
//get the report_to user & its full info
$useruid = $this->getDenpendentUser($tasInfo['USER_UID']);
$useruid = $this->getDenpendentUser($this->checkReplacedByUser($tasInfo['USER_UID']));
if (isset($useruid) && $useruid != '') {
$userFields = $this->getUsersFullNameFromArray($useruid);
}
// if there is no report_to user info, throw an exception indicating this
if (!isset($userFields) || $userFields['USR_UID'] == '') {
throw ( new Exception(G::LoadTranslation('ID_MSJ_REPORSTO')));// "The current user does not have a valid Reports To user. Please contact administrator.") ) ;
@@ -555,7 +553,7 @@ class Derivation
$iAppThreadIndex = $appFields['DEL_THREAD'];
$this->case->closeAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex);
break;
default:
// get all siblingThreads
//if($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI')
@@ -574,22 +572,22 @@ class Derivation
$sMIcompleteVar = $aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'])];
else
$sMIcompleteVar = $aData['APP_DATA']['TAS_MI_COMPLETE_VARIABLE'];
$discriminateThread = $sMIinstanceVar - $sMIcompleteVar;
// -1 because One App Delegation is closed by above Code
if($discriminateThread == count($siblingThreads))
$canDerivate =true;
else
$canDerivate =false;
break;
default:
if ( $currentDelegation['ROU_TYPE'] == 'SEC-JOIN') {
$siblingThreads = $this->case->getOpenSiblingThreads(
$nextDel['TAS_UID'],
$currentDelegation['APP_UID'],
$currentDelegation['DEL_INDEX'],
$nextDel['TAS_UID'],
$currentDelegation['APP_UID'],
$currentDelegation['DEL_INDEX'],
$currentDelegation['TAS_UID'],
$currentDelegation['ROU_TYPE']
);
@@ -641,26 +639,26 @@ class Derivation
$appFields['APP_STATUS'] = $currentDelegation['APP_STATUS'];
/* Start Block : Count the open threads of $currentDelegation['APP_UID'] */
$openThreads = $this->case->GetOpenThreads( $currentDelegation['APP_UID'] );
///////
$sw = 0;
if ($openThreads == 0) {
//Close case
$appFields["APP_STATUS"] = "COMPLETED";
$appFields["APP_FINISH_DATE"] = "now";
$this->verifyIsCaseChild($currentDelegation["APP_UID"]);
$sw = 1;
}
if (isset($iNewDelIndex)) {
$appFields["DEL_INDEX"] = $iNewDelIndex;
$appFields["TAS_UID"] = $nextDel["TAS_UID"];
$sw = 1;
}
if ($sw == 1) {
//Start Block : UPDATES APPLICATION
$this->case->updateCase($currentDelegation["APP_UID"], $appFields);
@@ -673,7 +671,7 @@ class Derivation
{
$iAppThreadIndex = $appFields['DEL_THREAD'];
$delType = 'NORMAL';
if (is_numeric($nextDel['DEL_PRIORITY'])) {
$nextDel['DEL_PRIORITY'] = (isset($nextDel['DEL_PRIORITY']) ? ($nextDel['DEL_PRIORITY'] >= 1 && $nextDel['DEL_PRIORITY'] <= 5 ? $nextDel['DEL_PRIORITY'] : '3') : '3');
}
@@ -686,12 +684,12 @@ class Derivation
// Create new delegation depending on the no of users in the group
$iNewAppThreadIndex = $appFields['DEL_THREAD'];
$this->case->closeAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex);
foreach($nextDel['NEXT_TASK']['USER_ASSIGNED'] as $key=>$aValue){
//Incrementing the Del_thread First so that new delegation has new del_thread
$iNewAppThreadIndex += 1;
//Creating new delegation according to users in group
$iMIDelIndex = $this->case->newAppDelegation(
$iMIDelIndex = $this->case->newAppDelegation(
$appFields['PRO_UID'],
$currentDelegation['APP_UID'],
$nextDel['TAS_UID'],
@@ -732,7 +730,7 @@ class Derivation
}
$iAppThreadIndex = $appFields['DEL_THREAD'];
switch ( $currentDelegation['ROU_TYPE'] ) {
case 'PARALLEL' :
case 'PARALLEL-BY-EVALUATION' :
@@ -741,12 +739,12 @@ class Derivation
$this->case->updateAppDelegation ( $currentDelegation['APP_UID'], $iNewDelIndex, $iNewThreadIndex );
//print " this->case->updateAppDelegation ( " . $currentDelegation['APP_UID'] .", " . $iNewDelIndex ." , " . $iNewThreadIndex . " )<br>";
break;
case 'DISCRIMINATOR':
if($currentDelegation['ROU_OPTIONAL'] == 'TRUE') {
$this->case->discriminateCases($currentDelegation);
} //No Break, executing Default Condition
default :
switch ($currentDelegation['TAS_ASSIGN_TYPE']) {
case 'CANCEL_MI':
@@ -776,7 +774,7 @@ class Derivation
$aOldFields['APP_DATA'] = array_merge($aOldFields['APP_DATA'], $aNewFields);
$aOldFields['APP_STATUS'] = 'TO_DO';
$this->case->updateCase($aNewCase['APPLICATION'], $aOldFields);
//Create a registry in SUB_APPLICATION table
$aSubApplication = array('APP_UID' => $aNewCase['APPLICATION'],
@@ -796,11 +794,11 @@ class Derivation
$oSubApplication->create($aSubApplication);
//Update the AppDelegation to execute the update trigger
$AppDelegation = AppDelegationPeer::retrieveByPK($aNewCase['APPLICATION'], $aNewCase['INDEX']);
// note added by krlos pacha carlos[at]colosa[dot]com
// the following line of code was commented because it is related to the 6878 bug
// note added by krlos pacha carlos[at]colosa[dot]com
// the following line of code was commented because it is related to the 6878 bug
//$AppDelegation->setDelInitDate("+1 second");
$AppDelegation->save();
//If not is SYNCHRONOUS derivate one more time
@@ -1031,8 +1029,28 @@ class Derivation
$aData[$aKey] = $userid;
}
return $aGrp;
//var_dump($aDerivation);
//die;
}
}
function checkReplacedByUser($user)
{
if (get_class($user) != 'Users') {
$userInstance = UsersPeer::retrieveByPK($user);
} else {
$userInstance = $user;
}
if (!is_object($userInstance)) {
throw new Exception("The user with the UID '$user' doesn't exist.");
}
if ($userInstance->getUsrStatus() == 'ACTIVE') {
return $userInstance->getUsrUid();
} else {
$userReplace = trim($userInstance->getUsrReplacedBy());
if ($userReplace != '') {
return $this->checkReplacedByUser(UsersPeer::retrieveByPK($userReplace));
} else {
return '';
}
}
}
}

View File

@@ -2,7 +2,7 @@
/**
* Dynaform.php
* @package workflow.engine.classes.model
*
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.
*
@@ -81,7 +81,7 @@ class Dynaform extends BaseDynaform {
if ($this->dyn_title !== $v || $v === '') {
$this->dyn_title = $v;
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$res = Content::addContent( 'DYN_TITLE', '', $this->getDynUid(), $lang, $this->dyn_title );
}
@@ -127,7 +127,7 @@ class Dynaform extends BaseDynaform {
if ($this->dyn_description !== $v || $v === '') {
$this->dyn_description = $v;
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$res = Content::addContent( 'DYN_DESCRIPTION', '', $this->getDynUid(), $lang, $this->dyn_description );
}
@@ -175,7 +175,7 @@ class Dynaform extends BaseDynaform {
$con->commit();
$sXml = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
$sXml .= '<dynaForm type="' . $this->getDynType() . '" name="' . $this->getProUid() . '/' . $this->getDynUid() . '" width="500" enabletemplate="0" mode="">'."\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');
@@ -200,7 +200,7 @@ class Dynaform extends BaseDynaform {
/**
*
* Creates a Dynaform based on a PMTable
*
*
* @name createFromPMTable
* @author gustavo cruz gustavo[at]colosa[dot]com
* @param array $aData Fields with :
@@ -252,7 +252,7 @@ class Dynaform extends BaseDynaform {
} else {
$sql = 'DESC '.$addTabName;
}
$dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
$sth = $dbh->createStatement();
$res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
@@ -277,7 +277,7 @@ class Dynaform extends BaseDynaform {
if ($res->get('Key') != '') {
$countKeys++;
}
if ($res->get('Extra') == 'auto_increment') {
if ($res->get('Extra') == 'auto_increment') {
$keyRequered .= $res->get('Field');
}
}
@@ -474,7 +474,7 @@ class Dynaform extends BaseDynaform {
throw($oError);
}
}
function getDynaformContent( $dynaformUid) {
$content = '';
$fields = $this->Load ( $dynaformUid);
@@ -482,9 +482,9 @@ class Dynaform extends BaseDynaform {
if (file_exists( $filename )) {
$content = file_get_contents ( $filename );
}
return $content;
}
}
function getDynaformFields( $dynaformUid) {
$content = '';
@@ -493,10 +493,10 @@ class Dynaform extends BaseDynaform {
if (file_exists( $filename )) {
$content = file_get_contents ( $filename );
}
$G_FORM = new xmlform ( $fields['DYN_FILENAME'] , PATH_DYNAFORM );
$G_FORM->parseFile( $filename , SYS_LANG, true );
return $G_FORM->fields;
}