diff --git a/workflow/engine/classes/class.pmTable.php b/workflow/engine/classes/class.pmTable.php new file mode 100644 index 000000000..eaa23ee47 --- /dev/null +++ b/workflow/engine/classes/class.pmTable.php @@ -0,0 +1,586 @@ +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +require_once 'classes/model/AdditionalTables.php'; + +/** + * PmTable Class + * New class to handle pmTable in native form invoking to Phing & Propel + * @author Erik Amaru Ortiz + */ +class PmTable +{ + private $dom = null; + private $schemaFile = ''; + + private $tableName; + private $columns; + + private $baseDir = ''; + private $targetDir = ''; + private $configDir = ''; + private $dataDir = ''; + private $classesDir = ''; + private $className = ''; + + private $dataSource = ''; + private $rootNode; + + private $dbConfig; + private $db; + + function __construct($tableName) + { + $this->tableName = $tableName; + $this->className = $this->toCamelCase($tableName); + $this->dbConfig = new StdClass(); + } + + + /** + * Set columns to pmTable + * @param array $columns contains a array of abjects + * array(StdClass->field_name, field_type, field_size, field_null, field_key, field_autoincrement,...) + */ + function setColumns($columns) + { + $this->columns = $columns; + } + + /** + * Set a data source + * @param string $dbsUid DBS_UID to relate the pmTable to phisical table + */ + function setDataSource($dbsUid) + { + $this->dataSource = $dbsUid; + + switch ($dbsUid) { + case 'workflow': case 'wf': case '0': case '': + $this->dbConfig->adapter= DB_ADAPTER; + $this->dbConfig->host = DB_HOST; + $this->dbConfig->name = DB_NAME; + $this->dbConfig->user = DB_USER; + $this->dbConfig->passwd = DB_PASS; + $this->dbConfig->port = 3306; //FIXME update this when port for workflow dsn will be available + break; + + case 'rp': case 'report': + $this->dbConfig->adapter= DB_ADAPTER; + $this->dbConfig->host = DB_REPORT_HOST; + $this->dbConfig->name = DB_REPORT_NAME; + $this->dbConfig->user = DB_REPORT_USER; + $this->dbConfig->passwd = DB_REPORT_PASS; + $this->dbConfig->port = 3306; //FIXME update this when port for rp dsn will be available + break; + + default: + require_once 'classes/model/DbSource.php'; + $dbSource = DbSource::load($dbsUid); + if (!is_object($dbSource)) { + throw new Exception("Db source with id $dbsUid does not exist!"); + } + + $this->dbConfig->adapter= $dbSource->getDbsType(); + $this->dbConfig->host = $dbSource->getDbsServer(); + $this->dbConfig->name = $dbSource->getDbsDatabaseName(); + $this->dbConfig->user = $dbSource->getDbsUsername(); + $this->dbConfig->passwd = $dbSource->getDbsPassword(); + $this->dbConfig->port = $dbSource->getDbsPort(); + } + } + + /** + * get Data base config object + * @return object containing dbConfig var + */ + public function getDbConfig() + { + return $this->dbConfig; + } + + /** + * Build the pmTable with all dependencies + */ + function build() + { + $this->prepare(); + $this->preparePropelIniFile(); + $this->buildSchema(); + $this->phingbuildModel(); + $this->phingbuildSql(); + $this->upgradeDatabase(); + } + + /** + * Prepare the pmTable env + */ + function prepare() + { + //prevent execute prepare() twice or more + if (is_object($this->dom)) { + return true; + } + + if ($this->dataSource == '' || $this->dataSource == 'wf' || !$this->dataSource) { + $this->dataSource = 'workflow'; + } + + $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); + + $this->dom = new DOMDocument('1.0', 'utf-8'); + $this->dom->preserveWhiteSpace = false; + $this->dom->formatOutput = true; + + if (file_exists($this->configDir . $this->schemaFilename)) { + if (@$this->dom->load($this->configDir . $this->schemaFilename) !== true) { + throw new Exception('Error: ' . $this->schemaFilename . ' is a invalid xml file!'); + } + $this->rootNode = $this->dom->firstChild; + } + else { + $this->rootNode = $this->dom->createElement('database'); + $this->rootNode->setAttribute('name', $this->dataSource); + $this->dom->appendChild($this->rootNode); + } + } + + /** + * Build the xml schema for propel + */ + function buildSchema() + { + $tableNode = $this->dom->createElement('table'); + $tableNode->setAttribute('name', $this->tableName); + + if ($this->hasAutoIncrementPKey()) { + $tableNode->setAttribute('idMethod', 'native'); + } + + foreach ($this->columns as $column) { + + // create the column node + $columnNode = $this->dom->createElement('column'); + // setting column node attributes + $columnNode->setAttribute('name', $column->field_name); + $columnNode->setAttribute('type', $column->field_type); + + if ($column->field_size != '' && $column->field_size != 0) { + $columnNode->setAttribute('size', $column->field_size); + } + + $columnNode->setAttribute('required', ($column->field_null? 'false' : 'true')); + + // only define the primaryKey attribute if it is defined + if ($column->field_key) { + $columnNode->setAttribute('primaryKey', "true"); + } + + // only define the autoIncrement attribute if it is defined + if ($column->field_autoincrement) { + $columnNode->setAttribute('autoIncrement', "true"); + } + $tableNode->appendChild($columnNode); + } + + $xpath = new DOMXPath($this->dom); + $xtable = $xpath->query('/database/table[@name="' . $this->tableName . '"]'); + + if ($xtable->length == 0) { //the table definition does not exist, then just append the new node + $this->rootNode->appendChild($tableNode); + } + else { // the table definition already exist, then replace the node + $replacedNode = $xtable->item(0); + $this->rootNode->replaceChild($tableNode, $replacedNode); + } + + // saving the xml result file + $this->saveSchema(); + } + + /** + * Remove the pmTable and all related objects, files and others + */ + public function remove() + { + $this->prepare(); + $this->removeFromSchema(); + $this->removeModelFiles(); + $this->dropTable(); + } + + /** + * Remove the target pmTable from schema of propel + */ + public function removeFromSchema() + { + $xpath = new DOMXPath($this->dom); + // locate the node + $xtable = $xpath->query('/database/table[@name="' . $this->tableName . '"]'); + if ($xtable->length == 0) { + return false; + } + + $this->rootNode->removeChild($xtable->item(0)); + // saving the xml result file + $this->saveSchema(); + } + + /** + * Remove the model related classes files + */ + public function removeModelFiles() + { + @unlink($this->classesDir . $this->className . '.php'); + @unlink($this->classesDir . $this->className . 'Peer.php'); + @unlink($this->classesDir . 'map' . PATH_SEP . $this->className . 'MapBuilder.php'); + @unlink($this->classesDir . 'om' . PATH_SEP . 'Base' . $this->className . '.php'); + @unlink($this->classesDir . 'om' . PATH_SEP . 'Base' . $this->className . 'Peer.php'); + } + + /** + * Drop the phisical table of target pmTable or any specified as parameter + */ + public function dropTable($table = null) + { + $table = isset($table) ? $table : $this->dataSource; + $con = Propel::getConnection(); + $stmt = $con->createStatement(); + + if (is_object($con)) { + $stmt->executeQuery("DROP TABLE {$this->tableName}"); + } + } + + /** + * Save the xml schema for propel + */ + public function saveSchema() + { + $this->dom->save($this->configDir . $this->schemaFilename); + } + + + /** + * Prepare and create if not exists the propel ini file + */ + public function preparePropelIniFile() + { + $adapter = $this->dbConfig->adapter; + + if (file_exists($this->configDir . "propel.$adapter.ini")) { + return true; + } + + if (!file_exists(PATH_CORE. PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini")) { + throw new Exception("Invalid or not supported engine '$adapter'!"); + } + + @copy(PATH_CORE. PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini", $this->configDir . "propel.$adapter.ini"); + } + + /** + * Upgrade the phisical database for the target pmTable + * It executes the schema.sql autogenerated by propel, but just execute the correspondent sentenses + * for the related table + * - this function is not executing other sentenses like 'SET FOREIGN_KEY_CHECKS = 0;' for mysql, and others + */ + public function upgradeDatabase() + { + $con = Propel::getConnection($this->dataSource); + $stmt = $con->createStatement(); + $lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql'); + $previous = NULL; + $queryStack = array(); + + foreach ($lines as $j => $line) { + $line = trim($line); // Remove comments from the script + + if (strpos($line, "--") === 0) { + $line = substr($line, 0, strpos($line, "--")); + } + + if (empty($line)) { + continue; + } + + if (strpos($line, "#") === 0) { + $line = substr($line, 0, strpos($line, "#")); + } + + if (empty($line)) { + continue; + } + + // Concatenate the previous line, if any, with the current + if ($previous) { + $line = $previous . " " . $line; + } + $previous = NULL; + + // If the current line doesnt end with ; then put this line together + // with the next one, thus supporting multi-line statements. + if (strrpos($line, ";") != strlen($line) - 1) { + $previous = $line; + continue; + } + + $line = substr($line, 0, strrpos($line, ";")); + + // just execute the drop and create table for target table nad not for others + if (stripos('CREATE TABLE') !== false || stripos('DROP TABLE') !== false) { + $isCreateForCurrentTable = preg_match('/CREATE\sTABLE\s[\'\"\`]{1}' . $this->tableName . '[\'\"\`]{1}/i', $line, $match); + if ($isCreateForCurrentTable) { + $queryStack['create'] = $line; + } + else { + $isDropForCurrentTable = preg_match('/DROP TABLE.*[\'\"\`]{1}' . $this->tableName . '[\'\"\`]{1}/i', $line, $match); + if ($isDropForCurrentTable) { + $queryStack['drop'] = $line; + } + } + } + + } + + if (isset($queryStack['create'])) { + // first at all we need to verify if we have a valid schema defined, + // so we verify that creating a dummy table + $swapQuery = str_replace($this->tableName, $this->tableName . '_TMP', $queryStack['create']); + + // if there is a problem with user defined table schema executeQuery() will throw a sql exception + $stmt->executeQuery($swapQuery); + + // if there was not problem above proceced deleting the dummy table and drop and create the target table + $stmt->executeQuery("DROP TABLE {$this->tableName}_TMP"); + if (!isset($queryStack['drop'])) { + $queryStack['drop'] = "DROP TABLE {$this->tableName}"; + } + if (!isset($queryStack['create'])) { + throw new Exception('A problem occurred resolving the schema to update for this table'); + } + $stmt->executeQuery($queryStack['drop']); + $stmt->executeQuery($queryStack['create']); + } + + + } + + /** + * Populate the report table with all case data + * @param string $sType + * @param string $sProcessUid + * @param string $sGrid + * @return number + */ + public function populateReportTable($sType = 'NORMAL', $sProcessUid = '', $sGrid = '') + { + require_once "classes/model/Application.php"; + + $con = Propel::getConnection($sConnection); + $stmt = $con->createStatement(); + if ($sType == 'GRID') { + $aAux = explode('-', $sGrid); + $sGrid = $aAux[0]; + } + + //select cases for this Process, ordered by APP_NUMBER + $criteria = new Criteria('workflow'); + $criteria->add(ApplicationPeer::PRO_UID, $sProcessUid); + $criteria->addAscendingOrderByColumn(ApplicationPeer::APP_NUMBER); + $dataset = ApplicationPeer::doSelectRS($criteria); + $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + + while ($dataset->next()) { + $row = $dataset->getRow(); + $aData = unserialize($aRow['APP_DATA']); + } + + return 0; + + + } + + /** + * verify if on the columns list was set a column as primary key + * @return boolean to affirm if was defined a column as pk. + */ + function hasAutoIncrementPKey() + { + foreach ($this->columns as $column) { + if ($column->field_autoincrement) { + return true; + } + } + + return false; + } + + /** + * + * @return array contains all supported columns types provided by propel + */ + function getPropelSupportedColumnTypes() + { + /** + * http://www.propelorm.org/wiki/Documentation/1.2/Schema + * [type = "BOOLEAN|TINYINT|SMALLINT|INTEGER|BIGINT|DOUBLE|FLOAT|REAL|DECIMAL|CHAR|{VARCHAR}|LONGVARCHAR|DATE|TIME|TIMESTAMP|BLOB|CLOB"] + */ + $types = array(); + + $types['BOOLEAN'] = 'BOOLEAN'; + $types['TINYINT'] = 'TINYINT'; + $types['SMALLINT'] = 'SMALLINT'; + $types['INTEGER'] = 'INTEGER'; + $types['BIGINT'] = 'BIGINT'; + $types['DOUBLE'] = 'DOUBLE'; + $types['FLOAT'] = 'FLOAT'; + $types['REAL'] = 'REAL'; + $types['DECIMAL'] = 'DECIMAL'; + $types['CHAR'] = 'CHAR'; + $types['VARCHAR'] = 'VARCHAR'; + $types['LONGVARCHAR'] = 'LONGVARCHAR'; + $types['DATE'] = 'DATE'; + $types['TIME'] = 'TIME'; + //$types['BLOB'] = 'BLOB'; <- disabled + //$types['CLOB'] = 'CLOB'; <- disabled + + return $types; + } + + /** + * @param string $name any string witha name separated by underscore + * @return string contains a camelcase expresion for $name + */ + public function toCamelCase($name) + { + $tmp = explode('_', trim($name)); + foreach ($tmp as $i => $part) { + $tmp[$i] = ucFirst(strtolower($part)); + } + return implode('', $tmp); + } + + /** + * Run om task for phing to build all mdoel classes + */ + public function phingbuildModel() + { + $this->_callPhing('om'); + } + + /** + * Run sql task for phing to generate the sql schema + */ + public function phingbuildSql() + { + $this->_callPhing('sql'); + } + + /** + * call phing to execute a determinated task + * @param string $taskName [om|sql] + */ + private function _callPhing($taskName) + { + $options = array( + 'project.dir' => $this->configDir, + 'build.properties' => "propel.{$this->dbConfig->adapter}.ini", + 'propel.targetPackage' => 'classes', + 'propel.output.dir' => $this->targetDir, + 'propel.php.dir' => $this->baseDir + ); + + self::callPhing(array($taskName), PATH_THIRDPARTY . 'propel-generator/build.xml', $options, false); + } + + /** + * @param string $target - task name to execute + * @param string $buildFile - build file path + * @param array $options - array options to override the options on .ini file + * @param bool $verbose - to show a verbose output + */ + public static function callPhing($target, $buildFile = '', $options = array(), $verbose = true) + { + $args = array(); + foreach ($options as $key => $value) { + $args[] = "-D$key=$value"; + } + + if ($buildFile) { + $args[] = '-f'; + $args[] = realpath($buildFile); + } + + if (!$verbose) { + $args[] = '-q'; + } + + if (is_array($target)) { + $args = array_merge($args, $target); + } + else { + $args[] = $target; + } + + if (DIRECTORY_SEPARATOR != '\\' && (function_exists('posix_isatty') && @posix_isatty(STDOUT))) { + $args[] = '-logger'; + $args[] = 'phing.listener.AnsiColorLogger'; + } + + Phing::startup(); + Phing::setProperty('phing.home', getenv('PHING_HOME')); + + $m = new pmPhing(); + $m->execute($args); + $m->runBuild(); + } + +} + +include_once 'phing/Phing.php'; +set_include_path(PATH_THIRDPARTY . 'propel-generator/classes/' . PATH_SEPARATOR . get_include_path()); + +if (!class_exists('Phing')) { + throw new Exception('Fatal Error: Phing is not loaded!'); +} + +class pmPhing extends Phing +{ + function getPhingVersion() + { + return 'pmPhing Ver 1.0'; + } +} diff --git a/workflow/engine/classes/model/AdditionalTables.php b/workflow/engine/classes/model/AdditionalTables.php index 91b439f74..f73b890b2 100644 --- a/workflow/engine/classes/model/AdditionalTables.php +++ b/workflow/engine/classes/model/AdditionalTables.php @@ -19,32 +19,6 @@ require_once 'classes/model/om/BaseAdditionalTables.php'; * @package workflow.engine.classes.model */ class AdditionalTables extends BaseAdditionalTables { - private $aDef = array( - 'mysql' => array( - 'TEXT' => 'TEXT', - 'CHAR' => 'CHAR', - 'VARCHAR' => 'VARCHAR', - 'INT' => 'INT', - 'FLOAT' => 'FLOAT', - 'DATE' => 'DATE' - ), - 'pgsql' => array( - 'TEXT' => 'TEXT', - 'CHAR' => 'CHAR', - 'VARCHAR' => 'VARCHAR', - 'INT' => 'INTEGER', - 'FLOAT' => 'REAL', - 'DATE' => 'DATE' - ), - 'mssql' => array( - 'TEXT' => 'TEXT', - 'CHAR' => 'NCHAR', - 'VARCHAR' => 'NVARCHAR', - 'INT' => 'INTEGER', - 'FLOAT' => 'FLOAT', - 'DATE' => 'CHAR (19)' - ) - ); /** * Function load @@ -223,23 +197,7 @@ class AdditionalTables extends BaseAdditionalTables { $oConnection->begin(); $iResult = $oAdditionalTables->delete(); $oConnection->commit(); - require_once 'classes/model/ShadowTable.php'; - if ($aAdditionalTables['ADD_TAB_SDW_AUTO_DELETE'] == 1) { - $oCriteria = new Criteria('workflow'); - $oCriteria->add(ShadowTablePeer::ADD_TAB_UID, $sUID); - ShadowTablePeer::doDelete($oCriteria); - } - else { - $oShadowTable = new ShadowTable(); - $oShadowTable->create(array( - 'ADD_TAB_UID' => $sUID, - 'SHD_ACTION' => 'DROP', - 'SHD_DETAILS' => '', - 'USR_UID' => (isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : ''), - 'APP_UID' => '', - 'SHD_DATE' => date('Y-m-d H:i:s')) - ); - } + return $iResult; } else { @@ -251,785 +209,24 @@ class AdditionalTables extends BaseAdditionalTables { throw($oError); } } - - function createTable($sTableName, $sConnection = '', $aFields = array()) { + + function deleteAll($id) + { + //deleting pm table + $additionalTable = AdditionalTables::load($id); + AdditionalTables::remove($id); - if ($sConnection == '' || $sConnection == 'wf') { - $sConnection = 'workflow'; - } - - try { - switch (DB_ADAPTER) { - case 'mysql': - - // trying to get a connection, if it doesn't exist Propel::getConnection() throws an exception - $con = Propel::getConnection($sConnection); - $stmt = $con->createStatement(); - - $sQuery = 'CREATE TABLE IF NOT EXISTS `' . $sTableName . '` ('; - $aPKs = array(); - foreach ($aFields as $aField) { - $aField['sFieldName'] = strtoupper($aField['sFieldName']); - switch ($aField['sType']) { - case 'VARCHAR': - $sQuery .= '`' . $aField['sFieldName'] . '` ' . $aField['sType'] . '(' . $aField['iSize'] . ')' . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " DEFAULT '',"; - break; - case 'TEXT': - $sQuery .= '`' . $aField['sFieldName'] . '` ' . $aField['sType'] . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " ,"; // " DEFAULT '',"; - break; - case 'DATE': - $sQuery .= '`' . $aField['sFieldName'] . '` ' . $aField['sType'] . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " ,"; // " DEFAULT '0000-00-00',"; - break; - case 'INT': - $sQuery .= '`' . $aField['sFieldName'] . '` ' . $aField['sType'] . '(' . $aField['iSize'] . ')' . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . ' ' . ($aField['bAI'] ? 'AUTO_INCREMENT' : "DEFAULT '0'") . ','; - if ($aField['bAI']) { - if (!in_array('`' . $aField['sFieldName'] . '`', $aPKs)) { - $aPKs[] = '`' . $aField['sFieldName'] . '`'; - } - } - break; - case 'FLOAT': - $sQuery .= '`' . $aField['sFieldName'] . '` ' . $aField['sType'] . '(' . $aField['iSize'] . ')' . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " DEFAULT '0',"; - break; - } - if ($aField['bPrimaryKey'] == 1) { - if (!in_array('`' . $aField['sFieldName'] . '`', $aPKs)) { - $aPKs[] = '`' . $aField['sFieldName'] . '`'; - } - } - } - $sQuery = substr($sQuery, 0, -1); - if (!empty($aPKs)) { - $sQuery .= ',PRIMARY KEY (' . implode(',', $aPKs) . ')'; - } - $sQuery .= ') DEFAULT CHARSET=utf8;'; - - $rs = $stmt->executeQuery('DROP TABLE IF EXISTS `' . $sTableName . '`'); - $rs = $stmt->executeQuery($sQuery); - break; - - case 'mysql2': - eval('$oConnection = @mysql_connect(' . $sDBHost . ', ' . $sDBUser . ', ' . $sDBPass . ');'); - if (!$oConnection) { - throw new Exception('Cannot connect to the server!'); - } - eval("if (!@mysql_select_db($sDBName)) { - throw new Exception('Cannot connect to the database ' . $sDBName . '!'); - }"); - $sQuery = 'CREATE TABLE IF NOT EXISTS `' . $sTableName . '` ('; - $aPKs = array(); - foreach ($aFields as $aField) { - $aField['sFieldName'] = strtoupper($aField['sFieldName']); - switch ($aField['sType']) { - case 'VARCHAR': - $sQuery .= '`' . $aField['sFieldName'] . '` ' . $aField['sType'] . '(' . $aField['iSize'] . ')' . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " DEFAULT '',"; - break; - case 'TEXT': - $sQuery .= '`' . $aField['sFieldName'] . '` ' . $aField['sType'] . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " ,"; // " DEFAULT '',"; - break; - case 'DATE': - $sQuery .= '`' . $aField['sFieldName'] . '` ' . $aField['sType'] . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " ,"; // " DEFAULT '0000-00-00',"; - break; - case 'INT': - $sQuery .= '`' . $aField['sFieldName'] . '` ' . $aField['sType'] . '(' . $aField['iSize'] . ')' . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . ' ' . ($aField['bAI'] ? 'AUTO_INCREMENT' : "DEFAULT '0'") . ','; - if ($aField['bAI']) { - if (!in_array('`' . $aField['sFieldName'] . '`', $aPKs)) { - $aPKs[] = '`' . $aField['sFieldName'] . '`'; - } - } - break; - case 'FLOAT': - $sQuery .= '`' . $aField['sFieldName'] . '` ' . $aField['sType'] . '(' . $aField['iSize'] . ')' . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " DEFAULT '0',"; - break; - } - if ($aField['bPrimaryKey'] == 1) { - if (!in_array('`' . $aField['sFieldName'] . '`', $aPKs)) { - $aPKs[] = '`' . $aField['sFieldName'] . '`'; - } - } - } - $sQuery = substr($sQuery, 0, -1); - if (!empty($aPKs)) { - $sQuery .= ',PRIMARY KEY (' . implode(',', $aPKs) . ')'; - } - $sQuery .= ') DEFAULT CHARSET=utf8;'; - if (!@mysql_query($sQuery)) { - throw new Exception('Cannot create the table "' . $sTableName . '"! ' . mysql_error() . ' SQL: ' . $sQuery); - } - break; - case 'mssql': - $sDBAdapter = DB_ADAPTER; - $sDBUser = DB_USER; - $sDBPass = DB_PASS; - $sDBHost = DB_HOST; // substr(DB_HOST, 0, strpos(DB_HOST,':')); - $sDBName = DB_NAME; - - $sDBHost = substr($sDBHost, 0, strpos($sDBHost,':')); - - $dsn = $sDBAdapter . '://' . $sDBUser . ':' . $sDBPass . '@' . $sDBHost . '/' . $sDBName; - - - $db =& DB::Connect( $dsn); - if (PEAR::isError($db)) { die($db->getMessage()); } - - $sQuery = 'CREATE TABLE ' . $sTableName . ' ('; - $aPKs = array(); - foreach ($aFields as $aField) { - switch ($aField['sType']) { - case 'VARCHAR': - $sQuery .= ' ' . $aField['sFieldName'] . ' ' . $aField['sType'] . '(' . $aField['iSize'] . ')' . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " DEFAULT '',"; - break; - case 'TEXT': - $sQuery .= ' ' . $aField['sFieldName'] . ' ' . $aField['sType'] . ' ,' ; ///-- " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " DEFAULT '',"; - break; - case 'DATE': - // In cases of incompatibility, use char(19) - $sQuery .= $aField['sFieldName'] . " char(19) " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " DEFAULT '0000-00-00',"; - break; - case 'INT': - $sQuery .= $aField['sFieldName'] . ' ' . $aField['sType'] . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . ' ' . ($aField['bAI'] ? 'AUTO_INCREMENT' : "DEFAULT '0'") . ','; - if ($aField['bAI']) { - if (!in_array(' ' . $aField['sFieldName'] . ' ', $aPKs)) { - $aPKs[] = ' ' . $aField['sFieldName'] . ' '; - } - } - break; - case 'FLOAT': - $sQuery .= ' ' . $aField['sFieldName'] . ' ' . $aField['sType'] . " " . ($aField['bNull'] ? 'NULL' : 'NOT NULL') . " DEFAULT '0',"; - break; - } - if ($aField['bPrimaryKey'] == 1) { - if (!in_array(' ' . $aField['sFieldName'] . ' ', $aPKs)) { - $aPKs[] = ' ' . $aField['sFieldName'] . ' '; - } - } - } - $sQuery = substr($sQuery, 0, -1); - if (!empty($aPKs)) { - $sQuery .= ',PRIMARY KEY (' . implode(',', $aPKs) . ')'; - } - $sQuery .= ') '; - $res = @$db->query($sQuery); - if (!$res) { - throw new Exception('Cannot create the table "' . $sTableName . '"!'); - } - - break; - - - } - } - catch (Exception $oError) { - throw($oError); - } - } - - function updateTable($sTableName, $sConnection = 'wf', $aNewFields = array(), $aOldFields = array()) { - $debug=false; - - if ($sConnection == '' || $sConnection == 'wf') { - $sConnection = 'workflow'; - } - try { - //$aKeys = array('PM_UNIQUE_ID'); - $aKeys = array(); - $aFieldsToAdd = array(); - $aFieldsToDelete = array(); - $aFieldsToAlter = array(); - - foreach ($aNewFields as $aNewField) { - $aNewField['FLD_NAME'] = strtoupper($aNewField['FLD_NAME']); - if (!isset($aOldFields[$aNewField['FLD_UID']])) { - $aFieldsToAdd[] = $aNewField; - } - - if ($aNewField['FLD_KEY'] == 1 || $aNewField['FLD_KEY'] === 'on' || $aNewField['FLD_AUTO_INCREMENT'] === 'on') { - if (!in_array($aNewField['FLD_NAME'], $aKeys)) { - $aKeys[] = $aNewField['FLD_NAME']; - } - } - - } - - foreach ($aOldFields as $aOldField) { - $aOldField['FLD_NAME'] = strtoupper($aOldField['FLD_NAME']); - if (!isset($aNewFields[$aOldField['FLD_UID']])) { - $aFieldsToDelete[] = $aOldField; - } - } - - if ($debug) { - echo 'new'; - print_r($aNewFields); - echo 'old'; - print_r($aOldFields); - echo 'to add'; - print_r($aFieldsToAdd); - echo 'keys'; - print_r($aKeys); - echo 'to delete'; - print_r($aFieldsToDelete); - } - - foreach ($aNewFields as $aNewField) { - if (isset($aOldFields[$aNewField['FLD_UID']])) { - $aOldField = $aOldFields[$aNewField['FLD_UID']]; - $bEqual = true; - - if (trim($aNewField['FLD_NAME']) != trim($aOldField['FLD_NAME'])) { - $bEqual = false; - } - if (trim($aNewField['FLD_TYPE']) != trim($aOldField['FLD_TYPE'])) { - $bEqual = false; - } - if (trim($aNewField['FLD_SIZE']) != trim($aOldField['FLD_SIZE'])) { - $bEqual = false; - } - if (trim($aNewField['FLD_NULL']) != trim($aOldField['FLD_NULL'])) { - $bEqual = false; - } - if (trim($aNewField['FLD_AUTO_INCREMENT']) != trim($aOldField['FLD_AUTO_INCREMENT'])) { - $bEqual = false; - } - if (trim($aNewField['FLD_KEY']) != trim($aOldField['FLD_KEY'])) { - $bEqual = false; - } - if (!$bEqual) { - $aNewField['FLD_NAME_OLD'] = $aOldFields[$aNewField['FLD_UID']]['FLD_NAME']; - $aFieldsToAlter[] = $aNewField; - } - } - - } - - if ($debug) { - echo 'to alter'; print_r($aFieldsToAlter); - } - - G::LoadSystem('database_' . strtolower(DB_ADAPTER)); - $oDataBase = new database(DB_ADAPTER, DB_HOST, DB_USER, DB_PASS, DB_NAME); - $oDataBase->iFetchType = MYSQL_NUM; - - //$oDataBase->executeQuery($oDataBase->generateDropPrimaryKeysSQL($sTableName)); - $con = Propel::getConnection($sConnection); - $stmt = $con->createStatement(); - - $sQuery = $oDataBase->generateDropPrimaryKeysSQL($sTableName); - if ($debug) { - echo 'sql drop pk'; - var_dump($sQuery); - } - try { - $rs = $stmt->executeQuery($sQuery); - } catch(PDOException $oException ) { - throw $oException; - } - - foreach ($aFieldsToDelete as $aFieldToDelete) { - //$oDataBase->executeQuery($oDataBase->generateDropColumnSQL($sTableName, strtoupper($aFieldToDelete['FLD_NAME']))); - $sQuery = $oDataBase->generateDropColumnSQL($sTableName, strtoupper($aFieldToDelete['FLD_NAME'])); - if ($debug) { - echo 'sql drop field'; - var_dump($sQuery); - } - $rs = $stmt->executeQuery($sQuery); - } - - foreach ($aFieldsToAdd as $aFieldToAdd) { - switch ($aFieldToAdd['FLD_TYPE']) { - case 'VARCHAR': - $aData = array( - 'Type' => 'VARCHAR(' . $aFieldToAdd['FLD_SIZE'] . ')', - 'Null' => ($aFieldToAdd['FLD_NULL'] == 1 || $aFieldToAdd['FLD_NULL'] === 'on' ? 'YES' : ''), - 'Default' => '' - ); - break; - case 'TEXT': - $aData = array( - 'Type' => 'TEXT', - 'Null' => ($aFieldToAdd['FLD_NULL'] == 1 || $aFieldToAdd['FLD_NULL'] === 'on' ? 'YES' : ''), - 'Default' => '' - ); - break; - case 'DATE': - $aData = array( - 'Type' => 'DATE', 'Null' => 'YES' - ); - // 'Null' => ($aFieldToAdd['FLD_NULL'] == 'on' ? 'YES' : ''), - // 'Default' => 'NULL'); // '0000-00-00'); - break; - case 'INT': - $aData = array( - 'Type' => 'INT(' . (int)$aFieldToAdd['FLD_SIZE'] . ')', - 'Null' => ($aFieldToAdd['FLD_NULL'] == 1 || $aFieldToAdd['FLD_NULL'] === 'on' ? 'YES' : ''), - 'Default' => '0', - 'AI' => ($aFieldToAdd['FLD_AUTO_INCREMENT'] == 1 || $aFieldToAdd['FLD_AUTO_INCREMENT'] === 'on' ? 1 : 0) - ); - break; - case 'FLOAT': - $aData = array( - 'Type' => 'FLOAT(' . (int)$aFieldToAdd['FLD_SIZE'] . ')', - 'Null' => ($aFieldToAdd['FLD_NULL'] == 1 || $aFieldToAdd['FLD_NULL'] == 'on' ? 'YES' : ''), - 'Default' => '0' - ); - break; - } - - //$oDataBase->executeQuery($oDataBase->generateAddColumnSQL($sTableName, strtoupper($aFieldToAdd['FLD_NAME']), $aData)); - $sQuery = $oDataBase->generateAddColumnSQL($sTableName, strtoupper($aFieldToAdd['FLD_NAME']), $aData); - if ($debug) { - echo 'sql add'; - var_dump($sQuery); - } - $rs = $stmt->executeQuery($sQuery); - } - - //$oDataBase->executeQuery($oDataBase->generateAddPrimaryKeysSQL($sTableName, $aKeys)); - $sQuery = $oDataBase->generateAddPrimaryKeysSQL($sTableName, $aKeys); - if ($debug) { - echo 'sql gen pk'; - var_dump($sQuery); - } - $rs = $stmt->executeQuery($sQuery); - - foreach ($aFieldsToAlter as $aFieldToAlter) { - switch ($aFieldToAlter['FLD_TYPE']) { - case 'VARCHAR': - $aData = array( - 'Type' => 'VARCHAR(' . $aFieldToAlter['FLD_SIZE'] . ')', - 'Null' => ($aFieldToAlter['FLD_NULL'] == 'on' ? 'YES' : ''), - 'Default' => '' - ); - break; - case 'TEXT': - $aData = array( - 'Type' => 'TEXT', - 'Null' => ($aFieldToAlter['FLD_NULL'] == 'on' ? 'YES' : ''), - 'Default' => '' - ); - break; - case 'DATE': - $aData = array( - 'Type' => 'DATE', 'Null' => 'YES' - ); - //'Null' => ($aFieldToAlter['FLD_NULL'] == 'on' ? 'YES' : ''), - //'Default' => 'NULL'); // '0000-00-00'); - break; - case 'INT': - $aData = array( - 'Type' => 'INT(' . (int)$aFieldToAlter['FLD_SIZE'] . ')', - 'Null' => ($aFieldToAlter['FLD_NULL'] == 'on' ? 'YES' : ''), - 'Default' => '0', - 'AI' => ($aFieldToAlter['FLD_AUTO_INCREMENT'] == 'on' ? 1 : 0) - ); - break; - case 'FLOAT': - $aData = array( - 'Type' => 'FLOAT(' . (int)$aFieldToAlter['FLD_SIZE'] . ')', - 'Null' => ($aFieldToAlter['FLD_NULL'] == 'on' ? 'YES' : ''), - 'Default' => '0' - ); - break; - } - //$oDataBase->executeQuery($oDataBase->generateChangeColumnSQL($sTableName, strtoupper($aFieldToAlter['FLD_NAME']), $aData, strtoupper($aFieldToAlter['FLD_NAME_OLD']))); - - $sQuery = $oDataBase->generateChangeColumnSQL($sTableName, strtoupper($aFieldToAlter['FLD_NAME']), $aData, strtoupper($aFieldToAlter['FLD_NAME_OLD'])); - if ($debug) { - echo 'sql alter'; - var_dump($sQuery); - } - $rs = $stmt->executeQuery($sQuery); - } - } - catch (Exception $oError) { - throw($oError); - } - } - - function createPropelClasses($sTableName, $sClassName, $aFields, $sAddTabUid, $connection='workflow') { - try { - /*$aUID = array('FLD_NAME' => 'PM_UNIQUE_ID', - 'FLD_TYPE' => 'INT', - 'FLD_SIZE' => '11', - 'FLD_KEY' => 'on', - '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']) : strtoupper($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); - } + //deleting fields + require_once 'classes/model/Fields.php'; + $criteria = new Criteria('workflow'); + $criteria->add(FieldsPeer::ADD_TAB_UID, $id); + FieldsPeer::doDelete($criteria); + + //remove all related to pmTable + G::loadClass('pmTable'); + $pmTable = new pmTable($additionalTable['ADD_TAB_NAME']); + $pmTable->setDataSource($additionalTable['DBS_UID']); + $pmTable->remove(); } function getPHPName($sName) { @@ -1048,116 +245,6 @@ class AdditionalTables extends BaseAdditionalTables { } } - function deleteAll($sUID) { - try { - //deleting pm table - $aData = $this->load($sUID); - $this->remove($sUID); - - //deleting fields - require_once 'classes/model/Fields.php'; - $oCriteria = new Criteria('workflow'); - $oCriteria->add(FieldsPeer::ADD_TAB_UID, $sUID); - FieldsPeer::doDelete($oCriteria); - - //deleting table - if ($aData['DBS_UID'] == 'wf' || $aData['DBS_UID'] == 'workflow' || $aData['DBS_UID'] == '' || $aData['DBS_UID'] == '0' || !$aData['DBS_UID']) { - G::LoadSystem('database_' . strtolower(DB_ADAPTER)); - $oDataBase = new database(DB_ADAPTER, DB_HOST, DB_USER, DB_PASS, DB_NAME); - $oDataBase->iFetchType = MYSQL_NUM; - $oDataBase->executeQuery($oDataBase->generateDropTableSQL($aData['ADD_TAB_NAME'])); - } else { - $con = Propel::getConnection($aData['DBS_UID']); - if (is_object($con)) { - $stmt = $con->createStatement(); - $stmt->executeQuery('DROP TABLE '.$aData['ADD_TAB_NAME']); - } - } - - - //deleting clases - $sClassName = $this->getPHPName($aData['ADD_TAB_CLASS_NAME'] != '' ? $aData['ADD_TAB_CLASS_NAME'] : $aData['ADD_TAB_NAME']); - $sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP; - - @unlink($sPath . $sClassName . '.php'); - @unlink($sPath . $sClassName . 'Peer.php'); - @unlink($sPath . 'map' . PATH_SEP . $sClassName . 'MapBuilder.php'); - @unlink($sPath . 'om' . PATH_SEP . 'Base' . $sClassName . '.php'); - @unlink($sPath . 'om' . PATH_SEP . 'Base' . $sClassName . 'Peer.php'); - } - catch (Exception $oError) { - throw($oError); - } - } - - function createXmlList($sUID) { - try { - $aData = $this->load($sUID, true); - $sPath = PATH_DYNAFORM . 'xmlLists' . PATH_SEP; - if (!file_exists($sPath)) { - G::mk_dir($sPath); - } - file_put_contents($sPath . 'additionalTablesDataOptions.xml', ' - - - - - - ' . G::LoadTranslation("ID_NEW") . ' - - - - ' . G::LoadTranslation("ID_IMPORT") . ' - - - - - - - -'); - $sKeys = ''; - $sXml = '' . "\n"; - $sXml .= '' . "\n". - ' - ' . G::LoadTranslation("ID_TABLE") . ': '.$aData['ADD_TAB_NAME'].']]> - '; - - //$sXml .= '' . "\n"; - foreach ($aData['FIELDS'] as $aField) { - - $fZise = $aField['FLD_SIZE'] > (1024/sizeof($aData['FIELDS'])) ? $aField['FLD_SIZE']: 1024/sizeof($aData['FIELDS']); - - - $sXml .= '<' . $aField['FLD_NAME'] . ' type="text" colWidth="'.$fZise.'px" titleAlign="left" align="left">' . "\n"; - $sXml .= '<' . SYS_LANG . '>' . ($aField['FLD_DESCRIPTION'] != '' ? $aField['FLD_DESCRIPTION'] : $aField['FLD_NAME']) . '' . "\n"; - $sXml .= '' . "\n"; - if ($aField['FLD_KEY'] == 1) { - $sKeys .= $aField['FLD_NAME'] . '=@#' . $aField['FLD_NAME'] . '&'; - } - } - $sKeys = substr($sKeys, 0, -5); - $sXml .= '' . "\n"; - $sXml .= '' . "\n"; - $sXml .= ''; - file_put_contents($sPath . $sUID . '.xml', $sXml); - } - catch (Exception $oError) { - throw($oError); - } - } - function getDataCriteria($sUID) { try { $aData = $this->load($sUID, true); @@ -1265,53 +352,6 @@ var additionalTablesDataDelete = function(sUID, sKeys) { } } - - function createXmlEdit($sUID, $bEnableKeys) { - try { - $aData = $this->load($sUID, true); - $sPath = PATH_DYNAFORM . 'xmlLists' . PATH_SEP; - $sXml = '' . "\n"; - $sXml .= ''; - //$sXml .= ''; - $sXml .= ''; - foreach ($aData['FIELDS'] as $aField) { - switch ($aField['FLD_TYPE']) { - case 'VARCHAR': - if( intVal($aField['FLD_SIZE']) <= 100){ - $vCharType = 'text'; - $vCharAtt = 'size="' . $aField['FLD_SIZE'] . '" maxlength="' . $aField['FLD_SIZE'] . '" validate="Any"'; - } else { - $vCharType = 'textarea'; - $vCharAtt = 'rows="3" cols="90"'; - } - $sXml .= '<' . $aField['FLD_NAME'] . ' type="'.$vCharType.'" '. $vCharAtt .' required="' . (($aField['FLD_KEY'] == 1) && ($aField['FLD_AUTO_INCREMENT'] == 0) || ($aField['FLD_NULL'] == 0) ? '1' : '0') . '" readonly="0" mode="' . ($bEnableKeys ? 'edit' : ($aField['FLD_KEY'] == 1 ? 'view' : 'edit')) . '"><' . SYS_LANG . '>' . ($aField['FLD_DESCRIPTION'] != '' ? $aField['FLD_DESCRIPTION'] : $aField['FLD_NAME']) . '</' . SYS_LANG . '></' . $aField['FLD_NAME'] . '>'; - break; - case 'TEXT': - $sXml .= '<' . $aField['FLD_NAME'] . ' type="textarea" required="' . (($aField['FLD_KEY'] == 1) && ($aField['FLD_AUTO_INCREMENT'] == 0) || ($aField['FLD_NULL'] == 0) ? '1' : '0') . '" readonly="0" rows="8" cols="90" mode="' . ($bEnableKeys ? 'edit' : ($aField['FLD_KEY'] == 1 ? 'view' : 'edit')) . '"><' . SYS_LANG . '>' . ($aField['FLD_DESCRIPTION'] != '' ? $aField['FLD_DESCRIPTION'] : $aField['FLD_NAME']) . '</' . SYS_LANG . '></' . $aField['FLD_NAME'] . '>'; - break; - case 'DATE': - $sXml .= '<' . $aField['FLD_NAME'] . ' type="date" beforedate="-15y" afterdate="15y" mask="Y-m-d" required="' . ((($aField['FLD_KEY'] == 1) && ($aField['FLD_AUTO_INCREMENT'] == 0) || ($aField['FLD_NULL'] == 0) ) ? '1' : '0') . '" readonly="0" size="15" mode="' . ($bEnableKeys ? 'edit' : ($aField['FLD_KEY'] == 1 ? 'view' : 'edit')) . '"><' . SYS_LANG . '>' . ($aField['FLD_DESCRIPTION'] != '' ? $aField['FLD_DESCRIPTION'] : $aField['FLD_NAME']) . '</' . SYS_LANG . '></' . $aField['FLD_NAME'] . '>'; - break; - case 'INT': - $sXml .= '<' . $aField['FLD_NAME'] . ' type="text" maxlength="' . $aField['FLD_SIZE'] . '" validate="Int" required="' . (($aField['FLD_KEY'] == 1) && ($aField['FLD_AUTO_INCREMENT'] == 0) || ($aField['FLD_NULL'] == 0) ? '1' : '0') . '" readonly="0" size="' .($aField['FLD_SIZE']<=100?$aField['FLD_SIZE']:100). '" mode="' . ($bEnableKeys ? 'edit' : ($aField['FLD_KEY'] == 1 ? 'view' : 'edit')) . '"><' . SYS_LANG . '>' . ($aField['FLD_DESCRIPTION'] != '' ? $aField['FLD_DESCRIPTION'] : $aField['FLD_NAME']) . '</' . SYS_LANG . '></' . $aField['FLD_NAME'] . '>'; - break; - case 'FLOAT': - $sXml .= '<' . $aField['FLD_NAME'] . ' type="text" maxlength="' . $aField['FLD_SIZE'] . '" validate="Real" required="' . (($aField['FLD_KEY'] == 1) && ($aField['FLD_AUTO_INCREMENT'] == 0) || ($aField['FLD_NULL'] == 0) ? '1' : '0') . '" readonly="0" size="' . ($aField['FLD_SIZE']<=100?$aField['FLD_SIZE']:100) . '" mode="' . ($bEnableKeys ? 'edit' : ($aField['FLD_KEY'] == 1 ? 'view' : 'edit')) . '"><' . SYS_LANG . '>' . ($aField['FLD_DESCRIPTION'] != '' ? $aField['FLD_DESCRIPTION'] : $aField['FLD_NAME']) . '</' . SYS_LANG . '></' . $aField['FLD_NAME'] . '>'; - break; - } - } - $sXml .= '<btnSave type="submit"><' . SYS_LANG . '>' . G::LoadTranslation('ID_SAVE_CHANGES') . '</' . SYS_LANG . '></btnSave>'; - $sXml .= '<btnBack type="button" onclick="history.back()"><' . SYS_LANG . '>' . G::LoadTranslation('ID_CANCEL') . '</' . SYS_LANG . '></btnBack>'; - $sXml .= '</dynaForm>'; -// g::pr($aField); -// g::pr($sXml); die; - file_put_contents($sPath . $sUID . 'Edit.xml', $sXml); - } - catch (Exception $oError) { - throw($oError); - } - } - function saveDataInTable($sUID, $aFields) { try { $aData = $this->load($sUID, true); diff --git a/workflow/engine/classes/model/DbSource.php b/workflow/engine/classes/model/DbSource.php index 9d74d9e5d..062ccdd1b 100644 --- a/workflow/engine/classes/model/DbSource.php +++ b/workflow/engine/classes/model/DbSource.php @@ -84,7 +84,7 @@ class DbSource extends BaseDbSource return $oCriteria; } - public function load($Uid, $ProUID) + public function load($Uid, $ProUID='') { try { $oRow = DbSourcePeer::retrieveByPK($Uid, $ProUID); diff --git a/workflow/engine/classes/model/map/FieldsMapBuilder.php b/workflow/engine/classes/model/map/FieldsMapBuilder.php index 971c3cfeb..d88f2416b 100644 --- a/workflow/engine/classes/model/map/FieldsMapBuilder.php +++ b/workflow/engine/classes/model/map/FieldsMapBuilder.php @@ -74,9 +74,9 @@ class FieldsMapBuilder { $tMap->addColumn('FLD_DESCRIPTION', 'FldDescription', 'string', CreoleTypes::LONGVARCHAR, true, null); - $tMap->addColumn('FLD_TYPE', 'FldType', 'string', CreoleTypes::VARCHAR, true, 10); + $tMap->addColumn('FLD_TYPE', 'FldType', 'string', CreoleTypes::VARCHAR, true, 20); - $tMap->addColumn('FLD_SIZE', 'FldSize', 'int', CreoleTypes::INTEGER, true, null); + $tMap->addColumn('FLD_SIZE', 'FldSize', 'int', CreoleTypes::INTEGER, false, null); $tMap->addColumn('FLD_NULL', 'FldNull', 'int', CreoleTypes::TINYINT, true, null); diff --git a/workflow/engine/classes/model/om/BaseFields.php b/workflow/engine/classes/model/om/BaseFields.php index ca85224d4..33c94e498 100644 --- a/workflow/engine/classes/model/om/BaseFields.php +++ b/workflow/engine/classes/model/om/BaseFields.php @@ -74,7 +74,7 @@ abstract class BaseFields extends BaseObject implements Persistent { * The value for the fld_size field. * @var int */ - protected $fld_size = 1; + protected $fld_size = 0; /** @@ -458,7 +458,7 @@ abstract class BaseFields extends BaseObject implements Persistent { $v = (int) $v; } - if ($this->fld_size !== $v || $v === 1) { + if ($this->fld_size !== $v || $v === 0) { $this->fld_size = $v; $this->modifiedColumns[] = FieldsPeer::FLD_SIZE; } diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml index e9c2d50f6..694076867 100644 --- a/workflow/engine/config/schema.xml +++ b/workflow/engine/config/schema.xml @@ -2080,8 +2080,8 @@ <column name="FLD_INDEX" type="INTEGER" required="true" default="1"/> <column name="FLD_NAME" type="VARCHAR" size="60" required="true" default=""/> <column name="FLD_DESCRIPTION" type="LONGVARCHAR" required="true"/> - <column name="FLD_TYPE" type="VARCHAR" size="10" required="true" default=""/> - <column name="FLD_SIZE" type="INTEGER" required="true" default="1"/> + <column name="FLD_TYPE" type="VARCHAR" size="20" required="true" default=""/> + <column name="FLD_SIZE" type="INTEGER" required="false" default="0"/> <column name="FLD_NULL" type="TINYINT" required="true" default="1"/> <column name="FLD_AUTO_INCREMENT" type="TINYINT" required="true" default="0"/> <column name="FLD_KEY" type="TINYINT" required="true" default="0"/> diff --git a/workflow/engine/controllers/pmTables.php b/workflow/engine/controllers/pmTables.php index ed3df8201..890490fa6 100644 --- a/workflow/engine/controllers/pmTables.php +++ b/workflow/engine/controllers/pmTables.php @@ -57,40 +57,50 @@ class pmTables extends Controller public function edit($httpData) { require_once PATH_CONTROLLERS . 'pmTablesProxy.php'; - $addTabUid = isset($httpData->id) ? $httpData->id : false; - $table = false; - $repTabPluginPermissions = false; - $additionalTables = new AdditionalTables(); + require_once 'classes/model/AdditionalTables.php'; + G::loadClass('pmTable'); - if ($addTabUid !== false) { // if is a edit request - require_once 'classes/model/AdditionalTables.php'; + $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 - switch ($table['ADD_TAB_TYPE']) { - case 'NORMAL': - case 'GRID': + if ($table['ADD_TAB_TYPE'] == 'NORMAL' || $table['ADD_TAB_TYPE'] == 'GRID') { $repTabPluginPermissions = $this->_getSimpleReportPluginDef(); - break; } } - $jsFile = isset($httpData->tableType) && $httpData->tableType == 'report' ? 'editReport' : 'edit'; - - $this->includeExtJS('pmTables/' . $jsFile, $this->debug); - - //fix for backware compatibility - if ($table) { - $table['DBS_UID'] = $table['DBS_UID'] == null || $table['DBS_UID'] == '' ? 'workflow': $table['DBS_UID']; - } + $this->includeExtJS('pmTables/' . $jsFile); $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); G::RenderPage('publish', 'extJs'); @@ -108,6 +118,7 @@ class pmTables extends Controller $this->includeExtJS('pmTables/data', $this->debug); $this->setJSVar('tableDef', $tableDef); + //g::pr($tableDef['FIELDS']); G::RenderPage('publish', 'extJs'); } diff --git a/workflow/engine/controllers/pmTablesProxy.php b/workflow/engine/controllers/pmTablesProxy.php index 5f0a857ed..1c5c3ea22 100644 --- a/workflow/engine/controllers/pmTablesProxy.php +++ b/workflow/engine/controllers/pmTablesProxy.php @@ -178,7 +178,7 @@ class pmTablesProxy extends HttpProxyController * save pm table */ public function save() - { + { require_once 'classes/model/AdditionalTables.php'; require_once 'classes/model/Fields.php'; try { @@ -186,25 +186,53 @@ class pmTablesProxy extends HttpProxyController $data['PRO_UID'] = trim($data['PRO_UID']); $data['columns'] = G::json_decode($_POST['columns']); //decofing data columns $isReportTable = $data['PRO_UID'] != '' ? true : false; - - // Reserved Words - $aReservedWords = array( - 'ALTER', 'CLOSE', 'COMMIT', 'CREATE', 'DECLARE', - 'DELETE', 'DROP', 'FETCH', 'FUNCTION', 'GRANT', - 'INDEX', 'INSERT', 'OPEN', 'REVOKE', 'ROLLBACK', - 'SELECT', 'SYNONYM', 'TABLE', 'UPDATE', 'VIEW', - 'APP_UID', 'ROW' - ); - $oAdditionalTables = new AdditionalTables(); $oFields = new Fields(); + $repTabClassName = $oAdditionalTables->getPHPName($data['REP_TAB_NAME']); + $columns = $data['columns']; + + // Reserved Words + $reservedWords = array( + 'ALTER', 'CLOSE', 'COMMIT', 'CREATE', 'DECLARE', 'DELETE', 'DROP', 'FETCH', 'FUNCTION', 'GRANT', + 'INDEX', 'INSERT', 'OPEN', 'REVOKE', 'ROLLBACK', 'SELECT', 'SYNONYM', 'TABLE', 'UPDATE', 'VIEW', 'APP_UID', 'ROW' + ); // verify if exists. - $aNameTable = $oAdditionalTables->loadByName($data['REP_TAB_NAME']); + if ($data['REP_TAB_UID'] == '') { //new report table + if ($isReportTable) { //setting default columns + $defaultColumns = $this->_getReportTableDefaultColumns($data['REP_TAB_TYPE']); + $columns = array_merge($defaultColumns, $columns); + } + + /** validations **/ + if(is_array($oAdditionalTables->loadByName($data['REP_TAB_NAME']))) { + throw new Exception('The table "' . $data['REP_TAB_NAME'] . '" already exits.'); + } - $repTabClassName = $oAdditionalTables->getPHPName($data['REP_TAB_NAME']); + if (in_array(strtoupper($data['REP_TAB_NAME']), $reservedWords) ) { + throw new Exception('Could not create the table with the name "' . $data['REP_TAB_NAME'] . '" because it is a reserved word.'); + } + } + + //backward compatility + foreach ($columns as $i => $column) { + switch ($column->field_type) { + case 'INT': $columns[$i]->field_type = 'INTEGER'; break; + case 'TEXT': $columns[$i]->field_type = 'LONGVARCHAR'; break; + } + } - $repTabData = array( + G::loadClass('pmTable'); + ob_start(); + $pmTable = new pmTable($data['REP_TAB_NAME']); + $pmTable->setDataSource($data['REP_TAB_CONNECTION']); + $pmTable->setColumns($columns); + $pmTable->build(); + $buildResult = ob_get_contents(); + ob_end_clean(); + + // Updating additional table struture information + $addTabData = array( 'ADD_TAB_UID' => $data['REP_TAB_UID'], 'ADD_TAB_NAME' => $data['REP_TAB_NAME'], 'ADD_TAB_CLASS_NAME' => $repTabClassName, @@ -215,60 +243,22 @@ class pmTablesProxy extends HttpProxyController 'ADD_TAB_TYPE' => $data['REP_TAB_TYPE'], 'ADD_TAB_GRID' => $data['REP_TAB_GRID'] ); - - $columns = $data['columns']; - if ($data['REP_TAB_UID'] == '') { //new report table - - if ($isReportTable) { //setting default columns - $defaultColumns = $this->_getReportTableDefaultColumns($data['REP_TAB_TYPE']); - $columns = array_merge($defaultColumns, $columns); - } - - /** validations **/ - if(is_array($aNameTable)) { - throw new Exception('The table "' . $data['REP_TAB_NAME'] . '" already exits.'); - } - - if (in_array(strtoupper($data['REP_TAB_NAME']), $aReservedWords) ) { - throw new Exception('Could not create the table with the name "' . $data['REP_TAB_NAME'] . '" because it is a reserved word.'); - } //create record - $addTabUid = $oAdditionalTables->create($repTabData); - + $addTabUid = $oAdditionalTables->create($addTabData); } else { //editing report table - $addTabUid = $data['REP_TAB_UID']; - //loading old data before update - $addTabBeforeData = $oAdditionalTables->load($addTabUid, true); //updating record - $oAdditionalTables->update($repTabData); + $addTabUid = $data['REP_TAB_UID']; + $oAdditionalTables->update($addTabData); //removing old data fields references $oCriteria = new Criteria('workflow'); $oCriteria->add(FieldsPeer::ADD_TAB_UID, $data['REP_TAB_UID']); - //$oCriteria->add(FieldsPeer::FLD_NAME, 'APP_UID', Criteria::NOT_EQUAL); - //$oCriteria->add(FieldsPeer::FLD_NAME, 'ROW', Criteria::NOT_EQUAL); FieldsPeer::doDelete($oCriteria); - - //getting old fieldnames - $oldFields = array(); - foreach ($addTabBeforeData['FIELDS'] as $field) { - $oldFields[$field['FLD_UID']] = $field; - } } - - $aFields = array(); - $fieldsList = array(); - $editFieldsList = array(); - + + // Updating pmtable fields foreach ($columns as $i => $column) { - //new feature, to reorder the columns - // if (isset($oldFields[$column->uid])) { // the the field alreaday exists - // if ($oldFields[$column->uid]['FLD_INDEX'] != $i) { // if its index has changed - // $column->uid = ''; //set as new field, - // } - // } - $field = array( 'FLD_UID' => $column->uid, 'FLD_INDEX' => $i, @@ -276,50 +266,40 @@ class pmTablesProxy extends HttpProxyController 'FLD_NAME' => $column->field_name, 'FLD_DESCRIPTION' => $column->field_label, 'FLD_TYPE' => $column->field_type, - 'FLD_SIZE' => $column->field_size, - 'FLD_NULL' => (isset($column->field_null) && $column->field_null ? 1 : 0), - 'FLD_AUTO_INCREMENT' => (isset($column->field_bai) && $column->field_bai ? 1 : 0), - 'FLD_KEY' => (isset($column->field_key) && $column->field_key ? 1 : 0), + 'FLD_SIZE' => $column->field_size=='' ? NULL : $column->field_size, + 'FLD_NULL' => $column->field_null ? 1 : 0, + 'FLD_AUTO_INCREMENT' => $column->field_autoincrement ? 1 : 0, + 'FLD_KEY' => $column->field_key ? 1 : 0, 'FLD_FOREIGN_KEY' => 0, 'FLD_FOREIGN_KEY_TABLE' => '', 'FLD_DYN_NAME' => $column->field_dyn, 'FLD_DYN_UID' => $column->field_uid, - 'FLD_FILTER' => (isset($column->field_filter) && $column->field_filter ? 1 : 0) + 'FLD_FILTER' => (isset($column->field_filter) && $column->field_filter) ? 1 : 0 ); - - $fieldUid = $oFields->create($field); - $fieldsList[] = $field; - - if($data['REP_TAB_UID'] == '') { //new - $aFields[] = array( - 'sType' => $column->field_type, - 'iSize' => $column->field_size, - 'sFieldName' => $column->field_name, - 'bNull' => (isset($column->field_null) ? $column->field_null : 1), - 'bAI' => (isset($column->field_bai) ? $column->field_bai : 0), - 'bPrimaryKey' => (isset($column->field_key) ? $column->field_key : 0) - ); - } else { //editing - $field['FLD_UID'] = $fieldUid; - $aFields[$fieldUid] = $field; - } - } - if ($data['REP_TAB_UID'] == '') { //create a new report table - $oAdditionalTables->createTable($data['REP_TAB_NAME'], $data['REP_TAB_CONNECTION'], $aFields); - - } else { //editing - //print_R($aFields); - $oAdditionalTables->updateTable($data['REP_TAB_NAME'], $data['REP_TAB_CONNECTION'], $aFields, $oldFields); - } - $oAdditionalTables->createPropelClasses($data['REP_TAB_NAME'], '', $fieldsList, $addTabUid, $data['REP_TAB_CONNECTION']); - if ($isReportTable) { - $oAdditionalTables->populateReportTable($data['REP_TAB_NAME'], $data['REP_TAB_CONNECTION'], $data['REP_TAB_TYPE'], $fieldsList, $data['PRO_UID'], $data['REP_TAB_GRID']); + $oFields->create($field); } + + // if ($isReportTable) { + // $oAdditionalTables->populateReportTable($data['REP_TAB_NAME'], $data['REP_TAB_CONNECTION'], $data['REP_TAB_TYPE'], $fieldsList, $data['PRO_UID'], $data['REP_TAB_GRID']); + // } $result->success = true; + $result->msg = $buildResult; } catch (Exception $e) { + $buildResult = ob_get_contents(); + ob_end_clean(); $result->success = false; - $result->msg = $e->getMessage(); + + // if it is a propel exception message + if (preg_match('/(.*)\s\[(.*):\s(.*)\]\s\[(.*):\s(.*)\]/', $e->getMessage(), $match)) { + $result->msg = $match[3]; + $result->type = ucfirst($pmTable->getDbConfig()->adapter); + } + else { + $result->msg = $e->getMessage(); + $result->type = G::loadTranslation('ID_EXCEPTION'); + } + $result->trace = $e->getTraceAsString(); } @@ -332,16 +312,16 @@ class pmTablesProxy extends HttpProxyController */ public function delete($httpData) { - G::LoadClass('reportTables'); $rows = G::json_decode(stripslashes($httpData->rows)); - $rp = new reportTables(); - $at = new AdditionalTables(); try { foreach ($rows as $row ) { if($row->type == 'CLASSIC') { + G::LoadClass('reportTables'); + $rp = new reportTables(); $rp->deleteReportTable($row->id); } else { + $at = new AdditionalTables(); $at->deleteAll($row->id); } } @@ -415,7 +395,8 @@ class pmTablesProxy extends HttpProxyController throw new Exception("ERROR: $className class file doesn't exit!"); } - require_once $sPath . $this->className . '.php'; + //require_once $sPath . $this->className . '.php'; + require_once 'classes/' . $this->className . '.php'; $toSave = false; if (is_array($rows)) { //multiple @@ -1043,6 +1024,7 @@ class pmTablesProxy extends HttpProxyController $application->field_key = 1; $application->field_null = 0; $application->field_filter = false; + $application->field_autoincrement = false; array_push($defaultColumns, $application); $application = new stdClass(); //APP_NUMBER @@ -1051,12 +1033,13 @@ class pmTablesProxy extends HttpProxyController $application->field_uid = ''; $application->field_name = 'APP_NUMBER'; $application->field_label = 'APP_NUMBER'; - $application->field_type = 'INT'; + $application->field_type = 'INTEGER'; $application->field_size = 11; $application->field_dyn = ''; $application->field_key = 0; $application->field_null = 0; $application->field_filter = false; + $application->field_autoincrement = false; array_push($defaultColumns, $application); //if it is a grid report table @@ -1067,12 +1050,13 @@ class pmTablesProxy extends HttpProxyController $gridIndex->field_uid = ''; $gridIndex->field_name = 'ROW'; $gridIndex->field_label = 'ROW'; - $gridIndex->field_type = 'INT'; + $gridIndex->field_type = 'INTEGER'; $gridIndex->field_size = '11'; $gridIndex->field_dyn = ''; $gridIndex->field_key = 1; $gridIndex->field_null = 0; $gridIndex->field_filter = false; + $application->field_autoincrement = false; array_push($defaultColumns, $gridIndex); } diff --git a/workflow/engine/methods/additionalTables/additionalTablesAjax.php b/workflow/engine/methods/additionalTables/additionalTablesAjax.php deleted file mode 100644 index 103d14c0f..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesAjax.php +++ /dev/null @@ -1,290 +0,0 @@ -<?php -/** - * additionalTablesAjax.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -if(isset($_POST['action'])) { - switch ($_POST['action']) { - case 'tableExists': - G::LoadSystem('database_' . strtolower(DB_ADAPTER)); - $oDataBase = new database(DB_ADAPTER, DB_HOST, DB_USER, DB_PASS, DB_NAME); - $oDataBase->iFetchType = MYSQL_NUM; - $oDataset = $oDataBase->executeQuery($oDataBase->generateShowTablesLikeSQL($_POST['sTableName'])); - echo $oDataBase->countResults($oDataset); - break; - case 'classExists': - $sClassName = strtolower(trim($_POST['sClassName'])); - $aDirectories = array(); - $aClasses = array(); - $aDirectories[] = PATH_GULLIVER; - $aDirectories[] = PATH_THIRDPARTY; - $aDirectories[] = PATH_RBAC; - $aDirectories[] = PATH_CORE . 'classes' . PATH_SEP; - foreach ($aDirectories as $sDirectory) { - includeClasses($sDirectory, $aClasses, true); - } - echo (int)class_exists($sClassName); - break; - - case 'exportexporView': - global $G_PUBLISH; - require_once ( 'classes/class.xmlfield_InputPM.php' ); - require_once 'classes/model/AdditionalTables.php'; - - $G_PUBLISH = new Publisher(); - - $oCriteria = new Criteria('workflow'); - $oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UID); - $oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_NAME); - $oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_DESCRIPTION); - $oCriteria->add(AdditionalTablesPeer::ADD_TAB_UID, '', Criteria::NOT_EQUAL); - - $G_PUBLISH->AddContent('propeltable', 'additionalTables/paged-table', 'additionalTables/additionalTablesExportList', $oCriteria); - G::RenderPage('publish', 'raw'); - break; - case 'updatePageSize': - G::LoadClass('configuration'); - $c = new Configurations(); - $arr['pageSize'] = $_REQUEST['size']; - $arr['dateSave'] = date('Y-m-d H:i:s'); - $config = Array(); - $config[] = $arr; - $c->aConfig = $config; - $c->saveConfig('additionalTablesList', 'pageSize','',$_SESSION['USER_LOGGED']); - echo '{success: true}'; - break; - case 'updatePageSizeData': - G::LoadClass('configuration'); - $c = new Configurations(); - $arr['pageSize'] = $_REQUEST['size']; - $arr['dateSave'] = date('Y-m-d H:i:s'); - $config = Array(); - $config[] = $arr; - $c->aConfig = $config; - $c->saveConfig('additionalTablesData', 'pageSize','',$_SESSION['USER_LOGGED']); - echo '{success: true}'; - break; - - case 'doExport': - # @Author: Erik Amaru Ortiz <aortiz.erik@gmail.com> - - require_once 'classes/model/AdditionalTables.php'; - - $tables = explode(',', $_POST['tables']); - $schema = explode(',', $_POST['schema']); - $data = explode(',', $_POST['data']); - - 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 ($tables as $uid) { - - $aTable = new additionalTables(); - $tRecord = $aTable->load($uid); - $oAdditionalTables = new additionalTables(); - $table = $oAdditionalTables->getAllData($uid); - - $rows = $table['rows']; - $count = $table['count']; - - array_push($EXPORT_TRACEBACK, Array( - 'uid' => $uid, - 'name' => $tRecord['ADD_TAB_NAME'], - 'num_regs' => sizeof($rows), - 'schema' => in_array($uid, $schema)? 'yes': 'no', - 'data' => in_array($uid, $data)? 'yes': 'no' -// 'schema' => ($schema[$c]=='Export')? 'yes': 'no', -// 'data' => ($data[$c]=='Export')? 'yes': 'no' - )); - } - - $sTrace = "TABLE UID\t\t\t\tTABLE 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 = 'SYS-'.strtoupper(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($EXPORT_TRACEBACK as $record){ - - if($record['schema'] == 'yes'){ - $oAdditionalTables = new AdditionalTables(); - $aData = $oAdditionalTables->load($record['uid'], true); - - $bufferType = '@SCHEMA'; - $SDATA = serialize($aData); - $fsUid = sprintf("%09d", strlen($record['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, $record['uid'] ); //writing the xmlfile - $bytesSaved += fwrite($fp, $fsData); //writing the size of xml file - $bytesSaved += fwrite($fp, $SDATA); //writing the xmlfile - } - - if($record['data'] == 'yes'){ - //export data - $oAdditionalTables = new additionalTables(); - $table = $oAdditionalTables->getAllData($uid); - - $rows = $table['rows']; - $count = $table['count']; - - $bufferType = '@DATA'; - $SDATA = serialize($rows); - $fsUid = sprintf("%09d", strlen($record['name'])); - $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, $record['name'] ); //writing the xmlfile - $bytesSaved += fwrite($fp, $fsData); //writing the size of xml file - $bytesSaved += fwrite($fp, $SDATA); //writing the xmlfile - - } - } - - fclose ($fp); - - $filenameLink = "../additionalTables/doExport?f={$filenameOnly}"; - $aFields['SIZE'] = round(($bytesSaved/1024), 2)." Kb"; - $aFields['META'] = "<pre>".$META."</pre>"; - $aFields['FILENAME'] = $filenameOnly; - $aFields['FILENAME_LINK'] = $filenameLink; - - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'additionalTables/doExport', '', $aFields, ''); - G::RenderPage('publish', 'raw'); - - break; - - } - -} - -if(isset($_POST['function'])) { - $sfunction = $_POST['function']; - switch($sfunction) { - case 'existClass' : - $result = ''; - require_once 'classes/model/AdditionalTables.php'; - $tables = explode(',', $_POST['tables']); - $schema = explode(',', $_POST['schema']); - $data = explode(',', $_POST['data']); - - G::LoadCLass('net'); - $net = new NET(G::getIpAddress()); - G::LoadClass("system"); - $EXPORT_TRACEBACK = Array(); - foreach ($tables as $uid) { - $aTable = new additionalTables(); - $tRecord = $aTable->load($uid); - $oAdditionalTables = new additionalTables(); - $ocaux = $oAdditionalTables->checkClassNotExist($uid); - if($ocaux == null ){ - $result = $result . ' <br> ' . $tRecord['ADD_TAB_NAME']; - } - } - return print $result; - break; - } -} - -function includeClasses($sDirectory, &$aClasses, $bRecursive = false) { - $aClassesFilter = array('class.filterForm.php', - 'class.dvEditor.php', - 'class.htmlArea.php', - 'class.database_base.php', - 'class.error.php', - 'class.xmlMenu.php', - 'class.form.php', - 'class.xmlform.php', - 'class.xmlformExtension.php', - 'pakeFileTask.class.php', - 'class.groupUser.php', - 'class.xmlfield_InputPM.php', - 'class.dynaFormField.php', - 'class.toolBar.php'); - $oDirectory = dir($sDirectory); - while ($sObject = $oDirectory->read()) { - if (!in_array($sObject, array('.', '..'))) { - if (is_dir($sDirectory . PATH_SEP . $sObject)) { - if ($bRecursive && ($sObject != 'html2ps_pdf') && ($sObject == 'propel-generator')) { - includeClasses($sDirectory . PATH_SEP . $sObject, $aClasses, true); - } - } - else { - $aAux = pathinfo($sDirectory . PATH_SEP . $sObject); - if (!isset($aAux['extension'])) { - $aAux['extension'] = ''; - } - if (strtolower($aAux['extension']) == 'php') { - try { - if (!in_array($aAux['basename'], $aClassesFilter)) { - @include $sDirectory . PATH_SEP . $sObject; - } - } - catch (Exception $oError) { - //Nothing - } - $aClasses[] = $sObject; - } - } - } - } -} diff --git a/workflow/engine/methods/additionalTables/additionalTablesData.php b/workflow/engine/methods/additionalTables/additionalTablesData.php deleted file mode 100644 index 82599cd29..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesData.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php -/** - * additionalTablesData.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -global $RBAC; -$RBAC->requirePermissions('PM_SETUP_ADVANCE'); -$G_PUBLISH = new Publisher; - -$oHeadPublisher =& headPublisher::getSingleton(); - -require_once 'classes/model/AdditionalTables.php'; -$oAdditionalTables = new AdditionalTables(); -$oAdditionalTables->createXmlList($_GET['sUID']); -$arrTable = $oAdditionalTables->load($_GET['sUID'],true); -$fields = $arrTable['FIELDS']; - -G::LoadClass('configuration'); -$c = new Configurations(); -$configPage = $c->getConfiguration('additionalTablesData', 'pageSize','',$_SESSION['USER_LOGGED']); -$Config['pageSize'] = isset($configPage['pageSize']) ? $configPage['pageSize'] : 20; - -$arrNames = Array(); -$arrDescrip = Array(); -$arrPKF = Array(); -$c = 0; -$xPKF = ""; -foreach ($fields as $field){ - $c++; - $arrNames[] = $field['FLD_NAME']; - $arrDescrip[] = $field['FLD_DESCRIPTION']; - if ($field['FLD_KEY']=='1'){ - $arrPKF[] = $field['FLD_NAME']; - } -} -$xPKF = implode(',', $arrPKF); - - -//$oHeadPublisher->usingExtJs('ux/Ext.ux.fileUploadField'); -$oHeadPublisher->addExtJsScript('additionalTables/additionalTablesData', false); //adding a javascript file .js -$oHeadPublisher->addContent('additionalTables/additionalTablesData'); //adding a html file .html. - -$table_uid = Array(); -$table_uid['UID'] = $_GET['sUID']; -$table_uid['COUNTER'] = $c; -$table_uid['TABLE_NAME'] = $arrTable['ADD_TAB_NAME']; -$table_uid['PKF'] = $xPKF; - - -$oHeadPublisher->assign('TABLES', $table_uid); -$oHeadPublisher->assign('NAMES', $arrNames); -$oHeadPublisher->assign('VALUES', $arrDescrip); -$oHeadPublisher->assign('CONFIG', $Config); - -G::RenderPage('publish', 'extJs'); diff --git a/workflow/engine/methods/additionalTables/additionalTablesDataDelete.php b/workflow/engine/methods/additionalTables/additionalTablesDataDelete.php deleted file mode 100644 index 47d30902d..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesDataDelete.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php -/** - * additionalTablesDataDelete.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -global $RBAC; -if ($RBAC->userCanAccess('PM_SETUP') != 1) { - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - G::header('location: ../login/login'); - die; -} - -$sUID = $_GET['sUID']; -unset($_GET['sUID']); - -require_once 'classes/model/AdditionalTables.php'; -$oAdditionalTables = new AdditionalTables(); -//$oAdditionalTables->deleteDataInTable($_POST['sUID'], $_POST['sPMUID']); -$oAdditionalTables->deleteDataInTable($sUID, $_GET); - -G::header('Location: additionalTablesData?sUID=' . $sUID); \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/additionalTablesDataEdit.php b/workflow/engine/methods/additionalTables/additionalTablesDataEdit.php deleted file mode 100644 index 077bd8e48..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesDataEdit.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/** - * additionalTablesDataEdit.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -global $RBAC; -if ($RBAC->userCanAccess('PM_SETUP') != 1) { - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - G::header('location: ../login/login'); - die; -} - -$sUID = $_GET['sUID']; -unset($_GET['sUID']); - -require_once 'classes/model/AdditionalTables.php'; -$oAdditionalTables = new AdditionalTables(); -$oAdditionalTables->createXmlEdit($sUID, false); - -$G_MAIN_MENU = 'processmaker'; -$G_SUB_MENU = 'setup'; -$G_ID_MENU_SELECTED = 'SETUP'; -$G_ID_SUB_MENU_SELECTED = 'ADDITIONAL_TABLES'; - -$G_PUBLISH = new Publisher(); -$G_PUBLISH->AddContent('xmlform', 'xmlform', 'xmlLists/' . $sUID . 'Edit', '', $oAdditionalTables->getDataTable($sUID, $_GET), 'additionalTablesUpdateData?sUID=' . $sUID, '', '', PATH_DYNAFORM); -G::RenderPage('publishBlank', 'blank'); \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/additionalTablesDataImport.php b/workflow/engine/methods/additionalTables/additionalTablesDataImport.php deleted file mode 100644 index 210221cf1..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesDataImport.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -/** - * additionalTablesDataImport.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -if (preg_match('/[\x00-\x08\x0b-\x0c\x0e\x1f]/', file_get_contents($_FILES['form']['tmp_name']['CSV_FILE'])) === 0) { - if ($oFile = fopen($_FILES['form']['tmp_name']['CSV_FILE'], 'r')) { - require_once 'classes/model/AdditionalTables.php'; - $oAdditionalTables = new AdditionalTables(); - $aAdditionalTables = $oAdditionalTables->load($_POST['form']['ADD_TAB_UID'], true); - $sErrorMessages = ''; - $i = 1; - while (($aAux = fgetcsv($oFile, 4096, $_POST['form']['CSV_DELIMITER'])) !== false) { - if ($i > 1) { - $aData = array(); - $j = 0; - foreach ($aAdditionalTables['FIELDS'] as $aField) { - $aData[$aField['FLD_NAME']] = (isset($aAux[$j]) ? $aAux[$j] : ''); - $j++; - } - try { - if (!$oAdditionalTables->saveDataInTable($_POST['form']['ADD_TAB_UID'], $aData)) { - $sErrorMessages .= G::LoadTranslation('ID_DUPLICATE_ENTRY_PRIMARY_KEY') . ', ' . G::LoadTranslation('ID_LINE') . ' ' . $i . '<br />'; - } - } - catch (Exception $oError) { - $sErrorMessages .= G::LoadTranslation('ID_ERROR_INSERT_LINE') . ': ' . G::LoadTranslation('ID_LINE') . ' ' . $i . '<br />'; - } - } - $i++; - } - fclose($oFile); - } - if ($sErrorMessages != '') { - G::SendMessageText($sErrorMessages, 'warning'); - } - G::header('Location: additionalTablesData?sUID=' . $_POST['form']['ADD_TAB_UID']); - die; -} -else { - G::SendTemporalMessage('ID_UPLOAD_VALID_CSV_FILE', 'error', 'labels'); - G::header('Location: additionalTablesData?sUID=' . $_POST['form']['ADD_TAB_UID']); - die; -} diff --git a/workflow/engine/methods/additionalTables/additionalTablesDataImportForm.php b/workflow/engine/methods/additionalTables/additionalTablesDataImportForm.php deleted file mode 100644 index 7535c763e..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesDataImportForm.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php -/** - * additionalTablesDataImportForm.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -global $RBAC; -if ($RBAC->userCanAccess('PM_SETUP') != 1) { - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - G::header('location: ../login/login'); - die; -} - -require_once 'classes/model/AdditionalTables.php'; -$oAdditionalTables = new AdditionalTables(); - -$G_MAIN_MENU = 'processmaker'; -//$G_SUB_MENU = 'setup'; -$G_ID_MENU_SELECTED = 'SETUP'; -//$G_ID_SUB_MENU_SELECTED = 'ADDITIONAL_TABLES'; - -$G_PUBLISH = new Publisher(); -$G_PUBLISH->AddContent('xmlform', 'xmlform', 'additionalTables/additionalTablesTitle', '', $oAdditionalTables->load($_GET['sUID'])); -$G_PUBLISH->AddContent('xmlform', 'xmlform', 'additionalTables/additionalTablesDataImportForm', '', array('ADD_TAB_UID' => $_GET['sUID']), '../additionalTables/additionalTablesDataImport'); -G::RenderPage('publishBlank', 'blank'); \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/additionalTablesDataNew.php b/workflow/engine/methods/additionalTables/additionalTablesDataNew.php deleted file mode 100644 index 6ea0932f5..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesDataNew.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php -/** - * additionalTablesDataNew.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -global $RBAC; -if ($RBAC->userCanAccess('PM_SETUP') != 1) { - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - G::header('location: ../login/login'); - die; -} - -require_once 'classes/model/AdditionalTables.php'; -$oAdditionalTables = new AdditionalTables(); -$oAdditionalTables->createXmlEdit($_GET['sUID'], true); - -$G_MAIN_MENU = 'processmaker'; -//$G_SUB_MENU = 'setup'; -$G_ID_MENU_SELECTED = 'SETUP'; -//$G_ID_SUB_MENU_SELECTED = 'ADDITIONAL_TABLES'; - -$G_PUBLISH = new Publisher(); -$G_PUBLISH->AddContent('xmlform', 'xmlform', 'xmlLists/' . $_GET['sUID'] . 'Edit', '', '', 'additionalTablesSaveData?sUID=' . $_GET['sUID'], '', '', PATH_DYNAFORM); -G::RenderPage('publishBlank', 'blank'); \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/additionalTablesDelete.php b/workflow/engine/methods/additionalTables/additionalTablesDelete.php deleted file mode 100644 index 4775a0c3c..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesDelete.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * additionalTablesDelete.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -global $RBAC; -if ($RBAC->userCanAccess('PM_SETUP') != 1) { - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - G::header('location: ../login/login'); - die; -} - -if (!isset($_GET['sUID'])) { - die; -} - -if ($_GET['sUID'] == '') { - die; -} - -require_once 'classes/model/AdditionalTables.php'; -$oAdditionalTables = new AdditionalTables(); -$oAdditionalTables->deleteMultiple($_GET['sUID']); - -G::Header('Location: additionalTablesList'); \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/additionalTablesDoImport.php b/workflow/engine/methods/additionalTables/additionalTablesDoImport.php deleted file mode 100755 index 68b493da4..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesDoImport.php +++ /dev/null @@ -1,203 +0,0 @@ -<? -/** - * processes_ImportFile.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -/* - * @Author: Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com> - */ - -require_once 'classes/model/AdditionalTables.php'; - -try { - - echo '<pre>'; - //print_R($_POST['form']['OVERWRITE']); - - $overWrite = isset($_POST['form']['OVERWRITE'])? true: false; - - //save the file - if ($_FILES['form']['error']['FILENAME'] == 0) { - $PUBLIC_ROOT_PATH = PATH_DATA.'sites'.PATH_SEP.SYS_SYS.PATH_SEP.'public'.PATH_SEP; - - $filename = $_FILES['form']['name']['FILENAME']; - $tempName = $_FILES['form']['tmp_name']['FILENAME']; - G::uploadFile($tempName, $PUBLIC_ROOT_PATH, $filename ); - - $fileContent = file_get_contents($PUBLIC_ROOT_PATH.$filename); - - if(strpos($fileContent, '-----== ProcessMaker Open Source Private Tables ==-----') !== false){ - $oMap = new aTablesMap(); - - $fp = fopen($PUBLIC_ROOT_PATH.$filename, "rb"); - $fsData = intval(fread($fp, 9)); //reading the metadata - $sType = fread($fp, $fsData); //reading string $oData - - require_once 'classes/model/AdditionalTables.php'; - $oAdditionalTables = new AdditionalTables(); - require_once 'classes/model/Fields.php'; - $oFields = new Fields(); - - while ( !feof($fp) ) { - switch($sType){ - case '@META': - $fsData = intval(fread($fp, 9)); - $METADATA = fread($fp, $fsData); - //print_r($METADATA); - break; - case '@SCHEMA': - - $fsUid = intval(fread($fp, 9)); - $uid = fread($fp, $fsUid); - - $fsData = intval(fread($fp, 9)); - $schema = fread($fp, $fsData); - $contentSchema = unserialize($schema); - //print_r($contentSchema); - - if($overWrite){ - $aTable = new additionalTables(); - try{ - $tRecord = $aTable->load($uid); - $aTable->deleteAll($uid); - } catch(Exception $e){ - $tRecord = $aTable->loadByName($contentSchema['ADD_TAB_NAME']); - if($tRecord[0]){ - $aTable->deleteAll($tRecord[0]['ADD_TAB_UID']); - } - } - } else { - #verify if exists some table with the same name - $aTable = new additionalTables(); - $tRecord = $aTable->loadByName("{$contentSchema['ADD_TAB_NAME']}%"); - - if($tRecord){ - $tNameOld = $contentSchema['ADD_TAB_NAME']; - $contentSchema['ADD_TAB_NAME'] = "{$contentSchema['ADD_TAB_NAME']}".sizeof($tRecord); - $contentSchema['ADD_TAB_CLASS_NAME'] = "{$contentSchema['ADD_TAB_CLASS_NAME']}".sizeof($tRecord); - $oMap->addRoute($tNameOld, $contentSchema['ADD_TAB_NAME']); - } - - } - - $sAddTabUid = $oAdditionalTables->create( - array( - 'ADD_TAB_NAME' => $contentSchema['ADD_TAB_NAME'], - 'ADD_TAB_CLASS_NAME' => $contentSchema['ADD_TAB_CLASS_NAME'], - 'ADD_TAB_DESCRIPTION' => $contentSchema['ADD_TAB_DESCRIPTION'], - 'ADD_TAB_SDW_LOG_INSERT' => $contentSchema['ADD_TAB_SDW_LOG_INSERT'], - 'ADD_TAB_SDW_LOG_UPDATE' => $contentSchema['ADD_TAB_SDW_LOG_UPDATE'], - 'ADD_TAB_SDW_LOG_DELETE' => $contentSchema['ADD_TAB_SDW_LOG_DELETE'], - 'ADD_TAB_SDW_LOG_SELECT' => $contentSchema['ADD_TAB_SDW_LOG_SELECT'], - 'ADD_TAB_SDW_MAX_LENGTH' => $contentSchema['ADD_TAB_SDW_MAX_LENGTH'], - 'ADD_TAB_SDW_AUTO_DELETE' => $contentSchema['ADD_TAB_SDW_AUTO_DELETE'], - 'ADD_TAB_PLG_UID' => $contentSchema['ADD_TAB_PLG_UID'] - ), - $contentSchema['FIELDS'] - ); - - - $aFields = array(); - foreach( $contentSchema['FIELDS'] as $iRow => $aRow ){ - unset($aRow['FLD_UID']); - $aRow['ADD_TAB_UID'] = $sAddTabUid; - $oFields->create($aRow); -// print_R($aRow); die; - $aFields[] = array( - 'sType' => $contentSchema['FIELDS'][$iRow]['FLD_TYPE'], - 'iSize' => $contentSchema['FIELDS'][$iRow]['FLD_SIZE'], - 'sFieldName' => $contentSchema['FIELDS'][$iRow]['FLD_NAME'], - 'bNull' => $contentSchema['FIELDS'][$iRow]['FLD_NULL'], - 'bAI' => $contentSchema['FIELDS'][$iRow]['FLD_AUTO_INCREMENT'], - 'bPrimaryKey' => $contentSchema['FIELDS'][$iRow]['FLD_KEY'] - ); - } - $oAdditionalTables->createTable($contentSchema['ADD_TAB_NAME'], 'wf', $aFields); - - for($i=1; $i <= count($contentSchema['FIELDS']); $i++){ - $contentSchema['FIELDS'][$i]['FLD_NULL'] = $contentSchema['FIELDS'][$i]['FLD_NULL'] == '1' ? 'on' : ''; - $contentSchema['FIELDS'][$i]['FLD_AUTO_INCREMENT'] = $contentSchema['FIELDS'][$i]['FLD_AUTO_INCREMENT'] == '1' ? 'on' : ''; - $contentSchema['FIELDS'][$i]['FLD_KEY'] = $contentSchema['FIELDS'][$i]['FLD_KEY'] == '1' ? 'on' : ''; - $contentSchema['FIELDS'][$i]['FLD_FOREIGN_KEY'] = $contentSchema['FIELDS'][$i]['FLD_FOREIGN_KEY'] == '1' ? 'on' : ''; - } - - $oAdditionalTables->createPropelClasses($contentSchema['ADD_TAB_NAME'], $contentSchema['ADD_TAB_CLASS_NAME'], $contentSchema['FIELDS'], $sAddTabUid); - - break; - case '@DATA': - $fstName = intval(fread($fp, 9)); - $tName = fread($fp, $fstName); - $fsData = intval(fread($fp, 9)); - $contentData = unserialize(fread($fp, $fsData)); - - $tName = $oMap->route($tName); - - $oAdditionalTables = new AdditionalTables(); - $tRecord = $oAdditionalTables->loadByName($tName); - - if($tRecord){ - foreach($contentData as $data){ - unset($data['DUMMY']); - $oAdditionalTables->saveDataInTable($tRecord[0]['ADD_TAB_UID'], $data); - } - } - break; - } - $fsData = intval(fread($fp, 9)); - if($fsData > 0){ - $sType = fread($fp, $fsData); - } else { - break; - } - } - - G::header("location: additionalTablesList"); - - } else { - G::SendTemporalMessage ('INVALID_FILE', "Error"); - G::header("location: additionalTablesToImport"); - } - - } -} catch(Exception $e){ - echo $e; -} - - -class aTablesMap{ - var $aMap; - - function route($uid){ - if( isset($this->aMap[$uid]) ){ - return $this->aMap[$uid]; - } else { - return $uid; - } - } - - function addRoute($item, $equal){ - $this->aMap[$item] = $equal; - } - -} - \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/additionalTablesEdit.php b/workflow/engine/methods/additionalTables/additionalTablesEdit.php deleted file mode 100644 index 6f6df4ce4..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesEdit.php +++ /dev/null @@ -1,109 +0,0 @@ -<?php -/** - * additionalTablesEdit.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -global $RBAC; -if ($RBAC->userCanAccess('PM_SETUP') != 1) { - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - G::header('location: ../login/login'); - die; -} - -if (!isset($_GET['sUID'])) { - G::header('Location: additionalTablesList'); - die; -} - -if ($_GET['sUID'] == '') { - G::header('Location: additionalTablesList'); - die; -} - -$G_MAIN_MENU = 'processmaker'; -//$G_SUB_MENU = 'setup'; -$G_ID_MENU_SELECTED = 'SETUP'; -//$G_ID_SUB_MENU_SELECTED = 'ADDITIONAL_TABLES'; - -require_once 'classes/model/AdditionalTables.php'; -$oAdditionalTables = new AdditionalTables(); -$aData = $oAdditionalTables->load($_GET['sUID'], true); -if ($aData['ADD_TAB_SDW_LOG_INSERT'] == 1) { - $aData['ADD_TAB_SDW_LOG_INSERT'] = 'on'; -} -else { - $aData['ADD_TAB_SDW_LOG_INSERT'] = ''; -} -if ($aData['ADD_TAB_SDW_LOG_UPDATE'] == 1) { - $aData['ADD_TAB_SDW_LOG_UPDATE'] = 'on'; -} -else { - $aData['ADD_TAB_SDW_LOG_UPDATE'] = ''; -} -if ($aData['ADD_TAB_SDW_LOG_DELETE'] == 1) { - $aData['ADD_TAB_SDW_LOG_DELETE'] = 'on'; -} -else { - $aData['ADD_TAB_SDW_LOG_DELETE'] = ''; -} -if ($aData['ADD_TAB_SDW_LOG_SELECT'] == 1) { - $aData['ADD_TAB_SDW_LOG_SELECT'] = 'on'; -} -else { - $aData['ADD_TAB_SDW_LOG_SELECT'] = ''; -} -if ($aData['ADD_TAB_SDW_AUTO_DELETE'] == 1) { - $aData['ADD_TAB_SDW_AUTO_DELETE'] = 'on'; -} -else { - $aData['ADD_TAB_SDW_AUTO_DELETE'] = ''; -} -foreach ($aData['FIELDS'] as $iRow => $aRow) { - if ($aRow['FLD_NULL'] == 1) { - $aData['FIELDS'][$iRow]['FLD_NULL'] = 'on'; - } - else { - $aData['FIELDS'][$iRow]['FLD_NULL'] = ''; - } - if ($aRow['FLD_AUTO_INCREMENT'] == 1) { - $aData['FIELDS'][$iRow]['FLD_AUTO_INCREMENT'] = 'on'; - } - else { - $aData['FIELDS'][$iRow]['FLD_AUTO_INCREMENT'] = ''; - } - if ($aRow['FLD_KEY'] == 1) { - $aData['FIELDS'][$iRow]['FLD_KEY'] = 'on'; - } - else { - $aData['FIELDS'][$iRow]['FLD_KEY'] = ''; - } - if ($aRow['FLD_FOREIGN_KEY'] == 1) { - $aData['FIELDS'][$iRow]['FLD_FOREIGN_KEY'] = 'on'; - } - else { - $aData['FIELDS'][$iRow]['FLD_FOREIGN_KEY'] = ''; - } -} - -$G_PUBLISH = new Publisher(); -$G_PUBLISH->AddContent('xmlform', 'xmlform', 'additionalTables/additionalTablesEdit', '', $aData, '../additionalTables/additionalTablesSave'); -G::RenderPage('publishBlank', 'blank'); \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/additionalTablesList.php b/workflow/engine/methods/additionalTables/additionalTablesList.php deleted file mode 100644 index 5ea059e96..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesList.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -/** - * additionalTablesList.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -global $RBAC; -$RBAC->requirePermissions('PM_SETUP_ADVANCE'); -$G_PUBLISH = new Publisher; - -G::LoadClass('configuration'); -$c = new Configurations(); -$configPage = $c->getConfiguration('additionalTablesList', 'pageSize','',$_SESSION['USER_LOGGED']); -$Config['pageSize'] = isset($configPage['pageSize']) ? $configPage['pageSize'] : 20; - -$oHeadPublisher =& headPublisher::getSingleton(); - -//$oHeadPublisher->usingExtJs('ux/Ext.ux.fileUploadField'); -$oHeadPublisher->addExtJsScript('additionalTables/additionalTablesList', false); //adding a javascript file .js -$oHeadPublisher->addContent('additionalTables/additionalTablesList'); //adding a html file .html. -$oHeadPublisher->assign('FORMATS',$c->getFormats()); -$oHeadPublisher->assign('CONFIG', $Config); -G::RenderPage('publish', 'extJs'); - -/*global $RBAC; -if ($RBAC->userCanAccess('PM_SETUP') != 1) { - G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); - G::header('location: ../login/login'); - die; -} - -require_once 'classes/model/AdditionalTables.php'; -$oCriteria = new Criteria('workflow'); -$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UID); -$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_NAME); -$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_DESCRIPTION); -$oCriteria->add(AdditionalTablesPeer::ADD_TAB_UID, '', Criteria::NOT_EQUAL); - -$G_MAIN_MENU = 'processmaker'; -//$G_SUB_MENU = 'admin'; -$G_ID_MENU_SELECTED = 'SETUP'; -//$G_ID_SUB_MENU_SELECTED = 'ADMIN'; - -$G_PUBLISH = new Publisher; -$G_PUBLISH->AddContent('propeltable', 'paged-table', 'additionalTables/additionalTablesList', $oCriteria, '', ''); -G::RenderPage('publishBlank', 'blank');*/ \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/additionalTablesNew.php b/workflow/engine/methods/additionalTables/additionalTablesNew.php deleted file mode 100644 index 90670c040..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesNew.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php -/** - * additionalTablesNew.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -global $RBAC; -if ($RBAC->userCanAccess('PM_SETUP') != 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 = 'ADDITIONAL_TABLES'; - -$G_PUBLISH = new Publisher(); -$G_PUBLISH->AddContent('xmlform', 'xmlform', 'additionalTables/additionalTablesNew', '', '', '../additionalTables/additionalTablesSave'); -G::RenderPage('publishBlank', 'blank'); \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/additionalTablesSave.php b/workflow/engine/methods/additionalTables/additionalTablesSave.php deleted file mode 100644 index b16d0f878..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesSave.php +++ /dev/null @@ -1,220 +0,0 @@ -<?php -/** - * additionalTablesSave.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -unset($_POST['form']['ADD_TAB_NAME_OLD']); -unset($_POST['form']['ADD_TAB_CLASS_NAME_OLD']); -if (!isset($_POST['form']['ADD_TAB_SDW_LOG_INSERT'])) { - $_POST['form']['ADD_TAB_SDW_LOG_INSERT'] = ''; -} -if (!isset($_POST['form']['ADD_TAB_SDW_LOG_UPDATE'])) { - $_POST['form']['ADD_TAB_SDW_LOG_UPDATE'] = ''; -} -if (!isset($_POST['form']['ADD_TAB_SDW_LOG_DELETE'])) { - $_POST['form']['ADD_TAB_SDW_LOG_DELETE'] = ''; -} -if (!isset($_POST['form']['ADD_TAB_SDW_LOG_SELECT'])) { - $_POST['form']['ADD_TAB_SDW_LOG_SELECT'] = ''; -} -if (!isset($_POST['form']['ADD_TAB_SDW_MAX_LENGTH'])) { - $_POST['form']['ADD_TAB_SDW_MAX_LENGTH'] = 0; -} -if (!isset($_POST['form']['ADD_TAB_SDW_AUTO_DELETE'])) { - $_POST['form']['ADD_TAB_SDW_AUTO_DELETE'] = ''; -} -foreach ($_POST['form']['FIELDS'] as $iRow => $aRow) { - if (!isset($_POST['form']['FIELDS'][$iRow]['FLD_NULL'])) { - $_POST['form']['FIELDS'][$iRow]['FLD_NULL'] = ''; - } - if (!isset($_POST['form']['FIELDS'][$iRow]['FLD_AUTO_INCREMENT'])) { - $_POST['form']['FIELDS'][$iRow]['FLD_AUTO_INCREMENT'] = ''; - } - if (!isset($_POST['form']['FIELDS'][$iRow]['FLD_KEY'])) { - $_POST['form']['FIELDS'][$iRow]['FLD_KEY'] = ''; - } - if (!isset($_POST['form']['FIELDS'][$iRow]['FLD_FOREIGN_KEY'])) { - $_POST['form']['FIELDS'][$iRow]['FLD_FOREIGN_KEY'] = ''; - } - if (!isset($_POST['form']['FIELDS'][$iRow]['FLD_FOREIGN_KEY_TABLE'])) { - $_POST['form']['FIELDS'][$iRow]['FLD_FOREIGN_KEY_TABLE'] = ''; - } - - if (!isset($_POST['form']['FIELDS'][$iRow]['FLD_NULL_HDN'])) { - $_POST['form']['FIELDS'][$iRow]['FLD_NULL_HDN'] = ''; - } - if (!isset($_POST['form']['FIELDS'][$iRow]['FLD_KEY_HDN'])) { - $_POST['form']['FIELDS'][$iRow]['FLD_KEY_HDN'] = ''; - } - // replace values check - if (isset($_POST['form']['FIELDS'][$iRow]['FLD_KEY']) && $_POST['form']['FIELDS'][$iRow]['FLD_KEY_HDN'] == 'on') { - $_POST['form']['FIELDS'][$iRow]['FLD_KEY'] = $_POST['form']['FIELDS'][$iRow]['FLD_KEY_HDN']; - } - if (isset($_POST['form']['FIELDS'][$iRow]['FLD_NULL']) && $_POST['form']['FIELDS'][$iRow]['FLD_NULL_HDN'] == 'on') { - $_POST['form']['FIELDS'][$iRow]['FLD_NULL'] = $_POST['form']['FIELDS'][$iRow]['FLD_NULL_HDN']; - } -} - -$aKeys = array(); -$aDynavars = array(); -$aNoKeys = array(); -foreach ($_POST['form']['FIELDS'] as $aRow) { - if ($aRow['FLD_KEY'] == 'on') { - $aKeys[] = $aRow; - if(isset($aRow['CASE_VARIABLE'])) - $aDynavars[] = array('FLD_UID'=>$aRow['FLD_UID'],'CASE_VARIABLE'=>$aRow['CASE_VARIABLE']); - else - $aDynavars[] = array('FLD_UID'=>$aRow['FLD_UID'],'CASE_VARIABLE'=>''); - } - else { - $aNoKeys[] = $aRow; - } -} -//print_r($_POST); -$aDynavars = serialize($aDynavars); -//var_dump($aKeys); -//print_r($aDynavars); -//die; -$_POST['form']['FIELDS'] = array(); -$i = 1; -foreach ($aKeys as $aRow) { - $_POST['form']['FIELDS'][$i] = $aRow; - $i++; -} -foreach ($aNoKeys as $aRow) { - $_POST['form']['FIELDS'][$i] = $aRow; - $i++; -} - -require_once 'classes/model/AdditionalTables.php'; -$oAdditionalTables = new AdditionalTables(); -require_once 'classes/model/Fields.php'; -$oFields = new Fields(); - -if ($_POST['form']['ADD_TAB_UID'] == '') { - - // We verified that the table does not exist. - $aNameTable = $oAdditionalTables->loadByName($_POST['form']['ADD_TAB_NAME']); - if(is_array($aNameTable)) { - G::SendMessageText('There is already a table named "' . $_POST['form']['ADD_TAB_NAME'] . '" in the database. Table creation canceled.', 'warning'); - G::header('Location: additionalTablesList'); - die; - } - // Reserved Words - $aReservedWords = array ('ALTER', 'CLOSE', 'COMMIT', 'CREATE', 'DECLARE', - 'DELETE', 'DROP', 'FETCH', 'FUNCTION', 'GRANT', - 'INDEX', 'INSERT', 'OPEN', 'REVOKE', 'ROLLBACK', - 'SELECT', 'SYNONYM', 'TABLE', 'UPDATE', 'VIEW' ); - if (in_array(strtoupper($_POST['form']['ADD_TAB_NAME']), $aReservedWords) ) { - G::SendMessageText('Could not create the table with the name "' . $_POST['form']['ADD_TAB_NAME'] . '" because it is a reserved word.', 'warning'); - G::header('Location: additionalTablesList'); - die; - } - - $arrFields = $_POST['form']['FIELDS']; - $newaFields = array(); - foreach ($arrFields as $arrField){ - $arrField['FLD_NAME'] = strtoupper($arrField['FLD_NAME']); - $newaFields[] = $arrField; - } - - $sAddTabUid = $oAdditionalTables->create(array('ADD_TAB_NAME' => $_POST['form']['ADD_TAB_NAME'], - 'ADD_TAB_CLASS_NAME' => $_POST['form']['ADD_TAB_CLASS_NAME'], - 'ADD_TAB_DESCRIPTION' => $_POST['form']['ADD_TAB_DESCRIPTION'], - 'ADD_TAB_SDW_LOG_INSERT' => ($_POST['form']['ADD_TAB_SDW_LOG_INSERT'] == 'on' ? 1 : 0), - 'ADD_TAB_SDW_LOG_UPDATE' => ($_POST['form']['ADD_TAB_SDW_LOG_UPDATE'] == 'on' ? 1 : 0), - 'ADD_TAB_SDW_LOG_DELETE' => ($_POST['form']['ADD_TAB_SDW_LOG_DELETE'] == 'on' ? 1 : 0), - 'ADD_TAB_SDW_LOG_SELECT' => ($_POST['form']['ADD_TAB_SDW_LOG_SELECT'] == 'on' ? 1 : 0), - 'ADD_TAB_SDW_MAX_LENGTH' => $_POST['form']['ADD_TAB_SDW_MAX_LENGTH'], - 'ADD_TAB_SDW_AUTO_DELETE' => ($_POST['form']['ADD_TAB_SDW_AUTO_DELETE'] == 'on' ? 1 : 0), - 'ADD_TAB_DYNAVARS' => $aDynavars, - 'ADD_TAB_PLG_UID' => ''), $newaFields); - $aFields = array(); - /*$aFields[] = array('sType' => 'INT', - 'iSize' => '11', - 'sFieldName' => 'PM_UNIQUE_ID', - 'bNull' => 0, - 'bAI' => 1, - 'bPrimaryKey' => 1);*/ - foreach ($_POST['form']['FIELDS'] as $iRow => $aRow) { - $oFields->create(array('FLD_INDEX' => $iRow, - 'ADD_TAB_UID' => $sAddTabUid, - 'FLD_NAME' => strtoupper($_POST['form']['FIELDS'][$iRow]['FLD_NAME']), - 'FLD_DESCRIPTION' => $_POST['form']['FIELDS'][$iRow]['FLD_DESCRIPTION'], - 'FLD_TYPE' => $_POST['form']['FIELDS'][$iRow]['FLD_TYPE'], - 'FLD_SIZE' => $_POST['form']['FIELDS'][$iRow]['FLD_SIZE'], - 'FLD_NULL' => ($_POST['form']['FIELDS'][$iRow]['FLD_NULL'] == 'on' ? 1 : 0), - 'FLD_AUTO_INCREMENT' => ($_POST['form']['FIELDS'][$iRow]['FLD_AUTO_INCREMENT'] == 'on' ? 1 : 0), - 'FLD_KEY' => ($_POST['form']['FIELDS'][$iRow]['FLD_KEY'] == 'on' ? 1 : 0), - 'FLD_FOREIGN_KEY' => ($_POST['form']['FIELDS'][$iRow]['FLD_FOREIGN_KEY'] == 'on' ? 1 : 0), - 'FLD_FOREIGN_KEY_TABLE' => $_POST['form']['FIELDS'][$iRow]['FLD_FOREIGN_KEY_TABLE'])); - $aFields[] = array('sType' => $_POST['form']['FIELDS'][$iRow]['FLD_TYPE'], - 'iSize' => $_POST['form']['FIELDS'][$iRow]['FLD_SIZE'], - 'sFieldName' => strtoupper($_POST['form']['FIELDS'][$iRow]['FLD_NAME']), - 'bNull' => ($_POST['form']['FIELDS'][$iRow]['FLD_NULL'] == 'on' ? 1 : 0), - 'bAI' => ($_POST['form']['FIELDS'][$iRow]['FLD_AUTO_INCREMENT'] == 'on' ? 1 : 0), - 'bPrimaryKey' => ($_POST['form']['FIELDS'][$iRow]['FLD_KEY'] == 'on' ? 1 : 0)); - } - $oAdditionalTables->createTable($_POST['form']['ADD_TAB_NAME'], 'wf', $aFields); - $oAdditionalTables->createPropelClasses($_POST['form']['ADD_TAB_NAME'], $_POST['form']['ADD_TAB_CLASS_NAME'], $newaFields, $sAddTabUid); -} -else { - $aData = $oAdditionalTables->load($_POST['form']['ADD_TAB_UID'], true); - $oAdditionalTables->update(array('ADD_TAB_UID' => $_POST['form']['ADD_TAB_UID'], - 'ADD_TAB_NAME' => $_POST['form']['ADD_TAB_NAME'], - 'ADD_TAB_CLASS_NAME' => $_POST['form']['ADD_TAB_CLASS_NAME'], - 'ADD_TAB_DESCRIPTION' => $_POST['form']['ADD_TAB_DESCRIPTION'], - 'ADD_TAB_SDW_LOG_INSERT' => ($_POST['form']['ADD_TAB_SDW_LOG_INSERT'] == 'on' ? 1 : 0), - 'ADD_TAB_SDW_LOG_UPDATE' => ($_POST['form']['ADD_TAB_SDW_LOG_UPDATE'] == 'on' ? 1 : 0), - 'ADD_TAB_SDW_LOG_DELETE' => ($_POST['form']['ADD_TAB_SDW_LOG_DELETE'] == 'on' ? 1 : 0), - 'ADD_TAB_SDW_LOG_SELECT' => ($_POST['form']['ADD_TAB_SDW_LOG_SELECT'] == 'on' ? 1 : 0), - 'ADD_TAB_SDW_MAX_LENGTH' => $_POST['form']['ADD_TAB_SDW_MAX_LENGTH'], - 'ADD_TAB_SDW_AUTO_DELETE' => ($_POST['form']['ADD_TAB_SDW_AUTO_DELETE'] == 'on' ? 1 : 0), - 'ADD_TAB_DYNAVARS' => $aDynavars, - 'ADD_TAB_PLG_UID' => ''), $_POST['form']['FIELDS']); - $oCriteria = new Criteria('workflow'); - $oCriteria->add(FieldsPeer::ADD_TAB_UID, $_POST['form']['ADD_TAB_UID']); - FieldsPeer::doDelete($oCriteria); - $aNewFields = array(); - foreach ($_POST['form']['FIELDS'] as $iRow => $aField) { - $sUID = $oFields->create(array('FLD_UID' => $_POST['form']['FIELDS'][$iRow]['FLD_UID'], - 'ADD_TAB_UID' => $_POST['form']['ADD_TAB_UID'], - 'FLD_INDEX' => $iRow, - 'FLD_NAME' => strtoupper($_POST['form']['FIELDS'][$iRow]['FLD_NAME']), - 'FLD_DESCRIPTION' => $_POST['form']['FIELDS'][$iRow]['FLD_DESCRIPTION'], - 'FLD_TYPE' => $_POST['form']['FIELDS'][$iRow]['FLD_TYPE'], - 'FLD_SIZE' => $_POST['form']['FIELDS'][$iRow]['FLD_SIZE'], - 'FLD_NULL' => ($_POST['form']['FIELDS'][$iRow]['FLD_NULL'] == 'on' ? 1 : 0), - 'FLD_AUTO_INCREMENT' => ($_POST['form']['FIELDS'][$iRow]['FLD_AUTO_INCREMENT'] == 'on' ? 1 : 0), - 'FLD_KEY' => ($_POST['form']['FIELDS'][$iRow]['FLD_KEY'] == 'on' ? 1 : 0), - 'FLD_FOREIGN_KEY' => ($_POST['form']['FIELDS'][$iRow]['FLD_FOREIGN_KEY'] == 'on' ? 1 : 0), - 'FLD_FOREIGN_KEY_TABLE' => $_POST['form']['FIELDS'][$iRow]['FLD_FOREIGN_KEY_TABLE'])); - $aNewFields[$sUID] = $aField; - } - $aOldFields = array(); - foreach ($aData['FIELDS'] as $aField) { - $aOldFields[$aField['FLD_UID']] = $aField; - } - $oAdditionalTables->updateTable($_POST['form']['ADD_TAB_NAME'], 'wf', $aNewFields, $aOldFields); - $oAdditionalTables->createPropelClasses($_POST['form']['ADD_TAB_NAME'], $_POST['form']['ADD_TAB_CLASS_NAME'], $_POST['form']['FIELDS'], $aData['ADD_TAB_UID']); -} -G::header('Location: additionalTablesList'); \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/additionalTablesSaveData.php b/workflow/engine/methods/additionalTables/additionalTablesSaveData.php deleted file mode 100644 index 374e2a911..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesSaveData.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php -/** - * additionalTablesSaveData.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -unset($_POST['form']['btnSave']); - -require_once 'classes/model/AdditionalTables.php'; -$oAdditionalTables = new AdditionalTables(); -if (!$oAdditionalTables->saveDataInTable($_GET['sUID'], $_POST['form'])) { - G::SendTemporalMessage('ID_DUPLICATE_ENTRY_PRIMARY_KEY', 'warning'); -} - -G::header('Location: additionalTablesData?sUID=' . $_GET['sUID']); \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/additionalTablesToExport.php b/workflow/engine/methods/additionalTables/additionalTablesToExport.php deleted file mode 100644 index 4decd624b..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesToExport.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** - * additionalTablesToExport.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -global $RBAC; -$RBAC->requirePermissions('PM_SETUP_ADVANCE'); -$G_PUBLISH = new Publisher; - -$oHeadPublisher =& headPublisher::getSingleton(); - - -$oHeadPublisher->addExtJsScript('additionalTables/additionalTablesExport', false); //adding a javascript file .js -$oHeadPublisher->addContent('additionalTables/additionalTablesExport'); //adding a html file .html. - -$toSend = Array(); -$toSend['UID_LIST'] = $_GET["sUID"]; - - -$oHeadPublisher->assign('EXPORT_TABLES', $toSend); -G::RenderPage('publish', 'extJs'); -?> \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/additionalTablesToImport.php b/workflow/engine/methods/additionalTables/additionalTablesToImport.php deleted file mode 100755 index 87f93a31d..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesToImport.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php -/** - * processes_DownloadFile.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - //add more security, and catch any error or exception - -/* - * Author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com> - * - */ -global $RBAC; -if ($RBAC->userCanAccess('PM_SETUP') != 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 = 'ADDITIONAL_TABLES'; - -$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_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'additionalTables/additionalTablesToImport.xml', '', $Fields, 'additionalTablesDoImport'); - G::RenderPage('publishBlank', 'blank'); diff --git a/workflow/engine/methods/additionalTables/additionalTablesUpdateData.php b/workflow/engine/methods/additionalTables/additionalTablesUpdateData.php deleted file mode 100644 index a50b4e8ec..000000000 --- a/workflow/engine/methods/additionalTables/additionalTablesUpdateData.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php -/** - * additionalTablesUpdateData.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -unset($_POST['form']['btnSave']); - -require_once 'classes/model/AdditionalTables.php'; -$oAdditionalTables = new AdditionalTables(); -$oAdditionalTables->updateDataInTable($_GET['sUID'], $_POST['form']); - -G::header('Location: additionalTablesData?sUID=' . $_GET['sUID']. '&r='.rand()); \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/data_additionalTablesData.php b/workflow/engine/methods/additionalTables/data_additionalTablesData.php deleted file mode 100644 index 3679561f8..000000000 --- a/workflow/engine/methods/additionalTables/data_additionalTablesData.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -/** - * data_additionalTablesList.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -require_once 'classes/model/AdditionalTables.php'; - -G::LoadClass('configuration'); -$co = new Configurations(); -$config = $co->getConfiguration('additionalTablesData', 'pageSize','',$_SESSION['USER_LOGGED']); -$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20; -$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0; -$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size; - -$oAdditionalTables = new AdditionalTables(); -$oAdditionalTables->createXmlList($_GET['sUID']); - -$ocaux = $oAdditionalTables->getDataCriteria($_GET['sUID']); -$rsc = AdditionalTablesPeer::doSelectRS($ocaux); -$rsc->setFetchmode(ResultSet::FETCHMODE_ASSOC); -$total_rows = 0; -while ($rsc->next()){ - $total_rows++; -} - -$ocaux1 = $oAdditionalTables->getDataCriteria($_GET['sUID']); -$ocaux1->setLimit($limit); -$ocaux1->setOffset($start); - -$rs = AdditionalTablesPeer::DoSelectRs ($ocaux1); -$rs->setFetchmode (ResultSet::FETCHMODE_ASSOC); - -$rows = Array(); -while($rs->next()){ - $rows[] = $rs->getRow(); -} -echo '{rows: '.G::json_encode($rows).', total_rows: '.$total_rows.'}'; \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/data_additionalTablesExport.php b/workflow/engine/methods/additionalTables/data_additionalTablesExport.php deleted file mode 100644 index 0027b8a2b..000000000 --- a/workflow/engine/methods/additionalTables/data_additionalTablesExport.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/** - * data_additionalTablesList.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -require_once 'classes/model/AdditionalTables.php'; - -$oCriteria = new Criteria('workflow'); -$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UID); -$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_NAME); -$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_DESCRIPTION); -$oCriteria->addSelectColumn("'".G::LoadTranslation('ID_ACTION_EXPORT')."' as 'CH_SCHEMA'"); -$oCriteria->addSelectColumn("'".G::LoadTranslation('ID_ACTION_EXPORT')."' as 'CH_DATA'"); - -$uids = explode(',',$_GET['aUID']); - -foreach ($uids as $UID){ - if (!isset($CC)){ - $CC = $oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_UID, $UID ,Criteria::EQUAL); - }else{ - $CC->addOr($oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_UID, $UID ,Criteria::EQUAL)); - } -} -$oCriteria->add($CC); -$oCriteria->addAnd($oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_UID, '', Criteria::NOT_EQUAL)); - -$oDataset = AdditionalTablesPeer::doSelectRS ( $oCriteria ); -$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); - -$addTables = Array(); -while( $oDataset->next() ) { - $addTables[] = $oDataset->getRow(); -} -echo G::json_encode($addTables); \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/data_additionalTablesList.php b/workflow/engine/methods/additionalTables/data_additionalTablesList.php deleted file mode 100644 index dd601a33e..000000000 --- a/workflow/engine/methods/additionalTables/data_additionalTablesList.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php -/** - * data_additionalTablesList.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -require_once 'classes/model/AdditionalTables.php'; -G::LoadClass('configuration'); -$co = new Configurations(); -$config = $co->getConfiguration('additionalTablesList', 'pageSize','',$_SESSION['USER_LOGGED']); -$env = $co->getConfiguration('ENVIRONMENT_SETTINGS', ''); -$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20; -$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0; -$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size; -$filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : ''; - -$oCriteria = new Criteria('workflow'); -$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UID); -$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_NAME); -$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_DESCRIPTION); -$oCriteria->add(AdditionalTablesPeer::PRO_UID, '', Criteria::EQUAL); -if ($filter!=''){ - $oCriteria->add( - $oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_NAME, '%'.$filter.'%',Criteria::LIKE)->addOr( - $oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_DESCRIPTION, '%'.$filter.'%',Criteria::LIKE))); -} -$total_tables = AdditionalTablesPeer::doCount($oCriteria); -//$oDataset = AdditionalTablesPeer::doSelectRS ( $oCriteria ); -//$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); -//$oDataset->next(); -//$row = $oDataset->getRow(); -//$total_tables = $row['CNT']; - -$oCriteria->clear(); -$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UID); -$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_NAME); -$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_DESCRIPTION); -$oCriteria->add(AdditionalTablesPeer::ADD_TAB_UID, '', Criteria::NOT_EQUAL); -$oCriteria->add(AdditionalTablesPeer::PRO_UID, '', Criteria::EQUAL); -if ($filter!=''){ - $oCriteria->add( - $oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_NAME, '%'.$filter.'%',Criteria::LIKE)->addOr( - $oCriteria->getNewCriterion(AdditionalTablesPeer::ADD_TAB_DESCRIPTION, '%'.$filter.'%',Criteria::LIKE))); -} - -$oCriteria->setLimit($limit); -$oCriteria->setOffset($start); - -$oDataset = AdditionalTablesPeer::doSelectRS ( $oCriteria ); -$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); - -$addTables = Array(); -while( $oDataset->next() ) { - $addTables[] = $oDataset->getRow(); -} -echo '{tables: '.G::json_encode($addTables).', total_tables: '.$total_tables.'}'; \ No newline at end of file diff --git a/workflow/engine/methods/additionalTables/doExport.php b/workflow/engine/methods/additionalTables/doExport.php deleted file mode 100755 index 27443e34b..000000000 --- a/workflow/engine/methods/additionalTables/doExport.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** - * processes_DownloadFile.php - * - * ProcessMaker Open Source Edition - * Copyright (C) 2004 - 2008 Colosa Inc.23 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - //add more security, and catch any error or exception - -/* - * Author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com> - * - */ - - $PUBLIC_ROOT_PATH = PATH_DATA.'sites'.PATH_SEP.SYS_SYS.PATH_SEP.'public'.PATH_SEP; - $sFileName = $_GET['f']; - - $realPath = $PUBLIC_ROOT_PATH . $sFileName; - G::streamFile ( $realPath, true ); - unlink($realPath); \ No newline at end of file diff --git a/workflow/engine/templates/additionalTables/Table.tpl b/workflow/engine/templates/additionalTables/Table.tpl deleted file mode 100644 index 8be3cc4aa..000000000 --- a/workflow/engine/templates/additionalTables/Table.tpl +++ /dev/null @@ -1,19 +0,0 @@ -<?php - -require_once '{pathClasses}/' . SYS_SYS . '/classes/om/Base{className}.php'; - - -/** - * Skeleton subclass for representing a row from the '{tableName}' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package classes.model - */ -class {className} extends Base{className} { - -} // {className} diff --git a/workflow/engine/templates/additionalTables/TablePeer.tpl b/workflow/engine/templates/additionalTables/TablePeer.tpl deleted file mode 100644 index ad955b6bc..000000000 --- a/workflow/engine/templates/additionalTables/TablePeer.tpl +++ /dev/null @@ -1,23 +0,0 @@ -<?php - - // include base peer class - require_once '{pathClasses}/' . SYS_SYS . '/classes/om/Base{className}Peer.php'; - - // include object class - include_once '{pathClasses}/' . SYS_SYS . '/classes/{className}.php'; - - -/** - * Skeleton subclass for performing query and update operations on the '{tableName}' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package classes.model - */ -class {className}Peer extends Base{className}Peer { - -} // {className}Peer diff --git a/workflow/engine/templates/additionalTables/additionalTablesData.html b/workflow/engine/templates/additionalTables/additionalTablesData.html deleted file mode 100644 index 432f567b5..000000000 --- a/workflow/engine/templates/additionalTables/additionalTablesData.html +++ /dev/null @@ -1,3 +0,0 @@ -<div style="padding: 15px"> -<div id="list-panel"></div> -</div> diff --git a/workflow/engine/templates/additionalTables/additionalTablesData.js b/workflow/engine/templates/additionalTables/additionalTablesData.js deleted file mode 100644 index 4658c0e8a..000000000 --- a/workflow/engine/templates/additionalTables/additionalTablesData.js +++ /dev/null @@ -1,317 +0,0 @@ -/* - * @author: Qennix - * Jan 12th, 2011 - */ - -//Keyboard Events -new Ext.KeyMap(document, { - key: Ext.EventObject.F5, - fn: function(keycode, e) { - if (! e.ctrlKey) { - if (Ext.isIE) { - // IE6 doesn't allow cancellation of the F5 key, so trick it into - // thinking some other key was pressed (backspace in this case) - e.browserEvent.keyCode = 8; - } - e.stopEvent(); - document.location = document.location; - }else{ - Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5'); - } - } -}); - -var newButton; -var editButton; -var deleteButton; -var importButton; -var backButton; - -var store; -var expander; -var cmodel; -var infoGrid; -var viewport; -var smodel; - -var FIELD_CM; -var FIELD_DS; - -Ext.onReady(function(){ - var xColumns = new Array(); - var xFields = new Array(); - - pageSize = parseInt(CONFIG.pageSize); - - newButton = new Ext.Action({ - text: _('ID_ADD_ROW'), - iconCls: 'button_menu_ext ss_sprite ss_add', - handler: NewPMTableRow - }); - - editButton = new Ext.Action({ - text: _('ID_EDIT'), - iconCls: 'button_menu_ext ss_sprite ss_pencil', - handler: EditPMTableRow, - disabled: true - }); - - deleteButton = new Ext.Action({ - text: _('ID_DELETE'), - iconCls: 'button_menu_ext ss_sprite ss_delete', - handler: DeletePMTableRow, - disabled: true - }); - - importButton = new Ext.Action({ - text: _('ID_IMPORT'), - iconCls: 'silk-add', - icon: '/images/import.gif', - handler: ImportPMTableCSV - }); - - backButton = new Ext.Action({ - text: _('ID_BACK'), - iconCls: 'button_menu_ext ss_sprite ss_arrow_redo', - handler: BackPMList - }); - - contextMenu = new Ext.menu.Menu({ - items: [editButton, deleteButton] - }); - - //This loop loads columns and fields to store and column model - for (var c=0; c<NAMES.length; c++){ - var xLabel = VALUES[c]; - var xCol = NAMES[c]; - FIELD_CM = Ext.util.JSON.decode('{"header": "' + xLabel +'", "dataIndex": "' + xCol + '", "hidden": false, "hideable": true, "width": 40}'); - xColumns[c] = FIELD_CM; - FIELD_DS = Ext.util.JSON.decode('{"name": "' + xCol + '"}'); - xFields[c] = FIELD_DS; - } - - var idField = Ext.util.JSON.decode('{"id":"' + TABLES.PKF +'", "dataIndex": "' + TABLES.PKF +'","hidden" :true, "hideable":false}'); - - xColumns.unshift(idField); - - smodel = new Ext.grid.CheckboxSelectionModel({ - listeners:{ - selectionchange: function(sm){ - var count_rows = sm.getCount(); - switch(count_rows){ - case 0: - editButton.disable(); - deleteButton.disable(); - break; - case 1: - editButton.enable(); - deleteButton.enable(); - break; - default: - editButton.disable(); - deleteButton.disable(); - break; - } - } - } - }); - - xColumns.unshift(smodel); - - store = new Ext.data.GroupingStore( { - proxy : new Ext.data.HttpProxy({ - url: 'data_additionalTablesData?sUID=' + TABLES.UID - }), - reader : new Ext.data.JsonReader( { - root: 'rows', - totalProperty: 'total_rows', - fields : xFields - }) - }); - - cmodel = new Ext.grid.ColumnModel({ - defaults: { - width: 50, - sortable: true - }, - columns: xColumns - }); - - storePageSize = new Ext.data.SimpleStore({ - fields: ['size'], - data: [['20'],['30'],['40'],['50'],['100']], - autoLoad: true - }); - - comboPageSize = new Ext.form.ComboBox({ - typeAhead : false, - mode : 'local', - triggerAction : 'all', - store: storePageSize, - valueField: 'size', - displayField: 'size', - width: 50, - editable: false, - listeners:{ - select: function(c,d,i){ - UpdatePageConfig(d.data['size']); - bbarpaging.pageSize = parseInt(d.data['size']); - bbarpaging.moveFirst(); - } - } - }); - - comboPageSize.setValue(pageSize); - - bbarpaging = new Ext.PagingToolbar({ - pageSize: pageSize, - store: store, - displayInfo: true, - displayMsg: _('ID_GRID_PAGE_DISPLAYING_ROWS_MESSAGE') + '    ', - emptyMsg: _('ID_GRID_PAGE_NO_ROWS_MESSAGE'), - items: ['-',_('ID_PAGE_SIZE')+':',comboPageSize] - }); - - - infoGrid = new Ext.grid.GridPanel({ - region: 'center', - layout: 'fit', - id: 'infoGrid', - height:100, - autoWidth : true, - title : _('ID_PM_TABLE') + " : " +TABLES.TABLE_NAME, - stateful : true, - stateId : 'grid', - enableColumnResize: true, - enableHdMenu: true, - frame:false, - columnLines: false, - viewConfig: { - forceFit:true - }, - store: store, - cm: cmodel, - sm: smodel, - tbar:[newButton,'-',editButton, deleteButton,'-',importButton,{xtype: 'tbfill' }, backButton], - bbar: bbarpaging, - listeners: { - rowdblclick: EditPMTableRow, - render: function(){ - this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING_GRID')}); - } - }, - view: new Ext.grid.GroupingView({ - forceFit:true, - groupTextTpl: '{text}' - }) - }); - - infoGrid.on('rowcontextmenu', - function (grid, rowIndex, evt) { - var sm = grid.getSelectionModel(); - sm.selectRow(rowIndex, sm.isSelected(rowIndex)); - }, - this - ); - - infoGrid.on('contextmenu', function(evt){evt.preventDefault();}, this); - infoGrid.addListener('rowcontextmenu',onMessageContextMenu, this); - - infoGrid.store.load(); - - viewport = new Ext.Viewport({ - layout: 'fit', - autoScroll: false, - items: [ - infoGrid - ] - }); -}); - -//Funtion Handles Context Menu Opening -onMessageContextMenu = function (grid, rowIndex, e) { - e.stopEvent(); - var coords = e.getXY(); - contextMenu.showAt([coords[0], coords[1]]); -}; - - - -/////JS FUNCTIONS - -//Capitalize String Function -capitalize = function(s){ - s = s.toLowerCase(); - return s.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } ); -}; - -//Do Nothing Function -DoNothing = function(){}; - -//Load New PM Table Row Forms -NewPMTableRow = function(){ - location.href = 'additionalTablesDataNew?sUID=' + TABLES.UID; -}; - -//Load PM Table Edition Row Form -EditPMTableRow = function(){ - iGrid = Ext.getCmp('infoGrid'); - rowsSelected = iGrid.getSelectionModel().getSelections(); - var aRowsSeleted = (RetrieveRowsID(rowsSelected)).split(",") ; - var aTablesPKF = (TABLES.PKF).split(","); ; - var sParam = ''; - for(var i=0;i<aTablesPKF.length; i++){ - sParam += '&' + aTablesPKF[i] + '=' + aRowsSeleted[i]; - } - location.href = 'additionalTablesDataEdit?sUID='+TABLES.UID+sParam; -}; - -//Confirm PM Table Row Deletion Tasks -DeletePMTableRow = function(){ - iGrid = Ext.getCmp('infoGrid'); - rowsSelected = iGrid.getSelectionModel().getSelections(); - Ext.Msg.confirm(_('ID_CONFIRM'), _('ID_MSG_CONFIRM_DELETE_ROW'), - function(btn, text){ - if (btn=="yes"){ - var aRowsSeleted = (RetrieveRowsID(rowsSelected)).split(",") ; - var aTablesPKF = (TABLES.PKF).split(","); ; - var sParam = ''; - for(var i=0;i<aTablesPKF.length; i++){ - sParam += '&' + aTablesPKF[i] + '=' + aRowsSeleted[i]; - } - location.href = 'additionalTablesDataDelete?sUID='+TABLES.UID+sParam; - } - }); -}; - -//Load Import PM Table From CSV Source -ImportPMTableCSV = function(){ - location.href = 'additionalTablesDataImportForm?sUID=' + TABLES.UID; -}; - -//Load PM Table List -BackPMList = function(){ - location.href = 'additionalTablesList'; -}; - -//Gets UIDs from a array of rows -RetrieveRowsID = function(rows){ - var arrAux = new Array(); - var arrPKF = new Array(); - arrPKF = TABLES.PKF.split(','); - if(rows.length>0){ - var c = 0; - for(var i=0; i<arrPKF.length; i++){ - arrAux[i] = rows[c].get(arrPKF[i]); - } - } - return arrAux.join(','); -}; - -//Update Page Size Configuration -UpdatePageConfig = function(pageSize){ - Ext.Ajax.request({ - url: 'additionalTablesAjax', - params: {action:'updatePageSizeData', size: pageSize} - }); -}; \ No newline at end of file diff --git a/workflow/engine/templates/additionalTables/additionalTablesExport.html b/workflow/engine/templates/additionalTables/additionalTablesExport.html deleted file mode 100644 index 432f567b5..000000000 --- a/workflow/engine/templates/additionalTables/additionalTablesExport.html +++ /dev/null @@ -1,3 +0,0 @@ -<div style="padding: 15px"> -<div id="list-panel"></div> -</div> diff --git a/workflow/engine/templates/additionalTables/additionalTablesExport.js b/workflow/engine/templates/additionalTables/additionalTablesExport.js deleted file mode 100644 index da8580283..000000000 --- a/workflow/engine/templates/additionalTables/additionalTablesExport.js +++ /dev/null @@ -1,193 +0,0 @@ - -/* - * @author: Qennix - * Jan 13th, 2011 - */ - -//Keyboard Events -new Ext.KeyMap(document, { - key: Ext.EventObject.F5, - fn: function(keycode, e) { - if (! e.ctrlKey) { - if (Ext.isIE) { - // IE6 doesn't allow cancellation of the F5 key, so trick it into - // thinking some other key was pressed (backspace in this case) - e.browserEvent.keyCode = 8; - } - e.stopEvent(); - document.location = document.location; - }else{ - Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5'); - } - } -}); - -var store; -var cmodel; -var smodel; -var infoGrid; -var viewport; - -var cancelButton; -var exportButton; - -var w; - -Ext.onReady(function(){ - Ext.QuickTips.init(); - - var reader = new Ext.data.ArrayReader({}, [{name: 'action'}]); - - var comboStore = new Ext.data.Store({ - reader: reader, - data: Ext.grid.dummyData - }); - - exportButton = new Ext.Action({ - text: _('ID_EXPORT'), - iconCls: 'silk-add', - icon: '/images/export.png', - handler: ExportPMTables - }); - - cancelButton = new Ext.Action({ - text: _('ID_CANCEL'), - iconCls: 'button_menu_ext ss_sprite ss_arrow_redo', - handler: CancelExport - }); - - store = new Ext.data.GroupingStore( { - proxy : new Ext.data.HttpProxy({ - url: 'data_additionalTablesExport?aUID='+EXPORT_TABLES.UID_LIST - }), - reader : new Ext.data.JsonReader( { - root: '', - fields : [ - {name : 'ADD_TAB_UID'}, - {name : 'ADD_TAB_NAME'}, - {name : 'ADD_TAB_DESCRIPTION'}, - {name : 'CH_SCHEMA'}, - {name : 'CH_DATA'} - ] - }) - }); - - var action_edit = new Ext.form.ComboBox({ - typeAhead: true, - triggerAction: 'all', - mode: 'local', - store: comboStore, - displayField: 'action', - valueField: 'action' - }); - - cmodel = new Ext.grid.ColumnModel({ - defaults: { - width: 10, - sortable: true - }, - columns: [ - new Ext.grid.RowNumberer(), - //smodel, - {id:'ADD_TAB_UID', dataIndex: 'ADD_TAB_UID', hidden:true, hideable:false}, - {header: _('ID_NAME'), dataIndex: 'ADD_TAB_NAME', width: 20, align:'left'}, - {header: _('ID_DESCRIPTION'), dataIndex: 'ADD_TAB_DESCRIPTION', width: 50, hidden:false, align:'left'},//, - {header: _('ID_SCHEMA'), dataIndex: 'CH_SCHEMA', hidden: false, width: 20, editor: action_edit, align: 'center'}, - {header: 'DATA', dataIndex: 'CH_DATA', hidden: false, width: 20, editor: action_edit, align: 'center'} - ] - }); - - infoGrid = new Ext.grid.EditorGridPanel({ - store: store, - cm: cmodel, - width: 600, - height: 300, - title: _('ID_ADDITIONAL_TABLES') + ': ' +_('ID_TITLE_EXPORT_TOOL'), - frame: false, - clicksToEdit: 1, - id: 'infoGrid', - - sm: new Ext.grid.RowSelectionModel({singleSelect: false}), - tbar:[exportButton, {xtype: 'tbfill'} ,cancelButton],//'-', editButton, deleteButton,'-', dataButton,{xtype: 'tbfill'} , importButton, exportButton], - view: new Ext.grid.GroupingView({ - forceFit:true, - groupTextTpl: '{text}' - }) - }); - - infoGrid.store.load(); - - viewport = new Ext.Viewport({ - layout: 'fit', - autoScroll: false, - items: [ - infoGrid - ] - }); - -}); - -//Cancels Export View -CancelExport = function(){ - location.href = 'additionalTablesList'; -}; - -//Export Schema/Data from PM Tables -ExportPMTables = function(){ - iGrid = Ext.getCmp('infoGrid'); - var storeExport = iGrid.getStore(); - var UIDs = new Array(); - var SCHs = new Array(); - var DATs = new Array(); - for (var r=0; r<storeExport.getCount(); r++){ - row = storeExport.getAt(r); - UIDs[r] = row.data['ADD_TAB_UID']; - if (row.data['CH_SCHEMA']==_('ID_ACTION_EXPORT')){ - SCHs[r] = row.data['ADD_TAB_UID']; - }else{ - SCHs[r] = 0; - } - if (row.data['CH_DATA']==_('ID_ACTION_EXPORT')){ - DATs[r] = row.data['ADD_TAB_UID']; - }else{ - DATs[r] = 0; - } - } - Ext.Ajax.request({ - url: 'additionalTablesAjax', - success: SuccessExport, - failure: DoNothing, - params: { action: 'doExport', tables: UIDs.join(','), schema: SCHs.join(','), data: DATs.join(',') } - }); -}; - -//Response Export Handler -SuccessExport = function(response, opts){ - w = new Ext.Window({ - height: 350, - width: 670, - resizable: false, - html: response.responseText, - autoscroll: false, - title: _('ID_TITLE_EXPORT_RESULT'), - closable: true, - buttons: [{ - text: _('ID_CLOSE'), -// iconCls: 'silk-add', - handler: CloseExport - }] - }); - w.show(); -}; - -//Close Export Dialog -CloseExport = function(){ - w.close(); -}; - - -//Do Nothing Function -DoNothing = function(){}; - -Ext.grid.dummyData = [['Export'],['Ignore']]; - diff --git a/workflow/engine/templates/additionalTables/additionalTablesList.html b/workflow/engine/templates/additionalTables/additionalTablesList.html deleted file mode 100644 index 432f567b5..000000000 --- a/workflow/engine/templates/additionalTables/additionalTablesList.html +++ /dev/null @@ -1,3 +0,0 @@ -<div style="padding: 15px"> -<div id="list-panel"></div> -</div> diff --git a/workflow/engine/templates/additionalTables/additionalTablesList.js b/workflow/engine/templates/additionalTables/additionalTablesList.js deleted file mode 100644 index 59b7cadcb..000000000 --- a/workflow/engine/templates/additionalTables/additionalTablesList.js +++ /dev/null @@ -1,359 +0,0 @@ -/* - * @author: Qennix - * Jan 10th, 2011 - */ - -//Keyboard Events -new Ext.KeyMap(document, { - key: Ext.EventObject.F5, - fn: function(keycode, e) { - if (! e.ctrlKey) { - if (Ext.isIE) { - // IE6 doesn't allow cancellation of the F5 key, so trick it into - // thinking some other key was pressed (backspace in this case) - e.browserEvent.keyCode = 8; - } - e.stopEvent(); - document.location = document.location; - }else{ - Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5'); - } - } -}); - -var newButton; -var editButton; -var deleteButton; -var importButton; -var exportButton; -var dataButton; - -var store; -var expander; -var cmodel; -var infoGrid; -var viewport; -var smodel; - -var rowsSelected; - -Ext.onReady(function(){ - Ext.QuickTips.init(); - - pageSize = parseInt(CONFIG.pageSize); - - newButton = new Ext.Action({ - text: _('ID_NEW_ADD_TABLE'), - iconCls: 'button_menu_ext ss_sprite ss_add', - handler: NewPMTable - }); - - editButton = new Ext.Action({ - text: _('ID_EDIT'), - iconCls: 'button_menu_ext ss_sprite ss_pencil', - handler: EditPMTable, - disabled: true - }); - - deleteButton = new Ext.Action({ - text: _('ID_DELETE'), - iconCls: 'button_menu_ext ss_sprite ss_delete', - handler: DeletePMTable, - disabled: true - }); - - importButton = new Ext.Action({ - text: _('ID_IMPORT'), - iconCls: 'silk-add', - icon: '/images/import.gif', - handler: ImportPMTable - }); - - exportButton = new Ext.Action({ - text: _('ID_EXPORT'), - iconCls: 'silk-add', - icon: '/images/export.png', - handler: ExportPMTable, - disabled: true - }); - - dataButton = new Ext.Action({ - text: ' ' + _('ID_DATA'), - iconCls: 'silk-add', - icon: '/images/icon-pmtables.png', - handler: PMTableData, - disabled: true - }); - - searchButton = new Ext.Action({ - text: _('ID_SEARCH'), - handler: DoSearch - }); - - contextMenu = new Ext.menu.Menu({ - items: [editButton, deleteButton,'-',dataButton,'-',exportButton] - }); - - searchText = new Ext.form.TextField ({ - id: 'searchTxt', - ctCls:'pm_search_text_field', - allowBlank: true, - width: 150, - emptyText: _('ID_ENTER_SEARCH_TERM'), - listeners: { - specialkey: function(f,e){ - if (e.getKey() == e.ENTER) { - DoSearch(); - } - }, - focus: function(f,e) { - var row = infoGrid.getSelectionModel().getSelected(); - infoGrid.getSelectionModel().deselectRow(infoGrid.getStore().indexOf(row)); - } - } - }); - - clearTextButton = new Ext.Action({ - text: 'X', - ctCls:'pm_search_x_button', - handler: GridByDefault - }); - - storePageSize = new Ext.data.SimpleStore({ - fields: ['size'], - data: [['20'],['30'],['40'],['50'],['100']], - autoLoad: true - }); - - comboPageSize = new Ext.form.ComboBox({ - typeAhead : false, - mode : 'local', - triggerAction : 'all', - store: storePageSize, - valueField: 'size', - displayField: 'size', - width: 50, - editable: false, - listeners:{ - select: function(c,d,i){ - UpdatePageConfig(d.data['size']); - bbarpaging.pageSize = parseInt(d.data['size']); - bbarpaging.moveFirst(); - } - } - }); - - comboPageSize.setValue(pageSize); - - - store = new Ext.data.GroupingStore( { - proxy : new Ext.data.HttpProxy({ - url: 'data_additionalTablesList' - }), - reader : new Ext.data.JsonReader( { - root: 'tables', - totalProperty: 'total_tables', - fields : [ - {name : 'ADD_TAB_UID'}, - {name : 'ADD_TAB_NAME'}, - {name : 'ADD_TAB_DESCRIPTION'} - ] - }) - }); - - smodel = new Ext.grid.CheckboxSelectionModel({ - listeners:{ - selectionchange: function(sm){ - var count_rows = sm.getCount(); - switch(count_rows){ - case 0: - editButton.disable(); - deleteButton.disable(); - exportButton.disable(); - dataButton.disable(); - break; - case 1: - editButton.enable(); - deleteButton.enable(); - exportButton.enable(); - dataButton.enable(); - break; - default: - editButton.disable(); - deleteButton.enable(); - exportButton.enable(); - dataButton.disable(); - break; - } - } - } - }); - - cmodel = new Ext.grid.ColumnModel({ - defaults: { - width: 50, - sortable: true - }, - columns: [ - smodel, - {id:'ADD_TAB_UID', dataIndex: 'ADD_TAB_UID', hidden:true, hideable:false}, - {header: _('ID_NAME'), dataIndex: 'ADD_TAB_NAME', width: 300, align:'left'}, - {header: _('ID_DESCRIPTION'), dataIndex: 'ADD_TAB_DESCRIPTION', width: 400, hidden:false, align:'left'} - ] - }); - - bbarpaging = new Ext.PagingToolbar({ - pageSize: pageSize, - store: store, - displayInfo: true, - displayMsg: _('ID_GRID_PAGE_DISPLAYING_PMTABLES_MESSAGE') + '    ', - emptyMsg: _('ID_GRID_PAGE_NO_PMTABLES_MESSAGE'), - items: ['-',_('ID_PAGE_SIZE')+':',comboPageSize] - }); - - infoGrid = new Ext.grid.GridPanel({ - region: 'center', - layout: 'fit', - id: 'infoGrid', - height:100, - autoWidth : true, - title : _('ID_ADDITIONAL_TABLES'), - stateful : true, - stateId : 'grid', - enableColumnResize: true, - enableHdMenu: true, - frame:false, - columnLines: false, - viewConfig: { - forceFit:true - }, - store: store, - cm: cmodel, - sm: smodel, - tbar:[newButton, '-', editButton, deleteButton,'-', dataButton,'-' , importButton, exportButton,{xtype: 'tbfill'},searchText,clearTextButton,searchButton], - bbar: bbarpaging, - listeners: { - rowdblclick: PMTableData, - render: function(){ - this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING_GRID')}); - } - }, - view: new Ext.grid.GroupingView({ - forceFit:true, - groupTextTpl: '{text}' - }) - }); - - infoGrid.on('rowcontextmenu', - function (grid, rowIndex, evt) { - var sm = grid.getSelectionModel(); - sm.selectRow(rowIndex, sm.isSelected(rowIndex)); - }, - this - ); - - infoGrid.on('contextmenu', function(evt){evt.preventDefault();}, this); - infoGrid.addListener('rowcontextmenu',onMessageContextMenu, this); - - infoGrid.store.load(); - - viewport = new Ext.Viewport({ - layout: 'fit', - autoScroll: false, - items: [ - infoGrid - ] - }); -}); - -//Funtion Handles Context Menu Opening -onMessageContextMenu = function (grid, rowIndex, e) { - e.stopEvent(); - var coords = e.getXY(); - contextMenu.showAt([coords[0], coords[1]]); -}; - -/////JS FUNCTIONS - -//Capitalize String Function -capitalize = function(s){ - s = s.toLowerCase(); - return s.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } ); -}; - -//Do Nothing Function -DoNothing = function(){}; - -//Load New PM Table Forms -NewPMTable = function(){ - location.href = 'additionalTablesNew'; -}; - -newReportTable = function(){ - location.href = '../reportTables/new'; -}; - -//Load PM Table Edition Forms -EditPMTable = function(){ - iGrid = Ext.getCmp('infoGrid'); - rowsSelected = iGrid.getSelectionModel().getSelections(); - location.href = 'additionalTablesEdit?sUID='+RetrieveRowsID(rowsSelected)+'&rand='+Math.random(); -}; - -//Confirm PM Table Deletion Tasks -DeletePMTable = function(){ - iGrid = Ext.getCmp('infoGrid'); - rowsSelected = iGrid.getSelectionModel().getSelections(); - Ext.Msg.confirm(_('ID_CONFIRM'), _('ID_CONFIRM_DELETE_PM_TABLE'), - function(btn, text){ - if (btn=="yes"){ - location.href = 'additionalTablesDelete?sUID='+RetrieveRowsID(rowsSelected)+'&rand='+Math.random(); - } - }); -}; - -//Load Import PM Table Form -ImportPMTable = function(){ - location.href = 'additionalTablesToImport'; -}; - -//Load Export PM Tables Form -ExportPMTable = function(){ - iGrid = Ext.getCmp('infoGrid'); - rowsSelected = iGrid.getSelectionModel().getSelections(); - location.href = 'additionalTablesToExport?sUID='+RetrieveRowsID(rowsSelected)+'&rand='+Math.random(); -}; - -//Load PM TAble Data -PMTableData = function(){ - iGrid = Ext.getCmp('infoGrid'); - rowsSelected = iGrid.getSelectionModel().getSelections(); - location.href = 'additionalTablesData?sUID='+RetrieveRowsID(rowsSelected)+'&rand='+Math.random(); -}; - -//Gets UIDs from a array of rows -RetrieveRowsID = function(rows){ - var arrAux = new Array(); - for(var c=0; c<rows.length; c++){ - arrAux[c] = rows[c].get('ADD_TAB_UID'); - } - return arrAux.join(','); -}; -//Update Page Size Configuration -UpdatePageConfig = function(pageSize){ - Ext.Ajax.request({ - url: 'additionalTablesAjax', - params: {action:'updatePageSize', size: pageSize} - }); -}; - -//Do Search Function -DoSearch = function(){ - infoGrid.store.load({params: {textFilter: searchText.getValue()}}); -}; - -//Load Grid By Default -GridByDefault = function(){ - searchText.reset(); - infoGrid.store.load(); -}; \ No newline at end of file diff --git a/workflow/engine/templates/additionalTables/map/TableMapBuilder.tpl b/workflow/engine/templates/additionalTables/map/TableMapBuilder.tpl deleted file mode 100644 index 5877aca99..000000000 --- a/workflow/engine/templates/additionalTables/map/TableMapBuilder.tpl +++ /dev/null @@ -1,78 +0,0 @@ -<?php - -require_once PATH_THIRDPARTY . 'propel/map/MapBuilder.php'; -include_once PATH_THIRDPARTY . 'creole/CreoleTypes.php'; - - -/** - * This class adds structure of '{tableName}' table to '{connection}' DatabaseMap object. - * - * - * - * These statically-built map classes are used by Propel to do runtime db structure discovery. - * For example, the createSelectSql() method checks the type of a given column used in an - * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive - * (i.e. if it's a text column type). - * - * @package classes.model.map - */ -class {className}MapBuilder { - - /** - * The (dot-path) name of this class - */ - const CLASS_NAME = 'classes.model.map.{className}MapBuilder'; - - /** - * The database map. - */ - private $dbMap; - - /** - * Tells us if this DatabaseMapBuilder is built so that we - * don't have to re-build it every time. - * - * @return boolean true if this DatabaseMapBuilder is built, false otherwise. - */ - public function isBuilt() - { - return ($this->dbMap !== null); - } - - /** - * Gets the databasemap this map builder built. - * - * @return the databasemap - */ - public function getDatabaseMap() - { - return $this->dbMap; - } - - /** - * The doBuild() method builds the DatabaseMap - * - * @return void - * @throws PropelException - */ - public function doBuild() - { - $this->dbMap = Propel::getDatabaseMap('{connection}'); - - $tMap = $this->dbMap->addTable('{tableName}'); - - $tMap->setPhpName('{className}'); - - $tMap->setUseIdGenerator({useIdGenerator}); - -<!-- START BLOCK : primaryKeys --> - $tMap->addPrimaryKey('{name}', '{phpName}', '{type}', CreoleTypes::{creoleType}, {notNull}, {size}); -<!-- END BLOCK : primaryKeys --> - -<!-- START BLOCK : columnsWhitoutKeys --> - $tMap->addColumn('{name}', '{phpName}', '{type}', CreoleTypes::{creoleType}, {notNull}, {size}); -<!-- END BLOCK : columnsWhitoutKeys --> - - } // doBuild() - -} // {className}MapBuilder diff --git a/workflow/engine/templates/additionalTables/om/BaseTable.tpl b/workflow/engine/templates/additionalTables/om/BaseTable.tpl deleted file mode 100644 index cba356cf5..000000000 --- a/workflow/engine/templates/additionalTables/om/BaseTable.tpl +++ /dev/null @@ -1,530 +0,0 @@ -<?php - -require_once PATH_THIRDPARTY . 'propel/om/BaseObject.php'; - -require_once PATH_THIRDPARTY . 'propel/om/Persistent.php'; - - -include_once PATH_THIRDPARTY . 'propel/util/Criteria.php'; - -include_once '{pathClasses}/' . SYS_SYS . '/classes/{className}Peer.php'; - -/** - * Base class that represents a row from the '{tableName}' table. - * - * - * - * @package classes.model.om - */ -abstract class Base{className} extends BaseObject implements Persistent { - - - /** - * The Peer class. - * Instance provides a convenient way of calling static methods on a class - * that calling code may not be able to identify. - * @var {className}Peer - */ - protected static $peer; - -<!-- START BLOCK : allColumns1 --> - /** - * The value for the {var} field. - * @var {type} - */ - protected {attribute}; -<!-- END BLOCK : allColumns1 --> - - /** - * Flag to prevent endless save loop, if this object is referenced - * by another object which falls in this transaction. - * @var boolean - */ - protected $alreadyInSave = false; - - /** - * Flag to prevent endless validation loop, if this object is referenced - * by another object which falls in this transaction. - * @var boolean - */ - protected $alreadyInValidation = false; - -<!-- START BLOCK : allColumns2 --> - {getFunction} - -<!-- END BLOCK : allColumns2 --> -<!-- START BLOCK : allColumns3 --> - /** - * Set the value of [{var}] column. - * - * @param {type} $v new value - * @return void - */ - public function set{phpName}($v) - { - {setFunction} - } // set{phpName}() - -<!-- END BLOCK : allColumns3 --> - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (1-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. - * @param int $startcol 1-based offset column which indicates which restultset column to start with. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate(ResultSet $rs, $startcol = 1) - { - try { -<!-- START BLOCK : allColumns4 --> - $this->{var} = $rs->get{type2}($startcol + {index}); -<!-- END BLOCK : allColumns4 --> - - $this->resetModified(); - - $this->setNew(false); - - // FIXME - using NUM_COLUMNS may be clearer. - return $startcol + {totalColumns}; // {totalColumns} = {className}Peer::NUM_COLUMNS - {className}Peer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating {className} object", $e); - } - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param Connection $con - * @return void - * @throws PropelException - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete($con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection({className}Peer::DATABASE_NAME); - } - - try { - $con->begin(); - {className}Peer::doDelete($this, $con); - $this->setDeleted(true); - $con->commit(); - require_once 'classes/model/AdditionalTables.php'; - $oAdditionalTables = new AdditionalTables(); - $aAdditionalTables = $oAdditionalTables->load({className}Peer::__UID__); - if ($aAdditionalTables['ADD_TAB_SDW_LOG_DELETE'] == 1) { - require_once 'classes/model/ShadowTable.php'; - $oShadowTable = new ShadowTable(); - $oShadowTable->create(array('ADD_TAB_UID' => {className}Peer::__UID__, - 'SHD_ACTION' => 'DELETE', - 'SHD_DETAILS' => serialize($this->toArray(BasePeer::TYPE_FIELDNAME)), - 'USR_UID' => (isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : ''), - 'APP_UID' => (isset($_SESSION['APPLICATION']) ? $_SESSION['APPLICATION'] : ''), - 'SHD_DATE' => date('Y-m-d H:i:s'))); - } - } catch (PropelException $e) { - $con->rollback(); - throw $e; - } - } - - /** - * Stores the object in the database. If the object is new, - * it inserts it; otherwise an update is performed. This method - * wraps the doSave() worker method in a transaction. - * - * @param Connection $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see doSave() - */ - public function save($con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection({className}Peer::DATABASE_NAME); - } - - try { - $con->begin(); - $affectedRows = $this->doSave($con); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollback(); - throw $e; - } - } - - /** - * Stores the object in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param Connection $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave($con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - - // If this object has been modified, then save it to the database. - if ($this->isModified()) { - if ($this->isNew()) { - $pk = {className}Peer::doInsert($this, $con); - $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which - // should always be true here (even though technically - // BasePeer::doInsert() can insert multiple rows). - - $this->setNew(false); - $sAction = 'INSERT'; - $sField = 'ADD_TAB_SDW_LOG_INSERT'; - } else { - $affectedRows += {className}Peer::doUpdate($this, $con); - $sAction = 'UPDATE'; - $sField = 'ADD_TAB_SDW_LOG_UPDATE'; - } - require_once 'classes/model/AdditionalTables.php'; - $oAdditionalTables = new AdditionalTables(); - $aAdditionalTables = $oAdditionalTables->load({className}Peer::__UID__); - if ($aAdditionalTables[$sField] == 1) { - require_once 'classes/model/ShadowTable.php'; - $oShadowTable = new ShadowTable(); - $oShadowTable->create(array('ADD_TAB_UID' => {className}Peer::__UID__, - 'SHD_ACTION' => $sAction, - 'SHD_DETAILS' => serialize($this->toArray(BasePeer::TYPE_FIELDNAME)), - 'USR_UID' => (isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : ''), - 'APP_UID' => (isset($_SESSION['APPLICATION']) ? $_SESSION['APPLICATION'] : ''), - 'SHD_DATE' => date('Y-m-d H:i:s'))); - } - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then <code>true</code> is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = {className}Peer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TYPE_PHPNAME, - * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = {className}Peer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - return $this->getByPosition($pos); - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch($pos) { -<!-- START BLOCK : allColumns5 --> - case {index}: - return $this->get{phpName}(); - break; -<!-- END BLOCK : allColumns5 --> - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType One of the class type constants TYPE_PHPNAME, - * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM - * @return an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME) - { - $keys = {className}Peer::getFieldNames($keyType); - $result = array( -<!-- START BLOCK : allColumns6 --> - $keys[{index}] => $this->get{phpName}(), -<!-- START BLOCK : allColumns6 --> - ); - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TYPE_PHPNAME, - * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = {className}Peer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - return $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch($pos) { -<!-- START BLOCK : allColumns7 --> - case {index}: - $this->set{phpName}($value); - break; -<!-- END BLOCK : allColumns7 --> - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, - * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = {className}Peer::getFieldNames($keyType); -<!-- START BLOCK : allColumns8 --> - if (array_key_exists($keys[{index}], $arr)) $this->set{phpName}($arr[$keys[{index}]]); -<!-- END BLOCK : allColumns8 --> - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria({className}Peer::DATABASE_NAME); -<!-- START BLOCK : allColumns9 --> - if ($this->isColumnModified({className}Peer::{name})) $criteria->add({className}Peer::{name}, $this->{var}); -<!-- END BLOCK : allColumns9 --> - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria({className}Peer::DATABASE_NAME); -<!-- START BLOCK : primaryKeys1 --> - $criteria->add({className}Peer::{name}, $this->{var}); -<!-- END BLOCK : primaryKeys1 --> - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return string - */ - public function getPrimaryKey() - { - {getPrimaryKeyFunction} - } - - /** - * Generic method to set the primary key (add_tab_uid column). - * - * @param string $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - {setPrimaryKeyFunction} - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of {className} (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false) - { -<!-- START BLOCK : columnsWhitoutKeys --> - $copyObj->set{phpName}($this->{var}); -<!-- END BLOCK : columnsWhitoutKeys --> - - $copyObj->setNew(true); -<!-- START BLOCK : primaryKeys2 --> - $copyObj->set{phpName}({defaultValue}); // this is a pkey column, so set to default value -<!-- END BLOCK : primaryKeys2 --> - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return {className} Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return {className}Peer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new {className}Peer(); - } - return self::$peer; - } - -} // Base{className} diff --git a/workflow/engine/templates/additionalTables/om/BaseTablePeer.tpl b/workflow/engine/templates/additionalTables/om/BaseTablePeer.tpl deleted file mode 100644 index bcbbb9446..000000000 --- a/workflow/engine/templates/additionalTables/om/BaseTablePeer.tpl +++ /dev/null @@ -1,584 +0,0 @@ -<?php - -require_once PATH_THIRDPARTY . 'propel/util/BasePeer.php'; -// The object class -- needed for instanceof checks in this class. -// actual class may be a subclass -- as returned by {className}Peer::getOMClass() -include_once '{pathClasses}/' . SYS_SYS . '/classes/{className}.php'; - -/** - * Base static class for performing query and update operations on the '{tableName}' table. - * - * - * - * @package classes.model.om - */ -abstract class Base{className}Peer { - - /** the default database name for this class */ - const DATABASE_NAME = '{connection}'; - - /** the table name for this class */ - const TABLE_NAME = '{tableName}'; - - /** the table GUID for this class */ - const __UID__ = '{GUID}'; - - /** A class that can be returned by this peer. */ - const CLASS_DEFAULT = 'classes.model.{className}'; - - /** The total number of columns. */ - const NUM_COLUMNS = {totalColumns}; - - /** The number of lazy-loaded columns. */ - const NUM_LAZY_LOAD_COLUMNS = 0; - -<!-- START BLOCK : allColumns1 --> - /** the column name for the {name} field */ - const {name} = '{tableName}.{name}'; -<!-- END BLOCK : allColumns1 --> - - /** The PHP to DB Name Mapping */ - private static $phpNameMap = null; - - - /** - * holds an array of fieldnames - * - * first dimension keys are the type constants - * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' - */ - private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ( -<!-- START BLOCK : allColumns2 --> -'{phpName}', -<!-- END BLOCK : allColumns2 --> -), - BasePeer::TYPE_COLNAME => array ( -<!-- START BLOCK : allColumns3 --> -{className}Peer::{name}, -<!-- END BLOCK : allColumns3 --> -), - BasePeer::TYPE_FIELDNAME => array ( -<!-- START BLOCK : allColumns4 --> -'{name}', -<!-- END BLOCK : allColumns4 --> -), - BasePeer::TYPE_NUM => array ( -<!-- START BLOCK : allColumns5 --> -{index}, -<!-- END BLOCK : allColumns5 --> -)); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ( -<!-- START BLOCK : allColumns6 --> -'{phpName}' => {index}, -<!-- END BLOCK : allColumns6 --> -), - BasePeer::TYPE_COLNAME => array ( -<!-- START BLOCK : allColumns7 --> -{className}Peer::{name} => {index}, -<!-- END BLOCK : allColumns7 --> -), - BasePeer::TYPE_FIELDNAME => array ( -<!-- START BLOCK : allColumns8 --> -'{name}' => {index}, -<!-- END BLOCK : allColumns8 --> -), - BasePeer::TYPE_NUM => array ( -<!-- START BLOCK : allColumns9 --> -{index}, -<!-- START BLOCK : allColumns9 --> -)); - - /** - * @return MapBuilder the map builder for this peer - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getMapBuilder() - { - include_once '{pathClasses}/' . SYS_SYS . '/classes/map/{className}MapBuilder.php'; - return BasePeer::getMapBuilder('classes.model.map.{className}MapBuilder'); - } - /** - * Gets a map (hash) of PHP names to DB column names. - * - * @return array The PHP to DB name map for this peer - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. - */ - public static function getPhpNameMap() - { - if (self::$phpNameMap === null) { - $map = {className}Peer::getTableMap(); - $columns = $map->getColumns(); - $nameMap = array(); - foreach ($columns as $column) { - $nameMap[$column->getPhpName()] = $column->getColumnName(); - } - self::$phpNameMap = $nameMap; - } - return self::$phpNameMap; - } - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants TYPE_PHPNAME, - * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - */ - static public function translateFieldName($name, $fromType, $toType) - { - $toNames = self::getFieldNames($toType); - $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); - } - return $toNames[$key]; - } - - /** - * Returns an array of of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants TYPE_PHPNAME, - * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM - * @return array A list of field names - */ - - static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, self::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); - } - return self::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * <code> - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * </code> - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. {className}Peer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace({className}Peer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param criteria object containing the columns to add. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria) - { -<!-- START BLOCK : allColumns10 --> - $criteria->addSelectColumn({className}Peer::{name}); -<!-- END BLOCK : allColumns10 --> - } - - const COUNT = 'COUNT({tableName}.{firstColumn})'; - const COUNT_DISTINCT = 'COUNT(DISTINCT {tableName}.{firstColumn})'; - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). - * @param Connection $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, $con = null) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // clear out anything that might confuse the ORDER BY clause - $criteria->clearSelectColumns()->clearOrderByColumns(); - if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->addSelectColumn({className}Peer::COUNT_DISTINCT); - } else { - $criteria->addSelectColumn({className}Peer::COUNT); - } - - // just in case we're grouping: add those columns to the select statement - foreach($criteria->getGroupByColumns() as $column) - { - $criteria->addSelectColumn($column); - } - - $rs = {className}Peer::doSelectRS($criteria, $con); - if ($rs->next()) { - return $rs->getInt(1); - } else { - // no rows returned; we infer that means 0 matches. - return 0; - } - } - /** - * Method to select one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param Connection $con - * @return {className} - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = {className}Peer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - return null; - } - /** - * Method to do selects. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param Connection $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, $con = null) - { - return {className}Peer::populateObjects({className}Peer::doSelectRS($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() - * method to get a ResultSet. - * - * Use this method directly if you want to just get the resultset - * (instead of an array of objects). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param Connection $con the connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return ResultSet The resultset object with numerically-indexed fields. - * @see BasePeer::doSelect() - */ - public static function doSelectRS(Criteria $criteria, $con = null) - { - if ($con === null) { - $con = Propel::getConnection(self::DATABASE_NAME); - } - - if (!$criteria->getSelectColumns()) { - $criteria = clone $criteria; - {className}Peer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(self::DATABASE_NAME); - - // BasePeer returns a Creole ResultSet, set to return - // rows indexed numerically. - return BasePeer::doSelect($criteria, $con); - } - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(ResultSet $rs) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = {className}Peer::getOMClass(); - $cls = Propel::import($cls); - // populate the object(s) - while($rs->next()) { - - $obj = new $cls(); - $obj->hydrate($rs); - $results[] = $obj; - - } - return $results; - } - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); - } - - /** - * The class that the Peer will make instances of. - * - * This uses a dot-path notation which is tranalted into a path - * relative to a location on the PHP include_path. - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') - * - * @return string path.to.ClassName - */ - public static function getOMClass() - { - return {className}Peer::CLASS_DEFAULT; - } - - /** - * Method perform an INSERT on the database, given a {className} or Criteria object. - * - * @param mixed $values Criteria or {className} object containing data that is used to create the INSERT statement. - * @param Connection $con the connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, $con = null) - { - if ($con === null) { - $con = Propel::getConnection(self::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from {className} object - } - - - // Set the correct dbName - $criteria->setDbName(self::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->begin(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch(PropelException $e) { - $con->rollback(); - throw $e; - } - - return $pk; - } - - /** - * Method perform an UPDATE on the database, given a {className} or Criteria object. - * - * @param mixed $values Criteria or {className} object containing data that is used to create the UPDATE statement. - * @param Connection $con The connection to use (specify Connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, $con = null) - { - if ($con === null) { - $con = Propel::getConnection(self::DATABASE_NAME); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity -<!-- START BLOCK : primaryKeys1 --> - $comparison = $criteria->getComparison({className}Peer::{name}); - $selectCriteria->add({className}Peer::{name}, $criteria->remove({className}Peer::{name}), $comparison); -<!-- END BLOCK : primaryKeys1 --> - } else { // $values is {className} object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(self::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Method to DELETE all rows from the {tableName} table. - * - * @return int The number of affected rows (if supported by underlying database driver). - */ - public static function doDeleteAll($con = null) - { - if ($con === null) { - $con = Propel::getConnection(self::DATABASE_NAME); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->begin(); - $affectedRows += BasePeer::doDeleteAll({className}Peer::TABLE_NAME, $con); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollback(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a {className} or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or {className} object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param Connection $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, $con = null) - { - if ($con === null) { - $con = Propel::getConnection({className}Peer::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } elseif ($values instanceof {className}) { - - $criteria = $values->buildPkeyCriteria(); - } else { - // it must be the primary key - $criteria = new Criteria(self::DATABASE_NAME); - {forDoDeleteFunction} - } - - // Set the correct dbName - $criteria->setDbName(self::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->begin(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollback(); - throw $e; - } - } - - /** - * Validates all modified columns of given {className} object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param {className} $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate({className} $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap({className}Peer::DATABASE_NAME); - $tableMap = $dbMap->getTable({className}Peer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach($cols as $colName) { - if ($tableMap->containsColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate({className}Peer::DATABASE_NAME, {className}Peer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param mixed $pk the primary key. - * @param Connection $con the connection to use - * @return {className} - */ - public static function retrieveByPK( {sKeys}, $con = null) { - if ($con === null) { - $con = Propel::getConnection(self::DATABASE_NAME); - } - $criteria = new Criteria(); - -<!-- START BLOCK : primaryKeys2 --> - $criteria->add({className}Peer::{name}, ${var}); -<!-- START BLOCK : primaryKeys2 --> - - //$criteria->add({className}Peer::PM_UNIQUE_ID, $pm_unique_id); - $v = {className}Peer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param Connection $con the connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - {retrieveByPKsFunction} - -} // Base{className}Peer - -// static code to register the map builder for this Peer with the main Propel class -if (Propel::isInit()) { - // the MapBuilder classes register themselves with Propel during initialization - // so we need to load them here. - try { - Base{className}Peer::getMapBuilder(); - } catch (Exception $e) { - Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); - } -} else { - // even if Propel is not yet initialized, the map builder class can be registered - // now and then it will be loaded when Propel initializes. - require_once '{pathClasses}/' . SYS_SYS . '/classes/map/{className}MapBuilder.php'; - Propel::registerMapBuilder('classes.model.map.{className}MapBuilder'); -} diff --git a/workflow/engine/templates/additionalTables/paged-table.html b/workflow/engine/templates/additionalTables/paged-table.html deleted file mode 100755 index cde0e60bb..000000000 --- a/workflow/engine/templates/additionalTables/paged-table.html +++ /dev/null @@ -1,222 +0,0 @@ -<!-- START BLOCK : headBlock --> -<div class="treeBase"> -<table cellpadding="0" cellspacing="0" border="0"><tr><td> -<div class="boxTop"><div class="a"></div><div class="b"></div><div class="c"></div></div> -<div class="pagedTableDefault"> - <table id="pagedtable[{pagedTable_Id}]" name="pagedtable[{pagedTable_Name}]" border="0" cellspacing="0" cellpadding="0" class="Default"> -<tr > - <td valign="top"> - - <span class='subtitle'>{title}</span> - <table cellspacing="0" cellpadding="0" width="100%" border="0"> - <!-- START BLOCK : headerBlock --> - <tr><td class="headerContent">{content}</td></tr> - <!-- END BLOCK : headerBlock --> - </table> - <table id="table[{pagedTable_Id}]" name="table[{pagedTable_Name}]" cellspacing="0" cellpadding="0" width="100%" class="pagedTable"> - <!-- END BLOCK : headBlock --> - <!-- START BLOCK : contentBlock --> - <script type="text/javascript">{pagedTable_JS}</script> - <tr> - <!-- START BLOCK : headers --> - <td class="pagedTableHeader"><img style="{displaySeparator}" src="/js/maborak/core/images/separatorTable.gif" /></td> - <td width="{width}" style="{align}" class="pagedTableHeader" > - <a href="{href}" onclick="{onclick}">{header}</a> - </td> - <!-- END BLOCK : headers --> - </tr> - - - - <!-- START BLOCK : row --> - - <!-- START BLOCK : rowMaster --> - <tr class='{masterRowClass}' id="{masterRowName}"> - <!-- START BLOCK : fieldMaster --> - <td class="pagedTableHeader1"><a href="#" ><img src="/images/minus.gif" onClick="toggleMasterDetailGroup('table[{pagedTable_Name}]','{masterRowName}',this);return false;" border="0"></a><b>{value1}</b></td><td class="pagedTableHeader1" {alignAttr}><b>{value}</b> </td> - <!-- END BLOCK : fieldMaster --> - </tr> -<!-- END BLOCK : rowMaster --> - - <tr class='{class}' onmouseover="setRowClass(this, 'RowPointer' )" onmouseout="setRowClass(this, '{class}')" name="{rowName}" id="{rowName}"> - <!-- START BLOCK : field --> - <td{classAttr}></td><td{classAttr}{alignAttr}>{value}</td> - <!-- END BLOCK : field --> - </tr> -<!-- END BLOCK : row --> - - - <!-- START BLOCK : rowTag --> - <!-- END BLOCK : rowTag --> - - <!-- START BLOCK : norecords --> - <tr class='Row2'> - <td nowrap colspan="{columnCount}" align='center' >  - {noRecordsFound}<br>  - </td> - </tr> - <!-- END BLOCK : norecords --> - - <!-- START BLOCK : bottomFooter --> - <tr> - <td class="treeNode" colspan="6" align="right" > - - <a href="#" onclick="checkAll()">{labels:CHECK_ALL}</a> /  - <a href="#" onclick="uncheckAll()">{labels:UNCHECK_ALL}</a> /  - <a href="#" onclick="doExport()">{labels:ID_EXPORT}</a> - <!-- <input style="" class="module_app_button___gray " id="form[BTN_SUBMIT]" name="form[BTN_SUBMIT]" value="Assign" onclick="selectionX();" type="button"> --> - </td> - </tr> - - <tr> - <td nowrap colspan="{columnCount}"> - <table width="100%" border="0" cellspacing="0" cellpadding="0"> - <tr class="pagedTableFooter"> - <td width="110px" style="{indexStyle}"> - {labels:ID_ROWS} {firstRow}-{lastRow}/{totalRows}  - </td> - <!--<td style="text-align:center;{fastSearchStyle}"><!--{labels:ID_SEARCH} - <input type="text" class="FormField" onkeypress="if (event.keyCode===13){pagedTableId}.doFastSearch(this.value);if (event.keyCode===13)return false;" value="{fastSearchValue}" onfocus="this.select();" size="10" style="{fastSearchStyle}"/> - </td>--> - <td style="text-align:center;"> - {first}{prev}{next}{last} - </td> - <td width="60px" style="text-align:right;padding-right:8px;{indexStyle}">{labels:ID_PAGE} {currentPage}/{totalPages}</td> - </tr> - </table> - </td> - </tr> - <!-- END BLOCK : bottomFooter --> - <!-- END BLOCK : contentBlock --> -<!-- START BLOCK : closeBlock --> - </table> - - </td> -</tr> -</table> -</div> -<div class="boxBottom"><div class="a"></div><div class="b"></div><div class="c"></div></div> -</td></tr></table></div> -<!-- END BLOCK : closeBlock --> -<!-- START IGNORE --> - -<script type="text/javascript"> - -function toggleMasterDetailGroup(tablename,groupName,imgicon){ - groupNameArray=groupName.split(","); - table=getElementByName(tablename); - var rows = table.getElementsByTagName('tr'); - for(i=0;i<rows.length;i++){ - if(rows[i].id!=""){ - currentRowArray=rows[i].id.split(","); - sw=false; - - tempVar=currentRowArray[0].split("_MD_"); - if(tempVar[0]==""){ - if(currentRowArray.length>groupNameArray.length){ - currentRowArray[0]=tempVar[1]; - } - } - for(j=0;j<groupNameArray.length;j++){ - if(currentRowArray[j]==groupNameArray[j]){ - sw=true; - }else{ - sw=false; - } - } - if(sw){ - if (rows[i].style.display == '') { - rows[i].style.display = 'none'; - imgicon.src="/images/plus_red.gif"; - }else{ - rows[i].style.display = ''; - imgicon.src="/images/minus.gif"; - } - } - } - } -} - -function $(id){ - return document.getElementById(id); -} - - -if (typeof(checks_selected_ids) == "undefined"){ - var checks_selected_ids = new Array(); - var checks_selected_schema = new Array(); - var checks_selected_data = new Array(); -} - -function catchSelectedItems(){ - var inputs = document.getElementsByTagName("input"); - - for(i=0; i<inputs.length; i++){ - if( inputs[i].type == "checkbox" ){ - try{ - inputs[i].onclick = function(){ - if(this.checked){ - if( this.id.search(/ADD_TAB_UID/) != -1){ - checks_selected_ids.push(this.value); - } else if( this.id.search(/ADD_SCHEMA/) != -1){ - checks_selected_schema.push(this.value); - } else if( this.id.search(/ADD_DATA/) != -1){ - checks_selected_data.push(this.value); - } - } else { - if( this.id.search(/ADD_TAB_UID/) != -1){ - checks_selected_ids.deleteByValue(this.value); - } else if( this.id.search(/ADD_SCHEMA/) != -1){ - checks_selected_schema.deleteByValue(this.value); - } else if( this.id.search(/ADD_DATA/) != -1){ - checks_selected_data.deleteByValue(this.value); - } - } - }; - - for(j=0; j<checks_selected_ids.length; j++){ - if( inputs[i].value == checks_selected_ids[j] ){ - inputs[i].checked = true; - } - } - for(j=0; j<checks_selected_schema.length; j++){ - if( inputs[i].value == checks_selected_schema[j] ){ - inputs[i].checked = true; - } - } - for(j=0; j<checks_selected_data.length; j++){ - if( inputs[i].value == checks_selected_data[j] ){ - inputs[i].checked = true; - } - } - } catch(e){alert(e)} - } - } -} -setTimeout('catchSelectedItems()', 300); - - -function checkAll(){ - var inputs = document.getElementsByTagName("input"); - - for(i=0; i<inputs.length; i++){ - if( inputs[i].type == "checkbox" && inputs[i].checked == false){ - inputs[i].checked = true; - inputs[i].onclick(); - } - } -} - -function uncheckAll(){ - var inputs = document.getElementsByTagName("input"); - - for(i=0; i<inputs.length; i++){ - if( inputs[i].type == "checkbox" ){ - inputs[i].checked = false; - inputs[i].onclick(); - } - } -} - -</script> -<!-- END IGNORE --> \ No newline at end of file diff --git a/workflow/engine/templates/additionalTables/paged-table2.html b/workflow/engine/templates/additionalTables/paged-table2.html deleted file mode 100755 index c3853bfb8..000000000 --- a/workflow/engine/templates/additionalTables/paged-table2.html +++ /dev/null @@ -1,137 +0,0 @@ -<!-- START BLOCK : headBlock --> -<table cellpadding="0" cellspacing="0" border="0"><tr><td> -<div class="boxTop"><div class="a"></div><div class="b"></div><div class="c"></div></div> -<div class="pagedTableDefault"> - <table id="pagedtable[{pagedTable_Id}]" name="pagedtable[{pagedTable_Name}]" border="0" cellspacing="0" cellpadding="0" class="Default"> -<tr > - <td valign="top"> - <span class='subtitle'>{title}</span> - <center><span id="mainlabel" class="SelectedMenu"></span></center><br/> - <table cellspacing="0" cellpadding="0" width="100%" border="0"> - <!-- START BLOCK : headerBlock --> - <tr><td class="headerContent">{content}</td></tr> - <!-- END BLOCK : headerBlock --> - </table> - <table id="table[{pagedTable_Id}]" name="table[{pagedTable_Name}]" cellspacing="0" cellpadding="0" width="100%" class="pagedTable"> - <!-- END BLOCK : headBlock --> - <!-- START BLOCK : contentBlock --> - <script type="text/javascript">{pagedTable_JS}</script> - <tr> - <!-- START BLOCK : headers --> - <td class="pagedTableHeader"><img style="{displaySeparator}" src="/js/maborak/core/images/separatorTable.gif" /></td> - <td width="{width}" style="{align}" class="pagedTableHeader" > - <a href="{href}" onclick="{onclick}">{header}</a> - </td> - <!-- END BLOCK : headers --> - </tr> - -<!-- START IGNORE --> -<script type="text/javascript"> -document.getElementById('mainlabel').innerHTML = groupname; -</script> -<!-- END IGNORE --> - - <!-- START BLOCK : row --> - - <!-- START BLOCK : rowMaster --> - <tr class='{masterRowClass}' id="{masterRowName}"> - <!-- START BLOCK : fieldMaster --> - <td class="pagedTableHeader1"><a href="#" ><img src="/images/minus.gif" onClick="toggleMasterDetailGroup('table[{pagedTable_Name}]','{masterRowName}',this);return false;" border="0"></a><b>{value1}</b></td><td class="pagedTableHeader1" {alignAttr}><b>{value}</b> </td> - <!-- END BLOCK : fieldMaster --> - </tr> -<!-- END BLOCK : rowMaster --> - - <tr class='{class}' onmouseover="setRowClass(this, 'RowPointer' )" onmouseout="setRowClass(this, '{class}')" name="{rowName}" id="{rowName}"> - <!-- START BLOCK : field --> - <td{classAttr}></td><td{classAttr}{alignAttr}>{value}</td> - <!-- END BLOCK : field --> - </tr> -<!-- END BLOCK : row --> - - - <!-- START BLOCK : rowTag --> - <!-- END BLOCK : rowTag --> - - <!-- START BLOCK : norecords --> - <tr class='Row2'> - <td nowrap colspan="{columnCount}" align='center' >  - {noRecordsFound}<br>  - </td> - </tr> - <!-- END BLOCK : norecords --> - - <!-- START BLOCK : bottomFooter --> - - <tr> - <td nowrap colspan="{columnCount}"> - <table width="100%" border="0" cellspacing="0" cellpadding="0"> - <tr class="pagedTableFooter"> - <td width="110px" style="{indexStyle}"> - {labels:ID_ROWS} {firstRow}-{lastRow}/{totalRows}  - </td> - <!--<td style="text-align:center;{fastSearchStyle}"><!--{labels:ID_SEARCH} - <input type="text" class="FormField" onkeypress="if (event.keyCode===13){pagedTableId}.doFastSearch(this.value);if (event.keyCode===13)return false;" value="{fastSearchValue}" onfocus="this.select();" size="10" style="{fastSearchStyle}"/> - </td>--> - <td style="text-align:center;"> - {first}{prev}{next}{last} - </td> - <td width="60px" style="text-align:right;padding-right:8px;{indexStyle}">{labels:ID_PAGE} {currentPage}/{totalPages}</td> - </tr> - </table> - </td> - </tr> - <!-- END BLOCK : bottomFooter --> - <!-- END BLOCK : contentBlock --> -<!-- START BLOCK : closeBlock --> - </table> - - </td> -</tr> -</table> -</div> -<div class="boxBottom"><div class="a"></div><div class="b"></div><div class="c"></div></div> -</td></tr></table> -<!-- END BLOCK : closeBlock --> -<!-- START IGNORE --> - -<script type="text/javascript"> - -function toggleMasterDetailGroup(tablename,groupName,imgicon){ - groupNameArray=groupName.split(","); - table=getElementByName(tablename); - var rows = table.getElementsByTagName('tr'); - for(i=0;i<rows.length;i++){ - if(rows[i].id!=""){ - currentRowArray=rows[i].id.split(","); - sw=false; - //alert(groupNameArray); - //alert(currentRowArray); - tempVar=currentRowArray[0].split("_MD_"); - if(tempVar[0]==""){ - if(currentRowArray.length>groupNameArray.length){ - currentRowArray[0]=tempVar[1]; - } - } - for(j=0;j<groupNameArray.length;j++){ - if(currentRowArray[j]==groupNameArray[j]){ - sw=true; - }else{ - sw=false; - } - } - if(sw){ - if (rows[i].style.display == '') { - rows[i].style.display = 'none'; - imgicon.src="/images/plus_red.gif"; - }else{ - rows[i].style.display = ''; - imgicon.src="/images/minus.gif"; - } - } - } - } -} -document.getElementById('mainlabel').innerHTML = '<font size="2"><b>'+groupname+' group</b></font>'; - -</script> -<!-- END IGNORE --> \ No newline at end of file diff --git a/workflow/engine/templates/pmTables/data.js b/workflow/engine/templates/pmTables/data.js index 519f5b12a..ac64ad9e8 100644 --- a/workflow/engine/templates/pmTables/data.js +++ b/workflow/engine/templates/pmTables/data.js @@ -256,7 +256,8 @@ Ext.onReady(function(){ layout: 'fit', autoScroll: false, items: [infoGrid] - }); + }); + }); //Funtion Handles Context Menu Opening diff --git a/workflow/engine/templates/pmTables/edit.js b/workflow/engine/templates/pmTables/edit.js index d8272b58c..702d7197c 100644 --- a/workflow/engine/templates/pmTables/edit.js +++ b/workflow/engine/templates/pmTables/edit.js @@ -193,7 +193,8 @@ Ext.onReady(function(){ forceSelection: true, store: new Ext.data.SimpleStore({ fields: ['type_id', 'type'], - data : [['VARCHAR',_("ID_VARCHAR")],['TEXT',_("ID_TEXT")],['DATE',_("ID_DATE")],['INT',_("ID_INT")],['FLOAT',_("ID_FLOAT")]], + //data : [['VARCHAR',_("ID_VARCHAR")],['TEXT',_("ID_TEXT")],['DATE',_("ID_DATE")],['INT',_("ID_INT")],['FLOAT',_("ID_FLOAT")]], + data: columnsTypes, sortInfo: {field:'type_id', direction:'ASC'} }) }) @@ -231,9 +232,9 @@ Ext.onReady(function(){ }, { xtype: 'booleancolumn', header: _('ID_AUTO_INCREMENT'), - dataIndex: 'field_bai', + dataIndex: 'field_autoincrement', align: 'center', - width: 50, + width: 80, trueText: 'Yes', falseText: 'No', editor: { @@ -277,7 +278,7 @@ Ext.onReady(function(){ {name: 'field_type'}, {name: 'field_size', type: 'float'}, {name: 'field_null', type: 'float'}, - {name: 'field_bai', type: 'float'}, + {name: 'field_autoincrement', type: 'float'}, {name: 'field_filter', type: 'string'} ] }); @@ -582,12 +583,19 @@ Ext.onReady(function(){ buttons:[ { text: TABLE === false ? _("ID_CREATE") : _("ID_UPDATE"), - handler: createReportTable + handler: function() { + if (TABLE === false || dataNumRows == 0) { + createReportTable(); + } + else { + PMExt.confirm(_('ID_CONFIRM'), _('ID_PMTABLE_SAVE_AND_DATA_LOST'), createReportTable); + } + } }, { text:_("ID_CANCEL"), handler: function() { proParam = PRO_UID !== false ? '?PRO_UID='+PRO_UID : ''; - location.href = '../pmTables' + proParam; //history.back(); + location.href = '../pmTables' + proParam; } } ] @@ -607,7 +615,19 @@ Ext.onReady(function(){ loadTableRowsFromArray(TABLE.FIELDS); } - //DDLoadFields(); + + if (dataNumRows > 0) { + var tpl = new Ext.Template( + '<div id="fb" style="border: 1px solid #FF0000; background-color:#FFAAAA; display:none; padding:15px; color:#000000; font-size:12px;">'+ + '<b>Warning: </b> ' + dataNumRows + ' ' + _('ID_PMTABLE_DATA_EXISTS_WARNINIG') + ' <a href="#" id="hideWarning">[ '+_('ID_HIDE')+' ]</a></div>' + ); + var newEl = tpl.insertFirst(document.getElementById('assignedGrid')); + + Ext.fly('hideWarning').on('click', function() { + Ext.fly(newEl).slideOut('t',{remove:true}); + }); + Ext.fly(newEl).slideIn(); + } }); @@ -660,7 +680,7 @@ function createReportTable() } // validate field size for varchar & int column types - if ((row.data['field_type'] == 'VARCHAR' || row.data['field_type'] == 'INT') && row.data['field_size'] == '') { + if ((row.data['field_type'] == 'VARCHAR' || row.data['field_type'] == 'INTEGER') && row.data['field_size'] == '') { PMExt.error(_('ID_ERROR'), _('ID_PMTABLES_ALERT5')+' '+row.data['field_name']+' ('+row.data['field_type']+').'); return false; } @@ -690,13 +710,25 @@ function createReportTable() columns : Ext.util.JSON.encode(columns) }, success: function(resp){ - result = Ext.util.JSON.decode(resp.responseText); - - if (result.success) { - proParam = PRO_UID !== false ? '?PRO_UID='+PRO_UID : ''; - location.href = '../pmTables' + proParam; //history.back(); - } else { - Ext.Msg.alert( _('ID_ERROR'), result.msg); + try { + result = Ext.util.JSON.decode(resp.responseText); + + if (result.success) { + proParam = PRO_UID !== false ? '?PRO_UID='+PRO_UID : ''; + location.href = '../pmTables' + proParam; //history.back(); + } else { + PMExt.error(_('ID_ERROR'), result.type +': '+result.msg); + if (window.console && window.console.firebug) { + window.console.log(result.msg); + window.console.log(result.trace); + } + } + } catch (e) { + if (dbg) { + _showDebugWin(resp.responseText); + } else { + PMExt.error('ERROR', 'Something was wrong.'); + } } }, failure: function(obj, resp){ @@ -706,19 +738,41 @@ function createReportTable() } //end createReportTable +function _showDebugWin(content) +{ + dbgWin = new Ext.Window({ + title: '', + id: 'dbgWin', + layout: 'fit', + width: 570, + height: 400, + modal: false, + autoScroll: true, + maximizable: true, + //closeAction: 'hide', + maximizable : false, + items: [], + x: 0, + y: 0, + html: '<pre>' + content + '</pre>' + }); + + dbgWin.show(); +} + function addColumn() { var PMRow = assignedGrid.getStore().recordType; //var meta = mapPMFieldType(records[i].data['FIELD_UID']); var row = new PMRow({ - uid : '', + uid : '', field_uid : '', field_dyn : '', - field_name : '', - field_label : '', - field_type : '', - field_size : '', - field_key : 0, - field_null : 1 + field_name : '', + field_label: '', + field_type : '', + field_size : '', + field_key : 0, + field_null : 1 }); var len = assignedGrid.getStore().data.length; @@ -927,7 +981,7 @@ function loadTableRowsFromArray(records) field_size : records[i].FLD_SIZE, field_key : records[i].FLD_KEY == '1' ? true : false, field_null : records[i].FLD_NULL == '1' ? true : false, - field_bai : records[i].FLD_AUTO_INCREMENT == '1' ? true : false, + field_autoincrement : records[i].FLD_AUTO_INCREMENT == '1' ? true : false, field_filter: records[i].FLD_FILTER == '1' ? true : false }); store.add(row); diff --git a/workflow/engine/templates/pmTables/editReport.js b/workflow/engine/templates/pmTables/editReport.js index 170415e48..4a469cf23 100644 --- a/workflow/engine/templates/pmTables/editReport.js +++ b/workflow/engine/templates/pmTables/editReport.js @@ -314,7 +314,8 @@ Ext.onReady(function(){ valueField:'type_id', store: new Ext.data.SimpleStore({ fields: ['type_id', 'type'], - data : [['VARCHAR',_("ID_VARCHAR")],['TEXT',_("ID_TEXT")],['DATE',_("ID_DATE")],['INT',_("ID_INT")],['FLOAT',_("ID_FLOAT")]], + //data : [['VARCHAR',_("ID_VARCHAR")],['TEXT',_("ID_TEXT")],['DATE',_("ID_DATE")],['INT',_("ID_INT")],['FLOAT',_("ID_FLOAT")]], + data: columnsTypes, sortInfo: {field:'type_id', direction:'ASC'} }) }) @@ -330,7 +331,7 @@ Ext.onReady(function(){ }, { xtype: 'booleancolumn', header: _('ID_AUTO_INCREMENT'), - dataIndex: 'field_bai', + dataIndex: 'field_autoincrement', align: 'center', width: 50, trueText: 'Yes', @@ -380,7 +381,7 @@ Ext.onReady(function(){ {name: 'field_type'}, {name: 'field_size', type: 'float'}, {name: 'field_null', type: 'float'}, - {name: 'field_bai', type: 'float'}, + {name: 'field_autoincrement', type: 'float'}, {name: 'field_filter', type: 'string'} ] }); @@ -931,7 +932,7 @@ function createReportTable() } // validate field size for varchar & int column types - if ((row.data['field_type'] == 'VARCHAR' || row.data['field_type'] == 'INT') && row.data['field_size'] == '') { + if ((row.data['field_type'] == 'VARCHAR' || row.data['field_type'] == 'INTEGER') && row.data['field_size'] == '') { PMExt.error(_('ID_ERROR'), _('ID_PMTABLES_ALERT5')+' '+row.data['field_name']+' ('+row.data['field_type']+').'); return false; } @@ -962,7 +963,11 @@ function createReportTable() proParam = PRO_UID !== false ? '?PRO_UID='+PRO_UID : ''; location.href = '../pmTables' + proParam; //history.back(); } else { - Ext.Msg.alert( _('ID_ERROR'), result.msg+'\n'+result.trace); + PMExt.error(_('ID_ERROR'), result.type +': '+result.msg); + if (window.console && window.console.firebug) { + window.console.log(result.msg); + window.console.log(result.trace); + } } }, failure: function(obj, resp){ @@ -1139,15 +1144,17 @@ function setReportFields(records) { var meta = mapPMFieldType(records[i].data['FIELD_UID']); var row = new PMRow({ uid : '', - field_uid : records[i].data['FIELD_UID'], - field_dyn : records[i].data['FIELD_NAME'], + _index : records[i].data['_index'] !== '' ? records[i].data['_index'] : records[i].data['FIELD_DYN'], + field_uid : records[i].data['FIELD_UID'], + field_dyn : records[i].data['FIELD_NAME'], field_name : records[i].data['FIELD_NAME'].toUpperCase(), field_label : records[i].data['FIELD_NAME'].toUpperCase(), field_type : meta.type, field_size : meta.size, field_key : 0, field_null : 1, - _index : records[i].data['_index'] ? records[i].data['_index'] : records[i].data['FIELD_DYN'] + field_filter: 0, + field_autoincrement : 0 }); store.add(row); @@ -1231,7 +1238,7 @@ function loadTableRowsFromArray(records) field_size : records[i].FLD_SIZE, field_key : records[i].FLD_KEY, field_null : records[i].FLD_NULL, - field_bai : records[i].FLD_AUTO_INCREMENT == '1' ? true : false, + field_autoincrement : records[i].FLD_AUTO_INCREMENT == '1' ? true : false, field_filter: records[i].FLD_FILTER == '1' ? true : false, _index : '' }); @@ -1270,7 +1277,7 @@ function mapPMFieldType(id) sizeField='32'; break; case 'currency': - typeField='INT'; + typeField='INTEGER'; sizeField='11'; break; case 'percentage': @@ -1282,8 +1289,8 @@ function mapPMFieldType(id) sizeField=''; break; case 'textarea': - typeField='TEXT'; - sizeField=''; + typeField='VARCHAR'; + sizeField='255'; break; default: diff --git a/workflow/public_html/sysGeneric.php b/workflow/public_html/sysGeneric.php index e5b6bcf34..4b6513219 100644 --- a/workflow/public_html/sysGeneric.php +++ b/workflow/public_html/sysGeneric.php @@ -255,8 +255,8 @@ $startingTime = array_sum(explode(' ',microtime())); G::LoadSystem('form'); G::LoadSystem('menu'); G::LoadSystem("xmlMenu"); - G::LoadSystem('dvEditor'); - G::LoadSystem('table'); + //G::LoadSystem('dvEditor'); + //G::LoadSystem('table'); G::LoadSystem('controller'); G::LoadSystem('httpProxyController'); G::LoadSystem('pmException'); @@ -295,6 +295,11 @@ $startingTime = array_sum(explode(' ',microtime())); if ( file_exists( PATH_DB . SYS_TEMP . '/db.php' ) ) { require_once( PATH_DB . SYS_TEMP . '/db.php' ); define ( 'SYS_SYS' , SYS_TEMP ); + + // defining constant for workspace shared directory + define ( 'PATH_WORKSPACE' , PATH_DB . SYS_SYS . PATH_SEP ); + // including workspace shared classes -> particularlly for pmTables + set_include_path(get_include_path() . PATH_SEPARATOR . PATH_WORKSPACE); } else { $aMessage['MESSAGE'] = G::LoadTranslation ('ID_NOT_WORKSPACE');