Endpoint for mobile and download status 206 (Streaming)
This commit is contained in:
143
workflow/engine/methods/cases/casesStreamingFile.php
Normal file
143
workflow/engine/methods/cases/casesStreamingFile.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/**
|
||||
* casesStreamingFile.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*/
|
||||
|
||||
/**
|
||||
* File for get Streaming file type audio and video
|
||||
* return in header code 206
|
||||
*
|
||||
* Created by Dev: Ronald Quenta
|
||||
* E-mail: ronald.otn@gmail.com
|
||||
*/
|
||||
|
||||
$actionAjax = isset( $_REQUEST['actionAjax'] ) ? $_REQUEST['actionAjax'] : null;
|
||||
|
||||
if ($actionAjax == "streaming") {
|
||||
|
||||
$app_uid = isset( $_REQUEST['a'] ) ? $_REQUEST['a'] : null;
|
||||
$inp_doc_uid = isset( $_REQUEST['d'] ) ? $_REQUEST['d'] : null;
|
||||
$oAppDocument = new \AppDocument();
|
||||
|
||||
if (! isset( $fileData['version'] )) {
|
||||
//Load last version of the document
|
||||
$docVersion = $oAppDocument->getLastAppDocVersion( $inp_doc_uid );
|
||||
} else {
|
||||
$docVersion = $fileData['version'];
|
||||
}
|
||||
|
||||
$oAppDocument->Fields = $oAppDocument->load( $inp_doc_uid, $docVersion );
|
||||
|
||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||
$iDocVersion = $oAppDocument->getDocVersion();
|
||||
$info = pathinfo( $oAppDocument->getAppDocFilename() );
|
||||
$ext = (isset($info['extension'])?$info['extension']:'');
|
||||
|
||||
//$app_uid = \G::getPathFromUID($oAppDocument->Fields['APP_UID']);
|
||||
$file = \G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid);
|
||||
|
||||
$realPath = PATH_DOCUMENT . $app_uid . '/' . $file[0] . $file[1] . '_' . $iDocVersion . '.' . $ext;
|
||||
$realPath1 = PATH_DOCUMENT . $app_uid . '/' . $file[0] . $file[1] . '.' . $ext;
|
||||
|
||||
if (file_exists( $realPath )) {
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$mimeType = finfo_file($finfo, $realPath);
|
||||
finfo_close($finfo);
|
||||
if ($ext == "mp3") {
|
||||
$mimeType = "audio/mpeg";
|
||||
}
|
||||
rangeDownload($realPath,$mimeType);
|
||||
} elseif (file_exists( $realPath1 )) {
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$mimeType = finfo_file($finfo, $realPath1);
|
||||
finfo_close($finfo);
|
||||
if ($ext == "mp3") {
|
||||
$mimeType = "audio/mpeg";
|
||||
}
|
||||
rangeDownload($realPath1,$mimeType);
|
||||
} else {
|
||||
header ("HTTP/1.0 404 Not Found");
|
||||
return;
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
function rangeDownload($location,$mimeType)
|
||||
{
|
||||
if (!file_exists($location))
|
||||
{
|
||||
header ("HTTP/1.0 404 Not Found");
|
||||
return;
|
||||
}
|
||||
//echo ($mimeType);die;
|
||||
$size = filesize($location);
|
||||
$time = date('r', filemtime($location));
|
||||
|
||||
$fm = @fopen($location, 'rb');
|
||||
if (!$fm)
|
||||
{
|
||||
header ("HTTP/1.0 505 Internal server error");
|
||||
return;
|
||||
}
|
||||
|
||||
$begin = 0;
|
||||
$end = $size - 1;
|
||||
|
||||
if (isset($_SERVER['HTTP_RANGE']))
|
||||
{
|
||||
if (preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches))
|
||||
{
|
||||
$begin = intval($matches[1]);
|
||||
if (!empty($matches[2]))
|
||||
{
|
||||
$end = intval($matches[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header('HTTP/1.0 206 Partial Content');
|
||||
header("Content-Type: $mimeType");
|
||||
header('Cache-Control: public, must-revalidate, max-age=0');
|
||||
header('Pragma: no-cache');
|
||||
header('Accept-Ranges: bytes');
|
||||
header('Content-Length:' . (($end - $begin) + 1));
|
||||
if (isset($_SERVER['HTTP_RANGE']))
|
||||
{
|
||||
header("Content-Range: bytes $begin-$end/$size");
|
||||
}
|
||||
header("Content-Disposition: inline; filename=$location");
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header("Last-Modified: $time");
|
||||
|
||||
$cur = $begin;
|
||||
fseek($fm, $begin, 0);
|
||||
|
||||
while(!feof($fm) && $cur <= $end && (connection_status() == 0))
|
||||
{
|
||||
set_time_limit(0);
|
||||
print fread($fm, min(1024 * 16, ($end - $cur) + 1));
|
||||
$cur += 1024 * 16;
|
||||
flush();
|
||||
}
|
||||
}
|
||||
602
workflow/engine/src/ProcessMaker/BusinessModel/Light.php
Normal file
602
workflow/engine/src/ProcessMaker/BusinessModel/Light.php
Normal file
@@ -0,0 +1,602 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class for part mobile
|
||||
*
|
||||
* Created by Dev: Ronald Quenta
|
||||
* E-mail: ronald.otn@gmail.com
|
||||
*/
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use G;
|
||||
use Criteria;
|
||||
use UsersPeer;
|
||||
use AppDelegationPeer;
|
||||
use AppDelayPeer;
|
||||
|
||||
class Light
|
||||
{
|
||||
|
||||
/**
|
||||
* Method get list start case
|
||||
*
|
||||
* @param $userId User id
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getProcessListStartCase($userId)
|
||||
{
|
||||
$response = null;
|
||||
try {
|
||||
$oProcess = new \Process();
|
||||
$oCase = new \Cases();
|
||||
|
||||
//Get ProcessStatistics Info
|
||||
$start = 0;
|
||||
$limit = '';
|
||||
$proData = $oProcess->getAllProcesses( $start, $limit, null, null, false, true );
|
||||
|
||||
$processListInitial = $oCase->getStartCasesPerType( $userId, 'category' );
|
||||
|
||||
$processList = array ();
|
||||
foreach ($processListInitial as $key => $procInfo) {
|
||||
if (isset( $procInfo['pro_uid'] )) {
|
||||
if (trim( $procInfo['cat'] ) == "") {
|
||||
$procInfo['cat'] = "_OTHER_";
|
||||
}
|
||||
$processList[$procInfo['catname']][$procInfo['value']] = $procInfo;
|
||||
}
|
||||
}
|
||||
|
||||
ksort( $processList );
|
||||
foreach ($processList as $key => $processInfo) {
|
||||
ksort( $processList[$key] );
|
||||
}
|
||||
|
||||
foreach ($proData as $key => $proInfo) {
|
||||
$proData[$proInfo['PRO_UID']] = $proInfo;
|
||||
}
|
||||
|
||||
$task = new \ProcessMaker\BusinessModel\Task();
|
||||
$task->setFormatFieldNameInUppercase(false);
|
||||
$task->setArrayParamException(array("taskUid" => "act_uid", "stepUid" => "step_uid"));
|
||||
|
||||
foreach ($processList as $key => $processInfo) {
|
||||
$tempTreeChildren = array ();
|
||||
foreach ($processList[$key] as $keyChild => $processInfoChild) {
|
||||
$tempTreeChild['text'] = htmlentities($keyChild, ENT_QUOTES, 'UTF-8'); //ellipsis ( $keyChild, 50 );
|
||||
$tempTreeChild['processId'] = $processInfoChild['pro_uid'];
|
||||
$tempTreeChild['taskId'] = $processInfoChild['uid'];
|
||||
$forms = $task->getSteps($processInfoChild['uid']);
|
||||
$newForm = array();
|
||||
$c = 0;
|
||||
foreach ($forms as $k => $form) {
|
||||
if ($form['step_type_obj'] == "DYNAFORM") {
|
||||
$newForm[$c]['formId'] = $form['step_uid_obj'];
|
||||
$newForm[$c]['index'] = $c+1;
|
||||
$newForm[$c]['title'] = $form['obj_title'];
|
||||
$newForm[$c]['description'] = $form['obj_description'];
|
||||
$c++;
|
||||
}
|
||||
}
|
||||
$tempTreeChild['forms'] = $newForm;
|
||||
if (isset( $proData[$processInfoChild['pro_uid']] )) {
|
||||
$tempTreeChildren[] = $tempTreeChild;
|
||||
}
|
||||
}
|
||||
$response = $tempTreeChildren;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get counters each type of list
|
||||
* @param $userId
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getCounterCase($userId)
|
||||
{
|
||||
try {
|
||||
$userUid = (isset( $userId ) && $userId != '') ? $userId : null;
|
||||
$oAppCache = new \AppCacheView();
|
||||
|
||||
$aTypes = Array ();
|
||||
$aTypes['to_do'] = 'toDo';
|
||||
$aTypes['draft'] = 'draft';
|
||||
$aTypes['cancelled'] = 'cancelled';
|
||||
$aTypes['sent'] = 'participated';
|
||||
$aTypes['paused'] = 'paused';
|
||||
$aTypes['completed'] = 'completed';
|
||||
$aTypes['selfservice'] = 'unassigned';
|
||||
|
||||
$aCount = $oAppCache->getAllCounters( array_keys( $aTypes ), $userUid );
|
||||
|
||||
$response = Array ();
|
||||
foreach ($aCount as $type => $count) {
|
||||
$response[$aTypes[$type]] = $count;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $sAppUid
|
||||
* @return Criteria
|
||||
*/
|
||||
public function getTransferHistoryCriteria($sAppUid)
|
||||
{
|
||||
$c = new Criteria('workflow');
|
||||
$c->addAsColumn('TAS_TITLE', 'TAS_TITLE.CON_VALUE');
|
||||
$c->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
||||
$c->addSelectColumn(UsersPeer::USR_LASTNAME);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
||||
$c->addSelectColumn(AppDelegationPeer::PRO_UID);
|
||||
$c->addSelectColumn(AppDelegationPeer::TAS_UID);
|
||||
$c->addSelectColumn(AppDelegationPeer::APP_UID);
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||
///-- $c->addAsColumn('USR_NAME', "CONCAT(USR_LASTNAME, ' ', USR_FIRSTNAME)");
|
||||
$sDataBase = 'database_' . strtolower(DB_ADAPTER);
|
||||
if (G::LoadSystemExist($sDataBase)) {
|
||||
G::LoadSystem($sDataBase);
|
||||
$oDataBase = new \database();
|
||||
$c->addAsColumn('USR_NAME', $oDataBase->concatString("USR_LASTNAME", "' '", "USR_FIRSTNAME"));
|
||||
$c->addAsColumn(
|
||||
'DEL_FINISH_DATE', $oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'-'", AppDelegationPeer::DEL_FINISH_DATE)
|
||||
);
|
||||
$c->addAsColumn(
|
||||
'APP_TYPE', $oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'IN_PROGRESS'", AppDelayPeer::APP_TYPE)
|
||||
);
|
||||
}
|
||||
$c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
|
||||
$c->addSelectColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE);
|
||||
$c->addSelectColumn(AppDelayPeer::APP_DISABLE_ACTION_DATE);
|
||||
//APP_DELEGATION LEFT JOIN USERS
|
||||
$c->addJoin(AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
|
||||
|
||||
//APP_DELAY FOR MORE DESCRIPTION
|
||||
//$c->addJoin(AppDelegationPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX, Criteria::LEFT_JOIN);
|
||||
//$c->addJoin(AppDelegationPeer::APP_UID, AppDelayPeer::APP_UID, Criteria::LEFT_JOIN);
|
||||
$del = \DBAdapter::getStringDelimiter();
|
||||
$app = array();
|
||||
$app[] = array(AppDelegationPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX);
|
||||
$app[] = array(AppDelegationPeer::APP_UID, AppDelayPeer::APP_UID);
|
||||
$c->addJoinMC($app, Criteria::LEFT_JOIN);
|
||||
|
||||
//LEFT JOIN CONTENT TAS_TITLE
|
||||
$c->addAlias("TAS_TITLE", 'CONTENT');
|
||||
$del = \DBAdapter::getStringDelimiter();
|
||||
$appTitleConds = array();
|
||||
$appTitleConds[] = array(AppDelegationPeer::TAS_UID, 'TAS_TITLE.CON_ID');
|
||||
$appTitleConds[] = array('TAS_TITLE.CON_CATEGORY', $del . 'TAS_TITLE' . $del);
|
||||
$appTitleConds[] = array('TAS_TITLE.CON_LANG', $del . SYS_LANG . $del);
|
||||
$c->addJoinMC($appTitleConds, Criteria::LEFT_JOIN);
|
||||
|
||||
//WHERE
|
||||
$c->add(AppDelegationPeer::APP_UID, $sAppUid);
|
||||
|
||||
//ORDER BY
|
||||
$c->clearOrderByColumns();
|
||||
$c->addAscendingOrderByColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* GET history of case
|
||||
*
|
||||
* @param $app_uid
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getCasesListHistory($app_uid)
|
||||
{
|
||||
G::LoadClass( 'case' );
|
||||
G::LoadClass( "BasePeer" );
|
||||
|
||||
//global $G_PUBLISH;
|
||||
$c = $this->getTransferHistoryCriteria( $app_uid );
|
||||
|
||||
//$result = new \stdClass();
|
||||
$aProcesses = Array ();
|
||||
|
||||
$rs = \GulliverBasePeer::doSelectRs( $c );
|
||||
$rs->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next();
|
||||
for ($j = 0; $j < $rs->getRecordCount(); $j ++) {
|
||||
$result = $rs->getRow();
|
||||
$result["ID_HISTORY"] = $result["PRO_UID"] . '_' . $result["APP_UID"] . '_' . $result["TAS_UID"];
|
||||
$aProcesses[] = $result;
|
||||
$rs->next();
|
||||
$processUid = $result["PRO_UID"];
|
||||
}
|
||||
|
||||
$process = new \Process();
|
||||
|
||||
$arrayProcessData = $process->load($processUid);
|
||||
|
||||
//$newDir = '/tmp/test/directory';
|
||||
//G::verifyPath( $newDir );
|
||||
|
||||
$result = array();
|
||||
$result["processName"] = $arrayProcessData["PRO_TITLE"];
|
||||
//$result["PRO_DESCRIPTION"] = $arrayProcessData["PRO_DESCRIPTION"];
|
||||
$result['flow'] = $aProcesses;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* starting one case
|
||||
*
|
||||
* @param string $userId
|
||||
* @param string $proUid
|
||||
* @param string $taskUid
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function startCase($userId = '', $proUid = '', $taskUid = '')
|
||||
{
|
||||
try {
|
||||
$oCase = new \Cases();
|
||||
|
||||
$this->lookinginforContentProcess( $proUid );
|
||||
|
||||
$aData = $oCase->startCase( $taskUid, $userId );
|
||||
|
||||
$response = array();
|
||||
$response['caseId'] = $aData['APPLICATION'];
|
||||
$response['caseIndex'] = $aData['INDEX'];
|
||||
$response['caseNumber'] = $aData['CASE_NUMBER'];
|
||||
|
||||
} catch (Exception $e) {
|
||||
$response['status'] = 'failure';
|
||||
$response['message'] = $e->getMessage();
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function lookinginforContentProcess ($sproUid)
|
||||
{
|
||||
$oContent = new \Content();
|
||||
///we are looking for a pro title for this process $sproUid
|
||||
$oCriteria = new \Criteria( 'workflow' );
|
||||
$oCriteria->add( \ContentPeer::CON_CATEGORY, 'PRO_TITLE' );
|
||||
$oCriteria->add( \ContentPeer::CON_LANG, 'en' );
|
||||
$oCriteria->add( \ContentPeer::CON_ID, $sproUid );
|
||||
$oDataset = \ContentPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
if (! is_array( $aRow )) {
|
||||
|
||||
$oC = new \Criteria( 'workflow' );
|
||||
$oC->addSelectColumn( \TaskPeer::TAS_UID );
|
||||
$oC->add( \TaskPeer::PRO_UID, $sproUid );
|
||||
$oDataset1 = \TaskPeer::doSelectRS( $oC );
|
||||
$oDataset1->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
while ($oDataset1->next()) {
|
||||
$aRow1 = $oDataset1->getRow();
|
||||
|
||||
$oCriteria1 = new \Criteria( 'workflow' );
|
||||
$oCriteria1->add( ContentPeer::CON_CATEGORY, 'TAS_TITLE' );
|
||||
$oCriteria1->add( ContentPeer::CON_LANG, SYS_LANG );
|
||||
$oCriteria1->add( ContentPeer::CON_ID, $aRow1['TAS_UID'] );
|
||||
$oDataset2 = ContentPeer::doSelectRS( $oCriteria1 );
|
||||
$oDataset2->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset2->next();
|
||||
$aRow2 = $oDataset2->getRow();
|
||||
|
||||
Content::insertContent( 'TAS_TITLE', '', $aRow2['CON_ID'], 'en', $aRow2['CON_VALUE'] );
|
||||
}
|
||||
$oC2 = new Criteria( 'workflow' );
|
||||
$oC2->add( ContentPeer::CON_CATEGORY, 'PRO_TITLE' );
|
||||
$oC2->add( ContentPeer::CON_LANG, SYS_LANG );
|
||||
$oC2->add( ContentPeer::CON_ID, $sproUid );
|
||||
$oDataset3 = ContentPeer::doSelectRS( $oC2 );
|
||||
$oDataset3->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset3->next();
|
||||
$aRow3 = $oDataset3->getRow();
|
||||
|
||||
Content::insertContent( 'PRO_TITLE', '', $aRow3['CON_ID'], 'en', $aRow3['CON_VALUE'] );
|
||||
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Route Case
|
||||
*
|
||||
* @param string $applicationUid Unique id of Case
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $delIndex
|
||||
* @param string $bExecuteTriggersBeforeAssignment
|
||||
*
|
||||
* return array Return an array with Task Case
|
||||
*/
|
||||
public function updateRouteCase($applicationUid, $userUid, $delIndex)
|
||||
{
|
||||
try {
|
||||
if (!$delIndex) {
|
||||
$delIndex = \AppDelegation::getCurrentIndex($applicationUid);
|
||||
}
|
||||
\G::LoadClass('wsBase');
|
||||
$ws = new \wsBase();
|
||||
$fields = $ws->derivateCase($userUid, $applicationUid, $delIndex, $bExecuteTriggersBeforeAssignment = false);
|
||||
$array = json_decode(json_encode($fields), true);
|
||||
if ($array ["status_code"] != 0) {
|
||||
throw (new \Exception($array ["message"]));
|
||||
} else {
|
||||
unset($array['status_code']);
|
||||
unset($array['message']);
|
||||
unset($array['timestamp']);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user Data
|
||||
*
|
||||
* @param string $applicationUid Unique id of Case
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $delIndex
|
||||
* @param string $bExecuteTriggersBeforeAssignment
|
||||
*
|
||||
* return array Return an array with Task Case
|
||||
*/
|
||||
public function getUserData($userUid)
|
||||
{
|
||||
try {
|
||||
$direction = PATH_IMAGES_ENVIRONMENT_USERS . $userUid . ".gif";
|
||||
if (! file_exists( $direction )) {
|
||||
$direction = PATH_HOME . 'public_html/images/user.gif';
|
||||
}
|
||||
$gestor = fopen($direction, "r");
|
||||
$contenido = fread($gestor, filesize($direction));
|
||||
fclose($gestor);
|
||||
$oUser = new \Users();
|
||||
$aUserLog = $oUser->loadDetailed($userUid);
|
||||
$response['userId'] = $aUserLog['USR_UID'];
|
||||
$response['firstName'] = $aUserLog['USR_FIRSTNAME'];
|
||||
$response['lastName'] = $aUserLog['USR_LASTNAME'];
|
||||
$response['fullName'] = $aUserLog['USR_FIRSTNAME'].' '.$aUserLog['USR_LASTNAME'];
|
||||
$response['email'] = $aUserLog['USR_EMAIL'];
|
||||
$response['userRole'] = $aUserLog['USR_ROLE_NAME'];
|
||||
$response['userPhone'] = $aUserLog['USR_PHONE'];
|
||||
$response['updateDate'] = $aUserLog['USR_UPDATE_DATE'];
|
||||
$response['userPhoto'] = base64_encode($contenido);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download files and resize dimensions in file type image
|
||||
* if not type image return content file
|
||||
*
|
||||
* return array Return an array with Task Case
|
||||
*/
|
||||
public function downloadFile($app_uid, $request_data)
|
||||
{
|
||||
try {
|
||||
$oAppDocument = new \AppDocument();
|
||||
$arrayFiles = array();
|
||||
foreach ($request_data as $key => $fileData) {
|
||||
if (! isset( $fileData['version'] )) {
|
||||
//Load last version of the document
|
||||
$docVersion = $oAppDocument->getLastAppDocVersion( $fileData['fileId'] );
|
||||
} else {
|
||||
$docVersion = $fileData['version'];
|
||||
}
|
||||
$oAppDocument->Fields = $oAppDocument->load( $fileData['fileId'], $docVersion );
|
||||
|
||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||
$iDocVersion = $oAppDocument->getDocVersion();
|
||||
$info = pathinfo( $oAppDocument->getAppDocFilename() );
|
||||
$ext = (isset($info['extension'])?$info['extension']:'');//BUG fix: must handle files without any extension
|
||||
|
||||
//$app_uid = \G::getPathFromUID($oAppDocument->Fields['APP_UID']);
|
||||
$file = \G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid);
|
||||
|
||||
$realPath = PATH_DOCUMENT . $app_uid . '/' . $file[0] . $file[1] . '_' . $iDocVersion . '.' . $ext;
|
||||
$realPath1 = PATH_DOCUMENT . $app_uid . '/' . $file[0] . $file[1] . '.' . $ext;
|
||||
|
||||
$width = isset($fileData['width']) ? $fileData['width']:null;
|
||||
$height = isset($fileData['height']) ? $fileData['height']:null;
|
||||
if (file_exists( $realPath )) {
|
||||
switch($ext){
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
case 'gif':
|
||||
case 'png':
|
||||
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
|
||||
$arrayFiles[$key]['fileContent'] = base64_encode($this->imagesThumbnails($realPath, $ext, $width, $height));
|
||||
break;
|
||||
default:
|
||||
$fileTmp = fopen($realPath, "r");
|
||||
$content = fread($fileTmp, filesize($realPath));
|
||||
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
|
||||
$arrayFiles[$key]['fileContent'] = base64_encode($content);
|
||||
fclose($fileTmp);
|
||||
break;
|
||||
}
|
||||
} elseif (file_exists( $realPath1 )) {
|
||||
switch($ext){
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
case 'gif':
|
||||
case 'png':
|
||||
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
|
||||
$arrayFiles[$key]['fileContent'] = $this->imagesThumbnails($realPath1, $ext, $width, $height);
|
||||
break;
|
||||
default:
|
||||
$fileTmp = fopen($realPath, "r");
|
||||
$content = fread($fileTmp, filesize($realPath));
|
||||
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
|
||||
$arrayFiles[$key]['fileContent'] = base64_encode($content);
|
||||
fclose($fileTmp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
return $arrayFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* resize image if send width or height
|
||||
*
|
||||
* @param $path
|
||||
* @param $extensions
|
||||
* @param null $newWidth
|
||||
* @param null $newHeight
|
||||
* @return string
|
||||
*/
|
||||
public function imagesThumbnails($path, $extensions, $newWidth = null, $newHeight = null)
|
||||
{
|
||||
switch($extensions){
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
$imgTmp = imagecreatefromjpeg($path);
|
||||
break;
|
||||
case 'gif':
|
||||
$imgTmp = imagecreatefromgif($path);
|
||||
break;
|
||||
case 'png':
|
||||
$imgTmp = imagecreatefrompng($path);
|
||||
break;
|
||||
}
|
||||
|
||||
$width = imagesx($imgTmp);
|
||||
$height = imagesy($imgTmp);
|
||||
|
||||
$ratio = $width / $height;
|
||||
|
||||
$isThumbnails = false;
|
||||
if (isset($newWidth) && !isset($newHeight)) {
|
||||
$newwidth = $newWidth;
|
||||
$newheight = round($newwidth / $ratio);
|
||||
$isThumbnails = true;
|
||||
} elseif (!isset($newWidth) && isset($newHeight)) {
|
||||
$newheight = $newHeight;
|
||||
$newwidth = round($newheight / $ratio);
|
||||
$isThumbnails = true;
|
||||
} elseif (isset($newWidth) && isset($newHeight)) {
|
||||
$newwidth = $newWidth;
|
||||
$newheight = $newHeight;
|
||||
$isThumbnails = true;
|
||||
}
|
||||
|
||||
$thumb = $imgTmp;
|
||||
if ($isThumbnails) {
|
||||
$thumb = imagecreatetruecolor($newwidth, $newheight);
|
||||
imagecopyresampled($thumb, $imgTmp, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
|
||||
}
|
||||
ob_start();
|
||||
switch($extensions){
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
imagejpeg($thumb);
|
||||
break;
|
||||
case 'gif':
|
||||
imagegif($thumb);
|
||||
break;
|
||||
case 'png':
|
||||
imagepng($thumb);
|
||||
break;
|
||||
}
|
||||
$image = ob_get_clean();
|
||||
imagedestroy($thumb);
|
||||
return $image;
|
||||
}
|
||||
|
||||
public function logout($oauthAccessTokenId, $refresh)
|
||||
{
|
||||
$aFields = array();
|
||||
|
||||
if (!isset($_GET['u'])) {
|
||||
$aFields['URL'] = '';
|
||||
} else {
|
||||
$aFields['URL'] = htmlspecialchars(addslashes(stripslashes(strip_tags(trim(urldecode($_GET['u']))))));
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['G_MESSAGE'])) {
|
||||
$_SESSION['G_MESSAGE'] = '';
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['G_MESSAGE_TYPE'])) {
|
||||
$_SESSION['G_MESSAGE_TYPE'] = '';
|
||||
}
|
||||
|
||||
$msg = $_SESSION['G_MESSAGE'];
|
||||
$msgType = $_SESSION['G_MESSAGE_TYPE'];
|
||||
|
||||
if (!isset($_SESSION['FAILED_LOGINS'])) {
|
||||
$_SESSION['FAILED_LOGINS'] = 0;
|
||||
$_SESSION["USERNAME_PREVIOUS1"] = "";
|
||||
$_SESSION["USERNAME_PREVIOUS2"] = "";
|
||||
}
|
||||
|
||||
$sFailedLogins = $_SESSION['FAILED_LOGINS'];
|
||||
$usernamePrevious1 = $_SESSION["USERNAME_PREVIOUS1"];
|
||||
$usernamePrevious2 = $_SESSION["USERNAME_PREVIOUS2"];
|
||||
|
||||
$aFields['LOGIN_VERIFY_MSG'] = G::loadTranslation('LOGIN_VERIFY_MSG');
|
||||
|
||||
//start new session
|
||||
@session_destroy();
|
||||
session_start();
|
||||
session_regenerate_id();
|
||||
|
||||
setcookie("workspaceSkin", SYS_SKIN, time() + 24*60*60, "/sys".SYS_SYS);
|
||||
|
||||
if (strlen($msg) > 0) {
|
||||
$_SESSION['G_MESSAGE'] = $msg;
|
||||
}
|
||||
if (strlen($msgType) > 0) {
|
||||
$_SESSION['G_MESSAGE_TYPE'] = $msgType;
|
||||
}
|
||||
|
||||
$_SESSION['FAILED_LOGINS'] = $sFailedLogins;
|
||||
$_SESSION["USERNAME_PREVIOUS1"] = $usernamePrevious1;
|
||||
$_SESSION["USERNAME_PREVIOUS2"] = $usernamePrevious2;
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if (!class_exists('pmLicenseManager')) {
|
||||
G::LoadClass('pmLicenseManager');
|
||||
}
|
||||
$licenseManager =& \pmLicenseManager::getSingleton();
|
||||
if (in_array(md5($licenseManager->result), array('38afd7ae34bd5e3e6fc170d8b09178a3', 'ba2b45bdc11e2a4a6e86aab2ac693cbb'))) {
|
||||
$G_PUBLISH = new \Publisher();
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/licenseExpired', '', array(), 'licenseUpdate');
|
||||
G::RenderPage('publish');
|
||||
die();
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
try {
|
||||
$oatoken = new \OauthAccessTokens();
|
||||
$result = $oatoken->remove($oauthAccessTokenId);
|
||||
|
||||
$response["status"] = "OK";
|
||||
} catch (Exception $e) {
|
||||
$response["status"] = "ERROR";
|
||||
$response["message"] = $e->getMessage();
|
||||
}
|
||||
return $response;
|
||||
|
||||
}
|
||||
}
|
||||
723
workflow/engine/src/ProcessMaker/Services/Api/Light.php
Normal file
723
workflow/engine/src/ProcessMaker/Services/Api/Light.php
Normal file
@@ -0,0 +1,723 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class for part mobile
|
||||
*
|
||||
* Created by Dev: Ronald Quenta
|
||||
* E-mail: ronald.otn@gmail.com
|
||||
*/
|
||||
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use \G;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Process Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class Light extends Api
|
||||
{
|
||||
/**
|
||||
* Get list counters
|
||||
* @return array
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /counters
|
||||
*/
|
||||
public function countersCases ()
|
||||
{
|
||||
try {
|
||||
$oMobile = new \ProcessMaker\BusinessModel\Light();
|
||||
$counterCase = $oMobile->getCounterCase($this->getUserId());
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $counterCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list process start
|
||||
* @return array
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /start-case
|
||||
*/
|
||||
public function getProcessListStartCase ()
|
||||
{
|
||||
try {
|
||||
$oMobile = new \ProcessMaker\BusinessModel\Light();
|
||||
$startCase = $oMobile->getProcessListStartCase($this->getUserId());
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $startCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list Case To Do
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /todo
|
||||
*/
|
||||
public function doGetCasesListToDo(
|
||||
$start = 0,
|
||||
$limit = 10,
|
||||
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
|
||||
$dir = 'DESC',
|
||||
$cat_uid = '',
|
||||
$pro_uid = '',
|
||||
$search = ''
|
||||
) {
|
||||
try {
|
||||
$dataList['userId'] = $this->getUserId();
|
||||
$dataList['action'] = 'todo';
|
||||
$dataList['paged'] = true;
|
||||
$dataList['start'] = $start;
|
||||
$dataList['limit'] = $limit;
|
||||
$dataList['sort'] = $sort;
|
||||
$dataList['dir'] = $dir;
|
||||
$dataList['category'] = $cat_uid;
|
||||
$dataList['process'] = $pro_uid;
|
||||
$dataList['search'] = $search;
|
||||
|
||||
$oCases = new \ProcessMaker\BusinessModel\Cases();
|
||||
$response = $oCases->getList($dataList);
|
||||
$result = $this->parserDataTodo($response['data']);
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
public function parserDataTodo ($data)
|
||||
{
|
||||
$structure = array(
|
||||
//'app_uid' => 'mongoId',
|
||||
'app_uid' => 'caseId',
|
||||
'app_title' => 'caseTitle',
|
||||
'app_number' => 'caseNumber',
|
||||
'app_update_date' => 'date',
|
||||
'del_task_due_date' => 'dueDate',
|
||||
//'' => 'status'
|
||||
'user' => array(
|
||||
'usrcr_usr_uid' => 'userId',
|
||||
'usrcr_usr_firstname' => 'firstName',
|
||||
'usrcr_usr_lastname' => 'lastName',
|
||||
'usrcr_usr_username' => 'fullName',
|
||||
),
|
||||
'prevUser' => array(
|
||||
'previous_usr_uid' => 'userId',
|
||||
'previous_usr_firstname' => 'firstName',
|
||||
'previous_usr_lastname' => 'lastName',
|
||||
'previous_usr_username' => 'fullName',
|
||||
),
|
||||
'process' => array(
|
||||
'pro_uid' => 'processId',
|
||||
'app_pro_title' => 'name'
|
||||
),
|
||||
'task' => array(
|
||||
'tas_uid' => 'taskId',
|
||||
'app_tas_title' => 'name'
|
||||
),
|
||||
'inp_doc_uid' => 'documentUid' //Esta opcion es temporal
|
||||
);
|
||||
|
||||
$response = $this->replaceFields($data, $structure);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list Cases Participated
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /participated
|
||||
*/
|
||||
public function doGetCasesListParticipated(
|
||||
$start = 0,
|
||||
$limit = 10,
|
||||
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
|
||||
$dir = 'DESC',
|
||||
$cat_uid = '',
|
||||
$pro_uid = '',
|
||||
$search = ''
|
||||
) {
|
||||
try {
|
||||
$dataList['userId'] = $this->getUserId();
|
||||
$dataList['action'] = 'sent';
|
||||
$dataList['paged'] = true;
|
||||
$dataList['start'] = $start;
|
||||
$dataList['limit'] = $limit;
|
||||
$dataList['sort'] = $sort;
|
||||
$dataList['dir'] = $dir;
|
||||
$dataList['category'] = $cat_uid;
|
||||
$dataList['process'] = $pro_uid;
|
||||
$dataList['search'] = $search;
|
||||
$oCases = new \ProcessMaker\BusinessModel\Cases();
|
||||
$response = $oCases->getList($dataList);
|
||||
$result = $this->parserDataParticipated($response['data']);
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
public function parserDataParticipated ($data)
|
||||
{
|
||||
$structure = array(
|
||||
//'app_uid' => 'mongoId',
|
||||
'app_uid' => 'caseId',
|
||||
'app_title' => 'caseTitle',
|
||||
'app_number' => 'caseNumber',
|
||||
'app_update_date' => 'date',
|
||||
'del_task_due_date' => 'dueDate',
|
||||
'currentUser' => array(
|
||||
'usrcr_usr_uid' => 'userId',
|
||||
'usrcr_usr_firstname' => 'firstName',
|
||||
'usrcr_usr_lastname' => 'lastName',
|
||||
'usrcr_usr_username' => 'fullName',
|
||||
),
|
||||
'prevUser' => array(
|
||||
'previous_usr_uid' => 'userId',
|
||||
'previous_usr_firstname' => 'firstName',
|
||||
'previous_usr_lastname' => 'lastName',
|
||||
'previous_usr_username' => 'fullName',
|
||||
),
|
||||
'process' => array(
|
||||
'pro_uid' => 'processId',
|
||||
'app_pro_title' => 'name'
|
||||
),
|
||||
'task' => array(
|
||||
'tas_uid' => 'taskId',
|
||||
'app_tas_title' => 'name'
|
||||
)
|
||||
);
|
||||
|
||||
$response = $this->replaceFields($data, $structure);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list Cases Paused
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /paused
|
||||
*/
|
||||
public function doGetCasesListPaused(
|
||||
$start = 0,
|
||||
$limit = 10,
|
||||
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
|
||||
$dir = 'DESC',
|
||||
$cat_uid = '',
|
||||
$pro_uid = '',
|
||||
$search = ''
|
||||
) {
|
||||
try {
|
||||
$dataList['userId'] = $this->getUserId();
|
||||
$dataList['action'] = 'paused';
|
||||
$dataList['paged'] = true;
|
||||
|
||||
$dataList['start'] = $start;
|
||||
$dataList['limit'] = $limit;
|
||||
$dataList['sort'] = $sort;
|
||||
$dataList['dir'] = $dir;
|
||||
$dataList['category'] = $cat_uid;
|
||||
$dataList['process'] = $pro_uid;
|
||||
$dataList['search'] = $search;
|
||||
$oCases = new \ProcessMaker\BusinessModel\Cases();
|
||||
$response = $oCases->getList($dataList);
|
||||
$result = $this->parserDataParticipated($response['data']);
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
public function parserDataPaused ($data)
|
||||
{
|
||||
$structure = array(
|
||||
//'app_uid' => 'mongoId',
|
||||
'app_uid' => 'caseId',
|
||||
'app_title' => 'caseTitle',
|
||||
'app_number' => 'caseNumber',
|
||||
'app_update_date' => 'date',
|
||||
'del_task_due_date' => 'dueDate',
|
||||
'currentUser' => array(
|
||||
'usrcr_usr_uid' => 'userId',
|
||||
'usrcr_usr_firstname' => 'firstName',
|
||||
'usrcr_usr_lastname' => 'lastName',
|
||||
'usrcr_usr_username' => 'fullName',
|
||||
),
|
||||
'prevUser' => array(
|
||||
'previous_usr_uid' => 'userId',
|
||||
'previous_usr_firstname' => 'firstName',
|
||||
'previous_usr_lastname' => 'lastName',
|
||||
'previous_usr_username' => 'fullName',
|
||||
),
|
||||
'process' => array(
|
||||
'pro_uid' => 'processId',
|
||||
'app_pro_title' => 'name'
|
||||
),
|
||||
'task' => array(
|
||||
'tas_uid' => 'taskId',
|
||||
'app_tas_title' => 'name'
|
||||
)
|
||||
);
|
||||
|
||||
$response = $this->replaceFields($data, $structure);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list Cases Unassigned
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /unassigned
|
||||
*/
|
||||
public function doGetCasesListUnassigned(
|
||||
$start = 0,
|
||||
$limit = 0,
|
||||
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
|
||||
$dir = 'DESC',
|
||||
$cat_uid = '',
|
||||
$pro_uid = '',
|
||||
$search = ''
|
||||
) {
|
||||
try {
|
||||
$dataList['userId'] = $this->getUserId();
|
||||
$dataList['action'] = 'unassigned';
|
||||
$dataList['paged'] = false;
|
||||
|
||||
$dataList['start'] = $start;
|
||||
$dataList['limit'] = $limit;
|
||||
$dataList['sort'] = $sort;
|
||||
$dataList['dir'] = $dir;
|
||||
$dataList['category'] = $cat_uid;
|
||||
$dataList['process'] = $pro_uid;
|
||||
$dataList['search'] = $search;
|
||||
$oCases = new \ProcessMaker\BusinessModel\Cases();
|
||||
$response = $oCases->getList($dataList);
|
||||
$result = $this->parserDataUnassigned($response);
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
public function parserDataUnassigned ($data)
|
||||
{
|
||||
$structure = array(
|
||||
//'app_uid' => 'mongoId',
|
||||
'app_uid' => 'caseId',
|
||||
'app_title' => 'caseTitle',
|
||||
'app_number' => 'caseNumber',
|
||||
'app_update_date' => 'date',
|
||||
'del_task_due_date' => 'dueDate',
|
||||
'currentUser' => array(
|
||||
'usrcr_usr_uid' => 'userId',
|
||||
'usrcr_usr_firstname' => 'firstName',
|
||||
'usrcr_usr_lastname' => 'lastName',
|
||||
'usrcr_usr_username' => 'fullName',
|
||||
),
|
||||
'prevUser' => array(
|
||||
'previous_usr_uid' => 'userId',
|
||||
'previous_usr_firstname' => 'firstName',
|
||||
'previous_usr_lastname' => 'lastName',
|
||||
'previous_usr_username' => 'fullName',
|
||||
),
|
||||
'process' => array(
|
||||
'pro_uid' => 'processId',
|
||||
'app_pro_title' => 'name'
|
||||
),
|
||||
'task' => array(
|
||||
'tas_uid' => 'taskId',
|
||||
'app_tas_title' => 'name'
|
||||
)
|
||||
);
|
||||
|
||||
$response = $this->replaceFields($data, $structure);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function replaceFields ($data, $structure)
|
||||
{
|
||||
$response = array();
|
||||
foreach ($data as $field => $d) {
|
||||
if (is_array($d)) {
|
||||
$newData = array();
|
||||
foreach ($d as $field => $value) {
|
||||
if (array_key_exists($field, $structure)) {
|
||||
$newName = $structure[$field];
|
||||
$newData[$newName] = $value;
|
||||
} else {
|
||||
foreach ($structure as $name => $str) {
|
||||
if (is_array($str) && array_key_exists($field, $str)) {
|
||||
$newName = $str[$field];
|
||||
$newData[$name][$newName] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$response[] = $newData;
|
||||
} else {
|
||||
if (array_key_exists($field, $structure)) {
|
||||
$newName = $structure[$field];
|
||||
$response[$newName] = $d;
|
||||
} else {
|
||||
foreach ($structure as $name => $str) {
|
||||
if (is_array($str) && array_key_exists($field, $str)) {
|
||||
$newName = $str[$field];
|
||||
$response[$name][$newName] = $d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list History case
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /history/:app_uid
|
||||
*
|
||||
* @param string $app_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetCasesListHistory($app_uid)
|
||||
{
|
||||
try {
|
||||
$oMobile = new \ProcessMaker\BusinessModel\Light();
|
||||
$response = $oMobile->getCasesListHistory($app_uid);
|
||||
$response['flow'] = $this->parserDataHistory($response['flow']);
|
||||
$r = new \stdclass();
|
||||
$r->data = $response;
|
||||
$r->totalCount = count($response['flow']);
|
||||
return $r;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
public function parserDataHistory ($data)
|
||||
{
|
||||
$structure = array(
|
||||
//'' => 'caseId',
|
||||
//'' => 'caseTitle',
|
||||
//'' => 'processName',
|
||||
//'' => 'ownerFullName',
|
||||
//'flow' => array(
|
||||
'TAS_TITLE' => 'taskName',
|
||||
//'' => 'userId',
|
||||
'USR_NAME' => 'userFullName',
|
||||
'APP_TYPE' => 'flowStatus', // is null default Router in FE
|
||||
'DEL_DELEGATE_DATE' => 'dueDate',
|
||||
//)
|
||||
);
|
||||
|
||||
$response = $this->replaceFields($data, $structure);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @url GET /project/:prj_uid/dynaforms
|
||||
*
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetDynaForms($prj_uid)
|
||||
{
|
||||
try {
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$process->setFormatFieldNameInUppercase(false);
|
||||
$process->setArrayFieldNameForException(array("processUid" => "prj_uid"));
|
||||
|
||||
$response = $process->getDynaForms($prj_uid);
|
||||
$result = $this->parserDataDynaForm($response);
|
||||
foreach ($result as $k => $form) {
|
||||
$result[$k]['formContent'] = (isset($form['formContent']) && $form['formContent'] != null)?json_decode($form['formContent']):"";
|
||||
$result[$k]['index'] = $k;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /project/:prj_uid/activity/:act_uid/steps
|
||||
*
|
||||
* @param string $act_uid {@min 32}{@max 32}
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetActivitySteps($act_uid, $prj_uid)
|
||||
{
|
||||
try {
|
||||
$task = new \ProcessMaker\BusinessModel\Task();
|
||||
$task->setFormatFieldNameInUppercase(false);
|
||||
$task->setArrayParamException(array("taskUid" => "act_uid", "stepUid" => "step_uid"));
|
||||
|
||||
$activitySteps = $task->getSteps($act_uid);
|
||||
|
||||
//$step = new \ProcessMaker\Services\Api\Project\Activity\Step();
|
||||
|
||||
$dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
|
||||
$dynaForm->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$response = array();
|
||||
for ($i = 0; $i < count($activitySteps); $i++) {
|
||||
if ($activitySteps[$i]['step_type_obj'] == "DYNAFORM") {
|
||||
$dataForm = $dynaForm->getDynaForm($activitySteps[$i]['step_uid_obj']);
|
||||
$result = $this->parserDataDynaForm($dataForm);
|
||||
$result['formContent'] = (isset($result['formContent']) && $result['formContent'] != null)?json_decode($result['formContent']):"";
|
||||
$result['index'] = $i;
|
||||
//$activitySteps[$i]["triggers"] = $step->doGetActivityStepTriggers($activitySteps[$i]["step_uid"], $act_uid, $prj_uid);
|
||||
$response[] = $result;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /project/dynaform/:dyn_uid
|
||||
*
|
||||
* @param string $dyn_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetDynaForm($dyn_uid)
|
||||
{
|
||||
try {
|
||||
$dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
|
||||
$dynaForm->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$response = $dynaForm->getDynaForm($dyn_uid);
|
||||
$result = $this->parserDataDynaForm($response);
|
||||
$result['formContent'] = (isset($result['formContent']) && $result['formContent'] != null)?json_decode($result['formContent']):"";
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /project/dynaforms
|
||||
*
|
||||
*/
|
||||
public function doGetDynaFormsId($request_data)
|
||||
{
|
||||
try {
|
||||
$dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
|
||||
$dynaForm->setFormatFieldNameInUppercase(false);
|
||||
$return = array();
|
||||
foreach ($request_data['formId'] as $dyn_uid) {
|
||||
$response = $dynaForm->getDynaForm($dyn_uid);
|
||||
$result = $this->parserDataDynaForm($response);
|
||||
$result['formContent'] = (isset($result['formContent']) && $result['formContent'] != null)?json_decode($result['formContent']):"";
|
||||
$return[] = $result;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function parserDataDynaForm ($data)
|
||||
{
|
||||
$structure = array(
|
||||
'dyn_uid' => 'formId',
|
||||
'dyn_title' => 'formTitle',
|
||||
'dyn_description' => 'formDescription',
|
||||
//'dyn_type' => 'formType',
|
||||
'dyn_content' => 'formContent'
|
||||
);
|
||||
|
||||
$response = $this->replaceFields($data, $structure);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /process/:pro_uid/task/:task_uid/start-case
|
||||
*
|
||||
* @param string $pro_uid {@min 32}{@max 32}
|
||||
* @param string $task_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function postStartCase($pro_uid, $task_uid)
|
||||
{
|
||||
try {
|
||||
$oMobile = new \ProcessMaker\BusinessModel\Light();
|
||||
$result = $oMobile->startCase($this->getUserId(), $pro_uid, $task_uid);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Route Case
|
||||
* @url PUT /cases/:app_uid/route-case
|
||||
*
|
||||
* @param string $app_uid {@min 32}{@max 32}
|
||||
* @param string $del_index {@from body}
|
||||
*/
|
||||
public function doPutRouteCase($app_uid, $del_index = null)
|
||||
{
|
||||
try {
|
||||
$oMobile = new \ProcessMaker\BusinessModel\Light();
|
||||
$response = $oMobile->updateRouteCase($app_uid, $this->getUserId(), $del_index);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /user/data
|
||||
*/
|
||||
public function doGetUserData()
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$oMobile = new \ProcessMaker\BusinessModel\Light();
|
||||
$response = $oMobile->getUserData($userUid);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /users/data
|
||||
*/
|
||||
public function doGetUsersData($request_data)
|
||||
{
|
||||
try {
|
||||
$response = array();
|
||||
$oMobile = new \ProcessMaker\BusinessModel\Light();
|
||||
foreach ($request_data['user']['ids'] as $userUid) {
|
||||
$response[] = $oMobile->getUserData($userUid);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /case/:app_uid/input-document
|
||||
*
|
||||
* @param string $app_uid { @min 32}{@max 32}
|
||||
* @param string $tas_uid {@min 32}{@max 32}
|
||||
* @param string $app_doc_comment
|
||||
* @param string $inp_doc_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doPostInputDocument($app_uid, $tas_uid, $app_doc_comment, $inp_doc_uid)
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$inputDocument = new \ProcessMaker\BusinessModel\Cases\InputDocument();
|
||||
$file = $inputDocument->addCasesInputDocument($app_uid, $tas_uid, $app_doc_comment, $inp_doc_uid, $userUid);
|
||||
$response = $this->parserInputDocument($file);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function parserInputDocument ($data)
|
||||
{
|
||||
$structure = array(
|
||||
'app_doc_uid' => 'fileId',
|
||||
'app_doc_filename' => 'fileName',
|
||||
'app_doc_version' => 'version'
|
||||
);
|
||||
$response = $this->replaceFields($data, $structure);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /case/:app_uid/input-document/location
|
||||
*
|
||||
* @param string $app_uid { @min 32}{@max 32}
|
||||
* @param string $tas_uid {@min 32}{@max 32}
|
||||
* @param string $app_doc_comment
|
||||
* @param string $inp_doc_uid {@min 32}{@max 32}
|
||||
* @param float $latitude {@min -90}{@max 90}
|
||||
* @param float $longitude {@min -180}{@max 180}
|
||||
*/
|
||||
public function postInputDocumentLocation($app_uid, $tas_uid, $app_doc_comment, $inp_doc_uid, $latitude, $longitude)
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$inputDocument = new \ProcessMaker\BusinessModel\Cases\InputDocument();
|
||||
$url = "http://maps.googleapis.com/maps/api/staticmap?center=".$latitude.','.$longitude."&format=jpg&size=600x600&zoom=15&markers=color:blue%7Clabel:S%7C".$latitude.','.$longitude;
|
||||
$imageLocation = imagecreatefromjpeg($url);
|
||||
$tmpfname = tempnam("php://temp","pmm");
|
||||
imagejpeg($imageLocation, $tmpfname);
|
||||
|
||||
$_FILES["form"]["type"] = "image/jpeg";
|
||||
$_FILES["form"]["name"] = 'Location.jpg';
|
||||
$_FILES["form"]["tmp_name"] = $tmpfname;
|
||||
$_FILES["form"]["error"] = 0;
|
||||
$sizes = getimagesize($tmpfname);
|
||||
$_FILES["form"]["size"] = ($sizes['0'] * $sizes['1']);
|
||||
$file = $inputDocument->addCasesInputDocument($app_uid, $tas_uid, $app_doc_comment, $inp_doc_uid, $userUid);
|
||||
|
||||
$strPathName = PATH_DOCUMENT . G::getPathFromUID($app_uid) . PATH_SEP;
|
||||
$strFileName = $file->app_doc_uid . "_" . $file->app_doc_version . ".jpg";
|
||||
copy($tmpfname, $strPathName . "/" . $strFileName);
|
||||
$response = $this->parserInputDocument($file);
|
||||
unlink($tmpfname);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /case/:app_uid/download64
|
||||
*
|
||||
* @param string $app_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function postDownloadFile($app_uid, $request_data)
|
||||
{
|
||||
try {
|
||||
$oMobile = new \ProcessMaker\BusinessModel\Light();
|
||||
$files = $oMobile->downloadFile($app_uid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /logout
|
||||
*
|
||||
* @param $access
|
||||
* @param $refresh
|
||||
* @return mixed
|
||||
*/
|
||||
public function postLogout($access, $refresh)
|
||||
{
|
||||
try {
|
||||
$oMobile = new \ProcessMaker\BusinessModel\Light();
|
||||
$files = $oMobile->logout($access, $refresh);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
}
|
||||
@@ -98,3 +98,5 @@ debug = 1
|
||||
[alias: emails]
|
||||
email = "ProcessMaker\Services\Api\EmailServer"
|
||||
|
||||
[alias: light]
|
||||
light = "ProcessMaker\Services\Api\Light"
|
||||
@@ -894,6 +894,7 @@ if (! defined( 'EXECUTE_BY_CRON' )) {
|
||||
$noLoginFiles[] = 'casesSaveDataView';
|
||||
$noLoginFiles[] = 'propelTableAjax';
|
||||
$noLoginFiles[] = 'licenseUpdate';
|
||||
$noLoginFiles[] = 'casesStreamingFile';
|
||||
|
||||
$noLoginFolders[] = 'services';
|
||||
$noLoginFolders[] = 'tracker';
|
||||
|
||||
Reference in New Issue
Block a user