Merges upstream master branch manually due to conflicts in the System REST end point.
This commit is contained in:
@@ -11,6 +11,65 @@ use \DepartmentPeer;
|
||||
*/
|
||||
class Department
|
||||
{
|
||||
/**
|
||||
* Verify if exists the title of a Department
|
||||
*
|
||||
* @param string $departmentTitle Title
|
||||
* @param string $departmentUidExclude Unique id of Department to exclude
|
||||
*
|
||||
* return bool Return true if exists the title of a Department, false otherwise
|
||||
*/
|
||||
public function existsTitle($departmentTitle, $departmentUidExclude = "")
|
||||
{
|
||||
try {
|
||||
$delimiter = \DBAdapter::getStringDelimiter();
|
||||
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\DepartmentPeer::DEP_UID);
|
||||
|
||||
$criteria->addAlias("CT", \ContentPeer::TABLE_NAME);
|
||||
|
||||
$arrayCondition = array();
|
||||
$arrayCondition[] = array(\DepartmentPeer::DEP_UID, "CT.CON_ID", \Criteria::EQUAL);
|
||||
$arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "DEPO_TITLE" . $delimiter, \Criteria::EQUAL);
|
||||
$arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
|
||||
$criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
|
||||
|
||||
if ($departmentUidExclude != "") {
|
||||
$criteria->add(\DepartmentPeer::DEP_UID, $departmentUidExclude, \Criteria::NOT_EQUAL);
|
||||
}
|
||||
|
||||
$criteria->add("CT.CON_VALUE", $departmentTitle, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \DepartmentPeer::doSelectRS($criteria);
|
||||
|
||||
return ($rsCriteria->next())? true : false;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if exists the title of a Department
|
||||
*
|
||||
* @param string $departmentTitle Title
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
* @param string $departmentUidExclude Unique id of Department to exclude
|
||||
*
|
||||
* return void Throw exception if exists the title of a Department
|
||||
*/
|
||||
public function throwExceptionIfExistsTitle($departmentTitle, $fieldNameForException, $departmentUidExclude = "")
|
||||
{
|
||||
try {
|
||||
if ($this->existsTitle($departmentTitle, $departmentUidExclude)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_DEPARTMENT_TITLE_ALREADY_EXISTS", array($fieldNameForException, $departmentTitle)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list for Departments
|
||||
*
|
||||
@@ -99,25 +158,63 @@ class Department
|
||||
}
|
||||
|
||||
/**
|
||||
* Put Assign User
|
||||
* Assign User to Department
|
||||
*
|
||||
* @access public
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @param string $departmentUid Unique id of Department
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* @return void
|
||||
* return array Return data of the User assigned to Department
|
||||
*/
|
||||
public function assignUser($dep_uid, $usr_uid)
|
||||
public function assignUser($departmentUid, array $arrayData)
|
||||
{
|
||||
$dep_uid = Validator::depUid($dep_uid);
|
||||
$usr_uid = Validator::usrUid($usr_uid);
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$validator = new \ProcessMaker\BusinessModel\Validator();
|
||||
|
||||
$dep = new \Department();
|
||||
$dep->load($dep_uid);
|
||||
$dep_manager = $dep->getDepManager();
|
||||
$manager = ($dep_manager == '') ? true : false;
|
||||
$dep->addUserToDepartment( $dep_uid, $usr_uid, $manager, false );
|
||||
$dep->updateDepartmentManager( $dep_uid );
|
||||
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
|
||||
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
|
||||
|
||||
//Set data
|
||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||
|
||||
unset($arrayData["DEP_UID"]);
|
||||
|
||||
//Set variables
|
||||
$arrayUserFieldDefinition = array(
|
||||
"DEP_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "departmentUid"),
|
||||
"USR_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUid")
|
||||
);
|
||||
|
||||
$arrayUserFieldNameForException = array(
|
||||
"departmentUid" => strtolower("DEP_UID"),
|
||||
"userUid" => strtolower("USR_UID")
|
||||
);
|
||||
|
||||
//Verify data
|
||||
$departmentUid = \ProcessMaker\BusinessModel\Validator::depUid($departmentUid);
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $arrayUserFieldDefinition, $arrayUserFieldNameForException, true);
|
||||
|
||||
$process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $arrayUserFieldNameForException["userUid"]);
|
||||
|
||||
//Assign User
|
||||
$department = new \Department();
|
||||
|
||||
$department->load($departmentUid);
|
||||
|
||||
$department->addUserToDepartment($departmentUid, $arrayData["USR_UID"], ($department->getDepManager() == "")? true : false, false);
|
||||
$department->updateDepartmentManager($departmentUid);
|
||||
|
||||
//Return
|
||||
$arrayData = array_merge(array("DEP_UID" => $departmentUid), $arrayData);
|
||||
|
||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,6 +336,11 @@ class Department
|
||||
Validator::isBoolean($create, '$create');
|
||||
|
||||
$dep_data = array_change_key_case($dep_data, CASE_UPPER);
|
||||
|
||||
if ($create) {
|
||||
unset($dep_data["DEP_UID"]);
|
||||
}
|
||||
|
||||
$oDepartment = new \Department();
|
||||
if (isset($dep_data['DEP_UID']) && $dep_data['DEP_UID'] != '') {
|
||||
Validator::depUid($dep_data['DEP_UID']);
|
||||
@@ -254,18 +356,21 @@ class Department
|
||||
}
|
||||
|
||||
if (!$create) {
|
||||
$dep_data['DEPO_TITLE'] = $dep_data['DEP_TITLE'];
|
||||
if (isset($dep_data['DEP_TITLE'])) {
|
||||
Validator::depTitle($dep_data['DEP_TITLE'], $dep_data['DEP_UID']);
|
||||
if (isset($dep_data["DEP_TITLE"])) {
|
||||
$this->throwExceptionIfExistsTitle($dep_data["DEP_TITLE"], strtolower("DEP_TITLE"), $dep_data["DEP_UID"]);
|
||||
|
||||
$dep_data["DEPO_TITLE"] = $dep_data["DEP_TITLE"];
|
||||
}
|
||||
|
||||
$oDepartment->update($dep_data);
|
||||
$oDepartment->updateDepartmentManager($dep_data['DEP_UID']);
|
||||
} else {
|
||||
if (isset($dep_data['DEP_TITLE'])) {
|
||||
Validator::depTitle($dep_data['DEP_TITLE']);
|
||||
$this->throwExceptionIfExistsTitle($dep_data["DEP_TITLE"], strtolower("DEP_TITLE"));
|
||||
} else {
|
||||
throw (new \Exception(\G::LoadTranslation("ID_FIELD_REQUIRED", array('dep_title'))));
|
||||
}
|
||||
|
||||
$dep_uid = $oDepartment->create($dep_data);
|
||||
$response = $this->getDepartment($dep_uid);
|
||||
return $response;
|
||||
|
||||
@@ -604,15 +604,17 @@ class Light
|
||||
*/
|
||||
public function getInformation($userUid, $type, $app_uid)
|
||||
{
|
||||
//$response = array();
|
||||
switch ($type) {
|
||||
case 'paused':
|
||||
case 'participated':
|
||||
$oCase = new \Cases();
|
||||
$iDelIndex = $oCase->getCurrentDelegationCase( $app_uid );
|
||||
$aFields = $oCase->loadCase( $app_uid, $iDelIndex );
|
||||
$this->getInfoResume($userUid, $aFields, $type);
|
||||
$response = $this->getInfoResume($userUid, $aFields, $type);
|
||||
break;
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -662,9 +664,120 @@ class Light
|
||||
$Fields['TAS_TITLE'] = $aTask['TAS_TITLE'];
|
||||
}
|
||||
|
||||
require_once(PATH_GULLIVER .'../thirdparty/smarty/libs/Smarty.class.php');
|
||||
$G_PUBLISH = new \Publisher();
|
||||
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_Resume.xml', '', $Fields, '' );
|
||||
$G_PUBLISH->RenderContent();
|
||||
// require_once(PATH_GULLIVER .'../thirdparty/smarty/libs/Smarty.class.php');
|
||||
// $G_PUBLISH = new \Publisher();
|
||||
// $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_Resume.xml', '', $Fields, '' );
|
||||
// $G_PUBLISH->RenderContent();
|
||||
return $Fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* first step for upload file
|
||||
* create uid app_document for upload file
|
||||
*
|
||||
* @param $userUid
|
||||
* @param $Fields
|
||||
* @param $type
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function postUidUploadFiles($userUid, $app_uid, $request_data)
|
||||
{
|
||||
$response = array();
|
||||
if (count( $request_data ) > 0) {
|
||||
foreach ($request_data as $k => $file) {
|
||||
$indocUid = null;
|
||||
$fieldName = null;
|
||||
$oCase = new \Cases();
|
||||
$DEL_INDEX = $oCase->getCurrentDelegation( $app_uid, $userUid );
|
||||
|
||||
$aFields = array (
|
||||
"APP_UID" => $app_uid,
|
||||
"DEL_INDEX" => $DEL_INDEX,
|
||||
"USR_UID" => $userUid,
|
||||
"DOC_UID" => - 1,
|
||||
"APP_DOC_TYPE" => "ATTACHED",
|
||||
"APP_DOC_CREATE_DATE" => date( "Y-m-d H:i:s" ),
|
||||
"APP_DOC_COMMENT" => "",
|
||||
"APP_DOC_TITLE" => "",
|
||||
"APP_DOC_FILENAME" => $file['name'],
|
||||
"APP_DOC_FIELDNAME" => $fieldName
|
||||
);
|
||||
|
||||
$oAppDocument = new \AppDocument();
|
||||
$oAppDocument->create( $aFields );
|
||||
$response[$k]['docVersion'] = $iDocVersion = $oAppDocument->getDocVersion();
|
||||
$response[$k]['appDocUid'] = $sAppDocUid = $oAppDocument->getAppDocUid();
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* second step for upload file
|
||||
* upload file in foler app_uid
|
||||
*
|
||||
* @param $userUid
|
||||
* @param $Fields
|
||||
* @param $type
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function documentUploadFiles($userUid, $app_uid, $app_doc_uid, $request_data)
|
||||
{
|
||||
if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) {
|
||||
$arrayField = array ();
|
||||
$arrayFileName = array ();
|
||||
$arrayFileTmpName = array ();
|
||||
$arrayFileError = array ();
|
||||
$i = 0;
|
||||
|
||||
foreach ($_FILES["form"]["name"] as $fieldIndex => $fieldValue) {
|
||||
if (is_array( $fieldValue )) {
|
||||
foreach ($fieldValue as $index => $value) {
|
||||
if (is_array( $value )) {
|
||||
foreach ($value as $grdFieldIndex => $grdFieldValue) {
|
||||
$arrayField[$i]["grdName"] = $fieldIndex;
|
||||
$arrayField[$i]["grdFieldName"] = $grdFieldIndex;
|
||||
$arrayField[$i]["index"] = $index;
|
||||
|
||||
$arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex][$index][$grdFieldIndex];
|
||||
$arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex][$index][$grdFieldIndex];
|
||||
$arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex][$index][$grdFieldIndex];
|
||||
$i = $i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$arrayField[$i] = $fieldIndex;
|
||||
|
||||
$arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex];
|
||||
$arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex];
|
||||
$arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex];
|
||||
$i = $i + 1;
|
||||
}
|
||||
}
|
||||
if (count( $arrayField ) > 0) {
|
||||
for ($i = 0; $i <= count( $arrayField ) - 1; $i ++) {
|
||||
if ($arrayFileError[$i] == 0) {
|
||||
$indocUid = null;
|
||||
$fieldName = null;
|
||||
$fileSizeByField = 0;
|
||||
|
||||
$oAppDocument = new \AppDocument();
|
||||
$aAux = $oAppDocument->load($app_doc_uid);
|
||||
|
||||
$iDocVersion = $oAppDocument->getDocVersion();
|
||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||
$aInfo = pathinfo( $oAppDocument->getAppDocFilename() );
|
||||
$sExtension = ((isset( $aInfo["extension"] )) ? $aInfo["extension"] : "");
|
||||
$pathUID = G::getPathFromUID($app_uid);
|
||||
$sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP;
|
||||
$sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
|
||||
G::uploadFile( $arrayFileTmpName[$i], $sPathName, $sFileName );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
use \G;
|
||||
use \Criteria;
|
||||
use \UsersPeer;
|
||||
|
||||
/**
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
@@ -180,4 +182,45 @@ class Lists {
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get counters for lists
|
||||
*
|
||||
* @access public
|
||||
* @param array $userId, User Uid
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function getCounters($userId)
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_INBOX);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_DRAFT);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_CANCELLED);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_PARTICIPATED);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_PAUSED);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_COMPLETED);
|
||||
$criteria->add( UsersPeer::USR_UID, $userId, Criteria::EQUAL );
|
||||
$dataset = UsersPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$dataset->next();
|
||||
$aRow = $dataset->getRow();
|
||||
|
||||
$oAppCache = new \AppCacheView();
|
||||
$totalUnassigned = $oAppCache->getListCounters('selfservice', $userId, false);
|
||||
|
||||
$response = array(
|
||||
array('count' => $aRow['USR_TOTAL_INBOX'], 'item' => 'CASES_INBOX'),
|
||||
array('count' => $aRow['USR_TOTAL_DRAFT'], 'item' => 'CASES_DRAFT'),
|
||||
array('count' => $aRow['USR_TOTAL_CANCELLED'], 'item' => 'CASES_CANCELLED'),
|
||||
array('count' => $aRow['USR_TOTAL_PARTICIPATED'], 'item' => 'CASES_SENT'),
|
||||
array('count' => $aRow['USR_TOTAL_PAUSED'], 'item' => 'CASES_PAUSED'),
|
||||
array('count' => $aRow['USR_TOTAL_COMPLETED'], 'item' => 'CASES_COMPLETED'),
|
||||
array('count' => $totalUnassigned, 'item' => 'CASES_SELFSERVICE')
|
||||
);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -169,6 +169,10 @@ class Process
|
||||
public function throwExceptionIfDataNotMetFieldDefinition($arrayData, $arrayFieldDefinition, $arrayFieldNameForException, $flagValidateRequired = true)
|
||||
{
|
||||
try {
|
||||
|
||||
\G::LoadSystem('inputfilter');
|
||||
$filter = new \InputFilter();
|
||||
|
||||
if ($flagValidateRequired) {
|
||||
foreach ($arrayFieldDefinition as $key => $value) {
|
||||
$fieldName = $key;
|
||||
@@ -187,6 +191,7 @@ class Process
|
||||
foreach ($arrayData as $key => $value) {
|
||||
$fieldName = $key;
|
||||
$fieldValue = $value;
|
||||
|
||||
|
||||
if (isset($arrayFieldDefinition[$fieldName])) {
|
||||
$fieldNameAux = (isset($arrayFieldNameForException[$arrayFieldDefinition[$fieldName]["fieldNameAux"]]))? $arrayFieldNameForException[$arrayFieldDefinition[$fieldName]["fieldNameAux"]] : "";
|
||||
@@ -281,6 +286,7 @@ class Process
|
||||
}
|
||||
|
||||
if (is_string($fieldValue) && trim($fieldValue) . "" != "") {
|
||||
$fieldValue = $filter->validateInput($fieldValue);
|
||||
eval("\$arrayAux = $fieldValue;");
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ class User
|
||||
if ($form['USR_REPLACED_BY'] != '') {
|
||||
$oReplacedBy = \UsersPeer::retrieveByPK($form['USR_REPLACED_BY']);
|
||||
if (is_null($oReplacedBy)) {
|
||||
throw new \Exception('usr_replaced_by:'.$form['USR_REPLACED_BY'].' '.\G::LoadTranslation('ID_AUTHENTICATION_SOURCE_INVALID'));
|
||||
throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_EXIST", array(strtolower("USR_REPLACED_BY"), $form["USR_REPLACED_BY"])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,47 +35,6 @@ class Validator
|
||||
return $dep_uid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate dep_title
|
||||
* @var string $dep_title. Name or Title for Departament
|
||||
* @var string $dep_uid. Uid for Departament
|
||||
*
|
||||
* @access public
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @url GET
|
||||
*/
|
||||
static public function depTitle($dep_title, $dep_uid = '')
|
||||
{
|
||||
$dep_title = trim($dep_title);
|
||||
if ($dep_title == '') {
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array('dep_title',''))));
|
||||
}
|
||||
|
||||
$oCriteria = new \Criteria( 'workflow' );
|
||||
$oCriteria->clearSelectColumns();
|
||||
$oCriteria->addSelectColumn( \ContentPeer::CON_CATEGORY );
|
||||
$oCriteria->addSelectColumn( \ContentPeer::CON_VALUE );
|
||||
$oCriteria->addSelectColumn( \DepartmentPeer::DEP_PARENT );
|
||||
$oCriteria->add( \ContentPeer::CON_CATEGORY, 'DEPO_TITLE' );
|
||||
$oCriteria->addJoin( \ContentPeer::CON_ID, \DepartmentPeer::DEP_UID, \Criteria::LEFT_JOIN );
|
||||
$oCriteria->add( \ContentPeer::CON_VALUE, $dep_title );
|
||||
$oCriteria->add( \ContentPeer::CON_LANG, SYS_LANG );
|
||||
if ($dep_uid != '') {
|
||||
$oCriteria->add( \ContentPeer::CON_ID, $dep_uid, \Criteria::NOT_EQUAL );
|
||||
}
|
||||
|
||||
$oDataset = \DepartmentPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
if ($oDataset->next()) {
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array('dep_title',$dep_title))));
|
||||
}
|
||||
return $dep_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate dep_status
|
||||
* @var string $dep_uid. Uid for Departament
|
||||
|
||||
@@ -398,7 +398,7 @@ class WebEntry
|
||||
|
||||
|
||||
$fileContent .= "G::LoadClass('pmDynaform');\n";
|
||||
$fileContent .= "\$a = new pmDynaform('".$arrayWebEntryData["DYN_UID"]."', array());\n";
|
||||
$fileContent .= "\$a = new pmDynaform(array('CURRENT_DYNAFORM'=>'" . $arrayWebEntryData["DYN_UID"] . "'));\n";
|
||||
$fileContent .= "if(\$a->isResponsive()){";
|
||||
$fileContent .= "\$a->printWebEntry('".$fileName."Post.php');";
|
||||
$fileContent .= "}else {";
|
||||
|
||||
@@ -80,25 +80,21 @@ class Department extends Api
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dep_uid {@min 1}{@max 32}
|
||||
* @param string $usr_uid {@min 1}{@max 32}
|
||||
* @url POST /:dep_uid/assign-user
|
||||
*
|
||||
* @access public
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @param string $dep_uid {@min 32}{@max 32}
|
||||
* @param array $request_data
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @url PUT /:dep_uid/assign-user/:usr_uid
|
||||
* @status 201
|
||||
*/
|
||||
public function doPutAssignUser($dep_uid, $usr_uid)
|
||||
public function doPostAssignUser($dep_uid, array $request_data)
|
||||
{
|
||||
try {
|
||||
$oDepartment = new \ProcessMaker\BusinessModel\Department();
|
||||
$response = $oDepartment->assignUser($dep_uid, $usr_uid);
|
||||
return $response;
|
||||
$department = new \ProcessMaker\BusinessModel\Department();
|
||||
|
||||
$arrayData = $department->assignUser($dep_uid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -351,26 +351,27 @@ class Light extends Api
|
||||
foreach ($d as $field => $value) {
|
||||
if (array_key_exists($field, $structure)) {
|
||||
$newName = $structure[$field];
|
||||
$newData[$newName] = $value;
|
||||
$newData[$newName] = is_null($value) ? "":$value;
|
||||
} else {
|
||||
foreach ($structure as $name => $str) {
|
||||
if (is_array($str) && array_key_exists($field, $str)) {
|
||||
$newName = $str[$field];
|
||||
$newData[$name][$newName] = $value;
|
||||
$newData[$name][$newName] = is_null($value) ? "":$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$response[] = $newData;
|
||||
if (count($newData) > 0)
|
||||
$response[] = $newData;
|
||||
} else {
|
||||
if (array_key_exists($field, $structure)) {
|
||||
$newName = $structure[$field];
|
||||
$response[$newName] = $d;
|
||||
$response[$newName] = is_null($d) ? "":$d;
|
||||
} else {
|
||||
foreach ($structure as $name => $str) {
|
||||
if (is_array($str) && array_key_exists($field, $str)) {
|
||||
$newName = $str[$field];
|
||||
$response[$name][$newName] = $d;
|
||||
$response[$name][$newName] = is_null($d) ? "":$d;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -726,9 +727,77 @@ class Light extends Api
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$oMobile = new \ProcessMaker\BusinessModel\Light();
|
||||
$oMobile->getInformation($userUid, $type, $app_uid);
|
||||
$response = $oMobile->getInformation($userUid, $type, $app_uid);
|
||||
$response = $this->parserGetInformation($response);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function parserGetInformation ($data)
|
||||
{
|
||||
$structure = array(
|
||||
'case' => array(
|
||||
'PRO_TITLE' => 'processTitle',
|
||||
'APP_TITLE' => 'caseTitle',
|
||||
'APP_NUMBER' => 'caseNumber',
|
||||
'APP_STATUS' => 'caseStatus',
|
||||
'APP_UID' => 'caseId',
|
||||
'CREATOR' => 'caseCreator',
|
||||
'CREATE_DATE' => 'caseCreateDate',
|
||||
'UPDATE_DATE' => 'caseUpdateData',
|
||||
'DESCRIPTION' => 'caseDescription'
|
||||
),
|
||||
'task' => array(
|
||||
'TAS_TITLE' => 'taskTitle',
|
||||
'CURRENT_USER' => 'currentUser',
|
||||
'DEL_DELEGATE_DATE' => 'delDelegateDate',
|
||||
'DEL_INIT_DATE' => 'delInitDate',
|
||||
'DEL_TASK_DUE_DATE' => 'delDueDate',
|
||||
'DEL_FINISH_DATE' => 'delFinishDate'
|
||||
)
|
||||
);
|
||||
|
||||
$response = $this->replaceFields($data, $structure);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /case/:app_uid/upload
|
||||
*
|
||||
* @param $access
|
||||
* @param $refresh
|
||||
* @return mixed
|
||||
*/
|
||||
public function uidUploadFiles($app_uid, $request_data)
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$oMobile = new \ProcessMaker\BusinessModel\Light();
|
||||
$filesUids = $oMobile->postUidUploadFiles($userUid, $app_uid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $filesUids;
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /case/:app_uid/upload/:app_doc_uid
|
||||
*
|
||||
* @param $access
|
||||
* @param $refresh
|
||||
* @return mixed
|
||||
*/
|
||||
public function documentUploadFiles($app_uid, $app_doc_uid, $request_data)
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$oMobile = new \ProcessMaker\BusinessModel\Light();
|
||||
$filesUids = $oMobile->documentUploadFiles($userUid, $app_uid, $app_doc_uid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $filesUids;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,28 @@ class System extends Api
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get count for all lists
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /counters-lists
|
||||
*/
|
||||
public function doGetCountersLists()
|
||||
{
|
||||
try {
|
||||
$userId = $this->getUserId();
|
||||
$lists = new \ProcessMaker\BusinessModel\Lists();
|
||||
$response = $lists->getCounters($userId);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
|
||||
@@ -57,7 +57,7 @@ class Server implements iAuthenticate
|
||||
}
|
||||
|
||||
// Pass a storage object or array of storage objects to the OAuth2 server class
|
||||
$this->server = new \OAuth2\Server($this->storage, array('allow_implicit' => true));
|
||||
$this->server = new \OAuth2\Server($this->storage, array('allow_implicit' => true, 'access_lifetime' => 86400));
|
||||
|
||||
$this->server->setConfig('enforce_state', false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user