public function __construct() { $javaInput = PATH_C . 'javaBridgePM' . PATH_SEP . 'input' . PATH_SEP; $javaOutput = PATH_C . 'javaBridgePM' . PATH_SEP . 'output' . PATH_SEP; G::mk_dir($javaInput); G::mk_dir($javaOutput); }
function run_flush_cache($args, $opts) { $rootDir = realpath(__DIR__."/../../../../"); $app = new Maveriks\WebApplication(); $app->setRootDir($rootDir); $loadConstants = false; $workspaces = get_workspaces_from_args($args); if (! defined("PATH_C")) { die("ERROR: seems processmaker is not properly installed (System constants are missing).".PHP_EOL); } CLI::logging("Flush ".pakeColor::colorize("system", "INFO")." cache ... "); G::rm_dir(PATH_C); G::mk_dir(PATH_C, 0777); echo "DONE" . PHP_EOL; foreach ($workspaces as $workspace) { echo "Flush workspace " . pakeColor::colorize($workspace->name, "INFO") . " cache ... "; G::rm_dir($workspace->path . "/cache"); G::mk_dir($workspace->path . "/cache", 0777); G::rm_dir($workspace->path . "/cachefiles"); G::mk_dir($workspace->path . "/cachefiles", 0777); echo "DONE" . PHP_EOL; } }
function runHotfixInstall($command, $args) { CLI::logging("HOTFIX", PATH_DATA . "log" . PATH_SEP . "upgrades.log"); CLI::logging("Install hotfix to system\n"); $arrayFile = $command; if (count($arrayFile) > 0) { //Install hotfix foreach ($arrayFile as $value) { $f = $value; $result = workspaceTools::hotfixInstall($f); CLI::logging($result["message"] . "\n"); } //Clear server's cache CLI::logging("\nClearing cache...\n"); if (defined("PATH_C")) { G::rm_dir(PATH_C); G::mk_dir(PATH_C, 0777); } //Safe upgrade for JavaScript files CLI::logging("\nSafe upgrade for files cached by the browser\n\n"); G::browserCacheFilesSetUid(); CLI::logging("HOTFIX done\n"); } else { CLI::logging("Please specify the hotfix to install\n"); } }
/** * skinsSave.php * * ProcessMaker Open Source Edition * Copyright (C) 2004 - 2008 Colosa Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. * */ 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); } }
/** * import process fromLibrary: downloads and imports a process from the ProcessMaker library * * @param string sessionId : The session ID (which was obtained at login). * @param string processId : * @param string version : * @param string importOption : * @param string usernameLibrary : The username to obtain access to the ProcessMaker library. * @param string passwordLibrary : The password to obtain access to the ProcessMaker library. * @return $eturns will return an object */ public function importProcessFromLibrary($processId, $version = '', $importOption = '', $usernameLibrary = '', $passwordLibrary = '') { try { G::LoadClass('processes'); //$versionReq = $_GET['v']; //. (isset($_GET['s']) ? '&s=' . $_GET['s'] : '') $ipaddress = $_SERVER['REMOTE_ADDR']; $oProcesses = new Processes(); $oProcesses->ws_open_public(); $oProcess = $oProcesses->ws_processGetData($processId); if ($oProcess->status_code != 0) { throw new Exception($oProcess->message); } $privacy = $oProcess->privacy; $strSession = ''; if ($privacy != 'FREE') { global $sessionId; $antSession = $sessionId; $oProcesses->ws_open($usernameLibrary, $passwordLibrary); $strSession = "&s=" . $sessionId; $sessionId = $antSession; } //downloading the file $localPath = PATH_DOCUMENT . 'input' . PATH_SEP; G::mk_dir($localPath); $newfilename = G::GenerateUniqueId() . '.pm'; $downloadUrl = PML_DOWNLOAD_URL . '?id=' . $processId . $strSession; $oProcess = new Processes(); $oProcess->downloadFile($downloadUrl, $localPath, $newfilename); //getting the ProUid from the file recently downloaded $oData = $oProcess->getProcessData($localPath . $newfilename); if (is_null($oData)) { $data['DOWNLOAD_URL'] = $downloadUrl; $data['LOCAL_PATH'] = $localPath; $data['NEW_FILENAME'] = $newfilename; throw new Exception(G::loadTranslation('ID_ERROR_URL_PROCESS_INVALID', SYS_LANG, $data)); } $sProUid = $oData->process['PRO_UID']; $oData->process['PRO_UID_OLD'] = $sProUid; //if the process exists, we need to check the $importOption to and re-import if the user wants, if ($oProcess->processExists($sProUid)) { //Update the current Process, overwriting all tasks and steps if ($importOption == 1) { $oProcess->updateProcessFromData($oData, $localPath . $newfilename); //delete the xmlform cache if (file_exists(PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid)) { $oDirectory = dir(PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP . $sProUid); while ($sObjectName = $oDirectory->read()) { if ($sObjectName != '.' && $sObjectName != '..') { $strAux = PATH_OUTTRUNK . 'compiled' . PATH_SEP . 'xmlform' . PATH_SEP; $strAux = $strAux . $sProUid . PATH_SEP . $sObjectName; unlink($strAux); } } $oDirectory->close(); } $sNewProUid = $sProUid; } //Disable current Process and create a new version of the Process if ($importOption == 2) { $oProcess->disablePreviousProcesses($sProUid); $sNewProUid = $oProcess->getUnusedProcessGUID(); $oProcess->setProcessGuid($oData, $sNewProUid); $oProcess->setProcessParent($oData, $sProUid); $oData->process['PRO_TITLE'] = "New - " . $oData->process['PRO_TITLE'] . ' - ' . date('M d, H:i'); $oProcess->renewAll($oData); $oProcess->createProcessFromData($oData, $localPath . $newfilename); } //Create a completely new Process without change the current Process if ($importOption == 3) { //krumo ($oData); die; $sNewProUid = $oProcess->getUnusedProcessGUID(); $oProcess->setProcessGuid($oData, $sNewProUid); $strAux = "Copy of - " . $oData->process['PRO_TITLE'] . ' - ' . date('M d, H:i'); $oData->process['PRO_TITLE'] = $strAux; $oProcess->renewAll($oData); $oProcess->createProcessFromData($oData, $localPath . $newfilename); } if ($importOption != 1 && $importOption != 2 && $importOption != 3) { throw new Exception(G::loadTranslation('ID_PROCESS_ALREADY_IN_SYSTEM')); } } //finally, creating the process if the process doesn't exist if (!$oProcess->processExists($processId)) { $oProcess->createProcessFromData($oData, $localPath . $newfilename); } //show the info after the imported process $oProcess = new Processes(); $oProcess->ws_open_public(); $processData = $oProcess->ws_processGetData($processId); $result->status_code = 0; $result->message = G::loadTranslation('ID_COMMAND_EXECUTED_SUCCESSFULLY'); $result->timestamp = date('Y-m-d H:i:s'); $result->processId = $processId; $result->processTitle = $processData->title; $result->category = isset($processData->category) ? $processData->category : ''; $result->version = $processData->version; return $result; } catch (Exception $e) { $result = new wsResponse(100, $e->getMessage()); return $result; } }
/** * verify path * * @author Fernando Ontiveros Lira <*****@*****.**> * @access public * @param string $strPath path * @param boolean $createPath if true this public function will create the path * @return boolean */ public function verifyPath($strPath, $createPath = false) { $folder_path = strstr($strPath, '.') ? dirname($strPath) : $strPath; if (file_exists($strPath) || @is_dir($strPath)) { return true; } else { if ($createPath) { //TODO:: Define Environment constants: Devel (0777), Production (0770), ... G::mk_dir($strPath, 0777); } else { return false; } } return false; }
<?php global $G_FORM; $sPRO_UID = $oData->PRO_UID; $sTASKS = $oData->TASKS; $sDYNAFORM = $oData->DYNAFORM; $sWE_TYPE = $oData->WE_TYPE; $sWS_USER = $oData->WS_USER; $sWS_PASS = $oData->WS_PASS; $sWS_ROUNDROBIN = $oData->WS_ROUNDROBIN; $sWE_USR = $oData->WE_USR; $withWS = $sWE_TYPE == 'WS'; G::LoadClass("system"); try { $pathProcess = PATH_DATA_SITE . 'public' . PATH_SEP . $sPRO_UID . PATH_SEP; G::mk_dir($pathProcess, 0777); $oTask = new Task(); $TaskFields = $oTask->load($sTASKS); $WE_EVN_UID = $oTask->getStartingEvent($sTASKS); if ($TaskFields['TAS_ASSIGN_TYPE'] != 'BALANCED') { throw new Exception("The task '" . $TaskFields['TAS_TITLE'] . "' doesn't have a valid assignment type. The task needs to have a 'Cyclical Assignment'."); } G::LoadClass('tasks'); $oTask = new Tasks(); $user = $oTask->assignUsertoTask($sTASKS); if ($user == 0) { throw new Exception(G::LoadTranslation('ID_TASK') . "'" . $TaskFields['TAS_TITLE'] . "'" . G::LoadTranslation('ID_NOT_HAVE_USERS')); } $http = G::is_https() ? "https://" : "http://"; $sContent = ''; $infoProcess = new Process();
function getTranslationEnvironments() { $filePath = $this->envFilePath; $envs = array(); if (!file_exists($filePath)) { //the transaltions table file doesn't exist, then build it if (!is_dir(dirname($this->envFilePath))) { G::mk_dir(dirname($this->envFilePath)); } $translationsPath = PATH_CORE . "content" . PATH_SEP . 'translations' . PATH_SEP; $basePOFile = $translationsPath . 'english' . PATH_SEP . 'processmaker.en.po'; $params = self::getInfoFromPOFile($basePOFile); $this->addTranslationEnvironment($params['LOCALE'], $params['HEADERS'], $params['COUNT']); //getting more lanuguage translations $files = glob($translationsPath . "*.po"); foreach ($files as $file) { $params = self::getInfoFromPOFile($file); $this->addTranslationEnvironment($params['LOCALE'], $params['HEADERS'], $params['COUNT']); } } $envs = unserialize(file_get_contents($filePath)); $environments = array(); foreach ($envs as $LAN_ID => $rec1) { foreach ($rec1 as $IC_UID => $rec2) { $environments[] = $rec2; } } return $environments; /*G::LoadSystem('dbMaintenance'); $o = new DataBaseMaintenance('localhost', 'root', 'atopml2005'); $o->connect('wf_os'); $r = $o->query('select * from ISO_COUNTRY'); foreach($r as $i=>$v){ $r[$i]['IC_NAME'] = utf8_encode($r[$i]['IC_NAME']); unset($r[$i]['IC_SORT_ORDER']); } $r1 = $o->query('select * from LANGUAGE'); $r2 = Array(); foreach($r1 as $i=>$v){ $r2[$i]['LAN_NAME'] = utf8_encode($r1[$i]['LAN_NAME']); $r2[$i]['LAN_ID'] = utf8_encode($r1[$i]['LAN_ID']); } $s = Array('ISO_COUNTRY'=>$r, 'LANGUAGE'=>$r2); file_put_contents($translationsPath . 'pmos-translations.meta', serialize($s)); */ }
} $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); //it was added to show the logo into management plugin add by krlos 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; if (is_file($imagen)) { showLogo($imagen); } else { $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']}");
function save($params) { require_once 'classes/model/Event.php'; global $G_FORM; $sPRO_UID = $params->pro_uid; $sEVN_UID = $params->evn_uid; $sDYNAFORM = $params->initDyna; $sWS_USER = trim($params->username); $sWS_PASS = trim($params->password); $sWS_ROUNDROBIN = ''; $sWE_USR = ''; $xDYNA = $params->dynaform; if ($xDYNA != '') { $pro_uid = $params->pro_uid; $filename = $xDYNA; $filename = $filename . '.php'; unlink(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $pro_uid . PATH_SEP . $filename); unlink(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $pro_uid . PATH_SEP . str_replace(".php", "Post", $filename) . ".php"); } //return $params; G::LoadClass("system"); $pathProcess = PATH_DATA_SITE . 'public' . PATH_SEP . $sPRO_UID . PATH_SEP; G::mk_dir($pathProcess, 0777); $oEvent = new Event(); $oEvent->load($sEVN_UID); $sTASKS = $oEvent->getEvnTasUidTo(); $oTask = new Task(); $oTask->load($sTASKS); $tas_title = $oTask->getTasTitle(); if (G::is_https()) { $http = 'https://'; } else { $http = 'http://'; } $sContent = ''; $SITE_PUBLIC_PATH = ''; if (file_exists($SITE_PUBLIC_PATH . '')) { } require_once 'classes/model/Dynaform.php'; $oDynaform = new Dynaform(); $aDynaform = $oDynaform->load($sDYNAFORM); $dynTitle = str_replace(' ', '_', str_replace('/', '_', $aDynaform['DYN_TITLE'])); $sContent = "<?php\n"; $sContent .= "global \$_DBArray;\n"; $sContent .= "if (!isset(\$_DBArray)) {\n"; $sContent .= " \$_DBArray = array();\n"; $sContent .= "}\n"; $sContent .= "\$_SESSION['PROCESS'] = '" . $sPRO_UID . "';\n"; $sContent .= "\$_SESSION['CURRENT_DYN_UID'] = '" . $sDYNAFORM . "';\n"; $sContent .= "\$G_PUBLISH = new Publisher;\n"; $sContent .= "\$G_PUBLISH->AddContent('dynaform', 'xmlform', '" . $sPRO_UID . '/' . $sDYNAFORM . "', '', array(), '" . $dynTitle . 'Post.php' . "');\n"; $sContent .= "G::RenderPage('publish', 'blank');"; file_put_contents($pathProcess . $dynTitle . '.php', $sContent); //creating the second file, the post file who receive the post form. $pluginTpl = PATH_CORE . 'templates' . PATH_SEP . 'processes' . PATH_SEP . 'webentryPost.tpl'; $template = new TemplatePower($pluginTpl); $template->prepare(); $template->assign('wsdlUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2'); $template->assign('wsUploadUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/upload'); $template->assign('processUid', $sPRO_UID); $template->assign('dynaformUid', $sDYNAFORM); $template->assign('taskUid', $sTASKS); $template->assign('wsUser', $sWS_USER); $template->assign('wsPass', 'md5:' . md5($sWS_PASS)); $template->assign('wsRoundRobin', $sWS_ROUNDROBIN); if ($sWE_USR == "2") { $template->assign('USR_VAR', "\$cInfo = ws_getCaseInfo(\$caseId);\n\t \$USR_UID = \$cInfo->currentUsers->userId;"); } else { $template->assign('USR_VAR', '$USR_UID = -1;'); } $template->assign('dynaform', $dynTitle); $template->assign('timestamp', date('l jS \\of F Y h:i:s A')); $template->assign('ws', SYS_SYS); $template->assign('version', System::getVersion()); $fileName = $pathProcess . $dynTitle . 'Post.php'; file_put_contents($fileName, $template->getOutputContent()); //creating the third file, only if this wsClient.php file doesn't exists. $fileName = $pathProcess . 'wsClient.php'; $pluginTpl = PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP . 'ws' . PATH_SEP . 'wsClient.php'; if (file_exists($fileName)) { if (filesize($fileName) != filesize($pluginTpl)) { @copy($fileName, $pathProcess . 'wsClient.php.bck'); @unlink($fileName); $template = new TemplatePower($pluginTpl); $template->prepare(); file_put_contents($fileName, $template->getOutputContent()); } } else { $template = new TemplatePower($pluginTpl); $template->prepare(); file_put_contents($fileName, $template->getOutputContent()); } require_once 'classes/model/Event.php'; $oEvent = new Event(); $aDataEvent = array(); $aDataEvent['EVN_UID'] = $sEVN_UID; $aDataEvent['EVN_RELATED_TO'] = 'MULTIPLE'; $aDataEvent['EVN_ACTION'] = $sDYNAFORM; $aDataEvent['EVN_CONDITIONS'] = $sWS_USER; $output = $oEvent->update($aDataEvent); $link = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sPRO_UID . '/' . $dynTitle . '.php'; $this->success = true; $this->msg = G::LoadTranslation('ID_WEB_ENTRY_SUCCESS_NEW'); $this->W_LINK = $link; $this->TAS_TITLE = $tas_title; $this->DYN_TITLE = $dynTitle; $this->USR_UID = $sWS_USER; }
/** * * @method * * Generates an Output Document * * @name PMFGenerateOutputDocument * @label PMF Generate Output Document * * @param string(32) | $outputID | Output ID | Output Document ID * @return none | $none | None | None * */ function PMFGenerateOutputDocument($outputID, $sApplication = null, $index = null, $sUserLogged = null) { $g = new G(); $g->sessionVarSave(); if ($sApplication) { $_SESSION["APPLICATION"] = $sApplication; } else { $sApplication = $_SESSION["APPLICATION"]; } if ($index) { $_SESSION["INDEX"] = $index; } else { $index = $_SESSION["INDEX"]; } if ($sUserLogged) { $_SESSION["USER_LOGGED"] = $sUserLogged; } else { $sUserLogged = $_SESSION["USER_LOGGED"]; } G::LoadClass('case'); $oCase = new Cases(); $oCase->thisIsTheCurrentUser($sApplication, $index, $sUserLogged, '', 'casesListExtJs'); //require_once 'classes/model/OutputDocument.php'; $oOutputDocument = new OutputDocument(); $aOD = $oOutputDocument->load($outputID); $Fields = $oCase->loadCase($sApplication); //The $_GET['UID'] variable is used when a process executes. //$_GET['UID']=($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID']; //$sUID = ($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID']; $sFilename = preg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'])); require_once 'classes/model/AppFolder.php'; require_once 'classes/model/AppDocument.php'; //Get the Custom Folder ID (create if necessary) $oFolder = new AppFolder(); //$aOD['OUT_DOC_DESTINATION_PATH'] = ($aOD['OUT_DOC_DESTINATION_PATH']=='')?PATH_DOCUMENT // . $_SESSION['APPLICATION'] . PATH_SEP . 'outdocs'. PATH_SEP:$aOD['OUT_DOC_DESTINATION_PATH']; $folderId = $oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH'], $sApplication); //Tags $fileTags = $oFolder->parseTags($aOD['OUT_DOC_TAGS'], $sApplication); //Get last Document Version and apply versioning if is enabled $oAppDocument = new AppDocument(); $lastDocVersion = $oAppDocument->getLastDocVersion($outputID, $sApplication); $oCriteria = new Criteria('workflow'); $oCriteria->add(AppDocumentPeer::APP_UID, $sApplication); //$oCriteria->add(AppDocumentPeer::DEL_INDEX, $index); $oCriteria->add(AppDocumentPeer::DOC_UID, $outputID); $oCriteria->add(AppDocumentPeer::DOC_VERSION, $lastDocVersion); $oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT'); $oDataset = AppDocumentPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); if ($aOD['OUT_DOC_VERSIONING'] && $lastDocVersion != 0) { //Create new Version of current output $lastDocVersion++; if ($aRow = $oDataset->getRow()) { $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], 'APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion + 1, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags); $oAppDocument = new AppDocument(); $oAppDocument->create($aFields); $sDocUID = $aRow['APP_DOC_UID']; } } else { ////No versioning so Update a current Output or Create new if no exist if ($aRow = $oDataset->getRow()) { //Update $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], 'APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags); $oAppDocument = new AppDocument(); $oAppDocument->update($aFields); $sDocUID = $aRow['APP_DOC_UID']; } else { //we are creating the appdocument row //create if ($lastDocVersion == 0) { $lastDocVersion++; } $aFields = array('APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags); $oAppDocument = new AppDocument(); $aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create($aFields); } } $sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion; $pathOutput = PATH_DOCUMENT . G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP; //G::pr($sFilename);die; G::mk_dir($pathOutput); $aProperties = array(); if (!isset($aOD['OUT_DOC_MEDIA'])) { $aOD['OUT_DOC_MEDIA'] = 'Letter'; } if (!isset($aOD['OUT_DOC_LEFT_MARGIN'])) { $aOD['OUT_DOC_LEFT_MARGIN'] = '15'; } if (!isset($aOD['OUT_DOC_RIGHT_MARGIN'])) { $aOD['OUT_DOC_RIGHT_MARGIN'] = '15'; } if (!isset($aOD['OUT_DOC_TOP_MARGIN'])) { $aOD['OUT_DOC_TOP_MARGIN'] = '15'; } if (!isset($aOD['OUT_DOC_BOTTOM_MARGIN'])) { $aOD['OUT_DOC_BOTTOM_MARGIN'] = '15'; } $aProperties['media'] = $aOD['OUT_DOC_MEDIA']; $aProperties['margins'] = array('left' => $aOD['OUT_DOC_LEFT_MARGIN'], 'right' => $aOD['OUT_DOC_RIGHT_MARGIN'], 'top' => $aOD['OUT_DOC_TOP_MARGIN'], 'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN']); if (isset($aOD['OUT_DOC_REPORT_GENERATOR'])) { $aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR']; } $oOutputDocument->generate($outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (bool) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties); //Plugin Hook PM_UPLOAD_DOCUMENT for upload document //G::LoadClass('plugin'); $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) { $triggerDetail = $oPluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT); $aFields['APP_DOC_PLUGIN'] = $triggerDetail->sNamespace; $oAppDocument1 = new AppDocument(); $oAppDocument1->update($aFields); $sPathName = PATH_DOCUMENT . G::getPathFromUID($sApplication) . PATH_SEP; $oData['APP_UID'] = $sApplication; $oData['ATTACHMENT_FOLDER'] = true; switch ($aOD['OUT_DOC_GENERATE']) { case "BOTH": $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "PDF"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly unlink($pathOutput . $sFilename . '.pdf'); } $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "DOC"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly unlink($pathOutput . $sFilename . '.doc'); } break; case "PDF": $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "PDF"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly unlink($pathOutput . $sFilename . '.pdf'); } break; case "DOC": $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "DOC"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly unlink($pathOutput . $sFilename . '.doc'); } break; } } $g->sessionVarRestore(); }
/** * Prepare the pmTable env */ public function prepare($loadSchema = true) { //prevent execute prepare() twice or more if (is_object($this->dom)) { return true; } $this->schemaFilename = 'schema.xml'; $this->baseDir = PATH_DB . SYS_SYS . PATH_SEP; $this->targetDir = $this->baseDir . 'pmt-propel' . PATH_SEP . $this->dataSource . PATH_SEP; $this->configDir = $this->targetDir . 'config' . PATH_SEP; $this->dataDir = $this->targetDir . 'data' . PATH_SEP; $this->classesDir = $this->baseDir . 'classes' . PATH_SEP; // G::mk_dir create the requested dir and the parents directories if not exists G::mk_dir($this->configDir); G::mk_dir($this->dataDir); if ($loadSchema) { $this->loadSchema(); } }
function run_upgrade($command, $args) { CLI::logging("UPGRADE", PROCESSMAKER_PATH . "upgrade.log"); CLI::logging("Checking files integrity...\n"); //setting flag to true to check into sysGeneric.php $flag = G::isPMUnderUpdating(1); //start to upgrade $checksum = System::verifyChecksum(); if ($checksum === false) { CLI::logging(CLI::error("checksum.txt not found, integrity check is not possible") . "\n"); if (!CLI::question("Integrity check failed, do you want to continue the upgrade?")) { CLI::logging("Upgrade failed\n"); $flag = G::isPMUnderUpdating(0); die; } } else { if (!empty($checksum['missing'])) { CLI::logging(CLI::error("The following files were not found in the installation:") . "\n"); foreach ($checksum['missing'] as $missing) { CLI::logging(" {$missing}\n"); } } if (!empty($checksum['diff'])) { CLI::logging(CLI::error("The following files have modifications:") . "\n"); foreach ($checksum['diff'] as $diff) { CLI::logging(" {$diff}\n"); } } if (!(empty($checksum['missing']) || empty($checksum['diff']))) { if (!CLI::question("Integrity check failed, do you want to continue the upgrade?")) { CLI::logging("Upgrade failed\n"); $flag = G::isPMUnderUpdating(0); die; } } } CLI::logging("Clearing cache...\n"); if (defined('PATH_C')) { G::rm_dir(PATH_C); G::mk_dir(PATH_C, 0777); } $workspaces = get_workspaces_from_args($command); $count = count($workspaces); $first = true; $errors = false; $countWorkspace = 0; $buildCacheView = array_key_exists("buildACV", $args); foreach ($workspaces as $index => $workspace) { if (!defined("SYS_SYS")) { define("SYS_SYS", $workspace->name); } if (!defined("PATH_DATA_SITE")) { define("PATH_DATA_SITE", PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP); } try { $countWorkspace++; CLI::logging("Upgrading workspaces ({$countWorkspace}/{$count}): " . CLI::info($workspace->name) . "\n"); $workspace->upgrade($first, $buildCacheView, $workspace->name); $workspace->close(); $first = false; } catch (Exception $e) { CLI::logging("Errors upgrading workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n"); $errors = true; } } // SAVE Upgrades/Patches $arrayPatch = glob(PATH_TRUNK . 'patch-*'); if ($arrayPatch) { foreach ($arrayPatch as $value) { if (file_exists($value)) { // copy content the patch $names = pathinfo($value); $nameFile = $names['basename']; $contentFile = file_get_contents($value); $contentFile = preg_replace("[\n|\r|\n\r]", '', $contentFile); CLI::logging($contentFile . ' installed (' . $nameFile . ')', PATH_DATA . 'log/upgrades.log'); // move file of patch $newFile = PATH_DATA . $nameFile; G::rm_dir($newFile); copy($value, $newFile); G::rm_dir($value); } } } else { CLI::logging('ProcessMaker ' . System::getVersion() . ' installed', PATH_DATA . 'log/upgrades.log'); } //Safe upgrade for JavaScript files CLI::logging("\nSafe upgrade for files cached by the browser\n\n"); G::browserCacheFilesSetUid(); //Status if ($errors) { CLI::logging("Upgrade finished but there were errors upgrading workspaces.\n"); CLI::logging(CLI::error("Please check the log above to correct any issues.") . "\n"); } else { CLI::logging("Upgrade successful\n"); } //setting flag to false $flag = G::isPMUnderUpdating(0); }
/** * Set value in WE_DATA * * @param string $webEntryUid Unique id of Web Entry * * return void */ public function setWeData($webEntryUid) { try { //Verify data $this->throwExceptionIfNotExistsWebEntry($webEntryUid, $this->arrayFieldNameForException["webEntryUid"]); //Set variables $arrayWebEntryData = $this->getWebEntry($webEntryUid, true); $processUid = $arrayWebEntryData["PRO_UID"]; $taskUid = $arrayWebEntryData["TAS_UID"]; $dynaFormUid = $arrayWebEntryData["DYN_UID"]; $webEntryMethod = $arrayWebEntryData["WE_METHOD"]; $webEntryInputDocumentAccess = $arrayWebEntryData["WE_INPUT_DOCUMENT_ACCESS"]; $webEntryData = ""; $wsRoundRobin = 0; //0, 1 //0 - Cyclical Assignment $pathDataPublicProcess = PATH_DATA_PUBLIC . $processUid; //Delete previous files if (trim($arrayWebEntryData["WE_DATA"]) != "") { $fileName = str_replace(".php", "", trim($arrayWebEntryData["WE_DATA"])); $file = $pathDataPublicProcess . PATH_SEP . $fileName . ".php"; if (is_file($file) && file_exists($file)) { unlink($file); unlink($pathDataPublicProcess . PATH_SEP . $fileName . "Post.php"); } } //Create files \G::mk_dir($pathDataPublicProcess, 0777); $http = \G::is_https() ? "https://" : "http://"; switch ($webEntryMethod) { case "WS": require_once PATH_RBAC . "model" . PATH_SEP . "RbacUsers.php"; $user = new \RbacUsers(); $arrayUserData = $user->load($arrayWebEntryData["USR_UID"]); $usrUsername = $arrayUserData["USR_USERNAME"]; $usrPassword = $arrayUserData["USR_PASSWORD"]; $dynaForm = new \Dynaform(); $arrayDynaFormData = $dynaForm->Load($arrayWebEntryData["DYN_UID"]); //Creating sys.info; $sitePublicPath = ""; if (file_exists($sitePublicPath . "")) { } //Creating the first file $weTitle = $this->sanitizeFilename($arrayWebEntryData["WE_TITLE"]); $fileName = $weTitle; $fileContent = "<?php\n"; $fileContent .= "global \$_DBArray;\n"; $fileContent .= "if (!isset(\$_DBArray)) {\n"; $fileContent .= " \$_DBArray = array();\n"; $fileContent .= "}\n"; $fileContent .= "\$_SESSION[\"PROCESS\"] = \"" . $processUid . "\";\n"; $fileContent .= "\$_SESSION[\"CURRENT_DYN_UID\"] = \"" . $dynaFormUid . "\";\n"; $fileContent .= "\$G_PUBLISH = new Publisher();\n"; $fileContent .= "G::LoadClass(\"pmDynaform\");\n"; $fileContent .= "\$a = new pmDynaform(array(\"CURRENT_DYNAFORM\" => \"" . $arrayWebEntryData["DYN_UID"] . "\"));\n"; $fileContent .= "if (\$a->isResponsive()) {"; $fileContent .= " \$a->printWebEntry(\"" . $fileName . "Post.php\");"; $fileContent .= "} else {"; $fileContent .= " \$G_PUBLISH->AddContent(\"dynaform\", \"xmlform\", \"" . $processUid . PATH_SEP . $dynaFormUid . "\", \"\", array(), \"" . $fileName . "Post.php\");\n"; $fileContent .= " G::RenderPage(\"publish\", \"blank\");"; $fileContent .= "}"; file_put_contents($pathDataPublicProcess . PATH_SEP . $fileName . ".php", $fileContent); //Creating the second file, the post file who receive the post form. $pluginTpl = PATH_TPL . "processes" . PATH_SEP . "webentryPost.tpl"; $template = new \TemplatePower($pluginTpl); $template->prepare(); $template->assign("wsdlUrl", $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/wsdl2"); $template->assign("wsUploadUrl", $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/upload"); $template->assign("processUid", $processUid); $template->assign("dynaformUid", $dynaFormUid); $template->assign("taskUid", $taskUid); $template->assign("wsUser", $usrUsername); $template->assign("wsPass", \Bootstrap::getPasswordHashType() . ':' . $usrPassword); $template->assign("wsRoundRobin", $wsRoundRobin); if ($webEntryInputDocumentAccess == 0) { //Restricted to process permissions $template->assign("USR_VAR", "\$cInfo = ws_getCaseInfo(\$caseId);\n\t \$USR_UID = \$cInfo->currentUsers->userId;"); } else { //No Restriction $template->assign("USR_VAR", "\$USR_UID = -1;"); } $template->assign("dynaform", $arrayDynaFormData["DYN_TITLE"]); $template->assign("timestamp", date("l jS \\of F Y h:i:s A")); $template->assign("ws", SYS_SYS); $template->assign("version", \System::getVersion()); $fileName = $pathDataPublicProcess . PATH_SEP . $weTitle . "Post.php"; file_put_contents($fileName, $template->getOutputContent()); //Creating the third file, only if this wsClient.php file doesn't exist. $fileName = $pathDataPublicProcess . PATH_SEP . "wsClient.php"; $pluginTpl = PATH_CORE . "templates" . PATH_SEP . "processes" . PATH_SEP . "wsClient.php"; if (file_exists($fileName)) { if (filesize($fileName) != filesize($pluginTpl)) { copy($fileName, $pathDataPublicProcess . PATH_SEP . "wsClient.php.bak"); unlink($fileName); $template = new \TemplatePower($pluginTpl); $template->prepare(); file_put_contents($fileName, $template->getOutputContent()); } } else { $template = new \TemplatePower($pluginTpl); $template->prepare(); file_put_contents($fileName, $template->getOutputContent()); } //Event $task = new \Task(); $arrayTaskData = $task->load($arrayWebEntryData["TAS_UID"]); $weEventUid = $task->getStartingEvent(); if ($weEventUid != "") { $event = new \Event(); $arrayEventData = array(); $arrayEventData["EVN_UID"] = $weEventUid; $arrayEventData["EVN_RELATED_TO"] = "MULTIPLE"; $arrayEventData["EVN_ACTION"] = $dynaFormUid; $arrayEventData["EVN_CONDITIONS"] = $usrUsername; $result = $event->update($arrayEventData); } //WE_DATA $webEntryData = $weTitle . ".php"; break; case "HTML": global $G_FORM; if (!class_exists("Smarty")) { $loader = \Maveriks\Util\ClassLoader::getInstance(); $loader->addClass("Smarty", PATH_THIRDPARTY . "smarty" . PATH_SEP . "libs" . PATH_SEP . "Smarty.class.php"); } $G_FORM = new \Form($processUid . "/" . $dynaFormUid, PATH_DYNAFORM, SYS_LANG, false); $G_FORM->action = $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/cases_StartExternal.php"; $scriptCode = ""; $scriptCode = $G_FORM->render(PATH_TPL . "xmlform" . ".html", $scriptCode); $scriptCode = str_replace("/controls/", $http . $_SERVER["HTTP_HOST"] . "/controls/", $scriptCode); $scriptCode = str_replace("/js/maborak/core/images/", $http . $_SERVER["HTTP_HOST"] . "/js/maborak/core/images/", $scriptCode); //Render the template $pluginTpl = PATH_TPL . "processes" . PATH_SEP . "webentry.tpl"; $template = new \TemplatePower($pluginTpl); $template->prepare(); $step = new \Step(); $sUidGrids = $step->lookingforUidGrids($processUid, $dynaFormUid); $template->assign("URL_MABORAK_JS", \G::browserCacheFilesUrl("/js/maborak/core/maborak.js")); $template->assign("URL_TRANSLATION_ENV_JS", \G::browserCacheFilesUrl("/jscore/labels/" . SYS_LANG . ".js")); $template->assign("siteUrl", $http . $_SERVER["HTTP_HOST"]); $template->assign("sysSys", SYS_SYS); $template->assign("sysLang", SYS_LANG); $template->assign("sysSkin", SYS_SKIN); $template->assign("processUid", $processUid); $template->assign("dynaformUid", $dynaFormUid); $template->assign("taskUid", $taskUid); $template->assign("dynFileName", $processUid . "/" . $dynaFormUid); $template->assign("formId", $G_FORM->id); $template->assign("scriptCode", $scriptCode); if (sizeof($sUidGrids) > 0) { foreach ($sUidGrids as $k => $v) { $template->newBlock("grid_uids"); $template->assign("siteUrl", $http . $_SERVER["HTTP_HOST"]); $template->assign("gridFileName", $processUid . "/" . $v); } } //WE_DATA $html = str_replace("</body>", "</form></body>", str_replace("</form>", "", $template->getOutputContent())); $webEntryData = $html; break; } //Update //Update where $criteriaWhere = new \Criteria("workflow"); $criteriaWhere->add(\WebEntryPeer::WE_UID, $webEntryUid); //Update set $criteriaSet = new \Criteria("workflow"); $criteriaSet->add(\WebEntryPeer::WE_DATA, $webEntryData); \BasePeer::doUpdate($criteriaWhere, $criteriaSet, \Propel::getConnection("workflow")); } catch (\Exception $e) { throw $e; } }
/** * @covers G::mk_dir * @todo Implement testMk_dir(). */ public function testMk_dir() { $newDir = PATH_HOME . 'test'; G::mk_dir($newDir); $this->assertTrue(is_dir($newDir)); if (is_dir($newDir)) { rmdir($newDir); } }
} /** * URL path to tcpdf installation folder (http://localhost/tcpdf/). * By default it is automatically calculated but you can also set it as a fixed string to improve performances. */ define('K_PATH_URL', $k_path_url); /** * path for PDF fonts * use K_PATH_MAIN.'fonts/old/' for old non-UTF8 fonts */ define('K_PATH_FONTS', K_PATH_MAIN . 'fonts/'); /** * cache directory for temporary files (full path) */ //define ('K_PATH_CACHE', K_PATH_MAIN.'cache/'); G::mk_dir(PATH_DATA_REPORTS . 'cache/'); define('K_PATH_CACHE', PATH_DATA_REPORTS . 'cache/'); /** * cache directory for temporary files (url path) */ define('K_PATH_URL_CACHE', K_PATH_URL . 'cache/'); /** *images directory */ define('K_PATH_IMAGES', K_PATH_MAIN . 'images/'); /** * blank image */ define('K_BLANK_IMAGE', K_PATH_IMAGES . '_blank.png'); /** * page format
/** * This function creates a directory * * * @name pm_copy * * @param string $source * @param string $target * @return void */ public function pm_copy($source, $target) { if (!is_dir(dirname($target))) { G::mk_dir(dirname($target)); } if (!copy($source, $target)) { krumo($source); krumo($target); } }
/** * Show Logo File */ public function showLogoFile() { $_GET['id'] = $_REQUEST['id']; $base64Id = base64_decode($_GET['id']); $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); $dir = PATH_DATA . "sites" . PATH_SEP . str_replace("sys", "", $ainfoSite[1]) . PATH_SEP . "files/logos"; $imagen = $dir . PATH_SEP . $base64Id; if (is_file($imagen)) { self::showLogo($imagen); } else { $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); } $newDir .= PATH_SEP . $base64Id; $dir .= PATH_SEP . $base64Id; copy($dir, $newDir); self::showLogo($newDir); die; } die; exit; }
$fileName = trim($params[1], "\" "); } } } } } if (preg_match("/^.*json.*\$/i", $fileContentType)) { $r = G::json_decode(stream_get_contents($fileData)); if ($r->status == "ERROR") { throw new Exception($r->message); } } /////// $dir = PATH_DATA . "upgrade" . PATH_SEP . "processmaker"; G::rm_dir($dir); G::mk_dir($dir); if (!file_exists($dir)) { throw new Exception("Could not create destination directory."); } /////// $fileName = $dir . PATH_SEP . $fileName; $file = @fopen($fileName, "wb"); if ($file === false) { throw new Exception("Could not open destination file."); } while (!feof($fileData)) { $data = fread($fileData, BUFSIZE); //Just to be safe, check all error conditions if ($data === "" || $data === false) { break; }
/** * Function addExtJsScript * adding a javascript file . * * js * add a js file in the extension Javascript Array, * later, when we use the includeExtJs function, all the files in this array will be included in the output * if the second argument is true, the file will not be minified, this is useful for debug purposes. * * Feature added - <*****@*****.**> * - Hook to find javascript registered from plugins and load them * * @author Fernando Ontiveros <*****@*****.**> * @author Erik Amaru Ortiz <*****@*****.**> * @access public * @return string */ public function addExtJsScript($filename, $debug = false, $isExternal = false) { $sPath = PATH_TPL; //if the template file doesn't exists, then try with the plugins folders if (!is_file($sPath . $filename . ".js")) { $aux = explode(PATH_SEP, $filename); //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment if (count($aux) > 2 && defined('G_PLUGIN_CLASS')) { $flagPlugin = false; $keyPlugin = count($aux) - 2; $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->isRegisteredFolder($aux[$keyPlugin])) { $flagPlugin = true; } else { $keyPlugin--; if ($oPluginRegistry->isRegisteredFolder($aux[$keyPlugin])) { $flagPlugin = true; } } if ($flagPlugin) { array_push($this->extJsLibrary, 'translation.' . trim($aux[$keyPlugin]) . '.' . SYS_LANG); $sPath = PATH_PLUGINS; } } } if (!$isExternal) { $jsFilename = $sPath . $filename . '.js'; } else { $jsFilename = $filename . '.js'; } if (!file_exists($jsFilename)) { return; } $mtime = filemtime($jsFilename); G::mk_dir(PATH_C . 'ExtJs'); if ($debug) { $cacheName = str_replace('/', '_', $filename); $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js'; file_put_contents($cacheFilename, file_get_contents($jsFilename)); } else { $cacheName = md5($mtime . $jsFilename); $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js'; if (!file_exists($cacheFilename)) { require_once PATH_THIRDPARTY . 'jsmin/jsmin.php'; $content = JSMin::minify(file_get_contents($jsFilename)); file_put_contents($cacheFilename, $content); } } $this->extJsScript[] = '/extjs/' . $cacheName; //hook for registered javascripts from plugins if (class_exists('PMPluginRegistry')) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); $pluginJavascripts = $oPluginRegistry->getRegisteredJavascriptBy($filename); } else { $pluginJavascripts = array(); } if (count($pluginJavascripts) > 0) { if ($debug) { foreach ($pluginJavascripts as $pluginJsFile) { $jsPluginCacheName = ''; if (substr($pluginJsFile, -3) != '.js') { $pluginJsFile .= '.js'; } if (file_exists(PATH_PLUGINS . $pluginJsFile)) { $jsPluginCacheName = str_replace('/', '_', str_replace('.js', '', $pluginJsFile)); $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . ".js"; file_put_contents($cacheFilename, file_get_contents(PATH_PLUGINS . $pluginJsFile)); } if ($jsPluginCacheName != '') { $this->extJsScript[] = '/extjs/' . $jsPluginCacheName; } } } else { foreach ($pluginJavascripts as $pluginJsFile) { $jsPluginCacheName = ''; if (substr($pluginJsFile, -3) !== '.js') { $pluginJsFile .= '.js'; } if (file_exists(PATH_PLUGINS . $pluginJsFile)) { $mtime = filemtime(PATH_PLUGINS . $pluginJsFile); $jsPluginCacheName = md5($mtime . $pluginJsFile); $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . '.js'; if (!file_exists($cacheFilename)) { require_once PATH_THIRDPARTY . 'jsmin/jsmin.php'; $content = JSMin::minify(file_get_contents(PATH_PLUGINS . $pluginJsFile)); file_put_contents($cacheFilename, $content); } } if ($jsPluginCacheName != '') { $this->extJsScript[] = '/extjs/' . $jsPluginCacheName; } } } } //end hook for registered javascripts from plugins }
/** * create the files from a . * * * pm file * * @param $oData process data * @param $pmFilename process file name * @return boolean true */ public function createFiles ($oData, $pmFilename) { if (! file_exists( $pmFilename )) { throw (new Exception( 'Unable to read uploaded .pm file, please check permissions. ' )); } if (! filesize( $pmFilename ) >= 9) { throw (new Exception( 'Uploaded .pm file is corrupted, please check the file before continue. ' )); } $fp = fopen( $pmFilename, "rb" ); $fsData = intval( fread( $fp, 9 ) ); //reading the size of $oData $contents = fread( $fp, $fsData ); //reading string $oData $path = PATH_DYNAFORM . $oData->process['PRO_UID'] . PATH_SEP; if (! is_dir( $path )) { G::verifyPath( $path, true ); } $sIdentifier = 1; while (! feof( $fp ) && is_numeric( $sIdentifier )) { $sIdentifier = fread( $fp, 9 ); //reading the size of $filename if (is_numeric( $sIdentifier )) { $fsXmlGuid = intval( $sIdentifier ); //reading the size of $filename if ($fsXmlGuid > 0) { $XmlGuid = fread( $fp, $fsXmlGuid ); //reading string $XmlGuid } $fsXmlContent = intval( fread( $fp, 9 ) ); //reading the size of $XmlContent if ($fsXmlContent > 0) { $newXmlGuid = $oData->dynaformFiles[$XmlGuid]; if (isset( $oData->process['PRO_UID_OLD'] )) { $XmlContent = fread( $fp, $fsXmlContent ); //reading string $XmlContent $XmlContent = str_replace( $oData->process['PRO_UID_OLD'], $oData->process['PRO_UID'], $XmlContent ); $XmlContent = str_replace( $XmlGuid, $newXmlGuid, $XmlContent ); if (isset( $oData->inputFiles )) { foreach($oData->inputFiles as $input => $valInput){ $oldInput = $input; $newInput = $oData->inputFiles[$oldInput]; $XmlContent = str_replace( $oldInput, $newInput, $XmlContent ); } } //foreach if (isset( $oData->gridFiles )) { if (is_array( $oData->gridFiles )) { foreach ($oData->gridFiles as $key => $value) { $XmlContent = str_replace( $key, $value, $XmlContent ); } } } if (isset( $oData->sqlConnections )) { foreach ($oData->sqlConnections as $key => $value) { $XmlContent = str_replace( $key, $value, $XmlContent ); } } #here we verify if is adynaform or a html $aAux = explode( ' ', $XmlContent ); $ext = (strpos( $aAux[0], '<?xml' ) !== false ? '.xml' : '.html'); $sFileName = $path . $newXmlGuid . $ext; $bytesSaved = @file_put_contents( $sFileName, $XmlContent ); //if ( $bytesSaved != $fsXmlContent ) throw ( new Exception ('Error writing dynaform file in directory : ' . $path ) ); } } } } //now mailTemplates and public files $pathPublic = PATH_DATA_SITE . 'public' . PATH_SEP . $oData->process['PRO_UID'] . PATH_SEP; $pathMailTem = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $oData->process['PRO_UID'] . PATH_SEP; G::mk_dir( $pathPublic ); G::mk_dir( $pathMailTem ); if ($sIdentifier == 'MAILTEMPL') { $sIdentifier = 1; while (! feof( $fp ) && is_numeric( $sIdentifier )) { $sIdentifier = fread( $fp, 9 ); //reading the size of $filename if (is_numeric( $sIdentifier )) { $fsFileName = intval( $sIdentifier ); //reading the size of $filename if ($fsFileName > 0) { $sFileName = fread( $fp, $fsFileName ); //reading filename string } $fsContent = intval( fread ( $fp, 9)) or 0; //reading the size of $Content if ($fsContent > 0) { $fileContent = fread( $fp, $fsContent ); //reading string $XmlContent $newFileName = $pathMailTem . $sFileName; $bytesSaved = @file_put_contents( $newFileName, $fileContent ); if ($bytesSaved != $fsContent) { throw (new Exception( 'Error writing MailTemplate file in directory : ' . $pathMailTem )); } } } } } if (trim( $sIdentifier ) == 'PUBLIC') { //Get WebEntry file names $arrayWebEntryFile = array(); $fh = fopen($pmFilename, "rb"); $contents = fread($fh, intval(fread($fh, 9))); //Reading string $oData while (!feof($fh)) { $fsFileName = intval(fread($fh, 9)); //Reading the size of $filename if ($fsFileName > 0) { $sFileName = fread($fh, $fsFileName); //Reading filename string if (preg_match("/^(.+)Post\.php$/", $sFileName, $arrayMatch)) { $arrayWebEntryFile[] = $arrayMatch[1] . ".php"; $arrayWebEntryFile[] = $arrayMatch[1] . "Post.php"; } } } fclose($fh); //Public files $sIdentifier = 1; while (! feof( $fp ) && is_numeric( $sIdentifier )) { $sIdentifier = fread( $fp, 9 ); //reading the size of $filename if (is_numeric( $sIdentifier )) { $fsFileName = intval( $sIdentifier ); //reading the size of $filename if ($fsFileName > 0) { $sFileName = fread( $fp, $fsFileName ); //reading filename string } $fsContent = intval( fread ( $fp, 9)) or 0; //reading the size of $Content if ($fsContent > 0) { $fileContent = fread( $fp, $fsContent ); //reading string $XmlContent $newFileName = $pathPublic . $sFileName; if (in_array($sFileName, $arrayWebEntryFile)) { continue; } $bytesSaved = @file_put_contents( $newFileName, $fileContent ); if ($bytesSaved != $fsContent) { throw (new Exception( 'Error writing Public file in directory : ' . $pathPublic )); } } } } } fclose( $fp ); return true; }
/** * Get data of Cases OutputDocument * * @param string $applicationUid * @param string $outputDocumentUid * @param string $userUid * * return object Return an object with data of an OutputDocument */ public function addCasesOutputDocument($applicationUid, $outputDocumentUid, $userUid) { try { $sApplication = $applicationUid; $index = \AppDelegation::getCurrentIndex($applicationUid); $sUserLogged = $userUid; $outputID = $outputDocumentUid; $g = new \G(); $g->sessionVarSave(); \G::LoadClass( 'case' ); $oCase = new \Cases(); $oCase->thisIsTheCurrentUser( $sApplication, $index, $sUserLogged, '', 'casesListExtJs' ); //require_once 'classes/model/OutputDocument.php'; $oOutputDocument = new \OutputDocument(); $aOD = $oOutputDocument->load( $outputID ); $Fields = $oCase->loadCase( $sApplication ); $sFilename = preg_replace( '[^A-Za-z0-9_]', '_', \G::replaceDataField( $aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'] ) ); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppFolder.php"); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppDocument.php"); //Get the Custom Folder ID (create if necessary) $oFolder = new \AppFolder(); $folderId = $oFolder->createFromPath( $aOD['OUT_DOC_DESTINATION_PATH'], $sApplication ); //Tags $fileTags = $oFolder->parseTags( $aOD['OUT_DOC_TAGS'], $sApplication ); //Get last Document Version and apply versioning if is enabled $oAppDocument = new \AppDocument(); $lastDocVersion = $oAppDocument->getLastDocVersion( $outputID, $sApplication ); $oCriteria = new \Criteria( 'workflow' ); $oCriteria->add( \AppDocumentPeer::APP_UID, $sApplication ); $oCriteria->add( \AppDocumentPeer::DOC_UID, $outputID ); $oCriteria->add( \AppDocumentPeer::DOC_VERSION, $lastDocVersion ); $oCriteria->add( \AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT' ); $oDataset = \AppDocumentPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); if (($aOD['OUT_DOC_VERSIONING']) && ($lastDocVersion != 0)) { //Create new Version of current output $lastDocVersion ++; if ($aRow = $oDataset->getRow()) { $aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion + 1,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags); $oAppDocument = new \AppDocument(); $oAppDocument->create( $aFields ); $sDocUID = $aRow['APP_DOC_UID']; } } else { ////No versioning so Update a current Output or Create new if no exist if ($aRow = $oDataset->getRow()) { //Update $aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags ); $oAppDocument = new \AppDocument(); $oAppDocument->update( $aFields ); $sDocUID = $aRow['APP_DOC_UID']; } else { //we are creating the appdocument row //create if ($lastDocVersion == 0) { $lastDocVersion ++; } $aFields = array ('APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags ); $oAppDocument = new \AppDocument(); $aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create( $aFields ); } } $sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion; $pathOutput = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP; //G::pr($sFilename);die; \G::mk_dir( $pathOutput ); $aProperties = array (); if (! isset( $aOD['OUT_DOC_MEDIA'] )) { $aOD['OUT_DOC_MEDIA'] = 'Letter'; } if (! isset( $aOD['OUT_DOC_LEFT_MARGIN'] )) { $aOD['OUT_DOC_LEFT_MARGIN'] = '15'; } if (! isset( $aOD['OUT_DOC_RIGHT_MARGIN'] )) { $aOD['OUT_DOC_RIGHT_MARGIN'] = '15'; } if (! isset( $aOD['OUT_DOC_TOP_MARGIN'] )) { $aOD['OUT_DOC_TOP_MARGIN'] = '15'; } if (! isset( $aOD['OUT_DOC_BOTTOM_MARGIN'] )) { $aOD['OUT_DOC_BOTTOM_MARGIN'] = '15'; } $aProperties['media'] = $aOD['OUT_DOC_MEDIA']; $aProperties['margins'] = array ('left' => $aOD['OUT_DOC_LEFT_MARGIN'],'right' => $aOD['OUT_DOC_RIGHT_MARGIN'],'top' => $aOD['OUT_DOC_TOP_MARGIN'],'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN'] ); if (isset($aOD['OUT_DOC_REPORT_GENERATOR'])) { $aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR']; } $this->generate( $outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties , $applicationUid); //Plugin Hook PM_UPLOAD_DOCUMENT for upload document //G::LoadClass('plugin'); $oPluginRegistry = & \PMPluginRegistry::getSingleton(); if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( 'uploadDocumentData' )) { $triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT ); $aFields['APP_DOC_PLUGIN'] = $triggerDetail->sNamespace; $oAppDocument1 = new \AppDocument(); $oAppDocument1->update( $aFields ); $sPathName = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP; $oData['APP_UID'] = $sApplication; $oData['ATTACHMENT_FOLDER'] = true; switch ($aOD['OUT_DOC_GENERATE']) { case "BOTH": $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() ); $documentData->sFileType = "PDF"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); if ($uploadReturn) { //Only delete if the file was saved correctly unlink( $pathOutput . $sFilename . '.pdf' ); } $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() ); $documentData->sFileType = "DOC"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); if ($uploadReturn) { //Only delete if the file was saved correctly unlink( $pathOutput . $sFilename . '.doc' ); } break; case "PDF": $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() ); $documentData->sFileType = "PDF"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); if ($uploadReturn) { //Only delete if the file was saved correctly unlink( $pathOutput . $sFilename . '.pdf' ); } break; case "DOC": $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() ); $documentData->sFileType = "DOC"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); if ($uploadReturn) { //Only delete if the file was saved correctly unlink( $pathOutput . $sFilename . '.doc' ); } break; } } $g->sessionVarRestore(); $oAppDocument = \AppDocumentPeer::retrieveByPK( $aFields['APP_DOC_UID'], $lastDocVersion); if ($oAppDocument->getAppDocStatus() == 'DELETED') { $oAppDocument->setAppDocStatus('ACTIVE'); $oAppDocument->save(); } $response = $this->getCasesOutputDocument($applicationUid, $userUid, $aFields['APP_DOC_UID']); return $response; } catch (\Exception $e) { throw $e; } }
/** * DEPRECATED createPropelClasses() * * Don't use this method, it was left only for backward compatibility * for some external plugins that still is using it */ public function createPropelClasses($sTableName, $sClassName, $aFields, $sAddTabUid, $connection = 'workflow') { try { /* $aUID = array('FLD_NAME' => 'PM_UNIQUE_ID', 'FLD_TYPE' => 'INT', 'FLD_KEY' => 'on', 'FLD_SIZE' => '11', 'FLD_NULL' => '', 'FLD_AUTO_INCREMENT' => 'on'); array_unshift($aFields, $aUID); */ $aTypes = array( 'VARCHAR' => 'string', 'TEXT' => 'string', 'DATE' => 'int', 'INT' => 'int', 'FLOAT' => 'double' ); $aCreoleTypes = array( 'VARCHAR' => 'VARCHAR', 'TEXT' => 'LONGVARCHAR', 'DATE' => 'TIMESTAMP', 'INT' => 'INTEGER', 'FLOAT' => 'DOUBLE' ); if ($sClassName == '') { $sClassName = $this->getPHPName($sTableName); } $sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP; if (!file_exists($sPath)) { G::mk_dir($sPath); } if (!file_exists($sPath . 'map')) { G::mk_dir($sPath . 'map'); } if (!file_exists($sPath . 'om')) { G::mk_dir($sPath . 'om'); } $aData = array(); $aData['pathClasses'] = substr(PATH_DB, 0, -1); $aData['tableName'] = $sTableName; $aData['className'] = $sClassName; $aData['connection'] = $connection; $aData['GUID'] = $sAddTabUid; $aData['firstColumn'] = isset($aFields[0]) ? strtoupper($aFields[0]['FLD_NAME']) : ($aFields[1]['FLD_NAME']); $aData['totalColumns'] = count($aFields); $aData['useIdGenerator'] = 'false'; $oTP1 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'Table.tpl'); $oTP1->prepare(); $oTP1->assignGlobal($aData); file_put_contents($sPath . $sClassName . '.php', $oTP1->getOutputContent()); $oTP2 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'TablePeer.tpl'); $oTP2->prepare(); $oTP2->assignGlobal($aData); file_put_contents($sPath . $sClassName . 'Peer.php', $oTP2->getOutputContent()); $aColumns = array(); $aPKs = array(); $aNotPKs = array(); $i = 0; foreach ($aFields as $iKey => $aField) { $aField['FLD_NAME'] = strtoupper($aField['FLD_NAME']); if ($aField['FLD_TYPE'] == 'DATE') { $aField['FLD_NULL'] = ''; } $aColumn = array( 'name' => $aField['FLD_NAME'], 'phpName' => $this->getPHPName($aField['FLD_NAME']), 'type' => $aTypes[$aField['FLD_TYPE']], 'creoleType' => $aCreoleTypes[$aField['FLD_TYPE']], 'notNull' => ($aField['FLD_NULL'] == 'on' ? 'true' : 'false'), 'size' => (($aField['FLD_TYPE'] == 'VARCHAR') || ($aField['FLD_TYPE'] == 'INT') || ($aField['FLD_TYPE'] == 'FLOAT') ? $aField['FLD_SIZE'] : 'null'), 'var' => strtolower($aField['FLD_NAME']), 'attribute' => (($aField['FLD_TYPE'] == 'VARCHAR') || ($aField['FLD_TYPE'] == 'TEXT') || ($aField['FLD_TYPE'] == 'DATE') ? '$' . strtolower($aField['FLD_NAME']) . " = ''" : '$' . strtolower($aField['FLD_NAME']) . ' = 0'), 'index' => $i, ); if ($aField['FLD_TYPE'] == 'DATE') { $aColumn['getFunction'] = '/** * Get the [optionally formatted] [' . $aColumn['var'] . '] column value. * * @param string $format The date/time format string (either date()-style or strftime()-style). * If format is NULL, then the integer unix timestamp will be returned. * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). * @throws PropelException - if unable to convert the date/time to timestamp. */ public function get' . $aColumn['phpName'] . '($format = "Y-m-d") { if ($this->' . $aColumn['var'] . ' === null || $this->' . $aColumn['var'] . ' === "") { return null; } elseif (!is_int($this->' . $aColumn['var'] . ')) { // a non-timestamp value was set externally, so we convert it if (($this->' . $aColumn['var'] . ' == "0000-00-00 00:00:00") || ($this->' . $aColumn['var'] . ' == "0000-00-00") || !$this->' . $aColumn['var'] . ') { $ts = "0"; } else { $ts = strtotime($this->' . $aColumn['var'] . '); } if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE throw new PropelException("Unable to parse value of [' . $aColumn['var'] . '] as date/time value: " . var_export($this->' . $aColumn['var'] . ', true)); } } else { $ts = $this->' . $aColumn['var'] . '; } if ($format === null) { return $ts; } elseif (strpos($format, "%") !== false) { return strftime($format, $ts); } else { return date($format, $ts); } }'; } else { $aColumn['getFunction'] = '/** * Get the [' . $aColumn['var'] . '] column value. * * @return string */ public function get' . $aColumn['phpName'] . '() { return $this->' . $aColumn['var'] . '; }'; } switch ($aField['FLD_TYPE']) { case 'VARCHAR': case 'TEXT': $aColumn['setFunction'] = '// Since the native PHP type for this column is string, // we will cast the input to a string (if it is not). if ($v !== null && !is_string($v)) { $v = (string) $v; } if ($this->' . $aColumn['var'] . ' !== $v) { $this->' . $aColumn['var'] . ' = $v; $this->modifiedColumns[] = ' . $aData['className'] . 'Peer::' . $aColumn['name'] . '; }'; break; case 'DATE': $aColumn['setFunction'] = 'if ($v !== null && !is_int($v)) { // if($v == \'\') // $ts = null; // else $ts = strtotime($v); if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE //throw new PropelException("Unable to parse date/time value for [' . $aColumn['var'] . '] from input: " // . var_export($v, true)); } } else { $ts = $v; } if ($this->' . $aColumn['var'] . ' !== $ts) { $this->' . $aColumn['var'] . ' = $ts; $this->modifiedColumns[] = ' . $aData['className'] . 'Peer::' . $aColumn['name'] . '; }'; break; case 'INT': $aColumn['setFunction'] = '// Since the native PHP type for this column is integer, // we will cast the input value to an int (if it is not). if ($v !== null && !is_int($v) && is_numeric($v)) { $v = (int) $v; } if ($this->' . $aColumn['var'] . ' !== $v || $v === 1) { $this->' . $aColumn['var'] . ' = $v; $this->modifiedColumns[] = ' . $aData['className'] . 'Peer::' . $aColumn['name'] . '; }'; break; case 'FLOAT': $aColumn['setFunction'] = 'if ($this->' . $aColumn['var'] . ' !== $v || $v === 0) { $this->' . $aColumn['var'] . ' = $v; $this->modifiedColumns[] = ' . $aData['className'] . 'Peer::' . $aColumn['name'] . '; }'; break; } $aColumns[] = $aColumn; if ($aField['FLD_KEY'] == 1 || $aField['FLD_KEY'] === 'on') { $aPKs[] = $aColumn; } else { $aNotPKs[] = $aColumn; } if ($aField['FLD_AUTO_INCREMENT'] == 1 || $aField['FLD_AUTO_INCREMENT'] === 'on') { $aData['useIdGenerator'] = 'true'; } $i++; } $oTP3 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'map' . PATH_SEP . 'TableMapBuilder.tpl'); $oTP3->prepare(); $oTP3->assignGlobal($aData); foreach ($aPKs as $iIndex => $aColumn) { $oTP3->newBlock('primaryKeys'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP3->assign($sKey, $aColumn[$sKey]); } } $oTP3->gotoBlock('_ROOT'); foreach ($aNotPKs as $iIndex => $aColumn) { $oTP3->newBlock('columnsWhitoutKeys'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP3->assign($sKey, $aColumn[$sKey]); } } file_put_contents($sPath . PATH_SEP . 'map' . PATH_SEP . $sClassName . 'MapBuilder.php', $oTP3->getOutputContent()); $oTP4 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'om' . PATH_SEP . 'BaseTable.tpl'); $oTP4->prepare(); switch (count($aPKs)) { case 0: $aData['getPrimaryKeyFunction'] = 'return null;'; $aData['setPrimaryKeyFunction'] = ''; break; case 1: $aData['getPrimaryKeyFunction'] = 'return $this->get' . $aPKs[0]['phpName'] . '();'; $aData['setPrimaryKeyFunction'] = '$this->set' . $aPKs[0]['phpName'] . '($key);'; break; default: $aData['getPrimaryKeyFunction'] = '$pks = array();' . "\n"; $aData['setPrimaryKeyFunction'] = ''; foreach ($aPKs as $iIndex => $aColumn) { $aData['getPrimaryKeyFunction'] .= '$pks[' . $iIndex . '] = $this->get' . $aColumn['phpName'] . '();' . "\n"; $aData['setPrimaryKeyFunction'] .= '$this->set' . $aColumn['phpName'] . '($keys[' . $iIndex . ']);' . "\n"; } $aData['getPrimaryKeyFunction'] .= 'return $pks;' . "\n"; break; } $oTP4->assignGlobal($aData); foreach ($aColumns as $iIndex => $aColumn) { $oTP4->newBlock('allColumns1'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP4->assign($sKey, $aColumn[$sKey]); } $oTP4->newBlock('allColumns2'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP4->assign($sKey, $aColumn[$sKey]); } $oTP4->newBlock('allColumns3'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP4->assign($sKey, $aColumn[$sKey]); } $oTP4->newBlock('allColumns4'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP4->assign($sKey, $aColumn[$sKey]); } $oTP4->newBlock('allColumns5'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP4->assign($sKey, $aColumn[$sKey]); } $oTP4->newBlock('allColumns6'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP4->assign($sKey, $aColumn[$sKey]); } $oTP4->newBlock('allColumns7'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP4->assign($sKey, $aColumn[$sKey]); } $oTP4->newBlock('allColumns8'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP4->assign($sKey, $aColumn[$sKey]); } $oTP4->newBlock('allColumns9'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP4->assign($sKey, $aColumn[$sKey]); } } $oTP4->gotoBlock('_ROOT'); foreach ($aPKs as $iIndex => $aColumn) { $oTP4->newBlock('primaryKeys1'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP4->assign($sKey, $aColumn[$sKey]); } } $oTP4->gotoBlock('_ROOT'); foreach ($aPKs as $iIndex => $aColumn) { $oTP4->newBlock('primaryKeys2'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP4->assign($sKey, $aColumn[$sKey]); } } $oTP4->gotoBlock('_ROOT'); foreach ($aNotPKs as $iIndex => $aColumn) { $oTP4->newBlock('columnsWhitoutKeys'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP4->assign($sKey, $aColumn[$sKey]); } } file_put_contents($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $sClassName . '.php', $oTP4->getOutputContent()); $oTP5 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'om' . PATH_SEP . 'BaseTablePeer.tpl'); $oTP5->prepare(); $sKeys = ''; foreach ($aPKs as $iIndex => $aColumn) { $sKeys .= '$' . $aColumn['var'] . ', '; } $sKeys = substr($sKeys, 0, -2); //$sKeys = '$pm_unique_id'; if ($sKeys != '') { $aData['sKeys'] = $sKeys; } else { $aData['sKeys'] = '$DUMMY'; } $oTP5->assignGlobal($aData); foreach ($aColumns as $iIndex => $aColumn) { $oTP5->newBlock('allColumns1'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP5->assign($sKey, $aColumn[$sKey]); } $oTP5->newBlock('allColumns2'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP5->assign($sKey, $aColumn[$sKey]); } $oTP5->newBlock('allColumns3'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP5->assign($sKey, $aColumn[$sKey]); } $oTP5->newBlock('allColumns4'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP5->assign($sKey, $aColumn[$sKey]); } $oTP5->newBlock('allColumns5'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP5->assign($sKey, $aColumn[$sKey]); } $oTP5->newBlock('allColumns6'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP5->assign($sKey, $aColumn[$sKey]); } $oTP5->newBlock('allColumns7'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP5->assign($sKey, $aColumn[$sKey]); } $oTP5->newBlock('allColumns8'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP5->assign($sKey, $aColumn[$sKey]); } $oTP5->newBlock('allColumns9'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP5->assign($sKey, $aColumn[$sKey]); } $oTP5->newBlock('allColumns10'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP5->assign($sKey, $aColumn[$sKey]); } } $oTP5->gotoBlock('_ROOT'); foreach ($aPKs as $iIndex => $aColumn) { $oTP5->newBlock('primaryKeys1'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP5->assign($sKey, $aColumn[$sKey]); } } foreach ($aPKs as $iIndex => $aColumn) { $oTP5->newBlock('primaryKeys2'); $aKeys = array_keys($aColumn); foreach ($aKeys as $sKey) { $oTP5->assign($sKey, $aColumn[$sKey]); } } file_put_contents($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $sClassName . 'Peer.php', $oTP5->getOutputContent()); } catch (Exception $oError) { throw($oError); } }
/** * log the queries and other information to install.log, * the install.log files should be placed in shared/logs * for that reason we are using the $_REQUEST of pathShared */ public function installLog ($text) { $serverAddr = $_SERVER['SERVER_ADDR']; //if this function is called outside the createWorkspace, just returns and do nothing if (! isset( $_REQUEST['pathShared'] )) { return; } //log file is in shared/logs $pathShared = trim( $_REQUEST['pathShared'] ); if (substr( $pathShared, - 1 ) != '/') { $pathShared .= '/'; } $pathSharedLog = $pathShared . 'log/'; G::verifyPath($pathSharedLog, true); $logFile = $pathSharedLog . 'install.log'; if (! is_file( $logFile )) { G::mk_dir( dirname( $pathShared ) ); $fpt = fopen( $logFile, 'w' ); if ($fpt !== null) { fwrite( $fpt, sprintf( "%s %s\n", date( 'Y:m:d H:i:s' ), '----- '. G::LoadTranslation('ID_STARTING_LOG_FILE') .' ------' ) ); fclose( $fpt ); } else { throw (new Exception( G::LoadTranslation('ID_FILE_NOT_WRITEABLE', SYS_LANG, Array($logFile) ) )); return $false; } } G::LoadSystem('inputfilter'); $filter = new InputFilter(); $logFile = $filter->validateInput($logFile, 'path'); $fpt = fopen( $logFile, 'a' ); fwrite( $fpt, sprintf( "%s %s\n", date( 'Y:m:d H:i:s' ), trim( $text ) ) ); fclose( $fpt ); return true; }
/** * send message * * @param string $caseId * @param string $sFrom * @param string $sTo * @param string $sCc * @param string $sBcc * @param string $sSubject * @param string $sTemplate * @param $appFields = null * @param $aAttachment = null * @param boolean $showMessage = true * @param int $delIndex = 0 * @param $config = array * @return $result will return an object */ public function sendMessage( $caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $appFields = null, $aAttachment = null, $showMessage = true, $delIndex = 0, $config = array() ) { try { if (!class_exists('System')) { G::LoadClass('system'); } /*----------------------------------********---------------------------------*/ $aSetup = System::getEmailConfiguration(); /*----------------------------------********---------------------------------*/ $msgError = ""; if(sizeof($aSetup) == 0){ $msgError = "The default configuration wasn't defined"; } $oSpool = new spoolRun(); $oSpool->setConfig($aSetup); $oCase = new Cases(); $oldFields = $oCase->loadCase( $caseId ); $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $oldFields['PRO_UID'] . PATH_SEP; $fileTemplate = $pathEmail . $sTemplate; G::mk_dir( $pathEmail, 0777, true ); if (! file_exists( $fileTemplate )) { $data['FILE_TEMPLATE'] = $fileTemplate; $result = new wsResponse( 28, G::LoadTranslation( 'ID_TEMPLATE_FILE_NOT_EXIST', SYS_LANG, $data ) ); return $result; } if ($appFields == null) { $Fields = $oldFields['APP_DATA']; } else { $Fields = array_merge( $oldFields['APP_DATA'], $appFields ); } $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $Fields, false); $sFrom = G::buildFrom($aSetup, $sFrom); $showMessage = ($showMessage) ? 1 : 0 ; $messageArray = array( "msg_uid" => "", "app_uid" => $caseId, "del_index" => $delIndex, "app_msg_type" => "TRIGGER", "app_msg_subject" => $sSubject, "app_msg_from" => $sFrom, "app_msg_to" => $sTo, "app_msg_body" => $sBody, "app_msg_cc" => $sCc, "app_msg_bcc" => $sBcc, "app_msg_attach" => $aAttachment, "app_msg_template" => "", "app_msg_status" => "pending", "app_msg_show_message" => $showMessage, "app_msg_error" => $msgError, "contentTypeIsHtml" => (preg_match("/^.+\.html?$/i", $fileTemplate))? true : false ); $oSpool->create( $messageArray ); $oSpool->sendMail(); if ($oSpool->status == 'sent') { $result = new wsResponse( 0, G::loadTranslation( 'ID_MESSAGE_SENT' ) . ": " . $sTo ); } else { $result = new wsResponse( 29, $oSpool->status . ' ' . $oSpool->error . print_r( $aSetup, 1 ) ); } return $result; } catch (Exception $e) { return new wsResponse( 100, $e->getMessage() ); } }
/** * Function xmlformTemplate * * @author David S. Callizaya S. <*****@*****.**> * @access public * @param string form * @param string templateFile * @return string */ public function parseFile($filename, $language, $forceParse) { $this->language = $language; $filenameInitial = $filename; $filename = $this->home . $filename; //if the xmlform file doesn't exists, then try with the plugins folders if (!is_file($filename)) { $aux = explode(PATH_SEP, $filenameInitial); //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment if (count($aux) > 2) { //Subfolders $filename = array_pop($aux); $aux0 = implode(PATH_SEP, $aux); $aux = array(); $aux[0] = $aux0; $aux[1] = $filename; } if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($response = $oPluginRegistry->isRegisteredFolder($aux[0])) { if ($response !== true) { $sPath = PATH_PLUGINS . $response . PATH_SEP; } else { $sPath = PATH_PLUGINS; } $filename = $sPath . $aux[0] . PATH_SEP . $aux[1]; } } } $this->fileName = $filename; $parsedFile = dirname($filename) . PATH_SEP . basename($filename, 'xml') . $language; $parsedFilePath = defined('PATH_C') ? defined('SYS_SYS') ? PATH_C . 'ws' . PATH_SEP . SYS_SYS . PATH_SEP : PATH_C : PATH_DATA; $parsedFilePath .= 'xmlform/' . substr($parsedFile, strlen($this->home)); // Improvement for the js cache - Start $realPath = substr(realpath($this->fileName), strlen(realpath($this->home)), -4); if (substr($realPath, 0, 1) != PATH_SEP) { $realPath = PATH_SEP . $realPath; } $filesToDelete = substr((defined('PATH_C') ? PATH_C : PATH_DATA) . 'xmlform/', 0, -1) . $realPath . '.*.js'; $auxPath = explode(PATH_SEP, $realPath); $auxPath[count($auxPath) - 1] = $auxPath[count($auxPath) - 1] . '.' . md5(filemtime($this->fileName)); $realPath = implode(PATH_SEP, $auxPath); // Improvement for the js cache - End $this->parsedFile = $parsedFilePath; $this->scriptURL = '/jsform' . $realPath . '.js'; $this->scriptFile = substr((defined('PATH_C') ? PATH_C : PATH_DATA) . 'xmlform/', 0, -1) . substr($this->scriptURL, 7); $this->id = G::createUID('', substr($this->fileName, strlen($this->home))); $this->scriptURL = str_replace('\\', '/', $this->scriptURL); $newVersion = false; if ($forceParse || (!file_exists($this->parsedFile) || filemtime($filename) > filemtime($this->parsedFile) || filemtime(__FILE__) > filemtime($this->parsedFile)) || !file_exists($this->scriptFile) || filemtime($filename) > filemtime($this->scriptFile)) { if (glob($filesToDelete)) { foreach (glob($filesToDelete) as $fileToDelete) { @unlink($fileToDelete); } } $this->tree = new Xml_Document(); $this->tree->parseXmlFile($filename); //$this->tree->unsetParent(); if (!is_object($this->tree->children[0])) { throw new Exception('Failure loading root node.'); } $this->tree =& $this->tree->children[0]->toTree(); //ERROR CODE [1] : Failed to read the xml document if (!isset($this->tree)) { return 1; } $xmlNode =& $this->tree->children; //Set the form's attributes $myAttributes = get_class_vars(get_class($this)); foreach ($myAttributes as $k => $v) { $myAttributes[$k] = strtolower($k); } foreach ($this->tree->attributes as $k => $v) { $key = array_search(strtolower($k), $myAttributes); if ($key !== false && strtolower($k) !== 'fields' && strtolower($k) !== 'values') { $this->{$key} = $v; } } //Reeplace non valid characters in xmlform name with "_" $this->name = preg_replace('/\\W/', '_', $this->name); //Create fields foreach ($xmlNode as $k => $v) { if ($xmlNode[$k]->type !== 'cdata' && isset($xmlNode[$k]->attributes['type'])) { if (class_exists('XmlForm_Field_' . $xmlNode[$k]->attributes['type'])) { $x = '$field = new XmlForm_Field_' . $xmlNode[$k]->attributes['type'] . '( $xmlNode[$k], $language, $this->home, $this);'; eval($x); } else { $field = new XmlForm_Field($xmlNode[$k], $language, $this->home, $this); } $field->language = $this->language; $this->fields[$field->name] = $field; } if (isset($xmlNode[$k]->attributes['required']) || isset($xmlNode[$k]->attributes['validate'])) { // the fields or xml nodes with a required attribute are put in an array that is passed to the view file $isEditMode = isset($xmlNode[$k]->attributes['mode']) && $xmlNode[$k]->attributes['mode'] == 'view' ? false : true; if ($isEditMode && $this->mode != 'view') { $validateValue = ""; if (isset($xmlNode[$k]->attributes['validate'])) { $validateValue = $xmlNode[$k]->attributes['validate']; } $requiredValue = "0"; if (isset($xmlNode[$k]->attributes['required'])) { $requiredValue = $xmlNode[$k]->attributes['required'] == 1 ? '1' : '0'; } $this->requiredFields[] = array('name' => $field->name, 'type' => $xmlNode[$k]->attributes['type'], 'label' => addslashes(trim($field->label)), 'validate' => $validateValue, 'required' => $requiredValue); } } } //$oJSON = new Services_JSON(); $jsonRequired = G::json_encode($this->requiredFields); $this->objectRequiredFields = str_replace('"', "%27", str_replace("'", "%39", $jsonRequired)); //Load the default values //$this->setDefaultValues(); //Save the cache file if (!is_dir(dirname($this->parsedFile))) { G::mk_dir(dirname($this->parsedFile)); } $f = fopen($this->parsedFile, 'w+'); //ERROR CODE [2] : Failed to open cache file if ($f === false) { return 2; } fwrite($f, "<?php\n"); /* fwrite ($f, '$this = unserialize( \'' . addcslashes( serialize ( $this ), '\\\'' ) . '\' );' . "\n" );*/ foreach ($this as $key => $value) { //cho $key .'<br/>'; switch ($key) { case 'home': case 'fileName': case 'parsedFile': case 'scriptFile': case 'scriptURL': break; default: switch (true) { case is_string($this->{$key}): fwrite($f, '$this->' . $key . '=\'' . addcslashes($this->{$key}, '\\\'') . '\'' . ";\n"); break; case is_bool($this->{$key}): fwrite($f, '$this->' . $key . '=' . ($this->{$key} ? 'true;' : 'false') . ";\n"); break; case is_null($this->{$key}): fwrite($f, '$this->' . $key . '=null' . ";\n"); break; case is_float($this->{$key}): case is_int($this->{$key}): fwrite($f, '$this->' . $key . '=' . $this->{$key} . ";\n"); break; default: fwrite($f, '$this->' . $key . ' = unserialize( \'' . addcslashes(serialize($this->{$key}), '\\\'') . '\' );' . "\n"); } } } fwrite($f, "?>"); fclose($f); $newVersion = true; } //if $forceParse //Loads the parsedFile. require $this->parsedFile; $this->fileName = $filename; $this->parsedFile = $parsedFile; //RECREATE LA JS file //Note: Template defined with publisher doesn't affect the .js file //created at this point. if ($newVersion) { $template = PATH_CORE . 'templates/' . $this->type . '.html'; //If the type is not the correct template name, use xmlform.html //if (!file_exists($template)) $template = PATH_CORE . 'templates/xmlform.html'; if ($template !== '' && file_exists($template)) { if (!is_dir(dirname($this->scriptFile))) { G::mk_dir(dirname($this->scriptFile)); } $f = fopen($this->scriptFile, 'w'); $o = new xmlformTemplate($this, $template); $scriptContent = $o->printJSFile($this); unset($o); fwrite($f, $scriptContent); fclose($f); } } return 0; }
<?php $ipaddress = $_SERVER['REMOTE_ADDR']; try { $aux = explode('|', $_GET['id']); $index = 0; $ObjUid = str_replace('"', '', $aux[$index++]); if (isset($_GET['v'])) { $versionReq = $_GET['v']; } //downloading the file $localPath = PATH_DOCUMENT . 'input' . PATH_SEP; G::mk_dir($localPath); $newfilename = G::GenerateUniqueId() . '.pm'; $downloadUrl = PML_DOWNLOAD_URL . '?id=' . $ObjUid . (isset($_GET['s']) ? '&s=' . $_GET['s'] : ''); //print "<hr>$downloadUrl<hr>";die; G::LoadClass('processes'); $oProcess = new Processes(); $oProcess->downloadFile($downloadUrl, $localPath, $newfilename); //getting the ProUid from the file recently downloaded $oData = $oProcess->getProcessData($localPath . $newfilename); if (is_null($oData)) { throw new Exception('Error'); } $Fields['IMPORT_OPTION'] = 2; $Fields['PRO_FILENAME'] = $newfilename; $Fields['OBJ_UID'] = $ObjUid; $sProUid = $oData->process['PRO_UID']; $oData->process['PRO_UID_OLD'] = $sProUid; //print $sProUid;die; //if the process exists, we need to ask what kind of re-import the user wants,
public function verifyFilesOldEnterprise ($workspace) { $this->initPropel( true ); $pathBackup = PATH_DATA . 'backups'; if (!file_exists($pathBackup)) { G::mk_dir($pathBackup, 0777); } $pathNewFile = PATH_DATA . 'backups' . PATH_SEP . 'enterpriseBackup'; $pathDirectoryEnterprise = PATH_CORE . 'plugins' . PATH_SEP . 'enterprise'; $pathFileEnterprise = PATH_CORE . 'plugins' . PATH_SEP . 'enterprise.php'; if (!file_exists($pathDirectoryEnterprise) && !file_exists($pathFileEnterprise)) { CLI::logging(" Without changes... \n"); return true; } CLI::logging(" Migrating Enterprise Core version...\n"); if (!file_exists($pathNewFile)) { CLI::logging(" Creating folder in $pathNewFile\n"); G::mk_dir($newDiretory, 0777); } $shared_stat = stat(PATH_DATA); if (file_exists($pathDirectoryEnterprise)) { CLI::logging(" Copying Enterprise Directory to $pathNewFile...\n"); if ($shared_stat !== false) { workspaceTools::dirPerms($pathDirectoryEnterprise, $shared_stat['uid'], $shared_stat['gid'], $shared_stat['mode']); } else { CLI::logging(CLI::error("Could not get shared folder permissions, workspace permissions couldn't be changed") . "\n"); } if (G::recursive_copy($pathDirectoryEnterprise, $pathNewFile . PATH_SEP. 'enterprise')) { CLI::logging(" Removing $pathDirectoryEnterprise...\n"); G::rm_dir($pathDirectoryEnterprise); } else { CLI::logging(CLI::error(" Error: Failure to copy from $pathDirectoryEnterprise...\n")); } if (file_exists($pathDirectoryEnterprise)) { CLI::logging(CLI::info(" Remove manually $pathDirectoryEnterprise...\n")); } } if (file_exists($pathFileEnterprise)) { CLI::logging(" Copying Enterprise.php file to $pathNewFile...\n"); if ($shared_stat !== false) { workspaceTools::dirPerms($pathFileEnterprise, $shared_stat['uid'], $shared_stat['gid'], $shared_stat['mode']); } else { CLI::logging(CLI::error("Could not get shared folder permissions, workspace permissions couldn't be changed") . "\n"); } CLI::logging(" Removing $pathFileEnterprise...\n"); copy($pathFileEnterprise , $pathNewFile. PATH_SEP . 'enterprise.php'); G::rm_dir($pathFileEnterprise); if (file_exists($pathFileEnterprise)) { CLI::logging(CLI::info(" Remove manually $pathFileEnterprise...\n")); } } }
$sDocUID = $aRow['APP_DOC_UID']; } else { //create if ($lastDocVersion == 0) { $lastDocVersion++; } $aFields = array('APP_UID' => $_SESSION['APPLICATION'], 'DEL_INDEX' => $_SESSION['INDEX'], 'DOC_UID' => $_GET['UID'], 'DOC_VERSION' => $lastDocVersion, 'USR_UID' => $_SESSION['USER_LOGGED'], 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags); $oAppDocument = new AppDocument(); $aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create($aFields); } } //$sFilename = ereg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'])); //if ( $sFilename == '' ) $sFilename='_'; $sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion; $pathOutput = PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP . 'outdocs' . PATH_SEP; G::mk_dir($pathOutput); switch ($aOD['OUT_DOC_TYPE']) { case 'HTML': $aProperties = array(); //maui if (!isset($aOD['OUT_DOC_MEDIA'])) { $aOD['OUT_DOC_MEDIA'] = 'Letter'; } if (!isset($aOD['OUT_DOC_LEFT_MARGIN'])) { $aOD['OUT_DOC_LEFT_MARGIN'] = '15'; } if (!isset($aOD['OUT_DOC_RIGHT_MARGIN'])) { $aOD['OUT_DOC_RIGHT_MARGIN'] = '15'; } if (!isset($aOD['OUT_DOC_TOP_MARGIN'])) { $aOD['OUT_DOC_TOP_MARGIN'] = '15';
// end backward compatibility // include the workspace installed configuration require_once FILE_PATHS_INSTALLED; // defining system constant when a valid workspace environment exists define('PATH_LANGUAGECONT', PATH_DATA . "META-INF" . PATH_SEP); define('PATH_CUSTOM_SKINS', PATH_DATA . 'skins' . PATH_SEP); define('PATH_TEMPORAL', PATH_C . 'dynEditor/'); define('PATH_DB', PATH_DATA . 'sites' . PATH_SEP); // smarty constants define('PATH_SMARTY_C', PATH_C . 'smarty' . PATH_SEP . 'c'); define('PATH_SMARTY_CACHE', PATH_C . 'smarty' . PATH_SEP . 'cache'); if (!is_dir(PATH_SMARTY_C)) { G::mk_dir(PATH_SMARTY_C); } if (!is_dir(PATH_SMARTY_CACHE)) { G::mk_dir(PATH_SMARTY_CACHE); } } // set include path set_include_path(PATH_CORE . PATH_SEPARATOR . PATH_THIRDPARTY . PATH_SEPARATOR . PATH_THIRDPARTY . 'pear' . PATH_SEPARATOR . PATH_RBAC_CORE . PATH_SEPARATOR . get_include_path()); /** * Global definitions, before it was the defines.php file */ // URL Key define("URL_KEY", 'c0l0s40pt1mu59r1m3'); // Other definitions define('TIMEOUT_RESPONSE', 100); //web service timeout define('APPLICATION_CODE', 'ProcessMaker'); //to login like workflow system define('MAIN_POFILE', 'processmaker');