Merge remote-tracking branch 'upstream/3.0.1.8' into 3.0.1.7-Gmail

This commit is contained in:
Dante
2016-02-17 14:18:56 -04:00
45 changed files with 1083 additions and 281 deletions

View File

@@ -75,6 +75,50 @@ class Cases
}
}
/**
* Get list counters
*
* @param string $userUid Unique id of User
* @param array $arrayType Type lists
*
* @return array Return the list counters
*/
public function getListCounters($userUid, array $arrayType)
{
try {
$solrEnabled = false;
$solrConf = \System::solrEnv();
if ($solrConf !== false) {
$ApplicationSolrIndex = new \AppSolr(
$solrConf['solr_enabled'],
$solrConf['solr_host'],
$solrConf['solr_instance']
);
if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
$solrEnabled = true;
}
}
$appCacheView = new \AppCacheView();
if ($solrEnabled) {
$arrayListCounter = array_merge(
$ApplicationSolrIndex->getCasesCount($userUid),
$appCacheView->getAllCounters(['completed', 'cancelled'], $userUid)
);
} else {
$arrayListCounter = $appCacheView->getAllCounters($arrayType, $userUid);
}
//Return
return $arrayListCounter;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get list for Cases
*
@@ -1117,12 +1161,15 @@ class Cases
$aAux = $oAppDocument->load($aRow['APP_DOC_UID'], $aRow['DOC_VERSION']);
$lastVersion = $oAppDocument->getLastAppDocVersion($aRow['APP_DOC_UID'], $sApplicationUID);
try {
$aAux1 = $oUser->load($aAux['USR_UID']);
if ($aAux['USR_UID'] !== "-1") {
try {
$aAux1 = $oUser->load($aAux['USR_UID']);
$sUser = $conf->usersNameFormatBySetParameters($confEnvSetting["format"], $aAux1["USR_USERNAME"], $aAux1["USR_FIRSTNAME"], $aAux1["USR_LASTNAME"]);
} catch (Exception $oException) {
//$sUser = '(USER DELETED)';
$sUser = $conf->usersNameFormatBySetParameters($confEnvSetting["format"], $aAux1["USR_USERNAME"], $aAux1["USR_FIRSTNAME"], $aAux1["USR_LASTNAME"]);
} catch (Exception $oException) {
$sUser = '***';
}
} else {
$sUser = '***';
}
$aFields = array(
@@ -2420,4 +2467,196 @@ class Cases
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* Get Users to reassign
*
* @param string $userUid Unique id of User (User logged)
* @param string $taskUid Unique id of Task
* @param array $arrayFilterData Data of the filters
* @param string $sortField Field name to sort
* @param string $sortDir Direction of sorting (ASC, DESC)
* @param int $start Start
* @param int $limit Limit
*
* @return array Return Users to reassign
*/
public function getUsersToReassign($userUid, $taskUid, $arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
{
try {
$arrayUser = [];
$numRecTotal = 0;
//Set variables
$task = \TaskPeer::retrieveByPK($taskUid);
$processUid = $task->getProUid();
$user = new \ProcessMaker\BusinessModel\User();
$task = new \Tasks();
$group = new \Groups();
//Set variables
$filterName = 'filter';
if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData['filter'])) {
$arrayAux = [
'' => 'filter',
'LEFT' => 'lfilter',
'RIGHT' => 'rfilter'
];
$filterName = $arrayAux[(isset($arrayFilterData['filterOption']))? $arrayFilterData['filterOption'] : ''];
}
//Get data
if (!is_null($limit) && $limit . '' == '0') {
//Return
return [
'total' => $numRecTotal,
'start' => (int)((!is_null($start))? $start : 0),
'limit' => (int)((!is_null($limit))? $limit : 0),
$filterName => (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData['filter']))? $arrayFilterData['filter'] : '',
'data' => $arrayUser
];
}
//Set variables
$processSupervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
$arrayResult = $processSupervisor->getProcessSupervisors($processUid, 'ASSIGNED', null, null, null, 'group');
$arrayGroupUid = array_merge(
array_map(function ($value) { return $value['GRP_UID']; }, $task->getGroupsOfTask($taskUid, 1)), //Groups
array_map(function ($value) { return $value['GRP_UID']; }, $task->getGroupsOfTask($taskUid, 2)), //AdHoc Groups
array_map(function ($value) { return $value['grp_uid']; }, $arrayResult['data']) //ProcessSupervisor Groups
);
$sqlTaskUser = '
SELECT ' . \TaskUserPeer::USR_UID . '
FROM ' . \TaskUserPeer::TABLE_NAME . '
WHERE ' . \TaskUserPeer::TAS_UID . ' = \'%s\' AND
' . \TaskUserPeer::TU_TYPE . ' IN (1, 2) AND
' . \TaskUserPeer::TU_RELATION . ' = 1
';
$sqlGroupUser = '
SELECT ' . \GroupUserPeer::USR_UID . '
FROM ' . \GroupUserPeer::TABLE_NAME . '
WHERE ' . \GroupUserPeer::GRP_UID . ' IN (%s)
';
$sqlProcessSupervisor = '
SELECT ' . \ProcessUserPeer::USR_UID . '
FROM ' . \ProcessUserPeer::TABLE_NAME . '
WHERE ' . \ProcessUserPeer::PRO_UID . ' = \'%s\' AND
' . \ProcessUserPeer::PU_TYPE . ' = \'%s\'
';
$sqlUserToReassign = '(' . sprintf($sqlTaskUser, $taskUid) . ')';
if (!empty($arrayGroupUid)) {
$sqlUserToReassign .= ' UNION (' . sprintf($sqlGroupUser, '\'' . implode('\', \'', $arrayGroupUid) . '\'') . ')';
}
$sqlUserToReassign .= ' UNION (' . sprintf($sqlProcessSupervisor, $processUid, 'SUPERVISOR') . ')';
//Query
$criteria = new \Criteria('workflow');
$criteria->addSelectColumn(\UsersPeer::USR_UID);
$criteria->addSelectColumn(\UsersPeer::USR_USERNAME);
$criteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME);
$criteria->addSelectColumn(\UsersPeer::USR_LASTNAME);
$criteria->addAlias('USER_TO_REASSIGN', '(' . $sqlUserToReassign . ')');
$criteria->addJoin(\UsersPeer::USR_UID, 'USER_TO_REASSIGN.USR_UID', \Criteria::INNER_JOIN);
if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData['filter']) && trim($arrayFilterData['filter']) != '') {
$arraySearch = [
'' => '%' . $arrayFilterData['filter'] . '%',
'LEFT' => $arrayFilterData['filter'] . '%',
'RIGHT' => '%' . $arrayFilterData['filter']
];
$search = $arraySearch[(isset($arrayFilterData['filterOption']))? $arrayFilterData['filterOption'] : ''];
$criteria->add(
$criteria->getNewCriterion(\UsersPeer::USR_USERNAME, $search, \Criteria::LIKE)->addOr(
$criteria->getNewCriterion(\UsersPeer::USR_FIRSTNAME, $search, \Criteria::LIKE))->addOr(
$criteria->getNewCriterion(\UsersPeer::USR_LASTNAME, $search, \Criteria::LIKE))
);
}
$criteria->add(\UsersPeer::USR_STATUS, 'ACTIVE', \Criteria::EQUAL);
if (!$user->checkPermission($userUid, 'PM_SUPERVISOR')) {
$criteria->add(\UsersPeer::USR_UID, $userUid, \Criteria::NOT_EQUAL);
}
//Number records total
$criteriaCount = clone $criteria;
$criteriaCount->clearSelectColumns();
$criteriaCount->addSelectColumn('COUNT(' . \UsersPeer::USR_UID . ') AS NUM_REC');
$rsCriteriaCount = \UsersPeer::doSelectRS($criteriaCount);
$rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$result = $rsCriteriaCount->next();
$row = $rsCriteriaCount->getRow();
$numRecTotal = (int)($row['NUM_REC']);
//Query
if (!is_null($sortField) && trim($sortField) != '') {
$sortField = strtoupper($sortField);
if (in_array(\UsersPeer::TABLE_NAME . '.' . $sortField, $criteria->getSelectColumns())) {
$sortField = \UsersPeer::TABLE_NAME . '.' . $sortField;
} else {
$sortField = \UsersPeer::USR_FIRSTNAME;
}
} else {
$sortField = \UsersPeer::USR_FIRSTNAME;
}
if (!is_null($sortDir) && trim($sortDir) != '' && strtoupper($sortDir) == 'DESC') {
$criteria->addDescendingOrderByColumn($sortField);
} else {
$criteria->addAscendingOrderByColumn($sortField);
}
if (!is_null($start)) {
$criteria->setOffset((int)($start));
}
if (!is_null($limit)) {
$criteria->setLimit((int)($limit));
}
$rsCriteria = \UsersPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$arrayUser[] = $row;
}
//Return
return [
'total' => $numRecTotal,
'start' => (int)((!is_null($start))? $start : 0),
'limit' => (int)((!is_null($limit))? $limit : 0),
$filterName => (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData['filter']))? $arrayFilterData['filter'] : '',
'data' => $arrayUser
];
} catch (\Exception $e) {
throw $e;
}
}
}

View File

@@ -3,6 +3,26 @@ namespace ProcessMaker\BusinessModel\Cases;
class InputDocument
{
/**
* Verify exists app_doc_uid in table APP_DOCUMENT
*
* @param string $applicationUid
*
* return void Throw exception
*/
private function throwExceptionIfNotExistsAppDocument($appDocumentUid)
{
try {
$appDocument = \AppDocumentPeer::retrieveByPK($appDocumentUid, 1);
if (is_null($appDocument)) {
throw new \Exception(\G::LoadTranslation("ID_CASES_INPUT_DOES_NOT_EXIST", array($appDocumentUid)));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Check if the user has permissions
*
@@ -47,6 +67,9 @@ class InputDocument
throw new \Exception(\G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION_DELETE_INPUT_DOCUMENT", array($userUid)));
}
//verfiry exists $appDocumentUid
$this->throwExceptionIfNotExistsAppDocument($appDocumentUid);
//Verify data permission
$flagPermission = 0;
@@ -351,13 +374,16 @@ class InputDocument
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$arrayUserData = $user->load($row["USR_UID"]);
$sUser = '***';
if ($row["USR_UID"] !== '-1') {
$arrayUserData = $user->load($row["USR_UID"]);
$sUser = $configuraction->usersNameFormatBySetParameters($confEnvSetting["format"], $arrayUserData["USR_USERNAME"], $arrayUserData["USR_FIRSTNAME"], $arrayUserData["USR_LASTNAME"]);
}
$arrayAppDocument = $appDocument->load($row["APP_DOC_UID"], $row["DOC_VERSION"]);
$row["APP_DOC_FILENAME"] = $arrayAppDocument["APP_DOC_FILENAME"];
$row["APP_DOC_CREATE_USER"] = $configuraction->usersNameFormatBySetParameters($confEnvSetting["format"], $arrayUserData["USR_USERNAME"], $arrayUserData["USR_FIRSTNAME"], $arrayUserData["USR_LASTNAME"]);
$row["APP_DOC_CREATE_USER"] = $sUser;
$row["APP_DOC_LINK"] = "cases/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"];
$arrayInputDocument[] = $this->getAppDocumentDataFromRecord($row);

View File

@@ -3,6 +3,26 @@ namespace ProcessMaker\BusinessModel\Cases;
class OutputDocument
{
/**
* Verify exists app_doc_uid in table APP_DOCUMENT when is output
*
* @param string $applicationUid
*
* return void Throw exception output not exists
*/
private function throwExceptionIfNotExistsAppDocument($appDocumentUid)
{
try {
$appDocument = \AppDocumentPeer::retrieveByPK($appDocumentUid, 1);
if (is_null($appDocument)) {
throw new \Exception(\G::LoadTranslation("ID_CASES_OUTPUT_DOES_NOT_EXIST", array($appDocumentUid)));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Check if the user has permissions
*
@@ -26,6 +46,9 @@ class OutputDocument
$flagInbox = 0;
}
//Verfiry exists $appDocumentUid
$this->throwExceptionIfNotExistsAppDocument($appDocumentUid);
//Verify data permission
$flagPermission = 0;

View File

@@ -50,6 +50,27 @@ class Department
}
}
/**
* Verify if the User is not in a Department
*
* @param string $departmentUid
* @param string $userUid
*
* return void Throw exception user not exists
*/
private function throwExceptionUserNotExistsInDepartment($departmentUid, $userUid)
{
try {
$user = \UsersPeer::retrieveByPK($userUid);
if (is_null($user) || $user->getDepUid() != $departmentUid) {
throw new \Exception(\G::LoadTranslation('ID_USER_NOT_EXIST_DEPARTMENT', [$userUid]));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if exists the title of a Department
*
@@ -253,6 +274,8 @@ class Department
$dep_uid = Validator::depUid($dep_uid);
$usr_uid = Validator::usrUid($usr_uid);
$this->throwExceptionUserNotExistsInDepartment($dep_uid, $usr_uid);
$dep = new \Department();
$dep->load( $dep_uid );
$manager = $dep->getDepManager();

View File

@@ -22,6 +22,18 @@ class Light
{
$response = null;
try {
// getting bpmn projects
$c = new Criteria('workflow');
$c->addSelectColumn(\BpmnProjectPeer::PRJ_UID);
$ds = \ProcessPeer::doSelectRS($c, \Propel::getDbConnection('workflow_ro'));
$ds->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$bpmnProjects = array();
while ($ds->next()) {
$row = $ds->getRow();
$bpmnProjects[] = $row['PRJ_UID'];
}
$oProcess = new \Process();
$oCase = new \Cases();
@@ -65,7 +77,7 @@ class Light
$tempTreeChildren = array ();
foreach ($processList[$key] as $keyChild => $processInfoChild) {
$webEntryEventStart = $webEntryEvent->getWebEntryEvents($processInfoChild['pro_uid']);
if(empty($webEntryEventStart)){
if (empty($webEntryEventStart) && in_array($processInfoChild['pro_uid'], $bpmnProjects)) {
$tempTreeChild['text'] = $keyChild; //ellipsis ( $keyChild, 50 );
$tempTreeChild['processId'] = $processInfoChild['pro_uid'];
$tempTreeChild['taskId'] = $processInfoChild['uid'];

View File

@@ -152,11 +152,13 @@ class NotificationDevice
{
try {
$response = array();
$typeList = 'todo';
foreach ($aTasks as $aTask) {
$arrayTaskUser = array();
switch ($aTask["TAS_ASSIGN_TYPE"]) {
case "SELF_SERVICE":
$arrayTaskUser = $this->getTaskUserSelfService($aTask["TAS_UID"], $appFields);
$typeList = 'unassigned';
break;
default:
if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) {
@@ -181,7 +183,7 @@ class NotificationDevice
'caseId' => $appFields['APP_UID'],
'caseTitle' => $appFields['APP_TITLE'],
'delIndex' => $delIndex,
'typeList' => 'todo'
'typeList' => $typeList
);
if ($userIds) {

View File

@@ -2,7 +2,6 @@
namespace ProcessMaker\BusinessModel;
use \G;
use Luracast\Restler\User;
class ProcessSupervisor
{

View File

@@ -231,6 +231,9 @@ class Variable
$this->throwExceptionIfNotExistsVariable($variableUid);
//Verify variable
$this->throwExceptionIfVariableIsAssociatedAditionalTable($variableUid);
$variable = $this->getVariable($processUid, $variableUid);
\G::LoadClass('pmDynaform');
$pmDynaform = new \pmDynaform();
@@ -556,13 +559,16 @@ class Variable
\G::LoadClass('pmDynaform');
$pmDynaform = new \pmDynaform();
$field = $pmDynaform->searchField($arrayVariable["dyn_uid"], $arrayVariable["field_id"]);
$variableDbConnectionUid = $field !== null ? $field->dbConnection : "";
$dbConnection = "workflow";
if ($field !== null && !empty($field->dbConnection)) {
$dbConnection = $field->dbConnection;
}
$variableSql = $field !== null ? $field->sql : "";
//Get data
$_SESSION["PROCESS"] = $processUid;
$cnn = \Propel::getConnection(($variableDbConnectionUid . "" != "")? $variableDbConnectionUid : "workflow");
$cnn = \Propel::getConnection($dbConnection);
$stmt = $cnn->createStatement();
$replaceFields = G::replaceDataField($variableSql, $arrayVariable);
@@ -605,6 +611,40 @@ class Variable
}
}
/**
* Check if the variable is associated to Report Table
*
* @param string $variableUid Unique id of variable
*
* @return void Throw exception
*/
public function throwExceptionIfVariableIsAssociatedAditionalTable($variableUid)
{
try {
$criteria = new \Criteria('workflow');
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_UID);
$criteria->addJoin(\ProcessVariablesPeer::PRJ_UID, \AdditionalTablesPeer::PRO_UID, \Criteria::INNER_JOIN);
$arrayCondition = [];
$arrayCondition[] = array(\AdditionalTablesPeer::ADD_TAB_UID, \FieldsPeer::ADD_TAB_UID, \Criteria::EQUAL);
$arrayCondition[] = array(\ProcessVariablesPeer::VAR_NAME, \FieldsPeer::FLD_NAME, \Criteria::EQUAL);
$criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
$criteria->add(\ProcessVariablesPeer::VAR_UID, $variableUid, \Criteria::EQUAL);
$rsCriteria = \ProcessVariablesPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
if ($rsCriteria->next()) {
throw new \Exception(\G::LoadTranslation('ID_VARIABLE_ASSOCIATED_WITH_REPORT_TABLE', array($variableUid)));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if the variable is being used in a Dynaform
*
@@ -677,13 +717,16 @@ class Variable
\G::LoadClass('pmDynaform');
$pmDynaform = new \pmDynaform();
$field = $pmDynaform->searchField($arrayVariable["dyn_uid"], $variableName);
$variableDbConnectionUid = $field !== null ? $field->dbConnection : "";
$dbConnection = "workflow";
if ($field !== null && !empty($field->dbConnection)) {
$dbConnection = $field->dbConnection;
}
$variableSql = $field !== null ? $field->sql : "";
//Get data
$_SESSION["PROCESS"] = $processUid;
$cnn = \Propel::getConnection(($variableDbConnectionUid . "" != "") ? $variableDbConnectionUid : "workflow");
$cnn = \Propel::getConnection($dbConnection);
$stmt = $cnn->createStatement();
$replaceFields = G::replaceDataField($variableSql, $arrayVariable);
@@ -702,7 +745,7 @@ class Variable
}
$parser = new \PHPSQLParser($replaceFields);
$filter = str_replace("'", "''", $filter);
$replaceFields = $this->queryModified($parser->parsed, $filter, "*searchtype*", $start, $limit);
$replaceFields = $this->queryModified($parser->parsed, $filter, "*searchtype*", $start, $limit, $dbConnection);
$rs = $stmt->executeQuery($replaceFields, \ResultSet::FETCHMODE_NUM);
while ($rs->next()) {
@@ -721,7 +764,7 @@ class Variable
}
}
public function queryModified($sqlParsed, $inputSel = "", $searchType, $start, $limit)
public function queryModified($sqlParsed, $inputSel = "", $searchType = "*searchtype*", $start = 0, $limit = "", $dbConnection = "workflow")
{
if (!empty($sqlParsed['SELECT'])) {
$sqlSelectOptions = (isset($sqlParsed["OPTIONS"]) && count($sqlParsed["OPTIONS"]) > 0) ? implode(" ", $sqlParsed["OPTIONS"]) : null;
@@ -844,6 +887,26 @@ class Variable
if (!empty($sqlParsed['LIMIT'])) {
$sqlLimit = " LIMIT " . $sqlParsed['LIMIT']['start'] . ", " . $sqlParsed['LIMIT']['end'];
}
//get database provider
$a = new \Criteria("workflow");
$a->addSelectColumn(\DbSourcePeer::DBS_TYPE);
$a->add(\DbSourcePeer::DBS_UID, $dbConnection, \Criteria::EQUAL);
$ds = \DbSourcePeer::doSelectRS($a);
$ds->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$ds->next();
$row = $ds->getRow();
if (isset($row["DBS_TYPE"])) {
if ($row["DBS_TYPE"] === "pgsql") {
$sqlLimit = $this->limitPgsql($start, $limit);
}
if ($row["DBS_TYPE"] === "mssql") {
return $this->limitMssqlOracle($sqlSelect, $sqlFrom, $sqlWhere, $sqlGroupBy, $sqlHaving, $sqlOrderBy, $start, $limit, true);
}
if ($row["DBS_TYPE"] === "oracle") {
return $this->limitMssqlOracle($sqlSelect, $sqlFrom, $sqlWhere, $sqlGroupBy, $sqlHaving, $sqlOrderBy, $start, $limit, false);
}
}
return $sqlSelect . $sqlFrom . $sqlWhere . $sqlGroupBy . $sqlHaving . $sqlOrderBy . $sqlLimit;
}
@@ -873,6 +936,36 @@ class Variable
}
}
public function limitPgsql($start = 0, $limit = "")
{
$sqlLimit = "";
if ($start >= 0) {
$sqlLimit = " OFFSET " . $start;
}
if ($limit !== "") {
$sqlLimit = $sqlLimit . " LIMIT " . $limit;
}
return $sqlLimit;
}
public function limitMssqlOracle($sqlSelect = "", $sqlFrom = "", $sqlWhere = "", $sqlGroupBy = "", $sqlHaving = "", $sqlOrderBy = "", $start = 0, $limit = "", $isMssql = true)
{
$sqlLimit = "";
if ($start >= 0) {
$sqlLimit = "WHERE rn >= " . $start;
}
if ($start >= 0 && $limit != "") {
$sqlLimit = "WHERE rn BETWEEN " . $start . " AND " . $limit;
}
$sql = ""
. "SELECT * FROM ("
. " " . $sqlSelect . ", ROW_NUMBER() OVER( " . $sqlOrderBy . " desc )-1 " . ($isMssql ? " AS " : "") . " rn "
. " " . $sqlFrom . $sqlWhere . $sqlGroupBy . $sqlHaving
. ")" . ($isMssql ? " AS A " : "")
. $sqlLimit;
return $sql;
}
public function getVariableTypeByName($processUid, $variableName)
{
try {
@@ -897,4 +990,4 @@ class Variable
}
}
}
}

View File

@@ -114,20 +114,19 @@ class Department extends Api
}
/**
* @url PUT /:dep_uid/unassign-user/:usr_uid
* @url DELETE /:dep_uid/unassign-user/:usr_uid
*
* @param string $dep_uid {@min 1}{@max 32}
* @param string $usr_uid {@min 1}{@max 32}
*
* @return array
* @status 200
*
*/
public function doPutUnassignUser($dep_uid, $usr_uid)
public function doDeleteUnassignUser($dep_uid, $usr_uid)
{
try {
$oDepartment = new \ProcessMaker\BusinessModel\Department();
$response = $oDepartment->unassignUser($dep_uid, $usr_uid);
return $response;
$oDepartment->unassignUser($dep_uid, $usr_uid);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}

View File

@@ -39,9 +39,25 @@ class Light extends Api
{
try {
$userId = $this->getUserId();
$lists = new \ProcessMaker\BusinessModel\Lists();
$response = $lists->getCounters($userId);
$result = $this->parserCountersCases($response);
/*----------------------------------********---------------------------------*/
if (true) {
//In enterprise version this block of code should always be executed
//In community version this block of code is deleted and is executed the other
$list = new \ProcessMaker\BusinessModel\Lists();
$arrayListCounter = $list->getCounters($userId);
} else {
/*----------------------------------********---------------------------------*/
$case = new \ProcessMaker\BusinessModel\Cases();
$arrayListCounter = $case->getListCounters(
$userId,
['to_do', 'draft', 'sent', 'selfservice', 'paused', 'completed', 'cancelled']
);
/*----------------------------------********---------------------------------*/
}
/*----------------------------------********---------------------------------*/
$result = $this->parserCountersCases($arrayListCounter);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
@@ -58,12 +74,23 @@ class Light extends Api
"CASES_PAUSED" => "paused",
"CASES_COMPLETED" => "completed",
"CASES_SELFSERVICE" => "unassigned",
'to_do' => 'toDo',
'draft' => 'draft',
'cancelled' => 'cancelled',
'sent' => 'participated',
'paused' => 'paused',
'completed' => 'completed',
'selfservice' => 'unassigned'
);
$response = array();
foreach ($data as $counterList) {
foreach ($data as $key => $counterList) {
if(isset($structure[$counterList['item']])){
$name = $structure[$counterList['item']];
$response[$name] = $counterList['count'];
} else {
if (isset($structure[$key])) {
$response[$structure[$key]] = $counterList;
}
}
}
return $response;
@@ -105,7 +132,6 @@ class Light extends Api
$filter = '',
$date_from = '',
$date_to = '',
$action = '',
$newestthan = '',
$oldestthan =''
) {
@@ -123,14 +149,26 @@ class Light extends Api
$dataList['filter'] = $filter;
$dataList['dateFrom'] = $date_from;
$dataList['dateTo'] = $date_to;
$dataList['action'] = $action;
$dataList['newestthan'] = $newestthan;
$dataList['oldestthan'] = $oldestthan;
Validator::throwExceptionIfDataNotMetIso8601Format($dataList, $this->arrayFieldIso8601);
$dataList = DateTime::convertDataToUtc($dataList, $this->arrayFieldIso8601);
$lists = new \ProcessMaker\BusinessModel\Lists();
$response = $lists->getList('inbox', $dataList);
/*----------------------------------********---------------------------------*/
if (true) {
//In enterprise version this block of code should always be executed
//In community version this block of code is deleted and is executed the other
$list = new \ProcessMaker\BusinessModel\Lists();
$response = $list->getList('inbox', $dataList);
} else {
/*----------------------------------********---------------------------------*/
$case = new \ProcessMaker\BusinessModel\Cases();
$response = $case->getList($dataList);
/*----------------------------------********---------------------------------*/
}
/*----------------------------------********---------------------------------*/
if ($newestthan != '') {
$response['data'] = array_reverse($response['data']);
}
@@ -209,8 +247,21 @@ class Light extends Api
Validator::throwExceptionIfDataNotMetIso8601Format($dataList, $this->arrayFieldIso8601);
$dataList = DateTime::convertDataToUtc($dataList, $this->arrayFieldIso8601);
$oCases = new \ProcessMaker\BusinessModel\Lists();
$response = $oCases->getList('inbox', $dataList);
/*----------------------------------********---------------------------------*/
if (true) {
//In enterprise version this block of code should always be executed
//In community version this block of code is deleted and is executed the other
$list = new \ProcessMaker\BusinessModel\Lists();
$response = $list->getList('inbox', $dataList);
} else {
/*----------------------------------********---------------------------------*/
$case = new \ProcessMaker\BusinessModel\Cases();
$response = $case->getList($dataList);
/*----------------------------------********---------------------------------*/
}
/*----------------------------------********---------------------------------*/
if ($newestthan != '') {
$response['data'] = array_reverse($response['data']);
}
@@ -279,6 +330,7 @@ class Light extends Api
) {
try {
$dataList['userId'] = $this->getUserId();
$dataList['action'] = 'sent';
$dataList['paged'] = $paged;
$dataList['count'] = $count;
@@ -298,8 +350,21 @@ class Light extends Api
Validator::throwExceptionIfDataNotMetIso8601Format($dataList, $this->arrayFieldIso8601);
$dataList = DateTime::convertDataToUtc($dataList, $this->arrayFieldIso8601);
$oCases = new \ProcessMaker\BusinessModel\Lists();
$response = $oCases->getList('participated_last', $dataList);
/*----------------------------------********---------------------------------*/
if (true) {
//In enterprise version this block of code should always be executed
//In community version this block of code is deleted and is executed the other
$list = new \ProcessMaker\BusinessModel\Lists();
$response = $list->getList('participated_last', $dataList);
} else {
/*----------------------------------********---------------------------------*/
$case = new \ProcessMaker\BusinessModel\Cases();
$response = $case->getList($dataList);
/*----------------------------------********---------------------------------*/
}
/*----------------------------------********---------------------------------*/
if ($newestthan != '') {
$response['data'] = array_reverse($response['data']);
}
@@ -380,8 +445,21 @@ class Light extends Api
$dataList['filter'] = $filter;
$dataList['dateFrom'] = $date_from;
$dataList['dateTo'] = $date_to;
$lists = new \ProcessMaker\BusinessModel\Lists();
$response = $lists->getList('paused', $dataList);
/*----------------------------------********---------------------------------*/
if (true) {
//In enterprise version this block of code should always be executed
//In community version this block of code is deleted and is executed the other
$list = new \ProcessMaker\BusinessModel\Lists();
$response = $list->getList('paused', $dataList);
} else {
/*----------------------------------********---------------------------------*/
$case = new \ProcessMaker\BusinessModel\Cases();
$response = $case->getList($dataList);
/*----------------------------------********---------------------------------*/
}
/*----------------------------------********---------------------------------*/
$result = $this->parserDataParticipated($response['data']);
return DateTime::convertUtcToIso8601($result, $this->arrayFieldIso8601);
} catch (\Exception $e) {
@@ -511,13 +589,27 @@ class Light extends Api
if (is_array($d)) {
$newData = array();
foreach ($d as $field => $value) {
if (array_key_exists($field, $structure)) {
$newName = $structure[$field];
if (
preg_match(
'/\|(' . $field . ')\|/i',
'|' . implode('|', array_keys($structure)) . '|',
$arrayMatch
) &&
!is_array($structure[$arrayMatch[1]])
) {
$newName = $structure[$arrayMatch[1]];
$newData[$newName] = is_null($value) ? "":$value;
} else {
foreach ($structure as $name => $str) {
if (is_array($str) && array_key_exists($field, $str)) {
$newName = $str[$field];
if (is_array($str) &&
preg_match(
'/\|(' . $field . ')\|/i',
'|' . implode('|', array_keys($str)) . '|',
$arrayMatch
) &&
!is_array($str[$arrayMatch[1]])
) {
$newName = $str[$arrayMatch[1]];
$newData[$name][$newName] = is_null($value) ? "":$value;
}
}
@@ -526,13 +618,27 @@ class Light extends Api
if (count($newData) > 0)
$response[] = $newData;
} else {
if (array_key_exists($field, $structure)) {
$newName = $structure[$field];
if (
preg_match(
'/\|(' . $field . ')\|/i',
'|' . implode('|', array_keys($structure)) . '|',
$arrayMatch
) &&
!is_array($structure[$arrayMatch[1]])
) {
$newName = $structure[$arrayMatch[1]];
$response[$newName] = is_null($d) ? "":$d;
} else {
foreach ($structure as $name => $str) {
if (is_array($str) && array_key_exists($field, $str)) {
$newName = $str[$field];
if (is_array($str) &&
preg_match(
'/\|(' . $field . ')\|/i',
'|' . implode('|', array_keys($str)) .'|',
$arrayMatch
) &&
!is_array($str[$arrayMatch[1]])
) {
$newName = $str[$arrayMatch[1]];
$response[$name][$newName] = is_null($d) ? "":$d;
}
}

View File

@@ -118,7 +118,9 @@ class TimerEvent extends Api
public function doPutTimerEvent($prj_uid, $tmrevn_uid, array $request_data)
{
try {
$arrayData = $this->timerEvent->update($tmrevn_uid, $request_data);
\ProcessMaker\BusinessModel\Validator::throwExceptionIfDataNotMetIso8601Format($request_data, $this->arrayFieldIso8601);
$arrayData = $this->timerEvent->update($tmrevn_uid, \ProcessMaker\Util\DateTime::convertDataToUtc($request_data, $this->arrayFieldIso8601));
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}

View File

@@ -65,7 +65,8 @@ class System extends Api
try {
$enabledFeatures = array();
/*----------------------------------********---------------------------------*/
$keys = array ('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=');
$keys = array ('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=',
'oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=');
foreach ($keys as $key) {
if (\PMLicensedFeatures
::getSingleton()