CODE STYLE
workflow/engine/methods/processes/process_Delete.php workflow/engine/methods/processes/processes_DeleteObjectPermission.php workflow/engine/methods/processes/processes_doUpload.php workflow/engine/methods/processes/processes_DownloadFile.php workflow/engine/methods/processes/processes_DownloadFileXpdl.php workflow/engine/methods/processes/processes_checkProperties.php workflow/engine/methods/processes/processes_Export.php workflow/engine/methods/processes/processes_GetFile.php workflow/engine/methods/processes/processes_Import.php workflow/engine/methods/processes/processes_Import_Ajax.php
This commit is contained in:
@@ -12,51 +12,49 @@
|
||||
*
|
||||
* 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
|
||||
* 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/>.
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
global $RBAC;
|
||||
$access = $RBAC->userCanAccess('PM_FACTORY');
|
||||
if( $access != 1 ){
|
||||
switch ($access){
|
||||
case -1:
|
||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
||||
G::header('location: ../login/login');
|
||||
die;
|
||||
break;
|
||||
case -2:
|
||||
default:
|
||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
|
||||
G::header('location: ../login/login');
|
||||
die;
|
||||
break;
|
||||
}
|
||||
}
|
||||
G::LoadClass('processMap');
|
||||
$access = $RBAC->userCanAccess( 'PM_FACTORY' );
|
||||
if ($access != 1) {
|
||||
switch ($access) {
|
||||
case - 1:
|
||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
|
||||
G::header( 'location: ../login/login' );
|
||||
die();
|
||||
break;
|
||||
case - 2:
|
||||
default:
|
||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
|
||||
G::header( 'location: ../login/login' );
|
||||
die();
|
||||
break;
|
||||
}
|
||||
}
|
||||
G::LoadClass( 'processMap' );
|
||||
$oProcessMap = new ProcessMap();
|
||||
|
||||
$UIDS = explode(',', $_POST['PRO_UIDS']);
|
||||
$UIDS = explode( ',', $_POST['PRO_UIDS'] );
|
||||
|
||||
try{
|
||||
|
||||
foreach($UIDS as $UID){
|
||||
$oProcessMap->deleteProcess($UID);
|
||||
}
|
||||
$resp->status = 0;
|
||||
$resp->msg = 'All process was deleted successfully';
|
||||
echo G::json_encode($resp);
|
||||
} catch(Exception $e){
|
||||
$resp->status = 1;
|
||||
$resp->msg = $e->getMessage();
|
||||
echo G::json_encode($resp);
|
||||
}
|
||||
try {
|
||||
|
||||
|
||||
|
||||
foreach ($UIDS as $UID) {
|
||||
$oProcessMap->deleteProcess( $UID );
|
||||
}
|
||||
$resp->status = 0;
|
||||
$resp->msg = 'All process was deleted successfully';
|
||||
echo G::json_encode( $resp );
|
||||
} catch (Exception $e) {
|
||||
$resp->status = 1;
|
||||
$resp->msg = $e->getMessage();
|
||||
echo G::json_encode( $resp );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,63 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* processes_Save.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
global $RBAC;
|
||||
$access = $RBAC->userCanAccess('PM_FACTORY');
|
||||
if( $access != 1 ){
|
||||
switch ($access)
|
||||
{
|
||||
case -1:
|
||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
||||
G::header('location: ../login/login');
|
||||
die;
|
||||
break;
|
||||
case -2:
|
||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
|
||||
G::header('location: ../login/login');
|
||||
die;
|
||||
break;
|
||||
default:
|
||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
||||
G::header('location: ../login/login');
|
||||
die;
|
||||
break;
|
||||
}
|
||||
}
|
||||
try{
|
||||
require_once 'classes/model/ObjectPermission.php';
|
||||
$oOP = new ObjectPermission();
|
||||
$oOP = ObjectPermissionPeer::retrieveByPK($_GET['OP_UID']);
|
||||
$sProcessUID = $oOP->getProUid();
|
||||
$oOP->delete();
|
||||
$result->success = true;
|
||||
$result->msg = G::LoadTranslation('ID_REPORTTABLE_REMOVED');
|
||||
G::LoadClass('processMap');
|
||||
$oProcessMap = new ProcessMap();
|
||||
$oProcessMap->getObjectsPermissionsCriteria($sProcessUID);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$result->success = false;
|
||||
$result->msg = $e->getMessage();
|
||||
}
|
||||
print G::json_encode($result);
|
||||
<?php
|
||||
/**
|
||||
* processes_Save.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
global $RBAC;
|
||||
$access = $RBAC->userCanAccess( 'PM_FACTORY' );
|
||||
if ($access != 1) {
|
||||
switch ($access) {
|
||||
case - 1:
|
||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
|
||||
G::header( 'location: ../login/login' );
|
||||
die();
|
||||
break;
|
||||
case - 2:
|
||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
|
||||
G::header( 'location: ../login/login' );
|
||||
die();
|
||||
break;
|
||||
default:
|
||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
|
||||
G::header( 'location: ../login/login' );
|
||||
die();
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
require_once 'classes/model/ObjectPermission.php';
|
||||
$oOP = new ObjectPermission();
|
||||
$oOP = ObjectPermissionPeer::retrieveByPK( $_GET['OP_UID'] );
|
||||
$sProcessUID = $oOP->getProUid();
|
||||
$oOP->delete();
|
||||
$result->success = true;
|
||||
$result->msg = G::LoadTranslation( 'ID_REPORTTABLE_REMOVED' );
|
||||
G::LoadClass( 'processMap' );
|
||||
$oProcessMap = new ProcessMap();
|
||||
$oProcessMap->getObjectsPermissionsCriteria( $sProcessUID );
|
||||
} catch (Exception $e) {
|
||||
$result->success = false;
|
||||
$result->msg = $e->getMessage();
|
||||
}
|
||||
print G::json_encode( $result );
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* processes_DownloadFile.php
|
||||
*
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -12,26 +12,25 @@
|
||||
*
|
||||
* 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
|
||||
* 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.,
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
//add more security, and catch any error or exception
|
||||
|
||||
$sFileName = $_GET['p'] . '.pm';
|
||||
$file=PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName.'tpm';
|
||||
$filex=PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName;
|
||||
|
||||
if(file_exists($file))
|
||||
{
|
||||
rename($file, $filex);
|
||||
}
|
||||
|
||||
$realPath = PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName;
|
||||
G::streamFile ( $realPath, true );
|
||||
//add more security, and catch any error or exception
|
||||
|
||||
|
||||
$sFileName = $_GET['p'] . '.pm';
|
||||
$file = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName . 'tpm';
|
||||
$filex = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
|
||||
|
||||
if (file_exists( $file )) {
|
||||
rename( $file, $filex );
|
||||
}
|
||||
|
||||
$realPath = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
|
||||
G::streamFile( $realPath, true );
|
||||
|
||||
@@ -1,37 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* processes_DownloadFile.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
//add more security, and catch any error or exception
|
||||
|
||||
$sFileName = $_GET['p'] . '.xpdl';
|
||||
$file=PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName.'tpm';
|
||||
$filex=PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName;
|
||||
|
||||
if(file_exists($file))
|
||||
{
|
||||
rename($file, $filex);
|
||||
}
|
||||
|
||||
$realPath = PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName;
|
||||
G::streamFile ( $realPath, true );
|
||||
<?php
|
||||
/**
|
||||
* processes_DownloadFile.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
//add more security, and catch any error or exception
|
||||
|
||||
|
||||
$sFileName = $_GET['p'] . '.xpdl';
|
||||
$file = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName . 'tpm';
|
||||
$filex = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
|
||||
|
||||
if (file_exists( $file )) {
|
||||
rename( $file, $filex );
|
||||
}
|
||||
|
||||
$realPath = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
|
||||
G::streamFile( $realPath, true );
|
||||
|
||||
@@ -12,100 +12,94 @@
|
||||
*
|
||||
* 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
|
||||
* 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/>.
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
G::LoadThirdParty('pear/json','class.json');
|
||||
G::LoadThirdParty( 'pear/json', 'class.json' );
|
||||
|
||||
try {
|
||||
function myTruncate($chain, $limit, $break='.', $pad='...') {
|
||||
if (strlen($chain) <= $limit) {
|
||||
return $chain;
|
||||
}
|
||||
$breakpoint = strpos($chain, $break, $limit);
|
||||
if (false !== $breakpoint) {
|
||||
$len =strlen($chain) - 1;
|
||||
if ($breakpoint < $len) {
|
||||
$chain = substr($chain, 0, $breakpoint) . $pad;
|
||||
}
|
||||
}
|
||||
return $chain;
|
||||
}
|
||||
function addTitlle($Category, $Id, $Lang) {
|
||||
require_once 'classes/model/Content.php';
|
||||
$content = new Content();
|
||||
$value = $content->load($Category,'', $Id, $Lang);
|
||||
return $value;
|
||||
}
|
||||
|
||||
$oJSON = new Services_JSON();
|
||||
$stdObj = $oJSON->decode( $_POST['data'] );
|
||||
if ( isset ($stdObj->pro_uid ) )
|
||||
$sProUid = $stdObj->pro_uid;
|
||||
else
|
||||
throw ( new Exception ( 'the process uid is not defined!.' ) );
|
||||
|
||||
/* Includes */
|
||||
G::LoadClass('processes');
|
||||
$oProcess = new Processes();
|
||||
$proFields = $oProcess->serializeProcess( $sProUid );
|
||||
$Fields = $oProcess->saveSerializedProcess ( $proFields );
|
||||
$pathLength = strlen(PATH_DATA ."sites".PATH_SEP.SYS_SYS.PATH_SEP."files".PATH_SEP."output".PATH_SEP);
|
||||
$length = strlen($Fields['PRO_TITLE']) + $pathLength;
|
||||
|
||||
foreach($Fields as $key => $value)
|
||||
{
|
||||
if ($key == 'PRO_TITLE') {
|
||||
$Fields[$key] = myTruncate($value, 65, ' ', '...');
|
||||
function myTruncate ($chain, $limit, $break = '.', $pad = '...')
|
||||
{
|
||||
if (strlen( $chain ) <= $limit) {
|
||||
return $chain;
|
||||
}
|
||||
$breakpoint = strpos( $chain, $break, $limit );
|
||||
if (false !== $breakpoint) {
|
||||
$len = strlen( $chain ) - 1;
|
||||
if ($breakpoint < $len) {
|
||||
$chain = substr( $chain, 0, $breakpoint ) . $pad;
|
||||
}
|
||||
}
|
||||
return $chain;
|
||||
}
|
||||
if ($key == 'FILENAME') {
|
||||
$Fields[$key] = myTruncate($value, 60, '_', '...pm');
|
||||
}
|
||||
if (($length) >= 250) {
|
||||
if ($key == 'FILENAME_LINK') {
|
||||
list($file,$rest) = explode ('p=',$value);
|
||||
list($filenameLink,$rest) = explode ('&',$rest);
|
||||
$Fields[$key] = myTruncate($filenameLink, 250 - $pathLength, '_', '');
|
||||
$Fields[$key] = $file."p=".$Fields[$key].'&'.$rest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Render page */
|
||||
if (isset($_REQUEST["processMap"]) && $_REQUEST["processMap"] == 1) {
|
||||
function addTitlle ($Category, $Id, $Lang)
|
||||
{
|
||||
require_once 'classes/model/Content.php';
|
||||
$content = new Content();
|
||||
$value = $content->load( $Category, '', $Id, $Lang );
|
||||
return $value;
|
||||
}
|
||||
|
||||
$oJSON = new Services_JSON();
|
||||
$stdObj = $oJSON->decode( $_POST['data'] );
|
||||
if (isset( $stdObj->pro_uid ))
|
||||
$sProUid = $stdObj->pro_uid;
|
||||
else
|
||||
throw (new Exception( 'the process uid is not defined!.' ));
|
||||
|
||||
/* Includes */
|
||||
G::LoadClass( 'processes' );
|
||||
$oProcess = new Processes();
|
||||
$proFields = $oProcess->serializeProcess( $sProUid );
|
||||
$Fields = $oProcess->saveSerializedProcess( $proFields );
|
||||
$pathLength = strlen( PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP );
|
||||
$length = strlen( $Fields['PRO_TITLE'] ) + $pathLength;
|
||||
|
||||
foreach ($Fields as $key => $value) {
|
||||
if ($key == 'PRO_TITLE') {
|
||||
$Fields[$key] = myTruncate( $value, 65, ' ', '...' );
|
||||
}
|
||||
if ($key == 'FILENAME') {
|
||||
$Fields[$key] = myTruncate( $value, 60, '_', '...pm' );
|
||||
}
|
||||
if (($length) >= 250) {
|
||||
if ($key == 'FILENAME_LINK') {
|
||||
list ($file, $rest) = explode( 'p=', $value );
|
||||
list ($filenameLink, $rest) = explode( '&', $rest );
|
||||
$Fields[$key] = myTruncate( $filenameLink, 250 - $pathLength, '_', '' );
|
||||
$Fields[$key] = $file . "p=" . $Fields[$key] . '&' . $rest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Render page */
|
||||
if (isset( $_REQUEST["processMap"] ) && $_REQUEST["processMap"] == 1) {
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent( "xmlform", "xmlform", "processes/processes_Export", "", $Fields );
|
||||
|
||||
G::RenderPage( "publish", "raw" );
|
||||
} else {
|
||||
$xmlFrm = new XmlForm();
|
||||
$xmlFrm->home = PATH_XMLFORM . "processes" . PATH_SEP;
|
||||
$xmlFrm->parseFile( "processes_Export.xml", SYS_LANG, true );
|
||||
|
||||
$Fields["xmlFrmFieldLabel"] = array ("title" => $xmlFrm->fields["TITLE"]->label,"proTitle" => $xmlFrm->fields["PRO_TITLE"]->label,"proDescription" => $xmlFrm->fields["PRO_DESCRIPTION"]->label,"size" => $xmlFrm->fields["SIZE"]->label,"fileName" => $xmlFrm->fields["FILENAME_LABEL"]->label
|
||||
);
|
||||
|
||||
echo G::json_encode( $Fields );
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent("xmlform", "xmlform", "processes/processes_Export", "", $Fields);
|
||||
|
||||
G::RenderPage("publish", "raw");
|
||||
}
|
||||
else {
|
||||
$xmlFrm = new XmlForm();
|
||||
$xmlFrm->home = PATH_XMLFORM . "processes" . PATH_SEP;
|
||||
$xmlFrm->parseFile("processes_Export.xml" , SYS_LANG, true);
|
||||
|
||||
$Fields["xmlFrmFieldLabel"] = array(
|
||||
"title" => $xmlFrm->fields["TITLE"]->label,
|
||||
"proTitle" => $xmlFrm->fields["PRO_TITLE"]->label,
|
||||
"proDescription" => $xmlFrm->fields["PRO_DESCRIPTION"]->label,
|
||||
"size" => $xmlFrm->fields["SIZE"]->label,
|
||||
"fileName" => $xmlFrm->fields["FILENAME_LABEL"]->label
|
||||
);
|
||||
|
||||
echo G::json_encode($Fields);
|
||||
}
|
||||
}
|
||||
catch ( Exception $e ){
|
||||
$G_PUBLISH = new Publisher;
|
||||
$aMessage['MESSAGE'] = $e->getMessage();
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
|
||||
G::RenderPage('publish', 'raw' );
|
||||
$aMessage['MESSAGE'] = $e->getMessage();
|
||||
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
|
||||
G::RenderPage( 'publish', 'raw' );
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<?php
|
||||
<?php
|
||||
switch ($_GET['MAIN_DIRECTORY']) {
|
||||
case 'mailTemplates':
|
||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $_GET['PRO_UID'] . PATH_SEP . ($_GET['CURRENT_DIRECTORY'] != '' ? $_GET['CURRENT_DIRECTORY'] . PATH_SEP : '');
|
||||
break;
|
||||
case 'public':
|
||||
$sDirectory = PATH_DATA_PUBLIC . $_GET['PRO_UID'] . PATH_SEP . ($_GET['CURRENT_DIRECTORY'] != '' ? $_GET['CURRENT_DIRECTORY'] . PATH_SEP : '');
|
||||
break;
|
||||
default:
|
||||
die;
|
||||
break;
|
||||
}
|
||||
//fixed: added a file extension when is a javascript file by krlos
|
||||
$_GET['FILE'] .= ($_GET['sFilextension']!='' && $_GET['sFilextension']=='javascript')?'.js':'';
|
||||
|
||||
if (file_exists($sDirectory . $_GET['FILE'])) {
|
||||
G::streamFile($sDirectory . $_GET['FILE'], true);
|
||||
case 'mailTemplates':
|
||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $_GET['PRO_UID'] . PATH_SEP . ($_GET['CURRENT_DIRECTORY'] != '' ? $_GET['CURRENT_DIRECTORY'] . PATH_SEP : '');
|
||||
break;
|
||||
case 'public':
|
||||
$sDirectory = PATH_DATA_PUBLIC . $_GET['PRO_UID'] . PATH_SEP . ($_GET['CURRENT_DIRECTORY'] != '' ? $_GET['CURRENT_DIRECTORY'] . PATH_SEP : '');
|
||||
break;
|
||||
default:
|
||||
die();
|
||||
break;
|
||||
}
|
||||
//fixed: added a file extension when is a javascript file by krlos
|
||||
$_GET['FILE'] .= ($_GET['sFilextension'] != '' && $_GET['sFilextension'] == 'javascript') ? '.js' : '';
|
||||
|
||||
if (file_exists( $sDirectory . $_GET['FILE'] )) {
|
||||
G::streamFile( $sDirectory . $_GET['FILE'], true );
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* processes_Import.php
|
||||
*
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -12,54 +12,51 @@
|
||||
*
|
||||
* 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
|
||||
* 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.,
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
$access = $RBAC->userCanAccess('PM_FACTORY');
|
||||
if( $access != 1 ){
|
||||
switch ($access)
|
||||
{
|
||||
case -1:
|
||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
||||
G::header('location: ../login/login');
|
||||
die;
|
||||
break;
|
||||
case -2:
|
||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
|
||||
G::header('location: ../login/login');
|
||||
die;
|
||||
break;
|
||||
default:
|
||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
||||
G::header('location: ../login/login');
|
||||
die;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$access = $RBAC->userCanAccess( 'PM_FACTORY' );
|
||||
if ($access != 1) {
|
||||
switch ($access) {
|
||||
case - 1:
|
||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
|
||||
G::header( 'location: ../login/login' );
|
||||
die();
|
||||
break;
|
||||
case - 2:
|
||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
|
||||
G::header( 'location: ../login/login' );
|
||||
die();
|
||||
break;
|
||||
default:
|
||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
|
||||
G::header( 'location: ../login/login' );
|
||||
die();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
/* Includes */
|
||||
G::LoadClass('processes');
|
||||
|
||||
/* Render page */
|
||||
$G_MAIN_MENU = 'processmaker';
|
||||
$G_ID_MENU_SELECTED = 'PROCESSES';
|
||||
$G_PUBLISH = new Publisher;
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_Import', '', NULL, 'processes_ImportFile' );
|
||||
G::RenderPage( "publish", "blank");
|
||||
/* Includes */
|
||||
G::LoadClass( 'processes' );
|
||||
|
||||
}
|
||||
catch ( Exception $e ){
|
||||
$G_PUBLISH = new Publisher;
|
||||
$aMessage['MESSAGE'] = $e->getMessage();
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
|
||||
G::RenderPage('publish', "blank");
|
||||
}
|
||||
/* Render page */
|
||||
$G_MAIN_MENU = 'processmaker';
|
||||
$G_ID_MENU_SELECTED = 'PROCESSES';
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'processes/processes_Import', '', NULL, 'processes_ImportFile' );
|
||||
G::RenderPage( "publish", "blank" );
|
||||
|
||||
} catch (Exception $e) {
|
||||
$G_PUBLISH = new Publisher();
|
||||
$aMessage['MESSAGE'] = $e->getMessage();
|
||||
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
|
||||
G::RenderPage( 'publish', "blank" );
|
||||
}
|
||||
|
||||
@@ -12,327 +12,311 @@
|
||||
*
|
||||
* 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
|
||||
* 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/>.
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
ini_set('max_execution_time', '0');
|
||||
ini_set( 'max_execution_time', '0' );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function reservedWordsSqlValidate($data)
|
||||
function reservedWordsSqlValidate ($data)
|
||||
{
|
||||
$arrayAux = array();
|
||||
$arrayAux = array ();
|
||||
$reservedWordsSql = G::reservedWordsSql();
|
||||
|
||||
foreach ($data->reportTables as $rptIndex => $rptValue) {
|
||||
if (in_array(strtoupper($rptValue["REP_TAB_NAME"]), $reservedWordsSql)) {
|
||||
if (in_array( strtoupper( $rptValue["REP_TAB_NAME"] ), $reservedWordsSql )) {
|
||||
$arrayAux[] = $rptValue["REP_TAB_NAME"];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($arrayAux) > 0) {
|
||||
throw (new Exception(G::LoadTranslation("ID_PMTABLE_INVALID_NAME", array(implode(", ", $arrayAux)))));
|
||||
if (count( $arrayAux ) > 0) {
|
||||
throw (new Exception( G::LoadTranslation( "ID_PMTABLE_INVALID_NAME", array (implode( ", ", $arrayAux )
|
||||
) ) ));
|
||||
}
|
||||
|
||||
$arrayAux = array();
|
||||
$arrayAux = array ();
|
||||
|
||||
foreach ($data->reportTablesVars as $rptIndex => $rptValue) {
|
||||
if (in_array(strtoupper($rptValue["REP_VAR_NAME"]), $reservedWordsSql)) {
|
||||
if (in_array( strtoupper( $rptValue["REP_VAR_NAME"] ), $reservedWordsSql )) {
|
||||
$arrayAux[] = $rptValue["REP_VAR_NAME"];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($arrayAux) > 0) {
|
||||
throw (new Exception(G::LoadTranslation("ID_PMTABLE_INVALID_FIELD_NAME", array(implode(", ", $arrayAux)))));
|
||||
if (count( $arrayAux ) > 0) {
|
||||
throw (new Exception( G::LoadTranslation( "ID_PMTABLE_INVALID_FIELD_NAME", array (implode( ", ", $arrayAux )
|
||||
) ) ));
|
||||
}
|
||||
}
|
||||
|
||||
$action = isset( $_REQUEST['ajaxAction'] ) ? $_REQUEST['ajaxAction'] : null;
|
||||
|
||||
$result = new stdClass();
|
||||
$result->success = true;
|
||||
$result->catchMessage = "";
|
||||
|
||||
|
||||
|
||||
$action = isset($_REQUEST['ajaxAction']) ? $_REQUEST['ajaxAction'] : null;
|
||||
|
||||
$result = new stdClass();
|
||||
$result->success = true;
|
||||
$result->catchMessage = "";
|
||||
|
||||
if ( $action == "uploadFileNewProcess") {
|
||||
if ($action == "uploadFileNewProcess") {
|
||||
try {
|
||||
//type of file, bpmn, xpdl, or pm
|
||||
$processFileType = $_REQUEST["processFileType"];
|
||||
$oProcess = new stdClass();
|
||||
$oData = new stdClass();
|
||||
//type of file, bpmn, xpdl, or pm
|
||||
$processFileType = $_REQUEST["processFileType"];
|
||||
$oProcess = new stdClass();
|
||||
$oData = new stdClass();
|
||||
|
||||
$isCorrectTypeFile = 1;
|
||||
$isCorrectTypeFile = 1;
|
||||
|
||||
if ( isset($_FILES['form']['type']['PROCESS_FILENAME']) ) {
|
||||
$allowedExtensions = array($processFileType);
|
||||
$allowedExtensions = array( 'xpdl', 'bpmn', 'pm');
|
||||
if (!in_array(end(explode(".", $_FILES['form']['name']['PROCESS_FILENAME'])), $allowedExtensions)) {
|
||||
throw new Exception(G::LoadTranslation("ID_FILE_UPLOAD_INCORRECT_EXTENSION"));
|
||||
if (isset( $_FILES['form']['type']['PROCESS_FILENAME'] )) {
|
||||
$allowedExtensions = array ($processFileType
|
||||
);
|
||||
$allowedExtensions = array ('xpdl','bpmn','pm'
|
||||
);
|
||||
if (! in_array( end( explode( ".", $_FILES['form']['name']['PROCESS_FILENAME'] ) ), $allowedExtensions )) {
|
||||
throw new Exception( G::LoadTranslation( "ID_FILE_UPLOAD_INCORRECT_EXTENSION" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($processFileType != "pm" && $processFileType != "xpdl" && $processFileType != "bpmn" ) {
|
||||
throw new Exception(G::LoadTranslation("ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR"));
|
||||
}
|
||||
|
||||
if ($processFileType == "pm") {
|
||||
G::LoadClass('processes');
|
||||
$oProcess = new Processes();
|
||||
}
|
||||
|
||||
if ($processFileType == "xpdl") {
|
||||
G::LoadClass('xpdl');
|
||||
$oProcess = new Xpdl();
|
||||
}
|
||||
|
||||
$result->success = true;
|
||||
$result->ExistProcessInDatabase = ""; //"" -Default
|
||||
//0 -Dont exist process
|
||||
//1 -exist process
|
||||
$result->ExistGroupsInDatabase = ""; //"" -Default
|
||||
//0 -Dont exist process
|
||||
//1 -exist process
|
||||
$optionGroupExistInDatabase = isset($_REQUEST["optionGroupExistInDatabase"]) ? $_REQUEST["optionGroupExistInDatabase"] : null;
|
||||
|
||||
//!Upload file
|
||||
if ( ! is_null($optionGroupExistInDatabase)) {
|
||||
$filename = $_REQUEST["PRO_FILENAME"];
|
||||
$path = PATH_DOCUMENT . 'input' . PATH_SEP ;
|
||||
}
|
||||
else {
|
||||
if ($_FILES['form']['error']['PROCESS_FILENAME'] == 0){
|
||||
$filename = $_FILES['form']['name']['PROCESS_FILENAME'];
|
||||
$path = PATH_DOCUMENT . 'input' . PATH_SEP ;
|
||||
$tempName = $_FILES['form']['tmp_name']['PROCESS_FILENAME'];
|
||||
//$action = "none";
|
||||
G::uploadFile($tempName, $path, $filename );
|
||||
if ($processFileType != "pm" && $processFileType != "xpdl" && $processFileType != "bpmn") {
|
||||
throw new Exception( G::LoadTranslation( "ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR" ) );
|
||||
}
|
||||
}
|
||||
|
||||
//importing a bpmn diagram, using external class to do it.
|
||||
if ($processFileType == "bpmn") {
|
||||
G::LoadClass('bpmnExport');
|
||||
$bpmn = new bpmnExport();
|
||||
$bpmn->importBpmn( $path . $filename);
|
||||
die;
|
||||
}
|
||||
|
||||
//if file is a .pm or .xpdl file continues normally the importing
|
||||
if ($processFileType == "pm") {
|
||||
$oData = $oProcess->getProcessData ( $path . $filename );
|
||||
}
|
||||
else {
|
||||
$oData = $oProcess->getProcessDataXpdl ( $path . $filename );
|
||||
}
|
||||
|
||||
reservedWordsSqlValidate($oData);
|
||||
|
||||
//!Upload file
|
||||
$Fields['PRO_FILENAME'] = $filename;
|
||||
$Fields['IMPORT_OPTION'] = 2;
|
||||
|
||||
$sProUid = $oData->process['PRO_UID'];
|
||||
|
||||
$oData->process['PRO_UID_OLD'] = $sProUid;
|
||||
|
||||
if ( $oProcess->processExists ( $sProUid ) ) {
|
||||
$result->ExistProcessInDatabase = 1;
|
||||
}
|
||||
else {
|
||||
$result->ExistProcessInDatabase = 0;
|
||||
}
|
||||
|
||||
//!respect of the groups
|
||||
$result->ExistGroupsInDatabase = 1;
|
||||
$result->groupBeforeAccion = $action;
|
||||
if (!is_null($optionGroupExistInDatabase)) {
|
||||
if ($optionGroupExistInDatabase == 1) {
|
||||
$oData->groupwfs = $oProcess->renameExistingGroups($oData->groupwfs);
|
||||
}
|
||||
else if ($optionGroupExistInDatabase == 2) {
|
||||
$oBaseGroup = $oData->groupwfs;
|
||||
$oNewGroup = $oProcess->mergeExistingGroups($oData->groupwfs);
|
||||
$oData->groupwfs = $oNewGroup;
|
||||
$oData->taskusers = $oProcess->mergeExistingUsers($oBaseGroup, $oNewGroup, $oData->taskusers);
|
||||
}
|
||||
$result->ExistGroupsInDatabase = 0;
|
||||
}
|
||||
else {
|
||||
if ( !($oProcess->checkExistingGroups($oData->groupwfs) > 0) ) {
|
||||
$result->ExistGroupsInDatabase = 0;
|
||||
}
|
||||
}
|
||||
//!respect of the groups
|
||||
|
||||
if ($result->ExistProcessInDatabase == 0 && $result->ExistGroupsInDatabase == 0){
|
||||
if ($processFileType == "pm") {
|
||||
$oProcess->createProcessFromData ($oData, $path . $filename );
|
||||
G::LoadClass( 'processes' );
|
||||
$oProcess = new Processes();
|
||||
}
|
||||
else {
|
||||
if ( !isset( $oData->tasks) ) $oData->tasks = array();
|
||||
$tasks = $oData->tasks;
|
||||
$oProcess->createProcessFromDataXpdl ($oData,$tasks);
|
||||
|
||||
if ($processFileType == "xpdl") {
|
||||
G::LoadClass( 'xpdl' );
|
||||
$oProcess = new Xpdl();
|
||||
}
|
||||
}
|
||||
|
||||
//!data ouput
|
||||
$result->sNewProUid = $sProUid;
|
||||
$result->proFileName = $Fields['PRO_FILENAME'];
|
||||
}
|
||||
catch (Exception $e ) {
|
||||
$result->response = $e->getMessage();
|
||||
$result->catchMessage = $e->getMessage();
|
||||
$result->success = true;
|
||||
}
|
||||
}
|
||||
$result->success = true;
|
||||
$result->ExistProcessInDatabase = ""; //"" -Default
|
||||
//0 -Dont exist process
|
||||
//1 -exist process
|
||||
$result->ExistGroupsInDatabase = ""; //"" -Default
|
||||
//0 -Dont exist process
|
||||
//1 -exist process
|
||||
$optionGroupExistInDatabase = isset( $_REQUEST["optionGroupExistInDatabase"] ) ? $_REQUEST["optionGroupExistInDatabase"] : null;
|
||||
|
||||
if ($action == "uploadFileNewProcessExist") {
|
||||
//!Upload file
|
||||
if (! is_null( $optionGroupExistInDatabase )) {
|
||||
$filename = $_REQUEST["PRO_FILENAME"];
|
||||
$path = PATH_DOCUMENT . 'input' . PATH_SEP;
|
||||
} else {
|
||||
if ($_FILES['form']['error']['PROCESS_FILENAME'] == 0) {
|
||||
$filename = $_FILES['form']['name']['PROCESS_FILENAME'];
|
||||
$path = PATH_DOCUMENT . 'input' . PATH_SEP;
|
||||
$tempName = $_FILES['form']['tmp_name']['PROCESS_FILENAME'];
|
||||
//$action = "none";
|
||||
G::uploadFile( $tempName, $path, $filename );
|
||||
}
|
||||
}
|
||||
|
||||
//importing a bpmn diagram, using external class to do it.
|
||||
if ($processFileType == "bpmn") {
|
||||
G::LoadClass( 'bpmnExport' );
|
||||
$bpmn = new bpmnExport();
|
||||
$bpmn->importBpmn( $path . $filename );
|
||||
die();
|
||||
}
|
||||
|
||||
//if file is a .pm or .xpdl file continues normally the importing
|
||||
if ($processFileType == "pm") {
|
||||
$oData = $oProcess->getProcessData( $path . $filename );
|
||||
} else {
|
||||
$oData = $oProcess->getProcessDataXpdl( $path . $filename );
|
||||
}
|
||||
|
||||
reservedWordsSqlValidate( $oData );
|
||||
|
||||
//!Upload file
|
||||
$Fields['PRO_FILENAME'] = $filename;
|
||||
$Fields['IMPORT_OPTION'] = 2;
|
||||
|
||||
$sProUid = $oData->process['PRO_UID'];
|
||||
|
||||
$oData->process['PRO_UID_OLD'] = $sProUid;
|
||||
|
||||
if ($oProcess->processExists( $sProUid )) {
|
||||
$result->ExistProcessInDatabase = 1;
|
||||
} else {
|
||||
$result->ExistProcessInDatabase = 0;
|
||||
}
|
||||
|
||||
//!respect of the groups
|
||||
$result->ExistGroupsInDatabase = 1;
|
||||
$result->groupBeforeAccion = $action;
|
||||
if (! is_null( $optionGroupExistInDatabase )) {
|
||||
if ($optionGroupExistInDatabase == 1) {
|
||||
$oData->groupwfs = $oProcess->renameExistingGroups( $oData->groupwfs );
|
||||
} else if ($optionGroupExistInDatabase == 2) {
|
||||
$oBaseGroup = $oData->groupwfs;
|
||||
$oNewGroup = $oProcess->mergeExistingGroups( $oData->groupwfs );
|
||||
$oData->groupwfs = $oNewGroup;
|
||||
$oData->taskusers = $oProcess->mergeExistingUsers( $oBaseGroup, $oNewGroup, $oData->taskusers );
|
||||
}
|
||||
$result->ExistGroupsInDatabase = 0;
|
||||
} else {
|
||||
if (! ($oProcess->checkExistingGroups( $oData->groupwfs ) > 0)) {
|
||||
$result->ExistGroupsInDatabase = 0;
|
||||
}
|
||||
}
|
||||
//!respect of the groups
|
||||
|
||||
|
||||
if ($result->ExistProcessInDatabase == 0 && $result->ExistGroupsInDatabase == 0) {
|
||||
if ($processFileType == "pm") {
|
||||
$oProcess->createProcessFromData( $oData, $path . $filename );
|
||||
} else {
|
||||
if (! isset( $oData->tasks ))
|
||||
$oData->tasks = array ();
|
||||
$tasks = $oData->tasks;
|
||||
$oProcess->createProcessFromDataXpdl( $oData, $tasks );
|
||||
}
|
||||
}
|
||||
|
||||
//!data ouput
|
||||
$result->sNewProUid = $sProUid;
|
||||
$result->proFileName = $Fields['PRO_FILENAME'];
|
||||
} catch (Exception $e) {
|
||||
$result->response = $e->getMessage();
|
||||
$result->catchMessage = $e->getMessage();
|
||||
$result->success = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == "uploadFileNewProcessExist") {
|
||||
try {
|
||||
$option = $_REQUEST["IMPORT_OPTION"];
|
||||
$filename = $_REQUEST["PRO_FILENAME"];
|
||||
$processFileType = $_REQUEST["processFileType"];
|
||||
$option = $_REQUEST["IMPORT_OPTION"];
|
||||
$filename = $_REQUEST["PRO_FILENAME"];
|
||||
$processFileType = $_REQUEST["processFileType"];
|
||||
|
||||
$result->ExistGroupsInDatabase = ""; //"" -Default
|
||||
//0 -Dont exist process
|
||||
//1 -exist process
|
||||
$result->ExistGroupsInDatabase = ""; //"" -Default
|
||||
//0 -Dont exist process
|
||||
//1 -exist process
|
||||
|
||||
$optionGroupExistInDatabase = isset($_REQUEST["optionGroupExistInDatabase"]) ? $_REQUEST["optionGroupExistInDatabase"] : null;
|
||||
$sNewProUid = "";
|
||||
|
||||
$oProcess = new stdClass();
|
||||
if ($processFileType != "pm" && $processFileType != "xpdl") {
|
||||
throw new Exception(G::LoadTranslation("ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR"));
|
||||
}
|
||||
$optionGroupExistInDatabase = isset( $_REQUEST["optionGroupExistInDatabase"] ) ? $_REQUEST["optionGroupExistInDatabase"] : null;
|
||||
$sNewProUid = "";
|
||||
|
||||
//load the variables
|
||||
if ($processFileType == "pm") {
|
||||
G::LoadClass('processes');
|
||||
$oProcess = new Processes();
|
||||
}
|
||||
else {
|
||||
G::LoadClass('xpdl');
|
||||
$oProcess = new Xpdl();
|
||||
}
|
||||
|
||||
$path = PATH_DOCUMENT . 'input' . PATH_SEP ;
|
||||
|
||||
if ($processFileType == "pm"){
|
||||
$oData = $oProcess->getProcessData ( $path . $filename );
|
||||
}
|
||||
else {
|
||||
$oData = $oProcess->getProcessDataXpdl ( $path . $filename );
|
||||
}
|
||||
|
||||
reservedWordsSqlValidate($oData);
|
||||
|
||||
$Fields['PRO_FILENAME'] = $filename;
|
||||
$sProUid = $oData->process['PRO_UID'];
|
||||
|
||||
$oData->process['PRO_UID_OLD'] = $sProUid;
|
||||
|
||||
$result->ExistGroupsInDatabase = 1;
|
||||
if ( !is_null($optionGroupExistInDatabase)) {
|
||||
if ($optionGroupExistInDatabase == 1){
|
||||
$oData->groupwfs = $oProcess->renameExistingGroups($oData->groupwfs);
|
||||
$oProcess = new stdClass();
|
||||
if ($processFileType != "pm" && $processFileType != "xpdl") {
|
||||
throw new Exception( G::LoadTranslation( "ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR" ) );
|
||||
}
|
||||
else if ($optionGroupExistInDatabase == 2) {
|
||||
$oBaseGroup = $oData->groupwfs;
|
||||
$oNewGroup = $oProcess->mergeExistingGroups($oData->groupwfs);
|
||||
$oData->groupwfs = $oNewGroup;
|
||||
$oData->taskusers = $oProcess->mergeExistingUsers($oBaseGroup, $oNewGroup, $oData->taskusers);
|
||||
}
|
||||
$result->ExistGroupsInDatabase = 0;
|
||||
}
|
||||
else {
|
||||
if ( !($oProcess->checkExistingGroups($oData->groupwfs) > 0) ) {
|
||||
$result->ExistGroupsInDatabase = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($result->ExistGroupsInDatabase == 0) {
|
||||
//Update the current Process, overwriting all tasks and steps
|
||||
if ( $option == 1 ) {
|
||||
$oProcess->updateProcessFromData ($oData, $path . $filename );
|
||||
if (file_exists(PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid)) {
|
||||
$oDirectory = dir(PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid);
|
||||
while ($sObjectName = $oDirectory->read()) {
|
||||
if (($sObjectName != '.') && ($sObjectName != '..')) {
|
||||
unlink(PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid . PATH_SEP . $sObjectName);
|
||||
}
|
||||
//load the variables
|
||||
if ($processFileType == "pm") {
|
||||
G::LoadClass( 'processes' );
|
||||
$oProcess = new Processes();
|
||||
} else {
|
||||
G::LoadClass( 'xpdl' );
|
||||
$oProcess = new Xpdl();
|
||||
}
|
||||
|
||||
$path = PATH_DOCUMENT . 'input' . PATH_SEP;
|
||||
|
||||
if ($processFileType == "pm") {
|
||||
$oData = $oProcess->getProcessData( $path . $filename );
|
||||
} else {
|
||||
$oData = $oProcess->getProcessDataXpdl( $path . $filename );
|
||||
}
|
||||
|
||||
reservedWordsSqlValidate( $oData );
|
||||
|
||||
$Fields['PRO_FILENAME'] = $filename;
|
||||
$sProUid = $oData->process['PRO_UID'];
|
||||
|
||||
$oData->process['PRO_UID_OLD'] = $sProUid;
|
||||
|
||||
$result->ExistGroupsInDatabase = 1;
|
||||
if (! is_null( $optionGroupExistInDatabase )) {
|
||||
if ($optionGroupExistInDatabase == 1) {
|
||||
$oData->groupwfs = $oProcess->renameExistingGroups( $oData->groupwfs );
|
||||
} else if ($optionGroupExistInDatabase == 2) {
|
||||
$oBaseGroup = $oData->groupwfs;
|
||||
$oNewGroup = $oProcess->mergeExistingGroups( $oData->groupwfs );
|
||||
$oData->groupwfs = $oNewGroup;
|
||||
$oData->taskusers = $oProcess->mergeExistingUsers( $oBaseGroup, $oNewGroup, $oData->taskusers );
|
||||
}
|
||||
$oDirectory->close();
|
||||
}
|
||||
$sNewProUid = $sProUid;
|
||||
}
|
||||
|
||||
//Disable current Process and create a new version of the Process
|
||||
if ( $option == 2 ) {
|
||||
$oProcess->disablePreviousProcesses( $sProUid );
|
||||
$sNewProUid = $oProcess->getUnusedProcessGUID() ;
|
||||
$oProcess->setProcessGuid ( $oData, $sNewProUid );
|
||||
$oProcess->setProcessParent( $oData, $sProUid );
|
||||
$oData->process['PRO_TITLE'] = "New - " . $oData->process['PRO_TITLE'] . ' - ' . date ( 'M d, H:i' );
|
||||
$oProcess->renewAll ( $oData );
|
||||
|
||||
if ($processFileType == "pm") {
|
||||
$oProcess->createProcessFromData ($oData, $path . $filename );
|
||||
}
|
||||
else {
|
||||
if ( !isset( $oData->tasks) ) {
|
||||
$oData->tasks = array();
|
||||
$result->ExistGroupsInDatabase = 0;
|
||||
} else {
|
||||
if (! ($oProcess->checkExistingGroups( $oData->groupwfs ) > 0)) {
|
||||
$result->ExistGroupsInDatabase = 0;
|
||||
}
|
||||
$tasks = $oData->tasks;
|
||||
$oProcess->createProcessFromDataXpdl ($oData,$tasks);
|
||||
}
|
||||
}
|
||||
|
||||
//Create a completely new Process without change the current Process
|
||||
if ( $option == 3 ) {
|
||||
//krumo ($oData); die;
|
||||
$sNewProUid = $oProcess->getUnusedProcessGUID() ;
|
||||
$oProcess->setProcessGuid ( $oData, $sNewProUid );
|
||||
$oData->process['PRO_TITLE'] = "Copy of - " . $oData->process['PRO_TITLE'] . ' - ' . date ( 'M d, H:i' );
|
||||
$oProcess->renewAll ( $oData );
|
||||
|
||||
if ($processFileType == "pm"){
|
||||
$oProcess->createProcessFromData ($oData, $path . $filename );
|
||||
}
|
||||
else {
|
||||
if ( !isset( $oData->tasks) ) {
|
||||
$oData->tasks = array();
|
||||
if ($result->ExistGroupsInDatabase == 0) {
|
||||
//Update the current Process, overwriting all tasks and steps
|
||||
if ($option == 1) {
|
||||
$oProcess->updateProcessFromData( $oData, $path . $filename );
|
||||
if (file_exists( PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid )) {
|
||||
$oDirectory = dir( PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid );
|
||||
while ($sObjectName = $oDirectory->read()) {
|
||||
if (($sObjectName != '.') && ($sObjectName != '..')) {
|
||||
unlink( PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid . PATH_SEP . $sObjectName );
|
||||
}
|
||||
}
|
||||
$oDirectory->close();
|
||||
}
|
||||
$sNewProUid = $sProUid;
|
||||
}
|
||||
$tasks = $oData->tasks;
|
||||
$oProcess->createProcessFromDataXpdl ($oData,$tasks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//!data ouput
|
||||
$result->fileName = $filename;
|
||||
$result->importOption = $option;
|
||||
$result->sNewProUid = $sNewProUid;
|
||||
$result->success = true;
|
||||
$result->ExistGroupsInDatabase = $result->ExistGroupsInDatabase;
|
||||
$result->groupBeforeAccion = $action;
|
||||
//!data ouput
|
||||
//Disable current Process and create a new version of the Process
|
||||
if ($option == 2) {
|
||||
$oProcess->disablePreviousProcesses( $sProUid );
|
||||
$sNewProUid = $oProcess->getUnusedProcessGUID();
|
||||
$oProcess->setProcessGuid( $oData, $sNewProUid );
|
||||
$oProcess->setProcessParent( $oData, $sProUid );
|
||||
$oData->process['PRO_TITLE'] = "New - " . $oData->process['PRO_TITLE'] . ' - ' . date( 'M d, H:i' );
|
||||
$oProcess->renewAll( $oData );
|
||||
|
||||
if ($processFileType == "pm") {
|
||||
$oProcess->createProcessFromData( $oData, $path . $filename );
|
||||
} else {
|
||||
if (! isset( $oData->tasks )) {
|
||||
$oData->tasks = array ();
|
||||
}
|
||||
$tasks = $oData->tasks;
|
||||
$oProcess->createProcessFromDataXpdl( $oData, $tasks );
|
||||
}
|
||||
}
|
||||
|
||||
//Create a completely new Process without change the current Process
|
||||
if ($option == 3) {
|
||||
//krumo ($oData); die;
|
||||
$sNewProUid = $oProcess->getUnusedProcessGUID();
|
||||
$oProcess->setProcessGuid( $oData, $sNewProUid );
|
||||
$oData->process['PRO_TITLE'] = "Copy of - " . $oData->process['PRO_TITLE'] . ' - ' . date( 'M d, H:i' );
|
||||
$oProcess->renewAll( $oData );
|
||||
|
||||
if ($processFileType == "pm") {
|
||||
$oProcess->createProcessFromData( $oData, $path . $filename );
|
||||
} else {
|
||||
if (! isset( $oData->tasks )) {
|
||||
$oData->tasks = array ();
|
||||
}
|
||||
$tasks = $oData->tasks;
|
||||
$oProcess->createProcessFromDataXpdl( $oData, $tasks );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//!data ouput
|
||||
$result->fileName = $filename;
|
||||
$result->importOption = $option;
|
||||
$result->sNewProUid = $sNewProUid;
|
||||
$result->success = true;
|
||||
$result->ExistGroupsInDatabase = $result->ExistGroupsInDatabase;
|
||||
$result->groupBeforeAccion = $action;
|
||||
//!data ouput
|
||||
} catch (Exception $e) {
|
||||
$result->response = $e->getMessage();
|
||||
$result->success = true;
|
||||
}
|
||||
catch (Exception $e ) {
|
||||
$result->response = $e->getMessage();
|
||||
$result->success = true;
|
||||
}
|
||||
}
|
||||
|
||||
echo G::json_encode($result);
|
||||
exit();
|
||||
}
|
||||
|
||||
echo G::json_encode( $result );
|
||||
exit();
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* processes_checkProperties.php
|
||||
*
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -12,79 +12,77 @@
|
||||
*
|
||||
* 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
|
||||
* 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.,
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
global $RBAC;
|
||||
|
||||
$access = $RBAC->userCanAccess('PM_FACTORY');
|
||||
if( $access != 1 ){
|
||||
switch ($access)
|
||||
{
|
||||
case -1:
|
||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
||||
G::header('location: ../login/login');
|
||||
die;
|
||||
break;
|
||||
case -2:
|
||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
|
||||
G::header('location: ../login/login');
|
||||
die;
|
||||
break;
|
||||
default:
|
||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
||||
G::header('location: ../login/login');
|
||||
die;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$access = $RBAC->userCanAccess( 'PM_FACTORY' );
|
||||
if ($access != 1) {
|
||||
switch ($access) {
|
||||
case - 1:
|
||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
|
||||
G::header( 'location: ../login/login' );
|
||||
die();
|
||||
break;
|
||||
case - 2:
|
||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
|
||||
G::header( 'location: ../login/login' );
|
||||
die();
|
||||
break;
|
||||
default:
|
||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
|
||||
G::header( 'location: ../login/login' );
|
||||
die();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$form = $_POST ['form'];
|
||||
$form = $_POST['form'];
|
||||
|
||||
//$tasUid = $form['TASKS'];
|
||||
//$tasUid = $form['TASKS'];
|
||||
$tasUid = $form['TAS_PARENT'];
|
||||
$spSynchronous = $form['SP_SYNCHRONOUS'];
|
||||
|
||||
require_once 'classes/model/Route.php';
|
||||
require_once 'classes/model/Task.php';
|
||||
|
||||
$oRoute= new Route();
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(RoutePeer::ROU_NEXT_TASK);
|
||||
$oCriteria->add(RoutePeer::TAS_UID, $tasUid);
|
||||
$oDataset = RoutePeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oRoute = new Route();
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( RoutePeer::ROU_NEXT_TASK );
|
||||
$oCriteria->add( RoutePeer::TAS_UID, $tasUid );
|
||||
$oDataset = RoutePeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
$sw=1;
|
||||
// if there are more step we're looking them and we're checking TAS_ASSIGN_TYPE field
|
||||
while ($oDataset->next() && $sw){
|
||||
$aRow = $oDataset->getRow();
|
||||
|
||||
$oCriteria1 = new Criteria('workflow');
|
||||
$oCriteria1->addSelectColumn(TaskPeer::TAS_ASSIGN_TYPE);
|
||||
$oCriteria1->add(TaskPeer::PRO_UID, $form['PRO_PARENT']);
|
||||
$oCriteria1->add(TaskPeer::TAS_UID, $aRow['ROU_NEXT_TASK']);
|
||||
$oDataset1 = TaskPeer::doSelectRS($oCriteria1);
|
||||
$oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset1->next();
|
||||
$aRow1 = $oDataset1->getRow();
|
||||
|
||||
if($spSynchronous && $aRow1['TAS_ASSIGN_TYPE']=='MANUAL')
|
||||
$sw=0;
|
||||
$sw = 1;
|
||||
// if there are more step we're looking them and we're checking TAS_ASSIGN_TYPE field
|
||||
while ($oDataset->next() && $sw) {
|
||||
$aRow = $oDataset->getRow();
|
||||
|
||||
$oCriteria1 = new Criteria( 'workflow' );
|
||||
$oCriteria1->addSelectColumn( TaskPeer::TAS_ASSIGN_TYPE );
|
||||
$oCriteria1->add( TaskPeer::PRO_UID, $form['PRO_PARENT'] );
|
||||
$oCriteria1->add( TaskPeer::TAS_UID, $aRow['ROU_NEXT_TASK'] );
|
||||
$oDataset1 = TaskPeer::doSelectRS( $oCriteria1 );
|
||||
$oDataset1->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset1->next();
|
||||
$aRow1 = $oDataset1->getRow();
|
||||
|
||||
if ($spSynchronous && $aRow1['TAS_ASSIGN_TYPE'] == 'MANUAL')
|
||||
$sw = 0;
|
||||
|
||||
}
|
||||
///If there are at least one TAS_ASSIGN_TYPE field with MANUAL it returns 1
|
||||
if(!$sw)
|
||||
return print $spSynchronous;
|
||||
else
|
||||
return print '0';
|
||||
|
||||
|
||||
///If there are at least one TAS_ASSIGN_TYPE field with MANUAL it returns 1
|
||||
if (! $sw)
|
||||
return print $spSynchronous;
|
||||
else
|
||||
return print '0';
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
<?php
|
||||
sleep(1);
|
||||
|
||||
if(isset($_SESSION['processes_upload'])){
|
||||
$form = $_SESSION['processes_upload'];
|
||||
switch ($form['MAIN_DIRECTORY']) {
|
||||
case 'mailTemplates':
|
||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $form['PRO_UID'] . PATH_SEP . ($form['CURRENT_DIRECTORY'] != '' ? $form['CURRENT_DIRECTORY'] . PATH_SEP : '');
|
||||
break;
|
||||
case 'public':
|
||||
$sDirectory = PATH_DATA_PUBLIC . $form['PRO_UID'] . PATH_SEP . ($form['CURRENT_DIRECTORY'] != '' ? $form['CURRENT_DIRECTORY'] . PATH_SEP : '');
|
||||
break;
|
||||
default:
|
||||
die;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($_FILES['form']['error'] == "0") {
|
||||
G::uploadFile($_FILES['form']['tmp_name'], $sDirectory, $_FILES['form']['name']);
|
||||
$msg = "Uploaded (" . (round((filesize($sDirectory.$_FILES['form']['name'])/1024) * 10) /10) . " kb)";
|
||||
$result = 1;
|
||||
//echo $sDirectory.$_FILES['form']['name'];
|
||||
} else {
|
||||
$msg = "Failed";
|
||||
$result = 0;
|
||||
}
|
||||
|
||||
<?php
|
||||
sleep( 1 );
|
||||
|
||||
if (isset( $_SESSION['processes_upload'] )) {
|
||||
$form = $_SESSION['processes_upload'];
|
||||
switch ($form['MAIN_DIRECTORY']) {
|
||||
case 'mailTemplates':
|
||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $form['PRO_UID'] . PATH_SEP . ($form['CURRENT_DIRECTORY'] != '' ? $form['CURRENT_DIRECTORY'] . PATH_SEP : '');
|
||||
break;
|
||||
case 'public':
|
||||
$sDirectory = PATH_DATA_PUBLIC . $form['PRO_UID'] . PATH_SEP . ($form['CURRENT_DIRECTORY'] != '' ? $form['CURRENT_DIRECTORY'] . PATH_SEP : '');
|
||||
break;
|
||||
default:
|
||||
die();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($_FILES['form']['error'] == "0") {
|
||||
G::uploadFile( $_FILES['form']['tmp_name'], $sDirectory, $_FILES['form']['name'] );
|
||||
$msg = "Uploaded (" . (round( (filesize( $sDirectory . $_FILES['form']['name'] ) / 1024) * 10 ) / 10) . " kb)";
|
||||
$result = 1;
|
||||
//echo $sDirectory.$_FILES['form']['name'];
|
||||
} else {
|
||||
$msg = "Failed";
|
||||
$result = 0;
|
||||
}
|
||||
|
||||
echo "{'result': $result, 'msg':'$msg'}";
|
||||
Reference in New Issue
Block a user