From 75ffa736232efbd8da7d11d4a41f578ad1878880 Mon Sep 17 00:00:00 2001 From: Brayan Pereyra Date: Wed, 1 Apr 2015 15:31:02 -0400 Subject: [PATCH 01/10] PM-1957 Correccion en validacion al guardar CONSOLIDATED --- .../engine/classes/class.consolidatedCases.php | 16 ++++++++++++++-- .../src/ProcessMaker/BusinessModel/Task.php | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/workflow/engine/classes/class.consolidatedCases.php b/workflow/engine/classes/class.consolidatedCases.php index 85776f9ca..3cabfd476 100644 --- a/workflow/engine/classes/class.consolidatedCases.php +++ b/workflow/engine/classes/class.consolidatedCases.php @@ -6,6 +6,7 @@ class ConsolidatedCases { function saveConsolidated ($data) { + $status = $data['con_status']; $sTasUid = $data['tas_uid']; $sDynUid = $data['dyn_uid']; $sProUid = $data['pro_uid']; @@ -14,11 +15,21 @@ class ConsolidatedCases $title = $data['title']; if ($sRepTabUid != '') { + if (!$status) { + $oCaseConsolidated = new CaseConsolidated(); + $oCaseConsolidated = CaseConsolidatedPeer::retrieveByPK($sTasUid); + if (!(is_object($oCaseConsolidated)) || get_class($oCaseConsolidated) != 'CaseConsolidated') { + $oCaseConsolidated = new CaseConsolidated(); + $oCaseConsolidated->setTasUid($sTasUid); + $oCaseConsolidated->setConStatus('INACTIVE'); + $oCaseConsolidated->save(); + } + return 1; + } $rptUid = null; $criteria = new Criteria(); - $criteria->addSelectColumn(ReportTablePeer::REP_TAB_UID); - $criteria->add(ReportTablePeer::REP_TAB_NAME, $tableName); + $criteria->add(ReportTablePeer::REP_TAB_UID, $sRepTabUid); $rsCriteria = ReportTablePeer::doSelectRS($criteria); if ($rsCriteria->next()) { @@ -39,6 +50,7 @@ class ConsolidatedCases @unlink($sPath . PATH_SEP . 'map' . PATH_SEP . $sClassName . 'MapBuilder.php'); @unlink($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $sClassName . '.php'); @unlink($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $sClassName . 'Peer.php'); + $sRepTabUid = ''; } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Task.php b/workflow/engine/src/ProcessMaker/BusinessModel/Task.php index 404e63f68..b643559aa 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Task.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Task.php @@ -387,6 +387,7 @@ class Task G::LoadClass("consolidatedCases"); $consolidated = new \ConsolidatedCases(); $dataConso = array( + 'con_status' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_enable'], 'tas_uid' => $arrayProperty['TAS_UID'], 'dyn_uid' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_dynaform'], 'pro_uid' => $arrayProperty['PRO_UID'], @@ -395,7 +396,6 @@ class Task 'title' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_title'] ); $consolidated->saveConsolidated($dataConso); - } $arrayResult["status"] = "OK"; From d85098ff0653b1833afe48bc23f78a802dec842f Mon Sep 17 00:00:00 2001 From: "marcelo.cuiza" Date: Thu, 2 Apr 2015 09:44:16 -0400 Subject: [PATCH 02/10] PM-2061 Resolver las incidencias Very High y High del third Party Se validaron las incidencias --- gulliver/system/class.dbMaintenance.php | 8 ++ .../drivers/pgsql/metadata/PgSQLTableInfo.php | 77 +++++++++++++++++++ .../sqlite/metadata/SQLiteTableInfo.php | 12 ++- .../thirdparty/pear/PEAR/Command/Package.php | 11 +++ 4 files changed, 107 insertions(+), 1 deletion(-) diff --git a/gulliver/system/class.dbMaintenance.php b/gulliver/system/class.dbMaintenance.php index 5dbac67aa..1e6022198 100755 --- a/gulliver/system/class.dbMaintenance.php +++ b/gulliver/system/class.dbMaintenance.php @@ -443,8 +443,16 @@ class DataBaseMaintenance if (empty( $aTables )) return false; printf( "%-70s", "LOCK TABLES" ); + + if(is_array($aTables)) { + foreach($aTables as $k => $v) { + $aTables[$k] = mysql_real_escape_string($v); + } + } + $sQuery = "LOCK TABLES " . implode( " READ, ", $aTables ) . " READ; "; $sQuery = $filter->preventSqlInjection($sQuery); + if (@mysql_query( $sQuery )) { echo " [OK]\n"; return true; diff --git a/gulliver/thirdparty/creole/drivers/pgsql/metadata/PgSQLTableInfo.php b/gulliver/thirdparty/creole/drivers/pgsql/metadata/PgSQLTableInfo.php index 3a21d0ec8..be6988af0 100755 --- a/gulliver/thirdparty/creole/drivers/pgsql/metadata/PgSQLTableInfo.php +++ b/gulliver/thirdparty/creole/drivers/pgsql/metadata/PgSQLTableInfo.php @@ -70,6 +70,17 @@ class PgSQLTableInfo extends TableInfo { // Get the columns, types, etc. // Based on code from pgAdmin3 (http://www.pgadmin.org/) + + $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] ); + $docuroot = explode( '/', $realdocuroot ); + array_pop( $docuroot ); + $pathhome = implode( '/', $docuroot ) . '/'; + array_pop( $docuroot ); + $pathTrunk = implode( '/', $docuroot ) . '/'; + require_once($pathTrunk.'gulliver/system/class.inputfilter.php'); + $filter = new InputFilter(); + $this->oid = $filter->validateInput($this->oid, 'int'); + $result = pg_query ($this->conn->getResource(), sprintf ("SELECT att.attname, att.atttypmod, @@ -203,6 +214,17 @@ class PgSQLTableInfo extends TableInfo { { throw new SQLException ("Invalid domain name [" . $strDomain . "]"); } // if (strlen (trim ($strDomain)) < 1) + + $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] ); + $docuroot = explode( '/', $realdocuroot ); + array_pop( $docuroot ); + $pathhome = implode( '/', $docuroot ) . '/'; + array_pop( $docuroot ); + $pathTrunk = implode( '/', $docuroot ) . '/'; + require_once($pathTrunk.'gulliver/system/class.inputfilter.php'); + $filter = new InputFilter(); + $strDomain = $filter->validateInput($strDomain); + $result = pg_query ($this->conn->getResource(), sprintf ("SELECT d.typname as domname, b.typname as basetype, @@ -243,6 +265,16 @@ class PgSQLTableInfo extends TableInfo { protected function initForeignKeys() { include_once 'creole/metadata/ForeignKeyInfo.php'; + + $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] ); + $docuroot = explode( '/', $realdocuroot ); + array_pop( $docuroot ); + $pathhome = implode( '/', $docuroot ) . '/'; + array_pop( $docuroot ); + $pathTrunk = implode( '/', $docuroot ) . '/'; + require_once($pathTrunk.'gulliver/system/class.inputfilter.php'); + $filter = new InputFilter(); + $this->oid = $filter->validateInput($this->oid, 'int'); $result = pg_query ($this->conn->getResource(), sprintf ("SELECT conname, @@ -328,6 +360,16 @@ class PgSQLTableInfo extends TableInfo { // columns have to be loaded first if (!$this->colsLoaded) $this->initColumns(); + + $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] ); + $docuroot = explode( '/', $realdocuroot ); + array_pop( $docuroot ); + $pathhome = implode( '/', $docuroot ) . '/'; + array_pop( $docuroot ); + $pathTrunk = implode( '/', $docuroot ) . '/'; + require_once($pathTrunk.'gulliver/system/class.inputfilter.php'); + $filter = new InputFilter(); + $this->oid = $filter->validateInput($this->oid, 'int'); $result = pg_query ($this->conn->getResource(), sprintf ("SELECT DISTINCT ON(cls.relname) @@ -343,6 +385,16 @@ class PgSQLTableInfo extends TableInfo { if (!$result) { throw new SQLException("Could not list indexes keys for table: " . $this->name, pg_last_error($this->conn->getResource())); } + + $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] ); + $docuroot = explode( '/', $realdocuroot ); + array_pop( $docuroot ); + $pathhome = implode( '/', $docuroot ) . '/'; + array_pop( $docuroot ); + $pathTrunk = implode( '/', $docuroot ) . '/'; + require_once($pathTrunk.'gulliver/system/class.inputfilter.php'); + $filter = new InputFilter(); + $this->oid = $filter->validateInput($this->oid); while($row = pg_fetch_assoc($result)) { $name = $row["idxname"]; @@ -353,6 +405,8 @@ class PgSQLTableInfo extends TableInfo { $arrColumns = explode (' ', $row['indkey']); foreach ($arrColumns as $intColNum) { + $intColNum = $filter->validateInput($intColNum, 'int'); + $result2 = pg_query ($this->conn->getResource(), sprintf ("SELECT a.attname FROM pg_catalog.pg_class c JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid WHERE c.oid = '%s' AND a.attnum = %d AND NOT a.attisdropped @@ -380,6 +434,16 @@ class PgSQLTableInfo extends TableInfo { // Primary Keys + $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] ); + $docuroot = explode( '/', $realdocuroot ); + array_pop( $docuroot ); + $pathhome = implode( '/', $docuroot ) . '/'; + array_pop( $docuroot ); + $pathTrunk = implode( '/', $docuroot ) . '/'; + require_once($pathTrunk.'gulliver/system/class.inputfilter.php'); + $filter = new InputFilter(); + $this->oid = $filter->validateInput($this->oid); + $result = pg_query($this->conn->getResource(), sprintf ("SELECT DISTINCT ON(cls.relname) cls.relname as idxname, @@ -395,11 +459,24 @@ class PgSQLTableInfo extends TableInfo { // Loop through the returned results, grouping the same key_name together // adding each column for that key. + + $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] ); + $docuroot = explode( '/', $realdocuroot ); + array_pop( $docuroot ); + $pathhome = implode( '/', $docuroot ) . '/'; + array_pop( $docuroot ); + $pathTrunk = implode( '/', $docuroot ) . '/'; + require_once($pathTrunk.'gulliver/system/class.inputfilter.php'); + $filter = new InputFilter(); + $this->oid = $filter->validateInput($this->oid); + while($row = pg_fetch_assoc($result)) { $arrColumns = explode (' ', $row['indkey']); foreach ($arrColumns as $intColNum) { + $intColNum = $filter->validateInput($intColNum, 'int'); + $result2 = pg_query ($this->conn->getResource(), sprintf ("SELECT a.attname FROM pg_catalog.pg_class c JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid WHERE c.oid = '%s' AND a.attnum = %d AND NOT a.attisdropped diff --git a/gulliver/thirdparty/creole/drivers/sqlite/metadata/SQLiteTableInfo.php b/gulliver/thirdparty/creole/drivers/sqlite/metadata/SQLiteTableInfo.php index 011deaa82..c88eab6a1 100755 --- a/gulliver/thirdparty/creole/drivers/sqlite/metadata/SQLiteTableInfo.php +++ b/gulliver/thirdparty/creole/drivers/sqlite/metadata/SQLiteTableInfo.php @@ -103,13 +103,23 @@ class SQLiteTableInfo extends TableInfo { include_once 'creole/metadata/IndexInfo.php'; // columns have to be loaded first - if (!$this->colsLoaded) $this->initColumns(); + if (!$this->colsLoaded) $this->initColumns(); + + $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] ); + $docuroot = explode( '/', $realdocuroot ); + array_pop( $docuroot ); + $pathhome = implode( '/', $docuroot ) . '/'; + array_pop( $docuroot ); + $pathTrunk = implode( '/', $docuroot ) . '/'; + require_once($pathTrunk.'gulliver/system/class.inputfilter.php'); + $filter = new InputFilter(); $sql = "PRAGMA index_list('".$this->name."')"; $res = sqlite_query($this->conn->getResource(), $sql); while($row = sqlite_fetch_array($res, SQLITE_ASSOC)) { $name = $row['name']; + $name = $filter->validateInput($name); $this->indexes[$name] = new IndexInfo($name); // get columns for that index diff --git a/gulliver/thirdparty/pear/PEAR/Command/Package.php b/gulliver/thirdparty/pear/PEAR/Command/Package.php index 544452e4e..f7b24490f 100755 --- a/gulliver/thirdparty/pear/PEAR/Command/Package.php +++ b/gulliver/thirdparty/pear/PEAR/Command/Package.php @@ -451,6 +451,17 @@ Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm } $plist = implode(" ", $params); $cmd = "$php -C -d include_path=$cwd$ps$ip -f $run_tests -- $plist"; + + $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] ); + $docuroot = explode( '/', $realdocuroot ); + array_pop( $docuroot ); + $pathhome = implode( '/', $docuroot ) . '/'; + array_pop( $docuroot ); + $pathTrunk = implode( '/', $docuroot ) . '/'; + require_once($pathTrunk.'gulliver/system/class.inputfilter.php'); + $filter = new InputFilter(); + $cmd = $filter->validateInput($cmd); + system($cmd); return true; } From 3e407d4770979117b5c68e37ba4444cd9612aac4 Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Thu, 2 Apr 2015 11:56:46 -0400 Subject: [PATCH 03/10] PM-2017 "Admin > Settings > Cases Lists Cache Builder..." SOLVED Issue: Admin > Settings > Cases Lists Cache Builder: La informacion en el contenedor "Workflow Applications Cache Info" no se muestra Cause: Se esta mandando un parametro de tipo array al metodo "setUserInfo", este metodo espera como parametro un string Solution: Se manda un parametro correcto al metodo "setUserInfo" Note: - Este cambio corrige el notice ----> Array to string conversion... - Se observo que en el server de QA en donde se replico el problema, existe una instalacion de MySQL (osea ya existe esta instancia). Posteriormente utilizaron el instalador de ProcessMaker (.exe), en donde este instalador tiene otra instancia de MySQL (el instalador .exe tiene Apache, PHP y MySQL). Este entorno de servidor es complejo ya que existen varias instancias de MySQL. Lo correcto seria tener un server limpio y luego instalar el .exe - Se pide a QA que pruebe el instalador .exe actual que se tiene y probarlo en un server limpio --- gulliver/thirdparty/creole/Creole.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulliver/thirdparty/creole/Creole.php b/gulliver/thirdparty/creole/Creole.php index 4897a5dcc..175878527 100755 --- a/gulliver/thirdparty/creole/Creole.php +++ b/gulliver/thirdparty/creole/Creole.php @@ -244,7 +244,7 @@ class Creole { try { $obj->connect($dsninfo, $flags); } catch(SQLException $sqle) { - $sqle->setUserInfo($dsninfo); + $sqle->setUserInfo((isset($dsninfo["username"]))? $dsninfo["username"] : ""); throw $sqle; } $persistent = ($flags & Creole::PERSISTENT) === Creole::PERSISTENT; From 819dfb3e138bacefdb8c51d6f698650c32261c47 Mon Sep 17 00:00:00 2001 From: "Paula V. Quispe" Date: Thu, 2 Apr 2015 15:33:36 -0400 Subject: [PATCH 04/10] I solved the issue PM-2067 with mask %Y-%m-%d %k:%M --- gulliver/system/class.xmlform.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index 6bbc9a46a..73b519c94 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -4819,16 +4819,37 @@ class XmlForm_Field_Date extends XmlForm_Field_SimpleText } } - $withHours = (strpos($mask, '%H') !== false || strpos($mask, '%M') !== false || strpos($mask, '%S') !== false); + $withHours = (strpos($mask, '%H') !== false || strpos($mask, '%I') !== false || strpos($mask, '%k') !== false || strpos($mask, '%l') !== false || strpos($mask, '%M') !== false || strpos($mask, '%S') !== false); $tmp = str_replace( "%", "", $mask ); return $this->date_create_from_format($tmp, $value, $withHours); } + /* + //Year + %Y year with the century + %y year without the century (range 00 to 99) + //Month + %m month, range 01 to 12 + %B full month name + %b abbreviated month name + //Day + %d the day of the month (range 01 to 31) + %e the day of the month (range 1 to 31) + //Hour + %H hour, range 00 to 23 (24h format) + %I hour, range 01 to 12 (12h format) + %k hour, range 0 to 23 (24h format) + %l hour, range 1 to 12 (12h format) + //Min + %M minute, range 00 to 59 + //Sec + %S seconds, range 00 to 59 + */ function date_create_from_format( $dformat, $dvalue, $withHours = false ) { $schedule = $dvalue; - $schedule_format = str_replace(array('Y','m','d','H','M','S'),array('%Y','%m','%d','%H','%M','%S') ,$dformat); + $schedule_format = str_replace(array('Y','y','m','B','b','d','e','H','I','k','l','M','S'),array('%Y','%y','%m','%B','%b','%d','%e','%H','%I','%k','%l','%M','%S') ,$dformat); $ugly = strptime($schedule, $schedule_format); $ymd = sprintf( '%04d-%02d-%02d %02d:%02d:%02d', From 4f240f4eaaa70b7b2e09a1eec843d6dd3768f506 Mon Sep 17 00:00:00 2001 From: Luis Fernando Saisa Lopez Date: Thu, 2 Apr 2015 16:12:00 -0400 Subject: [PATCH 05/10] PM-2047 "Se puede asignar permisos de proceso a usuarios..." SOLVED > Code Issue: Se puede asignar permisos de proceso a usuarios que se encuentran inactivos > Solution: Se corrige validacion la validacion existente. --- workflow/engine/src/ProcessMaker/BusinessModel/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/User.php b/workflow/engine/src/ProcessMaker/BusinessModel/User.php index 20384e993..bc9607d6f 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/User.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/User.php @@ -1060,7 +1060,7 @@ class User } } } - $oCriteria->add(\UsersPeer::USR_STATUS, 'CLOSED', \Criteria::ALT_NOT_EQUAL); + $oCriteria->add(\UsersPeer::USR_STATUS, "ACTIVE", \Criteria::EQUAL); $oDataset = \UsersPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($oDataset->next()) { From 87c22be11b13d85c4b21debc4ed7d46ebb1da43d Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Fri, 3 Apr 2015 14:31:32 -0400 Subject: [PATCH 06/10] PM-2009 --- workflow/engine/classes/class.pmDynaform.php | 236 ++++++++++++++++-- .../ProcessMaker/BusinessModel/DynaForm.php | 218 ---------------- .../ProcessMaker/BusinessModel/Variable.php | 32 +-- .../Services/Api/Project/DynaForm.php | 50 +--- 4 files changed, 236 insertions(+), 300 deletions(-) diff --git a/workflow/engine/classes/class.pmDynaform.php b/workflow/engine/classes/class.pmDynaform.php index a5d1302fa..df201b088 100644 --- a/workflow/engine/classes/class.pmDynaform.php +++ b/workflow/engine/classes/class.pmDynaform.php @@ -125,14 +125,18 @@ class pmDynaform if ($json->dbConnection !== "" && $json->dbConnection !== "none" && $json->sql !== "") { $cnn = Propel::getConnection($json->dbConnection); $stmt = $cnn->createStatement(); - $rs = $stmt->executeQuery(strtoupper($json->sql), \ResultSet::FETCHMODE_NUM); - while ($rs->next()) { - $row = $rs->getRow(); - $option = array( - "label" => isset($row[1]) ? $row[1] : $row[0], - "value" => $row[0] - ); - array_push($json->options, $option); + try { + $rs = $stmt->executeQuery($json->sql, \ResultSet::FETCHMODE_NUM); + while ($rs->next()) { + $row = $rs->getRow(); + $option = array( + "label" => isset($row[1]) ? $row[1] : $row[0], + "value" => $row[0] + ); + array_push($json->options, $option); + } + } catch (Exception $e) { + } } if (isset($json->options[0])) { @@ -371,16 +375,11 @@ class pmDynaform public function synchronizeVariable($processUid, $newVariable, $oldVariable) { $criteria = new Criteria("workflow"); - $criteria->addSelectColumn(DynaformPeer::DYN_UID); $criteria->addSelectColumn(DynaformPeer::DYN_CONTENT); - $criteria->add(DynaformPeer::PRO_UID, $processUid, Criteria::EQUAL); - $rsCriteria = DynaformPeer::doSelectRS($criteria); - $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); - while ($rsCriteria->next()) { $aRow = $rsCriteria->getRow(); $json = G::json_decode($aRow['DYN_CONTENT']); @@ -415,10 +414,8 @@ class pmDynaform $json->name = $newVariable["VAR_NAME"]; if (isset($json->dbConnection) && $json->dbConnection === $oldVariable["VAR_DBCONNECTION"]) $json->dbConnection = $newVariable["VAR_DBCONNECTION"]; - if (isset($json->sql) && $json->sql === $oldVariable["VAR_SQL"]) $json->sql = $newVariable["VAR_SQL"]; - if (isset($json->options) && G::json_encode($json->options) === $oldVariable["VAR_ACCEPTED_VALUES"]) { $json->options = G::json_decode($newVariable["VAR_ACCEPTED_VALUES"]); } @@ -430,16 +427,11 @@ class pmDynaform public function isUsed($processUid, $variable) { $criteria = new Criteria("workflow"); - $criteria->addSelectColumn(DynaformPeer::DYN_UID); $criteria->addSelectColumn(DynaformPeer::DYN_CONTENT); - $criteria->add(DynaformPeer::PRO_UID, $processUid, Criteria::EQUAL); - $rsCriteria = DynaformPeer::doSelectRS($criteria); - $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); - while ($rsCriteria->next()) { $aRow = $rsCriteria->getRow(); $json = G::json_decode($aRow['DYN_CONTENT']); @@ -469,6 +461,210 @@ class pmDynaform return false; } + public function searchField($dyn_uid, $field_id) + { + $a = new Criteria("workflow"); + $a->addSelectColumn(DynaformPeer::DYN_CONTENT); + $a->add(DynaformPeer::DYN_UID, $dyn_uid, Criteria::EQUAL); + $ds = ProcessPeer::doSelectRS($a); + $ds->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $ds->next(); + $row = $ds->getRow(); + $json = G::json_decode($row["DYN_CONTENT"]); + return $this->jsonsf($json, $field_id); + } + + private function jsonsf(&$json, $id) + { + foreach ($json as $key => $value) { + $sw1 = is_array($value); + $sw2 = is_object($value); + if ($sw1 || $sw2) { + $val = $this->jsonsf($value, $id); + if ($val !== null) + return $val; + } + if (!$sw1 && !$sw2) { + if ($key === "id" && $id === $value) { + return $json; + } + } + } + return null; + } + + public function downloadLanguage($dyn_uid, $lang) + { + if ($lang === "en") { + $a = new Criteria("workflow"); + $a->addSelectColumn(DynaformPeer::DYN_CONTENT); + $a->add(DynaformPeer::DYN_UID, $dyn_uid, Criteria::EQUAL); + $ds = ProcessPeer::doSelectRS($a); + $ds->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $ds->next(); + $row = $ds->getRow(); + if ($row["DYN_CONTENT"] !== null && $row["DYN_CONTENT"] !== "") { + $json = \G::json_decode($row["DYN_CONTENT"]); + $this->jsonl($json); + } + $string = ""; + $string = $string . "msgid \"\"\n"; + $string = $string . "msgstr \"\"\n"; + $string = $string . "\"Project-Id-Version: PM 4.0.1\\n\"\n"; + $string = $string . "\"POT-Creation-Date: \\n\"\n"; + $string = $string . "\"PO-Revision-Date: 2010-12-02 11:44+0100 \\n\"\n"; + $string = $string . "\"Last-Translator: Colosa\\n\"\n"; + $string = $string . "\"Language-Team: Colosa Developers Team \\n\"\n"; + $string = $string . "\"MIME-Version: 1.0\\n\"\n"; + $string = $string . "\"Content-Type: text/plain; charset=utf-8\\n\"\n"; + $string = $string . "\"Content-Transfer_Encoding: 8bit\\n\"\n"; + $string = $string . "\"X-Poedit-Language: English\\n\"\n"; + $string = $string . "\"X-Poedit-Country: United States\\n\"\n"; + $string = $string . "\"X-Poedit-SourceCharset: utf-8\\n\"\n"; + $string = $string . "\"Content-Transfer-Encoding: 8bit\\n\"\n"; + $string = $string . "\"File-Name: processmaker.en.po\\n\"\n\n"; + + $n = count($this->dyn_conten_labels); + for ($i = 0; $i < $n; $i++) { + $string = $string . "msgid \"" . $this->dyn_conten_labels[$i] . "\"\n"; + $string = $string . "msgstr \"" . $this->dyn_conten_labels[$i] . "\"\n\n"; + } + return array("labels" => $string, "lang" => $lang); + } else { + $a = new Criteria("workflow"); + $a->addSelectColumn(DynaformPeer::DYN_LABEL); + $a->add(DynaformPeer::DYN_UID, $dyn_uid, Criteria::EQUAL); + $ds = ProcessPeer::doSelectRS($a); + $ds->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $ds->next(); + $row = $ds->getRow(); + $data = G::json_decode($row["DYN_LABEL"]); + $string = ""; + $string = $string . "msgid \"\"\n"; + $string = $string . "msgstr \"\"\n"; + foreach ($data->{$lang} as $key => $value) { + if (is_string($value)) { + $string = $string . "\"" . $key . ": " . $value . "\\n\"\n"; + } + } + $string = $string . "\n"; + foreach ($data->{$lang}->Labels as $key => $value) { + $string = $string . "msgid \"" . $value->msgid . "\"\n"; + $string = $string . "msgstr \"" . $value->msgstr . "\"\n\n"; + } + return array("labels" => $string, "lang" => $lang); + } + } + + public function uploadLanguage($dyn_uid) + { + if (!isset($_FILES["LANGUAGE"])) { + throw new Exception(G::LoadTranslation("ID_ERROR_UPLOADING_FILENAME")); + } + if (pathinfo($_FILES["LANGUAGE"]["name"], PATHINFO_EXTENSION) != "po") { + throw new Exception(G::LoadTranslation("ID_FILE_UPLOAD_INCORRECT_EXTENSION")); + } + $translation = array(); + G::LoadSystem('i18n_po'); + $i18n = new i18n_PO($_FILES["LANGUAGE"]["tmp_name"]); + $i18n->readInit(); + while ($rowTranslation = $i18n->getTranslation()) { + array_push($translation, $rowTranslation); + } + $name = $_FILES["LANGUAGE"]["name"]; + $name = explode(".", $name); + if (isset($name[1]) && isset($name[2]) && $name[1] . "." . $name[2] === "en.po") { + return; + } + $content = $i18n->getHeaders(); + $content["File-Name"] = $_FILES["LANGUAGE"]["name"]; + $content["Labels"] = $translation; + + $con = Propel::getConnection(DynaformPeer::DATABASE_NAME); + $con->begin(); + $oPro = DynaformPeer::retrieveByPk($dyn_uid); + + $dyn_labels = new stdClass(); + if ($oPro->getDynLabel() !== null && $oPro->getDynLabel() !== "") { + $dyn_labels = G::json_decode($oPro->getDynLabel()); + } + $dyn_labels->$name[count($name) - 2] = $content; + + $oPro->setDynLabel(G::json_encode($dyn_labels)); + $oPro->save(); + $con->commit(); + } + + public function listLanguage($dyn_uid) + { + $list = array(); + $a = new Criteria("workflow"); + $a->addSelectColumn(DynaformPeer::DYN_LABEL); + $a->add(DynaformPeer::DYN_UID, $dyn_uid, Criteria::EQUAL); + $ds = ProcessPeer::doSelectRS($a); + $ds->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $ds->next(); + $row = $ds->getRow(); + + if ($row["DYN_LABEL"] === null || $row["DYN_LABEL"] === "") { + return $list; + } + + $dyn_label = \G::json_decode($row["DYN_LABEL"]); + foreach ($dyn_label as $key => $value) { + array_push($list, array( + "Lang" => $key, + "File-Name" => isset($value->{"File-Name"}) ? $value->{"File-Name"} : "", + "Project-Id-Version" => isset($value->{"Project-Id-Version"}) ? $value->{"Project-Id-Version"} : "", + "POT-Creation-Date" => isset($value->{"POT-Creation-Date"}) ? $value->{"POT-Creation-Date"} : "", + "PO-Revision-Date" => isset($value->{"PO-Revision-Date"}) ? $value->{"PO-Revision-Date"} : "", + "Last-Translator" => isset($value->{"Last-Translator"}) ? $value->{"Last-Translator"} : "", + "Language-Team" => isset($value->{"Language-Team"}) ? $value->{"Language-Team"} : "", + "MIME-Version" => isset($value->{"MIME-Version"}) ? $value->{"MIME-Version"} : "", + "Content-Type" => isset($value->{"Content-Type"}) ? $value->{"Content-Type"} : "", + "Content-Transfer_Encoding" => isset($value->{"Content-Transfer_Encoding"}) ? $value->{"Content-Transfer_Encoding"} : "", + "X-Poedit-Language" => isset($value->{"X-Poedit-Language"}) ? $value->{"X-Poedit-Language"} : "", + "X-Poedit-Country" => isset($value->{"X-Poedit-Country"}) ? $value->{"X-Poedit-Country"} : "", + "X-Poedit-SourceCharset" => isset($value->{"X-Poedit-SourceCharset"}) ? $value->{"X-Poedit-SourceCharset"} : "", + "Content-Transfer-Encoding" => isset($value->{"Content-Transfer-Encoding"}) ? $value->{"Content-Transfer-Encoding"} : "" + )); + } + return $list; + } + + private $dyn_conten_labels = array(); + + private function jsonl(&$json) + { + foreach ($json as $key => $value) { + $sw1 = is_array($value); + $sw2 = is_object($value); + if ($sw1 || $sw2) { + $this->jsonl($value); + } + if (!$sw1 && !$sw2) { + if ($key === "label") { + $json->label; + array_push($this->dyn_conten_labels, $json->label); + } + } + } + } + + public function deleteLanguage($dyn_uid, $lang) + { + $con = Propel::getConnection(DynaformPeer::DATABASE_NAME); + $con->begin(); + $oPro = DynaformPeer::retrieveByPk($dyn_uid); + + $dyn_labels = \G::json_decode($oPro->getDynLabel()); + unset($dyn_labels->{$lang}); + + $oPro->setDynLabel(G::json_encode($dyn_labels)); + $oPro->save(); + $con->commit(); + } + private function clientToken() { $client = $this->getClientCredentials(); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php b/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php index d6afc78c4..a8a5f67a1 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php @@ -1134,222 +1134,4 @@ class DynaForm throw $e; } } - - /** - * download file *.po - * - * @param string $projectUid Unique id of Project - * @param string $dynaFormUid Unique id of DynaForm - * - * return - */ - public function downloadLanguage($projectUid, $dynaFormUid, $lang) - { - try { - $dynaForm = new \Dynaform(); - $arraydata = $dynaForm->Load($dynaFormUid); - $data = \G::json_decode($arraydata["DYN_LABEL"]); - $string = ""; - $string = $string . "msgid \"\"\n"; - $string = $string . "msgstr \"\"\n"; - foreach ($data->{$lang} as $key => $value) { - if (is_string($value)) { - $string = $string . "\"" . $key . ":" . $value . "\\n\"\n"; } - } - $string = $string . "\n"; - foreach ($data->{$lang}->Labels as $key => $value) { - $string = $string . "msgid \"" . $value->msgid . "\"\n"; - $string = $string . "msgstr \"" . $value->msgstr . "\"\n\n"; - } - return array("labels" => $string, "lang" => $lang); - } catch (\Exception $e) { - throw $e; - } - } - - /** - * upload file *.po - * - * @param string $projectUid Unique id of Project - * @param string $dynaFormUid Unique id of DynaForm - * - * return - */ - public function uploadLanguage($projectUid, $dynaFormUid) - { - try { - if (isset($_FILES["LANGUAGE"]) && pathinfo($_FILES["LANGUAGE"]["name"], PATHINFO_EXTENSION) == "po") { - $translation = array(); - \G::LoadSystem('i18n_po'); - $i18n = new \i18n_PO($_FILES["LANGUAGE"]["tmp_name"]); - $i18n->readInit(); - while ($rowTranslation = $i18n->getTranslation()) { - array_push($translation, $rowTranslation); - } - $name = $_FILES["LANGUAGE"]["name"]; - $name = explode(".", $name); - $content = $i18n->getHeaders(); - $content["File-Name"] = $_FILES["LANGUAGE"]["name"]; - $content["Labels"] = $translation; - - $dynaForm = new \Dynaform(); - $arraydata = $dynaForm->Load($dynaFormUid); - - if ($arraydata["DYN_LABEL"] !== null && $arraydata["DYN_LABEL"] !== "") { - $dyn_labels = \G::json_decode($arraydata["DYN_LABEL"]); - } else { - $dyn_labels = new \stdClass(); - } - $dyn_labels->$name[count($name) - 2] = $content; - - $arraydata["DYN_LABEL"] = \G::json_encode($dyn_labels); - $dynaForm->update($arraydata); - return $dyn_labels; - } else { - throw new \Exception(\G::LoadTranslation("ID_DYNAFORM_INCORRECT_FILE_NAME")); - } - } catch (\Exception $e) { - throw $e; - } - } - - /** - * list file .po - * - * @param string $projectUid Unique id of Project - * @param string $dynaFormUid Unique id of DynaForm - * - * return - */ - public function listLanguage($projectUid, $dynaFormUid) - { - try { - $list = array(); - $dynaForm = new \Dynaform(); - $arraydata = $dynaForm->Load($dynaFormUid); - - if ($arraydata["DYN_LABEL"] === null || $arraydata["DYN_LABEL"] === "") - return $list; - $dyn_labels = \G::json_decode($arraydata["DYN_LABEL"]); - foreach ($dyn_labels as $key => $value) { - array_push($list, array( - "Lang" => $key, - "File-Name" => isset($value->{"File-Name"}) ? $value->{"File-Name"} : "", - "Project-Id-Version" => isset($value->{"Project-Id-Version"}) ? $value->{"Project-Id-Version"} : "", - "POT-Creation-Date" => isset($value->{"POT-Creation-Date"}) ? $value->{"POT-Creation-Date"} : "", - "PO-Revision-Date" => isset($value->{"PO-Revision-Date"}) ? $value->{"PO-Revision-Date"} : "", - "Last-Translator" => isset($value->{"Last-Translator"}) ? $value->{"Last-Translator"} : "", - "Language-Team" => isset($value->{"Language-Team"}) ? $value->{"Language-Team"} : "", - "MIME-Version" => isset($value->{"MIME-Version"}) ? $value->{"MIME-Version"} : "", - "Content-Type" => isset($value->{"Content-Type"}) ? $value->{"Content-Type"} : "", - "Content-Transfer_Encoding" => isset($value->{"Content-Transfer_Encoding"}) ? $value->{"Content-Transfer_Encoding"} : "", - "X-Poedit-Language" => isset($value->{"X-Poedit-Language"}) ? $value->{"X-Poedit-Language"} : "", - "X-Poedit-Country" => isset($value->{"X-Poedit-Country"}) ? $value->{"X-Poedit-Country"} : "", - "X-Poedit-SourceCharset" => isset($value->{"X-Poedit-SourceCharset"}) ? $value->{"X-Poedit-SourceCharset"} : "", - "Content-Transfer-Encoding" => isset($value->{"Content-Transfer-Encoding"}) ? $value->{"Content-Transfer-Encoding"} : "" - )); - } - return $list; - } catch (\Exception $e) { - throw $e; - } - } - - /** - * list file .po - * - * @param string $projectUid Unique id of Project - * @param string $dynaFormUid Unique id of DynaForm - * - * return - */ - public function downloadLabels($projectUid, $dynaFormUid) - { - try { - $dynaForm = new \Dynaform(); - $arraydata = $dynaForm->Load($dynaFormUid); - if ($arraydata["DYN_CONTENT"] !== null && $arraydata["DYN_CONTENT"] !== "") { - $json = \G::json_decode($arraydata["DYN_CONTENT"]); - $this->jsonr($json); - } - $string = ""; - $string = $string . "msgid \"\"\n"; - $string = $string . "msgstr \"\"\n"; - $string = $string . "\"Project-Id-Version: PM 4.0.1\\n\"\n"; - $string = $string . "\"POT-Creation-Date: \\n\"\n"; - $string = $string . "\"PO-Revision-Date: 2010-12-02 11:44+0100 \\n\"\n"; - $string = $string . "\"Last-Translator: Colosa\\n\"\n"; - $string = $string . "\"Language-Team: Colosa Developers Team \\n\"\n"; - $string = $string . "\"MIME-Version: 1.0\\n\"\n"; - $string = $string . "\"Content-Type: text/plain; charset=utf-8\\n\"\n"; - $string = $string . "\"Content-Transfer_Encoding: 8bit\\n\"\n"; - $string = $string . "\"X-Poedit-Language: English\\n\"\n"; - $string = $string . "\"X-Poedit-Country: United States\\n\"\n"; - $string = $string . "\"X-Poedit-SourceCharset: utf-8\\n\"\n"; - $string = $string . "\"Content-Transfer-Encoding: 8bit\\n\"\n\n"; - - $n = count($this->dyn_conten_labels); - for ($i = 0; $i < $n; $i++) { - $string = $string . "msgid \"" . $this->dyn_conten_labels[$i] . "\"\n"; - $string = $string . "msgstr \"" . $this->dyn_conten_labels[$i] . "\"\n\n"; - } - return array("labels" => $string, "lang" => "en"); - } catch (\Exception $e) { - throw $e; - } - } - - private $dyn_conten_labels = array(); - - /** - * labels in dyn_content - * - * @param array $dyn_content - */ - private function jsonr(&$json) - { - foreach ($json as $key => $value) { - $sw1 = is_array($value); - $sw2 = is_object($value); - if ($sw1 || $sw2) { - $this->jsonr($value); - } - if (!$sw1 && !$sw2) { - if ($key === "label") { - $json->label; - array_push($this->dyn_conten_labels, $json->label); - } - } - } - } - - /** - * delete labels - * - * @param string $projectUid Unique id of Project - * @param string $dynaFormUid Unique id of DynaForm - * - * return - */ - public function deleteLanguage($projectUid, $dynaFormUid, $lang) - { - try { - $dynaForm = new \Dynaform(); - $arraydata = $dynaForm->Load($dynaFormUid); - - if ($arraydata["DYN_LABEL"] !== null && $arraydata["DYN_LABEL"] !== "") { - $dyn_labels = \G::json_decode($arraydata["DYN_LABEL"]); - unset($dyn_labels->{$lang}); - } - - $arraydata["DYN_LABEL"] = \G::json_encode($dyn_labels); - $dynaForm->update($arraydata); - return; - } catch (\Exception $e) { - throw $e; - } - } -} - - diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php b/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php index ae1deecbe..fc4d5b237 100755 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Variable.php @@ -494,30 +494,12 @@ class Variable $process->throwExceptionIfNotExistsProcess($processUid, strtolower("PRJ_UID")); //Set data - $variableDbConnectionUid = ""; - $variableSql = ""; - - $criteria = new \Criteria("workflow"); - - $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_DBCONNECTION); - $criteria->addSelectColumn(\ProcessVariablesPeer::VAR_SQL); - $criteria->add(\ProcessVariablesPeer::PRJ_UID, $processUid, \Criteria::EQUAL); - $criteria->add(\ProcessVariablesPeer::VAR_NAME, $variableName, \Criteria::EQUAL); - - $rsCriteria = \ProcessVariablesPeer::doSelectRS($criteria); - $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); - if ($rsCriteria->next()) { - $row = $rsCriteria->getRow(); - - $variableDbConnectionUid = $row["VAR_DBCONNECTION"]; - $variableSql = strtoupper($row["VAR_SQL"]); - } else { - throw new \Exception(G::LoadTranslation("ID_PROCESS_VARIABLE_DOES_NOT_EXIST", array("VAR_NAME", $variableName))); - } - - //Verify data - $this->throwExceptionIfSomeRequiredVariableSqlIsMissingInVariables($variableName, $variableSql, $arrayVariable); - + \G::LoadClass('pmDynaform'); + $pmDynaform = new \pmDynaform(); + $field = $pmDynaform->searchField($arrayVariable["dyn_uid"], $arrayVariable["field_id"]); + $variableDbConnectionUid = $field !== null ? $field->dbConnection : ""; + $variableSql = $field !== null ? $field->sql : ""; + //Get data $_SESSION["PROCESS"] = $processUid; @@ -533,7 +515,7 @@ class Variable $arrayRecord[] = array( strtolower("VALUE") => $row[0], - strtolower("TEXT") => $row[1] + strtolower("TEXT") => isset($row[1]) ? $row[1] : $row[0] ); } diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Project/DynaForm.php b/workflow/engine/src/ProcessMaker/Services/Api/Project/DynaForm.php index 1f6bfc3e1..81b145247 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Project/DynaForm.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Project/DynaForm.php @@ -122,13 +122,12 @@ class DynaForm extends Api public function doGetDynaFormLanguage($dyn_uid, $prj_uid, $lang) { try { - $dynaForm = new \ProcessMaker\BusinessModel\DynaForm(); - $dynaForm->setFormatFieldNameInUppercase(false); - $response = $dynaForm->downloadLanguage($prj_uid, $dyn_uid, $lang); - return $response; + \G::LoadClass('pmDynaform'); + $pmDynaform = new \pmDynaform(); + return $pmDynaform->downloadLanguage($dyn_uid, $lang); } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); -} + } } /** @@ -140,10 +139,9 @@ class DynaForm extends Api public function doPostDynaFormLanguage($dyn_uid, $prj_uid) { try { - $dynaForm = new \ProcessMaker\BusinessModel\DynaForm(); - $dynaForm->setFormatFieldNameInUppercase(false); - $response = $dynaForm->uploadLanguage($prj_uid, $dyn_uid); - return $response; + \G::LoadClass('pmDynaform'); + $pmDynaform = new \pmDynaform(); + $pmDynaform->uploadLanguage($dyn_uid); } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } @@ -158,10 +156,9 @@ class DynaForm extends Api public function doDeleteDynaFormLanguage($dyn_uid, $prj_uid, $lang) { try { - $dynaForm = new \ProcessMaker\BusinessModel\DynaForm(); - $dynaForm->setFormatFieldNameInUppercase(false); - $response = $dynaForm->deleteLanguage($prj_uid, $dyn_uid, $lang); - return $response; + \G::LoadClass('pmDynaform'); + $pmDynaform = new \pmDynaform(); + $pmDynaform->deleteLanguage($dyn_uid, $lang); } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } @@ -176,33 +173,12 @@ class DynaForm extends Api public function doGetListDynaFormLanguage($dyn_uid, $prj_uid) { try { - $dynaForm = new \ProcessMaker\BusinessModel\DynaForm(); - $dynaForm->setFormatFieldNameInUppercase(false); - $response = $dynaForm->listLanguage($prj_uid, $dyn_uid); - return $response; - } catch (\Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); - } - } - - /** - * @url GET /:prj_uid/dynaform/:dyn_uid/download-labels - * - * @param string $dyn_uid {@min 32}{@max 32} - * @param string $prj_uid {@min 32}{@max 32} - */ - public function doGetListDynaFormLabels($dyn_uid, $prj_uid) - { - try { - $dynaForm = new \ProcessMaker\BusinessModel\DynaForm(); - $dynaForm->setFormatFieldNameInUppercase(false); - $response = $dynaForm->downloadLabels($prj_uid, $dyn_uid); - return $response; + \G::LoadClass('pmDynaform'); + $pmDynaform = new \pmDynaform(); + return $pmDynaform->listLanguage($dyn_uid); } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } } - - From 6fa60dc0c1d33058c4f6527264b74fb172bb562f Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Sat, 4 Apr 2015 18:43:24 -0400 Subject: [PATCH 07/10] PM-1447 --- workflow/engine/classes/class.pmDynaform.php | 2 +- workflow/engine/templates/processes/main.js | 71 ++++++++++---------- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/workflow/engine/classes/class.pmDynaform.php b/workflow/engine/classes/class.pmDynaform.php index df201b088..4d7138c8c 100644 --- a/workflow/engine/classes/class.pmDynaform.php +++ b/workflow/engine/classes/class.pmDynaform.php @@ -184,7 +184,7 @@ class pmDynaform $cells = array(); foreach ($json->columns as $column) { //data - if ($column->type === "checkbox" || $column->type === "text" || $column->type === "textarea" || $column->type === "dropdown" || $column->type === "datetime") { + if ($column->type === "text" || $column->type === "textarea" || $column->type === "dropdown" || $column->type === "datetime" || $column->type === "checkbox" || $column->type === "file" || $column->type === "link") { array_push($cells, array( "value" => isset($row[$column->name]) ? $row[$column->name] : "", "label" => isset($row[$column->name . "_label"]) ? $row[$column->name . "_label"] : "" diff --git a/workflow/engine/templates/processes/main.js b/workflow/engine/templates/processes/main.js index e2b9b33bb..476ed74cc 100755 --- a/workflow/engine/templates/processes/main.js +++ b/workflow/engine/templates/processes/main.js @@ -601,13 +601,7 @@ function saveProcess() if (projectType == 'classicProject') { location.href = 'processes_Map?PRO_UID='+resp.result.PRO_UID; } else { - if ((navigator.userAgent.indexOf("MSIE") != -1) || (navigator.userAgent.indexOf("Trident") != -1)) { - winDesigner = window.open("../designer?prj_uid=" + resp.result.PRO_UID, 'winDesigner'); - Ext.getCmp('newProjectWin').close(); - processesGrid.store.reload(); - } else { - location.href = '../designer?prj_uid=' + resp.result.PRO_UID; - } + openWindowIfIE('../designer?prj_uid=' + resp.result.PRO_UID); } }, failure: function(obj, resp) { @@ -656,12 +650,7 @@ editProcess = function(typeParam) } else { url = 'processes_Map?PRO_UID=' + pro_uid; } - - if ( ((navigator.userAgent.indexOf("MSIE")!=-1) || (navigator.userAgent.indexOf("Trident")!=-1)) && (type == "bpmn") ) { - winDesigner = window.open(url, 'winDesigner'); - } else { - location.href = url; - } + openWindowIfIE(url); } editNewProcess = function(){ @@ -870,6 +859,7 @@ importProcessExistGroup = function() var processFileType = importProcessGlobal.processFileType; var w = new Ext.Window({ + id : 'importProcessExistGroupWindow', title : _('ID_IMPORT_PROCESS') + processFileTypeTitle, header : false, width : 460, @@ -966,13 +956,7 @@ importProcessExistGroup = function() var sNewProUid = resp_.sNewProUid; if (typeof(resp_.project_type) != "undefined" && resp_.project_type == "bpmn") { - if ((navigator.userAgent.indexOf("MSIE") != -1) || (navigator.userAgent.indexOf("Trident") != -1)) { - winDesigner = window.open("../designer?prj_uid=" + sNewProUid, 'winDesigner'); - w.close(); - processesGrid.store.reload(); - } else { - window.location.href = "../designer?prj_uid=" + sNewProUid; - } + openWindowIfIE("../designer?prj_uid=" + sNewProUid); } else { window.location.href = "processes_Map?PRO_UID=" + sNewProUid; } @@ -1012,6 +996,7 @@ importProcessExistProcess = function() var proFileName = importProcessGlobal.proFileName; var w = new Ext.Window({ + id : 'importProcessExistProcessWindow', title : _('ID_IMPORT_PROCESS') + processFileTypeTitle, header : false, width : 460, @@ -1115,14 +1100,7 @@ importProcessExistProcess = function() if (resp_.ExistGroupsInDatabase == 0) { if (typeof(resp_.project_type) != "undefined" && resp_.project_type == "bpmn") { - if ((navigator.userAgent.indexOf("MSIE") != -1) || (navigator.userAgent.indexOf("Trident") != -1)) { - winDesigner = window.open("../designer?prj_uid=" + sNewProUid,'winDesigner'); - Ext.getCmp('importProcessWindow').close(); - w.close(); - processesGrid.store.reload(); - } else { - window.location.href = "../designer?prj_uid=" + sNewProUid; - } + openWindowIfIE("../designer?prj_uid=" + sNewProUid); } else { window.location.href = "processes_Map?PRO_UID=" + sNewProUid; } @@ -1263,13 +1241,7 @@ importProcess = function() var sNewProUid = resp_.sNewProUid; if (typeof(resp_.project_type) != "undefined" && resp_.project_type == "bpmn") { - if ((navigator.userAgent.indexOf("MSIE") != -1) || (navigator.userAgent.indexOf("Trident") != -1)) { - winDesigner = window.open("../designer?prj_uid=" + sNewProUid,"winDesigner"); - w.close(); - processesGrid.store.reload(); - } else { - window.location.href = "../designer?prj_uid=" + sNewProUid; - } + openWindowIfIE("../designer?prj_uid=" + sNewProUid); } else { window.location.href = "processes_Map?PRO_UID=" + sNewProUid; } @@ -1334,6 +1306,7 @@ importProcess = function() } var windowbpmnoption = new Ext.Window({ + id: 'windowBpmnOptionWindow', title: _('ID_IMPORT_PROCESS'), header: false, width: 420, @@ -1507,3 +1480,31 @@ Ext.EventManager.on(window, 'beforeunload', function () { if (winDesigner) winDesigner.close(); }); + + +function openWindowIfIE(pathDesigner) { + if ((navigator.userAgent.indexOf("MSIE") != -1) || (navigator.userAgent.indexOf("Trident") != -1)) { + if (Ext.getCmp('newProjectWin')) + Ext.getCmp('newProjectWin').close(); + if (Ext.getCmp('importProcessWindow')) + Ext.getCmp('importProcessWindow').close(); + if (Ext.getCmp('importProcessExistGroupWindow')) + Ext.getCmp('importProcessExistGroupWindow').close(); + if (Ext.getCmp('importProcessExistProcessWindow')) + Ext.getCmp('importProcessExistProcessWindow').close(); + if (Ext.getCmp('windowBpmnOptionWindow')) + Ext.getCmp('windowBpmnOptionWindow').close(); + processesGrid.store.reload(); + if (winDesigner && winDesigner.closed === false) { + if (winDesigner.window.PMDesigner.project.isDirty()) { + Ext.Msg.alert(_('ID_REFRESH_LABEL'), _('ID_UNSAVED_TRIGGERS_WINDOW')); + } else { + winDesigner = window.open(pathDesigner, 'winDesigner'); + } + } else { + winDesigner = window.open(pathDesigner, 'winDesigner'); + } + return; + } + location.href = pathDesigner; +} From c13a06b64c8ec38ca47c810126d6d08e7b4ac8ee Mon Sep 17 00:00:00 2001 From: jonathan Date: Sat, 4 Apr 2015 19:19:33 -0400 Subject: [PATCH 08/10] update styles in navbar --- workflow/engine/templates/designer/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/engine/templates/designer/index.html b/workflow/engine/templates/designer/index.html index c5e4e3634..94e05ad23 100644 --- a/workflow/engine/templates/designer/index.html +++ b/workflow/engine/templates/designer/index.html @@ -83,7 +83,7 @@