diff --git a/gulliver/system/class.dbtable.php b/gulliver/system/class.dbtable.php index 38a63dcd2..12ab7d9f9 100755 --- a/gulliver/system/class.dbtable.php +++ b/gulliver/system/class.dbtable.php @@ -39,15 +39,16 @@ */ class DBTable { - var $_dbc; - var $_dbses; - var $_dset; - var $table_name; - var $table_keys; - var $Fields = null; - var $is_new; - var $errorLevel; - var $debug = false; + + public $_dbc; + public $_dbses; + public $_dset; + public $table_name; + public $table_keys; + public $Fields = null; + public $is_new; + public $errorLevel; + public $debug = false; /** * Initiate a database conecction using default values @@ -57,11 +58,11 @@ class DBTable * @param object $objConnection conecction string * @return void */ - function dBTable ($objConnection = null, $strTable = "", $arrKeys = array( 'UID' )) + public function dBTable($objConnection = null, $strTable = "", $arrKeys = array('UID')) { $this->_dbc = null; $this->_dbses = null; - $this->SetTo( $objConnection, $strTable, $arrKeys ); + $this->SetTo($objConnection, $strTable, $arrKeys); } /** @@ -74,25 +75,25 @@ class DBTable * @param array $arrKeys table keys defaultvalue=UID * @return void */ - function setTo ($objDBConnection, $strTable = "", $arrKeys = array( 'UID' )) + public function setTo($objDBConnection, $strTable = "", $arrKeys = array('UID')) { $this->_dbc = $objDBConnection; - if ($this->_dbc != null && strcasecmp( get_class( $objDBConnection ), 'dbconnection' ) == 0) { - $this->_dbses = new DBSession( $this->_dbc ); - $this->_dbses->UseDB( DB_NAME ); + if ($this->_dbc != null && strcasecmp(get_class($objDBConnection), 'dbconnection') == 0) { + $this->_dbses = new DBSession($this->_dbc); + $this->_dbses->UseDB(DB_NAME); } else { - $dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBTable function without create an instance of DBConnection", 'G_Error', true ); + $dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBTable function without create an instance of DBConnection", 'G_Error', true); //DBconnection::logError( $dberror ); return $dberror; } $this->is_new = true; $this->Fields = null; $this->table_name = $strTable; - if (is_array( $arrKeys )) { + if (is_array($arrKeys)) { $this->table_keys = $arrKeys; } else { - $this->table_keys = array (0 => $arrKeys + $this->table_keys = array(0 => $arrKeys ); } $this->errorLevel = $this->_dbc->errorLevel; @@ -105,23 +106,23 @@ class DBTable * @access public * @return void */ - function loadEmpty () + public function loadEmpty() { $stQry = "DESCRIBE `" . $this->table_name . "`"; - $dset = $this->_dbses->execute( $stQry ); + $dset = $this->_dbses->execute($stQry); //$dset = new DBRecordSet( $this->_dbses->Result ); $nlim = $dset->Count(); $this->Fields = null; - for ($ncount = 0; $ncount < $nlim; $ncount ++) { + for ($ncount = 0; $ncount < $nlim; $ncount++) { $data = $dset->Read(); $fname = $data['Field']; $fval = ""; - $ftypearr = explode( $data['Type'], '(' ); + $ftypearr = explode($data['Type'], '('); $ftype = $ftypearr[0]; if ($data['Key'] == 'PRI') { - if (is_array( $this->table_keys )) { - $this->table_keys[count( $this->table_keys ) - 1] = $fname; + if (is_array($this->table_keys)) { + $this->table_keys[count($this->table_keys) - 1] = $fname; } else { $this->table_keys[0] = $fname; } @@ -152,7 +153,7 @@ class DBTable * @param string $strWhere string which contains conditions * @return strint */ - function loadWhere ($strWhere) + public function loadWhere($strWhere) { $this->Fields = null; @@ -160,8 +161,8 @@ class DBTable if ($strWhere != "") { $stQry .= " WHERE " . $strWhere; } - $this->_dset = $this->_dbses->Execute( $stQry, $this->debug, $this->errorLevel ); - if (DB::isError( $this->_dset )) { + $this->_dset = $this->_dbses->Execute($stQry, $this->debug, $this->errorLevel); + if (DB::isError($this->_dset)) { return $this->_dset; } @@ -184,13 +185,13 @@ class DBTable * @param array array of arguments key values * @return void */ - function load () + public function load() { // bug::traceRoute(); $ncount = 0; $stWhere = ""; $arrKeys = func_get_args(); - if (isset( $arrKeys[0] ) && is_array( $arrKeys[0] )) { + if (isset($arrKeys[0]) && is_array($arrKeys[0])) { foreach ($this->table_keys as $key => $val) { if ($stWhere == "") { $stWhere .= " $val = '" . $arrKeys[0][$val] . "' "; @@ -205,10 +206,10 @@ class DBTable } else { $stWhere .= " AND " . $this->table_keys[$ncount] . "='" . $val . "'"; } - $ncount ++; + $ncount++; } } - return $this->LoadWhere( $stWhere ); + return $this->LoadWhere($stWhere); } /** @@ -219,15 +220,15 @@ class DBTable * @param eter string seq * @return string */ - function nextvalPGSql ($seq) + public function nextvalPGSql($seq) { $stQry = " Select NEXTVAL( '$seq' ) "; - $dset = $this->_dbses->Execute( $stQry ); + $dset = $this->_dbses->Execute($stQry); $row = $dset->Read(); - if (is_array( $row )) { + if (is_array($row)) { return $row['NEXTVAL']; } - die( "Sequence '$seq' is not exist!!" ); + die("Sequence '$seq' is not exist!!"); return - 1; } @@ -239,11 +240,11 @@ class DBTable * @return boolean * */ - function insert () + public function insert() { $strFields = ""; $strValues = ""; - if (defined( 'DB_ADAPTER' )) { + if (defined('DB_ADAPTER')) { $DBEngine = DB_ADAPTER; } else { $DBEngine = 'mysql'; @@ -251,23 +252,23 @@ class DBTable foreach ($this->Fields as $field => $val) { $strFields .= $field . ","; $iskey = false; - if (isset( $this->table_keys ) && is_array( $this->table_keys )) { - $iskey = in_array( $field, $this->table_keys ) && strtoupper( substr( trim( $val ), 0, 7 ) ) == "NEXTVAL"; + if (isset($this->table_keys) && is_array($this->table_keys)) { + $iskey = in_array($field, $this->table_keys) && strtoupper(substr(trim($val), 0, 7)) == "NEXTVAL"; } - $dbcType = isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine; + $dbcType = isset($this->_dbc->type) ? $this->_dbc->type : $DBEngine; // Commented by new format of textarea in javascript - if (! $iskey) { + if (!$iskey) { $val = "'" . $val . "'"; } - ///-- $val = "'" . G::sqlEscape( $val , $dbcType ) . "'"; + ///-- $val = "'" . G::sqlEscape( $val , $dbcType ) . "'"; $strValues .= $val . ", "; } - $strFields = substr( $strFields, 0, strlen( $strFields ) - 1 ); - $strValues = substr( $strValues, 0, strlen( $strValues ) - 1 ); + $strFields = substr($strFields, 0, strlen($strFields) - 1); + $strValues = substr($strValues, 0, strlen($strValues) - 1); $stQry = "INSERT INTO `" . $this->table_name . "` ( " . $strFields . " ) values ( " . $strValues . " ) "; - $result = $this->_dbses->Execute( $stQry, $this->debug ); + $result = $this->_dbses->Execute($stQry, $this->debug); return $result; } @@ -278,14 +279,14 @@ class DBTable * @access public * @return boolean */ - function update () + public function update() { $stQry = ""; $stWhere = ''; - $remainKeys = array (); + $remainKeys = array(); - if (defined( 'DB_ADAPTER' )) { + if (defined('DB_ADAPTER')) { $DBEngine = DB_ADAPTER; } else { $DBEngine = 'mysql'; @@ -296,21 +297,21 @@ class DBTable } foreach ($this->Fields as $field => $val) { $iskey = false; - $iskey = in_array( $field, $this->table_keys ); + $iskey = in_array($field, $this->table_keys); if ($iskey == false) { $stQry .= $field . "='" . $val . "', "; // Commented by new format of textarea in javascript ///-- $stQry .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "', "; } else { if ($stWhere == "") { - $stWhere .= $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'"; + $stWhere .= $field . "='" . G::sqlEscape($val, isset($this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'"; } else { - $stWhere .= " AND " . $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'"; + $stWhere .= " AND " . $field . "='" . G::sqlEscape($val, isset($this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'"; } $remainKeys[$field] = true; } } - foreach ($remainKeys as $field => $bool) + foreach ($remainKeys as $field => $bool) { if ($bool == false) { if ($stWhere != "") { $stWhere = " AND "; @@ -318,20 +319,21 @@ class DBTable $stWhere .= $field . "= ''"; $remainKeys[$field] = true; } + } - $stQry = trim( $stQry ); - $stQry = substr( $stQry, 0, strlen( $stQry ) - 1 ); //to remove the last comma , - if (! $stQry) { + $stQry = trim($stQry); + $stQry = substr($stQry, 0, strlen($stQry) - 1); //to remove the last comma , + if (!$stQry) { return; } $stQry = "UPDATE `" . $this->table_name . "` SET " . $stQry; - $stWhere = trim( $stWhere ); + $stWhere = trim($stWhere); if ($stWhere != "") { $stQry .= " WHERE " . $stWhere; } $result = false; - $result = $this->_dbses->execute( $stQry, $this->debug, $this->errorLevel ); + $result = $this->_dbses->execute($stQry, $this->debug, $this->errorLevel); $this->is_new = false; return $result; } @@ -345,7 +347,7 @@ class DBTable * @access public * @return boolean */ - function save () + public function save() { if ($this->is_new == true) { return $this->Insert(); @@ -361,13 +363,13 @@ class DBTable * @access public * @return boolean */ - function delete () + public function delete() { $stQry = "delete from `" . $this->table_name . "` "; $stWhere = ''; - $remainKeys = array (); - if (defined( 'DB_ADAPTER' )) { + $remainKeys = array(); + if (defined('DB_ADAPTER')) { $DBEngine = DB_ADAPTER; } else { $DBEngine = 'mysql'; @@ -375,21 +377,21 @@ class DBTable foreach ($this->table_keys as $k => $v) { $remainKeys[$v] = false; } - if (is_array( $this->Fields )) { + if (is_array($this->Fields)) { foreach ($this->Fields as $field => $val) { $iskey = false; - $iskey = in_array( $field, $this->table_keys ); + $iskey = in_array($field, $this->table_keys); if ($iskey == true) { if ($stWhere == "") { - $stWhere .= $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'"; + $stWhere .= $field . "='" . G::sqlEscape($val, isset($this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'"; } else { - $stWhere .= " AND " . $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'"; + $stWhere .= " AND " . $field . "='" . G::sqlEscape($val, isset($this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'"; } $remainKeys[$field] = true; } } } - foreach ($remainKeys as $field => $bool) + foreach ($remainKeys as $field => $bool) { if ($bool == false) { if ($stWhere != "") { $stWhere .= " AND "; @@ -397,17 +399,18 @@ class DBTable $stWhere .= $field . "= ''"; $remainKeys[$field] = true; } + } - $stQry = trim( $stQry ); - $stWhere = trim( $stWhere ); + $stQry = trim($stQry); + $stWhere = trim($stWhere); if ($stWhere == '') { - $dberror = PEAR::raiseError( null, G_ERROR_WARNING_MESSAGE, null, 'null', "You tried to call delete method without WHERE clause, if you want to delete all records use dbsession", 'G_Error', true ); - DBconnection::logError( $dberror, $this->errorLevel ); + $dberror = PEAR::raiseError(null, G_ERROR_WARNING_MESSAGE, null, 'null', "You tried to call delete method without WHERE clause, if you want to delete all records use dbsession", 'G_Error', true); + DBconnection::logError($dberror, $this->errorLevel); return $dberror; } $stQry .= " WHERE " . $stWhere; - $result = $this->_dbses->execute( $stQry, $this->debug, $this->errorLevel ); + $result = $this->_dbses->execute($stQry, $this->debug, $this->errorLevel); $this->is_new = false; return $result; } @@ -421,9 +424,9 @@ class DBTable * @access public * @return boolean */ - function next () + public function next() { $this->Fields = $this->_dset->read(); } } - + \ No newline at end of file diff --git a/gulliver/system/class.i18n_po.php b/gulliver/system/class.i18n_po.php index 4f06e3bf5..5e04ec6fe 100755 --- a/gulliver/system/class.i18n_po.php +++ b/gulliver/system/class.i18n_po.php @@ -35,183 +35,176 @@ * date Aug 31th, 2010 * @copyright (C) 2002 by Colosa Development Team. */ - class i18n_PO { + private $_file = null; private $_string = ''; private $_meta; private $_fp; private $_fileComments; - protected $_editingHeader; protected $_fileLine; - protected $flagEndHeaders; protected $flagError; protected $flagInit; protected $lineNumber; - public $translatorComments; public $extractedComments; public $references; public $flags; public $previousUntranslatedStrings; - function __construct ($file) + public function __construct($file) { $this->file = $file; } - function buildInit () + public function buildInit() { - $this->_fp = fopen( $this->file, 'w' ); + $this->_fp = fopen($this->file, 'w'); - if (! is_resource( $this->_fp )) { - throw new Exception( 'Could\'t open ' . $this->file . ' file' ); + if (!is_resource($this->_fp)) { + throw new Exception('Could\'t open ' . $this->file . ' file'); } // lock PO file exclusively - if (! flock( $this->_fp, LOCK_EX )) { - fclose( $this->_fp ); + if (!flock($this->_fp, LOCK_EX)) { + fclose($this->_fp); return false; } $this->_meta = 'msgid ""'; - $this->_writeLine( $this->_meta ); + $this->_writeLine($this->_meta); $this->_meta = 'msgstr ""'; - $this->_writeLine( $this->_meta ); + $this->_writeLine($this->_meta); $this->_editingHeader = true; } - function readInit () + public function readInit() { - $this->_fp = fopen( $this->file, 'r' ); + $this->_fp = fopen($this->file, 'r'); - if (! is_resource( $this->_fp )) { - throw new Exception( 'Could\'t open ' . $this->file . ' file' ); + if (!is_resource($this->_fp)) { + throw new Exception('Could\'t open ' . $this->file . ' file'); } //skipping comments $this->skipCommets(); //deaing headers $this->readHeaders(); - $this->translatorComments = Array (); - $this->extractedComments = Array (); - $this->references = Array (); - $this->flags = Array (); - $this->previousUntranslatedStrings = Array (); + $this->translatorComments = Array(); + $this->extractedComments = Array(); + $this->references = Array(); + $this->flags = Array(); + $this->previousUntranslatedStrings = Array(); } - function addHeader ($id, $value) + public function addHeader($id, $value) { if ($this->_editingHeader) { - $meta = '"' . trim( $id ) . ': ' . trim( $value ) . '\n"'; - $this->_writeLine( $meta ); + $meta = '"' . trim($id) . ': ' . trim($value) . '\n"'; + $this->_writeLine($meta); } } - function addTranslatorComment ($str) + public function addTranslatorComment($str) { $this->headerStroke(); - $comment = '# ' . trim( $str ); - $this->_writeLine( $comment ); + $comment = '# ' . trim($str); + $this->_writeLine($comment); } - function addExtractedComment ($str) + public function addExtractedComment($str) { $this->headerStroke(); - $comment = '#. ' . trim( $str ); - $this->_writeLine( $comment ); + $comment = '#. ' . trim($str); + $this->_writeLine($comment); } - function addReference ($str) + public function addReference($str) { $this->headerStroke(); - $reference = '#: ' . trim( $str ); - $this->_writeLine( $reference ); + $reference = '#: ' . trim($str); + $this->_writeLine($reference); } - function addFlag ($str) + public function addFlag($str) { $this->headerStroke(); - $flag = '#, ' . trim( $str ); - $this->_writeLine( $flag ); + $flag = '#, ' . trim($str); + $this->_writeLine($flag); } - function addPreviousUntranslatedString ($str) + public function addPreviousUntranslatedString($str) { $this->headerStroke(); - $str = '#| ' . trim( $str ); - $this->_writeLine( $str ); + $str = '#| ' . trim($str); + $this->_writeLine($str); } - function addTranslation ($msgid, $msgstr) + public function addTranslation($msgid, $msgstr) { $this->headerStroke(); - $this->_writeLine( 'msgid "' . $this->prepare( $msgid, true ) . '"' ); - $this->_writeLine( 'msgstr "' . $this->prepare( $msgstr, true ) . '"' ); - $this->_writeLine( '' ); + $this->_writeLine('msgid "' . $this->prepare($msgid, true) . '"'); + $this->_writeLine('msgstr "' . $this->prepare($msgstr, true) . '"'); + $this->_writeLine(''); } - function _writeLine ($str) + public function _writeLine($str) { - $this->_write( $str . "\n" ); + $this->_write($str . "\n"); } - function _write ($str) + public function _write($str) { - fwrite( $this->_fp, $str ); + fwrite($this->_fp, $str); } - function prepare ($string, $reverse = false) + public function prepare($string, $reverse = false) { //$string = str_replace('\"', '"', $string); //$string = stripslashes($string); if ($reverse) { - $smap = array ('"',"\n","\t","\r" - ); - $rmap = array ('\"','\\n"' . "\n" . '"','\\t','\\r' - ); - return (string) str_replace( $smap, $rmap, $string ); + $smap = array('"', "\n", "\t", "\r"); + $rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r'); + return (string) str_replace($smap, $rmap, $string); } else { - $string = preg_replace( '/"\s+"/', '', $string ); - $smap = array ('\\n','\\r','\\t','\"' - ); - $rmap = array ("\n","\r","\t",'"' - ); - return (string) str_replace( $smap, $rmap, $string ); + $string = preg_replace('/"\s+"/', '', $string); + $smap = array('\\n', '\\r', '\\t', '\"'); + $rmap = array("\n", "\r", "\t", '"'); + return (string) str_replace($smap, $rmap, $string); } } - function headerStroke () + public function headerStroke() { if ($this->_editingHeader) { $this->_editingHeader = false; - $this->_writeLine( '' ); - ; + $this->_writeLine(''); + } } /** * read funtions * */ - private function skipCommets () + private function skipCommets() { $this->_fileComments = ''; do { - $lastPos = ftell( $this->_fp ); - $line = fgets( $this->_fp ); + $lastPos = ftell($this->_fp); + $line = fgets($this->_fp); $this->_fileComments .= $line; - } while ((substr( $line, 0, 1 ) == '#' || trim( $line ) == '') && ! feof( $this->_fp )); + } while ((substr($line, 0, 1) == '#' || trim($line) == '') && !feof($this->_fp)); - fseek( $this->_fp, $lastPos ); + fseek($this->_fp, $lastPos); } - private function readHeaders () + private function readHeaders() { $this->flagEndHeaders = false; $this->flagError = false; @@ -219,18 +212,17 @@ class i18n_PO $this->lineNumber = 0; $errMsg = ''; - while (! $this->flagError && ! $this->flagEndHeaders) { + while (!$this->flagError && !$this->flagEndHeaders) { - if ($this->flagInit) { //in first instance + if ($this->flagInit) { + //in first instance $this->flagInit = false; //unset init flag - - //read the first and second line of the file - $firstLine = fgets( $this->_fp ); - $secondLine = fgets( $this->_fp ); + $firstLine = fgets($this->_fp); + $secondLine = fgets($this->_fp); //verifying the file head - if (strpos( $firstLine, 'msgid ""' ) === false || strpos( $secondLine, 'msgstr ""' ) === false) { + if (strpos($firstLine, 'msgid ""') === false || strpos($secondLine, 'msgstr ""') === false) { $this->flagError = true; $errMsg = 'Misplace for firts msgid "" and msgstr "" in the header'; } @@ -238,36 +230,34 @@ class i18n_PO } //getting the new line - $this->_fileLine = trim( fgets( $this->_fp ) ); + $this->_fileLine = trim(fgets($this->_fp)); //set line number - $this->lineNumber ++; + $this->lineNumber++; //verifying that is not end of file and applying a restriction for to read just the twenty firsts lines - if (trim( $this->_fileLine ) == '' || ! $this->_fileLine || $this->lineNumber >= 20) { + if (trim($this->_fileLine) == '' || !$this->_fileLine || $this->lineNumber >= 20) { $this->flagEndHeaders = true; // set ending to read the headers continue; } //verify if has a valid mask header line - preg_match( '/^"([a-z0-9\._-]+)\s*:\s*([\W\w]+)\\\n"$/i', $this->_fileLine, $match ); + preg_match('/^"([a-z0-9\._-]+)\s*:\s*([\W\w]+)\\\n"$/i', $this->_fileLine, $match); //for a valid header line the $match size should three - if (sizeof( $match ) == 3) { - $key = trim( $match[1] ); //getting the key of the header - $value = trim( $match[2] ); //getting the value of the header + if (sizeof($match) == 3) { + $key = trim($match[1]); //getting the key of the header + $value = trim($match[2]); //getting the value of the header $this->_meta[$key] = $value; //setting a new header } else { $this->flagEndHeaders = true; //otherwise set the ending to read the headers break; } } //end looking for headeers - - //verifying the headers data - if (! isset( $this->_meta['X-Poedit-Language'] )) { - if (! isset( $this->_meta['Language'] )) { + if (!isset($this->_meta['X-Poedit-Language'])) { + if (!isset($this->_meta['Language'])) { $this->flagError = true; $errMsg = "X-Poedit-Language and Language meta doesn't exist"; - } else if ($this->_meta['Language'] == '') { + } elseif ($this->_meta['Language'] == '') { $this->flagError = true; $errMsg = "Language meta is empty"; } else { @@ -275,85 +265,85 @@ class i18n_PO unset($this->_meta['Language']); $this->flagError = false; } - } else if ($this->_meta['X-Poedit-Language'] == '') { + } elseif ($this->_meta['X-Poedit-Language'] == '') { $this->flagError = true; $errMsg = "X-Poedit-Language meta is empty"; } //if the country is not present in metadata - if (! isset( $this->_meta['X-Poedit-Country'] )) { + if (!isset($this->_meta['X-Poedit-Country'])) { $this->_meta['X-Poedit-Country'] = '.'; - } else if ($this->_meta['X-Poedit-Country'] == '') { + } elseif ($this->_meta['X-Poedit-Country'] == '') { $this->_meta['X-Poedit-Country'] = '.'; } //thowing the exception if is necesary if ($this->flagError) { - throw new Exception( "This file is not a valid PO file. ($errMsg)" ); + throw new Exception("This file is not a valid PO file. ($errMsg)"); } } - function getHeaders () + public function getHeaders() { return $this->_meta; } - public function getTranslation () + public function getTranslation() { $flagReadingComments = true; - $this->translatorComments = Array (); - $this->extractedComments = Array (); - $this->references = Array (); - $this->flags = Array (); + $this->translatorComments = Array(); + $this->extractedComments = Array(); + $this->references = Array(); + $this->flags = Array(); //getting the new line - while ($flagReadingComments && ! $this->flagError) { + while ($flagReadingComments && !$this->flagError) { - $this->_fileLine = trim( fgets( $this->_fp ) ); + $this->_fileLine = trim(fgets($this->_fp)); //set line number - $this->lineNumber ++; + $this->lineNumber++; - if (! $this->_fileLine) { + if (!$this->_fileLine) { return false; } - $prefix = substr( $this->_fileLine, 0, 2 ); + $prefix = substr($this->_fileLine, 0, 2); switch ($prefix) { case '# ': - $lineItem = str_replace( '# ', '', $this->_fileLine ); + $lineItem = str_replace('# ', '', $this->_fileLine); $this->translatorComments[] = $lineItem; break; case '#.': - if (substr_count( $this->_fileLine, '#. ' ) == 0) { + if (substr_count($this->_fileLine, '#. ') == 0) { $this->flagError = true; } else { - $lineItem = str_replace( '#. ', '', $this->_fileLine ); + $lineItem = str_replace('#. ', '', $this->_fileLine); $this->extractedComments[] = $lineItem; } break; case '#:': - if (substr_count( $this->_fileLine, '#: ' ) == 0) { + if (substr_count($this->_fileLine, '#: ') == 0) { $this->flagError = true; } else { - $lineItem = str_replace( '#: ', '', $this->_fileLine ); + $lineItem = str_replace('#: ', '', $this->_fileLine); $this->references[] = $lineItem; } break; case '#,': - if (substr_count( $this->_fileLine, '#, ' ) == 0) { + if (substr_count($this->_fileLine, '#, ') == 0) { $this->flagError = true; } else { - $lineItem = str_replace( '#, ', '', $this->_fileLine ); + $lineItem = str_replace('#, ', '', $this->_fileLine); $this->flags[] = $lineItem; } break; case '#|': - if (substr_count( $this->_fileLine, '#| ' ) == 0) { + if (substr_count($this->_fileLine, '#| ') == 0) { $this->flagError = true; } else { - $lineItem = str_replace( '#| ', '', $this->_fileLine ); + $lineItem = str_replace('#| ', '', $this->_fileLine); $this->previousUntranslatedStrings[] = $lineItem; } break; @@ -362,15 +352,15 @@ class i18n_PO } } - if (! $this->_fileLine) { + if (!$this->_fileLine) { return false; } //Getting the msgid - preg_match( '/\s*msgid\s*"(.*)"\s*/s', $this->_fileLine, $match ); + preg_match('/\s*msgid\s*"(.*)"\s*/s', $this->_fileLine, $match); - if (sizeof( $match ) != 2) { - throw new Exception( 'Invalid PO file format1' ); + if (sizeof($match) != 2) { + throw new Exception('Invalid PO file format1'); } $msgid = ''; @@ -378,15 +368,15 @@ class i18n_PO do { //g::pr($match); $msgid .= $match[1]; - $this->_fileLine = trim( fgets( $this->_fp ) ); - preg_match( '/^"(.*)"\s*/s', $this->_fileLine, $match ); - } while (sizeof( $match ) == 2); + $this->_fileLine = trim(fgets($this->_fp)); + preg_match('/^"(.*)"\s*/s', $this->_fileLine, $match); + } while (sizeof($match) == 2); //Getting the msgstr - preg_match( '/\s*msgstr\s*"(.*)"\s*/s', $this->_fileLine, $match ); + preg_match('/\s*msgstr\s*"(.*)"\s*/s', $this->_fileLine, $match); - if (sizeof( $match ) != 2) { - throw new Exception( 'Invalid PO file format2' ); + if (sizeof($match) != 2) { + throw new Exception('Invalid PO file format2'); } $msgstr = ''; @@ -394,24 +384,23 @@ class i18n_PO do { //g::pr($match); $msgstr .= $match[1] . "\n"; - $this->_fileLine = trim( fgets( $this->_fp ) ); - preg_match( '/^"(.*)"\s*/s', $this->_fileLine, $match ); - } while (sizeof( $match ) == 2); + $this->_fileLine = trim(fgets($this->_fp)); + preg_match('/^"(.*)"\s*/s', $this->_fileLine, $match); + } while (sizeof($match) == 2); - /*g::pr($this->translatorComments); - g::pr($this->references); - g::pr($match); - die;*/ + /* g::pr($this->translatorComments); + g::pr($this->references); + g::pr($match); + die; */ - return Array ('msgid' => trim( $msgid ),'msgstr' => trim( $msgstr ) - ); + return Array('msgid' => trim($msgid), 'msgstr' => trim($msgstr)); } //garbage - function __destruct () + public function __destruct() { if ($this->_fp) { - fclose( $this->_fp ); + fclose($this->_fp); } } } diff --git a/gulliver/system/class.menu.php b/gulliver/system/class.menu.php index a17bd5479..6ebc472c5 100755 --- a/gulliver/system/class.menu.php +++ b/gulliver/system/class.menu.php @@ -30,6 +30,7 @@ * @package gulliver.system * */ + /** * * @@ -43,18 +44,19 @@ */ class Menu { - var $Id = null; - var $Options = null; - var $Labels = null; - var $Icons = null; - var $JS = null; - var $Types = null; - var $Class = "mnu"; - var $Classes = null; - var $Enabled = null; - var $optionOn = - 1; - var $id_optionOn = ""; - var $ElementClass = null; + + public $Id = null; + public $Options = null; + public $Labels = null; + public $Icons = null; + public $JS = null; + public $Types = null; + public $Class = "mnu"; + public $Classes = null; + public $Enabled = null; + public $optionOn = - 1; + public $id_optionOn = ""; + public $ElementClass = null; /** * Set menu style @@ -64,7 +66,7 @@ class Menu * @param $strClass name of style class default value 'mnu' * @return void */ - function SetClass ($strClass = "mnu") + public function SetClass($strClass = "mnu") { $this->Class = "mnu"; } @@ -77,35 +79,35 @@ class Menu * @param $strMenuName name of menu * @return void */ - function Load ($strMenuName) + public function Load($strMenuName) { global $G_TMP_MENU; $G_TMP_MENU = null; $G_TMP_MENU = new Menu(); - $fMenu = G::ExpandPath( "menus" ) . $strMenuName . ".php"; + $fMenu = G::ExpandPath("menus") . $strMenuName . ".php"; //if the menu file doesn't exists, then try with the plugins folders - if (! is_file( $fMenu )) { - $aux = explode( PATH_SEP, $strMenuName ); - if (count( $aux ) == 2) { + if (!is_file($fMenu)) { + $aux = explode(PATH_SEP, $strMenuName); + if (count($aux) == 2) { $oPluginRegistry = & PMPluginRegistry::getSingleton(); - if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { + if ($oPluginRegistry->isRegisteredFolder($aux[0])) { $fMenu = PATH_PLUGINS . $aux[0] . PATH_SEP . $aux[1] . ".php"; } } } - if (! is_file( $fMenu )) { + if (!is_file($fMenu)) { return; } include ($fMenu); //this line will add options to current menu. $oPluginRegistry = & PMPluginRegistry::getSingleton(); - $oPluginRegistry->getMenus( $strMenuName ); + $oPluginRegistry->getMenus($strMenuName); //? $c = 0; - for ($i = 0; $i < count( $G_TMP_MENU->Options ); $i ++) + for ($i = 0; $i < count($G_TMP_MENU->Options); $i++) { if ($G_TMP_MENU->Enabled[$i] == 1) { $this->Options[$c] = $G_TMP_MENU->Options[$i]; $this->Labels[$c] = $G_TMP_MENU->Labels[$i]; @@ -116,15 +118,17 @@ class Menu $this->Id[$c] = $G_TMP_MENU->Id[$i]; $this->Classes[$c] = $G_TMP_MENU->Classes[$i]; $this->ElementClass[$c] = $G_TMP_MENU->ElementClass[$i]; - $c ++; + $c++; } else { - if ($i == $this->optionOn) + if ($i == $this->optionOn) { $this->optionOn = - 1; - elseif ($i < $this->optionOn) - $this->optionOn --; - elseif ($this->optionOn > 0) - $this->optionOn --; //added this line + } elseif ($i < $this->optionOn) { + $this->optionOn--; + } elseif ($this->optionOn > 0) { + $this->optionOn--; //added this line + } } + } $G_TMP_MENU = null; } @@ -135,11 +139,11 @@ class Menu * @access public * @return int */ - function OptionCount () + public function OptionCount() { $result = 0; - if (is_array( $this->Options )) { - $result = count( $this->Options ); + if (is_array($this->Options)) { + $result = count($this->Options); } return $result; } @@ -154,7 +158,7 @@ class Menu * @param string $strType type, defualt value ='plugins' * @return void */ - function AddOption ($strLabel, $strURL, $strType = "plugins") + public function AddOption($strLabel, $strURL, $strType = "plugins") { $pos = $this->OptionCount(); $this->Options[$pos] = $strURL; @@ -162,7 +166,7 @@ class Menu $this->Types[$pos] = $strType; $this->Enabled[$pos] = 1; $this->Id[$pos] = $pos; - unset( $pos ); + unset($pos); } /** @@ -176,20 +180,20 @@ class Menu * @param string $strType type, defualt value ='plugins' * @return void */ - function AddIdOption ($strId, $strLabel, $strURL, $strType = "plugins") + public function AddIdOption($strId, $strLabel, $strURL, $strType = "plugins") { $pos = $this->OptionCount(); $this->Options[$pos] = $strURL; $this->Labels[$pos] = $strLabel; $this->Types[$pos] = $strType; $this->Enabled[$pos] = 1; - if (is_array( $strId )) { + if (is_array($strId)) { $this->Id[$pos] = $strId[0]; $this->Classes[$pos] = $strId[1]; } else { $this->Id[$pos] = $strId; } - unset( $pos ); + unset($pos); } /** @@ -201,7 +205,7 @@ class Menu * @param string $strType type, defualt value ='plugins' * @return void */ - function AddRawOption ($strURL = "", $strType = "plugins") + public function AddRawOption($strURL = "", $strType = "plugins") { $pos = $this->OptionCount(); $this->Options[$pos] = $strURL; @@ -209,7 +213,7 @@ class Menu $this->Types[$pos] = $strType; $this->Enabled[$pos] = 1; $this->Id[$pos] = $pos; - unset( $pos ); + unset($pos); } /** @@ -224,7 +228,7 @@ class Menu * @param string $elementClass default value ='' * @return void */ - function AddIdRawOption ($strId, $strURL = "", $label = "", $icon = "", $js = "", $strType = "plugins", $elementClass = '') + public function AddIdRawOption($strId, $strURL = "", $label = "", $icon = "", $js = "", $strType = "plugins", $elementClass = '') { $pos = $this->OptionCount(); $this->Options[$pos] = $strURL; @@ -234,13 +238,13 @@ class Menu $this->Types[$pos] = $strType; $this->Enabled[$pos] = 1; $this->ElementClass[$pos] = $elementClass; - if (is_array( $strId )) { + if (is_array($strId)) { $this->Id[$pos] = $strId[0]; $this->Classes[$pos] = $strId[1]; } else { $this->Id[$pos] = $strId; } - unset( $pos ); + unset($pos); } /** @@ -251,7 +255,7 @@ class Menu * @param string $intPos menu option's position * @return void */ - function DisableOptionPos ($intPos) + public function DisableOptionPos($intPos) { $this->Enabled[$intPos] = 0; } @@ -264,10 +268,10 @@ class Menu * @param string $id menu's id * @return void */ - function DisableOptionId ($id) + public function DisableOptionId($id) { - if (array_search( $id, $this->Id )) { - $this->Enabled[array_search( $id, $this->Id )] = 0; + if (array_search($id, $this->Id)) { + $this->Enabled[array_search($id, $this->Id)] = 0; } } @@ -279,7 +283,7 @@ class Menu * @param string $intPos menu option's position * @return void */ - function RenderOption ($intPos) + public function RenderOption($intPos) { if ($this->Enabled[$intPos] != 1) { return; @@ -290,9 +294,9 @@ class Menu } $target = $this->Options[$intPos]; if ($this->Types[$intPos] != "absolute") { - if (defined( 'ENABLE_ENCRYPT' )) { + if (defined('ENABLE_ENCRYPT')) { $target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target; - } else if (defined( 'SYS_SYS' )) { + } elseif (defined('SYS_SYS')) { $target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target; } else { $target = "/sys/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target; @@ -301,10 +305,9 @@ class Menu $label = $this->Labels[$intPos]; $result = ""; - $result .= htmlentities( $label, ENT_NOQUOTES, 'utf-8' ); + $result .= htmlentities($label, ENT_NOQUOTES, 'utf-8'); $result .= ""; - print ($result) ; - + print ($result); } /** @@ -319,18 +322,18 @@ class Menu * @param string $G_ID_MENU_SELECTED * @return array */ - function generateArrayForTemplate ($G_MAIN_MENU, $classOn, $classOff, $G_MENU_SELECTED, $G_ID_MENU_SELECTED) + public function generateArrayForTemplate($G_MAIN_MENU, $classOn, $classOff, $G_MENU_SELECTED, $G_ID_MENU_SELECTED) { - $menus = array (); + $menus = array(); if ($G_MAIN_MENU == null) { return $menus; } - $this->Load( $G_MAIN_MENU ); + $this->Load($G_MAIN_MENU); $this->optionOn = $G_MENU_SELECTED; $this->id_optionOn = $G_ID_MENU_SELECTED; //$this->Class = $G_MENU_CLASS; - if (is_array( $this->Options )) { - for ($ncount = 0; $ncount < $this->OptionCount(); $ncount ++) { + if (is_array($this->Options)) { + for ($ncount = 0; $ncount < $this->OptionCount(); $ncount++) { $target = $this->Options[$ncount]; //$aux = $this->Icons[$ncount]; @@ -340,10 +343,10 @@ class Menu $target = $this->Options[$ncount]; } if ($this->Types[$ncount] != 'absolute') { - if (defined( 'SYS_SYS' )) { - $target = '/sys' . SYS_TEMP . G::encryptLink( '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] ); + if (defined('SYS_SYS')) { + $target = '/sys' . SYS_TEMP . G::encryptLink('/' . SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount]); } else { - $target = '/sys/' . G::encryptLink( SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] ); + $target = '/sys/' . G::encryptLink(SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount]); } } $label = $this->Labels[$ncount]; @@ -374,11 +377,10 @@ class Menu $elementclass = 'class="' . $this->ElementClass[$ncount] . '"'; } - $menus[] = array ('id' => $ncount,'target' => $target,'label' => $label,'onMenu' => $onMenu,'classname' => $classname,'imageLeft' => $imageLeft,'onclick' => $onclick,'icon' => $icon,'aux' => $aux,'idName' => $idName,'elementclass' => $elementclass - ); + $menus[] = array('id' => $ncount, 'target' => $target, 'label' => $label, 'onMenu' => $onMenu, 'classname' => $classname, 'imageLeft' => $imageLeft, 'onclick' => $onclick, 'icon' => $icon, 'aux' => $aux, 'idName' => $idName, 'elementclass' => $elementclass); } } return $menus; } } - + \ No newline at end of file diff --git a/gulliver/system/class.tree.php b/gulliver/system/class.tree.php index 5ab93891f..81be8ff5c 100755 --- a/gulliver/system/class.tree.php +++ b/gulliver/system/class.tree.php @@ -1,4 +1,5 @@  "; - var $minus = " "; - var $point = " "; + + public $template = 'tree.html'; + public $nodeType = 'base'; + public $nodeClass = 'treeNode'; + public $contentClass = 'treeContent'; + public $width = '100%'; + public $contentWidth = '360'; + public $contracted = false; + public $showSign = true; + public $isChild = false; + public $plus = " "; + public $minus = " "; + public $point = " "; /** * Tree @@ -54,18 +55,18 @@ class Tree extends Xml_Node * * @return none */ - public function Tree ($xmlnode = null) + public function Tree($xmlnode = null) { - if (! isset( $xmlnode )) { + if (!isset($xmlnode)) { return; } - if (isset( $xmlnode->attributes['nodeType'] )) { + if (isset($xmlnode->attributes['nodeType'])) { $this->nodeType = $xmlnode->attributes['nodeType']; } foreach ($xmlnode as $key => $value) { if ($key === 'children') { foreach ($xmlnode->children as $key => $value) { - $this->children[$key] = new Tree( $value->toTree() ); + $this->children[$key] = new Tree($value->toTree()); } } elseif ($key === 'attributes') { foreach ($xmlnode->attributes as $key => $value) { @@ -86,10 +87,9 @@ class Tree extends Xml_Node * * @return object(Tree) $newNode */ - - public function &addChild ($name, $label, $attributes = array()) + public function &addChild($name, $label, $attributes = array()) { - $newNode = new Tree( new Xml_Node( $name, 'open', $label, $attributes ) ); + $newNode = new Tree(new Xml_Node($name, 'open', $label, $attributes)); $this->children[] = & $newNode; return $newNode; } @@ -99,15 +99,15 @@ class Tree extends Xml_Node * * @return string '...' */ - public function printPlus () + public function printPlus() { $plus = 'none'; $minus = 'none'; $point = 'none'; if ($this->showSign) { - if ((sizeof( $this->children ) > 0) && ($this->contracted)) { + if ((sizeof($this->children) > 0) && ($this->contracted)) { $plus = ''; - } elseif ((sizeof( $this->children ) > 0) && (! $this->contracted)) { + } elseif ((sizeof($this->children) > 0) && (!$this->contracted)) { $minus = ''; } else { $point = ''; @@ -121,7 +121,7 @@ class Tree extends Xml_Node * * @return $this->value */ - public function printLabel () + public function printLabel() { return $this->value; } @@ -131,7 +131,7 @@ class Tree extends Xml_Node * * @return string $html */ - public function printContent () + public function printContent() { $html = ''; $row = 0; @@ -150,11 +150,10 @@ class Tree extends Xml_Node * * @return $obj->printObject( array( 'node' => &$this ) ) */ - public function render () + public function render() { - $obj = new objectTemplate( $this->template ); - return $obj->printObject( array ('node' => &$this - ) ); + $obj = new objectTemplate($this->template); + return $obj->printObject(array('node' => &$this)); } } diff --git a/gulliver/system/class.xmlDocument.php b/gulliver/system/class.xmlDocument.php index e4c7f6ecc..8b75d6137 100755 --- a/gulliver/system/class.xmlDocument.php +++ b/gulliver/system/class.xmlDocument.php @@ -34,11 +34,11 @@ */ class Xml_Node { - var $name = ''; - var $type = ''; - var $value = ''; //maybe not necesary - var $attributes = array (); - var $children = array (); + public $name = ''; + public $type = ''; + public $value = ''; //maybe not necesary + public $attributes = array (); + public $children = array (); /** * Function Xml_Node @@ -51,7 +51,7 @@ class Xml_Node * @param eter string attributes * @return string */ - function Xml_Node ($name, $type, $value, $attributes = array()) + public function Xml_Node ($name, $type, $value, $attributes = array()) { $this->name = $name; $this->type = $type; @@ -68,7 +68,7 @@ class Xml_Node * @param eter string value * @return string */ - function addAttribute ($name, $value) + public function addAttribute ($name, $value) { $this->attributes[$name] = $value; return true; @@ -82,7 +82,7 @@ class Xml_Node * @param eter string childNode * @return string */ - function addChildNode ($childNode) + public function addChildNode ($childNode) { if (is_object( $childNode ) && strcasecmp( get_class( $childNode ), 'Xml_Node' ) == 0) { $this->type = 'open'; @@ -101,7 +101,7 @@ class Xml_Node * @access public * @return string */ - function toTree () + public function toTree () { $arr = new Xml_Node( $this->name, $this->type, $this->value, $this->attributes ); unset( $arr->parent ); @@ -112,7 +112,7 @@ class Xml_Node return $arr; } - function toArray ($obj = null) + public function toArray ($obj = null) { $arr = array (); if (! isset( $obj )) { @@ -136,7 +136,7 @@ class Xml_Node * @param eter string xpath * @return string */ - function &findNode ($xpath) + public function &findNode ($xpath) { $n = null; $p = explode( '/', $xpath ); @@ -180,7 +180,7 @@ class Xml_Node * @param eter string xpath * @return string */ - function getXML () + public function getXML () { switch ($this->type) { case 'open': @@ -237,7 +237,7 @@ class Xml_Node return $xml; } - function getCDATAValue () + public function getCDATAValue () { $cdata = htmlentities( $this->value, ENT_QUOTES, 'utf-8' ); if ($this->value === $cdata) { @@ -257,7 +257,7 @@ class Xml_Node */ class Xml_document extends Xml_Node { - var $currentNode; + public $currentNode; /** * Function Xml_document @@ -266,7 +266,7 @@ class Xml_document extends Xml_Node * @access public * @return string */ - function Xml_document () + public function Xml_document () { $this->currentNode = &$this; } @@ -280,7 +280,7 @@ class Xml_document extends Xml_Node * @param eter string content * @return string */ - function parseXmlFile ($filename, $content = "") + public function parseXmlFile ($filename, $content = "") { //$content is a new variable, if it has any value then use it instead of the file content. if ($content == "") { if (! file_exists( $filename )) { @@ -333,7 +333,7 @@ class Xml_document extends Xml_Node * @param eter string xpath * @return string */ - function &findNode ($xpath) + public function &findNode ($xpath) { if (substr( $xpath, 0, 1 ) == '/') { return parent::findNode( substr( $xpath, 1 ) ); @@ -357,7 +357,7 @@ class Xml_document extends Xml_Node * @access public * @return string $xml */ - function getXML () + public function getXML () { $xml = '' . "\n"; $xml .= $this->children[0]->getXML(); @@ -370,7 +370,7 @@ class Xml_document extends Xml_Node * @access public * @return void */ - function save ($filename) + public function save ($filename) { $xml = $this->getXML(); $fp = fopen( $filename, 'w' ); diff --git a/gulliver/system/class.xmlformExtension.php b/gulliver/system/class.xmlformExtension.php index c431c05b5..57c413ad4 100755 --- a/gulliver/system/class.xmlformExtension.php +++ b/gulliver/system/class.xmlformExtension.php @@ -1,161 +1,160 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -/** - * - * @package gulliver.system - */ - -class XmlForm_Field_Label extends XmlForm_Field -{ - var $withoutValue = true; - var $align = 'left'; -} - -/** - * Special class for pagedTable - * condition: PHP expression whose result defines whether to "mark" - * the following columns (that is if true) - * - * @package gulliver.system - */ -class XmlForm_Field_cellMark extends XmlForm_Field -{ - /* Defines the style of the next tds - of the pagedTable. - */ - var $showInTable = "0"; - var $style = ""; - var $styleAlt = ""; - var $className = ""; - var $classNameAlt = ""; - var $condition = 'false'; - - /** - * tdStyle - * - * @param string $values - * @param string $owner - * - * @return string $value - */ - function tdStyle ($values, $owner) - { - $value = G::replaceDataField( $this->condition, $owner->values ); - $value = @eval( 'return (' . $value . ');' ); - $row = $values['row__']; - $style = ((($row % 2) == 0) && ($this->styleAlt != 0)) ? $this->styleAlt : $this->style; - return ($value) ? $style : ''; - } - - /** - * tdClass - * - * @param string $values - * @param string $owner - * - * @return $value - */ - function tdClass ($values, $owner) - { - $value = G::replaceDataField( $this->condition, $owner->values ); - $value = @eval( 'return (' . $value . ');' ); - $row = $values['row__']; - $style = (($row % 2) == 0) ? $this->classNameAlt : $this->className; - return ($value) ? $style : ''; - } -} - -/** - * XmlForm_Field_DVEditor - * - * extends XmlForm_Field - * - * @package gulliver.system - * - */ -class XmlForm_Field_DVEditor extends XmlForm_Field -{ - var $toolbarSet = 'toolbar2lines.html'; - var $width = '90%'; - var $height = '200'; - - /** - * render - * - * @param string $value - * @param string $owner default value NULL - * - * @return string '
...
' - */ - function render ($value, $owner = null) - { - return '
'; - } - - /** - * attachEvents - * - * @param string $element - * - * @return $html - */ - function attachEvents ($element) - { - $html = 'var _editor' . $this->name . '=new DVEditor(getField("form[' . $this->name . ']").parentNode,getField("form[' . $this->name . ']").value)'; - return $html; - } -} - -/** - * Special field: Add a search box (fast search) for the related pagedTable - * - * The PAGED_TABLE_ID reserved field must be defined in the xml. - * Use PAGED_TABLE_FAST_SEARCH reserved field, it contains the saved value for each table. - * example: - * Ex1. - * - * - * Search - * - * Ex2 (Using type="text"). - * - * - * Search - * - * - * @package gulliver.system - */ -class XmlForm_Field_FastSearch extends XmlForm_Field_Text -{ - var $onkeypress = "if (event.keyCode===13)@#PAGED_TABLE_ID.doFastSearch(this.value);if (event.keyCode===13)return false;"; - var $colAlign = "right"; - var $colWidth = "180"; - var $label = "@G::LoadTranslation(ID_SEARCH)"; +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +/** + * + * @package gulliver.system + */ +class XmlForm_Field_Label extends XmlForm_Field +{ + public $withoutValue = true; + public $align = 'left'; } - + +/** + * Special class for pagedTable + * condition: PHP expression whose result defines whether to "mark" + * the following columns (that is if true) + * + * @package gulliver.system + */ +class XmlForm_Field_cellMark extends XmlForm_Field +{ + /* Defines the style of the next tds + of the pagedTable. + */ + public $showInTable = "0"; + public $style = ""; + public $styleAlt = ""; + public $className = ""; + public $classNameAlt = ""; + public $condition = 'false'; + + /** + * tdStyle + * + * @param string $values + * @param string $owner + * + * @return string $value + */ + public function tdStyle($values, $owner) + { + $value = G::replaceDataField($this->condition, $owner->values); + $value = @eval('return (' . $value . ');'); + $row = $values['row__']; + $style = ((($row % 2) == 0) && ($this->styleAlt != 0)) ? $this->styleAlt : $this->style; + return ($value) ? $style : ''; + } + + /** + * tdClass + * + * @param string $values + * @param string $owner + * + * @return $value + */ + public function tdClass($values, $owner) + { + $value = G::replaceDataField($this->condition, $owner->values); + $value = @eval('return (' . $value . ');'); + $row = $values['row__']; + $style = (($row % 2) == 0) ? $this->classNameAlt : $this->className; + return ($value) ? $style : ''; + } +} + +/** + * XmlForm_Field_DVEditor + * + * extends XmlForm_Field + * + * @package gulliver.system + * + */ +class XmlForm_Field_DVEditor extends XmlForm_Field +{ + public $toolbarSet = 'toolbar2lines.html'; + public $width = '90%'; + public $height = '200'; + + /** + * render + * + * @param string $value + * @param string $owner default value NULL + * + * @return string '
...
' + */ + public function render($value, $owner = null) + { + return '
'; + } + + /** + * attachEvents + * + * @param string $element + * + * @return $html + */ + public function attachEvents($element) + { + $html = 'var _editor' . $this->name . '=new DVEditor(getField("form[' . $this->name . ']").parentNode,getField("form[' . $this->name . ']").value)'; + return $html; + } +} + +/** + * Special field: Add a search box (fast search) for the related pagedTable + * + * The PAGED_TABLE_ID reserved field must be defined in the xml. + * Use PAGED_TABLE_FAST_SEARCH reserved field, it contains the saved value for each table. + * example: + * Ex1. + * + * + * Search + * + * Ex2 (Using type="text"). + * + * + * Search + * + * + * @package gulliver.system + */ +class XmlForm_Field_FastSearch extends XmlForm_Field_Text +{ + public $onkeypress = "if (event.keyCode===13)@#PAGED_TABLE_ID.doFastSearch(this.value);if (event.keyCode===13)return false;"; + public $colAlign = "right"; + public $colWidth = "180"; + public $label = "@G::LoadTranslation(ID_SEARCH)"; +} + diff --git a/workflow/engine/classes/class.Installer.php b/workflow/engine/classes/class.Installer.php index 262b9e1fa..a8d5a4d05 100755 --- a/workflow/engine/classes/class.Installer.php +++ b/workflow/engine/classes/class.Installer.php @@ -33,7 +33,6 @@ // License: LGPL, see LICENSE //////////////////////////////////////////////////// - /** * Processmaker Installer * @@ -41,13 +40,13 @@ * @author maborak * @copyright 2008 COLOSA */ - class Installer { - public $options = Array (); - public $result = Array (); - public $error = Array (); - public $report = Array (); + + public $options = Array(); + public $result = Array(); + public $error = Array(); + public $report = Array(); private $connection_database; /** @@ -56,7 +55,7 @@ class Installer * @param string $pPRO_UID * @return void */ - function __construct () + public function __construct() { } @@ -67,15 +66,15 @@ class Installer * @param boolean $confirmed * @return void */ - public function create_site ($config = Array(), $confirmed = false) + public function create_site($config = Array(), $confirmed = false) { - $this->options = G::array_concat( Array ('isset' => false,'password' => G::generate_password( 12 ),'path_data' => @PATH_DATA,'path_compiled' => @PATH_C,'name' => $config['name'],'database' => Array (),'admin' => Array ('username' => 'admin','password' => 'admin' - ),'advanced' => Array ('ao_db_wf' => 'wf_' . $config['name'],'ao_db_rb' => 'rb_' . $config['name'],'ao_db_rp' => 'rp_' . $config['name'],'ao_db_drop' => false - ) - ), $config ); - $a = @explode( SYSTEM_HASH, G::decrypt( HASH_INSTALLATION, SYSTEM_HASH ) ); - $this->options['database'] = G::array_concat( Array ('username' => @$a[1],'password' => @$a[2],'hostname' => @$a[0] - ), $this->options['database'] ); + $this->options = G::array_concat(Array('isset' => false, 'password' => G::generate_password(12), 'path_data' => @PATH_DATA, 'path_compiled' => @PATH_C, 'name' => $config['name'], 'database' => Array(), 'admin' => Array('username' => 'admin', 'password' => 'admin' + ), 'advanced' => Array('ao_db_wf' => 'wf_' . $config['name'], 'ao_db_rb' => 'rb_' . $config['name'], 'ao_db_rp' => 'rp_' . $config['name'], 'ao_db_drop' => false + ) + ), $config); + $a = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH)); + $this->options['database'] = G::array_concat(Array('username' => @$a[1], 'password' => @$a[2], 'hostname' => @$a[0] + ), $this->options['database']); return ($confirmed === true) ? $this->make_site() : $this->create_site_test(); } @@ -85,9 +84,9 @@ class Installer * @param string $name Default value "workflow" * @return string file_exists(PATH_DATA."sites/".$name); */ - public function isset_site ($name = "workflow") + public function isset_site($name = "workflow") { - return file_exists( PATH_DATA . "sites/" . $name ); + return file_exists(PATH_DATA . "sites/" . $name); } /** @@ -95,17 +94,17 @@ class Installer * * @return void */ - private function create_site_test () + private function create_site_test() { - $name = (preg_match( '/^[\w]+$/i', trim( $this->options['name'] ) )) ? true : false; - $result = Array ('path_data' => $this->is_dir_writable( $this->options['path_data'] ),'path_compiled' => $this->is_dir_writable( $this->options['path_compiled'] ),'database' => $this->check_connection(),'access_level' => $this->cc_status,'isset' => ($this->options['isset'] == true) ? $this->isset_site( $this->options['name'] ) : false,'microtime' => microtime(),'workspace' => $this->options['name'],'name' => array ('status' => $name,'message' => ($name) ? 'PASSED' : 'Workspace name invalid' - ),'admin' => array ('username' => (preg_match( '/^[\w@\.-]+$/i', trim( $this->options['admin']['username'] ) )) ? true : false,'password' => ((trim( $this->options['admin']['password'] ) == '') ? false : true) - ) + $name = (preg_match('/^[\w]+$/i', trim($this->options['name']))) ? true : false; + $result = Array('path_data' => $this->is_dir_writable($this->options['path_data']), 'path_compiled' => $this->is_dir_writable($this->options['path_compiled']), 'database' => $this->check_connection(), 'access_level' => $this->cc_status, 'isset' => ($this->options['isset'] == true) ? $this->isset_site($this->options['name']) : false, 'microtime' => microtime(), 'workspace' => $this->options['name'], 'name' => array('status' => $name, 'message' => ($name) ? 'PASSED' : 'Workspace name invalid' + ), 'admin' => array('username' => (preg_match('/^[\w@\.-]+$/i', trim($this->options['admin']['username']))) ? true : false, 'password' => ((trim($this->options['admin']['password']) == '') ? false : true) + ) ); $result['name']['message'] = ($result['isset']) ? 'Workspace already exist' : $result['name']['message']; $result['name']['status'] = ($result['isset']) ? false : $result['name']['status']; //print_r($result); - return Array ('created' => G::var_compare( true, $result['path_data'], $result['database']['connection'], $result['name']['status'], $result['database']['version'], $result['database']['ao']['ao_db_wf']['status'], $result['database']['ao']['ao_db_rb']['status'], $result['database']['ao']['ao_db_rp']['status'], $result['admin']['username'], (($result['isset']) ? false : true), $result['admin']['password'] ),'result' => $result + return Array('created' => G::var_compare(true, $result['path_data'], $result['database']['connection'], $result['name']['status'], $result['database']['version'], $result['database']['ao']['ao_db_wf']['status'], $result['database']['ao']['ao_db_rb']['status'], $result['database']['ao']['ao_db_rp']['status'], $result['admin']['username'], (($result['isset']) ? false : true), $result['admin']['password']), 'result' => $result ); } @@ -114,13 +113,13 @@ class Installer * * @return array $test */ - private function make_site () + private function make_site() { $test = $this->create_site_test(); if ($test["created"] == true || $this->options["advanced"]["ao_db_drop"] == true) { /* Check if the hostname is local (localhost or 127.0.0.1) */ - $islocal = (strcmp( substr( $this->options['database']['hostname'], 0, strlen( 'localhost' ) ), 'localhost' ) === 0) || (strcmp( substr( $this->options['database']['hostname'], 0, strlen( '127.0.0.1' ) ), '127.0.0.1' ) === 0); + $islocal = (strcmp(substr($this->options['database']['hostname'], 0, strlen('localhost')), 'localhost') === 0) || (strcmp(substr($this->options['database']['hostname'], 0, strlen('127.0.0.1')), '127.0.0.1') === 0); $this->wf_site_name = $wf = $this->options['advanced']['ao_db_wf']; @@ -132,79 +131,77 @@ class Installer if ($this->options['advanced']['ao_db_drop'] === true) { //Delete workspace directory if exists - - //Drop databases - $this->run_query( "DROP DATABASE IF EXISTS " . $wf, "Drop database $wf" ); - $this->run_query( "DROP DATABASE IF EXISTS " . $rb, "Drop database $rb" ); - $this->run_query( "DROP DATABASE IF EXISTS " . $rp, "Drop database $rp" ); + $this->run_query("DROP DATABASE IF EXISTS " . $wf, "Drop database $wf"); + $this->run_query("DROP DATABASE IF EXISTS " . $rb, "Drop database $rb"); + $this->run_query("DROP DATABASE IF EXISTS " . $rp, "Drop database $rp"); } - $this->run_query( "CREATE DATABASE IF NOT EXISTS " . $wf . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database $wf" ); - $this->run_query( "CREATE DATABASE IF NOT EXISTS " . $rb . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database $rb" ); - $this->run_query( "CREATE DATABASE IF NOT EXISTS " . $rp . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database $rp" ); + $this->run_query("CREATE DATABASE IF NOT EXISTS " . $wf . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database $wf"); + $this->run_query("CREATE DATABASE IF NOT EXISTS " . $rb . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database $rb"); + $this->run_query("CREATE DATABASE IF NOT EXISTS " . $rp . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database $rp"); if ($this->cc_status == 1) { $host = ($islocal) ? "localhost" : "%"; - $this->run_query( "GRANT ALL PRIVILEGES ON `$wf`.* TO $wf@'$host' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user $wf on database $wf" ); - $this->run_query( "GRANT ALL PRIVILEGES ON `$rb`.* TO $rb@'$host' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user $rb on database $rb" ); - $this->run_query( "GRANT ALL PRIVILEGES ON `$rp`.* TO $rp@'$host' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user $rp on database $rp" ); + $this->run_query("GRANT ALL PRIVILEGES ON `$wf`.* TO $wf@'$host' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user $wf on database $wf"); + $this->run_query("GRANT ALL PRIVILEGES ON `$rb`.* TO $rb@'$host' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user $rb on database $rb"); + $this->run_query("GRANT ALL PRIVILEGES ON `$rp`.* TO $rp@'$host' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user $rp on database $rp"); } /* Dump schema workflow && data */ - $this->log( "Import database schema:\n" ); - $myPortA = explode( ":", $this->options['database']['hostname'] ); - if (count( $myPortA ) < 2) { + $this->log("Import database schema:\n"); + $myPortA = explode(":", $this->options['database']['hostname']); + if (count($myPortA) < 2) { $myPortA[1] = "3306"; } $myPort = $myPortA[1]; $this->options['database']['hostname'] = $myPortA[0]; - mysql_select_db( $wf, $this->connection_database ); + mysql_select_db($wf, $this->connection_database); $pws = PATH_WORKFLOW_MYSQL_DATA . $schema; - $qws = $this->query_sql_file( PATH_WORKFLOW_MYSQL_DATA . $schema, $this->connection_database ); - $this->log( $qws, isset( $qws['errors'] ) ); - $qwv = $this->query_sql_file( PATH_WORKFLOW_MYSQL_DATA . $values, $this->connection_database ); - $this->log( $qwv, isset( $qwv['errors'] ) ); + $qws = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $schema, $this->connection_database); + $this->log($qws, isset($qws['errors'])); + $qwv = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $values, $this->connection_database); + $this->log($qwv, isset($qwv['errors'])); /* Dump schema rbac && data */ $pws = PATH_RBAC_MYSQL_DATA . $schema; - mysql_select_db( $rb, $this->connection_database ); - $qrs = $this->query_sql_file( PATH_RBAC_MYSQL_DATA . $schema, $this->connection_database ); - $this->log( $qrs, isset( $qrs['errors'] ) ); - $qrv = $this->query_sql_file( PATH_RBAC_MYSQL_DATA . $values, $this->connection_database ); - $this->log( $qrv, isset( $qrv['errors'] ) ); + mysql_select_db($rb, $this->connection_database); + $qrs = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $schema, $this->connection_database); + $this->log($qrs, isset($qrs['errors'])); + $qrv = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $values, $this->connection_database); + $this->log($qrv, isset($qrv['errors'])); - mysql_select_db( $wf, $this->connection_database ); + mysql_select_db($wf, $this->connection_database); require_once ("propel/Propel.php"); require_once ('classes/model/AppCacheView.php'); $appCache = new AppCacheView(); - $appCache->setPathToAppCacheFiles( PATH_METHODS . 'setup/setupSchemas/' ); - $triggers = $appCache->getTriggers( "en" ); - $this->log( "Create 'cases list cache' triggers" ); + $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup/setupSchemas/'); + $triggers = $appCache->getTriggers("en"); + $this->log("Create 'cases list cache' triggers"); foreach ($triggers as $triggerName => $trigger) { - $this->run_query( $trigger, "-> Trigger $triggerName" ); + $this->run_query($trigger, "-> Trigger $triggerName"); } $path_site = $this->options['path_data'] . "/sites/" . $this->options['name'] . "/"; $db_file = $path_site . "db.php"; - @mkdir( $path_site, 0777, true ); - @mkdir( $path_site . "files/", 0777, true ); - @mkdir( $path_site . "mailTemplates/", 0777, true ); - @mkdir( $path_site . "public/", 0777, true ); - @mkdir( $path_site . "reports/", 0777, true ); - @mkdir( $path_site . "xmlForms", 0777, true ); + @mkdir($path_site, 0777, true); + @mkdir($path_site . "files/", 0777, true); + @mkdir($path_site . "mailTemplates/", 0777, true); + @mkdir($path_site . "public/", 0777, true); + @mkdir($path_site . "reports/", 0777, true); + @mkdir($path_site . "xmlForms", 0777, true); $db_text = "options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_NAME', '" . $wf . "' );\n" . "define ('DB_USER', '" . (($this->cc_status == 1) ? $wf : $this->options['database']['username']) . "' );\n" . "define ('DB_PASS', '" . (($this->cc_status == 1) ? $this->options['password'] : $this->options['database']['password']) . "' );\n" . "define ('DB_RBAC_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_RBAC_NAME', '" . $rb . "' );\n" . "define ('DB_RBAC_USER', '" . (($this->cc_status == 1) ? $rb : $this->options['database']['username']) . "' );\n" . "define ('DB_RBAC_PASS', '" . (($this->cc_status == 1) ? $this->options['password'] : $this->options['database']['password']) . "' );\n" . "define ('DB_REPORT_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_REPORT_NAME', '" . $rp . "' );\n" . "define ('DB_REPORT_USER', '" . (($this->cc_status == 1) ? $rp : $this->options['database']['username']) . "' );\n" . "define ('DB_REPORT_PASS', '" . (($this->cc_status == 1) ? $this->options['password'] : $this->options['database']['password']) . "' );\n" . "?>"; - $fp = @fopen( $db_file, "w" ); - $this->log( "Create: " . $db_file . " => " . ((! $fp) ? $fp : "OK") . "\n", $fp === FALSE ); - $ff = @fputs( $fp, $db_text, strlen( $db_text ) ); - $this->log( "Write: " . $db_file . " => " . ((! $ff) ? $ff : "OK") . "\n", $ff === FALSE ); + $fp = @fopen($db_file, "w"); + $this->log("Create: " . $db_file . " => " . ((!$fp) ? $fp : "OK") . "\n", $fp === false); + $ff = @fputs($fp, $db_text, strlen($db_text)); + $this->log("Write: " . $db_file . " => " . ((!$ff) ? $ff : "OK") . "\n", $ff === false); - fclose( $fp ); + fclose($fp); $this->set_admin(); } return $test; @@ -215,18 +212,18 @@ class Installer * * @return void */ - public function set_admin () + public function set_admin() { - mysql_select_db( $this->wf_site_name, $this->connection_database ); + mysql_select_db($this->wf_site_name, $this->connection_database); // The mysql_escape_string function has been DEPRECATED as of PHP 5.3.0. // $this->run_query('UPDATE USERS SET USR_USERNAME = \''.mysql_escape_string($this->options['admin']['username']).'\', `USR_PASSWORD` = \''.md5($this->options['admin']['password']).'\' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1', // "Add 'admin' user in ProcessMaker (wf)"); - $this->run_query( 'UPDATE USERS SET USR_USERNAME = \'' . mysql_real_escape_string( $this->options['admin']['username'] ) . '\', ' . ' `USR_PASSWORD` = \'' . md5( $this->options['admin']['password'] ) . '\' ' . ' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1', "Add 'admin' user in ProcessMaker (wf)" ); - mysql_select_db( $this->rbac_site_name, $this->connection_database ); + $this->run_query('UPDATE USERS SET USR_USERNAME = \'' . mysql_real_escape_string($this->options['admin']['username']) . '\', ' . ' `USR_PASSWORD` = \'' . md5($this->options['admin']['password']) . '\' ' . ' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1', "Add 'admin' user in ProcessMaker (wf)"); + mysql_select_db($this->rbac_site_name, $this->connection_database); // The mysql_escape_string function has been DEPRECATED as of PHP 5.3.0. // $this->run_query('UPDATE USERS SET USR_USERNAME = \''.mysql_escape_string($this->options['admin']['username']).'\', `USR_PASSWORD` = \''.md5($this->options['admin']['password']).'\' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1', // "Add 'admin' user in ProcessMaker (rb)"); - $this->run_query( 'UPDATE USERS SET USR_USERNAME = \'' . mysql_real_escape_string( $this->options['admin']['username'] ) . '\', ' . ' `USR_PASSWORD` = \'' . md5( $this->options['admin']['password'] ) . '\' ' . ' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1', "Add 'admin' user in ProcessMaker (rb)" ); + $this->run_query('UPDATE USERS SET USR_USERNAME = \'' . mysql_real_escape_string($this->options['admin']['username']) . '\', ' . ' `USR_PASSWORD` = \'' . md5($this->options['admin']['password']) . '\' ' . ' WHERE `USR_UID` = \'00000000000000000000000000000001\' LIMIT 1', "Add 'admin' user in ProcessMaker (rb)"); } /** @@ -236,11 +233,11 @@ class Installer * @param string $query SQL command * @param string $description Description to log instead of $query */ - private function run_query ($query, $description = NULL) + private function run_query($query, $description = null) { - $result = @mysql_query( $query, $this->connection_database ); + $result = @mysql_query($query, $this->connection_database); $error = ($result) ? false : mysql_error(); - $this->log( ($description ? $description : $query) . " => " . (($error) ? $error : "OK") . "\n", $error ); + $this->log(($description ? $description : $query) . " => " . (($error) ? $error : "OK") . "\n", $error); } /** @@ -250,29 +247,29 @@ class Installer * @param string $connection * @return array $report */ - public function query_sql_file ($file, $connection) + public function query_sql_file($file, $connection) { - $lines = file( $file ); - $previous = NULL; + $lines = file($file); + $previous = null; $errors = ''; - @mysql_query( "SET NAMES 'utf8';" ); + @mysql_query("SET NAMES 'utf8';"); foreach ($lines as $j => $line) { - $line = trim( $line ); // Remove comments from the script + $line = trim($line); // Remove comments from the script - if (strpos( $line, "--" ) === 0) { - $line = substr( $line, 0, strpos( $line, "--" ) ); + if (strpos($line, "--") === 0) { + $line = substr($line, 0, strpos($line, "--")); } - if (empty( $line )) { + if (empty($line)) { continue; } - if (strpos( $line, "#" ) === 0) { - $line = substr( $line, 0, strpos( $line, "#" ) ); + if (strpos($line, "#") === 0) { + $line = substr($line, 0, strpos($line, "#")); } - if (empty( $line )) { + if (empty($line)) { continue; } @@ -280,17 +277,17 @@ class Installer if ($previous) { $line = $previous . " " . $line; } - $previous = NULL; + $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) { + if (strrpos($line, ";") != strlen($line) - 1) { $previous = $line; continue; } - $line = substr( $line, 0, strrpos( $line, ";" ) ); - @mysql_query( $line, $connection ); + $line = substr($line, 0, strrpos($line, ";")); + @mysql_query($line, $connection); } } @@ -300,9 +297,8 @@ class Installer * @return void * @todo Empty function */ - private function check_path () + private function check_path() { - } /** @@ -311,11 +307,11 @@ class Installer * @param string $path * @return string $path */ - private function find_root_path ($path) + private function find_root_path($path) { $i = 0; //prevent loop inifinity - while (! is_dir( $path ) && ($path = dirname( $path )) && ((strlen( $path ) > 1) && $i < 10)) { - $i ++; + while (!is_dir($path) && ($path = dirname($path)) && ((strlen($path) > 1) && $i < 10)) { + $i++; } return $path; } @@ -327,12 +323,13 @@ class Installer * @param integer $def default value 777 * @return integer $def */ - public function file_permisions ($file, $def = 777) + public function file_permisions($file, $def = 777) { - if (PHP_OS == 'WINNT') + if (PHP_OS == 'WINNT') { return $def; - else - return (int) substr( sprintf( '%o', @fileperms( $file ) ), - 4 ); + } else { + return (int) substr(sprintf('%o', @fileperms($file)), - 4); + } } /** @@ -341,14 +338,14 @@ class Installer * @param string $dir default value empty * @return string $path */ - public function is_dir_writable ($dir = '') + public function is_dir_writable($dir = '') { if (PHP_OS == 'WINNT') { - $dir = $this->find_root_path( $dir ); - return file_exists( $dir ); + $dir = $this->find_root_path($dir); + return file_exists($dir); } else { - $dir = $this->find_root_path( $dir ); - return (is_writable( $dir ) && is_readable( $dir )); + $dir = $this->find_root_path($dir); + return (is_writable($dir) && is_readable($dir)); } } @@ -358,18 +355,18 @@ class Installer * @param string $dir default value empty * @return string $path */ - public function getDirectoryFiles ($dir, $extension) + public function getDirectoryFiles($dir, $extension) { - $filesArray = array (); - if (file_exists( $dir )) { - if ($handle = opendir( $dir )) { - while (false !== ($file = readdir( $handle ))) { - $fileParts = explode( ".", $file ); - if ($fileParts[count( $fileParts ) - 1] == $extension) { + $filesArray = array(); + if (file_exists($dir)) { + if ($handle = opendir($dir)) { + while (false !== ($file = readdir($handle))) { + $fileParts = explode(".", $file); + if ($fileParts[count($fileParts) - 1] == $extension) { $filesArray[] = $file; } } - closedir( $handle ); + closedir($handle); } } return $filesArray; @@ -381,14 +378,14 @@ class Installer * @param string $dbName * @return boolean true or false */ - public function check_db_empty ($dbName) + public function check_db_empty($dbName) { - $a = @mysql_select_db( $dbName, $this->connection_database ); - if (! $a) { + $a = @mysql_select_db($dbName, $this->connection_database); + if (!$a) { return true; } - $q = @mysql_query( 'SHOW TABLES', $this->connection_database ); - return (@mysql_num_rows( $q ) > 0) ? false : true; + $q = @mysql_query('SHOW TABLES', $this->connection_database); + return (@mysql_num_rows($q) > 0) ? false : true; } /** @@ -397,32 +394,32 @@ class Installer * @param string $dbName * @return Array Array('status' => true or false,'message' => string) */ - public function check_db ($dbName) + public function check_db($dbName) { - if (! $this->connection_database) { + if (!$this->connection_database) { //erik: new verification if the mysql extension is enabled - $error = class_exists( 'mysql_error' ) ? mysql_error() : 'Mysql Module for PHP is not enabled!'; - return Array ('status' => false,'message' => $error + $error = class_exists('mysql_error') ? mysql_error() : 'Mysql Module for PHP is not enabled!'; + return Array('status' => false, 'message' => $error ); } else { - if (! mysql_select_db( $dbName, $this->connection_database ) && $this->cc_status != 1) { - return Array ('status' => false,'message' => mysql_error() + if (!mysql_select_db($dbName, $this->connection_database) && $this->cc_status != 1) { + return Array('status' => false, 'message' => mysql_error() ); } else { /* var_dump($this->options['advanced']['ao_db_drop'],$this->cc_status,$this->check_db_empty($dbName)); - if(($this->options['advanced']['ao_db_drop']===false && $this->cc_status!=1 && !$this->check_db_empty($dbName)) ) - { - return Array('status'=>false,'message'=>'Database is not empty'); - } - else - { - return Array('status'=>true,'message'=>'OK'); - }*/ - if ($this->options['advanced']['ao_db_drop'] === true || $this->check_db_empty( $dbName )) { - return Array ('status' => true,'message' => 'PASSED' + if(($this->options['advanced']['ao_db_drop']===false && $this->cc_status!=1 && !$this->check_db_empty($dbName)) ) + { + return Array('status'=>false,'message'=>'Database is not empty'); + } + else + { + return Array('status'=>true,'message'=>'OK'); + } */ + if ($this->options['advanced']['ao_db_drop'] === true || $this->check_db_empty($dbName)) { + return Array('status' => true, 'message' => 'PASSED' ); } else { - return Array ('status' => false,'message' => 'Database is not empty' + return Array('status' => false, 'message' => 'Database is not empty' ); } } @@ -434,31 +431,31 @@ class Installer * * @return Array $rt */ - private function check_connection () + private function check_connection() { - if (! function_exists( "mysql_connect" )) { + if (!function_exists("mysql_connect")) { $this->cc_status = 0; - $rt = Array ('connection' => false,'grant' => 0,'version' => false,'message' => "ERROR: Mysql Module for PHP is not enabled, try install php-mysql package.",'ao' => Array ('ao_db_wf' => false,'ao_db_rb' => false,'ao_db_rp' => false - ) + $rt = Array('connection' => false, 'grant' => 0, 'version' => false, 'message' => "ERROR: Mysql Module for PHP is not enabled, try install php-mysql package.", 'ao' => Array('ao_db_wf' => false, 'ao_db_rb' => false, 'ao_db_rp' => false + ) ); } else { - $this->connection_database = @mysql_connect( $this->options['database']['hostname'], $this->options['database']['username'], $this->options['database']['password'] ); - $rt = Array ('version' => false,'ao' => Array ('ao_db_wf' => false,'ao_db_rb' => false,'ao_db_rp' => false - ) + $this->connection_database = @mysql_connect($this->options['database']['hostname'], $this->options['database']['username'], $this->options['database']['password']); + $rt = Array('version' => false, 'ao' => Array('ao_db_wf' => false, 'ao_db_rb' => false, 'ao_db_rp' => false + ) ); - if (! $this->connection_database) { + if (!$this->connection_database) { $this->cc_status = 0; $rt['connection'] = false; $rt['grant'] = 0; $rt['message'] = "Mysql error: " . mysql_error(); } else { - preg_match( '@[0-9]+\.[0-9]+\.[0-9]+@', mysql_get_server_info( $this->connection_database ), $version ); - $rt['version'] = version_compare( @$version[0], "4.1.0", ">=" ); + preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', mysql_get_server_info($this->connection_database), $version); + $rt['version'] = version_compare(@$version[0], "4.1.0", ">="); $rt['connection'] = true; $dbNameTest = "PROCESSMAKERTESTDC"; - $db = @mysql_query( "CREATE DATABASE " . $dbNameTest, $this->connection_database ); - if (! $db) { + $db = @mysql_query("CREATE DATABASE " . $dbNameTest, $this->connection_database); + if (!$db) { $this->cc_status = 3; $rt['grant'] = 3; //$rt['message'] = "Db GRANTS error: ".mysql_error(); @@ -468,27 +465,26 @@ class Installer //@mysql_drop_db("processmaker_testGA"); $usrTest = "wfrbtest"; $chkG = "GRANT ALL PRIVILEGES ON `" . $dbNameTest . "`.* TO " . $usrTest . "@'%' IDENTIFIED BY 'sample' WITH GRANT OPTION"; - $ch = @mysql_query( $chkG, $this->connection_database ); - if (! $ch) { + $ch = @mysql_query($chkG, $this->connection_database); + if (!$ch) { $this->cc_status = 2; $rt['grant'] = 2; //$rt['message'] = "USER PRIVILEGES ERROR"; $rt['message'] = "Successful connection"; } else { $this->cc_status = 1; - @mysql_query( "DROP USER " . $usrTest . "@'%'", $this->connection_database ); + @mysql_query("DROP USER " . $usrTest . "@'%'", $this->connection_database); $rt['grant'] = 1; $rt['message'] = "Successful connection"; } - @mysql_query( "DROP DATABASE " . $dbNameTest, $this->connection_database ); - + @mysql_query("DROP DATABASE " . $dbNameTest, $this->connection_database); } // var_dump($wf,$rb,$rp); } } - $rt['ao']['ao_db_wf'] = $this->check_db( $this->options['advanced']['ao_db_wf'] ); - $rt['ao']['ao_db_rb'] = $this->check_db( $this->options['advanced']['ao_db_rb'] ); - $rt['ao']['ao_db_rp'] = $this->check_db( $this->options['advanced']['ao_db_rp'] ); + $rt['ao']['ao_db_wf'] = $this->check_db($this->options['advanced']['ao_db_wf']); + $rt['ao']['ao_db_rb'] = $this->check_db($this->options['advanced']['ao_db_rb']); + $rt['ao']['ao_db_rp'] = $this->check_db($this->options['advanced']['ao_db_rp']); return $rt; } @@ -498,11 +494,12 @@ class Installer * @param string $text * @return void */ - public function log ($text, $failed = NULL) + public function log($text, $failed = null) { - array_push( $this->report, $text ); - if ($failed) - throw new Exception( is_string( $text ) ? $text : var_export( $text, true ) ); + array_push($this->report, $text); + if ($failed) { + throw new Exception(is_string($text) ? $text : var_export($text, true) ); + } } } -?> + diff --git a/workflow/engine/classes/class.dates.php b/workflow/engine/classes/class.dates.php index 5d9dea6da..c8f582503 100755 --- a/workflow/engine/classes/class.dates.php +++ b/workflow/engine/classes/class.dates.php @@ -1,4 +1,5 @@ */ - require_once ("classes/model/TaskPeer.php"); require_once ("classes/model/HolidayPeer.php"); @@ -40,14 +40,14 @@ require_once ("classes/model/HolidayPeer.php"); */ class dates { - private $holidays = array (); - private $weekends = array (); - private $range = array (); + + private $holidays = array(); + private $weekends = array(); + private $range = array(); private $skipEveryYear = true; private $calendarDays = false; //by default we are using working days private $hoursPerDay = 8; //you should change this - /** * Function that calculate a final date based on $sInitDate and $iDuration * This function also uses a Calendar component (class.calendar.php) where all the definition of @@ -70,14 +70,14 @@ class dates * * */ - function calculateDate ($sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid = NULL, $ProUid = NULL, $TasUid = NULL) + public function calculateDate($sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid = null, $ProUid = null, $TasUid = null) { //$oldDate=$this->calculateDate_noCalendar( $sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid, $ProUid, $TasUid); //Set Calendar when the object is instanced in this order/priority (Task, User, Process, Default) - G::LoadClass( 'calendar' ); - $calendarObj = new calendar( $UsrUid, $ProUid, $TasUid ); + G::LoadClass('calendar'); + $calendarObj = new calendar($UsrUid, $ProUid, $TasUid); //Get next Business Hours/Range based on : - switch (strtoupper( $sTimeUnit )) { + switch (strtoupper($sTimeUnit)) { case 'DAYS': $hoursToProcess = $iDuration * 8; break; //In Hours @@ -85,75 +85,75 @@ class dates $hoursToProcess = $iDuration; break; //In Hours } - $dateArray = explode( " ", $sInitDate ); + $dateArray = explode(" ", $sInitDate); $currentDate = $dateArray[0]; - $currentTime = isset( $dateArray[1] ) ? $dateArray[1] : "00:00:00"; + $currentTime = isset($dateArray[1]) ? $dateArray[1] : "00:00:00"; - $startTime = (float) array_sum( explode( ' ', microtime() ) ); + $startTime = (float) array_sum(explode(' ', microtime())); - $calendarObj->addCalendarLog( "* Starting at: $startTime" ); - $calendarObj->addCalendarLog( ">>>>> Hours to Process: $hoursToProcess" ); - $calendarObj->addCalendarLog( ">>>>> Current Date: $currentDate" ); - $calendarObj->addCalendarLog( ">>>>> Current Time: $currentTime" ); - $array_hours = explode( ":", $currentTime ); + $calendarObj->addCalendarLog("* Starting at: $startTime"); + $calendarObj->addCalendarLog(">>>>> Hours to Process: $hoursToProcess"); + $calendarObj->addCalendarLog(">>>>> Current Date: $currentDate"); + $calendarObj->addCalendarLog(">>>>> Current Time: $currentTime"); + $array_hours = explode(":", $currentTime); $seconds2 = $array_hours[2]; $minutes2 = 0; while ($hoursToProcess > 0) { - $validBusinessHour = $calendarObj->getNextValidBusinessHoursRange( $currentDate, $currentTime ); + $validBusinessHour = $calendarObj->getNextValidBusinessHoursRange($currentDate, $currentTime); //For Date/Time operations - $currentDateA = explode( "-", $validBusinessHour['DATE'] ); - $currentTimeA = explode( ":", $validBusinessHour['TIME'] ); + $currentDateA = explode("-", $validBusinessHour['DATE']); + $currentTimeA = explode(":", $validBusinessHour['TIME']); $hour = $currentTimeA[0]; $minute = $currentTimeA[1]; - $second = isset( $currentTimeA[2] ) ? $currentTimeA[2] : 0; + $second = isset($currentTimeA[2]) ? $currentTimeA[2] : 0; $month = $currentDateA[1]; $day = $currentDateA[2]; $year = $currentDateA[0]; - $normalizedDate = date( "Y-m-d H:i:s", mktime( $hour, $minute, $second, $month, $day, $year ) ); - $normalizedDateInt = mktime( $hour, $minute, $second, $month, $day, $year ); + $normalizedDate = date("Y-m-d H:i:s", mktime($hour, $minute, $second, $month, $day, $year)); + $normalizedDateInt = mktime($hour, $minute, $second, $month, $day, $year); $normalizedDateSeconds = ($hour * 60 * 60) + ($minute * 60); - $arrayHour = explode( ".", $hoursToProcess ); - if (isset( $arrayHour[1] )) { + $arrayHour = explode(".", $hoursToProcess); + if (isset($arrayHour[1])) { $minutes1 = $arrayHour[1]; - $cadm = strlen( $minutes1 ); - $minutes2 = (($minutes1 / pow( 10, $cadm )) * 60); + $cadm = strlen($minutes1); + $minutes2 = (($minutes1 / pow(10, $cadm)) * 60); } - $possibleTime = date( "Y-m-d H:i:s", mktime( $hour + $hoursToProcess, $minute + $minutes2, $second + $seconds2, $month, $day, $year ) ); - $possibleTimeInt = mktime( $hour + $hoursToProcess, $minute + $minutes2, $second + $seconds2, $month, $day, $year ); + $possibleTime = date("Y-m-d H:i:s", mktime($hour + $hoursToProcess, $minute + $minutes2, $second + $seconds2, $month, $day, $year)); + $possibleTimeInt = mktime($hour + $hoursToProcess, $minute + $minutes2, $second + $seconds2, $month, $day, $year); $offsetPermitedMinutes = "0"; - $calendarBusinessEndA = explode( ":", $validBusinessHour['BUSINESS_HOURS']['CALENDAR_BUSINESS_END'] ); - $calendarBusinessEndNormalized = date( "Y-m-d H:i:s", mktime( $calendarBusinessEndA[0], $calendarBusinessEndA[1] + $offsetPermitedMinutes, 0, $month, $day, $year ) ); - $calendarBusinessEndInt = mktime( $calendarBusinessEndA[0], $calendarBusinessEndA[1] + $offsetPermitedMinutes, 0, $month, $day, $year ); + $calendarBusinessEndA = explode(":", $validBusinessHour['BUSINESS_HOURS']['CALENDAR_BUSINESS_END']); + $calendarBusinessEndNormalized = date("Y-m-d H:i:s", mktime($calendarBusinessEndA[0], $calendarBusinessEndA[1] + $offsetPermitedMinutes, 0, $month, $day, $year)); + $calendarBusinessEndInt = mktime($calendarBusinessEndA[0], $calendarBusinessEndA[1] + $offsetPermitedMinutes, 0, $month, $day, $year); $calendarBusinessEndSeconds = ($calendarBusinessEndA[0] * 60 * 60) + ($calendarBusinessEndA[1] * 60); - $calendarObj->addCalendarLog( "Possible time: $possibleTime" ); - $calendarObj->addCalendarLog( "Current Start Date/Time: $normalizedDate" ); - $calendarObj->addCalendarLog( "Calendar Business End: $calendarBusinessEndNormalized" ); + $calendarObj->addCalendarLog("Possible time: $possibleTime"); + $calendarObj->addCalendarLog("Current Start Date/Time: $normalizedDate"); + $calendarObj->addCalendarLog("Calendar Business End: $calendarBusinessEndNormalized"); if ($possibleTimeInt > $calendarBusinessEndInt) { - $currentDateTimeB = explode( " ", $calendarBusinessEndNormalized ); + $currentDateTimeB = explode(" ", $calendarBusinessEndNormalized); $currentDate = $currentDateTimeB[0]; $currentTime = $currentDateTimeB[1]; - $diff = abs( $normalizedDateSeconds - $calendarBusinessEndSeconds ); + $diff = abs($normalizedDateSeconds - $calendarBusinessEndSeconds); $diffHours = $diff / 3600; $hoursToProcess = $hoursToProcess - $diffHours; } else { - $currentDateTimeA = explode( " ", $possibleTime ); + $currentDateTimeA = explode(" ", $possibleTime); $currentDate = $currentDateTimeA[0]; $currentTime = $currentDateTimeA[1]; $hoursToProcess = 0; } - $calendarObj->addCalendarLog( "** Hours to Process: $hoursToProcess" ); + $calendarObj->addCalendarLog("** Hours to Process: $hoursToProcess"); } - $calendarObj->addCalendarLog( "+++++++++++ Calculated Due Date $currentDate $currentTime" ); + $calendarObj->addCalendarLog("+++++++++++ Calculated Due Date $currentDate $currentTime"); $result['DUE_DATE'] = $currentDate . " " . $currentTime; - $result['DUE_DATE_SECONDS'] = strtotime( $currentDate . " " . $currentTime ); + $result['DUE_DATE_SECONDS'] = strtotime($currentDate . " " . $currentTime); //$result['OLD_DUE_DATE'] = date("Y-m-d H:i:s",$oldDate); //$result['OLD_DUE_DATE_SECONDS']= $oldDate; - $endTime = (float) array_sum( explode( ' ', microtime() ) ); - $calendarObj->addCalendarLog( "* Ending at: $endTime" ); - $calcTime = round( $endTime - $startTime, 3 ); - $calendarObj->addCalendarLog( "** Processing time: " . sprintf( "%.4f", ($endTime - $startTime) ) . " seconds" ); + $endTime = (float) array_sum(explode(' ', microtime())); + $calendarObj->addCalendarLog("* Ending at: $endTime"); + $calcTime = round($endTime - $startTime, 3); + $calendarObj->addCalendarLog("** Processing time: " . sprintf("%.4f", ($endTime - $startTime)) . " seconds"); $result['DUE_DATE_LOG'] = $calendarObj->calendarLog; return $result; } @@ -175,34 +175,35 @@ class dates * @return integer timestamp of the result * @deprecated renamed by Hugo Loza (see calculateDate new function) */ - - function calculateDate_noCalendar ($sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid = NULL, $ProUid = NULL, $TasUid = NULL) + public function calculateDate_noCalendar($sInitDate, $iDuration, $sTimeUnit, $iTypeDay, $UsrUid = null, $ProUid = null, $TasUid = null) { //load in class variables the config of working days, holidays etc.. - $this->prepareInformation( $UsrUid, $ProUid, $TasUid ); + $this->prepareInformation($UsrUid, $ProUid, $TasUid); $iHours = 0; $iDays = 0; //convert the $iDuration and $sTimeUnit in hours and days, take in mind 8 hours = 1 day. and then we will have similar for 5 days = 1 weekends - if (strtolower( $sTimeUnit ) == 'hours') { - $iAux = intval( abs( $iDuration ) ); + if (strtolower($sTimeUnit) == 'hours') { + $iAux = intval(abs($iDuration)); $iHours = $iAux % $this->hoursPerDay; - $iDays = intval( $iAux / $this->hoursPerDay ); + $iDays = intval($iAux / $this->hoursPerDay); } - if (strtolower( $sTimeUnit ) == 'days') { - $iAux = intval( abs( $iDuration * $this->hoursPerDay ) ); + if (strtolower($sTimeUnit) == 'days') { + $iAux = intval(abs($iDuration * $this->hoursPerDay)); $iHours = $iAux % 8; - $iDays = intval( $iAux / 8 ); + $iDays = intval($iAux / 8); } $addSign = ($iDuration >= 0) ? '+' : '-'; - $iInitDate = strtotime( $sInitDate ); - if ($iTypeDay == 1) { // working days + $iInitDate = strtotime($sInitDate); + if ($iTypeDay == 1) { + // working days // if there are days calculate the days, - $iEndDate = $this->addDays( $iInitDate, $iDays, $addSign ); + $iEndDate = $this->addDays($iInitDate, $iDays, $addSign); // if there are hours calculate the hours, and probably add a day if the quantity of hours for last day > 8 hours - $iEndDate = $this->addHours( $iEndDate, $iHours, $addSign ); - } else { // $task->getTasTypeDay() == 2 // calendar days - $iEndDate = strtotime( $addSign . $iDays . ' days ', $iInitDate ); - $iEndDate = strtotime( $addSign . $iHours . ' hours ', $iEndDate ); + $iEndDate = $this->addHours($iEndDate, $iHours, $addSign); + } else { + // $task->getTasTypeDay() == 2 // calendar days + $iEndDate = strtotime($addSign . $iDays . ' days ', $iInitDate); + $iEndDate = strtotime($addSign . $iHours . ' hours ', $iEndDate); } return $iEndDate; } @@ -218,59 +219,57 @@ class dates * @return int * */ - function calculateDuration ($sInitDate, $sEndDate = '', $UsrUid = NULL, $ProUid = NULL, $TasUid = NULL) + public function calculateDuration($sInitDate, $sEndDate = '', $UsrUid = null, $ProUid = null, $TasUid = null) { - $this->prepareInformation( $UsrUid, $ProUid, $TasUid ); + $this->prepareInformation($UsrUid, $ProUid, $TasUid); if ((string) $sEndDate == '') { - $sEndDate = date( 'Y-m-d H:i:s' ); + $sEndDate = date('Y-m-d H:i:s'); } - if (strtotime( $sInitDate ) > strtotime( $sEndDate )) { + if (strtotime($sInitDate) > strtotime($sEndDate)) { $sAux = $sInitDate; $sInitDate = $sEndDate; $sEndDate = $sAux; } - $aAux1 = explode( ' ', $sInitDate ); - $aAux2 = explode( ' ', $sEndDate ); - $aInitDate = explode( '-', $aAux1[0] ); - $aEndDate = explode( '-', $aAux2[0] ); + $aAux1 = explode(' ', $sInitDate); + $aAux2 = explode(' ', $sEndDate); + $aInitDate = explode('-', $aAux1[0]); + $aEndDate = explode('-', $aAux2[0]); $i = 1; $iWorkedDays = 0; $bFinished = false; $fHours1 = 0.0; $fHours2 = 0.0; - if (count( $aInitDate ) != 3) { - $aInitDate = array (0,0,0 - ); + if (count($aInitDate) != 3) { + $aInitDate = array(0, 0, 0); } - if (count( $aEndDate ) != 3) { - $aEndDate = array (0,0,0 - ); + if (count($aEndDate) != 3) { + $aEndDate = array(0, 0, 0); } if ($aInitDate !== $aEndDate) { - while (! $bFinished && ($i < 10000)) { - $sAux = date( 'Y-m-d', mktime( 0, 0, 0, $aInitDate[1], $aInitDate[2] + $i, $aInitDate[0] ) ); - if ($sAux != implode( '-', $aEndDate )) { - if (! in_array( $sAux, $this->holidays )) { - if (! in_array( date( 'w', mktime( 0, 0, 0, $aInitDate[1], $aInitDate[2] + $i, $aInitDate[0] ) ), $this->weekends )) { - $iWorkedDays ++; + while (!$bFinished && ($i < 10000)) { + $sAux = date('Y-m-d', mktime(0, 0, 0, $aInitDate[1], $aInitDate[2] + $i, $aInitDate[0])); + if ($sAux != implode('-', $aEndDate)) { + if (!in_array($sAux, $this->holidays)) { + if (!in_array(date('w', mktime(0, 0, 0, $aInitDate[1], $aInitDate[2] + $i, $aInitDate[0])), $this->weekends)) { + $iWorkedDays++; } } - $i ++; + $i++; } else { $bFinished = true; } } - if (isset( $aAux1[1] )) { - $aAux1[1] = explode( ':', $aAux1[1] ); + if (isset($aAux1[1])) { + $aAux1[1] = explode(':', $aAux1[1]); $fHours1 = 24 - ($aAux1[1][0] + ($aAux1[1][1] / 60) + ($aAux1[1][2] / 3600)); } - if (isset( $aAux2[1] )) { - $aAux2[1] = explode( ':', $aAux2[1] ); + if (isset($aAux2[1])) { + $aAux2[1] = explode(':', $aAux2[1]); $fHours2 = $aAux2[1][0] + ($aAux2[1][1] / 60) + ($aAux2[1][2] / 3600); } $fDuration = ($iWorkedDays * 24) + $fHours1 + $fHours2; } else { - $fDuration = (strtotime( $sEndDate ) - strtotime( $sInitDate )) / 3600; + $fDuration = (strtotime($sEndDate) - strtotime($sInitDate)) / 3600; } return $fDuration; } @@ -283,25 +282,25 @@ class dates * @param string $TasUid * @return void */ - function prepareInformation ($UsrUid = NULL, $ProUid = NULL, $TasUid = NULL) + public function prepareInformation($UsrUid = null, $ProUid = null, $TasUid = null) { // setup calendarDays according the task - if (isset( $TasUid )) { - $task = TaskPeer::retrieveByPK( $TasUid ); - if (! is_null( $task )) { + if (isset($TasUid)) { + $task = TaskPeer::retrieveByPK($TasUid); + if (!is_null($task)) { $this->calendarDays = ($task->getTasTypeDay() == 2); } } //get an array with all holidays. - $aoHolidays = HolidayPeer::doSelect( new Criteria() ); - $holidays = array (); - foreach ($aoHolidays as $holiday) - $holidays[] = strtotime( $holiday->getHldDate() ); + $aoHolidays = HolidayPeer::doSelect(new Criteria()); + $holidays = array(); + foreach ($aoHolidays as $holiday) { + $holidays[] = strtotime($holiday->getHldDate()); + } - // by default the weekdays are from monday to friday - $this->weekends = array (0,6 - ); + // by default the weekdays are from monday to friday + $this->weekends = array(0, 6); $this->holidays = $holidays; return; } @@ -312,7 +311,7 @@ class dates * @param $bSkipEveryYear * @return void */ - function setSkipEveryYear ($bSkipEveryYear) + public function setSkipEveryYear($bSkipEveryYear) { $this->skipEveryYear = $bSkipEveryYear === true; } @@ -323,12 +322,13 @@ class dates * @param data $sDate * @return void */ - function addHoliday ($sDate) + public function addHoliday($sDate) { - if ($date = strtotime( $sDate )) - $this->holidays[] = self::truncateTime( $date ); - else - throw new Exception( "Invalid date: $sDate." ); + if ($date = strtotime($sDate)) { + $this->holidays[] = self::truncateTime($date); + } else { + throw new Exception("Invalid date: $sDate."); + } } /** @@ -337,10 +337,11 @@ class dates * @param date/array $aDate must be an array of (strtotime type) dates * @return void */ - function setHolidays ($aDates) + public function setHolidays($aDates) { - foreach ($aDates as $sDate) + foreach ($aDates as $sDate) { $this->holidays = $aDates; + } } /** @@ -351,7 +352,7 @@ class dates * 7=Saturday * @return void */ - function setWeekends ($aWeekends) + public function setWeekends($aWeekends) { $this->weekends = $aWeekends; } @@ -364,10 +365,11 @@ class dates * 7=Saturday * @return void */ - function skipDayOfWeek ($iDayNumber) + public function skipDayOfWeek($iDayNumber) { - if ($iDayNumber < 1 || $iDayNumber > 7) - throw new Exception( "The day of week must be a number from 1 to 7." ); + if ($iDayNumber < 1 || $iDayNumber > 7) { + throw new Exception("The day of week must be a number from 1 to 7."); + } $this->weekends[] = $iDayNumber; } @@ -378,24 +380,24 @@ class dates * @param date $sDateB must be a (strtotime type) dates * @return void */ - function addNonWorkingRange ($sDateA, $sDateB) + public function addNonWorkingRange($sDateA, $sDateB) { - if ($date = strtotime( $sDateA )) - $iDateA = self::truncateTime( $date ); - else - throw new Exception( "Invalid date: $sDateA." ); - if ($date = strtotime( $sDateB )) - $iDateB = self::truncateTime( $date ); - else - throw new Exception( "Invalid date: $sDateB." ); + if ($date = strtotime($sDateA)) { + $iDateA = self::truncateTime($date); + } else { + throw new Exception("Invalid date: $sDateA."); + } + if ($date = strtotime($sDateB)) { + $iDateB = self::truncateTime($date); + } else { + throw new Exception("Invalid date: $sDateB."); + } if ($iDateA > $iDateB) { $s = $iDateA; $iDateA = $iDateB; $iDateB = $s; } - ; - $this->range[] = array ($iDateA,$iDateB - ); + $this->range[] = array($iDateA, $iDateB); } /** @@ -407,15 +409,16 @@ class dates * @param string $addSign * @return date $iEndDate */ - private function addDays ($iInitDate, $iDaysCount, $addSign = '+') + private function addDays($iInitDate, $iDaysCount, $addSign = '+') { $iEndDate = $iInitDate; $aList = $this->holidays; - for ($r = 1; $r <= $iDaysCount; $r ++) { - $iEndDate = strtotime( $addSign . "1 day", $iEndDate ); - $dayOfWeek = idate( 'w', $iEndDate ); //now sunday=0 - if (array_search( $dayOfWeek, $this->weekends ) !== false) - $r --; //continue loop, but we are adding one more day. + for ($r = 1; $r <= $iDaysCount; $r++) { + $iEndDate = strtotime($addSign . "1 day", $iEndDate); + $dayOfWeek = idate('w', $iEndDate); //now sunday=0 + if (array_search($dayOfWeek, $this->weekends) !== false) { + $r--; //continue loop, but we are adding one more day. + } } return $iEndDate; } @@ -428,10 +431,9 @@ class dates * @param string $addSign * @return $iEndDate */ - - private function addHours ($sInitDate, $iHoursCount, $addSign = '+') + private function addHours($sInitDate, $iHoursCount, $addSign = '+') { - $iEndDate = strtotime( $addSign . $iHoursCount . " hours", $sInitDate ); + $iEndDate = strtotime($addSign . $iHoursCount . " hours", $sInitDate); return $iEndDate; } @@ -441,18 +443,19 @@ class dates * @param $iDate = valid timestamp * @return true if it is within any of the ranges defined. */ - private function inRange ($iDate) + private function inRange($iDate) { $aRange = $this->range; - $iYear = idate( 'Y', $iDate ); + $iYear = idate('Y', $iDate); foreach ($aRange as $key => $rang) { if ($this->skipEveryYear) { - $deltaYears = idate( 'Y', $rang[1] ) - idate( 'Y', $rang[0] ); - $rang[0] = self::changeYear( $rang[0], $iYear ); - $rang[1] = self::changeYear( $rang[1], $iYear + $deltaYears ); + $deltaYears = idate('Y', $rang[1]) - idate('Y', $rang[0]); + $rang[0] = self::changeYear($rang[0], $iYear); + $rang[1] = self::changeYear($rang[1], $iYear + $deltaYears); } - if (($iDate >= $rang[0]) && ($iDate <= $rang[1])) + if (($iDate >= $rang[0]) && ($iDate <= $rang[1])) { return true; + } } return false; } @@ -463,9 +466,9 @@ class dates * @param $iDate = valid timestamp * @return date */ - private function truncateTime ($iDate) + private function truncateTime($iDate) { - return mktime( 0, 0, 0, idate( 'm', $iDate ), idate( 'd', $iDate ), idate( 'Y', $iDate ) ); + return mktime(0, 0, 0, idate('m', $iDate), idate('d', $iDate), idate('Y', $iDate)); } /** @@ -474,10 +477,9 @@ class dates * @param timestamp $iDate * @return date */ - private function getTime ($iDate) + private function getTime($iDate) { - return array (idate( 'H', $iDate ),idate( 'm', $iDate ),idate( 's', $iDate ) - ); + return array(idate('H', $iDate), idate('m', $iDate), idate('s', $iDate)); } /** @@ -487,9 +489,9 @@ class dates * @param timestamp $aTime * @return date */ - private function setTime ($iDate, $aTime) + private function setTime($iDate, $aTime) { - return mktime( $aTime[0], $aTime[1], $aTime[2], idate( 'm', $iDate ), idate( 'd', $iDate ), idate( 'Y', $iDate ) ); + return mktime($aTime[0], $aTime[1], $aTime[2], idate('m', $iDate), idate('d', $iDate), idate('Y', $iDate)); } /** @@ -501,11 +503,11 @@ class dates * @param List $iYear * @return array */ - private function listForYear ($iYear) + private function listForYear($iYear) { $aList = $this->holidays; foreach ($aList as $k => $v) { - $aList[$k] = self::changeYear( $v, $iYear ); + $aList[$k] = self::changeYear($v, $iYear); } return $aList; } @@ -520,12 +522,12 @@ class dates * @param date $iDate * @return array */ - private function changeYear ($iDate, $iYear) + private function changeYear($iDate, $iYear) { - if ($delta = ($iYear - idate( 'Y', $iDate ))) { - $iDate = strtotime( "$delta year", $iDate ); + if ($delta = ($iYear - idate('Y', $iDate))) { + $iDate = strtotime("$delta year", $iDate); } return $iDate; } } -?> \ No newline at end of file + diff --git a/workflow/engine/classes/class.groups.php b/workflow/engine/classes/class.groups.php index c5eee412f..ccf9b0333 100755 --- a/workflow/engine/classes/class.groups.php +++ b/workflow/engine/classes/class.groups.php @@ -1,4 +1,5 @@ addJoin( UsersPeer::USR_UID, GroupUserPeer::USR_UID, Criteria::LEFT_JOIN ); - $oCriteria->add( GroupUserPeer::GRP_UID, $sGroupUID ); - $oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' ); - $oDataset = UsersPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria->addJoin(UsersPeer::USR_UID, GroupUserPeer::USR_UID, Criteria::LEFT_JOIN); + $oCriteria->add(GroupUserPeer::GRP_UID, $sGroupUID); + $oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE'); + $oDataset = UsersPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { @@ -72,22 +72,22 @@ class Groups * @param string $sUserUID * @return array */ - function getActiveGroupsForAnUser ($sUserUID) + public function getActiveGroupsForAnUser($sUserUID) { try { $oCriteria = new Criteria(); - $oCriteria->addSelectColumn( GroupUserPeer::GRP_UID ); - $oCriteria->addSelectColumn( GroupwfPeer::GRP_STATUS ); - $oCriteria->add( GroupUserPeer::USR_UID, $sUserUID ); - $oCriteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' ); - $oCriteria->addJoin( GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN ); - $oDataset = GroupUserPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria->addSelectColumn(GroupUserPeer::GRP_UID); + $oCriteria->addSelectColumn(GroupwfPeer::GRP_STATUS); + $oCriteria->add(GroupUserPeer::USR_UID, $sUserUID); + $oCriteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE'); + $oCriteria->addJoin(GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN); + $oDataset = GroupUserPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); - $aGroups = array (); + $aGroups = array(); $aRow = $oDataset->getRow(); - while (is_array( $aRow )) { + while (is_array($aRow)) { $aGroups[] = $aRow['GRP_UID']; $oDataset->next(); $aRow = $oDataset->getRow(); @@ -104,16 +104,16 @@ class Groups * @param string $GrpUid, $UsrUid * @return array */ - function addUserToGroup ($GrpUid, $UsrUid) + public function addUserToGroup($GrpUid, $UsrUid) { try { - $oGrp = GroupUserPeer::retrieveByPk( $GrpUid, $UsrUid ); - if (is_object( $oGrp ) && get_class( $oGrp ) == 'GroupUser') { + $oGrp = GroupUserPeer::retrieveByPk($GrpUid, $UsrUid); + if (is_object($oGrp) && get_class($oGrp) == 'GroupUser') { return true; } else { $oGrp = new GroupUser(); - $oGrp->setGrpUid( $GrpUid ); - $oGrp->setUsrUid( $UsrUid ); + $oGrp->setGrpUid($GrpUid); + $oGrp->setUsrUid($UsrUid); $oGrp->Save(); } } catch (exception $oError) { @@ -121,15 +121,15 @@ class Groups } } - /* - * Remove a user from group - * @param string $GrpUid, $UsrUid - * @return array - */ - function removeUserOfGroup ($GrpUid, $UsrUid) + /** + * Remove a user from group + * @param string $GrpUid, $UsrUid + * @return array + */ + public function removeUserOfGroup($GrpUid, $UsrUid) { $gu = new GroupUser(); - $gu->remove( $GrpUid, $UsrUid ); + $gu->remove($GrpUid, $UsrUid); } /** @@ -138,13 +138,13 @@ class Groups * @param none * @return $objects */ - function getAllGroups () + public function getAllGroups() { try { $criteria = new Criteria(); - $criteria->add( GroupwfPeer::GRP_UID, "", Criteria::NOT_EQUAL ); - $con = Propel::getConnection( GroupwfPeer::DATABASE_NAME ); - $objects = GroupwfPeer::doSelect( $criteria, $con ); + $criteria->add(GroupwfPeer::GRP_UID, "", Criteria::NOT_EQUAL); + $con = Propel::getConnection(GroupwfPeer::DATABASE_NAME); + $objects = GroupwfPeer::doSelect($criteria, $con); return $objects; } catch (exception $e) { throw $e; @@ -157,16 +157,16 @@ class Groups * @param $sUserUid user uid * @return an array of group objects */ - function getUserGroups ($sUserUID) + public function getUserGroups($sUserUID) { try { $criteria = new Criteria(); - $criteria->add( GroupwfPeer::GRP_UID, "", Criteria::NOT_EQUAL ); - $criteria->add( GroupUserPeer::USR_UID, $sUserUID ); - $criteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' ); - $criteria->addJoin( GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN ); - $con = Propel::getConnection( GroupwfPeer::DATABASE_NAME ); - $objects = GroupwfPeer::doSelect( $criteria, $con ); + $criteria->add(GroupwfPeer::GRP_UID, "", Criteria::NOT_EQUAL); + $criteria->add(GroupUserPeer::USR_UID, $sUserUID); + $criteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE'); + $criteria->addJoin(GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN); + $con = Propel::getConnection(GroupwfPeer::DATABASE_NAME); + $objects = GroupwfPeer::doSelect($criteria, $con); return $objects; } catch (exception $e) { throw $e; @@ -180,34 +180,33 @@ class Groups * @param string $sUserUid * @return object */ - - function getAvailableGroupsCriteria ($sUserUid, $filter = '') + public function getAvailableGroupsCriteria($sUserUid, $filter = '') { try { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( GroupUserPeer::GRP_UID ); - $oCriteria->add( GroupUserPeer::USR_UID, $sUserUid ); - $oCriteria->add( GroupUserPeer::GRP_UID, '', Criteria::NOT_EQUAL ); - $oDataset = GroupUserPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(GroupUserPeer::GRP_UID); + $oCriteria->add(GroupUserPeer::USR_UID, $sUserUid); + $oCriteria->add(GroupUserPeer::GRP_UID, '', Criteria::NOT_EQUAL); + $oDataset = GroupUserPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); - $gUIDs = array (); + $gUIDs = array(); while ($aRow = $oDataset->getRow()) { $gUIDs[] = $aRow['GRP_UID']; $oDataset->next(); } - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( GroupwfPeer::GRP_UID ); - $oCriteria->addSelectColumn( GroupwfPeer::GRP_STATUS ); - $oCriteria->addSelectColumn( ContentPeer::CON_VALUE ); - $oCriteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN ); - $oCriteria->add( GroupwfPeer::GRP_UID, $gUIDs, Criteria::NOT_IN ); - $oCriteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' ); - $oCriteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' ); - $oCriteria->add( ContentPeer::CON_LANG, SYS_LANG ); + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(GroupwfPeer::GRP_UID); + $oCriteria->addSelectColumn(GroupwfPeer::GRP_STATUS); + $oCriteria->addSelectColumn(ContentPeer::CON_VALUE); + $oCriteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN); + $oCriteria->add(GroupwfPeer::GRP_UID, $gUIDs, Criteria::NOT_IN); + $oCriteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE'); + $oCriteria->add(ContentPeer::CON_CATEGORY, 'GRP_TITLE'); + $oCriteria->add(ContentPeer::CON_LANG, SYS_LANG); if ($filter != '') { - $oCriteria->add( ContentPeer::CON_VALUE, '%' . $filter . '%', Criteria::LIKE ); + $oCriteria->add(ContentPeer::CON_VALUE, '%' . $filter . '%', Criteria::LIKE); } return $oCriteria; @@ -223,24 +222,23 @@ class Groups * @param string $sUserUid * @return object */ - - function getAssignedGroupsCriteria ($sUserUid, $filter = '') + public function getAssignedGroupsCriteria($sUserUid, $filter = '') { try { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( GroupwfPeer::GRP_UID ); - $oCriteria->addSelectColumn( GroupwfPeer::GRP_STATUS ); - $oCriteria->addSelectColumn( GroupwfPeer::GRP_LDAP_DN ); - $oCriteria->addSelectColumn( ContentPeer::CON_VALUE ); - $oCriteria->addJoin( GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN ); - $oCriteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN ); - $oCriteria->add( GroupUserPeer::USR_UID, $sUserUid, Criteria::EQUAL ); - $oCriteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' ); - $oCriteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' ); - $oCriteria->add( ContentPeer::CON_LANG, SYS_LANG ); + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(GroupwfPeer::GRP_UID); + $oCriteria->addSelectColumn(GroupwfPeer::GRP_STATUS); + $oCriteria->addSelectColumn(GroupwfPeer::GRP_LDAP_DN); + $oCriteria->addSelectColumn(ContentPeer::CON_VALUE); + $oCriteria->addJoin(GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN); + $oCriteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN); + $oCriteria->add(GroupUserPeer::USR_UID, $sUserUid, Criteria::EQUAL); + $oCriteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE'); + $oCriteria->add(ContentPeer::CON_CATEGORY, 'GRP_TITLE'); + $oCriteria->add(ContentPeer::CON_LANG, SYS_LANG); if ($filter != '') { - $oCriteria->add( ContentPeer::CON_VALUE, '%' . $filter . '%', Criteria::LIKE ); + $oCriteria->add(ContentPeer::CON_VALUE, '%' . $filter . '%', Criteria::LIKE); } return $oCriteria; @@ -249,16 +247,16 @@ class Groups } } - function getGroupsForUser ($usrUid) + public function getGroupsForUser($usrUid) { - $criteria = $this->getAssignedGroupsCriteria( $usrUid ); - $criteria->addAscendingOrderByColumn( ContentPeer::CON_VALUE ); - $dataset = GroupwfPeer::doSelectRS( $criteria ); - $dataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $criteria = $this->getAssignedGroupsCriteria($usrUid); + $criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE); + $dataset = GroupwfPeer::doSelectRS($criteria); + $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $dataset->next(); - $groups = array (); + $groups = array(); while ($row = $dataset->getRow()) { - if (! isset( $groups[$row['GRP_UID']] )) { + if (!isset($groups[$row['GRP_UID']])) { $groups[$row['GRP_UID']] = $row; } $dataset->next(); @@ -272,12 +270,12 @@ class Groups * @param string $sUsrUid * @return void */ - public function removeUserOfAllGroups ($sUserUID = '') + public function removeUserOfAllGroups($sUserUID = '') { try { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( GroupUserPeer::USR_UID, $sUserUID ); - GroupUserPeer::doDelete( $oCriteria ); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(GroupUserPeer::USR_UID, $sUserUID); + GroupUserPeer::doDelete($oCriteria); } catch (exception $oError) { throw ($oError); } @@ -289,21 +287,21 @@ class Groups * @param string $sGroupUID * @return array */ - function getUsersGroupCriteria ($sGroupUID = '') + public function getUsersGroupCriteria($sGroupUID = '') { require_once 'classes/model/GroupUser.php'; require_once 'classes/model/Users.php'; try { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( GroupUserPeer::GRP_UID ); - $oCriteria->addSelectColumn( UsersPeer::USR_UID ); - $oCriteria->addSelectColumn( UsersPeer::USR_USERNAME ); - $oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME ); - $oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME ); - $oCriteria->addSelectColumn( UsersPeer::USR_EMAIL ); - $oCriteria->addJoin( GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN ); - $oCriteria->add( GroupUserPeer::GRP_UID, $sGroupUID ); - $oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' ); + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(GroupUserPeer::GRP_UID); + $oCriteria->addSelectColumn(UsersPeer::USR_UID); + $oCriteria->addSelectColumn(UsersPeer::USR_USERNAME); + $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); + $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME); + $oCriteria->addSelectColumn(UsersPeer::USR_EMAIL); + $oCriteria->addJoin(GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); + $oCriteria->add(GroupUserPeer::GRP_UID, $sGroupUID); + $oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE'); return $oCriteria; } catch (exception $oError) { throw ($oError); @@ -316,19 +314,19 @@ class Groups * @param string $sGroupUID * @return array */ - function getUserGroupsCriteria ($sUserUID = '') + public function getUserGroupsCriteria($sUserUID = '') { require_once 'classes/model/GroupUser.php'; require_once 'classes/model/Users.php'; try { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( UsersPeer::USR_UID ); - $oCriteria->addSelectColumn( GroupUserPeer::GRP_UID ); - $oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME ); - $oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME ); - $oCriteria->addJoin( GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN ); - $oCriteria->add( GroupUserPeer::GRP_UID, $sUserUID ); - $oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' ); + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(UsersPeer::USR_UID); + $oCriteria->addSelectColumn(GroupUserPeer::GRP_UID); + $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); + $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME); + $oCriteria->addJoin(GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); + $oCriteria->add(GroupUserPeer::GRP_UID, $sUserUID); + $oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE'); return $oCriteria; } catch (exception $oError) { throw ($oError); @@ -341,17 +339,17 @@ class Groups * @param string $sGroupUid * @return integer $cnt */ - function getNumberGroups ($sUserUID) + public function getNumberGroups($sUserUID) { try { - $allGroups = $this->getUserGroups( $sUserUID ); + $allGroups = $this->getUserGroups($sUserUID); $cnt = 0; foreach ($allGroups as $group) { - $cnt ++; + $cnt++; } return $cnt; } catch (exception $oError) { - print_r( $oError ); + print_r($oError); } } @@ -361,28 +359,28 @@ class Groups * @param string $sGroupUID * @return object */ - function getAvailableUsersCriteria ($sGroupUID = '') + public function getAvailableUsersCriteria($sGroupUID = '') { try { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( UsersPeer::USR_UID ); - $oCriteria->addJoin( GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN ); - $oCriteria->add( GroupUserPeer::GRP_UID, $sGroupUID ); - $oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' ); - $oDataset = UsersPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(UsersPeer::USR_UID); + $oCriteria->addJoin(GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); + $oCriteria->add(GroupUserPeer::GRP_UID, $sGroupUID); + $oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE'); + $oDataset = UsersPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); - $aUIDs = array (); + $aUIDs = array(); while ($aRow = $oDataset->getRow()) { $aUIDs[] = $aRow['USR_UID']; $oDataset->next(); } - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( UsersPeer::USR_UID ); - $oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME ); - $oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME ); - $oCriteria->add( UsersPeer::USR_UID, $aUIDs, Criteria::NOT_IN ); - $oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' ); + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(UsersPeer::USR_UID); + $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); + $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME); + $oCriteria->add(UsersPeer::USR_UID, $aUIDs, Criteria::NOT_IN); + $oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE'); return $oCriteria; } catch (exception $oError) { throw ($oError); @@ -396,11 +394,11 @@ class Groups * @param $UsrUid user Uid * @return 1/0 if it's or not assigned */ - function verifyUsertoGroup ($GrpUid, $UsrUid) + public function verifyUsertoGroup($GrpUid, $UsrUid) { try { - $oGrp = GroupUserPeer::retrieveByPk( $GrpUid, $UsrUid ); - if (is_object( $oGrp ) && get_class( $oGrp ) == 'GroupUser') { + $oGrp = GroupUserPeer::retrieveByPk($GrpUid, $UsrUid); + if (is_object($oGrp) && get_class($oGrp) == 'GroupUser') { return 1; } else { return 0; @@ -416,22 +414,23 @@ class Groups * @param $sGroupUid group Uid * @return 1/0 if exist or not */ - function verifyGroup ($sGroupUID) + public function verifyGroup($sGroupUID) { try { - $aUsers = array (); + $aUsers = array(); $oCriteria = new Criteria(); //$oCriteria->addJoin(UsersPeer::USR_UID, GroupUserPeer::USR_UID, Criteria::LEFT_JOIN); - $oCriteria->add( GroupwfPeer::GRP_UID, $sGroupUID ); + $oCriteria->add(GroupwfPeer::GRP_UID, $sGroupUID); //$oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE'); - $oDataset = GroupwfPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset = GroupwfPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aRow = $oDataset->getRow(); - if (is_array( $aRow )) + if (is_array($aRow)) { return 1; - else + } else { return 0; + } } catch (exception $oError) { throw ($oError); } @@ -444,14 +443,14 @@ class Groups * @return an array of objects/false/exception object * */ - public function load ($GrpUid) + public function load($GrpUid) { try { $criteria = new Criteria(); - $criteria->add( GroupwfPeer::GRP_UID, $GrpUid, Criteria::EQUAL ); - $con = Propel::getConnection( GroupwfPeer::DATABASE_NAME ); - $objects = GroupwfPeer::doSelect( $criteria, $con ); - if (is_array( $objects ) && count( $objects ) > 0) { + $criteria->add(GroupwfPeer::GRP_UID, $GrpUid, Criteria::EQUAL); + $con = Propel::getConnection(GroupwfPeer::DATABASE_NAME); + $objects = GroupwfPeer::doSelect($criteria, $con); + if (is_array($objects) && count($objects) > 0) { return $objects[0]; } else { return false; @@ -461,3 +460,4 @@ class Groups } } } + diff --git a/workflow/engine/classes/class.pmGauge.php b/workflow/engine/classes/class.pmGauge.php index 5b43ebb77..6c09d84ed 100755 --- a/workflow/engine/classes/class.pmGauge.php +++ b/workflow/engine/classes/class.pmGauge.php @@ -2,147 +2,147 @@ class pmGauge { + /** * width */ - var $w = 610; + public $w = 610; /** * height */ - var $h = 300; + public $h = 300; /** * value of gauge */ - var $value = 50; + public $value = 50; /** * maxValue */ - var $maxValue = 100; + public $maxValue = 100; /** * redFrom */ - var $redFrom = 80; + public $redFrom = 80; /** * redTo */ - var $redTo = 100; + public $redTo = 100; /** * yellowFrom */ - var $yellowFrom = 60; + public $yellowFrom = 60; /** * yellowTo */ - var $yellowTo = 80; + public $yellowTo = 80; /** * greenFrom */ - var $greenFrom = 0; + public $greenFrom = 0; /** * greenTo */ - var $greenTo = 60; + public $greenTo = 60; /** * centerLabel, the label in the middle of the gauge */ - var $centerLabel = ''; + public $centerLabel = ''; - function render () + public function render() { $this->h = $this->w / 2; - $im = imagecreatetruecolor( $this->w, $this->h ); + $im = imagecreatetruecolor($this->w, $this->h); $width = $this->w; $height = $this->h; - $center_x = intval( $width / 2 ); - $center_y = intval( $height / 2 ); + $center_x = intval($width / 2); + $center_y = intval($height / 2); //gauge color - $bgcolor = ImageColorAllocate( $im, 247, 247, 247 ); - $extRing = ImageColorAllocate( $im, 214, 214, 214 ); - $blueRing = ImageColorAllocate( $im, 70, 132, 238 ); - $blueRingLine = ImageColorAllocate( $im, 106, 114, 127 ); - $arrowBody = ImageColorAllocate( $im, 228, 114, 86 ); - $arrowLine = ImageColorAllocate( $im, 207, 74, 42 ); - $redArc = ImageColorAllocate( $im, 220, 57, 18 ); - $yellowArc = ImageColorAllocate( $im, 255, 153, 0 ); + $bgcolor = ImageColorAllocate($im, 247, 247, 247); + $extRing = ImageColorAllocate($im, 214, 214, 214); + $blueRing = ImageColorAllocate($im, 70, 132, 238); + $blueRingLine = ImageColorAllocate($im, 106, 114, 127); + $arrowBody = ImageColorAllocate($im, 228, 114, 86); + $arrowLine = ImageColorAllocate($im, 207, 74, 42); + $redArc = ImageColorAllocate($im, 220, 57, 18); + $yellowArc = ImageColorAllocate($im, 255, 153, 0); - $black = ImageColorAllocate( $im, 0, 0, 0 ); - $white = ImageColorAllocate( $im, 255, 255, 255 ); - $gray = ImageColorAllocate( $im, 190, 190, 190 ); + $black = ImageColorAllocate($im, 0, 0, 0); + $white = ImageColorAllocate($im, 255, 255, 255); + $gray = ImageColorAllocate($im, 190, 190, 190); $fontArial = PATH_THIRDPARTY . 'html2ps_pdf/fonts/arial.ttf'; - ImageFilledRectangle( $im, 0, 0, $width - 1, $height - 1, $white ); - ImageRectangle( $im, 0, 0, $width - 1, $height - 1, $gray ); + ImageFilledRectangle($im, 0, 0, $width - 1, $height - 1, $white); + ImageRectangle($im, 0, 0, $width - 1, $height - 1, $gray); //center coords - $cX = intval( $this->w / 2 ); + $cX = intval($this->w / 2); //$cX = intval($this->w /4); - $cY = intval( $this->h / 2 ); + $cY = intval($this->h / 2); //diameter for gauge - $diameter = intval( $this->h * 4 / 5 ); + $diameter = intval($this->h * 4 / 5); - $this->renderGauge( $im, $cX, $cY, $diameter ); + $this->renderGauge($im, $cX, $cY, $diameter); /* - //center coords - $cX = intval($this->w * 3/4); - $cY = intval($this->h /2); + //center coords + $cX = intval($this->w * 3/4); + $cY = intval($this->h /2); - //diameter for gauge - $diameter = intval( $this->h * 4/5 ); + //diameter for gauge + $diameter = intval( $this->h * 4/5 ); - $this->renderGauge($im, $cX, $cY, $diameter); + $this->renderGauge($im, $cX, $cY, $diameter); */ - Header( "Content-type: image/png" ); - ImagePng( $im ); - + Header("Content-type: image/png"); + ImagePng($im); } - function renderGauge ($im, $cX, $cY, $diameter) + public function renderGauge($im, $cX, $cY, $diameter) { //gauge color - $bgcolor = ImageColorAllocate( $im, 247, 247, 247 ); - $extRing = ImageColorAllocate( $im, 214, 214, 214 ); - $blueRing = ImageColorAllocate( $im, 70, 132, 238 ); - $blueRingLine = ImageColorAllocate( $im, 106, 114, 127 ); - $arrowBody = ImageColorAllocate( $im, 228, 114, 86 ); - $arrowLine = ImageColorAllocate( $im, 207, 74, 42 ); - $redArc = ImageColorAllocate( $im, 220, 57, 18 ); - $yellowArc = ImageColorAllocate( $im, 255, 153, 0 ); - $greenArc = ImageColorAllocate( $im, 0, 136, 0 ); + $bgcolor = ImageColorAllocate($im, 247, 247, 247); + $extRing = ImageColorAllocate($im, 214, 214, 214); + $blueRing = ImageColorAllocate($im, 70, 132, 238); + $blueRingLine = ImageColorAllocate($im, 106, 114, 127); + $arrowBody = ImageColorAllocate($im, 228, 114, 86); + $arrowLine = ImageColorAllocate($im, 207, 74, 42); + $redArc = ImageColorAllocate($im, 220, 57, 18); + $yellowArc = ImageColorAllocate($im, 255, 153, 0); + $greenArc = ImageColorAllocate($im, 0, 136, 0); - $black = ImageColorAllocate( $im, 0, 0, 0 ); - $white = ImageColorAllocate( $im, 255, 255, 255 ); - $gray = ImageColorAllocate( $im, 190, 190, 190 ); + $black = ImageColorAllocate($im, 0, 0, 0); + $white = ImageColorAllocate($im, 255, 255, 255); + $gray = ImageColorAllocate($im, 190, 190, 190); $fontArial = PATH_THIRDPARTY . 'html2ps_pdf/fonts/arial.ttf'; - $dX = intval( $diameter * 8 / 7 ); //for now ratio aspect is 8:7 - $dY = intval( $diameter ); - $dXRing = intval( $dX * 0.90 ); - $dYRing = intval( $dY * 0.90 ); + $dX = intval($diameter * 8 / 7); //for now ratio aspect is 8:7 + $dY = intval($diameter); + $dXRing = intval($dX * 0.90); + $dYRing = intval($dY * 0.90); - $dXRingColor = intval( $dX * 0.86 ); - $dYRingColor = intval( $dY * 0.86 ); + $dXRingColor = intval($dX * 0.86); + $dYRingColor = intval($dY * 0.86); - $dXRingCenter = intval( $dX * 0.66 ); - $dYRingCenter = intval( $dY * 0.66 ); + $dXRingCenter = intval($dX * 0.66); + $dYRingCenter = intval($dY * 0.66); - imagefilledellipse( $im, $cX, $cY, $dX, $dY, $extRing ); + imagefilledellipse($im, $cX, $cY, $dX, $dY, $extRing); - imagefilledellipse( $im, $cX, $cY, $dXRing, $dYRing, $bgcolor ); + imagefilledellipse($im, $cX, $cY, $dXRing, $dYRing, $bgcolor); //drawing the red arc if ($this->redFrom > $this->maxValue) { @@ -172,19 +172,19 @@ class pmGauge $greenTo = $this->greenTo / $this->maxValue * 300 - 240; if ($this->redFrom != $this->redTo || $this->redTo != $this->maxValue) { - imagefilledarc( $im, $cX, $cY, $dXRingColor, $dYRingColor, $redFrom, $redTo, $redArc, IMG_ARC_PIE ); + imagefilledarc($im, $cX, $cY, $dXRingColor, $dYRingColor, $redFrom, $redTo, $redArc, IMG_ARC_PIE); } if ($this->yellowFrom != $this->yellowTo || $this->yellowTo != $this->maxValue) { - imagefilledarc( $im, $cX, $cY, $dXRingColor, $dYRingColor, $yellowFrom, $yellowTo, $yellowArc, IMG_ARC_PIE ); + imagefilledarc($im, $cX, $cY, $dXRingColor, $dYRingColor, $yellowFrom, $yellowTo, $yellowArc, IMG_ARC_PIE); } if ($this->greenFrom != $this->greenTo || $this->greenTo != $this->maxValue) { - imagefilledarc( $im, $cX, $cY, $dXRingColor, $dYRingColor, $greenFrom, $greenTo, $greenArc, IMG_ARC_PIE ); + imagefilledarc($im, $cX, $cY, $dXRingColor, $dYRingColor, $greenFrom, $greenTo, $greenArc, IMG_ARC_PIE); } - imagefilledellipse( $im, $cX, $cY, $dXRingCenter, $dYRingCenter, $bgcolor ); + imagefilledellipse($im, $cX, $cY, $dXRingCenter, $dYRingCenter, $bgcolor); //ticks - $radiusX = intval( $dX * 0.42 ); - $radiusY = intval( $dY * 0.42 ); + $radiusX = intval($dX * 0.42); + $radiusY = intval($dY * 0.42); $min = 5; while ($min <= 55) { if ($min % 5 == 0) { @@ -194,91 +194,90 @@ class pmGauge } $ang = (2 * M_PI * $min) / 60; - $x1 = sin( $ang ) * ($radiusX - $len) + $cX; - $y1 = cos( $ang ) * ($radiusY - $len) + $cY; - $x2 = sin( $ang ) * $radiusX + $cX; - $y2 = cos( $ang ) * $radiusY + $cY; + $x1 = sin($ang) * ($radiusX - $len) + $cX; + $y1 = cos($ang) * ($radiusY - $len) + $cY; + $x2 = sin($ang) * $radiusX + $cX; + $y2 = cos($ang) * $radiusY + $cY; - ImageLine( $im, $x1, $y1, $x2, $y2, $black ); + ImageLine($im, $x1, $y1, $x2, $y2, $black); if ($min % 5 == 0) { - $textToDisplay = sprintf( "%d", (55 - $min) * $this->maxValue / 50 ); - $bbox = imagettfbbox( 8, 0, $fontArial, $textToDisplay ); - $x1 = sin( $ang ) * ($radiusX - 2.5 * $len) + $cX - $bbox[4] / 2; - $y1 = cos( $ang ) * ($radiusY - 2.5 * $len) + $cY + 2; // - abs($bbox[5]); - imagettftext( $im, 8, 0, $x1, $y1, $gray, $fontArial, $textToDisplay ); + $textToDisplay = sprintf("%d", (55 - $min) * $this->maxValue / 50); + $bbox = imagettfbbox(8, 0, $fontArial, $textToDisplay); + $x1 = sin($ang) * ($radiusX - 2.5 * $len) + $cX - $bbox[4] / 2; + $y1 = cos($ang) * ($radiusY - 2.5 * $len) + $cY + 2; // - abs($bbox[5]); + imagettftext($im, 8, 0, $x1, $y1, $gray, $fontArial, $textToDisplay); } - $min ++; + $min++; } - if (trim( $this->centerLabel ) != '') { - $textToDisplay = trim( $this->centerLabel ); - $bbox = imagettfbbox( 8, 0, $fontArial, $textToDisplay ); + if (trim($this->centerLabel) != '') { + $textToDisplay = trim($this->centerLabel); + $bbox = imagettfbbox(8, 0, $fontArial, $textToDisplay); $x1 = $cX - $bbox[4] / 2; - $y1 = $cY * 3 / 4 + abs( $bbox[5] ); - imagettftext( $im, 8, 0, $x1, $y1, $black, $fontArial, $textToDisplay ); + $y1 = $cY * 3 / 4 + abs($bbox[5]); + imagettftext($im, 8, 0, $x1, $y1, $black, $fontArial, $textToDisplay); } - imagettftext( $im, 9, 0, $cX * 0.60, $cY * 1.8, $gray, $fontArial, $this->open ); - imagettftext( $im, 9, 0, $cX * 1.40, $cY * 1.8, $gray, $fontArial, $this->completed ); + imagettftext($im, 9, 0, $cX * 0.60, $cY * 1.8, $gray, $fontArial, $this->open); + imagettftext($im, 9, 0, $cX * 1.40, $cY * 1.8, $gray, $fontArial, $this->completed); //drawing the arrow, simple way - $radiusX = intval( $dX * 0.35 ); - $radiusY = intval( $dY * 0.35 ); + $radiusX = intval($dX * 0.35); + $radiusY = intval($dY * 0.35); $ang = - M_PI / 6 + 2 * M_PI - (2 * M_PI * $this->value) * 50 / 60 / $this->maxValue; - $x1 = sin( $ang ) * ($radiusX) + $cX; - $y1 = cos( $ang ) * ($radiusY) + $cY; - ImageLine( $im, $cX, $cY, $x1, $y1, $arrowLine ); + $x1 = sin($ang) * ($radiusX) + $cX; + $y1 = cos($ang) * ($radiusY) + $cY; + ImageLine($im, $cX, $cY, $x1, $y1, $arrowLine); /* - //arrowLine - $arrowHeight = intval($dY * 0.02); - $arrowWidth = intval($dX * 0.35); - $arrowTail = intval($dX * 0.15); - $values = array( - 0, -$arrowHeight, - -$arrowTail, 0, - 0, $arrowHeight, - $arrowWidth, 0, - 0, -$arrowHeight - ); + //arrowLine + $arrowHeight = intval($dY * 0.02); + $arrowWidth = intval($dX * 0.35); + $arrowTail = intval($dX * 0.15); + $values = array( + 0, -$arrowHeight, + -$arrowTail, 0, + 0, $arrowHeight, + $arrowWidth, 0, + 0, -$arrowHeight + ); - //rotate n degrees - $n = 20; - $ang = (2 * M_PI * $n) / 60; + //rotate n degrees + $n = 20; + $ang = (2 * M_PI * $n) / 60; - foreach ( $values as $k => $val ) { - if ( $k % 2 == 0 ) { - //$values[$k] = sin($ang)*$val + 20; - $values[$k] = sin($ang)*($val/$cX)*$; - $values[$k] += $cX; - } + foreach ( $values as $k => $val ) { + if ( $k % 2 == 0 ) { + //$values[$k] = sin($ang)*$val + 20; + $values[$k] = sin($ang)*($val/$cX)*$; + $values[$k] += $cX; + } else { - //$ys = intval(sin($sec * M_PI/30 - M_PI/2) * R); - //$values[$k] = intval(sin($n * M_PI/30 - M_PI/2) *$val); - $values[$k] = (cos($ang))*($val/$cY)*$cY; - $values[$k] += $cY; - } - } + //$ys = intval(sin($sec * M_PI/30 - M_PI/2) * R); + //$values[$k] = intval(sin($n * M_PI/30 - M_PI/2) *$val); + $values[$k] = (cos($ang))*($val/$cY)*$cY; + $values[$k] += $cY; + } + } imagefilledpolygon ($im, $values, 5, $arrowBody); imagepolygon ($im, $values, 5, $arrowLine); - */ - //blue ring + */ + //blue ring $dXBlueRing = $dX * 0.07; $dYBlueRing = $dY * 0.07; - imagefilledellipse( $im, $cX, $cY, $dXBlueRing, $dXBlueRing, $blueRing ); - imageellipse( $im, $cX, $cY, $dXBlueRing, $dYBlueRing, $blueRingLine ); + imagefilledellipse($im, $cX, $cY, $dXBlueRing, $dXBlueRing, $blueRing); + imageellipse($im, $cX, $cY, $dXBlueRing, $dYBlueRing, $blueRingLine); - imageellipse( $im, $cX, $cY, $dX, $dY, $black ); + imageellipse($im, $cX, $cY, $dX, $dY, $black); - $textToDisplay = sprintf( "%5.2f%%", $this->value ); - $bbox = imagettfbbox( 9, 0, $fontArial, $textToDisplay ); + $textToDisplay = sprintf("%5.2f%%", $this->value); + $bbox = imagettfbbox(9, 0, $fontArial, $textToDisplay); $centerX = $cX - $bbox[4] / 2; - $centerY = $cY + $dYRing / 2 + 3 - abs( $bbox[5] ); - imagettftext( $im, 9, 0, $centerX, $centerY, $black, $fontArial, $textToDisplay ); - + $centerY = $cY + $dYRing / 2 + 3 - abs($bbox[5]); + imagettftext($im, 9, 0, $centerX, $centerY, $black, $fontArial, $textToDisplay); } } diff --git a/workflow/engine/classes/class.serverConfiguration.php b/workflow/engine/classes/class.serverConfiguration.php index 399ca25eb..79fd692e8 100755 --- a/workflow/engine/classes/class.serverConfiguration.php +++ b/workflow/engine/classes/class.serverConfiguration.php @@ -35,13 +35,14 @@ */ class serverConf { - private $_aProperties = array (); - private $_aHeartbeatConfig = array (); - private $_aWSapces = array (); - private $aWSinfo = array (); - private $pluginsA = array (); - private $errors = array (); - private static $instance = NULL; + + private $_aProperties = array(); + private $_aHeartbeatConfig = array(); + private $_aWSapces = array(); + private $aWSinfo = array(); + private $pluginsA = array(); + private $errors = array(); + private static $instance = null; private $haveSetupData = false; private $beatType = 'starting'; private $ip; @@ -57,14 +58,13 @@ class serverConf public $logins; private $lanDirection; private $lanLanguage; - public $workspaces = array (); - public $rtlLang = array ('ar','iw','fa' - ); + public $workspaces = array(); + public $rtlLang = array('ar', 'iw', 'fa'); public $filePath = ''; - public function __construct () + public function __construct() { - if (defined( 'PATH_DATA' )) { + if (defined('PATH_DATA')) { $this->filePath = PATH_DATA . 'srvConf.singleton'; } } @@ -75,12 +75,12 @@ class serverConf * * @return object */ - function &getSingleton () + public function &getSingleton() { - if (self::$instance == NULL) { + if (self::$instance == null) { self::$instance = new serverConf(); - if ((file_exists( self::$instance->filePath )) && (filesize( self::$instance->filePath ) > 0)) { - self::$instance->unSerializeInstance( file_get_contents( self::$instance->filePath ) ); + if ((file_exists(self::$instance->filePath)) && (filesize(self::$instance->filePath) > 0)) { + self::$instance->unSerializeInstance(file_get_contents(self::$instance->filePath)); } } return self::$instance; @@ -92,9 +92,9 @@ class serverConf * * @return void */ - function serializeInstance () + public function serializeInstance() { - return serialize( self::$instance ); + return serialize(self::$instance); } /** @@ -103,13 +103,13 @@ class serverConf * @param string $serialized * @return void */ - function unSerializeInstance ($serialized) + public function unSerializeInstance($serialized) { - if (self::$instance == NULL) { + if (self::$instance == null) { self::$instance = new serverConf(); } - if ($instance = @unserialize( $serialized )) { + if ($instance = @unserialize($serialized)) { self::$instance = $instance; } } @@ -120,12 +120,11 @@ class serverConf * * @return void */ - - function saveSingleton () + public function saveSingleton() { - if (defined( 'PATH_DATA' )) { + if (defined('PATH_DATA')) { $this->filePath = PATH_DATA . 'srvConf.singleton'; - $size = file_put_contents( $this->filePath, $this->serializeInstance() ); + $size = file_put_contents($this->filePath, $this->serializeInstance()); } } @@ -136,7 +135,7 @@ class serverConf * @param string $propertyName * @param string $propertyValue */ - function setProperty ($propertyName, $propertyValue) + public function setProperty($propertyName, $propertyValue) { $this->_aProperties[$propertyName] = $propertyValue; $this->saveSingleton(); @@ -149,10 +148,10 @@ class serverConf * @param string $propertyName * @return void */ - function unsetProperty ($propertyName) + public function unsetProperty($propertyName) { - if (isset( $this->_aProperties[$propertyName] )) { - unset( $this->_aProperties[$propertyName] ); + if (isset($this->_aProperties[$propertyName])) { + unset($this->_aProperties[$propertyName]); $this->saveSingleton(); } } @@ -164,9 +163,9 @@ class serverConf * @param string $propertyName * @return string/null */ - function getProperty ($propertyName) + public function getProperty($propertyName) { - if (isset( $this->_aProperties[$propertyName] )) { + if (isset($this->_aProperties[$propertyName])) { return $this->_aProperties[$propertyName]; } else { return null; @@ -179,19 +178,21 @@ class serverConf * * @return void */ - function sucessfulLogin () + public function sucessfulLogin() { - $this->logins ++; - if (isset( $this->workspaces[SYS_SYS] ) && isset( $this->workspaces[SYS_SYS]['WSP_LOGINS'] )) - $this->workspaces[SYS_SYS]['WSP_LOGINS'] ++; + $this->logins++; + if (isset($this->workspaces[SYS_SYS]) && isset($this->workspaces[SYS_SYS]['WSP_LOGINS'])) { + $this->workspaces[SYS_SYS]['WSP_LOGINS']++; + } - if (isset( $this->workspaces[SYS_SYS] ) && ! isset( $this->workspaces[SYS_SYS]['WSP_LOGINS'] )) + if (isset($this->workspaces[SYS_SYS]) && !isset($this->workspaces[SYS_SYS]['WSP_LOGINS'])) { $this->workspaces[SYS_SYS]['WSP_LOGINS'] = 1; + } $this->saveSingleton(); } - function setWsInfo ($wsname, $info) + public function setWsInfo($wsname, $info) { $this->aWSinfo[$wsname] = $info; } @@ -202,11 +203,12 @@ class serverConf * @param string $wsName * @return void */ - function changeStatusWS ($wsName) + public function changeStatusWS($wsName) { - if (isset( $this->_aWSapces[$wsName] )) { //Enable WS - unset( $this->_aWSapces[$wsName] ); + if (isset($this->_aWSapces[$wsName])) { + //Enable WS + unset($this->_aWSapces[$wsName]); } else { $this->_aWSapces[$wsName] = 'disabled'; } @@ -220,9 +222,9 @@ class serverConf * @param $wsname * @return boolean */ - function isWSDisabled ($wsName) + public function isWSDisabled($wsName) { - return isset( $this->_aWSapces[$wsName] ); + return isset($this->_aWSapces[$wsName]); } /** @@ -232,14 +234,16 @@ class serverConf * * @return boolean */ - function checkIfHostNameHasChanged () + public function checkIfHostNameHasChanged() { //removed the PM_VERSION control, because when an upgrade is done, the haveSetupData has to be changed. - if ($this->ip != getenv( 'SERVER_ADDR' )) + if ($this->ip != getenv('SERVER_ADDR')) { return false; + } - if ($this->host != getenv( 'SERVER_NAME' )) + if ($this->host != getenv('SERVER_NAME')) { return false; + } return $this->haveSetupData; } @@ -251,17 +255,18 @@ class serverConf * param * @return array */ - function getWSList () + public function getWSList() { $dir = PATH_DB; - $wsArray = array (); - if (file_exists( $dir )) { - if ($handle = opendir( $dir )) { - while (false !== ($file = readdir( $handle ))) { + $wsArray = array(); + if (file_exists($dir)) { + if ($handle = opendir($dir)) { + while (false !== ($file = readdir($handle))) { if (($file != ".") && ($file != "..")) { - if (file_exists( PATH_DB . $file . '/db.php' )) { //print $file."/db.php
"; - $statusl = ($this->isWSDisabled( $file )) ? 'DISABLED' : 'ENABLED'; - if (isset( $this->aWSinfo[$file] )) { + if (file_exists(PATH_DB . $file . '/db.php')) { + //print $file."/db.php
"; + $statusl = ($this->isWSDisabled($file)) ? 'DISABLED' : 'ENABLED'; + if (isset($this->aWSinfo[$file])) { $wsInfo = $this->aWSinfo[$file]; } else { $wsInfo['num_processes'] = "not gathered yet"; @@ -269,19 +274,17 @@ class serverConf ; $wsInfo['num_users'] = "not gathered yet"; } - $wsArray[$file] = array ('WSP_ID' => $file,'WSP_NAME' => $file,'WSP_STATUS' => $statusl,'WSP_PROCESS_COUNT' => $wsInfo['num_processes'],'WSP_CASES_COUNT' => $wsInfo['num_cases'],'WSP_USERS_COUNT' => isset( $wsInfo['num_users'] ) ? $wsInfo['num_users'] : "" - ); - if (isset( $this->workspaces[$file]['WSP_LOGINS'] )) + $wsArray[$file] = array ('WSP_ID' => $file,'WSP_NAME' => $file,'WSP_STATUS' => $statusl,'WSP_PROCESS_COUNT' => $wsInfo['num_processes'],'WSP_CASES_COUNT' => $wsInfo['num_cases'],'WSP_USERS_COUNT' => isset( $wsInfo['num_users'] ) ? $wsInfo['num_users'] : ""); + if (isset($this->workspaces[$file]['WSP_LOGINS'])) { $wsArray[$file]['WSP_LOGINS'] = $this->workspaces[$file]['WSP_LOGINS']; - + } } } } - closedir( $handle ); + closedir($handle); } } return $wsArray; - } /** @@ -294,27 +297,27 @@ class serverConf * @param string $wsName * @return array */ - function getWorkspaceInfo ($wsName) + public function getWorkspaceInfo($wsName) { - $aResult = Array ('num_processes' => '0','num_cases' => '0' + $aResult = Array('num_processes' => '0', 'num_cases' => '0' ); - $result = array (); + $result = array(); require_once 'classes/model/Process.php'; require_once 'classes/model/Application.php'; require_once 'classes/model/Users.php'; - $Criteria = new Criteria( 'workflow' ); - $Criteria->add( ProcessPeer::PRO_STATUS, 'ACTIVE', CRITERIA::EQUAL ); - $aResult['num_processes'] = ProcessPeer::doCount( $Criteria ); + $Criteria = new Criteria('workflow'); + $Criteria->add(ProcessPeer::PRO_STATUS, 'ACTIVE', CRITERIA::EQUAL); + $aResult['num_processes'] = ProcessPeer::doCount($Criteria); - $Criteria = new Criteria( 'workflow' ); - $Criteria->add( ApplicationPeer::APP_STATUS, 'COMPLETED', CRITERIA::NOT_EQUAL ); - $aResult['num_cases'] = ApplicationPeer::doCount( $Criteria ); + $Criteria = new Criteria('workflow'); + $Criteria->add(ApplicationPeer::APP_STATUS, 'COMPLETED', CRITERIA::NOT_EQUAL); + $aResult['num_cases'] = ApplicationPeer::doCount($Criteria); - $Criteria = new Criteria( 'workflow' ); - $Criteria->add( UsersPeer::USR_STATUS, array ('DELETED','DISABLED' - ), CRITERIA::NOT_IN ); - $aResult['num_users'] = UsersPeer::doCount( $Criteria ); + $Criteria = new Criteria('workflow'); + $Criteria->add(UsersPeer::USR_STATUS, array('DELETED', 'DISABLED' + ), CRITERIA::NOT_IN); + $aResult['num_users'] = UsersPeer::doCount($Criteria); return $aResult; } @@ -324,7 +327,7 @@ class serverConf * * @return array */ - function getPluginsList () + public function getPluginsList() { return $this->pluginsA; } @@ -333,30 +336,31 @@ class serverConf * * * Register a PLugin */ - function addPlugin ($workspace, $info) + public function addPlugin($workspace, $info) { $this->pluginsA[$workspace] = $info; } - function getDBVersion () + public function getDBVersion() { $sMySQLVersion = '?????'; - if (defined( "DB_HOST" )) { - G::LoadClass( 'net' ); - G::LoadClass( 'dbConnections' ); - $dbNetView = new NET( DB_HOST ); - $dbNetView->loginDbServer( DB_USER, DB_PASS ); + if (defined("DB_HOST")) { + G::LoadClass('net'); + G::LoadClass('dbConnections'); + $dbNetView = new NET(DB_HOST); + $dbNetView->loginDbServer(DB_USER, DB_PASS); - $dbConns = new dbConnections( '' ); + $dbConns = new dbConnections(''); $availdb = ''; foreach ($dbConns->getDbServicesAvailables() as $key => $val) { - if ($availdb != '') + if ($availdb != '') { $availdb .= ', '; + } $availdb .= $val['name']; } try { - $sMySQLVersion = $dbNetView->getDbServerVersion( 'mysql' ); + $sMySQLVersion = $dbNetView->getDbServerVersion('mysql'); } catch (Exception $oException) { $sMySQLVersion = '?????'; } @@ -370,10 +374,10 @@ class serverConf * * @return void */ - function resetLogins () + public function resetLogins() { $this->logins = 0; - if (is_array( $this->workspaces )) { + if (is_array($this->workspaces)) { foreach ($this->workspaces as $wsName => $wsinfo) { $this->workspaces[$wsName]['WSP_LOGINS'] = 0; } @@ -386,25 +390,26 @@ class serverConf * @param void * @return string */ - function getLanDirection () + public function getLanDirection() { - if (! isset( $this->lanDirection )) { + if (!isset($this->lanDirection)) { $this->lanDirection = 'L'; } - if (defined( 'SYS_LANG' )) { + if (defined('SYS_LANG')) { //if we already have the landirection for this language, just return from serverConf - if ($this->lanLanguage == SYS_LANG) + if ($this->lanLanguage == SYS_LANG) { return $this->lanDirection; + } - //if not , we need to query Database, in order to get the direction + //if not , we need to query Database, in order to get the direction $this->lanDirection = 'L'; //default value; $this->lanLanguage = SYS_LANG; require_once 'classes/model/Language.php'; $oLang = new Language(); try { - $aLang = $oLang->load( SYS_LANG ); - if (isset( $aLang['LAN_DIRECTION'] )) { - $this->lanDirection = strtoupper( $aLang['LAN_DIRECTION'] ); + $aLang = $oLang->load(SYS_LANG); + if (isset($aLang['LAN_DIRECTION'])) { + $this->lanDirection = strtoupper($aLang['LAN_DIRECTION']); } $this->saveSingleton(); } catch (Exception $e) { @@ -422,7 +427,7 @@ class serverConf * @param string $propertyValue * @param string $workspace */ - function setHeartbeatProperty ($propertyName, $propertyValue, $workspace) + public function setHeartbeatProperty($propertyName, $propertyValue, $workspace) { $this->_aHeartbeatConfig[$workspace][$propertyName] = $propertyValue; $this->saveSingleton(); @@ -436,10 +441,11 @@ class serverConf * @param string $workspace * @return void */ - function unsetHeartbeatProperty ($propertyName, $workspace) + public function unsetHeartbeatProperty($propertyName, $workspace) { - if (isset( $this->_aHeartbeatConfig[$workspace][$propertyName] )) - unset( $this->_aHeartbeatConfig[$workspace][$propertyName] ); + if (isset($this->_aHeartbeatConfig[$workspace][$propertyName])) { + unset($this->_aHeartbeatConfig[$workspace][$propertyName]); + } $this->saveSingleton(); } @@ -450,19 +456,19 @@ class serverConf * @param string $propertyName * @return string/null */ - function getHeartbeatProperty ($propertyName, $workspace) + public function getHeartbeatProperty($propertyName, $workspace) { - if (isset( $this->_aHeartbeatConfig[$workspace][$propertyName] )) { + if (isset($this->_aHeartbeatConfig[$workspace][$propertyName])) { return $this->_aHeartbeatConfig[$workspace][$propertyName]; } else { return null; } } - function isRtl ($lang = SYS_LANG) + public function isRtl($lang = SYS_LANG) { - $lang = substr( $lang, 0, 2 ); - return in_array( $lang, $this->rtlLang ); + $lang = substr($lang, 0, 2); + return in_array($lang, $this->rtlLang); } - -} \ No newline at end of file +} + \ No newline at end of file diff --git a/workflow/engine/classes/class.solr.php b/workflow/engine/classes/class.solr.php index f8a7f7272..3dbdfd32d 100644 --- a/workflow/engine/classes/class.solr.php +++ b/workflow/engine/classes/class.solr.php @@ -1,4 +1,5 @@ _solrIsEnabled = $solrIsEnabled; @@ -56,7 +59,7 @@ class BpmnEngine_SearchIndexAccess_Solr } //Verify solr server response - try{ + try { $resultServerStatus = $this->ping($workspace); } catch (Exception $e) { $resultServerStatus = false; @@ -74,44 +77,42 @@ class BpmnEngine_SearchIndexAccess_Solr * @param workspace: workspace name * @return total */ - public function getNumberDocuments ($workspace) + public function getNumberDocuments($workspace) { - if (! $this->_solrIsEnabled) + if (!$this->_solrIsEnabled) { return; - // get configuration information in base to workspace parameter - - + } + // get configuration information in base to workspace parameter // get total number of documents in registry - $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; + $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct .= $workspace; $solrIntruct .= "/select/?q=*:*"; $solrIntruct .= self::SOLR_VERSION; $solrIntruct .= "&start=0&rows=0&echoParams=none&wt=json"; - $handlerTotal = curl_init( $solrIntruct ); - curl_setopt( $handlerTotal, CURLOPT_RETURNTRANSFER, true ); + $handlerTotal = curl_init($solrIntruct); + curl_setopt($handlerTotal, CURLOPT_RETURNTRANSFER, true); //Apply proxy settings $sysConf = System::getSystemConfiguration(); if ($sysConf['proxy_host'] != '') { - curl_setopt( $handlerTotal, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') ); + curl_setopt($handlerTotal, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); if ($sysConf['proxy_port'] != '') { - curl_setopt( $handlerTotal, CURLOPT_PROXYPORT, $sysConf['proxy_port'] ); + curl_setopt($handlerTotal, CURLOPT_PROXYPORT, $sysConf['proxy_port']); } if ($sysConf['proxy_user'] != '') { - curl_setopt( $handlerTotal, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); + curl_setopt($handlerTotal, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); } - curl_setopt( $handlerTotal, CURLOPT_HTTPHEADER, array ('Expect:' - ) ); + curl_setopt($handlerTotal, CURLOPT_HTTPHEADER, array('Expect:')); } - $responseTotal = curl_exec( $handlerTotal ); - curl_close( $handlerTotal ); + $responseTotal = curl_exec($handlerTotal); + curl_close($handlerTotal); // verify the result of solr - $responseSolrTotal = G::json_decode( $responseTotal ); + $responseSolrTotal = G::json_decode($responseTotal); if ($responseSolrTotal->responseHeader->status != 0) { - throw new Exception( "Error returning the total number of documents in Solr." . $solrIntruct . " response error: " . $response . "\n" ); + throw new Exception("Error returning the total number of documents in Solr." . $solrIntruct . " response error: " . $response . "\n"); } $numTotalDocs = $responseSolrTotal->response->numFound; return $numTotalDocs; @@ -125,41 +126,42 @@ class BpmnEngine_SearchIndexAccess_Solr * * @return solr response */ - public function executeQuery ($solrRequestData) + public function executeQuery($solrRequestData) { - if (! $this->_solrIsEnabled) + if (!$this->_solrIsEnabled) { return; + } $solrIntruct = ''; // get configuration information in base to workspace parameter $workspace = $solrRequestData->workspace; // format request - $query = empty( $solrRequestData->searchText ) ? '*:*' : $solrRequestData->searchText; - $query = rawurlencode( $query ); + $query = empty($solrRequestData->searchText) ? '*:*' : $solrRequestData->searchText; + $query = rawurlencode($query); $start = '&start=' . $solrRequestData->startAfter; $rows = '&rows=' . $solrRequestData->pageSize; $fieldList = ''; $cols = $solrRequestData->includeCols; - if (! empty( $cols )) { - $fieldList = "&fl=" . implode( ",", $cols ); + if (!empty($cols)) { + $fieldList = "&fl=" . implode(",", $cols); } $sort = ''; if ($solrRequestData->numSortingCols > 0) { $sort = '&sort='; - for ($i = 0; $i < $solrRequestData->numSortingCols; $i ++) { + for ($i = 0; $i < $solrRequestData->numSortingCols; $i++) { $sort .= $solrRequestData->sortCols[$i] . "%20" . $solrRequestData->sortDir[$i] . ","; } - $sort = substr_replace( $sort, "", - 1 ); + $sort = substr_replace($sort, "", - 1); } - $resultFormat = empty( $solrRequestData->resultFormat ) ? '' : '&wt=' . $solrRequestData->resultFormat; + $resultFormat = empty($solrRequestData->resultFormat) ? '' : '&wt=' . $solrRequestData->resultFormat; $filters = ''; - $aFilters = explode( ',', $solrRequestData->filterText ); + $aFilters = explode(',', $solrRequestData->filterText); foreach ($aFilters as $value) { - $filters .= '&fq=' . urlencode( $value ); + $filters .= '&fq=' . urlencode($value); } - $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; + $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct .= $workspace; $solrIntruct .= "/select/?q=$query"; $solrIntruct .= "&echoParams=none"; @@ -172,30 +174,29 @@ class BpmnEngine_SearchIndexAccess_Solr $solrIntruct .= $resultFormat; // send query // search the cases in base to datatable parameters - $handler = curl_init( $solrIntruct ); - curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); + $handler = curl_init($solrIntruct); + curl_setopt($handler, CURLOPT_RETURNTRANSFER, true); //Apply proxy settings $sysConf = System::getSystemConfiguration(); if ($sysConf['proxy_host'] != '') { - curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') ); + curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); if ($sysConf['proxy_port'] != '') { - curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] ); + curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']); } if ($sysConf['proxy_user'] != '') { - curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); + curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); } - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:' - ) ); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); } - $response = curl_exec( $handler ); - curl_close( $handler ); + $response = curl_exec($handler); + curl_close($handler); // decode - $responseSolr = G::json_decode( $response ); + $responseSolr = G::json_decode($response); if ($responseSolr->responseHeader->status != 0) { - throw new Exception( "Error executing query to Solr." . $solrIntruct . " response error: " . $response . "\n" ); + throw new Exception("Error executing query to Solr." . $solrIntruct . " response error: " . $response . "\n"); } return $responseSolr; @@ -209,44 +210,42 @@ class BpmnEngine_SearchIndexAccess_Solr * * @return solr response */ - public function updateDocument ($solrUpdateDocument) + public function updateDocument($solrUpdateDocument) { - if (! $this->_solrIsEnabled) + if (!$this->_solrIsEnabled) { return; + } $solrIntruct = ''; // get configuration information in base to workspace parameter - $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; + $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct .= $solrUpdateDocument->workspace; $solrIntruct .= "/update"; - $handler = curl_init( $solrIntruct ); - curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml' - ) ); // -H - curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary - curl_setopt( $handler, CURLOPT_POSTFIELDS, $solrUpdateDocument->document ); // data - - + $handler = curl_init($solrIntruct); + curl_setopt($handler, CURLOPT_RETURNTRANSFER, true); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml' + )); // -H + curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary + curl_setopt($handler, CURLOPT_POSTFIELDS, $solrUpdateDocument->document); // data //Apply proxy settings $sysConf = System::getSystemConfiguration(); if ($sysConf['proxy_host'] != '') { - curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') ); + curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); if ($sysConf['proxy_port'] != '') { - curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] ); + curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']); } if ($sysConf['proxy_user'] != '') { - curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); + curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); } - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:' - ) ); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); } - $response = curl_exec( $handler ); - curl_close( $handler ); + $response = curl_exec($handler); + curl_close($handler); - $swOk = strpos( $response, '0' ); - if (! $swOk) { - throw new Exception( "Error updating document in Solr." . $solrIntruct . " response error: " . $response . "\n" ); + $swOk = strpos($response, '0'); + if (!$swOk) { + throw new Exception("Error updating document in Solr." . $solrIntruct . " response error: " . $response . "\n"); } } @@ -258,44 +257,41 @@ class BpmnEngine_SearchIndexAccess_Solr * * @return solr response */ - public function commitChanges ($workspace) + public function commitChanges($workspace) { - if (! $this->_solrIsEnabled) + if (!$this->_solrIsEnabled) { return; + } $solrIntruct = ''; // get configuration information in base to workspace parameter - $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; + $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct .= $workspace; $solrIntruct .= "/update"; - $handler = curl_init( $solrIntruct ); - curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml' - ) ); // -H - curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary - curl_setopt( $handler, CURLOPT_POSTFIELDS, "" ); // data - - + $handler = curl_init($solrIntruct); + curl_setopt($handler, CURLOPT_RETURNTRANSFER, true); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H + curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary + curl_setopt($handler, CURLOPT_POSTFIELDS, ""); // data //Apply proxy settings $sysConf = System::getSystemConfiguration(); if ($sysConf['proxy_host'] != '') { - curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') ); + curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); if ($sysConf['proxy_port'] != '') { - curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] ); + curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']); } if ($sysConf['proxy_user'] != '') { - curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); + curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); } - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:' - ) ); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); } - $response = curl_exec( $handler ); - curl_close( $handler ); + $response = curl_exec($handler); + curl_close($handler); - $swOk = strpos( $response, '0' ); - if (! $swOk) { - throw new Exception( "Error commiting changes in Solr." . $solrIntruct . " response error: " . $response . "\n" ); + $swOk = strpos($response, '0'); + if (!$swOk) { + throw new Exception("Error commiting changes in Solr." . $solrIntruct . " response error: " . $response . "\n"); } } @@ -307,45 +303,42 @@ class BpmnEngine_SearchIndexAccess_Solr * * @return solr response */ - public function rollbackChanges ($workspace) + public function rollbackChanges($workspace) { - if (! $this->_solrIsEnabled) + if (!$this->_solrIsEnabled) { return; + } $solrIntruct = ''; // get configuration information in base to workspace parameter - $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; + $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct .= $workspace; $solrIntruct .= "/update"; - $handler = curl_init( $solrIntruct ); - curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml' - ) ); // -H - curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary - curl_setopt( $handler, CURLOPT_POSTFIELDS, "" ); // data - - + $handler = curl_init($solrIntruct); + curl_setopt($handler, CURLOPT_RETURNTRANSFER, true); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H + curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary + curl_setopt($handler, CURLOPT_POSTFIELDS, ""); // data //Apply proxy settings $sysConf = System::getSystemConfiguration(); if ($sysConf['proxy_host'] != '') { - curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') ); + curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); if ($sysConf['proxy_port'] != '') { - curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] ); + curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']); } if ($sysConf['proxy_user'] != '') { - curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); + curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); } - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:' - ) ); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); } - $response = curl_exec( $handler ); - curl_close( $handler ); + $response = curl_exec($handler); + curl_close($handler); - $swOk = strpos( $response, '0' ); - if (! $swOk) { - throw new Exception( "Error rolling back changes in Solr." . $solrIntruct . " response error: " . $response . "\n" ); + $swOk = strpos($response, '0'); + if (!$swOk) { + throw new Exception("Error rolling back changes in Solr." . $solrIntruct . " response error: " . $response . "\n"); } } @@ -357,45 +350,42 @@ class BpmnEngine_SearchIndexAccess_Solr * * @return solr response */ - public function optimizeChanges ($workspace) + public function optimizeChanges($workspace) { - if (! $this->_solrIsEnabled) + if (!$this->_solrIsEnabled) { return; + } $solrIntruct = ''; // get configuration information in base to workspace parameter - $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; + $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct .= $workspace; $solrIntruct .= "/update"; - $handler = curl_init( $solrIntruct ); - curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml' - ) ); // -H - curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary - curl_setopt( $handler, CURLOPT_POSTFIELDS, "" ); // data - - + $handler = curl_init($solrIntruct); + curl_setopt($handler, CURLOPT_RETURNTRANSFER, true); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H + curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary + curl_setopt($handler, CURLOPT_POSTFIELDS, ""); // data //Apply proxy settings $sysConf = System::getSystemConfiguration(); if ($sysConf['proxy_host'] != '') { - curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') ); + curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); if ($sysConf['proxy_port'] != '') { - curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] ); + curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']); } if ($sysConf['proxy_user'] != '') { - curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); + curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); } - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:' - ) ); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); } - $response = curl_exec( $handler ); - curl_close( $handler ); + $response = curl_exec($handler); + curl_close($handler); - $swOk = strpos( $response, '0' ); - if (! $swOk) { - throw new Exception( "Error optimizing changes in Solr." . $solrIntruct . " response error: " . $response . "\n" ); + $swOk = strpos($response, '0'); + if (!$swOk) { + throw new Exception("Error optimizing changes in Solr." . $solrIntruct . " response error: " . $response . "\n"); } } @@ -406,40 +396,40 @@ class BpmnEngine_SearchIndexAccess_Solr * @throws Exception * @return void mixed of field names */ - public function getListIndexedStoredFields ($workspace) + public function getListIndexedStoredFields($workspace) { - if (! $this->_solrIsEnabled) + if (!$this->_solrIsEnabled) { return; + } $solrIntruct = ''; // get configuration information in base to workspace parameter - $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; + $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct .= $workspace; $solrIntruct .= "/admin/luke?numTerms=0&wt=json"; - $handler = curl_init( $solrIntruct ); - curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); + $handler = curl_init($solrIntruct); + curl_setopt($handler, CURLOPT_RETURNTRANSFER, true); //Apply proxy settings $sysConf = System::getSystemConfiguration(); if ($sysConf['proxy_host'] != '') { - curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') ); + curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); if ($sysConf['proxy_port'] != '') { - curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] ); + curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']); } if ($sysConf['proxy_user'] != '') { - curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); + curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); } - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:' - ) ); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); } - $response = curl_exec( $handler ); - curl_close( $handler ); + $response = curl_exec($handler); + curl_close($handler); // decode - $responseSolr = G::json_decode( $response ); + $responseSolr = G::json_decode($response); if ($responseSolr->responseHeader->status != 0) { - throw new Exception( "Error getting index fields in Solr." . $solrIntruct . " response error: " . $response . "\n" ); + throw new Exception("Error getting index fields in Solr." . $solrIntruct . " response error: " . $response . "\n"); } return $responseSolr; } @@ -461,7 +451,7 @@ class BpmnEngine_SearchIndexAccess_Solr $solrIntruct = ""; //Get configuration information in base to workspace parameter - $solrIntruct = (substr($this->_solrHost, -1) == "/")? $this->_solrHost : $this->_solrHost . "/"; + $solrIntruct = (substr($this->_solrHost, -1) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct .= $workspace; $solrIntruct .= "/admin/ping?wt=json"; @@ -472,14 +462,14 @@ class BpmnEngine_SearchIndexAccess_Solr $sysConf = System::getSystemConfiguration(); if ($sysConf["proxy_host"] != "") { - curl_setopt($handler, CURLOPT_PROXY, $sysConf["proxy_host"] . (($sysConf["proxy_port"] != "")? ":" . $sysConf["proxy_port"] : "")); + curl_setopt($handler, CURLOPT_PROXY, $sysConf["proxy_host"] . (($sysConf["proxy_port"] != "") ? ":" . $sysConf["proxy_port"] : "")); if ($sysConf["proxy_port"] != "") { curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf["proxy_port"]); } if ($sysConf["proxy_user"] != "") { - curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf["proxy_user"] . (($sysConf["proxy_pass"] != "")? ":" . $sysConf["proxy_pass"] : "")); + curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf["proxy_user"] . (($sysConf["proxy_pass"] != "") ? ":" . $sysConf["proxy_pass"] : "")); } curl_setopt($handler, CURLOPT_HTTPHEADER, array("Expect:")); @@ -494,7 +484,7 @@ class BpmnEngine_SearchIndexAccess_Solr } //Decode - $responseSolr = G::json_decode ($response); + $responseSolr = G::json_decode($response); if ($responseSolr->responseHeader->status != "OK") { throw new Exception("Error pinging Solr server." . $solrIntruct . " response error: " . $response . "\n"); @@ -511,48 +501,45 @@ class BpmnEngine_SearchIndexAccess_Solr * * @return solr response */ - public function deleteAllDocuments ($workspace) + public function deleteAllDocuments($workspace) { - if (! $this->_solrIsEnabled) + if (!$this->_solrIsEnabled) { return; - // $registry = Zend_Registry::getInstance(); + } + // $registry = Zend_Registry::getInstance(); $solrIntruct = ''; // get configuration information in base to workspace parameter - $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; + $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct .= $workspace; $solrIntruct .= "/update"; - $handler = curl_init( $solrIntruct ); - curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml' - ) ); // -H - curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary - curl_setopt( $handler, CURLOPT_POSTFIELDS, "*:*" ); // data - - + $handler = curl_init($solrIntruct); + curl_setopt($handler, CURLOPT_RETURNTRANSFER, true); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H + curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary + curl_setopt($handler, CURLOPT_POSTFIELDS, "*:*"); // data //Apply proxy settings $sysConf = System::getSystemConfiguration(); if ($sysConf['proxy_host'] != '') { - curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') ); + curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); if ($sysConf['proxy_port'] != '') { - curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] ); + curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']); } if ($sysConf['proxy_user'] != '') { - curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); + curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); } - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:' - ) ); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); } - $response = curl_exec( $handler ); + $response = curl_exec($handler); - curl_close( $handler ); + curl_close($handler); - $swOk = strpos( $response, '0' ); - if (! $swOk) { - throw new Exception( "Error deleting all documents in Solr." . $solrIntruct . " response error: " . $response . "\n" ); + $swOk = strpos($response, '0'); + if (!$swOk) { + throw new Exception("Error deleting all documents in Solr." . $solrIntruct . " response error: " . $response . "\n"); } } @@ -564,48 +551,45 @@ class BpmnEngine_SearchIndexAccess_Solr * * @return solr response */ - public function deleteDocument ($workspace, $idQuery) + public function deleteDocument($workspace, $idQuery) { - if (! $this->_solrIsEnabled) + if (!$this->_solrIsEnabled) { return; - // $registry = Zend_Registry::getInstance(); + } + // $registry = Zend_Registry::getInstance(); $solrIntruct = ''; // get configuration information in base to workspace parameter - $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; + $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct .= $workspace; $solrIntruct .= "/update"; - $handler = curl_init( $solrIntruct ); - curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml' - ) ); // -H - curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary - curl_setopt( $handler, CURLOPT_POSTFIELDS, "" . $idQuery . "" ); // data - - + $handler = curl_init($solrIntruct); + curl_setopt($handler, CURLOPT_RETURNTRANSFER, true); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H + curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary + curl_setopt($handler, CURLOPT_POSTFIELDS, "" . $idQuery . ""); // data //Apply proxy settings $sysConf = System::getSystemConfiguration(); if ($sysConf['proxy_host'] != '') { - curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') ); + curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); if ($sysConf['proxy_port'] != '') { - curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] ); + curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']); } if ($sysConf['proxy_user'] != '') { - curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); + curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); } - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:' - ) ); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); } - $response = curl_exec( $handler ); + $response = curl_exec($handler); - curl_close( $handler ); + curl_close($handler); - $swOk = strpos( $response, '0' ); - if (! $swOk) { - throw new Exception( "Error deleting document in Solr." . $solrIntruct . " response error: " . $response . "\n" ); + $swOk = strpos($response, '0'); + if (!$swOk) { + throw new Exception("Error deleting document in Solr." . $solrIntruct . " response error: " . $response . "\n"); } } @@ -615,18 +599,19 @@ class BpmnEngine_SearchIndexAccess_Solr * @param Entity_FacetRequest $facetRequestEntity * @return solr response: list of facets array */ - public function getFacetsList ($facetRequest) + public function getFacetsList($facetRequest) { - if (! $this->_solrIsEnabled) + if (!$this->_solrIsEnabled) { return; + } $solrIntruct = ''; // get configuration information in base to workspace parameter $workspace = $facetRequest->workspace; // format request - $query = empty( $facetRequest->searchText ) ? '*:*' : $facetRequest->searchText; - $query = rawurlencode( $query ); + $query = empty($facetRequest->searchText) ? '*:*' : $facetRequest->searchText; + $query = rawurlencode($query); $start = '&start=0'; $rows = '&rows=0'; $facets = '&facet=on&facet.mincount=1&facet.limit=20'; // enable facet and @@ -639,7 +624,7 @@ class BpmnEngine_SearchIndexAccess_Solr foreach ($facetRequest->facetQueries as $value) { $facets .= '&facet.query=' . $value; } - if (! empty( $facetRequest->facetDates )) { + if (!empty($facetRequest->facetDates)) { foreach ($facetRequest->facetDates as $value) { $facets .= '&facet.date=' . $value; } @@ -656,7 +641,7 @@ class BpmnEngine_SearchIndexAccess_Solr $resultFormat = '&wt=json'; - $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/"; + $solrIntruct = (substr($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/"; $solrIntruct .= $workspace; $solrIntruct .= "/select/?q=$query"; $solrIntruct .= "&echoParams=none"; @@ -669,30 +654,29 @@ class BpmnEngine_SearchIndexAccess_Solr // send query // search the cases in base to datatable parameters - $handler = curl_init( $solrIntruct ); - curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true ); + $handler = curl_init($solrIntruct); + curl_setopt($handler, CURLOPT_RETURNTRANSFER, true); //Apply proxy settings $sysConf = System::getSystemConfiguration(); if ($sysConf['proxy_host'] != '') { - curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') ); + curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); if ($sysConf['proxy_port'] != '') { - curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] ); + curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']); } if ($sysConf['proxy_user'] != '') { - curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); + curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); } - curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:' - ) ); + curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:')); } - $response = curl_exec( $handler ); - curl_close( $handler ); + $response = curl_exec($handler); + curl_close($handler); // decode - $responseSolr = G::json_decode( $response ); + $responseSolr = G::json_decode($response); if ($responseSolr->responseHeader->status != 0) { - throw new Exception( "Error getting faceted list from Solr." . $solrIntruct . " response error: " . $response . "\n" ); + throw new Exception("Error getting faceted list from Solr." . $solrIntruct . " response error: " . $response . "\n"); } return $responseSolr; diff --git a/workflow/engine/classes/class.tasks.php b/workflow/engine/classes/class.tasks.php index 489fd46aa..1f19bc8f6 100755 --- a/workflow/engine/classes/class.tasks.php +++ b/workflow/engine/classes/class.tasks.php @@ -1,4 +1,5 @@ addJoin( GroupwfPeer::GRP_UID, TaskUserPeer::USR_UID, Criteria::LEFT_JOIN ); - $oCriteria->add( TaskUserPeer::TAS_UID, $sTaskUID ); - $oCriteria->add( TaskUserPeer::TU_TYPE, $iType ); - $oCriteria->add( TaskUserPeer::TU_RELATION, 2 ); - $oCriteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' ); - $oDataset = GroupwfPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $aGroups = array(); + $oCriteria = new Criteria('workflow'); + $oCriteria->addJoin(GroupwfPeer::GRP_UID, TaskUserPeer::USR_UID, Criteria::LEFT_JOIN); + $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID); + $oCriteria->add(TaskUserPeer::TU_TYPE, $iType); + $oCriteria->add(TaskUserPeer::TU_RELATION, 2); + $oCriteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE'); + $oDataset = GroupwfPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aGroups[] = $aRow; @@ -84,28 +83,28 @@ class Tasks * @param string $sProUid * @return array */ - public function getAllTasks ($sProUid) + public function getAllTasks($sProUid) { try { - $aTasks = array (); + $aTasks = array(); $sDelimiter = DBAdapter::getStringDelimiter(); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( TaskPeer::PRO_UID, $sProUid ); - $aConditions = array (); - $aConditions[] = array (TaskPeer::TAS_UID,ContentPeer::CON_ID + $oCriteria = new Criteria('workflow'); + $oCriteria->add(TaskPeer::PRO_UID, $sProUid); + $aConditions = array(); + $aConditions[] = array(TaskPeer::TAS_UID, ContentPeer::CON_ID ); - $aConditions[] = array (ContentPeer::CON_CATEGORY,$sDelimiter . 'TAS_TITLE' . $sDelimiter + $aConditions[] = array(ContentPeer::CON_CATEGORY, $sDelimiter . 'TAS_TITLE' . $sDelimiter ); - $aConditions[] = array (ContentPeer::CON_LANG,$sDelimiter . SYS_LANG . $sDelimiter + $aConditions[] = array(ContentPeer::CON_LANG, $sDelimiter . SYS_LANG . $sDelimiter ); - $oCriteria->addJoinMC( $aConditions, Criteria::LEFT_JOIN ); - $oCriteria->addAscendingOrderByColumn( ContentPeer::CON_VALUE ); - $oDataset = TaskPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); + $oCriteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE); + $oDataset = TaskPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oTask = new Task(); - $aTasks[] = $oTask->Load( $aRow['TAS_UID'] ); + $aTasks[] = $oTask->Load($aRow['TAS_UID']); $oDataset->next(); } return $aTasks; @@ -120,13 +119,14 @@ class Tasks * @param string $aTasks * @return array */ - public function createTaskRows ($aTask) + public function createTaskRows($aTask) { foreach ($aTask as $key => $row) { $oTask = new Task(); - if ($oTask->taskExists( $row['TAS_UID'] )) - $oTask->remove( $row['TAS_UID'] ); - $res = $oTask->createRow( $row ); + if ($oTask->taskExists($row['TAS_UID'])) { + $oTask->remove($row['TAS_UID']); + } + $res = $oTask->createRow($row); } return; } @@ -137,14 +137,15 @@ class Tasks * @param string $aTasks * @return array */ - public function updateTaskRows ($aTask) + public function updateTaskRows($aTask) { foreach ($aTask as $key => $row) { $oTask = new Task(); - if ($oTask->taskExists( $row['TAS_UID'] )) - $oTask->remove( $row['TAS_UID'] ); - else - $res = $oTask->update( $row ); + if ($oTask->taskExists($row['TAS_UID'])) { + $oTask->remove($row['TAS_UID']); + } else { + $res = $oTask->update($row); + } } return; } @@ -155,14 +156,14 @@ class Tasks * @param string $sProUid * @return array */ - public function getAllRoutes ($sProUid) + public function getAllRoutes($sProUid) { try { - $aRoutes = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( RoutePeer::PRO_UID, $sProUid ); - $oDataset = RoutePeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $aRoutes = array(); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(RoutePeer::PRO_UID, $sProUid); + $oDataset = RoutePeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aRoutes[] = $aRow; @@ -180,10 +181,10 @@ class Tasks * @param string $aTasks * @return array */ - public function createRouteRows ($aRoutes) + public function createRouteRows($aRoutes) { - $routeID = array (); - $aField = array (); + $routeID = array(); + $aField = array(); $taskParallel = ''; $taskSecJoin = ''; $taskEvaluate = ''; @@ -197,8 +198,6 @@ class Tasks $oTask = new Task(); $oEvent = new Event(); //unset ($row['ROU_UID']); - - //Saving Gateway into the GATEWAY table $idTask = $row['TAS_UID']; $nextTask = $row['ROU_NEXT_TASK']; @@ -211,53 +210,54 @@ class Tasks if ($idTask != $taskParallel) { $taskParallel = $idTask; - $sGatewayUID = $oProcessMap->saveNewGateway( $row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK'] ); + $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']); } break; case 'SEC-JOIN': if ($nextTask != $taskSecJoin) { $taskSecJoin = $nextTask; - $sGatewayUID = $oProcessMap->saveNewGateway( $row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK'] ); + $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']); } break; case 'EVALUATE': if ($idTask != $taskEvaluate) { $taskEvaluate = $idTask; - $sGatewayUID = $oProcessMap->saveNewGateway( $row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK'] ); + $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']); } break; case 'PARALLEL-BY-EVALUATION': if ($idTask != $taskParallelEv) { $taskParallelEv = $idTask; - $sGatewayUID = $oProcessMap->saveNewGateway( $row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK'] ); + $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']); } break; case 'SELECT': if ($idTask != $taskSelect) { $taskSelect = $idTask; - $sGatewayUID = $oProcessMap->saveNewGateway( $row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK'] ); + $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']); } break; case 'DISCRIMINATOR': if ($nextTask != $taskDiscriminator) { $taskDiscriminator = $nextTask; - $sGatewayUID = $oProcessMap->saveNewGateway( $row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK'] ); + $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']); } break; } $row['GAT_UID'] = $sGatewayUID; } - if ($oRoute->routeExists( $row['ROU_UID'] )) - $oRoute->remove( $row['ROU_UID'] ); + if ($oRoute->routeExists($row['ROU_UID'])) { + $oRoute->remove($row['ROU_UID']); + } - $routeID = $oRoute->create( $row ); + $routeID = $oRoute->create($row); //saving end event while import old processes - if (isset( $end ) && $end == 1) { - if (! $oEvent->existsByTaskUidFrom( $idTask )) { + if (isset($end) && $end == 1) { + if (!$oEvent->existsByTaskUidFrom($idTask)) { if ($sRouteType == "SEQUENTIAL") { - $aTaskDetails = $oTask->load( $idTask ); + $aTaskDetails = $oTask->load($idTask); $positionX = $aTaskDetails['TAS_POSX'] + $aTaskDetails['TAS_WIDTH'] / 2; $positionY = $aTaskDetails['TAS_POSY'] + $aTaskDetails['TAS_HEIGHT'] + 10; @@ -270,16 +270,15 @@ class Tasks $aData['EVN_RELATED_TO'] = 'MULTIPLE'; $aData['EVN_WHEN'] = '1'; $aData['EVN_ACTION'] = ''; - $sEvn_uid = $oEvent->create( $aData ); + $sEvn_uid = $oEvent->create($aData); $aField['ROU_UID'] = $routeID; $aField['ROU_EVN_UID'] = $sEvn_uid; - $oRoute->update( $aField ); + $oRoute->update($aField); $end = 0; } } } - } return; } @@ -290,15 +289,16 @@ class Tasks * @param string $aTasks * @return array */ - public function updateRouteRows ($aRoutes) + public function updateRouteRows($aRoutes) { foreach ($aRoutes as $key => $row) { $oRoute = new Route(); //krumo ($row); - if (is_array( $oRoute->load( $row['ROU_UID'] ) )) - $oRoute->remove( $row['ROU_UID'] ); - else - $res = $oRoute->update( $row ); + if (is_array($oRoute->load($row['ROU_UID']))) { + $oRoute->remove($row['ROU_UID']); + } else { + $res = $oRoute->update($row); + } } return; } @@ -310,17 +310,17 @@ class Tasks * @param integer $iType * @return array */ - public function getUsersOfTask ($sTaskUID, $iType) + public function getUsersOfTask($sTaskUID, $iType) { try { - $aUsers = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addJoin( UsersPeer::USR_UID, TaskUserPeer::USR_UID, Criteria::LEFT_JOIN ); - $oCriteria->add( TaskUserPeer::TAS_UID, $sTaskUID ); - $oCriteria->add( TaskUserPeer::TU_TYPE, $iType ); - $oCriteria->add( TaskUserPeer::TU_RELATION, 1 ); - $oDataset = UsersPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $aUsers = array(); + $oCriteria = new Criteria('workflow'); + $oCriteria->addJoin(UsersPeer::USR_UID, TaskUserPeer::USR_UID, Criteria::LEFT_JOIN); + $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID); + $oCriteria->add(TaskUserPeer::TU_TYPE, $iType); + $oCriteria->add(TaskUserPeer::TU_RELATION, 1); + $oDataset = UsersPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aUsers[] = $aRow; @@ -338,7 +338,7 @@ class Tasks * @param string $sTaskUID * @return void */ - function deleteTask ($sTaskUID = '') + public function deleteTask($sTaskUID = '') { try { //Instance classes @@ -348,58 +348,58 @@ class Tasks $oStep = new Step(); $oStepTrigger = new StepTrigger(); //Get task information - $aFields = $oTask->load( $sTaskUID ); + $aFields = $oTask->load($sTaskUID); //Delete routes - $oTasks->deleteAllRoutesOfTask( $aFields['PRO_UID'], $sTaskUID, true ); + $oTasks->deleteAllRoutesOfTask($aFields['PRO_UID'], $sTaskUID, true); //Delete gateways - $oTasks->deleteAllGatewayOfTask( $aFields['PRO_UID'], $sTaskUID, true ); + $oTasks->deleteAllGatewayOfTask($aFields['PRO_UID'], $sTaskUID, true); //Delete the users assigned to task - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( TaskUserPeer::TAS_UID, $sTaskUID ); - $oDataset1 = TaskUserPeer::doSelectRS( $oCriteria ); - $oDataset1->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID); + $oDataset1 = TaskUserPeer::doSelectRS($oCriteria); + $oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset1->next(); while ($aRow1 = $oDataset1->getRow()) { - $oTaskUser->remove( $aRow1['TAS_UID'], $aRow1['USR_UID'], $aRow1['TU_TYPE'], $aRow1['TU_RELATION'] ); + $oTaskUser->remove($aRow1['TAS_UID'], $aRow1['USR_UID'], $aRow1['TU_TYPE'], $aRow1['TU_RELATION']); $oDataset1->next(); } //Delete the steps of task - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( StepPeer::TAS_UID, $sTaskUID ); - $oDataset1 = StepPeer::doSelectRS( $oCriteria ); - $oDataset1->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(StepPeer::TAS_UID, $sTaskUID); + $oDataset1 = StepPeer::doSelectRS($oCriteria); + $oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset1->next(); while ($aRow1 = $oDataset1->getRow()) { //Delete the triggers assigned to step - /*$oCriteria = new Criteria('workflow'); - $oCriteria->add(StepTriggerPeer::STEP_UID, $aRow1['STEP_UID']); - $oDataset2 = StepTriggerPeer::doSelectRS($oCriteria); - $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset2->next(); - while ($aRow2 = $oDataset2->getRow()) { - $oStepTrigger->remove($aRow2['STEP_UID'], $aRow2['TAS_UID'], $aRow2['TRI_UID'], $aRow2['ST_TYPE']); - $oDataset2->next(); - }*/ - $oStep->remove( $aRow1['STEP_UID'] ); + /* $oCriteria = new Criteria('workflow'); + $oCriteria->add(StepTriggerPeer::STEP_UID, $aRow1['STEP_UID']); + $oDataset2 = StepTriggerPeer::doSelectRS($oCriteria); + $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $oDataset2->next(); + while ($aRow2 = $oDataset2->getRow()) { + $oStepTrigger->remove($aRow2['STEP_UID'], $aRow2['TAS_UID'], $aRow2['TRI_UID'], $aRow2['ST_TYPE']); + $oDataset2->next(); + } */ + $oStep->remove($aRow1['STEP_UID']); $oDataset1->next(); } //Delete step triggers - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( StepTriggerPeer::TAS_UID, $sTaskUID ); - StepTriggerPeer::doDelete( $oCriteria ); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(StepTriggerPeer::TAS_UID, $sTaskUID); + StepTriggerPeer::doDelete($oCriteria); //Delete permissions - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ObjectPermissionPeer::TAS_UID, $sTaskUID ); - ObjectPermissionPeer::doDelete( $oCriteria ); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ObjectPermissionPeer::OP_TASK_SOURCE, $sTaskUID ); - ObjectPermissionPeer::doDelete( $oCriteria ); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(ObjectPermissionPeer::TAS_UID, $sTaskUID); + ObjectPermissionPeer::doDelete($oCriteria); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(ObjectPermissionPeer::OP_TASK_SOURCE, $sTaskUID); + ObjectPermissionPeer::doDelete($oCriteria); //Delete task - $oTask->remove( $sTaskUID ); + $oTask->remove($sTaskUID); //Delete cases schedulers added by krlos - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( CaseSchedulerPeer::TAS_UID, $sTaskUID ); - CaseSchedulerPeer::doDelete( $oCriteria ); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(CaseSchedulerPeer::TAS_UID, $sTaskUID); + CaseSchedulerPeer::doDelete($oCriteria); } catch (Exception $oError) { throw ($oError); } @@ -412,22 +412,22 @@ class Tasks * @param string $sTaskUID * @return boolean */ - public function deleteAllRoutesOfTask ($sProcessUID = '', $sTaskUID = '', $bAll = false) + public function deleteAllRoutesOfTask($sProcessUID = '', $sTaskUID = '', $bAll = false) { try { $oProcess = new Process(); - $aFields = $oProcess->load( $sProcessUID ); + $aFields = $oProcess->load($sProcessUID); $oTask = new Task(); - $aFields = $oTask->load( $sTaskUID ); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( RoutePeer::PRO_UID, $sProcessUID ); - $oCriteria->add( RoutePeer::TAS_UID, $sTaskUID ); - RoutePeer::doDelete( $oCriteria ); + $aFields = $oTask->load($sTaskUID); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID); + $oCriteria->add(RoutePeer::TAS_UID, $sTaskUID); + RoutePeer::doDelete($oCriteria); if ($bAll) { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( RoutePeer::PRO_UID, $sProcessUID ); - $oCriteria->add( RoutePeer::ROU_NEXT_TASK, $sTaskUID ); - RoutePeer::doDelete( $oCriteria ); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID); + $oCriteria->add(RoutePeer::ROU_NEXT_TASK, $sTaskUID); + RoutePeer::doDelete($oCriteria); } return true; } catch (Exception $oError) { @@ -441,18 +441,18 @@ class Tasks * @param string $sProUid * @return array */ - public function getAllGateways ($sProUid) + public function getAllGateways($sProUid) { try { - $aGateways = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( GatewayPeer::PRO_UID, $sProUid ); - $oDataset = GatewayPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $aGateways = array(); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(GatewayPeer::PRO_UID, $sProUid); + $oDataset = GatewayPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oGateway = new Gateway(); - $aGateways[] = $oGateway->load( $aRow['GAT_UID'] ); + $aGateways[] = $oGateway->load($aRow['GAT_UID']); $oDataset->next(); } return $aGateways; @@ -467,17 +467,19 @@ class Tasks * @param string $aTasks * @return array */ - public function createGatewayRows ($aGateway) + public function createGatewayRows($aGateway) { foreach ($aGateway as $key => $row) { $oGateway = new Gateway(); - if ($oGateway->gatewayExists( $row['GAT_UID'] )) - $oGateway->remove( $row['GAT_UID'] ); + if ($oGateway->gatewayExists($row['GAT_UID'])) { + $oGateway->remove($row['GAT_UID']); + } - if ($row['TAS_UID'] != '' && $row['GAT_NEXT_TASK'] != '') + if ($row['TAS_UID'] != '' && $row['GAT_NEXT_TASK'] != '') { continue; - else - $res = $oGateway->createRow( $row ); + } else { + $res = $oGateway->createRow($row); + } } return; } @@ -489,22 +491,22 @@ class Tasks * @param string $sTaskUID * @return boolean */ - public function deleteAllGatewayOfTask ($sProcessUID = '', $sTaskUID = '', $bAll = false) + public function deleteAllGatewayOfTask($sProcessUID = '', $sTaskUID = '', $bAll = false) { try { $oProcess = new Process(); - $aFields = $oProcess->load( $sProcessUID ); + $aFields = $oProcess->load($sProcessUID); $oTask = new Task(); - $aFields = $oTask->load( $sTaskUID ); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( GatewayPeer::PRO_UID, $sProcessUID ); - $oCriteria->add( GatewayPeer::TAS_UID, $sTaskUID ); - GatewayPeer::doDelete( $oCriteria ); + $aFields = $oTask->load($sTaskUID); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(GatewayPeer::PRO_UID, $sProcessUID); + $oCriteria->add(GatewayPeer::TAS_UID, $sTaskUID); + GatewayPeer::doDelete($oCriteria); if ($bAll) { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( GatewayPeer::PRO_UID, $sProcessUID ); - $oCriteria->add( GatewayPeer::GAT_NEXT_TASK, $sTaskUID ); - GatewayPeer::doDelete( $oCriteria ); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(GatewayPeer::PRO_UID, $sProcessUID); + $oCriteria->add(GatewayPeer::GAT_NEXT_TASK, $sTaskUID); + GatewayPeer::doDelete($oCriteria); } return true; } catch (Exception $oError) { @@ -520,12 +522,11 @@ class Tasks * @param string $iType * @return integer */ - public function assignUser ($sTaskUID = '', $sUserUID = '', $iType = '') + public function assignUser($sTaskUID = '', $sUserUID = '', $iType = '') { try { $oTaskUser = new TaskUser(); - return $oTaskUser->create( array ('TAS_UID' => $sTaskUID,'USR_UID' => $sUserUID,'TU_TYPE' => $iType,'TU_RELATION' => 1 - ) ); + return $oTaskUser->create(array('TAS_UID' => $sTaskUID, 'USR_UID' => $sUserUID, 'TU_TYPE' => $iType, 'TU_RELATION' => 1)); } catch (Exception $oError) { throw ($oError); } @@ -539,30 +540,30 @@ class Tasks * @param string $iType * @return integer */ - public function assignGroup ($sTaskUID = '', $sGroupUID = '', $iType = '') + public function assignGroup($sTaskUID = '', $sGroupUID = '', $iType = '') { try { $oTaskUser = new TaskUser(); - /*$oCriteria = new Criteria('workflow'); - $oCriteria->add(GroupUserPeer::GRP_UID, $sGroupUID); - $oDataset = GroupUserPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - while ($aGroupUser = $oDataset->getRow()) { - $oCriteria = new Criteria('workflow'); - $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID); - $oCriteria->add(TaskUserPeer::USR_UID, $aGroupUser['USR_UID']); - $oDataset2 = TaskUserPeer::doSelectRS($oCriteria); - $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset2->next(); - $aRow = $oDataset2->getRow(); - if (!is_array($aRow)) { - $this->assignUser($sTaskUID, $aGroupUser['USR_UID'], $iType); - } - $oDataset->next(); - }*/ - return $oTaskUser->create( array ('TAS_UID' => $sTaskUID,'USR_UID' => $sGroupUID,'TU_TYPE' => $iType,'TU_RELATION' => 2 - ) ); + /* $oCriteria = new Criteria('workflow'); + $oCriteria->add(GroupUserPeer::GRP_UID, $sGroupUID); + $oDataset = GroupUserPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + while ($aGroupUser = $oDataset->getRow()) { + $oCriteria = new Criteria('workflow'); + $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID); + $oCriteria->add(TaskUserPeer::USR_UID, $aGroupUser['USR_UID']); + $oDataset2 = TaskUserPeer::doSelectRS($oCriteria); + $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $oDataset2->next(); + $aRow = $oDataset2->getRow(); + if (!is_array($aRow)) { + $this->assignUser($sTaskUID, $aGroupUser['USR_UID'], $iType); + } + $oDataset->next(); + } */ + return $oTaskUser->create(array('TAS_UID' => $sTaskUID, 'USR_UID' => $sGroupUID, 'TU_TYPE' => $iType, 'TU_RELATION' => 2 + )); } catch (Exception $oError) { throw ($oError); } @@ -574,12 +575,12 @@ class Tasks * @param string $sUserUID * @return void */ - public function ofToAssignUserOfAllTasks ($sUserUID = '') + public function ofToAssignUserOfAllTasks($sUserUID = '') { try { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( TaskUserPeer::USR_UID, $sUserUID ); - TaskUserPeer::doDelete( $oCriteria ); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(TaskUserPeer::USR_UID, $sUserUID); + TaskUserPeer::doDelete($oCriteria); } catch (Exception $oError) { throw ($oError); } @@ -593,11 +594,11 @@ class Tasks * @param integer $iType * @return boolean */ - public function ofToAssignUser ($sTaskUID = '', $sUserUID = '', $iType = 0) + public function ofToAssignUser($sTaskUID = '', $sUserUID = '', $iType = 0) { try { $oTaskUser = new TaskUser(); - $oTaskUser->remove( $sTaskUID, $sUserUID, $iType, 1 ); + $oTaskUser->remove($sTaskUID, $sUserUID, $iType, 1); return true; } catch (Exception $oError) { throw ($oError); @@ -612,11 +613,11 @@ class Tasks * @param integer $iType * @return boolean */ - public function ofToAssignGroup ($sTaskUID = '', $sGroupUID = '', $iType = 0) + public function ofToAssignGroup($sTaskUID = '', $sGroupUID = '', $iType = 0) { try { $oTaskUser = new TaskUser(); - return $oTaskUser->remove( $sTaskUID, $sGroupUID, $iType, 2 ); + return $oTaskUser->remove($sTaskUID, $sGroupUID, $iType, 2); } catch (Exception $oError) { throw ($oError); } @@ -628,15 +629,15 @@ class Tasks * @param string $sTaskUID * @return array */ - public function getStepsOfTask ($sTaskUID) + public function getStepsOfTask($sTaskUID) { try { - $aSteps = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( StepPeer::TAS_UID, $sTaskUID ); - $oCriteria->addAscendingOrderByColumn( StepPeer::STEP_POSITION ); - $oDataset = StepPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $aSteps = array(); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(StepPeer::TAS_UID, $sTaskUID); + $oCriteria->addAscendingOrderByColumn(StepPeer::STEP_POSITION); + $oDataset = StepPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aSteps[] = $aRow; @@ -654,10 +655,10 @@ class Tasks * @param string $sProcessUID * @return boolean */ - public function existsBuildingElements ($sProcessUID) + public function existsBuildingElements($sProcessUID) { try { - $oCriteria = new Criteria( 'workflow' ); + $oCriteria = new Criteria('workflow'); //$oCriteria->add(StepPeer::PRO_UID, $sProcessUID); //$oDataset = StepPeer::doSelectRS($oCriteria); //$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); @@ -674,20 +675,20 @@ class Tasks * @param string $sProUid * @return array */ - public function getStartingTaskForUser ($sProUid, $sUsrUid) + public function getStartingTaskForUser($sProUid, $sUsrUid) { try { - $aTasks = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( TaskPeer::PRO_UID, $sProUid ); + $aTasks = array(); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(TaskPeer::PRO_UID, $sProUid); //$oCriteria->add(TaskPeer::TAS_USER, $sUsrUid); - $oCriteria->add( TaskPeer::TAS_START, 'TRUE' ); - $oDataset = TaskPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria->add(TaskPeer::TAS_START, 'TRUE'); + $oDataset = TaskPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oTask = new Task(); - $aTasks[] = $oTask->Load( $aRow['TAS_UID'] ); + $aTasks[] = $oTask->Load($aRow['TAS_UID']); $oDataset->next(); } return $aTasks; @@ -702,20 +703,21 @@ class Tasks * @param string $sTaskUID * @return array */ - public function assignUsertoTask ($sTaskUID) + public function assignUsertoTask($sTaskUID) { try { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( TaskUserPeer::USR_UID ); - $oCriteria->add( TaskUserPeer::TAS_UID, $sTaskUID ); - $oDataset = TaskUserPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(TaskUserPeer::USR_UID); + $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID); + $oDataset = TaskUserPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aRow = $oDataset->getRow(); - if (is_array( $aRow )) + if (is_array($aRow)) { return 1; - else + } else { return 0; + } } catch (Exception $oError) { throw ($oError); } @@ -727,23 +729,24 @@ class Tasks * @param string $sUsrUid, $sTaskUID * @return array */ - public function verifyUsertoTask ($sUsrUid, $sTaskUID) + public function verifyUsertoTask($sUsrUid, $sTaskUID) { try { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( TaskUserPeer::USR_UID ); - $oCriteria->addSelectColumn( TaskUserPeer::TAS_UID ); - $oCriteria->addSelectColumn( TaskUserPeer::TU_RELATION ); - $oCriteria->add( TaskUserPeer::TAS_UID, $sTaskUID ); - $oCriteria->add( TaskUserPeer::USR_UID, $sUsrUid ); - $oDataset = TaskUserPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(TaskUserPeer::USR_UID); + $oCriteria->addSelectColumn(TaskUserPeer::TAS_UID); + $oCriteria->addSelectColumn(TaskUserPeer::TU_RELATION); + $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID); + $oCriteria->add(TaskUserPeer::USR_UID, $sUsrUid); + $oDataset = TaskUserPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aRow = $oDataset->getRow(); - if (is_array( $aRow )) + if (is_array($aRow)) { return $aRow; - else + } else { return $aRow; + } } catch (Exception $oError) { throw ($oError); } @@ -755,41 +758,41 @@ class Tasks * @param string $sUsrUID * @return array */ - public function getTasksThatUserIsAssigned ($sUserUID) + public function getTasksThatUserIsAssigned($sUserUID) { try { - $aTasks = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( TaskUserPeer::USR_UID, $sUserUID ); - $oCriteria->add( TaskUserPeer::TU_RELATION, 1 ); - $oDataset = TaskUserPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $aTasks = array(); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(TaskUserPeer::USR_UID, $sUserUID); + $oCriteria->add(TaskUserPeer::TU_RELATION, 1); + $oDataset = TaskUserPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aTasks[] = $aRow['TAS_UID']; $oDataset->next(); } - $aGroups = array (); + $aGroups = array(); $oCriteria = new Criteria(); - $oCriteria->add( GroupwfPeer::GRP_UID, '', Criteria::NOT_EQUAL ); - $oCriteria->add( GroupUserPeer::USR_UID, $sUserUID ); - $oCriteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' ); - $oCriteria->addJoin( GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN ); - $oDataset = GroupwfPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria->add(GroupwfPeer::GRP_UID, '', Criteria::NOT_EQUAL); + $oCriteria->add(GroupUserPeer::USR_UID, $sUserUID); + $oCriteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE'); + $oCriteria->addJoin(GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN); + $oDataset = GroupwfPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aGroups[] = $aRow['GRP_UID']; $oDataset->next(); } - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( TaskUserPeer::USR_UID, $aGroups, Criteria::IN ); - $oCriteria->add( TaskUserPeer::TU_RELATION, 2 ); - $oDataset = TaskUserPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(TaskUserPeer::USR_UID, $aGroups, Criteria::IN); + $oCriteria->add(TaskUserPeer::TU_RELATION, 2); + $oDataset = TaskUserPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { - if (! in_array( $aRow['TAS_UID'], $aTasks )) { + if (!in_array($aRow['TAS_UID'], $aTasks)) { $aTasks[] = $aRow['TAS_UID']; } $oDataset->next(); @@ -806,15 +809,15 @@ class Tasks * @param string $sProUid, $sTaskUid * @return array by Everth */ - public function getRoute ($sProUid, $sTaskUid) + public function getRoute($sProUid, $sTaskUid) { try { - $aRoutes = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( RoutePeer::PRO_UID, $sProUid ); - $oCriteria->add( RoutePeer::TAS_UID, $sTaskUid ); - $oDataset = RoutePeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $aRoutes = array(); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(RoutePeer::PRO_UID, $sProUid); + $oCriteria->add(RoutePeer::TAS_UID, $sTaskUid); + $oDataset = RoutePeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aRoutes[] = $aRow; @@ -833,16 +836,16 @@ class Tasks * @param string $sProUid, $sTaskUid * @return array by Girish */ - public function getRouteByType ($sProUid, $sRouteNextTaskUid, $sRouteType) + public function getRouteByType($sProUid, $sRouteNextTaskUid, $sRouteType) { try { - $aRoutes = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( RoutePeer::PRO_UID, $sProUid ); - $oCriteria->add( RoutePeer::ROU_NEXT_TASK, $sRouteNextTaskUid ); - $oCriteria->add( RoutePeer::ROU_TYPE, $sRouteType ); - $oDataset = RoutePeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $aRoutes = array(); + $oCriteria = new Criteria('workflow'); + $oCriteria->add(RoutePeer::PRO_UID, $sProUid); + $oCriteria->add(RoutePeer::ROU_NEXT_TASK, $sRouteNextTaskUid); + $oCriteria->add(RoutePeer::ROU_TYPE, $sRouteType); + $oDataset = RoutePeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aRoutes[] = $aRow; @@ -854,6 +857,5 @@ class Tasks throw ($oError); } } - } -?> + \ No newline at end of file diff --git a/workflow/engine/classes/entities/FacetRequest.php b/workflow/engine/classes/entities/FacetRequest.php index f4c9ef772..5c0fbeeb1 100644 --- a/workflow/engine/classes/entities/FacetRequest.php +++ b/workflow/engine/classes/entities/FacetRequest.php @@ -1,43 +1,45 @@ initializeObject ($data); - - $requiredFields = array ( - "workspace" - ); - - $obj->validateRequiredFields ($requiredFields); - - return $obj; - } -} \ No newline at end of file + public $workspace = ''; + public $searchText = ''; + public $facetFields = array(); + public $facetQueries = array(); + public $facetDates = array(); + public $facetDatesStart = ''; + public $facetDatesEnd = ''; + public $facetDateGap = ''; + public $facetRanges = array(); + public $filters = array(); + public $selectedFacetsString = ''; + + private function __construct() + { + } + + public static function createEmpty() + { + $obj = new Entity_FacetRequest (); + return $obj; + } + + public static function createForRequest($data) + { + $obj = new Entity_FacetRequest (); + + $obj->initializeObject($data); + + $requiredFields = array( + "workspace" + ); + + $obj->validateRequiredFields($requiredFields); + + return $obj; + } +} + \ No newline at end of file diff --git a/workflow/engine/classes/entities/SolrRequestData.php b/workflow/engine/classes/entities/SolrRequestData.php index f84bd79e6..4bd43f4be 100644 --- a/workflow/engine/classes/entities/SolrRequestData.php +++ b/workflow/engine/classes/entities/SolrRequestData.php @@ -1,46 +1,48 @@ initializeObject ($data); - - $requiredFields = array ( - 'workspace' - ); - - $obj->validateRequiredFields ($requiredFields); - - return $obj; - } -} \ No newline at end of file + public $workspace = ''; + public $startAfter = 0; + public $pageSize = 10; + public $searchText = '*:*'; + public $filterText = ''; // comma separated list of filters field:value + public $numSortingCols = 0; // number of columns that are sorted + public $sortableCols = array(); // array of booleans indicating if column is + // sortable (true, false) + public $sortCols = array(); // array of indices of sorted columns index + // based in the total number of sorting cols + public $sortDir = array(); // array of direction of sorting for each + // column (desc, asc) + public $includeCols = array(); + public $resultFormat = 'xml'; // json, xml, php + + private function __construct() + { + } + + public static function createEmpty() + { + $obj = new Entity_SolrRequestData (); + return $obj; + } + + public static function createForRequestPagination($data) + { + $obj = new Entity_SolrRequestData (); + + $obj->initializeObject($data); + + $requiredFields = array( + 'workspace' + ); + + $obj->validateRequiredFields($requiredFields); + + return $obj; + } +} + \ No newline at end of file diff --git a/workflow/engine/classes/model/OutputDocument.php b/workflow/engine/classes/model/OutputDocument.php index d4b1468ae..23bf12e74 100755 --- a/workflow/engine/classes/model/OutputDocument.php +++ b/workflow/engine/classes/model/OutputDocument.php @@ -1,4 +1,5 @@ toArray(BasePeer::TYPE_FIELDNAME); - $aFields['OUT_DOC_TITLE'] = $oOutputDocument->getOutDocTitle(); + $aFields['OUT_DOC_TITLE'] = $oOutputDocument->getOutDocTitle(); $aFields['OUT_DOC_DESCRIPTION'] = $oOutputDocument->getOutDocDescription(); - $aFields['OUT_DOC_FILENAME'] = $oOutputDocument->getOutDocFilename(); - $aFields['OUT_DOC_TEMPLATE'] = $oOutputDocument->getOutDocTemplate(); + $aFields['OUT_DOC_FILENAME'] = $oOutputDocument->getOutDocFilename(); + $aFields['OUT_DOC_TEMPLATE'] = $oOutputDocument->getOutDocTemplate(); $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); return $aFields; @@ -96,10 +97,11 @@ class OutputDocument extends BaseOutputDocument } /* - * Load the application document registry - * @param string $sAppDocUid - * @return variant - */ + * Load the application document registry + * @param string $sAppDocUid + * @return variant + */ + public function load($sOutDocUid) { try { @@ -107,11 +109,11 @@ class OutputDocument extends BaseOutputDocument if (!is_null($oOutputDocument)) { $aFields = $oOutputDocument->toArray(BasePeer::TYPE_FIELDNAME); - $aFields['OUT_DOC_TITLE'] = $oOutputDocument->getOutDocTitle(); - $aFields['PRO_UID'] = $oOutputDocument->getProUid(); + $aFields['OUT_DOC_TITLE'] = $oOutputDocument->getOutDocTitle(); + $aFields['PRO_UID'] = $oOutputDocument->getProUid(); $aFields['OUT_DOC_DESCRIPTION'] = $oOutputDocument->getOutDocDescription(); - $aFields['OUT_DOC_FILENAME'] = $oOutputDocument->getOutDocFilename(); - $aFields['OUT_DOC_TEMPLATE'] = $oOutputDocument->getOutDocTemplate(); + $aFields['OUT_DOC_FILENAME'] = $oOutputDocument->getOutDocFilename(); + $aFields['OUT_DOC_TEMPLATE'] = $oOutputDocument->getOutDocTemplate(); $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); return $aFields; @@ -127,13 +129,13 @@ class OutputDocument extends BaseOutputDocument * Create the application document registry * @param array $aData * @return string - **/ + * */ public function create($aData) { $oConnection = Propel::getConnection(OutputDocumentPeer::DATABASE_NAME); try { - if (isset($aData['OUT_DOC_UID']) && $aData['OUT_DOC_UID']== '') { + if (isset($aData['OUT_DOC_UID']) && $aData['OUT_DOC_UID'] == '') { unset($aData['OUT_DOC_UID']); } @@ -181,7 +183,7 @@ class OutputDocument extends BaseOutputDocument $sMessage .= $oValidationFailure->getMessage() . '
'; } - throw (new Exception('The registry cannot be created!
'.$sMessage)); + throw (new Exception('The registry cannot be created!
' . $sMessage)); } } catch (Exception $oError) { $oConnection->rollback(); @@ -194,7 +196,7 @@ class OutputDocument extends BaseOutputDocument * Update the application document registry * @param array $aData * @return string - **/ + * */ public function update($aData) { $oConnection = Propel::getConnection(OutputDocumentPeer::DATABASE_NAME); @@ -236,7 +238,7 @@ class OutputDocument extends BaseOutputDocument $sMessage .= $oValidationFailure->getMessage() . '
'; } - throw (new Exception('The registry cannot be updated!
'.$sMessage)); + throw (new Exception('The registry cannot be updated!
' . $sMessage)); } } else { throw (new Exception('This row doesn\'t exist!')); @@ -252,7 +254,7 @@ class OutputDocument extends BaseOutputDocument * Remove the application document registry * @param array $aData * @return string - **/ + * */ public function remove($sOutDocUid) { $oConnection = Propel::getConnection(OutputDocumentPeer::DATABASE_NAME); @@ -289,10 +291,7 @@ class OutputDocument extends BaseOutputDocument if ($this->out_doc_title == '') { try { $this->out_doc_title = Content::load( - 'OUT_DOC_TITLE', - '', - $this->getOutDocUid(), - (defined('SYS_LANG')? SYS_LANG : 'en') + 'OUT_DOC_TITLE', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en') ); } catch (Exception $oError) { throw ($oError); @@ -311,7 +310,7 @@ class OutputDocument extends BaseOutputDocument public function setOutDocTitle($sValue) { if ($sValue !== null && !is_string($sValue)) { - $sValue = (string)$sValue; + $sValue = (string) $sValue; } if ($this->out_doc_title !== $sValue || $sValue === '') { @@ -319,11 +318,7 @@ class OutputDocument extends BaseOutputDocument $this->out_doc_title = $sValue; $iResult = Content::addContent( - 'OUT_DOC_TITLE', - '', - $this->getOutDocUid(), - (defined('SYS_LANG')? SYS_LANG : 'en'), - $this->out_doc_title + 'OUT_DOC_TITLE', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->out_doc_title ); } catch (Exception $oError) { $this->out_doc_title = ''; @@ -342,10 +337,7 @@ class OutputDocument extends BaseOutputDocument if ($this->out_doc_description == '') { try { $this->out_doc_description = Content::load( - 'OUT_DOC_DESCRIPTION', - '', - $this->getOutDocUid(), - (defined('SYS_LANG')? SYS_LANG : 'en') + 'OUT_DOC_DESCRIPTION', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en') ); } catch (Exception $oError) { throw ($oError); @@ -364,7 +356,7 @@ class OutputDocument extends BaseOutputDocument public function setOutDocDescription($sValue) { if ($sValue !== null && !is_string($sValue)) { - $sValue = (string)$sValue; + $sValue = (string) $sValue; } if ($this->out_doc_description !== $sValue || $sValue === '') { @@ -372,11 +364,7 @@ class OutputDocument extends BaseOutputDocument $this->out_doc_description = $sValue; $iResult = Content::addContent( - 'OUT_DOC_DESCRIPTION', - '', - $this->getOutDocUid(), - (defined('SYS_LANG')? SYS_LANG : 'en'), - $this->out_doc_description + 'OUT_DOC_DESCRIPTION', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->out_doc_description ); } catch (Exception $oError) { $this->out_doc_description = ''; @@ -395,10 +383,7 @@ class OutputDocument extends BaseOutputDocument if ($this->out_doc_filename == '') { try { $this->out_doc_filename = Content::load( - 'OUT_DOC_FILENAME', - '', - $this->getOutDocUid(), - (defined('SYS_LANG')? SYS_LANG : 'en') + 'OUT_DOC_FILENAME', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en') ); } catch (Exception $oError) { throw ($oError); @@ -417,7 +402,7 @@ class OutputDocument extends BaseOutputDocument public function setOutDocFilename($sValue) { if ($sValue !== null && !is_string($sValue)) { - $sValue = (string)$sValue; + $sValue = (string) $sValue; } if ($this->out_doc_filename !== $sValue || $sValue === '') { @@ -425,11 +410,7 @@ class OutputDocument extends BaseOutputDocument $this->out_doc_filename = $sValue; $iResult = Content::addContent( - 'OUT_DOC_FILENAME', - '', - $this->getOutDocUid(), - (defined('SYS_LANG')? SYS_LANG : 'en'), - $this->out_doc_filename + 'OUT_DOC_FILENAME', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->out_doc_filename ); } catch (Exception $oError) { $this->out_doc_filename = ''; @@ -448,10 +429,7 @@ class OutputDocument extends BaseOutputDocument if ($this->out_doc_template == '') { try { $this->out_doc_template = Content::load( - 'OUT_DOC_TEMPLATE', - '', - $this->getOutDocUid(), - (defined('SYS_LANG')? SYS_LANG : 'en') + 'OUT_DOC_TEMPLATE', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en') ); } catch (Exception $oError) { throw ($oError); @@ -470,7 +448,7 @@ class OutputDocument extends BaseOutputDocument public function setOutDocTemplate($sValue) { if ($sValue !== null && !is_string($sValue)) { - $sValue = (string)$sValue; + $sValue = (string) $sValue; } if ($this->out_doc_template !== $sValue || $sValue === '') { @@ -478,11 +456,7 @@ class OutputDocument extends BaseOutputDocument $this->out_doc_template = $sValue; $iResult = Content::addContent( - 'OUT_DOC_TEMPLATE', - '', - $this->getOutDocUid(), - (defined('SYS_LANG')? SYS_LANG : 'en'), - $this->out_doc_template + 'OUT_DOC_TEMPLATE', '', $this->getOutDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->out_doc_template ); } catch (Exception $oError) { $this->out_doc_template = ''; @@ -493,22 +467,15 @@ class OutputDocument extends BaseOutputDocument } /* - * Generate the output document - * @param string $sUID - * @param array $aFields - * @param string $sPath - * @return variant - */ - public function generate( - $sUID, - $aFields, - $sPath, - $sFilename, - $sContent, - $sLandscape = false, - $sTypeDocToGener = 'BOTH', - $aProperties = array() - ) { + * Generate the output document + * @param string $sUID + * @param array $aFields + * @param string $sPath + * @return variant + */ + + public function generate($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $sTypeDocToGener = 'BOTH', $aProperties = array()) + { if (($sUID != '') && is_array($aFields) && ($sPath != '')) { $sContent = G::replaceDataGridField($sContent, $aFields); @@ -518,46 +485,46 @@ class OutputDocument extends BaseOutputDocument $oFile = fopen($sPath . $sFilename . '.doc', 'wb'); $size = array(); - $size["Letter"] = "216mm 279mm"; - $size["Legal"] = "216mm 357mm"; - $size["Executive"] = "184mm 267mm"; - $size["B5"] = "182mm 257mm"; - $size["Folio"] = "216mm 330mm"; - $size["A0Oversize"] = "882mm 1247mm"; - $size["A0"] = "841mm 1189mm"; - $size["A1"] = "594mm 841mm"; - $size["A2"] = "420mm 594mm"; - $size["A3"] = "297mm 420mm"; - $size["A4"] = "210mm 297mm"; - $size["A5"] = "148mm 210mm"; - $size["A6"] = "105mm 148mm"; - $size["A7"] = "74mm 105mm"; - $size["A8"] = "52mm 74mm"; - $size["A9"] = "37mm 52mm"; - $size["A10"] = "26mm 37mm"; - $size["Screenshot640"] = "640mm 480mm"; - $size["Screenshot800"] = "800mm 600mm"; + $size["Letter"] = "216mm 279mm"; + $size["Legal"] = "216mm 357mm"; + $size["Executive"] = "184mm 267mm"; + $size["B5"] = "182mm 257mm"; + $size["Folio"] = "216mm 330mm"; + $size["A0Oversize"] = "882mm 1247mm"; + $size["A0"] = "841mm 1189mm"; + $size["A1"] = "594mm 841mm"; + $size["A2"] = "420mm 594mm"; + $size["A3"] = "297mm 420mm"; + $size["A4"] = "210mm 297mm"; + $size["A5"] = "148mm 210mm"; + $size["A6"] = "105mm 148mm"; + $size["A7"] = "74mm 105mm"; + $size["A8"] = "52mm 74mm"; + $size["A9"] = "37mm 52mm"; + $size["A10"] = "26mm 37mm"; + $size["Screenshot640"] = "640mm 480mm"; + $size["Screenshot800"] = "800mm 600mm"; $size["Screenshot1024"] = "1024mm 768mm"; - $sizeLandscape["Letter"] = "279mm 216mm"; - $sizeLandscape["Legal"] = "357mm 216mm"; - $sizeLandscape["Executive"] = "267mm 184mm"; - $sizeLandscape["B5"] = "257mm 182mm"; - $sizeLandscape["Folio"] = "330mm 216mm"; - $sizeLandscape["A0Oversize"] = "1247mm 882mm"; - $sizeLandscape["A0"] = "1189mm 841mm"; - $sizeLandscape["A1"] = "841mm 594mm"; - $sizeLandscape["A2"] = "594mm 420mm"; - $sizeLandscape["A3"] = "420mm 297mm"; - $sizeLandscape["A4"] = "297mm 210mm"; - $sizeLandscape["A5"] = "210mm 148mm"; - $sizeLandscape["A6"] = "148mm 105mm"; - $sizeLandscape["A7"] = "105mm 74mm"; - $sizeLandscape["A8"] = "74mm 52mm"; - $sizeLandscape["A9"] = "52mm 37mm"; - $sizeLandscape["A10"] = "37mm 26mm"; - $sizeLandscape["Screenshot640"] = "480mm 640mm"; - $sizeLandscape["Screenshot800"] = "600mm 800mm"; + $sizeLandscape["Letter"] = "279mm 216mm"; + $sizeLandscape["Legal"] = "357mm 216mm"; + $sizeLandscape["Executive"] = "267mm 184mm"; + $sizeLandscape["B5"] = "257mm 182mm"; + $sizeLandscape["Folio"] = "330mm 216mm"; + $sizeLandscape["A0Oversize"] = "1247mm 882mm"; + $sizeLandscape["A0"] = "1189mm 841mm"; + $sizeLandscape["A1"] = "841mm 594mm"; + $sizeLandscape["A2"] = "594mm 420mm"; + $sizeLandscape["A3"] = "420mm 297mm"; + $sizeLandscape["A4"] = "297mm 210mm"; + $sizeLandscape["A5"] = "210mm 148mm"; + $sizeLandscape["A6"] = "148mm 105mm"; + $sizeLandscape["A7"] = "105mm 74mm"; + $sizeLandscape["A8"] = "74mm 52mm"; + $sizeLandscape["A9"] = "52mm 37mm"; + $sizeLandscape["A10"] = "37mm 26mm"; + $sizeLandscape["Screenshot640"] = "480mm 640mm"; + $sizeLandscape["Screenshot800"] = "600mm 800mm"; $sizeLandscape["Screenshot1024"] = "768mm 1024mm"; if (!isset($aProperties['media'])) { @@ -624,11 +591,11 @@ class OutputDocument extends BaseOutputDocument success = true; - $result->msg = G::LoadTranslation( 'ID_CASE_REACTIVATED_SUCCESSFULLY', SYS_LANG, "success" ); + $result->msg = G::LoadTranslation('ID_CASE_REACTIVATED_SUCCESSFULLY', SYS_LANG, "success"); } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); } } - public function dynaformViewFromHistory () + public function dynaformViewFromHistory() { ?> - AddContent( "dynaform", "xmlform", $_SESSION["PROCESS"] . "/" . $_POST["DYN_UID"], "", $Fields["APP_DATA"], "", "", "view" ); + $G_PUBLISH->AddContent("dynaform", "xmlform", $_SESSION["PROCESS"] . "/" . $_POST["DYN_UID"], "", $Fields["APP_DATA"], "", "", "view"); ?> existsTrigger(PM_GET_CASES_AJAX_LISTENER)) { $ajax = $pluginRegistry->executeTriggers(PM_GET_CASES_AJAX_LISTENER, null); } else { @@ -833,10 +830,11 @@ if (!($ajax instanceof Ajax)) { $ajax = new Ajax(); } -G::LoadClass( 'case' ); +G::LoadClass('case'); $action = $_REQUEST['action']; -unset( $_REQUEST['action'] ); +unset($_REQUEST['action']); + +$ajax->$action($_REQUEST); -$ajax->$action( $_REQUEST ); \ No newline at end of file diff --git a/workflow/engine/methods/processes/ajaxListener.php b/workflow/engine/methods/processes/ajaxListener.php index 4e8642f29..e90bd0dd7 100755 --- a/workflow/engine/methods/processes/ajaxListener.php +++ b/workflow/engine/methods/processes/ajaxListener.php @@ -1,4 +1,5 @@ * @date Jan 10th, 2010 */ - $action = $_REQUEST['action']; -unset( $_REQUEST['action'] ); +unset($_REQUEST['action']); $ajax = new Ajax(); -$ajax->$action( $_REQUEST ); +$ajax->$action($_REQUEST); class Ajax { - function categoriesList () + public function categoriesList() { require_once "classes/model/ProcessCategory.php"; $processCategory = new ProcessCategory(); - $defaultOption = Array (); - $defaultOption[] = Array ('CATEGORY_UID' => '','CATEGORY_NAME' => G::LoadTranslation( 'ID_ALL' ) - ); - $defaultOption[] = Array ('CATEGORY_UID' => '','CATEGORY_NAME' => G::LoadTranslation( 'ID_PROCESS_NO_CATEGORY' ) - ); + $defaultOption = Array(); + $defaultOption[] = Array('CATEGORY_UID' => '', 'CATEGORY_NAME' => G::LoadTranslation('ID_ALL')); + $defaultOption[] = Array('CATEGORY_UID' => '', 'CATEGORY_NAME' => G::LoadTranslation('ID_PROCESS_NO_CATEGORY')); - $response->rows = array_merge( $defaultOption, $processCategory->getAll( 'array' ) ); + $response->rows = array_merge($defaultOption, $processCategory->getAll('array')); - echo G::json_encode( $response ); + echo G::json_encode($response); } - function processCategories () + public function processCategories() { require_once "classes/model/ProcessCategory.php"; $processCategory = new ProcessCategory(); - $defaultOption = Array (); - $defaultOption[] = Array ('CATEGORY_UID' => '','CATEGORY_NAME' => G::LoadTranslation( 'ID_PROCESS_NO_CATEGORY' ) - ); + $defaultOption = Array(); + $defaultOption[] = Array('CATEGORY_UID' => '', 'CATEGORY_NAME' => G::LoadTranslation('ID_PROCESS_NO_CATEGORY')); - $response->rows = array_merge( $defaultOption, $processCategory->getAll( 'array' ) ); + $response->rows = array_merge($defaultOption, $processCategory->getAll('array')); - echo G::json_encode( $response ); + echo G::json_encode($response); } - function saveProcess () + public function saveProcess() { try { require_once 'classes/model/Task.php'; - G::LoadClass( 'processMap' ); + G::LoadClass('processMap'); $oProcessMap = new ProcessMap(); - if (! isset( $_POST['PRO_UID'] )) { + if (!isset($_POST['PRO_UID'])) { - if (Process::existsByProTitle( $_POST['PRO_TITLE'] )) { - $result = array ('success' => false,'msg' => 'Process Save Error','errors' => array ('PRO_TITLE' => G::LoadTranslation( 'ID_PROCESSTITLE_ALREADY_EXISTS', SYS_LANG, $_POST ) - ) + if (Process::existsByProTitle($_POST['PRO_TITLE'])) { + $result = array( + 'success' => false, + 'msg' => 'Process Save Error', + 'errors' => array('PRO_TITLE' => G::LoadTranslation('ID_PROCESSTITLE_ALREADY_EXISTS', SYS_LANG, $_POST)) ); - print G::json_encode( $result ); - exit( 0 ); + print G::json_encode($result); + exit(0); } $processData['USR_UID'] = $_SESSION['USER_LOGGED']; @@ -89,138 +87,135 @@ class Ajax $processData['PRO_DESCRIPTION'] = $_POST['PRO_DESCRIPTION']; $processData['PRO_CATEGORY'] = $_POST['PRO_CATEGORY']; - $sProUid = $oProcessMap->createProcess( $processData ); + $sProUid = $oProcessMap->createProcess($processData); //call plugins $oData['PRO_UID'] = $sProUid; - $oData['PRO_TEMPLATE'] = (isset( $_POST['PRO_TEMPLATE'] ) && $_POST['PRO_TEMPLATE'] != '') ? $_POST['form']['PRO_TEMPLATE'] : ''; + $oData['PRO_TEMPLATE'] = (isset($_POST['PRO_TEMPLATE']) && $_POST['PRO_TEMPLATE'] != '') ? $_POST['form']['PRO_TEMPLATE'] : ''; $oData['PROCESSMAP'] = $oProcessMap; $oPluginRegistry = & PMPluginRegistry::getSingleton(); - $oPluginRegistry->executeTriggers( PM_NEW_PROCESS_SAVE, $oData ); - + $oPluginRegistry->executeTriggers(PM_NEW_PROCESS_SAVE, $oData); } else { //$oProcessMap->updateProcess($_POST['form']); $sProUid = $_POST['PRO_UID']; } //Save Calendar ID for this process - if (isset( $_POST['PRO_CALENDAR'] )) { - G::LoadClass( "calendar" ); + if (isset($_POST['PRO_CALENDAR'])) { + G::LoadClass("calendar"); $calendarObj = new Calendar(); - $calendarObj->assignCalendarTo( $sProUid, $_POST['PRO_CALENDAR'], 'PROCESS' ); + $calendarObj->assignCalendarTo($sProUid, $_POST['PRO_CALENDAR'], 'PROCESS'); } $result->success = true; $result->PRO_UID = $sProUid; - $result->msg = G::LoadTranslation( 'ID_CREATE_PROCESS_SUCCESS' ); + $result->msg = G::LoadTranslation('ID_CREATE_PROCESS_SUCCESS'); } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); } - print G::json_encode( $result ); + print G::json_encode($result); } - function changeStatus () + public function changeStatus() { - $ids = explode( ',', $_REQUEST['UIDS'] ); + $ids = explode(',', $_REQUEST['UIDS']); - G::LoadClass( 'processes' ); + G::LoadClass('processes'); $oProcess = new Processes(); - if (count( $ids ) > 0) { - foreach ($ids as $id) - $oProcess->changeStatus( $id ); + if (count($ids) > 0) { + foreach ($ids as $id) { + $oProcess->changeStatus($id); + } } } - function changeDebugMode () + public function changeDebugMode() { - $ids = explode( ',', $_REQUEST['UIDS'] ); + $ids = explode(',', $_REQUEST['UIDS']); - G::LoadClass( 'processes' ); + G::LoadClass('processes'); $oProcess = new Processes(); - if (count( $ids ) > 0) { - foreach ($ids as $id) - $oProcess->changeDebugMode( $id ); + if (count($ids) > 0) { + foreach ($ids as $id) { + $oProcess->changeDebugMode($id); + } } } - function getUsers ($params) + public function getUsers($params) { require_once 'classes/model/Users.php'; - G::LoadClass( 'configuration' ); + G::LoadClass('configuration'); $conf = new Configurations(); - $search = isset( $params['search'] ) ? $params['search'] : null; - $users = Users::getAll( $params['start'], $params['limit'], $search ); + $search = isset($params['search']) ? $params['search'] : null; + $users = Users::getAll($params['start'], $params['limit'], $search); foreach ($users->data as $i => $user) { - $users->data[$i]['USER'] = $conf->getEnvSetting( 'format', Array ('userName' => $user['USR_USERNAME'],'firstName' => $user['USR_FIRSTNAME'],'lastName' => $user['USR_LASTNAME'] - ) ); + $users->data[$i]['USER'] = $conf->getEnvSetting('format', Array('userName' => $user['USR_USERNAME'], 'firstName' => $user['USR_FIRSTNAME'], 'lastName' => $user['USR_LASTNAME'])); } - print G::json_encode( $users ); + print G::json_encode($users); } - function getGroups ($params) + public function getGroups($params) { require_once 'classes/model/Groupwf.php'; - $search = isset( $params['search'] ) ? $params['search'] : null; - $groups = Groupwf::getAll( $params['start'], $params['limit'], $search ); + $search = isset($params['search']) ? $params['search'] : null; + $groups = Groupwf::getAll($params['start'], $params['limit'], $search); - print G::json_encode( $groups ); + print G::json_encode($groups); } - function assignUsersTask ($param) + public function assignUsersTask($param) { try { require_once 'classes/model/TaskUser.php'; require_once 'classes/model/Task.php'; $oTaskUser = new TaskUser(); - $UIDS = explode( ',', $param['UIDS'] ); + $UIDS = explode(',', $param['UIDS']); $TU_TYPE = 1; foreach ($UIDS as $UID) { - if ($_POST['TU_RELATION'] == 1) - $oTaskUser->create( array ('TAS_UID' => $param['TAS_UID'],'USR_UID' => $UID,'TU_TYPE' => $TU_TYPE,'TU_RELATION' => 1 - ) ); - else - $oTaskUser->create( array ('TAS_UID' => $param['TAS_UID'],'USR_UID' => $UID,'TU_TYPE' => $TU_TYPE,'TU_RELATION' => 2 - ) ); + if ($_POST['TU_RELATION'] == 1) { + $oTaskUser->create(array('TAS_UID' => $param['TAS_UID'], 'USR_UID' => $UID, 'TU_TYPE' => $TU_TYPE, 'TU_RELATION' => 1)); + } else { + $oTaskUser->create(array('TAS_UID' => $param['TAS_UID'], 'USR_UID' => $UID, 'TU_TYPE' => $TU_TYPE, 'TU_RELATION' => 2)); + } } - $task = TaskPeer::retrieveByPk( $param['TAS_UID'] ); + $task = TaskPeer::retrieveByPk($param['TAS_UID']); $result->success = true; - if (count( $UIDS ) > 1) - $result->msg = __( 'ID_ACTORS_ASSIGNED_SUCESSFULLY', SYS_LANG, Array (count( $UIDS ),$task->getTasTitle() - ) ); - else - $result->msg = __( 'ID_ACTOR_ASSIGNED_SUCESSFULLY', SYS_LANG, Array ('tas_title' => $task->getTasTitle() - ) ); + if (count($UIDS) > 1) { + $result->msg = __('ID_ACTORS_ASSIGNED_SUCESSFULLY', SYS_LANG, Array(count($UIDS), $task->getTasTitle())); + } else { + $result->msg = __('ID_ACTOR_ASSIGNED_SUCESSFULLY', SYS_LANG, Array('tas_title' => $task->getTasTitle())); + } } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); } - print G::json_encode( $result ); + print G::json_encode($result); } - function removeUsersTask ($param) + public function removeUsersTask($param) { try { require_once 'classes/model/TaskUser.php'; $oTaskUser = new TaskUser(); - $USR_UIDS = explode( ',', $param['USR_UID'] ); - $TU_RELATIONS = explode( ',', $param['TU_RELATION'] ); + $USR_UIDS = explode(',', $param['USR_UID']); + $TU_RELATIONS = explode(',', $param['TU_RELATION']); $TU_TYPE = 1; foreach ($USR_UIDS as $i => $USR_UID) { if ($TU_RELATIONS[$i] == 1) { - $oTaskUser->remove( $param['TAS_UID'], $USR_UID, $TU_TYPE, 1 ); - + $oTaskUser->remove($param['TAS_UID'], $USR_UID, $TU_TYPE, 1); } else { - $oTaskUser->remove( $param['TAS_UID'], $USR_UID, $TU_TYPE, 2 ); + $oTaskUser->remove($param['TAS_UID'], $USR_UID, $TU_TYPE, 2); } } @@ -231,19 +226,19 @@ class Ajax $result->msg = $e->getMessage(); } - print G::json_encode( $result ); + print G::json_encode($result); } - function getUsersTask ($param) + public function getUsersTask($param) { require_once 'classes/model/TaskUser.php'; - G::LoadClass( 'configuration' ); - $usersTaskList = Array (); + G::LoadClass('configuration'); + $usersTaskList = Array(); $task = new TaskUser(); $conf = new Configurations(); $TU_TYPE = 1; - $usersTask = $task->getUsersTask( $param['TAS_UID'], $TU_TYPE ); + $usersTask = $task->getUsersTask($param['TAS_UID'], $TU_TYPE); foreach ($usersTask->data as $userTask) { $usersTaskListItem['TAS_UID'] = $userTask['TAS_UID']; @@ -251,8 +246,9 @@ class Ajax $usersTaskListItem['USR_USERNAME'] = $userTask['USR_USERNAME']; $usersTaskListItem['USR_FIRSTNAME'] = $userTask['USR_FIRSTNAME']; $usersTaskListItem['USR_LASTNAME'] = $userTask['USR_LASTNAME']; - } else + } else { $usersTaskListItem['NAME'] = $userTask['GRP_TITLE']; + } $usersTaskListItem['TU_RELATION'] = $userTask['TU_RELATION']; $usersTaskListItem['USR_UID'] = $userTask['USR_UID']; @@ -263,33 +259,33 @@ class Ajax $result->data = $usersTaskList; $result->totalCount = $usersTask->totalCount; - print G::json_encode( $result ); + print G::json_encode($result); } - function getProcessDetail ($param) + public function getProcessDetail($param) { require_once 'classes/model/Process.php'; $PRO_UID = $param['PRO_UID']; - G::loadClass( 'tasks' ); + G::loadClass('tasks'); $tasks = new Tasks(); - $process = ProcessPeer::retrieveByPk( $PRO_UID ); + $process = ProcessPeer::retrieveByPk($PRO_UID); - $tasksList = $tasks->getAllTasks( $PRO_UID ); + $tasksList = $tasks->getAllTasks($PRO_UID); $rootNode->id = $process->getProUid(); $rootNode->type = 'process'; - $rootNode->typeLabel = G::LoadTranslation( 'ID_PROCESS' ); + $rootNode->typeLabel = G::LoadTranslation('ID_PROCESS'); $rootNode->text = $process->getProTitle(); - $rootNode->leaf = count( $tasksList ) > 0 ? false : true; + $rootNode->leaf = count($tasksList) > 0 ? false : true; $rootNode->iconCls = 'ss_sprite ss_application'; $rootNode->expanded = true; foreach ($tasksList as $task) { $node = new stdClass(); $node->id = $task['TAS_UID']; $node->type = 'task'; - $node->typeLabel = G::LoadTranslation( 'ID_TASK' ); + $node->typeLabel = G::LoadTranslation('ID_TASK'); $node->text = $task['TAS_TITLE']; $node->iconCls = 'ss_sprite ss_layout'; $node->leaf = true; @@ -297,23 +293,23 @@ class Ajax } $treeDetail[] = $rootNode; - print G::json_encode( $treeDetail ); + print G::json_encode($treeDetail); } - function getProperties ($param) + public function getProperties($param) { switch ($param['type']) { case 'process': require_once 'classes/model/ProcessCategory.php'; require_once 'classes/model/CalendarDefinition.php'; - G::LoadClass( 'processMap' ); - $oProcessMap = new processMap( new DBConnection() ); - $process = $oProcessMap->editProcessNew( $param['UID'] ); - $category = ProcessCategoryPeer::retrieveByPk( $process['PRO_CATEGORY'] ); - $categoryName = is_object( $category ) ? $category->getCategoryName() : ''; - $calendar = CalendarDefinitionPeer::retrieveByPk( $process['PRO_CALENDAR'] ); - $calendarName = is_object( $calendar ) ? $calendar->getCalendarName() : ''; + G::LoadClass('processMap'); + $oProcessMap = new processMap(new DBConnection()); + $process = $oProcessMap->editProcessNew($param['UID']); + $category = ProcessCategoryPeer::retrieveByPk($process['PRO_CATEGORY']); + $categoryName = is_object($category) ? $category->getCategoryName() : ''; + $calendar = CalendarDefinitionPeer::retrieveByPk($process['PRO_CALENDAR']); + $calendarName = is_object($calendar) ? $calendar->getCalendarName() : ''; $properties['Title'] = $process['PRO_TITLE']; $properties['Description'] = $process['PRO_DESCRIPTION']; @@ -324,11 +320,10 @@ class Ajax $result->sucess = true; $result->prop = $properties; break; - case 'task': require_once 'classes/model/Task.php'; $task = new Task(); - $taskData = $task->load( $param['UID'] ); + $taskData = $task->load($param['UID']); $properties['Title'] = $taskData['TAS_TITLE']; $properties['Description'] = $taskData['TAS_DESCRIPTION']; @@ -341,10 +336,10 @@ class Ajax break; } - print G::json_encode( $result ); + print G::json_encode($result); } - function saveProperties ($param) + public function saveProperties($param) { try { $result->sucess = true; @@ -354,7 +349,7 @@ class Ajax case 'process': require_once 'classes/model/ProcessCategory.php'; require_once 'classes/model/CalendarDefinition.php'; - G::LoadClass( 'processMap' ); + G::LoadClass('processMap'); $oProcessMap = new ProcessMap(); $process['PRO_UID'] = $param['UID']; @@ -371,25 +366,24 @@ class Ajax break; case 'Category': $fieldName = 'PRO_CATEGORY'; - $category = ProcessCategory::loadByCategoryName( $param['value'] ); + $category = ProcessCategory::loadByCategoryName($param['value']); $param['value'] = $category[0]['CATEGORY_UID']; break; case 'Calendar': $fieldName = 'PRO_CALENDAR'; - $calendar = CalendarDefinition::loadByCalendarName( $param['value'] ); + $calendar = CalendarDefinition::loadByCalendarName($param['value']); - G::LoadClass( "calendar" ); + G::LoadClass("calendar"); $calendarObj = new Calendar(); - $calendarObj->assignCalendarTo( $process['PRO_UID'], $calendar['CALENDAR_UID'], 'PROCESS' ); + $calendarObj->assignCalendarTo($process['PRO_UID'], $calendar['CALENDAR_UID'], 'PROCESS'); break; } if ($fieldName != 'PRO_CALENDAR') { $process[$fieldName] = $param['value']; - $oProcessMap->updateProcess( $process ); + $oProcessMap->updateProcess($process); } break; - case 'task': require_once 'classes/model/Task.php'; $oTask = new Task(); @@ -407,12 +401,12 @@ class Ajax break; case 'Starting Task': $fieldName = 'TAS_START'; - $param['value'] = strtoupper( $param['value'] ); + $param['value'] = strtoupper($param['value']); break; } $task[$fieldName] = $param['value']; - print_r( $task ); - $oTask->update( $task ); + print_r($task); + $oTask->update($task); break; } @@ -421,47 +415,43 @@ class Ajax $result->msg = $e->getMessage(); } - print G::json_encode( $result ); + print G::json_encode($result); } - function getCategoriesList () + public function getCategoriesList() { require_once "classes/model/ProcessCategory.php"; $processCategory = new ProcessCategory(); - $defaultOption = Array (); - $defaultOption[] = Array ('CATEGORY_UID' => '','CATEGORY_NAME' => '' - ); + $defaultOption = Array(); + $defaultOption[] = Array('CATEGORY_UID' => '', 'CATEGORY_NAME' => ''); - $response->rows = array_merge( $defaultOption, $processCategory->getAll( 'array' ) ); + $response->rows = array_merge($defaultOption, $processCategory->getAll('array')); - print G::json_encode( $response ); + print G::json_encode($response); } - function getCaledarList () + public function getCaledarList() { - G::LoadClass( 'calendar' ); + G::LoadClass('calendar'); $calendar = new CalendarDefinition(); - $calendarObj = $calendar->getCalendarList( true, true ); - $calendarObj['array'][0] = Array ('CALENDAR_UID' => '','CALENDAR_NAME' => '' - ); + $calendarObj = $calendar->getCalendarList(true, true); + $calendarObj['array'][0] = Array('CALENDAR_UID' => '', 'CALENDAR_NAME' => ''); $response->rows = $calendarObj['array']; - print G::json_encode( $response ); + print G::json_encode($response); } - function getPMVariables ($param) + public function getPMVariables($param) { - G::LoadClass( 'processMap' ); - $oProcessMap = new processMap( new DBConnection() ); - $response->rows = getDynaformsVars( $param['PRO_UID'] ); + G::LoadClass('processMap'); + $oProcessMap = new processMap(new DBConnection()); + $response->rows = getDynaformsVars($param['PRO_UID']); foreach ($response->rows as $i => $var) { $response->rows[$i]['sName'] = "@@{$var['sName']}"; } - print G::json_encode( $response ); + print G::json_encode($response); } - } - diff --git a/workflow/engine/methods/processes/processes_availableProcessesUser.php b/workflow/engine/methods/processes/processes_availableProcessesUser.php index 88df5999a..b9f9a297b 100755 --- a/workflow/engine/methods/processes/processes_availableProcessesUser.php +++ b/workflow/engine/methods/processes/processes_availableProcessesUser.php @@ -1,4 +1,5 @@ - * @Date 19/05/2008 - * @LastModification none - */ +/** + * @Description This is a callback for the View of all groups from a determinated user + * @author Everth S. Berrios Morales + * @Date 19/05/2008 + * @LastModification none + */ try { - $sProUid=$oData->PRO_UID; + $sProUid = $oData->PRO_UID; - require_once 'classes/model/Users.php'; - require_once 'classes/model/ProcessUser.php'; + require_once 'classes/model/Users.php'; + require_once 'classes/model/ProcessUser.php'; - G::LoadClass('processMap'); - $oProcessMap = new ProcessMap(); - $c = $oProcessMap->listNoProcessesUser($sProUid); - global $RBAC; - $RBAC->loadUserRolePermission($RBAC->sSystem, $_SESSION['USER_LOGGED']); - - $G_PUBLISH = new Publisher; - $G_PUBLISH->AddContent('propeltable', 'paged-table', 'processes/processes_availableProcessesUser', $c, array('PRO_UID' => $sProUid)); - G::RenderPage( 'publish', 'raw' ); + G::LoadClass('processMap'); + $oProcessMap = new ProcessMap(); + $c = $oProcessMap->listNoProcessesUser($sProUid); + global $RBAC; + $RBAC->loadUserRolePermission($RBAC->sSystem, $_SESSION['USER_LOGGED']); + $G_PUBLISH = new Publisher; + $G_PUBLISH->AddContent('propeltable', 'paged-table', 'processes/processes_availableProcessesUser', $c, array('PRO_UID' => $sProUid)); + G::RenderPage('publish', 'raw'); +} catch (Exception $e) { + $G_PUBLISH = new Publisher; + $aMessage['MESSAGE'] = $e->getMessage(); + $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage); + G::RenderPage('publish', 'raw'); } -catch ( Exception $e ){ - $G_PUBLISH = new Publisher; - $aMessage['MESSAGE'] = $e->getMessage(); - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); - G::RenderPage('publish', 'raw' ); -} -?> \ No newline at end of file + diff --git a/workflow/engine/methods/tools/ajaxListener.php b/workflow/engine/methods/tools/ajaxListener.php index 9c1c0fd9b..de1788c2c 100755 --- a/workflow/engine/methods/tools/ajaxListener.php +++ b/workflow/engine/methods/tools/ajaxListener.php @@ -1,4 +1,5 @@ * @date Jan 10th, 2010 */ - require "classes/model/Translation.php"; $action = $_REQUEST['action']; -unset( $_REQUEST['action'] ); +unset($_REQUEST['action']); $ajax = new Ajax(); -$ajax->$action( $_REQUEST ); +$ajax->$action($_REQUEST); class Ajax { - function getList ($params) + public function getList($params) { - $search = isset( $params['search'] ) ? $params['search'] : null; - $params['dateFrom'] = str_replace( 'T00:00:00', '', $params['dateFrom'] ); - $params['dateTo'] = str_replace( 'T00:00:00', '', $params['dateTo'] ); - $result = Translation::getAll( 'en', $params['start'], $params['limit'], $search, $params['dateFrom'], $params['dateTo'] ); + $search = isset($params['search']) ? $params['search'] : null; + $params['dateFrom'] = str_replace('T00:00:00', '', $params['dateFrom']); + $params['dateTo'] = str_replace('T00:00:00', '', $params['dateTo']); + $result = Translation::getAll('en', $params['start'], $params['limit'], $search, $params['dateFrom'], $params['dateTo']); //$result = Translation::getAll('en', $params['start'], $params['limit'], $search); - /*foreach($result->data as $i=>$row){ - $result->data[$i]['TRN_VALUE'] = substr($row['TRN_VALUE'], 0, 15) . '...'; - }*/ + /* foreach($result->data as $i=>$row){ + $result->data[$i]['TRN_VALUE'] = substr($row['TRN_VALUE'], 0, 15) . '...'; + } */ - echo G::json_encode( $result ); + echo G::json_encode($result); } - function save () + public function save() { try { require_once ("classes/model/Translation.php"); $id = $_POST['id']; - $label = preg_replace( "[\n|\r|\n\r]", ' ', $_POST['label'] ); + $label = preg_replace("[\n|\r|\n\r]", ' ', $_POST['label']); - $res = Translation::addTranslation( 'LABEL', $id, 'en', $label ); + $res = Translation::addTranslation('LABEL', $id, 'en', $label); if ($res['codError'] < 0) { $result->success = false; $result->msg = $res['message']; @@ -69,51 +68,48 @@ class Ajax $result->success = true; $result->msg = 'Label ' . $id . ' saved Successfully!'; } - } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); } - print G::json_encode( $result ); + print G::json_encode($result); } - function delete () + public function delete() { require_once ("classes/model/Translation.php"); - $ids = explode( ',', $_POST['IDS'] ); + $ids = explode(',', $_POST['IDS']); $category = 'LABEL'; try { foreach ($ids as $id) { - $tr = TranslationPeer::retrieveByPK( $category, $id, 'en' ); - if ((is_object( $tr ) && get_class( $tr ) == 'Translation')) { + $tr = TranslationPeer::retrieveByPK($category, $id, 'en'); + if ((is_object($tr) && get_class($tr) == 'Translation')) { $tr->delete(); } } $result->success = true; $result->msg = 'Deleted Successfully!'; - } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); } - print G::json_encode( $result ); + print G::json_encode($result); } - function rebuild () + public function rebuild() { try { require_once ("classes/model/Translation.php"); $t = new Translation(); - $result = Translation::generateFileTranslation( 'en' ); + $result = Translation::generateFileTranslation('en'); $result['success'] = true; - } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); } - print G::json_encode( $result ); + print G::json_encode($result); } } diff --git a/workflow/engine/methods/triggers/triggers_WizardSave.php b/workflow/engine/methods/triggers/triggers_WizardSave.php index cd8a84228..633cf33f6 100755 --- a/workflow/engine/methods/triggers/triggers_WizardSave.php +++ b/workflow/engine/methods/triggers/triggers_WizardSave.php @@ -1,4 +1,5 @@ userCanAccess( "PM_FACTORY" )) != 1) { +if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) { return $RBAC_Response; } require_once ('classes/model/Triggers.php'); $oTrigger = new Triggers(); -G::LoadClass( 'processMap' ); -$oProcessMap = new processMap( new DBConnection() ); +G::LoadClass('processMap'); +$oProcessMap = new processMap(new DBConnection()); $aDataTriggers = $_POST; -$aInfoFunction = explode( ",", $aDataTriggers['ALLFUNCTION'] ); -$aInfoFunctionType = explode( ",", $aDataTriggers['ALLFUNCTION_TYPE'] ); +$aInfoFunction = explode(",", $aDataTriggers['ALLFUNCTION']); +$aInfoFunctionType = explode(",", $aDataTriggers['ALLFUNCTION_TYPE']); $sPMfunction = " /*************************************************** @@ -42,75 +42,73 @@ $sPMfunction = " * Generated by ProcessMaker Trigger Wizard * Library: " . $aDataTriggers['LIBRARY_NAME'] . " * Method: " . $aDataTriggers['PMFUNTION_LABEL'] . " - * Date: " . date( "Y-m-d H:i:s" ) . " + * Date: " . date("Y-m-d H:i:s") . " * - * ProcessMaker " . date( "Y" ) . " + * ProcessMaker " . date("Y") . " * ****************************************************/ "; -$methodParamsFinal = array (); +$methodParamsFinal = array(); //Generate params to send $i = 0; foreach ($aInfoFunction as $k => $v) { if ($v != '') { - $sOptionTrigger = trim( str_replace( "$", "", $v ) ); - if (strstr( $sOptionTrigger, "=" )) { - $aOptionParameters = explode( "=", $sOptionTrigger ); - $sOptionTrigger = trim( $aOptionParameters[0] ); + $sOptionTrigger = trim(str_replace("$", "", $v)); + if (strstr($sOptionTrigger, "=")) { + $aOptionParameters = explode("=", $sOptionTrigger); + $sOptionTrigger = trim($aOptionParameters[0]); } if ($aDataTriggers[$sOptionTrigger] != '') { - if ((strstr( $aDataTriggers[$sOptionTrigger], "@@" ))) { - $option = trim( $aDataTriggers[$sOptionTrigger] ); + if ((strstr($aDataTriggers[$sOptionTrigger], "@@"))) { + $option = trim($aDataTriggers[$sOptionTrigger]); } else { - $aDataTriggers[$sOptionTrigger] = (strstr( $aDataTriggers[$sOptionTrigger], 'array' )) ? str_replace( "'", '"', $aDataTriggers[$sOptionTrigger] ) : str_replace( "'", "\'", $aDataTriggers[$sOptionTrigger] ); - switch(trim($aInfoFunctionType[$i])) { - case 'boolean' : - $option = $aDataTriggers[$sOptionTrigger]; - break; - case 'int' : - $option = intval($aDataTriggers[$sOptionTrigger]); - break; - case 'float' : - case 'real' : - case 'double' : - $option = floatval($aDataTriggers[$sOptionTrigger]); - break; - default: - $option = (is_numeric( $aDataTriggers[$sOptionTrigger] ) || is_bool($aDataTriggers[$sOptionTrigger]) ) ? trim( $aDataTriggers[$sOptionTrigger] ) : (strstr( $aDataTriggers[$sOptionTrigger], "array" )) ? trim( $aDataTriggers[$sOptionTrigger] ) : "'" . trim( $aDataTriggers[$sOptionTrigger] ) . "'"; - break; + $aDataTriggers[$sOptionTrigger] = (strstr($aDataTriggers[$sOptionTrigger], 'array')) ? str_replace("'", '"', $aDataTriggers[$sOptionTrigger]) : str_replace("'", "\'", $aDataTriggers[$sOptionTrigger]); + switch (trim($aInfoFunctionType[$i])) { + case 'boolean': + $option = $aDataTriggers[$sOptionTrigger]; + break; + case 'int': + $option = intval($aDataTriggers[$sOptionTrigger]); + break; + case 'float': + case 'real': + case 'double': + $option = floatval($aDataTriggers[$sOptionTrigger]); + break; + default: + $option = (is_numeric($aDataTriggers[$sOptionTrigger]) || is_bool($aDataTriggers[$sOptionTrigger]) ) ? trim($aDataTriggers[$sOptionTrigger]) : (strstr($aDataTriggers[$sOptionTrigger], "array")) ? trim($aDataTriggers[$sOptionTrigger]) : "'" . trim($aDataTriggers[$sOptionTrigger]) . "'"; + break; } - } } else { $option = "''"; } $methodParamsFinal[] = $option; - } - $i++; + $i++; } //G::pr($methodParamsFinal);die; -$sPMfunction .= (isset( $aDataTriggers['TRI_ANSWER'] ) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : ""; -$sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode( ",", $methodParamsFinal ) . ");"; +$sPMfunction .= (isset($aDataTriggers['TRI_ANSWER']) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : ""; +$sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode(",", $methodParamsFinal) . ");"; //Create Trigger $aDataTriggers['TRI_WEBBOT'] = $sPMfunction; -$aDataTriggersParams = array (); -$aDataTriggersParams['hash'] = md5( $sPMfunction ); +$aDataTriggersParams = array(); +$aDataTriggersParams['hash'] = md5($sPMfunction); $aDataTriggersParams['params'] = $aDataTriggers; -$aDataTriggers['TRI_PARAM'] = serialize( $aDataTriggersParams ); -$oTrigger->create( $aDataTriggers ); +$aDataTriggers['TRI_PARAM'] = serialize($aDataTriggersParams); +$oTrigger->create($aDataTriggers); //Update Info $aDataTriggers['TRI_UID'] = $oTrigger->getTriUid(); -$oTrigger->update( $aDataTriggers ); +$oTrigger->update($aDataTriggers); //Update Trigger Array -$oProcessMap->triggersList( $aDataTriggers['PRO_UID'] ); +$oProcessMap->triggersList($aDataTriggers['PRO_UID']); diff --git a/workflow/engine/methods/triggers/triggers_WizardUpdate.php b/workflow/engine/methods/triggers/triggers_WizardUpdate.php index 9eb20c0db..26b6738e9 100755 --- a/workflow/engine/methods/triggers/triggers_WizardUpdate.php +++ b/workflow/engine/methods/triggers/triggers_WizardUpdate.php @@ -1,4 +1,5 @@ userCanAccess( "PM_FACTORY" )) != 1) { +if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) { return $RBAC_Response; } -if (! class_exists( 'Triggers' )) { +if (!class_exists('Triggers')) { require_once ('classes/model/Triggers.php'); } $oTrigger = new Triggers(); -G::LoadClass( 'processMap' ); -$oProcessMap = new processMap( new DBConnection() ); +G::LoadClass('processMap'); +$oProcessMap = new processMap(new DBConnection()); $aDataTriggers = $_POST; $triUid = $_POST['TRI_UID']; -$aInfoFunction = explode( ",", $aDataTriggers['ALLFUNCTION'] ); -$aInfoFunctionType = explode( ",", $aDataTriggers['ALLFUNCTION_TYPE'] ); +$aInfoFunction = explode(",", $aDataTriggers['ALLFUNCTION']); +$aInfoFunctionType = explode(",", $aDataTriggers['ALLFUNCTION_TYPE']); $sPMfunction = " /*************************************************** * * Generated by ProcessMaker Trigger Wizard * Library: " . $aDataTriggers['LIBRARY_NAME'] . " * Method: " . $aDataTriggers['PMFUNTION_LABEL'] . " - * Date: " . date( "Y-m-d H:i:s" ) . " + * Date: " . date("Y-m-d H:i:s") . " * - * ProcessMaker " . date( "Y" ) . " + * ProcessMaker " . date("Y") . " * ****************************************************/ "; -$methodParamsFinal = array (); +$methodParamsFinal = array(); //Generate params to send $i = 0; foreach ($aInfoFunction as $k => $v) { if ($v != '') { - $sOptionTrigger = trim( str_replace( "$", "", $v ) ); - if (strstr( $sOptionTrigger, "=" )) { - $aOptionParameters = explode( "=", $sOptionTrigger ); - $sOptionTrigger = trim( $aOptionParameters[0] ); + $sOptionTrigger = trim(str_replace("$", "", $v)); + if (strstr($sOptionTrigger, "=")) { + $aOptionParameters = explode("=", $sOptionTrigger); + $sOptionTrigger = trim($aOptionParameters[0]); } if ($aDataTriggers[$sOptionTrigger] != '') { - if ((strstr( $aDataTriggers[$sOptionTrigger], "@@" ))) { + if ((strstr($aDataTriggers[$sOptionTrigger], "@@"))) { $option = $aDataTriggers[$sOptionTrigger]; } else { - $aDataTriggers[$sOptionTrigger] = (strstr( $aDataTriggers[$sOptionTrigger], 'array' )) ? str_replace( "'", '"', $aDataTriggers[$sOptionTrigger] ) : str_replace( "'", "\'", $aDataTriggers[$sOptionTrigger] ); - switch(trim($aInfoFunctionType[$i])) { - case 'boolean' : - $option = $aDataTriggers[$sOptionTrigger]; - break; - case 'int' : - $option = intval($aDataTriggers[$sOptionTrigger]); - break; - case 'float' : - case 'real' : - case 'double' : - $option = floatval($aDataTriggers[$sOptionTrigger]); - break; - default: - $option = (is_numeric( $aDataTriggers[$sOptionTrigger] ) || is_bool($aDataTriggers[$sOptionTrigger]) ) ? trim( $aDataTriggers[$sOptionTrigger] ) : (strstr( $aDataTriggers[$sOptionTrigger], "array" )) ? trim( $aDataTriggers[$sOptionTrigger] ) : "'" . trim( $aDataTriggers[$sOptionTrigger] ) . "'"; - break; + $aDataTriggers[$sOptionTrigger] = (strstr($aDataTriggers[$sOptionTrigger], 'array')) ? str_replace("'", '"', $aDataTriggers[$sOptionTrigger]) : str_replace("'", "\'", $aDataTriggers[$sOptionTrigger]); + switch (trim($aInfoFunctionType[$i])) { + case 'boolean': + $option = $aDataTriggers[$sOptionTrigger]; + break; + case 'int': + $option = intval($aDataTriggers[$sOptionTrigger]); + break; + case 'float': + case 'real': + case 'double': + $option = floatval($aDataTriggers[$sOptionTrigger]); + break; + default: + $option = (is_numeric($aDataTriggers[$sOptionTrigger]) || is_bool($aDataTriggers[$sOptionTrigger]) ) ? trim($aDataTriggers[$sOptionTrigger]) : (strstr($aDataTriggers[$sOptionTrigger], "array")) ? trim($aDataTriggers[$sOptionTrigger]) : "'" . trim($aDataTriggers[$sOptionTrigger]) . "'"; + break; } - } } else { $option = "' '"; } $methodParamsFinal[] = $option; - } - $i++; + $i++; } -$sPMfunction .= (isset( $aDataTriggers['TRI_ANSWER'] ) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : ""; -$sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode( ",", $methodParamsFinal ) . ");"; +$sPMfunction .= (isset($aDataTriggers['TRI_ANSWER']) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : ""; +$sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode(",", $methodParamsFinal) . ");"; //Create Trigger $aDataTriggers['TRI_WEBBOT'] = $sPMfunction; -$aDataTriggersParams = array (); -$aDataTriggersParams['hash'] = md5( $sPMfunction ); +$aDataTriggersParams = array(); +$aDataTriggersParams['hash'] = md5($sPMfunction); $aDataTriggersParams['params'] = $aDataTriggers; -$aDataTriggers['TRI_PARAM'] = serialize( $aDataTriggersParams ); +$aDataTriggers['TRI_PARAM'] = serialize($aDataTriggersParams); //$oTrigger->create ( $aDataTriggers ); -$aDataTriggerLoaded = $oTrigger->load( $triUid ); +$aDataTriggerLoaded = $oTrigger->load($triUid); //var_dump($aDataTriggerLoaded); //die; //Update Info $aDataTriggers['TRI_UID'] = $oTrigger->getTriUid(); -$oTrigger->update( $aDataTriggers ); +$oTrigger->update($aDataTriggers); //Update Trigger Array -$oProcessMap->triggersList( $aDataTriggers['PRO_UID'] ); +$oProcessMap->triggersList($aDataTriggers['PRO_UID']); diff --git a/workflow/engine/services/rest/crud/OutputDocument.php b/workflow/engine/services/rest/crud/OutputDocument.php index d65c49275..f29070f4d 100644 --- a/workflow/engine/services/rest/crud/OutputDocument.php +++ b/workflow/engine/services/rest/crud/OutputDocument.php @@ -2,6 +2,7 @@ class Services_Rest_OutputDocument { + /** * Implementation for 'GET' method for Rest API * @@ -10,7 +11,7 @@ class Services_Rest_OutputDocument * @return array $result Returns array within multiple records or a single record depending if * a single selection was requested passing id(s) as param */ - protected function get($outDocUid=null) + protected function get($outDocUid = null) { $result = array(); try { @@ -44,7 +45,7 @@ class Services_Rest_OutputDocument $criteria->addSelectColumn(OutputDocumentPeer::OUT_DOC_PDF_SECURITY_OPEN_PASSWORD); $criteria->addSelectColumn(OutputDocumentPeer::OUT_DOC_PDF_SECURITY_OWNER_PASSWORD); $criteria->addSelectColumn(OutputDocumentPeer::OUT_DOC_PDF_SECURITY_PERMISSIONS); - + $dataset = AppEventPeer::doSelectRS($criteria); $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); @@ -65,7 +66,7 @@ class Services_Rest_OutputDocument $paramValues .= "NULL"; } } - throw new RestException(417, "table OutputDocument ($paramValues)" ); + throw new RestException(417, "table OutputDocument ($paramValues)"); } } } catch (RestException $e) { @@ -76,6 +77,5 @@ class Services_Rest_OutputDocument return $result; } - - } +