From 0f6644bcb012343c452b0f21bcbdc21627470a57 Mon Sep 17 00:00:00 2001 From: jennylee Date: Wed, 17 Oct 2012 17:21:35 -0400 Subject: [PATCH 1/4] CODE STYLE, workflow/engine/methods/setup/ PART 3 (final) FILES: setup.js setup.php setupAjax.php showLogoFile.php skin_Ajax.php skinsExport.php skinsList.php skinsNew.php skinsSave.php upgrade.php upgrade_RBAC.php upgrade_System.php upgrade_SystemAjax.php uplogo.php webServices.php webServicesAjax.php webServicesList.php webServicesSetup.php webServicesSetupSave.php weekend.php weekendAjax.php workPeriod.js workPeriod.php workPeriodGraph.php workPeriodSave.php --- workflow/engine/methods/setup/setup.js | 135 +- workflow/engine/methods/setup/setup.php | 69 +- workflow/engine/methods/setup/setupAjax.php | 44 +- .../engine/methods/setup/showLogoFile.php | 141 +- workflow/engine/methods/setup/skin_Ajax.php | 330 +- workflow/engine/methods/setup/skinsExport.php | 267 +- workflow/engine/methods/setup/skinsList.php | 200 +- workflow/engine/methods/setup/skinsNew.php | 115 +- workflow/engine/methods/setup/skinsSave.php | 115 +- workflow/engine/methods/setup/upgrade.php | 146 +- .../engine/methods/setup/upgrade_RBAC.php | 3 +- .../engine/methods/setup/upgrade_System.php | 218 +- .../methods/setup/upgrade_SystemAjax.php | 785 ++--- workflow/engine/methods/setup/uplogo.php | 83 +- workflow/engine/methods/setup/webServices.php | 317 +- .../engine/methods/setup/webServicesAjax.php | 2734 +++++++++-------- .../engine/methods/setup/webServicesList.php | 36 +- .../engine/methods/setup/webServicesSetup.php | 62 +- .../methods/setup/webServicesSetupSave.php | 32 +- workflow/engine/methods/setup/weekend.php | 61 +- workflow/engine/methods/setup/weekendAjax.php | 72 +- workflow/engine/methods/setup/workPeriod.js | 30 +- workflow/engine/methods/setup/workPeriod.php | 56 +- .../engine/methods/setup/workPeriodGraph.php | 148 +- .../engine/methods/setup/workPeriodSave.php | 50 +- 25 files changed, 3146 insertions(+), 3103 deletions(-) diff --git a/workflow/engine/methods/setup/setup.js b/workflow/engine/methods/setup/setup.js index 2faaf5fda..bc590f9ba 100755 --- a/workflow/engine/methods/setup/setup.js +++ b/workflow/engine/methods/setup/setup.js @@ -1,73 +1,84 @@ +function abc(panel, txt) { + /* + * commonDialog ( '', 'saved' , 'saved', {}, '' ) ; setTimeout ( + * leimnud.closure({instance:myDialog,method:function(panel){ + * + * myDialog.remove(); panel.tabLastSelected=false; panel.tabSelected=1; + * panel.makeTab(); },args:panel}) , 1000 ); + */ + var img = document.getElementById('workPeriodGraph'); + img.src = 'workPeriodGraph?b=' + Math.random(); -function abc( panel, txt ) { -/* commonDialog ( '', 'saved' , 'saved', {}, '' ) ; - setTimeout ( leimnud.closure({instance:myDialog,method:function(panel){ - - myDialog.remove(); - panel.tabLastSelected=false; - panel.tabSelected=1; - panel.makeTab(); - },args:panel}) , 1000 ); -*/ - var img = document.getElementById( 'workPeriodGraph' ); - img.src = 'workPeriodGraph?b=' + Math.random() ; - -// panel.clearContent(); -// panel.addContent ( txt ); - return false; + // panel.clearContent(); + // panel.addContent ( txt ); + return false; } -function showHideFilterForm( divName) -{ - if (document.getElementById( divName ).style.display==='none') - document.getElementById( divName).style.display = ''; - else - document.getElementById( divName).style.display = 'none'; +function showHideFilterForm(divName) { + if (document.getElementById(divName).style.display === 'none') + document.getElementById(divName).style.display = ''; + else + document.getElementById(divName).style.display = 'none'; } - - - function newHoliday(ev) { - var coor = leimnud.dom.mouse(ev); - var myPanel=new leimnud.module.panel(); - myPanel.options={ - size:{w:500,h:200}, - position:{x:coor.x-200,y:coor.y}, - title:"New Holiday", - theme:"panel", - control:{ - close:true, - drag:true - }, - fx: { modal:true } - }; - - myPanel.make(); + var coor = leimnud.dom.mouse(ev); + var myPanel = new leimnud.module.panel(); + myPanel.options = { + size : { + w : 500, + h : 200 + }, + position : { + x : coor.x - 200, + y : coor.y + }, + title : "New Holiday", + theme : "panel", + control : { + close : true, + drag : true + }, + fx : { + modal : true + } + }; - var r = new leimnud.module.rpc.xmlhttp({url:"holidayNew.php"}); - r.callback=leimnud.closure({Function:function(rpc){ - myPanel.addContent(rpc.xmlhttp.responseText); - },args:r}) - r.make(); + myPanel.make(); + + var r = new leimnud.module.rpc.xmlhttp({ + url : "holidayNew.php" + }); + r.callback = leimnud.closure({ + Function : function(rpc) { + myPanel.addContent(rpc.xmlhttp.responseText); + }, + args : r + }) + r.make(); } -function deleteHoliday( uid ) { - url = "setupAjax.php?action=deleteHoliday&uid=" + uid; - var r = new leimnud.module.rpc.xmlhttp({url: url }); - r.callback=leimnud.closure({Function:function(rpc){ - //myPanel.addContent(rpc.xmlhttp.responseText); - myPanel = setupPanel.panels.control; - myPanel.tabLastSelected=false; - myPanel.tabSelected=0; - myPanel.makeTab(); +function deleteHoliday(uid) { + url = "setupAjax.php?action=deleteHoliday&uid=" + uid; + var r = new leimnud.module.rpc.xmlhttp({ + url : url + }); + r.callback = leimnud.closure({ + Function : function(rpc) { + // myPanel.addContent(rpc.xmlhttp.responseText); + myPanel = setupPanel.panels.control; + myPanel.tabLastSelected = false; + myPanel.tabSelected = 0; + myPanel.makeTab(); + + }, + args : r + }) + r.make(); + + // myPanel.clearContent(); + // myPanel.addContent ( uid ); + +} - },args:r}) - r.make(); - - -// myPanel.clearContent(); -// myPanel.addContent ( uid ); - -} \ No newline at end of file diff --git a/workflow/engine/methods/setup/setup.php b/workflow/engine/methods/setup/setup.php index d14deb371..3474063f4 100755 --- a/workflow/engine/methods/setup/setup.php +++ b/workflow/engine/methods/setup/setup.php @@ -12,76 +12,71 @@ * * 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 . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ /** * New Admin User interface + * * @author Erik A. O. * @date Apr 5th, 2010 */ -if (($RBAC_Response=$RBAC->userCanAccess("PM_SETUP"))!=1) return $RBAC_Response; +if (($RBAC_Response = $RBAC->userCanAccess( "PM_SETUP" )) != 1) + return $RBAC_Response; $G_MAIN_MENU = "processmaker"; -$G_ID_MENU_SELECTED = "SETUP"; -$G_PUBLISH = new Publisher; +$G_ID_MENU_SELECTED = "SETUP"; +$G_PUBLISH = new Publisher(); global $G_TMP_MENU; $oMenu = new Menu(); -$oMenu->load('setup'); -$toolItems = Array(); +$oMenu->load( 'setup' ); +$toolItems = Array (); -foreach( $oMenu->Options as $i=>$option) { - $toolItems[] = Array( - 'id' => $oMenu->Id[$i], - 'link' => ($oMenu->Options[$i]!='')? $oMenu->Options[$i]: '#', - 'onclick' => ($oMenu->JS[$i]!='')? $oMenu->JS[$i]: '', - 'label' => $oMenu->Labels[$i], - 'icon' => ($oMenu->Icons[$i]!='')? $oMenu->Icons[$i]: 'icon-pmlogo.png', - 'target'=> ($oMenu->JS[$i]!='')? '': 'admToolsContent' - ); +foreach ($oMenu->Options as $i => $option) { + $toolItems[] = Array ('id' => $oMenu->Id[$i],'link' => ($oMenu->Options[$i] != '') ? $oMenu->Options[$i] : '#','onclick' => ($oMenu->JS[$i] != '') ? $oMenu->JS[$i] : '','label' => $oMenu->Labels[$i],'icon' => ($oMenu->Icons[$i] != '') ? $oMenu->Icons[$i] : 'icon-pmlogo.png','target' => ($oMenu->JS[$i] != '') ? '' : 'admToolsContent' + ); } $template = new TemplatePower( PATH_TPL . 'setup' . PATH_SEP . 'tools.html' ); $template->prepare(); -$template->assign ('LeftWidth', '230'); -$template->assign ('contentHeight', '520'); +$template->assign( 'LeftWidth', '230' ); +$template->assign( 'contentHeight', '520' ); -if( isset($_GET['i18']) ){ - $_SESSION['TOOLS_VIEWTYPE'] = true; - $template->assign ('displayLanguageTool', 'block'); +if (isset( $_GET['i18'] )) { + $_SESSION['TOOLS_VIEWTYPE'] = true; + $template->assign( 'displayLanguageTool', 'block' ); } else { - $template->assign ('displayLanguageTool', 'none'); + $template->assign( 'displayLanguageTool', 'none' ); } -if( isset($_GET['newSite']) ){ - $template->assign ('displayNewSiteTool', 'block'); +if (isset( $_GET['newSite'] )) { + $template->assign( 'displayNewSiteTool', 'block' ); } else { - $template->assign ('displayNewSiteTool', 'none'); + $template->assign( 'displayNewSiteTool', 'none' ); } - -foreach($toolItems as $item) { - $template->newBlock( 'tool_options'); - foreach($item as $propertyName=>$propertyValue) - $template->assign ($propertyName, $propertyValue); +foreach ($toolItems as $item) { + $template->newBlock( 'tool_options' ); + foreach ($item as $propertyName => $propertyValue) + $template->assign( $propertyName, $propertyValue ); } -$G_PUBLISH->AddContent('template', '', '', '', $template ); -G::RenderPage('publish'); -if(isset($_GET['module'])){ +$G_PUBLISH->AddContent( 'template', '', '', '', $template ); +G::RenderPage( 'publish' ); +if (isset( $_GET['module'] )) { - print " + print " "; -} \ No newline at end of file +} + diff --git a/workflow/engine/methods/setup/setupAjax.php b/workflow/engine/methods/setup/setupAjax.php index b5f11bcfa..8c6df6445 100755 --- a/workflow/engine/methods/setup/setupAjax.php +++ b/workflow/engine/methods/setup/setupAjax.php @@ -1,10 +1,10 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * along with this program. If not, see . + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ -if (($RBAC_Response=$RBAC->userCanAccess("PM_SETUP"))!=1) return $RBAC_Response; -//$oSMTPJSON = new Services_JSON(); -//$oSMTPData = $oSMTPJSON->decode(stripslashes($_POST['data'])); -//$sOutput = ''; - G::LoadClass('setup'); +if (($RBAC_Response = $RBAC->userCanAccess( "PM_SETUP" )) != 1) + return $RBAC_Response; + //$oSMTPJSON = new Services_JSON(); + //$oSMTPData = $oSMTPJSON->decode(stripslashes($_POST['data'])); + //$sOutput = ''; +G::LoadClass( 'setup' ); - $oSMTPSetup = new Setup(new DBConnection); +$oSMTPSetup = new Setup( new DBConnection() ); - $action = strtolower ( $_GET['action'] ); - $data = $_GET; +$action = strtolower( $_GET['action'] ); +$data = $_GET; + +$arr = get_class_methods( get_class( $oSMTPSetup ) ); +foreach ($arr as $method) { + if ($method == $action) + $oSMTPSetup->{$action}( $_GET ); +} - $arr = get_class_methods( get_class($oSMTPSetup) ); - foreach ($arr as $method) { - if ( $method == $action ) - $oSMTPSetup->{$action} ( $_GET ); - } -?> \ No newline at end of file diff --git a/workflow/engine/methods/setup/showLogoFile.php b/workflow/engine/methods/setup/showLogoFile.php index a2c4e747b..756d08500 100755 --- a/workflow/engine/methods/setup/showLogoFile.php +++ b/workflow/engine/methods/setup/showLogoFile.php @@ -12,105 +12,104 @@ * * 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 . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ // if (($RBAC_Response = $RBAC->userCanAccess("PM_CASES"))!=1) return $RBAC_Response; - $idDecode64 = base64_decode($_GET['id']); - $idExploded = explode( '/', $idDecode64 ); - if ( $idExploded[0] == '' ) array_shift($idExploded); - if ( $idExploded[0] == 'plugin' ) { + +$idDecode64 = base64_decode( $_GET['id'] ); +$idExploded = explode( '/', $idDecode64 ); +if ($idExploded[0] == '') + array_shift( $idExploded ); +if ($idExploded[0] == 'plugin') { //Get the Plugin Folder, always the first element - $pluginFolder = $idExploded[1]; - $pluginFilename = PATH_PLUGINS . $pluginFolder . PATH_SEP . 'public_html'. PATH_SEP . $idExploded[2]; - if ( file_exists ( $pluginFilename ) ) { - G::streamFile ( $pluginFilename ); + $pluginFolder = $idExploded[1]; + $pluginFilename = PATH_PLUGINS . $pluginFolder . PATH_SEP . 'public_html' . PATH_SEP . $idExploded[2]; + if (file_exists( $pluginFilename )) { + G::streamFile( $pluginFilename ); } - die; - } + die(); +} - $ainfoSite = explode("/",$_SERVER["REQUEST_URI"]); +$ainfoSite = explode( "/", $_SERVER["REQUEST_URI"] ); //it was added to show the logo into management plugin add by krlos - if(isset($_GET['wsName']) && $_GET['wsName']!=''){ +if (isset( $_GET['wsName'] ) && $_GET['wsName'] != '') { $ainfoSite[1] = $_GET['wsName']; - } +} //end add - $dir=PATH_DATA."sites".PATH_SEP.str_replace("sys","",$ainfoSite[1]).PATH_SEP."files/logos"; - $imagen = $dir .PATH_SEP.$idDecode64; +$dir = PATH_DATA . "sites" . PATH_SEP . str_replace( "sys", "", $ainfoSite[1] ) . PATH_SEP . "files/logos"; +$imagen = $dir . PATH_SEP . $idDecode64; +if (is_file( $imagen )) { + showLogo( $imagen ); - if (is_file($imagen)) - { - showLogo($imagen); +} else { - } - else { + $newDir = PATH_DATA . "sites" . PATH_SEP . str_replace( "sys", "", $ainfoSite[1] ) . PATH_SEP . "files/logos"; + $dir = PATH_HOME . "public_html/files/logos"; - $newDir = PATH_DATA."sites".PATH_SEP.str_replace("sys","",$ainfoSite[1]).PATH_SEP."files/logos"; - $dir = PATH_HOME . "public_html/files/logos"; - - if(!is_dir($newDir)){ - G::mk_dir($newDir); - } - //this function does copy all logos from public_html/files/logos to /shared/site/yourSite/files/logos - //cpyMoreLogos($dir,$newDir); - $newDir .= PATH_SEP.$idDecode64; - $dir .= PATH_SEP.$idDecode64; - copy($dir,$newDir); - showLogo($newDir); - die; - - } - - - function showLogo($imagen){ - $info = @getimagesize($imagen); - $fp = fopen($imagen, "rb"); - if ($info && $fp) { - header("Content-type: {$info['mime']}"); - fpassthru($fp); - exit; - } else { - throw new Exception("Image format not valid"); + if (! is_dir( $newDir )) { + G::mk_dir( $newDir ); } - } + //this function does copy all logos from public_html/files/logos to /shared/site/yourSite/files/logos + //cpyMoreLogos($dir,$newDir); + $newDir .= PATH_SEP . $idDecode64; + $dir .= PATH_SEP . $idDecode64; + copy( $dir, $newDir ); + showLogo( $newDir ); + die(); - function cpyMoreLogos($dir,$newDir){ - if (file_exists($dir)) { - if ($handle = opendir($dir)) { - while (false !== ($file = readdir($handle))) { - if(($file!=".")&&($file!="..")) { - $extention=explode(".", $file); - $aImageProp=getimagesize($dir.'/'.$file, $info); - $sfileExtention = strtoupper($extention[count($extention)-1]); - if( in_array($sfileExtention, array('JPG','JPEG','PNG','GIF') ) ) { +} - $dir1 = $dir.PATH_SEP.$file; - $dir2 = $newDir.PATH_SEP.$file; - //print $dir1 ." *** ".$dir2."

"; - copy($dir1,$dir2); +function showLogo ($imagen) +{ + $info = @getimagesize( $imagen ); + $fp = fopen( $imagen, "rb" ); + if ($info && $fp) { + header( "Content-type: {$info['mime']}" ); + fpassthru( $fp ); + exit(); + } else { + throw new Exception( "Image format not valid" ); + } +} +function cpyMoreLogos ($dir, $newDir) +{ + if (file_exists( $dir )) { + if ($handle = opendir( $dir )) { + while (false !== ($file = readdir( $handle ))) { + if (($file != ".") && ($file != "..")) { + $extention = explode( ".", $file ); + $aImageProp = getimagesize( $dir . '/' . $file, $info ); + $sfileExtention = strtoupper( $extention[count( $extention ) - 1] ); + if (in_array( $sfileExtention, array ('JPG','JPEG','PNG','GIF' + ) )) { - } + $dir1 = $dir . PATH_SEP . $file; + $dir2 = $newDir . PATH_SEP . $file; + //print $dir1 ." *** ".$dir2."

"; + copy( $dir1, $dir2 ); + + } + } } - } - closedir($handle); + closedir( $handle ); } - } - } + } +} -die; - +die(); ?> + diff --git a/workflow/engine/methods/setup/skin_Ajax.php b/workflow/engine/methods/setup/skin_Ajax.php index 695dae0f6..3fb3e8161 100755 --- a/workflow/engine/methods/setup/skin_Ajax.php +++ b/workflow/engine/methods/setup/skin_Ajax.php @@ -1,255 +1,250 @@ aConfig = $config; - $c->saveConfig('skinsList', 'pageSize', '', $_SESSION['USER_LOGGED']); + $c->saveConfig( 'skinsList', 'pageSize', '', $_SESSION['USER_LOGGED'] ); echo '{success: true}'; } -function skinList() +function skinList () { - G::loadClass('system'); + G::loadClass( 'system' ); $skinList = System::getSkingList(); - + $wildcard = ''; - if(isset($_REQUEST['activeskin'])) - { + if (isset( $_REQUEST['activeskin'] )) { $wildcard = '@'; } foreach ($skinList['skins'] as $key => $value) { if ($value['SKIN_FOLDER_ID'] != 'simplified' && $value['SKIN_FOLDER_ID'] != 'uxs') { - if($skinList['currentSkin'] == $value['SKIN_FOLDER_ID']){ - $value['SKIN_STATUS'] = $wildcard . G::LoadTranslation('ID_ACTIVE'); + if ($skinList['currentSkin'] == $value['SKIN_FOLDER_ID']) { + $value['SKIN_STATUS'] = $wildcard . G::LoadTranslation( 'ID_ACTIVE' ); $value['SKIN_NAME'] = $wildcard . $value['SKIN_NAME']; $value['SKIN_DESCRIPTION'] = $wildcard . $value['SKIN_DESCRIPTION']; $value['SKIN_AUTHOR'] = $wildcard . $value['SKIN_AUTHOR']; $value['SKIN_CREATEDATE'] = $wildcard . $value['SKIN_CREATEDATE']; $value['SKIN_MODIFIEDDATE'] = $wildcard . $value['SKIN_MODIFIEDDATE']; - } - else{ - $value['SKIN_STATUS'] = G::LoadTranslation('ID_INACTIVE'); + } else { + $value['SKIN_STATUS'] = G::LoadTranslation( 'ID_INACTIVE' ); } $skinListArray['skins'][] = $value; } } $skinListArray['currentSkin'] = $skinList['currentSkin']; - echo G::json_encode($skinListArray); + echo G::json_encode( $skinListArray ); } -function newSkin($baseSkin='classic') +function newSkin ($baseSkin = 'classic') { - $skinBase = $baseSkin != "" ? strtolower($baseSkin) : 'classic'; - if ((isset($_REQUEST['skinBase'])) && ($_REQUEST['skinBase'] != "")) { - $skinBase = strtolower($_REQUEST['skinBase']); + $skinBase = $baseSkin != "" ? strtolower( $baseSkin ) : 'classic'; + if ((isset( $_REQUEST['skinBase'] )) && ($_REQUEST['skinBase'] != "")) { + $skinBase = strtolower( $_REQUEST['skinBase'] ); } try { - if (!(isset($_REQUEST['skinName']))) { - throw ( new Exception(G::LoadTranslation('ID_SKIN_NAME_REQUIRED')) ); + if (! (isset( $_REQUEST['skinName'] ))) { + throw (new Exception( G::LoadTranslation( 'ID_SKIN_NAME_REQUIRED' ) )); } - if (!(isset($_REQUEST['skinFolder']))) { - throw ( new Exception(G::LoadTranslation('ID_SKIN_FOLDER_REQUIRED')) ); + if (! (isset( $_REQUEST['skinFolder'] ))) { + throw (new Exception( G::LoadTranslation( 'ID_SKIN_FOLDER_REQUIRED' ) )); } //Should validate skin folder name here //if.... + $skinName = $_REQUEST['skinName']; $skinFolder = $_REQUEST['skinFolder']; - $skinDescription = isset($_REQUEST['skinDescription']) ? $_REQUEST['skinDescription'] : ''; - $skinAuthor = isset($_REQUEST['skinAuthor']) ? $_REQUEST['skinAuthor'] : 'ProcessMaker Team'; + $skinDescription = isset( $_REQUEST['skinDescription'] ) ? $_REQUEST['skinDescription'] : ''; + $skinAuthor = isset( $_REQUEST['skinAuthor'] ) ? $_REQUEST['skinAuthor'] : 'ProcessMaker Team'; - if (is_dir(PATH_CUSTOM_SKINS . $skinFolder)) { - throw ( new Exception(G::LoadTranslation('ID_SKIN_ALREADY_EXISTS')) ); + if (is_dir( PATH_CUSTOM_SKINS . $skinFolder )) { + throw (new Exception( G::LoadTranslation( 'ID_SKIN_ALREADY_EXISTS' ) )); } - if (strtolower($skinFolder) == 'classic') { - throw ( new Exception(G::LoadTranslation('ID_SKIN_ALREADY_EXISTS')) ); + if (strtolower( $skinFolder ) == 'classic') { + throw (new Exception( G::LoadTranslation( 'ID_SKIN_ALREADY_EXISTS' ) )); } //All validations OK then create skin switch ($skinBase) { //Validate skin base case 'uxmodern': - copy_skin_folder(G::ExpandPath("skinEngine") . 'uxmodern' . PATH_SEP, PATH_CUSTOM_SKINS . - $skinFolder,array("config.xml")); - $pathBase=G::ExpandPath("skinEngine") . 'base' . PATH_SEP; + copy_skin_folder( G::ExpandPath( "skinEngine" ) . 'uxmodern' . PATH_SEP, PATH_CUSTOM_SKINS . $skinFolder, array ("config.xml" + ) ); + $pathBase = G::ExpandPath( "skinEngine" ) . 'base' . PATH_SEP; break; case 'classic': //Special Copy of this dir + xmlreplace - copy_skin_folder(G::ExpandPath("skinEngine") . 'base' . PATH_SEP, PATH_CUSTOM_SKINS . - $skinFolder,array("config.xml","baseCss")); - $pathBase=G::ExpandPath("skinEngine") . 'base' . PATH_SEP; + copy_skin_folder( G::ExpandPath( "skinEngine" ) . 'base' . PATH_SEP, PATH_CUSTOM_SKINS . $skinFolder, array ("config.xml","baseCss" + ) ); + $pathBase = G::ExpandPath( "skinEngine" ) . 'base' . PATH_SEP; break; default: //Commmon copy/paste of a folder + xmlrepalce - copy_skin_folder(PATH_CUSTOM_SKINS . $skinBase, PATH_CUSTOM_SKINS . $skinFolder,array("config.xml")); - $pathBase=PATH_CUSTOM_SKINS.$skinBase; + copy_skin_folder( PATH_CUSTOM_SKINS . $skinBase, PATH_CUSTOM_SKINS . $skinFolder, array ("config.xml" + ) ); + $pathBase = PATH_CUSTOM_SKINS . $skinBase; break; } //ReBuild config file //TODO: Improve this pre_replace lines - $configFileOriginal = $pathBase . PATH_SEP . 'config.xml'; + $configFileOriginal = $pathBase . PATH_SEP . 'config.xml'; $configFileFinal = PATH_CUSTOM_SKINS . $skinFolder . PATH_SEP . 'config.xml'; - $xmlConfiguration = file_get_contents($configFileOriginal); - $xmlConfiguration = preg_replace('/()(.+?)(<\/id>)/i', '' . G::generateUniqueID() . - '', $xmlConfiguration); - $xmlConfiguration = preg_replace("/()(.+?)(<\/name>)/i", "" . $skinName . - "", $xmlConfiguration); - $xmlConfiguration = preg_replace("/()(.+?)(<\/description>)/i", "" . - $skinDescription . "", $xmlConfiguration); - $xmlConfiguration = preg_replace("/()(.+?)(<\/author>)/i", "" . $skinAuthor . - "", $xmlConfiguration); - $xmlConfiguration = preg_replace("/()(.+?)(<\/createDate>)/i", "" . - date("Y-m-d H:i:s") . "", $xmlConfiguration); - $xmlConfiguration = preg_replace("/()(.+?)(<\/modifiedDate>)/i", "" . - date("Y-m-d H:i:s") . "", $xmlConfiguration); - file_put_contents($configFileFinal, $xmlConfiguration); + $xmlConfiguration = file_get_contents( $configFileOriginal ); + $xmlConfiguration = preg_replace( '/()(.+?)(<\/id>)/i', '' . G::generateUniqueID() . '', $xmlConfiguration ); + $xmlConfiguration = preg_replace( "/()(.+?)(<\/name>)/i", "" . $skinName . "", $xmlConfiguration ); + $xmlConfiguration = preg_replace( "/()(.+?)(<\/description>)/i", "" . $skinDescription . "", $xmlConfiguration ); + $xmlConfiguration = preg_replace( "/()(.+?)(<\/author>)/i", "" . $skinAuthor . "", $xmlConfiguration ); + $xmlConfiguration = preg_replace( "/()(.+?)(<\/createDate>)/i", "" . date( "Y-m-d H:i:s" ) . "", $xmlConfiguration ); + $xmlConfiguration = preg_replace( "/()(.+?)(<\/modifiedDate>)/i", "" . date( "Y-m-d H:i:s" ) . "", $xmlConfiguration ); + file_put_contents( $configFileFinal, $xmlConfiguration ); $response['success'] = true; - $response['message'] = G::LoadTranslation('ID_SKIN_SUCCESS_CREATE'); - print_r(G::json_encode($response)); + $response['message'] = G::LoadTranslation( 'ID_SKIN_SUCCESS_CREATE' ); + print_r( G::json_encode( $response ) ); } catch (Exception $e) { $response['success'] = false; $response['message'] = $e->getMessage(); $response['error'] = $e->getMessage(); - print_r(G::json_encode($response)); + print_r( G::json_encode( $response ) ); } } -function importSkin() +function importSkin () { try { - if (!isset($_FILES['uploadedFile'])) { - throw ( new Exception(G::LoadTranslation('ID_SKIN_FILE_REQUIRED')) ); + if (! isset( $_FILES['uploadedFile'] )) { + throw (new Exception( G::LoadTranslation( 'ID_SKIN_FILE_REQUIRED' ) )); } - $uploadedInstances = count($_FILES['uploadedFile']['name']); + $uploadedInstances = count( $_FILES['uploadedFile']['name'] ); $sw_error = false; - $sw_error_exists = isset($_FILES['uploadedFile']['error']); + $sw_error_exists = isset( $_FILES['uploadedFile']['error'] ); $emptyInstances = 0; - $quequeUpload = array(); + $quequeUpload = array (); // upload files & check for errors $tmp = $_FILES['uploadedFile']['tmp_name']; - $items = stripslashes($_FILES['uploadedFile']['name']); + $items = stripslashes( $_FILES['uploadedFile']['name'] ); if ($sw_error_exists) { $up_err = $_FILES['uploadedFile']['error']; } else { - $up_err= ( file_exists($tmp) ? 0 : 4); + $up_err = (file_exists( $tmp ) ? 0 : 4); } if ($items == "" || $up_err == 4) { - throw ( new Exception(G::LoadTranslation('ID_SKIN_FILE_REQUIRED'))); + throw (new Exception( G::LoadTranslation( 'ID_SKIN_FILE_REQUIRED' ) )); } if ($up_err == 1 || $up_err == 2) { - throw ( new Exception(G::LoadTranslation('ID_FILE_TOO_BIG'))); + throw (new Exception( G::LoadTranslation( 'ID_FILE_TOO_BIG' ) )); //$errors[$i]='miscfilesize'; } if ($up_err == 3) { - throw ( new Exception(G::LoadTranslation('ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR'))); + throw (new Exception( G::LoadTranslation( 'ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR' ) )); //$errors[$i]='miscfilepart'; } - if (!@is_uploaded_file($tmp)) { - throw ( new Exception(G::LoadTranslation('ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR'))); + if (! @is_uploaded_file( $tmp )) { + throw (new Exception( G::LoadTranslation( 'ID_ERROR_UPLOAD_FILE_CONTACT_ADMINISTRATOR' ) )); //$errors[$i]='uploadfile'; } - $fileInfo = pathinfo($items); - $validType = array('tar', 'gz'); + $fileInfo = pathinfo( $items ); + $validType = array ('tar','gz' + ); - if (!in_array($fileInfo['extension'], $validType)) { - throw ( new Exception(G::LoadTranslation('ID_FILE_UPLOAD_INCORRECT_EXTENSION'))); + if (! in_array( $fileInfo['extension'], $validType )) { + throw (new Exception( G::LoadTranslation( 'ID_FILE_UPLOAD_INCORRECT_EXTENSION' ) )); //$errors[$i]='wrongtype'; } $filename = $items; $tempPath = PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP; - G::verifyPath($tempPath, true); + G::verifyPath( $tempPath, true ); $tempName = $tmp; - G::uploadFile($tempName, $tempPath, $filename); - G::LoadThirdParty('pear/Archive', 'Tar'); - $tar = new Archive_Tar($tempPath . $filename); + G::uploadFile( $tempName, $tempPath, $filename ); + G::LoadThirdParty( 'pear/Archive', 'Tar' ); + $tar = new Archive_Tar( $tempPath . $filename ); $aFiles = $tar->listContent(); $swConfigFile = false; foreach ($aFiles as $key => $val) { - if (basename($val['filename']) == 'config.xml') { - $skinName = dirname($val['filename']); - $skinArray = explode("/", $skinName); - if (count($skinArray) == 1) { + if (basename( $val['filename'] ) == 'config.xml') { + $skinName = dirname( $val['filename'] ); + $skinArray = explode( "/", $skinName ); + if (count( $skinArray ) == 1) { $swConfigFile = true; } } } - if (!$swConfigFile) { - @unlink(PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP . $filename); - throw ( new Exception(G::LoadTranslation('ID_SKIN_CONFIGURATION_MISSING'))); + if (! $swConfigFile) { + @unlink( PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP . $filename ); + throw (new Exception( G::LoadTranslation( 'ID_SKIN_CONFIGURATION_MISSING' ) )); } - if (is_dir(PATH_CUSTOM_SKINS . $skinName)) { - if ((isset($_REQUEST['overwrite_files'])) && ($_REQUEST['overwrite_files'] == 'on')) { - G::rm_dir(PATH_CUSTOM_SKINS . $skinName, false); + if (is_dir( PATH_CUSTOM_SKINS . $skinName )) { + if ((isset( $_REQUEST['overwrite_files'] )) && ($_REQUEST['overwrite_files'] == 'on')) { + G::rm_dir( PATH_CUSTOM_SKINS . $skinName, false ); } else { - throw ( new Exception(G::LoadTranslation('ID_SKIN_ALREADY_EXISTS'))); + throw (new Exception( G::LoadTranslation( 'ID_SKIN_ALREADY_EXISTS' ) )); } } - $res = $tar->extract(PATH_CUSTOM_SKINS); - if (!$res) { - throw ( new Exception(G::LoadTranslation('ID_SKIN_ERROR_EXTRACTING'))); + $res = $tar->extract( PATH_CUSTOM_SKINS ); + if (! $res) { + throw (new Exception( G::LoadTranslation( 'ID_SKIN_ERROR_EXTRACTING' ) )); } //Delete Temporal - @unlink(PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP . $filename); + @unlink( PATH_CUSTOM_SKINS . '.tmp' . PATH_SEP . $filename ); $response['success'] = true; - $response['message'] = G::LoadTranslation('ID_SKIN_SUCCESSFUL_IMPORTED'); - print_r(G::json_encode($response)); + $response['message'] = G::LoadTranslation( 'ID_SKIN_SUCCESSFUL_IMPORTED' ); + print_r( G::json_encode( $response ) ); } catch (Exception $e) { $response['success'] = false; $response['message'] = $e->getMessage(); $response['error'] = $e->getMessage(); - print_r(G::json_encode($response)); + print_r( G::json_encode( $response ) ); } } -function exportSkin($skinToExport="") +function exportSkin ($skinToExport = "") { try { - if (!isset($_REQUEST['SKIN_FOLDER_ID'])) { - throw ( new Exception(G::LoadTranslation('ID_SKIN_NAME_REQUIRED')) ); + if (! isset( $_REQUEST['SKIN_FOLDER_ID'] )) { + throw (new Exception( G::LoadTranslation( 'ID_SKIN_NAME_REQUIRED' ) )); } $skinName = $_REQUEST['SKIN_FOLDER_ID']; @@ -257,113 +252,116 @@ function exportSkin($skinToExport="") $skinFolderBase = PATH_CUSTOM_SKINS . $skinName; $skinFolder = $skinFolderBase . PATH_SEP; $skinTar = PATH_CUSTOM_SKINS . $skinName . '.tar'; - if (!is_dir($skinFolder)) { - throw ( new Exception(G::LoadTranslation('ID_SKIN_DOESNT_EXIST')) ); + if (! is_dir( $skinFolder )) { + throw (new Exception( G::LoadTranslation( 'ID_SKIN_DOESNT_EXIST' ) )); } - if (!file_exists($skinFolder . "config.xml")) { - throw ( new Exception(G::LoadTranslation('ID_SKIN_CONFIGURATION_MISSING')) ); + if (! file_exists( $skinFolder . "config.xml" )) { + throw (new Exception( G::LoadTranslation( 'ID_SKIN_CONFIGURATION_MISSING' ) )); } - if (file_exists($skinTar)) { + if (file_exists( $skinTar )) { //try to delete - if (!unlink($skinTar)) { - throw ( new Exception(G::LoadTranslation('ID_SKIN_FOLDER_PERMISSIONS')) ); + if (! unlink( $skinTar )) { + throw (new Exception( G::LoadTranslation( 'ID_SKIN_FOLDER_PERMISSIONS' ) )); } } //Try to generate tar file - G::LoadThirdParty('pear/Archive', 'Tar'); - $tar = new Archive_Tar($skinTar); + G::LoadThirdParty( 'pear/Archive', 'Tar' ); + $tar = new Archive_Tar( $skinTar ); $tar->_compress = false; - addTarFolder($tar, $skinFolder, PATH_CUSTOM_SKINS); + addTarFolder( $tar, $skinFolder, PATH_CUSTOM_SKINS ); $response['success'] = true; $response['message'] = $skinTar; - print_r(G::json_encode($response)); + print_r( G::json_encode( $response ) ); } catch (Exception $e) { $response['success'] = false; $response['message'] = $e->getMessage(); - print_r(G::json_encode($response)); + print_r( G::json_encode( $response ) ); } } -function deleteSkin() + +function deleteSkin () { try { - if (!(isset($_REQUEST['SKIN_FOLDER_ID']))) { - throw (new Exception(G::LoadTranslation('ID_SKIN_FOLDER_REQUIRED'))); + if (! (isset( $_REQUEST['SKIN_FOLDER_ID'] ))) { + throw (new Exception( G::LoadTranslation( 'ID_SKIN_FOLDER_REQUIRED' ) )); } - if (($_REQUEST['SKIN_FOLDER_ID'])=="classic") { - throw (new Exception(G::LoadTranslation('ID_SKIN_FOLDER_NOT_DELETEABLE'))); + if (($_REQUEST['SKIN_FOLDER_ID']) == "classic") { + throw (new Exception( G::LoadTranslation( 'ID_SKIN_FOLDER_NOT_DELETEABLE' ) )); } - $folderId=$_REQUEST['SKIN_FOLDER_ID']; - if (!is_dir(PATH_CUSTOM_SKINS.$folderId)) { - throw (new Exception(G::LoadTranslation('ID_SKIN_NOT_EXISTS'))); + $folderId = $_REQUEST['SKIN_FOLDER_ID']; + if (! is_dir( PATH_CUSTOM_SKINS . $folderId )) { + throw (new Exception( G::LoadTranslation( 'ID_SKIN_NOT_EXISTS' ) )); } //Delete - G::rm_dir(PATH_CUSTOM_SKINS.$folderId); + G::rm_dir( PATH_CUSTOM_SKINS . $folderId ); $response['success'] = true; $response['message'] = "$folderId deleted"; } catch (Exception $e) { $response['success'] = false; - $response['error']=$response['message'] = $e->getMessage(); - print_r(G::json_encode($response)); + $response['error'] = $response['message'] = $e->getMessage(); + print_r( G::json_encode( $response ) ); } } -function streamSkin() + +function streamSkin () { $skinTar = $_REQUEST['file']; $bDownload = true; - G::streamFile($skinTar, $bDownload, basename($skinTar)); - @unlink($fileTar); + G::streamFile( $skinTar, $bDownload, basename( $skinTar ) ); + @unlink( $fileTar ); } -function addTarFolder($tar, $pathBase, $pluginHome) +function addTarFolder ($tar, $pathBase, $pluginHome) { - $aux = explode(PATH_SEP, $pathBase); - if ($aux[count($aux) - 2] == '.svn') { + $aux = explode( PATH_SEP, $pathBase ); + if ($aux[count( $aux ) - 2] == '.svn') { return; } - if ($handle = opendir($pathBase)) { - while (false !== ($file = readdir($handle))) { - if (is_file($pathBase . $file)) { + if ($handle = opendir( $pathBase )) { + while (false !== ($file = readdir( $handle ))) { + if (is_file( $pathBase . $file )) { //print "file $file \n"; - $tar->addModify($pathBase . $file, '', $pluginHome); + $tar->addModify( $pathBase . $file, '', $pluginHome ); } - if (is_dir($pathBase . $file) && $file != '..' && $file != '.') { + if (is_dir( $pathBase . $file ) && $file != '..' && $file != '.') { //print "dir $pathBase$file \n"; - addTarFolder($tar, $pathBase . $file . PATH_SEP, $pluginHome); + addTarFolder( $tar, $pathBase . $file . PATH_SEP, $pluginHome ); } } - closedir($handle); + closedir( $handle ); } } -function copy_skin_folder($path, $dest, $exclude=array()) +function copy_skin_folder ($path, $dest, $exclude = array()) { - $defaultExcluded=array(".",".."); - $excludedItems=array_merge($defaultExcluded,$exclude); - if (is_dir($path)) { - @mkdir($dest); - $objects = scandir($path); - if (sizeof($objects) > 0) { + $defaultExcluded = array (".",".." + ); + $excludedItems = array_merge( $defaultExcluded, $exclude ); + if (is_dir( $path )) { + @mkdir( $dest ); + $objects = scandir( $path ); + if (sizeof( $objects ) > 0) { foreach ($objects as $file) { - if (in_array($file,$excludedItems)) { + if (in_array( $file, $excludedItems )) { continue; } // go on - if (is_dir($path . PATH_SEP . $file)) { - copy_skin_folder($path . PATH_SEP . $file, $dest . PATH_SEP . $file,$exclude); + if (is_dir( $path . PATH_SEP . $file )) { + copy_skin_folder( $path . PATH_SEP . $file, $dest . PATH_SEP . $file, $exclude ); } else { - copy($path . PATH_SEP . $file, $dest . PATH_SEP . $file); + copy( $path . PATH_SEP . $file, $dest . PATH_SEP . $file ); } } } return true; - } elseif (is_file($path)) { - return copy($path, $dest); + } elseif (is_file( $path )) { + return copy( $path, $dest ); } else { return false; } diff --git a/workflow/engine/methods/setup/skinsExport.php b/workflow/engine/methods/setup/skinsExport.php index 0262986f0..87e29798b 100755 --- a/workflow/engine/methods/setup/skinsExport.php +++ b/workflow/engine/methods/setup/skinsExport.php @@ -1,4 +1,5 @@ . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ - - function copyFile ( $input, $output ) { - $content = file_get_contents ( $input ); - $filename = $output . PATH_SEP . basename ( $input ); - return file_put_contents ( $filename, $content ); - } - function savePluginFile ( $tplName, $fileName, $fields ) { - $pluginTpl = PATH_GULLIVER_HOME . 'bin' . PATH_SEP . 'tasks' .PATH_SEP . 'templates' . PATH_SEP . $tplName . '.tpl'; +function copyFile ($input, $output) +{ + $content = file_get_contents( $input ); + $filename = $output . PATH_SEP . basename( $input ); + return file_put_contents( $filename, $content ); +} + +function savePluginFile ($tplName, $fileName, $fields) +{ + $pluginTpl = PATH_GULLIVER_HOME . 'bin' . PATH_SEP . 'tasks' . PATH_SEP . 'templates' . PATH_SEP . $tplName . '.tpl'; $template = new TemplatePower( $pluginTpl ); $template->prepare(); - - if ( is_array ($fields) ) { - foreach ( $fields as $block => $data ) { - $template->gotoBlock( "_ROOT" ); - if ( is_array( $data) ) - foreach ( $data as $rowId => $row ) { - $template->newBlock( $block ); - foreach ( $row as $key => $val ) - $template->assign( $key, $val ); - } - else - $template->assign( $block, $data ); - } - } - - $content = $template->getOutputContent(); - $iSize = file_put_contents ( $fileName, $content ); - return $iSize; - } - function addTarFolder ( $tar, $pathBase,$pluginHome ) { - $aux = explode( PATH_SEP, $pathBase); - if ( $aux[count($aux) -2 ] == '.svn' ) return; - - if ($handle = opendir( $pathBase )) { - while ( false !== ($file = readdir($handle))) { - if ( is_file ( $pathBase . $file ) ) { - //print "file $file \n"; - $tar->addModify( $pathBase . $file,'', $pluginHome); + if (is_array( $fields )) { + foreach ($fields as $block => $data) { + $template->gotoBlock( "_ROOT" ); + if (is_array( $data )) + foreach ($data as $rowId => $row) { + $template->newBlock( $block ); + foreach ($row as $key => $val) + $template->assign( $key, $val ); + } + else + $template->assign( $block, $data ); } - if ( is_dir ( $pathBase . $file ) && $file != '..' && $file != '.' ) { - //print "dir $pathBase$file \n"; - addTarFolder ( $tar, $pathBase . $file . PATH_SEP ,$pluginHome); - } - } - closedir($handle); } - } - - function packPlugin ( $pluginName, $version ) { + $content = $template->getOutputContent(); + $iSize = file_put_contents( $fileName, $content ); + return $iSize; +} - $pathBase = PATH_DATA . 'skins' . PATH_SEP . $pluginName . PATH_SEP; - $pathHome = PATH_DATA . 'skins' . PATH_SEP . $pluginName ; - $fileTar = PATH_DATA . 'skins' . PATH_SEP . $pluginName . '-' . $version . '.tar'; - - G::LoadSystem ('templatePower'); -/* +function addTarFolder ($tar, $pathBase, $pluginHome) +{ + $aux = explode( PATH_SEP, $pathBase ); + if ($aux[count( $aux ) - 2] == '.svn') + return; + + if ($handle = opendir( $pathBase )) { + while (false !== ($file = readdir( $handle ))) { + if (is_file( $pathBase . $file )) { + //print "file $file \n"; + $tar->addModify( $pathBase . $file, '', $pluginHome ); + } + if (is_dir( $pathBase . $file ) && $file != '..' && $file != '.') { + //print "dir $pathBase$file \n"; + addTarFolder( $tar, $pathBase . $file . PATH_SEP, $pluginHome ); + } + } + closedir( $handle ); + } +} + +function packPlugin ($pluginName, $version) +{ + + $pathBase = PATH_DATA . 'skins' . PATH_SEP . $pluginName . PATH_SEP; + $pathHome = PATH_DATA . 'skins' . PATH_SEP . $pluginName; + $fileTar = PATH_DATA . 'skins' . PATH_SEP . $pluginName . '-' . $version . '.tar'; + + G::LoadSystem( 'templatePower' ); + /* $pluginDirectory = PATH_PLUGINS . $pluginName; $pluginOutDirectory = PATH_OUTTRUNK . 'plugins' . PATH_SEP . $pluginName; $pluginHome = PATH_OUTTRUNK . 'plugins' . PATH_SEP . $pluginName; - //verify if plugin exists, + //verify if plugin exists, $pluginClassFilename = PATH_PLUGINS . $pluginName . PATH_SEP . 'class.' . $pluginName . '.php'; - if ( !is_file ( $pluginClassFilename ) ) { + if ( !is_file ( $pluginClassFilename ) ) { printf("The plugin %s doesn't exist in this file %s \n", pakeColor::colorize( $pluginName, 'ERROR'), pakeColor::colorize( $pluginClassFilename, 'INFO') ); die ; } - */ - G::LoadThirdParty( 'pear/Archive','Tar'); - $tar = new Archive_Tar ( $fileTar); - $tar->_compress=false; + */ + G::LoadThirdParty( 'pear/Archive', 'Tar' ); + $tar = new Archive_Tar( $fileTar ); + $tar->_compress = false; //$tar->createModify( $pathHome . PATH_SEP . $pluginName . '.php' ,'', $pathHome); - addTarFolder ( $tar, $pathBase, $pathHome ); - $aFiles = $tar->listContent(); - return $fileTar; - } - -global $RBAC; -switch ($RBAC->userCanAccess('PM_SETUP')) -{ - case -2: - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels'); - G::header('location: ../login/login'); - die; - break; - case -1: - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - G::header('location: ../login/login'); - die; - break; + addTarFolder( $tar, $pathBase, $pathHome ); + $aFiles = $tar->listContent(); + return $fileTar; } - G::LoadClass("system"); +global $RBAC; +switch ($RBAC->userCanAccess( 'PM_SETUP' )) { + case - 2: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; + case - 1: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; +} - $id = $_GET['id']; - - $fileObj = PATH_SKINS . $id . '.cnf'; - - if ( !file_exists($fileObj) ) { +G::LoadClass( "system" ); + +$id = $_GET['id']; + +$fileObj = PATH_SKINS . $id . '.cnf'; + +if (! file_exists( $fileObj )) { $oConf = new stdClass(); $oConf->name = $id; $oConf->description = "description of skin $id "; - $oConf->version = 1; - file_put_contents ( $fileObj, serialize ( $oConf) ); - } + $oConf->version = 1; + file_put_contents( $fileObj, serialize( $oConf ) ); +} + +$oConf = unserialize( file_get_contents( $fileObj ) ); +$oConf->version += 1; +file_put_contents( $fileObj, serialize( $oConf ) ); + +$pathHome = PATH_DATA . 'skins' . PATH_SEP . $id . PATH_SEP; +$pathBase = PATH_DATA . 'skins' . PATH_SEP . $id . PATH_SEP . $id . PATH_SEP; +$pathPublic = $pathBase . 'data' . PATH_SEP . 'public_html' . PATH_SEP; +$pathImages = PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP . 'images' . PATH_SEP; + +G::mk_dir( $pathBase ); +G::mk_dir( $pathBase . 'data' ); +G::mk_dir( $pathPublic ); +G::mk_dir( $pathPublic . 'images' ); - $oConf = unserialize ( file_get_contents ( $fileObj )); - $oConf->version += 1; - file_put_contents ( $fileObj, serialize ( $oConf) ); - - $pathHome = PATH_DATA . 'skins' . PATH_SEP . $id . PATH_SEP; - $pathBase = PATH_DATA . 'skins' . PATH_SEP . $id . PATH_SEP . $id . PATH_SEP; - $pathPublic = $pathBase . 'data' . PATH_SEP . 'public_html' . PATH_SEP ; - $pathImages = PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP . 'images' . PATH_SEP; - - G::mk_dir ( $pathBase ); - G::mk_dir ( $pathBase . 'data' ); - G::mk_dir ( $pathPublic ); - G::mk_dir ( $pathPublic . 'images' ); - // file_put_contents ( PATH_DATA . 'skins' . PATH_SEP . $id , "hello world" ); - $fields['className'] = $id; - $fields['version'] = $oConf->version; - $fields['description'] = $oConf->description; - $fields['PMversion'] = System::getVersion(); - savePluginFile ( 'skinPluginMainClass' , $pathHome . $id . '.php', $fields ); +$fields['className'] = $id; +$fields['version'] = $oConf->version; +$fields['description'] = $oConf->description; +$fields['PMversion'] = System::getVersion(); +savePluginFile( 'skinPluginMainClass', $pathHome . $id . '.php', $fields ); - savePluginFile ( 'skinPluginClass' , $pathBase . 'class.' . $id . '.php', $fields ); - - copyFile ( PATH_SKINS . $id . '.php' , $pathBase . 'data' ); - copyFile ( PATH_SKINS . $id . '.html' , $pathBase . 'data' ); - copyFile ( PATH_SKINS . $id . '.cnf' , $pathBase . 'data' ); - - copyFile ( PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP . 'iepngfix.htc' , $pathPublic ); - copyFile ( PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP . 'style.css' , $pathPublic ); +savePluginFile( 'skinPluginClass', $pathBase . 'class.' . $id . '.php', $fields ); +copyFile( PATH_SKINS . $id . '.php', $pathBase . 'data' ); +copyFile( PATH_SKINS . $id . '.html', $pathBase . 'data' ); +copyFile( PATH_SKINS . $id . '.cnf', $pathBase . 'data' ); - $aFiles = array (); - if ($handle = opendir( $pathImages )) { - while ( false !== ($file = readdir($handle))) { - if ( substr($file,0,1) != '.' ) { - if ( isset($aFiles[ $file ]) ) $aFiles[$file] = 0; - copyFile ( $pathImages. $file , $pathPublic . 'images' . PATH_SEP ); - - } +copyFile( PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP . 'iepngfix.htc', $pathPublic ); +copyFile( PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP . 'style.css', $pathPublic ); + +$aFiles = array (); +if ($handle = opendir( $pathImages )) { + while (false !== ($file = readdir( $handle ))) { + if (substr( $file, 0, 1 ) != '.') { + if (isset( $aFiles[$file] )) + $aFiles[$file] = 0; + copyFile( $pathImages . $file, $pathPublic . 'images' . PATH_SEP ); + + } } - closedir($handle); - } - - $fileTar = packPlugin ( $id, $oConf->version ); - + closedir( $handle ); +} + +$fileTar = packPlugin( $id, $oConf->version ); + +$bDownload = true; +G::streamFile( $fileTar, $bDownload, basename( $fileTar ) ); + +@G::rm_dir( $pathHome ); +@unlink( $fileTar ); - $bDownload = true; - G::streamFile ( $fileTar, $bDownload, basename($fileTar) ); - - @G::rm_dir ($pathHome); - @unlink ($fileTar); diff --git a/workflow/engine/methods/setup/skinsList.php b/workflow/engine/methods/setup/skinsList.php index 31ee281dc..85006b1b2 100755 --- a/workflow/engine/methods/setup/skinsList.php +++ b/workflow/engine/methods/setup/skinsList.php @@ -1,4 +1,4 @@ -. + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ -if($RBAC->userCanAccess('PM_SETUP') != 1 && $RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1){ - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - //G::header('location: ../login/login'); - die; +if ($RBAC->userCanAccess( 'PM_SETUP' ) != 1 && $RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) { + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + //G::header('location: ../login/login'); + die(); } - + $G_MAIN_MENU = 'processmaker'; $G_SUB_MENU = 'setup'; $G_ID_MENU_SELECTED = 'SETUP'; $G_ID_SUB_MENU_SELECTED = 'CALENDAR'; -$G_PUBLISH = new Publisher; +$G_PUBLISH = new Publisher(); -G::LoadClass('configuration'); +G::LoadClass( 'configuration' ); $c = new Configurations(); -$configPage = $c->getConfiguration('skinList', 'pageSize','',$_SESSION['USER_LOGGED']); -$Config['pageSize'] = isset($configPage['pageSize']) ? $configPage['pageSize'] : 20; +$configPage = $c->getConfiguration( 'skinList', 'pageSize', '', $_SESSION['USER_LOGGED'] ); +$Config['pageSize'] = isset( $configPage['pageSize'] ) ? $configPage['pageSize'] : 20; -$oHeadPublisher =& headPublisher::getSingleton(); -$oHeadPublisher->addExtJsScript('setup/skinList', false); //adding a javascript file .js -$oHeadPublisher->addContent('setup/skinList'); //adding a html file .html. -$oHeadPublisher->assign('CONFIG', $Config); -$oHeadPublisher->assign('SYS_SKIN', SYS_SKIN); +$oHeadPublisher = & headPublisher::getSingleton(); +$oHeadPublisher->addExtJsScript( 'setup/skinList', false ); //adding a javascript file .js +$oHeadPublisher->addContent( 'setup/skinList' ); //adding a html file .html. +$oHeadPublisher->assign( 'CONFIG', $Config ); +$oHeadPublisher->assign( 'SYS_SKIN', SYS_SKIN ); -$oHeadPublisher->assign('FORMATS',$c->getFormats()); +$oHeadPublisher->assign( 'FORMATS', $c->getFormats() ); -G::RenderPage('publish', 'extJs'); -die; +G::RenderPage( 'publish', 'extJs' ); +die(); global $RBAC; -$access = $RBAC->userCanAccess('PM_SETUP'); -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_SETUP' ); +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; + } } - // lets display the items - $items[] = array ( 'id' => 'char', 'title' => 'char', 'type' => 'char', 'creator' => 'char' , - 'modifiedBy' => 'char', 'filename' => 'char', 'size' => 'char', 'mime' => 'char'); +// lets display the items +$items[] = array ('id' => 'char','title' => 'char','type' => 'char','creator' => 'char','modifiedBy' => 'char','filename' => 'char','size' => 'char','mime' => 'char' +); - //***************** Skins ************************** - $aFiles = array (); - if ($handle = opendir( PATH_SKINS )) { - while ( false !== ($file = readdir($handle))) { - G::pr($file); - $filename = substr ( $file,0, strrpos($file, '.')); +//***************** Skins ************************** +$aFiles = array (); +if ($handle = opendir( PATH_SKINS )) { + while (false !== ($file = readdir( $handle ))) { + G::pr( $file ); + $filename = substr( $file, 0, strrpos( $file, '.' ) ); - // list of no complete skins - $aFilterSkinsList = Array('blank', 'green', 'raw', 'tracker', 'iphone', 'green-submenu', 'extJsInitLoad', 'extJs' ); - - if ( !is_dir(PATH_SKINS. $file) ) { - if ( !in_array($filename, $aFilterSkinsList) /*&& /*/ && !strpos($file, '.tar', 1) ) { - if ( !isset($aFiles[ $filename ]) ) $aFiles[$filename] = 0; - if ( strpos($file, '.php', 1) ) $aFiles[ $filename ] += 1; - if ( strpos($file, '.html',1) ) $aFiles[ $filename ] += 2; + // list of no complete skins + $aFilterSkinsList = Array ('blank','green','raw','tracker','iphone','green-submenu','extJsInitLoad','extJs' + ); + + if (! is_dir( PATH_SKINS . $file )) { + if (! in_array( $filename, $aFilterSkinsList ) /*&& /*/ && ! strpos( $file, '.tar', 1 )) { + if (! isset( $aFiles[$filename] )) + $aFiles[$filename] = 0; + if (strpos( $file, '.php', 1 )) + $aFiles[$filename] += 1; + if (strpos( $file, '.html', 1 )) + $aFiles[$filename] += 2; + } } - } } - closedir($handle); - + closedir( $handle ); //now walk in the array to get the .cnf file and display properties - foreach ( $aFiles as $key => $val ) { - $description = ''; - $version = ''; - if ( file_exists ( PATH_SKINS . $key . '.cnf' ) ) { - $serial = file_get_contents ( PATH_SKINS . $key . '.cnf' ); - $previousErrorRep = ini_get("error_reporting"); - error_reporting( E_ERROR ) ; - $prop = unserialize ( $serial ); - error_reporting( $previousErrorRep ); - if ( !is_object( $prop ) ) { - @unlink ( PATH_SKINS . $key . '.cnf'); + foreach ($aFiles as $key => $val) { + $description = ''; + $version = ''; + if (file_exists( PATH_SKINS . $key . '.cnf' )) { + $serial = file_get_contents( PATH_SKINS . $key . '.cnf' ); + $previousErrorRep = ini_get( "error_reporting" ); + error_reporting( E_ERROR ); + $prop = unserialize( $serial ); + error_reporting( $previousErrorRep ); + if (! is_object( $prop )) { + @unlink( PATH_SKINS . $key . '.cnf' ); + } + if (isset( $prop ) && isset( $prop->description )) + $description = $prop->description; + if (isset( $prop ) && isset( $prop->version )) + $version = $prop->version; } - if ( isset ( $prop) && isset($prop->description) ) $description = $prop->description; - if ( isset ( $prop) && isset($prop->version ) ) $version = $prop->version; - } - - $linkPackValue = G::LoadTranslation('ID_EXPORT') ; - $link = 'skinsExport?id=' . $key ; - $items[] = array ( - 'id' => count($items), - 'name' => $key, - 'filename' => $key, - 'description' => $description, - 'version' => $version, - 'url' => $link, - 'linkPackValue' => $linkPackValue - ); + + $linkPackValue = G::LoadTranslation( 'ID_EXPORT' ); + $link = 'skinsExport?id=' . $key; + $items[] = array ('id' => count( $items ),'name' => $key,'filename' => $key,'description' => $description,'version' => $version,'url' => $link,'linkPackValue' => $linkPackValue + ); } $folders['items'] = $items; - } - - $_DBArray['plugins'] = $items; - $_SESSION['_DBArray'] = $_DBArray; +} - G::LoadClass( 'ArrayPeer'); - $c = new Criteria ('dbarray'); - $c->setDBArrayTable('plugins'); - $c->addAscendingOrderByColumn ('id'); +$_DBArray['plugins'] = $items; +$_SESSION['_DBArray'] = $_DBArray; - $G_MAIN_MENU = 'processmaker'; - $G_ID_MENU_SELECTED = 'SETUP'; - $G_SUB_MENU = 'setup'; - $G_ID_SUB_MENU_SELECTED = 'SKINS'; +G::LoadClass( 'ArrayPeer' ); +$c = new Criteria( 'dbarray' ); +$c->setDBArrayTable( 'plugins' ); +$c->addAscendingOrderByColumn( 'id' ); - $G_PUBLISH = new Publisher; +$G_MAIN_MENU = 'processmaker'; +$G_ID_MENU_SELECTED = 'SETUP'; +$G_SUB_MENU = 'setup'; +$G_ID_SUB_MENU_SELECTED = 'SKINS'; - $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/skinsList', $c ); +$G_PUBLISH = new Publisher(); - G::RenderPage('publishBlank', 'blank'); +$G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/skinsList', $c ); + +G::RenderPage( 'publishBlank', 'blank' ); diff --git a/workflow/engine/methods/setup/skinsNew.php b/workflow/engine/methods/setup/skinsNew.php index 7875f9dd3..2bdd99ed0 100755 --- a/workflow/engine/methods/setup/skinsNew.php +++ b/workflow/engine/methods/setup/skinsNew.php @@ -1,58 +1,57 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -$access = $RBAC->userCanAccess('PM_SETUP'); -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; - } -} -if (($RBAC_Response=$RBAC->userCanAccess("PM_SETUP"))!=1) return $RBAC_Response; - - $dbc = new DBConnection; - $G_PUBLISH = new Publisher; - $G_MAIN_MENU = 'processmaker'; - $G_ID_MENU_SELECTED = 'SETUP'; - $G_SUB_MENU = 'setup'; - $G_ID_SUB_MENU_SELECTED = 'SKINS'; - - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', "setup/skinsNew", '', null, "skinsSave"); - G::RenderPage( 'publishBlank', 'blank' ); - \ No newline at end of file +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +$access = $RBAC->userCanAccess( 'PM_SETUP' ); +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; + } +} +if (($RBAC_Response = $RBAC->userCanAccess( "PM_SETUP" )) != 1) + return $RBAC_Response; + +$dbc = new DBConnection(); +$G_PUBLISH = new Publisher(); +$G_MAIN_MENU = 'processmaker'; +$G_ID_MENU_SELECTED = 'SETUP'; +$G_SUB_MENU = 'setup'; +$G_ID_SUB_MENU_SELECTED = 'SKINS'; + +$G_PUBLISH->AddContent( 'xmlform', 'xmlform', "setup/skinsNew", '', null, "skinsSave" ); +G::RenderPage( 'publishBlank', 'blank' ); + diff --git a/workflow/engine/methods/setup/skinsSave.php b/workflow/engine/methods/setup/skinsSave.php index 13ddf9f7f..5c09fc002 100755 --- a/workflow/engine/methods/setup/skinsSave.php +++ b/workflow/engine/methods/setup/skinsSave.php @@ -1,4 +1,5 @@ . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ - - function xcopy ( $pathSource, $pathTarget ) { - G::mk_dir ($pathTarget); - if ($handle = opendir( $pathSource )) { - while ( false !== ($file = readdir($handle))) { - if ( substr($file,0,1) != '.' && !is_dir ($file) ) { - $content = file_get_contents ( $pathSource . $file ); - $filename = $pathTarget . $file ; - file_put_contents ( $filename, $content ); - } - } - closedir($handle); - } - } - - -global $RBAC; -switch ($RBAC->userCanAccess('PM_SETUP')) +function xcopy ($pathSource, $pathTarget) { - case -2: - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels'); - G::header('location: ../login/login'); - die; - break; - case -1: - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - G::header('location: ../login/login'); - die; - break; + G::mk_dir( $pathTarget ); + if ($handle = opendir( $pathSource )) { + while (false !== ($file = readdir( $handle ))) { + if (substr( $file, 0, 1 ) != '.' && ! is_dir( $file )) { + $content = file_get_contents( $pathSource . $file ); + $filename = $pathTarget . $file; + file_put_contents( $filename, $content ); + } + } + closedir( $handle ); + } } - G::LoadClass("system"); +global $RBAC; +switch ($RBAC->userCanAccess( 'PM_SETUP' )) { + case - 2: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; + case - 1: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; +} - $id = strip_tags ( str_replace ( ' ', '_', trim ($_POST['form']['NAME']) ) ); - $desc = $_POST['form']['DESCRIPTION']; - - $fileObj = PATH_SKINS . $id . '.cnf'; - - if ( !file_exists($fileObj) ) { +G::LoadClass( "system" ); + +$id = strip_tags( str_replace( ' ', '_', trim( $_POST['form']['NAME'] ) ) ); +$desc = $_POST['form']['DESCRIPTION']; + +$fileObj = PATH_SKINS . $id . '.cnf'; + +if (! file_exists( $fileObj )) { $oConf = new stdClass(); $oConf->name = $id; $oConf->description = $desc; - $oConf->version = 1; - file_put_contents ( $fileObj, serialize ( $oConf) ); - } + $oConf->version = 1; + file_put_contents( $fileObj, serialize( $oConf ) ); +} - $oConf = unserialize ( file_get_contents ( $fileObj )); +$oConf = unserialize( file_get_contents( $fileObj ) ); - $contentPHP = file_get_contents ( PATH_SKINS . 'green.php' ); - $contentPHP = str_replace ( 'green.html', $id.'.html', $contentPHP ); - file_put_contents ( PATH_SKINS . $id . '.php', $contentPHP ); - - $contentHTML = file_get_contents ( PATH_SKINS . 'green.html' ); - $contentHTML = str_replace ( 'green', $id , $contentHTML ); - file_put_contents ( PATH_SKINS . $id . '.html', $contentHTML ); +$contentPHP = file_get_contents( PATH_SKINS . 'green.php' ); +$contentPHP = str_replace( 'green.html', $id . '.html', $contentPHP ); +file_put_contents( PATH_SKINS . $id . '.php', $contentPHP ); - $pathImages = PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP . 'images' . PATH_SEP; - G::mk_dir ( $pathImages ); - - xcopy ( - PATH_HTML . 'skins' . PATH_SEP . 'green' . PATH_SEP , - PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP - ); +$contentHTML = file_get_contents( PATH_SKINS . 'green.html' ); +$contentHTML = str_replace( 'green', $id, $contentHTML ); +file_put_contents( PATH_SKINS . $id . '.html', $contentHTML ); - xcopy ( - PATH_HTML . 'skins' . PATH_SEP . 'green' . PATH_SEP . 'images'. PATH_SEP, - PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP . 'images'. PATH_SEP - ); +$pathImages = PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP . 'images' . PATH_SEP; +G::mk_dir( $pathImages ); + +xcopy( PATH_HTML . 'skins' . PATH_SEP . 'green' . PATH_SEP, PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP ); + +xcopy( PATH_HTML . 'skins' . PATH_SEP . 'green' . PATH_SEP . 'images' . PATH_SEP, PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP . 'images' . PATH_SEP ); + +G::Header( 'Location: ../../' . $id . '/setup/skinsList' ); - G::Header ( 'Location: ../../' . $id . '/setup/skinsList' ); diff --git a/workflow/engine/methods/setup/upgrade.php b/workflow/engine/methods/setup/upgrade.php index ee4e912dd..b9fd189c3 100755 --- a/workflow/engine/methods/setup/upgrade.php +++ b/workflow/engine/methods/setup/upgrade.php @@ -1,74 +1,72 @@ -. - * - * 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_SETUP_ADVANCE'); -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; - } -} -//calculating the max upload file size; - $POST_MAX_SIZE = ini_get('post_max_size'); - $mul = substr($POST_MAX_SIZE, -1); - $mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1))); - $postMaxSize = (int)$POST_MAX_SIZE * $mul; - - $UPLOAD_MAX_SIZE = ini_get('upload_max_filesize'); - $mul = substr($UPLOAD_MAX_SIZE, -1); - $mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1))); - $uploadMaxSize = (int)$UPLOAD_MAX_SIZE * $mul; - - if ( $postMaxSize < $uploadMaxSize ) $uploadMaxSize = $postMaxSize; - - - $G_MAIN_MENU = 'processmaker'; - $G_SUB_MENU = 'setup'; - $G_ID_MENU_SELECTED = 'SETUP'; - $G_ID_SUB_MENU_SELECTED = 'UPGRADE'; - - G::LoadClass("system"); - - $Fields['PM_VERSION'] = System::getVersion(); - $Fields['MAX_FILE_SIZE'] = $uploadMaxSize . " (" . $UPLOAD_MAX_SIZE . ") "; - - $G_PUBLISH = new Publisher; - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/upgrade', '', $Fields, 'upgrade_System'); - G::RenderPage('publishBlank', 'blank'); - +. + * + * 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_SETUP_ADVANCE' ); +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; + } +} +//calculating the max upload file size; +$POST_MAX_SIZE = ini_get( 'post_max_size' ); +$mul = substr( $POST_MAX_SIZE, - 1 ); +$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1))); +$postMaxSize = (int) $POST_MAX_SIZE * $mul; + +$UPLOAD_MAX_SIZE = ini_get( 'upload_max_filesize' ); +$mul = substr( $UPLOAD_MAX_SIZE, - 1 ); +$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1))); +$uploadMaxSize = (int) $UPLOAD_MAX_SIZE * $mul; + +if ($postMaxSize < $uploadMaxSize) + $uploadMaxSize = $postMaxSize; + +$G_MAIN_MENU = 'processmaker'; +$G_SUB_MENU = 'setup'; +$G_ID_MENU_SELECTED = 'SETUP'; +$G_ID_SUB_MENU_SELECTED = 'UPGRADE'; + +G::LoadClass( "system" ); + +$Fields['PM_VERSION'] = System::getVersion(); +$Fields['MAX_FILE_SIZE'] = $uploadMaxSize . " (" . $UPLOAD_MAX_SIZE . ") "; + +$G_PUBLISH = new Publisher(); +$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/upgrade', '', $Fields, 'upgrade_System' ); +G::RenderPage( 'publishBlank', 'blank' ); + diff --git a/workflow/engine/methods/setup/upgrade_RBAC.php b/workflow/engine/methods/setup/upgrade_RBAC.php index 647b39652..372af5d9d 100755 --- a/workflow/engine/methods/setup/upgrade_RBAC.php +++ b/workflow/engine/methods/setup/upgrade_RBAC.php @@ -39,4 +39,5 @@ $aRequiredPermissions = array('PM_LOGIN', 'PM_FOLDERS_VIEW', 'PM_FOLDERS_ADD_FOLDER', 'PM_FOLDERS_ADD_FILE' - ); \ No newline at end of file + ); + diff --git a/workflow/engine/methods/setup/upgrade_System.php b/workflow/engine/methods/setup/upgrade_System.php index 96db604be..fdc4d9e6c 100755 --- a/workflow/engine/methods/setup/upgrade_System.php +++ b/workflow/engine/methods/setup/upgrade_System.php @@ -1,110 +1,108 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -/** - * New System Upgrade controller - * - * @author Erik A. O. - * @date May 12th, 2010 - */ -global $RBAC; -switch ($RBAC->userCanAccess('PM_SETUP_ADVANCE')) -{ - case -2: - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels'); - G::header('location: ../login/login'); - die; - break; - case -1: - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - G::header('location: ../login/login'); - die; - break; -} -set_time_limit(0); - -$G_MAIN_MENU = 'processmaker'; -$G_SUB_MENU = 'setup'; -$G_ID_MENU_SELECTED = 'SETUP'; -$G_ID_SUB_MENU_SELECTED = 'UPGRADE'; - -require_once "classes/class.system.php"; -$oSystem = new System(); - -try { - if( ! $oSystem->verifyFileForUpgrade() ){ - throw ( new Exception ("There was an error uploading the file, probably the file size if greater than upload_max_filesize parameter in php.ini, please check this parameter and try again." ) ); - } - $oSystem->cleanupUpgradeDirectory(); - $oSystem->getUpgradedFilesList(); - - $ver = $oSystem->upgrade(); - $G_PUBLISH = new Publisher; - $aMessage['THEMESSAGE1'] = G::LoadTranslation('ID_UPGRADE_READY') ." ". $ver[0] ." ". G::LoadTranslation('ID_TO') ." ". $ver[1] .""; - $aMessage['THEMESSAGE2'] = file_get_contents($oSystem->sUpgradeFileList); - $aMessage['THEMESSAGE3'] = ''; - - if ( !is_Array($oSystem->aErrors) || count($oSystem->aErrors) == 0 ) - $aMessage['THEMESSAGE4'] = G::LoadTranslation('ID_NONE'); - else - $aMessage['THEMESSAGE4'] = implode( "\n", $oSystem->aErrors) ; - - $oHeadPublisher =& headPublisher::getSingleton(); - if( file_exists(PATH_CORE . 'js' . PATH_SEP . 'setup' . PATH_SEP . 'upgrade_System.js') ){ - $oHeadPublisher->addScriptFile('/jscore/setup/upgrade_System.js'); - } else { - $oHeadPublisher->addScriptCode("function upgradeSystem(wsCount) { - document.getElementById('form[THETITLE3]').innerHTML = wsCount + ' workspaces to update.'; - document.getElementById('form[SUBTITLE4]').innerHTML = '   Please wait...'; - updateWorkspace(wsCount); - }; - function updateWorkspace(id) { - if(id < 0) return false; - var oRPC = new leimnud.module.rpc.xmlhttp({ - async : true, - method: 'POST', - url: '../setup/upgrade_SystemAjax', - args : 'id=' + id - }); - oRPC.callback = function(rpc) { - document.getElementById('form[SUBTITLE4]').innerHTML = rpc.xmlhttp.responseText; - updateWorkspace(id-1); - }.extend(this); - oRPC.make(); - };"); - } - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showInfoUpdate', '', $aMessage ); - - G::RenderPage( 'publishBlank', 'blank' ); - G::evalJScript('upgradeSystem('.count($oSystem->aWorkspaces).')'); - exit(0); -} -catch (Exception $e) { - $G_PUBLISH = new Publisher; - $aMessage['MESSAGE'] = $e->getMessage(); - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); - G::RenderPage( 'publishBlank', 'blank' ); - exit(0); -} +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +/** + * New System Upgrade controller + * + * @author Erik A. O. + * @date May 12th, 2010 + */ +global $RBAC; +switch ($RBAC->userCanAccess( 'PM_SETUP_ADVANCE' )) { + case - 2: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; + case - 1: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; +} +set_time_limit( 0 ); + +$G_MAIN_MENU = 'processmaker'; +$G_SUB_MENU = 'setup'; +$G_ID_MENU_SELECTED = 'SETUP'; +$G_ID_SUB_MENU_SELECTED = 'UPGRADE'; + +require_once "classes/class.system.php"; +$oSystem = new System(); + +try { + if (! $oSystem->verifyFileForUpgrade()) { + throw (new Exception( "There was an error uploading the file, probably the file size if greater than upload_max_filesize parameter in php.ini, please check this parameter and try again." )); + } + $oSystem->cleanupUpgradeDirectory(); + $oSystem->getUpgradedFilesList(); + + $ver = $oSystem->upgrade(); + $G_PUBLISH = new Publisher(); + $aMessage['THEMESSAGE1'] = G::LoadTranslation( 'ID_UPGRADE_READY' ) . " " . $ver[0] . " " . G::LoadTranslation( 'ID_TO' ) . " " . $ver[1] . ""; + $aMessage['THEMESSAGE2'] = file_get_contents( $oSystem->sUpgradeFileList ); + $aMessage['THEMESSAGE3'] = ''; + + if (! is_Array( $oSystem->aErrors ) || count( $oSystem->aErrors ) == 0) + $aMessage['THEMESSAGE4'] = G::LoadTranslation( 'ID_NONE' ); + else + $aMessage['THEMESSAGE4'] = implode( "\n", $oSystem->aErrors ); + + $oHeadPublisher = & headPublisher::getSingleton(); + if (file_exists( PATH_CORE . 'js' . PATH_SEP . 'setup' . PATH_SEP . 'upgrade_System.js' )) { + $oHeadPublisher->addScriptFile( '/jscore/setup/upgrade_System.js' ); + } else { + $oHeadPublisher->addScriptCode( "function upgradeSystem(wsCount) { + document.getElementById('form[THETITLE3]').innerHTML = wsCount + ' workspaces to update.'; + document.getElementById('form[SUBTITLE4]').innerHTML = '   Please wait...'; + updateWorkspace(wsCount); + }; + function updateWorkspace(id) { + if(id < 0) return false; + var oRPC = new leimnud.module.rpc.xmlhttp({ + async : true, + method: 'POST', + url: '../setup/upgrade_SystemAjax', + args : 'id=' + id + }); + oRPC.callback = function(rpc) { + document.getElementById('form[SUBTITLE4]').innerHTML = rpc.xmlhttp.responseText; + updateWorkspace(id-1); + }.extend(this); + oRPC.make(); + };" ); + } + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showInfoUpdate', '', $aMessage ); + + G::RenderPage( 'publishBlank', 'blank' ); + G::evalJScript( 'upgradeSystem(' . count( $oSystem->aWorkspaces ) . ')' ); + exit( 0 ); +} catch (Exception $e) { + $G_PUBLISH = new Publisher(); + $aMessage['MESSAGE'] = $e->getMessage(); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); + G::RenderPage( 'publishBlank', 'blank' ); + exit( 0 ); +} + diff --git a/workflow/engine/methods/setup/upgrade_SystemAjax.php b/workflow/engine/methods/setup/upgrade_SystemAjax.php index 7fa78bb32..74c928e88 100755 --- a/workflow/engine/methods/setup/upgrade_SystemAjax.php +++ b/workflow/engine/methods/setup/upgrade_SystemAjax.php @@ -1,389 +1,396 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - global $DB_ADAPTER; - global $DB_HOST; - global $DB_USER; - global $DB_PASS; - global $DB_NAME; - set_time_limit (0); - - $id = ''; - if ( isset($_POST['id'] ) ) $id = $_POST['id']; - - G::LoadClass('languages'); - G::LoadSystem('database_mysql'); - - $aUpgradeData = unserialize( file_get_contents (PATH_DATA . 'log' . PATH_SEP . "upgrade.data.bin" )); - $aWorkspaces = $aUpgradeData['workspaces']; - - if ( is_array ( $aWorkspaces ) && count($aWorkspaces) > 0 ) { - $workspace = array_shift ( $aUpgradeData['workspaces']); - - eval ( getDatabaseCredentials(PATH_DB . $workspace . PATH_SEP . 'db.php')) ; - $oDataBase = new database($DB_ADAPTER, $DB_HOST, $DB_USER, $DB_PASS, $DB_NAME); - $oDataBase->iFetchType = MYSQL_NUM; - - //processing .po file - if ( $aUpgradeData['sPoFile'] != '' ) { - $oLanguages = new languages(); - $oLanguages->importLanguage($aUpgradeData['sPoFile'], $aUpgradeData['bForceXmlPoFile'] ); - $aUpgradeData['bForceXmlPoFile'] = false; - } - - if ($aUpgradeData['sSchemaFile'] != '') - processMasterSchemaFile( $aUpgradeData['sSchemaFile'] ); - - - //draw a gauge control indicating the progress in workspaces - $gauge = intval( (( $aUpgradeData['wsQuantity'] - count($aWorkspaces) + 1 ) / $aUpgradeData['wsQuantity'] ) * 301 ); - print "
"; - print "
"; - print "
"; - print "
Upgrading the workspace $workspace| $id Remaining
"; - file_put_contents (PATH_DATA . 'log' . PATH_SEP . "upgrade.data.bin", serialize($aUpgradeData) ); - } - else { - print "
    "; - print "
"; - print "
"; - print "
Finished! All workspaces were upgraded successfully.
"; - } - -die; - -function getDatabaseCredentials ( $dbFile ) { - $sContent = file_get_contents( $dbFile ); - $sContent = str_replace('', '', $sContent); - $sContent = str_replace('define', '', $sContent); - $sContent = str_replace("('", '$', $sContent); - $sContent = str_replace("',", '=', $sContent); - $sContent = str_replace(");", ';', $sContent); - return $sContent; -} - -function processMasterSchemaFile ( $sSchemaFile ) { - global $DB_ADAPTER; - global $DB_HOST; - global $DB_USER; - global $DB_PASS; - global $DB_NAME; - global $aUpgradeData; - - //convert newSchema to array - if ( isset($aUpgradeData['aNewSchema']) ) { - $aNewSchema = $aUpgradeData['aNewSchema']; - } - else { - $aNewSchema = schemaToArray($sSchemaFile); - $aUpgradeData['aNewSchema'] = $aNewSchema; - } - $aOldSchema = processSchemaFile(); - if ( is_null($aOldSchema) ) { - return; - } - $aChanges = obtainChanges($aOldSchema, $aNewSchema); - - $oDataBase = new database($DB_ADAPTER, $DB_HOST, $DB_USER, $DB_PASS, $DB_NAME); - if ( !$oDataBase->isConnected() ) { - return; - } - $oDataBase->iFetchType = MYSQL_NUM; - - $oDataBase->logQuery ( count ($aChanges ) ); - - foreach ($aChanges['tablesToAdd'] as $sTable => $aColumns) { - $oDataBase->executeQuery($oDataBase->generateCreateTableSQL($sTable, $aColumns)); - if (isset($aChanges['tablesToAdd'][$sTable]['INDEXES'])) { - foreach ($aChanges['tablesToAdd'][$sTable]['INDEXES'] as $indexName => $aIndex) { - $oDataBase->executeQuery($oDataBase->generateAddKeysSQL($sTable, $indexName, $aIndex ) ); - } - } - } - - foreach ($aChanges['tablesToAlter'] as $sTable => $aActions) { - foreach ($aActions as $sAction => $aAction) { - foreach ($aAction as $sColumn => $vData) { - switch ($sAction) { - case 'DROP': - $oDataBase->executeQuery($oDataBase->generateDropColumnSQL($sTable, $vData)); - break; - case 'ADD': - $oDataBase->executeQuery($oDataBase->generateAddColumnSQL($sTable, $sColumn, $vData)); - break; - case 'CHANGE': - $oDataBase->executeQuery($oDataBase->generateChangeColumnSQL($sTable, $sColumn, $vData)); - break; - } - } - } - } - - foreach ($aChanges['tablesWithNewIndex'] as $sTable => $aIndexes) { - foreach ($aIndexes as $sIndexName => $aIndexFields ) { - $oDataBase->executeQuery($oDataBase->generateAddKeysSQL($sTable, $sIndexName, $aIndexFields )); - } - } - - foreach ($aChanges['tablesToAlterIndex'] as $sTable => $aIndexes) { - foreach ($aIndexes as $sIndexName => $aIndexFields ) { - $oDataBase->executeQuery($oDataBase->generateDropKeySQL($sTable, $sIndexName )); - $oDataBase->executeQuery($oDataBase->generateAddKeysSQL($sTable, $sIndexName, $aIndexFields )); - } - } - $oDataBase->close(); -} - - -function processSchemaFile( ) { - global $DB_ADAPTER; - global $DB_HOST; - global $DB_USER; - global $DB_PASS; - global $DB_NAME; - - try { - G::LoadSystem( 'database_' . strtolower($DB_ADAPTER)); - - $aOldSchema = array(); - $oDataBase = new database($DB_ADAPTER, $DB_HOST, $DB_USER, $DB_PASS, $DB_NAME); - - if ( !$oDataBase->isConnected() ) { - $oDataBase->logQuery ('Does not exist an available connection!'); - return NULL; - } - - $oDataBase->iFetchType = MYSQL_NUM; - $oDataset1 = $oDataBase->executeQuery($oDataBase->generateShowTablesSQL()); - - } catch ( Exception $e ) { - $oDataBase->logQuery ( $e->getmessage() ); - return NULL; - } - - //going thru all tables in current WF_ database - while ($aRow1 = $oDataBase->getRegistry( $oDataset1) ) { - $aPrimaryKeys = array(); - $sTable = strtoupper($aRow1[0]); - - //get description of each table, ( column and primary keys ) - //$oDataset2 = $oDataBase->executeQuery( $oDataBase->generateDescTableSQL($aRow1[0]) ); - $oDataset2 = $oDataBase->executeQuery( $oDataBase->generateDescTableSQL($sTable ) ); - $aOldSchema[ $sTable ] = array(); - $oDataBase->iFetchType = MYSQL_ASSOC; - while ($aRow2 = $oDataBase->getRegistry($oDataset2)) { - $aOldSchema[$sTable][$aRow2['Field']]['Field'] = $aRow2['Field']; - $aOldSchema[$sTable][$aRow2['Field']]['Type'] = $aRow2['Type']; - $aOldSchema[$sTable][$aRow2['Field']]['Null'] = $aRow2['Null']; - $aOldSchema[$sTable][$aRow2['Field']]['Default'] = $aRow2['Default']; - } - - //get indexes of each table SHOW INDEX FROM `ADDITIONAL_TABLES`; -- WHERE Key_name <> 'PRIMARY' - $oDataset2 = $oDataBase->executeQuery($oDataBase->generateTableIndexSQL($aRow1[0])); - $oDataBase->iFetchType = MYSQL_ASSOC; - while ($aRow2 = $oDataBase->getRegistry($oDataset2)) { - if ( !isset($aOldSchema[$sTable]['INDEXES']) ) { - $aOldSchema[$sTable]['INDEXES'] = array(); - } - if (!isset($aOldSchema[$sTable]['INDEXES'][$aRow2['Key_name']] ) ) { - $aOldSchema[$sTable]['INDEXES'][$aRow2['Key_name']] = array(); - } - $aOldSchema[$sTable]['INDEXES'][$aRow2['Key_name']][] = $aRow2['Column_name']; - } - - $oDataBase->iFetchType = MYSQL_NUM; //this line is neccesary because the next fetch needs to be with MYSQL_NUM - } - //finally return the array with old schema obtained from the Database - if ( count($aOldSchema) == 0 ) $aOldSchema = null; - return $aOldSchema; -} - -//process the schema file in the patch file, and obtain an array -function schemaToArray($sSchemaFile) { - try { - $aSchema = array(); - $oXml = new DomDocument(); - $oXml->load($sSchemaFile); - $aTables = $oXml->getElementsByTagName('table'); - foreach ($aTables as $oTable) { - $aPrimaryKeys = array(); - $sTableName = $oTable->getAttribute('name'); - $aSchema[$sTableName] = array(); - $aColumns = $oTable->getElementsByTagName('column'); - foreach ($aColumns as $oColumn) { - $sColumName = $oColumn->getAttribute('name'); - $aSchema[$sTableName][$sColumName] = array(); - $aVendors = $oColumn->getElementsByTagName('vendor'); - foreach ($aVendors as $oVendor) { - if ($oVendor->getAttribute('type') == DB_ADAPTER) { - break; - } - } - $aParameters = $oColumn->getElementsByTagName('parameter'); - foreach ($aParameters as $oParameter) { - $parameterName = ucwords($oParameter->getAttribute('name')); - if ( $parameterName == 'Key' && strtoupper($oParameter->getAttribute('value')) == 'PRI' ) { - $aPrimaryKeys[] = $oColumn->getAttribute('name'); - } - - if ( in_array ( $parameterName, array('Field','Type','Null','Default') ) ) { - $aSchema[$sTableName][$sColumName][$parameterName] = $oParameter->getAttribute('value'); - } - } - } - - if ( is_array($aPrimaryKeys) && count($aPrimaryKeys) > 0 ) { - $aSchema[$sTableName]['INDEXES']['PRIMARY'] = $aPrimaryKeys; - } - $aIndexes = $oTable->getElementsByTagName('index'); - foreach ($aIndexes as $oIndex) { - $aIndex = array(); - $aIndexesColumns = $oIndex->getElementsByTagName('index-column'); - foreach ($aIndexesColumns as $oIndexColumn) { - $aIndex[] = $oIndexColumn->getAttribute('name'); - } - $aSchema[$sTableName]['INDEXES'][ $oIndex->getAttribute('name') ] = $aIndex; - } - } - return $aSchema; - } - catch (Exception $oError) { - throw $oError; - } -} - -function obtainChanges($aOldSchema, $aNewSchema) { - //$aChanges = array('tablesToDelete' => array(), 'tablesToAdd' => array(), 'tablesToAlter' => array()); - //Tables to delete, but this is disabled - //foreach ($aOldSchema as $sTableName => $aColumns) { - // if ( !isset($aNewSchema[$sTableName])) { - // if (!in_array($sTableName, array('KT_APPLICATION', 'KT_DOCUMENT', 'KT_PROCESS'))) { - // $aChanges['tablesToDelete'][] = $sTableName; - // } - // } - //} - - $aChanges = array('tablesToAdd' => array(), 'tablesToAlter' => array(), 'tablesWithNewIndex' => array(), 'tablesToAlterIndex'=> array()); - - //new tables to create and alter - foreach ($aNewSchema as $sTableName => $aColumns) { - if (!isset($aOldSchema[$sTableName])) { - $aChanges['tablesToAdd'][$sTableName] = $aColumns; - } - else { - //drop old columns - foreach ($aOldSchema[$sTableName] as $sColumName => $aParameters) { - if (!isset($aNewSchema[$sTableName][$sColumName])) { - if (!isset($aChanges['tablesToAlter'][$sTableName])) { - $aChanges['tablesToAlter'][$sTableName] = array('DROP' => array(), 'ADD' => array(), 'CHANGE' => array()); - } - $aChanges['tablesToAlter'][$sTableName]['DROP'][$sColumName] = $sColumName; - } - } - - //create new columns - //foreach ($aNewSchema[$sTableName] as $sColumName => $aParameters) { - foreach ($aColumns as $sColumName => $aParameters) { - if ($sColumName != 'INDEXES') { - if (!isset($aOldSchema[$sTableName][$sColumName])) { //this column doesnt exist in oldschema - if (!isset($aChanges['tablesToAlter'][$sTableName])) { - $aChanges['tablesToAlter'][$sTableName] = array('DROP' => array(), 'ADD' => array(), 'CHANGE' => array()); - } - $aChanges['tablesToAlter'][$sTableName]['ADD'][$sColumName] = $aParameters; - } - else { //the column exists - $newField = $aNewSchema[$sTableName][$sColumName]; - $oldField = $aOldSchema[$sTableName][$sColumName]; - //both are null, no change is required - if ( !isset($newField['Default']) && !isset($oldField['Default'])) $changeDefaultAttr = false; - //one of them is null, change IS required - if ( !isset($newField['Default']) && isset($oldField['Default']) && $oldField['Default']!= '') $changeDefaultAttr = true; - if ( isset($newField['Default']) && !isset($oldField['Default'])) $changeDefaultAttr = true; - //both are defined and they are different. - if ( isset($newField['Default']) && isset($oldField['Default']) ) { - if ( $newField['Default'] != $oldField['Default'] ) - $changeDefaultAttr = true; - else - $changeDefaultAttr = false; - } - //special cases - // BLOB and TEXT columns cannot have DEFAULT values. http://dev.mysql.com/doc/refman/5.0/en/blob.html - if ( in_array(strtolower($newField['Type']), array('text','mediumtext') ) ) - $changeDefaultAttr = false; - - //#1067 - Invalid default value for datetime field - if ( in_array($newField['Type'], array('datetime')) && isset($newField['Default']) && $newField['Default']== '' ) - $changeDefaultAttr = false; - - //#1067 - Invalid default value for int field - if ( substr($newField['Type'], 0, 3 ) && isset($newField['Default']) && $newField['Default']== '' ) - $changeDefaultAttr = false; - - //if any difference exists, then insert the difference in aChanges - if ( $newField['Field'] != $oldField['Field'] || - $newField['Type'] != $oldField['Type'] || - $newField['Null'] != $oldField['Null'] || - $changeDefaultAttr ) { - if (!isset($aChanges['tablesToAlter'][$sTableName])) { - $aChanges['tablesToAlter'][$sTableName] = array('DROP' => array(), 'ADD' => array(), 'CHANGE' => array()); - } - $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Field'] = $newField['Field']; - $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Type'] = $newField['Type']; - $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Null'] = $newField['Null']; - if ( isset($newField['Default']) ) - $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Default'] = $newField['Default']; - else - $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Default'] = null; - - } - } - } //only columns, no the indexes column - }//foreach $aColumns - - //now check the indexes of table - if ( isset($aNewSchema[$sTableName]['INDEXES']) ) { - foreach ( $aNewSchema[$sTableName]['INDEXES'] as $indexName => $indexFields ) { - if (!isset( $aOldSchema[$sTableName]['INDEXES'][$indexName]) ) { - if (!isset($aChanges['tablesWithNewIndex'][$sTableName])) { - $aChanges['tablesWithNewIndex'][$sTableName] = array(); - } - $aChanges['tablesWithNewIndex'][$sTableName][$indexName] = $indexFields; - } - else { - if ( $aOldSchema[$sTableName]['INDEXES'][$indexName] != $indexFields ) { - if (!isset($aChanges['tablesToAlterIndex'][$sTableName])) { - $aChanges['tablesToAlterIndex'][$sTableName] = array(); - } - $aChanges['tablesToAlterIndex'][$sTableName][$indexName] = $indexFields; - } - } - } - } - } //for-else table exists - } //for new schema - return $aChanges; -} - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ +global $DB_ADAPTER; +global $DB_HOST; +global $DB_USER; +global $DB_PASS; +global $DB_NAME; +set_time_limit( 0 ); + +$id = ''; +if (isset( $_POST['id'] )) + $id = $_POST['id']; + +G::LoadClass( 'languages' ); +G::LoadSystem( 'database_mysql' ); + +$aUpgradeData = unserialize( file_get_contents( PATH_DATA . 'log' . PATH_SEP . "upgrade.data.bin" ) ); +$aWorkspaces = $aUpgradeData['workspaces']; + +if (is_array( $aWorkspaces ) && count( $aWorkspaces ) > 0) { + $workspace = array_shift( $aUpgradeData['workspaces'] ); + + eval( getDatabaseCredentials( PATH_DB . $workspace . PATH_SEP . 'db.php' ) ); + $oDataBase = new database( $DB_ADAPTER, $DB_HOST, $DB_USER, $DB_PASS, $DB_NAME ); + $oDataBase->iFetchType = MYSQL_NUM; + + //processing .po file + if ($aUpgradeData['sPoFile'] != '') { + $oLanguages = new languages(); + $oLanguages->importLanguage( $aUpgradeData['sPoFile'], $aUpgradeData['bForceXmlPoFile'] ); + $aUpgradeData['bForceXmlPoFile'] = false; + } + + if ($aUpgradeData['sSchemaFile'] != '') + processMasterSchemaFile( $aUpgradeData['sSchemaFile'] ); + + //draw a gauge control indicating the progress in workspaces + $gauge = intval( (($aUpgradeData['wsQuantity'] - count( $aWorkspaces ) + 1) / $aUpgradeData['wsQuantity']) * 301 ); + print "
"; + print "
"; + print "
"; + print "
Upgrading the workspace $workspace| $id Remaining
"; + file_put_contents( PATH_DATA . 'log' . PATH_SEP . "upgrade.data.bin", serialize( $aUpgradeData ) ); +} else { + print "
    "; + print "
"; + print "
"; + print "
Finished! All workspaces were upgraded successfully.
"; +} + +die(); + +function getDatabaseCredentials ($dbFile) +{ + $sContent = file_get_contents( $dbFile ); + $sContent = str_replace( '', '', $sContent ); + $sContent = str_replace( 'define', '', $sContent ); + $sContent = str_replace( "('", '$', $sContent ); + $sContent = str_replace( "',", '=', $sContent ); + $sContent = str_replace( ");", ';', $sContent ); + return $sContent; +} + +function processMasterSchemaFile ($sSchemaFile) +{ + global $DB_ADAPTER; + global $DB_HOST; + global $DB_USER; + global $DB_PASS; + global $DB_NAME; + global $aUpgradeData; + + //convert newSchema to array + if (isset( $aUpgradeData['aNewSchema'] )) { + $aNewSchema = $aUpgradeData['aNewSchema']; + } else { + $aNewSchema = schemaToArray( $sSchemaFile ); + $aUpgradeData['aNewSchema'] = $aNewSchema; + } + $aOldSchema = processSchemaFile(); + if (is_null( $aOldSchema )) { + return; + } + $aChanges = obtainChanges( $aOldSchema, $aNewSchema ); + + $oDataBase = new database( $DB_ADAPTER, $DB_HOST, $DB_USER, $DB_PASS, $DB_NAME ); + if (! $oDataBase->isConnected()) { + return; + } + $oDataBase->iFetchType = MYSQL_NUM; + + $oDataBase->logQuery( count( $aChanges ) ); + + foreach ($aChanges['tablesToAdd'] as $sTable => $aColumns) { + $oDataBase->executeQuery( $oDataBase->generateCreateTableSQL( $sTable, $aColumns ) ); + if (isset( $aChanges['tablesToAdd'][$sTable]['INDEXES'] )) { + foreach ($aChanges['tablesToAdd'][$sTable]['INDEXES'] as $indexName => $aIndex) { + $oDataBase->executeQuery( $oDataBase->generateAddKeysSQL( $sTable, $indexName, $aIndex ) ); + } + } + } + + foreach ($aChanges['tablesToAlter'] as $sTable => $aActions) { + foreach ($aActions as $sAction => $aAction) { + foreach ($aAction as $sColumn => $vData) { + switch ($sAction) { + case 'DROP': + $oDataBase->executeQuery( $oDataBase->generateDropColumnSQL( $sTable, $vData ) ); + break; + case 'ADD': + $oDataBase->executeQuery( $oDataBase->generateAddColumnSQL( $sTable, $sColumn, $vData ) ); + break; + case 'CHANGE': + $oDataBase->executeQuery( $oDataBase->generateChangeColumnSQL( $sTable, $sColumn, $vData ) ); + break; + } + } + } + } + + foreach ($aChanges['tablesWithNewIndex'] as $sTable => $aIndexes) { + foreach ($aIndexes as $sIndexName => $aIndexFields) { + $oDataBase->executeQuery( $oDataBase->generateAddKeysSQL( $sTable, $sIndexName, $aIndexFields ) ); + } + } + + foreach ($aChanges['tablesToAlterIndex'] as $sTable => $aIndexes) { + foreach ($aIndexes as $sIndexName => $aIndexFields) { + $oDataBase->executeQuery( $oDataBase->generateDropKeySQL( $sTable, $sIndexName ) ); + $oDataBase->executeQuery( $oDataBase->generateAddKeysSQL( $sTable, $sIndexName, $aIndexFields ) ); + } + } + $oDataBase->close(); +} + +function processSchemaFile () +{ + global $DB_ADAPTER; + global $DB_HOST; + global $DB_USER; + global $DB_PASS; + global $DB_NAME; + + try { + G::LoadSystem( 'database_' . strtolower( $DB_ADAPTER ) ); + + $aOldSchema = array (); + $oDataBase = new database( $DB_ADAPTER, $DB_HOST, $DB_USER, $DB_PASS, $DB_NAME ); + + if (! $oDataBase->isConnected()) { + $oDataBase->logQuery( 'Does not exist an available connection!' ); + return null; + } + + $oDataBase->iFetchType = MYSQL_NUM; + $oDataset1 = $oDataBase->executeQuery( $oDataBase->generateShowTablesSQL() ); + + } catch (Exception $e) { + $oDataBase->logQuery( $e->getmessage() ); + return null; + } + + //going thru all tables in current WF_ database + while ($aRow1 = $oDataBase->getRegistry( $oDataset1 )) { + $aPrimaryKeys = array (); + $sTable = strtoupper( $aRow1[0] ); + + //get description of each table, ( column and primary keys ) + //$oDataset2 = $oDataBase->executeQuery( $oDataBase->generateDescTableSQL($aRow1[0]) ); + $oDataset2 = $oDataBase->executeQuery( $oDataBase->generateDescTableSQL( $sTable ) ); + $aOldSchema[$sTable] = array (); + $oDataBase->iFetchType = MYSQL_ASSOC; + while ($aRow2 = $oDataBase->getRegistry( $oDataset2 )) { + $aOldSchema[$sTable][$aRow2['Field']]['Field'] = $aRow2['Field']; + $aOldSchema[$sTable][$aRow2['Field']]['Type'] = $aRow2['Type']; + $aOldSchema[$sTable][$aRow2['Field']]['Null'] = $aRow2['Null']; + $aOldSchema[$sTable][$aRow2['Field']]['Default'] = $aRow2['Default']; + } + + //get indexes of each table SHOW INDEX FROM `ADDITIONAL_TABLES`; -- WHERE Key_name <> 'PRIMARY' + $oDataset2 = $oDataBase->executeQuery( $oDataBase->generateTableIndexSQL( $aRow1[0] ) ); + $oDataBase->iFetchType = MYSQL_ASSOC; + while ($aRow2 = $oDataBase->getRegistry( $oDataset2 )) { + if (! isset( $aOldSchema[$sTable]['INDEXES'] )) { + $aOldSchema[$sTable]['INDEXES'] = array (); + } + if (! isset( $aOldSchema[$sTable]['INDEXES'][$aRow2['Key_name']] )) { + $aOldSchema[$sTable]['INDEXES'][$aRow2['Key_name']] = array (); + } + $aOldSchema[$sTable]['INDEXES'][$aRow2['Key_name']][] = $aRow2['Column_name']; + } + + $oDataBase->iFetchType = MYSQL_NUM; //this line is neccesary because the next fetch needs to be with MYSQL_NUM + } + //finally return the array with old schema obtained from the Database + if (count( $aOldSchema ) == 0) + $aOldSchema = null; + return $aOldSchema; +} + +//process the schema file in the patch file, and obtain an array +function schemaToArray ($sSchemaFile) +{ + try { + $aSchema = array (); + $oXml = new DomDocument(); + $oXml->load( $sSchemaFile ); + $aTables = $oXml->getElementsByTagName( 'table' ); + foreach ($aTables as $oTable) { + $aPrimaryKeys = array (); + $sTableName = $oTable->getAttribute( 'name' ); + $aSchema[$sTableName] = array (); + $aColumns = $oTable->getElementsByTagName( 'column' ); + foreach ($aColumns as $oColumn) { + $sColumName = $oColumn->getAttribute( 'name' ); + $aSchema[$sTableName][$sColumName] = array (); + $aVendors = $oColumn->getElementsByTagName( 'vendor' ); + foreach ($aVendors as $oVendor) { + if ($oVendor->getAttribute( 'type' ) == DB_ADAPTER) { + break; + } + } + $aParameters = $oColumn->getElementsByTagName( 'parameter' ); + foreach ($aParameters as $oParameter) { + $parameterName = ucwords( $oParameter->getAttribute( 'name' ) ); + if ($parameterName == 'Key' && strtoupper( $oParameter->getAttribute( 'value' ) ) == 'PRI') { + $aPrimaryKeys[] = $oColumn->getAttribute( 'name' ); + } + + if (in_array( $parameterName, array ('Field','Type','Null','Default' + ) )) { + $aSchema[$sTableName][$sColumName][$parameterName] = $oParameter->getAttribute( 'value' ); + } + } + } + + if (is_array( $aPrimaryKeys ) && count( $aPrimaryKeys ) > 0) { + $aSchema[$sTableName]['INDEXES']['PRIMARY'] = $aPrimaryKeys; + } + $aIndexes = $oTable->getElementsByTagName( 'index' ); + foreach ($aIndexes as $oIndex) { + $aIndex = array (); + $aIndexesColumns = $oIndex->getElementsByTagName( 'index-column' ); + foreach ($aIndexesColumns as $oIndexColumn) { + $aIndex[] = $oIndexColumn->getAttribute( 'name' ); + } + $aSchema[$sTableName]['INDEXES'][$oIndex->getAttribute( 'name' )] = $aIndex; + } + } + return $aSchema; + } catch (Exception $oError) { + throw $oError; + } +} + +function obtainChanges ($aOldSchema, $aNewSchema) +{ + //$aChanges = array('tablesToDelete' => array(), 'tablesToAdd' => array(), 'tablesToAlter' => array()); + //Tables to delete, but this is disabled + //foreach ($aOldSchema as $sTableName => $aColumns) { + // if ( !isset($aNewSchema[$sTableName])) { + // if (!in_array($sTableName, array('KT_APPLICATION', 'KT_DOCUMENT', 'KT_PROCESS'))) { + // $aChanges['tablesToDelete'][] = $sTableName; + // } + // } + //} + + + $aChanges = array ('tablesToAdd' => array (),'tablesToAlter' => array (),'tablesWithNewIndex' => array (),'tablesToAlterIndex' => array () + ); + + //new tables to create and alter + foreach ($aNewSchema as $sTableName => $aColumns) { + if (! isset( $aOldSchema[$sTableName] )) { + $aChanges['tablesToAdd'][$sTableName] = $aColumns; + } else { + //drop old columns + foreach ($aOldSchema[$sTableName] as $sColumName => $aParameters) { + if (! isset( $aNewSchema[$sTableName][$sColumName] )) { + if (! isset( $aChanges['tablesToAlter'][$sTableName] )) { + $aChanges['tablesToAlter'][$sTableName] = array ('DROP' => array (),'ADD' => array (),'CHANGE' => array () + ); + } + $aChanges['tablesToAlter'][$sTableName]['DROP'][$sColumName] = $sColumName; + } + } + + //create new columns + //foreach ($aNewSchema[$sTableName] as $sColumName => $aParameters) { + foreach ($aColumns as $sColumName => $aParameters) { + if ($sColumName != 'INDEXES') { + if (! isset( $aOldSchema[$sTableName][$sColumName] )) { //this column doesnt exist in oldschema + if (! isset( $aChanges['tablesToAlter'][$sTableName] )) { + $aChanges['tablesToAlter'][$sTableName] = array ('DROP' => array (),'ADD' => array (),'CHANGE' => array () + ); + } + $aChanges['tablesToAlter'][$sTableName]['ADD'][$sColumName] = $aParameters; + } else { //the column exists + $newField = $aNewSchema[$sTableName][$sColumName]; + $oldField = $aOldSchema[$sTableName][$sColumName]; + //both are null, no change is required + if (! isset( $newField['Default'] ) && ! isset( $oldField['Default'] )) + $changeDefaultAttr = false; + //one of them is null, change IS required + if (! isset( $newField['Default'] ) && isset( $oldField['Default'] ) && $oldField['Default'] != '') + $changeDefaultAttr = true; + if (isset( $newField['Default'] ) && ! isset( $oldField['Default'] )) + $changeDefaultAttr = true; + //both are defined and they are different. + if (isset( $newField['Default'] ) && isset( $oldField['Default'] )) { + if ($newField['Default'] != $oldField['Default']) + $changeDefaultAttr = true; + else + $changeDefaultAttr = false; + } + //special cases + // BLOB and TEXT columns cannot have DEFAULT values. http://dev.mysql.com/doc/refman/5.0/en/blob.html + if (in_array( strtolower( $newField['Type'] ), array ('text','mediumtext' + ) )) + $changeDefaultAttr = false; + + //#1067 - Invalid default value for datetime field + if (in_array( $newField['Type'], array ('datetime' + ) ) && isset( $newField['Default'] ) && $newField['Default'] == '') + $changeDefaultAttr = false; + + //#1067 - Invalid default value for int field + if (substr( $newField['Type'], 0, 3 ) && isset( $newField['Default'] ) && $newField['Default'] == '') + $changeDefaultAttr = false; + + //if any difference exists, then insert the difference in aChanges + if ($newField['Field'] != $oldField['Field'] || $newField['Type'] != $oldField['Type'] || $newField['Null'] != $oldField['Null'] || $changeDefaultAttr) { + if (! isset( $aChanges['tablesToAlter'][$sTableName] )) { + $aChanges['tablesToAlter'][$sTableName] = array ('DROP' => array (),'ADD' => array (),'CHANGE' => array () + ); + } + $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Field'] = $newField['Field']; + $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Type'] = $newField['Type']; + $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Null'] = $newField['Null']; + if (isset( $newField['Default'] )) + $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Default'] = $newField['Default']; + else + $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Default'] = null; + + } + } + } //only columns, no the indexes column + } //foreach $aColumns + + + //now check the indexes of table + if (isset( $aNewSchema[$sTableName]['INDEXES'] )) { + foreach ($aNewSchema[$sTableName]['INDEXES'] as $indexName => $indexFields) { + if (! isset( $aOldSchema[$sTableName]['INDEXES'][$indexName] )) { + if (! isset( $aChanges['tablesWithNewIndex'][$sTableName] )) { + $aChanges['tablesWithNewIndex'][$sTableName] = array (); + } + $aChanges['tablesWithNewIndex'][$sTableName][$indexName] = $indexFields; + } else { + if ($aOldSchema[$sTableName]['INDEXES'][$indexName] != $indexFields) { + if (! isset( $aChanges['tablesToAlterIndex'][$sTableName] )) { + $aChanges['tablesToAlterIndex'][$sTableName] = array (); + } + $aChanges['tablesToAlterIndex'][$sTableName][$indexName] = $indexFields; + } + } + } + } + } //for-else table exists + } //for new schema + return $aChanges; +} + diff --git a/workflow/engine/methods/setup/uplogo.php b/workflow/engine/methods/setup/uplogo.php index 9f133afc8..20691d262 100755 --- a/workflow/engine/methods/setup/uplogo.php +++ b/workflow/engine/methods/setup/uplogo.php @@ -12,50 +12,50 @@ * * 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 . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ - - global $RBAC; - G::LoadClass('replacementLogo'); - - if($RBAC->userCanAccess('PM_SETUP') != 1 && $RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1){ - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - die; - } - //calculating the max upload file size; - $POST_MAX_SIZE = ini_get('post_max_size'); - $mul = substr($POST_MAX_SIZE, -1); - $mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1))); - $postMaxSize = (int)$POST_MAX_SIZE * $mul; - - $UPLOAD_MAX_SIZE = ini_get('upload_max_filesize'); - $mul = substr($UPLOAD_MAX_SIZE, -1); - $mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1))); - $uploadMaxSize = (int)$UPLOAD_MAX_SIZE * $mul; +global $RBAC; +G::LoadClass( 'replacementLogo' ); - if ( $postMaxSize < $uploadMaxSize ) $uploadMaxSize = $postMaxSize; - $Fields['MAX_FILE_SIZE'] = $uploadMaxSize . " (" . $UPLOAD_MAX_SIZE . ") "; +if ($RBAC->userCanAccess( 'PM_SETUP' ) != 1 && $RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) { + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + die(); +} - $G_MAIN_MENU = 'processmaker'; - $G_SUB_MENU = 'setup'; - $G_ID_MENU_SELECTED = 'SETUP'; - $G_ID_SUB_MENU_SELECTED = 'LOGO'; - - $G_PUBLISH = new Publisher; - $oHeadPublisher =& headPublisher::getSingleton(); - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/uplogo', '', $Fields ); - - $G_PUBLISH->AddContent('view', 'setup/uplogo' ); - G::RenderPage( "publishBlank", "blank"); +//calculating the max upload file size; +$POST_MAX_SIZE = ini_get( 'post_max_size' ); +$mul = substr( $POST_MAX_SIZE, - 1 ); +$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1))); +$postMaxSize = (int) $POST_MAX_SIZE * $mul; + +$UPLOAD_MAX_SIZE = ini_get( 'upload_max_filesize' ); +$mul = substr( $UPLOAD_MAX_SIZE, - 1 ); +$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1))); +$uploadMaxSize = (int) $UPLOAD_MAX_SIZE * $mul; + +if ($postMaxSize < $uploadMaxSize) + $uploadMaxSize = $postMaxSize; +$Fields['MAX_FILE_SIZE'] = $uploadMaxSize . " (" . $UPLOAD_MAX_SIZE . ") "; + +$G_MAIN_MENU = 'processmaker'; +$G_SUB_MENU = 'setup'; +$G_ID_MENU_SELECTED = 'SETUP'; +$G_ID_SUB_MENU_SELECTED = 'LOGO'; + +$G_PUBLISH = new Publisher(); +$oHeadPublisher = & headPublisher::getSingleton(); +$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/uplogo', '', $Fields ); + +$G_PUBLISH->AddContent( 'view', 'setup/uplogo' ); +G::RenderPage( "publishBlank", "blank" ); ?> + diff --git a/workflow/engine/methods/setup/webServices.php b/workflow/engine/methods/setup/webServices.php index b0092e326..24cec672c 100755 --- a/workflow/engine/methods/setup/webServices.php +++ b/workflow/engine/methods/setup/webServices.php @@ -1,161 +1,158 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -if($RBAC->userCanAccess('PM_SETUP') != 1 && $RBAC->userCanAccess('PM_FACTORY') != 1){ - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - //G::header('location: ../login/login'); - die; -} - - $G_MAIN_MENU = 'processmaker'; - //$G_SUB_MENU = 'setup'; - $G_ID_MENU_SELECTED = 'SETUP'; - //$G_ID_SUB_MENU_SELECTED = 'WEBSERVICES'; - - if (!extension_loaded('soap')) { - $G_PUBLISH = new Publisher; - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/wsMessage'); - G::RenderPage( "publish" ); - } - else - { - $G_PUBLISH = new Publisher; - $G_PUBLISH->AddContent('view', 'setup/webServicesTree' ); - $G_PUBLISH->AddContent('smarty', 'groups/groups_usersList', '', '', array()); - - G::RenderPage( "publish-treeview", 'blank'); - } - - $link_Edit = G::encryptlink('webServicesSetup'); - $link_List = G::encryptlink('webServicesList'); - - -?> - \ No newline at end of file diff --git a/workflow/engine/methods/setup/webServicesAjax.php b/workflow/engine/methods/setup/webServicesAjax.php index 40af50272..56c37eedd 100755 --- a/workflow/engine/methods/setup/webServicesAjax.php +++ b/workflow/engine/methods/setup/webServicesAjax.php @@ -1,1346 +1,1396 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -ini_set ( "soap.wsdl_cache_enabled", "0" ); // enabling WSDL cache - -G::LoadClass ( 'ArrayPeer' ); -if($RBAC->userCanAccess('PM_SETUP') != 1 && $RBAC->userCanAccess('PM_FACTORY') != 1){ - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - //G::header('location: ../login/login'); - die; -} - -G::LoadInclude ( 'ajax' ); +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ +ini_set( "soap.wsdl_cache_enabled", "0" ); // enabling WSDL cache + + +G::LoadClass( 'ArrayPeer' ); +if ($RBAC->userCanAccess( 'PM_SETUP' ) != 1 && $RBAC->userCanAccess( 'PM_FACTORY' ) != 1) { + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + //G::header('location: ../login/login'); + die(); +} + +G::LoadInclude( 'ajax' ); //G::pr($_SESSION); -$_POST['action'] = get_ajax_value ( 'action' ); -if( $_POST['action'] == '' ){ - $_POST['action'] = (isset($_GET['action']))?$_GET['action']: ''; -} - -switch ($_POST ['action']) { - case 'showForm' : - global $G_PUBLISH; - $xmlform = isset ( $_POST ['wsID'] ) ? 'setup/ws' . $_POST ['wsID'] : ''; - if (file_exists ( PATH_XMLFORM . $xmlform . '.xml' )) { - - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - $G_PUBLISH = new Publisher ( ); - $fields ['SESSION_ID'] = isset ( $_SESSION ['WS_SESSION_ID'] ) ? $_SESSION ['WS_SESSION_ID'] : ''; - $fields ['ACTION'] = $_POST ['wsID']; - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', $xmlform, '', $fields, '../setup/webServicesAjax' ); - G::RenderPage ( 'publish', 'raw' ); - } - break; - - case 'showDetails' : - G::LoadClass ( 'groups' ); - - $dbc = new DBConnection ( ); - $ses = new DBSession ( $dbc ); - - if (! isset ( $_SESSION ['END_POINT'] )) { - $aFields ['WS_HOST'] = $_SERVER ['HTTP_HOST']; - $aFields ['WS_WORKSPACE'] = SYS_SYS; - } else { - if (strpos ( $_SESSION ['END_POINT'], 'https' ) !== false) { - preg_match ( '@^(?:https://)?([^/]+)@i', $_SESSION ['END_POINT'], $coincidencias ); - } else { - preg_match ( '@^(?:http://)?([^/]+)@i', $_SESSION ['END_POINT'], $coincidencias ); - } - $aAux = explode ( ':', $coincidencias [1] ); - $aFields ['WS_HOST'] = $aAux [0]; - $aFields ['WS_PORT'] = (isset ( $aAux [1] ) ? $aAux [1] : ''); - $aAux = explode ( $aAux [0] . (isset ( $aAux [1] ) ? ':' . $aAux [1] : ''), $_SESSION ['END_POINT'] ); - $aAux = explode ( '/', $aAux [1] ); - $aFields ['WS_WORKSPACE'] = substr ( $aAux [1], 3 ); - } - - $rows [] = array ('uid' => 'char', 'name' => 'char', 'age' => 'integer', 'balance' => 'float' ); - $rows [] = array ('uid' => 'http', 'name' => 'http' ); - $rows [] = array ('uid' => 'https', 'name' => 'https' ); - - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - $_DBArray ['protocol'] = $rows; - $_SESSION ['_DBArray'] = $_DBArray; - - if (! isset ( $_SESSION ['END_POINT'] )) { - //$wsdl = 'http://'.$_SERVER['HTTP_HOST'].'/sys'.SYS_SYS. '/'. SYS_LANG .'/classic/services/wsdl'; - $wsdl = 'http://' . $_SERVER ['HTTP_HOST']; - $workspace = SYS_SYS; - } else { - $wsdl = $_SESSION ['END_POINT']; - $workspace = $_SESSION ['WS_WORKSPACE']; - } - - $defaultEndpoint = 'http://' . $_SERVER ['SERVER_NAME'] . ':' . $_SERVER ['SERVER_PORT'] . '/sys' . SYS_SYS . '/'. SYS_LANG .'/classic/services/wsdl2'; - - $wsdl = isset ( $_SESSION ['END_POINT'] ) ? $_SESSION ['END_POINT'] : $defaultEndpoint; - - $wsSessionId = ''; - if (isset ( $_SESSION ['WS_SESSION_ID'] )) { - $wsSessionId = $_SESSION ['WS_SESSION_ID']; - } - - $aFields ['WSDL'] = $wsdl; - $aFields ['OS'] = $workspace; - $aFields ['WSID'] = $wsSessionId; - - $G_PUBLISH = new Publisher ( ); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/webServicesDetails', '', $aFields, 'webServicesSetupSave' ); - - G::RenderPage ( "publish", "raw" ); - - break; - case 'showUploadFilesForm': - global $G_PUBLISH; - $xmlform = 'setup/wsSendFiles'; - if (file_exists ( PATH_XMLFORM . $xmlform . '.xml' )) { - - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - - $G_PUBLISH = new Publisher ( ); - $fields ['SESSION_ID'] = isset ( $_SESSION ['WS_SESSION_ID'] ) ? $_SESSION ['WS_SESSION_ID'] : ''; - $fields ['ACTION'] = 'wsSendFiles'; - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', $xmlform, '', $fields, '../setup/webServicesAjax'); - G::RenderPage ( 'publish', 'blank' ); - } - break; - }try { - global $G_PUBLISH; - if (isset ( $_POST ['form'] ['ACTION'] )) { - $frm = $_POST ['form']; - $action = $frm ['ACTION']; - if (isset ( $_POST ["epr"] )) { - $_SESSION ['END_POINT'] = $_POST ["epr"]; - } - $defaultEndpoint = 'http://' . $_SERVER ['SERVER_NAME'] . ':' . $_SERVER ['SERVER_PORT'] . '/sys' . SYS_SYS . '/'. SYS_LANG .'/classic/services/wsdl2'; - - $endpoint = isset ( $_SESSION ['END_POINT'] ) ? $_SESSION ['END_POINT'] : $defaultEndpoint; - - $sessionId = isset ( $_SESSION ['SESSION_ID'] ) ? $_SESSION ['SESSION_ID'] : ''; - - //Apply proxy settings - $proxy = array(); - $sysConf = System::getSystemConfiguration(); - if ($sysConf['proxy_host'] != '') { - $proxy['proxy_host'] = $sysConf['proxy_host']; - if ($sysConf['proxy_port'] != '') { - $proxy['proxy_port'] = $sysConf['proxy_port']; - } - if ($sysConf['proxy_user'] != '') { - $proxy['proxy_login'] = $sysConf['proxy_user']; - } - if ($sysConf['proxy_pass'] != '') { - $proxy['proxy_password'] = $sysConf['proxy_pass']; - } - } - - @$client = new SoapClient($endpoint, $proxy); - - switch ($action) { - case "Login" : - $user = $frm ["USER_ID"]; - $pass = $frm ["PASSWORD"]; - $params = array ('userid' => $user, 'password' => $pass ); - $result = $client->__SoapCall ( 'login', array ($params ) ); - $_SESSION ['WS_SESSION_ID'] = ''; - if ($result->status_code == 0) { - $_SESSION ['WS_SESSION_ID'] = $result->message; - } - $G_PUBLISH = new Publisher ( ); - $fields ['status_code'] = $result->status_code; - $fields ['message'] = 'ProcessMaker WebService version: ' . $result->version . "\n" . $result->message; - $fields ['version'] = $result->version; - $fields ['time_stamp'] = $result->timestamp; - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - G::RenderPage ( 'publish', 'raw' ); - break; - case "ProcessList" : - $sessionId = $frm ["SESSION_ID"]; - $params = array ('sessionId' => $sessionId ); - - $wsResponse = $client->__SoapCall ( 'ProcessList', array ($params ) ); - $result = G::PMWSCompositeResponse($wsResponse, 'processes'); - - $G_PUBLISH = new Publisher(); - $rows [] = array ('guid' => 'char', 'name' => 'char' ); - - if( is_array($result) ){ - foreach ( $result as $key => $item ) { - if (isset ( $item->item )) - foreach ( $item->item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - } - else if (is_array ( $item )) - foreach ( $item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - } - else { - if (isset ( $item->guid )) - $guid = $item->guid; - if (isset ( $item->name )) - $name = $item->name; - } - - $rows [] = array ('guid' => $guid, 'name' => $name ); - } - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - $_DBArray ['process'] = $rows; - $_SESSION ['_DBArray'] = $_DBArray; - - $c = new Criteria ( 'dbarray' ); - $c->setDBArrayTable ( 'process' ); - $c->addAscendingOrderByColumn ( 'name' ); - $G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'setup/wsrProcessList', $c ); - } else if( is_object($result) ){ - $_SESSION ['WS_SESSION_ID'] = ''; - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = date("Y-m-d H:i:s"); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - } - - G::RenderPage ( 'publish', 'raw' ); - break; - case "RoleList" : - $sessionId = $frm ["SESSION_ID"]; - $params = array ('sessionId' => $sessionId ); - $wsResponse = $client->__SoapCall ( 'RoleList', array ($params ) ); - $result = G::PMWSCompositeResponse($wsResponse, 'roles'); - - $G_PUBLISH = new Publisher (); - - $rows [] = array ('guid' => 'char', 'name' => 'char'); - if ( is_array ( $result )){ - - foreach ( $result as $key => $item ) { - if (isset ( $item->item )) - foreach ( $item->item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - } - else if (is_array ( $item )) - foreach ( $item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - } - else { - if (isset ( $item->guid )) - $guid = $item->guid; - if (isset ( $item->name )) - $name = $item->name; - } - - $rows [] = array ('guid' => $guid, 'name' => $name ); - } - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - $_DBArray ['role'] = $rows; - $_SESSION ['_DBArray'] = $_DBArray; - - G::LoadClass ( 'ArrayPeer' ); - $c = new Criteria ( 'dbarray' ); - $c->setDBArrayTable ( 'role' ); - $c->addAscendingOrderByColumn ( 'name' ); - $G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'setup/wsrRoleList', $c ); - } else if( is_object($result) ){ - $_SESSION ['WS_SESSION_ID'] = ''; - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = date("Y-m-d H:i:s"); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - } - - G::RenderPage ( 'publish', 'raw' ); - break; - - case "GroupList" : - $sessionId = $frm ["SESSION_ID"]; - $params = array ('sessionId' => $sessionId ); - $wsResponse = $client->__SoapCall ( 'GroupList', array ($params ) ); - $result = G::PMWSCompositeResponse($wsResponse, 'groups'); - - $G_PUBLISH = new Publisher ( ); - $rows [] = array ('guid' => 'char', 'name' => 'char' ); - if (is_array ( $result )){ - foreach ( $result as $key => $item ) { - if (isset ( $item->item )) - foreach ( $item->item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - } - else if (is_array ( $item )) - foreach ( $item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - } - else { - if (isset ( $item->guid )) - $guid = $item->guid; - if (isset ( $item->name )) - $name = $item->name; - } - - $rows [] = array ('guid' => $guid, 'name' => $name ); - } - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - $_DBArray ['group'] = $rows; - $_SESSION ['_DBArray'] = $_DBArray; - - G::LoadClass ( 'ArrayPeer' ); - $c = new Criteria ( 'dbarray' ); - $c->setDBArrayTable ( 'group' ); - $c->addAscendingOrderByColumn ( 'name' ); - $G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'setup/wsrGroupList', $c ); - } else if( is_object($result) ){ - $_SESSION ['WS_SESSION_ID'] = ''; - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = date("Y-m-d H:i:s"); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - } - - G::RenderPage ( 'publish', 'raw' ); - break; - - case "CaseList" : - $sessionId = $frm ["SESSION_ID"]; - $params = array ('sessionId' => $sessionId ); - $wsResponse = $client->__SoapCall ( 'CaseList', array ($params ) ); - - $G_PUBLISH = new Publisher ( ); - $rows [] = array ('guid' => 'char', 'name' => 'char', 'status' => 'char', 'delIndex' => 'char' ); - - $result = G::PMWSCompositeResponse($wsResponse, 'cases'); - - if ( is_array( $result )) { - foreach ( $result as $key => $item ) { - if (isset ( $item->item )) - foreach ( $item->item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - if ($val->key == 'status') - $status = $val->value; - if ($val->key == 'delIndex') - $delIndex = $val->value; - } - else if (is_array ( $item )) - foreach ( $item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - if ($val->key == 'status') - $status = $val->value; - if ($val->key == 'delIndex') - $delIndex = $val->value; - } - else { - if (isset ( $item->guid )) - $guid = $item->guid; - if (isset ( $item->name )) - $name = $item->name; - if (isset ( $item->status )) - $status = $item->status; - if (isset ( $item->delIndex )) - $delIndex = $item->delIndex; - - } - $rows [] = array ('guid' => $guid, 'name' => $name, 'status' => $status, 'delIndex' => $delIndex ); - - } - - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - $_DBArray ['case'] = $rows; - $_SESSION ['_DBArray'] = $_DBArray; - - G::LoadClass ( 'ArrayPeer' ); - $c = new Criteria ( 'dbarray' ); - $c->setDBArrayTable ( 'case' ); - //$c->addAscendingOrderByColumn ( 'name' ); - $G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'setup/wsrCaseList', $c ); - - } else if( is_object($result) ){ - $_SESSION ['WS_SESSION_ID'] = ''; - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = date("Y-m-d H:i:s"); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - } - - G::RenderPage ( 'publish', 'raw' ); - break; - - - case "UnassignedCaseList" : - - $sessionId = $frm ["SESSION_ID"]; - $params = array ('sessionId' => $sessionId ); - - $wsResponse = $client->__SoapCall ( 'UnassignedCaseList', array ($params )); - - $G_PUBLISH = new Publisher ( ); - $rows [] = array ('guid' => 'char', 'name' => 'char', 'delIndex' => 'char' ); - $result = G::PMWSCompositeResponse($wsResponse, 'cases'); - - if ( is_array( $result )) { - foreach ( $result as $key => $item ) { - if (isset ( $item->item )) - foreach ( $item->item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - if ($val->key == 'delIndex') - $delIndex = $val->value; - } - else if (is_array ( $item )) - foreach ( $item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - if ($val->key == 'delIndex') - $delIndex = $val->value; - } - else { - if (isset ( $item->guid )) - $guid = $item->guid; - if (isset ( $item->name )) - $name = $item->name; - if (isset ( $item->delIndex )) - $delIndex = $item->delIndex; - } - $rows [] = array ('guid' => $guid, 'name' => $name, 'delIndex' => $delIndex ); - } - - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - $_DBArray ['case'] = $rows; - $_SESSION ['_DBArray'] = $_DBArray; - - G::LoadClass ( 'ArrayPeer' ); - $c = new Criteria ( 'dbarray' ); - $c->setDBArrayTable ( 'case' ); - $G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'setup/wsrUnassignedCaseList', $c ); - - } - else if( is_object($result) ){ - $_SESSION ['WS_SESSION_ID'] = ''; - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = date("Y-m-d H:i:s"); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - } - - G::RenderPage ( 'publish', 'raw' ); - break; - - case "UserList" : - $sessionId = $frm ["SESSION_ID"]; - $params = array ('sessionId' => $sessionId ); - $wsResponse = $client->__SoapCall ( 'UserList', array ($params ) ); - $result = G::PMWSCompositeResponse($wsResponse, 'users'); - - $G_PUBLISH = new Publisher(); - $rows [] = array ('guid' => 'char', 'name' => 'char' ); - if (is_array ( $result )){ - - foreach ( $result as $key => $item ) { - if (isset ( $item->item )) - foreach ( $item->item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - } - else if (is_array ( $item )) - foreach ( $item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - } - else { - if (isset ( $item->guid )) - $guid = $item->guid; - if (isset ( $item->name )) - $name = $item->name; - } - - $rows [] = array ('guid' => $guid, 'name' => $name ); - } - - - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - $_DBArray ['user'] = $rows; - $_SESSION ['_DBArray'] = $_DBArray; - - G::LoadClass ( 'ArrayPeer' ); - $c = new Criteria ( 'dbarray' ); - $c->setDBArrayTable ( 'user' ); - $c->addAscendingOrderByColumn ( 'name' ); - $G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'setup/wsrUserList', $c ); - - } else if( is_object($result) ){ - $_SESSION ['WS_SESSION_ID'] = ''; - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = date("Y-m-d H:i:s"); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - } - G::RenderPage ( 'publish', 'raw' ); - break; - - case "SendMessage" : - require_once('classes/model/Application.php'); - $sessionId = $frm ["SESSION_ID"]; - $from = $frm ["FROM"]; - $to = $frm ["TO_EMAIL"]; - $cc = isset($frm ["CC_MAIL"]) ?$frm ["CC_MAIL"] :''; - $bcc = isset($frm ["BCC_MAIL"])?$frm ["BCC_MAIL"] :''; - $caseId = $frm ["CASE_ID"]; - $subject = $frm ["SUBJECT"]; - $message = $frm ["MESSAGE"]; - // getting the proUid variable - $oCases = new Application(); - $oCases->load($caseId); - $proUid = $oCases->getProUid(); - $caseNumber = $oCases->getAppNumber(); - - // generating the path for the template msj - $templateFile = PATH_DB.SYS_SYS.PATH_SEP.'mailTemplates'.PATH_SEP.$proUid.PATH_SEP.'tempTemplate.hml'; - // generating the file adding the msj variable - $messageBody = "message for case: ".$caseNumber. "
" . $message; - file_put_contents($templateFile, $messageBody); - - $params = array ( 'sessionId' => $sessionId, - 'caseId' => $caseId, - 'from' => $from, - 'to' => $to, - 'cc' => $cc, - 'bcc' => $bcc, - 'subject' => $subject, - 'template' => 'tempTemplate.hml' ); - $result = $client->__SoapCall ( 'sendMessage', array ($params ) ); - $G_PUBLISH = new Publisher ( ); - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = $result->timestamp; - - if( $result->status_code == 9 ){ - $_SESSION ['WS_SESSION_ID'] = ''; - } - - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - G::RenderPage ( 'publish', 'raw' ); - break; - - case "SendVariables" : - $sessionId = $frm ["SESSION_ID"]; - $caseId = $frm ["CASE_ID"]; - $variables = Array(); - - $o = new stdClass(); - $o->name = $frm ["NAME1"]; - $o->value = $frm ["VALUE1"]; - array_push($variables, $o); - $o = new stdClass(); - $o->name = $frm ["NAME2"]; - $o->value = $frm ["VALUE2"]; - array_push($variables, $o); - - $params = array ('sessionId' => $sessionId, 'caseId' => $caseId, 'variables' => $variables ); - $result = $client->__SoapCall ( 'SendVariables', array ($params ) ); - $G_PUBLISH = new Publisher(); - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = $result->timestamp; - - if( $result->status_code == 9 ){ - $_SESSION ['WS_SESSION_ID'] = ''; - } - - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - G::RenderPage ( 'publish', 'raw' ); - break; - - case "DerivateCase" : - $sessionId = $frm ["SESSION_ID"]; - $caseId = $frm ["CASE_ID"]; - $delIndex = $frm ["DEL_INDEX"]; - - $params = array ('sessionId' => $sessionId, 'caseId' => $caseId, 'delIndex' => $delIndex ); - $result = $client->__SoapCall ( 'RouteCase', array ($params ) ); - $G_PUBLISH = new Publisher ( ); - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = $result->timestamp; - - if( $result->status_code == 9 ){ - $_SESSION ['WS_SESSION_ID'] = ''; - } - - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - G::RenderPage ( 'publish', 'raw' ); - break; - - case "ReassignCase" : - $sessionId = $frm ["SESSION_ID"]; - $caseId = $frm ["CASE_ID"]; - $delIndex = $frm ["DEL_INDEX"]; - $userIdSource = $frm ['USERIDSOURCE']; - $userIdTarget = $frm ['USERIDTARGET']; - - $params = array ('sessionId' => $sessionId, 'caseId' => $caseId, 'delIndex' => $delIndex, 'userIdSource' => $userIdSource, 'userIdTarget' => $userIdTarget ); - $result = $client->__SoapCall ( 'reassignCase', array ($params ) ); - - $G_PUBLISH = new Publisher ( ); - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = $result->timestamp; - - if( $result->status_code == 9 ){ - $_SESSION ['WS_SESSION_ID'] = ''; - } - - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - G::RenderPage ( 'publish', 'raw' ); - - break; - - case "NewCaseImpersonate" : - $sessionId = $frm ["SESSION_ID"]; - $processId = $frm ["PROCESS_ID"]; - $userId = $frm ["USER_ID"]; - $variables = Array(); - foreach ( $frm ['VARIABLES'] as $iRow => $aRow ) { - $o = new stdClass(); - $o->name = $aRow ['NAME']; - $o->value = $aRow ['VALUE']; - array_push($variables, $o); - } - $params = array ('sessionId' => $sessionId, 'processId' => $processId, 'userId' => $userId, 'variables' => $variables ); - $result = $client->__SoapCall ( 'NewCaseImpersonate', array ($params ) ); - $G_PUBLISH = new Publisher ( ); - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = $result->timestamp; - - if( $result->status_code == 9 ){ - $_SESSION ['WS_SESSION_ID'] = ''; - } - - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - G::RenderPage ( 'publish', 'raw' ); - break; - - case "NewCase" : - $sessionId = $frm ["SESSION_ID"]; - $processId = $frm ["PROCESS_ID"]; - $taskId = $frm ["TASK_ID"]; - - $variables = Array(); - foreach ( $frm ['VARIABLES'] as $iRow => $aRow ) { - $o = new stdClass(); - $o->name = $aRow ['NAME']; - $o->value = $aRow ['VALUE']; - array_push($variables, $o); - } - $params = array ('sessionId' => $sessionId, 'processId' => $processId, 'taskId' => $taskId, 'variables' => $variables ); - $result = $client->__SoapCall ( 'NewCase', array ($params ) ); - - $G_PUBLISH = new Publisher ( ); - - $fields ['status_code'] = $result->status_code; - $fields ['time_stamp'] = $result->timestamp; - if( isset($result->caseId) ){ - $fields ['message'] = "Case ID: ".$result->caseId."\nCase Number: ".$result->caseNumber."\n".$result->message; - } else { - $fields ['message'] = ''; - } - if( $result->status_code == 9 ){ - $_SESSION ['WS_SESSION_ID'] = ''; - } - - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - G::RenderPage ( 'publish', 'raw' ); - break; - - case "AssignUserToGroup" : - $sessionId = $frm ["SESSION_ID"]; - $userId = $frm ["USER_ID"]; - $groupId = $frm ["GROUP_ID"]; - $params = array ('sessionId' => $sessionId, 'userId' => $userId, 'groupId' => $groupId ); - $result = $client->__SoapCall ( 'AssignUserToGroup', array ($params ) ); - $G_PUBLISH = new Publisher ( ); - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = $result->timestamp; - - if( $result->status_code == 9 ){ - $_SESSION ['WS_SESSION_ID'] = ''; - } - - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - G::RenderPage ( 'publish', 'raw' ); - break; - - case "CreateUser" : - $sessionId = $frm ["SESSION_ID"]; - $userId = $frm ["USER_ID"]; - $firstname = $frm ["FIRST_NAME"]; - $lastname = $frm ["LAST_NAME"]; - $email = $frm ["EMAIL"]; - $role = $frm ["ROLE"]; - $password = $frm ["PASSWORD"]; - - $params = array ('sessionId' => $sessionId, 'userId' => $userId, 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'role' => $role, 'password' => $password ); - $result = $client->__SoapCall ( 'CreateUser', array ($params ) ); - $G_PUBLISH = new Publisher ( ); - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = $result->timestamp; - - if( $result->status_code == 9 ){ - $_SESSION ['WS_SESSION_ID'] = ''; - } - - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - G::RenderPage ( 'publish', 'raw' ); - break; - - case "TaskList" : - $sessionId = $frm ["SESSION_ID"]; - $params = array ('sessionId' => $sessionId ); - $wsResponse = $client->__SoapCall ( 'TaskList', array ($params ) ); - $result = G::PMWSCompositeResponse($wsResponse, 'tasks'); - - $G_PUBLISH = new Publisher ( ); - $rows [] = array ('guid' => 'char', 'name' => 'char' ); - - if (is_array ( $result )){ - - foreach ( $result as $key => $item ) { - if (isset ( $item->item )) - foreach ( $item->item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - } - else if (is_array ( $item )) - foreach ( $item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - } - else { - if (isset ( $item->guid )) - $guid = $item->guid; - if (isset ( $item->name )) - $name = $item->name; - } - - $rows [] = array ('guid' => $guid, 'name' => $name ); - } - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - $_DBArray ['task'] = $rows; - $_SESSION ['_DBArray'] = $_DBArray; - - G::LoadClass ( 'ArrayPeer' ); - $c = new Criteria ( 'dbarray' ); - $c->setDBArrayTable ( 'task' ); - $c->addAscendingOrderByColumn ( 'name' ); - $G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'setup/wsrTaskList', $c ); - } else if( is_object($result) ){ - $_SESSION ['WS_SESSION_ID'] = ''; - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = date("Y-m-d H:i:s"); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - } - G::RenderPage ( 'publish', 'raw' ); - break; - - case "TriggerList" : - $sessionId = $frm ["SESSION_ID"]; - $params = array ('sessionId' => $sessionId ); - - $wsResponse = $client->__SoapCall ( 'triggerList', array ($params ) ); - $result = G::PMWSCompositeResponse($wsResponse, 'triggers'); - - $G_PUBLISH = new Publisher (); - $rows [] = array ('guid' => 'char', 'name' => 'char', 'processId' => 'char' ); - - if (is_array ( $result )){ - foreach ( $result as $key => $item ) { - if (isset ( $item->item )) - foreach ( $item->item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - if ($val->key == 'processId') - $processId = $val->value; - } - else if (is_array ( $item )) - foreach ( $item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - if ($val->key == 'processId') - $processId = $val->value; - } - else { - if (isset ( $item->guid )) - $guid = $item->guid; - if (isset ( $item->name )) - $name = $item->name; - if (isset ( $item->processId )) - $processId = $item->processId; - } - $rows [] = array ('guid' => $guid, 'name' => $name, 'processId' => $processId ); - } - - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - - foreach ( $rows as $key => $row ) { - $proId = $row['processId']; - if ( isset ($_DBArray ['process']) && is_array ($_DBArray ['process']) ) - foreach ( $_DBArray ['process'] as $pkey => $prow ) { - if ( $proId == $prow['guid'] ) { - $rows[ $key ]['processId'] = $prow['name']; - } - } +$_POST['action'] = get_ajax_value( 'action' ); +if ($_POST['action'] == '') { + $_POST['action'] = (isset( $_GET['action'] )) ? $_GET['action'] : ''; +} + +switch ($_POST['action']) { + case 'showForm': + global $G_PUBLISH; + $xmlform = isset( $_POST['wsID'] ) ? 'setup/ws' . $_POST['wsID'] : ''; + if (file_exists( PATH_XMLFORM . $xmlform . '.xml' )) { + + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + $G_PUBLISH = new Publisher(); + $fields['SESSION_ID'] = isset( $_SESSION['WS_SESSION_ID'] ) ? $_SESSION['WS_SESSION_ID'] : ''; + $fields['ACTION'] = $_POST['wsID']; + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', $xmlform, '', $fields, '../setup/webServicesAjax' ); + G::RenderPage( 'publish', 'raw' ); + } + break; + case 'showDetails': + G::LoadClass( 'groups' ); + + $dbc = new DBConnection(); + $ses = new DBSession( $dbc ); + + if (! isset( $_SESSION['END_POINT'] )) { + $aFields['WS_HOST'] = $_SERVER['HTTP_HOST']; + $aFields['WS_WORKSPACE'] = SYS_SYS; + } else { + if (strpos( $_SESSION['END_POINT'], 'https' ) !== false) { + preg_match( '@^(?:https://)?([^/]+)@i', $_SESSION['END_POINT'], $coincidencias ); + } else { + preg_match( '@^(?:http://)?([^/]+)@i', $_SESSION['END_POINT'], $coincidencias ); + } + $aAux = explode( ':', $coincidencias[1] ); + $aFields['WS_HOST'] = $aAux[0]; + $aFields['WS_PORT'] = (isset( $aAux[1] ) ? $aAux[1] : ''); + $aAux = explode( $aAux[0] . (isset( $aAux[1] ) ? ':' . $aAux[1] : ''), $_SESSION['END_POINT'] ); + $aAux = explode( '/', $aAux[1] ); + $aFields['WS_WORKSPACE'] = substr( $aAux[1], 3 ); + } + + $rows[] = array ('uid' => 'char','name' => 'char','age' => 'integer','balance' => 'float' + ); + $rows[] = array ('uid' => 'http','name' => 'http' + ); + $rows[] = array ('uid' => 'https','name' => 'https' + ); + + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + $_DBArray['protocol'] = $rows; + $_SESSION['_DBArray'] = $_DBArray; + + if (! isset( $_SESSION['END_POINT'] )) { + //$wsdl = 'http://'.$_SERVER['HTTP_HOST'].'/sys'.SYS_SYS. '/'. SYS_LANG .'/classic/services/wsdl'; + $wsdl = 'http://' . $_SERVER['HTTP_HOST']; + $workspace = SYS_SYS; + } else { + $wsdl = $_SESSION['END_POINT']; + $workspace = $_SESSION['WS_WORKSPACE']; + } + + $defaultEndpoint = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/classic/services/wsdl2'; + + $wsdl = isset( $_SESSION['END_POINT'] ) ? $_SESSION['END_POINT'] : $defaultEndpoint; + + $wsSessionId = ''; + if (isset( $_SESSION['WS_SESSION_ID'] )) { + $wsSessionId = $_SESSION['WS_SESSION_ID']; + } + + $aFields['WSDL'] = $wsdl; + $aFields['OS'] = $workspace; + $aFields['WSID'] = $wsSessionId; + + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/webServicesDetails', '', $aFields, 'webServicesSetupSave' ); + + G::RenderPage( "publish", "raw" ); + break; + case 'showUploadFilesForm': + global $G_PUBLISH; + $xmlform = 'setup/wsSendFiles'; + if (file_exists( PATH_XMLFORM . $xmlform . '.xml' )) { + + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + + $G_PUBLISH = new Publisher(); + $fields['SESSION_ID'] = isset( $_SESSION['WS_SESSION_ID'] ) ? $_SESSION['WS_SESSION_ID'] : ''; + $fields['ACTION'] = 'wsSendFiles'; + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', $xmlform, '', $fields, '../setup/webServicesAjax' ); + G::RenderPage( 'publish', 'blank' ); + } + break; +} +try { + global $G_PUBLISH; + if (isset( $_POST['form']['ACTION'] )) { + $frm = $_POST['form']; + $action = $frm['ACTION']; + if (isset( $_POST["epr"] )) { + $_SESSION['END_POINT'] = $_POST["epr"]; + } + $defaultEndpoint = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/classic/services/wsdl2'; + + $endpoint = isset( $_SESSION['END_POINT'] ) ? $_SESSION['END_POINT'] : $defaultEndpoint; + + $sessionId = isset( $_SESSION['SESSION_ID'] ) ? $_SESSION['SESSION_ID'] : ''; + + //Apply proxy settings + $proxy = array (); + $sysConf = System::getSystemConfiguration(); + if ($sysConf['proxy_host'] != '') { + $proxy['proxy_host'] = $sysConf['proxy_host']; + if ($sysConf['proxy_port'] != '') { + $proxy['proxy_port'] = $sysConf['proxy_port']; + } + if ($sysConf['proxy_user'] != '') { + $proxy['proxy_login'] = $sysConf['proxy_user']; + } + if ($sysConf['proxy_pass'] != '') { + $proxy['proxy_password'] = $sysConf['proxy_pass']; + } + } + + @$client = new SoapClient( $endpoint, $proxy ); + + switch ($action) { + case "Login": + $user = $frm["USER_ID"]; + $pass = $frm["PASSWORD"]; + $params = array ('userid' => $user,'password' => $pass + ); + $result = $client->__SoapCall( 'login', array ($params + ) ); + $_SESSION['WS_SESSION_ID'] = ''; + if ($result->status_code == 0) { + $_SESSION['WS_SESSION_ID'] = $result->message; + } + $G_PUBLISH = new Publisher(); + $fields['status_code'] = $result->status_code; + $fields['message'] = 'ProcessMaker WebService version: ' . $result->version . "\n" . $result->message; + $fields['version'] = $result->version; + $fields['time_stamp'] = $result->timestamp; + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + G::RenderPage( 'publish', 'raw' ); + break; + case "ProcessList": + $sessionId = $frm["SESSION_ID"]; + $params = array ('sessionId' => $sessionId + ); + + $wsResponse = $client->__SoapCall( 'ProcessList', array ($params + ) ); + $result = G::PMWSCompositeResponse( $wsResponse, 'processes' ); + + $G_PUBLISH = new Publisher(); + $rows[] = array ('guid' => 'char','name' => 'char' + ); + + if (is_array( $result )) { + foreach ($result as $key => $item) { + if (isset( $item->item )) + foreach ($item->item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + } + else if (is_array( $item )) + foreach ($item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + } + else { + if (isset( $item->guid )) + $guid = $item->guid; + if (isset( $item->name )) + $name = $item->name; + } + + $rows[] = array ('guid' => $guid,'name' => $name + ); + } + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + $_DBArray['process'] = $rows; + $_SESSION['_DBArray'] = $_DBArray; + + $c = new Criteria( 'dbarray' ); + $c->setDBArrayTable( 'process' ); + $c->addAscendingOrderByColumn( 'name' ); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrProcessList', $c ); + } else if (is_object( $result )) { + $_SESSION['WS_SESSION_ID'] = ''; + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = date( "Y-m-d H:i:s" ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + } + + G::RenderPage( 'publish', 'raw' ); + break; + case "RoleList": + $sessionId = $frm["SESSION_ID"]; + $params = array ('sessionId' => $sessionId + ); + $wsResponse = $client->__SoapCall( 'RoleList', array ($params + ) ); + $result = G::PMWSCompositeResponse( $wsResponse, 'roles' ); + + $G_PUBLISH = new Publisher(); + + $rows[] = array ('guid' => 'char','name' => 'char' + ); + if (is_array( $result )) { + + foreach ($result as $key => $item) { + if (isset( $item->item )) + foreach ($item->item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + } + else if (is_array( $item )) + foreach ($item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + } + else { + if (isset( $item->guid )) + $guid = $item->guid; + if (isset( $item->name )) + $name = $item->name; + } + + $rows[] = array ('guid' => $guid,'name' => $name + ); + } + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + $_DBArray['role'] = $rows; + $_SESSION['_DBArray'] = $_DBArray; + + G::LoadClass( 'ArrayPeer' ); + $c = new Criteria( 'dbarray' ); + $c->setDBArrayTable( 'role' ); + $c->addAscendingOrderByColumn( 'name' ); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrRoleList', $c ); + } else if (is_object( $result )) { + $_SESSION['WS_SESSION_ID'] = ''; + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = date( "Y-m-d H:i:s" ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + } + + G::RenderPage( 'publish', 'raw' ); + break; + case "GroupList": + $sessionId = $frm["SESSION_ID"]; + $params = array ('sessionId' => $sessionId + ); + $wsResponse = $client->__SoapCall( 'GroupList', array ($params + ) ); + $result = G::PMWSCompositeResponse( $wsResponse, 'groups' ); + + $G_PUBLISH = new Publisher(); + $rows[] = array ('guid' => 'char','name' => 'char' + ); + if (is_array( $result )) { + foreach ($result as $key => $item) { + if (isset( $item->item )) + foreach ($item->item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + } + else if (is_array( $item )) + foreach ($item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + } + else { + if (isset( $item->guid )) + $guid = $item->guid; + if (isset( $item->name )) + $name = $item->name; + } + + $rows[] = array ('guid' => $guid,'name' => $name + ); + } + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + $_DBArray['group'] = $rows; + $_SESSION['_DBArray'] = $_DBArray; + + G::LoadClass( 'ArrayPeer' ); + $c = new Criteria( 'dbarray' ); + $c->setDBArrayTable( 'group' ); + $c->addAscendingOrderByColumn( 'name' ); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrGroupList', $c ); + } else if (is_object( $result )) { + $_SESSION['WS_SESSION_ID'] = ''; + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = date( "Y-m-d H:i:s" ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + } + + G::RenderPage( 'publish', 'raw' ); + break; + case "CaseList": + $sessionId = $frm["SESSION_ID"]; + $params = array ('sessionId' => $sessionId + ); + $wsResponse = $client->__SoapCall( 'CaseList', array ($params + ) ); + + $G_PUBLISH = new Publisher(); + $rows[] = array ('guid' => 'char','name' => 'char','status' => 'char','delIndex' => 'char' + ); + + $result = G::PMWSCompositeResponse( $wsResponse, 'cases' ); + + if (is_array( $result )) { + foreach ($result as $key => $item) { + if (isset( $item->item )) + foreach ($item->item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + if ($val->key == 'status') + $status = $val->value; + if ($val->key == 'delIndex') + $delIndex = $val->value; + } + else if (is_array( $item )) + foreach ($item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + if ($val->key == 'status') + $status = $val->value; + if ($val->key == 'delIndex') + $delIndex = $val->value; + } + else { + if (isset( $item->guid )) + $guid = $item->guid; + if (isset( $item->name )) + $name = $item->name; + if (isset( $item->status )) + $status = $item->status; + if (isset( $item->delIndex )) + $delIndex = $item->delIndex; + + } + $rows[] = array ('guid' => $guid,'name' => $name,'status' => $status,'delIndex' => $delIndex + ); + + } + + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + $_DBArray['case'] = $rows; + $_SESSION['_DBArray'] = $_DBArray; + + G::LoadClass( 'ArrayPeer' ); + $c = new Criteria( 'dbarray' ); + $c->setDBArrayTable( 'case' ); + //$c->addAscendingOrderByColumn ( 'name' ); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrCaseList', $c ); + + } else if (is_object( $result )) { + $_SESSION['WS_SESSION_ID'] = ''; + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = date( "Y-m-d H:i:s" ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + } + + G::RenderPage( 'publish', 'raw' ); + break; + case "UnassignedCaseList": + $sessionId = $frm["SESSION_ID"]; + $params = array ('sessionId' => $sessionId + ); + + $wsResponse = $client->__SoapCall( 'UnassignedCaseList', array ($params + ) ); + + $G_PUBLISH = new Publisher(); + $rows[] = array ('guid' => 'char','name' => 'char','delIndex' => 'char' + ); + $result = G::PMWSCompositeResponse( $wsResponse, 'cases' ); + + if (is_array( $result )) { + foreach ($result as $key => $item) { + if (isset( $item->item )) + foreach ($item->item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + if ($val->key == 'delIndex') + $delIndex = $val->value; + } + else if (is_array( $item )) + foreach ($item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + if ($val->key == 'delIndex') + $delIndex = $val->value; + } + else { + if (isset( $item->guid )) + $guid = $item->guid; + if (isset( $item->name )) + $name = $item->name; + if (isset( $item->delIndex )) + $delIndex = $item->delIndex; + } + $rows[] = array ('guid' => $guid,'name' => $name,'delIndex' => $delIndex + ); + } + + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + $_DBArray['case'] = $rows; + $_SESSION['_DBArray'] = $_DBArray; + + G::LoadClass( 'ArrayPeer' ); + $c = new Criteria( 'dbarray' ); + $c->setDBArrayTable( 'case' ); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrUnassignedCaseList', $c ); + + } else if (is_object( $result )) { + $_SESSION['WS_SESSION_ID'] = ''; + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = date( "Y-m-d H:i:s" ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + } + + G::RenderPage( 'publish', 'raw' ); + break; + case "UserList": + $sessionId = $frm["SESSION_ID"]; + $params = array ('sessionId' => $sessionId + ); + $wsResponse = $client->__SoapCall( 'UserList', array ($params + ) ); + $result = G::PMWSCompositeResponse( $wsResponse, 'users' ); + + $G_PUBLISH = new Publisher(); + $rows[] = array ('guid' => 'char','name' => 'char' + ); + if (is_array( $result )) { + + foreach ($result as $key => $item) { + if (isset( $item->item )) + foreach ($item->item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + } + else if (is_array( $item )) + foreach ($item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + } + else { + if (isset( $item->guid )) + $guid = $item->guid; + if (isset( $item->name )) + $name = $item->name; + } + + $rows[] = array ('guid' => $guid,'name' => $name + ); + } + + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + $_DBArray['user'] = $rows; + $_SESSION['_DBArray'] = $_DBArray; + + G::LoadClass( 'ArrayPeer' ); + $c = new Criteria( 'dbarray' ); + $c->setDBArrayTable( 'user' ); + $c->addAscendingOrderByColumn( 'name' ); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrUserList', $c ); + + } else if (is_object( $result )) { + $_SESSION['WS_SESSION_ID'] = ''; + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = date( "Y-m-d H:i:s" ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + } + G::RenderPage( 'publish', 'raw' ); + break; + case "SendMessage": + require_once ('classes/model/Application.php'); + $sessionId = $frm["SESSION_ID"]; + $from = $frm["FROM"]; + $to = $frm["TO_EMAIL"]; + $cc = isset( $frm["CC_MAIL"] ) ? $frm["CC_MAIL"] : ''; + $bcc = isset( $frm["BCC_MAIL"] ) ? $frm["BCC_MAIL"] : ''; + $caseId = $frm["CASE_ID"]; + $subject = $frm["SUBJECT"]; + $message = $frm["MESSAGE"]; + // getting the proUid variable + $oCases = new Application(); + $oCases->load( $caseId ); + $proUid = $oCases->getProUid(); + $caseNumber = $oCases->getAppNumber(); + + // generating the path for the template msj + $templateFile = PATH_DB . SYS_SYS . PATH_SEP . 'mailTemplates' . PATH_SEP . $proUid . PATH_SEP . 'tempTemplate.hml'; + // generating the file adding the msj variable + $messageBody = "message for case: " . $caseNumber . "
" . $message; + file_put_contents( $templateFile, $messageBody ); + + $params = array ('sessionId' => $sessionId,'caseId' => $caseId,'from' => $from,'to' => $to,'cc' => $cc,'bcc' => $bcc,'subject' => $subject,'template' => 'tempTemplate.hml' + ); + $result = $client->__SoapCall( 'sendMessage', array ($params + ) ); + $G_PUBLISH = new Publisher(); + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = $result->timestamp; + + if ($result->status_code == 9) { + $_SESSION['WS_SESSION_ID'] = ''; + } + + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + G::RenderPage( 'publish', 'raw' ); + break; + case "SendVariables": + $sessionId = $frm["SESSION_ID"]; + $caseId = $frm["CASE_ID"]; + $variables = Array (); + + $o = new stdClass(); + $o->name = $frm["NAME1"]; + $o->value = $frm["VALUE1"]; + array_push( $variables, $o ); + $o = new stdClass(); + $o->name = $frm["NAME2"]; + $o->value = $frm["VALUE2"]; + array_push( $variables, $o ); + + $params = array ('sessionId' => $sessionId,'caseId' => $caseId,'variables' => $variables + ); + $result = $client->__SoapCall( 'SendVariables', array ($params + ) ); + $G_PUBLISH = new Publisher(); + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = $result->timestamp; + + if ($result->status_code == 9) { + $_SESSION['WS_SESSION_ID'] = ''; + } + + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + G::RenderPage( 'publish', 'raw' ); + break; + case "DerivateCase": + $sessionId = $frm["SESSION_ID"]; + $caseId = $frm["CASE_ID"]; + $delIndex = $frm["DEL_INDEX"]; + + $params = array ('sessionId' => $sessionId,'caseId' => $caseId,'delIndex' => $delIndex + ); + $result = $client->__SoapCall( 'RouteCase', array ($params + ) ); + $G_PUBLISH = new Publisher(); + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = $result->timestamp; + + if ($result->status_code == 9) { + $_SESSION['WS_SESSION_ID'] = ''; + } + + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + G::RenderPage( 'publish', 'raw' ); + break; + case "ReassignCase": + $sessionId = $frm["SESSION_ID"]; + $caseId = $frm["CASE_ID"]; + $delIndex = $frm["DEL_INDEX"]; + $userIdSource = $frm['USERIDSOURCE']; + $userIdTarget = $frm['USERIDTARGET']; + + $params = array ('sessionId' => $sessionId,'caseId' => $caseId,'delIndex' => $delIndex,'userIdSource' => $userIdSource,'userIdTarget' => $userIdTarget + ); + $result = $client->__SoapCall( 'reassignCase', array ($params + ) ); + + $G_PUBLISH = new Publisher(); + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = $result->timestamp; + + if ($result->status_code == 9) { + $_SESSION['WS_SESSION_ID'] = ''; + } + + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + G::RenderPage( 'publish', 'raw' ); + break; + case "NewCaseImpersonate": + $sessionId = $frm["SESSION_ID"]; + $processId = $frm["PROCESS_ID"]; + $userId = $frm["USER_ID"]; + $variables = Array (); + foreach ($frm['VARIABLES'] as $iRow => $aRow) { + $o = new stdClass(); + $o->name = $aRow['NAME']; + $o->value = $aRow['VALUE']; + array_push( $variables, $o ); + } + $params = array ('sessionId' => $sessionId,'processId' => $processId,'userId' => $userId,'variables' => $variables + ); + $result = $client->__SoapCall( 'NewCaseImpersonate', array ($params + ) ); + $G_PUBLISH = new Publisher(); + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = $result->timestamp; + + if ($result->status_code == 9) { + $_SESSION['WS_SESSION_ID'] = ''; + } + + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + G::RenderPage( 'publish', 'raw' ); + break; + case "NewCase": + $sessionId = $frm["SESSION_ID"]; + $processId = $frm["PROCESS_ID"]; + $taskId = $frm["TASK_ID"]; + + $variables = Array (); + foreach ($frm['VARIABLES'] as $iRow => $aRow) { + $o = new stdClass(); + $o->name = $aRow['NAME']; + $o->value = $aRow['VALUE']; + array_push( $variables, $o ); + } + $params = array ('sessionId' => $sessionId,'processId' => $processId,'taskId' => $taskId,'variables' => $variables + ); + $result = $client->__SoapCall( 'NewCase', array ($params + ) ); + + $G_PUBLISH = new Publisher(); + + $fields['status_code'] = $result->status_code; + $fields['time_stamp'] = $result->timestamp; + if (isset( $result->caseId )) { + $fields['message'] = "Case ID: " . $result->caseId . "\nCase Number: " . $result->caseNumber . "\n" . $result->message; + } else { + $fields['message'] = ''; + } + if ($result->status_code == 9) { + $_SESSION['WS_SESSION_ID'] = ''; + } + + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + G::RenderPage( 'publish', 'raw' ); + break; + case "AssignUserToGroup": + $sessionId = $frm["SESSION_ID"]; + $userId = $frm["USER_ID"]; + $groupId = $frm["GROUP_ID"]; + $params = array ('sessionId' => $sessionId,'userId' => $userId,'groupId' => $groupId + ); + $result = $client->__SoapCall( 'AssignUserToGroup', array ($params + ) ); + $G_PUBLISH = new Publisher(); + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = $result->timestamp; + + if ($result->status_code == 9) { + $_SESSION['WS_SESSION_ID'] = ''; + } + + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + G::RenderPage( 'publish', 'raw' ); + break; + case "CreateUser": + $sessionId = $frm["SESSION_ID"]; + $userId = $frm["USER_ID"]; + $firstname = $frm["FIRST_NAME"]; + $lastname = $frm["LAST_NAME"]; + $email = $frm["EMAIL"]; + $role = $frm["ROLE"]; + $password = $frm["PASSWORD"]; + + $params = array ('sessionId' => $sessionId,'userId' => $userId,'firstname' => $firstname,'lastname' => $lastname,'email' => $email,'role' => $role,'password' => $password + ); + $result = $client->__SoapCall( 'CreateUser', array ($params + ) ); + $G_PUBLISH = new Publisher(); + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = $result->timestamp; + + if ($result->status_code == 9) { + $_SESSION['WS_SESSION_ID'] = ''; + } + + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + G::RenderPage( 'publish', 'raw' ); + break; + case "TaskList": + $sessionId = $frm["SESSION_ID"]; + $params = array ('sessionId' => $sessionId + ); + $wsResponse = $client->__SoapCall( 'TaskList', array ($params + ) ); + $result = G::PMWSCompositeResponse( $wsResponse, 'tasks' ); + + $G_PUBLISH = new Publisher(); + $rows[] = array ('guid' => 'char','name' => 'char' + ); + + if (is_array( $result )) { + + foreach ($result as $key => $item) { + if (isset( $item->item )) + foreach ($item->item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + } + else if (is_array( $item )) + foreach ($item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + } + else { + if (isset( $item->guid )) + $guid = $item->guid; + if (isset( $item->name )) + $name = $item->name; + } + + $rows[] = array ('guid' => $guid,'name' => $name + ); + } + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + $_DBArray['task'] = $rows; + $_SESSION['_DBArray'] = $_DBArray; + + G::LoadClass( 'ArrayPeer' ); + $c = new Criteria( 'dbarray' ); + $c->setDBArrayTable( 'task' ); + $c->addAscendingOrderByColumn( 'name' ); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrTaskList', $c ); + } else if (is_object( $result )) { + $_SESSION['WS_SESSION_ID'] = ''; + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = date( "Y-m-d H:i:s" ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + } + G::RenderPage( 'publish', 'raw' ); + break; + case "TriggerList": + $sessionId = $frm["SESSION_ID"]; + $params = array ('sessionId' => $sessionId + ); + + $wsResponse = $client->__SoapCall( 'triggerList', array ($params + ) ); + $result = G::PMWSCompositeResponse( $wsResponse, 'triggers' ); + + $G_PUBLISH = new Publisher(); + $rows[] = array ('guid' => 'char','name' => 'char','processId' => 'char' + ); + + if (is_array( $result )) { + foreach ($result as $key => $item) { + if (isset( $item->item )) + foreach ($item->item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + if ($val->key == 'processId') + $processId = $val->value; + } + else if (is_array( $item )) + foreach ($item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + if ($val->key == 'processId') + $processId = $val->value; + } + else { + if (isset( $item->guid )) + $guid = $item->guid; + if (isset( $item->name )) + $name = $item->name; + if (isset( $item->processId )) + $processId = $item->processId; + } + $rows[] = array ('guid' => $guid,'name' => $name,'processId' => $processId + ); + } + + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + + foreach ($rows as $key => $row) { + $proId = $row['processId']; + if (isset( $_DBArray['process'] ) && is_array( $_DBArray['process'] )) + foreach ($_DBArray['process'] as $pkey => $prow) { + if ($proId == $prow['guid']) { + $rows[$key]['processId'] = $prow['name']; + } + } + } + + $_DBArray['triggers'] = $rows; + $_SESSION['_DBArray'] = $_DBArray; + + G::LoadClass( 'ArrayPeer' ); + $c = new Criteria( 'dbarray' ); + $c->setDBArrayTable( 'triggers' ); + $c->addAscendingOrderByColumn( 'name' ); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrTriggerList', $c ); + + } else if (is_object( $result )) { + $_SESSION['WS_SESSION_ID'] = ''; + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = date( "Y-m-d H:i:s" ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + } + + G::RenderPage( 'publish', 'raw' ); + break; + case "InputDocumentList": + $caseId = $frm["CASE_ID"]; + $sessionId = $frm["SESSION_ID"]; + $params = array ('sessionId' => $sessionId,'caseId' => $caseId + ); + + $wsResponse = $client->__SoapCall( 'InputDocumentList', array ($params + ) ); + + //g::pr($wsResponse); + $result = G::PMWSCompositeResponse( $wsResponse, 'documents' ); + + $G_PUBLISH = new Publisher(); + $rows[] = array ('guid' => 'char','name' => 'char','processId' => 'char' + ); + + if (is_array( $result )) { + foreach ($result as $key => $item) { + if (isset( $item->item )) + foreach ($item->item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'filename') + $filename = $val->value; + if ($val->key == 'docId') + $docId = $val->value; + if ($val->key == 'version') + $version = $val->value; + if ($val->key == 'createDate') + $createDate = $val->value; + if ($val->key == 'createBy') + $createBy = $val->value; + if ($val->key == 'type') + $type = $val->value; + if ($val->key == 'link') + $link = $val->value; + } + else if (is_array( $item )) + foreach ($item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'filename') + $filename = $val->value; + if ($val->key == 'docId') + $docId = $val->value; + if ($val->key == 'version') + $version = $val->value; + if ($val->key == 'createDate') + $createDate = $val->value; + if ($val->key == 'createBy') + $createBy = $val->value; + if ($val->key == 'type') + $type = $val->value; + if ($val->key == 'link') + $link = $val->value; + } + else { + if (isset( $item->guid )) + $guid = $item->guid; + if (isset( $item->filename )) + $filename = $item->filename; + if (isset( $item->docId )) + $docId = $item->docId; + if (isset( $item->version )) + $version = $item->version; + if (isset( $item->createDate )) + $createDate = $item->createDate; + if (isset( $item->createBy )) + $createBy = $item->createBy; + if (isset( $item->type )) + $type = $item->type; + if (isset( $item->link )) + $link = $item->link; + } + $rows[] = array ('guid' => $guid,'filename' => $filename,'docId' => $docId,'version' => $version,'createDate' => $createDate,'createBy' => $createBy,'type' => $type,'link' => $link + ); + } + + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + $_DBArray['inputDocument'] = $rows; + $documentArray = array (); + $documentArray[] = array ('guid' => 'char','filename' => 'char' + ); + if (isset( $_DBArray['inputDocument'] )) + foreach ($_DBArray['inputDocument'] as $key => $val) + if ($key != 0 && isset( $val['filename'] )) + $documentArray[] = array ('guid' => $val['guid'],'filename' => $val['filename'] + ); + if (isset( $_DBArray['outputDocument'] )) + foreach ($_DBArray['outputDocument'] as $key => $val) + if ($key != 0 && isset( $val['filename'] )) + $documentArray[] = array ('guid' => $val['guid'],'filename' => $val['filename'] + ); + $_DBArray['documents'] = $documentArray; + $_DBArray['WS_TMP_CASE_UID'] = $frm["CASE_ID"]; + $_SESSION['_DBArray'] = $_DBArray; + + G::LoadClass( 'ArrayPeer' ); + $c = new Criteria( 'dbarray' ); + $c->setDBArrayTable( 'inputDocument' ); + $c->addAscendingOrderByColumn( 'name' ); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrInputDocumentList', $c ); + + } else if (is_object( $result )) { + $_SESSION['WS_SESSION_ID'] = ''; + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = date( "Y-m-d H:i:s" ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + } + G::RenderPage( 'publish', 'raw' ); + break; + case "InputDocumentProcessList": + $processId = $frm["PROCESS_ID"]; + $sessionId = $frm["SESSION_ID"]; + $params = array ('sessionId' => $sessionId,'processId' => $processId + ); + + $wsResponse = $client->__SoapCall( 'InputDocumentProcessList', array ($params + ) ); + $result = G::PMWSCompositeResponse( $wsResponse, 'documents' ); + + $G_PUBLISH = new Publisher(); + $rows[] = array ('guid' => 'char','name' => 'char','description' => 'char' + ); + if (is_array( $result )) { + foreach ($result as $key => $item) { + if (isset( $item->item )) + foreach ($item->item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + if ($val->key == 'description') + $description = $val->value; + } + else if (is_array( $item )) + foreach ($item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'name') + $name = $val->value; + if ($val->key == 'description') + $description = $val->value; + } + else { + if (isset( $item->guid )) + $guid = $item->guid; + if (isset( $item->name )) + $name = $item->name; + if (isset( $item->description )) + $description = $item->description; + } + $rows[] = array ('guid' => $guid,'name' => $name,'description' => $description + ); + } + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + $_DBArray['inputDocuments'] = $rows; + $_SESSION['_DBArray'] = $_DBArray; + + G::LoadClass( 'ArrayPeer' ); + $c = new Criteria( 'dbarray' ); + $c->setDBArrayTable( 'inputDocuments' ); + $c->addAscendingOrderByColumn( 'name' ); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrInputDocumentProcessList', $c ); + } else if (is_object( $result )) { + $_SESSION['WS_SESSION_ID'] = ''; + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = date( "Y-m-d H:i:s" ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + } + G::RenderPage( 'publish', 'raw' ); + break; + case "OutputDocumentList": + $caseId = $frm["CASE_ID"]; + $sessionId = $frm["SESSION_ID"]; + $params = array ('sessionId' => $sessionId,'caseId' => $caseId + ); + + $wsResponse = $client->__SoapCall( 'outputDocumentList', array ($params + ) ); + $result = G::PMWSCompositeResponse( $wsResponse, 'documents' ); + + $G_PUBLISH = new Publisher(); + $rows = array (); + $rows[] = array ('guid' => 'char','name' => 'char' + ); + if (is_array( $result )) { + + foreach ($result as $key => $item) { + if (isset( $item->item )) + foreach ($item->item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'filename') + $filename = $val->value; + if ($val->key == 'docId') + $docId = $val->value; + if ($val->key == 'version') + $version = $val->value; + if ($val->key == 'createDate') + $createDate = $val->value; + if ($val->key == 'createBy') + $createBy = $val->value; + if ($val->key == 'type') + $type = $val->value; + if ($val->key == 'link') + $link = $val->value; + } + else if (is_array( $item )) + foreach ($item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + if ($val->key == 'filename') + $filename = $val->value; + if ($val->key == 'docId') + $docId = $val->value; + if ($val->key == 'version') + $version = $val->value; + if ($val->key == 'createDate') + $createDate = $val->value; + if ($val->key == 'createBy') + $createBy = $val->value; + if ($val->key == 'type') + $type = $val->value; + if ($val->key == 'link') + $link = $val->value; + } + else { + if (isset( $item->guid )) + $guid = $item->guid; + if (isset( $item->filename )) + $filename = $item->filename; + if (isset( $item->docId )) + $docId = $item->docId; + if (isset( $item->version )) + $version = $item->version; + if (isset( $item->createDate )) + $createDate = $item->createDate; + if (isset( $item->createBy )) + $createBy = $item->createBy; + if (isset( $item->type )) + $type = $item->type; + if (isset( $item->link )) + $link = $item->link; + } + $rows[] = array ('guid' => $guid,'filename' => $filename,'docId' => $docId,'version' => $version,'createDate' => $createDate,'createBy' => $createBy,'type' => $type,'link' => $link + ); + } + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + $_DBArray['outputDocument'] = $rows; + $documentArray = array (); + $documentArray[] = array ('guid' => 'char','filename' => 'char' + ); + if (isset( $_DBArray['inputDocument'] )) + foreach ($_DBArray['inputDocument'] as $key => $val) + if ($key != 0 && isset( $val['filename'] )) + $documentArray[] = array ('guid' => $val['guid'],'filename' => $val['filename'] + ); + if (isset( $_DBArray['outputDocument'] )) + foreach ($_DBArray['outputDocument'] as $key => $val) + if ($key != 0 && isset( $val['filename'] )) + $documentArray[] = array ('guid' => $val['guid'],'filename' => $val['filename'] + ); + $_DBArray['documents'] = $documentArray; + $_SESSION['_DBArray'] = $_DBArray; + + G::LoadClass( 'ArrayPeer' ); + $c = new Criteria( 'dbarray' ); + $c->setDBArrayTable( 'outputDocument' ); + $c->addAscendingOrderByColumn( 'name' ); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrOutputDocumentList', $c ); + } else if (is_object( $result )) { + $_SESSION['WS_SESSION_ID'] = ''; + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = date( "Y-m-d H:i:s" ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + } + + G::RenderPage( 'publish', 'raw' ); + break; + //add removeUserFromGroup + case "removeUserFromGroup": + $sessionId = $frm["SESSION_ID"]; + $userId = $frm["USER_ID"]; + $groupId = $frm["GROUP_ID"]; + $params = array ('sessionId' => $sessionId,'userId' => $userId,'groupId' => $groupId + ); + $result = $client->__SoapCall( 'removeUserFromGroup', array ($params + ) ); + $G_PUBLISH = new Publisher(); + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = $result->timestamp; + if ($result->status_code == 9) { + $_SESSION['WS_SESSION_ID'] = ''; + } + + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + G::RenderPage( 'publish', 'raw' ); + break; + //end add + case "RemoveDocument": + $appDocUid = $frm["APP_DOC_UID"]; + $sessionId = $frm["SESSION_ID"]; + $params = array ('sessionId' => $sessionId,'appDocUid' => $appDocUid + ); + $result = $client->__SoapCall( 'RemoveDocument', array ($params + ) ); + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = $result->timestamp; + + if ($result->status_code == 9) { + $_SESSION['WS_SESSION_ID'] = ''; + } + + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + G::RenderPage( 'publish', 'raw' ); + break; + case "TaskCase": + $sessionId = $frm["SESSION_ID"]; + $caseId = $frm["CASE_ID"]; + + $params = array ('sessionId' => $sessionId,'caseId' => $caseId + ); + $wsResponse = $client->__SoapCall( 'TaskCase', array ($params + ) ); + $result = G::PMWSCompositeResponse( $wsResponse, 'taskCases' ); + + $G_PUBLISH = new Publisher(); + $rows[] = array ('guid' => 'char','name' => 'char' + ); + + if (is_array( $result )) { + + foreach ($result as $key => $item) { + if (isset( $item->item )) + foreach ($item->item as $index => $val) { + if ($val->key == 'guid') { + $guid = $val->value; + } + if ($val->key == 'name') { + $name = $val->value; + } + } + else if (is_array( $item )) + foreach ($item as $index => $val) { + if ($val->key == 'guid') + $guid = $val->value; + } + if ($val->key == 'name') { + $name = $val->value; + } } - - $_DBArray ['triggers'] = $rows; - $_SESSION ['_DBArray'] = $_DBArray; - - G::LoadClass ( 'ArrayPeer' ); - $c = new Criteria ( 'dbarray' ); - $c->setDBArrayTable ( 'triggers' ); - $c->addAscendingOrderByColumn ( 'name' ); - $G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'setup/wsrTriggerList', $c ); - - } else if ( is_object($result) ){ - $_SESSION ['WS_SESSION_ID'] = ''; - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = date("Y-m-d H:i:s"); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - } - - G::RenderPage ( 'publish', 'raw' ); - break; - - case "InputDocumentList" : - $caseId = $frm ["CASE_ID"]; - $sessionId = $frm ["SESSION_ID"]; - $params = array ('sessionId' => $sessionId, 'caseId' => $caseId ); - - $wsResponse = $client->__SoapCall ( 'InputDocumentList', array ($params ) ); - - //g::pr($wsResponse); - $result = G::PMWSCompositeResponse($wsResponse, 'documents'); - - $G_PUBLISH = new Publisher ( ); - $rows [] = array ('guid' => 'char', 'name' => 'char', 'processId' => 'char' ); - - if (is_array( $result )){ - foreach ( $result as $key => $item ) { - if (isset ( $item->item )) - foreach ( $item->item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'filename') - $filename = $val->value; - if ($val->key == 'docId') - $docId = $val->value; - if ($val->key == 'version') - $version = $val->value; - if ($val->key == 'createDate') - $createDate = $val->value; - if ($val->key == 'createBy') - $createBy = $val->value; - if ($val->key == 'type') - $type = $val->value; - if ($val->key == 'link') - $link = $val->value; - } - else if (is_array ( $item )) - foreach ( $item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'filename') - $filename = $val->value; - if ($val->key == 'docId') - $docId = $val->value; - if ($val->key == 'version') - $version = $val->value; - if ($val->key == 'createDate') - $createDate = $val->value; - if ($val->key == 'createBy') - $createBy = $val->value; - if ($val->key == 'type') - $type = $val->value; - if ($val->key == 'link') - $link = $val->value; - } - else { - if (isset ( $item->guid )) - $guid = $item->guid; - if (isset ( $item->filename )) - $filename = $item->filename; - if (isset ( $item->docId )) - $docId = $item->docId; - if (isset ( $item->version )) - $version = $item->version; - if (isset ( $item->createDate )) - $createDate = $item->createDate; - if (isset ( $item->createBy )) - $createBy = $item->createBy; - if (isset ( $item->type )) - $type = $item->type; - if (isset ( $item->link )) - $link = $item->link; - } - $rows [] = array ('guid' => $guid, 'filename' => $filename, 'docId' => $docId, 'version' => $version, - 'createDate' => $createDate, 'createBy' => $createBy, 'type' => $type, 'link' => $link ); - } - - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - $_DBArray ['inputDocument'] = $rows; - $documentArray = array(); - $documentArray[] = array ('guid' => 'char', 'filename' => 'char' ); - if ( isset($_DBArray ['inputDocument']) ) - foreach ( $_DBArray ['inputDocument'] as $key => $val ) - if ( $key != 0 && isset ($val['filename']) ) - $documentArray[] = array ('guid' => $val['guid'], 'filename' => $val['filename'] ); - if ( isset($_DBArray ['outputDocument']) ) - foreach ( $_DBArray ['outputDocument'] as $key => $val ) - if ( $key != 0 && isset ($val['filename']) ) - $documentArray[] = array ('guid' => $val['guid'], 'filename' => $val['filename'] ); - $_DBArray ['documents'] = $documentArray; - $_DBArray ['WS_TMP_CASE_UID'] = $frm ["CASE_ID"]; - $_SESSION ['_DBArray'] = $_DBArray; - - G::LoadClass ( 'ArrayPeer' ); - $c = new Criteria ( 'dbarray' ); - $c->setDBArrayTable ( 'inputDocument' ); - $c->addAscendingOrderByColumn ( 'name' ); - $G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'setup/wsrInputDocumentList', $c ); - - } else if ( is_object($result) ){ - $_SESSION ['WS_SESSION_ID'] = ''; - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = date("Y-m-d H:i:s"); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - } - G::RenderPage ( 'publish', 'raw' ); - - break; - - case "InputDocumentProcessList" : - $processId = $frm ["PROCESS_ID"]; - $sessionId = $frm ["SESSION_ID"]; - $params = array ('sessionId' => $sessionId, 'processId' => $processId ); - - $wsResponse = $client->__SoapCall ( 'InputDocumentProcessList', array ($params ) ); - $result = G::PMWSCompositeResponse($wsResponse, 'documents'); - - $G_PUBLISH = new Publisher(); - $rows [] = array ('guid' => 'char', 'name' => 'char', 'description' => 'char' ); - if (is_array ( $result )){ - foreach ( $result as $key => $item ) { - if (isset ( $item->item )) - foreach ( $item->item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - if ($val->key == 'description') - $description = $val->value; - } - else if (is_array ( $item )) - foreach ( $item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - if ($val->key == 'description') - $description = $val->value; - } - else { - if (isset ( $item->guid )) - $guid = $item->guid; - if (isset ( $item->name )) - $name = $item->name; - if (isset ( $item->description )) - $description = $item->description; - } - $rows [] = array ('guid' => $guid, 'name' => $name, 'description' => $description ); - } - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - $_DBArray ['inputDocuments'] = $rows; - $_SESSION ['_DBArray'] = $_DBArray; - - G::LoadClass ( 'ArrayPeer' ); - $c = new Criteria ( 'dbarray' ); - $c->setDBArrayTable ( 'inputDocuments' ); - $c->addAscendingOrderByColumn ( 'name' ); - $G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'setup/wsrInputDocumentProcessList', $c ); - } else if ( is_object($result) ){ - $_SESSION ['WS_SESSION_ID'] = ''; - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = date("Y-m-d H:i:s"); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - } - G::RenderPage ( 'publish', 'raw' ); - break; - - - case "OutputDocumentList" : - $caseId = $frm ["CASE_ID"]; - $sessionId = $frm ["SESSION_ID"]; - $params = array ('sessionId' => $sessionId, 'caseId' => $caseId ); - - $wsResponse = $client->__SoapCall ( 'outputDocumentList', array ($params ) ); - $result = G::PMWSCompositeResponse($wsResponse, 'documents'); - - $G_PUBLISH = new Publisher ( ); - $rows = array(); - $rows [] = array ('guid' => 'char', 'name' => 'char' ); - if (is_array ( $result )){ - - foreach ( $result as $key => $item ) { - if (isset ( $item->item )) - foreach ( $item->item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'filename') - $filename = $val->value; - if ($val->key == 'docId') - $docId = $val->value; - if ($val->key == 'version') - $version = $val->value; - if ($val->key == 'createDate') - $createDate = $val->value; - if ($val->key == 'createBy') - $createBy = $val->value; - if ($val->key == 'type') - $type = $val->value; - if ($val->key == 'link') - $link = $val->value; - } - else if (is_array ( $item )) - foreach ( $item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'filename') - $filename = $val->value; - if ($val->key == 'docId') - $docId = $val->value; - if ($val->key == 'version') - $version = $val->value; - if ($val->key == 'createDate') - $createDate = $val->value; - if ($val->key == 'createBy') - $createBy = $val->value; - if ($val->key == 'type') - $type = $val->value; - if ($val->key == 'link') - $link = $val->value; - } - else { - if (isset ( $item->guid )) - $guid = $item->guid; - if (isset ( $item->filename )) - $filename = $item->filename; - if (isset ( $item->docId )) - $docId = $item->docId; - if (isset ( $item->version )) - $version = $item->version; - if (isset ( $item->createDate )) - $createDate = $item->createDate; - if (isset ( $item->createBy )) - $createBy = $item->createBy; - if (isset ( $item->type )) - $type = $item->type; - if (isset ( $item->link )) - $link = $item->link; - } - $rows [] = array ('guid' => $guid, 'filename' => $filename, 'docId' => $docId, 'version' => $version, - 'createDate' => $createDate, 'createBy' => $createBy, 'type' => $type, 'link' => $link ); - } - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - $_DBArray ['outputDocument'] = $rows; - $documentArray = array(); - $documentArray[] = array ('guid' => 'char', 'filename' => 'char' ); - if ( isset($_DBArray ['inputDocument']) ) - foreach ( $_DBArray ['inputDocument'] as $key => $val ) - if ( $key != 0 && isset ($val['filename']) ) - $documentArray[] = array ('guid' => $val['guid'], 'filename' => $val['filename'] ); - if ( isset($_DBArray ['outputDocument']) ) - foreach ( $_DBArray ['outputDocument'] as $key => $val ) - if ( $key != 0 && isset ($val['filename']) ) - $documentArray[] = array ('guid' => $val['guid'], 'filename' => $val['filename'] ); - $_DBArray ['documents'] = $documentArray; - $_SESSION ['_DBArray'] = $_DBArray; - - G::LoadClass ( 'ArrayPeer' ); - $c = new Criteria ( 'dbarray' ); - $c->setDBArrayTable ( 'outputDocument' ); - $c->addAscendingOrderByColumn ( 'name' ); - $G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'setup/wsrOutputDocumentList', $c ); - } else if ( is_object($result) ){ - $_SESSION ['WS_SESSION_ID'] = ''; - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = date("Y-m-d H:i:s"); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - } - - G::RenderPage ( 'publish', 'raw' ); - break; -//add removeUserFromGroup -case "removeUserFromGroup" : - $sessionId = $frm ["SESSION_ID"]; - $userId = $frm ["USER_ID"]; - $groupId = $frm ["GROUP_ID"]; - $params = array ('sessionId' => $sessionId, 'userId' => $userId, 'groupId' => $groupId ); - $result = $client->__SoapCall ( 'removeUserFromGroup', array ($params ) ); - $G_PUBLISH = new Publisher ( ); - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = $result->timestamp; - if( $result->status_code == 9 ){ - $_SESSION ['WS_SESSION_ID'] = ''; - } - - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - G::RenderPage ( 'publish', 'raw' ); - break; -//end add - case "RemoveDocument" : - $appDocUid = $frm ["APP_DOC_UID"]; - $sessionId = $frm ["SESSION_ID"]; - $params = array ('sessionId' => $sessionId, 'appDocUid' => $appDocUid ); - $result = $client->__SoapCall ( 'RemoveDocument', array ($params ) ); - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = $result->timestamp; - - if( $result->status_code == 9 ){ - $_SESSION ['WS_SESSION_ID'] = ''; - } - - $G_PUBLISH = new Publisher ( ); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - G::RenderPage ( 'publish', 'raw' ); - break; - - case "TaskCase" : - $sessionId = $frm ["SESSION_ID"]; - $caseId = $frm ["CASE_ID"]; - - $params = array ('sessionId' => $sessionId, 'caseId' => $caseId ); - $wsResponse = $client->__SoapCall ( 'TaskCase', array ($params ) ); - $result = G::PMWSCompositeResponse($wsResponse, 'taskCases'); - - $G_PUBLISH = new Publisher ( ); - $rows [] = array ('guid' => 'char', 'name' => 'char' ); - - if (is_array ( $result )){ - - foreach ( $result as $key => $item ) { - if (isset ( $item->item )) - foreach ( $item->item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - } - else if (is_array ( $item )) - foreach ( $item as $index => $val ) { - if ($val->key == 'guid') - $guid = $val->value; - if ($val->key == 'name') - $name = $val->value; - } - else { - if (isset ( $item->guid )) - $guid = $item->guid; - if (isset ( $item->name )) - $name = $item->name; - } - - $rows [] = array ('guid' => $guid, 'name' => $name ); - } - - global $_DBArray; - $_DBArray = (isset ( $_SESSION ['_DBArray'] ) ? $_SESSION ['_DBArray'] : ''); - $_DBArray ['taskCases'] = $rows; - $_SESSION ['_DBArray'] = $_DBArray; - - G::LoadClass ( 'ArrayPeer' ); - $c = new Criteria ( 'dbarray' ); - $c->setDBArrayTable ( 'taskCases' ); - $c->addAscendingOrderByColumn ( 'name' ); - $G_PUBLISH->AddContent ( 'propeltable', 'paged-table', 'setup/wsrTaskCase', $c ); - } else if ( is_object($result) ){ - $_SESSION ['WS_SESSION_ID'] = ''; - $fields ['status_code'] = $result->status_code; - $fields ['message'] = $result->message; - $fields ['time_stamp'] = date("Y-m-d H:i:s"); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - } - - G::RenderPage ( 'publish', 'raw' ); - break; - - case "wsSendFiles" : - if ( isset($_FILES['form']) ) { - foreach ($_FILES['form']['name'] as $sFieldName => $vValue) { - if ( $_FILES['form']['error'][$sFieldName] == 0 ){ - file_put_contents(G::sys_get_temp_dir().PATH_SEP.$_FILES['form']['name'][$sFieldName], file_get_contents($_FILES['form']['tmp_name'][$sFieldName])); - $filename = G::sys_get_temp_dir().PATH_SEP.$_FILES['form']['name'][$sFieldName]; - } - } - } - -// G::pr ( $_SESSION ); - if(!isset($_POST['form']['INPUT_DOCUMENT'])){ - $_POST['form']['INPUT_DOCUMENT'] = ''; - } - - - if (isset($_SESSION['_DBArray']['inputDocument'])){ - foreach($_SESSION['_DBArray']['inputDocument'] as $inputDocument){ - if ($inputDocument['guid']==$_POST['form']['INPUT_DOCUMENT']){ - $doc_uid = $inputDocument['docId']; - } - } - } else { - $doc_uid = "default"; - } - if(!isset($_SESSION['_DBArray']['WS_TMP_CASE_UID'])){ - $_SESSION['_DBArray']['WS_TMP_CASE_UID'] = ''; - } - $usr_uid = $_SESSION['USER_LOGGED']; - $app_uid = $_SESSION['_DBArray']['WS_TMP_CASE_UID']; - $del_index = 1; - - function sendFile($FILENAME, $USR_UID, $APP_UID, $DEL_INDEX = 1, $DOC_UID = NULL, $title = NULL, $comment = NULL) { - $defaultEndpoint = 'http://' . $_SERVER ['SERVER_NAME'] . ':' . $_SERVER ['SERVER_PORT'] . '/sys' . SYS_SYS . '/'. SYS_LANG .'/classic/services/upload'; - $upload = isset ( $_SESSION ['END_POINT'] ) ? $_SESSION ['END_POINT'] : $defaultEndpoint; - - $DOC_UID = ($DOC_UID != NULL) ? $DOC_UID : - 1; - $APP_DOC_TYPE = ($DOC_UID == - 1) ? 'ATTACHED' : 'INPUT'; - $title = ($title != NULL) ? $title : $FILENAME; - $comment = ($comment != NULL) ? $comment : ''; - - $params = array ( - 'ATTACH_FILE' => "@$FILENAME", - 'APPLICATION' => $APP_UID, - 'INDEX' => $DEL_INDEX, - 'USR_UID' => $USR_UID, - 'DOC_UID' => $DOC_UID, - 'APP_DOC_TYPE' => $APP_DOC_TYPE, - 'TITLE' => $title, - 'COMMENT' => $comment - ); - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $defaultEndpoint); - //curl_setopt($ch, CURLOPT_VERBOSE, 1); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $params); - $response = curl_exec($ch); - curl_close($ch); - return $response; - } - - $fields ['status_code'] = 0; - $fields ['time_stamp'] = date( "Y-m-d H:i:s" ); - if ($_POST['form']['UPLOAD_OPTION']=='1'){ - // G::pr($doc_uid); - $fields ['message'] = sendFile($filename, $usr_uid, $app_uid, 1, $doc_uid); - - } else { - $fields ['message'] = sendFile($filename, $usr_uid, $app_uid); - } - $G_PUBLISH = new Publisher ( ); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); - G::RenderPage ( 'publish', 'blank' ); - die (); - break; - default : - print_r ( $_POST ); - } - } - global $_DBArray; - - -} catch ( Exception $e ) { - $G_PUBLISH = new Publisher ( ); - $aMessage ['MESSAGE'] = $e->getMessage (); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); - G::RenderPage ( 'publish', 'raw' ); + else + + { + if (isset( $item->guid )) { + $guid = $item->guid; + } + if (isset( $item->name )) { + $name = $item->name; + } + } + + $rows[] = array ('guid' => $guid,'name' => $name + ); + } + + global $_DBArray; + $_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : ''); + $_DBArray['taskCases'] = $rows; + $_SESSION['_DBArray'] = $_DBArray; + + G::LoadClass( 'ArrayPeer' ); + $c = new Criteria( 'dbarray' ); + $c->setDBArrayTable( 'taskCases' ); + $c->addAscendingOrderByColumn( 'name' ); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrTaskCase', $c ); + } else + + if (is_object( $result )) { + $_SESSION['WS_SESSION_ID'] = ''; + $fields['status_code'] = $result->status_code; + $fields['message'] = $result->message; + $fields['time_stamp'] = date( "Y-m-d H:i:s" ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + } + + G::RenderPage( 'publish', 'raw' ); + break; + case "wsSendFiles": + + + if (isset( $_FILES['form'] )) { + foreach ($_FILES['form']['name'] as $sFieldName => $vValue) { + if ($_FILES['form']['error'][$sFieldName] == 0) { + file_put_contents( G::sys_get_temp_dir() . PATH_SEP . $_FILES['form']['name'][$sFieldName], file_get_contents( $_FILES['form']['tmp_name'][$sFieldName] ) ); + $filename = G::sys_get_temp_dir() . PATH_SEP . $_FILES['form']['name'][$sFieldName]; + } + } + } + + // G::pr ( $_SESSION ); + if (! isset( $_POST['form']['INPUT_DOCUMENT'] )) { + $_POST['form']['INPUT_DOCUMENT'] = ''; + } + + if (isset( $_SESSION['_DBArray']['inputDocument'] )) { + foreach ($_SESSION['_DBArray']['inputDocument'] as $inputDocument) { + if ($inputDocument['guid'] == $_POST['form']['INPUT_DOCUMENT']) { + $doc_uid = $inputDocument['docId']; + } + } + } else { + $doc_uid = "default"; + } + if (! isset( $_SESSION['_DBArray']['WS_TMP_CASE_UID'] )) { + $_SESSION['_DBArray']['WS_TMP_CASE_UID'] = ''; + } + $usr_uid = $_SESSION['USER_LOGGED']; + $app_uid = $_SESSION['_DBArray']['WS_TMP_CASE_UID']; + $del_index = 1; + + function sendFile ($FILENAME, $USR_UID, $APP_UID, $DEL_INDEX = 1, $DOC_UID = null, $title = null, $comment = null) + { + $defaultEndpoint = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/classic/services/upload'; + $upload = isset( $_SESSION['END_POINT'] ) ? $_SESSION['END_POINT'] : $defaultEndpoint; + + $DOC_UID = ($DOC_UID != null) ? $DOC_UID : - 1; + $APP_DOC_TYPE = ($DOC_UID == - 1) ? 'ATTACHED' : 'INPUT'; + $title = ($title != null) ? $title : $FILENAME; + $comment = ($comment != null) ? $comment : ''; + + $params = array ('ATTACH_FILE' => "@$FILENAME",'APPLICATION' => $APP_UID,'INDEX' => $DEL_INDEX,'USR_UID' => $USR_UID,'DOC_UID' => $DOC_UID,'APP_DOC_TYPE' => $APP_DOC_TYPE,'TITLE' => $title,'COMMENT' => $comment + ); + + $ch = curl_init(); + curl_setopt( $ch, CURLOPT_URL, $defaultEndpoint ); + //curl_setopt($ch, CURLOPT_VERBOSE, 1); + curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); + curl_setopt( $ch, CURLOPT_POST, 1 ); + curl_setopt( $ch, CURLOPT_POSTFIELDS, $params ); + $response = curl_exec( $ch ); + curl_close( $ch ); + return $response; + } + + $fields['status_code'] = 0; + $fields['time_stamp'] = date( "Y-m-d H:i:s" ); + if ($_POST['form']['UPLOAD_OPTION'] == '1') { + // G::pr($doc_uid); + $fields['message'] = sendFile( $filename, $usr_uid, $app_uid, 1, $doc_uid ); + + } else { + $fields['message'] = sendFile( $filename, $usr_uid, $app_uid ); + } + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields ); + G::RenderPage( 'publish', 'blank' ); + die(); + break; + default: + + + print_r( $_POST ); + } +} + + + global $_DBArray; + +} catch (Exception $e) { + $G_PUBLISH = new Publisher(); + $aMessage['MESSAGE'] = $e->getMessage(); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); + G::RenderPage( 'publish', 'raw' ); } diff --git a/workflow/engine/methods/setup/webServicesList.php b/workflow/engine/methods/setup/webServicesList.php index 665b34163..652f8188a 100755 --- a/workflow/engine/methods/setup/webServicesList.php +++ b/workflow/engine/methods/setup/webServicesList.php @@ -1,10 +1,10 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * along with this program. If not, see . + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ -if($RBAC->userCanAccess('PM_SETUP') != 1 && $RBAC->userCanAccess('PM_FACTORY') != 1){ - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - //G::header('location: ../login/login'); - die; +if ($RBAC->userCanAccess( 'PM_SETUP' ) != 1 && $RBAC->userCanAccess( 'PM_FACTORY' ) != 1) { + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + //G::header('location: ../login/login'); + die(); } - - //G::genericForceLogin( 'WF_MYINFO' , 'login/noViewPage', $urlLogin = 'login/login' ); - $G_PUBLISH = new Publisher; - $G_PUBLISH->AddContent('view', 'setup/webServicesTree' ); - G::RenderPage( "publish-raw" , "raw" ); -?> +//G::genericForceLogin( 'WF_MYINFO' , 'login/noViewPage', $urlLogin = 'login/login' ); + + +$G_PUBLISH = new Publisher(); +$G_PUBLISH->AddContent( 'view', 'setup/webServicesTree' ); +G::RenderPage( "publish-raw", "raw" ); + diff --git a/workflow/engine/methods/setup/webServicesSetup.php b/workflow/engine/methods/setup/webServicesSetup.php index 36cc27741..ba3426e42 100755 --- a/workflow/engine/methods/setup/webServicesSetup.php +++ b/workflow/engine/methods/setup/webServicesSetup.php @@ -12,52 +12,52 @@ * * 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 . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ -if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response; +if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) + return $RBAC_Response; - G::LoadClass('groups'); +G::LoadClass( 'groups' ); - $dbc = new DBConnection(); - $ses = new DBSession($dbc); +$dbc = new DBConnection(); +$ses = new DBSession( $dbc ); - if (!isset($_SESSION['END_POINT'])) { - $aFields['WS_HOST'] = $_SERVER['HTTP_HOST']; - $aFields['WS_WORKSPACE'] = SYS_SYS; - } - else { - if (strpos($_SESSION['END_POINT'], 'https') !== false) { - preg_match('@^(?:https://)?([^/]+)@i', $_SESSION['END_POINT'], $coincidencias); +if (! isset( $_SESSION['END_POINT'] )) { + $aFields['WS_HOST'] = $_SERVER['HTTP_HOST']; + $aFields['WS_WORKSPACE'] = SYS_SYS; +} else { + if (strpos( $_SESSION['END_POINT'], 'https' ) !== false) { + preg_match( '@^(?:https://)?([^/]+)@i', $_SESSION['END_POINT'], $coincidencias ); + } else { + preg_match( '@^(?:http://)?([^/]+)@i', $_SESSION['END_POINT'], $coincidencias ); } - else { - preg_match('@^(?:http://)?([^/]+)@i', $_SESSION['END_POINT'], $coincidencias); - } - $aAux = explode(':', $coincidencias[1]); - $aFields['WS_HOST'] = $aAux[0]; - $aFields['WS_PORT'] = (isset($aAux[1]) ? $aAux[1] : ''); - $aAux = explode($aAux[0] . (isset($aAux[1]) ? ':' . $aAux[1] : ''), $_SESSION['END_POINT']); - $aAux = explode('/', $aAux[1]); - $aFields['WS_WORKSPACE'] = substr($aAux[1], 3); - } + $aAux = explode( ':', $coincidencias[1] ); + $aFields['WS_HOST'] = $aAux[0]; + $aFields['WS_PORT'] = (isset( $aAux[1] ) ? $aAux[1] : ''); + $aAux = explode( $aAux[0] . (isset( $aAux[1] ) ? ':' . $aAux[1] : ''), $_SESSION['END_POINT'] ); + $aAux = explode( '/', $aAux[1] ); + $aFields['WS_WORKSPACE'] = substr( $aAux[1], 3 ); +} -$rows[] = array ( 'uid' => 'char', 'name' => 'char', 'age' => 'integer', 'balance' => 'float' ); -$rows[] = array ( 'uid' => 'http', 'name' => 'http' ); -$rows[] = array ( 'uid' => 'https', 'name' => 'https' ); +$rows[] = array ('uid' => 'char','name' => 'char','age' => 'integer','balance' => 'float' +); +$rows[] = array ('uid' => 'http','name' => 'http' +); +$rows[] = array ('uid' => 'https','name' => 'https' +); $_DBArray['protocol'] = $rows; $_SESSION['_DBArray'] = $_DBArray; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/webServicesSetup', '', $aFields , 'webServicesSetupSave'); +$G_PUBLISH = new Publisher(); +$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/webServicesSetup', '', $aFields, 'webServicesSetupSave' ); - G::RenderPage( "publish" , "raw" ); +G::RenderPage( "publish", "raw" ); -?> \ No newline at end of file diff --git a/workflow/engine/methods/setup/webServicesSetupSave.php b/workflow/engine/methods/setup/webServicesSetupSave.php index 7e0cbf0c7..c7cf800fe 100755 --- a/workflow/engine/methods/setup/webServicesSetupSave.php +++ b/workflow/engine/methods/setup/webServicesSetupSave.php @@ -1,22 +1,16 @@ \ No newline at end of file diff --git a/workflow/engine/methods/setup/weekend.php b/workflow/engine/methods/setup/weekend.php index 1c2599273..4f1de3a69 100755 --- a/workflow/engine/methods/setup/weekend.php +++ b/workflow/engine/methods/setup/weekend.php @@ -1,10 +1,10 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * along with this program. If not, see . + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ -if (($RBAC_Response=$RBAC->userCanAccess("PM_SETUP"))!=1) return $RBAC_Response; -G::LoadInclude('ajax'); +if (($RBAC_Response = $RBAC->userCanAccess( "PM_SETUP" )) != 1) + return $RBAC_Response; +G::LoadInclude( 'ajax' ); - $G_ENABLE_BLANK_SKIN = true; +$G_ENABLE_BLANK_SKIN = true; -$ARR_WEEKDAYS[0] = array('SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY'); -$ARR_WEEKDAYS['es'] = array("Domingo?", "Lunes?", "Martes?", "Miércoles?", "Jueves?", "Viernes?", "Sábado?"); -$ARR_WEEKDAYS['en'] = array("Sunday?", "Monday?", "Tuesday?", "Wednesday?", "Thursday?", "Friday?", "Saturday?"); -$ARR_WEEKDAYS['fa'] = array('یکشنبه','دوشنبه','سه شنبه','چهارشنبه','پنجشنبه ','جمعه','آدینه'); +$ARR_WEEKDAYS[0] = array ('SUNDAY','MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY' +); +$ARR_WEEKDAYS['es'] = array ("Domingo?","Lunes?","Martes?","Miércoles?","Jueves?","Viernes?","Sábado?" +); +$ARR_WEEKDAYS['en'] = array ("Sunday?","Monday?","Tuesday?","Wednesday?","Thursday?","Friday?","Saturday?" +); +$ARR_WEEKDAYS['fa'] = array ('یکشنبه','دوشنبه','سه شنبه','چهارشنبه','پنجشنبه ','جمعه','آدینه' +); -$dbc = new DBConnection; -$ses = new DBSession($dbc); +$dbc = new DBConnection(); +$ses = new DBSession( $dbc ); -$holidays=$ses->execute( "SELECT LEX_VALUE FROM LEXICO WHERE LEX_TOPIC ='NOWORKINGDAY' "); +$holidays = $ses->execute( "SELECT LEX_VALUE FROM LEXICO WHERE LEX_TOPIC ='NOWORKINGDAY' " ); -$config=array(); -for($id=0;$id<7;$id++) -{ - $res=$ses->execute(" SELECT * FROM LEXICO WHERE LEX_KEY = '".$ARR_WEEKDAYS[0][$id]."' AND LEX_TOPIC ='HOLIDAY' "); - $res=$res->read(); - $config[$ARR_WEEKDAYS[0][$id]]=$res['LEX_VALUE']; +$config = array (); +for ($id = 0; $id < 7; $id ++) { + $res = $ses->execute( " SELECT * FROM LEXICO WHERE LEX_KEY = '" . $ARR_WEEKDAYS[0][$id] . "' AND LEX_TOPIC ='HOLIDAY' " ); + $res = $res->read(); + $config[$ARR_WEEKDAYS[0][$id]] = $res['LEX_VALUE']; } -$G_PUBLISH = new Publisher; -$G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/weekend', '',$config ,'' ); +$G_PUBLISH = new Publisher(); +$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/weekend', '', $config, '' ); G::RenderPage( 'publish' ); ?>