diff --git a/workflow/engine/classes/class.AppSolr.php b/workflow/engine/classes/class.AppSolr.php
index 3c7b03282..2f67ad9e2 100644
--- a/workflow/engine/classes/class.AppSolr.php
+++ b/workflow/engine/classes/class.AppSolr.php
@@ -1,6 +1,6 @@
code}]: {$this->message}\n";
- }
+ // Redefine the exception so message isn't optional
+ public function __construct ($message, $code = 0)
+ {
+ // some code
+ // make sure everything is assigned properly
+ parent::__construct( $message, $code );
+ }
+
+ // custom string representation of object
+ public function __toString ()
+ {
+ return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
+ }
}
/**
* Application without Delegations exception
*
* @author Herbert Saal Gutierrez
- *
+ *
* @category Colosa
* @copyright Copyright (c) 2005-2012 Colosa Inc. (http://www.colosa.com)
*/
class ApplicationWithoutDelegationRecordsException extends Exception
{
- // Redefine the exception so message isn't optional
- public function __construct($message, $code = 0)
- {
- // some code
- // make sure everything is assigned properly
- parent::__construct ($message, $code);
- }
-
- // custom string representation of object
- public function __toString()
- {
- return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
- }
+ // Redefine the exception so message isn't optional
+ public function __construct ($message, $code = 0)
+ {
+ // some code
+ // make sure everything is assigned properly
+ parent::__construct( $message, $code );
+ }
+
+ // custom string representation of object
+ public function __toString ()
+ {
+ return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
+ }
}
/**
@@ -95,19 +94,19 @@ class ApplicationWithoutDelegationRecordsException extends Exception
*/
class ApplicationWithCorruptDynaformException extends Exception
{
- // Redefine the exception so message isn't optional
- public function __construct($message, $code = 0)
- {
- // some code
- // make sure everything is assigned properly
- parent::__construct ($message, $code);
- }
+ // Redefine the exception so message isn't optional
+ public function __construct ($message, $code = 0)
+ {
+ // some code
+ // make sure everything is assigned properly
+ parent::__construct( $message, $code );
+ }
- // custom string representation of object
- public function __toString()
- {
- return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
- }
+ // custom string representation of object
+ public function __toString ()
+ {
+ return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
+ }
}
/**
@@ -120,19 +119,19 @@ class ApplicationWithCorruptDynaformException extends Exception
*/
class ApplicationAPP_DATAUnserializeException extends Exception
{
- // Redefine the exception so message isn't optional
- public function __construct($message, $code = 0)
- {
- // some code
- // make sure everything is assigned properly
- parent::__construct ($message, $code);
- }
+ // Redefine the exception so message isn't optional
+ public function __construct ($message, $code = 0)
+ {
+ // some code
+ // make sure everything is assigned properly
+ parent::__construct( $message, $code );
+ }
- // custom string representation of object
- public function __toString()
- {
- return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
- }
+ // custom string representation of object
+ public function __toString ()
+ {
+ return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
+ }
}
/**
@@ -146,2513 +145,2206 @@ class ApplicationAPP_DATAUnserializeException extends Exception
*/
class AppSolr
{
- private $_solrIsEnabled = false;
- private $_solrHost = "";
- private $_solrInstance = "";
- private $debug = false; //false
-
- public function __construct($SolrEnabled, $SolrHost, $SolrInstance)
- {
- // define solr availability
- $this->_solrIsEnabled = $SolrEnabled;
- $this->_solrHost = $SolrHost;
- $this->_solrInstance = $SolrInstance;
- }
-
- /**
- * Return if the Solr functionality is enabled.
- * @return boolean true:enabled functionality, false:disabled functionality
- */
- public function isSolrEnabled()
- {
- return $this->_solrIsEnabled;
- }
-
- /**
- * Gets the information of Grids using Solr server.
- *
- * Returns the list of records for the grid depending of the function
- * conditions
- * If doCount is true only the count of records is returned.
- *
- * @param string $userUid
- * current logged user.
- * @param int $start
- * the offset to return the group of records. Used for pagination.
- * @param int $limit
- * The number of records to return in the set.
- * @param string $action
- * the action: todo, participated, draft, unassigned
- * @param string $filter
- * filter the results posible values ('read', 'unread', 'started',
- * 'completed')
- * @param string $search
- * search string
- * @param string $process
- * PRO_UID to filter results by specified process.
- * @param string $user
- * USR_UID to filter results by specified user.
- * @param string $status
- * filter by an application Status : TO_DO, COMPLETED, DRAFT
- * @param string $type
- * default extjs
- * @param string $dateFrom
- * filter by DEL_DELEGATE_DATE, not used
- * @param string $dateTo
- * filter by DEL_DELEGATE_DATE, not used
- * @param string $callback
- * default stcCallback1001 not used
- * @param string $dir
- * sort direction ASC, DESC
- * @param string $sort
- * sort field
- * @param boolean $doCount
- * default=false, if true only the count of records is returned.
- * @return array return the list of cases
- */
- public function getAppGridData($userUid, $start = null, $limit = null, $action = null, $filter = null, $search = null, $process = null, $user = null, $status = null, $type = null, $dateFrom = null, $dateTo = null, $callback = null, $dir = null, $sort = 'APP_CACHE_VIEW.APP_NUMBER', $doCount = false)
- {
-
- $callback = isset ($callback) ? $callback : 'stcCallback1001';
- $dir = isset ($dir) ? $dir : 'DESC'; // direction of sort column
- // (ASC, DESC)
- $sort = isset ($sort) ? $sort : ''; // sort column (APP_NUMBER,
- // CASE_SUMMARY,
- // CASE_NOTES_COUNT, APP_TITLE,
- // APP_PRO_TITLE, APP_TAS_TITLE,
- // APP_DEL_PREVIOUS_USER,
- // DEL_TASK_DUE_DATE,
- // APP_UPDATE_DATE, DEL_PRIORITY)
- $start = isset ($start) ? $start : '0';
- $limit = isset ($limit) ? $limit : '25';
- $filter = isset ($filter) ? $filter : ''; // posible values ('read',
- // 'unread', 'started',
- // 'completed')
- $search = isset ($search) ? $search : ''; // search in fields, plain text
- $process = isset ($process) ? $process : ''; // filter by an specific
- // process
- // uid
- $user = isset ($user) ? $user : ''; // filter by an specific user uid
- $status = isset ($status) ? strtoupper ($status) : ''; // filter by an
- // specific
- // app_status
- $action = isset ($action) ? $action : 'todo'; // todo, paused
- $type = isset ($type) ? $type : 'extjs';
- $dateFrom = isset ($dateFrom) ? $dateFrom : ''; // filter by
- // DEL_DELEGATE_DATE
- $dateTo = isset ($dateTo) ? $dateTo : ''; // filter by DEL_DELEGATE_DATE
-
- $swErrorInSearchText = false;
- $solrQueryResult = null;
- $aPriorities = array('1'=>'VL', '2'=>'L', '3'=>'N', '4'=>'H', '5'=>'VH');
- $delegationIndexes = array();
-
- $result = array ();
- $result ['totalCount'] = 0;
- $result ['data'] = array ();
- $result ['success'] = false;
- $result ['message'] = "Error description.";
-
- G::LoadClass ('searchIndex');
-
- try {
- if($this->debug)
- {
- $this->initTimeAll = microtime (true);
- }
-
- // the array of data that must be returned with placeholders
- $columsToInclude = array (
- 'APP_CREATE_DATE',
- '',
- '',
- '',
- 'APP_NUMBER',
- '',
- 'APP_PRO_TITLE',
- 'APP_STATUS',
- '',
- '',
- 'APP_TITLE',
- 'APP_UID',
- 'DEL_LAST_UPDATE_DATE',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- 'DEL_MAX_PRIORITY',
- '',
- '',
- '',
- '',
- '',
- 'PRO_UID',
- '',
- ''
- );
- // create pagination data
- $solrSearchText = "";
- $sortableCols = array ();
- $sortCols = array ();
- $sortDir = array ();
- $numSortingCols = 0;
-
- // define sort conditions, default APP_NUMBER, desc
- // only one column is sorted
- $dir = strtolower ($dir);
-
- if (! empty ($sort)) {
- switch ($sort) {
- case 'APP_CACHE_VIEW.APP_NUMBER' :
- case 'APP_NUMBER' :
- $sortCols [0] = 4;
- $sortableCols [0] = 'true';
- $sortDir [0] = $dir;
- break;
- // multivalue field can't be ordered
- case 'APP_TITLE' :
- $sortCols [0] = 10;
- $sortableCols [0] = 'true';
- $sortDir [0] = $dir;
- break;
- case 'APP_PRO_TITLE' :
- $sortCols [0] = 6;
- $sortableCols [0] = 'true';
- $sortDir [0] = $dir;
- break;
- case 'APP_UPDATE_DATE' :
- $sortCols [0] = 12;
- $sortableCols [0] = 'true';
- $sortDir [0] = $dir;
- break;
- default :
- $sortCols [0] = 4;
- $sortableCols [0] = 'true';
- $sortDir [0] = 'desc';
- break;
- }
- $numSortingCols ++;
- }
-
- // get del_index field
- $delIndexDynaField = "";
- // process filter
- if ($process != '') {
- $solrSearchText .= "PRO_UID:" . $process . " AND ";
- }
- // status filter
- if ($status != '') {
- $solrSearchText .= "APP_STATUS:" . $status . " AND ";
- }
- // todo list, add condition
- if ($userUid != null && $action == 'todo') {
- if ($filter == 'read') {
- $solrSearchText .= "APP_ASSIGNED_USERS_READ:" . $userUid . " AND ";
- $delegationIndexes[] = "APP_ASSIGNED_USER_READ_DEL_INDEX_" . trim ($userUid) . '_txt';
- }
- elseif ($filter == 'unread') {
- $solrSearchText .= "APP_ASSIGNED_USERS_UNREAD:" . $userUid . " AND ";
- $delegationIndexes[] = "APP_ASSIGNED_USER_UNREAD_DEL_INDEX_" . trim ($userUid) . '_txt';
- }
- else {
- $solrSearchText .= "APP_ASSIGNED_USERS:" . $userUid . " AND ";
- $delegationIndexes[] = "APP_ASSIGNED_USER_DEL_INDEX_" . trim ($userUid) . '_txt';
- }
- }
- // participated, add condition
- if ($userUid != null && $action == 'sent') {
- if ($filter == 'started') {
- $solrSearchText .= "APP_PARTICIPATED_USERS_STARTED:" . $userUid . " AND ";
- $delegationIndexes[] = "APP_PARTICIPATED_USER_STARTED_DEL_INDEX_" . trim ($userUid) . '_txt';
- }
- elseif ($filter == 'completed') {
- $solrSearchText .= "APP_PARTICIPATED_USERS_COMPLETED:" . $userUid . " AND ";
- $delegationIndexes[] = "APP_PARTICIPATED_USER_COMPLETED_DEL_INDEX_" . trim ($userUid) . '_txt';
- }
- else {
- $solrSearchText .= "APP_PARTICIPATED_USERS:" . $userUid . " AND ";
- $delegationIndexes[] = "APP_PARTICIPATED_USER_DEL_INDEX_" . trim ($userUid) . '_txt';
- }
- }
- // draft, add condition
- if ($userUid != null && $action == 'draft') {
- $solrSearchText .= "APP_DRAFT_USER:" . $userUid . " AND ";
- // index is allways 1
- }
- // unassigned, add condition
- if ($userUid != null && $action == 'unassigned') {
- // get the list of groups to which belongs the user.
- $userGroups = $this->getUserGroups ($userUid);
+ private $_solrIsEnabled = false;
+ private $_solrHost = "";
+ private $_solrInstance = "";
+ private $debug = false; //false
- $solrSearchText .= "(APP_UNASSIGNED_USERS:" . $userUid;
- if (count ($userGroups) > 0) {
- $solrSearchText .= " OR ";
-
- foreach ($userGroups as $group) {
- $solrSearchText .= "APP_UNASSIGNED_GROUPS:" . $group ['GRP_UID'] . " OR ";
- }
-
- // remove last OR in condition
- if ($solrSearchText != '')
- $solrSearchText = substr_replace ($solrSearchText, "", - 4);
- }
- $solrSearchText .= ") AND ";
-
- $delegationIndexes[] = "APP_UNASSIGNED_USER_GROUP_DEL_INDEX_" . trim ($userUid) . '_txt';
- foreach ($userGroups as $group) {
- $delegationIndexes[] = "APP_UNASSIGNED_USER_GROUP_DEL_INDEX_" . trim ($group ['GRP_UID']) . '_txt';
- }
- }
-
- //search action
- if ($action == 'search' && $dateFrom != "" && $dateTo != "") {
- $fromDate = date ("Y-m-d", strtotime ($dateFrom));
- $toDate = date ("Y-m-d", strtotime ($dateTo));
-
- $searchDateOriginal = "DEL_LAST_UPDATE_DATE:[" . $fromDate . " TO " . $toDate . "]";
- //FechaRegistro:[2011-04-15 TO 2011-04-30]
-
- $searchDateFormatedSolr = $this->getSearchText ($searchDateOriginal);
-
- $solrSearchText .= "(" . $searchDateFormatedSolr . ") AND ";
-
- }
-
- // remove last AND in condition
- if ($solrSearchText != '')
- $solrSearchText = substr_replace ($solrSearchText, "", - 5);
-
- // add parenthesis to Solr search text
- if ($solrSearchText != "")
- $solrSearchText = "(" . $solrSearchText . ")";
-
- // create query string, add query conditions
- if ($search != '') {
- // format search string
- // return exception in case of invalid text
- $search = $this->getSearchText ($search);
-
- if ($solrSearchText != "" && $search != "")
- $solrSearchText .= " AND ";
- if ($search != "")
- $solrSearchText .= "(" . $search . ")";
- }
- // add del_index dynamic fields to list of resulting columns
- // the fields begin in the 30th column and more
- $columsToInclude = array_merge ($columsToInclude, $delegationIndexes);
-
- // if is a counter no records are returned
- if ($doCount) {
- $start = 0;
- $limit = 0;
- $numSortingCols = 0;
- $columsToInclude = array ();
- }
-
- $data = array (
- 'workspace' => $this->_solrInstance, // solr instance
- 'startAfter' => intval ($start),
- 'pageSize' => intval ($limit),
- 'searchText' => $solrSearchText,
- 'filterText' => '', // $filter, //ex:'field1:value1,field2:[value2.1
- // TO value2.2],field3:value3'
- 'numSortingCols' => $numSortingCols,
- 'sortableCols' => $sortableCols,
- 'sortCols' => $sortCols,
- 'sortDir' => $sortDir,
- 'includeCols' => $columsToInclude,
- 'resultFormat' => 'json'
- );
-
- $solrRequestData = Entity_SolrRequestData::createForRequestPagination ($data);
- // use search index to return list of cases
- $searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
- // execute query
- $solrQueryResult = $searchIndex->getDataTablePaginatedList ($solrRequestData);
-
- if($this->debug)
- {
- $this->afterSolrQueryTime = microtime (true);
- }
- //return inmediatelly
- if ($doCount) {
- $result ['totalCount'] = $solrQueryResult->iTotalDisplayRecords;
- $result ['data'] = array();
- $result ['success'] = true;
- $result ['result'] = true;
- $result ['message'] = "";
-
- return $result;
- }
- // complete return data, complete list of columns in grid
- $resultColumns = array (
- "APP_CREATE_DATE",
- "APP_CURRENT_USER",
- "APP_DEL_PREVIOUS_USER",
- "APP_FINISH_DATE",
- "APP_NUMBER",
- "APP_OVERDUE_PERCENTAGE",
- "APP_PRO_TITLE",
- "APP_STATUS",
- "APP_TAS_TITLE",
- "APP_THREAD_STATUS",
- "APP_TITLE",
- "APP_UID",
- "APP_UPDATE_DATE",
- "DEL_DELAYED",
- "DEL_DELAY_DURATION",
- "DEL_DELEGATE_DATE",
- "DEL_DURATION",
- "DEL_FINISHED",
- "DEL_FINISH_DATE",
- "DEL_INDEX",
- "DEL_INIT_DATE",
- "DEL_PRIORITY",
- "DEL_QUEUE_DURATION",
- "DEL_STARTED",
- "DEL_TASK_DUE_DATE",
- "DEL_THREAD_STATUS",
- "PREVIOUS_USR_UID",
- "PRO_UID",
- "TAS_UID",
- "USR_UID"
- );
-
- $rows = array ();
- // number of found records
- $result ['totalCount'] = $solrQueryResult->iTotalDisplayRecords;
- //get all the data from database
- $appUids = array();
- foreach ($solrQueryResult->aaData as $i => $data) {
- $appUids[] = $data [11];
- }
-
- $aaappsDBData = $this->getListApplicationDelegationData ($appUids);
-
- if($this->debug)
- {
- $this->afterDbQueryTime = microtime (true);
- }
- // complete the missing data to display it in the grid.
- $delIndexes = array(); //store all the delegation indexes
- foreach ($solrQueryResult->aaData as $i => $data) {
- //initialize array
- $delIndexes = array();
- // complete empty values
- $appUID = $data [11];
- //get all the delindexes
- for($i = 30 ; $i < count($data) ; $i++) {
- if (is_array ($data [$i])) {
- foreach($data [$i] as $delIndex){
- $delIndexes[] = $delIndex;
- }
- }
- }
- // verify if the delindex is an array
- // if is not check different types of repositories
- // the delegation index must always be defined.
- if (count($delIndexes) == 0) {
- // if is draft
- if ($action == 'draft') {
- $delIndexes [] = 1; // the first default index
- }
- elseif ($action == 'search') {
- // get all the indexes
+ public function __construct ($SolrEnabled, $SolrHost, $SolrInstance)
+ {
+ // define solr availability
+ $this->_solrIsEnabled = $SolrEnabled;
+ $this->_solrHost = $SolrHost;
+ $this->_solrInstance = $SolrInstance;
+ }
- //$delIndexes = $this->getApplicationDelegationsIndex ($appUID);
- $indexes = $this->aaSearchRecords ($aaappsDBData, array (
- 'APP_UID' => $appUID
- ));
-
- foreach ($indexes as $index) {
- $delIndexes[] = $aaappsDBData [$index]['DEL_INDEX'];
+ /**
+ * Return if the Solr functionality is enabled.
+ *
+ * @return boolean true:enabled functionality, false:disabled functionality
+ */
+ public function isSolrEnabled ()
+ {
+ return $this->_solrIsEnabled;
+ }
+
+ /**
+ * Gets the information of Grids using Solr server.
+ *
+ * Returns the list of records for the grid depending of the function
+ * conditions
+ * If doCount is true only the count of records is returned.
+ *
+ * @param string $userUid current logged user.
+ * @param int $start the offset to return the group of records. Used for pagination.
+ * @param int $limit The number of records to return in the set.
+ * @param string $action the action: todo, participated, draft, unassigned
+ * @param string $filter filter the results posible values ('read', 'unread', 'started',
+ * 'completed')
+ * @param string $search search string
+ * @param string $process PRO_UID to filter results by specified process.
+ * @param string $user USR_UID to filter results by specified user.
+ * @param string $status filter by an application Status : TO_DO, COMPLETED, DRAFT
+ * @param string $type default extjs
+ * @param string $dateFrom filter by DEL_DELEGATE_DATE, not used
+ * @param string $dateTo filter by DEL_DELEGATE_DATE, not used
+ * @param string $callback default stcCallback1001 not used
+ * @param string $dir sort direction ASC, DESC
+ * @param string $sort sort field
+ * @param boolean $doCount default=false, if true only the count of records is returned.
+ * @return array return the list of cases
+ */
+ public function getAppGridData ($userUid, $start = null, $limit = null, $action = null, $filter = null, $search = null, $process = null, $user = null, $status = null, $type = null, $dateFrom = null, $dateTo = null, $callback = null, $dir = null, $sort = 'APP_CACHE_VIEW.APP_NUMBER', $doCount = false)
+ {
+
+ $callback = isset( $callback ) ? $callback : 'stcCallback1001';
+ $dir = isset( $dir ) ? $dir : 'DESC'; // direction of sort column
+ // (ASC, DESC)
+ $sort = isset( $sort ) ? $sort : ''; // sort column (APP_NUMBER,
+ // CASE_SUMMARY,
+ // CASE_NOTES_COUNT, APP_TITLE,
+ // APP_PRO_TITLE, APP_TAS_TITLE,
+ // APP_DEL_PREVIOUS_USER,
+ // DEL_TASK_DUE_DATE,
+ // APP_UPDATE_DATE, DEL_PRIORITY)
+ $start = isset( $start ) ? $start : '0';
+ $limit = isset( $limit ) ? $limit : '25';
+ $filter = isset( $filter ) ? $filter : ''; // posible values ('read',
+ // 'unread', 'started',
+ // 'completed')
+ $search = isset( $search ) ? $search : ''; // search in fields, plain text
+ $process = isset( $process ) ? $process : ''; // filter by an specific
+ // process
+ // uid
+ $user = isset( $user ) ? $user : ''; // filter by an specific user uid
+ $status = isset( $status ) ? strtoupper( $status ) : ''; // filter by an
+ // specific
+ // app_status
+ $action = isset( $action ) ? $action : 'todo'; // todo, paused
+ $type = isset( $type ) ? $type : 'extjs';
+ $dateFrom = isset( $dateFrom ) ? $dateFrom : ''; // filter by
+ // DEL_DELEGATE_DATE
+ $dateTo = isset( $dateTo ) ? $dateTo : ''; // filter by DEL_DELEGATE_DATE
+
+
+ $swErrorInSearchText = false;
+ $solrQueryResult = null;
+ $aPriorities = array ('1' => 'VL','2' => 'L','3' => 'N','4' => 'H','5' => 'VH'
+ );
+ $delegationIndexes = array ();
+
+ $result = array ();
+ $result['totalCount'] = 0;
+ $result['data'] = array ();
+ $result['success'] = false;
+ $result['message'] = "Error description.";
+
+ G::LoadClass( 'searchIndex' );
+
+ try {
+ if ($this->debug) {
+ $this->initTimeAll = microtime( true );
}
- }
- else {
- //error an index must always be defined
- print "Delegation not defined\n";
- }
- /*
- elseif ($action == 'unassigned'){
- $delIndexes = $this->getApplicationDelegationsIndex ($appUID);
- }*/
- }
- //remove duplicated
- $delIndexes = array_unique($delIndexes);
- foreach ($delIndexes as $delIndex) {
- $aRow = array ();
- foreach ($resultColumns as $j => $columnName) {
- $aRow [$columnName] = $data [$j];
- }
- // convert date from solr format UTC to local time in MySQL format
- $solrdate = $data [0];
- $localDate = date ('Y-m-d H:i:s', strtotime ($solrdate));
- $aRow ['APP_CREATE_DATE'] = $localDate;
-
- $solrdate = $data [12];
- $localDate = date ('Y-m-d H:i:s', strtotime ($solrdate));
- $aRow ['APP_UPDATE_DATE'] = $localDate;
-
- // get delegation data from DB
- //filter data from db
- $indexes = $this->aaSearchRecords ($aaappsDBData, array (
- 'APP_UID' => $appUID,
- 'DEL_INDEX' => $delIndex
- ));
-
- foreach ($indexes as $index) {
- $row = $aaappsDBData [$index];
- }
-
- if(!isset($row))
- {
- $fh = fopen("SolrAppWhitoutDelIndex.txt", 'a') or die("can't open file to store Solr search time.");
- fwrite($fh, sprintf("Solr AppUid: %s DelIndex: %s not found.\r\n", $appUID, $delIndex));
- fclose($fh);
- continue;
- }
- //$row = $this->getAppDelegationData ($appUID, $delIndex);
-
- $aRow ['APP_FINISH_DATE'] = null;
- $aRow ['APP_CURRENT_USER'] = $row ['USR_NAME'] . " " . $row ['USR_LAST'];
- $aRow ['APP_DEL_PREVIOUS_USER'] = $row ['USR_PREV_NAME'] . " " . $row ['USR_PREV_LAST'];
- $aRow ['APP_OVERDUE_PERCENTAGE'] = $row ['APP_OVERDUE_PERCENTAGE'];
- $aRow ['APP_TAS_TITLE'] = $row ['APP_TAS_TITLE'];
- $aRow ['APP_THREAD_STATUS'] = $row ['APP_THREAD_STATUS'];
- $aRow ['DEL_DELAYED'] = $row ['DEL_DELAYED'];
- $aRow ['DEL_DELAY_DURATION'] = $row ['DEL_DELAY_DURATION'];
- $aRow ['DEL_DELEGATE_DATE'] = $row ['DEL_DELEGATE_DATE'];
- $aRow ['DEL_DURATION'] = $row ['DEL_DURATION'];
- $aRow ['DEL_FINISHED'] = (isset ($row ['DEL_FINISH_DATE']) && $row ['DEL_FINISH_DATE'] != '') ? 1 : 0;
- $aRow ['DEL_FINISH_DATE'] = $row ['DEL_FINISH_DATE'];
- $aRow ['DEL_INDEX'] = $row ['DEL_INDEX'];
- $aRow ['DEL_INIT_DATE'] = $row ['DEL_INIT_DATE'];
- $aRow ['DEL_QUEUE_DURATION'] = $row ['DEL_QUEUE_DURATION'];
- $aRow ['DEL_STARTED'] = (isset ($row ['DEL_INIT_DATE']) && $row ['DEL_INIT_DATE'] != '') ? 1 : 0;
- $aRow ['DEL_TASK_DUE_DATE'] = $row ['DEL_TASK_DUE_DATE'];
- $aRow ['DEL_THREAD_STATUS'] = $row ['DEL_THREAD_STATUS'];
- $aRow ['PREVIOUS_USR_UID'] = $row ['PREVIOUS_USR_UID'];
- $aRow ['TAS_UID'] = $row ['TAS_UID'];
- $aRow ['USR_UID'] = $userUid;
- $aRow ['DEL_PRIORITY'] = G::LoadTranslation("ID_PRIORITY_{$aPriorities[$aRow['DEL_PRIORITY']]}");
-
- $rows [] = $aRow;
- }
- }
- $result ['data'] = $rows;
- $result ['success'] = true;
- $result ['result'] = true;
- $result ['message'] = "";
-
- /*********************************************/
- if($this->debug)
- {
- $this->afterPrepareResultTime = microtime (true);
-
- $fh = fopen("SolrSearchTime.txt", 'a') or die("can't open file to store Solr search time.");
- //fwrite($fh, sprintf("Solr Query time: %s DB Query time: %s Prepare result time: %s \n", gmdate ('H:i:s:u', ($this->afterSolrQueryTime - $this->initTimeAll)), gmdate ('H:i:s:u', ($this->afterDbQueryTime - $this->afterSolrQueryTime)), gmdate ('H:i:s:u', ($this->afterPrepareResultTime - $this->afterDbQueryTime)) ));
- fwrite($fh, sprintf("Solr Query time: %s DB Query time: %s Prepare result time: %s Total:%s \r\n", ($this->afterSolrQueryTime - $this->initTimeAll), ($this->afterDbQueryTime - $this->afterSolrQueryTime), ($this->afterPrepareResultTime - $this->afterDbQueryTime), ($this->afterPrepareResultTime - $this->initTimeAll) ));
- fclose($fh);
- }
- /***************************************/
-
- return $result;
-
- } // end try
- catch ( InvalidIndexSearchTextException $ex ) {
- // return empty result with description of error
- $result = array ();
- $result ['totalCount'] = 0;
- $result ['data'] = array ();
- $result ['success'] = true;
- $result ['result'] = false;
- $result ['message'] = $ex->getMessage ();
- return $result;
- }
- }
-
- /**
- * Get the array of counters of cases
- *
- * @param string $userUid
- * the current logged user uid identifier
- */
- public function getCasesCount($userUid)
- {
- $casesCount = array ();
-
- // get number of records in todo list
- $data = $this->getAppGridData ($userUid, 0, 0, 'todo', null, null, null, null, null,
- null, null, null, null, null, null, true);
- $casesCount ['to_do'] = $data ['totalCount'];
- // get number of records in participated list
- $data = $this->getAppGridData ($userUid, 0, 0, 'sent', null, null, null, null, null,
- null, null, null, null, null, null, true);
- $casesCount ['sent'] = $data ['totalCount'];
- // get number of records in draft list
- $data = $this->getAppGridData ($userUid, 0, 0, 'draft', null, null, null, null, null,
- null, null, null, null, null, null, true);
- $casesCount ['draft'] = $data ['totalCount'];
- // get number of records in unassigned list
- $data = $this->getAppGridData ($userUid, 0, 0, 'unassigned', null, null, null, null,
- null, null, null, null, null, null, null, true);
- $casesCount ['selfservice'] = $data ['totalCount'];
-
- return $casesCount;
- }
-
- /**
- * Get the user groups
- * @param string $usrUID the user identifier
- * @return array of user groups
- */
- public function getUserGroups($usrUID)
- {
- $gu = new GroupUser ();
- $rows = $gu->getAllUserGroups ($usrUID);
- return $rows;
- }
-
- /**
- * Get the application delegation record from database
- *
- * @param string $aappUIDs
- * array of Application identifiers
- * @return array of arrays with delegation information.
- */
- public function getListApplicationDelegationData($aappUIDs)
- {
-
- $c = new Criteria ();
-
- $c->addSelectColumn (AppDelegationPeer::APP_UID);
- $c->addSelectColumn (AppDelegationPeer::DEL_INDEX);
-
- $c->addAsColumn ('USR_NAME', 'u.USR_FIRSTNAME');
- $c->addAsColumn ('USR_LAST', 'u.USR_LASTNAME');
-
- $c->addAsColumn ('USR_PREV_NAME', 'uprev.USR_FIRSTNAME');
- $c->addAsColumn ('USR_PREV_LAST', 'uprev.USR_LASTNAME');
- $c->addAsColumn ('PREVIOUS_USR_UID', 'uprev.USR_UID');
-
- $c->addAsColumn ('APP_TAS_TITLE', 'ctastitle.CON_VALUE');
- $c->addAsColumn ('APP_THREAD_STATUS', 'at.APP_THREAD_STATUS');
-
- $c->addSelectColumn (AppDelegationPeer::APP_OVERDUE_PERCENTAGE);
-
- $c->addSelectColumn (AppDelegationPeer::DEL_DELAYED);
- $c->addSelectColumn (AppDelegationPeer::DEL_DELAY_DURATION);
- $c->addSelectColumn (AppDelegationPeer::DEL_DELEGATE_DATE);
- $c->addSelectColumn (AppDelegationPeer::DEL_DURATION);
- $c->addSelectColumn (AppDelegationPeer::DEL_FINISH_DATE);
- $c->addSelectColumn (AppDelegationPeer::DEL_INIT_DATE);
- $c->addSelectColumn (AppDelegationPeer::DEL_QUEUE_DURATION);
- $c->addSelectColumn (AppDelegationPeer::DEL_TASK_DUE_DATE);
- $c->addSelectColumn (AppDelegationPeer::DEL_THREAD_STATUS);
- $c->addSelectColumn (AppDelegationPeer::TAS_UID);
-
- $c->addAlias ('u', 'USERS');
- $c->addAlias ('uprev', 'USERS');
- $c->addAlias ('adprev', 'APP_DELEGATION');
- $c->addAlias ('ctastitle', 'CONTENT');
- $c->addAlias ('at', 'APP_THREAD');
-
- $aConditions = array ();
- $aConditions [] = array (
- AppDelegationPeer::USR_UID,
- 'u.USR_UID'
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $aConditions = array ();
- $aConditions [] = array (
- AppDelegationPeer::APP_UID,
- 'adprev.APP_UID'
- );
- $aConditions [] = array (
- AppDelegationPeer::DEL_PREVIOUS,
- 'adprev.DEL_INDEX'
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $aConditions = array ();
- $aConditions [] = array (
- AppDelegationPeer::TAS_UID,
- 'ctastitle.CON_ID'
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $aConditions = array ();
- $aConditions [] = array (
- 'adprev.USR_UID',
- 'uprev.USR_UID'
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $aConditions = array ();
- $aConditions [] = array (
- AppDelegationPeer::APP_UID,
- 'at.APP_UID'
- );
- $aConditions [] = array (
- AppDelegationPeer::DEL_THREAD,
- 'at.APP_THREAD_INDEX'
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $c->add (AppDelegationPeer::APP_UID, $aappUIDs, Criteria::IN );
- //$c->add (AppDelegationPeer::DEL_INDEX, $delIndex);
-
- $c->add ('ctastitle.CON_CATEGORY', 'TAS_TITLE');
- $c->add ('ctastitle.CON_LANG', 'en');
-
- $rs = AppDelegationPeer::doSelectRS ($c);
- $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
- // echo $c->toString();
- $rs->next ();
- $row = $rs->getRow ();
-
- $appDataRows = array ();
- while (is_array ($row)) {
- $appDataRows [] = $row;
- $rs->next ();
- $row = $rs->getRow ();
- }
-
- return $appDataRows;
- }
-
- /**
- * Get the application delegation record from database
- *
- * @param string $appUID
- * Application identifier
- * @param string $delIndex
- * delegation index
- * @return array with delegation record.
- */
- public function getAppDelegationData($appUID, $delIndex)
- {
-
- $c = new Criteria ();
-
- $c->addSelectColumn (AppDelegationPeer::APP_UID);
- $c->addSelectColumn (AppDelegationPeer::DEL_INDEX);
-
- $c->addAsColumn ('USR_NAME', 'u.USR_FIRSTNAME');
- $c->addAsColumn ('USR_LAST', 'u.USR_LASTNAME');
-
- $c->addAsColumn ('USR_PREV_NAME', 'uprev.USR_FIRSTNAME');
- $c->addAsColumn ('USR_PREV_LAST', 'uprev.USR_LASTNAME');
- $c->addAsColumn ('PREVIOUS_USR_UID', 'uprev.USR_UID');
-
- $c->addAsColumn ('APP_TAS_TITLE', 'ctastitle.CON_VALUE');
- $c->addAsColumn ('APP_THREAD_STATUS', 'at.APP_THREAD_STATUS');
-
- $c->addSelectColumn (AppDelegationPeer::APP_OVERDUE_PERCENTAGE);
-
- $c->addSelectColumn (AppDelegationPeer::DEL_DELAYED);
- $c->addSelectColumn (AppDelegationPeer::DEL_DELAY_DURATION);
- $c->addSelectColumn (AppDelegationPeer::DEL_DELEGATE_DATE);
- $c->addSelectColumn (AppDelegationPeer::DEL_DURATION);
- $c->addSelectColumn (AppDelegationPeer::DEL_FINISH_DATE);
- $c->addSelectColumn (AppDelegationPeer::DEL_INIT_DATE);
- $c->addSelectColumn (AppDelegationPeer::DEL_QUEUE_DURATION);
- $c->addSelectColumn (AppDelegationPeer::DEL_TASK_DUE_DATE);
- $c->addSelectColumn (AppDelegationPeer::DEL_THREAD_STATUS);
- $c->addSelectColumn (AppDelegationPeer::TAS_UID);
-
- $c->addAlias ('u', 'USERS');
- $c->addAlias ('uprev', 'USERS');
- $c->addAlias ('adprev', 'APP_DELEGATION');
- $c->addAlias ('ctastitle', 'CONTENT');
- $c->addAlias ('at', 'APP_THREAD');
-
- $aConditions = array ();
- $aConditions [] = array (
- AppDelegationPeer::USR_UID,
- 'u.USR_UID'
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $aConditions = array ();
- $aConditions [] = array (
- AppDelegationPeer::APP_UID,
- 'adprev.APP_UID'
- );
- $aConditions [] = array (
- AppDelegationPeer::DEL_PREVIOUS,
- 'adprev.DEL_INDEX'
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $aConditions = array ();
- $aConditions [] = array (
- AppDelegationPeer::TAS_UID,
- 'ctastitle.CON_ID'
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $aConditions = array ();
- $aConditions [] = array (
- 'adprev.USR_UID',
- 'uprev.USR_UID'
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $aConditions = array ();
- $aConditions [] = array (
- AppDelegationPeer::APP_UID,
- 'at.APP_UID'
- );
- $aConditions [] = array (
- AppDelegationPeer::DEL_THREAD,
- 'at.APP_THREAD_INDEX'
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $c->add (AppDelegationPeer::APP_UID, $appUID);
- $c->add (AppDelegationPeer::DEL_INDEX, $delIndex);
-
- $c->add ('ctastitle.CON_CATEGORY', 'TAS_TITLE');
- $c->add ('ctastitle.CON_LANG', 'en');
-
- $rs = AppDelegationPeer::doSelectRS ($c);
- $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
- // echo $c->toString();
- $rs->next ();
- $row = $rs->getRow ();
-
- return $row;
- }
-
- /**
- * return the correct search text for solr.
- * if a field is included only search in this field.
- *
- * @param string $plainSearchText
- * @return string formated Solr search string.
- */
- public function getSearchText($plainSearchText)
- {
- $formattedSearchText = "";
- // if an error is found in string null is returned
- $includeToken = true;
-
- // prepare string to separate and join parentesis
- // " " => " "
- $count = 1;
- while ($count > 0) {
- $plainSearchText = preg_replace ('/\s\s+/', ' ', $plainSearchText, - 1, $count);
- }
- // "text0( text1" => "text0 (text1"; "text0 )text1" => "text0) text1";
- $plainSearchText = preg_replace ('/\s\[\s/', '[', $plainSearchText);
- $plainSearchText = preg_replace ('/\s\]\s/', '] ', $plainSearchText);
- $plainSearchText = preg_replace ('/\s"\s/', '" ', $plainSearchText);
-
- // print "format search string: " . $plainSearchText . "\n";
- // format
- // 1: plain text that is used to search in text field: concat field
- // 2: a field is specified [field_name]:["phrase search"]
- // [field_name]:["phrase search"] [field_name]:[word_search] word_search
- // "phrase search"
- // to scape a reserved character use a double value: "::", """"
- // ex: (APP_ASSIGNED_USERS:7091676694d9269da75c254003021135) AND
- // (contrato_t:76* AND Causal_t:1021 AND Materiales AND 143073)
- // ex: date search => APP_CREATE_DATE:[2012-03-12T00:00:00Z TO
- // 2012-04-12T00:00:00Z]
- // ex: phrase => TEXT:"This is a lazy dog"
-
- // search the first
-
- // cache the index fields
- G::LoadClass ('PMmemcached');
- $oMemcache = PMmemcached::getSingleton ($this->_solrInstance);
- $ListFieldsInfo = $oMemcache->get ('Solr_Index_Fields');
- if (! $ListFieldsInfo) {
- G::LoadClass ('searchIndex');
-
- $searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
- // execute query
- $ListFieldsInfo = $searchIndex->getIndexFields ($this->_solrInstance);
-
- //var_dump($ListFieldsInfo);
- // cache
- $oMemcache->set ('Solr_Index_Fields', $ListFieldsInfo);
-
- }
-
- $tok = strtok ($plainSearchText, " ");
-
- while ($tok !== false) {
- $fieldName = substr ($tok, 0, strpos ($tok, ":")); // strstr ( $tok,
- // ":",
- // true ); php 5.3
- $searchText = strstr ($tok, ":");
-
- // verify if there's a field definition
- if ($fieldName === false || $fieldName == "") {
- // it's not a field
- // the token is not a field
- // add it completelly
- $includeToken = true;
- // no field found
- $formattedSearchText .= $tok; // used to search in the general default
- // text field
- }
- else {
- // it's a field
- // verify if is complete
- if ($fieldName == "" || $searchText == ":") {
- $includeToken = false;
- throw new InvalidIndexSearchTextException ("Invalid search text, verify the syntax. Expected format = {variable_name}:{search_text}");
- }
-
- // field name found
- // search index field name
- $indexFieldName = "";
- if (array_key_exists ($fieldName, $ListFieldsInfo)) {
- $indexFieldName = $ListFieldsInfo [$fieldName];
- }
- else {
- // no field name found
- // don't include field search
- // return message about it
- $includeToken = false;
- throw new InvalidIndexSearchTextException ("Invalid search text, variable not found.");
- }
-
- // The token is part of a phrase, date or a word?
- if ($searchText [1] == "[" || $searchText [1] == "\"") { //
- // expecting
- // date
- // interval
- // we must
- // search
- // the end of
- // the
- // phrase
-
- // the phrase is complete?
- if ($searchText [1] == "[" && $searchText [strlen ($searchText) - 1] == "]") {
- // complete phrase ok, the date must be validated
- // throw new InvalidIndexSearchTextException("Invalid search text.
- // Expected date interval format =>
- // {variable_name}:[YYYY-MM-DDThh:mm:ssZ TO YYYY-MM-DDThh:mm:ssZ]");
- }
- elseif ($searchText [1] == "\"" && $searchText [strlen ($searchText) - 1] == "\"") {
- // the phrase is complete and is ok.
- }
- else {
- // search end of phrase
- $tok = strtok (" ");
- $found = false;
- while ($tok !== false) {
- if ((($searchText [1] == "[") && ($tok [strlen ($tok) - 1] == "]")) || (($searchText [1] == "\"") && ($tok [strlen ($tok) - 1] == "\""))) {
- // end of phrase found
- $found = true;
- $searchText .= " " . $tok;
- break;
- }
- else {
- // continue adding text
- $searchText .= " " . $tok;
- }
- $tok = strtok (" ");
- }
- if (! $found) {
- // error invalid text
- // Expected date interval format => {variable_name}:[YYYY-MM-DDThh:mm:ssZ TO YYYY-MM-DDThh:mm:ssZ]
- throw new InvalidIndexSearchTextException ("Invalid search text. The date or phase is not completed");
- }
- }
- }
-
- // validate phrase in case of date
- if (($searchText [1] == "[")) {
- // validate date range format
- // use regular expresion to validate it [yyyy-mm-dd TO yyyy-mm-dd]
- $reg = "/:\[(\d\d\d\d-\d\d-\d\d|\*)\sTO\s(\d\d\d\d-\d\d-\d\d|\*)\]/";
- // convert date to utc
- $matched = preg_match ($reg, $searchText, $matches);
- if ($matched == 1) {
- // the date interval is valid
- // convert to SOlr format
- $fromDateOriginal = $matches [1];
- $fromDate = $matches [1];
-
- $toDateOriginal = $matches [2];
- $toDate = $matches [2];
-
- if ($fromDateOriginal != '*') {
- // TODO complete date creation
- // list($year, $month, $day) = sscanf($fromDateOriginal,
- // '%04d/%02d/%02d');
- // $fromDateDatetime = new DateTime($fromDateOriginal);
- // $fromDateDatetime = date_create_from_format ( 'Y-m-d',
- // $fromDateOriginal );
- // $fromDateDatetime->getTimestamp ()
- $fromDate = gmdate ("Y-m-d\T00:00:00\Z", strtotime ($fromDateOriginal));
- }
- if ($toDateOriginal != '*') {
- // list($year, $month, $day) = sscanf($fromDateOriginal,
- // '%04d/%02d/%02d');
- // $toDateDatetime = new DateTime($toDateOriginal);
- // $toDateDatetime = date_create_from_format ( 'Y-m-d',
- // $toDateOriginal );
- $toDate = gmdate ("Y-m-d\T23:59:59.999\Z", strtotime ($toDateOriginal));
- }
- $searchText = ":[" . $fromDate . " TO " . $toDate . "]";
- }
- else {
- throw new InvalidIndexSearchTextException ("Invalid search text. Expected date interval format => {variable_name}:[YYYY-MM-DD TO YYYY-MM-DD]");
- }
- }
-
- $formattedSearchText .= $indexFieldName . $searchText;
- $includeToken = true;
- }
-
- if ($includeToken)
- $formattedSearchText .= " AND ";
-
- // next token
- $tok = strtok (" ");
- }
- // remove last AND
- $formattedSearchText = substr_replace ($formattedSearchText, "", - 5);
- return $formattedSearchText;
- }
-
- /**
- * Get all the application delegation records from database
- *
- * @param string $appUID
- * Application identifier
- * @return array delegation records
- */
- public function getApplicationDelegationsIndex($appUID)
- {
- $delIndexes = array ();
-
- $c = new Criteria ();
-
- $c->addSelectColumn (AppDelegationPeer::DEL_INDEX);
- $c->add (AppDelegationPeer::APP_UID, $appUID);
-
- $rs = AppDelegationPeer::doSelectRS ($c);
- $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
-
- $rs->next ();
- $row = $rs->getRow ();
-
- while (is_array ($row)) {
- $delIndexes [] = $row ['DEL_INDEX'];
- $rs->next ();
- $row = $rs->getRow ();
- }
-
- return $delIndexes;
-
- }
-
-
- /**
- * Update the information of the specified applications in Solr
- *
- * @param array $aaAPPUIDs
- * Array of arrays of App_UID that must be updated,
- * APP_UID is permitted also
- */
- public function updateApplicationSearchIndex($aaAPPUIDs)
- {
- if (empty ($aaAPPUIDs))
- return;
-
- if (! is_array ($aaAPPUIDs)) {
- // convert to array
- $APPUID = $aaAPPUIDs;
- $aaAPPUIDs = array ();
- $aaAPPUIDs [] = array (
- 'APP_UID' => $APPUID
- );
- }
- // check if index server is available
- if (! $this->isSolrEnabled ()) {
- // store update in table and return
- foreach ($aaAPPUIDs as $aAPPUID) {
- $this->applicationChangedUpdateSolrQueue ($aAPPUID ['APP_UID'], true);
- }
- return;
- }
-
- if($this->debug)
- {
- $this->beforeCreateSolrXMLDocTime = microtime (true);
- }
- // create XML document
- $xmlDoc = $this->createSolrXMLDocument ($aaAPPUIDs);
-
- if($this->debug)
- {
- $this->afterCreateSolrXMLDocTime = microtime (true);
- }
- // update document
- $data = array (
- 'workspace' => $this->_solrInstance,
- 'document' => $xmlDoc
- );
-
- $oSolrUpdateDocument = Entity_SolrUpdateDocument::createForRequest ($data);
-
- G::LoadClass ('searchIndex');
-
- $oSearchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
+ // the array of data that must be returned with placeholders
+ $columsToInclude = array ('APP_CREATE_DATE','','','','APP_NUMBER','','APP_PRO_TITLE','APP_STATUS','','','APP_TITLE','APP_UID','DEL_LAST_UPDATE_DATE','','','','','','','','','DEL_MAX_PRIORITY','','','','','','PRO_UID','',''
+ );
+ // create pagination data
+ $solrSearchText = "";
+ $sortableCols = array ();
+ $sortCols = array ();
+ $sortDir = array ();
+ $numSortingCols = 0;
- try{
- $oSearchIndex->updateIndexDocument ($oSolrUpdateDocument);
-
- if($this->debug)
- {
- $this->afterUpdateSolrXMLDocTime = microtime (true);
- }
- // commit changes
- $oSearchIndex->commitIndexChanges ($this->_solrInstance);
-
- }
- catch(Exception $ex) {
- //print "Excepcion indexing data: " . $ex->getMessage() . "\n"; die;
- $fh = fopen("./SolrIndexErrors.txt", 'a') or die("can't open file to store Solr index errors.");
- fwrite($fh, $ex->getMessage());
- fclose($fh);
- }
- if($this->debug)
- {
- $this->afterCommitSolrDocTime = microtime (true);
-
- $fh = fopen("SolrIndexTime.txt", 'a') or die("can't open file to store Solr index time.");
- //fwrite($fh, sprintf("Solr Query time: %s DB Query time: %s Prepare result time: %s \n", gmdate ('H:i:s:u', ($this->afterSolrQueryTime - $this->initTimeAll)), gmdate ('H:i:s:u', ($this->afterDbQueryTime - $this->afterSolrQueryTime)), gmdate ('H:i:s:u', ($this->afterPrepareResultTime - $this->afterDbQueryTime)) ));
- fwrite($fh, sprintf("Solr Create XML Document time: %s Update Solr Document time: %s Commit Solr Changes time: %s Total:%s \r\n", ($this->afterCreateSolrXMLDocTime - $this->beforeCreateSolrXMLDocTime), ($this->afterUpdateSolrXMLDocTime - $this->afterCreateSolrXMLDocTime), ($this->afterCommitSolrDocTime - $this->afterUpdateSolrXMLDocTime), ($this->afterCommitSolrDocTime - $this->beforeCreateSolrXMLDocTime) ));
- fclose($fh);
- }
- }
-
- /**
- * Delete the specified application record from Solr
- *
- * @param string $appUID
- * Application identifier
- */
- public function deleteApplicationSearchIndex($appUID)
- {
- if (empty ($appUID))
- return;
-
- // check if index server is available
- if (! $this->_solrIsEnabled) {
- // store update in table and return
- $this->applicationChangedUpdateSolrQueue ($appUID ['APP_UID'], 2); // delete
- return;
- }
-
- $idQuery = "APP_UID:" . $appUID;
-
- G::LoadClass ('searchIndex');
-
- $oSearchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
-
- $oSearchIndex->deleteDocumentFromIndex ($this->_solrInstance, $idQuery);
-
- // commit changes
- $oSearchIndex->commitIndexChanges ($this->_solrInstance);
- }
-
- /**
- * Create XML data in Solr format of the specified applications
- * this function uses the buildSearchIndexDocumentPMOS2 function to create
- * each record
- *
- * @param array $aaAPPUIDs
- * array of arrays of application identifiers
- * @return string The resulting XML document in Solr format
- */
- public function createSolrXMLDocument($aaAPPUIDs)
- {
- if($this->debug)
- {
- $this->getApplicationDataDBTime = 0;
- $this->getBuilXMLDocTime = 0;
- }
- // search data from DB
- $xmlDoc = "\n";
- $xmlDoc .= "\n";
-
- //get all application data from DB of all applications and delegations
- $aAPPUIDs = array();
- foreach($aaAPPUIDs as $aAPPUID) {
- $aAPPUIDs[] =$aAPPUID ['APP_UID'];
- }
- if($this->debug)
- {
- $this->beforeGetApplicationDataDBTime = microtime (true);
- }
- $aaAllAppDelData = $this->getListApplicationUpdateDelegationData($aAPPUIDs);
- if($this->debug)
- {
- $this->afterGetApplicationDataDBTime = microtime (true);
-
- $this->getApplicationDataDBTime = $this->afterGetApplicationDataDBTime - $this->beforeGetApplicationDataDBTime;
- }
- foreach ($aaAPPUIDs as $aAPPUID) {
- try {
-
- if($this->debug)
- {
- $this->beforePrepareApplicationDataDBTime = microtime (true);
- }
- //filter data, include all the rows of the application
- // get delegation data from DB
- $aaAppData = array();
- //filter data from db
- $indexes = $this->aaSearchRecords ($aaAllAppDelData, array (
- 'APP_UID' => $aAPPUID ['APP_UID']
- ));
-
- foreach ($indexes as $index) {
- $aaAppData[] = $aaAllAppDelData [$index];
- }
-
- $result = $this->getApplicationIndexData ($aAPPUID ['APP_UID'], $aaAppData);
-
- if($this->debug)
- {
- $this->afterPrepareApplicationDataDBTime = microtime (true);
-
- $this->getPreparedApplicationDataDBTime = $this->afterPrepareApplicationDataDBTime - $this->beforePrepareApplicationDataDBTime;
- }
-
- }
- catch ( ApplicationWithoutDelegationRecordsException $ex ) {
- // exception trying to get application information
- // skip and continue with the next application
- $fh = fopen("./SolrIndexErrors.txt", 'a') or die("can't open file to store Solr index errors.");
- fwrite($fh, $ex->getMessage());
- fclose($fh);
- continue;
- }
- catch( ApplicationWithCorruptDynaformException $ex) {
- $fh = fopen("./SolrIndexErrors.txt", 'a') or die("can't open file to store Solr index errors.");
- fwrite($fh, $ex->getMessage());
- fclose($fh);
- continue;
- }
- catch (Exception $ex) {
- $fh = fopen("./SolrIndexErrors.txt", 'a') or die("can't open file to store Solr index errors.");
- fwrite($fh, "getApplicationIndexData " . $aAPPUID . ":" . $ex->getMessage() . "\n");
- fclose($fh);
- continue;
- }
-
- $documentInformation = $result [0];
- $dynaformFieldTypes = $result [1];
- $lastUpdateDate = $result [2];
- $maxPriority = $result [3];
- $assignedUsers = $result [4];
- $assignedUsersRead = $result [5];
- $assignedUsersUnread = $result [6];
- $draftUser = $result [7];
- $participatedUsers = $result [8];
- $participatedUsersStartedByUser = $result [9];
- $participatedUsersCompletedByUser = $result [10];
- $unassignedUsers = $result [11];
- $unassignedGroups = $result [12];
+ // define sort conditions, default APP_NUMBER, desc
+ // only one column is sorted
+ $dir = strtolower( $dir );
- try {
-
- // create document
- $xmlDoc .= $this->buildSearchIndexDocumentPMOS2 ($documentInformation, $dynaformFieldTypes,
- $lastUpdateDate, $maxPriority, $assignedUsers, $assignedUsersRead, $assignedUsersUnread,
- $draftUser, $participatedUsers, $participatedUsersStartedByUser, $participatedUsersCompletedByUser,
- $unassignedUsers, $unassignedGroups);
-
- if($this->debug)
- {
- $this->afterBuilXMLDocTime = microtime (true);
-
- $this->getBuilXMLDocTime += $this->afterBuilXMLDocTime - $this->afterGetApplicationDataDBTime;
- }
- }
- catch ( ApplicationAPP_DATAUnserializeException $ex ) {
- // exception trying to get application information
- $fh = fopen("./SolrIndexErrors.txt", 'a') or die("can't open file to store Solr index errors.");
- fwrite($fh, $ex->getMessage());
- fclose($fh);
- // skip and continue with the next application
- continue;
- }
- catch (Exception $ex) {
- $fh = fopen("./SolrIndexErrors.txt", 'a') or die("can't open file to store Solr index errors.");
- fwrite($fh, "buildSearchIndexDocumentPMOS2 " . $aAPPUID . ":" . $ex->getMessage() . "\n");
- fclose($fh);
- continue;
- }
-
- }
-
- $xmlDoc .= "\n";
-
- if($this->debug)
- {
- $fh = fopen("SolrIndexTime.txt", 'a') or die("can't open file to store Solr index time.");
- fwrite($fh, sprintf("Get Data DB time: %s Prepare DB data Time: %s Create XML file time: %s \r\n", $this->getApplicationDataDBTime, $this->getPreparedApplicationDataDBTime, $this->getBuilXMLDocTime ));
- fclose($fh);
- }
-
- return $xmlDoc;
- }
-
- /**
- * build Solr index document xml for an application
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @param
- * [in] array $documentData array of data for the xml document of
- * application
- * @param
- * [in] array $dynaformFieldTypes array of dynaform field types, used
- * to store the info of APP_DATA with types
- * @param
- * [in] array $appTitles array of array of application titles in all
- * languages
- * @param
- * [in] array $proTitles array of array of process titles in all
- * languages
- * @param
- * [in] array $assignedUsers array of array of uids of assigned users
- * to Application UIDs
- * @param
- * [in] array $draftUsers array of array of uids of draft users to
- * Application UIDs
- * @param
- * [in] array $participatedUsers array of array of participated users
- * UIDs in application
- * @param
- * [in] array $unassignedUsers array of unassigned users UIDs
- * @param
- * [in] array $unassignedGroups array of unassigned groups UIDs
- * @param
- * [out] xml xml document
- *
- * $xmlDoc .= buildSearchIndexDocumentPMOS2($documentInformation,
- * $dynaformFieldTypes,
- * $lastUpdateDate, $maxPriority,
- * $assignedUsers, $assignedUsersRead, $assignedUsersUnread,
- * $draftUser,
- * $participatedUsers, $participatedUsersStartedByUser,
- * $participatedUsersCompletedByUser,
- * $unassignedUsers, $unassignedGroups);*
- */
- public function buildSearchIndexDocumentPMOS2($documentData, $dynaformFieldTypes, $lastUpdateDate,
- $maxPriority, $assignedUsers, $assignedUsersRead, $assignedUsersUnread, $draftUser,
- $participatedUsers, $participatedUsersStartedByUser, $participatedUsersCompletedByUser,
- $unassignedUsers, $unassignedGroups)
- {
- // build xml document
-
- $writer = new XMLWriter ();
- $writer->openMemory ();
- $writer->setIndent (4);
-
- $writer->startElement ("doc");
-
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_UID');
- $writer->text ($documentData ['APP_UID']);
- $writer->endElement ();
-
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_NUMBER');
- $writer->text ($documentData ['APP_NUMBER']);
- $writer->endElement ();
-
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_STATUS');
- $writer->text ($documentData ['APP_STATUS']);
- $writer->endElement ();
-
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'PRO_UID');
- $writer->text ($documentData ['PRO_UID']);
- $writer->endElement ();
-
- if (! empty ($documentData ['APP_TITLE'])) {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_TITLE');
- $writer->text ($documentData ['APP_TITLE']);
- $writer->endElement ();
- }
- else {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_TITLE');
- $writer->text ("");
- $writer->endElement ();
- }
-
- if (! empty ($documentData ['PRO_TITLE'])) {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_PRO_TITLE');
- $writer->text ($documentData ['PRO_TITLE']);
- $writer->endElement ();
-
- }
- else {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_PRO_TITLE');
- $writer->text ("");
- $writer->endElement ();
- }
-
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_CREATE_DATE');
- // convert date to UTC with gmdate
- $writer->text (gmdate ("Y-m-d\TH:i:s\Z", strtotime ($documentData ['APP_CREATE_DATE'])));
- $writer->endElement ();
-
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'DEL_LAST_UPDATE_DATE');
- // convert date to UTC with gmdate
- $writer->text (gmdate ("Y-m-d\TH:i:s\Z", strtotime ($lastUpdateDate)));
- $writer->endElement ();
-
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'DEL_MAX_PRIORITY');
- $writer->text ($maxPriority);
- $writer->endElement ();
-
- if (is_array ($assignedUsers) && ! empty ($assignedUsers)) {
- foreach ($assignedUsers as $userUID) {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_ASSIGNED_USERS');
- $writer->text ($userUID ['USR_UID']);
- $writer->endElement ();
-
- // add dynamic field for del_index information
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_ASSIGNED_USER_DEL_INDEX_' . trim ($userUID ['USR_UID']) . '_txt');
- $writer->text ($userUID ['DEL_INDEX']);
- $writer->endElement ();
-
- }
- }
-
- if (is_array ($assignedUsersRead) && ! empty ($assignedUsersRead)) {
- foreach ($assignedUsersRead as $userUID) {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_ASSIGNED_USERS_READ');
- $writer->text ($userUID ['USR_UID']);
- $writer->endElement ();
-
- // add dynamic field for del_index information
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_ASSIGNED_USER_READ_DEL_INDEX_' . trim ($userUID ['USR_UID']) . '_txt');
- $writer->text ($userUID ['DEL_INDEX']);
- $writer->endElement ();
- }
- }
-
- if (is_array ($assignedUsersUnread) && ! empty ($assignedUsersUnread)) {
- foreach ($assignedUsersUnread as $userUID) {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_ASSIGNED_USERS_UNREAD');
- $writer->text ($userUID ['USR_UID']);
- $writer->endElement ();
-
- // add dynamic field for del_index information
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_ASSIGNED_USER_UNREAD_DEL_INDEX_' . trim ($userUID ['USR_UID']) . '_txt');
- $writer->text ($userUID ['DEL_INDEX']);
- $writer->endElement ();
- }
- }
-
- if (! empty ($draftUser)) {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_DRAFT_USER');
- $writer->text ($draftUser ['USR_UID']);
- $writer->endElement ();
- }
-
- if (is_array ($participatedUsers) && ! empty ($participatedUsers)) {
- foreach ($participatedUsers as $userUID) {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_PARTICIPATED_USERS');
- $writer->text ($userUID ['USR_UID']);
- $writer->endElement ();
-
- // add dynamic field for del_index information
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_PARTICIPATED_USER_DEL_INDEX_' . trim ($userUID ['USR_UID']) . '_txt');
- $writer->text ($userUID ['DEL_INDEX']);
- $writer->endElement ();
- }
- }
-
- if (is_array ($participatedUsersStartedByUser) && ! empty ($participatedUsersStartedByUser)) {
- foreach ($participatedUsersStartedByUser as $userUID) {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_PARTICIPATED_USERS_STARTED');
- $writer->text ($userUID ['USR_UID']);
- $writer->endElement ();
-
- // add dynamic field for del_index information
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_PARTICIPATED_USER_STARTED_DEL_INDEX_' . trim ($userUID ['USR_UID']) . '_txt');
- $writer->text ($userUID ['DEL_INDEX']);
- $writer->endElement ();
- }
- }
-
- if (is_array ($participatedUsersCompletedByUser) && ! empty ($participatedUsersCompletedByUser)) {
- foreach ($participatedUsersCompletedByUser as $userUID) {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_PARTICIPATED_USERS_COMPLETED');
- $writer->text ($userUID ['USR_UID']);
- $writer->endElement ();
-
- // add dynamic field for del_index information
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_PARTICIPATED_USER_COMPLETED_DEL_INDEX_' . trim ($userUID ['USR_UID']) . '_txt');
- $writer->text ($userUID ['DEL_INDEX']);
- $writer->endElement ();
- }
- }
+ if (! empty( $sort )) {
+ switch ($sort) {
+ case 'APP_CACHE_VIEW.APP_NUMBER':
+ case 'APP_NUMBER':
+ $sortCols[0] = 4;
+ $sortableCols[0] = 'true';
+ $sortDir[0] = $dir;
+ break;
+ // multivalue field can't be ordered
+ case 'APP_TITLE':
+ $sortCols[0] = 10;
+ $sortableCols[0] = 'true';
+ $sortDir[0] = $dir;
+ break;
+ case 'APP_PRO_TITLE':
+ $sortCols[0] = 6;
+ $sortableCols[0] = 'true';
+ $sortDir[0] = $dir;
+ break;
+ case 'APP_UPDATE_DATE':
+ $sortCols[0] = 12;
+ $sortableCols[0] = 'true';
+ $sortDir[0] = $dir;
+ break;
+ default:
+ $sortCols[0] = 4;
+ $sortableCols[0] = 'true';
+ $sortDir[0] = 'desc';
+ break;
+ }
+ $numSortingCols ++;
+ }
- if (is_array ($unassignedUsers) && ! empty ($unassignedUsers)) {
- foreach ($unassignedUsers as $userUID) {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_UNASSIGNED_USERS');
- $writer->text ($userUID ['USR_UID']);
- $writer->endElement ();
-
- // add dynamic field for del_index information
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_UNASSIGNED_USER_GROUP_DEL_INDEX_' . trim ($userUID ['USR_UID']) . '_txt');
- $writer->text ($userUID ['DEL_INDEX']);
- $writer->endElement ();
- }
- }
-
- if (is_array ($unassignedGroups) && ! empty ($unassignedGroups)) {
- foreach ($unassignedGroups as $groupUID) {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_UNASSIGNED_GROUPS');
- $writer->text ($groupUID ['USR_UID']);
- $writer->endElement ();
-
- // add dynamic field for del_index information
- $writer->startElement ("field");
- $writer->writeAttribute ('name', 'APP_UNASSIGNED_USER_GROUP_DEL_INDEX_' . trim ($groupUID ['USR_UID']) . '_txt');
- $writer->text ($groupUID ['DEL_INDEX']);
- $writer->endElement ();
- }
- }
+ // get del_index field
+ $delIndexDynaField = "";
+ // process filter
+ if ($process != '') {
+ $solrSearchText .= "PRO_UID:" . $process . " AND ";
+ }
+ // status filter
+ if ($status != '') {
+ $solrSearchText .= "APP_STATUS:" . $status . " AND ";
+ }
+ // todo list, add condition
+ if ($userUid != null && $action == 'todo') {
+ if ($filter == 'read') {
+ $solrSearchText .= "APP_ASSIGNED_USERS_READ:" . $userUid . " AND ";
+ $delegationIndexes[] = "APP_ASSIGNED_USER_READ_DEL_INDEX_" . trim( $userUid ) . '_txt';
+ } elseif ($filter == 'unread') {
+ $solrSearchText .= "APP_ASSIGNED_USERS_UNREAD:" . $userUid . " AND ";
+ $delegationIndexes[] = "APP_ASSIGNED_USER_UNREAD_DEL_INDEX_" . trim( $userUid ) . '_txt';
+ } else {
+ $solrSearchText .= "APP_ASSIGNED_USERS:" . $userUid . " AND ";
+ $delegationIndexes[] = "APP_ASSIGNED_USER_DEL_INDEX_" . trim( $userUid ) . '_txt';
+ }
+ }
+ // participated, add condition
+ if ($userUid != null && $action == 'sent') {
+ if ($filter == 'started') {
+ $solrSearchText .= "APP_PARTICIPATED_USERS_STARTED:" . $userUid . " AND ";
+ $delegationIndexes[] = "APP_PARTICIPATED_USER_STARTED_DEL_INDEX_" . trim( $userUid ) . '_txt';
+ } elseif ($filter == 'completed') {
+ $solrSearchText .= "APP_PARTICIPATED_USERS_COMPLETED:" . $userUid . " AND ";
+ $delegationIndexes[] = "APP_PARTICIPATED_USER_COMPLETED_DEL_INDEX_" . trim( $userUid ) . '_txt';
+ } else {
+ $solrSearchText .= "APP_PARTICIPATED_USERS:" . $userUid . " AND ";
+ $delegationIndexes[] = "APP_PARTICIPATED_USER_DEL_INDEX_" . trim( $userUid ) . '_txt';
+ }
+ }
+ // draft, add condition
+ if ($userUid != null && $action == 'draft') {
+ $solrSearchText .= "APP_DRAFT_USER:" . $userUid . " AND ";
+ // index is allways 1
+ }
+ // unassigned, add condition
+ if ($userUid != null && $action == 'unassigned') {
+ // get the list of groups to which belongs the user.
+ $userGroups = $this->getUserGroups( $userUid );
- // get the serialized fields
- if (! empty ($documentData ['APP_DATA']) && $documentData ['APP_DATA'] != "N;" ) {
-
- $UnSerializedCaseData = unserialize ($documentData ['APP_DATA']);
-
- if ($UnSerializedCaseData === false) {
- $UnSerializedCaseData = preg_replace ('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $documentData ['APP_DATA']); // utf8_encode
- $UnSerializedCaseData = unserialize ($UnSerializedCaseData);
- }
-
- if (! $UnSerializedCaseData) {
- // error unserializing
- throw new ApplicationAPP_DATAUnserializeException ("Could not unserialize APP_DATA of APP_UID: " . $documentData ['APP_UID'] . "\n");
- }
- else {
- foreach ($UnSerializedCaseData as $k => $value) {
- if (! is_array ($value) && ! is_object ($value) && $value != '' && $k != 'SYS_LANG' && $k != 'SYS_SKIN' && $k != 'SYS_SYS') {
- // search the field type in array of dynaform fields
- if (! empty ($dynaformFieldTypes) && array_key_exists (trim ($k), $dynaformFieldTypes)) {
- $type = $dynaformFieldTypes [trim ($k)];
- $typeSufix = '_t';
- switch ($type) {
- case 'text' :
- $typeSufix = '_t';
- break;
- case 'Int' :
- if(intval ($value) > 2147483647) {
- $typeSufix = '_tl'; //for long values
- $value = intval ($value);
- }
- else {
- $typeSufix = '_ti';
- $value = intval ($value);
- }
- break;
- case 'Real' :
- $typeSufix = '_td';
- $value = floatval ($value);
- break;
- case 'date' :
- $newdate = false;
- $withHour = true;
- // try to convert string to date
- // TODO convert to php 5.2 format
- /*
- * $newdate = date_create_from_format ( 'Y-m-d H:i:s', $value
- * ); if (! $newdate) { $newdate = date_create_from_format (
- * 'Y-m-d', $value ); $withHour = false; } if (! $newdate) {
- * $newdate = date_create_from_format ( 'd/m/Y', $value );
- * $withHour = false; } if (! $newdate) { $newdate =
- * date_create_from_format ( 'j/m/Y', $value ); $withHour =
- * false; }
- */
- $newdate = strtotime ($value);
- if (! $newdate) {
- $typeSufix = '*'; // not store field
- }
- else {
- $typeSufix = '_tdt';
+ $solrSearchText .= "(APP_UNASSIGNED_USERS:" . $userUid;
+ if (count( $userGroups ) > 0) {
+ $solrSearchText .= " OR ";
+
+ foreach ($userGroups as $group) {
+ $solrSearchText .= "APP_UNASSIGNED_GROUPS:" . $group['GRP_UID'] . " OR ";
+ }
+
+ // remove last OR in condition
+ if ($solrSearchText != '') {
+ $solrSearchText = substr_replace( $solrSearchText, "", - 4 );
+ }
+ }
+ $solrSearchText .= ") AND ";
+
+ $delegationIndexes[] = "APP_UNASSIGNED_USER_GROUP_DEL_INDEX_" . trim( $userUid ) . '_txt';
+ foreach ($userGroups as $group) {
+ $delegationIndexes[] = "APP_UNASSIGNED_USER_GROUP_DEL_INDEX_" . trim( $group['GRP_UID'] ) . '_txt';
+ }
+ }
+
+ //search action
+ if ($action == 'search' && $dateFrom != "" && $dateTo != "") {
+ $fromDate = date( "Y-m-d", strtotime( $dateFrom ) );
+ $toDate = date( "Y-m-d", strtotime( $dateTo ) );
+
+ $searchDateOriginal = "DEL_LAST_UPDATE_DATE:[" . $fromDate . " TO " . $toDate . "]";
+ //FechaRegistro:[2011-04-15 TO 2011-04-30]
+
+
+ $searchDateFormatedSolr = $this->getSearchText( $searchDateOriginal );
+
+ $solrSearchText .= "(" . $searchDateFormatedSolr . ") AND ";
+
+ }
+
+ // remove last AND in condition
+ if ($solrSearchText != '') {
+ $solrSearchText = substr_replace( $solrSearchText, "", - 5 );
+ }
+
+ // add parenthesis to Solr search text
+ if ($solrSearchText != "") {
+ $solrSearchText = "(" . $solrSearchText . ")";
+ }
+ // create query string, add query conditions
+ if ($search != '') {
+ // format search string
+ // return exception in case of invalid text
+ $search = $this->getSearchText( $search );
+
+ if ($solrSearchText != "" && $search != "") {
+ $solrSearchText .= " AND ";
+ }
+ if ($search != "") {
+ $solrSearchText .= "(" . $search . ")";
+ }
+ }
+ // add del_index dynamic fields to list of resulting columns
+ // the fields begin in the 30th column and more
+ $columsToInclude = array_merge( $columsToInclude, $delegationIndexes );
+
+ // if is a counter no records are returned
+ if ($doCount) {
+ $start = 0;
+ $limit = 0;
+ $numSortingCols = 0;
+ $columsToInclude = array ();
+ }
+
+ $data = array ('workspace' => $this->_solrInstance, // solr instance
+ 'startAfter' => intval( $start ),'pageSize' => intval( $limit ),'searchText' => $solrSearchText,'filterText' => '', // $filter, //ex:'field1:value1,field2:[value2.1
+ // TO value2.2],field3:value3'
+ 'numSortingCols' => $numSortingCols,'sortableCols' => $sortableCols,'sortCols' => $sortCols,'sortDir' => $sortDir,'includeCols' => $columsToInclude,'resultFormat' => 'json'
+ );
+
+ $solrRequestData = Entity_SolrRequestData::createForRequestPagination( $data );
+ // use search index to return list of cases
+ $searchIndex = new BpmnEngine_Services_SearchIndex( $this->_solrIsEnabled, $this->_solrHost );
+ // execute query
+ $solrQueryResult = $searchIndex->getDataTablePaginatedList( $solrRequestData );
+
+ if ($this->debug) {
+ $this->afterSolrQueryTime = microtime( true );
+ }
+ //return inmediatelly
+ if ($doCount) {
+ $result['totalCount'] = $solrQueryResult->iTotalDisplayRecords;
+ $result['data'] = array ();
+ $result['success'] = true;
+ $result['result'] = true;
+ $result['message'] = "";
+
+ return $result;
+ }
+ // complete return data, complete list of columns in grid
+ $resultColumns = array ("APP_CREATE_DATE","APP_CURRENT_USER","APP_DEL_PREVIOUS_USER","APP_FINISH_DATE","APP_NUMBER","APP_OVERDUE_PERCENTAGE","APP_PRO_TITLE","APP_STATUS","APP_TAS_TITLE","APP_THREAD_STATUS","APP_TITLE","APP_UID","APP_UPDATE_DATE","DEL_DELAYED","DEL_DELAY_DURATION","DEL_DELEGATE_DATE","DEL_DURATION","DEL_FINISHED","DEL_FINISH_DATE","DEL_INDEX","DEL_INIT_DATE","DEL_PRIORITY","DEL_QUEUE_DURATION","DEL_STARTED","DEL_TASK_DUE_DATE","DEL_THREAD_STATUS","PREVIOUS_USR_UID","PRO_UID","TAS_UID","USR_UID"
+ );
+
+ $rows = array ();
+ // number of found records
+ $result['totalCount'] = $solrQueryResult->iTotalDisplayRecords;
+
+ //get all the data from database
+ $appUids = array ();
+ foreach ($solrQueryResult->aaData as $i => $data) {
+ $appUids[] = $data[11];
+ }
+
+ $aaappsDBData = $this->getListApplicationDelegationData( $appUids );
+
+ if ($this->debug) {
+ $this->afterDbQueryTime = microtime( true );
+ }
+ // complete the missing data to display it in the grid.
+ $delIndexes = array (); //store all the delegation indexes
+ foreach ($solrQueryResult->aaData as $i => $data) {
+ //initialize array
+ $delIndexes = array ();
+ // complete empty values
+ $appUID = $data[11];
+ //get all the delindexes
+ for ($i = 30; $i < count( $data ); $i ++) {
+ if (is_array( $data[$i] )) {
+ foreach ($data[$i] as $delIndex) {
+ $delIndexes[] = $delIndex;
+ }
+ }
+ }
+ // verify if the delindex is an array
+ // if is not check different types of repositories
+ // the delegation index must always be defined.
+ if (count( $delIndexes ) == 0) {
+ // if is draft
+ if ($action == 'draft') {
+ $delIndexes[] = 1; // the first default index
+ } elseif ($action == 'search') {
+ // get all the indexes
+
+
+ //$delIndexes = $this->getApplicationDelegationsIndex ($appUID);
+ $indexes = $this->aaSearchRecords( $aaappsDBData, array ('APP_UID' => $appUID
+ ) );
+
+ foreach ($indexes as $index) {
+ $delIndexes[] = $aaappsDBData[$index]['DEL_INDEX'];
+ }
+
+ } else {
+ //error an index must always be defined
+ print "Delegation not defined\n";
+ }
/*
- * if ($withHour) //$value = gmdate ( "Y-m-d\TH:i:s\Z",
- * $newdate->getTimestamp () ); $value = gmdate (
- * "Y-m-d\TH:i:s\Z", $newdate ); else { $value = gmdate (
- * "Y-m-d\T00:00:00\Z", $newdate ); }
+ * elseif ($action == 'unassigned'){ $delIndexes = $this->getApplicationDelegationsIndex ($appUID); }
*/
- $value = gmdate ("Y-m-d\T00:00:00\Z", $newdate);
- }
- break;
- case 'dropdown' :
- $typeSufix = '_t';
- break;
- case 'textarea' :
- $typeSufix = '_t';
- break;
- case 'currency' :
- $typeSufix = '_td';
- $value = floatval ($value);
- break;
- case 'percentage' :
- $typeSufix = '_t';
- break;
- case 'password' :
- $typeSufix = '_t';
- break;
- case 'suggest' :
- $typeSufix = '_t';
- break;
- case 'yesno' :
- $typeSufix = '_t';
- break;
- case 'listbox' :
- $typeSufix = '_t';
- break;
- case 'checkbox' :
- $typeSufix = '_t';
- break;
- case 'checkgroup' :
- $typeSufix = '_t';
- break;
- case 'radiogroup' :
- $typeSufix = '_t';
- break;
- case 'hidden' :
- $typeSufix = '_t';
- break;
- }
- if ($typeSufix != '*') {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', trim ($k) . $typeSufix);
- $writer->text ($value);
- $writer->endElement ();
- }
+ }
+ //remove duplicated
+ $delIndexes = array_unique( $delIndexes );
+ foreach ($delIndexes as $delIndex) {
+ $aRow = array ();
+ foreach ($resultColumns as $j => $columnName) {
+ $aRow[$columnName] = $data[$j];
+ }
+ // convert date from solr format UTC to local time in MySQL format
+ $solrdate = $data[0];
+ $localDate = date( 'Y-m-d H:i:s', strtotime( $solrdate ) );
+ $aRow['APP_CREATE_DATE'] = $localDate;
+
+ $solrdate = $data[12];
+ $localDate = date( 'Y-m-d H:i:s', strtotime( $solrdate ) );
+ $aRow['APP_UPDATE_DATE'] = $localDate;
+
+ // get delegation data from DB
+ //filter data from db
+ $indexes = $this->aaSearchRecords( $aaappsDBData, array ('APP_UID' => $appUID,'DEL_INDEX' => $delIndex
+ ) );
+
+ foreach ($indexes as $index) {
+ $row = $aaappsDBData[$index];
+ }
+
+ if (! isset( $row )) {
+ $fh = fopen( "SolrAppWhitoutDelIndex.txt", 'a' ) or die( "can't open file to store Solr search time." );
+ fwrite( $fh, sprintf( "Solr AppUid: %s DelIndex: %s not found.\r\n", $appUID, $delIndex ) );
+ fclose( $fh );
+ continue;
+ }
+ //$row = $this->getAppDelegationData ($appUID, $delIndex);
+
+
+ $aRow['APP_FINISH_DATE'] = null;
+ $aRow['APP_CURRENT_USER'] = $row['USR_NAME'] . " " . $row['USR_LAST'];
+ $aRow['APP_DEL_PREVIOUS_USER'] = $row['USR_PREV_NAME'] . " " . $row['USR_PREV_LAST'];
+ $aRow['APP_OVERDUE_PERCENTAGE'] = $row['APP_OVERDUE_PERCENTAGE'];
+ $aRow['APP_TAS_TITLE'] = $row['APP_TAS_TITLE'];
+ $aRow['APP_THREAD_STATUS'] = $row['APP_THREAD_STATUS'];
+ $aRow['DEL_DELAYED'] = $row['DEL_DELAYED'];
+ $aRow['DEL_DELAY_DURATION'] = $row['DEL_DELAY_DURATION'];
+ $aRow['DEL_DELEGATE_DATE'] = $row['DEL_DELEGATE_DATE'];
+ $aRow['DEL_DURATION'] = $row['DEL_DURATION'];
+ $aRow['DEL_FINISHED'] = (isset( $row['DEL_FINISH_DATE'] ) && $row['DEL_FINISH_DATE'] != '') ? 1 : 0;
+ $aRow['DEL_FINISH_DATE'] = $row['DEL_FINISH_DATE'];
+ $aRow['DEL_INDEX'] = $row['DEL_INDEX'];
+ $aRow['DEL_INIT_DATE'] = $row['DEL_INIT_DATE'];
+ $aRow['DEL_QUEUE_DURATION'] = $row['DEL_QUEUE_DURATION'];
+ $aRow['DEL_STARTED'] = (isset( $row['DEL_INIT_DATE'] ) && $row['DEL_INIT_DATE'] != '') ? 1 : 0;
+ $aRow['DEL_TASK_DUE_DATE'] = $row['DEL_TASK_DUE_DATE'];
+ $aRow['DEL_THREAD_STATUS'] = $row['DEL_THREAD_STATUS'];
+ $aRow['PREVIOUS_USR_UID'] = $row['PREVIOUS_USR_UID'];
+ $aRow['TAS_UID'] = $row['TAS_UID'];
+ $aRow['USR_UID'] = $userUid;
+ $aRow['DEL_PRIORITY'] = G::LoadTranslation( "ID_PRIORITY_{$aPriorities[$aRow['DEL_PRIORITY']]}" );
+
+ $rows[] = $aRow;
+ }
}
- else {
- $writer->startElement ("field");
- $writer->writeAttribute ('name', trim ($k) . '_t');
- $writer->text ($value);
- $writer->endElement ();
+ $result['data'] = $rows;
+ $result['success'] = true;
+ $result['result'] = true;
+ $result['message'] = "";
+
+ /**
+ * ******************************************
+ */
+ if ($this->debug) {
+ $this->afterPrepareResultTime = microtime( true );
+
+ $fh = fopen( "SolrSearchTime.txt", 'a' ) or die( "can't open file to store Solr search time." );
+ //fwrite($fh, sprintf("Solr Query time: %s DB Query time: %s Prepare result time: %s \n", gmdate ('H:i:s:u', ($this->afterSolrQueryTime - $this->initTimeAll)), gmdate ('H:i:s:u', ($this->afterDbQueryTime - $this->afterSolrQueryTime)), gmdate ('H:i:s:u', ($this->afterPrepareResultTime - $this->afterDbQueryTime)) ));
+ fwrite( $fh, sprintf( "Solr Query time: %s DB Query time: %s Prepare result time: %s Total:%s \r\n", ($this->afterSolrQueryTime - $this->initTimeAll), ($this->afterDbQueryTime - $this->afterSolrQueryTime), ($this->afterPrepareResultTime - $this->afterDbQueryTime), ($this->afterPrepareResultTime - $this->initTimeAll) ) );
+ fclose( $fh );
}
- }
- } // foreach unserialized data
- }// else unserialize APP_DATA
- } // empty APP_DATA
-
- $writer->endElement (); // end /doc
-
- return $writer->outputMemory (true);
- }
-
- /**
- * Search records in specified application delegation data
- *
- * @param string $AppUID
- * application identifier
- * @param string $allAppDbData
- * array of rows (array) with application data
- * @throws ApplicationWithoutDelegationRecordsException
- * @return array array of arrays with the following information(
- * $documentInformation,
- * $dynaformFieldTypes,
- * $lastUpdateDate,
- * $maxPriority,
- * $assignedUsers,
- * $assignedUsersRead,
- * $assignedUsersUnread,
- * $draftUser,
- * $participatedUsers,
- * $participatedUsersStartedByUser,
- * $participatedUsersCompletedByUser,
- * $unassignedUsers,
- * $unassignedGroups
- */
- public function getApplicationIndexData($AppUID, $allAppDbData)
- {
- G::LoadClass ('memcached');
+ /**
+ * ************************************
+ */
- // get all the application data
- //$allAppDbData = $this->getApplicationDelegationData ($AppUID);
- // check if the application record was found
- // this case occurs when the application doesn't have related delegation
- // records.
- if (empty ($allAppDbData) || ! isset ($allAppDbData [0])) {
- throw new ApplicationWithoutDelegationRecordsException ("Application without delegation records. APP_UID: " . $AppUID . "\n");
- }
-
- // copy the application information
- $documentInformation = $allAppDbData [0];
+ return $result;
- // get the last delegate date using the del_delegate_date
- $index = $this->aaGetMaximun ($allAppDbData, 'DEL_DELEGATE_DATE', 'DATE');
-
- $lastUpdateDate = $allAppDbData [$index] ['DEL_DELEGATE_DATE'];
-
- // get the delegate with max priority => minimun value
- $index2 = $this->aaGetMinimun ($allAppDbData, 'DEL_PRIORITY', 'NUMBER', 'DEL_THREAD_STATUS', 'OPEN');
-
- if ($index2 == null) {
- // get the last priority
- $maxPriority = $allAppDbData [$index] ['DEL_PRIORITY'];
- }
- else {
- $maxPriority = $allAppDbData [$index2] ['DEL_PRIORITY'];
- }
-
- $assignedUsers = array ();
- $indexes = $this->aaSearchRecords ($allAppDbData, array (
- 'DEL_THREAD_STATUS' => 'OPEN',
- 'DEL_FINISH_DATE' => 'NULL',
- 'APP_STATUS' => 'TO_DO',
- 'APP_THREAD_STATUS' => 'OPEN'
- ));
- foreach ($indexes as $index) {
- $assignedUsers [] = array (
- 'USR_UID' => $allAppDbData [$index] ['USR_UID'],
- 'DEL_INDEX' => $allAppDbData [$index] ['DEL_INDEX']
- );
- }
-
- $assignedUsersRead = array ();
- $indexes = $this->aaSearchRecords ($allAppDbData, array (
- 'DEL_THREAD_STATUS' => 'OPEN',
- 'DEL_FINISH_DATE' => 'NULL',
- 'APP_STATUS' => 'TO_DO',
- 'APP_THREAD_STATUS' => 'OPEN',
- 'DEL_INIT_DATE' => 'NOTNULL'
- ));
- foreach ($indexes as $index) {
- $assignedUsersRead [] = array (
- 'USR_UID' => $allAppDbData [$index] ['USR_UID'],
- 'DEL_INDEX' => $allAppDbData [$index] ['DEL_INDEX']
- );
- }
-
- $assignedUsersUnread = array ();
- $indexes = $this->aaSearchRecords ($allAppDbData, array (
- 'DEL_THREAD_STATUS' => 'OPEN',
- 'DEL_FINISH_DATE' => 'NULL',
- 'APP_STATUS' => 'TO_DO',
- 'APP_THREAD_STATUS' => 'OPEN',
- 'DEL_INIT_DATE' => 'NULL'
- ));
- foreach ($indexes as $index) {
- $assignedUsersUnread [] = array (
- 'USR_UID' => $allAppDbData [$index] ['USR_UID'],
- 'DEL_INDEX' => $allAppDbData [$index] ['DEL_INDEX']
- );
- }
-
- $draftUser = array ();
- $indexes = $this->aaSearchRecords ($allAppDbData, array (
- 'DEL_THREAD_STATUS' => 'OPEN',
- 'DEL_FINISH_DATE' => 'NULL',
- 'APP_STATUS' => 'DRAFT',
- 'APP_THREAD_STATUS' => 'OPEN'
- ));
- if (! empty ($indexes)) {
- $draftUser = array (
- 'USR_UID' => $allAppDbData [$indexes [0]] ['USR_UID'],
- 'DEL_INDEX' => $allAppDbData [$indexes [0]] ['DEL_INDEX']
- );
- }
-
- $participatedUsers = array ();
- foreach ($allAppDbData as $row) {
- $participatedUsers [] = array (
- 'USR_UID' => $row ['USR_UID'],
- 'DEL_INDEX' => $row ['DEL_INDEX']
- );
- }
-
- $participatedUsersStartedByUser = array ();
- $indexes = $this->aaSearchRecords ($allAppDbData, array (
- 'DEL_INDEX' => '1'
- ));
- foreach ($indexes as $index) {
- $participatedUsersStartedByUser [] = array (
- 'USR_UID' => $allAppDbData [$index] ['USR_UID'],
- 'DEL_INDEX' => $allAppDbData [$index] ['DEL_INDEX']
- );
- }
-
- $participatedUsersCompletedByUser = array ();
- $indexes = $this->aaSearchRecords ($allAppDbData, array (
- 'APP_STATUS' => 'COMPLETED'
- ));
- foreach ($indexes as $index) {
- $participatedUsersCompletedByUser [] = array (
- 'USR_UID' => $allAppDbData [$index] ['USR_UID'],
- 'DEL_INDEX' => $allAppDbData [$index] ['DEL_INDEX']
- );
- }
- // search information of unassigned users
- // the unassigned users are the self service users and groups.
- // the self service users are defined in the TASKs of the PROCESS.
- $unassignedUsers = array ();
- $unassignedGroups = array ();
- //filter only the delegations that are in selfservice status
- // `USR_UID` = '' AND `DEL_FINISH_DATE` IS NULL
- $indexes = $this->aaSearchRecords ($allAppDbData, array (
- 'USR_UID' => 'NULL',
- 'DEL_FINISH_DATE' => 'NULL',
- 'APP_THREAD_STATUS' => 'OPEN'
- ));
- foreach ($indexes as $index) {
- $unassignedUsersGroups = array ();
- // use cache
- $oMemcache = PMmemcached::getSingleton ($this->_solrInstance);
- $unassignedUsersGroups = $oMemcache->get ($allAppDbData [$index] ['PRO_UID'] . "_" . $allAppDbData [$index] ['TAS_UID']);
- if (! $unassignedUsersGroups) {
-
- $unassignedUsersGroups = $this->getTaskUnassignedUsersGroupsData ($allAppDbData [$index] ['PRO_UID'], $allAppDbData [$index] ['TAS_UID']);
-
- // if the task has unassigned users or groups add del_index of delegation
- foreach ($unassignedUsersGroups as $i => $newRow) {
- $unassignedUsersGroups [$i] ['DEL_INDEX'] = $allAppDbData [$index] ['DEL_INDEX'];
+ } catch (InvalidIndexSearchTextException $ex) {
+ // return empty result with description of error
+ $result = array ();
+ $result['totalCount'] = 0;
+ $result['data'] = array ();
+ $result['success'] = true;
+ $result['result'] = false;
+ $result['message'] = $ex->getMessage();
+ return $result;
}
- // store in cache
- $oMemcache->set ($allAppDbData [$index] ['PRO_UID'] . "_" . $allAppDbData [$index] ['TAS_UID'], $unassignedUsersGroups);
- }
-
- // copy list of unassigned users and groups
- foreach ($unassignedUsersGroups as $unassignedUserGroup) {
- //unassigned users
- if ($unassignedUserGroup ['TU_RELATION'] == 1) {
- $unassignedUsers [] = array (
- 'USR_UID' => $unassignedUserGroup ['USR_UID'],
- 'DEL_INDEX' => $unassignedUserGroup ['DEL_INDEX']
- );
- }
- //unassigned groups
- elseif ($unassignedUserGroup ['TU_RELATION'] == 2) {
- $unassignedGroups [] = array (
- 'USR_UID' => $unassignedUserGroup ['USR_UID'],
- 'DEL_INDEX' => $unassignedUserGroup ['DEL_INDEX']
- );
- }
- }
-
}
- // Get DataTypes of dynaforms
- // use cache array to store the dynaform variables per process
- // use memory array to store information of Datatypes of Dynaforms
- // All the datatypes of the process => all variables in all dynaforms in the
- // process
- $dynaformFieldTypes = array ();
- // get cache instance
- $oMemcache = PMmemcached::getSingleton ($this->_solrInstance);
- $dynaformFieldTypes = $oMemcache->get ($documentInformation ['PRO_UID']);
- if (! $dynaformFieldTypes) {
- G::LoadClass ('dynaformhandler');
- $dynaformFileNames = $this->getProcessDynaformFileNames ($documentInformation ['PRO_UID']);
- $dynaformFields = array ();
- foreach ($dynaformFileNames as $dynaformFileName) {
- if (is_file(PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml') &&
- filesize(PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml') >0 ) {
- $dyn = new dynaFormHandler (PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml');
- $dynaformFields [] = $dyn->getFields ();
- }
- if (is_file(PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml') &&
- filesize(PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName ['DYN_FILENAME'] . '.xml') == 0 ) {
-
- throw new ApplicationWithCorruptDynaformException("Application with corrupt dynaform. APP_UID: " . $AppUID . "\n");
- }
- }
-
- foreach ($dynaformFields as $aDynFormFields) {
- foreach ($aDynFormFields as $field) {
- // create array of fields and types
- if ($field->getAttribute ('validate') == 'Int') {
- $dynaformFieldTypes [$field->nodeName] = 'Int';
- }
- elseif ($field->getAttribute ('validate') == 'Real') {
- $dynaformFieldTypes [$field->nodeName] = 'Real';
- }
- else {
- $dynaformFieldTypes [$field->nodeName] = $field->getAttribute ('type');
- }
- }
- }
- // create cache of dynaformfields
- $oMemcache->set ($documentInformation ['PRO_UID'], $dynaformFieldTypes);
+ /**
+ * Get the array of counters of cases
+ *
+ * @param string $userUid the current logged user uid identifier
+ */
+ public function getCasesCount ($userUid)
+ {
+ $casesCount = array ();
+
+ // get number of records in todo list
+ $data = $this->getAppGridData( $userUid, 0, 0, 'todo', null, null, null, null, null, null, null, null, null, null, null, true );
+ $casesCount['to_do'] = $data['totalCount'];
+ // get number of records in participated list
+ $data = $this->getAppGridData( $userUid, 0, 0, 'sent', null, null, null, null, null, null, null, null, null, null, null, true );
+ $casesCount['sent'] = $data['totalCount'];
+ // get number of records in draft list
+ $data = $this->getAppGridData( $userUid, 0, 0, 'draft', null, null, null, null, null, null, null, null, null, null, null, true );
+ $casesCount['draft'] = $data['totalCount'];
+ // get number of records in unassigned list
+ $data = $this->getAppGridData( $userUid, 0, 0, 'unassigned', null, null, null, null, null, null, null, null, null, null, null, true );
+ $casesCount['selfservice'] = $data['totalCount'];
+
+ return $casesCount;
}
- // return result values
- $result = array (
- $documentInformation,
- $dynaformFieldTypes,
- $lastUpdateDate,
- $maxPriority,
- $assignedUsers,
- $assignedUsersRead,
- $assignedUsersUnread,
- $draftUser,
- $participatedUsers,
- $participatedUsersStartedByUser,
- $participatedUsersCompletedByUser,
- $unassignedUsers,
- $unassignedGroups
- );
-
- return $result;
- }
-
- /**
- * Find the maximun value of the specified column in the array and return the
- * row index
- *
- * @param array $arr
- * array of arrays with the data
- * @param string $column
- * column name to search in
- * @param string $columnType
- * column type STRING, NUMBER, DATE
- * @param string $columnCondition
- * column condition
- * @param string $condition
- * the condition
- * @return integer The index of the maximun record in array
- */
- public function aaGetMaximun($arr, $column, $columnType = 'STRING',
- $columnCondition = "", $condition = "")
- {
- // get first value
- $auxValue = $arr [0] [$column];
- $index = null;
- foreach ($arr as $i => $row) {
- switch ($columnType) {
- case 'STRING' :
- if ((strnatcmp ($row [$column], $auxValue) >= 0) && (($columnCondition == "") || ($row [$columnCondition] == $condition))) {
- $auxValue = $row [$column];
- $index = $i;
- }
- break;
- case 'NUMBER' :
- if (($row [$column] >= $auxValue) && (($columnCondition == "") || ($row [$columnCondition] == $condition))) {
- $auxValue = $row [$column];
- $index = $i;
- }
- break;
- case 'DATE' :
- if ((strtotime ($row [$column]) >= strtotime ($auxValue)) && (($columnCondition == "") || ($row [$columnCondition] == $condition))) {
- $auxValue = $row [$column];
- $index = $i;
- }
- break;
- }
+
+ /**
+ * Get the user groups
+ *
+ * @param string $usrUID the user identifier
+ * @return array of user groups
+ */
+ public function getUserGroups ($usrUID)
+ {
+ $gu = new GroupUser();
+ $rows = $gu->getAllUserGroups( $usrUID );
+ return $rows;
}
- return $index;
- }
-
- /**
- * Get minimum of array of arrays
- *
- * @param array $arr
- * array of arrays with the data
- * @param string $column
- * the name of the column to search in
- * @param string $columnType
- * the column type STRING, NUMBER, DATE
- * @param string $columnCondition
- * the column condition
- * @param string $condition
- * the condition
- * @return Ambigous Index of the minimun value found
- */
- public function aaGetMinimun($arr, $column, $columnType = 'STRING',
- $columnCondition = "", $condition = "")
- {
- // get first value
- $auxValue = $arr [0] [$column];
- $index = null;
- foreach ($arr as $i => $row) {
- switch ($columnType) {
- case 'STRING' :
- if ((strnatcmp ($row [$column], $auxValue) <= 0) && (($columnCondition == "") || ($row [$columnCondition] == $condition))) {
- $auxValue = $row [$column];
- $index = $i;
- }
- break;
- case 'NUMBER' :
- if (($row [$column] <= $auxValue) && (($columnCondition == "") || ($row [$columnCondition] == $condition))) {
- $auxValue = $row [$column];
- $index = $i;
- }
- break;
- case 'DATE' :
- if ((strtotime ($row [$column]) <= strtotime ($auxValue)) && (($columnCondition == "") || ($row [$columnCondition] == $condition))) {
- $auxValue = $row [$column];
- $index = $i;
-
- }
- break;
- }
+
+ /**
+ * Get the application delegation record from database
+ *
+ * @param string $aappUIDs array of Application identifiers
+ * @return array of arrays with delegation information.
+ */
+ public function getListApplicationDelegationData ($aappUIDs)
+ {
+
+ $c = new Criteria();
+
+ $c->addSelectColumn( AppDelegationPeer::APP_UID );
+ $c->addSelectColumn( AppDelegationPeer::DEL_INDEX );
+
+ $c->addAsColumn( 'USR_NAME', 'u.USR_FIRSTNAME' );
+ $c->addAsColumn( 'USR_LAST', 'u.USR_LASTNAME' );
+
+ $c->addAsColumn( 'USR_PREV_NAME', 'uprev.USR_FIRSTNAME' );
+ $c->addAsColumn( 'USR_PREV_LAST', 'uprev.USR_LASTNAME' );
+ $c->addAsColumn( 'PREVIOUS_USR_UID', 'uprev.USR_UID' );
+
+ $c->addAsColumn( 'APP_TAS_TITLE', 'ctastitle.CON_VALUE' );
+ $c->addAsColumn( 'APP_THREAD_STATUS', 'at.APP_THREAD_STATUS' );
+
+ $c->addSelectColumn( AppDelegationPeer::APP_OVERDUE_PERCENTAGE );
+
+ $c->addSelectColumn( AppDelegationPeer::DEL_DELAYED );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DELAY_DURATION );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DELEGATE_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DURATION );
+ $c->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_INIT_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_QUEUE_DURATION );
+ $c->addSelectColumn( AppDelegationPeer::DEL_TASK_DUE_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_THREAD_STATUS );
+ $c->addSelectColumn( AppDelegationPeer::TAS_UID );
+
+ $c->addAlias( 'u', 'USERS' );
+ $c->addAlias( 'uprev', 'USERS' );
+ $c->addAlias( 'adprev', 'APP_DELEGATION' );
+ $c->addAlias( 'ctastitle', 'CONTENT' );
+ $c->addAlias( 'at', 'APP_THREAD' );
+
+ $aConditions = array ();
+ $aConditions[] = array (AppDelegationPeer::USR_UID,'u.USR_UID'
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $aConditions = array ();
+ $aConditions[] = array (AppDelegationPeer::APP_UID,'adprev.APP_UID'
+ );
+ $aConditions[] = array (AppDelegationPeer::DEL_PREVIOUS,'adprev.DEL_INDEX'
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $aConditions = array ();
+ $aConditions[] = array (AppDelegationPeer::TAS_UID,'ctastitle.CON_ID'
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $aConditions = array ();
+ $aConditions[] = array ('adprev.USR_UID','uprev.USR_UID'
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $aConditions = array ();
+ $aConditions[] = array (AppDelegationPeer::APP_UID,'at.APP_UID'
+ );
+ $aConditions[] = array (AppDelegationPeer::DEL_THREAD,'at.APP_THREAD_INDEX'
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $c->add( AppDelegationPeer::APP_UID, $aappUIDs, Criteria::IN );
+ //$c->add (AppDelegationPeer::DEL_INDEX, $delIndex);
+
+
+ $c->add( 'ctastitle.CON_CATEGORY', 'TAS_TITLE' );
+ $c->add( 'ctastitle.CON_LANG', 'en' );
+
+ $rs = AppDelegationPeer::doSelectRS( $c );
+ $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ // echo $c->toString();
+ $rs->next();
+ $row = $rs->getRow();
+
+ $appDataRows = array ();
+ while (is_array( $row )) {
+ $appDataRows[] = $row;
+ $rs->next();
+ $row = $rs->getRow();
+ }
+
+ return $appDataRows;
}
- return $index;
- }
-
- /**
- * Search array of indexes that fullfill the conditions
- *
- * @param
- * array of arrays $arr contains the arrays that are searched
- * @param array $andColumnsConditions
- * contain the conditions that must fullfill 'Column'=>'Condition'
- * @return array of indexes with the found records
- */
- public function aaSearchRecords($arr, $andColumnsConditions)
- {
- $indexes = array ();
- $isEqual = true;
- foreach ($arr as $i => $row) {
- $evaluateRow = false;
- // evaluate each row
- foreach ($andColumnsConditions as $column => $valueCondition) {
- $condition = $valueCondition;
+
+ /**
+ * Get the application delegation record from database
+ *
+ * @param string $appUID Application identifier
+ * @param string $delIndex delegation index
+ * @return array with delegation record.
+ */
+ public function getAppDelegationData ($appUID, $delIndex)
+ {
+
+ $c = new Criteria();
+
+ $c->addSelectColumn( AppDelegationPeer::APP_UID );
+ $c->addSelectColumn( AppDelegationPeer::DEL_INDEX );
+
+ $c->addAsColumn( 'USR_NAME', 'u.USR_FIRSTNAME' );
+ $c->addAsColumn( 'USR_LAST', 'u.USR_LASTNAME' );
+
+ $c->addAsColumn( 'USR_PREV_NAME', 'uprev.USR_FIRSTNAME' );
+ $c->addAsColumn( 'USR_PREV_LAST', 'uprev.USR_LASTNAME' );
+ $c->addAsColumn( 'PREVIOUS_USR_UID', 'uprev.USR_UID' );
+
+ $c->addAsColumn( 'APP_TAS_TITLE', 'ctastitle.CON_VALUE' );
+ $c->addAsColumn( 'APP_THREAD_STATUS', 'at.APP_THREAD_STATUS' );
+
+ $c->addSelectColumn( AppDelegationPeer::APP_OVERDUE_PERCENTAGE );
+
+ $c->addSelectColumn( AppDelegationPeer::DEL_DELAYED );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DELAY_DURATION );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DELEGATE_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DURATION );
+ $c->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_INIT_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_QUEUE_DURATION );
+ $c->addSelectColumn( AppDelegationPeer::DEL_TASK_DUE_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_THREAD_STATUS );
+ $c->addSelectColumn( AppDelegationPeer::TAS_UID );
+
+ $c->addAlias( 'u', 'USERS' );
+ $c->addAlias( 'uprev', 'USERS' );
+ $c->addAlias( 'adprev', 'APP_DELEGATION' );
+ $c->addAlias( 'ctastitle', 'CONTENT' );
+ $c->addAlias( 'at', 'APP_THREAD' );
+
+ $aConditions = array ();
+ $aConditions[] = array (AppDelegationPeer::USR_UID,'u.USR_UID'
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $aConditions = array ();
+ $aConditions[] = array (AppDelegationPeer::APP_UID,'adprev.APP_UID'
+ );
+ $aConditions[] = array (AppDelegationPeer::DEL_PREVIOUS,'adprev.DEL_INDEX'
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $aConditions = array ();
+ $aConditions[] = array (AppDelegationPeer::TAS_UID,'ctastitle.CON_ID'
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $aConditions = array ();
+ $aConditions[] = array ('adprev.USR_UID','uprev.USR_UID'
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $aConditions = array ();
+ $aConditions[] = array (AppDelegationPeer::APP_UID,'at.APP_UID'
+ );
+ $aConditions[] = array (AppDelegationPeer::DEL_THREAD,'at.APP_THREAD_INDEX'
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $c->add( AppDelegationPeer::APP_UID, $appUID );
+ $c->add( AppDelegationPeer::DEL_INDEX, $delIndex );
+
+ $c->add( 'ctastitle.CON_CATEGORY', 'TAS_TITLE' );
+ $c->add( 'ctastitle.CON_LANG', 'en' );
+
+ $rs = AppDelegationPeer::doSelectRS( $c );
+ $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ // echo $c->toString();
+ $rs->next();
+ $row = $rs->getRow();
+
+ return $row;
+ }
+
+ /**
+ * return the correct search text for solr.
+ * if a field is included only search in this field.
+ *
+ * @param string $plainSearchText
+ * @return string formated Solr search string.
+ */
+ public function getSearchText ($plainSearchText)
+ {
+ $formattedSearchText = "";
+ // if an error is found in string null is returned
+ $includeToken = true;
+
+ // prepare string to separate and join parentesis
+ // " " => " "
+ $count = 1;
+ while ($count > 0) {
+ $plainSearchText = preg_replace( '/\s\s+/', ' ', $plainSearchText, - 1, $count );
+ }
+ // "text0( text1" => "text0 (text1"; "text0 )text1" => "text0) text1";
+ $plainSearchText = preg_replace( '/\s\[\s/', '[', $plainSearchText );
+ $plainSearchText = preg_replace( '/\s\]\s/', '] ', $plainSearchText );
+ $plainSearchText = preg_replace( '/\s"\s/', '" ', $plainSearchText );
+
+ // print "format search string: " . $plainSearchText . "\n";
+ // format
+ // 1: plain text that is used to search in text field: concat field
+ // 2: a field is specified [field_name]:["phrase search"]
+ // [field_name]:["phrase search"] [field_name]:[word_search] word_search
+ // "phrase search"
+ // to scape a reserved character use a double value: "::", """"
+ // ex: (APP_ASSIGNED_USERS:7091676694d9269da75c254003021135) AND
+ // (contrato_t:76* AND Causal_t:1021 AND Materiales AND 143073)
+ // ex: date search => APP_CREATE_DATE:[2012-03-12T00:00:00Z TO
+ // 2012-04-12T00:00:00Z]
+ // ex: phrase => TEXT:"This is a lazy dog"
+
+
+ // search the first
+
+
+ // cache the index fields
+ G::LoadClass( 'PMmemcached' );
+ $oMemcache = PMmemcached::getSingleton( $this->_solrInstance );
+ $ListFieldsInfo = $oMemcache->get( 'Solr_Index_Fields' );
+ if (! $ListFieldsInfo) {
+ G::LoadClass( 'searchIndex' );
+
+ $searchIndex = new BpmnEngine_Services_SearchIndex( $this->_solrIsEnabled, $this->_solrHost );
+ // execute query
+ $ListFieldsInfo = $searchIndex->getIndexFields( $this->_solrInstance );
+
+ //var_dump($ListFieldsInfo);
+ // cache
+ $oMemcache->set( 'Solr_Index_Fields', $ListFieldsInfo );
+
+ }
+
+ $tok = strtok( $plainSearchText, " " );
+
+ while ($tok !== false) {
+ $fieldName = substr( $tok, 0, strpos( $tok, ":" ) ); // strstr ( $tok,
+ // ":",
+ // true ); php 5.3
+ $searchText = strstr( $tok, ":" );
+
+ // verify if there's a field definition
+ if ($fieldName === false || $fieldName == "") {
+ // it's not a field
+ // the token is not a field
+ // add it completelly
+ $includeToken = true;
+ // no field found
+ $formattedSearchText .= $tok; // used to search in the general default
+ // text field
+ } else {
+ // it's a field
+ // verify if is complete
+ if ($fieldName == "" || $searchText == ":") {
+ $includeToken = false;
+ throw new InvalidIndexSearchTextException( "Invalid search text, verify the syntax. Expected format = {variable_name}:{search_text}" );
+ }
+
+ // field name found
+ // search index field name
+ $indexFieldName = "";
+ if (array_key_exists( $fieldName, $ListFieldsInfo )) {
+ $indexFieldName = $ListFieldsInfo[$fieldName];
+ } else {
+ // no field name found
+ // don't include field search
+ // return message about it
+ $includeToken = false;
+ throw new InvalidIndexSearchTextException( "Invalid search text, variable not found." );
+ }
+
+ // The token is part of a phrase, date or a word?
+ if ($searchText[1] == "[" || $searchText[1] == "\"") {
+ // expecting date interval we must search the end of the phrase
+ // the phrase is complete?
+ if ($searchText[1] == "[" && $searchText[strlen( $searchText ) - 1] == "]") {
+ // complete phrase ok, the date must be validated
+ // throw new InvalidIndexSearchTextException("Invalid search text.
+ // Expected date interval format =>
+ // {variable_name}:[YYYY-MM-DDThh:mm:ssZ TO YYYY-MM-DDThh:mm:ssZ]");
+ } elseif ($searchText[1] == "\"" && $searchText[strlen( $searchText ) - 1] == "\"") {
+ // the phrase is complete and is ok.
+ } else {
+ // search end of phrase
+ $tok = strtok( " " );
+ $found = false;
+ while ($tok !== false) {
+ if ((($searchText[1] == "[") && ($tok[strlen( $tok ) - 1] == "]")) || (($searchText[1] == "\"") && ($tok[strlen( $tok ) - 1] == "\""))) {
+ // end of phrase found
+ $found = true;
+ $searchText .= " " . $tok;
+ break;
+ } else {
+ // continue adding text
+ $searchText .= " " . $tok;
+ }
+ $tok = strtok( " " );
+ }
+ if (! $found) {
+ // error invalid text
+ // Expected date interval format => {variable_name}:[YYYY-MM-DDThh:mm:ssZ TO YYYY-MM-DDThh:mm:ssZ]
+ throw new InvalidIndexSearchTextException( "Invalid search text. The date or phase is not completed" );
+ }
+ }
+ }
+
+ // validate phrase in case of date
+ if (($searchText[1] == "[")) {
+ // validate date range format
+ // use regular expresion to validate it [yyyy-mm-dd TO yyyy-mm-dd]
+ $reg = "/:\[(\d\d\d\d-\d\d-\d\d|\*)\sTO\s(\d\d\d\d-\d\d-\d\d|\*)\]/";
+ // convert date to utc
+ $matched = preg_match( $reg, $searchText, $matches );
+ if ($matched == 1) {
+ // the date interval is valid
+ // convert to SOlr format
+ $fromDateOriginal = $matches[1];
+ $fromDate = $matches[1];
+
+ $toDateOriginal = $matches[2];
+ $toDate = $matches[2];
+
+ if ($fromDateOriginal != '*') {
+ // TODO complete date creation
+ // list($year, $month, $day) = sscanf($fromDateOriginal,
+ // '%04d/%02d/%02d');
+ // $fromDateDatetime = new DateTime($fromDateOriginal);
+ // $fromDateDatetime = date_create_from_format ( 'Y-m-d',
+ // $fromDateOriginal );
+ // $fromDateDatetime->getTimestamp ()
+ $fromDate = gmdate( "Y-m-d\T00:00:00\Z", strtotime( $fromDateOriginal ) );
+ }
+ if ($toDateOriginal != '*') {
+ // list($year, $month, $day) = sscanf($fromDateOriginal,
+ // '%04d/%02d/%02d');
+ // $toDateDatetime = new DateTime($toDateOriginal);
+ // $toDateDatetime = date_create_from_format ( 'Y-m-d',
+ // $toDateOriginal );
+ $toDate = gmdate( "Y-m-d\T23:59:59.999\Z", strtotime( $toDateOriginal ) );
+ }
+ $searchText = ":[" . $fromDate . " TO " . $toDate . "]";
+ } else {
+ throw new InvalidIndexSearchTextException( "Invalid search text. Expected date interval format => {variable_name}:[YYYY-MM-DD TO YYYY-MM-DD]" );
+ }
+ }
+
+ $formattedSearchText .= $indexFieldName . $searchText;
+ $includeToken = true;
+ }
+
+ if ($includeToken) {
+ $formattedSearchText .= " AND ";
+ }
+ // next token
+ $tok = strtok( " " );
+ }
+ // remove last AND
+ $formattedSearchText = substr_replace( $formattedSearchText, "", - 5 );
+ return $formattedSearchText;
+ }
+
+ /**
+ * Get all the application delegation records from database
+ *
+ * @param string $appUID Application identifier
+ * @return array delegation records
+ */
+ public function getApplicationDelegationsIndex ($appUID)
+ {
+ $delIndexes = array ();
+
+ $c = new Criteria();
+
+ $c->addSelectColumn( AppDelegationPeer::DEL_INDEX );
+ $c->add( AppDelegationPeer::APP_UID, $appUID );
+
+ $rs = AppDelegationPeer::doSelectRS( $c );
+ $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+
+ $rs->next();
+ $row = $rs->getRow();
+
+ while (is_array( $row )) {
+ $delIndexes[] = $row['DEL_INDEX'];
+ $rs->next();
+ $row = $rs->getRow();
+ }
+
+ return $delIndexes;
+
+ }
+
+ /**
+ * Update the information of the specified applications in Solr
+ *
+ * @param array $aaAPPUIDs Array of arrays of App_UID that must be updated,
+ * APP_UID is permitted also
+ */
+ public function updateApplicationSearchIndex ($aaAPPUIDs)
+ {
+ if (empty( $aaAPPUIDs )) {
+ return;
+ }
+
+ if (! is_array( $aaAPPUIDs )) {
+ // convert to array
+ $APPUID = $aaAPPUIDs;
+ $aaAPPUIDs = array ();
+ $aaAPPUIDs[] = array ('APP_UID' => $APPUID
+ );
+ }
+ // check if index server is available
+ if (! $this->isSolrEnabled()) {
+ // store update in table and return
+ foreach ($aaAPPUIDs as $aAPPUID) {
+ $this->applicationChangedUpdateSolrQueue( $aAPPUID['APP_UID'], true );
+ }
+ return;
+ }
+
+ if ($this->debug) {
+ $this->beforeCreateSolrXMLDocTime = microtime( true );
+ }
+ // create XML document
+ $xmlDoc = $this->createSolrXMLDocument( $aaAPPUIDs );
+
+ if ($this->debug) {
+ $this->afterCreateSolrXMLDocTime = microtime( true );
+ }
+ // update document
+ $data = array ('workspace' => $this->_solrInstance,'document' => $xmlDoc
+ );
+
+ $oSolrUpdateDocument = Entity_SolrUpdateDocument::createForRequest( $data );
+
+ G::LoadClass( 'searchIndex' );
+
+ $oSearchIndex = new BpmnEngine_Services_SearchIndex( $this->_solrIsEnabled, $this->_solrHost );
+
+ try {
+ $oSearchIndex->updateIndexDocument( $oSolrUpdateDocument );
+
+ if ($this->debug) {
+ $this->afterUpdateSolrXMLDocTime = microtime( true );
+ }
+ // commit changes
+ $oSearchIndex->commitIndexChanges( $this->_solrInstance );
+
+ } catch (Exception $ex) {
+ //print "Excepcion indexing data: " . $ex->getMessage() . "\n"; die;
+ $fh = fopen( "./SolrIndexErrors.txt", 'a' ) or die( "can't open file to store Solr index errors." );
+ fwrite( $fh, $ex->getMessage() );
+ fclose( $fh );
+ }
+ if ($this->debug) {
+ $this->afterCommitSolrDocTime = microtime( true );
+
+ $fh = fopen( "SolrIndexTime.txt", 'a' ) or die( "can't open file to store Solr index time." );
+ //fwrite($fh, sprintf("Solr Query time: %s DB Query time: %s Prepare result time: %s \n", gmdate ('H:i:s:u', ($this->afterSolrQueryTime - $this->initTimeAll)), gmdate ('H:i:s:u', ($this->afterDbQueryTime - $this->afterSolrQueryTime)), gmdate ('H:i:s:u', ($this->afterPrepareResultTime - $this->afterDbQueryTime)) ));
+ fwrite( $fh, sprintf( "Solr Create XML Document time: %s Update Solr Document time: %s Commit Solr Changes time: %s Total:%s \r\n", ($this->afterCreateSolrXMLDocTime - $this->beforeCreateSolrXMLDocTime), ($this->afterUpdateSolrXMLDocTime - $this->afterCreateSolrXMLDocTime), ($this->afterCommitSolrDocTime - $this->afterUpdateSolrXMLDocTime), ($this->afterCommitSolrDocTime - $this->beforeCreateSolrXMLDocTime) ) );
+ fclose( $fh );
+ }
+ }
+
+ /**
+ * Delete the specified application record from Solr
+ *
+ * @param string $appUID Application identifier
+ */
+ public function deleteApplicationSearchIndex ($appUID)
+ {
+ if (empty( $appUID )) {
+ return;
+ }
+
+ // check if index server is available
+ if (! $this->_solrIsEnabled) {
+ // store update in table and return
+ $this->applicationChangedUpdateSolrQueue( $appUID['APP_UID'], 2 ); // delete
+ return;
+ }
+
+ $idQuery = "APP_UID:" . $appUID;
+
+ G::LoadClass( 'searchIndex' );
+
+ $oSearchIndex = new BpmnEngine_Services_SearchIndex( $this->_solrIsEnabled, $this->_solrHost );
+
+ $oSearchIndex->deleteDocumentFromIndex( $this->_solrInstance, $idQuery );
+
+ // commit changes
+ $oSearchIndex->commitIndexChanges( $this->_solrInstance );
+ }
+
+ /**
+ * Create XML data in Solr format of the specified applications
+ * this function uses the buildSearchIndexDocumentPMOS2 function to create
+ * each record
+ *
+ * @param array $aaAPPUIDs array of arrays of application identifiers
+ * @return string The resulting XML document in Solr format
+ */
+ public function createSolrXMLDocument ($aaAPPUIDs)
+ {
+ if ($this->debug) {
+ $this->getApplicationDataDBTime = 0;
+ $this->getBuilXMLDocTime = 0;
+ }
+ // search data from DB
+ $xmlDoc = "\n";
+ $xmlDoc .= "\n";
+
+ //get all application data from DB of all applications and delegations
+ $aAPPUIDs = array ();
+ foreach ($aaAPPUIDs as $aAPPUID) {
+ $aAPPUIDs[] = $aAPPUID['APP_UID'];
+ }
+ if ($this->debug) {
+ $this->beforeGetApplicationDataDBTime = microtime( true );
+ }
+ $aaAllAppDelData = $this->getListApplicationUpdateDelegationData( $aAPPUIDs );
+ if ($this->debug) {
+ $this->afterGetApplicationDataDBTime = microtime( true );
+
+ $this->getApplicationDataDBTime = $this->afterGetApplicationDataDBTime - $this->beforeGetApplicationDataDBTime;
+ }
+ foreach ($aaAPPUIDs as $aAPPUID) {
+ try {
+
+ if ($this->debug) {
+ $this->beforePrepareApplicationDataDBTime = microtime( true );
+ }
+ //filter data, include all the rows of the application
+ // get delegation data from DB
+ $aaAppData = array ();
+ //filter data from db
+ $indexes = $this->aaSearchRecords( $aaAllAppDelData, array ('APP_UID' => $aAPPUID['APP_UID']
+ ) );
+
+ foreach ($indexes as $index) {
+ $aaAppData[] = $aaAllAppDelData[$index];
+ }
+
+ $result = $this->getApplicationIndexData( $aAPPUID['APP_UID'], $aaAppData );
+
+ if ($this->debug) {
+ $this->afterPrepareApplicationDataDBTime = microtime( true );
+
+ $this->getPreparedApplicationDataDBTime = $this->afterPrepareApplicationDataDBTime - $this->beforePrepareApplicationDataDBTime;
+ }
+
+ } catch (ApplicationWithoutDelegationRecordsException $ex) {
+ // exception trying to get application information
+ // skip and continue with the next application
+ $fh = fopen( "./SolrIndexErrors.txt", 'a' ) or die( "can't open file to store Solr index errors." );
+ fwrite( $fh, $ex->getMessage() );
+ fclose( $fh );
+ continue;
+ } catch (ApplicationWithCorruptDynaformException $ex) {
+ $fh = fopen( "./SolrIndexErrors.txt", 'a' ) or die( "can't open file to store Solr index errors." );
+ fwrite( $fh, $ex->getMessage() );
+ fclose( $fh );
+ continue;
+ } catch (Exception $ex) {
+ $fh = fopen( "./SolrIndexErrors.txt", 'a' ) or die( "can't open file to store Solr index errors." );
+ fwrite( $fh, "getApplicationIndexData " . $aAPPUID . ":" . $ex->getMessage() . "\n" );
+ fclose( $fh );
+ continue;
+ }
+
+ $documentInformation = $result[0];
+ $dynaformFieldTypes = $result[1];
+ $lastUpdateDate = $result[2];
+ $maxPriority = $result[3];
+ $assignedUsers = $result[4];
+ $assignedUsersRead = $result[5];
+ $assignedUsersUnread = $result[6];
+ $draftUser = $result[7];
+ $participatedUsers = $result[8];
+ $participatedUsersStartedByUser = $result[9];
+ $participatedUsersCompletedByUser = $result[10];
+ $unassignedUsers = $result[11];
+ $unassignedGroups = $result[12];
+
+ try {
+
+ // create document
+ $xmlDoc .= $this->buildSearchIndexDocumentPMOS2( $documentInformation, $dynaformFieldTypes, $lastUpdateDate, $maxPriority, $assignedUsers, $assignedUsersRead, $assignedUsersUnread, $draftUser, $participatedUsers, $participatedUsersStartedByUser, $participatedUsersCompletedByUser, $unassignedUsers, $unassignedGroups );
+
+ if ($this->debug) {
+ $this->afterBuilXMLDocTime = microtime( true );
+
+ $this->getBuilXMLDocTime += $this->afterBuilXMLDocTime - $this->afterGetApplicationDataDBTime;
+ }
+ } catch (ApplicationAPP_DATAUnserializeException $ex) {
+ // exception trying to get application information
+ $fh = fopen( "./SolrIndexErrors.txt", 'a' ) or die( "can't open file to store Solr index errors." );
+ fwrite( $fh, $ex->getMessage() );
+ fclose( $fh );
+ // skip and continue with the next application
+ continue;
+ } catch (Exception $ex) {
+ $fh = fopen( "./SolrIndexErrors.txt", 'a' ) or die( "can't open file to store Solr index errors." );
+ fwrite( $fh, "buildSearchIndexDocumentPMOS2 " . $aAPPUID . ":" . $ex->getMessage() . "\n" );
+ fclose( $fh );
+ continue;
+ }
+
+ }
+
+ $xmlDoc .= "\n";
+
+ if ($this->debug) {
+ $fh = fopen( "SolrIndexTime.txt", 'a' ) or die( "can't open file to store Solr index time." );
+ fwrite( $fh, sprintf( "Get Data DB time: %s Prepare DB data Time: %s Create XML file time: %s \r\n", $this->getApplicationDataDBTime, $this->getPreparedApplicationDataDBTime, $this->getBuilXMLDocTime ) );
+ fclose( $fh );
+ }
+
+ return $xmlDoc;
+ }
+
+ /**
+ * build Solr index document xml for an application
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @param [in] array $documentData array of data for the xml document of
+ * application
+ * @param [in] array $dynaformFieldTypes array of dynaform field types, used
+ * to store the info of APP_DATA with types
+ * @param [in] array $appTitles array of array of application titles in all
+ * languages
+ * @param [in] array $proTitles array of array of process titles in all
+ * languages
+ * @param [in] array $assignedUsers array of array of uids of assigned users
+ * to Application UIDs
+ * @param [in] array $draftUsers array of array of uids of draft users to
+ * Application UIDs
+ * @param [in] array $participatedUsers array of array of participated users
+ * UIDs in application
+ * @param [in] array $unassignedUsers array of unassigned users UIDs
+ * @param [in] array $unassignedGroups array of unassigned groups UIDs
+ * @param [out] xml xml document
+ *
+ * $xmlDoc .= buildSearchIndexDocumentPMOS2($documentInformation,
+ * $dynaformFieldTypes,
+ * $lastUpdateDate, $maxPriority,
+ * $assignedUsers, $assignedUsersRead, $assignedUsersUnread,
+ * $draftUser,
+ * $participatedUsers, $participatedUsersStartedByUser,
+ * $participatedUsersCompletedByUser,
+ * $unassignedUsers, $unassignedGroups);*
+ */
+ public function buildSearchIndexDocumentPMOS2 ($documentData, $dynaformFieldTypes, $lastUpdateDate, $maxPriority, $assignedUsers, $assignedUsersRead, $assignedUsersUnread, $draftUser, $participatedUsers, $participatedUsersStartedByUser, $participatedUsersCompletedByUser, $unassignedUsers, $unassignedGroups)
+ {
+ // build xml document
+
+
+ $writer = new XMLWriter();
+ $writer->openMemory();
+ $writer->setIndent( 4 );
+
+ $writer->startElement( "doc" );
+
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_UID' );
+ $writer->text( $documentData['APP_UID'] );
+ $writer->endElement();
+
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_NUMBER' );
+ $writer->text( $documentData['APP_NUMBER'] );
+ $writer->endElement();
+
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_STATUS' );
+ $writer->text( $documentData['APP_STATUS'] );
+ $writer->endElement();
+
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'PRO_UID' );
+ $writer->text( $documentData['PRO_UID'] );
+ $writer->endElement();
+
+ if (! empty( $documentData['APP_TITLE'] )) {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_TITLE' );
+ $writer->text( $documentData['APP_TITLE'] );
+ $writer->endElement();
+ } else {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_TITLE' );
+ $writer->text( "" );
+ $writer->endElement();
+ }
+
+ if (! empty( $documentData['PRO_TITLE'] )) {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_PRO_TITLE' );
+ $writer->text( $documentData['PRO_TITLE'] );
+ $writer->endElement();
+
+ } else {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_PRO_TITLE' );
+ $writer->text( "" );
+ $writer->endElement();
+ }
+
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_CREATE_DATE' );
+ // convert date to UTC with gmdate
+ $writer->text( gmdate( "Y-m-d\TH:i:s\Z", strtotime( $documentData['APP_CREATE_DATE'] ) ) );
+ $writer->endElement();
+
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'DEL_LAST_UPDATE_DATE' );
+ // convert date to UTC with gmdate
+ $writer->text( gmdate( "Y-m-d\TH:i:s\Z", strtotime( $lastUpdateDate ) ) );
+ $writer->endElement();
+
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'DEL_MAX_PRIORITY' );
+ $writer->text( $maxPriority );
+ $writer->endElement();
+
+ if (is_array( $assignedUsers ) && ! empty( $assignedUsers )) {
+ foreach ($assignedUsers as $userUID) {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_ASSIGNED_USERS' );
+ $writer->text( $userUID['USR_UID'] );
+ $writer->endElement();
+
+ // add dynamic field for del_index information
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_ASSIGNED_USER_DEL_INDEX_' . trim( $userUID['USR_UID'] ) . '_txt' );
+ $writer->text( $userUID['DEL_INDEX'] );
+ $writer->endElement();
+
+ }
+ }
+
+ if (is_array( $assignedUsersRead ) && ! empty( $assignedUsersRead )) {
+ foreach ($assignedUsersRead as $userUID) {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_ASSIGNED_USERS_READ' );
+ $writer->text( $userUID['USR_UID'] );
+ $writer->endElement();
+
+ // add dynamic field for del_index information
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_ASSIGNED_USER_READ_DEL_INDEX_' . trim( $userUID['USR_UID'] ) . '_txt' );
+ $writer->text( $userUID['DEL_INDEX'] );
+ $writer->endElement();
+ }
+ }
+
+ if (is_array( $assignedUsersUnread ) && ! empty( $assignedUsersUnread )) {
+ foreach ($assignedUsersUnread as $userUID) {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_ASSIGNED_USERS_UNREAD' );
+ $writer->text( $userUID['USR_UID'] );
+ $writer->endElement();
+
+ // add dynamic field for del_index information
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_ASSIGNED_USER_UNREAD_DEL_INDEX_' . trim( $userUID['USR_UID'] ) . '_txt' );
+ $writer->text( $userUID['DEL_INDEX'] );
+ $writer->endElement();
+ }
+ }
+
+ if (! empty( $draftUser )) {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_DRAFT_USER' );
+ $writer->text( $draftUser['USR_UID'] );
+ $writer->endElement();
+ }
+
+ if (is_array( $participatedUsers ) && ! empty( $participatedUsers )) {
+ foreach ($participatedUsers as $userUID) {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_PARTICIPATED_USERS' );
+ $writer->text( $userUID['USR_UID'] );
+ $writer->endElement();
+
+ // add dynamic field for del_index information
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_PARTICIPATED_USER_DEL_INDEX_' . trim( $userUID['USR_UID'] ) . '_txt' );
+ $writer->text( $userUID['DEL_INDEX'] );
+ $writer->endElement();
+ }
+ }
+
+ if (is_array( $participatedUsersStartedByUser ) && ! empty( $participatedUsersStartedByUser )) {
+ foreach ($participatedUsersStartedByUser as $userUID) {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_PARTICIPATED_USERS_STARTED' );
+ $writer->text( $userUID['USR_UID'] );
+ $writer->endElement();
+
+ // add dynamic field for del_index information
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_PARTICIPATED_USER_STARTED_DEL_INDEX_' . trim( $userUID['USR_UID'] ) . '_txt' );
+ $writer->text( $userUID['DEL_INDEX'] );
+ $writer->endElement();
+ }
+ }
+
+ if (is_array( $participatedUsersCompletedByUser ) && ! empty( $participatedUsersCompletedByUser )) {
+ foreach ($participatedUsersCompletedByUser as $userUID) {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_PARTICIPATED_USERS_COMPLETED' );
+ $writer->text( $userUID['USR_UID'] );
+ $writer->endElement();
+
+ // add dynamic field for del_index information
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_PARTICIPATED_USER_COMPLETED_DEL_INDEX_' . trim( $userUID['USR_UID'] ) . '_txt' );
+ $writer->text( $userUID['DEL_INDEX'] );
+ $writer->endElement();
+ }
+ }
+
+ if (is_array( $unassignedUsers ) && ! empty( $unassignedUsers )) {
+ foreach ($unassignedUsers as $userUID) {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_UNASSIGNED_USERS' );
+ $writer->text( $userUID['USR_UID'] );
+ $writer->endElement();
+
+ // add dynamic field for del_index information
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_UNASSIGNED_USER_GROUP_DEL_INDEX_' . trim( $userUID['USR_UID'] ) . '_txt' );
+ $writer->text( $userUID['DEL_INDEX'] );
+ $writer->endElement();
+ }
+ }
+
+ if (is_array( $unassignedGroups ) && ! empty( $unassignedGroups )) {
+ foreach ($unassignedGroups as $groupUID) {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_UNASSIGNED_GROUPS' );
+ $writer->text( $groupUID['USR_UID'] );
+ $writer->endElement();
+
+ // add dynamic field for del_index information
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', 'APP_UNASSIGNED_USER_GROUP_DEL_INDEX_' . trim( $groupUID['USR_UID'] ) . '_txt' );
+ $writer->text( $groupUID['DEL_INDEX'] );
+ $writer->endElement();
+ }
+ }
+
+ // get the serialized fields
+ if (! empty( $documentData['APP_DATA'] ) && $documentData['APP_DATA'] != "N;") {
+
+ $UnSerializedCaseData = unserialize( $documentData['APP_DATA'] );
+
+ if ($UnSerializedCaseData === false) {
+ $UnSerializedCaseData = preg_replace( '!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $documentData['APP_DATA'] ); // utf8_encode
+ $UnSerializedCaseData = unserialize( $UnSerializedCaseData );
+ }
+
+ if (! $UnSerializedCaseData) {
+ // error unserializing
+ throw new ApplicationAPP_DATAUnserializeException( "Could not unserialize APP_DATA of APP_UID: " . $documentData['APP_UID'] . "\n" );
+ } else {
+ foreach ($UnSerializedCaseData as $k => $value) {
+ if (! is_array( $value ) && ! is_object( $value ) && $value != '' && $k != 'SYS_LANG' && $k != 'SYS_SKIN' && $k != 'SYS_SYS') {
+ // search the field type in array of dynaform fields
+ if (! empty( $dynaformFieldTypes ) && array_key_exists( trim( $k ), $dynaformFieldTypes )) {
+ $type = $dynaformFieldTypes[trim( $k )];
+ $typeSufix = '_t';
+ switch ($type) {
+ case 'text':
+ $typeSufix = '_t';
+ break;
+ case 'Int':
+ if (intval( $value ) > 2147483647) {
+ $typeSufix = '_tl'; //for long values
+ $value = intval( $value );
+ } else {
+ $typeSufix = '_ti';
+ $value = intval( $value );
+ }
+ break;
+ case 'Real':
+ $typeSufix = '_td';
+ $value = floatval( $value );
+ break;
+ case 'date':
+ $newdate = false;
+ $withHour = true;
+ // try to convert string to date
+ // TODO convert to php 5.2 format
+ /*
+ * $newdate = date_create_from_format ( 'Y-m-d H:i:s', $value ); if (! $newdate) { $newdate = date_create_from_format ( 'Y-m-d', $value ); $withHour = false; } if (! $newdate) { $newdate = date_create_from_format ( 'd/m/Y', $value ); $withHour = false; } if (!
+ * $newdate) { $newdate = date_create_from_format ( 'j/m/Y', $value ); $withHour = false; }
+ */
+ $newdate = strtotime( $value );
+ if (! $newdate) {
+ $typeSufix = '*'; // not store field
+ } else {
+ $typeSufix = '_tdt';
+ /*
+ * if ($withHour) //$value = gmdate ( "Y-m-d\TH:i:s\Z", $newdate->getTimestamp () ); $value = gmdate ( "Y-m-d\TH:i:s\Z", $newdate ); else { $value = gmdate ( "Y-m-d\T00:00:00\Z", $newdate ); }
+ */
+ $value = gmdate( "Y-m-d\T00:00:00\Z", $newdate );
+ }
+ break;
+ case 'dropdown':
+ $typeSufix = '_t';
+ break;
+ case 'textarea':
+ $typeSufix = '_t';
+ break;
+ case 'currency':
+ $typeSufix = '_td';
+ $value = floatval( $value );
+ break;
+ case 'percentage':
+ $typeSufix = '_t';
+ break;
+ case 'password':
+ $typeSufix = '_t';
+ break;
+ case 'suggest':
+ $typeSufix = '_t';
+ break;
+ case 'yesno':
+ $typeSufix = '_t';
+ break;
+ case 'listbox':
+ $typeSufix = '_t';
+ break;
+ case 'checkbox':
+ $typeSufix = '_t';
+ break;
+ case 'checkgroup':
+ $typeSufix = '_t';
+ break;
+ case 'radiogroup':
+ $typeSufix = '_t';
+ break;
+ case 'hidden':
+ $typeSufix = '_t';
+ break;
+ }
+ if ($typeSufix != '*') {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', trim( $k ) . $typeSufix );
+ $writer->text( $value );
+ $writer->endElement();
+ }
+ } else {
+ $writer->startElement( "field" );
+ $writer->writeAttribute( 'name', trim( $k ) . '_t' );
+ $writer->text( $value );
+ $writer->endElement();
+ }
+ }
+ } // foreach unserialized data
+ } // else unserialize APP_DATA
+ } // empty APP_DATA
+
+
+ $writer->endElement(); // end /doc
+
+
+ return $writer->outputMemory( true );
+ }
+
+ /**
+ * Search records in specified application delegation data
+ *
+ * @param string $AppUID application identifier
+ * @param string $allAppDbData array of rows (array) with application data
+ * @throws ApplicationWithoutDelegationRecordsException
+ * @return array array of arrays with the following information(
+ * $documentInformation,
+ * $dynaformFieldTypes,
+ * $lastUpdateDate,
+ * $maxPriority,
+ * $assignedUsers,
+ * $assignedUsersRead,
+ * $assignedUsersUnread,
+ * $draftUser,
+ * $participatedUsers,
+ * $participatedUsersStartedByUser,
+ * $participatedUsersCompletedByUser,
+ * $unassignedUsers,
+ * $unassignedGroups
+ */
+ public function getApplicationIndexData ($AppUID, $allAppDbData)
+ {
+ G::LoadClass( 'memcached' );
+
+ // get all the application data
+ //$allAppDbData = $this->getApplicationDelegationData ($AppUID);
+ // check if the application record was found
+ // this case occurs when the application doesn't have related delegation
+ // records.
+ if (empty( $allAppDbData ) || ! isset( $allAppDbData[0] )) {
+ throw new ApplicationWithoutDelegationRecordsException( "Application without delegation records. APP_UID: " . $AppUID . "\n" );
+ }
+
+ // copy the application information
+ $documentInformation = $allAppDbData[0];
+
+ // get the last delegate date using the del_delegate_date
+ $index = $this->aaGetMaximun( $allAppDbData, 'DEL_DELEGATE_DATE', 'DATE' );
+
+ $lastUpdateDate = $allAppDbData[$index]['DEL_DELEGATE_DATE'];
+
+ // get the delegate with max priority => minimun value
+ $index2 = $this->aaGetMinimun( $allAppDbData, 'DEL_PRIORITY', 'NUMBER', 'DEL_THREAD_STATUS', 'OPEN' );
+
+ if ($index2 == null) {
+ // get the last priority
+ $maxPriority = $allAppDbData[$index]['DEL_PRIORITY'];
+ } else {
+ $maxPriority = $allAppDbData[$index2]['DEL_PRIORITY'];
+ }
+
+ $assignedUsers = array ();
+ $indexes = $this->aaSearchRecords( $allAppDbData, array ('DEL_THREAD_STATUS' => 'OPEN','DEL_FINISH_DATE' => 'NULL','APP_STATUS' => 'TO_DO','APP_THREAD_STATUS' => 'OPEN'
+ ) );
+ foreach ($indexes as $index) {
+ $assignedUsers[] = array ('USR_UID' => $allAppDbData[$index]['USR_UID'],'DEL_INDEX' => $allAppDbData[$index]['DEL_INDEX']
+ );
+ }
+
+ $assignedUsersRead = array ();
+ $indexes = $this->aaSearchRecords( $allAppDbData, array ('DEL_THREAD_STATUS' => 'OPEN','DEL_FINISH_DATE' => 'NULL','APP_STATUS' => 'TO_DO','APP_THREAD_STATUS' => 'OPEN','DEL_INIT_DATE' => 'NOTNULL'
+ ) );
+ foreach ($indexes as $index) {
+ $assignedUsersRead[] = array ('USR_UID' => $allAppDbData[$index]['USR_UID'],'DEL_INDEX' => $allAppDbData[$index]['DEL_INDEX']
+ );
+ }
+
+ $assignedUsersUnread = array ();
+ $indexes = $this->aaSearchRecords( $allAppDbData, array ('DEL_THREAD_STATUS' => 'OPEN','DEL_FINISH_DATE' => 'NULL','APP_STATUS' => 'TO_DO','APP_THREAD_STATUS' => 'OPEN','DEL_INIT_DATE' => 'NULL'
+ ) );
+ foreach ($indexes as $index) {
+ $assignedUsersUnread[] = array ('USR_UID' => $allAppDbData[$index]['USR_UID'],'DEL_INDEX' => $allAppDbData[$index]['DEL_INDEX']
+ );
+ }
+
+ $draftUser = array ();
+ $indexes = $this->aaSearchRecords( $allAppDbData, array ('DEL_THREAD_STATUS' => 'OPEN','DEL_FINISH_DATE' => 'NULL','APP_STATUS' => 'DRAFT','APP_THREAD_STATUS' => 'OPEN'
+ ) );
+ if (! empty( $indexes )) {
+ $draftUser = array ('USR_UID' => $allAppDbData[$indexes[0]]['USR_UID'],'DEL_INDEX' => $allAppDbData[$indexes[0]]['DEL_INDEX']
+ );
+ }
+
+ $participatedUsers = array ();
+ foreach ($allAppDbData as $row) {
+ $participatedUsers[] = array ('USR_UID' => $row['USR_UID'],'DEL_INDEX' => $row['DEL_INDEX']
+ );
+ }
+
+ $participatedUsersStartedByUser = array ();
+ $indexes = $this->aaSearchRecords( $allAppDbData, array ('DEL_INDEX' => '1'
+ ) );
+ foreach ($indexes as $index) {
+ $participatedUsersStartedByUser[] = array ('USR_UID' => $allAppDbData[$index]['USR_UID'],'DEL_INDEX' => $allAppDbData[$index]['DEL_INDEX']
+ );
+ }
+
+ $participatedUsersCompletedByUser = array ();
+ $indexes = $this->aaSearchRecords( $allAppDbData, array ('APP_STATUS' => 'COMPLETED'
+ ) );
+ foreach ($indexes as $index) {
+ $participatedUsersCompletedByUser[] = array ('USR_UID' => $allAppDbData[$index]['USR_UID'],'DEL_INDEX' => $allAppDbData[$index]['DEL_INDEX']
+ );
+ }
+ // search information of unassigned users
+ // the unassigned users are the self service users and groups.
+ // the self service users are defined in the TASKs of the PROCESS.
+ $unassignedUsers = array ();
+ $unassignedGroups = array ();
+ //filter only the delegations that are in selfservice status
+ // `USR_UID` = '' AND `DEL_FINISH_DATE` IS NULL
+ $indexes = $this->aaSearchRecords( $allAppDbData, array ('USR_UID' => 'NULL','DEL_FINISH_DATE' => 'NULL','APP_THREAD_STATUS' => 'OPEN'
+ ) );
+ foreach ($indexes as $index) {
+ $unassignedUsersGroups = array ();
+ // use cache
+ $oMemcache = PMmemcached::getSingleton( $this->_solrInstance );
+ $unassignedUsersGroups = $oMemcache->get( $allAppDbData[$index]['PRO_UID'] . "_" . $allAppDbData[$index]['TAS_UID'] );
+ if (! $unassignedUsersGroups) {
+
+ $unassignedUsersGroups = $this->getTaskUnassignedUsersGroupsData( $allAppDbData[$index]['PRO_UID'], $allAppDbData[$index]['TAS_UID'] );
+
+ // if the task has unassigned users or groups add del_index of delegation
+ foreach ($unassignedUsersGroups as $i => $newRow) {
+ $unassignedUsersGroups[$i]['DEL_INDEX'] = $allAppDbData[$index]['DEL_INDEX'];
+ }
+ // store in cache
+ $oMemcache->set( $allAppDbData[$index]['PRO_UID'] . "_" . $allAppDbData[$index]['TAS_UID'], $unassignedUsersGroups );
+ }
+
+ // copy list of unassigned users and groups
+ foreach ($unassignedUsersGroups as $unassignedUserGroup) {
+ //unassigned users
+ if ($unassignedUserGroup['TU_RELATION'] == 1) {
+ $unassignedUsers[] = array ('USR_UID' => $unassignedUserGroup['USR_UID'],'DEL_INDEX' => $unassignedUserGroup['DEL_INDEX']
+ );
+ } //unassigned groups
+ elseif ($unassignedUserGroup['TU_RELATION'] == 2) {
+ $unassignedGroups[] = array ('USR_UID' => $unassignedUserGroup['USR_UID'],'DEL_INDEX' => $unassignedUserGroup['DEL_INDEX']
+ );
+ }
+ }
+
+ }
+ // Get DataTypes of dynaforms
+ // use cache array to store the dynaform variables per process
+ // use memory array to store information of Datatypes of Dynaforms
+ // All the datatypes of the process => all variables in all dynaforms in the
+ // process
+ $dynaformFieldTypes = array ();
+
+ // get cache instance
+ $oMemcache = PMmemcached::getSingleton( $this->_solrInstance );
+ $dynaformFieldTypes = $oMemcache->get( $documentInformation['PRO_UID'] );
+ if (! $dynaformFieldTypes) {
+ G::LoadClass( 'dynaformhandler' );
+ $dynaformFileNames = $this->getProcessDynaformFileNames( $documentInformation['PRO_UID'] );
+ $dynaformFields = array ();
+ foreach ($dynaformFileNames as $dynaformFileName) {
+ if (is_file( PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName['DYN_FILENAME'] . '.xml' ) && filesize( PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName['DYN_FILENAME'] . '.xml' ) > 0) {
+ $dyn = new dynaFormHandler( PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName['DYN_FILENAME'] . '.xml' );
+ $dynaformFields[] = $dyn->getFields();
+ }
+ if (is_file( PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName['DYN_FILENAME'] . '.xml' ) && filesize( PATH_DATA . '/sites/workflow/xmlForms/' . $dynaformFileName['DYN_FILENAME'] . '.xml' ) == 0) {
+
+ throw new ApplicationWithCorruptDynaformException( "Application with corrupt dynaform. APP_UID: " . $AppUID . "\n" );
+ }
+ }
+
+ foreach ($dynaformFields as $aDynFormFields) {
+ foreach ($aDynFormFields as $field) {
+ // create array of fields and types
+ if ($field->getAttribute( 'validate' ) == 'Int') {
+ $dynaformFieldTypes[$field->nodeName] = 'Int';
+ } elseif ($field->getAttribute( 'validate' ) == 'Real') {
+ $dynaformFieldTypes[$field->nodeName] = 'Real';
+ } else {
+ $dynaformFieldTypes[$field->nodeName] = $field->getAttribute( 'type' );
+ }
+ }
+ }
+ // create cache of dynaformfields
+ $oMemcache->set( $documentInformation['PRO_UID'], $dynaformFieldTypes );
+ }
+ // return result values
+ $result = array ($documentInformation,$dynaformFieldTypes,$lastUpdateDate,$maxPriority,$assignedUsers,$assignedUsersRead,$assignedUsersUnread,$draftUser,$participatedUsers,$participatedUsersStartedByUser,$participatedUsersCompletedByUser,$unassignedUsers,$unassignedGroups
+ );
+
+ return $result;
+ }
+
+ /**
+ * Find the maximun value of the specified column in the array and return the
+ * row index
+ *
+ * @param array $arr array of arrays with the data
+ * @param string $column column name to search in
+ * @param string $columnType column type STRING, NUMBER, DATE
+ * @param string $columnCondition column condition
+ * @param string $condition the condition
+ * @return integer The index of the maximun record in array
+ */
+ public function aaGetMaximun ($arr, $column, $columnType = 'STRING', $columnCondition = "", $condition = "")
+ {
+ // get first value
+ $auxValue = $arr[0][$column];
+ $index = null;
+ foreach ($arr as $i => $row) {
+ switch ($columnType) {
+ case 'STRING':
+ if ((strnatcmp( $row[$column], $auxValue ) >= 0) && (($columnCondition == "") || ($row[$columnCondition] == $condition))) {
+ $auxValue = $row[$column];
+ $index = $i;
+ }
+ break;
+ case 'NUMBER':
+ if (($row[$column] >= $auxValue) && (($columnCondition == "") || ($row[$columnCondition] == $condition))) {
+ $auxValue = $row[$column];
+ $index = $i;
+ }
+ break;
+ case 'DATE':
+ if ((strtotime( $row[$column] ) >= strtotime( $auxValue )) && (($columnCondition == "") || ($row[$columnCondition] == $condition))) {
+ $auxValue = $row[$column];
+ $index = $i;
+ }
+ break;
+ }
+ }
+ return $index;
+ }
+
+ /**
+ * Get minimum of array of arrays
+ *
+ * @param array $arr array of arrays with the data
+ * @param string $column the name of the column to search in
+ * @param string $columnType the column type STRING, NUMBER, DATE
+ * @param string $columnCondition the column condition
+ * @param string $condition the condition
+ * @return Ambigous Index of the minimun value found
+ */
+ public function aaGetMinimun ($arr, $column, $columnType = 'STRING', $columnCondition = "", $condition = "")
+ {
+ // get first value
+ $auxValue = $arr[0][$column];
+ $index = null;
+ foreach ($arr as $i => $row) {
+ switch ($columnType) {
+ case 'STRING':
+ if ((strnatcmp( $row[$column], $auxValue ) <= 0) && (($columnCondition == "") || ($row[$columnCondition] == $condition))) {
+ $auxValue = $row[$column];
+ $index = $i;
+ }
+ break;
+ case 'NUMBER':
+ if (($row[$column] <= $auxValue) && (($columnCondition == "") || ($row[$columnCondition] == $condition))) {
+ $auxValue = $row[$column];
+ $index = $i;
+ }
+ break;
+ case 'DATE':
+ if ((strtotime( $row[$column] ) <= strtotime( $auxValue )) && (($columnCondition == "") || ($row[$columnCondition] == $condition))) {
+ $auxValue = $row[$column];
+ $index = $i;
+
+ }
+ break;
+ }
+ }
+ return $index;
+ }
+
+ /**
+ * Search array of indexes that fullfill the conditions
+ *
+ * @param array of arrays $arr contains the arrays that are searched
+ * @param array $andColumnsConditions contain the conditions that must fullfill 'Column'=>'Condition'
+ * @return array of indexes with the found records
+ */
+ public function aaSearchRecords ($arr, $andColumnsConditions)
+ {
+ $indexes = array ();
$isEqual = true;
- if ($valueCondition == 'NULL') {
- $isEqual = true;
- $condition = '';
- }
- if ($valueCondition == 'NOTNULL') {
- $isEqual = false;
- $condition = '';
- }
- if ($isEqual) {
- if ($row [$column] == $condition) {
- $evaluateRow = true;
- }
- else {
+ foreach ($arr as $i => $row) {
$evaluateRow = false;
- breaK;
- }
+ // evaluate each row
+ foreach ($andColumnsConditions as $column => $valueCondition) {
+ $condition = $valueCondition;
+ $isEqual = true;
+ if ($valueCondition == 'NULL') {
+ $isEqual = true;
+ $condition = '';
+ }
+ if ($valueCondition == 'NOTNULL') {
+ $isEqual = false;
+ $condition = '';
+ }
+ if ($isEqual) {
+ if ($row[$column] == $condition) {
+ $evaluateRow = true;
+ } else {
+ $evaluateRow = false;
+ breaK;
+ }
+ } else {
+ if ($row[$column] != $condition) {
+ $evaluateRow = true;
+ } else {
+ $evaluateRow = false;
+ breaK;
+ }
+ }
+ }
+ // add row to indexes
+ if ($evaluateRow) {
+ $indexes[] = $i;
+ }
}
- else {
- if ($row [$column] != $condition) {
- $evaluateRow = true;
- }
- else {
- $evaluateRow = false;
- breaK;
- }
+ return $indexes;
+ }
+
+ /**
+ * Get application and delegation data from database
+ *
+ * @param string $AppUID the application identifier
+ * @return array of records from database
+ */
+ public function getApplicationDelegationData ($AppUID)
+ {
+
+ $allAppDbData = array ();
+
+ $c = new Criteria();
+
+ $c->addSelectColumn( ApplicationPeer::APP_UID );
+ $c->addSelectColumn( ApplicationPeer::APP_NUMBER );
+ $c->addSelectColumn( ApplicationPeer::APP_STATUS );
+ $c->addSelectColumn( ApplicationPeer::PRO_UID );
+ $c->addSelectColumn( ApplicationPeer::APP_CREATE_DATE );
+ $c->addSelectColumn( ApplicationPeer::APP_FINISH_DATE );
+ $c->addSelectColumn( ApplicationPeer::APP_UPDATE_DATE );
+ $c->addSelectColumn( ApplicationPeer::APP_DATA );
+
+ $c->addAsColumn( 'APP_TITLE', 'capp.CON_VALUE' );
+ $c->addAsColumn( 'PRO_TITLE', 'cpro.CON_VALUE' );
+
+ $c->addSelectColumn( 'ad.DEL_INDEX' );
+ $c->addSelectColumn( 'ad.DEL_PREVIOUS' );
+ $c->addSelectColumn( 'ad.TAS_UID' );
+ $c->addSelectColumn( 'ad.USR_UID' );
+ $c->addSelectColumn( 'ad.DEL_TYPE' );
+ $c->addSelectColumn( 'ad.DEL_THREAD' );
+ $c->addSelectColumn( 'ad.DEL_THREAD_STATUS' );
+ $c->addSelectColumn( 'ad.DEL_PRIORITY' );
+ $c->addSelectColumn( 'ad.DEL_DELEGATE_DATE' );
+ $c->addSelectColumn( 'ad.DEL_INIT_DATE' );
+ $c->addSelectColumn( 'ad.DEL_TASK_DUE_DATE' );
+ $c->addSelectColumn( 'ad.DEL_FINISH_DATE' );
+ $c->addSelectColumn( 'ad.DEL_DURATION' );
+ $c->addSelectColumn( 'ad.DEL_QUEUE_DURATION' );
+ $c->addSelectColumn( 'ad.DEL_DELAY_DURATION' );
+ $c->addSelectColumn( 'ad.DEL_STARTED' );
+ $c->addSelectColumn( 'ad.DEL_FINISHED' );
+ $c->addSelectColumn( 'ad.DEL_DELAYED' );
+ $c->addSelectColumn( 'ad.APP_OVERDUE_PERCENTAGE' );
+
+ $c->addSelectColumn( 'at.APP_THREAD_INDEX' );
+ $c->addSelectColumn( 'at.APP_THREAD_PARENT' );
+ $c->addSelectColumn( 'at.APP_THREAD_STATUS' );
+
+ $c->addAlias( 'capp', 'CONTENT' );
+ $c->addAlias( 'cpro', 'CONTENT' );
+ $c->addAlias( 'ad', 'APP_DELEGATION' );
+ $c->addAlias( 'at', 'APP_THREAD' );
+
+ $aConditions = array ();
+ $aConditions[] = array (ApplicationPeer::APP_UID,'capp.CON_ID'
+ );
+ $aConditions[] = array ('capp.CON_CATEGORY',DBAdapter::getStringDelimiter() . 'APP_TITLE' . DBAdapter::getStringDelimiter()
+ );
+ $aConditions[] = array ('capp.CON_LANG',DBAdapter::getStringDelimiter() . 'en' . DBAdapter::getStringDelimiter()
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $aConditions = array ();
+ $aConditions[] = array (ApplicationPeer::PRO_UID,'cpro.CON_ID'
+ );
+ $aConditions[] = array ('cpro.CON_CATEGORY',DBAdapter::getStringDelimiter() . 'PRO_TITLE' . DBAdapter::getStringDelimiter()
+ );
+ $aConditions[] = array ('cpro.CON_LANG',DBAdapter::getStringDelimiter() . 'en' . DBAdapter::getStringDelimiter()
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $c->addJoin( ApplicationPeer::APP_UID, 'ad.APP_UID', Criteria::JOIN );
+
+ $aConditions = array ();
+ $aConditions[] = array ('ad.APP_UID','at.APP_UID'
+ );
+ $aConditions[] = array ('ad.DEL_THREAD','at.APP_THREAD_INDEX'
+ );
+ $c->addJoinMC( $aConditions, Criteria::JOIN );
+
+ $c->add( ApplicationPeer::APP_UID, $AppUID );
+
+ $rs = ApplicationPeer::doSelectRS( $c );
+ $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+
+ $rs->next();
+ $row = $rs->getRow();
+
+ while (is_array( $row )) {
+ $allAppDbData[] = $row;
+ $rs->next();
+ $row = $rs->getRow();
}
- }
- // add row to indexes
- if ($evaluateRow) {
- $indexes [] = $i;
- }
+ return $allAppDbData;
}
- return $indexes;
- }
-
- /**
- * Get application and delegation data from database
- *
- * @param string $AppUID
- * the application identifier
- * @return array of records from database
- */
- public function getApplicationDelegationData($AppUID)
- {
-
- $allAppDbData = array ();
-
- $c = new Criteria ();
-
- $c->addSelectColumn (ApplicationPeer::APP_UID);
- $c->addSelectColumn (ApplicationPeer::APP_NUMBER);
- $c->addSelectColumn (ApplicationPeer::APP_STATUS);
- $c->addSelectColumn (ApplicationPeer::PRO_UID);
- $c->addSelectColumn (ApplicationPeer::APP_CREATE_DATE);
- $c->addSelectColumn (ApplicationPeer::APP_FINISH_DATE);
- $c->addSelectColumn (ApplicationPeer::APP_UPDATE_DATE);
- $c->addSelectColumn (ApplicationPeer::APP_DATA);
-
- $c->addAsColumn ('APP_TITLE', 'capp.CON_VALUE');
- $c->addAsColumn ('PRO_TITLE', 'cpro.CON_VALUE');
-
- $c->addSelectColumn ('ad.DEL_INDEX');
- $c->addSelectColumn ('ad.DEL_PREVIOUS');
- $c->addSelectColumn ('ad.TAS_UID');
- $c->addSelectColumn ('ad.USR_UID');
- $c->addSelectColumn ('ad.DEL_TYPE');
- $c->addSelectColumn ('ad.DEL_THREAD');
- $c->addSelectColumn ('ad.DEL_THREAD_STATUS');
- $c->addSelectColumn ('ad.DEL_PRIORITY');
- $c->addSelectColumn ('ad.DEL_DELEGATE_DATE');
- $c->addSelectColumn ('ad.DEL_INIT_DATE');
- $c->addSelectColumn ('ad.DEL_TASK_DUE_DATE');
- $c->addSelectColumn ('ad.DEL_FINISH_DATE');
- $c->addSelectColumn ('ad.DEL_DURATION');
- $c->addSelectColumn ('ad.DEL_QUEUE_DURATION');
- $c->addSelectColumn ('ad.DEL_DELAY_DURATION');
- $c->addSelectColumn ('ad.DEL_STARTED');
- $c->addSelectColumn ('ad.DEL_FINISHED');
- $c->addSelectColumn ('ad.DEL_DELAYED');
- $c->addSelectColumn ('ad.APP_OVERDUE_PERCENTAGE');
-
- $c->addSelectColumn ('at.APP_THREAD_INDEX');
- $c->addSelectColumn ('at.APP_THREAD_PARENT');
- $c->addSelectColumn ('at.APP_THREAD_STATUS');
-
- $c->addAlias ('capp', 'CONTENT');
- $c->addAlias ('cpro', 'CONTENT');
- $c->addAlias ('ad', 'APP_DELEGATION');
- $c->addAlias ('at', 'APP_THREAD');
-
- $aConditions = array ();
- $aConditions [] = array (
- ApplicationPeer::APP_UID,
- 'capp.CON_ID'
- );
- $aConditions [] = array (
- 'capp.CON_CATEGORY',
- DBAdapter::getStringDelimiter () . 'APP_TITLE' . DBAdapter::getStringDelimiter ()
- );
- $aConditions [] = array (
- 'capp.CON_LANG',
- DBAdapter::getStringDelimiter () . 'en' . DBAdapter::getStringDelimiter ()
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $aConditions = array ();
- $aConditions [] = array (
- ApplicationPeer::PRO_UID,
- 'cpro.CON_ID'
- );
- $aConditions [] = array (
- 'cpro.CON_CATEGORY',
- DBAdapter::getStringDelimiter () . 'PRO_TITLE' . DBAdapter::getStringDelimiter ()
- );
- $aConditions [] = array (
- 'cpro.CON_LANG',
- DBAdapter::getStringDelimiter () . 'en' . DBAdapter::getStringDelimiter ()
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $c->addJoin (ApplicationPeer::APP_UID, 'ad.APP_UID', Criteria::JOIN);
-
- $aConditions = array ();
- $aConditions [] = array (
- 'ad.APP_UID',
- 'at.APP_UID'
- );
- $aConditions [] = array (
- 'ad.DEL_THREAD',
- 'at.APP_THREAD_INDEX'
- );
- $c->addJoinMC ($aConditions, Criteria::JOIN);
-
- $c->add (ApplicationPeer::APP_UID, $AppUID);
-
- $rs = ApplicationPeer::doSelectRS ($c);
- $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
-
- $rs->next ();
- $row = $rs->getRow ();
-
- while (is_array ($row)) {
- $allAppDbData [] = $row;
- $rs->next ();
- $row = $rs->getRow ();
- }
- return $allAppDbData;
- }
-
- /**
- * Get application and delegation data from database
- *
- * @param string $aAppUID
- * array of application identifiers
- * @return array of array of records from database
- */
- public function getListApplicationUpdateDelegationData($aaAppUIDs)
- {
-
- $allAppDbData = array ();
-
- $c = new Criteria ();
-
- $c->addSelectColumn (ApplicationPeer::APP_UID);
- $c->addSelectColumn (ApplicationPeer::APP_NUMBER);
- $c->addSelectColumn (ApplicationPeer::APP_STATUS);
- $c->addSelectColumn (ApplicationPeer::PRO_UID);
- $c->addSelectColumn (ApplicationPeer::APP_CREATE_DATE);
- $c->addSelectColumn (ApplicationPeer::APP_FINISH_DATE);
- $c->addSelectColumn (ApplicationPeer::APP_UPDATE_DATE);
- $c->addSelectColumn (ApplicationPeer::APP_DATA);
-
- $c->addAsColumn ('APP_TITLE', 'capp.CON_VALUE');
- $c->addAsColumn ('PRO_TITLE', 'cpro.CON_VALUE');
-
- $c->addSelectColumn ('ad.DEL_INDEX');
- $c->addSelectColumn ('ad.DEL_PREVIOUS');
- $c->addSelectColumn ('ad.TAS_UID');
- $c->addSelectColumn ('ad.USR_UID');
- $c->addSelectColumn ('ad.DEL_TYPE');
- $c->addSelectColumn ('ad.DEL_THREAD');
- $c->addSelectColumn ('ad.DEL_THREAD_STATUS');
- $c->addSelectColumn ('ad.DEL_PRIORITY');
- $c->addSelectColumn ('ad.DEL_DELEGATE_DATE');
- $c->addSelectColumn ('ad.DEL_INIT_DATE');
- $c->addSelectColumn ('ad.DEL_TASK_DUE_DATE');
- $c->addSelectColumn ('ad.DEL_FINISH_DATE');
- $c->addSelectColumn ('ad.DEL_DURATION');
- $c->addSelectColumn ('ad.DEL_QUEUE_DURATION');
- $c->addSelectColumn ('ad.DEL_DELAY_DURATION');
- $c->addSelectColumn ('ad.DEL_STARTED');
- $c->addSelectColumn ('ad.DEL_FINISHED');
- $c->addSelectColumn ('ad.DEL_DELAYED');
- $c->addSelectColumn ('ad.APP_OVERDUE_PERCENTAGE');
-
- $c->addSelectColumn ('at.APP_THREAD_INDEX');
- $c->addSelectColumn ('at.APP_THREAD_PARENT');
- $c->addSelectColumn ('at.APP_THREAD_STATUS');
-
- $c->addAlias ('capp', 'CONTENT');
- $c->addAlias ('cpro', 'CONTENT');
- $c->addAlias ('ad', 'APP_DELEGATION');
- $c->addAlias ('at', 'APP_THREAD');
-
- $aConditions = array ();
- $aConditions [] = array (
- ApplicationPeer::APP_UID,
- 'capp.CON_ID'
- );
- $aConditions [] = array (
- 'capp.CON_CATEGORY',
- DBAdapter::getStringDelimiter () . 'APP_TITLE' . DBAdapter::getStringDelimiter ()
- );
- $aConditions [] = array (
- 'capp.CON_LANG',
- DBAdapter::getStringDelimiter () . 'en' . DBAdapter::getStringDelimiter ()
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $aConditions = array ();
- $aConditions [] = array (
- ApplicationPeer::PRO_UID,
- 'cpro.CON_ID'
- );
- $aConditions [] = array (
- 'cpro.CON_CATEGORY',
- DBAdapter::getStringDelimiter () . 'PRO_TITLE' . DBAdapter::getStringDelimiter ()
- );
- $aConditions [] = array (
- 'cpro.CON_LANG',
- DBAdapter::getStringDelimiter () . 'en' . DBAdapter::getStringDelimiter ()
- );
- $c->addJoinMC ($aConditions, Criteria::LEFT_JOIN);
-
- $c->addJoin (ApplicationPeer::APP_UID, 'ad.APP_UID', Criteria::JOIN);
-
- $aConditions = array ();
- $aConditions [] = array (
- 'ad.APP_UID',
- 'at.APP_UID'
- );
- $aConditions [] = array (
- 'ad.DEL_THREAD',
- 'at.APP_THREAD_INDEX'
- );
- $c->addJoinMC ($aConditions, Criteria::JOIN);
-
- $c->add (ApplicationPeer::APP_UID, $aaAppUIDs, Criteria::IN);
-
- $rs = ApplicationPeer::doSelectRS ($c);
- $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
-
- $rs->next ();
- $row = $rs->getRow ();
-
- while (is_array ($row)) {
- $allAppDbData [] = $row;
- $rs->next ();
- $row = $rs->getRow ();
- }
- return $allAppDbData;
- }
-
- /**
- * Get the list of groups of unassigned users of the specified task from
- * database
- *
- * @param string $ProUID
- * Process identifier
- * @param string $TaskUID
- * task identifier
- * @return array of unassigned user groups
- */
- public function getTaskUnassignedUsersGroupsData($ProUID, $TaskUID)
- {
- $unassignedUsersGroups = array ();
-
- $c = new Criteria ();
-
- $c->addSelectColumn (TaskUserPeer::USR_UID);
- $c->addSelectColumn (TaskUserPeer::TU_RELATION);
-
- $aConditions = array ();
- $aConditions [] = array (
- TaskPeer::TAS_UID,
- TaskUserPeer::TAS_UID
- );
- $aConditions [] = array (
- TaskPeer::TAS_ASSIGN_TYPE,
- DBAdapter::getStringDelimiter () . 'SELF_SERVICE' . DBAdapter::getStringDelimiter ()
- );
- $c->addJoinMC ($aConditions, Criteria::JOIN);
-
- $c->add (TaskPeer::PRO_UID, $ProUID);
- $c->add (TaskPeer::TAS_UID, $TaskUID);
-
- $rs = TaskPeer::doSelectRS ($c);
- $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
- // echo $c->toString();
- $rs->next ();
- $row = $rs->getRow ();
-
- while (is_array ($row)) {
- $unassignedUsersGroups [] = $row;
- $rs->next ();
- $row = $rs->getRow ();
- }
-
- return $unassignedUsersGroups;
- }
-
- /**
- * Get the list of dynaform file names associated with the specified process
- * from database
- *
- * @param string $ProUID
- * process identifier
- * @return array of dynaform file names
- */
- public function getProcessDynaformFileNames($ProUID)
- {
- $dynaformFileNames = array ();
-
- $c = new Criteria ();
-
- $c->addSelectColumn (DynaformPeer::DYN_FILENAME);
-
- $c->add (DynaformPeer::PRO_UID, $ProUID);
-
- $rs = DynaformPeer::doSelectRS ($c);
- $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
- $rs->next ();
- $row = $rs->getRow ();
-
- while (is_array ($row)) {
- $dynaformFileNames [] = $row;
- $rs->next ();
- $row = $rs->getRow ();
- }
-
- return $dynaformFileNames;
- }
-
- /**
- * Store a flag indicating if the application was updated in database
- * table APP_SOLR_QUEUE
- *
- * @param string $AppUid
- * applicatiom identifier
- * @param integer $updated
- * 0:false, not updated, 1: updated, 2:deleted
- */
- public function applicationChangedUpdateSolrQueue($AppUid, $updated)
- {
- $oAppSolrQueue = new AppSolrQueue ();
-
- $oAppSolrQueue->createUpdate ($AppUid, $updated);
- }
-
- /**
- * Update application records in Solr that are stored in APP_SOLR_QUEUE table
- */
- public function synchronizePendingApplications()
- {
- // check table of pending updates
- $oAppSolrQueue = new AppSolrQueue ();
-
- $aAppSolrQueue = $oAppSolrQueue->getListUpdatedApplications ();
-
- foreach ($aAppSolrQueue as $oAppSolrQueueEntity) {
- // call the syncronization function
- if($oAppSolrQueueEntity->appUpdated == 1){
- $this->updateApplicationSearchIndex ($oAppSolrQueueEntity->appUid);
- }
- if($oAppSolrQueueEntity->appUpdated == 2){
- $this->deleteApplicationSearchIndex ($oAppSolrQueueEntity->appUid);
- }
- $this->applicationChangedUpdateSolrQueue ($oAppSolrQueueEntity->appUid, 0);
- }
- }
-
- /**
- * Get the total number of application records in database
- *
- * @return integer application counter
- */
- public function getCountApplicationsPMOS2()
- {
- $c = new Criteria ();
-
- $c->addSelectColumn (ApplicationPeer::APP_UID);
-
- $count = ApplicationPeer::doCount ($c);
-
- return $count;
- }
-
- /**
- * Get the total number of application records in search index
- *
- * @return integer application counter
- */
- public function getCountApplicationsSearchIndex()
- {
- G::LoadClass ('searchIndex');
-
- $searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
- // execute query
- $count = $searchIndex->getNumberDocuments ($this->_solrInstance);
-
- return $count;
- }
-
- /**
- * Optimize the records in search index
- *
- * @return
- */
- public function optimizeSearchIndex()
- {
- G::LoadClass ('searchIndex');
-
- $searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
- // execute query
- $searchIndex->optimizeIndexChanges ($this->_solrInstance);
-
- }
-
- /**
- * Get a paginated list of application uids from database.
- *
- * @param integer $skip
- * the offset from where to return the application records
- * @param integer $pagesize
- * the size of the page
- * @return array of application id's in the specified page.
- */
- public function getPagedApplicationUids($skip, $pagesize)
- {
-
- $c = new Criteria ();
-
- $c->addSelectColumn (ApplicationPeer::APP_UID);
- $c->setOffset ($skip);
- $c->setLimit ($pagesize);
-
- $rs = ApplicationPeer::doSelectRS ($c);
- $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
-
- $rs->next ();
- $row = $rs->getRow ();
- $appUIds = array ();
- while (is_array ($row)) {
- $appUIds [] = $row;
- $rs->next ();
- $row = $rs->getRow ();
- }
- return $appUIds;
- }
-
- /**
- * Reindex all the application records in Solr server
- * update applications in groups of 1000
- */
- public function reindexAllApplications($SkipRecords = 0, $indexTrunkSize = 1000)
- {
- $trunk = $indexTrunkSize;
- // delete all documents to begin reindex
- // deleteAllDocuments();
- // commitChanges();
- // print "Deleted all documents \n";
- // search trunks of id's to regenerate index
- $numRows = $this->getCountApplicationsPMOS2 ();
- print "Total number of records: " . $numRows . "\n";
- //
- $initTimeAll = microtime (true);
- for ($skip = $SkipRecords; $skip <= $numRows;) {
- $aaAPPUIds = $this->getPagedApplicationUids ($skip, $trunk);
-
- printf ("Indexing %d to %d \n", $skip, $skip + $trunk);
- $initTimeDoc = microtime (true);
- $this->updateApplicationSearchIndex ($aaAPPUIds);
-
- $curTimeDoc = gmdate ('H:i:s', (microtime (true) - $initTimeDoc));
- printf ("Indexing document time: %s \n", $curTimeDoc);
- $skip += $trunk;
- }
-
- $curTimeDoc = gmdate ('H:i:s', (microtime (true) - $initTimeAll));
- printf ("Total reindex time: %s \n", $curTimeDoc);
- printf ("Reindex completed successfully!!.\n");
- }
+ /**
+ * Get application and delegation data from database
+ *
+ * @param string $aAppUID array of application identifiers
+ * @return array of array of records from database
+ */
+ public function getListApplicationUpdateDelegationData ($aaAppUIDs)
+ {
+ $allAppDbData = array ();
+
+ $c = new Criteria();
+
+ $c->addSelectColumn( ApplicationPeer::APP_UID );
+ $c->addSelectColumn( ApplicationPeer::APP_NUMBER );
+ $c->addSelectColumn( ApplicationPeer::APP_STATUS );
+ $c->addSelectColumn( ApplicationPeer::PRO_UID );
+ $c->addSelectColumn( ApplicationPeer::APP_CREATE_DATE );
+ $c->addSelectColumn( ApplicationPeer::APP_FINISH_DATE );
+ $c->addSelectColumn( ApplicationPeer::APP_UPDATE_DATE );
+ $c->addSelectColumn( ApplicationPeer::APP_DATA );
+
+ $c->addAsColumn( 'APP_TITLE', 'capp.CON_VALUE' );
+ $c->addAsColumn( 'PRO_TITLE', 'cpro.CON_VALUE' );
+
+ $c->addSelectColumn( 'ad.DEL_INDEX' );
+ $c->addSelectColumn( 'ad.DEL_PREVIOUS' );
+ $c->addSelectColumn( 'ad.TAS_UID' );
+ $c->addSelectColumn( 'ad.USR_UID' );
+ $c->addSelectColumn( 'ad.DEL_TYPE' );
+ $c->addSelectColumn( 'ad.DEL_THREAD' );
+ $c->addSelectColumn( 'ad.DEL_THREAD_STATUS' );
+ $c->addSelectColumn( 'ad.DEL_PRIORITY' );
+ $c->addSelectColumn( 'ad.DEL_DELEGATE_DATE' );
+ $c->addSelectColumn( 'ad.DEL_INIT_DATE' );
+ $c->addSelectColumn( 'ad.DEL_TASK_DUE_DATE' );
+ $c->addSelectColumn( 'ad.DEL_FINISH_DATE' );
+ $c->addSelectColumn( 'ad.DEL_DURATION' );
+ $c->addSelectColumn( 'ad.DEL_QUEUE_DURATION' );
+ $c->addSelectColumn( 'ad.DEL_DELAY_DURATION' );
+ $c->addSelectColumn( 'ad.DEL_STARTED' );
+ $c->addSelectColumn( 'ad.DEL_FINISHED' );
+ $c->addSelectColumn( 'ad.DEL_DELAYED' );
+ $c->addSelectColumn( 'ad.APP_OVERDUE_PERCENTAGE' );
+
+ $c->addSelectColumn( 'at.APP_THREAD_INDEX' );
+ $c->addSelectColumn( 'at.APP_THREAD_PARENT' );
+ $c->addSelectColumn( 'at.APP_THREAD_STATUS' );
+
+ $c->addAlias( 'capp', 'CONTENT' );
+ $c->addAlias( 'cpro', 'CONTENT' );
+ $c->addAlias( 'ad', 'APP_DELEGATION' );
+ $c->addAlias( 'at', 'APP_THREAD' );
+
+ $aConditions = array ();
+ $aConditions[] = array (ApplicationPeer::APP_UID,'capp.CON_ID'
+ );
+ $aConditions[] = array ('capp.CON_CATEGORY',DBAdapter::getStringDelimiter() . 'APP_TITLE' . DBAdapter::getStringDelimiter()
+ );
+ $aConditions[] = array ('capp.CON_LANG',DBAdapter::getStringDelimiter() . 'en' . DBAdapter::getStringDelimiter()
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $aConditions = array ();
+ $aConditions[] = array (ApplicationPeer::PRO_UID,'cpro.CON_ID'
+ );
+ $aConditions[] = array ('cpro.CON_CATEGORY',DBAdapter::getStringDelimiter() . 'PRO_TITLE' . DBAdapter::getStringDelimiter()
+ );
+ $aConditions[] = array ('cpro.CON_LANG',DBAdapter::getStringDelimiter() . 'en' . DBAdapter::getStringDelimiter()
+ );
+ $c->addJoinMC( $aConditions, Criteria::LEFT_JOIN );
+
+ $c->addJoin( ApplicationPeer::APP_UID, 'ad.APP_UID', Criteria::JOIN );
+
+ $aConditions = array ();
+ $aConditions[] = array ('ad.APP_UID','at.APP_UID'
+ );
+ $aConditions[] = array ('ad.DEL_THREAD','at.APP_THREAD_INDEX'
+ );
+ $c->addJoinMC( $aConditions, Criteria::JOIN );
+
+ $c->add( ApplicationPeer::APP_UID, $aaAppUIDs, Criteria::IN );
+
+ $rs = ApplicationPeer::doSelectRS( $c );
+ $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+
+ $rs->next();
+ $row = $rs->getRow();
+
+ while (is_array( $row )) {
+ $allAppDbData[] = $row;
+ $rs->next();
+ $row = $rs->getRow();
+ }
+ return $allAppDbData;
+ }
+
+ /**
+ * Get the list of groups of unassigned users of the specified task from
+ * database
+ *
+ * @param string $ProUID Process identifier
+ * @param string $TaskUID task identifier
+ * @return array of unassigned user groups
+ */
+ public function getTaskUnassignedUsersGroupsData ($ProUID, $TaskUID)
+ {
+ $unassignedUsersGroups = array ();
+
+ $c = new Criteria();
+
+ $c->addSelectColumn( TaskUserPeer::USR_UID );
+ $c->addSelectColumn( TaskUserPeer::TU_RELATION );
+
+ $aConditions = array ();
+ $aConditions[] = array (TaskPeer::TAS_UID,TaskUserPeer::TAS_UID
+ );
+ $aConditions[] = array (TaskPeer::TAS_ASSIGN_TYPE,DBAdapter::getStringDelimiter() . 'SELF_SERVICE' . DBAdapter::getStringDelimiter()
+ );
+ $c->addJoinMC( $aConditions, Criteria::JOIN );
+
+ $c->add( TaskPeer::PRO_UID, $ProUID );
+ $c->add( TaskPeer::TAS_UID, $TaskUID );
+
+ $rs = TaskPeer::doSelectRS( $c );
+ $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ // echo $c->toString();
+ $rs->next();
+ $row = $rs->getRow();
+
+ while (is_array( $row )) {
+ $unassignedUsersGroups[] = $row;
+ $rs->next();
+ $row = $rs->getRow();
+ }
+
+ return $unassignedUsersGroups;
+ }
+
+ /**
+ * Get the list of dynaform file names associated with the specified process
+ * from database
+ *
+ * @param string $ProUID process identifier
+ * @return array of dynaform file names
+ */
+ public function getProcessDynaformFileNames ($ProUID)
+ {
+ $dynaformFileNames = array ();
+
+ $c = new Criteria();
+
+ $c->addSelectColumn( DynaformPeer::DYN_FILENAME );
+
+ $c->add( DynaformPeer::PRO_UID, $ProUID );
+
+ $rs = DynaformPeer::doSelectRS( $c );
+ $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $rs->next();
+ $row = $rs->getRow();
+
+ while (is_array( $row )) {
+ $dynaformFileNames[] = $row;
+ $rs->next();
+ $row = $rs->getRow();
+ }
+
+ return $dynaformFileNames;
+ }
+
+ /**
+ * Store a flag indicating if the application was updated in database
+ * table APP_SOLR_QUEUE
+ *
+ * @param string $AppUid applicatiom identifier
+ * @param integer $updated 0:false, not updated, 1: updated, 2:deleted
+ */
+ public function applicationChangedUpdateSolrQueue ($AppUid, $updated)
+ {
+ $oAppSolrQueue = new AppSolrQueue();
+
+ $oAppSolrQueue->createUpdate( $AppUid, $updated );
+ }
+
+ /**
+ * Update application records in Solr that are stored in APP_SOLR_QUEUE table
+ */
+ public function synchronizePendingApplications ()
+ {
+ // check table of pending updates
+ $oAppSolrQueue = new AppSolrQueue();
+
+ $aAppSolrQueue = $oAppSolrQueue->getListUpdatedApplications();
+
+ foreach ($aAppSolrQueue as $oAppSolrQueueEntity) {
+ // call the syncronization function
+ if ($oAppSolrQueueEntity->appUpdated == 1) {
+ $this->updateApplicationSearchIndex( $oAppSolrQueueEntity->appUid );
+ }
+ if ($oAppSolrQueueEntity->appUpdated == 2) {
+ $this->deleteApplicationSearchIndex( $oAppSolrQueueEntity->appUid );
+ }
+ $this->applicationChangedUpdateSolrQueue( $oAppSolrQueueEntity->appUid, 0 );
+ }
+ }
+
+ /**
+ * Get the total number of application records in database
+ *
+ * @return integer application counter
+ */
+ public function getCountApplicationsPMOS2 ()
+ {
+ $c = new Criteria();
+
+ $c->addSelectColumn( ApplicationPeer::APP_UID );
+
+ $count = ApplicationPeer::doCount( $c );
+
+ return $count;
+ }
+
+ /**
+ * Get the total number of application records in search index
+ *
+ * @return integer application counter
+ */
+ public function getCountApplicationsSearchIndex ()
+ {
+ G::LoadClass( 'searchIndex' );
+
+ $searchIndex = new BpmnEngine_Services_SearchIndex( $this->_solrIsEnabled, $this->_solrHost );
+ // execute query
+ $count = $searchIndex->getNumberDocuments( $this->_solrInstance );
+
+ return $count;
+ }
+
+ /**
+ * Optimize the records in search index
+ *
+ * @return
+ *
+ */
+ public function optimizeSearchIndex ()
+ {
+ G::LoadClass( 'searchIndex' );
+
+ $searchIndex = new BpmnEngine_Services_SearchIndex( $this->_solrIsEnabled, $this->_solrHost );
+ // execute query
+ $searchIndex->optimizeIndexChanges( $this->_solrInstance );
+
+ }
+
+ /**
+ * Get a paginated list of application uids from database.
+ *
+ * @param integer $skip the offset from where to return the application records
+ * @param integer $pagesize the size of the page
+ * @return array of application id's in the specified page.
+ */
+ public function getPagedApplicationUids ($skip, $pagesize)
+ {
+
+ $c = new Criteria();
+
+ $c->addSelectColumn( ApplicationPeer::APP_UID );
+ $c->setOffset( $skip );
+ $c->setLimit( $pagesize );
+
+ $rs = ApplicationPeer::doSelectRS( $c );
+ $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+
+ $rs->next();
+ $row = $rs->getRow();
+ $appUIds = array ();
+ while (is_array( $row )) {
+ $appUIds[] = $row;
+ $rs->next();
+ $row = $rs->getRow();
+ }
+ return $appUIds;
+ }
+
+ /**
+ * Reindex all the application records in Solr server
+ * update applications in groups of 1000
+ */
+ public function reindexAllApplications ($SkipRecords = 0, $indexTrunkSize = 1000)
+ {
+ $trunk = $indexTrunkSize;
+ // delete all documents to begin reindex
+ // deleteAllDocuments();
+ // commitChanges();
+ // print "Deleted all documents \n";
+ // search trunks of id's to regenerate index
+ $numRows = $this->getCountApplicationsPMOS2();
+ print "Total number of records: " . $numRows . "\n";
+ $initTimeAll = microtime( true );
+
+ for ($skip = $SkipRecords; $skip <= $numRows; true) {
+ $aaAPPUIds = $this->getPagedApplicationUids( $skip, $trunk );
+
+ printf( "Indexing %d to %d \n", $skip, $skip + $trunk );
+ $initTimeDoc = microtime( true );
+ $this->updateApplicationSearchIndex( $aaAPPUIds );
+
+ $curTimeDoc = gmdate( 'H:i:s', (microtime( true ) - $initTimeDoc) );
+ printf( "Indexing document time: %s \n", $curTimeDoc );
+ $skip += $trunk;
+ }
+
+ $curTimeDoc = gmdate( 'H:i:s', (microtime( true ) - $initTimeAll) );
+ printf( "Total reindex time: %s \n", $curTimeDoc );
+ printf( "Reindex completed successfully!!.\n" );
+ }
}
+
diff --git a/workflow/engine/classes/class.processMap.php b/workflow/engine/classes/class.processMap.php
index fa2d39bfd..c737bf338 100755
--- a/workflow/engine/classes/class.processMap.php
+++ b/workflow/engine/classes/class.processMap.php
@@ -80,187 +80,186 @@ class processMap {
* @return string
*/
- public function load($sProcessUID, $bView = false, $sApplicationUID = '', $iDelegation = 0, $sTask = '', $bCT = false)
- {
- try {
- $oProcess = new Process ( );
+ function load($sProcessUID, $bView = false, $sApplicationUID = '', $iDelegation = 0, $sTask = '', $bCT = false) {
+ try {
+ $oProcess = new Process ( );
- $aRow = $oProcess->load($sProcessUID);
- $oPM->title->label = strip_tags($aRow ['PRO_TITLE']);
- $oPM->title->position->x = $aRow ['PRO_TITLE_X'];
- $oPM->title->position->y = $aRow ['PRO_TITLE_Y'];
- $oPM->task = array();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(TaskPeer::PRO_UID);
- $oCriteria->addSelectColumn(TaskPeer::TAS_UID);
- $oCriteria->addSelectColumn(ContentPeer::CON_VALUE);
- $oCriteria->addSelectColumn(TaskPeer::TAS_START);
- $oCriteria->addSelectColumn(TaskPeer::TAS_POSX);
- $oCriteria->addSelectColumn(TaskPeer::TAS_POSY);
- $oCriteria->addSelectColumn(TaskPeer::TAS_COLOR);
- $oCriteria->addSelectColumn(TaskPeer::TAS_TYPE);
- $aConditions = array();
- $aConditions [] = array(0 => TaskPeer::TAS_UID, 1 => ContentPeer::CON_ID);
- $aConditions [] = array(0 => ContentPeer::CON_CATEGORY, 1 => DBAdapter::getStringDelimiter () . 'TAS_TITLE' . DBAdapter::getStringDelimiter ());
- $aConditions [] = array(0 => ContentPeer::CON_LANG, 1 => DBAdapter::getStringDelimiter () . SYS_LANG . DBAdapter::getStringDelimiter ());
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(TaskPeer::PRO_UID, $sProcessUID);
- $oDataset = TaskPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow1 = $oDataset->getRow()) {
- $oTask = null;
- $oTask->uid = $aRow1 ['TAS_UID'];
- $oTask->task_type = $aRow1 ['TAS_TYPE'];
- if ($aRow1 ['TAS_TYPE'] == 'NORMAL') {
- if (($aRow1 ['CON_VALUE'] == "")) { //There is no Label in Current SYS_LANG language so try to find in English - by default
- $oTask1 = new Task ( );
- $aFields1 = $oTask1->load($oTask->uid);
- $aRow1 ['CON_VALUE'] = $oTask1->getTasTitle();
- }
- $oTask->label = strip_tags($aRow1 ['CON_VALUE']);
- } else {
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter ();
- $oCriteria->add(SubProcessPeer::PRO_PARENT, $aRow1 ['PRO_UID']);
- $oCriteria->add(SubProcessPeer::TAS_PARENT, $aRow1 ['TAS_UID']);
+ $aRow = $oProcess->load($sProcessUID);
+ $oPM->title->label = strip_tags($aRow ['PRO_TITLE']);
+ $oPM->title->position->x = $aRow ['PRO_TITLE_X'];
+ $oPM->title->position->y = $aRow ['PRO_TITLE_Y'];
+ $oPM->task = array();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(TaskPeer::PRO_UID);
+ $oCriteria->addSelectColumn(TaskPeer::TAS_UID);
+ $oCriteria->addSelectColumn(ContentPeer::CON_VALUE);
+ $oCriteria->addSelectColumn(TaskPeer::TAS_START);
+ $oCriteria->addSelectColumn(TaskPeer::TAS_POSX);
+ $oCriteria->addSelectColumn(TaskPeer::TAS_POSY);
+ $oCriteria->addSelectColumn(TaskPeer::TAS_COLOR);
+ $oCriteria->addSelectColumn(TaskPeer::TAS_TYPE);
+ $aConditions = array();
+ $aConditions [] = array(0 => TaskPeer::TAS_UID, 1 => ContentPeer::CON_ID);
+ $aConditions [] = array(0 => ContentPeer::CON_CATEGORY, 1 => DBAdapter::getStringDelimiter () . 'TAS_TITLE' . DBAdapter::getStringDelimiter ());
+ $aConditions [] = array(0 => ContentPeer::CON_LANG, 1 => DBAdapter::getStringDelimiter () . SYS_LANG . DBAdapter::getStringDelimiter ());
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(TaskPeer::PRO_UID, $sProcessUID);
+ $oDataset = TaskPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow1 = $oDataset->getRow()) {
+ $oTask = null;
+ $oTask->uid = $aRow1 ['TAS_UID'];
+ $oTask->task_type = $aRow1 ['TAS_TYPE'];
+ if ($aRow1 ['TAS_TYPE'] == 'NORMAL') {
+ if (($aRow1 ['CON_VALUE'] == "")) { //There is no Label in Current SYS_LANG language so try to find in English - by default
+ $oTask1 = new Task ( );
+ $aFields1 = $oTask1->load($oTask->uid);
+ $aRow1 ['CON_VALUE'] = $oTask1->getTasTitle();
+ }
+ $oTask->label = strip_tags($aRow1 ['CON_VALUE']);
+ } else {
+ $oCriteria = new Criteria('workflow');
+ $del = DBAdapter::getStringDelimiter ();
+ $oCriteria->add(SubProcessPeer::PRO_PARENT, $aRow1 ['PRO_UID']);
+ $oCriteria->add(SubProcessPeer::TAS_PARENT, $aRow1 ['TAS_UID']);
- $oCriteria->addAsColumn('TAS_TITLE', 'C1.CON_VALUE');
- $oCriteria->addAlias("C1", 'CONTENT');
- $tasTitleConds = array();
- $tasTitleConds [] = array(SubProcessPeer::TAS_PARENT, 'C1.CON_ID');
- $tasTitleConds [] = array('C1.CON_CATEGORY', $del . 'TAS_TITLE' . $del);
- $tasTitleConds [] = array('C1.CON_LANG', $del . SYS_LANG . $del);
- $oCriteria->addJoinMC($tasTitleConds, Criteria::LEFT_JOIN);
+ $oCriteria->addAsColumn('TAS_TITLE', 'C1.CON_VALUE');
+ $oCriteria->addAlias("C1", 'CONTENT');
+ $tasTitleConds = array();
+ $tasTitleConds [] = array(SubProcessPeer::TAS_PARENT, 'C1.CON_ID');
+ $tasTitleConds [] = array('C1.CON_CATEGORY', $del . 'TAS_TITLE' . $del);
+ $tasTitleConds [] = array('C1.CON_LANG', $del . SYS_LANG . $del);
+ $oCriteria->addJoinMC($tasTitleConds, Criteria::LEFT_JOIN);
- $oDatasetX = SubProcessPeer::doSelectRS($oCriteria);
- $oDatasetX->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDatasetX->next();
- $aRowx = $oDatasetX->getRow();
- if ($oProcess->exists($aRowx ['PRO_UID'])) {
- //$aRowy = $oProcess->load($aRowx['PRO_UID']);
- //$oTask->label = $aRowy['PRO_TITLE'];
- $oTask->label = $aRowx ['TAS_TITLE'];
- } else {
- $oTask->label = strip_tags($aRow1 ['CON_VALUE']);
- }
+ $oDatasetX = SubProcessPeer::doSelectRS($oCriteria);
+ $oDatasetX->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDatasetX->next();
+ $aRowx = $oDatasetX->getRow();
+ if ($oProcess->exists($aRowx ['PRO_UID'])) {
+ //$aRowy = $oProcess->load($aRowx['PRO_UID']);
+ //$oTask->label = $aRowy['PRO_TITLE'];
+ $oTask->label = $aRowx ['TAS_TITLE'];
+ } else {
+ $oTask->label = strip_tags($aRow1 ['CON_VALUE']);
+ }
+ }
+ $oTask->taskINI = (strtolower($aRow1 ['TAS_START']) == 'true' ? true : false);
+ $oTask->position->x = (int) $aRow1 ['TAS_POSX'];
+ $oTask->position->y = (int) $aRow1 ['TAS_POSY'];
+ $oTask->derivation = null;
+ $oTask->derivation->to = array();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(RoutePeer::TAS_UID, $aRow1 ['TAS_UID']);
+ $oDataset2 = RoutePeer::doSelectRS($oCriteria);
+ $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset2->next();
+ while ($aRow2 = $oDataset2->getRow()) {
+ switch ($aRow2 ['ROU_TYPE']) {
+ case 'SEQUENTIAL' :
+ $aRow2 ['ROU_TYPE'] = 0;
+ break;
+ case 'SELECT' :
+ $aRow2 ['ROU_TYPE'] = 1;
+ break;
+ case 'EVALUATE' :
+ $aRow2 ['ROU_TYPE'] = 2;
+ break;
+ case 'PARALLEL' :
+ $aRow2 ['ROU_TYPE'] = 3;
+ break;
+ case 'PARALLEL-BY-EVALUATION' :
+ $aRow2 ['ROU_TYPE'] = 4;
+ break;
+ case 'SEC-JOIN' :
+ $aRow2 ['ROU_TYPE'] = 5;
+ break;
+ case 'DISCRIMINATOR' :
+ $aRow2 ['ROU_TYPE'] = 8;
+ break;
+ }
+ $oTo = null;
+ $oTo->task = $aRow2 ['ROU_NEXT_TASK'];
+ $oTo->condition = $aRow2 ['ROU_CONDITION'];
+ $oTo->executant = $aRow2 ['ROU_TO_LAST_USER'];
+ $oTo->optional = $aRow2 ['ROU_OPTIONAL'];
+ $oTask->derivation->type = $aRow2 ['ROU_TYPE'];
+ $oTask->derivation->to [] = $oTo;
+ $oDataset2->next();
+ }
+ if ($bCT) {
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn('COUNT(*) AS CANT');
+ $oCriteria->addSelectColumn('MIN(DEL_FINISH_DATE) AS FINISH');
+ $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID);
+ $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1 ['TAS_UID']);
+ $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria);
+ $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset2->next();
+ $aRow2 = $oDataset2->getRow();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn('DEL_FINISH_DATE');
+ $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID);
+ $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1 ['TAS_UID']);
+ $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null);
+ $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria);
+ $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset2->next();
+ $aRow3 = $oDataset2->getRow();
+ if ($aRow3) {
+ $aRow2 ['FINISH'] = '';
+ }
+ if (($aRow2 ['FINISH'] == null) && ($aRow1 ['TAS_UID'] == $sTask)) {
+ $oTask->color = '#FF0000';
+ } else {
+ if ($aRow2 ['CANT'] != 0) {
+ if ($aRow2 ['FINISH'] == null) {
+ //$oTask->color = '#FF9900';
+ $oTask->color = '#FF0000';
+ } else {
+ $oTask->color = '#006633';
+ }
}
- $oTask->taskINI = (strtolower($aRow1 ['TAS_START']) == 'true' ? true : false);
- $oTask->position->x = (int) $aRow1 ['TAS_POSX'];
- $oTask->position->y = (int) $aRow1 ['TAS_POSY'];
- $oTask->derivation = null;
- $oTask->derivation->to = array();
+ else {
+ $oTask->color = "#939598";
+ }
+ }
+ } else {
+ if ($bView && ($sApplicationUID != '') && ($iDelegation > 0) && ($sTask != '')) {
$oCriteria = new Criteria('workflow');
- $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
- $oCriteria->add(RoutePeer::TAS_UID, $aRow1 ['TAS_UID']);
- $oDataset2 = RoutePeer::doSelectRS($oCriteria);
+ $oCriteria->addSelectColumn('COUNT(*) AS CANT');
+ $oCriteria->addSelectColumn('MIN(DEL_FINISH_DATE) AS FINISH');
+ $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID);
+ $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1 ['TAS_UID']);
+ $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria);
$oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset2->next();
- while ($aRow2 = $oDataset2->getRow()) {
- switch ($aRow2 ['ROU_TYPE']) {
- case 'SEQUENTIAL' :
- $aRow2 ['ROU_TYPE'] = 0;
- break;
- case 'SELECT' :
- $aRow2 ['ROU_TYPE'] = 1;
- break;
- case 'EVALUATE' :
- $aRow2 ['ROU_TYPE'] = 2;
- break;
- case 'PARALLEL' :
- $aRow2 ['ROU_TYPE'] = 3;
- break;
- case 'PARALLEL-BY-EVALUATION' :
- $aRow2 ['ROU_TYPE'] = 4;
- break;
- case 'SEC-JOIN' :
- $aRow2 ['ROU_TYPE'] = 5;
- break;
- case 'DISCRIMINATOR' :
- $aRow2 ['ROU_TYPE'] = 8;
- break;
- }
- $oTo = null;
- $oTo->task = $aRow2 ['ROU_NEXT_TASK'];
- $oTo->condition = $aRow2 ['ROU_CONDITION'];
- $oTo->executant = $aRow2 ['ROU_TO_LAST_USER'];
- $oTo->optional = $aRow2 ['ROU_OPTIONAL'];
- $oTask->derivation->type = $aRow2 ['ROU_TYPE'];
- $oTask->derivation->to [] = $oTo;
- $oDataset2->next();
+ $aRow2 = $oDataset2->getRow();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn('DEL_FINISH_DATE');
+ $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID);
+ $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1 ['TAS_UID']);
+ $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null);
+ $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria);
+ $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset2->next();
+ $aRow3 = $oDataset2->getRow();
+ if ($aRow3) {
+ $aRow2 ['FINISH'] = '';
}
- if ($bCT) {
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn('COUNT(*) AS CANT');
- $oCriteria->addSelectColumn('MIN(DEL_FINISH_DATE) AS FINISH');
- $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID);
- $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1 ['TAS_UID']);
- $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria);
- $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset2->next();
- $aRow2 = $oDataset2->getRow();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn('DEL_FINISH_DATE');
- $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID);
- $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1 ['TAS_UID']);
- $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null);
- $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria);
- $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset2->next();
- $aRow3 = $oDataset2->getRow();
- if ($aRow3) {
- $aRow2 ['FINISH'] = '';
- }
- if (($aRow2 ['FINISH'] == null) && ($aRow1 ['TAS_UID'] == $sTask)) {
- $oTask->color = '#FF0000';
+ if (($aRow2 ['FINISH'] == null) && ($aRow1 ['TAS_UID'] == $sTask)) {
+ $oTask->color = '#FF0000';
+ } else {
+ if ($aRow2 ['CANT'] != 0) {
+ if ($aRow2 ['FINISH'] == null) {
+ $oTask->color = '#FF9900';
} else {
- if ($aRow2 ['CANT'] != 0) {
- if ($aRow2 ['FINISH'] == null) {
- //$oTask->color = '#FF9900';
- $oTask->color = '#FF0000';
- } else {
- $oTask->color = '#006633';
- }
- }
- else {
- $oTask->color = "#939598";
- }
- }
- } else {
- if ($bView && ($sApplicationUID != '') && ($iDelegation > 0) && ($sTask != '')) {
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn('COUNT(*) AS CANT');
- $oCriteria->addSelectColumn('MIN(DEL_FINISH_DATE) AS FINISH');
- $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID);
- $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1 ['TAS_UID']);
- $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria);
- $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset2->next();
- $aRow2 = $oDataset2->getRow();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn('DEL_FINISH_DATE');
- $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID);
- $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1 ['TAS_UID']);
- $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null);
- $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria);
- $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset2->next();
- $aRow3 = $oDataset2->getRow();
- if ($aRow3) {
- $aRow2 ['FINISH'] = '';
- }
- if (($aRow2 ['FINISH'] == null) && ($aRow1 ['TAS_UID'] == $sTask)) {
- $oTask->color = '#FF0000';
- } else {
- if ($aRow2 ['CANT'] != 0) {
- if ($aRow2 ['FINISH'] == null) {
- $oTask->color = '#FF9900';
- } else {
- $oTask->color = '#006633';
- }
- } else {
- $oTask->color = '#939598';
+ $oTask->color = '#006633';
}
+ } else {
+ $oTask->color = '#939598';
+ }
}
}
}
@@ -364,12 +363,12 @@ class processMap {
//Load extended task properties from plugin. By JHL Jan 18, 2011
$oPluginRegistry =& PMPluginRegistry::getSingleton();
- $activePluginsForTaskProperties=$oPluginRegistry->getTaskExtendedProperties();
+ $activePluginsForTaskProperties=$oPluginRegistry->getTaskExtendedProperties();
$oPM->taskOptions = array();
foreach($activePluginsForTaskProperties as $key => $taskPropertiesInfo){
- $taskOption['title']=$taskPropertiesInfo->sName;
- $taskOption['id']=$taskPropertiesInfo->sNamespace."--".$taskPropertiesInfo->sName;
- $oPM->taskOptions[]=$taskOption;
+ $taskOption['title']=$taskPropertiesInfo->sName;
+ $taskOption['id']=$taskPropertiesInfo->sNamespace."--".$taskPropertiesInfo->sName;
+ $oPM->taskOptions[]=$taskOption;
}
$oJSON = new Services_JSON();
@@ -379,79 +378,79 @@ class processMap {
}
}
- /*
- * Create a Process
- * @param array $aData
- * @return boolean
- */
- public function createProcess($aData)
- {
- try {
- $oProcess = new Process ( );
- return $oProcess->create($aData);
- } catch (Exception $oError) {
- throw ($oError);
- }
+ /*
+ * Create a Process
+ * @param array $aData
+ * @return boolean
+ */
+
+ function createProcess($aData) {
+ try {
+ $oProcess = new Process ( );
+ return $oProcess->create($aData);
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /*
- * Update a Process
- * @param array $aData
- * @return boolean
- */
- public function updateProcess($aData)
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($aData ['PRO_UID']);
- return $oProcess->update($aData);
- } catch (Exception $oError) {
- throw ($oError);
- }
+ /*
+ * Update a Process
+ * @param array $aData
+ * @return boolean
+ */
+
+ function updateProcess($aData) {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($aData ['PRO_UID']);
+ return $oProcess->update($aData);
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /*
- * Edit the Process Map information
- * @param string $sProcessUID
- * @return boolean
- */
- public function editProcess($sProcessUID)
- {
- try {
- $oProcess = new Process ();
+ /*
+ * Edit the Process Map information
+ * @param string $sProcessUID
+ * @return boolean
+ */
- if (!is_null($oProcess)) {
- G::loadClass('processes');
- $calendar = new Calendar();
- $files = Processes::getProcessFiles($sProcessUID, 'mail');
+ function editProcess($sProcessUID) {
+ try {
+ $oProcess = new Process ();
- $templates = array();
- $templates[] = 'dummy';
+ if (!is_null($oProcess)) {
+ G::loadClass('processes');
+ $calendar = new Calendar();
+ $files = Processes::getProcessFiles($sProcessUID, 'mail');
- foreach ($files as $file) {
- $templates[] = array('FILE' => $file['filename'], 'NAME' => $file['filename']);
- }
+ $templates = array();
+ $templates[] = 'dummy';
- $calendarObj = $calendar->getCalendarList(true, true);
+ foreach ($files as $file) {
+ $templates[] = array('FILE' => $file['filename'], 'NAME' => $file['filename']);
+ }
- global $_DBArray;
- $_DBArray['_TEMPLATES1'] = $templates;
- $_DBArray['availableCalendars'] = $calendarObj['array'];
- $_SESSION ['_DBArray'] = $_DBArray;
+ $calendarObj = $calendar->getCalendarList(true, true);
- $aFields = $oProcess->load($sProcessUID);
- $aFields['PRO_SUMMARY_DYNAFORM'] = (isset($aFields['PRO_DYNAFORMS']['PROCESS']) ? $aFields['PRO_DYNAFORMS']['PROCESS'] : '');
- $aFields['THETYPE'] = 'UPDATE';
- $calendarInfo = $calendar->getCalendarFor($sProcessUID, $sProcessUID, $sProcessUID);
+ global $_DBArray;
+ $_DBArray['_TEMPLATES1'] = $templates;
+ $_DBArray['availableCalendars'] = $calendarObj['array'];
+ $_SESSION ['_DBArray'] = $_DBArray;
- //If the function returns a DEFAULT calendar it means that this object doesn't have assigned any calendar
- $aFields['PRO_CALENDAR'] = $calendarInfo ['CALENDAR_APPLIED'] != 'DEFAULT' ? $calendarInfo ['CALENDAR_UID'] : "";
- $aFields['SYS_LANG'] = SYS_LANG;
+ $aFields = $oProcess->load($sProcessUID);
+ $aFields['PRO_SUMMARY_DYNAFORM'] = (isset($aFields['PRO_DYNAFORMS']['PROCESS']) ? $aFields['PRO_DYNAFORMS']['PROCESS'] : '');
+ $aFields['THETYPE'] = 'UPDATE';
+ $calendarInfo = $calendar->getCalendarFor($sProcessUID, $sProcessUID, $sProcessUID);
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_Edit', '', $aFields, 'processes_Save');
- G::RenderPage('publish', 'raw');
+ //If the function returns a DEFAULT calendar it means that this object doesn't have assigned any calendar
+ $aFields['PRO_CALENDAR'] = $calendarInfo ['CALENDAR_APPLIED'] != 'DEFAULT' ? $calendarInfo ['CALENDAR_UID'] : "";
+ $aFields['SYS_LANG'] = SYS_LANG;
+
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_Edit', '', $aFields, 'processes_Save');
+ G::RenderPage('publish', 'raw');
return true;
}
@@ -459,280 +458,281 @@ class processMap {
throw (new Exception('This row doesn\'t exist!'));
}
}
- catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Delete a Process
- * @param string $sProcessUID
- * @return boolean
- */
- public function deleteProcess($sProcessUID)
- {
- try {
- G::LoadClass('case');
- G::LoadClass('reportTables');
- //Instance all classes necesaries
- $oProcess = new Process ( );
- $oDynaform = new Dynaform ( );
- $oInputDocument = new InputDocument ( );
- $oOutputDocument = new OutputDocument ( );
- $oTrigger = new Triggers ( );
- $oRoute = new Route ( );
- $oGateway = new Gateway ( );
- $oEvent = new Event ( );
- $oSwimlaneElement = new SwimlanesElements ( );
- $oConfiguration = new Configuration ( );
- $oDbSource = new DbSource ( );
- $oReportTable = new ReportTables ( );
- $oCaseTracker = new CaseTracker ( );
- $oCaseTrackerObject = new CaseTrackerObject ( );
- //Delete the applications of process
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUID);
- $oDataset = ApplicationPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $oCase = new Cases ( );
- while ($aRow = $oDataset->getRow()) {
- $oCase->removeCase($aRow ['APP_UID']);
- $oDataset->next();
- }
- //Delete the tasks of process
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(TaskPeer::PRO_UID, $sProcessUID);
- $oDataset = TaskPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $this->deleteTask($aRow ['TAS_UID']);
- $oDataset->next();
- }
- //Delete the dynaforms of process
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
- $oDataset = DynaformPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oDynaform->remove($aRow ['DYN_UID']);
- $oDataset->next();
- }
- //Delete the input documents of process
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID);
- $oDataset = InputDocumentPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oInputDocument->remove($aRow ['INP_DOC_UID']);
- $oDataset->next();
- }
- //Delete the output documents of process
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(OutputDocumentPeer::PRO_UID, $sProcessUID);
- $oDataset = OutputDocumentPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oOutputDocument->remove($aRow ['OUT_DOC_UID']);
- $oDataset->next();
- }
-
- //Delete the triggers of process
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(TriggersPeer::PRO_UID, $sProcessUID);
- $oDataset = TriggersPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oTrigger->remove($aRow ['TRI_UID']);
- $oDataset->next();
- }
-
- //Delete the routes of process
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
- $oDataset = RoutePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oRoute->remove($aRow ['ROU_UID']);
- $oDataset->next();
- }
-
- //Delete the gateways of process
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(GatewayPeer::PRO_UID, $sProcessUID);
- $oDataset = GatewayPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oGateway->remove($aRow ['GAT_UID']);
- $oDataset->next();
- }
-
- //Delete the Event of process
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(EventPeer::PRO_UID, $sProcessUID);
- $oDataset = EventPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oEvent->remove($aRow ['EVN_UID']);
- $oDataset->next();
- }
-
- //Delete the swimlanes elements of process
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(SwimlanesElementsPeer::PRO_UID, $sProcessUID);
- $oDataset = SwimlanesElementsPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oSwimlaneElement->remove($aRow ['SWI_UID']);
- $oDataset->next();
- }
- //Delete the configurations of process
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(ConfigurationPeer::PRO_UID, $sProcessUID);
- $oDataset = ConfigurationPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oConfiguration->remove($aRow ['CFG_UID'], $aRow ['OBJ_UID'], $aRow ['PRO_UID'], $aRow ['USR_UID'], $aRow ['APP_UID']);
- $oDataset->next();
- }
- //Delete the DB sources of process
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(DbSourcePeer::PRO_UID, $sProcessUID);
- $oDataset = DbSourcePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- /**
- * note added by gustavo cruz gustavo-at-colosa-dot-com 27-01-2010
- * in order to solve the bug 0004389, we use the validation function Exists
- * inside the remove function in order to verify if the DbSource record
- * exists in the Database, however there is a strange behavior within the
- * propel engine, when the first record is erased somehow the "_deleted"
- * attribute of the next row is set to true, so when propel tries to erase
- * it, obviously it can't and trows an error. With the "Exist" function
- * we ensure that if there is the record in the database, the _delete attribute must be false.
- *
- * note added by gustavo cruz gustavo-at-colosa-dot-com 28-01-2010
- * I have just identified the source of the issue, when is created a $oDbSource DbSource object
- * it's used whenever a record is erased or removed in the db, however the problem
- * it's that the same object is used every time, and the delete method invoked
- * sets the _deleted attribute to true when its called, of course as we use
- * the same object, the first time works fine but trowns an error with the
- * next record, cos it's the same object and the delete method checks if the _deleted
- * attribute it's true or false, the attrib _deleted is setted to true the
- * first time and later is never changed, the issue seems to be part of
- * every remove function in the model classes, not only DbSource
- * i recommend that a more general solution must be achieved to resolve
- * this issue in every model class, to prevent future problems.
- * */
- $oDbSource->remove($aRow ['DBS_UID'], $sProcessUID);
- $oDataset->next();
- }
- //Delete the supervisors
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
- ProcessUserPeer::doDelete($oCriteria);
- //Delete the object permissions
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID);
- ObjectPermissionPeer::doDelete($oCriteria);
- //Delete the step supervisors
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
- StepSupervisorPeer::doDelete($oCriteria);
- //Delete the report tables
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(ReportTablePeer::PRO_UID, $sProcessUID);
- $oDataset = ReportTablePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oReportTable->deleteReportTable($aRow ['REP_TAB_UID']);
- $oDataset->next();
- }
- //Delete case tracker configuration
- $oCaseTracker->remove($sProcessUID);
- //Delete case tracker objects
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(CaseTrackerObjectPeer::PRO_UID, $sProcessUID);
- ProcessUserPeer::doDelete($oCriteria);
- //Delete the process
- try {
- $oProcess->remove($sProcessUID);
- } catch (Exception $oError) { //nada
- }
- return true;
- } catch (Exception $oError) {
+ catch (Exception $oError) {
throw ($oError);
}
}
- /*
- * Save the process title position
- * @param string sProcessUID
- * @param integer $iX
- * @param integer $iY
- * @return boolean
- */
- public function saveTitlePosition($sProcessUID = '', $iX = 0, $iY = 0)
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- $aFields ['PRO_UID'] = $sProcessUID;
- $aFields ['PRO_TITLE_X'] = $iX;
- $aFields ['PRO_TITLE_Y'] = $iY;
- $oProcess->update($aFields);
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
+ /*
+ * Delete a Process
+ * @param string $sProcessUID
+ * @return boolean
+ */
- /*
- * Steps of Tasks
- * @param string $sProcessUID
- * @param string $sTaskUID
- * @return boolean
- */
- public function steps($sProcessUID = '', $sTaskUID = '')
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- $oTask = new Task ( );
- $aFields = $oTask->load($sTaskUID);
- $aFields = array();
- $aFields ['PROCESS'] = $sProcessUID;
- $aFields ['TASK'] = $sTaskUID;
- $aFields ['CONFIRM'] = G::LoadTranslation('ID_MSG_CONFIRM_DELETE_STEP');
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'steps/steps_List', $this->getStepsCriteria($sTaskUID), $aFields);
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
+ function deleteProcess($sProcessUID) {
+ try {
+ G::LoadClass('case');
+ G::LoadClass('reportTables');
+ //Instance all classes necesaries
+ $oProcess = new Process ( );
+ $oDynaform = new Dynaform ( );
+ $oInputDocument = new InputDocument ( );
+ $oOutputDocument = new OutputDocument ( );
+ $oTrigger = new Triggers ( );
+ $oRoute = new Route ( );
+ $oGateway = new Gateway ( );
+ $oEvent = new Event ( );
+ $oSwimlaneElement = new SwimlanesElements ( );
+ $oConfiguration = new Configuration ( );
+ $oDbSource = new DbSource ( );
+ $oReportTable = new ReportTables ( );
+ $oCaseTracker = new CaseTracker ( );
+ $oCaseTrackerObject = new CaseTrackerObject ( );
+ //Delete the applications of process
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUID);
+ $oDataset = ApplicationPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $oCase = new Cases ( );
+ while ($aRow = $oDataset->getRow()) {
+ $oCase->removeCase($aRow ['APP_UID']);
+ $oDataset->next();
+ }
+ //Delete the tasks of process
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(TaskPeer::PRO_UID, $sProcessUID);
+ $oDataset = TaskPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $this->deleteTask($aRow ['TAS_UID']);
+ $oDataset->next();
+ }
+ //Delete the dynaforms of process
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
+ $oDataset = DynaformPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oDynaform->remove($aRow ['DYN_UID']);
+ $oDataset->next();
+ }
+ //Delete the input documents of process
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID);
+ $oDataset = InputDocumentPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oInputDocument->remove($aRow ['INP_DOC_UID']);
+ $oDataset->next();
+ }
+ //Delete the output documents of process
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(OutputDocumentPeer::PRO_UID, $sProcessUID);
+ $oDataset = OutputDocumentPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oOutputDocument->remove($aRow ['OUT_DOC_UID']);
+ $oDataset->next();
+ }
- /*
- * Return the steps list criteria object
- * @param string $sTaskUID
- * @return array
- */
- public function getStepsCriteria($sTaskUID = '')
- {
+ //Delete the triggers of process
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(TriggersPeer::PRO_UID, $sProcessUID);
+ $oDataset = TriggersPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oTrigger->remove($aRow ['TRI_UID']);
+ $oDataset->next();
+ }
+
+ //Delete the routes of process
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
+ $oDataset = RoutePeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oRoute->remove($aRow ['ROU_UID']);
+ $oDataset->next();
+ }
+
+ //Delete the gateways of process
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(GatewayPeer::PRO_UID, $sProcessUID);
+ $oDataset = GatewayPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oGateway->remove($aRow ['GAT_UID']);
+ $oDataset->next();
+ }
+
+ //Delete the Event of process
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(EventPeer::PRO_UID, $sProcessUID);
+ $oDataset = EventPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oEvent->remove($aRow ['EVN_UID']);
+ $oDataset->next();
+ }
+
+ //Delete the swimlanes elements of process
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(SwimlanesElementsPeer::PRO_UID, $sProcessUID);
+ $oDataset = SwimlanesElementsPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oSwimlaneElement->remove($aRow ['SWI_UID']);
+ $oDataset->next();
+ }
+ //Delete the configurations of process
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(ConfigurationPeer::PRO_UID, $sProcessUID);
+ $oDataset = ConfigurationPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oConfiguration->remove($aRow ['CFG_UID'], $aRow ['OBJ_UID'], $aRow ['PRO_UID'], $aRow ['USR_UID'], $aRow ['APP_UID']);
+ $oDataset->next();
+ }
+ //Delete the DB sources of process
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(DbSourcePeer::PRO_UID, $sProcessUID);
+ $oDataset = DbSourcePeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+
+ /**
+ * note added by gustavo cruz gustavo-at-colosa-dot-com 27-01-2010
+ * in order to solve the bug 0004389, we use the validation function Exists
+ * inside the remove function in order to verify if the DbSource record
+ * exists in the Database, however there is a strange behavior within the
+ * propel engine, when the first record is erased somehow the "_deleted"
+ * attribute of the next row is set to true, so when propel tries to erase
+ * it, obviously it can't and trows an error. With the "Exist" function
+ * we ensure that if there is the record in the database, the _delete attribute must be false.
+ *
+ * note added by gustavo cruz gustavo-at-colosa-dot-com 28-01-2010
+ * I have just identified the source of the issue, when is created a $oDbSource DbSource object
+ * it's used whenever a record is erased or removed in the db, however the problem
+ * it's that the same object is used every time, and the delete method invoked
+ * sets the _deleted attribute to true when its called, of course as we use
+ * the same object, the first time works fine but trowns an error with the
+ * next record, cos it's the same object and the delete method checks if the _deleted
+ * attribute it's true or false, the attrib _deleted is setted to true the
+ * first time and later is never changed, the issue seems to be part of
+ * every remove function in the model classes, not only DbSource
+ * i recommend that a more general solution must be achieved to resolve
+ * this issue in every model class, to prevent future problems.
+ * */
+ $oDbSource->remove($aRow ['DBS_UID'], $sProcessUID);
+ $oDataset->next();
+ }
+ //Delete the supervisors
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
+ ProcessUserPeer::doDelete($oCriteria);
+ //Delete the object permissions
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID);
+ ObjectPermissionPeer::doDelete($oCriteria);
+ //Delete the step supervisors
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
+ StepSupervisorPeer::doDelete($oCriteria);
+ //Delete the report tables
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(ReportTablePeer::PRO_UID, $sProcessUID);
+ $oDataset = ReportTablePeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oReportTable->deleteReportTable($aRow ['REP_TAB_UID']);
+ $oDataset->next();
+ }
+ //Delete case tracker configuration
+ $oCaseTracker->remove($sProcessUID);
+ //Delete case tracker objects
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(CaseTrackerObjectPeer::PRO_UID, $sProcessUID);
+ ProcessUserPeer::doDelete($oCriteria);
+ //Delete the process
+ try {
+ $oProcess->remove($sProcessUID);
+ } catch (Exception $oError) { //nada
+ }
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Save the process title position
+ * @param string sProcessUID
+ * @param integer $iX
+ * @param integer $iY
+ * @return boolean
+ */
+
+ function saveTitlePosition($sProcessUID = '', $iX = 0, $iY = 0) {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ $aFields ['PRO_UID'] = $sProcessUID;
+ $aFields ['PRO_TITLE_X'] = $iX;
+ $aFields ['PRO_TITLE_Y'] = $iY;
+ $oProcess->update($aFields);
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Steps of Tasks
+ * @param string $sProcessUID
+ * @param string $sTaskUID
+ * @return boolean
+ */
+
+ function steps($sProcessUID = '', $sTaskUID = '') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ $oTask = new Task ( );
+ $aFields = $oTask->load($sTaskUID);
+ $aFields = array();
+ $aFields ['PROCESS'] = $sProcessUID;
+ $aFields ['TASK'] = $sTaskUID;
+ $aFields ['CONFIRM'] = G::LoadTranslation('ID_MSG_CONFIRM_DELETE_STEP');
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'steps/steps_List', $this->getStepsCriteria($sTaskUID), $aFields);
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Return the steps list criteria object
+ * @param string $sTaskUID
+ * @return array
+ */
+
+ function getStepsCriteria($sTaskUID = '') {
try {
//call plugin
$oPluginRegistry = &PMPluginRegistry::getSingleton ();
@@ -764,7 +764,7 @@ class processMap {
case 'INPUT_DOCUMENT' :
$oInputDocument = new InputDocument ( );
$aFields = $oInputDocument->getByUid($aRow ['STEP_UID_OBJ']);
- if ( $aFields === false )
+ if( $aFields === false )
continue;
$sTitle = $aFields ['INP_DOC_TITLE'];
break;
@@ -772,7 +772,7 @@ class processMap {
$oOutputDocument = new OutputDocument ( );
$aFields = $oOutputDocument->getByUid($aRow ['STEP_UID_OBJ']);
- if ( $aFields === false )
+ if( $aFields === false )
continue;
$sTitle = $aFields ['OUT_DOC_TITLE'];
break;
@@ -810,205 +810,634 @@ class processMap {
}
}
- /*
- * Return the step triggers list criteria object
- * @param string $sStepUID
- * @param string $sTaskUID
- * @param string $sType
- * @return object
- */
- public function getStepTriggersCriteria($sStepUID = '', $sTaskUID = '', $sType = '')
- {
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn('C.CON_VALUE');
- $oCriteria->addSelectColumn('STEP_UID');
- $oCriteria->addSelectColumn('TRI_UID');
- $oCriteria->addSelectColumn('ST_TYPE');
- $oCriteria->addSelectColumn(StepTriggerPeer::ST_POSITION);
- $oCriteria->addAsColumn('TRI_TITLE', 'C.CON_VALUE');
- $oCriteria->addAlias('C', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(StepTriggerPeer::TRI_UID, 'C.CON_ID');
- $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'TRI_TITLE' . $sDelimiter);
- $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(StepTriggerPeer::STEP_UID, $sStepUID);
- $oCriteria->add(StepTriggerPeer::TAS_UID, $sTaskUID);
- $oCriteria->add(StepTriggerPeer::ST_TYPE, $sType);
- $oCriteria->addAscendingOrderByColumn(StepTriggerPeer::ST_POSITION);
- return $oCriteria;
- }
+ /*
+ * Return the step triggers list criteria object
+ * @param string $sStepUID
+ * @param string $sTaskUID
+ * @param string $sType
+ * @return object
+ */
- /*
- * Return the available building blocks list criteria object
- * @param string $sProcessUID
- * @param string $sTaskUID
- * @return object
- */
- public function getAvailableBBCriteria($sProcessUID = '', $sTaskUID = '')
- {
- try {
- $oTasks = new Tasks ( );
- $aSteps = $oTasks->getStepsOfTask($sTaskUID);
- $sUIDs = array();
- foreach ($aSteps as $aStep) {
- $sUIDs [] = $aStep ['STEP_UID_OBJ'];
- }
- $aBB = array();
- $aBB [] = array('STEP_UID' => 'char', 'STEP_TITLE' => 'char', 'STEP_TYPE_OBJ' => 'char', 'STEP_MODE' => 'char');
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(DynaformPeer::DYN_UID);
- $oCriteria->addAsColumn('DYN_TITLE', 'C.CON_VALUE');
- $oCriteria->addAlias('C', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(DynaformPeer::DYN_UID, 'C.CON_ID');
- $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'DYN_TITLE' . $sDelimiter);
- $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
- $oCriteria->add(DynaformPeer::DYN_UID, $sUIDs, Criteria::NOT_IN);
- $oCriteria->add(DynaformPeer::DYN_TYPE, 'xmlform');
- $oDataset = DynaformPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $i = 0;
- while ($aRow = $oDataset->getRow()) {
- $i++;
- if (($aRow ['DYN_TITLE'] == NULL) || ($aRow ['DYN_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
- $aRow ['DYN_TITLE'] = Content::Load("DYN_TITLE", "", $aRow ['DYN_UID'], SYS_LANG);
- }
- $aBB [] = array('STEP_UID' => $aRow ['DYN_UID'], 'STEP_TITLE' => $aRow ['DYN_TITLE'], 'STEP_TYPE_OBJ' => 'DYNAFORM', 'STEP_MODE' => '');
- $oDataset->next();
- }
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(InputDocumentPeer::INP_DOC_UID);
- $oCriteria->addAsColumn('INP_DOC_TITLE', 'C.CON_VALUE');
- $oCriteria->addAlias('C', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(InputDocumentPeer::INP_DOC_UID, 'C.CON_ID');
- $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'INP_DOC_TITLE' . $sDelimiter);
- $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID);
- $oCriteria->add(InputDocumentPeer::INP_DOC_UID, $sUIDs, Criteria::NOT_IN);
- $oDataset = InputDocumentPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- if (($aRow ['INP_DOC_TITLE'] == NULL) || ($aRow ['INP_DOC_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
- $aRow ['INP_DOC_TITLE'] = Content::Load("INP_DOC_TITLE", "", $aRow ['INP_DOC_UID'], SYS_LANG);
- }
- $aBB [] = array('STEP_UID' => $aRow ['INP_DOC_UID'], 'STEP_TITLE' => $aRow ['INP_DOC_TITLE'], 'STEP_TYPE_OBJ' => 'INPUT_DOCUMENT', 'STEP_MODE' => '');
- $oDataset->next();
- }
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(OutputDocumentPeer::OUT_DOC_UID);
- $oCriteria->addAsColumn('OUT_DOC_TITLE', 'C.CON_VALUE');
- $oCriteria->addAlias('C', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(OutputDocumentPeer::OUT_DOC_UID, 'C.CON_ID');
- $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'OUT_DOC_TITLE' . $sDelimiter);
- $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(OutputDocumentPeer::PRO_UID, $sProcessUID);
- $oCriteria->add(OutputDocumentPeer::OUT_DOC_UID, $sUIDs, Criteria::NOT_IN);
- $oDataset = OutputDocumentPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- if (($aRow ['OUT_DOC_TITLE'] == NULL) || ($aRow ['OUT_DOC_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
- $aRow ['OUT_DOC_TITLE'] = Content::Load("OUT_DOC_TITLE", "", $aRow ['OUT_DOC_UID'], SYS_LANG);
- }
- $aBB [] = array('STEP_UID' => $aRow ['OUT_DOC_UID'], 'STEP_TITLE' => $aRow ['OUT_DOC_TITLE'], 'STEP_TYPE_OBJ' => 'OUTPUT_DOCUMENT', 'STEP_MODE' => '');
- $oDataset->next();
- }
+ function getStepTriggersCriteria($sStepUID = '', $sTaskUID = '', $sType = '') {
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn('C.CON_VALUE');
+ $oCriteria->addSelectColumn('STEP_UID');
+ $oCriteria->addSelectColumn('TRI_UID');
+ $oCriteria->addSelectColumn('ST_TYPE');
+ $oCriteria->addSelectColumn(StepTriggerPeer::ST_POSITION);
+ $oCriteria->addAsColumn('TRI_TITLE', 'C.CON_VALUE');
+ $oCriteria->addAlias('C', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(StepTriggerPeer::TRI_UID, 'C.CON_ID');
+ $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'TRI_TITLE' . $sDelimiter);
+ $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(StepTriggerPeer::STEP_UID, $sStepUID);
+ $oCriteria->add(StepTriggerPeer::TAS_UID, $sTaskUID);
+ $oCriteria->add(StepTriggerPeer::ST_TYPE, $sType);
+ $oCriteria->addAscendingOrderByColumn(StepTriggerPeer::ST_POSITION);
+ return $oCriteria;
+ }
- //call plugin
- $oPluginRegistry = &PMPluginRegistry::getSingleton ();
- $externalSteps = $oPluginRegistry->getSteps();
- if (is_array($externalSteps) && count($externalSteps) > 0) {
- foreach ($externalSteps as $key => $stepVar) {
- $aBB [] = array('STEP_UID' => $stepVar->sStepId, 'STEP_TITLE' => $stepVar->sStepTitle, 'STEP_TYPE_OBJ' => 'EXTERNAL', 'STEP_MODE' => '');
- }
- }
- global $_DBArray;
- $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
- $_DBArray ['availableBB'] = $aBB;
- $_SESSION ['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('availableBB');
- $oCriteria->addAscendingOrderByColumn('STEP_TYPE_OBJ');
- $oCriteria->addAscendingOrderByColumn('STEP_TITLE');
- return $oCriteria;
- } catch (Exception $oError) {
- throw ($oError);
+ /*
+ * Return the available building blocks list criteria object
+ * @param string $sProcessUID
+ * @param string $sTaskUID
+ * @return object
+ */
+
+ function getAvailableBBCriteria($sProcessUID = '', $sTaskUID = '') {
+ try {
+ $oTasks = new Tasks ( );
+ $aSteps = $oTasks->getStepsOfTask($sTaskUID);
+ $sUIDs = array();
+ foreach ($aSteps as $aStep) {
+ $sUIDs [] = $aStep ['STEP_UID_OBJ'];
+ }
+ $aBB = array();
+ $aBB [] = array('STEP_UID' => 'char', 'STEP_TITLE' => 'char', 'STEP_TYPE_OBJ' => 'char', 'STEP_MODE' => 'char');
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(DynaformPeer::DYN_UID);
+ $oCriteria->addAsColumn('DYN_TITLE', 'C.CON_VALUE');
+ $oCriteria->addAlias('C', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(DynaformPeer::DYN_UID, 'C.CON_ID');
+ $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'DYN_TITLE' . $sDelimiter);
+ $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(DynaformPeer::DYN_UID, $sUIDs, Criteria::NOT_IN);
+ $oCriteria->add(DynaformPeer::DYN_TYPE, 'xmlform');
+ $oDataset = DynaformPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $i = 0;
+ while ($aRow = $oDataset->getRow()) {
+ $i++;
+ if (($aRow ['DYN_TITLE'] == NULL) || ($aRow ['DYN_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
+ $aRow ['DYN_TITLE'] = Content::Load("DYN_TITLE", "", $aRow ['DYN_UID'], SYS_LANG);
+ }
+ $aBB [] = array('STEP_UID' => $aRow ['DYN_UID'], 'STEP_TITLE' => $aRow ['DYN_TITLE'], 'STEP_TYPE_OBJ' => 'DYNAFORM', 'STEP_MODE' => '');
+ $oDataset->next();
+ }
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(InputDocumentPeer::INP_DOC_UID);
+ $oCriteria->addAsColumn('INP_DOC_TITLE', 'C.CON_VALUE');
+ $oCriteria->addAlias('C', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(InputDocumentPeer::INP_DOC_UID, 'C.CON_ID');
+ $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'INP_DOC_TITLE' . $sDelimiter);
+ $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(InputDocumentPeer::INP_DOC_UID, $sUIDs, Criteria::NOT_IN);
+ $oDataset = InputDocumentPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+
+ if (($aRow ['INP_DOC_TITLE'] == NULL) || ($aRow ['INP_DOC_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
+ $aRow ['INP_DOC_TITLE'] = Content::Load("INP_DOC_TITLE", "", $aRow ['INP_DOC_UID'], SYS_LANG);
+ }
+ $aBB [] = array('STEP_UID' => $aRow ['INP_DOC_UID'], 'STEP_TITLE' => $aRow ['INP_DOC_TITLE'], 'STEP_TYPE_OBJ' => 'INPUT_DOCUMENT', 'STEP_MODE' => '');
+ $oDataset->next();
+ }
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(OutputDocumentPeer::OUT_DOC_UID);
+ $oCriteria->addAsColumn('OUT_DOC_TITLE', 'C.CON_VALUE');
+ $oCriteria->addAlias('C', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(OutputDocumentPeer::OUT_DOC_UID, 'C.CON_ID');
+ $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'OUT_DOC_TITLE' . $sDelimiter);
+ $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(OutputDocumentPeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(OutputDocumentPeer::OUT_DOC_UID, $sUIDs, Criteria::NOT_IN);
+ $oDataset = OutputDocumentPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+
+ if (($aRow ['OUT_DOC_TITLE'] == NULL) || ($aRow ['OUT_DOC_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
+ $aRow ['OUT_DOC_TITLE'] = Content::Load("OUT_DOC_TITLE", "", $aRow ['OUT_DOC_UID'], SYS_LANG);
+ }
+ $aBB [] = array('STEP_UID' => $aRow ['OUT_DOC_UID'], 'STEP_TITLE' => $aRow ['OUT_DOC_TITLE'], 'STEP_TYPE_OBJ' => 'OUTPUT_DOCUMENT', 'STEP_MODE' => '');
+ $oDataset->next();
+ }
+
+ //call plugin
+ $oPluginRegistry = &PMPluginRegistry::getSingleton ();
+ $externalSteps = $oPluginRegistry->getSteps();
+ if (is_array($externalSteps) && count($externalSteps) > 0) {
+ foreach ($externalSteps as $key => $stepVar) {
+ $aBB [] = array('STEP_UID' => $stepVar->sStepId, 'STEP_TITLE' => $stepVar->sStepTitle, 'STEP_TYPE_OBJ' => 'EXTERNAL', 'STEP_MODE' => '');
}
+ }
+ global $_DBArray;
+ $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
+ $_DBArray ['availableBB'] = $aBB;
+ $_SESSION ['_DBArray'] = $_DBArray;
+ G::LoadClass('ArrayPeer');
+ $oCriteria = new Criteria('dbarray');
+ $oCriteria->setDBArrayTable('availableBB');
+ $oCriteria->addAscendingOrderByColumn('STEP_TYPE_OBJ');
+ $oCriteria->addAscendingOrderByColumn('STEP_TITLE');
+ return $oCriteria;
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /*
- * Users assigned to Tasks
- * @param string $sProcessUID
- * @param string $sTaskUID
- * @return boolean
- */
- public function users($sProcessUID = '', $sTaskUID = '')
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- $oTask = new Task ( );
- $aFields = $oTask->load($sTaskUID);
+ /*
+ * Users assigned to Tasks
+ * @param string $sProcessUID
+ * @param string $sTaskUID
+ * @return boolean
+ */
- $_SESSION ['iType'] = 1;
+ function users($sProcessUID = '', $sTaskUID = '') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ $oTask = new Task ( );
+ $aFields = $oTask->load($sTaskUID);
- $aFields ['TASK'] = $sTaskUID;
- $aFields ['TYPE'] = $_SESSION ['iType'];
- $aFields ['OF_TO_ASSIGN'] = G::LoadTranslation('ID_DE_ASSIGN');
- $aFields ['CONFIRM'] = G::LoadTranslation('ID_MSG_CONFIRM_DEASIGN_USER_GROUP_MESSAGE');
- $aFields ['UIDS'] = "'0'";
+ $_SESSION ['iType'] = 1;
- $oTasks = new Tasks ( );
- $oGroups = new Groups ( );
- $aAux1 = $oTasks->getGroupsOfTask($sTaskUID, $_SESSION ['iType']);
- foreach ($aAux1 as $aGroup) {
- $aAux2 = $oGroups->getUsersOfGroup($aGroup ['GRP_UID']);
- foreach ($aAux2 as $aUser) {
- $aFields ['UIDS'] .= ",'" . $aUser ['USR_UID'] . "'";
+ $aFields ['TASK'] = $sTaskUID;
+ $aFields ['TYPE'] = $_SESSION ['iType'];
+ $aFields ['OF_TO_ASSIGN'] = G::LoadTranslation('ID_DE_ASSIGN');
+ $aFields ['CONFIRM'] = G::LoadTranslation('ID_MSG_CONFIRM_DEASIGN_USER_GROUP_MESSAGE');
+ $aFields ['UIDS'] = "'0'";
+
+ $oTasks = new Tasks ( );
+ $oGroups = new Groups ( );
+ $aAux1 = $oTasks->getGroupsOfTask($sTaskUID, $_SESSION ['iType']);
+ foreach ($aAux1 as $aGroup) {
+ $aAux2 = $oGroups->getUsersOfGroup($aGroup ['GRP_UID']);
+ foreach ($aAux2 as $aUser) {
+ $aFields ['UIDS'] .= ",'" . $aUser ['USR_UID'] . "'";
+ }
+ }
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $oTask = new Task ( );
+ $aTask = $oTask->load($sTaskUID);
+
+ if ($aFields ['TAS_TYPE'] == 'TRUE') {
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'users/users_ShortList', $this->getTaskUsersCriteria($sTaskUID, $_SESSION ['iType']), $aFields);
+ } else {
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'users/users_ShortList2', $this->getTaskUsersCriteria($sTaskUID, $_SESSION ['iType']), $aFields);
+ }
+
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Users Adhoc assigned to Tasks
+ * @param string $sProcessUID
+ * @param string $sTaskUID
+ * @return boolean
+ */
+
+ function users_adhoc($sProcessUID = '', $sTaskUID = '') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ $oTask = new Task ( );
+ $aFields = $oTask->load($sTaskUID);
+
+ $_SESSION ['iType'] = 2;
+
+ $aFields ['TASK'] = $sTaskUID;
+ $aFields ['TYPE'] = $_SESSION ['iType'];
+ $aFields ['OF_TO_ASSIGN'] = G::LoadTranslation('ID_DE_ASSIGN');
+ $aFields ['CONFIRM'] = G::LoadTranslation('ID_MSG_CONFIRM_DEASIGN_USER_GROUP_MESSAGE');
+ $aFields ['UIDS'] = "'0'";
+
+ $oTasks = new Tasks ( );
+ $oGroups = new Groups ( );
+ $aAux1 = $oTasks->getGroupsOfTask($sTaskUID, $_SESSION ['iType']);
+ foreach ($aAux1 as $aGroup) {
+ $aAux2 = $oGroups->getUsersOfGroup($aGroup ['GRP_UID']);
+ foreach ($aAux2 as $aUser) {
+ $aFields ['UIDS'] .= ",'" . $aUser ['USR_UID'] . "'";
+ }
+ }
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $oTask = new Task ( );
+ $aTask = $oTask->load($sTaskUID);
+
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'users/users_ShortListAdhoc', $this->getTaskUsersCriteria($sTaskUID, $_SESSION ['iType']), $aFields);
+
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Return the tasks users list criteria object
+ * @param string $sTaskUID
+ * @param integer $iType
+ * @return array
+ */
+
+ function getTaskUsersCriteria($sTaskUID = '', $iType = 1) {
+ try {
+ $aUsers = array();
+ $aUsers [] = array('LABEL' => 'char', 'TAS_UID' => 'char', 'USR_UID' => 'char', 'TU_TYPE' => 'integer', 'TU_RELATION' => 'integer');
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addAsColumn('GRP_TITLE', 'C.CON_VALUE');
+ $oCriteria->addSelectColumn(TaskUserPeer::TAS_UID);
+ $oCriteria->addSelectColumn(TaskUserPeer::USR_UID);
+ $oCriteria->addSelectColumn(TaskUserPeer::TU_TYPE);
+ $oCriteria->addSelectColumn(TaskUserPeer::TU_RELATION);
+ $oCriteria->addAlias('C', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(TaskUserPeer::USR_UID, 'C.CON_ID');
+ $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'GRP_TITLE' . $sDelimiter);
+ $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID);
+ $oCriteria->add(TaskUserPeer::TU_TYPE, $iType);
+ $oCriteria->add(TaskUserPeer::TU_RELATION, 2);
+ $oDataset = TaskUserPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $c = 0;
+ while ($aRow = $oDataset->getRow()) {
+ $c++;
+ $oGroup = new Groupwf ( );
+ $aFields = $oGroup->load($aRow ['USR_UID']);
+ if ($aFields ['GRP_STATUS'] == 'ACTIVE') {
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn('COUNT(*) AS MEMBERS_NUMBER');
+ $oCriteria->add(GroupUserPeer::GRP_UID, $aRow ['USR_UID']);
+ $oDataset2 = GroupUserPeer::doSelectRS($oCriteria);
+ $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset2->next();
+ $aRow2 = $oDataset2->getRow();
+ } else {
+ $aRow2 ['GROUP_INACTIVE'] = '(' . G::LoadTranslation('ID_GROUP_INACTIVE') . ')';
+ }
+ $aUsers [] = array('LABEL' => (!isset($aRow2 ['GROUP_INACTIVE']) ? $aRow ['GRP_TITLE'] . ' (' . $aRow2 ['MEMBERS_NUMBER'] . ' ' . ((int) $aRow2 ['MEMBERS_NUMBER'] == 1 ? G::LoadTranslation('ID_USER') : G::LoadTranslation('ID_USERS')) . ')
' : $aRow ['GRP_TITLE'] . ' ' . $aRow2 ['GROUP_INACTIVE']), 'TAS_UID' => $aRow ['TAS_UID'], 'USR_UID' => $aRow ['USR_UID'], 'TU_TYPE' => $aRow ['TU_TYPE'], 'TU_RELATION' => $aRow ['TU_RELATION']);
+ $oDataset->next();
+ }
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
+ $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
+ $oCriteria->addSelectColumn(TaskUserPeer::TAS_UID);
+ $oCriteria->addSelectColumn(TaskUserPeer::USR_UID);
+ $oCriteria->addSelectColumn(TaskUserPeer::TU_TYPE);
+ $oCriteria->addSelectColumn(TaskUserPeer::TU_RELATION);
+ $oCriteria->addJoin(TaskUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
+ $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID);
+ $oCriteria->add(TaskUserPeer::TU_TYPE, $iType);
+ $oCriteria->add(TaskUserPeer::TU_RELATION, 1);
+ $oDataset = TaskUserPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aUsers [] = array('LABEL' => $aRow ['USR_FIRSTNAME'] . ' ' . $aRow ['USR_LASTNAME'], 'TAS_UID' => $aRow ['TAS_UID'], 'USR_UID' => $aRow ['USR_UID'], 'TU_TYPE' => $aRow ['TU_TYPE'], 'TU_RELATION' => $aRow ['TU_RELATION']);
+ $oDataset->next();
+ }
+ global $_DBArray;
+ $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
+ $_DBArray ['taskUsers'] = $aUsers;
+ $_SESSION ['_DBArray'] = $_DBArray;
+ G::LoadClass('ArrayPeer');
+ $oCriteria = new Criteria('dbarray');
+ $oCriteria->setDBArrayTable('taskUsers');
+ $oCriteria->addDescendingOrderByColumn(TaskUserPeer::TU_RELATION);
+ $oCriteria->addAscendingOrderByColumn('LABEL');
+ return $oCriteria;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Return the available users and users groups list criteria object
+ * @param string $sTaskUID
+ * @param integer $iType
+ * @return object
+ */
+
+ function getAvailableUsersCriteria($sTaskUID = '', $iType = 1) {
+ try {
+ $oTasks = new Tasks ( );
+ $aAux = $oTasks->getGroupsOfTask($sTaskUID, $iType);
+ $aUIDS1 = array();
+ $aUIDS2 = array();
+ foreach ($aAux as $aGroup) {
+ $aUIDS1 [] = $aGroup ['GRP_UID'];
+ }
+ $aAux = $oTasks->getUsersOfTask($sTaskUID, $iType);
+ foreach ($aAux as $aUser) {
+ $aUIDS2 [] = $aUser ['USR_UID'];
+ }
+ $aUsers = array();
+ $aUsers [] = array('LABEL' => 'char', 'TAS_UID' => 'char', 'USR_UID' => 'char', 'TU_TYPE' => 'integer', 'TU_RELATION' => 'integer');
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $groups = new Groupwf();
+ $start = '';
+ $limit = '';
+ $filter = '';
+ $result = $groups->getAllGroup($start,$limit,$filter);
+ $c = 0;
+ foreach ($result['rows'] as $results) {
+ $c++;
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn('COUNT(*) AS MEMBERS_NUMBER');
+ $oCriteria->add(GroupUserPeer::GRP_UID, $results ['GRP_UID']);
+ $oDataset2 = GroupUserPeer::doSelectRS($oCriteria);
+ $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset2->next();
+ $aRow2 = $oDataset2->getRow();
+ $aUsers [] = array ('LABEL' => $results ['GRP_TITLE'] .' (' . $aRow2 ['MEMBERS_NUMBER'] . ' ' . ((int) $aRow2 ['MEMBERS_NUMBER'] == 1 ? G::LoadTranslation('ID_USER') : G::LoadTranslation('ID_USERS')) . ')
', 'TAS_UID' => $sTaskUID, 'USR_UID' => $results ['GRP_UID'], 'TU_TYPE' => $iType, 'TU_RELATION' => 2);
+ }
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(UsersPeer::USR_UID);
+ $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
+ $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
+ $oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
+ $oCriteria->add(UsersPeer::USR_UID, $aUIDS2, Criteria::NOT_IN);
+ $oDataset = UsersPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aUsers [] = array('LABEL' => $aRow ['USR_FIRSTNAME'] . ' ' . $aRow ['USR_LASTNAME'], 'TAS_UID' => $sTaskUID, 'USR_UID' => $aRow ['USR_UID'], 'TU_TYPE' => $iType, 'TU_RELATION' => 1);
+ $oDataset->next();
+ }
+ global $_DBArray;
+ $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
+ $_DBArray ['availableUsers'] = $aUsers;
+ $_SESSION ['_DBArray'] = $_DBArray;
+ G::LoadClass('ArrayPeer');
+ $oCriteria = new Criteria('dbarray');
+ $oCriteria->setDBArrayTable('availableUsers');
+ $oCriteria->addDescendingOrderByColumn(TaskUserPeer::TU_RELATION);
+ $oCriteria->addAscendingOrderByColumn('LABEL');
+ return $oCriteria;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Conditions of the steps
+ * @param string $sProcessUID
+ * @param string $sTaskUID
+ * @return boolean
+ */
+
+ function stepsConditions($sProcessUID = '', $sTaskUID = '') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ $oTask = new Task ( );
+ $aFields = $oTask->load($sTaskUID);
+
+ $aFields ['PROCESS'] = $sProcessUID;
+ $aFields ['TASK'] = $sTaskUID;
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'steps/conditions_List', $this->getStepsCriteria($sTaskUID), $aFields);
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Triggers of the steps
+ * @param string $sProcessUID
+ * @param string $sTaskUID
+ * @return boolean
+ */
+
+ function stepsTriggers($sProcessUID = '', $sTaskUID = '') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ $oTask = new Task ( );
+ $aFields = $oTask->load($sTaskUID);
+
+ $_SESSION ['PROCESS'] = $sProcessUID;
+ $_SESSION ['TASK'] = $sTaskUID;
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('view', 'steps/triggers_Tree');
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Add a new task
+ * @param string $sProcessUID
+ * @param integer $iX
+ * @param integer $iY
+ * @return string
+ */
+
+ function addTask($sProcessUID = '', $iX = 0, $iY = 0, $iWidth = 165, $iHeight = 40) {
+ try {
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn('TAS_UID');
+ $oCriteria->add(TaskPeer::PRO_UID, $sProcessUID);
+ $oDataset = TaskPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+
+ $aTasks = array();
+ $iTaskNumber = 0;
+
+ while ($oDataset->next()) {
+ $aRow = $oDataset->getRow();
+
+ $aTasks[] = $aRow ["TAS_UID"];
+ $iTaskNumber = $iTaskNumber + 1;
+ }
+
+ if ($iTaskNumber > 0) {
+ $criteria = new Criteria("workflow");
+
+ $criteria->addSelectColumn(ContentPeer::CON_LANG);
+ $criteria->addSelectColumn(ContentPeer::CON_VALUE);
+ $criteria->add(ContentPeer::CON_ID, $aTasks, Criteria::IN);
+ $criteria->add(ContentPeer::CON_CATEGORY, "TAS_TITLE");
+
+ $rsSQLCON = ContentPeer::doSelectRS($criteria);
+ $rsSQLCON->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+
+ $numMaxLang = 0;
+ $numMax = 0;
+
+ while ($rsSQLCON->next()) {
+ $row = $rsSQLCON->getRow();
+
+ $conLang = $row["CON_LANG"];
+ $conValue = $row["CON_VALUE"];
+
+ if (preg_match("/^\S+\s(\d+)$/", $conValue, $matches)) {
+ $n = intval($matches[1]);
+
+ if ($conLang == SYS_LANG) {
+ if ($n > $numMaxLang) {
+ $numMaxLang = $n;
+ }
+ }
+ else {
+ if ($n > $numMax) {
+ $numMax = $n;
+ }
+ }
}
}
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $oTask = new Task ( );
- $aTask = $oTask->load($sTaskUID);
- if ($aFields ['TAS_TYPE'] == 'TRUE') {
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'users/users_ShortList', $this->getTaskUsersCriteria($sTaskUID, $_SESSION ['iType']), $aFields);
- } else {
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'users/users_ShortList2', $this->getTaskUsersCriteria($sTaskUID, $_SESSION ['iType']), $aFields);
+ if ($numMaxLang > 0) {
+ $numMax = $numMaxLang;
}
-<<<<<<< HEAD
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
-=======
+ if ($numMax > 0 && $numMax > $iTaskNumber) {
+ $iTaskNumber = $numMax + 1;
+ }
+ else {
+ $iTaskNumber = $iTaskNumber + 1;
+ }
+ }
+ else {
+ $iTaskNumber = 1;
+ }
+
+ $oTask = new Task();
+ $oNewTask->label = G::LoadTranslation('ID_TASK') . ' ' . $iTaskNumber;
+ $oNewTask->uid = $oTask->create(array('PRO_UID' => $sProcessUID, 'TAS_TITLE' => $oNewTask->label, 'TAS_POSX' => $iX, 'TAS_POSY' => $iY, 'TAS_WIDTH' => $iWidth, 'TAS_HEIGHT' => $iHeight));
+ $oNewTask->statusIcons = array();
+ $oNewTask->statusIcons[] = array('label' => '', 'icon' => '/images/alert.gif', 'message' => '', 'url' => '');
+ $oJSON = new Services_JSON();
+
+ return $oJSON->encode($oNewTask);
+ }
+ catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Edit the task properties
+ * @param string $sTaskUID
+ * @return boolean
+ */
+
+ function editTaskProperties($sTaskUID = '', $iForm = 1, $iIndex = 0) {
+ $sw_template=false;
+ try {
+ switch ($iForm) {
+ case 1 :
+ $sFilename = 'tasks/tasks_Definition.xml';
+ break;
+ case 2 :
+ $sFilename = 'tasks/tasks_AssignmentRules.xml';
+ break;
+ case 3 :
+ $sFilename = 'tasks/tasks_TimingControl.xml';
+ break;
+ case 4 :
+ $sFilename = 'tasks/tasks_Owner.xml';
+ break;
+ case 5 :
+ $sFilename = 'tasks/tasks_Permissions.xml';
+ break;
+ case 6 :
+ $sFilename = 'tasks/tasks_Labels.xml';
+ break;
+ case 7 :
+ $sFilename = 'tasks/tasks_Notifications.xml';
+ break;
+ default:
+ //if the $iForm is not one of the defaults then search under Plugins for an extended property. By JHL Jan 18, 2011
+ $oPluginRegistry =& PMPluginRegistry::getSingleton();
+ $activePluginsForTaskProperties=$oPluginRegistry->getTaskExtendedProperties();
+ $oPM->taskOptions = array();
+ foreach($activePluginsForTaskProperties as $key => $taskPropertiesInfo){
+ $id=$taskPropertiesInfo->sNamespace."--".$taskPropertiesInfo->sName;
+ if($id==$iForm){
+ $sFilename=$taskPropertiesInfo->sPage;
+ $sw_template=true;
+ }
+ }
+
+ //$sFilename = 'tasks/tasks_Owner.xml';
+ break;
+ }
+ $oTask = new Task ( );
+ $aFields = $oTask->load($sTaskUID);
+ $aFields ['INDEX'] = $iIndex;
+ $aFields ['IFORM'] = $iForm;
+ $aFields ['LANG'] = SYS_LANG;
+
+ /** Task Notifications **/
+ if($iForm == 7 || $iForm == 1 ) {
+ G::loadClass('processes');
+ $files = Processes::getProcessFiles($aFields['PRO_UID'], 'mail');
+
+ $templates = array();
+ $templates[] = 'dummy';
+
+ foreach ($files as $file) {
+ $templates[] = array('FILE' => $file['filename'], 'NAME' => $file['filename']);
+ }
+
+ global $_DBArray;
+ $_DBArray['_TEMPLATES1'] = $templates;
+ $_SESSION['_DBArray'] = $_DBArray;
+
+ if ($iForm == 7) {
+ // Additional configuration
+ G::loadClass('configuration');
+ $oConf = new Configurations;
+ $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aFields['TAS_UID'], '', '');
+ $conf = $oConf->aConfig;
+ if( isset($conf['TAS_DEF_MESSAGE_TYPE']) && isset($conf['TAS_DEF_MESSAGE_TYPE'])) {
+ $aFields['TAS_DEF_MESSAGE_TYPE'] = $conf['TAS_DEF_MESSAGE_TYPE'];
+ $aFields['TAS_DEF_MESSAGE_TEMPLATE'] = $conf['TAS_DEF_MESSAGE_TEMPLATE'];
+ }
+ }
+ }
+
+ if ($iForm == 3) { //Load Calendar Information
+ $calendar = new Calendar ( );
+ $calendarObj = $calendar->getCalendarList(true, true);
+
+ global $_DBArray;
+
+ $_DBArray ['availableCalendars'] = $calendarObj ['array'];
+
+ $_SESSION ['_DBArray'] = $_DBArray;
+
+ $calendarInfo = $calendar->getCalendarFor($sTaskUID, $sTaskUID, $sTaskUID);
+
//If the function returns a DEFAULT calendar it means that this object doesn't have assigned any calendar
$aFields ['TAS_CALENDAR'] = $calendarInfo ['CALENDAR_APPLIED'] != 'DEFAULT' ? $calendarInfo ['CALENDAR_UID'] : "";
}
-
- if ($iForm == 2) {
- if ($aFields['TAS_ASSIGN_TYPE'] == 'SELF_SERVICE' && $aFields['TAS_GROUP_VARIABLE'] != '') {
- $aFields['TAS_ASSIGN_TYPE'] = 'SELF_SERVICE_EVALUATE';
- }
- }
-
global $G_PUBLISH;
G::LoadClass('xmlfield_InputPM');
$G_PUBLISH = new Publisher ( );
@@ -1016,1251 +1445,927 @@ class processMap {
$G_PUBLISH->AddContent('view', $sFilename);
}else{
$G_PUBLISH->AddContent('xmlform', 'xmlform', $sFilename, '', $aFields);
->>>>>>> upstream/master
- }
- }
-
- /*
- * Users Adhoc assigned to Tasks
- * @param string $sProcessUID
- * @param string $sTaskUID
- * @return boolean
- */
- public function users_adhoc($sProcessUID = '', $sTaskUID = '')
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- $oTask = new Task ( );
- $aFields = $oTask->load($sTaskUID);
-
- $_SESSION ['iType'] = 2;
-
- $aFields ['TASK'] = $sTaskUID;
- $aFields ['TYPE'] = $_SESSION ['iType'];
- $aFields ['OF_TO_ASSIGN'] = G::LoadTranslation('ID_DE_ASSIGN');
- $aFields ['CONFIRM'] = G::LoadTranslation('ID_MSG_CONFIRM_DEASIGN_USER_GROUP_MESSAGE');
- $aFields ['UIDS'] = "'0'";
-
- $oTasks = new Tasks ( );
- $oGroups = new Groups ( );
- $aAux1 = $oTasks->getGroupsOfTask($sTaskUID, $_SESSION ['iType']);
- foreach ($aAux1 as $aGroup) {
- $aAux2 = $oGroups->getUsersOfGroup($aGroup ['GRP_UID']);
- foreach ($aAux2 as $aUser) {
- $aFields ['UIDS'] .= ",'" . $aUser ['USR_UID'] . "'";
- }
- }
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $oTask = new Task ( );
- $aTask = $oTask->load($sTaskUID);
-
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'users/users_ShortListAdhoc', $this->getTaskUsersCriteria($sTaskUID, $_SESSION ['iType']), $aFields);
-
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Return the tasks users list criteria object
- * @param string $sTaskUID
- * @param integer $iType
- * @return array
- */
- public function getTaskUsersCriteria($sTaskUID = '', $iType = 1)
- {
- try {
- $aUsers = array();
- $aUsers [] = array('LABEL' => 'char', 'TAS_UID' => 'char', 'USR_UID' => 'char', 'TU_TYPE' => 'integer', 'TU_RELATION' => 'integer');
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addAsColumn('GRP_TITLE', 'C.CON_VALUE');
- $oCriteria->addSelectColumn(TaskUserPeer::TAS_UID);
- $oCriteria->addSelectColumn(TaskUserPeer::USR_UID);
- $oCriteria->addSelectColumn(TaskUserPeer::TU_TYPE);
- $oCriteria->addSelectColumn(TaskUserPeer::TU_RELATION);
- $oCriteria->addAlias('C', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(TaskUserPeer::USR_UID, 'C.CON_ID');
- $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'GRP_TITLE' . $sDelimiter);
- $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID);
- $oCriteria->add(TaskUserPeer::TU_TYPE, $iType);
- $oCriteria->add(TaskUserPeer::TU_RELATION, 2);
- $oDataset = TaskUserPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $c = 0;
- while ($aRow = $oDataset->getRow()) {
- $c++;
- $oGroup = new Groupwf ( );
- $aFields = $oGroup->load($aRow ['USR_UID']);
- if ($aFields ['GRP_STATUS'] == 'ACTIVE') {
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn('COUNT(*) AS MEMBERS_NUMBER');
- $oCriteria->add(GroupUserPeer::GRP_UID, $aRow ['USR_UID']);
- $oDataset2 = GroupUserPeer::doSelectRS($oCriteria);
- $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset2->next();
- $aRow2 = $oDataset2->getRow();
- } else {
- $aRow2 ['GROUP_INACTIVE'] = '(' . G::LoadTranslation('ID_GROUP_INACTIVE') . ')';
- }
- $aUsers [] = array('LABEL' => (!isset($aRow2 ['GROUP_INACTIVE']) ? $aRow ['GRP_TITLE'] . ' (' . $aRow2 ['MEMBERS_NUMBER'] . ' ' . ((int) $aRow2 ['MEMBERS_NUMBER'] == 1 ? G::LoadTranslation('ID_USER') : G::LoadTranslation('ID_USERS')) . ')
' : $aRow ['GRP_TITLE'] . ' ' . $aRow2 ['GROUP_INACTIVE']), 'TAS_UID' => $aRow ['TAS_UID'], 'USR_UID' => $aRow ['USR_UID'], 'TU_TYPE' => $aRow ['TU_TYPE'], 'TU_RELATION' => $aRow ['TU_RELATION']);
- $oDataset->next();
- }
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
- $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
- $oCriteria->addSelectColumn(TaskUserPeer::TAS_UID);
- $oCriteria->addSelectColumn(TaskUserPeer::USR_UID);
- $oCriteria->addSelectColumn(TaskUserPeer::TU_TYPE);
- $oCriteria->addSelectColumn(TaskUserPeer::TU_RELATION);
- $oCriteria->addJoin(TaskUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
- $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID);
- $oCriteria->add(TaskUserPeer::TU_TYPE, $iType);
- $oCriteria->add(TaskUserPeer::TU_RELATION, 1);
- $oDataset = TaskUserPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $aUsers [] = array('LABEL' => $aRow ['USR_FIRSTNAME'] . ' ' . $aRow ['USR_LASTNAME'], 'TAS_UID' => $aRow ['TAS_UID'], 'USR_UID' => $aRow ['USR_UID'], 'TU_TYPE' => $aRow ['TU_TYPE'], 'TU_RELATION' => $aRow ['TU_RELATION']);
- $oDataset->next();
- }
- global $_DBArray;
- $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
- $_DBArray ['taskUsers'] = $aUsers;
- $_SESSION ['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('taskUsers');
- $oCriteria->addDescendingOrderByColumn(TaskUserPeer::TU_RELATION);
- $oCriteria->addAscendingOrderByColumn('LABEL');
- return $oCriteria;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Return the available users and users groups list criteria object
- * @param string $sTaskUID
- * @param integer $iType
- * @return object
- */
- public function getAvailableUsersCriteria($sTaskUID = '', $iType = 1)
- {
- try {
- $oTasks = new Tasks ( );
- $aAux = $oTasks->getGroupsOfTask($sTaskUID, $iType);
- $aUIDS1 = array();
- $aUIDS2 = array();
- foreach ($aAux as $aGroup) {
- $aUIDS1 [] = $aGroup ['GRP_UID'];
- }
- $aAux = $oTasks->getUsersOfTask($sTaskUID, $iType);
- foreach ($aAux as $aUser) {
- $aUIDS2 [] = $aUser ['USR_UID'];
- }
- $aUsers = array();
- $aUsers [] = array('LABEL' => 'char', 'TAS_UID' => 'char', 'USR_UID' => 'char', 'TU_TYPE' => 'integer', 'TU_RELATION' => 'integer');
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $groups = new Groupwf();
- $start = '';
- $limit = '';
- $filter = '';
- $result = $groups->getAllGroup($start,$limit,$filter);
- $c = 0;
- foreach ($result['rows'] as $results) {
- $c++;
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn('COUNT(*) AS MEMBERS_NUMBER');
- $oCriteria->add(GroupUserPeer::GRP_UID, $results ['GRP_UID']);
- $oDataset2 = GroupUserPeer::doSelectRS($oCriteria);
- $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset2->next();
- $aRow2 = $oDataset2->getRow();
- $aUsers [] = array ('LABEL' => $results ['GRP_TITLE'] .' (' . $aRow2 ['MEMBERS_NUMBER'] . ' ' . ((int) $aRow2 ['MEMBERS_NUMBER'] == 1 ? G::LoadTranslation('ID_USER') : G::LoadTranslation('ID_USERS')) . ')
', 'TAS_UID' => $sTaskUID, 'USR_UID' => $results ['GRP_UID'], 'TU_TYPE' => $iType, 'TU_RELATION' => 2);
- }
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(UsersPeer::USR_UID);
- $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
- $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
- $oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
- $oCriteria->add(UsersPeer::USR_UID, $aUIDS2, Criteria::NOT_IN);
- $oDataset = UsersPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $aUsers [] = array('LABEL' => $aRow ['USR_FIRSTNAME'] . ' ' . $aRow ['USR_LASTNAME'], 'TAS_UID' => $sTaskUID, 'USR_UID' => $aRow ['USR_UID'], 'TU_TYPE' => $iType, 'TU_RELATION' => 1);
- $oDataset->next();
- }
- global $_DBArray;
- $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
- $_DBArray ['availableUsers'] = $aUsers;
- $_SESSION ['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('availableUsers');
- $oCriteria->addDescendingOrderByColumn(TaskUserPeer::TU_RELATION);
- $oCriteria->addAscendingOrderByColumn('LABEL');
- return $oCriteria;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Conditions of the steps
- * @param string $sProcessUID
- * @param string $sTaskUID
- * @return boolean
- */
-
- public function stepsConditions($sProcessUID = '', $sTaskUID = '')
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- $oTask = new Task ( );
- $aFields = $oTask->load($sTaskUID);
-
- $aFields ['PROCESS'] = $sProcessUID;
- $aFields ['TASK'] = $sTaskUID;
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'steps/conditions_List', $this->getStepsCriteria($sTaskUID), $aFields);
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Triggers of the steps
- * @param string $sProcessUID
- * @param string $sTaskUID
- * @return boolean
- */
- public function stepsTriggers($sProcessUID = '', $sTaskUID = '')
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- $oTask = new Task ( );
- $aFields = $oTask->load($sTaskUID);
-
- $_SESSION ['PROCESS'] = $sProcessUID;
- $_SESSION ['TASK'] = $sTaskUID;
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('view', 'steps/triggers_Tree');
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Add a new task
- * @param string $sProcessUID
- * @param integer $iX
- * @param integer $iY
- * @return string
- */
- public function addTask($sProcessUID = '', $iX = 0, $iY = 0, $iWidth = 165, $iHeight = 40)
- {
- try {
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn('TAS_UID');
- $oCriteria->add(TaskPeer::PRO_UID, $sProcessUID);
- $oDataset = TaskPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
-
- $aTasks = array();
- $iTaskNumber = 0;
-
- while ($oDataset->next()) {
- $aRow = $oDataset->getRow();
- $aTasks[] = $aRow ["TAS_UID"];
- $iTaskNumber = $iTaskNumber + 1;
- }
-
- if ($iTaskNumber > 0) {
- $criteria = new Criteria("workflow");
- $criteria->addSelectColumn(ContentPeer::CON_LANG);
- $criteria->addSelectColumn(ContentPeer::CON_VALUE);
- $criteria->add(ContentPeer::CON_ID, $aTasks, Criteria::IN);
- $criteria->add(ContentPeer::CON_CATEGORY, "TAS_TITLE");
-
- $rsSQLCON = ContentPeer::doSelectRS($criteria);
- $rsSQLCON->setFetchmode(ResultSet::FETCHMODE_ASSOC);
-
- $numMaxLang = 0;
- $numMax = 0;
-
- while ($rsSQLCON->next()) {
- $row = $rsSQLCON->getRow();
-
- $conLang = $row["CON_LANG"];
- $conValue = $row["CON_VALUE"];
-
- if (preg_match("/^\S+\s(\d+)$/", $conValue, $matches)) {
- $n = intval($matches[1]);
-
- if ($conLang == SYS_LANG) {
- if ($n > $numMaxLang) {
- $numMaxLang = $n;
- }
- } else {
- if ($n > $numMax) {
- $numMax = $n;
- }
- }
- }
- }
-
- if ($numMaxLang > 0) {
- $numMax = $numMaxLang;
- }
-
- if ($numMax > 0 && $numMax > $iTaskNumber) {
- $iTaskNumber = $numMax + 1;
- } else {
- $iTaskNumber = $iTaskNumber + 1;
- }
- } else {
- $iTaskNumber = 1;
- }
-
- $oTask = new Task();
- $oNewTask->label = G::LoadTranslation('ID_TASK') . ' ' . $iTaskNumber;
- $oNewTask->uid = $oTask->create(array('PRO_UID' => $sProcessUID, 'TAS_TITLE' => $oNewTask->label, 'TAS_POSX' => $iX, 'TAS_POSY' => $iY, 'TAS_WIDTH' => $iWidth, 'TAS_HEIGHT' => $iHeight));
- $oNewTask->statusIcons = array();
- $oNewTask->statusIcons[] = array('label' => '', 'icon' => '/images/alert.gif', 'message' => '', 'url' => '');
- $oJSON = new Services_JSON();
-
- return $oJSON->encode($oNewTask);
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Edit the task properties
- * @param string $sTaskUID
- * @return boolean
- */
- public function editTaskProperties($sTaskUID = '', $iForm = 1, $iIndex = 0)
- {
- $sw_template=false;
- try {
- switch ($iForm) {
- case 1 :
- $sFilename = 'tasks/tasks_Definition.xml';
- break;
- case 2 :
- $sFilename = 'tasks/tasks_AssignmentRules.xml';
- break;
- case 3 :
- $sFilename = 'tasks/tasks_TimingControl.xml';
- break;
- case 4 :
- $sFilename = 'tasks/tasks_Owner.xml';
- break;
- case 5 :
- $sFilename = 'tasks/tasks_Permissions.xml';
- break;
- case 6 :
- $sFilename = 'tasks/tasks_Labels.xml';
- break;
- case 7 :
- $sFilename = 'tasks/tasks_Notifications.xml';
- break;
- default:
- //if the $iForm is not one of the defaults then search under Plugins for an extended property. By JHL Jan 18, 2011
- $oPluginRegistry =& PMPluginRegistry::getSingleton();
- $activePluginsForTaskProperties=$oPluginRegistry->getTaskExtendedProperties();
- $oPM->taskOptions = array();
- foreach($activePluginsForTaskProperties as $key => $taskPropertiesInfo){
- $id=$taskPropertiesInfo->sNamespace."--".$taskPropertiesInfo->sName;
- if ($id==$iForm){
- $sFilename=$taskPropertiesInfo->sPage;
- $sw_template=true;
- }
- }
-
- //$sFilename = 'tasks/tasks_Owner.xml';
- break;
- }
- $oTask = new Task ( );
- $aFields = $oTask->load($sTaskUID);
- $aFields ['INDEX'] = $iIndex;
- $aFields ['IFORM'] = $iForm;
- $aFields ['LANG'] = SYS_LANG;
-
- /** Task Notifications **/
- if ($iForm == 7 || $iForm == 1 ) {
- G::loadClass('processes');
- $files = Processes::getProcessFiles($aFields['PRO_UID'], 'mail');
-
- $templates = array();
- $templates[] = 'dummy';
-
- foreach ($files as $file) {
- $templates[] = array('FILE' => $file['filename'], 'NAME' => $file['filename']);
- }
-
- global $_DBArray;
- $_DBArray['_TEMPLATES1'] = $templates;
- $_SESSION['_DBArray'] = $_DBArray;
-
- if ($iForm == 7) {
- // Additional configuration
- G::loadClass('configuration');
- $oConf = new Configurations;
- $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aFields['TAS_UID'], '', '');
- $conf = $oConf->aConfig;
- if ( isset($conf['TAS_DEF_MESSAGE_TYPE']) && isset($conf['TAS_DEF_MESSAGE_TYPE'])) {
- $aFields['TAS_DEF_MESSAGE_TYPE'] = $conf['TAS_DEF_MESSAGE_TYPE'];
- $aFields['TAS_DEF_MESSAGE_TEMPLATE'] = $conf['TAS_DEF_MESSAGE_TEMPLATE'];
- }
- }
- }
-
- if ($iForm == 3) { //Load Calendar Information
- $calendar = new Calendar ( );
- $calendarObj = $calendar->getCalendarList(true, true);
-
- global $_DBArray;
-
- $_DBArray ['availableCalendars'] = $calendarObj ['array'];
-
- $_SESSION ['_DBArray'] = $_DBArray;
-
- $calendarInfo = $calendar->getCalendarFor($sTaskUID, $sTaskUID, $sTaskUID);
-
- //If the function returns a DEFAULT calendar it means that this object doesn't have assigned any calendar
- $aFields ['TAS_CALENDAR'] = $calendarInfo ['CALENDAR_APPLIED'] != 'DEFAULT' ? $calendarInfo ['CALENDAR_UID'] : "";
- }
- global $G_PUBLISH;
- G::LoadClass('xmlfield_InputPM');
- $G_PUBLISH = new Publisher ( );
- if ($sw_template){
- $G_PUBLISH->AddContent('view', $sFilename);
- } else {
- $G_PUBLISH->AddContent('xmlform', 'xmlform', $sFilename, '', $aFields);
- }
-
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Save the tasks positions
- * @param string $sTaskUID
- * @param integer $iX
- * @param integer $iY
- * @return integer
- */
- public function saveTaskPosition($sTaskUID = '', $iX = 0, $iY = 0)
- {
- try {
- $oTask = new Task ( );
- $aFields = $oTask->load($sTaskUID);
-
- $aFields ['TAS_UID'] = $sTaskUID;
- $aFields ['TAS_POSX'] = $iX;
- $aFields ['TAS_POSY'] = $iY;
- return $oTask->update($aFields);
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Delete a task
- * @param string $sTaskUID
- * @return boolean
- */
- public function deleteTask($sTaskUID = '')
- {
- try {
- $oTasks = new Tasks ( );
- $oTasks->deleteTask($sTaskUID);
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Delete a gateway
- * @param string $sProcessUID
- * @param string $sGatewayUID
- * @return boolean
- */
- public function deleteGateway($sProcessUID = '', $sGatewayUID = '')
- {
- try {
- //First get all routes information related to $sGatewayUID
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn('ROU_UID');
- $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
- $oCriteria->add(RoutePeer::GAT_UID, $sGatewayUID);
- $oDataset = RoutePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while($aRow = $oDataset->getRow()){
- $aRoutes [] = $aRow ['ROU_UID'];
- $oDataset->next();
- }
-
- $oGateway = new Gateway ( );
- if ($oGateway->gatewayExists($sGatewayUID))
- {
- $oTasks = new Tasks ( );
- $res = $oGateway->remove($sGatewayUID);
- if ($res){
- $oRoute = new Route( );
- foreach($aRoutes as $sRouteId){
- $oRoute->remove($sRouteId);
- }
- }
- }
- return;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Add a gateway
- * @param string $sProcessUID
- * @param string $sGatewayUID
- * @return boolean
- */
- public function addGateway($oData)
- {
- try {
- $oGateway = new Gateway ( );
- $aData = array();
- $aData['PRO_UID'] = $oData->pro_uid;
- $aData['GAT_X'] = $oData->position->x;
- $aData['GAT_Y'] = $oData->position->y;
- $aData['GAT_TYPE'] = $oData->gat_type;
- $sGat_uid = $oData->gat_uid;
- $oGatewayData = GatewayPeer::retrieveByPK($sGat_uid);
- if (is_null($oGatewayData)) {
- $sGat_uid = $oGateway->create($aData);
- } else {
- $aData['GAT_UID'] = $sGat_uid;
- if (isset($oData->tas_from)) {
- $aData['TAS_UID'] = $oData->tas_from;
- }
- if (isset($oData->tas_to)) {
- $aData['GAT_NEXT_TASK'] = $oData->tas_to;
- }
- $oGateway->update($aData);
- }
- $oEncode->uid = $sGat_uid;
- $oJSON = new Services_JSON ( );
- return $oJSON->encode($oEncode);
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Add a new guide
- * @param string $sProcessUID
- * @param integer $iPosition
- * @param string $sDirection
- * @return string
- */
- public function addGuide($sProcessUID = '', $iPosition = 0, $sDirection = 'vertical')
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- $oSL = new SwimlanesElements ( );
- switch ($sDirection) {
- case 'vertical' :
- $oNewGuide->uid = $oSL->create(array('PRO_UID' => $sProcessUID, 'SWI_TYPE' => 'LINE', 'SWI_X' => $iPosition, 'SWI_Y' => 0));
- break;
- case 'horizontal' :
- $oNewGuide->uid = $oSL->create(array('PRO_UID' => $sProcessUID, 'SWI_TYPE' => 'LINE', 'SWI_X' => 0, 'SWI_Y' => $iPosition));
- break;
- }
- $oJSON = new Services_JSON ( );
- return $oJSON->encode($oNewGuide);
- } catch (Exception $oError) {
- throw ($oError);
- }
}
- /*
- * Save the guide position
- * @param string $sSEUID
- * @param integer $iPosition
- * @param string $sDirection
- * @return integer
- */
- public function saveGuidePosition($sSEUID = '', $iPosition = 0, $sDirection = 'vertical')
- {
- try {
- $oSL = new SwimlanesElements ( );
- $aFields = $oSL->load($sSEUID);
- switch ($sDirection) {
- case 'vertical' :
- return $oSL->update(array('SWI_UID' => $sSEUID, 'SWI_X' => $iPosition));
- break;
- case 'horizontal' :
- return $oSL->update(array('SWI_UID' => $sSEUID, 'SWI_Y' => $iPosition));
- break;
- }
- } catch (Exception $oError) {
- throw ($oError);
- }
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
}
-
- /*
- * Delete a guide
- * @param string $sUID
- * @return boolean
- */
- public function deleteGuide($sSEUID = '')
- {
- try {
- $oSL = new SwimlanesElements ( );
- $aFields = $oSL->load($sSEUID);
- $oSL->remove($sSEUID);
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Delete all guides
- * @param string $sProcessUID
- * @return boolean
- */
- public function deleteGuides($sProcessUID = '')
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(SwimlanesElementsPeer::PRO_UID, $sProcessUID);
- $oCriteria->add(SwimlanesElementsPeer::SWI_TYPE, 'LINE');
- SwimlanesElementsPeer::doDelete($oCriteria);
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Add a new text
- * @param string $sProcessUID
- * @param string $sLabel
- * @param integer $iX
- * @param integer $iY
- * @return string
- */
- public function addText($sProcessUID = '', $sLabel = '', $iX = 0, $iY = 0 , $sNext_uid = '')
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- $oSL = new SwimlanesElements ( );
- $oNewText->uid = $oSL->create(array('PRO_UID' => $sProcessUID, 'SWI_TYPE' => 'TEXT', 'SWI_TEXT' => $sLabel, 'SWI_X' => $iX, 'SWI_Y' => $iY,'SWI_NEXT_UID' => $sNext_uid));
- $oJSON = new Services_JSON ( );
- return $oJSON->encode($oNewText);
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Update a text
- * @param string $sSEUID
- * @param string $sLabel
- * @return integer
- */
- public function updateText($sSEUID = '', $sLabel = '' , $sNext_uid = '')
- {
- try {
- $oSL = new SwimlanesElements ( );
- $aFields = $oSL->load($sSEUID);
- return $oSL->update(array('SWI_UID' => $sSEUID, 'SWI_TEXT' => $sLabel,'SWI_NEXT_UID' => $sNext_uid));
- } catch (Exception $oError) {
- throw ($oError);
- }
}
- /*
- * Save the text position
- * @param string $sSEUID
- * @param integer $iX
- * @param integer $iY
- * @return integer
- */
- public function saveTextPosition($sSEUID = '', $iX = 0, $iY = 0)
- {
- try {
- $oSL = new SwimlanesElements ( );
- $aFields = $oSL->load($sSEUID);
- return $oSL->update(array('SWI_UID' => $sSEUID, 'SWI_X' => $iX, 'SWI_Y' => $iY));
- } catch (Exception $oError) {
- throw ($oError);
- }
+ /*
+ * Save the tasks positions
+ * @param string $sTaskUID
+ * @param integer $iX
+ * @param integer $iY
+ * @return integer
+ */
+
+ function saveTaskPosition($sTaskUID = '', $iX = 0, $iY = 0) {
+ try {
+ $oTask = new Task ( );
+ $aFields = $oTask->load($sTaskUID);
+
+ $aFields ['TAS_UID'] = $sTaskUID;
+ $aFields ['TAS_POSX'] = $iX;
+ $aFields ['TAS_POSY'] = $iY;
+ return $oTask->update($aFields);
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Delete a task
+ * @param string $sTaskUID
+ * @return boolean
+ */
+
+ function deleteTask($sTaskUID = '') {
+ try {
+ $oTasks = new Tasks ( );
+ $oTasks->deleteTask($sTaskUID);
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Delete a gateway
+ * @param string $sProcessUID
+ * @param string $sGatewayUID
+ * @return boolean
+ */
+
+ function deleteGateway($sProcessUID = '', $sGatewayUID = '') {
+ try {
+ //First get all routes information related to $sGatewayUID
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn('ROU_UID');
+ $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(RoutePeer::GAT_UID, $sGatewayUID);
+ $oDataset = RoutePeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while($aRow = $oDataset->getRow()){
+ $aRoutes [] = $aRow ['ROU_UID'];
+ $oDataset->next();
+ }
+
+ $oGateway = new Gateway ( );
+ if($oGateway->gatewayExists($sGatewayUID))
+ {
+ $oTasks = new Tasks ( );
+ $res = $oGateway->remove($sGatewayUID);
+ if($res){
+ $oRoute = new Route( );
+ foreach($aRoutes as $sRouteId){
+ $oRoute->remove($sRouteId);
+ }
+ }
+ }
+ return;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Add a gateway
+ * @param string $sProcessUID
+ * @param string $sGatewayUID
+ * @return boolean
+ */
+
+ function addGateway($oData) {
+ try {
+ $oGateway = new Gateway ( );
+ $aData = array();
+ $aData['PRO_UID'] = $oData->pro_uid;
+ $aData['GAT_X'] = $oData->position->x;
+ $aData['GAT_Y'] = $oData->position->y;
+ $aData['GAT_TYPE'] = $oData->gat_type;
+ $sGat_uid = $oData->gat_uid;
+ $oGatewayData = GatewayPeer::retrieveByPK($sGat_uid);
+ if (is_null($oGatewayData)) {
+ $sGat_uid = $oGateway->create($aData);
+ }else{
+ $aData['GAT_UID'] = $sGat_uid;
+ if (isset($oData->tas_from))
+ $aData['TAS_UID'] = $oData->tas_from;
+ if (isset($oData->tas_to))
+ $aData['GAT_NEXT_TASK'] = $oData->tas_to;
+ $oGateway->update($aData);
+ }
+ $oEncode->uid = $sGat_uid;
+ $oJSON = new Services_JSON ( );
+ return $oJSON->encode($oEncode);
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Add a new guide
+ * @param string $sProcessUID
+ * @param integer $iPosition
+ * @param string $sDirection
+ * @return string
+ */
+
+ function addGuide($sProcessUID = '', $iPosition = 0, $sDirection = 'vertical') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ $oSL = new SwimlanesElements ( );
+ switch ($sDirection) {
+ case 'vertical' :
+ $oNewGuide->uid = $oSL->create(array('PRO_UID' => $sProcessUID, 'SWI_TYPE' => 'LINE', 'SWI_X' => $iPosition, 'SWI_Y' => 0));
+ break;
+ case 'horizontal' :
+ $oNewGuide->uid = $oSL->create(array('PRO_UID' => $sProcessUID, 'SWI_TYPE' => 'LINE', 'SWI_X' => 0, 'SWI_Y' => $iPosition));
+ break;
+ }
+ $oJSON = new Services_JSON ( );
+ return $oJSON->encode($oNewGuide);
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Save the guide position
+ * @param string $sSEUID
+ * @param integer $iPosition
+ * @param string $sDirection
+ * @return integer
+ */
+
+ function saveGuidePosition($sSEUID = '', $iPosition = 0, $sDirection = 'vertical') {
+ try {
+ $oSL = new SwimlanesElements ( );
+ $aFields = $oSL->load($sSEUID);
+ switch ($sDirection) {
+ case 'vertical' :
+ return $oSL->update(array('SWI_UID' => $sSEUID, 'SWI_X' => $iPosition));
+ break;
+ case 'horizontal' :
+ return $oSL->update(array('SWI_UID' => $sSEUID, 'SWI_Y' => $iPosition));
+ break;
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Delete a guide
+ * @param string $sUID
+ * @return boolean
+ */
+
+ function deleteGuide($sSEUID = '') {
+ try {
+ $oSL = new SwimlanesElements ( );
+ $aFields = $oSL->load($sSEUID);
+ $oSL->remove($sSEUID);
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Delete all guides
+ * @param string $sProcessUID
+ * @return boolean
+ */
+
+ function deleteGuides($sProcessUID = '') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(SwimlanesElementsPeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(SwimlanesElementsPeer::SWI_TYPE, 'LINE');
+ SwimlanesElementsPeer::doDelete($oCriteria);
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Add a new text
+ * @param string $sProcessUID
+ * @param string $sLabel
+ * @param integer $iX
+ * @param integer $iY
+ * @return string
+ */
+
+ function addText($sProcessUID = '', $sLabel = '', $iX = 0, $iY = 0 , $sNext_uid = '') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ $oSL = new SwimlanesElements ( );
+ $oNewText->uid = $oSL->create(array('PRO_UID' => $sProcessUID, 'SWI_TYPE' => 'TEXT', 'SWI_TEXT' => $sLabel, 'SWI_X' => $iX, 'SWI_Y' => $iY,'SWI_NEXT_UID' => $sNext_uid));
+ $oJSON = new Services_JSON ( );
+ return $oJSON->encode($oNewText);
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Update a text
+ * @param string $sSEUID
+ * @param string $sLabel
+ * @return integer
+ */
+
+ function updateText($sSEUID = '', $sLabel = '' , $sNext_uid = '') {
+ try {
+ $oSL = new SwimlanesElements ( );
+ $aFields = $oSL->load($sSEUID);
+ return $oSL->update(array('SWI_UID' => $sSEUID, 'SWI_TEXT' => $sLabel,'SWI_NEXT_UID' => $sNext_uid));
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Save the text position
+ * @param string $sSEUID
+ * @param integer $iX
+ * @param integer $iY
+ * @return integer
+ */
+
+ function saveTextPosition($sSEUID = '', $iX = 0, $iY = 0) {
+ try {
+ $oSL = new SwimlanesElements ( );
+ $aFields = $oSL->load($sSEUID);
+ return $oSL->update(array('SWI_UID' => $sSEUID, 'SWI_X' => $iX, 'SWI_Y' => $iY));
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Delete a text
+ * @param string $sSEUID
+ * @return boolean
+ */
+
+ function deleteText($sSEUID = '') {
+ try {
+ $oSL = new SwimlanesElements ( );
+ $aFields = $oSL->load($sSEUID);
+ $oSL->remove($sSEUID);
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Save the gateways positions
+ * @param string $sGatewayUID
+ * @param integer $iX
+ * @param integer $iY
+ * @return integer
+ */
+
+ function saveGatewayPosition($sGatewayUID = '', $iX = 0, $iY = 0) {
+ try {
+ $oGateway = new Gateway ( );
+ $aFields = $oGateway->load($sGatewayUID);
+
+ $aFields ['GAT_UID'] = $sGatewayUID;
+ $aFields ['GAT_X'] = $iX;
+ $aFields ['GAT_Y'] = $iY;
+ return $oGateway->update($aFields);
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Presents a small list of dynaforms of the process
+ * @param string $sProcessUID
+ * @return boolean
+ */
+
+ function dynaformsList($sProcessUID = '') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'dynaforms/dynaforms_ShortList', $this->getDynaformsCriteria($sProcessUID), $aFields);
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Return the dynaforms list criteria object
+ * @param string $sProcessUID
+ * @return object
+ */
+
+ function getDynaformsCriteria($sProcessUID = '') {
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(DynaformPeer::DYN_UID);
+ $oCriteria->addSelectColumn(DynaformPeer::PRO_UID);
+ $oCriteria->addSelectColumn(DynaformPeer::DYN_TYPE);
+ $oCriteria->addAsColumn('DYN_TITLE', 'C1.CON_VALUE');
+ $oCriteria->addAsColumn('DYN_DESCRIPTION', 'C2.CON_VALUE');
+ $oCriteria->addAlias('C1', 'CONTENT');
+ $oCriteria->addAlias('C2', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(DynaformPeer::DYN_UID, 'C1.CON_ID');
+ $aConditions [] = array('C1.CON_CATEGORY', $sDelimiter . 'DYN_TITLE' . $sDelimiter);
+ $aConditions [] = array('C1.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $aConditions = array();
+ $aConditions [] = array(DynaformPeer::DYN_UID, 'C2.CON_ID');
+ $aConditions [] = array('C2.CON_CATEGORY', $sDelimiter . 'DYN_DESCRIPTION' . $sDelimiter);
+ $aConditions [] = array('C2.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
+
+ $oDataset = DynaformPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $dynaformArray = array();
+ $dynaformArray [] = array('d' => 'char');
+ while ($aRow = $oDataset->getRow()) {
+ if (($aRow ['DYN_TITLE'] == NULL) || ($aRow ['DYN_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
+ $aRow ['DYN_TITLE'] = Content::Load("DYN_TITLE", "", $aRow ['DYN_UID'], SYS_LANG);
+ }
+ if (($aRow ['DYN_DESCRIPTION'] == NULL) || ($aRow ['DYN_DESCRIPTION'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
+ $aRow ['DYN_DESCRIPTION'] = Content::Load("DYN_DESCRIPTION", "", $aRow ['DYN_UID'], SYS_LANG);
+ }
+ $dynaformArray [] = $aRow;
+ $oDataset->next();
}
- /*
- * Delete a text
- * @param string $sSEUID
- * @return boolean
- */
- public function deleteText($sSEUID = '')
- {
- try {
- $oSL = new SwimlanesElements ( );
- $aFields = $oSL->load($sSEUID);
- $oSL->remove($sSEUID);
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
+
+ return $oCriteria;
+ }
+
+ /**
+ * getDynaformsList
+ *
+ * @param string $sProcessUID
+ * @return array $dynaformArray
+ */
+ function getDynaformsList($sProcessUID = '') {
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(DynaformPeer::DYN_UID);
+ $oCriteria->addSelectColumn(DynaformPeer::PRO_UID);
+ $oCriteria->addSelectColumn(DynaformPeer::DYN_TYPE);
+ $oCriteria->addAsColumn('DYN_TITLE', 'C1.CON_VALUE');
+ $oCriteria->addAsColumn('DYN_DESCRIPTION', 'C2.CON_VALUE');
+ $oCriteria->addAlias('C1', 'CONTENT');
+ $oCriteria->addAlias('C2', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(DynaformPeer::DYN_UID, 'C1.CON_ID');
+ $aConditions [] = array('C1.CON_CATEGORY', $sDelimiter . 'DYN_TITLE' . $sDelimiter);
+ $aConditions [] = array('C1.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $aConditions = array();
+ $aConditions [] = array(DynaformPeer::DYN_UID, 'C2.CON_ID');
+ $aConditions [] = array('C2.CON_CATEGORY', $sDelimiter . 'DYN_DESCRIPTION' . $sDelimiter);
+ $aConditions [] = array('C2.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
+
+ $oDataset = DynaformPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $dynaformArray = array();
+ while ($aRow = $oDataset->getRow()) {
+ if (($aRow ['DYN_TITLE'] == NULL) || ($aRow ['DYN_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
+ $aRow ['DYN_TITLE'] = Content::Load("DYN_TITLE", "", $aRow ['DYN_UID'], SYS_LANG);
+ }
+ if (($aRow ['DYN_DESCRIPTION'] == NULL) || ($aRow ['DYN_DESCRIPTION'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
+ $aRow ['DYN_DESCRIPTION'] = Content::Load("DYN_DESCRIPTION", "", $aRow ['DYN_UID'], SYS_LANG);
+ }
+ $dynaformArray [] = $aRow;
+ $oDataset->next();
}
- /*
- * Save the gateways positions
- * @param string $sGatewayUID
- * @param integer $iX
- * @param integer $iY
- * @return integer
- */
- public function saveGatewayPosition($sGatewayUID = '', $iX = 0, $iY = 0)
- {
- try {
- $oGateway = new Gateway ( );
- $aFields = $oGateway->load($sGatewayUID);
+ return $dynaformArray;
+ }
- $aFields ['GAT_UID'] = $sGatewayUID;
- $aFields ['GAT_X'] = $iX;
- $aFields ['GAT_Y'] = $iY;
- return $oGateway->update($aFields);
- } catch (Exception $oError) {
- throw ($oError);
- }
+ /*
+ * Presents a small list of output documents of the process
+ * @param string $sProcessUID
+ * @return boolean
+ */
+
+ function outputdocsList($sProcessUID = '') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'outputdocs/outputdocs_ShortList', $this->getOutputDocumentsCriteria($sProcessUID), $aFields);
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Return the output documents list criteria object
+ * @param string $sProcessUID
+ * @return object
+ */
+
+ function getOutputDocumentsCriteria($sProcessUID = '') {
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(OutputDocumentPeer::OUT_DOC_UID);
+ $oCriteria->addSelectColumn(OutputDocumentPeer::OUT_DOC_TYPE);
+ $oCriteria->addSelectColumn(OutputDocumentPeer::PRO_UID);
+ $oCriteria->addAsColumn('OUT_DOC_TITLE', 'C1.CON_VALUE');
+ $oCriteria->addAsColumn('OUT_DOC_DESCRIPTION', 'C2.CON_VALUE');
+ $oCriteria->addAlias('C1', 'CONTENT');
+ $oCriteria->addAlias('C2', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(OutputDocumentPeer::OUT_DOC_UID, 'C1.CON_ID');
+ $aConditions [] = array('C1.CON_CATEGORY', $sDelimiter . 'OUT_DOC_TITLE' . $sDelimiter);
+ $aConditions [] = array('C1.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $aConditions = array();
+ $aConditions [] = array(OutputDocumentPeer::OUT_DOC_UID, 'C2.CON_ID');
+ $aConditions [] = array('C2.CON_CATEGORY', $sDelimiter . 'OUT_DOC_DESCRIPTION' . $sDelimiter);
+ $aConditions [] = array('C2.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(OutputDocumentPeer::PRO_UID, $sProcessUID);
+
+ $oDataset = OutputDocumentPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $outputDocArray = array();
+ $outputDocArray [] = array('d' => 'char');
+ while ($aRow = $oDataset->getRow()) {
+ if (($aRow ['OUT_DOC_TITLE'] == NULL) || ($aRow ['OUT_DOC_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
+ $outputDocument = new OutputDocument ( );
+ $outputDocumentObj = $outputDocument->load($aRow ['OUT_DOC_UID']);
+ $aRow ['OUT_DOC_TITLE'] = $outputDocumentObj ['OUT_DOC_TITLE'];
+ $aRow ['OUT_DOC_DESCRIPTION'] = $outputDocumentObj ['OUT_DOC_DESCRIPTION'];
+ }
+ $outputDocArray [] = $aRow;
+ $oDataset->next();
+ }
+ global $_DBArray;
+ $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
+ $_DBArray ['outputDocArray'] = $outputDocArray;
+ $_SESSION ['_DBArray'] = $_DBArray;
+ G::LoadClass('ArrayPeer');
+ $oCriteria = new Criteria('dbarray');
+ $oCriteria->setDBArrayTable('outputDocArray');
+
+ return $oCriteria;
+ }
+
+ /*
+ * Presents a small list of input documents of the process
+ * @param string $sProcessUID Process UID
+ * @return void
+ */
+
+ function inputdocsList($sProcessUID = '') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'inputdocs/inputdocs_ShortList', $this->getInputDocumentsCriteria($sProcessUID), $aFields);
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Return the input documents list criteria object
+ * @param string $sProcessUID
+ * @return object
+ */
+
+ function getInputDocumentsCriteria($sProcessUID = '') {
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(InputDocumentPeer::INP_DOC_UID);
+ $oCriteria->addSelectColumn(InputDocumentPeer::PRO_UID);
+ $oCriteria->addAsColumn('INP_DOC_TITLE', 'C1.CON_VALUE');
+ $oCriteria->addAsColumn('INP_DOC_DESCRIPTION', 'C2.CON_VALUE');
+ $oCriteria->addAlias('C1', 'CONTENT');
+ $oCriteria->addAlias('C2', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(InputDocumentPeer::INP_DOC_UID, 'C1.CON_ID');
+ $aConditions [] = array('C1.CON_CATEGORY', $sDelimiter . 'INP_DOC_TITLE' . $sDelimiter);
+ $aConditions [] = array('C1.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $aConditions = array();
+ $aConditions [] = array(InputDocumentPeer::INP_DOC_UID, 'C2.CON_ID');
+ $aConditions [] = array('C2.CON_CATEGORY', $sDelimiter . 'INP_DOC_DESCRIPTION' . $sDelimiter);
+ $aConditions [] = array('C2.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID);
+
+ $oDataset = InputDocumentPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $inputDocArray = "";
+ $inputDocArray [] = array('INP_DOC_UID' => 'char', 'PRO_UID' => 'char', 'INP_DOC_TITLE' => 'char', 'INP_DOC_DESCRIPTION' => 'char');
+ while ($aRow = $oDataset->getRow()) {
+ if (($aRow ['INP_DOC_TITLE'] == NULL) || ($aRow ['INP_DOC_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
+ $inputDocument = new InputDocument ( );
+ $inputDocumentObj = $inputDocument->load($aRow ['INP_DOC_UID']);
+ $aRow ['INP_DOC_TITLE'] = $inputDocumentObj ['INP_DOC_TITLE'];
+ $aRow ['INP_DOC_DESCRIPTION'] = $inputDocumentObj ['INP_DOC_DESCRIPTION'];
+ }
+ $inputDocArray [] = $aRow;
+ $oDataset->next();
+ }
+ global $_DBArray;
+ $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
+
+ $_DBArray ['inputDocArrayMain'] = $inputDocArray;
+ $_SESSION ['_DBArray'] = $_DBArray;
+ G::LoadClass('ArrayPeer');
+ $oCriteria = new Criteria('dbarray');
+ $oCriteria->setDBArrayTable('inputDocArrayMain');
+
+ return $oCriteria;
+ }
+
+ /*
+ * Presents a small list of triggers of the process
+ * @param string $sProcessUID
+ * @return void
+ */
+
+ function triggersList($sProcessUID = '') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'triggers/triggers_ShortList', $this->getTriggersCriteria($sProcessUID), $aFields);
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /*
+ * Return the triggers list criteria object
+ * @param string $sProcessUID
+ * @return object
+ */
+
+ function getTriggersCriteria($sProcessUID = '') {
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(TriggersPeer::TRI_UID);
+ $oCriteria->addSelectColumn(TriggersPeer::PRO_UID);
+ $oCriteria->addAsColumn('TRI_TITLE', 'C1.CON_VALUE');
+ $oCriteria->addAsColumn('TRI_DESCRIPTION', 'C2.CON_VALUE');
+ $oCriteria->addAlias('C1', 'CONTENT');
+ $oCriteria->addAlias('C2', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(TriggersPeer::TRI_UID, 'C1.CON_ID');
+ $aConditions [] = array('C1.CON_CATEGORY', $sDelimiter . 'TRI_TITLE' . $sDelimiter);
+ $aConditions [] = array('C1.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $aConditions = array();
+ $aConditions [] = array(TriggersPeer::TRI_UID, 'C2.CON_ID');
+ $aConditions [] = array('C2.CON_CATEGORY', $sDelimiter . 'TRI_TITLE' . $sDelimiter);
+ $aConditions [] = array('C2.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(TriggersPeer::PRO_UID, $sProcessUID);
+ $oCriteria->addAscendingOrderByColumn('TRI_TITLE');
+
+
+ $oDataset = TriggersPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $triggersArray = "";
+ $triggersArray [] = array('TRI_UID' => 'char', 'PRO_UID' => 'char', 'TRI_TITLE' => 'char', 'TRI_DESCRIPTION' => 'char');
+ while ($aRow = $oDataset->getRow()) {
+
+ if (($aRow ['TRI_TITLE'] == NULL) || ($aRow ['TRI_TITLE'] == "")) { // There is no transaltion for this Trigger name, try to get/regenerate the label
+ $triggerO = new Triggers ( );
+ $triggerObj = $triggerO->load($aRow ['TRI_UID']);
+ $aRow ['TRI_TITLE'] = $triggerObj ['TRI_TITLE'];
+ $aRow ['TRI_DESCRIPTION'] = $triggerObj ['TRI_DESCRIPTION'];
+ }
+ $triggersArray [] = $aRow;
+ $oDataset->next();
}
- /*
- * Presents a small list of dynaforms of the process
- * @param string $sProcessUID
- * @return boolean
- */
- public function dynaformsList($sProcessUID = '')
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'dynaforms/dynaforms_ShortList', $this->getDynaformsCriteria($sProcessUID), $aFields);
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
- /*
- * Return the dynaforms list criteria object
- * @param string $sProcessUID
- * @return object
- */
- public function getDynaformsCriteria($sProcessUID = '')
- {
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(DynaformPeer::DYN_UID);
- $oCriteria->addSelectColumn(DynaformPeer::PRO_UID);
- $oCriteria->addSelectColumn(DynaformPeer::DYN_TYPE);
- $oCriteria->addAsColumn('DYN_TITLE', 'C1.CON_VALUE');
- $oCriteria->addAsColumn('DYN_DESCRIPTION', 'C2.CON_VALUE');
- $oCriteria->addAlias('C1', 'CONTENT');
- $oCriteria->addAlias('C2', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(DynaformPeer::DYN_UID, 'C1.CON_ID');
- $aConditions [] = array('C1.CON_CATEGORY', $sDelimiter . 'DYN_TITLE' . $sDelimiter);
- $aConditions [] = array('C1.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $aConditions = array();
- $aConditions [] = array(DynaformPeer::DYN_UID, 'C2.CON_ID');
- $aConditions [] = array('C2.CON_CATEGORY', $sDelimiter . 'DYN_DESCRIPTION' . $sDelimiter);
- $aConditions [] = array('C2.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
+ return $oCriteria;
+ }
- $oDataset = DynaformPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $dynaformArray = array();
- $dynaformArray [] = array('d' => 'char');
- while ($aRow = $oDataset->getRow()) {
- if (($aRow ['DYN_TITLE'] == NULL) || ($aRow ['DYN_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
- $aRow ['DYN_TITLE'] = Content::Load("DYN_TITLE", "", $aRow ['DYN_UID'], SYS_LANG);
- }
- if (($aRow ['DYN_DESCRIPTION'] == NULL) || ($aRow ['DYN_DESCRIPTION'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
- $aRow ['DYN_DESCRIPTION'] = Content::Load("DYN_DESCRIPTION", "", $aRow ['DYN_UID'], SYS_LANG);
- }
- $dynaformArray [] = $aRow;
- $oDataset->next();
- }
- return $oCriteria;
- }
+ /*
+ * Return the triggers list in a array
+ * @param string $sProcessUID
+ * @return array
+ */
- /**
- * getDynaformsList
- *
- * @param string $sProcessUID
- * @return array $dynaformArray
- */
- public function getDynaformsList($sProcessUID = '')
- {
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(DynaformPeer::DYN_UID);
- $oCriteria->addSelectColumn(DynaformPeer::PRO_UID);
- $oCriteria->addSelectColumn(DynaformPeer::DYN_TYPE);
- $oCriteria->addAsColumn('DYN_TITLE', 'C1.CON_VALUE');
- $oCriteria->addAsColumn('DYN_DESCRIPTION', 'C2.CON_VALUE');
- $oCriteria->addAlias('C1', 'CONTENT');
- $oCriteria->addAlias('C2', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(DynaformPeer::DYN_UID, 'C1.CON_ID');
- $aConditions [] = array('C1.CON_CATEGORY', $sDelimiter . 'DYN_TITLE' . $sDelimiter);
- $aConditions [] = array('C1.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $aConditions = array();
- $aConditions [] = array(DynaformPeer::DYN_UID, 'C2.CON_ID');
- $aConditions [] = array('C2.CON_CATEGORY', $sDelimiter . 'DYN_DESCRIPTION' . $sDelimiter);
- $aConditions [] = array('C2.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
+ function getTriggers($sProcessUID = '') {
+ $aTriggers = Array();
+ $oCriteria = $this->getTriggersCriteria($sProcessUID);
- $oDataset = DynaformPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $dynaformArray = array();
- while ($aRow = $oDataset->getRow()) {
- if (($aRow ['DYN_TITLE'] == NULL) || ($aRow ['DYN_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
- $aRow ['DYN_TITLE'] = Content::Load("DYN_TITLE", "", $aRow ['DYN_UID'], SYS_LANG);
- }
- if (($aRow ['DYN_DESCRIPTION'] == NULL) || ($aRow ['DYN_DESCRIPTION'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
- $aRow ['DYN_DESCRIPTION'] = Content::Load("DYN_DESCRIPTION", "", $aRow ['DYN_UID'], SYS_LANG);
- }
- $dynaformArray [] = $aRow;
- $oDataset->next();
- }
- return $dynaformArray;
- }
+ $oDataset = RoutePeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- /*
- * Presents a small list of output documents of the process
- * @param string $sProcessUID
- * @return boolean
- */
- public function outputdocsList($sProcessUID = '')
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'outputdocs/outputdocs_ShortList', $this->getOutputDocumentsCriteria($sProcessUID), $aFields);
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
+ while ($oDataset->next())
+ array_push($aTriggers, $oDataset->getRow());
- /*
- * Return the output documents list criteria object
- * @param string $sProcessUID
- * @return object
- */
- public function getOutputDocumentsCriteria($sProcessUID = '')
- {
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(OutputDocumentPeer::OUT_DOC_UID);
- $oCriteria->addSelectColumn(OutputDocumentPeer::OUT_DOC_TYPE);
- $oCriteria->addSelectColumn(OutputDocumentPeer::PRO_UID);
- $oCriteria->addAsColumn('OUT_DOC_TITLE', 'C1.CON_VALUE');
- $oCriteria->addAsColumn('OUT_DOC_DESCRIPTION', 'C2.CON_VALUE');
- $oCriteria->addAlias('C1', 'CONTENT');
- $oCriteria->addAlias('C2', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(OutputDocumentPeer::OUT_DOC_UID, 'C1.CON_ID');
- $aConditions [] = array('C1.CON_CATEGORY', $sDelimiter . 'OUT_DOC_TITLE' . $sDelimiter);
- $aConditions [] = array('C1.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $aConditions = array();
- $aConditions [] = array(OutputDocumentPeer::OUT_DOC_UID, 'C2.CON_ID');
- $aConditions [] = array('C2.CON_CATEGORY', $sDelimiter . 'OUT_DOC_DESCRIPTION' . $sDelimiter);
- $aConditions [] = array('C2.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(OutputDocumentPeer::PRO_UID, $sProcessUID);
+ return $aTriggers;
+ }
+
+ /*
+ * Presents a small list of Scheduled Tasks of the process
+ * @param string $sProcessUID
+ * @return void
+ */
+
+ function caseSchedulerList($sProcessUID = '') {
+ try {
+ /* $oCaseScheduler = new CaseScheduler();
+ $aRows = $oCaseScheduler->getAll();
+
+ //$oCaseScheduler->caseSchedulerCron();
+ // g::pr($aRows); die;
+
+ $fieldNames = Array(
+ 'SCH_UID' => 'char',
+ 'SCH_NAME' => 'char',
+ 'PRO_UID' => 'char',
+ 'TAS_UID' => 'char',
+ 'SCH_TIME_NEXT_RUN' => 'char',
+ 'SCH_LAST_RUN_TIME' => 'char',
+ 'SCH_STATE' => 'char',
+ 'SCH_LAST_STATE' => 'char',
+ 'USR_UID' => 'char',
+ 'SCH_OPTION' => 'char',
+ 'SCH_START_TIME' => 'char',
+ 'SCH_START_DATE' => 'char',
+ 'SCH_DAYS_PERFORM_TASK' => 'char',
+ 'SCH_EVERY_DAYS' => 'char',
+ 'SCH_WEEK_DAYS' => 'char',
+ 'SCH_START_DAY' => 'char',
+ 'SCH_MONTHS' => 'char',
+ 'SCH_END_DATE' => 'char',
+ 'SCH_REPEAT_EVERY' => 'char',
+ 'SCH_REPEAT_UNTIL' => 'char',
+ 'SCH_REPEAT_STOP_IF_RUNNING' => 'char',
+ 'PRO_PARENT' => 'char',
+ 'PRO_TIME' => 'char',
+ 'PRO_TIMEUNIT' => 'char',
+ 'PRO_STATUS' => 'char',
+ 'PRO_TYPE_DAY' => 'char',
+ 'PRO_TYPE' => 'char',
+ 'PRO_ASSIGNMENT' => 'char',
+ 'PRO_SHOW_MAP' => 'char',
+ 'PRO_SHOW_MESSAGE' => 'char',
+ 'PRO_SHOW_DELEGATE' => 'char',
+ 'PRO_SHOW_DYNAFORM' => 'char',
+ 'PRO_CATEGORY' => 'char',
+ 'PRO_SUB_CATEGORY' => 'char',
+ 'PRO_INDUSTRY' => 'char',
+ 'PRO_UPDATE_DATE' => 'char',
+ 'PRO_CREATE_DATE' => 'char',
+ 'PRO_CREATE_USER' => 'char',
+ 'PRO_HEIGHT' => 'char',
+ 'PRO_WIDTH' => 'char',
+ 'PRO_TITLE_X' => 'char',
+ 'PRO_TITLE_Y' => 'char',
+ 'PRO_DEBUG' => 'char',
+ 'PRO_TITLE' => 'char',
+ 'PRO_DESCRIPTION' => 'char',
+ 'TAS_TYPE' => 'char',
+ 'TAS_DURATION' => 'char',
+ 'TAS_DELAY_TYPE' => 'char',
+ 'TAS_TEMPORIZER' => 'char',
+ 'TAS_TYPE_DAY' => 'char',
+ 'TAS_TIMEUNIT' => 'char',
+ 'TAS_ALERT' => 'char',
+ 'TAS_PRIORITY_VARIABLE' => 'char',
+ 'TAS_ASSIGN_TYPE' => 'char',
+ 'TAS_ASSIGN_VARIABLE' => 'char',
+ 'TAS_ASSIGN_LOCATION' => 'char',
+ 'TAS_ASSIGN_LOCATION_ADHOC' => 'char',
+ 'TAS_TRANSFER_FLY' => 'char',
+ 'TAS_LAST_ASSIGNED' => 'char',
+ 'TAS_USER' => 'char',
+ 'TAS_CAN_UPLOAD' => 'char',
+ 'TAS_VIEW_UPLOAD' => 'char',
+ 'TAS_VIEW_ADDITIONAL_DOCUMENTATION' => 'char',
+ 'TAS_CAN_CANCEL' => 'char',
+ 'TAS_OWNER_APP' => 'char',
+ 'STG_UID' => 'char',
+ 'TAS_CAN_PAUSE' => 'char',
+ 'TAS_CAN_SEND_MESSAGE' => 'char',
+ 'TAS_CAN_DELETE_DOCS' => 'char',
+ 'TAS_SELF_SERVICE' => 'char',
+ 'TAS_START' => 'char',
+ 'TAS_TO_LAST_USER' => 'char',
+ 'TAS_SEND_LAST_EMAIL' => 'char',
+ 'TAS_DERIVATION' => 'char',
+ 'TAS_POSX' => 'char',
+ 'TAS_POSY' => 'char',
+ 'TAS_COLOR' => 'char',
+ 'TAS_TITLE' => 'char',
+ 'TAS_DESCRIPTION' => 'char',
+ 'TAS_DEF_TITLE' => 'char',
+ 'TAS_DEF_DESCRIPTION' => 'char',
+ 'TAS_DEF_PROC_CODE' => 'char',
+ 'TAS_DEF_MESSAGE' => 'char'
+ );
+
+
+ $aRows = array_merge(Array($fieldNames), $aRows);
+
+ // g::pr($aRows); die;
- $oDataset = OutputDocumentPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $outputDocArray = array();
- $outputDocArray [] = array('d' => 'char');
- while ($aRow = $oDataset->getRow()) {
- if (($aRow ['OUT_DOC_TITLE'] == NULL) || ($aRow ['OUT_DOC_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
- $outputDocument = new OutputDocument ( );
- $outputDocumentObj = $outputDocument->load($aRow ['OUT_DOC_UID']);
- $aRow ['OUT_DOC_TITLE'] = $outputDocumentObj ['OUT_DOC_TITLE'];
- $aRow ['OUT_DOC_DESCRIPTION'] = $outputDocumentObj ['OUT_DOC_DESCRIPTION'];
- }
- $outputDocArray [] = $aRow;
- $oDataset->next();
- }
global $_DBArray;
- $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
- $_DBArray ['outputDocArray'] = $outputDocArray;
- $_SESSION ['_DBArray'] = $_DBArray;
+ $_DBArray['cases_scheduler'] = $aRows;
+ $_SESSION['_DBArray'] = $_DBArray;
G::LoadClass('ArrayPeer');
$oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('outputDocArray');
+ $oCriteria->setDBArrayTable('cases_scheduler');
+ $G_PUBLISH = new Publisher;
- return $oCriteria;
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', '/cases/cases_Scheduler_List', $oCriteria, array('CONFIRM' => G::LoadTranslation('ID_MSG_CONFIRM_DELETE_CASE_SCHEDULER')));
+ G::RenderPage('publish');
+ //return true; */
+ $schedulerPath = SYS_URI . "cases/cases_Scheduler_List";
+ $html = "";
+ echo $html;
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /*
- * Presents a small list of input documents of the process
- * @param string $sProcessUID Process UID
- * @return void
- */
- public function inputdocsList($sProcessUID = '')
- {
- try {
- return true;
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'inputdocs/inputdocs_ShortList', $this->getInputDocumentsCriteria($sProcessUID), $aFields);
- G::RenderPage('publish', 'raw');
- } catch (Exception $oError) {
- throw ($oError);
- }
+ /*
+ * Presents a small list of Scheduled Task Logs of the process
+ * @param string $sProcessUID
+ * @return void
+ */
+
+ function logCaseSchedulerList($sProcessUID = '') {
+ try {
+ $oLogCaseScheduler = new LogCasesScheduler();
+ $aRows = $oLogCaseScheduler->getAll();
+
+ $fieldNames = Array(
+ 'PRO_UID' => 'char',
+ 'TAS_UID' => 'char',
+ 'USR_NAME' => 'char',
+ 'EXEC_DATE' => 'char',
+ 'EXEC_HOUR' => 'char',
+ 'RESULT' => 'char',
+ 'SCH_UID' => 'char',
+ 'WS_CREATE_CASE_STATUS' => 'char',
+ 'WS_ROUTE_CASE_STATUS' => 'char',
+ );
+
+ $aRows = array_merge(Array($fieldNames), $aRows);
+
+ $_DBArray['log_cases_scheduler'] = $aRows;
+ $_SESSION['_DBArray'] = $_DBArray;
+
+ $oCriteria = new Criteria('dbarray');
+ $oCriteria->setDBArrayTable('log_cases_scheduler');
+
+ $G_PUBLISH = new Publisher;
+ $G_PUBLISH->ROWS_PER_PAGE = 10;
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'cases/cases_Scheduler_Log', $oCriteria);
+ $G_PUBLISH->oPropelTable->rowsPerPage = 10;
+ G::RenderPage('publish', 'blank');
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /*
- * Return the input documents list criteria object
- * @param string $sProcessUID
- * @return object
- */
- public function getInputDocumentsCriteria($sProcessUID = '')
- {
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(InputDocumentPeer::INP_DOC_UID);
- $oCriteria->addSelectColumn(InputDocumentPeer::PRO_UID);
- $oCriteria->addAsColumn('INP_DOC_TITLE', 'C1.CON_VALUE');
- $oCriteria->addAsColumn('INP_DOC_DESCRIPTION', 'C2.CON_VALUE');
- $oCriteria->addAlias('C1', 'CONTENT');
- $oCriteria->addAlias('C2', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(InputDocumentPeer::INP_DOC_UID, 'C1.CON_ID');
- $aConditions [] = array('C1.CON_CATEGORY', $sDelimiter . 'INP_DOC_TITLE' . $sDelimiter);
- $aConditions [] = array('C1.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $aConditions = array();
- $aConditions [] = array(InputDocumentPeer::INP_DOC_UID, 'C2.CON_ID');
- $aConditions [] = array('C2.CON_CATEGORY', $sDelimiter . 'INP_DOC_DESCRIPTION' . $sDelimiter);
- $aConditions [] = array('C2.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID);
+ /*
+ * Presents a small list of messages of the process
+ * @param string $sProcessUID
+ * @return void
+ */
- $oDataset = InputDocumentPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $inputDocArray = "";
- $inputDocArray [] = array('INP_DOC_UID' => 'char', 'PRO_UID' => 'char', 'INP_DOC_TITLE' => 'char', 'INP_DOC_DESCRIPTION' => 'char');
- while ($aRow = $oDataset->getRow()) {
- if (($aRow ['INP_DOC_TITLE'] == NULL) || ($aRow ['INP_DOC_TITLE'] == "")) { // There is no transaltion for this Document name, try to get/regenerate the label
- $inputDocument = new InputDocument ( );
- $inputDocumentObj = $inputDocument->load($aRow ['INP_DOC_UID']);
- $aRow ['INP_DOC_TITLE'] = $inputDocumentObj ['INP_DOC_TITLE'];
- $aRow ['INP_DOC_DESCRIPTION'] = $inputDocumentObj ['INP_DOC_DESCRIPTION'];
- }
- $inputDocArray [] = $aRow;
- $oDataset->next();
- }
- global $_DBArray;
- $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
-
- $_DBArray ['inputDocArrayMain'] = $inputDocArray;
- $_SESSION ['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('inputDocArrayMain');
-
- return $oCriteria;
+ function messagesList($sProcessUID = '') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ global $G_PUBLISH;
+ $aFields ['PRO_UID'] = $sProcessUID;
+ $aFields ['SYS_LANG'] = SYS_LANG;
+ $G_PUBLISH = new Publisher ( );
+ //$G_PUBLISH->AddContent('pagedtable', 'paged-table', 'messages/messages_ShortList', $this->getMessagesCriteria($sProcessUID));
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /*
- * Presents a small list of triggers of the process
- * @param string $sProcessUID
- * @return void
- */
- public function triggersList($sProcessUID = '')
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'triggers/triggers_ShortList', $this->getTriggersCriteria($sProcessUID), $aFields);
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
+ /*
+ * Presents a small list of report tables of the process
+ * @param string $sProcessUID
+ * @return void
+ */
+
+ function reportTablesList($sProcessUID = '') {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'reportTables/reportTables_ShortList', $this->getReportTablesCriteria($sProcessUID), $aFields);
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /*
- * Return the triggers list criteria object
- * @param string $sProcessUID
- * @return object
- */
- public function getTriggersCriteria($sProcessUID = '')
- {
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(TriggersPeer::TRI_UID);
- $oCriteria->addSelectColumn(TriggersPeer::PRO_UID);
- $oCriteria->addAsColumn('TRI_TITLE', 'C1.CON_VALUE');
- $oCriteria->addAsColumn('TRI_DESCRIPTION', 'C2.CON_VALUE');
- $oCriteria->addAlias('C1', 'CONTENT');
- $oCriteria->addAlias('C2', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(TriggersPeer::TRI_UID, 'C1.CON_ID');
- $aConditions [] = array('C1.CON_CATEGORY', $sDelimiter . 'TRI_TITLE' . $sDelimiter);
- $aConditions [] = array('C1.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $aConditions = array();
- $aConditions [] = array(TriggersPeer::TRI_UID, 'C2.CON_ID');
- $aConditions [] = array('C2.CON_CATEGORY', $sDelimiter . 'TRI_TITLE' . $sDelimiter);
- $aConditions [] = array('C2.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(TriggersPeer::PRO_UID, $sProcessUID);
- $oCriteria->addAscendingOrderByColumn('TRI_TITLE');
+ /*
+ * Return the report tables list criteria object
+ * @param string $sProcessUID
+ * @return object
+ */
- $oDataset = TriggersPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $triggersArray = "";
- $triggersArray [] = array('TRI_UID' => 'char', 'PRO_UID' => 'char', 'TRI_TITLE' => 'char', 'TRI_DESCRIPTION' => 'char');
- while ($aRow = $oDataset->getRow()) {
- if (($aRow ['TRI_TITLE'] == NULL) || ($aRow ['TRI_TITLE'] == "")) { // There is no transaltion for this Trigger name, try to get/regenerate the label
- $triggerO = new Triggers ( );
- $triggerObj = $triggerO->load($aRow ['TRI_UID']);
- $aRow ['TRI_TITLE'] = $triggerObj ['TRI_TITLE'];
- $aRow ['TRI_DESCRIPTION'] = $triggerObj ['TRI_DESCRIPTION'];
- }
- $triggersArray [] = $aRow;
- $oDataset->next();
- }
- return $oCriteria;
- }
+ function getReportTablesCriteria($sProcessUID = '') {
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(ReportTablePeer::REP_TAB_UID);
+ $oCriteria->addSelectColumn(ReportTablePeer::PRO_UID);
+ $oCriteria->addSelectColumn(ReportTablePeer::REP_TAB_NAME);
+ $oCriteria->addSelectColumn(ReportTablePeer::REP_TAB_TYPE);
+ $oCriteria->addSelectColumn(ReportTablePeer::REP_TAB_CONNECTION);
+ // $oCriteria->addAsColumn ( 'REP_TAB_TITLE', 'C.CON_VALUE' );
+ $oCriteria->addAsColumn('REP_TAB_TITLE', "CASE WHEN C.CON_VALUE IS NULL THEN (SELECT DISTINCT MAX(A.CON_VALUE) FROM CONTENT A WHERE A.CON_ID = REPORT_TABLE.REP_TAB_UID ) ELSE C.CON_VALUE END ");
+ $oCriteria->addAlias('C', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(ReportTablePeer::REP_TAB_UID, 'C.CON_ID');
+ $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'REP_TAB_TITLE' . $sDelimiter);
+ $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(ReportTablePeer::PRO_UID, $sProcessUID);
+ return $oCriteria;
+ }
- /*
- * Return the triggers list in a array
- * @param string $sProcessUID
- * @return array
- */
- public function getTriggers($sProcessUID = '')
- {
- $aTriggers = Array();
- $oCriteria = $this->getTriggersCriteria($sProcessUID);
+ /*
+ * Show the current pattern
+ * @param string $sProcessUID
+ * @param string $sTaskUID
+ * @return boolean
+ */
- $oDataset = RoutePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ function currentPattern($sProcessUID, $sTaskUID) {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ $oTask = new Task ( );
+ $aFields = $oTask->load($sTaskUID);
+ $aFields = array();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(RoutePeer::TAS_UID, $sTaskUID);
+ $oCriteria->addAscendingOrderByColumn(RoutePeer::ROU_CASE);
+ $oDataset = RoutePeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $aRow = $oDataset->getRow();
+ $params = array();
+// $sql = BasePeer::createSelectSql($oCriteria, $params);
+// echo $sProcessUID."-".$sTaskUID."-";
+// echo $sql;
+// var_dump($aRow);
+// die();
- while ($oDataset->next()) {
- array_push($aTriggers, $oDataset->getRow());
- }
- return $aTriggers;
- }
-
- /*
- * Presents a small list of Scheduled Tasks of the process
- * @param string $sProcessUID
- * @return void
- */
- public function caseSchedulerList($sProcessUID = '')
- {
- try {
- $schedulerPath = SYS_URI . "cases/cases_Scheduler_List";
- $html = "";
- echo $html;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Presents a small list of Scheduled Task Logs of the process
- * @param string $sProcessUID
- * @return void
- */
- public function logCaseSchedulerList($sProcessUID = '')
- {
- try {
- $oLogCaseScheduler = new LogCasesScheduler();
- $aRows = $oLogCaseScheduler->getAll();
-
- $fieldNames = Array(
- 'PRO_UID' => 'char',
- 'TAS_UID' => 'char',
- 'USR_NAME' => 'char',
- 'EXEC_DATE' => 'char',
- 'EXEC_HOUR' => 'char',
- 'RESULT' => 'char',
- 'SCH_UID' => 'char',
- 'WS_CREATE_CASE_STATUS' => 'char',
- 'WS_ROUTE_CASE_STATUS' => 'char',
- );
-
- $aRows = array_merge(Array($fieldNames), $aRows);
-
- $_DBArray['log_cases_scheduler'] = $aRows;
- $_SESSION['_DBArray'] = $_DBArray;
-
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('log_cases_scheduler');
-
- $G_PUBLISH = new Publisher;
- $G_PUBLISH->ROWS_PER_PAGE = 10;
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'cases/cases_Scheduler_Log', $oCriteria);
- $G_PUBLISH->oPropelTable->rowsPerPage = 10;
- G::RenderPage('publish', 'blank');
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Presents a small list of messages of the process
- * @param string $sProcessUID
- * @return void
- */
- public function messagesList($sProcessUID = '')
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- global $G_PUBLISH;
- $aFields ['PRO_UID'] = $sProcessUID;
- $aFields ['SYS_LANG'] = SYS_LANG;
- $G_PUBLISH = new Publisher ( );
- //$G_PUBLISH->AddContent('pagedtable', 'paged-table', 'messages/messages_ShortList', $this->getMessagesCriteria($sProcessUID));
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Presents a small list of report tables of the process
- * @param string $sProcessUID
- * @return void
- */
- public function reportTablesList($sProcessUID = '')
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'reportTables/reportTables_ShortList', $this->getReportTablesCriteria($sProcessUID), $aFields);
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
- }
-
- /*
- * Return the report tables list criteria object
- * @param string $sProcessUID
- * @return object
- */
- public function getReportTablesCriteria($sProcessUID = '')
- {
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(ReportTablePeer::REP_TAB_UID);
- $oCriteria->addSelectColumn(ReportTablePeer::PRO_UID);
- $oCriteria->addSelectColumn(ReportTablePeer::REP_TAB_NAME);
- $oCriteria->addSelectColumn(ReportTablePeer::REP_TAB_TYPE);
- $oCriteria->addSelectColumn(ReportTablePeer::REP_TAB_CONNECTION);
- // $oCriteria->addAsColumn ( 'REP_TAB_TITLE', 'C.CON_VALUE' );
- $oCriteria->addAsColumn('REP_TAB_TITLE', "CASE WHEN C.CON_VALUE IS NULL THEN (SELECT DISTINCT MAX(A.CON_VALUE) FROM CONTENT A WHERE A.CON_ID = REPORT_TABLE.REP_TAB_UID ) ELSE C.CON_VALUE END ");
- $oCriteria->addAlias('C', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(ReportTablePeer::REP_TAB_UID, 'C.CON_ID');
- $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'REP_TAB_TITLE' . $sDelimiter);
- $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(ReportTablePeer::PRO_UID, $sProcessUID);
- return $oCriteria;
- }
-
- /*
- * Show the current pattern
- * @param string $sProcessUID
- * @param string $sTaskUID
- * @return boolean
- */
- public function currentPattern($sProcessUID, $sTaskUID)
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- $oTask = new Task ( );
- $aFields = $oTask->load($sTaskUID);
- $aFields = array();
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
- $oCriteria->add(RoutePeer::TAS_UID, $sTaskUID);
- $oCriteria->addAscendingOrderByColumn(RoutePeer::ROU_CASE);
- $oDataset = RoutePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aRow = $oDataset->getRow();
- $params = array();
if (is_array($aRow)) {
$aFields ['ROU_TYPE'] = $aRow ['ROU_TYPE'];
@@ -2348,713 +2453,695 @@ class processMap {
}
}
- $aFields ['action'] = 'savePattern';
- $aFields ['LANG'] = SYS_LANG;
- $aFields ['PROCESS'] = $sProcessUID;
- $aFields ['TASK'] = $sTaskUID;
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('xmlform', 'xmlform', 'patterns/' . $sXmlform, '', $aFields, '../patterns/patterns_Ajax');
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher();
- $aMessage = array();
- $aMessage['MESSAGE'] = $oError->getMessage();
- $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
- G::RenderPage( 'publish','blank');
- die;
- }
+ $aFields ['action'] = 'savePattern';
+ $aFields ['LANG'] = SYS_LANG;
+ $aFields ['PROCESS'] = $sProcessUID;
+ $aFields ['TASK'] = $sTaskUID;
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('xmlform', 'xmlform', 'patterns/' . $sXmlform, '', $aFields, '../patterns/patterns_Ajax');
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher();
+ $aMessage = array();
+ $aMessage['MESSAGE'] = $oError->getMessage();
+ $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
+ G::RenderPage( 'publish','blank');
+ die;
}
+ }
- /*
- * Show the new pattern form
- * @param string $sProcessUID
- * @param string $sTaskUID
- * @param string $sNextTask
- * @param string $sType
- * @return boolean
- */
- public function newPattern($sProcessUID, $sTaskUID, $sNextTask, $sType)
- {
- try {
- $oProcess = new Process ( );
- $aFields = $oProcess->load($sProcessUID);
- $oTask = new Task ( );
- $aFields = $oTask->load($sTaskUID);
- $aFields = array();
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
- $oCriteria->add(RoutePeer::TAS_UID, $sTaskUID);
- $oCriteria->addAscendingOrderByColumn(RoutePeer::ROU_CASE);
- $oDataset = RoutePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aRow = $oDataset->getRow();
- if (is_array($aRow)) {
- $aFields ['ROU_TYPE_OLD'] = $aRow ['ROU_TYPE'];
- if ($sType == $aFields ['ROU_TYPE_OLD']) {
- switch ($sType) {
- case 'SELECT' :
- $aFields ['GRID_SELECT_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
- $aFields ['GRID_SELECT_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
- $aFields ['GRID_SELECT_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
- $aFields ['GRID_SELECT_TYPE'] ['ROU_TO_LAST_USER'] [$aRow ['ROU_CASE']] = $aRow ['ROU_TO_LAST_USER'];
- while ($aRow = $oDataset->getRow()) {
- $aFields ['GRID_SELECT_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
- $aFields ['GRID_SELECT_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
- $aFields ['GRID_SELECT_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
- $aFields ['GRID_SELECT_TYPE'] ['ROU_TO_LAST_USER'] [$aRow ['ROU_CASE']] = $aRow ['ROU_TO_LAST_USER'];
- $oDataset->next();
- }
- break;
- case 'EVALUATE' :
- $aFields ['GRID_EVALUATE_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
- $aFields ['GRID_EVALUATE_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
- $aFields ['GRID_EVALUATE_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
- $aFields ['GRID_EVALUATE_TYPE'] ['ROU_TO_LAST_USER'] [$aRow ['ROU_CASE']] = $aRow ['ROU_TO_LAST_USER'];
- while ($aRow = $oDataset->getRow()) {
- $aFields ['GRID_EVALUATE_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
- $aFields ['GRID_EVALUATE_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
- $aFields ['GRID_EVALUATE_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
- $aFields ['GRID_EVALUATE_TYPE'] ['ROU_TO_LAST_USER'] [$aRow ['ROU_CASE']] = $aRow ['ROU_TO_LAST_USER'];
- $oDataset->next();
- }
- break;
- case 'PARALLEL' :
- $aFields ['GRID_PARALLEL_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
- $aFields ['GRID_PARALLEL_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
- while ($aRow = $oDataset->getRow()) {
- $aFields ['GRID_PARALLEL_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
- $aFields ['GRID_PARALLEL_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
- $oDataset->next();
- }
- break;
- case 'PARALLEL-BY-EVALUATION' :
- $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
- $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
- $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
- while ($aRow = $oDataset->getRow()) {
- $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
- $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
- $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
- $oDataset->next();
- }
- break;
- case 'DISCRIMINATOR' :
- $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
- $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
- $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
- $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_OPTIONAL'] [$aRow ['ROU_CASE']] = $aRow ['ROU_OPTIONAL'];
- while ( $aRow = $oDataset->getRow () ) {
- $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
- $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
- $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
- $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_OPTIONAL'] [$aRow ['ROU_CASE']] = $aRow ['ROU_OPTIONAL'];
- $oDataset->next ();
- }
- break;
- }
- } else {
+ /*
+ * Show the new pattern form
+ * @param string $sProcessUID
+ * @param string $sTaskUID
+ * @param string $sNextTask
+ * @param string $sType
+ * @return boolean
+ */
+ function newPattern($sProcessUID, $sTaskUID, $sNextTask, $sType) {
+ try {
+ $oProcess = new Process ( );
+ $aFields = $oProcess->load($sProcessUID);
+ $oTask = new Task ( );
+ $aFields = $oTask->load($sTaskUID);
+ $aFields = array();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(RoutePeer::TAS_UID, $sTaskUID);
+ $oCriteria->addAscendingOrderByColumn(RoutePeer::ROU_CASE);
+ $oDataset = RoutePeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $aRow = $oDataset->getRow();
+ if (is_array($aRow)) {
+ $aFields ['ROU_TYPE_OLD'] = $aRow ['ROU_TYPE'];
+ if ($sType == $aFields ['ROU_TYPE_OLD']) {
+ switch ($sType) {
+ case 'SELECT' :
+ $aFields ['GRID_SELECT_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
+ $aFields ['GRID_SELECT_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
+ $aFields ['GRID_SELECT_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
+ $aFields ['GRID_SELECT_TYPE'] ['ROU_TO_LAST_USER'] [$aRow ['ROU_CASE']] = $aRow ['ROU_TO_LAST_USER'];
+ while ($aRow = $oDataset->getRow()) {
+ $aFields ['GRID_SELECT_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
+ $aFields ['GRID_SELECT_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
+ $aFields ['GRID_SELECT_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
+ $aFields ['GRID_SELECT_TYPE'] ['ROU_TO_LAST_USER'] [$aRow ['ROU_CASE']] = $aRow ['ROU_TO_LAST_USER'];
+ $oDataset->next();
}
- }
- switch ($sType) {
- case 'SEQUENTIAL' :
- case 'SEC-JOIN' :
- $aFields ['ROU_NEXT_TASK'] = $sNextTask;
- break;
- case 'SELECT' :
- $iRow = (isset($aFields ['GRID_SELECT_TYPE']) ? count($aFields ['GRID_SELECT_TYPE'] ['ROU_UID']) + 1 : 0);
- $aFields ['GRID_SELECT_TYPE'] ['ROU_UID'] [$iRow] = '';
- $aFields ['GRID_SELECT_TYPE'] ['ROU_NEXT_TASK'] [$iRow] = $sNextTask;
- $aFields ['GRID_SELECT_TYPE'] ['ROU_CONDITION'] [$iRow] = '';
- $aFields ['GRID_SELECT_TYPE'] ['ROU_TO_LAST_USER'] [$iRow] = '';
- break;
- case 'EVALUATE' :
- $iRow = (isset($aFields ['GRID_PARALLEL_EVALUATION_TYPE']) ? count($aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_UID']) + 1 : 0);
- $aFields ['GRID_EVALUATE_TYPE'] ['ROU_UID'] [$iRow] = '';
- $aFields ['GRID_EVALUATE_TYPE'] ['ROU_NEXT_TASK'] [$iRow] = $sNextTask;
- $aFields ['GRID_EVALUATE_TYPE'] ['ROU_CONDITION'] [$iRow] = '';
- $aFields ['GRID_EVALUATE_TYPE'] ['ROU_TO_LAST_USER'] [$iRow] = '';
- break;
- case 'PARALLEL' :
- $iRow = (isset($aFields ['GRID_PARALLEL_TYPE']) ? count($aFields ['GRID_PARALLEL_TYPE'] ['ROU_UID']) + 1 : 0);
- $aFields ['GRID_PARALLEL_TYPE'] ['ROU_UID'] [$iRow] = '';
- $aFields ['GRID_PARALLEL_TYPE'] ['ROU_NEXT_TASK'] [$iRow] = $sNextTask;
- $aFields ['GRID_PARALLEL_TYPE'] ['ROU_CONDITION'] [$iRow] = '';
- $aFields ['GRID_PARALLEL_TYPE'] ['ROU_TO_LAST_USER'] [$iRow] = '';
- break;
- case 'PARALLEL-BY-EVALUATION' :
- $iRow = (isset($aFields ['GRID_PARALLEL_EVALUATION_TYPE']) ? count($aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_UID']) + 1 : 0);
- $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_UID'] [$iRow] = '';
- $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_NEXT_TASK'] [$iRow] = $sNextTask;
- $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_CONDITION'] [$iRow] = '';
- $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_TO_LAST_USER'] [$iRow] = '';
- break;
- case 'DISCRIMINATOR' :
- $iRow = (isset ( $aFields ['GRID_DISCRIMINATOR_TYPE'] ) ? count ( $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_UID'] ) + 1 : 0);
- $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_UID'] [$iRow] = '';
- $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_NEXT_TASK'] [$iRow] = $sNextTask;
- $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_CONDITION'] [$iRow] = '';
- $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_TO_LAST_USER'] [$iRow] = '';
- break;
- }
- $aFields ['action'] = 'savePattern';
- $aFields ['LANG'] = SYS_LANG;
- $aFields ['PROCESS'] = $sProcessUID;
- $aFields ['TASK'] = $sTaskUID;
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('xmlform', 'xmlform', 'patterns/patterns_Current', '', $aFields, '../patterns/patterns_Ajax');
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
+ break;
+ case 'EVALUATE' :
+ $aFields ['GRID_EVALUATE_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
+ $aFields ['GRID_EVALUATE_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
+ $aFields ['GRID_EVALUATE_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
+ $aFields ['GRID_EVALUATE_TYPE'] ['ROU_TO_LAST_USER'] [$aRow ['ROU_CASE']] = $aRow ['ROU_TO_LAST_USER'];
+ while ($aRow = $oDataset->getRow()) {
+ $aFields ['GRID_EVALUATE_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
+ $aFields ['GRID_EVALUATE_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
+ $aFields ['GRID_EVALUATE_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
+ $aFields ['GRID_EVALUATE_TYPE'] ['ROU_TO_LAST_USER'] [$aRow ['ROU_CASE']] = $aRow ['ROU_TO_LAST_USER'];
+ $oDataset->next();
+ }
+ break;
+ case 'PARALLEL' :
+ $aFields ['GRID_PARALLEL_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
+ $aFields ['GRID_PARALLEL_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
+ while ($aRow = $oDataset->getRow()) {
+ $aFields ['GRID_PARALLEL_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
+ $aFields ['GRID_PARALLEL_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
+ $oDataset->next();
+ }
+ break;
+ case 'PARALLEL-BY-EVALUATION' :
+ $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
+ $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
+ $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
+ while ($aRow = $oDataset->getRow()) {
+ $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
+ $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
+ $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
+ $oDataset->next();
+ }
+ break;
+ case 'DISCRIMINATOR' :
+ $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
+ $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
+ $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
+ $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_OPTIONAL'] [$aRow ['ROU_CASE']] = $aRow ['ROU_OPTIONAL'];
+ while ( $aRow = $oDataset->getRow () ) {
+ $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
+ $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
+ $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
+ $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_OPTIONAL'] [$aRow ['ROU_CASE']] = $aRow ['ROU_OPTIONAL'];
+ $oDataset->next ();
+ }
+ break;
+ }
+ } else {
+
}
+ }
+ switch ($sType) {
+ case 'SEQUENTIAL' :
+ case 'SEC-JOIN' :
+ $aFields ['ROU_NEXT_TASK'] = $sNextTask;
+ break;
+ case 'SELECT' :
+ $iRow = (isset($aFields ['GRID_SELECT_TYPE']) ? count($aFields ['GRID_SELECT_TYPE'] ['ROU_UID']) + 1 : 0);
+ $aFields ['GRID_SELECT_TYPE'] ['ROU_UID'] [$iRow] = '';
+ $aFields ['GRID_SELECT_TYPE'] ['ROU_NEXT_TASK'] [$iRow] = $sNextTask;
+ $aFields ['GRID_SELECT_TYPE'] ['ROU_CONDITION'] [$iRow] = '';
+ $aFields ['GRID_SELECT_TYPE'] ['ROU_TO_LAST_USER'] [$iRow] = '';
+ break;
+ case 'EVALUATE' :
+ $iRow = (isset($aFields ['GRID_PARALLEL_EVALUATION_TYPE']) ? count($aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_UID']) + 1 : 0);
+ $aFields ['GRID_EVALUATE_TYPE'] ['ROU_UID'] [$iRow] = '';
+ $aFields ['GRID_EVALUATE_TYPE'] ['ROU_NEXT_TASK'] [$iRow] = $sNextTask;
+ $aFields ['GRID_EVALUATE_TYPE'] ['ROU_CONDITION'] [$iRow] = '';
+ $aFields ['GRID_EVALUATE_TYPE'] ['ROU_TO_LAST_USER'] [$iRow] = '';
+ break;
+ case 'PARALLEL' :
+ $iRow = (isset($aFields ['GRID_PARALLEL_TYPE']) ? count($aFields ['GRID_PARALLEL_TYPE'] ['ROU_UID']) + 1 : 0);
+ $aFields ['GRID_PARALLEL_TYPE'] ['ROU_UID'] [$iRow] = '';
+ $aFields ['GRID_PARALLEL_TYPE'] ['ROU_NEXT_TASK'] [$iRow] = $sNextTask;
+ $aFields ['GRID_PARALLEL_TYPE'] ['ROU_CONDITION'] [$iRow] = '';
+ $aFields ['GRID_PARALLEL_TYPE'] ['ROU_TO_LAST_USER'] [$iRow] = '';
+ break;
+ case 'PARALLEL-BY-EVALUATION' :
+ $iRow = (isset($aFields ['GRID_PARALLEL_EVALUATION_TYPE']) ? count($aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_UID']) + 1 : 0);
+ $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_UID'] [$iRow] = '';
+ $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_NEXT_TASK'] [$iRow] = $sNextTask;
+ $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_CONDITION'] [$iRow] = '';
+ $aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_TO_LAST_USER'] [$iRow] = '';
+ break;
+ case 'DISCRIMINATOR' :
+ $iRow = (isset ( $aFields ['GRID_DISCRIMINATOR_TYPE'] ) ? count ( $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_UID'] ) + 1 : 0);
+ $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_UID'] [$iRow] = '';
+ $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_NEXT_TASK'] [$iRow] = $sNextTask;
+ $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_CONDITION'] [$iRow] = '';
+ $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_TO_LAST_USER'] [$iRow] = '';
+ break;
+ }
+ $aFields ['action'] = 'savePattern';
+ $aFields ['LANG'] = SYS_LANG;
+ $aFields ['PROCESS'] = $sProcessUID;
+ $aFields ['TASK'] = $sTaskUID;
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('xmlform', 'xmlform', 'patterns/patterns_Current', '', $aFields, '../patterns/patterns_Ajax');
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /**
- * getNumberOfRoutes
- *
- * @param string $sProcessUID Default value empty
- * @param string $sTaskUID Default value empty
- * @param string $sNextTask Default value empty
- * @param string $sType Default value empty
- * @return intenger ( int ) $aRow ['ROUTE_NUMBER']
- */
- public function getNumberOfRoutes($sProcessUID = '', $sTaskUID = '', $sNextTask = '', $sType = '')
- {
- try {
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn('COUNT(*) AS ROUTE_NUMBER');
- $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
- $oCriteria->add(RoutePeer::TAS_UID, $sTaskUID);
- $oCriteria->add(RoutePeer::ROU_NEXT_TASK, $sNextTask);
- $oCriteria->add(RoutePeer::ROU_TYPE, $sType);
- $oDataset = RoutePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aRow = $oDataset->getRow();
- return (int) $aRow ['ROUTE_NUMBER'];
- } catch (Exception $oError) {
- throw ($oError);
- }
+ /**
+ * getNumberOfRoutes
+ *
+ * @param string $sProcessUID Default value empty
+ * @param string $sTaskUID Default value empty
+ * @param string $sNextTask Default value empty
+ * @param string $sType Default value empty
+ * @return intenger ( int ) $aRow ['ROUTE_NUMBER']
+ */
+ function getNumberOfRoutes($sProcessUID = '', $sTaskUID = '', $sNextTask = '', $sType = '') {
+ try {
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn('COUNT(*) AS ROUTE_NUMBER');
+ $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(RoutePeer::TAS_UID, $sTaskUID);
+ $oCriteria->add(RoutePeer::ROU_NEXT_TASK, $sNextTask);
+ $oCriteria->add(RoutePeer::ROU_TYPE, $sType);
+ $oDataset = RoutePeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $aRow = $oDataset->getRow();
+ return (int) $aRow ['ROUTE_NUMBER'];
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /**
- * saveNewPattern
- *
- * @param string $sProcessUID Default value empty
- * @param string $sTaskUID Default value empty
- * @param string $sNextTask Default value empty
- * @param string $sType Default value empty
- * @param boolean $sDelete
- * @return array void
- */
- public function saveNewPattern($sProcessUID = '', $sTaskUID = '', $sNextTask = '', $sType = '', $sDelete='')
- {
- try {
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn('COUNT(*) AS ROUTE_NUMBER');
- $oCriteria->addSelectColumn('GAT_UID AS GATEWAY_UID');
- $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
- $oCriteria->add(RoutePeer::TAS_UID, $sTaskUID);
- $oCriteria->add(RoutePeer::ROU_TYPE, $sType);
- $oDataset = RoutePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aRow = $oDataset->getRow();
- $aFields ['PRO_UID'] = $sProcessUID;
- $aFields ['TAS_UID'] = $sTaskUID;
- $aFields ['ROU_NEXT_TASK'] = $sNextTask;
- $aFields ['ROU_TYPE'] = $sType;
- $aFields ['ROU_CASE'] = (int) $aRow ['ROUTE_NUMBER'] + 1;
+ /**
+ * saveNewPattern
+ *
+ * @param string $sProcessUID Default value empty
+ * @param string $sTaskUID Default value empty
+ * @param string $sNextTask Default value empty
+ * @param string $sType Default value empty
+ * @param boolean $sDelete
+ * @return array void
+ */
+ function saveNewPattern($sProcessUID = '', $sTaskUID = '', $sNextTask = '', $sType = '', $sDelete='') {
+ try {
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn('COUNT(*) AS ROUTE_NUMBER');
+ $oCriteria->addSelectColumn('GAT_UID AS GATEWAY_UID');
+ $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(RoutePeer::TAS_UID, $sTaskUID);
+ $oCriteria->add(RoutePeer::ROU_TYPE, $sType);
+ $oDataset = RoutePeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $aRow = $oDataset->getRow();
+ $aFields ['PRO_UID'] = $sProcessUID;
+ $aFields ['TAS_UID'] = $sTaskUID;
+ $aFields ['ROU_NEXT_TASK'] = $sNextTask;
+ $aFields ['ROU_TYPE'] = $sType;
+ $aFields ['ROU_CASE'] = (int) $aRow ['ROUTE_NUMBER'] + 1;
- $sGatewayUID = $aRow['GATEWAY_UID'];
+ $sGatewayUID = $aRow['GATEWAY_UID'];
- if ($sDelete && $sGatewayUID != ''){
- $oGateway = new Gateway ( );
- $oGateway->remove($sGatewayUID);
- }
- //Getting Gateway UID after saving gateway
- //if ($sType != 'SEQUENTIAL' && $sGatewayUID == '' && $sDelete == '1')
- if ($sType != 'SEQUENTIAL') {
- $oProcessMap = new processMap();
- $sGatewayUID = $oProcessMap->saveNewGateway($sProcessUID, $sTaskUID, $sNextTask);
- }
+ if($sDelete && $sGatewayUID != ''){
+ $oGateway = new Gateway ( );
+ $oGateway->remove($sGatewayUID);
+ }
+ //Getting Gateway UID after saving gateway
+ //if($sType != 'SEQUENTIAL' && $sGatewayUID == '' && $sDelete == '1')
+ if($sType != 'SEQUENTIAL')
+ {
+ $oProcessMap = new processMap();
+ $sGatewayUID = $oProcessMap->saveNewGateway($sProcessUID, $sTaskUID, $sNextTask);
+ }
- $aFields ['GAT_UID'] = (isset($sGatewayUID))?$sGatewayUID:'';
- $oRoute = new Route ( );
- $oRoute->create($aFields);
- } catch (Exception $oError) {
- throw ($oError);
- }
+ $aFields ['GAT_UID'] = (isset($sGatewayUID))?$sGatewayUID:'';
+ $oRoute = new Route ( );
+ $oRoute->create($aFields);
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /**
- * saveNewGateway
- *
- * @param string $sProcessUID Default value empty
- * @param string $sTaskUID Default value empty
- * @param string $sNextTask Default value empty
- * @param string $sType Default value empty (Route Type)
- * @return string $sGatewayUID
- */
- public function saveNewGateway($sProcessUID = '', $sTaskUID = '', $sNextTask = '', $sType = '')
- {
- try {
- $oTask = new Task();
- $aTaskDetails = $oTask->load($sTaskUID);
- $aFields ['PRO_UID'] = $sProcessUID;
- $aFields ['TAS_UID'] = $sTaskUID;
- $aFields ['GAT_NEXT_TASK'] = $sNextTask;
- $aFields ['GAT_X'] = $aTaskDetails['TAS_POSX'] + $aTaskDetails['TAS_WIDTH']/2;
- $aFields ['GAT_Y'] = $aTaskDetails['TAS_POSY'] + $aTaskDetails['TAS_HEIGHT'] + 10;
+ /**
+ * saveNewGateway
+ *
+ * @param string $sProcessUID Default value empty
+ * @param string $sTaskUID Default value empty
+ * @param string $sNextTask Default value empty
+ * @param string $sType Default value empty (Route Type)
+ * @return string $sGatewayUID
+ */
+ function saveNewGateway($sProcessUID = '', $sTaskUID = '', $sNextTask = '', $sType = '') {
+ try {
+ $oTask = new Task();
+ $aTaskDetails = $oTask->load($sTaskUID);
+ $aFields ['PRO_UID'] = $sProcessUID;
+ $aFields ['TAS_UID'] = $sTaskUID;
+ $aFields ['GAT_NEXT_TASK'] = $sNextTask;
+ $aFields ['GAT_X'] = $aTaskDetails['TAS_POSX'] + $aTaskDetails['TAS_WIDTH']/2;
+ $aFields ['GAT_Y'] = $aTaskDetails['TAS_POSY'] + $aTaskDetails['TAS_HEIGHT'] + 10;
- switch($sType)
- {
- case 'PARALLEL':
- $aFields ['GAT_TYPE'] = 'bpmnGatewayParallel';
- break;
- case 'SEC-JOIN':
- $aFields ['GAT_TYPE'] = 'bpmnGatewayParallel';
- break;
- case 'EVALUATE':
- $aFields ['GAT_TYPE'] = 'bpmnGatewayExclusiveData';
- break;
- case 'PARALLEL-BY-EVALUATION':
- $aFields ['GAT_TYPE'] = 'bpmnGatewayInclusive';
- break;
- case 'SELECT':
- $aFields ['GAT_TYPE'] = 'bpmnGatewayExclusiveData';
- break;
- case 'DISCRIMINATOR':
- $aFields ['GAT_TYPE'] = 'bpmnGatewayComplex';
- break;
- }
+ switch($sType)
+ {
+ case 'PARALLEL':
+ $aFields ['GAT_TYPE'] = 'bpmnGatewayParallel';
+ break;
+ case 'SEC-JOIN':
+ $aFields ['GAT_TYPE'] = 'bpmnGatewayParallel';
+ break;
+ case 'EVALUATE':
+ $aFields ['GAT_TYPE'] = 'bpmnGatewayExclusiveData';
+ break;
+ case 'PARALLEL-BY-EVALUATION':
+ $aFields ['GAT_TYPE'] = 'bpmnGatewayInclusive';
+ break;
+ case 'SELECT':
+ $aFields ['GAT_TYPE'] = 'bpmnGatewayExclusiveData';
+ break;
+ case 'DISCRIMINATOR':
+ $aFields ['GAT_TYPE'] = 'bpmnGatewayComplex';
+ break;
+ }
- $oGateway = new Gateway ( );
- $sGatewayUID = $oGateway->create($aFields);
- return $sGatewayUID;
+ $oGateway = new Gateway ( );
- } catch (Exception $oError) {
- throw ($oError);
- }
+ $sGatewayUID = $oGateway->create($aFields);
+
+ return $sGatewayUID;
+
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /*
- * Delete a derivation rule
- * @param string $sTaskUID
- * @return boolean
- */
- public function deleteDerivation($sTaskUID = '')
- {
- try {
- $oTask = new Task ( );
- $aFields = $oTask->load($sTaskUID);
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(RoutePeer::TAS_UID, $sTaskUID);
- RoutePeer::doDelete($oCriteria);
- return true;
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
+ /*
+ * Delete a derivation rule
+ * @param string $sTaskUID
+ * @return boolean
+ */
+
+ function deleteDerivation($sTaskUID = '') {
+ try {
+ $oTask = new Task ( );
+ $aFields = $oTask->load($sTaskUID);
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->add(RoutePeer::TAS_UID, $sTaskUID);
+ RoutePeer::doDelete($oCriteria);
+ return true;
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /**
- * getConditionProcessList
- *
- * @return object $oCriteria
- */
- public function getConditionProcessList()
- {
- $aProcesses = array();
- $aProcesses [] = array('PRO_UID' => 'char', 'PRO_TITLE' => 'char', 'PRO_DESCRIPTION' => 'char', 'PRO_STATUS' => 'char', 'PRO_CATEGORY' => 'char', 'PRO_CATEGORY_LABEL' => 'char');
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(ProcessPeer::PRO_UID);
- $oCriteria->add(ProcessPeer::PRO_STATUS, 'DISABLED', Criteria::NOT_EQUAL);
- $oDataset = ProcessPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ /**
+ * getConditionProcessList
+ *
+ * @return object $oCriteria
+ */
+ function getConditionProcessList() {
+ $aProcesses = array();
+ $aProcesses [] = array('PRO_UID' => 'char', 'PRO_TITLE' => 'char', 'PRO_DESCRIPTION' => 'char', 'PRO_STATUS' => 'char', 'PRO_CATEGORY' => 'char', 'PRO_CATEGORY_LABEL' => 'char');
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(ProcessPeer::PRO_UID);
+ $oCriteria->add(ProcessPeer::PRO_STATUS, 'DISABLED', Criteria::NOT_EQUAL);
+ $oDataset = ProcessPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $oProcess = new Process ( );
- while ($aRow = $oDataset->getRow()) {
- $aProcess = $oProcess->load($aRow ['PRO_UID']);
- $aProcesses [] = array('PRO_UID' => $aProcess ['PRO_UID'], 'PRO_TITLE' => $aProcess ['PRO_TITLE'], 'PRO_DESCRIPTION' => $aProcess ['PRO_DESCRIPTION'], 'PRO_STATUS' => ($aProcess ['PRO_STATUS'] == 'ACTIVE' ? G::LoadTranslation('ID_ACTIVE') : G::LoadTranslation('ID_INACTIVE')), 'PRO_CATEGORY' => $aProcess ['PRO_CATEGORY'], 'PRO_CATEGORY_LABEL' => $aProcess ['PRO_CATEGORY_LABEL']);
- $oDataset->next();
- }
- global $_DBArray;
- $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
- $_DBArray ['processes'] = $aProcesses;
- $_SESSION ['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('processes');
- return $oCriteria;
+
+
+ $oDataset->next();
+ $oProcess = new Process ( );
+ while ($aRow = $oDataset->getRow()) {
+ $aProcess = $oProcess->load($aRow ['PRO_UID']);
+ $aProcesses [] = array('PRO_UID' => $aProcess ['PRO_UID'], 'PRO_TITLE' => $aProcess ['PRO_TITLE'], 'PRO_DESCRIPTION' => $aProcess ['PRO_DESCRIPTION'], 'PRO_STATUS' => ($aProcess ['PRO_STATUS'] == 'ACTIVE' ? G::LoadTranslation('ID_ACTIVE') : G::LoadTranslation('ID_INACTIVE')), 'PRO_CATEGORY' => $aProcess ['PRO_CATEGORY'], 'PRO_CATEGORY_LABEL' => $aProcess ['PRO_CATEGORY_LABEL']);
+ $oDataset->next();
}
+ global $_DBArray;
+ $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
+ $_DBArray ['processes'] = $aProcesses;
+ $_SESSION ['_DBArray'] = $_DBArray;
+ G::LoadClass('ArrayPeer');
+ $oCriteria = new Criteria('dbarray');
+ $oCriteria->setDBArrayTable('processes');
+ return $oCriteria;
+ }
- /*
- * Show the dynaforms for the supervisors
- * @param string $sProcessUID
- * @return boolean
- */
- public function supervisorDynaforms($sProcessUID)
- {
- try {
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'dynaforms/dynaforms_Supervisor', $this->getSupervisorDynaformsCriteria($sProcessUID), array('PRO_UID' => $sProcessUID));
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
+ /*
+ * Show the dynaforms for the supervisors
+ * @param string $sProcessUID
+ * @return boolean
+ */
+
+ function supervisorDynaforms($sProcessUID) {
+ try {
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'dynaforms/dynaforms_Supervisor', $this->getSupervisorDynaformsCriteria($sProcessUID), array('PRO_UID' => $sProcessUID));
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /**
- * supervisorInputs
- *
- * @param string $sProcessUID
- * @return boolean true
- * throw Exception $oError
- */
- public function supervisorInputs($sProcessUID)
- {
- try {
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'inputdocs/inputdocs_Supervisor', $this->getSupervisorInputsCriteria($sProcessUID), array('PRO_UID' => $sProcessUID));
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
+ /**
+ * supervisorInputs
+ *
+ * @param string $sProcessUID
+ * @return boolean true
+ * throw Exception $oError
+ */
+ function supervisorInputs($sProcessUID) {
+ try {
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'inputdocs/inputdocs_Supervisor', $this->getSupervisorInputsCriteria($sProcessUID), array('PRO_UID' => $sProcessUID));
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /**
- * webEntry
- *
- * @param string $sProcessUID
- * @return boolean true
- * throw Exception $oError
- */
- public function webEntry($sProcessUID)
- {
- try {
- global $G_PUBLISH;
- global $G_FORM;
- $G_PUBLISH = new Publisher ( );
+ /**
+ * webEntry
+ *
+ * @param string $sProcessUID
+ * @return boolean true
+ * throw Exception $oError
+ */
+ function webEntry($sProcessUID) {
+ try {
+ global $G_PUBLISH;
+ global $G_FORM;
+ $G_PUBLISH = new Publisher ( );
- if (G::is_https ())
- $http = 'https://';
- else
- $http = 'http://';
+ if (G::is_https ())
+ $http = 'https://';
+ else
+ $http = 'http://';
- $link = $http . $_SERVER ['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sProcessUID . '/';
+ $link = $http . $_SERVER ['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sProcessUID . '/';
- $row = array();
- $c = 0;
+ $row = array();
+ $c = 0;
- /*
- $oTask = new Task ( );
- $TaskFields = $oTask->kgetassigType ( $sProcessUID , $tas='');
- */
- $TaskFields ['TAS_ASSIGN_TYPE'] = '';
- $row [] = array('W_TITLE' => '', 'W_DELETE' => '', 'TAS_ASSIGN_TYPE' => $TaskFields ['TAS_ASSIGN_TYPE']);
+ /*
+ $oTask = new Task ( );
+ $TaskFields = $oTask->kgetassigType ( $sProcessUID , $tas='');
+ */
+ $TaskFields ['TAS_ASSIGN_TYPE'] = '';
+ $row [] = array('W_TITLE' => '', 'W_DELETE' => '', 'TAS_ASSIGN_TYPE' => $TaskFields ['TAS_ASSIGN_TYPE']);
- if (is_dir(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $sProcessUID)) {
- $dir = opendir(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $sProcessUID);
- while ($archivo = readdir($dir)) { //print $archivo." ****
";
- if ($archivo != '.') {
- if ($archivo != '..') {
- $one = 0;
- $two = 0;
+ if (is_dir(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $sProcessUID)) {
+ $dir = opendir(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $sProcessUID);
+ while ($archivo = readdir($dir)) { //print $archivo." ****
";
+ if ($archivo != '.') {
+ if ($archivo != '..') {
+ $one = 0;
+ $two = 0;
- $alink = $link . $archivo;
+ $alink = $link . $archivo;
- $one = count(explode('wsClient.php', $archivo));
- $two = count(explode('Post.php', $archivo));
+ $one = count(explode('wsClient.php', $archivo));
+ $two = count(explode('Post.php', $archivo));
- if ($one == 1 && $two == 1) {
- $arlink = "" . $alink . "";
- $linkdelete = sprintf("delete", $alink, $archivo, $sProcessUID);
- $row [] = array('W_LINK' => $arlink, 'W_FILENAME' => $archivo, 'W_PRO_UID' => $sProcessUID);
- }
- }
+ if ($one == 1 && $two == 1) {
+ $arlink = "" . $alink . "";
+ $linkdelete = sprintf("delete", $alink, $archivo, $sProcessUID);
+ $row [] = array('W_LINK' => $arlink, 'W_FILENAME' => $archivo, 'W_PRO_UID' => $sProcessUID);
}
}
}
- global $_DBArray;
- $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
- $_DBArray ['reports'] = $row;
- $_SESSION ['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('reports');
- //if ($TaskFields['TAS_ASSIGN_TYPE'] == 'BALANCED') {
- //$G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_WebEntry', '', array('PRO_UID' => $sProcessUID, 'LANG' => SYS_LANG));
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'dynaforms/dynaforms_WebEntryList', $oCriteria, array('PRO_UID' => $sProcessUID, 'LANG' => SYS_LANG));
- /* }else{
- $aMessage['MESSAGE'] = G::loadTranslation( 'WEBEN_ONLY_BALANCED' );
- $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/showMessage', '',$aMessage );
-
- } */
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
}
+ }
+ global $_DBArray;
+ $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
+ $_DBArray ['reports'] = $row;
+ $_SESSION ['_DBArray'] = $_DBArray;
+ G::LoadClass('ArrayPeer');
+ $oCriteria = new Criteria('dbarray');
+ $oCriteria->setDBArrayTable('reports');
+ //if ($TaskFields['TAS_ASSIGN_TYPE'] == 'BALANCED') {
+ //$G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_WebEntry', '', array('PRO_UID' => $sProcessUID, 'LANG' => SYS_LANG));
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'dynaforms/dynaforms_WebEntryList', $oCriteria, array('PRO_UID' => $sProcessUID, 'LANG' => SYS_LANG));
+ /* }else{
+ $aMessage['MESSAGE'] = G::loadTranslation( 'WEBEN_ONLY_BALANCED' );
+ $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/showMessage', '',$aMessage );
+
+ } */
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /**
- * webEntry_new
- *
- * @param string $sProcessUID
- * @return boolean true
- * throw Exception $oError
- */
- public function webEntry_new($sProcessUID)
- {
- try {
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_WebEntry', '', array('PRO_UID' => $sProcessUID, 'LANG' => SYS_LANG));
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
+ /**
+ * webEntry_new
+ *
+ * @param string $sProcessUID
+ * @return boolean true
+ * throw Exception $oError
+ */
+ function webEntry_new($sProcessUID) {
+ try {
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_WebEntry', '', array('PRO_UID' => $sProcessUID, 'LANG' => SYS_LANG));
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /*
- * Return the supervisors dynaforms list criteria object
- * @param string $sProcessUID
- * @return object
- */
- public function getSupervisorDynaformsCriteria($sProcessUID = '')
- {
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_UID);
- $oCriteria->addSelectColumn(StepSupervisorPeer::PRO_UID);
- $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_TYPE_OBJ);
- $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_UID_OBJ);
- $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_POSITION);
- $oCriteria->addAsColumn('DYN_TITLE', 'C.CON_VALUE');
- $oCriteria->addAlias('C', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(StepSupervisorPeer::STEP_UID_OBJ, DynaformPeer::DYN_UID);
- $aConditions [] = array(StepSupervisorPeer::STEP_TYPE_OBJ, $sDelimiter . 'DYNAFORM' . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $aConditions = array();
- $aConditions [] = array(DynaformPeer::DYN_UID, 'C.CON_ID');
- $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'DYN_TITLE' . $sDelimiter);
- $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
- $oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, 'DYNAFORM');
- $oCriteria->addAscendingOrderByColumn(StepSupervisorPeer::STEP_POSITION);
- return $oCriteria;
+/**
+ * webEntryByTask
+ *
+ * @param string $sProcessUID
+ * @return boolean true
+ * throw Exception $oError
+ */
+// function webEntryByTask($sProcessUID, $sEventUID) {
+// $event = new Event();
+// $event->load($sEventUID);
+// $task_uid = $event->getEvnTasUidTo();
+// $tasks = new Tasks();
+// $tasks->get
+// $link = $sProcessUID.'/'.str_replace ( ' ', '_', str_replace ( '/', '_',$task_uid));
+//
+// return $link;
+// }
+
+ /*
+ * Return the supervisors dynaforms list criteria object
+ * @param string $sProcessUID
+ * @return object
+ */
+
+ function getSupervisorDynaformsCriteria($sProcessUID = '') {
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_UID);
+ $oCriteria->addSelectColumn(StepSupervisorPeer::PRO_UID);
+ $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_TYPE_OBJ);
+ $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_UID_OBJ);
+ $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_POSITION);
+ $oCriteria->addAsColumn('DYN_TITLE', 'C.CON_VALUE');
+ $oCriteria->addAlias('C', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(StepSupervisorPeer::STEP_UID_OBJ, DynaformPeer::DYN_UID);
+ $aConditions [] = array(StepSupervisorPeer::STEP_TYPE_OBJ, $sDelimiter . 'DYNAFORM' . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $aConditions = array();
+ $aConditions [] = array(DynaformPeer::DYN_UID, 'C.CON_ID');
+ $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'DYN_TITLE' . $sDelimiter);
+ $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, 'DYNAFORM');
+ $oCriteria->addAscendingOrderByColumn(StepSupervisorPeer::STEP_POSITION);
+ return $oCriteria;
+ }
+
+ /*
+ * Return the supervisors dynaforms list criteria object
+ * @param string $sProcessUID
+ * @return object
+ */
+
+ function getSupervisorInputsCriteria($sProcessUID = '') {
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_UID);
+ $oCriteria->addSelectColumn(StepSupervisorPeer::PRO_UID);
+ $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_TYPE_OBJ);
+ $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_UID_OBJ);
+ $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_POSITION);
+ $oCriteria->addAsColumn('INP_DOC_TITLE', 'C.CON_VALUE');
+ $oCriteria->addAlias('C', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(StepSupervisorPeer::STEP_UID_OBJ, InputDocumentPeer::INP_DOC_UID);
+ $aConditions [] = array(StepSupervisorPeer::STEP_TYPE_OBJ, $sDelimiter . 'INPUT_DOCUMENT' . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $aConditions = array();
+ $aConditions [] = array(InputDocumentPeer::INP_DOC_UID, 'C.CON_ID');
+ $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'INP_DOC_TITLE' . $sDelimiter);
+ $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, 'INPUT_DOCUMENT');
+ $oCriteria->addAscendingOrderByColumn(StepSupervisorPeer::STEP_POSITION);
+ return $oCriteria;
+ }
+
+ /*
+ * Show the available dynaforms for the supervisors
+ * @param string $sProcessUID
+ * @return boolean
+ */
+
+ function availableSupervisorDynaforms($sProcessUID) {
+ try {
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'dynaforms/dynaforms_AvailableSupervisorDynaforms', $this->getAvailableSupervisorDynaformsCriteria($sProcessUID), array('PRO_UID' => $sProcessUID));
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /*
- * Return the supervisors dynaforms list criteria object
- * @param string $sProcessUID
- * @return object
- */
- public function getSupervisorInputsCriteria($sProcessUID = '')
- {
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_UID);
- $oCriteria->addSelectColumn(StepSupervisorPeer::PRO_UID);
- $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_TYPE_OBJ);
- $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_UID_OBJ);
- $oCriteria->addSelectColumn(StepSupervisorPeer::STEP_POSITION);
- $oCriteria->addAsColumn('INP_DOC_TITLE', 'C.CON_VALUE');
- $oCriteria->addAlias('C', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(StepSupervisorPeer::STEP_UID_OBJ, InputDocumentPeer::INP_DOC_UID);
- $aConditions [] = array(StepSupervisorPeer::STEP_TYPE_OBJ, $sDelimiter . 'INPUT_DOCUMENT' . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $aConditions = array();
- $aConditions [] = array(InputDocumentPeer::INP_DOC_UID, 'C.CON_ID');
- $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'INP_DOC_TITLE' . $sDelimiter);
- $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
- $oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, 'INPUT_DOCUMENT');
- $oCriteria->addAscendingOrderByColumn(StepSupervisorPeer::STEP_POSITION);
- return $oCriteria;
+ /*
+ * Show the available input documents for the supervisors
+ * @param string $sProcessUID
+ * @return boolean
+ */
+
+ function availableSupervisorInputs($sProcessUID) {
+ try {
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'inputdocs/inputdocs_AvailableSupervisorInputs', $this->getAvailableSupervisorInputsCriteria($sProcessUID), array('PRO_UID' => $sProcessUID));
+ G::RenderPage('publish', 'raw');
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
}
+ }
- /*
- * Show the available dynaforms for the supervisors
- * @param string $sProcessUID
- * @return boolean
- */
- public function availableSupervisorDynaforms($sProcessUID)
- {
- try {
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'dynaforms/dynaforms_AvailableSupervisorDynaforms', $this->getAvailableSupervisorDynaformsCriteria($sProcessUID), array('PRO_UID' => $sProcessUID));
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
+ /*
+ * Return the available supervisors dynaforms list criteria object
+ * @param string $sProcessUID
+ * @return object
+ */
+
+ function getAvailableSupervisorDynaformsCriteria($sProcessUID = '') {
+ $oCriteria = $this->getSupervisorDynaformsCriteria($sProcessUID);
+ $oDataset = StepSupervisorPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $aUIDS = array();
+ while ($aRow = $oDataset->getRow()) {
+ $aUIDS [] = $aRow ['STEP_UID_OBJ'];
+ $oDataset->next();
}
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(DynaformPeer::DYN_UID);
+ $oCriteria->addSelectColumn(DynaformPeer::PRO_UID);
+ $oCriteria->addAsColumn('DYN_TITLE', 'C.CON_VALUE');
+ $oCriteria->addAlias('C', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(DynaformPeer::DYN_UID, 'C.CON_ID');
+ $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'DYN_TITLE' . $sDelimiter);
+ $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(DynaformPeer::DYN_TYPE, 'xmlform');
+ $oCriteria->add(DynaformPeer::DYN_UID, $aUIDS, Criteria::NOT_IN);
+ return $oCriteria;
+ }
- /*
- * Show the available input documents for the supervisors
- * @param string $sProcessUID
- * @return boolean
- */
- public function availableSupervisorInputs($sProcessUID)
- {
- try {
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'inputdocs/inputdocs_AvailableSupervisorInputs', $this->getAvailableSupervisorInputsCriteria($sProcessUID), array('PRO_UID' => $sProcessUID));
- G::RenderPage('publish', 'raw');
- return true;
- } catch (Exception $oError) {
- throw ($oError);
- }
+ /*
+ * Return the available supervisors input documents list criteria object
+ * @param string $sProcessUID
+ * @return object
+ */
+
+ function getAvailableSupervisorInputsCriteria($sProcessUID = '') {
+ $oCriteria = $this->getSupervisorInputsCriteria($sProcessUID);
+ $oDataset = StepSupervisorPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $aUIDS = array();
+ while ($aRow = $oDataset->getRow()) {
+ $aUIDS [] = $aRow ['STEP_UID_OBJ'];
+ $oDataset->next();
}
+ $sDelimiter = DBAdapter::getStringDelimiter ();
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(InputDocumentPeer::INP_DOC_UID);
+ $oCriteria->addSelectColumn(InputDocumentPeer::PRO_UID);
+ $oCriteria->addAsColumn('INP_DOC_TITLE', 'C.CON_VALUE');
+ $oCriteria->addAlias('C', 'CONTENT');
+ $aConditions = array();
+ $aConditions [] = array(InputDocumentPeer::INP_DOC_UID, 'C.CON_ID');
+ $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'INP_DOC_TITLE' . $sDelimiter);
+ $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
+ $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
+ $oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(InputDocumentPeer::INP_DOC_UID, $aUIDS, Criteria::NOT_IN);
+ return $oCriteria;
+ }
- /*
- * Return the available supervisors dynaforms list criteria object
- * @param string $sProcessUID
- * @return object
- */
- public function getAvailableSupervisorDynaformsCriteria($sProcessUID = '')
- {
- $oCriteria = $this->getSupervisorDynaformsCriteria($sProcessUID);
- $oDataset = StepSupervisorPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aUIDS = array();
- while ($aRow = $oDataset->getRow()) {
- $aUIDS [] = $aRow ['STEP_UID_OBJ'];
- $oDataset->next();
- }
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(DynaformPeer::DYN_UID);
- $oCriteria->addSelectColumn(DynaformPeer::PRO_UID);
- $oCriteria->addAsColumn('DYN_TITLE', 'C.CON_VALUE');
- $oCriteria->addAlias('C', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(DynaformPeer::DYN_UID, 'C.CON_ID');
- $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'DYN_TITLE' . $sDelimiter);
- $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
- $oCriteria->add(DynaformPeer::DYN_TYPE, 'xmlform');
- $oCriteria->add(DynaformPeer::DYN_UID, $aUIDS, Criteria::NOT_IN);
- return $oCriteria;
- }
+ /**
+ * assignSupervisorStep
+ *
+ * @param string $sProcessUID
+ * @param string $sObjType
+ * @param string $sObjUID
+ * @return void
+ */
+ function assignSupervisorStep($sProcessUID, $sObjType, $sObjUID) {
+ $oStepSupervisor = new StepSupervisor ( );
+ $oStepSupervisor->create(array('PRO_UID' => $sProcessUID, 'STEP_TYPE_OBJ' => $sObjType, 'STEP_UID_OBJ' => $sObjUID, 'STEP_POSITION' => $oStepSupervisor->getNextPosition($sProcessUID, $sObjType)));
+ }
- /*
- * Return the available supervisors input documents list criteria object
- * @param string $sProcessUID
- * @return object
- */
- public function getAvailableSupervisorInputsCriteria($sProcessUID = '')
- {
- $oCriteria = $this->getSupervisorInputsCriteria($sProcessUID);
- $oDataset = StepSupervisorPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aUIDS = array();
- while ($aRow = $oDataset->getRow()) {
- $aUIDS [] = $aRow ['STEP_UID_OBJ'];
- $oDataset->next();
- }
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(InputDocumentPeer::INP_DOC_UID);
- $oCriteria->addSelectColumn(InputDocumentPeer::PRO_UID);
- $oCriteria->addAsColumn('INP_DOC_TITLE', 'C.CON_VALUE');
- $oCriteria->addAlias('C', 'CONTENT');
- $aConditions = array();
- $aConditions [] = array(InputDocumentPeer::INP_DOC_UID, 'C.CON_ID');
- $aConditions [] = array('C.CON_CATEGORY', $sDelimiter . 'INP_DOC_TITLE' . $sDelimiter);
- $aConditions [] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID);
- $oCriteria->add(InputDocumentPeer::INP_DOC_UID, $aUIDS, Criteria::NOT_IN);
- return $oCriteria;
- }
+ /**
+ * removeSupervisorStep
+ *
+ * @param string $sStepUID
+ * @param string $sProcessUID
+ * @param string $sObjType
+ * @param string $sObjUID
+ * @param integer $iPosition
+ * @return void
+ */
+ function removeSupervisorStep($sStepUID, $sProcessUID, $sObjType, $sObjUID, $iPosition) {
+ $oStepSupervisor = new StepSupervisor ( );
+ $oStepSupervisor->remove($sStepUID);
+ $oStepSupervisor->reorderPositions($sProcessUID, $iPosition, $sObjType);
+ }
- /**
- * assignSupervisorStep
- * @param string $sProcessUID
- * @param string $sObjType
- * @param string $sObjUID
- * @return void
- */
- public function assignSupervisorStep($sProcessUID, $sObjType, $sObjUID)
- {
- $oStepSupervisor = new StepSupervisor ( );
- $oStepSupervisor->create(array('PRO_UID' => $sProcessUID, 'STEP_TYPE_OBJ' => $sObjType, 'STEP_UID_OBJ' => $sObjUID, 'STEP_POSITION' => $oStepSupervisor->getNextPosition($sProcessUID, $sObjType)));
- }
-
- /**
- * removeSupervisorStep
- *
- * @param string $sStepUID
- * @param string $sProcessUID
- * @param string $sObjType
- * @param string $sObjUID
- * @param integer $iPosition
- * @return void
- */
- public function removeSupervisorStep($sStepUID, $sProcessUID, $sObjType, $sObjUID, $iPosition) {
- $oStepSupervisor = new StepSupervisor ( );
- $oStepSupervisor->remove($sStepUID);
- $oStepSupervisor->reorderPositions($sProcessUID, $iPosition, $sObjType);
- }
-
- /**
- * listProcessesUser
- *
- * @param string $sProcessUID
- * @return object(Criteria) $oCriteria
- */
- public function listProcessesUser($sProcessUID)
- {
- $aResp = array(
- array(
- 'LA_PU_UID' => 'char',
- 'LA_PRO_UID' => 'char',
- 'LA_USR_UID' => 'char',
- 'LA_PU_NAME' => 'char',
- 'LA_PU_TYPE_NAME' => 'char')
- );
-
- // Groups
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(ProcessUserPeer::PU_UID);
- $oCriteria->addSelectColumn(ProcessUserPeer::USR_UID);
- $oCriteria->addSelectColumn(ProcessUserPeer::PRO_UID);
- $oCriteria->addAsColumn('GRP_TITLE', ContentPeer::CON_VALUE);
-
- $aConditions [] = array(ProcessUserPeer::USR_UID, ContentPeer::CON_ID);
- $aConditions [] = array(ContentPeer::CON_CATEGORY, DBAdapter::getStringDelimiter () . 'GRP_TITLE' . DBAdapter::getStringDelimiter ());
- $aConditions [] = array(ContentPeer::CON_LANG, DBAdapter::getStringDelimiter () . SYS_LANG . DBAdapter::getStringDelimiter ());
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
-
-<<<<<<< HEAD
- $oCriteria->add(ProcessUserPeer::PU_TYPE, 'GROUP_SUPERVISOR');
- $oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
- $oCriteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
-=======
/**
* listProcessesUser
*
@@ -3062,253 +3149,99 @@ class processMap {
* @return object(Criteria) $oCriteria
*/
function listProcessesUser($sProcessUID) {
- $aResp = array(
- array(
- 'LA_PU_UID' => 'char',
- 'LA_PRO_UID' => 'char',
- 'LA_USR_UID' => 'char',
- 'LA_PU_NAME' => 'char',
- 'LA_PU_TYPE_NAME' => 'char')
- );
- // Groups
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(ProcessUserPeer::PU_UID);
$oCriteria->addSelectColumn(ProcessUserPeer::USR_UID);
$oCriteria->addSelectColumn(ProcessUserPeer::PRO_UID);
- $oCriteria->addAsColumn('GRP_TITLE', ContentPeer::CON_VALUE);
-
- $aConditions [] = array(ProcessUserPeer::USR_UID, ContentPeer::CON_ID);
- $aConditions [] = array(ContentPeer::CON_CATEGORY, DBAdapter::getStringDelimiter () . 'GRP_TITLE' . DBAdapter::getStringDelimiter ());
- $aConditions [] = array(ContentPeer::CON_LANG, DBAdapter::getStringDelimiter () . SYS_LANG . DBAdapter::getStringDelimiter ());
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
-
- $oCriteria->add(ProcessUserPeer::PU_TYPE, 'GROUP_SUPERVISOR');
+ $oCriteria->addSelectColumn(ProcessUserPeer::PU_TYPE);
+ $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
+ $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
+ $oCriteria->addSelectColumn(UsersPeer::USR_EMAIL);
+ $oCriteria->addJoin(ProcessUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
$oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
- $oCriteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
+ return $oCriteria;
+ }
+ /**
+ * listNoProcessesUser
+ *
+ * @param string $sProcessUID
+ * @return object(Criteria) $oCriteria
+ */
+ function listNoProcessesUser($sProcessUID) {
+ G::LoadSystem('rbac');
+ $memcache = & PMmemcached::getSingleton(SYS_SYS);
+
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(ProcessUserPeer::USR_UID);
+ $oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
+ $oCriteria->add(ProcessUserPeer::PU_TYPE, 'SUPERVISOR');
$oDataset = ProcessUserPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
->>>>>>> upstream/master
-
- $oDataset = ProcessUserPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
-
- while ($aRow = $oDataset->getRow()) {
- $aResp[] = array(
- 'LA_PU_UID' => $aRow['PU_UID'],
- 'LA_PRO_UID' => $aRow['PRO_UID'],
- 'LA_USR_UID' => $aRow['USR_UID'],
- 'LA_PU_NAME' => $aRow['GRP_TITLE'],
- 'LA_PU_TYPE_NAME' => 'Group');
- $oDataset->next();
- }
-
- // Users
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(ProcessUserPeer::PU_UID);
- $oCriteria->addSelectColumn(ProcessUserPeer::USR_UID);
- $oCriteria->addSelectColumn(ProcessUserPeer::PRO_UID);
- $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
- $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
- $oCriteria->addSelectColumn(UsersPeer::USR_EMAIL);
- $oCriteria->addJoin(ProcessUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
- $oCriteria->add(ProcessUserPeer::PU_TYPE, 'SUPERVISOR');
- $oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
- $oCriteria->addAscendingOrderByColumn(UsersPeer::USR_FIRSTNAME);
- $oDataset = ProcessUserPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
-
- while ($aRow = $oDataset->getRow()) {
- $aResp[] = array(
- 'LA_PU_UID' => $aRow['PU_UID'],
- 'LA_PRO_UID' => $aRow['PRO_UID'],
- 'LA_USR_UID' => $aRow['USR_UID'],
- 'LA_PU_NAME' => $aRow['USR_FIRSTNAME'] . ' ' . $aRow['USR_LASTNAME'],
- 'LA_PU_TYPE_NAME' => 'User');
- $oDataset->next();
- }
-
- global $_DBArray;
- $_DBArray['data'] = $aResp;
- $_SESSION['_DBArray'] = $_DBArray;
- $LiCriteria = new Criteria('dbarray');
- $LiCriteria->setDBArrayTable('data');
-
- return $LiCriteria;
+ $aUIDS = array();
+ while ($aRow = $oDataset->getRow()) {
+ $aUIDS [] = $aRow ['USR_UID'];
+ $oDataset->next();
}
-
- /**
- * listNoProcessesUser
- *
- * @param string $sProcessUID
- * @return object(Criteria) $oCriteria
- */
- public function listNoProcessesUser($sProcessUID)
- {
- G::LoadSystem('rbac');
- $memcache = & PMmemcached::getSingleton(SYS_SYS);
-
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(ProcessUserPeer::USR_UID);
- $oCriteria->addSelectColumn(ProcessUserPeer::PU_TYPE);
- $oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
- $oCriteria->add(ProcessUserPeer::PU_TYPE, '%SUPERVISOR%', Criteria::LIKE);
- $oDataset = ProcessUserPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aUIDS = array();
- $aGRUS = array();
- while ($aRow = $oDataset->getRow()) {
- if ($aRow['PU_TYPE'] == 'SUPERVISOR') {
- $aUIDS [] = $aRow ['USR_UID'];
- } else {
- $aGRUS [] = $aRow ['USR_UID'];
- }
- $oDataset->next();
- }
-
- $aRespLi = array(
- array(
- 'UID' => 'char',
- 'USER_GROUP' => 'char',
- 'TYPE_UID' => 'char',
- 'PRO_UID' => 'char')
- );
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(GroupwfPeer::GRP_UID);
- $oCriteria->addAsColumn('GRP_TITLE', ContentPeer::CON_VALUE);
-
- $aConditions [] = array(GroupwfPeer::GRP_UID, ContentPeer::CON_ID);
- $aConditions [] = array(ContentPeer::CON_CATEGORY, DBAdapter::getStringDelimiter () . 'GRP_TITLE' . DBAdapter::getStringDelimiter ());
- $aConditions [] = array(ContentPeer::CON_LANG, DBAdapter::getStringDelimiter () . SYS_LANG . DBAdapter::getStringDelimiter ());
-
-<<<<<<< HEAD
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(GroupwfPeer::GRP_UID, $aGRUS, Criteria::NOT_IN);
-=======
- $aRespLi = array(
- array(
- 'UID' => 'char',
- 'USER_GROUP' => 'char',
- 'TYPE_UID' => 'char',
- 'PRO_UID' => 'char')
- );
+ $sDelimiter = DBAdapter::getStringDelimiter ();
$oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(GroupwfPeer::GRP_UID);
- $oCriteria->addAsColumn('GRP_TITLE', ContentPeer::CON_VALUE);
-
- $aConditions [] = array(GroupwfPeer::GRP_UID, ContentPeer::CON_ID);
- $aConditions [] = array(ContentPeer::CON_CATEGORY, DBAdapter::getStringDelimiter () . 'GRP_TITLE' . DBAdapter::getStringDelimiter ());
- $aConditions [] = array(ContentPeer::CON_LANG, DBAdapter::getStringDelimiter () . SYS_LANG . DBAdapter::getStringDelimiter ());
-
- $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
- $oCriteria->add(GroupwfPeer::GRP_UID, $aGRUS, Criteria::NOT_IN);
-
- $oCriteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
- $oDataset = GroupwfPeer::doSelectRS($oCriteria);
+ $oCriteria->addSelectColumn(UsersPeer::USR_UID);
+ $oCriteria->add(UsersPeer::USR_UID, $aUIDS, Criteria::NOT_IN);
+ $oDataset = UsersPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
->>>>>>> upstream/master
-
- $oCriteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
- $oDataset = GroupwfPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
-
- while ($aRow = $oDataset->getRow()) {
- $aRespLi[] = array( 'UID' => $aRow['GRP_UID'],
- 'USER_GROUP' => $aRow['GRP_TITLE'],
- 'TYPE_UID' => 'Group',
- 'PRO_UID' => $sProcessUID);
- $oDataset->next();
+ $aUIDS = array();
+ $oRBAC = RBAC::getSingleton ();
+ while ($aRow = $oDataset->getRow()) {
+ $memKey = 'rbacSession' . session_id();
+ if ( ($oRBAC->aUserInfo = $memcache->get($memKey)) === false ) {
+ $oRBAC->loadUserRolePermission($oRBAC->sSystem, $aRow ['USR_UID']);
+ $memcache->set( $memKey, $oRBAC->aUserInfo, PMmemcached::EIGHT_HOURS );
+ }
+ $aPermissions = $oRBAC->aUserInfo [$oRBAC->sSystem] ['PERMISSIONS'];
+ $bInclude = false;
+ foreach ($aPermissions as $aPermission) {
+ if ($aPermission ['PER_CODE'] == 'PM_SUPERVISOR') {
+ $bInclude = true;
}
-
- $sDelimiter = DBAdapter::getStringDelimiter ();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(UsersPeer::USR_UID);
- $oCriteria->add(UsersPeer::USR_UID, $aUIDS, Criteria::NOT_IN);
- $oDataset = UsersPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aUIDS = array();
- $oRBAC = RBAC::getSingleton ();
- while ($aRow = $oDataset->getRow()) {
- $memKey = 'rbacSession' . session_id();
- if ( ($oRBAC->aUserInfo = $memcache->get($memKey)) === false ) {
- $oRBAC->loadUserRolePermission($oRBAC->sSystem, $aRow ['USR_UID']);
- $memcache->set( $memKey, $oRBAC->aUserInfo, PMmemcached::EIGHT_HOURS );
- }
- $aPermissions = $oRBAC->aUserInfo [$oRBAC->sSystem] ['PERMISSIONS'];
- $bInclude = false;
- foreach ($aPermissions as $aPermission) {
- if ($aPermission ['PER_CODE'] == 'PM_SUPERVISOR') {
- $bInclude = true;
- }
- }
- if ($bInclude) {
- $aUIDS [] = $aRow ['USR_UID'];
- }
- $oDataset->next();
- }
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(UsersPeer::USR_UID);
- $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
- $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
- $oCriteria->add(UsersPeer::USR_UID, $aUIDS, Criteria::IN);
- $oCriteria->addAscendingOrderByColumn(UsersPeer::USR_FIRSTNAME);
- $oDataset = UsersPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
-
- while ($aRow = $oDataset->getRow()) {
- $aRespLi[] = array('UID' => $aRow['USR_UID'],
- 'USER_GROUP' => $aRow['USR_FIRSTNAME'] . ' ' . $aRow['USR_LASTNAME'],
- 'TYPE_UID' => 'User',
- 'PRO_UID' => $sProcessUID);
- $oDataset->next();
- }
-
- global $_DBArray;
- $_DBArray['data'] = $aRespLi;
- $_SESSION['_DBArray'] = $_DBArray;
- $LsCriteria = new Criteria('dbarray');
- $LsCriteria->setDBArrayTable('data');
-
- return $LsCriteria;
+ }
+ if ($bInclude) {
+ $aUIDS [] = $aRow ['USR_UID'];
+ }
+ $oDataset->next();
}
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(UsersPeer::USR_UID);
+ $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
+ $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
+ $oCriteria->add(UsersPeer::USR_UID, $aUIDS, Criteria::IN);
+ return $oCriteria;
+ }
- /**
- * assignProcessUser
- *
- * @param string $sProcessUID
- * @param string $sUsrUID
- * @return void
- */
- public function assignProcessUser($sProcessUID, $sUsrUID, $sTypeUID)
- {
- $oProcessUser = new ProcessUser ( );
- $puType = 'SUPERVISOR';
- if ($sTypeUID == 'Group') {
- $puType = 'GROUP_SUPERVISOR';
- }
- $oProcessUser->create(array('PU_UID' => G::generateUniqueID (), 'PRO_UID' => $sProcessUID, 'USR_UID' => $sUsrUID, 'PU_TYPE' => $puType));
- }
+ /**
+ * assignProcessUser
+ *
+ * @param string $sProcessUID
+ * @param string $sUsrUID
+ * @return void
+ */
+ function assignProcessUser($sProcessUID, $sUsrUID) {
+ $oProcessUser = new ProcessUser ( );
+ $oProcessUser->create(array('PU_UID' => G::generateUniqueID (), 'PRO_UID' => $sProcessUID, 'USR_UID' => $sUsrUID, 'PU_TYPE' => 'SUPERVISOR'));
+ }
- /**
- * removeProcessUser
- *
- * @param string $sPUUID
- * @return void
- */
- public function removeProcessUser($sPUUID)
- {
- $oProcessUser = new ProcessUser ( );
- $oProcessUser->remove($sPUUID);
- }
+ /**
+ * removeProcessUser
+ *
+ * @param string $sPUUID
+ * @return void
+ */
+ function removeProcessUser($sPUUID) {
+ $oProcessUser = new ProcessUser ( );
+ $oProcessUser->remove($sPUUID);
+ }
/**
* getObjectsPermissionsCriteria
@@ -3431,10 +3364,6 @@ class processMap {
$sObject = G::LoadTranslation('ID_ALL');
}
break;
- case 'CASES_NOTES' :
- $sObjectType = G::LoadTranslation('ID_CASES_NOTES');
- $sObject = G::LoadTranslation('ID_ALL');
- break;
default :
$sObjectType = G::LoadTranslation('ID_ALL');
$sObject = G::LoadTranslation('ID_ALL');
@@ -3462,62 +3391,59 @@ class processMap {
return $oCriteria;
}
- //new functions
- public function getAllObjectPermissionCount()
- {
- $c = $this->tmpCriteria;
- $c->clearSelectColumns();
- $c->addSelectColumn('COUNT(*)');
- $oDataset = ObjectPermissionPeer::doSelectRS($c);
- $oDataset->next();
- $aRow = $oDataset->getRow();
+ //new functions
+ function getAllObjectPermissionCount(){
+ $c = $this->tmpCriteria;
+ $c->clearSelectColumns();
+ $c->addSelectColumn('COUNT(*)');
+ $oDataset = ObjectPermissionPeer::doSelectRS($c);
+ $oDataset->next();
+ $aRow = $oDataset->getRow();
- if ( is_array($aRow) ) {
- return $aRow[0];
- } else {
- return 0;
+ if( is_array($aRow) )
+ return $aRow[0];
+ else
+ return 0;
+ }
+
+ function getExtObjectsPermissions($start, $limit,$sProcessUID) {
+ G::LoadClass('case');
+ Cases::verifyTable ();
+ $aObjectsPermissions = array();
+ //$aObjectsPermissions [] = array('OP_UID' => 'char', 'TASK_TARGET' => 'char', 'GROUP_USER' => 'char', 'TASK_SOURCE' => 'char', 'OBJECT_TYPE' => 'char', 'OBJECT' => 'char', 'PARTICIPATED' => 'char', 'ACTION' => 'char', 'OP_CASE_STATUS' => 'char');
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_UID);
+ $oCriteria->addSelectColumn(ObjectPermissionPeer::TAS_UID);
+ $oCriteria->addSelectColumn(ObjectPermissionPeer::USR_UID);
+ $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_USER_RELATION);
+ $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_TASK_SOURCE);
+ $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_PARTICIPATE);
+ $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_OBJ_TYPE);
+ $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_OBJ_UID);
+ $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_ACTION);
+ $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_CASE_STATUS);
+ $oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID);
+ $this->tmpCriteria = clone $oCriteria;
+
+ if($start != '')
+ $oCriteria->setOffset($start);
+ if($limit != '')
+ $oCriteria->setLimit($limit);
+
+ $oDataset = ObjectPermissionPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ //Obtain task target
+ if (($aRow ['TAS_UID'] != '') && ($aRow ['TAS_UID'] != '0')) {
+ try {
+ $oTask = new Task ( );
+ $aFields = $oTask->load($aRow ['TAS_UID']);
+ $sTaskTarget = $aFields ['TAS_TITLE'];
+ } catch (Exception $oError) {
+ $sTaskTarget = 'All Tasks';
}
- }
-
- public function getExtObjectsPermissions($start, $limit,$sProcessUID)
- {
- G::LoadClass('case');
- Cases::verifyTable ();
- $aObjectsPermissions = array();
- //$aObjectsPermissions [] = array('OP_UID' => 'char', 'TASK_TARGET' => 'char', 'GROUP_USER' => 'char', 'TASK_SOURCE' => 'char', 'OBJECT_TYPE' => 'char', 'OBJECT' => 'char', 'PARTICIPATED' => 'char', 'ACTION' => 'char', 'OP_CASE_STATUS' => 'char');
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_UID);
- $oCriteria->addSelectColumn(ObjectPermissionPeer::TAS_UID);
- $oCriteria->addSelectColumn(ObjectPermissionPeer::USR_UID);
- $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_USER_RELATION);
- $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_TASK_SOURCE);
- $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_PARTICIPATE);
- $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_OBJ_TYPE);
- $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_OBJ_UID);
- $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_ACTION);
- $oCriteria->addSelectColumn(ObjectPermissionPeer::OP_CASE_STATUS);
- $oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID);
- $this->tmpCriteria = clone $oCriteria;
-
- if ($start != '')
- $oCriteria->setOffset($start);
- if ($limit != '')
- $oCriteria->setLimit($limit);
-
- $oDataset = ObjectPermissionPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- //Obtain task target
- if (($aRow ['TAS_UID'] != '') && ($aRow ['TAS_UID'] != '0')) {
- try {
- $oTask = new Task ( );
- $aFields = $oTask->load($aRow ['TAS_UID']);
- $sTaskTarget = $aFields ['TAS_TITLE'];
- } catch (Exception $oError) {
- $sTaskTarget = 'All Tasks';
- }
- } else {
+ } else {
$sTaskTarget = G::LoadTranslation('ID_ANY_TASK');
}
//Obtain user or group
@@ -3587,3413 +3513,3408 @@ class processMap {
}
break;
}
- //Participated
- if ($aRow ['OP_PARTICIPATE'] == 0) {
- $sParticipated = G::LoadTranslation('ID_NO');
- } else {
- $sParticipated = G::LoadTranslation('ID_YES');
- }
- //Obtain action (permission)
- $sAction = G::LoadTranslation('ID_' . $aRow ['OP_ACTION']);
- //Add to array
- $aObjectsPermissions [] = array('OP_UID' => $aRow ['OP_UID'], 'TASK_TARGET' => $sTaskTarget, 'GROUP_USER' => $sUserGroup, 'TASK_SOURCE' => $sTaskSource, 'OBJECT_TYPE' => $sObjectType, 'OBJECT' => $sObject, 'PARTICIPATED' => $sParticipated, 'ACTION' => $sAction, 'OP_CASE_STATUS' => $aRow ['OP_CASE_STATUS']);
- $oDataset->next();
- }
- return $aObjectsPermissions;
+ //Participated
+ if ($aRow ['OP_PARTICIPATE'] == 0) {
+ $sParticipated = G::LoadTranslation('ID_NO');
+ } else {
+ $sParticipated = G::LoadTranslation('ID_YES');
+ }
+ //Obtain action (permission)
+ $sAction = G::LoadTranslation('ID_' . $aRow ['OP_ACTION']);
+ //Add to array
+ $aObjectsPermissions [] = array('OP_UID' => $aRow ['OP_UID'], 'TASK_TARGET' => $sTaskTarget, 'GROUP_USER' => $sUserGroup, 'TASK_SOURCE' => $sTaskSource, 'OBJECT_TYPE' => $sObjectType, 'OBJECT' => $sObject, 'PARTICIPATED' => $sParticipated, 'ACTION' => $sAction, 'OP_CASE_STATUS' => $aRow ['OP_CASE_STATUS']);
+ $oDataset->next();
+ }
+ return $aObjectsPermissions;
+ }
+
+ /**
+ * objectsPermissionsList
+ *
+ * @param string $sProcessUID
+ * @return boolean true
+ */
+ function objectsPermissionsList($sProcessUID) {
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('propeltable', 'paged-table', 'processes/processes_ObjectsPermissionsList', $this->getObjectsPermissionsCriteria($sProcessUID), array('PRO_UID' => $sProcessUID));
+ G::RenderPage('publish', 'raw');
+ return true;
+ }
+
+ /**
+ * newObjectPermission
+ *
+ * @param string $sProcessUID
+ * @return boolean true
+ */
+ function newObjectPermission($sProcessUID) {
+ $usersGroups = '';
+ $aAllObjects = array();
+ $aAllObjects [] = array('UID' => 'char', 'LABEL' => 'char');
+ $aAllDynaforms = array();
+ $aAllDynaforms [] = array('UID' => 'char', 'LABEL' => 'char');
+ $aAllInputs = array();
+ $aAllInputs [] = array('UID' => 'char', 'LABEL' => 'char');
+ $aAllOutputs = array();
+ $aAllOutputs [] = array('UID' => 'char', 'LABEL' => 'char');
+ $oCriteria = $this->getDynaformsCriteria($sProcessUID);
+ $oCriteria->add(DynaformPeer::DYN_TYPE, 'XMLFORM');
+ $oDataset = DynaformPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aRow ['DYN_TITLE'] = (isset($aRow ['DYN_TITLE'])) ? $aRow ['DYN_TITLE'] : '';
+ $aAllObjects [] = array('UID' => 'DYNAFORM|' . $aRow ['DYN_UID'],
+ 'LABEL' => $aRow ['DYN_TITLE'] . ' (' . G::LoadTranslation('ID_DYNAFORM') . ')');
+ $aAllDynaforms [] = array('UID' => $aRow ['DYN_UID'],
+ 'LABEL' => $aRow ['DYN_TITLE']);
+ $oDataset->next();
+ }
+ G::LoadClass('ArrayPeer');
+ $oDataset = ArrayBasePeer::doSelectRS($this->getInputDocumentsCriteria($sProcessUID));
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aAllObjects [] = array('UID' => 'INPUT_DOCUMENT|' . $aRow ['INP_DOC_UID'],
+ 'LABEL' => $aRow ['INP_DOC_TITLE'] . ' (' . G::LoadTranslation('ID_INPUT_DOCUMENT') . ')');
+ $aAllInputs [] = array('UID' => $aRow ['INP_DOC_UID'],
+ 'LABEL' => $aRow ['INP_DOC_TITLE']);
+ $oDataset->next();
+ }
+ G::LoadClass('ArrayPeer');
+ $oDataset = ArrayBasePeer::doSelectRS($this->getOutputDocumentsCriteria($sProcessUID));
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aAllObjects [] = array('UID' => 'OUTPUT_DOCUMENT|' . $aRow ['OUT_DOC_UID'], 'LABEL' => $aRow ['OUT_DOC_TITLE'] . ' (' . G::LoadTranslation('ID_OUTPUT_DOCUMENT') . ')');
+ $aAllOutputs [] = array('UID' => $aRow ['OUT_DOC_UID'], 'LABEL' => $aRow ['OUT_DOC_TITLE']);
+ $oDataset->next();
+ }
+ global $_DBArray;
+ $_DBArray = (isset($_SESSION ['_DBArray']) ? $_SESSION ['_DBArray'] : '');
+ $_DBArray ['allObjects'] = $aAllObjects;
+ $_DBArray ['allDynaforms'] = $aAllDynaforms;
+ $_DBArray ['allInputs'] = $aAllInputs;
+ $_DBArray ['allOutputs'] = $aAllOutputs;
+ $_SESSION ['_DBArray'] = $_DBArray;
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher ( );
+ $G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_NewObjectPermission', '', array('GROUP_USER' => $usersGroups, 'LANG' => SYS_LANG, 'PRO_UID' => $sProcessUID, 'ID_DELETE' => G::LoadTranslation('ID_DELETE')), 'processes_SaveObjectPermission');
+ G::RenderPage('publish', 'raw');
+ return true;
+ }
+
+ /**
+ * editObjectPermission
+ *
+ * @param string $sOP_UID
+ * @param string $sProcessUID
+ * @return void
+ */
+ function editObjectPermission($sOP_UID, $sProcessUID) {
+
+ $oCriteria = new Criteria ( );
+ $oCriteria->add(ObjectPermissionPeer::OP_UID, $sOP_UID);
+ $oDataset = ObjectPermissionPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $aRows = $oDataset->getRow();
+
+ $oCriteria = new Criteria ( );
+ $oCriteria->add(GroupwfPeer::GRP_UID, $aRows ['USR_UID']);
+ if (GroupwfPeer::doCount($oCriteria) == 1)
+ $user = '2|' . $aRows ['USR_UID'];
+
+ $oCriteria = new Criteria ( );
+ $oCriteria->add(UsersPeer::USR_UID, $aRows ['USR_UID']);
+ if (UsersPeer::doCount($oCriteria) == 1)
+ $user = '1|' . $aRows ['USR_UID'];
+
+ $aFields ['LANG'] = SYS_LANG;
+ $aFields ['OP_UID'] = $aRows ['OP_UID'];
+ $aFields ['PRO_UID'] = $aRows ['PRO_UID'];
+ $aFields ['OP_CASE_STATUS'] = $aRows ['OP_CASE_STATUS'];
+ $aFields ['TAS_UID'] = $aRows ['TAS_UID'];
+ $aFields ['OP_TASK_SOURCE'] = $aRows ['OP_TASK_SOURCE'];
+ $aFields ['OP_PARTICIPATE'] = $aRows ['OP_PARTICIPATE'];
+ $aFields ['OP_OBJ_TYPE'] = $aRows ['OP_OBJ_TYPE'];
+ $aFields ['OP_ACTION'] = $aRows ['OP_ACTION'];
+
+ switch ($aRows ['OP_OBJ_TYPE']) {
+ /* case 'ANY':
+ $aFields['OP_OBJ_TYPE'] = '';
+ break; */
+ case 'DYNAFORM' :
+ $aFields ['DYNAFORMS'] = $aRows ['OP_OBJ_UID'];
+ break;
+ case 'INPUT' :
+ $aFields ['INPUTS'] = $aRows ['OP_OBJ_UID'];
+ break;
+ case 'OUTPUT' :
+ $aFields ['OUTPUTS'] = $aRows ['OP_OBJ_UID'];
+ break;
}
- /**
- * objectsPermissionsList
- *
- * @param string $sProcessUID
- * @return boolean true
- */
- public function objectsPermissionsList($sProcessUID)
- {
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher ( );
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'processes/processes_ObjectsPermissionsList', $this->getObjectsPermissionsCriteria($sProcessUID), array('PRO_UID' => $sProcessUID));
- G::RenderPage('publish', 'raw');
- return true;
+ $usersGroups = '