Merge branch 'master' of bitbucket.org:colosa/processmaker
This commit is contained in:
@@ -15,12 +15,17 @@
|
||||
*/
|
||||
class AppNotes extends BaseAppNotes
|
||||
{
|
||||
public function getNotesList ($appUid, $usrUid = '', $start = '', $limit = '')
|
||||
public function getNotesList (
|
||||
$appUid,
|
||||
$usrUid = '',
|
||||
$start = '',
|
||||
$limit = 25,
|
||||
$sort = 'APP_NOTES.NOTE_DATE',
|
||||
$dir = 'DESC',
|
||||
$dateFrom = '',
|
||||
$dateTo = '',
|
||||
$search = '')
|
||||
{
|
||||
require_once ("classes/model/Users.php");
|
||||
|
||||
G::LoadClass( 'ArrayPeer' );
|
||||
|
||||
$Criteria = new Criteria( 'workflow' );
|
||||
$Criteria->clearSelectColumns();
|
||||
|
||||
@@ -41,13 +46,26 @@ class AppNotes extends BaseAppNotes
|
||||
|
||||
$Criteria->addJoin( AppNotesPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN );
|
||||
|
||||
$Criteria->add( appNotesPeer::APP_UID, $appUid, CRITERIA::EQUAL );
|
||||
$Criteria->add( AppNotesPeer::APP_UID, $appUid, Criteria::EQUAL );
|
||||
|
||||
if ($usrUid != '') {
|
||||
$Criteria->add( appNotesPeer::USR_UID, $usrUid, CRITERIA::EQUAL );
|
||||
$Criteria->add( AppNotesPeer::USR_UID, $usrUid, Criteria::EQUAL );
|
||||
}
|
||||
if ($dateFrom != '') {
|
||||
$Criteria->add( AppNotesPeer::NOTE_DATE, $dateFrom, Criteria::GREATER_EQUAL );
|
||||
}
|
||||
if ($dateTo != '') {
|
||||
$Criteria->add( AppNotesPeer::NOTE_DATE, $dateTo, Criteria::LESS_EQUAL );
|
||||
}
|
||||
if ($search != '') {
|
||||
$Criteria->add( AppNotesPeer::NOTE_CONTENT, '%'.$search.'%', Criteria::LIKE );
|
||||
}
|
||||
|
||||
$Criteria->addDescendingOrderByColumn( AppNotesPeer::NOTE_DATE );
|
||||
if ($dir == 'DESC') {
|
||||
$Criteria->addDescendingOrderByColumn($sort);
|
||||
} else {
|
||||
$Criteria->addAscendingOrderByColumn($sort);
|
||||
}
|
||||
|
||||
$response = array ();
|
||||
$totalCount = AppNotesPeer::doCount( $Criteria );
|
||||
|
||||
@@ -23,22 +23,36 @@
|
||||
*/
|
||||
ini_set( 'max_execution_time', '0' );
|
||||
|
||||
|
||||
$ext = pathinfo($_FILES["PROCESS_FILENAME"]["name"], PATHINFO_EXTENSION);
|
||||
|
||||
if ($ext == "pmx") {
|
||||
$importer = new \ProcessMaker\Importer\XmlImporter();
|
||||
$importer->setSourceFromGlobals("PROCESS_FILENAME");
|
||||
$data = array("usr_uid" => $_SESSION['USER_LOGGED']);
|
||||
$res = $importer->import($data);
|
||||
$result = array(
|
||||
"success" => true,
|
||||
"catchMessage" => "",
|
||||
"ExistProcessInDatabase" => 0,
|
||||
"ExistGroupsInDatabase" => 0,
|
||||
"sNewProUid" => $res[0]["new_uid"],
|
||||
"project_type" => "bpmn"
|
||||
);
|
||||
$importer->setData("usr_uid", $_SESSION['USER_LOGGED']);
|
||||
|
||||
try {
|
||||
$res = $importer->import();
|
||||
|
||||
$result = array(
|
||||
"success" => true,
|
||||
"catchMessage" => "",
|
||||
"ExistProcessInDatabase" => 0,
|
||||
"ExistGroupsInDatabase" => 0,
|
||||
"sNewProUid" => $res[0]["new_uid"],
|
||||
"project_type" => "bpmn"
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$result = array(
|
||||
"success" => true,
|
||||
"catchMessage" => "", //$e->getMessage(),
|
||||
"ExistProcessInDatabase" => 1,
|
||||
"ExistGroupsInDatabase" => 0,
|
||||
"groupBeforeAccion" => "uploadFileNewProcess",
|
||||
"sNewProUid" => "63626727053359dabb8fee8019503780",
|
||||
"proFileName" => $_FILES['PROCESS_FILENAME']['name'],
|
||||
"project_type" => "bpmn"
|
||||
);
|
||||
}
|
||||
|
||||
echo json_encode($result);
|
||||
exit(0);
|
||||
|
||||
@@ -649,7 +649,7 @@ class Cases
|
||||
$case = new \Cases();
|
||||
$fields = $case->loadCase($app_uid);
|
||||
if ($fields['APP_STATUS'] == 'CANCELLED') {
|
||||
throw (new \Exception("The case '$app_uid' is canceled"));
|
||||
throw (new \Exception("The case '$app_uid' is already canceled"));
|
||||
}
|
||||
$case->cancelCase( $app_uid, $del_index, $usr_uid );
|
||||
}
|
||||
@@ -1348,7 +1348,7 @@ class Cases
|
||||
|
||||
$case = new \Cases();
|
||||
$fields = $case->loadCase($app_uid);
|
||||
$data = array_merge($fields['APP_DATA'], array('APP_DATA' => $app_data));
|
||||
$data['APP_DATA'] = array_merge($fields['APP_DATA'], $app_data);
|
||||
$case->updateCase($app_uid, $data);
|
||||
}
|
||||
|
||||
@@ -1362,9 +1362,23 @@ class Cases
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function getCaseNotes($app_uid, $usr_uid) {
|
||||
public function getCaseNotes($app_uid, $usr_uid, $data_get) {
|
||||
Validator::isString($app_uid, '$app_uid');
|
||||
Validator::appUid($app_uid, '$app_uid');
|
||||
Validator::isString($usr_uid, '$usr_uid');
|
||||
Validator::usrUid($usr_uid, '$usr_uid');
|
||||
Validator::isArray($data_get, '$data_get');
|
||||
|
||||
Validator::isArray($data_get, '$data_get');
|
||||
$start = isset( $data_get["start"] ) ? $data_get["start"] : "0";
|
||||
$limit = isset( $data_get["limit"] ) ? $data_get["limit"] : "";
|
||||
$sort = isset( $data_get["sort"] ) ? $data_get["sort"] : "APP_NOTES.NOTE_DATE";
|
||||
$dir = isset( $data_get["dir"] ) ? $data_get["dir"] : "DESC";
|
||||
$user = isset( $data_get["user"] ) ? $data_get["user"] : "";
|
||||
$dateFrom = (!empty( $data_get["dateFrom"] )) ? substr( $data_get["dateFrom"], 0, 10 ) : "";
|
||||
$dateTo = (!empty( $data_get["dateTo"] )) ? substr( $data_get["dateTo"], 0, 10 ) : "";
|
||||
$search = isset( $data_get["search"] ) ? $data_get["search"] : "";
|
||||
$paged = isset( $data_get["paged"] ) ? $data_get["paged"] : true;
|
||||
|
||||
$case = new \Cases();
|
||||
$caseLoad = $case->loadCase($app_uid);
|
||||
@@ -1376,18 +1390,63 @@ class Cases
|
||||
throw (new \Exception("You do not have permission to cases notes."));
|
||||
}
|
||||
|
||||
if ($sort != 'APP_NOTE.NOTE_DATE') {
|
||||
$sort = G::toUpper($sort);
|
||||
$columnsAppCacheView = \AppNotesPeer::getFieldNames(\BasePeer::TYPE_FIELDNAME);
|
||||
if (!(in_array($sort, $columnsAppCacheView))) {
|
||||
$sort = 'APP_NOTES.NOTE_DATE';
|
||||
} else {
|
||||
$sort = 'APP_NOTES.'.$sort;
|
||||
}
|
||||
}
|
||||
if ((int)$start == 1 || (int)$start == 0) {
|
||||
$start = 0;
|
||||
}
|
||||
$dir = G::toUpper($dir);
|
||||
if (!($dir == 'DESC' || $dir == 'ASC')) {
|
||||
$dir = 'DESC';
|
||||
}
|
||||
if ($user != '') {
|
||||
Validator::usrUid($user, '$usr_uid');
|
||||
}
|
||||
if ($dateFrom != '') {
|
||||
Validator::isDate($dateFrom, 'Y-m-d', '$date_from');
|
||||
}
|
||||
if ($dateTo != '') {
|
||||
Validator::isDate($dateTo, 'Y-m-d', '$date_to');
|
||||
}
|
||||
|
||||
$appNote = new \AppNotes();
|
||||
$note_data = $appNote->getNotesList($app_uid);
|
||||
$note_data = $appNote->getNotesList($app_uid, $user, $start, $limit, $sort, $dir, $dateFrom, $dateTo, $search);
|
||||
$response = array();
|
||||
$response['total'] = $note_data['array']['totalCount'];
|
||||
$response['notes'] = array();
|
||||
$con = 0;
|
||||
foreach ($note_data['array']['notes'] as $value) {
|
||||
$response['notes'][$con]['app_uid'] = $value['APP_UID'];
|
||||
$response['notes'][$con]['usr_uid'] = $value['USR_UID'];
|
||||
$response['notes'][$con]['note_date'] = $value['NOTE_DATE'];
|
||||
$response['notes'][$con]['note_content'] = $value['NOTE_CONTENT'];
|
||||
$con++;
|
||||
if ($paged === true) {
|
||||
$response['total'] = $note_data['array']['totalCount'];
|
||||
$response['start'] = $start;
|
||||
$response['limit'] = $limit;
|
||||
$response['sort'] = $sort;
|
||||
$response['dir'] = $dir;
|
||||
$response['usr_uid'] = $user;
|
||||
$response['date_to'] = $dateTo;
|
||||
$response['date_from'] = $dateFrom;
|
||||
$response['search'] = $search;
|
||||
$response['data'] = array();
|
||||
$con = 0;
|
||||
foreach ($note_data['array']['notes'] as $value) {
|
||||
$response['data'][$con]['app_uid'] = $value['APP_UID'];
|
||||
$response['data'][$con]['usr_uid'] = $value['USR_UID'];
|
||||
$response['data'][$con]['note_date'] = $value['NOTE_DATE'];
|
||||
$response['data'][$con]['note_content'] = $value['NOTE_CONTENT'];
|
||||
$con++;
|
||||
}
|
||||
} else {
|
||||
$con = 0;
|
||||
foreach ($note_data['array']['notes'] as $value) {
|
||||
$response[$con]['app_uid'] = $value['APP_UID'];
|
||||
$response[$con]['usr_uid'] = $value['USR_UID'];
|
||||
$response[$con]['note_date'] = $value['NOTE_DATE'];
|
||||
$response[$con]['note_content'] = $value['NOTE_CONTENT'];
|
||||
$con++;
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ class OutputDocument
|
||||
$aData['out_doc_pdf_security_open_password'] = \G::encrypt( $aData['out_doc_pdf_security_open_password'], $outDocUid );
|
||||
$aData['out_doc_pdf_security_owner_password'] = \G::encrypt( $aData['out_doc_pdf_security_owner_password'], $outDocUid );
|
||||
}
|
||||
$this->updateOutputDocument($sProcessUID, $aData, $outDocUid);
|
||||
$this->updateOutputDocument($sProcessUID, $aData, $outDocUid, 1);
|
||||
//Return
|
||||
unset($aData["PRO_UID"]);
|
||||
$aData = array_change_key_case($aData, CASE_LOWER);
|
||||
@@ -283,10 +283,11 @@ class OutputDocument
|
||||
* @param string $sProcessUID
|
||||
* @param array $aData
|
||||
* @param string $sOutputDocumentUID
|
||||
* @param int $sFlag
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function updateOutputDocument($sProcessUID, $aData, $sOutputDocumentUID = '')
|
||||
public function updateOutputDocument($sProcessUID, $aData, $sOutputDocumentUID = '', $sFlag)
|
||||
{
|
||||
$oConnection = \Propel::getConnection(\OutputDocumentPeer::DATABASE_NAME);
|
||||
$pemission = $aData['out_doc_pdf_security_permissions'];
|
||||
@@ -306,7 +307,7 @@ class OutputDocument
|
||||
if ($oOutputDocument->validate()) {
|
||||
$oConnection->begin();
|
||||
if (isset($aData['OUT_DOC_TITLE'])) {
|
||||
if ($this->existsTitle($sProcessUID, $aData["OUT_DOC_TITLE"])) {
|
||||
if ($this->existsTitle($sProcessUID, $aData["OUT_DOC_TITLE"]) && $sFlag == 0) {
|
||||
throw (new \Exception(\G::LoadTranslation("ID_OUTPUT_NOT_SAVE")));
|
||||
}
|
||||
$oOutputDocument->setOutDocTitle($aData['OUT_DOC_TITLE']);
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Importer;
|
||||
|
||||
use ProcessMaker\Util;
|
||||
use ProcessMaker\Project\Adapter;
|
||||
|
||||
abstract class Importer
|
||||
{
|
||||
protected $data = array();
|
||||
protected $importData = array();
|
||||
protected $filename = "";
|
||||
protected $saveDir = "";
|
||||
|
||||
@@ -23,19 +28,55 @@ abstract class Importer
|
||||
*/
|
||||
const IMPORT_STAT_INVALID_SOURCE_FILE = 102;
|
||||
|
||||
public abstract function load();
|
||||
|
||||
public function import($option = self::IMPORT_OPTION_CREATE_NEW)
|
||||
{
|
||||
$this->prepare();
|
||||
|
||||
switch ($option) {
|
||||
case self::IMPORT_OPTION_CREATE_NEW:
|
||||
$this->prepare();
|
||||
$this->createNewProject();
|
||||
$result = $this->doImport();
|
||||
break;
|
||||
case self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW:
|
||||
break;
|
||||
case self::IMPORT_OPTION_OVERWRITE:
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare for import, it makes all validations needed
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function prepare()
|
||||
{
|
||||
if ($this->validateSource() === false) {
|
||||
throw new \Exception(
|
||||
"Error, Invalid file type or the file have corrupt data",
|
||||
self::IMPORT_STAT_INVALID_SOURCE_FILE
|
||||
);
|
||||
}
|
||||
|
||||
$this->importData = $this->load();
|
||||
|
||||
$this->validateImportData();
|
||||
|
||||
if ($this->targetExists()) {
|
||||
throw new \Exception(sprintf(
|
||||
"Project already exists, you need set an action to continue. " .
|
||||
"Avaliable actions: [%s|%s|%s].", self::IMPORT_OPTION_CREATE_NEW,
|
||||
self::IMPORT_OPTION_OVERWRITE, self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW
|
||||
), self::IMPORT_STAT_TARGET_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
public function setData($key, $value)
|
||||
{
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,18 +88,29 @@ abstract class Importer
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validateImportData()
|
||||
{
|
||||
if (! isset($this->importData["tables"]["bpmn"])) {
|
||||
throw new \Exception("BPMN Definition is missing.");
|
||||
}
|
||||
if (! isset($this->importData["tables"]["bpmn"]["project"]) || count($this->importData["tables"]["bpmn"]["project"]) !== 1) {
|
||||
throw new \Exception("BPMN table: \"Project\", definition is missing or has multiple definition.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the project already exists
|
||||
* @return mixed
|
||||
*/
|
||||
public function targetExists()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$prjUid = $this->importData["tables"]["bpmn"]["project"][0]["prj_uid"];
|
||||
|
||||
public function createNewProject()
|
||||
{
|
||||
$bpmnProject = \BpmnProjectPeer::retrieveByPK($prjUid);
|
||||
|
||||
return is_object($bpmnProject);
|
||||
}
|
||||
|
||||
public function updateProject()
|
||||
@@ -109,15 +161,6 @@ abstract class Importer
|
||||
*/
|
||||
public function setSourceFromGlobals($varName)
|
||||
{
|
||||
/*[PROCESS_FILENAME] => Array
|
||||
(
|
||||
[name] => sample29.pm
|
||||
[type] => application/pm
|
||||
[tmp_name] => /tmp/phpvHpCVO
|
||||
[error] => 0
|
||||
[size] => 1260881
|
||||
)*/
|
||||
|
||||
if (! array_key_exists($varName, $_FILES)) {
|
||||
throw new \Exception("Couldn't find specified source \"$varName\" in PHP Globals");
|
||||
}
|
||||
@@ -136,28 +179,75 @@ abstract class Importer
|
||||
umask($oldUmask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare for import, it makes all validations needed
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function prepare()
|
||||
protected function importBpmnTables(array $tables)
|
||||
{
|
||||
if ($this->validateSource() === false) {
|
||||
throw new \Exception(
|
||||
"Error, Invalid file type or the file have corrupt data",
|
||||
self::IMPORT_STAT_INVALID_SOURCE_FILE
|
||||
);
|
||||
}
|
||||
// Build BPMN project struct
|
||||
$project = $tables["project"][0];
|
||||
$diagram = $tables["diagram"][0];
|
||||
$diagram["activities"] = $tables["activity"];
|
||||
$diagram["artifacts"] = array();
|
||||
$diagram["events"] = $tables["event"];
|
||||
$diagram["flows"] = $tables["flow"];
|
||||
$diagram["gateways"] = $tables["gateway"];
|
||||
$diagram["lanes"] = array();
|
||||
$diagram["laneset"] = array();
|
||||
$project["diagrams"] = array($diagram);
|
||||
$project["prj_author"] = isset($this->data["usr_uid"])? $this->data["usr_uid"]: "00000000000000000000000000000001";
|
||||
$project["process"] = $tables["process"][0];
|
||||
|
||||
if ($this->targetExists()) {
|
||||
throw new \Exception(sprintf(
|
||||
"Project already exists, you need set an action to continue. " .
|
||||
"Avaliable actions: [%s|%s|%s].", self::IMPORT_OPTION_CREATE_NEW,
|
||||
self::IMPORT_OPTION_OVERWRITE, self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW
|
||||
), self::IMPORT_STAT_TARGET_ALREADY_EXISTS);
|
||||
}
|
||||
return Adapter\BpmnWorkflow::createFromStruct($project);
|
||||
}
|
||||
|
||||
return self::IMPORT_STAT_SUCCESS;
|
||||
protected function importWfTables(array $tables)
|
||||
{
|
||||
$tables = (object) $tables;
|
||||
|
||||
$processes = new \Processes();
|
||||
$processes->createProcessPropertiesFromData($tables);
|
||||
}
|
||||
|
||||
protected function importWfFiles(array $workflowFiles)
|
||||
{
|
||||
foreach ($workflowFiles as $target => $files) {
|
||||
switch ($target) {
|
||||
case "dynaforms":
|
||||
$basePath = PATH_DYNAFORM;
|
||||
break;
|
||||
case "public":
|
||||
$basePath = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP;
|
||||
break;
|
||||
case "templates":
|
||||
$basePath = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "mailTemplates" . PATH_SEP;
|
||||
break;
|
||||
default:
|
||||
$basePath = "";
|
||||
}
|
||||
|
||||
if (empty($basePath)) continue;
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filename = $basePath . $file["file_path"];
|
||||
$path = dirname($filename);
|
||||
|
||||
if (! is_dir($path)) {
|
||||
Util\Common::mk_dir($path, 0775);
|
||||
}
|
||||
|
||||
file_put_contents($filename, $file["file_content"]);
|
||||
chmod($filename, 0775);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function doImport()
|
||||
{
|
||||
$tables = $this->importData["tables"];
|
||||
$files = $this->importData["files"];
|
||||
|
||||
$result = $this->importBpmnTables($tables["bpmn"]);
|
||||
$this->importWfTables($tables["workflow"]);
|
||||
$this->importWfFiles($files["workflow"]);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Importer;
|
||||
|
||||
use ProcessMaker\Project\Adapter;
|
||||
use ProcessMaker\Util;
|
||||
|
||||
class XmlImporter extends Importer
|
||||
{
|
||||
/**
|
||||
@@ -12,17 +9,22 @@ class XmlImporter extends Importer
|
||||
protected $dom;
|
||||
protected $root;
|
||||
protected $version = "";
|
||||
protected $metadata;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->dom = new \DOMDocument();
|
||||
}
|
||||
|
||||
public function setSourceFile($filename)
|
||||
{
|
||||
$this->filename = $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* Example:
|
||||
* array(
|
||||
* "tables" => array("bpmn" => array(), "workflow" => array())
|
||||
* "files" => array("bpmn" => array(), "workflow" => array())
|
||||
* )
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
$this->dom->load($this->filename);
|
||||
@@ -36,13 +38,13 @@ class XmlImporter extends Importer
|
||||
}
|
||||
|
||||
// read metadata section
|
||||
$metadata = $this->root->getElementsByTagName("metadata");
|
||||
$metadataNode = $this->root->getElementsByTagName("metadata");
|
||||
|
||||
if ($metadata->length != 1) {
|
||||
if ($metadataNode->length != 1) {
|
||||
throw new \Exception("Invalid Document format, metadata section is missing or has multiple definition.");
|
||||
}
|
||||
|
||||
$metadata = $metadata->item(0);
|
||||
$this->metadata = $metadataNode->item(0);
|
||||
|
||||
// load project definition
|
||||
/** @var \DOMElement[]|\DomNodeList $definitions */
|
||||
@@ -57,7 +59,7 @@ class XmlImporter extends Importer
|
||||
$tables = array();
|
||||
|
||||
foreach ($definitions as $definition) {
|
||||
$defClass = strtoupper($definition->getAttribute("class"));
|
||||
$defClass = strtolower($definition->getAttribute("class"));
|
||||
$tables[$defClass] = array();
|
||||
|
||||
// getting tables def
|
||||
@@ -66,7 +68,7 @@ class XmlImporter extends Importer
|
||||
$tablesNodeList = $definition->getElementsByTagName("table");
|
||||
|
||||
foreach ($tablesNodeList as $tableNode) {
|
||||
$tableName = $tableNode->getAttribute("name"); //strtoupper($tableNode->getAttribute("name"));
|
||||
$tableName = strtolower($tableNode->getAttribute("name"));
|
||||
$tables[$defClass][$tableName] = array();
|
||||
/** @var \DOMElement[] $recordsNodeList */
|
||||
$recordsNodeList = $tableNode->getElementsByTagName("record");
|
||||
@@ -80,9 +82,9 @@ class XmlImporter extends Importer
|
||||
|
||||
foreach ($recordsNode->childNodes as $columnNode) {
|
||||
if ($columnNode->nodeName == "#text") continue;
|
||||
//$columns[strtoupper($columnNode->nodeName)] = self::createTextNode($columnNode);;
|
||||
$columnName = $defClass == "WORKFLOW" ? strtoupper($columnNode->nodeName) : $columnNode->nodeName;
|
||||
$columns[$columnName] = self::createTextNode($columnNode);
|
||||
//$columns[strtoupper($columnNode->nodeName)] = self::getTextNode($columnNode);;
|
||||
$columnName = $defClass == "workflow" ? strtoupper($columnNode->nodeName) : $columnNode->nodeName;
|
||||
$columns[$columnName] = self::getTextNode($columnNode);
|
||||
}
|
||||
|
||||
$tables[$defClass][$tableName][] = $columns;
|
||||
@@ -97,54 +99,28 @@ class XmlImporter extends Importer
|
||||
$filesNodeList = $wfFilesNodeList->item(0)->getElementsByTagName("file");
|
||||
|
||||
foreach ($filesNodeList as $fileNode) {
|
||||
$target = $fileNode->getAttribute("target");
|
||||
$target = strtolower($fileNode->getAttribute("target"));
|
||||
|
||||
if (! isset($wfFiles[$target])) {
|
||||
$wfFiles[$target] = array();
|
||||
}
|
||||
|
||||
$fileContent = self::createTextNode($fileNode->getElementsByTagName("file_content")->item(0));
|
||||
$fileContent = base64_decode($fileContent);
|
||||
|
||||
$fileContent = self::getTextNode($fileNode->getElementsByTagName("file_content")->item(0));
|
||||
$wfFiles[$target][] = array(
|
||||
"file_name" => self::createTextNode($fileNode->getElementsByTagName("file_name")->item(0)),
|
||||
"file_path" => self::createTextNode($fileNode->getElementsByTagName("file_path")->item(0)),
|
||||
"file_content" => $fileContent
|
||||
"file_name" => self::getTextNode($fileNode->getElementsByTagName("file_name")->item(0)),
|
||||
"file_path" => self::getTextNode($fileNode->getElementsByTagName("file_path")->item(0)),
|
||||
"file_content" => base64_decode($fileContent)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//print_r($tables);
|
||||
//print_r($wfFiles);
|
||||
return array($tables, $wfFiles);
|
||||
return array(
|
||||
"tables" => $tables,
|
||||
"files" => array("workflow" => $wfFiles, "bpmn" => array())
|
||||
);
|
||||
}
|
||||
|
||||
public function import($data = array())
|
||||
{
|
||||
list($tables, $files) = $this->load();
|
||||
|
||||
// Build BPMN project struct
|
||||
$project = $tables["BPMN"]["PROJECT"][0];
|
||||
$diagram = $tables["BPMN"]["DIAGRAM"][0];
|
||||
$diagram["activities"] = $tables["BPMN"]["ACTIVITY"];
|
||||
$diagram["artifacts"] = array();
|
||||
$diagram["events"] = $tables["BPMN"]["EVENT"];
|
||||
$diagram["flows"] = $tables["BPMN"]["FLOW"];
|
||||
$diagram["gateways"] = $tables["BPMN"]["GATEWAY"];
|
||||
$diagram["lanes"] = array();
|
||||
$diagram["laneset"] = array();
|
||||
$project["diagrams"] = array($diagram);
|
||||
$project["prj_author"] = isset($data["usr_uid"])? $data["usr_uid"]: "00000000000000000000000000000001";
|
||||
$project["process"] = $tables["BPMN"]["PROCESS"][0];
|
||||
$result = Adapter\BpmnWorkflow::createFromStruct($project);
|
||||
|
||||
$this->importWfTables($tables["WORKFLOW"]);
|
||||
$this->importWfFiles($files);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private static function createTextNode($node)
|
||||
private static function getTextNode($node)
|
||||
{
|
||||
if ($node->nodeType == XML_ELEMENT_NODE) {
|
||||
return $node->textContent;
|
||||
@@ -152,42 +128,4 @@ class XmlImporter extends Importer
|
||||
return (string) simplexml_import_dom($node->parentNode);
|
||||
}
|
||||
}
|
||||
|
||||
private static function importWfFiles(array $workflowFiles)
|
||||
{
|
||||
foreach ($workflowFiles as $target => $files) {
|
||||
switch ($target) {
|
||||
case "dynaforms": $basePath = PATH_DYNAFORM; break;
|
||||
case "public":
|
||||
$basePath = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP;
|
||||
break;
|
||||
case "templates":
|
||||
$basePath = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "mailTemplates" . PATH_SEP;
|
||||
break;
|
||||
default: $basePath = "";
|
||||
}
|
||||
|
||||
if (empty($basePath)) continue;
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filename = $basePath . $file["file_path"];
|
||||
$path = dirname($filename);
|
||||
|
||||
if (! is_dir($path)) {
|
||||
Util\Common::mk_dir($path, 0775);
|
||||
}
|
||||
|
||||
file_put_contents($filename, $file["file_content"]);
|
||||
chmod($filename, 0775);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function importWfTables($tables)
|
||||
{
|
||||
$tables = (object) $tables;
|
||||
|
||||
$processes = new \Processes();
|
||||
$processes->createProcessPropertiesFromData($tables);
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,9 @@ class Cases extends Api
|
||||
/**
|
||||
* Get list Cases To Do
|
||||
*
|
||||
* @param string $paged {@from path}
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $cat_uid {@from path}
|
||||
* @param string $pro_uid {@from path}
|
||||
@@ -65,9 +65,9 @@ class Cases extends Api
|
||||
/**
|
||||
* Get list Cases To Do with paged
|
||||
*
|
||||
* @param string $paged {@from path}
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $cat_uid {@from path}
|
||||
* @param string $pro_uid {@from path}
|
||||
@@ -112,9 +112,9 @@ class Cases extends Api
|
||||
/**
|
||||
* Get list Cases Draft
|
||||
*
|
||||
* @param string $paged {@from path}
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $cat_uid {@from path}
|
||||
* @param string $pro_uid {@from path}
|
||||
@@ -159,9 +159,9 @@ class Cases extends Api
|
||||
/**
|
||||
* Get list Cases Draft with paged
|
||||
*
|
||||
* @param string $paged {@from path}
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $cat_uid {@from path}
|
||||
* @param string $pro_uid {@from path}
|
||||
@@ -206,9 +206,9 @@ class Cases extends Api
|
||||
/**
|
||||
* Get list Cases Participated
|
||||
*
|
||||
* @param string $paged {@from path}
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $cat_uid {@from path}
|
||||
* @param string $pro_uid {@from path}
|
||||
@@ -253,9 +253,9 @@ class Cases extends Api
|
||||
/**
|
||||
* Get list Cases Participated with paged
|
||||
*
|
||||
* @param string $paged {@from path}
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $cat_uid {@from path}
|
||||
* @param string $pro_uid {@from path}
|
||||
@@ -300,9 +300,9 @@ class Cases extends Api
|
||||
/**
|
||||
* Get list Cases Unassigned
|
||||
*
|
||||
* @param string $paged {@from path}
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $cat_uid {@from path}
|
||||
* @param string $pro_uid {@from path}
|
||||
@@ -347,9 +347,9 @@ class Cases extends Api
|
||||
/**
|
||||
* Get list Cases Unassigned with paged
|
||||
*
|
||||
* @param string $paged {@from path}
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $cat_uid {@from path}
|
||||
* @param string $pro_uid {@from path}
|
||||
@@ -394,9 +394,9 @@ class Cases extends Api
|
||||
/**
|
||||
* Get list Cases Paused
|
||||
*
|
||||
* @param string $paged {@from path}
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $cat_uid {@from path}
|
||||
* @param string $pro_uid {@from path}
|
||||
@@ -441,9 +441,9 @@ class Cases extends Api
|
||||
/**
|
||||
* Get list Cases Paused with paged
|
||||
*
|
||||
* @param string $paged {@from path}
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $cat_uid {@from path}
|
||||
* @param string $pro_uid {@from path}
|
||||
@@ -488,16 +488,16 @@ class Cases extends Api
|
||||
/**
|
||||
* Get list Cases Advanced Search
|
||||
*
|
||||
* @param string $paged {@from path}
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $cat_uid {@from path}
|
||||
* @param string $pro_uid {@from path}
|
||||
* @param string $app_status {@from path}
|
||||
* @param string $user {@from path}
|
||||
* @param string $dateFrom {@from path}
|
||||
* @param string $dateTo {@from path}
|
||||
* @param string $date_from {@from path}
|
||||
* @param string $date_to {@from path}
|
||||
* @param string $search {@from path}
|
||||
* @return array
|
||||
*
|
||||
@@ -515,8 +515,8 @@ class Cases extends Api
|
||||
$pro_uid = '',
|
||||
$app_status = '',
|
||||
$user = '',
|
||||
$dateFrom = '',
|
||||
$dateTo = '',
|
||||
$date_from = '',
|
||||
$date_to = '',
|
||||
$search = ''
|
||||
)
|
||||
{
|
||||
@@ -533,8 +533,8 @@ class Cases extends Api
|
||||
$dataList['process'] = $pro_uid;
|
||||
$dataList['status'] = $app_status;
|
||||
$dataList['user'] = $user;
|
||||
$dataList['dateFrom'] = $dateFrom;
|
||||
$dataList['dateTo'] = $dateTo;
|
||||
$dataList['dateFrom'] = $date_from;
|
||||
$dataList['dateTo'] = $date_to;
|
||||
$dataList['search'] = $search;
|
||||
$oCases = new \BusinessModel\Cases();
|
||||
$response = $oCases->getList($dataList);
|
||||
@@ -547,16 +547,16 @@ class Cases extends Api
|
||||
/**
|
||||
* Get list Cases Advanced Search with Paged
|
||||
*
|
||||
* @param string $paged {@from path}
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $cat_uid {@from path}
|
||||
* @param string $pro_uid {@from path}
|
||||
* @param string $app_status {@from path}
|
||||
* @param string $usr_uid {@from path}
|
||||
* @param string $dateFrom {@from path}
|
||||
* @param string $dateTo {@from path}
|
||||
* @param string $date_from {@from path}
|
||||
* @param string $date_to {@from path}
|
||||
* @param string $search {@from path}
|
||||
* @return array
|
||||
*
|
||||
@@ -868,19 +868,97 @@ class Cases extends Api
|
||||
/**
|
||||
* Get Case Notes
|
||||
*
|
||||
* @param string $app_uid {@min 1}{@max 32}
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $usr_uid {@from path}
|
||||
* @param string $date_from {@from path}
|
||||
* @param string $date_to {@from path}
|
||||
* @param string $search {@from path}
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /:app_uid/notes
|
||||
*/
|
||||
public function doGetCaseNotes($app_uid)
|
||||
public function doGetCaseNotes(
|
||||
$app_uid,
|
||||
$start = 0,
|
||||
$limit = 25,
|
||||
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
|
||||
$dir = 'DESC',
|
||||
$usr_uid = '',
|
||||
$date_from = '',
|
||||
$date_to = '',
|
||||
$search = ''
|
||||
)
|
||||
{
|
||||
try {
|
||||
$dataList['paged'] = false;
|
||||
|
||||
$dataList['start'] = $start;
|
||||
$dataList['limit'] = $limit;
|
||||
$dataList['sort'] = $sort;
|
||||
$dataList['dir'] = $dir;
|
||||
$dataList['user'] = $usr_uid;
|
||||
$dataList['dateFrom'] = $date_from;
|
||||
$dataList['dateTo'] = $date_to;
|
||||
$dataList['search'] = $search;
|
||||
|
||||
$usr_uid = $this->getUserId();
|
||||
$cases = new \BusinessModel\Cases();
|
||||
$response = $cases->getCaseNotes($app_uid, $usr_uid);
|
||||
$response = $cases->getCaseNotes($app_uid, $usr_uid, $dataList);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Case Notes with Paged
|
||||
*
|
||||
* @param string $start {@from path}
|
||||
* @param string $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $usr_uid {@from path}
|
||||
* @param string $date_from {@from path}
|
||||
* @param string $date_to {@from path}
|
||||
* @param string $search {@from path}
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /:app_uid/notes/paged
|
||||
*/
|
||||
public function doGetCaseNotesPaged(
|
||||
$app_uid,
|
||||
$start = 0,
|
||||
$limit = 25,
|
||||
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
|
||||
$dir = 'DESC',
|
||||
$usr_uid = '',
|
||||
$date_from = '',
|
||||
$date_to = '',
|
||||
$search = ''
|
||||
)
|
||||
{
|
||||
try {
|
||||
$dataList['start'] = $start;
|
||||
$dataList['limit'] = $limit;
|
||||
$dataList['sort'] = $sort;
|
||||
$dataList['dir'] = $dir;
|
||||
$dataList['user'] = $usr_uid;
|
||||
$dataList['dateFrom'] = $date_from;
|
||||
$dataList['dateTo'] = $date_to;
|
||||
$dataList['search'] = $search;
|
||||
|
||||
$usr_uid = $this->getUserId();
|
||||
$cases = new \BusinessModel\Cases();
|
||||
$response = $cases->getCaseNotes($app_uid, $usr_uid, $dataList);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
|
||||
@@ -73,6 +73,29 @@ class Project extends Api
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:prj_uid/export
|
||||
*
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function export($prj_uid)
|
||||
{
|
||||
$exporter = new \ProcessMaker\Exporter\XmlExporter($prj_uid);
|
||||
|
||||
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
|
||||
$version = \ProcessMaker\Util\Common::getLastVersion($outputDir . $exporter->getProjectName() . "-*.pmx") + 1;
|
||||
$outputFilename = $outputDir . sprintf("%s-%s.%s", $exporter->getProjectName(), $version, "pmx");
|
||||
|
||||
$exporter->saveExport($outputFilename);
|
||||
|
||||
$httpStream = new \ProcessMaker\Util\IO\HttpStream();
|
||||
$fileExtension = pathinfo($outputFilename, PATHINFO_EXTENSION);
|
||||
|
||||
$httpStream->loadFromFile($outputFilename);
|
||||
$httpStream->setHeader("Content-Type", "application/$fileExtension");
|
||||
$httpStream->send();
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:prj_uid/process
|
||||
*
|
||||
|
||||
@@ -86,7 +86,7 @@ class OutputDocuments extends Api
|
||||
try {
|
||||
$request_data = (array)($request_data);
|
||||
$outputDocument = new \BusinessModel\OutputDocument();
|
||||
$arrayData = $outputDocument->updateOutputDocument($prjUid, $request_data, $outputDocumentUid);
|
||||
$arrayData = $outputDocument->updateOutputDocument($prjUid, $request_data, $outputDocumentUid, 0);
|
||||
} catch (\Exception $e) {
|
||||
//Response
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user