/** * edit pmtable * * @param string $httpData->id */ public function edit($httpData) { require_once PATH_CONTROLLERS . 'pmTablesProxy.php'; require_once 'classes/model/AdditionalTables.php'; G::loadClass('pmTable'); $additionalTables = new AdditionalTables(); $table = false; $addTabUid = isset($httpData->id) ? $httpData->id : false; $dataNumRows = 0; $repTabPluginPermissions = false; $columnsTypes = PmTable::getPropelSupportedColumnTypes(); $jsFile = isset($httpData->tableType) && $httpData->tableType == 'report' ? 'editReport' : 'edit'; $columnsTypesList = array(); foreach ($columnsTypes as $columnTypeName => $columnType) { $columnsTypesList[] = array($columnTypeName, $columnType); } if ($addTabUid) { $tableData = $additionalTables->getAllData($httpData->id, 0, 2); $dataNumRows = $tableData['count']; } if ($addTabUid !== false) { // if it is a edit request $tableFields = array(); $fieldsList = array(); $table = $additionalTables->load($addTabUid, true); //fix for backware compatibility $table['DBS_UID'] = $table['DBS_UID'] == null || $table['DBS_UID'] == '' ? 'workflow' : $table['DBS_UID']; $_SESSION['ADD_TAB_UID'] = $addTabUid; //list dynaform fields if ($table['ADD_TAB_TYPE'] == 'NORMAL' || $table['ADD_TAB_TYPE'] == 'GRID') { $repTabPluginPermissions = $this->_getSimpleReportPluginDef(); } } $this->includeExtJS('pmTables/' . $jsFile); $this->setJSVar('flagProcessmap', isset($_REQUEST['flagProcessmap']) ? $_REQUEST['flagProcessmap'] : 0); $this->setJSVar('ADD_TAB_UID', $addTabUid); $this->setJSVar('PRO_UID', isset($_GET['PRO_UID']) ? $_GET['PRO_UID'] : false); $this->setJSVar('TABLE', $table); $this->setJSVar('dbg', isset($httpData->dbg)); $this->setJSVar('columnsTypes', $columnsTypesList); $this->setJSVar('dataNumRows', $dataNumRows); $this->setJSVar('_plugin_permissions', $repTabPluginPermissions); $this->setJSVar('sizeTableName', $this->getSizeTableName()); $isBpmn = 0; if (isset($_GET['PRO_UID'])) { $process = new Process(); $isBpmn = $process->isBpmnProcess($_GET['PRO_UID']); } $this->setJSVar('isBpmn', $isBpmn); G::RenderPage('publish', 'extJs'); }
/** * Export PM tables * * @author : Erik Amaru Ortiz <*****@*****.**> */ public function export($httpData) { require_once 'classes/model/AdditionalTables.php'; $at = new AdditionalTables(); $tablesToExport = G::json_decode(stripslashes($httpData->rows)); try { G::LoadCLass('net'); $net = new NET(G::getIpAddress()); G::LoadClass("system"); $META = " \n-----== ProcessMaker Open Source Private Tables ==-----\n" . " @Ver: 1.0 Oct-2009\n" . " @Processmaker version: " . System::getVersion() . "\n" . " -------------------------------------------------------\n" . " @Export Date: " . date("l jS \\of F Y h:i:s A") . "\n" . " @Server address: " . getenv('SERVER_NAME') . " (" . getenv('SERVER_ADDR') . ")\n" . " @Client address: " . $net->hostname . "\n" . " @Workspace: " . SYS_SYS . "\n" . " @Export trace back:\n\n"; $EXPORT_TRACEBACK = array(); $c = 0; foreach ($tablesToExport as $table) { $tableRecord = $at->load($table->ADD_TAB_UID); $tableData = $at->getAllData($table->ADD_TAB_UID, null, null, false); $table->ADD_TAB_NAME = $tableRecord['ADD_TAB_NAME']; $rows = $tableData['rows']; $count = $tableData['count']; array_push($EXPORT_TRACEBACK, array('uid' => $table->ADD_TAB_UID, 'name' => $table->ADD_TAB_NAME, 'num_regs' => $tableData['count'], 'schema' => $table->_SCHEMA ? 'yes' : 'no', 'data' => $table->_DATA ? 'yes' : 'no')); } $sTrace = "TABLE UID TABLE NAME\tREGS\tSCHEMA\tDATA\n"; foreach ($EXPORT_TRACEBACK as $row) { $sTrace .= "{$row['uid']}\t{$row['name']}\t\t{$row['num_regs']}\t{$row['schema']}\t{$row['data']}\n"; } $META .= $sTrace; ///////////////EXPORT PROCESS $PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP; $filenameOnly = strtolower('SYS-' . SYS_SYS . "_" . date("Y-m-d") . '_' . date("Hi") . ".pmt"); $filename = $PUBLIC_ROOT_PATH . $filenameOnly; $fp = fopen($filename, "wb"); $bytesSaved = 0; $bufferType = '@META'; $fsData = sprintf("%09d", strlen($META)); $fsbufferType = sprintf("%09d", strlen($bufferType)); $bytesSaved += fwrite($fp, $fsbufferType); //writing the size of $oData $bytesSaved += fwrite($fp, $bufferType); //writing the $oData $bytesSaved += fwrite($fp, $fsData); //writing the size of $oData $bytesSaved += fwrite($fp, $META); //writing the $oData foreach ($tablesToExport as $table) { if ($table->_SCHEMA) { $oAdditionalTables = new AdditionalTables(); $aData = $oAdditionalTables->load($table->ADD_TAB_UID, true); $bufferType = '@SCHEMA'; $SDATA = serialize($aData); $fsUid = sprintf("%09d", strlen($table->ADD_TAB_UID)); $fsData = sprintf("%09d", strlen($SDATA)); $fsbufferType = sprintf("%09d", strlen($bufferType)); $bytesSaved += fwrite($fp, $fsbufferType); //writing the size of $oData $bytesSaved += fwrite($fp, $bufferType); //writing the $oData $bytesSaved += fwrite($fp, $fsUid); //writing the size of xml file $bytesSaved += fwrite($fp, $table->ADD_TAB_UID); //writing the xmlfile $bytesSaved += fwrite($fp, $fsData); //writing the size of xml file $bytesSaved += fwrite($fp, $SDATA); //writing the xmlfile } if ($table->_DATA) { //export data $oAdditionalTables = new additionalTables(); $tableData = $oAdditionalTables->getAllData($table->ADD_TAB_UID, null, null, false); $SDATA = serialize($tableData['rows']); $bufferType = '@DATA'; $fsbufferType = sprintf("%09d", strlen($bufferType)); $fsTableName = sprintf("%09d", strlen($table->ADD_TAB_NAME)); $fsData = sprintf("%09d", strlen($SDATA)); $bytesSaved += fwrite($fp, $fsbufferType); //writing type size $bytesSaved += fwrite($fp, $bufferType); //writing type $bytesSaved += fwrite($fp, $fsTableName); //writing the size of xml file $bytesSaved += fwrite($fp, $table->ADD_TAB_NAME); //writing the xmlfile $bytesSaved += fwrite($fp, $fsData); //writing the size of xml file $bytesSaved += fwrite($fp, $SDATA); //writing the xmlfile } } fclose($fp); $filenameLink = "pmTables/streamExported?f={$filenameOnly}"; $size = round($bytesSaved / 1024, 2) . " Kb"; $meta = "<pre>" . $META . "</pre>"; $filename = $filenameOnly; $link = $filenameLink; $result->success = true; $result->filename = $filenameOnly; $result->link = $link; $result->message = "Generated file: {$filenameOnly}, size: {$size}"; } catch (Exception $e) { $result->success = false; $result->message = $e->getMessage(); } return $result; }