From b7e254b425124fe763c16d24e5c70aabe4394a3e Mon Sep 17 00:00:00 2001 From: Hector Cortez Date: Thu, 14 Mar 2013 12:36:34 -0400 Subject: [PATCH] BUG 0000 Adjustment for the standardization of code. CODE_STYLE --- gulliver/system/class.i18n_po.php | 255 ++++---- gulliver/system/class.xmlDocument.php | 38 +- workflow/engine/classes/class.dates.php | 302 ++++----- .../methods/appFolder/appFolderSave.php | 86 ++- .../engine/methods/cases/ajaxListener.php | 600 +++++++++--------- .../engine/methods/processes/ajaxListener.php | 264 ++++---- .../engine/methods/tools/ajaxListener.php | 52 +- .../methods/triggers/triggers_WizardSave.php | 82 ++- .../triggers/triggers_WizardUpdate.php | 82 ++- 9 files changed, 864 insertions(+), 897 deletions(-) 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.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/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/methods/appFolder/appFolderSave.php b/workflow/engine/methods/appFolder/appFolderSave.php index 94e99c639..f4053ec9b 100755 --- a/workflow/engine/methods/appFolder/appFolderSave.php +++ b/workflow/engine/methods/appFolder/appFolderSave.php @@ -1,53 +1,49 @@ - setFolderUid( $FolderUid ); - $tr->setFolderParentUid( $FolderParentUid ); - $tr->setFolderName( $FolderName ); - $tr->setFolderCreateDate( $FolderCreateDate ); - $tr->setFolderUpdateDate( $FolderUpdateDate ); + //if exists the row in the database propel will update it, otherwise will insert. + $tr = AppFolderPeer::retrieveByPK($FolderUid); + if (!( is_object($tr) && get_class($tr) == 'AppFolder' )) { + $tr = new AppFolder(); + } + $tr->setFolderUid($FolderUid); + $tr->setFolderParentUid($FolderParentUid); + $tr->setFolderName($FolderName); + $tr->setFolderCreateDate($FolderCreateDate); + $tr->setFolderUpdateDate($FolderUpdateDate); - if ($tr->validate() ) { - // we save it, since we get no validation errors, or do whatever else you like. - $res = $tr->save(); - } - else { - // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $tr->getValidationFailures(); - foreach($validationFailuresArray as $objValidationFailure) { - $msg .= $objValidationFailure->getMessage() . "
"; - } - //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); - } + if ($tr->validate()) { + // we save it, since we get no validation errors, or do whatever else you like. + $res = $tr->save(); + } else { + // Something went wrong. We can now get the validationFailures and handle them. + $msg = ''; + $validationFailuresArray = $tr->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "
"; + } + //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); + } //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); - //to do: uniform coderror structures for all classes - - //if ( $res['codError'] < 0 ) { - // G::SendMessageText ( $res['message'] , 'error' ); - //} - G::Header('location: appFolderList'); - - } - catch ( Exception $e ) { + //if ( $res['codError'] < 0 ) { + // G::SendMessageText ( $res['message'] , 'error' ); + //} + G::Header('location: appFolderList'); +} catch (Exception $e) { $G_PUBLISH = new Publisher; $aMessage['MESSAGE'] = $e->getMessage(); - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); - G::RenderPage( 'publish', 'blank' ); - } - \ No newline at end of file + $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage); + G::RenderPage('publish', 'blank'); +} + \ No newline at end of file diff --git a/workflow/engine/methods/cases/ajaxListener.php b/workflow/engine/methods/cases/ajaxListener.php index 3cfcfd2dc..39c485986 100755 --- a/workflow/engine/methods/cases/ajaxListener.php +++ b/workflow/engine/methods/cases/ajaxListener.php @@ -27,7 +27,6 @@ * @author Erik Amaru Ortiz * @date Jan 3th, 2010 */ - //require_once 'classes/model/Application.php'; //require_once 'classes/model/Users.php'; //require_once 'classes/model/AppThread.php'; @@ -38,26 +37,26 @@ class Ajax { - public function getCaseMenu ($params) + public function getCaseMenu($params) { - G::LoadClass( "configuration" ); - G::LoadClass( "case" ); + G::LoadClass("configuration"); + G::LoadClass("case"); global $G_TMP_MENU; global $sStatus; $sStatus = $params['app_status']; $oCase = new Cases(); $conf = new Configurations(); $oMenu = new Menu(); - $oMenu->load( 'caseOptions' ); + $oMenu->load('caseOptions'); - $menuOptions = Array (); + $menuOptions = Array(); foreach ($oMenu->Options as $i => $action) { - $option = Array ('id' => $oMenu->Id[$i],'label' => $oMenu->Labels[$i],'action' => $action); + $option = Array('id' => $oMenu->Id[$i], 'label' => $oMenu->Labels[$i], 'action' => $action); switch ($option['id']) { case 'STEPS': - $option['options'] = Array (); + $option['options'] = Array(); break; case 'ACTIONS': $option['options'] = $this->getActionOptions(); @@ -69,20 +68,20 @@ class Ajax $menuOptions[] = $option; } - echo G::json_encode( $menuOptions ); + echo G::json_encode($menuOptions); } - public function steps () + public function steps() { - G::LoadClass( 'applications' ); + G::LoadClass('applications'); $applications = new Applications(); - $proUid = isset( $_SESSION['PROCESS'] ) ? $_SESSION['PROCESS'] : ''; - $tasUid = isset( $_SESSION['TASK'] ) ? $_SESSION['TASK'] : ''; - $appUid = isset( $_SESSION['APPLICATION'] ) ? $_SESSION['APPLICATION'] : ''; - $index = isset( $_SESSION['INDEX'] ) ? $_SESSION['INDEX'] : ''; - $steps = $applications->getSteps( $appUid, $index, $tasUid, $proUid ); - $list = array (); + $proUid = isset($_SESSION['PROCESS']) ? $_SESSION['PROCESS'] : ''; + $tasUid = isset($_SESSION['TASK']) ? $_SESSION['TASK'] : ''; + $appUid = isset($_SESSION['APPLICATION']) ? $_SESSION['APPLICATION'] : ''; + $index = isset($_SESSION['INDEX']) ? $_SESSION['INDEX'] : ''; + $steps = $applications->getSteps($appUid, $index, $tasUid, $proUid); + $list = array(); foreach ($steps as $step) { $item['id'] = $item['idtodraw'] = $step['id']; @@ -112,89 +111,89 @@ class Ajax $list[] = $item; } - echo G::json_encode( $list ); + echo G::json_encode($list); } - public function getInformationOptions () + public function getInformationOptions() { - $options = Array (); - $options[] = Array ('text' => G::LoadTranslation( 'ID_PROCESS_MAP' ),'fn' => 'processMap' ); - $options[] = Array ('text' => G::LoadTranslation( 'ID_PROCESS_INFORMATION' ),'fn' => 'processInformation'); - $options[] = Array ('text' => G::LoadTranslation( 'ID_TASK_INFORMATION' ),'fn' => 'taskInformation'); - $options[] = Array ('text' => G::LoadTranslation( 'ID_CASE_HISTORY' ),'fn' => 'caseHistory'); - $options[] = Array ('text' => G::LoadTranslation( 'ID_HISTORY_MESSAGE_CASE' ),'fn' => 'messageHistory'); - $options[] = Array ('text' => G::LoadTranslation( 'ID_DYNAFORMS' ),'fn' => 'dynaformHistory' ); - $options[] = Array ('text' => G::LoadTranslation( 'ID_UPLOADED_DOCUMENTS' ),'fn' => 'uploadedDocuments'); - $options[] = Array ('text' => G::LoadTranslation( 'ID_GENERATED_DOCUMENTS' ),'fn' => 'generatedDocuments'); + $options = Array(); + $options[] = Array('text' => G::LoadTranslation('ID_PROCESS_MAP'), 'fn' => 'processMap'); + $options[] = Array('text' => G::LoadTranslation('ID_PROCESS_INFORMATION'), 'fn' => 'processInformation'); + $options[] = Array('text' => G::LoadTranslation('ID_TASK_INFORMATION'), 'fn' => 'taskInformation'); + $options[] = Array('text' => G::LoadTranslation('ID_CASE_HISTORY'), 'fn' => 'caseHistory'); + $options[] = Array('text' => G::LoadTranslation('ID_HISTORY_MESSAGE_CASE'), 'fn' => 'messageHistory'); + $options[] = Array('text' => G::LoadTranslation('ID_DYNAFORMS'), 'fn' => 'dynaformHistory'); + $options[] = Array('text' => G::LoadTranslation('ID_UPLOADED_DOCUMENTS'), 'fn' => 'uploadedDocuments'); + $options[] = Array('text' => G::LoadTranslation('ID_GENERATED_DOCUMENTS'), 'fn' => 'generatedDocuments'); return $options; } - public function getActionOptions () + public function getActionOptions() { $APP_UID = $_SESSION['APPLICATION']; - $c = new Criteria( 'workflow' ); + $c = new Criteria('workflow'); $c->clearSelectColumns(); - $c->addSelectColumn( AppThreadPeer::APP_THREAD_PARENT ); - $c->add( AppThreadPeer::APP_UID, $APP_UID ); - $c->add( AppThreadPeer::APP_THREAD_STATUS, 'OPEN' ); - $cant = AppThreadPeer::doCount( $c ); + $c->addSelectColumn(AppThreadPeer::APP_THREAD_PARENT); + $c->add(AppThreadPeer::APP_UID, $APP_UID); + $c->add(AppThreadPeer::APP_THREAD_STATUS, 'OPEN'); + $cant = AppThreadPeer::doCount($c); $oCase = new Cases(); - $aFields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); + $aFields = $oCase->loadCase($_SESSION['APPLICATION'], $_SESSION['INDEX']); GLOBAL $RBAC; - $options = Array (); + $options = Array(); switch ($aFields['APP_STATUS']) { case 'DRAFT': - if (! AppDelay::isPaused( $_SESSION['APPLICATION'], $_SESSION['INDEX'] )) { - $options[] = Array ('text' => G::LoadTranslation( 'ID_PAUSED_CASE' ),'fn' => 'setUnpauseCaseDate'); + if (!AppDelay::isPaused($_SESSION['APPLICATION'], $_SESSION['INDEX'])) { + $options[] = Array('text' => G::LoadTranslation('ID_PAUSED_CASE'), 'fn' => 'setUnpauseCaseDate'); } else { - $options[] = Array ('text' => G::LoadTranslation( 'ID_UNPAUSE' ),'fn' => 'unpauseCase'); + $options[] = Array('text' => G::LoadTranslation('ID_UNPAUSE'), 'fn' => 'unpauseCase'); } - $options[] = Array ('text' => G::LoadTranslation( 'ID_DELETE' ),'fn' => 'deleteCase'); + $options[] = Array('text' => G::LoadTranslation('ID_DELETE'), 'fn' => 'deleteCase'); - if ($RBAC->userCanAccess( 'PM_REASSIGNCASE' ) == 1) { - $options[] = Array ('text' => G::LoadTranslation( 'ID_REASSIGN' ),'fn' => 'getUsersToReassign'); + if ($RBAC->userCanAccess('PM_REASSIGNCASE') == 1) { + $options[] = Array('text' => G::LoadTranslation('ID_REASSIGN'), 'fn' => 'getUsersToReassign'); } break; case 'TO_DO': - if (! AppDelay::isPaused( $_SESSION['APPLICATION'], $_SESSION['INDEX'] )) { - $options[] = Array ('text' => G::LoadTranslation( 'ID_PAUSED_CASE' ),'fn' => 'setUnpauseCaseDate'); + if (!AppDelay::isPaused($_SESSION['APPLICATION'], $_SESSION['INDEX'])) { + $options[] = Array('text' => G::LoadTranslation('ID_PAUSED_CASE'), 'fn' => 'setUnpauseCaseDate'); if ($cant == 1) { - if ($RBAC->userCanAccess( 'PM_CANCELCASE' ) == 1) { - $options[] = Array ('text' => G::LoadTranslation( 'ID_CANCEL' ),'fn' => 'cancelCase'); + if ($RBAC->userCanAccess('PM_CANCELCASE') == 1) { + $options[] = Array('text' => G::LoadTranslation('ID_CANCEL'), 'fn' => 'cancelCase'); } else { - $options[] = Array ('text' => G::LoadTranslation( 'ID_CANCEL' ),'fn' => 'cancelCase','hide' => 'hiden'); + $options[] = Array('text' => G::LoadTranslation('ID_CANCEL'), 'fn' => 'cancelCase', 'hide' => 'hiden'); } } } else { - $options[] = Array ('text' => G::LoadTranslation( 'ID_UNPAUSE' ),'fn' => 'unpauseCase'); + $options[] = Array('text' => G::LoadTranslation('ID_UNPAUSE'), 'fn' => 'unpauseCase'); } - if ($RBAC->userCanAccess( 'PM_REASSIGNCASE' ) == 1) { - $options[] = Array ('text' => G::LoadTranslation( 'ID_REASSIGN' ),'fn' => 'getUsersToReassign'); + if ($RBAC->userCanAccess('PM_REASSIGNCASE') == 1) { + $options[] = Array('text' => G::LoadTranslation('ID_REASSIGN'), 'fn' => 'getUsersToReassign'); } break; case 'CANCELLED': - $options[] = Array ('text' => G::LoadTranslation( 'ID_REACTIVATE' ),'fn' => 'reactivateCase'); + $options[] = Array('text' => G::LoadTranslation('ID_REACTIVATE'), 'fn' => 'reactivateCase'); break; } if ($_SESSION['TASK'] != '-1') { $oTask = new Task(); - $aTask = $oTask->load( $_SESSION['TASK'] ); + $aTask = $oTask->load($_SESSION['TASK']); if ($aTask['TAS_TYPE'] == 'ADHOC') { - $options[] = Array ('text' => G::LoadTranslation( 'ID_ADHOC_ASSIGNMENT' ),'fn' => 'adhocAssignmentUsers'); + $options[] = Array('text' => G::LoadTranslation('ID_ADHOC_ASSIGNMENT'), 'fn' => 'adhocAssignmentUsers'); } } return $options; } - public function processMap () + public function processMap() { global $G_PUBLISH; global $G_CONTENT; @@ -202,17 +201,17 @@ class Ajax global $G_TABLE; global $RBAC; - G::LoadClass( 'processMap' ); + G::LoadClass('processMap'); - $oTemplatePower = new TemplatePower( PATH_TPL . 'processes/processes_Map.html' ); + $oTemplatePower = new TemplatePower(PATH_TPL . 'processes/processes_Map.html'); $oTemplatePower->prepare(); $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower ); + $G_PUBLISH->AddContent('template', '', '', '', $oTemplatePower); $oHeadPublisher = & headPublisher::getSingleton(); //$oHeadPublisher->addScriptfile('/jscore/processmap/core/processmap.js'); - $oHeadPublisher->addScriptCode( ' - var maximunX = ' . processMap::getMaximunTaskX( $_SESSION['PROCESS'] ) . '; + $oHeadPublisher->addScriptCode(' + var maximunX = ' . processMap::getMaximunTaskX($_SESSION['PROCESS']) . '; window.onload = function(){ var pb=leimnud.dom.capture("tag.body 0"); Pm=new processmap(); @@ -290,146 +289,146 @@ class Ajax oLeyendsPanel.addContent(rpc.xmlhttp.responseText); }.extend(this); oRPC.make(); - }' ); + }'); - G::RenderPage( 'publish', 'blank' ); + G::RenderPage('publish', 'blank'); } - public function getProcessInformation () + public function getProcessInformation() { $process = new Process(); - $processData = $process->load( $_SESSION['PROCESS'] ); + $processData = $process->load($_SESSION['PROCESS']); require_once 'classes/model/Users.php'; $user = new Users(); try { - $userData = $user->load( $processData['PRO_CREATE_USER'] ); + $userData = $user->load($processData['PRO_CREATE_USER']); $processData['PRO_AUTHOR'] = $userData['USR_FIRSTNAME'] . ' ' . $userData['USR_LASTNAME']; } catch (Exception $oError) { $processData['PRO_AUTHOR'] = '(USER DELETED)'; } - $processData['PRO_CREATE_DATE'] = date( 'F j, Y', strtotime( $processData['PRO_CREATE_DATE'] ) ); + $processData['PRO_CREATE_DATE'] = date('F j, Y', strtotime($processData['PRO_CREATE_DATE'])); - print (G::json_encode( $processData )) ; + print (G::json_encode($processData)); } - public function getTaskInformation () + public function getTaskInformation() { $task = new Task(); if ($_SESSION['TASK'] == '-1') { $_SESSION['TASK'] = $_SESSION['CURRENT_TASK']; } - $taskData = $task->getDelegatedTaskData( $_SESSION['TASK'], $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); + $taskData = $task->getDelegatedTaskData($_SESSION['TASK'], $_SESSION['APPLICATION'], $_SESSION['INDEX']); - print (G::json_encode( $taskData )) ; + print (G::json_encode($taskData)); } - public function caseHistory () + public function caseHistory() { global $G_PUBLISH; - G::loadClass( 'configuration' ); + G::loadClass('configuration'); $oHeadPublisher = & headPublisher::getSingleton(); $conf = new Configurations(); - $oHeadPublisher->addExtJsScript( 'cases/caseHistory', true ); //adding a javascript file .js - $oHeadPublisher->addContent( 'cases/caseHistory' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); + $oHeadPublisher->addExtJsScript('cases/caseHistory', true); //adding a javascript file .js + $oHeadPublisher->addContent('cases/caseHistory'); //adding a html file .html. + $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber')); + G::RenderPage('publish', 'extJs'); } - public function messageHistory () + public function messageHistory() { global $G_PUBLISH; - G::loadClass( 'configuration' ); + G::loadClass('configuration'); $oHeadPublisher = & headPublisher::getSingleton(); $conf = new Configurations(); - $oHeadPublisher->addExtJsScript( 'cases/caseMessageHistory', true ); //adding a javascript file .js - $oHeadPublisher->addContent( 'cases/caseMessageHistory' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); + $oHeadPublisher->addExtJsScript('cases/caseMessageHistory', true); //adding a javascript file .js + $oHeadPublisher->addContent('cases/caseMessageHistory'); //adding a html file .html. + $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber')); + G::RenderPage('publish', 'extJs'); } - public function dynaformHistory () + public function dynaformHistory() { global $G_PUBLISH; - G::loadClass( 'configuration' ); + G::loadClass('configuration'); $oHeadPublisher = & headPublisher::getSingleton(); $conf = new Configurations(); - $oHeadPublisher->addExtJsScript( 'cases/caseHistoryDynaformPage', true ); //adding a javascript file .js - $oHeadPublisher->addContent( 'cases/caseHistoryDynaformPage' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); + $oHeadPublisher->addExtJsScript('cases/caseHistoryDynaformPage', true); //adding a javascript file .js + $oHeadPublisher->addContent('cases/caseHistoryDynaformPage'); //adding a html file .html. + $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber')); + G::RenderPage('publish', 'extJs'); } - public function uploadedDocuments () + public function uploadedDocuments() { global $G_PUBLISH; - G::loadClass( 'configuration' ); + G::loadClass('configuration'); $oHeadPublisher = & headPublisher::getSingleton(); $conf = new Configurations(); - $oHeadPublisher->addExtJsScript( 'cases/casesUploadedDocumentsPage', true ); //adding a javascript file .js - $oHeadPublisher->addContent( 'cases/casesUploadedDocumentsPage' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); + $oHeadPublisher->addExtJsScript('cases/casesUploadedDocumentsPage', true); //adding a javascript file .js + $oHeadPublisher->addContent('cases/casesUploadedDocumentsPage'); //adding a html file .html. + $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber')); + G::RenderPage('publish', 'extJs'); } - public function uploadedDocumentsSummary () + public function uploadedDocumentsSummary() { global $G_PUBLISH; - G::loadClass( 'configuration' ); + G::loadClass('configuration'); $oHeadPublisher = & headPublisher::getSingleton(); $conf = new Configurations(); - $oHeadPublisher->addExtJsScript( 'cases/casesUploadedDocumentsPage', true ); //adding a javascript file .js - $oHeadPublisher->addContent( 'cases/casesUploadedDocumentsPage' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); + $oHeadPublisher->addExtJsScript('cases/casesUploadedDocumentsPage', true); //adding a javascript file .js + $oHeadPublisher->addContent('cases/casesUploadedDocumentsPage'); //adding a html file .html. + $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber')); + G::RenderPage('publish', 'extJs'); } - public function generatedDocuments () + public function generatedDocuments() { global $G_PUBLISH; - G::loadClass( 'configuration' ); + G::loadClass('configuration'); $oHeadPublisher = & headPublisher::getSingleton(); $conf = new Configurations(); - $oHeadPublisher->addExtJsScript( 'cases/casesGenerateDocumentPage', true ); //adding a javascript file .js - $oHeadPublisher->addContent( 'cases/casesGenerateDocumentPage' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); + $oHeadPublisher->addExtJsScript('cases/casesGenerateDocumentPage', true); //adding a javascript file .js + $oHeadPublisher->addContent('cases/casesGenerateDocumentPage'); //adding a html file .html. + $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber')); + G::RenderPage('publish', 'extJs'); } - public function generatedDocumentsSummary () + public function generatedDocumentsSummary() { global $G_PUBLISH; - G::loadClass( 'configuration' ); + G::loadClass('configuration'); $oHeadPublisher = & headPublisher::getSingleton(); $conf = new Configurations(); - $oHeadPublisher->addExtJsScript( 'cases/casesGenerateDocumentPage', true ); //adding a javascript file .js - $oHeadPublisher->addContent( 'cases/casesGenerateDocumentPage' ); //adding a html file .html. - $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber' ) ); - G::RenderPage( 'publish', 'extJs' ); + $oHeadPublisher->addExtJsScript('cases/casesGenerateDocumentPage', true); //adding a javascript file .js + $oHeadPublisher->addContent('cases/casesGenerateDocumentPage'); //adding a html file .html. + $oHeadPublisher->assign('pageSize', $conf->getEnvSetting('casesListRowNumber')); + G::RenderPage('publish', 'extJs'); } - public function cancelCase () + public function cancelCase() { $oCase = new Cases(); $multiple = false; - if (isset( $_POST['APP_UID'] ) && isset( $_POST['DEL_INDEX'] )) { + if (isset($_POST['APP_UID']) && isset($_POST['DEL_INDEX'])) { $APP_UID = $_POST['APP_UID']; $DEL_INDEX = $_POST['DEL_INDEX']; - $appUids = explode( ',', $APP_UID ); - $delIndexes = explode( ',', $DEL_INDEX ); - if (count( $appUids ) > 1 && count( $delIndexes ) > 1) { + $appUids = explode(',', $APP_UID); + $delIndexes = explode(',', $DEL_INDEX); + if (count($appUids) > 1 && count($delIndexes) > 1) { $multiple = true; } - } elseif (isset( $_POST['sApplicationUID'] ) && isset( $_POST['iIndex'] )) { + } elseif (isset($_POST['sApplicationUID']) && isset($_POST['iIndex'])) { $APP_UID = $_POST['sApplicationUID']; $DEL_INDEX = $_POST['iIndex']; } else { @@ -441,31 +440,30 @@ class Ajax if ($_POST['NOTE_REASON'] != '') { require_once ("classes/model/AppNotes.php"); $appNotes = new AppNotes(); - $noteContent = addslashes( $_POST['NOTE_REASON'] ); - $appNotes->postNewNote( $APP_UID, $_SESSION['USER_LOGGED'], $noteContent, $_POST['NOTIFY_PAUSE'] ); + $noteContent = addslashes($_POST['NOTE_REASON']); + $appNotes->postNewNote($APP_UID, $_SESSION['USER_LOGGED'], $noteContent, $_POST['NOTIFY_PAUSE']); } // End save if ($multiple) { foreach ($appUids as $i => $appUid) { - $oCase->cancelCase( $appUid, $delIndexes[$i], $_SESSION['USER_LOGGED'] ); + $oCase->cancelCase($appUid, $delIndexes[$i], $_SESSION['USER_LOGGED']); } } else { - $oCase->cancelCase( $APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED'] ); + $oCase->cancelCase($APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED']); } } - public function getUsersToReassign () + public function getUsersToReassign() { $case = new Cases(); - $result->data = $case->getUsersToReassign( $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ); - - print G::json_encode( $result ); + $result->data = $case->getUsersToReassign($_SESSION['TASK'], $_SESSION['USER_LOGGED']); + print G::json_encode($result); } - public function reassignCase () + public function reassignCase() { $cases = new Cases(); $user = new Users(); @@ -473,31 +471,31 @@ class Ajax $TO_USR_UID = $_POST['USR_UID']; try { - $cases->reassignCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], $TO_USR_UID ); - $caseData = $app->load( $_SESSION['APPLICATION'] ); - $userData = $user->load( $TO_USR_UID ); + $cases->reassignCase($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], $TO_USR_UID); + $caseData = $app->load($_SESSION['APPLICATION']); + $userData = $user->load($TO_USR_UID); //print_r($caseData); $data['APP_NUMBER'] = $caseData['APP_NUMBER']; $data['USER'] = $userData['USR_LASTNAME'] . ' ' . $userData['USR_FIRSTNAME']; //TODO change with the farmated username from environment conf $result->status = 0; - $result->msg = G::LoadTranslation( 'ID_REASSIGNMENT_SUCCESS', SYS_LANG, $data ); + $result->msg = G::LoadTranslation('ID_REASSIGNMENT_SUCCESS', SYS_LANG, $data); } catch (Exception $e) { $result->status = 1; $result->msg = $e->getMessage(); } - print G::json_encode( $result ); + print G::json_encode($result); } - public function pauseCase () + public function pauseCase() { try { $unpauseDate = $_REQUEST['unpauseDate']; $oCase = new Cases(); - if (isset( $_POST['APP_UID'] ) && isset( $_POST['DEL_INDEX'] )) { + if (isset($_POST['APP_UID']) && isset($_POST['DEL_INDEX'])) { $APP_UID = $_POST['APP_UID']; $DEL_INDEX = $_POST['DEL_INDEX']; - } elseif (isset( $_POST['sApplicationUID'] ) && isset( $_POST['iIndex'] )) { + } elseif (isset($_POST['sApplicationUID']) && isset($_POST['iIndex'])) { $APP_UID = $_POST['sApplicationUID']; $DEL_INDEX = $_POST['iIndex']; } else { @@ -509,92 +507,92 @@ class Ajax if ($_REQUEST['NOTE_REASON'] != '') { require_once ("classes/model/AppNotes.php"); $appNotes = new AppNotes(); - $noteContent = addslashes( $_REQUEST['NOTE_REASON'] ); - $appNotes->postNewNote( $APP_UID, $_SESSION['USER_LOGGED'], $noteContent, $_REQUEST['NOTIFY_PAUSE'] ); + $noteContent = addslashes($_REQUEST['NOTE_REASON']); + $appNotes->postNewNote($APP_UID, $_SESSION['USER_LOGGED'], $noteContent, $_REQUEST['NOTIFY_PAUSE']); } // End save - $oCase->pauseCase( $APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED'], $unpauseDate ); + $oCase->pauseCase($APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED'], $unpauseDate); $app = new Application(); - $caseData = $app->load( $APP_UID ); + $caseData = $app->load($APP_UID); $data['APP_NUMBER'] = $caseData['APP_NUMBER']; $data['UNPAUSE_DATE'] = $unpauseDate; $result->success = true; - $result->msg = G::LoadTranslation( 'ID_CASE_PAUSED_SUCCESSFULLY', SYS_LANG, $data ); + $result->msg = G::LoadTranslation('ID_CASE_PAUSED_SUCCESSFULLY', SYS_LANG, $data); } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); } - echo G::json_encode( $result ); + echo G::json_encode($result); } - public function unpauseCase () + public function unpauseCase() { try { - $applicationUID = (isset( $_POST['APP_UID'] )) ? $_POST['APP_UID'] : $_SESSION['APPLICATION']; - $delIndex = (isset( $_POST['DEL_INDEX'] )) ? $_POST['DEL_INDEX'] : $_SESSION['INDEX']; + $applicationUID = (isset($_POST['APP_UID'])) ? $_POST['APP_UID'] : $_SESSION['APPLICATION']; + $delIndex = (isset($_POST['DEL_INDEX'])) ? $_POST['DEL_INDEX'] : $_SESSION['INDEX']; $oCase = new Cases(); - $oCase->unpauseCase( $applicationUID, $delIndex, $_SESSION['USER_LOGGED'] ); + $oCase->unpauseCase($applicationUID, $delIndex, $_SESSION['USER_LOGGED']); $app = new Application(); - $caseData = $app->load( $applicationUID ); + $caseData = $app->load($applicationUID); $data['APP_NUMBER'] = $caseData['APP_NUMBER']; $result->success = true; - $result->msg = G::LoadTranslation( 'ID_CASE_UNPAUSED_SUCCESSFULLY', SYS_LANG, $data ); + $result->msg = G::LoadTranslation('ID_CASE_UNPAUSED_SUCCESSFULLY', SYS_LANG, $data); } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); } - print G::json_encode( $result ); + print G::json_encode($result); } - public function deleteCase () + public function deleteCase() { try { - $applicationUID = (isset( $_POST['APP_UID'] )) ? $_POST['APP_UID'] : $_SESSION['APPLICATION']; + $applicationUID = (isset($_POST['APP_UID'])) ? $_POST['APP_UID'] : $_SESSION['APPLICATION']; $app = new Application(); - $caseData = $app->load( $applicationUID ); + $caseData = $app->load($applicationUID); $data['APP_NUMBER'] = $caseData['APP_NUMBER']; $oCase = new Cases(); - $oCase->removeCase( $applicationUID ); + $oCase->removeCase($applicationUID); $result->success = true; - $result->msg = G::LoadTranslation( 'ID_CASE_DELETED_SUCCESSFULLY', SYS_LANG, $data ); + $result->msg = G::LoadTranslation('ID_CASE_DELETED_SUCCESSFULLY', SYS_LANG, $data); } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); } - print G::json_encode( $result ); + print G::json_encode($result); } - public function reactivateCase () + public function reactivateCase() { try { - $applicationUID = (isset( $_POST['APP_UID'] )) ? $_POST['APP_UID'] : $_SESSION['APPLICATION']; - $delIndex = (isset( $_POST['DEL_INDEX'] )) ? $_POST['DEL_INDEX'] : $_SESSION['INDEX']; + $applicationUID = (isset($_POST['APP_UID'])) ? $_POST['APP_UID'] : $_SESSION['APPLICATION']; + $delIndex = (isset($_POST['DEL_INDEX'])) ? $_POST['DEL_INDEX'] : $_SESSION['INDEX']; $app = new Application(); - $caseData = $app->load( $applicationUID ); + $caseData = $app->load($applicationUID); $data['APP_NUMBER'] = $caseData['APP_NUMBER']; $oCase = new Cases(); - $oCase->reactivateCase( $applicationUID, $delIndex, $_SESSION['USER_LOGGED'] ); + $oCase->reactivateCase($applicationUID, $delIndex, $_SESSION['USER_LOGGED']); $result->success = true; - $result->msg = G::LoadTranslation( 'ID_CASE_REACTIVATED_SUCCESSFULLY', SYS_LANG, $data ); + $result->msg = G::LoadTranslation('ID_CASE_REACTIVATED_SUCCESSFULLY', SYS_LANG, $data); } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); } - print G::json_encode( $result ); + print G::json_encode($result); } - public function changeLogTab () + public function changeLogTab() { try { global $G_PUBLISH; @@ -603,169 +601,168 @@ class Ajax //!dataInput $idHistory = $_REQUEST["idHistory"]; //!dataInput - - //!dataSytem - $idHistoryArray = explode( "_", $idHistory ); + $idHistoryArray = explode("_", $idHistory); $_REQUEST["PRO_UID"] = $idHistoryArray[0]; $_REQUEST["APP_UID"] = $idHistoryArray[1]; $_REQUEST["TAS_UID"] = $idHistoryArray[2]; $_REQUEST["DYN_UID"] = ""; $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'view', 'cases/cases_DynaformHistory' ); + $G_PUBLISH->AddContent('view', 'cases/cases_DynaformHistory'); ?> 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/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']);