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:
jennylee
2012-10-17 12:03:40 -04:00
parent 7deb103424
commit 27ac82a803
10 changed files with 624 additions and 658 deletions

View File

@@ -12,51 +12,49 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * 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., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/ */
global $RBAC; global $RBAC;
$access = $RBAC->userCanAccess('PM_FACTORY'); $access = $RBAC->userCanAccess( 'PM_FACTORY' );
if( $access != 1 ){ if ($access != 1) {
switch ($access){ switch ($access) {
case -1: case - 1:
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header('location: ../login/login'); G::header( 'location: ../login/login' );
die; die();
break; break;
case -2: case - 2:
default: default:
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels'); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header('location: ../login/login'); G::header( 'location: ../login/login' );
die; die();
break; break;
} }
} }
G::LoadClass('processMap'); G::LoadClass( 'processMap' );
$oProcessMap = new ProcessMap(); $oProcessMap = new ProcessMap();
$UIDS = explode(',', $_POST['PRO_UIDS']); $UIDS = explode( ',', $_POST['PRO_UIDS'] );
try{ 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);
}
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 );
}

View File

@@ -1,63 +1,60 @@
<?php <?php
/** /**
* processes_Save.php * processes_Save.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * 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., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
* */
*/ global $RBAC;
global $RBAC; $access = $RBAC->userCanAccess( 'PM_FACTORY' );
$access = $RBAC->userCanAccess('PM_FACTORY'); if ($access != 1) {
if( $access != 1 ){ switch ($access) {
switch ($access) case - 1:
{ G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
case -1: G::header( 'location: ../login/login' );
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); die();
G::header('location: ../login/login'); break;
die; case - 2:
break; G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
case -2: G::header( 'location: ../login/login' );
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels'); die();
G::header('location: ../login/login'); break;
die; default:
break; G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
default: G::header( 'location: ../login/login' );
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); die();
G::header('location: ../login/login'); break;
die; }
break; }
} try {
} require_once 'classes/model/ObjectPermission.php';
try{ $oOP = new ObjectPermission();
require_once 'classes/model/ObjectPermission.php'; $oOP = ObjectPermissionPeer::retrieveByPK( $_GET['OP_UID'] );
$oOP = new ObjectPermission(); $sProcessUID = $oOP->getProUid();
$oOP = ObjectPermissionPeer::retrieveByPK($_GET['OP_UID']); $oOP->delete();
$sProcessUID = $oOP->getProUid(); $result->success = true;
$oOP->delete(); $result->msg = G::LoadTranslation( 'ID_REPORTTABLE_REMOVED' );
$result->success = true; G::LoadClass( 'processMap' );
$result->msg = G::LoadTranslation('ID_REPORTTABLE_REMOVED'); $oProcessMap = new ProcessMap();
G::LoadClass('processMap'); $oProcessMap->getObjectsPermissionsCriteria( $sProcessUID );
$oProcessMap = new ProcessMap(); } catch (Exception $e) {
$oProcessMap->getObjectsPermissionsCriteria($sProcessUID); $result->success = false;
} $result->msg = $e->getMessage();
catch (Exception $e) { }
$result->success = false; print G::json_encode( $result );
$result->msg = $e->getMessage();
}
print G::json_encode($result);

View File

@@ -1,10 +1,10 @@
<?php <?php
/** /**
* processes_DownloadFile.php * processes_DownloadFile.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * 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, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * 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., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/ */
//add more security, and catch any error or exception //add more security, and catch any error or exception
$sFileName = $_GET['p'] . '.pm';
$file=PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName.'tpm'; $sFileName = $_GET['p'] . '.pm';
$filex=PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName; $file = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName . 'tpm';
$filex = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
if(file_exists($file))
{ if (file_exists( $file )) {
rename($file, $filex); rename( $file, $filex );
} }
$realPath = PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName; $realPath = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
G::streamFile ( $realPath, true ); G::streamFile( $realPath, true );

View File

@@ -1,37 +1,36 @@
<?php <?php
/** /**
* processes_DownloadFile.php * processes_DownloadFile.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * 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., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
* */
*/ //add more security, and catch any error or exception
//add more security, and catch any error or exception
$sFileName = $_GET['p'] . '.xpdl'; $sFileName = $_GET['p'] . '.xpdl';
$file=PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName.'tpm'; $file = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName . 'tpm';
$filex=PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName; $filex = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
if(file_exists($file)) if (file_exists( $file )) {
{ rename( $file, $filex );
rename($file, $filex); }
}
$realPath = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
$realPath = PATH_DOCUMENT . 'output'. PATH_SEP. $sFileName; G::streamFile( $realPath, true );
G::streamFile ( $realPath, true );

View File

@@ -12,100 +12,94 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * 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., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/ */
G::LoadThirdParty( 'pear/json', 'class.json' );
G::LoadThirdParty('pear/json','class.json');
try { 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) function myTruncate ($chain, $limit, $break = '.', $pad = '...')
{ {
if ($key == 'PRO_TITLE') { if (strlen( $chain ) <= $limit) {
$Fields[$key] = myTruncate($value, 65, ' ', '...'); 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 */ function addTitlle ($Category, $Id, $Lang)
if (isset($_REQUEST["processMap"]) && $_REQUEST["processMap"] == 1) { {
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 = new Publisher();
$G_PUBLISH->AddContent("xmlform", "xmlform", "processes/processes_Export", "", $Fields); $aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage("publish", "raw"); 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' );
} }

View File

@@ -1,18 +1,18 @@
<?php <?php
switch ($_GET['MAIN_DIRECTORY']) { switch ($_GET['MAIN_DIRECTORY']) {
case 'mailTemplates': case 'mailTemplates':
$sDirectory = PATH_DATA_MAILTEMPLATES . $_GET['PRO_UID'] . PATH_SEP . ($_GET['CURRENT_DIRECTORY'] != '' ? $_GET['CURRENT_DIRECTORY'] . PATH_SEP : ''); $sDirectory = PATH_DATA_MAILTEMPLATES . $_GET['PRO_UID'] . PATH_SEP . ($_GET['CURRENT_DIRECTORY'] != '' ? $_GET['CURRENT_DIRECTORY'] . PATH_SEP : '');
break; break;
case 'public': case 'public':
$sDirectory = PATH_DATA_PUBLIC . $_GET['PRO_UID'] . PATH_SEP . ($_GET['CURRENT_DIRECTORY'] != '' ? $_GET['CURRENT_DIRECTORY'] . PATH_SEP : ''); $sDirectory = PATH_DATA_PUBLIC . $_GET['PRO_UID'] . PATH_SEP . ($_GET['CURRENT_DIRECTORY'] != '' ? $_GET['CURRENT_DIRECTORY'] . PATH_SEP : '');
break; break;
default: default:
die; die();
break; break;
} }
//fixed: added a file extension when is a javascript file by krlos //fixed: added a file extension when is a javascript file by krlos
$_GET['FILE'] .= ($_GET['sFilextension']!='' && $_GET['sFilextension']=='javascript')?'.js':''; $_GET['FILE'] .= ($_GET['sFilextension'] != '' && $_GET['sFilextension'] == 'javascript') ? '.js' : '';
if (file_exists($sDirectory . $_GET['FILE'])) { if (file_exists( $sDirectory . $_GET['FILE'] )) {
G::streamFile($sDirectory . $_GET['FILE'], true); G::streamFile( $sDirectory . $_GET['FILE'], true );
} }

View File

@@ -1,10 +1,10 @@
<?php <?php
/** /**
* processes_Import.php * processes_Import.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * 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, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * 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., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/ */
$access = $RBAC->userCanAccess('PM_FACTORY'); $access = $RBAC->userCanAccess( 'PM_FACTORY' );
if( $access != 1 ){ if ($access != 1) {
switch ($access) switch ($access) {
{ case - 1:
case -1: G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); G::header( 'location: ../login/login' );
G::header('location: ../login/login'); die();
die; break;
break; case - 2:
case -2: G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels'); G::header( 'location: ../login/login' );
G::header('location: ../login/login'); die();
die; break;
break; default:
default: G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); G::header( 'location: ../login/login' );
G::header('location: ../login/login'); die();
die; break;
break; }
} }
}
try { try {
/* Includes */
G::LoadClass('processes');
/* Render page */ /* Includes */
$G_MAIN_MENU = 'processmaker'; G::LoadClass( 'processes' );
$G_ID_MENU_SELECTED = 'PROCESSES';
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_Import', '', NULL, 'processes_ImportFile' );
G::RenderPage( "publish", "blank");
} /* Render page */
catch ( Exception $e ){ $G_MAIN_MENU = 'processmaker';
$G_PUBLISH = new Publisher; $G_ID_MENU_SELECTED = 'PROCESSES';
$aMessage['MESSAGE'] = $e->getMessage(); $G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'processes/processes_Import', '', NULL, 'processes_ImportFile' );
G::RenderPage('publish', "blank"); 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" );
}

View File

@@ -12,327 +12,311 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * 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., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * 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(); $reservedWordsSql = G::reservedWordsSql();
foreach ($data->reportTables as $rptIndex => $rptValue) { 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"]; $arrayAux[] = $rptValue["REP_TAB_NAME"];
} }
} }
if (count($arrayAux) > 0) { if (count( $arrayAux ) > 0) {
throw (new Exception(G::LoadTranslation("ID_PMTABLE_INVALID_NAME", array(implode(", ", $arrayAux))))); throw (new Exception( G::LoadTranslation( "ID_PMTABLE_INVALID_NAME", array (implode( ", ", $arrayAux )
) ) ));
} }
$arrayAux = array(); $arrayAux = array ();
foreach ($data->reportTablesVars as $rptIndex => $rptValue) { 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"]; $arrayAux[] = $rptValue["REP_VAR_NAME"];
} }
} }
if (count($arrayAux) > 0) { if (count( $arrayAux ) > 0) {
throw (new Exception(G::LoadTranslation("ID_PMTABLE_INVALID_FIELD_NAME", array(implode(", ", $arrayAux))))); 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 = "";
if ($action == "uploadFileNewProcess") {
$action = isset($_REQUEST['ajaxAction']) ? $_REQUEST['ajaxAction'] : null;
$result = new stdClass();
$result->success = true;
$result->catchMessage = "";
if ( $action == "uploadFileNewProcess") {
try { try {
//type of file, bpmn, xpdl, or pm //type of file, bpmn, xpdl, or pm
$processFileType = $_REQUEST["processFileType"]; $processFileType = $_REQUEST["processFileType"];
$oProcess = new stdClass(); $oProcess = new stdClass();
$oData = new stdClass(); $oData = new stdClass();
$isCorrectTypeFile = 1; $isCorrectTypeFile = 1;
if ( isset($_FILES['form']['type']['PROCESS_FILENAME']) ) { if (isset( $_FILES['form']['type']['PROCESS_FILENAME'] )) {
$allowedExtensions = array($processFileType); $allowedExtensions = array ($processFileType
$allowedExtensions = array( 'xpdl', 'bpmn', 'pm'); );
if (!in_array(end(explode(".", $_FILES['form']['name']['PROCESS_FILENAME'])), $allowedExtensions)) { $allowedExtensions = array ('xpdl','bpmn','pm'
throw new Exception(G::LoadTranslation("ID_FILE_UPLOAD_INCORRECT_EXTENSION")); );
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") {
if ($processFileType != "pm" && $processFileType != "xpdl" && $processFileType != "bpmn" ) { throw new Exception( G::LoadTranslation( "ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR" ) );
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 );
} }
}
//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") { if ($processFileType == "pm") {
$oProcess->createProcessFromData ($oData, $path . $filename ); G::LoadClass( 'processes' );
$oProcess = new Processes();
} }
else {
if ( !isset( $oData->tasks) ) $oData->tasks = array(); if ($processFileType == "xpdl") {
$tasks = $oData->tasks; G::LoadClass( 'xpdl' );
$oProcess->createProcessFromDataXpdl ($oData,$tasks); $oProcess = new Xpdl();
} }
}
//!data ouput $result->success = true;
$result->sNewProUid = $sProUid; $result->ExistProcessInDatabase = ""; //"" -Default
$result->proFileName = $Fields['PRO_FILENAME']; //0 -Dont exist process
} //1 -exist process
catch (Exception $e ) { $result->ExistGroupsInDatabase = ""; //"" -Default
$result->response = $e->getMessage(); //0 -Dont exist process
$result->catchMessage = $e->getMessage(); //1 -exist process
$result->success = true; $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 { try {
$option = $_REQUEST["IMPORT_OPTION"]; $option = $_REQUEST["IMPORT_OPTION"];
$filename = $_REQUEST["PRO_FILENAME"]; $filename = $_REQUEST["PRO_FILENAME"];
$processFileType = $_REQUEST["processFileType"]; $processFileType = $_REQUEST["processFileType"];
$result->ExistGroupsInDatabase = ""; //"" -Default $result->ExistGroupsInDatabase = ""; //"" -Default
//0 -Dont exist process //0 -Dont exist process
//1 -exist process //1 -exist process
$optionGroupExistInDatabase = isset($_REQUEST["optionGroupExistInDatabase"]) ? $_REQUEST["optionGroupExistInDatabase"] : null;
$sNewProUid = "";
$oProcess = new stdClass(); $optionGroupExistInDatabase = isset( $_REQUEST["optionGroupExistInDatabase"] ) ? $_REQUEST["optionGroupExistInDatabase"] : null;
if ($processFileType != "pm" && $processFileType != "xpdl") { $sNewProUid = "";
throw new Exception(G::LoadTranslation("ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR"));
}
//load the variables $oProcess = new stdClass();
if ($processFileType == "pm") { if ($processFileType != "pm" && $processFileType != "xpdl") {
G::LoadClass('processes'); throw new Exception( G::LoadTranslation( "ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR" ) );
$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);
}
$result->ExistGroupsInDatabase = 0;
}
else {
if ( !($oProcess->checkExistingGroups($oData->groupwfs) > 0) ) {
$result->ExistGroupsInDatabase = 0;
}
}
if ($result->ExistGroupsInDatabase == 0) { //load the variables
//Update the current Process, overwriting all tasks and steps if ($processFileType == "pm") {
if ( $option == 1 ) { G::LoadClass( 'processes' );
$oProcess->updateProcessFromData ($oData, $path . $filename ); $oProcess = new Processes();
if (file_exists(PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid)) { } else {
$oDirectory = dir(PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid); G::LoadClass( 'xpdl' );
while ($sObjectName = $oDirectory->read()) { $oProcess = new Xpdl();
if (($sObjectName != '.') && ($sObjectName != '..')) { }
unlink(PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid . PATH_SEP . $sObjectName);
} $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(); $result->ExistGroupsInDatabase = 0;
} } else {
$sNewProUid = $sProUid; if (! ($oProcess->checkExistingGroups( $oData->groupwfs ) > 0)) {
} $result->ExistGroupsInDatabase = 0;
//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 ($result->ExistGroupsInDatabase == 0) {
if ( $option == 3 ) { //Update the current Process, overwriting all tasks and steps
//krumo ($oData); die; if ($option == 1) {
$sNewProUid = $oProcess->getUnusedProcessGUID() ; $oProcess->updateProcessFromData( $oData, $path . $filename );
$oProcess->setProcessGuid ( $oData, $sNewProUid ); if (file_exists( PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid )) {
$oData->process['PRO_TITLE'] = "Copy of - " . $oData->process['PRO_TITLE'] . ' - ' . date ( 'M d, H:i' ); $oDirectory = dir( PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid );
$oProcess->renewAll ( $oData ); while ($sObjectName = $oDirectory->read()) {
if (($sObjectName != '.') && ($sObjectName != '..')) {
if ($processFileType == "pm"){ unlink( PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid . PATH_SEP . $sObjectName );
$oProcess->createProcessFromData ($oData, $path . $filename ); }
} }
else { $oDirectory->close();
if ( !isset( $oData->tasks) ) { }
$oData->tasks = array(); $sNewProUid = $sProUid;
} }
$tasks = $oData->tasks;
$oProcess->createProcessFromDataXpdl ($oData,$tasks);
}
}
}
//!data ouput //Disable current Process and create a new version of the Process
$result->fileName = $filename; if ($option == 2) {
$result->importOption = $option; $oProcess->disablePreviousProcesses( $sProUid );
$result->sNewProUid = $sNewProUid; $sNewProUid = $oProcess->getUnusedProcessGUID();
$result->success = true; $oProcess->setProcessGuid( $oData, $sNewProUid );
$result->ExistGroupsInDatabase = $result->ExistGroupsInDatabase; $oProcess->setProcessParent( $oData, $sProUid );
$result->groupBeforeAccion = $action; $oData->process['PRO_TITLE'] = "New - " . $oData->process['PRO_TITLE'] . ' - ' . date( 'M d, H:i' );
//!data ouput $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();

View File

@@ -1,10 +1,10 @@
<?php <?php
/** /**
* processes_checkProperties.php * processes_checkProperties.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * 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, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * 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., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/ */
global $RBAC; global $RBAC;
$access = $RBAC->userCanAccess('PM_FACTORY'); $access = $RBAC->userCanAccess( 'PM_FACTORY' );
if( $access != 1 ){ if ($access != 1) {
switch ($access) switch ($access) {
{ case - 1:
case -1: G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); G::header( 'location: ../login/login' );
G::header('location: ../login/login'); die();
die; break;
break; case - 2:
case -2: G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels'); G::header( 'location: ../login/login' );
G::header('location: ../login/login'); die();
die; break;
break; default:
default: G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); G::header( 'location: ../login/login' );
G::header('location: ../login/login'); die();
die; break;
break; }
} }
}
$form = $_POST ['form']; $form = $_POST['form'];
//$tasUid = $form['TASKS']; //$tasUid = $form['TASKS'];
$tasUid = $form['TAS_PARENT']; $tasUid = $form['TAS_PARENT'];
$spSynchronous = $form['SP_SYNCHRONOUS']; $spSynchronous = $form['SP_SYNCHRONOUS'];
require_once 'classes/model/Route.php'; require_once 'classes/model/Route.php';
require_once 'classes/model/Task.php'; require_once 'classes/model/Task.php';
$oRoute= new Route(); $oRoute = new Route();
$oCriteria = new Criteria('workflow'); $oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn(RoutePeer::ROU_NEXT_TASK); $oCriteria->addSelectColumn( RoutePeer::ROU_NEXT_TASK );
$oCriteria->add(RoutePeer::TAS_UID, $tasUid); $oCriteria->add( RoutePeer::TAS_UID, $tasUid );
$oDataset = RoutePeer::doSelectRS($oCriteria); $oDataset = RoutePeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$sw=1; $sw = 1;
// if there are more step we're looking them and we're checking TAS_ASSIGN_TYPE field // if there are more step we're looking them and we're checking TAS_ASSIGN_TYPE field
while ($oDataset->next() && $sw){ while ($oDataset->next() && $sw) {
$aRow = $oDataset->getRow(); $aRow = $oDataset->getRow();
$oCriteria1 = new Criteria('workflow'); $oCriteria1 = new Criteria( 'workflow' );
$oCriteria1->addSelectColumn(TaskPeer::TAS_ASSIGN_TYPE); $oCriteria1->addSelectColumn( TaskPeer::TAS_ASSIGN_TYPE );
$oCriteria1->add(TaskPeer::PRO_UID, $form['PRO_PARENT']); $oCriteria1->add( TaskPeer::PRO_UID, $form['PRO_PARENT'] );
$oCriteria1->add(TaskPeer::TAS_UID, $aRow['ROU_NEXT_TASK']); $oCriteria1->add( TaskPeer::TAS_UID, $aRow['ROU_NEXT_TASK'] );
$oDataset1 = TaskPeer::doSelectRS($oCriteria1); $oDataset1 = TaskPeer::doSelectRS( $oCriteria1 );
$oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset1->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset1->next(); $oDataset1->next();
$aRow1 = $oDataset1->getRow(); $aRow1 = $oDataset1->getRow();
if($spSynchronous && $aRow1['TAS_ASSIGN_TYPE']=='MANUAL') if ($spSynchronous && $aRow1['TAS_ASSIGN_TYPE'] == 'MANUAL')
$sw=0; $sw = 0;
} }
///If there are at least one TAS_ASSIGN_TYPE field with MANUAL it returns 1 ///If there are at least one TAS_ASSIGN_TYPE field with MANUAL it returns 1
if(!$sw) if (! $sw)
return print $spSynchronous; return print $spSynchronous;
else else
return print '0'; return print '0';

View File

@@ -1,29 +1,29 @@
<?php <?php
sleep(1); sleep( 1 );
if(isset($_SESSION['processes_upload'])){ if (isset( $_SESSION['processes_upload'] )) {
$form = $_SESSION['processes_upload']; $form = $_SESSION['processes_upload'];
switch ($form['MAIN_DIRECTORY']) { switch ($form['MAIN_DIRECTORY']) {
case 'mailTemplates': case 'mailTemplates':
$sDirectory = PATH_DATA_MAILTEMPLATES . $form['PRO_UID'] . PATH_SEP . ($form['CURRENT_DIRECTORY'] != '' ? $form['CURRENT_DIRECTORY'] . PATH_SEP : ''); $sDirectory = PATH_DATA_MAILTEMPLATES . $form['PRO_UID'] . PATH_SEP . ($form['CURRENT_DIRECTORY'] != '' ? $form['CURRENT_DIRECTORY'] . PATH_SEP : '');
break; break;
case 'public': case 'public':
$sDirectory = PATH_DATA_PUBLIC . $form['PRO_UID'] . PATH_SEP . ($form['CURRENT_DIRECTORY'] != '' ? $form['CURRENT_DIRECTORY'] . PATH_SEP : ''); $sDirectory = PATH_DATA_PUBLIC . $form['PRO_UID'] . PATH_SEP . ($form['CURRENT_DIRECTORY'] != '' ? $form['CURRENT_DIRECTORY'] . PATH_SEP : '');
break; break;
default: default:
die; die();
break; break;
} }
} }
if ($_FILES['form']['error'] == "0") { if ($_FILES['form']['error'] == "0") {
G::uploadFile($_FILES['form']['tmp_name'], $sDirectory, $_FILES['form']['name']); G::uploadFile( $_FILES['form']['tmp_name'], $sDirectory, $_FILES['form']['name'] );
$msg = "Uploaded (" . (round((filesize($sDirectory.$_FILES['form']['name'])/1024) * 10) /10) . " kb)"; $msg = "Uploaded (" . (round( (filesize( $sDirectory . $_FILES['form']['name'] ) / 1024) * 10 ) / 10) . " kb)";
$result = 1; $result = 1;
//echo $sDirectory.$_FILES['form']['name']; //echo $sDirectory.$_FILES['form']['name'];
} else { } else {
$msg = "Failed"; $msg = "Failed";
$result = 0; $result = 0;
} }
echo "{'result': $result, 'msg':'$msg'}"; echo "{'result': $result, 'msg':'$msg'}";