masterdetail[$i]]="novaluehere";
- }
- $rowName=array();
- foreach($breakField as $key => $value){
- if($value!="novaluehere"){
- $rowName[$key]=$key."_".$value;
- }
- }
- $this->tpl->assign( "masterRowName" , implode(",",$rowName));
- $this->tpl->assign( 'pagedTable_Name' , $this->name );
- $many="";
- $this->tpl->assign( "value1" ,str_pad($many, count($rowName)-1 , "-") );
- $this->tpl->gotoblock("rowMaster");
- $this->tpl->assign( "masterRowName" , "_MD_".implode(",",$rowName));
- $this->tpl->assign( "masterRowClass" , $keyMasterDetail==0?"masterDetailMain":"masterDetailOther");
+ $gridRows = 0;
+ $rs->next();
+ //Initialize the array of breakFields for Master Detail View
+ foreach ($this->masterdetail as $keyMasterDetail => $fieldMasterDetail) {
+ $breakField[$fieldMasterDetail] = "novaluehere";
}
- }
- $this->tpl->gotoblock("row");
- if ( !isset($rowName) ) $rowName = array();
- $this->tpl->assign( "rowName" , implode(",",$rowName));
- }
- //End Master Detail: This enable the MasterDEtail view
- //Merge $result with $xmlForm values (for default valuesSettings)
- if ( is_array ( $this->xmlForm->values ) )
- $result = array_merge($this->xmlForm->values, $result);
- foreach($this->fields as $r => $rval){
- if (strcasecmp($this->fields[$r]['Type'],'cellMark')==0){
- $result1 = $result;
- $result1['row__'] = $j+1;
- $result1 = array_merge($this->xmlForm->values, $result1);
- $this->xmlForm->setDefaultValues();
- $this->xmlForm->setValues( $result1 );
- $this->tdStyle = $this->xmlForm->fields[ $this->fields[$r]['Name'] ]->tdStyle( $result1 , $this->xmlForm );
- $this->tdClass = $this->xmlForm->fields[ $this->fields[$r]['Name'] ]->tdClass( $result1 , $this->xmlForm );
- }
- elseif ($this->style[$r]['showInTable'] != '0' ){
- if (($this->style[$r]['showInTable'] != '0' )&&(!(in_array($this->fields[$r]['Name'],$this->masterdetail))))
- $this->renderField($j+1,$r,$result);
- }
- }
- }
- $this->tpl->assign('_ROOT.gridRows','='. $gridRows); //number of rows in the current page
- $this->tpl->newBlock('rowTag');
- $this->tpl->assign('rowId','insertAtLast');
- if( $this->currentPage > 1 ) {
- $firstUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=1';
- $firstAjax = $this->id . ".doGoToPage(1);return false;";
- $prevpage = $this->currentPage - 1;
- $prevUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=' . $prevpage;
- $prevAjax = $this->id . ".doGoToPage(".$prevpage.");return false;";
- $first = " ";
- $prev = " ";
- }
- else{
- $first = " ";
- $prev = " ";
- }
- if( $this->currentPage < $this->totPages ) {
- $lastUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=' . $this->totPages;
- $lastAjax = $this->id . ".doGoToPage(" .$this->totPages.");return false;";
- $nextpage = $this->currentPage + 1;
- $nextUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=' . $nextpage;
- $nextAjax = $this->id . ".doGoToPage(" .$nextpage.");return false;";
- $next = " ";
- $last = " ";
- }
- else{
- $next = " ";
- $last = " ";
- }
- $pagesEnum='';
- for ($r=1;$r<=$this->totPages;$r++)
- if (($r>=($this->currentPage-5))&&($r<=($this->currentPage+5))){
- $pageAjax = $this->id . ".doGoToPage(" .$r.");return false;";
- if ($r!=$this->currentPage)
- $pagesEnum.=" ownerPage . '?order=' . $this->orderBy . '&page=' . $r , ENT_QUOTES , 'utf-8' ) . "\" onclick=\"".$pageAjax."\">".$r."";
- else
- $pagesEnum.=" ".$r."";
- }
- if ($this->totRows === 0) {
- $this->tpl->newBlock( 'norecords' );
- $this->tpl->assign( "columnCount", $this->colCount);
- $noRecordsFound='ID_NO_RECORDS_FOUND';
- if (G::LoadTranslation($noRecordsFound)) $noRecordsFound = G::LoadTranslation($noRecordsFound);
- $this->tpl->assign( "noRecordsFound", $noRecordsFound);
- }
- if (!$this->disableFooter) {
- $this->tpl->newBlock( "bottomFooter" );
- $this->tpl->assign( "columnCount", $this->colCount);
- $this->tpl->assign( "pagedTableId" , $this->id );
- if (($this->totRows !== 0)) {
- if ($this->totPages>1){
- $this->tpl->assign( "first" , $first );
- $this->tpl->assign( "prev" , $prev );
- $this->tpl->assign( "next" , $next );
- $this->tpl->assign( "last" , $last );
- }
- $this->tpl->assign( "currentPage" , $this->currentPage );
- $this->tpl->assign( "totalPages" , $this->totPages );
- $firstRow = ($this->currentPage-1) * $this->rowsPerPage+1;
- $lastRow = $firstRow+$rs->getRecordCount()-1;
- $this->tpl->assign( "firstRow" , $firstRow );
- $this->tpl->assign( "lastRow" , $lastRow );
- $this->tpl->assign( "totalRows" , $this->totRows );
- } else {
- $this->tpl->assign( "indexStyle", 'visibility:hidden;');
- }
- if ($this->searchBy) {
- $this->tpl->assign( "fastSearchValue" , $this->fastSearch );
- } else {
- $this->tpl->assign( "fastSearchStyle" , 'visibility:hidden;' );
- }
- if ($this->addRow)
- if($this->sqlInsert!='')
- $this->tpl->assign( "insert" , ''./*G::LoadXml('labels','ID_ADD_NEW')*/ 'ID_ADD_NEW' .'' );
- $this->tpl->assign("pagesEnum", $pagesEnum);
- }
-?>
+ $breakFieldKeys = array_flip( $this->masterdetail );
+ for ($j = 0; $j < $rs->getRecordCount(); $j ++) {
+ $result = $rs->getRow();
+ $rs->next();
+ $gridRows ++;
+ $this->tpl->newBlock( "row" );
+ $this->tpl->assign( "class", "Row" . (($j % 2) + 1) );
+ $this->tdStyle = '';
+ $this->tdClass = '';
+ //Start Master Detail: This enable the MasterDEtail view. By JHL November 2008
+ if (count( $this->masterdetail ) > 0) {
+ //TODO: Validate if there is a Field that doesn't exist
+ //TODO: Style
+ //TODO: Improve Collapse function....
+ foreach ($this->masterdetail as $keyMasterDetail => $fieldMasterDetail) {
+ if ($breakField[$fieldMasterDetail] != $result[$fieldMasterDetail]) {
+ $this->tpl->newBlock( "rowMaster" );
+ $this->tpl->newBlock( "fieldMaster" );
+ $this->tpl->assign( "alignAttr", " colspan=" . (count( $this->fields ) * 2) );
+ $this->tpl->assign( "value", $this->fields[$fieldMasterDetail]['Label'] == "" ? "" : $this->fields[$fieldMasterDetail]['Label'] . ": " . $this->xmlForm->fields[$fieldMasterDetail]->renderTable( $result[$fieldMasterDetail], $this->xmlForm, true ) );
+ $breakField[$fieldMasterDetail] = $result[$fieldMasterDetail];
+ for ($i = $breakFieldKeys[$fieldMasterDetail] + 1; $i < count( $breakField ); $i ++) {
+ $breakField[$this->masterdetail[$i]] = "novaluehere";
+ }
+ $rowName = array ();
+ foreach ($breakField as $key => $value) {
+ if ($value != "novaluehere") {
+ $rowName[$key] = $key . "_" . $value;
+ }
+ }
+ $this->tpl->assign( "masterRowName", implode( ",", $rowName ) );
+ $this->tpl->assign( 'pagedTable_Name', $this->name );
+ $many = "";
+ $this->tpl->assign( "value1", str_pad( $many, count( $rowName ) - 1, "-" ) );
+ $this->tpl->gotoblock( "rowMaster" );
+ $this->tpl->assign( "masterRowName", "_MD_" . implode( ",", $rowName ) );
+ $this->tpl->assign( "masterRowClass", $keyMasterDetail == 0 ? "masterDetailMain" : "masterDetailOther" );
+ }
+ }
+ $this->tpl->gotoblock( "row" );
+ if (! isset( $rowName ))
+ $rowName = array ();
+ $this->tpl->assign( "rowName", implode( ",", $rowName ) );
+ }
+ //End Master Detail: This enable the MasterDEtail view
+ //Merge $result with $xmlForm values (for default valuesSettings)
+ if (is_array( $this->xmlForm->values ))
+ $result = array_merge( $this->xmlForm->values, $result );
+ foreach ($this->fields as $r => $rval) {
+ if (strcasecmp( $this->fields[$r]['Type'], 'cellMark' ) == 0) {
+ $result1 = $result;
+ $result1['row__'] = $j + 1;
+ $result1 = array_merge( $this->xmlForm->values, $result1 );
+ $this->xmlForm->setDefaultValues();
+ $this->xmlForm->setValues( $result1 );
+ $this->tdStyle = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdStyle( $result1, $this->xmlForm );
+ $this->tdClass = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdClass( $result1, $this->xmlForm );
+ } elseif ($this->style[$r]['showInTable'] != '0') {
+ if (($this->style[$r]['showInTable'] != '0') && (! (in_array( $this->fields[$r]['Name'], $this->masterdetail ))))
+ $this->renderField( $j + 1, $r, $result );
+ }
+ }
+ }
+ $this->tpl->assign( '_ROOT.gridRows', '=' . $gridRows ); //number of rows in the current page
+ $this->tpl->newBlock( 'rowTag' );
+ $this->tpl->assign( 'rowId', 'insertAtLast' );
+ if ($this->currentPage > 1) {
+ $firstUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=1';
+ $firstAjax = $this->id . ".doGoToPage(1);return false;";
+ $prevpage = $this->currentPage - 1;
+ $prevUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=' . $prevpage;
+ $prevAjax = $this->id . ".doGoToPage(" . $prevpage . ");return false;";
+ $first = " ";
+ $prev = " ";
+ } else {
+ $first = " ";
+ $prev = " ";
+ }
+ if ($this->currentPage < $this->totPages) {
+ $lastUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=' . $this->totPages;
+ $lastAjax = $this->id . ".doGoToPage(" . $this->totPages . ");return false;";
+ $nextpage = $this->currentPage + 1;
+ $nextUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=' . $nextpage;
+ $nextAjax = $this->id . ".doGoToPage(" . $nextpage . ");return false;";
+ $next = " ";
+ $last = " ";
+ } else {
+ $next = " ";
+ $last = " ";
+ }
+ $pagesEnum = '';
+ for ($r = 1; $r <= $this->totPages; $r ++)
+ if (($r >= ($this->currentPage - 5)) && ($r <= ($this->currentPage + 5))) {
+ $pageAjax = $this->id . ".doGoToPage(" . $r . ");return false;";
+ if ($r != $this->currentPage)
+ $pagesEnum .= " ownerPage . '?order=' . $this->orderBy . '&page=' . $r, ENT_QUOTES, 'utf-8' ) . "\" onclick=\"" . $pageAjax . "\">" . $r . "";
+ else
+ $pagesEnum .= " " . $r . "";
+ }
+ if ($this->totRows === 0) {
+ $this->tpl->newBlock( 'norecords' );
+ $this->tpl->assign( "columnCount", $this->colCount );
+ $noRecordsFound = 'ID_NO_RECORDS_FOUND';
+ if (G::LoadTranslation( $noRecordsFound ))
+ $noRecordsFound = G::LoadTranslation( $noRecordsFound );
+ $this->tpl->assign( "noRecordsFound", $noRecordsFound );
+ }
+ if (! $this->disableFooter) {
+ $this->tpl->newBlock( "bottomFooter" );
+ $this->tpl->assign( "columnCount", $this->colCount );
+ $this->tpl->assign( "pagedTableId", $this->id );
+ if (($this->totRows !== 0)) {
+ if ($this->totPages > 1) {
+ $this->tpl->assign( "first", $first );
+ $this->tpl->assign( "prev", $prev );
+ $this->tpl->assign( "next", $next );
+ $this->tpl->assign( "last", $last );
+ }
+ $this->tpl->assign( "currentPage", $this->currentPage );
+ $this->tpl->assign( "totalPages", $this->totPages );
+ $firstRow = ($this->currentPage - 1) * $this->rowsPerPage + 1;
+ $lastRow = $firstRow + $rs->getRecordCount() - 1;
+ $this->tpl->assign( "firstRow", $firstRow );
+ $this->tpl->assign( "lastRow", $lastRow );
+ $this->tpl->assign( "totalRows", $this->totRows );
+ } else {
+ $this->tpl->assign( "indexStyle", 'visibility:hidden;' );
+ }
+ if ($this->searchBy) {
+ $this->tpl->assign( "fastSearchValue", $this->fastSearch );
+ } else {
+ $this->tpl->assign( "fastSearchStyle", 'visibility:hidden;' );
+ }
+ if ($this->addRow)
+ if ($this->sqlInsert != '')
+ $this->tpl->assign( "insert", ''./*G::LoadXml('labels','ID_ADD_NEW')*/ 'ID_ADD_NEW' . '' );
+ $this->tpl->assign( "pagesEnum", $pagesEnum );
+ }
+ ?>
-
tpl->newBlock( "closeBlock" );
+ }
+ //By JHL
+ //Put the content of the table in a variable to be used for other puposes
+ //Like rendering as PDF
+ global $_TABLE_CONTENT_;
+ $_TABLE_CONTENT_ = $this->tpl->getOutputContent();
+ $this->tpl->printToScreen();
+ unset( $this->tpl );
+ //unset($this->dbc);
+ //unset($this->ses);
+ $_SESSION['pagedTable[' . $this->id . ']'] = serialize( $this );
+ $this->fastSearch = '';
+ return;
}
- /********** CLOSE BLOCK ***************/
- if (($block ==='') || ($block==='close')) {
- $this->tpl->newBlock( "closeBlock" );
+
+ /**
+ * Function printForm
+ *
+ * @param string $filename
+ * @param array $data
+ * @return void
+ */
+ function printForm ($filename, $data = array())
+ {
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher();
+ $G_PUBLISH->AddContent( 'xmlform', 'xmlform', $filename, '', $data, $this->popupSubmit );
+ G::RenderPage( "publish", "blank" );
}
- //By JHL
- //Put the content of the table in a variable to be used for other puposes
- //Like rendering as PDF
- global $_TABLE_CONTENT_;
- $_TABLE_CONTENT_=$this->tpl->getOutputContent();
- $this->tpl->printToScreen();
- unset($this->tpl);
- //unset($this->dbc);
- //unset($this->ses);
- $_SESSION['pagedTable['.$this->id.']']= serialize($this);
- $this->fastSearch = '';
- return;
- }
- /**
- * Function printForm
- * @param string $filename
- * @param array $data
- * @return void
- */
- function printForm($filename,$data=array())
- { global $G_PUBLISH;
- $G_PUBLISH = new Publisher();
- $G_PUBLISH->AddContent('xmlform', 'xmlform', $filename, '', $data , $this->popupSubmit);
- G::RenderPage( "publish" , "blank" );
- }
}
\ No newline at end of file
diff --git a/workflow/engine/classes/class.replacementLogo.php b/workflow/engine/classes/class.replacementLogo.php
index ffd1ec036..fae2c5bf0 100755
--- a/workflow/engine/classes/class.replacementLogo.php
+++ b/workflow/engine/classes/class.replacementLogo.php
@@ -1,6 +1,8 @@
.
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
/**
+ *
* @package workflow.engine.classes
*/
-class replacementLogo {
-
- //var $dir='';
- /**
- * This function is the constructor of the replacementLogo class
- * param
- * @return void
- */
- function replacementLogo() {
-
- }
-
- /**
- * This function upload a file
- *
- *
- * @name upLoadFile
- *
- * @param string $dirUpload
- * @param string $namefile
- * @param string $typefile
- * @param string $errorfile
- * @param string $tpnfile
- * @param string $formf
- * @return string
- */
- function upLoadFile($dirUpload, $namefile, $typefile, $errorfile, $tpnfile, $formf) {
-
- //we are cheking the extension for file
- $aExt = explode ( ".", $namefile );
- $infoupload = ''; //|| ($formf["type"]['uploadfile'] == "application/octet-stream")image/png
- if (($typefile == "image/jpeg") || ($typefile == "image/png")) {
- if ($errorfile > 0) {
- $infoupload = "Return Code: " . $errorfile . "
";
- } else {
- if (file_exists ( $dirUpload . $namefile )) {
- $infoupload = $namefile . " already exist. ";
- } else {
- move_uploaded_file ( $tpnfile, $dirUpload . $namefile );
- $infoupload = "Stored in: " . $dirUpload . $namefile;
- }
- }
- } else {
- $infoupload = "- " . $typefile . " Invalid file your file should be jpeg";
+class replacementLogo
+{
+
+ //var $dir='';
+ /**
+ * This function is the constructor of the replacementLogo class
+ * param
+ *
+ * @return void
+ */
+ public function replacementLogo ()
+ {
+
}
- return $infoupload;
- }
-
- /**
- * This function gets the logos' names
- *
- *
- * @name getNameLogo
- *
- * param
- * @return array
- */
- function getNameLogo($usrUid) {
-
- require_once 'classes/model/Configuration.php';
- $oCriteria = new Criteria ( 'workflow' );
- $oCriteria->addSelectColumn ( ConfigurationPeer::CFG_VALUE );
- $oCriteria->add ( ConfigurationPeer::CFG_UID, 'USER_LOGO_REPLACEMENT' );
- $oDataset = ConfigurationPeer::doSelectRS ( $oCriteria );
- $oDataset->next ();
- $aRow = $oDataset->getRow ();
- if (isset ( $aRow [0] ))
- $ainfoLogo = @unserialize ( $aRow [0] );
- else
- $ainfoLogo = NULL;
-
- return ($ainfoLogo);
- }
-} // end class
+ /**
+ * This function upload a file
+ *
+ *
+ * @name upLoadFile
+ *
+ * @param string $dirUpload
+ * @param string $namefile
+ * @param string $typefile
+ * @param string $errorfile
+ * @param string $tpnfile
+ * @param string $formf
+ * @return string
+ */
+ public function upLoadFile ($dirUpload, $namefile, $typefile, $errorfile, $tpnfile, $formf)
+ {
+
+ //we are cheking the extension for file
+ $aExt = explode( ".", $namefile );
+ $infoupload = ''; //|| ($formf["type"]['uploadfile'] == "application/octet-stream")image/png
+ if (($typefile == "image/jpeg") || ($typefile == "image/png")) {
+ if ($errorfile > 0) {
+ $infoupload = "Return Code: " . $errorfile . "
";
+ } else {
+ if (file_exists( $dirUpload . $namefile )) {
+ $infoupload = $namefile . " already exist. ";
+ } else {
+ move_uploaded_file( $tpnfile, $dirUpload . $namefile );
+ $infoupload = "Stored in: " . $dirUpload . $namefile;
+ }
+ }
+ } else {
+ $infoupload = "- " . $typefile . " Invalid file your file should be jpeg";
+ }
+ return $infoupload;
+ }
+
+ /**
+ * This function gets the logos' names
+ *
+ *
+ * @name getNameLogo
+ *
+ * param
+ * @return array
+ */
+ public function getNameLogo ($usrUid)
+ {
+
+ require_once 'classes/model/Configuration.php';
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addSelectColumn( ConfigurationPeer::CFG_VALUE );
+ $oCriteria->add( ConfigurationPeer::CFG_UID, 'USER_LOGO_REPLACEMENT' );
+ $oDataset = ConfigurationPeer::doSelectRS( $oCriteria );
+ $oDataset->next();
+ $aRow = $oDataset->getRow();
+ if (isset( $aRow[0] )) {
+ $ainfoLogo = @unserialize( $aRow[0] );
+ } else {
+ $ainfoLogo = null;
+ }
+ return ($ainfoLogo);
+ }
+}
diff --git a/workflow/engine/classes/class.report.php b/workflow/engine/classes/class.report.php
index 39ce53d59..e17fc0063 100755
--- a/workflow/engine/classes/class.report.php
+++ b/workflow/engine/classes/class.report.php
@@ -1,6 +1,8 @@
.
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
-
/**
* Report - Report class
+ *
* @package workflow.engine.ProcessMaker
* @author Everth S. Berrios Morales
* @copyright 2008 COLOSA
*/
-class Report {
-
- /**
- * This function does a sql statment to a report
- *
- *
- * @name generatedReport1
- *
- * param
- * @return object
- */
- function generatedReport1()
- {
- $this->reportsPatch();
+class Report
+{
- require_once 'classes/model/AppDelegation.php';
- require_once 'classes/model/Application.php';
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
- $oCriteria->addSelectColumn(AppDelegationPeer::PRO_UID);
- $oCriteria->addAsColumn("MIN", "MIN(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("MAX", "MAX(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("TOTALDUR", "SUM(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("PROMEDIO", "AVG(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn('PRO_TITLE', 'C1.CON_VALUE' );
- $oCriteria->addAlias("C1", 'CONTENT');
- $proTitleConds = array();
- $proTitleConds[] = array( AppDelegationPeer::PRO_UID , 'C1.CON_ID' );
- $proTitleConds[] = array( 'C1.CON_CATEGORY' , $del . 'PRO_TITLE' . $del );
- $proTitleConds[] = array( 'C1.CON_LANG' , $del . SYS_LANG . $del );
- $oCriteria->addJoinMC($proTitleConds , Criteria::LEFT_JOIN);
- $oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID);
- $oCriteria->addGroupByColumn('C1.CON_VALUE');
-
- $oDataset = AppDelegationPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aProcess[] = array('PRO_UID' => 'char',
- 'PRO_TITLE' => 'char',
- 'CANTCASES' => 'integer',
- 'MIN' => 'float',
- 'MAX' => 'float',
- 'TOTALDUR' => 'float',
- 'PROMEDIO' => 'float');
- while ($aRow = $oDataset->getRow())
+ /**
+ * This function does a sql statment to a report
+ *
+ *
+ * @name generatedReport1
+ *
+ * param
+ * @return object
+ */
+ public function generatedReport1 ()
{
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(ApplicationPeer::PRO_UID);
- $oCriteria->add(ApplicationPeer::PRO_UID, $aRow['PRO_UID']);
+ $this->reportsPatch();
- $aProcess[] = array('PRO_UID' => $aRow['PRO_UID'],
- 'PRO_TITLE' => $aRow['PRO_TITLE'],
- 'CANTCASES' => ApplicationPeer::doCount($oCriteria),
- 'MIN' => number_format($aRow['MIN'], 2),
- 'MAX' => number_format($aRow['MAX'], 2),
- 'TOTALDUR' => number_format($aRow['TOTALDUR'], 2),
- 'PROMEDIO' => number_format($aRow['PROMEDIO'], 2));
+ require_once 'classes/model/AppDelegation.php';
+ require_once 'classes/model/Application.php';
+ $oCriteria = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+ $oCriteria->addSelectColumn( AppDelegationPeer::PRO_UID );
+ $oCriteria->addAsColumn( "MIN", "MIN(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "MAX", "MAX(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "TOTALDUR", "SUM(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "PROMEDIO", "AVG(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( 'PRO_TITLE', 'C1.CON_VALUE' );
+ $oCriteria->addAlias( "C1", 'CONTENT' );
+ $proTitleConds = array ();
+ $proTitleConds[] = array (AppDelegationPeer::PRO_UID,'C1.CON_ID'
+ );
+ $proTitleConds[] = array ('C1.CON_CATEGORY',$del . 'PRO_TITLE' . $del
+ );
+ $proTitleConds[] = array ('C1.CON_LANG',$del . SYS_LANG . $del
+ );
+ $oCriteria->addJoinMC( $proTitleConds, Criteria::LEFT_JOIN );
+ $oCriteria->addGroupByColumn( AppDelegationPeer::PRO_UID );
+ $oCriteria->addGroupByColumn( 'C1.CON_VALUE' );
+
+ $oDataset = AppDelegationPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
- }
+ $aProcess[] = array ('PRO_UID' => 'char','PRO_TITLE' => 'char','CANTCASES' => 'integer','MIN' => 'float','MAX' => 'float','TOTALDUR' => 'float','PROMEDIO' => 'float'
+ );
+ while ($aRow = $oDataset->getRow()) {
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addSelectColumn( ApplicationPeer::PRO_UID );
+ $oCriteria->add( ApplicationPeer::PRO_UID, $aRow['PRO_UID'] );
- global $_DBArray;
- $_DBArray['reports'] = $aProcess;
- $_SESSION['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('reports');
+ $aProcess[] = array ('PRO_UID' => $aRow['PRO_UID'],'PRO_TITLE' => $aRow['PRO_TITLE'],'CANTCASES' => ApplicationPeer::doCount( $oCriteria ),'MIN' => number_format( $aRow['MIN'], 2 ),'MAX' => number_format( $aRow['MAX'], 2 ),'TOTALDUR' => number_format( $aRow['TOTALDUR'], 2 ),'PROMEDIO' => number_format( $aRow['PROMEDIO'], 2 )
+ );
+ $oDataset->next();
+ }
- return $oCriteria;
- }
+ global $_DBArray;
+ $_DBArray['reports'] = $aProcess;
+ $_SESSION['_DBArray'] = $_DBArray;
+ G::LoadClass( 'ArrayPeer' );
+ $oCriteria = new Criteria( 'dbarray' );
+ $oCriteria->setDBArrayTable( 'reports' );
- /**
- * This function does a sql statment to a report wiht a condition
- * or maybe when you're looking for some specials cases
- *
- * @name generatedReport1_filter
- *
- * @param string $from
- * @param string $to
- * @param string $startedby
- * @return object
- */
- function generatedReport1_filter($from, $to, $startedby)
- {
- $this->reportsPatch();
+ return $oCriteria;
+ }
- require_once 'classes/model/AppDelegation.php';
- require_once 'classes/model/Application.php';
- require_once 'classes/model/Users.php';
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
- $oCriteria->addSelectColumn(UsersPeer::USR_UID);
- $oCriteria->addSelectColumn(AppDelegationPeer::PRO_UID);
- $oCriteria->addAsColumn("MIN", "MIN(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("MAX", "MAX(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("TOTALDUR", "SUM(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("PROMEDIO", "AVG(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn('PRO_TITLE', 'C1.CON_VALUE' );
- $oCriteria->addAlias("C1", 'CONTENT');
- $proTitleConds = array();
- $proTitleConds[] = array( AppDelegationPeer::PRO_UID , 'C1.CON_ID' );
- $proTitleConds[] = array( 'C1.CON_CATEGORY' , $del . 'PRO_TITLE' . $del );
- $proTitleConds[] = array( 'C1.CON_LANG' , $del . SYS_LANG . $del );
- $oCriteria->addJoinMC($proTitleConds , Criteria::LEFT_JOIN);
- $oCriteria->addJoin(AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
- //$oCriteria->add(AppDelegationPeer::DEL_DURATION, $from, Criteria::GREATER_EQUAL);
- //$oCriteria->add(AppDelegationPeer::DEL_DURATION, $to, Criteria::LESS_EQUAL);
- //$aAux1 = explode('-', $from); date('Y-m-d H:i:s', mktime(0, 0, 0, $aAux1[1], $aAux1[2], $aAux1[0]))
- $oCriteria->add($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $from.' 00:00:00', Criteria::GREATER_EQUAL)->addAnd($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $to.' 23:59:59', Criteria::LESS_EQUAL)));
+ /**
+ * This function does a sql statment to a report wiht a condition
+ * or maybe when you're looking for some specials cases
+ *
+ * @name generatedReport1_filter
+ *
+ * @param string $from
+ * @param string $to
+ * @param string $startedby
+ * @return object
+ */
+ public function generatedReport1_filter ($from, $to, $startedby)
+ {
+ $this->reportsPatch();
- if($startedby!='') $oCriteria->add(ApplicationPeer::APP_INIT_USER, $startedby);
+ require_once 'classes/model/AppDelegation.php';
+ require_once 'classes/model/Application.php';
+ require_once 'classes/model/Users.php';
+ $oCriteria = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+ $oCriteria->addSelectColumn( UsersPeer::USR_UID );
+ $oCriteria->addSelectColumn( AppDelegationPeer::PRO_UID );
+ $oCriteria->addAsColumn( "MIN", "MIN(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "MAX", "MAX(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "TOTALDUR", "SUM(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "PROMEDIO", "AVG(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( 'PRO_TITLE', 'C1.CON_VALUE' );
+ $oCriteria->addAlias( "C1", 'CONTENT' );
+ $proTitleConds = array ();
+ $proTitleConds[] = array (AppDelegationPeer::PRO_UID,'C1.CON_ID'
+ );
+ $proTitleConds[] = array ('C1.CON_CATEGORY',$del . 'PRO_TITLE' . $del
+ );
+ $proTitleConds[] = array ('C1.CON_LANG',$del . SYS_LANG . $del
+ );
+ $oCriteria->addJoinMC( $proTitleConds, Criteria::LEFT_JOIN );
+ $oCriteria->addJoin( AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN );
+ //$oCriteria->add(AppDelegationPeer::DEL_DURATION, $from, Criteria::GREATER_EQUAL);
+ //$oCriteria->add(AppDelegationPeer::DEL_DURATION, $to, Criteria::LESS_EQUAL);
+ //$aAux1 = explode('-', $from); date('Y-m-d H:i:s', mktime(0, 0, 0, $aAux1[1], $aAux1[2], $aAux1[0]))
+ $oCriteria->add( $oCriteria->getNewCriterion( AppDelegationPeer::DEL_INIT_DATE, $from . ' 00:00:00', Criteria::GREATER_EQUAL )->addAnd( $oCriteria->getNewCriterion( AppDelegationPeer::DEL_INIT_DATE, $to . ' 23:59:59', Criteria::LESS_EQUAL ) ) );
- $oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID);
- $oCriteria->addGroupByColumn('C1.CON_VALUE');
+ if ($startedby != '')
+ $oCriteria->add( ApplicationPeer::APP_INIT_USER, $startedby );
- $oDataset = AppDelegationPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
+ $oCriteria->addGroupByColumn( AppDelegationPeer::PRO_UID );
+ $oCriteria->addGroupByColumn( 'C1.CON_VALUE' );
- $aProcess[] = array('PRO_UID' => 'char',
- 'PRO_TITLE' => 'char',
- 'CANTCASES' => 'integer',
- 'MIN' => 'float',
- 'MAX' => 'float',
- 'TOTALDUR' => 'float',
- 'PROMEDIO' => 'float');
- while ($aRow = $oDataset->getRow()) {
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(ApplicationPeer::PRO_UID);
- $oCriteria->add(ApplicationPeer::PRO_UID, $aRow['PRO_UID']);
- if($startedby!='') $oCriteria->add(ApplicationPeer::APP_INIT_USER, $startedby);
-
- $aProcess[] = array('PRO_UID' => $aRow['PRO_UID'],
- 'PRO_TITLE' => $aRow['PRO_TITLE'],
- 'CANTCASES' => ApplicationPeer::doCount($oCriteria),
- 'MIN' => number_format($aRow['MIN'],2),
- 'MAX' => number_format($aRow['MAX'],2),
- 'TOTALDUR' => number_format($aRow['TOTALDUR'],2),
- 'PROMEDIO' => number_format($aRow['PROMEDIO'],2));
+ $oDataset = AppDelegationPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
- }
- global $_DBArray;
- $_DBArray['reports'] = $aProcess;
- $_SESSION['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('reports');
+ $aProcess[] = array ('PRO_UID' => 'char','PRO_TITLE' => 'char','CANTCASES' => 'integer','MIN' => 'float','MAX' => 'float','TOTALDUR' => 'float','PROMEDIO' => 'float'
+ );
+ while ($aRow = $oDataset->getRow()) {
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addSelectColumn( ApplicationPeer::PRO_UID );
+ $oCriteria->add( ApplicationPeer::PRO_UID, $aRow['PRO_UID'] );
+ if ($startedby != '')
+ $oCriteria->add( ApplicationPeer::APP_INIT_USER, $startedby );
- return $oCriteria;
- }
+ $aProcess[] = array ('PRO_UID' => $aRow['PRO_UID'],'PRO_TITLE' => $aRow['PRO_TITLE'],'CANTCASES' => ApplicationPeer::doCount( $oCriteria ),'MIN' => number_format( $aRow['MIN'], 2 ),'MAX' => number_format( $aRow['MAX'], 2 ),'TOTALDUR' => number_format( $aRow['TOTALDUR'], 2 ),'PROMEDIO' => number_format( $aRow['PROMEDIO'], 2 )
+ );
+ $oDataset->next();
+ }
- /**
- * This function gets info about a report
- *
- *
- * @name descriptionReport1
- *
- * @param string $PRO_UID
- * @return object
- */
- function descriptionReport1($PRO_UID)
- { $this->reportsPatch();
+ global $_DBArray;
+ $_DBArray['reports'] = $aProcess;
+ $_SESSION['_DBArray'] = $_DBArray;
+ G::LoadClass( 'ArrayPeer' );
+ $oCriteria = new Criteria( 'dbarray' );
+ $oCriteria->setDBArrayTable( 'reports' );
- require_once 'classes/model/AppDelegation.php';
- require_once 'classes/model/Task.php';
- require_once 'classes/model/Content.php';
+ return $oCriteria;
+ }
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
- $oCriteria->addSelectColumn(AppDelegationPeer::PRO_UID);
- $oCriteria->addAsColumn("MIN", "MIN(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("MAX", "MAX(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("TOTALDUR", "SUM(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("PROMEDIO", "AVG(".AppDelegationPeer::DEL_DURATION.")");
+ /**
+ * This function gets info about a report
+ *
+ *
+ * @name descriptionReport1
+ *
+ * @param string $PRO_UID
+ * @return object
+ */
+ public function descriptionReport1 ($PRO_UID)
+ {
+ $this->reportsPatch();
- $oCriteria->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
+ require_once 'classes/model/AppDelegation.php';
+ require_once 'classes/model/Task.php';
+ require_once 'classes/model/Content.php';
- $oCriteria->addAsColumn('TAS_TITLE', 'C.CON_VALUE');
- $oCriteria->addAlias("C", 'CONTENT');
+ $oCriteria = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+ $oCriteria->addSelectColumn( AppDelegationPeer::PRO_UID );
+ $oCriteria->addAsColumn( "MIN", "MIN(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "MAX", "MAX(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "TOTALDUR", "SUM(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "PROMEDIO", "AVG(" . AppDelegationPeer::DEL_DURATION . ")" );
- $proContentConds = array();
- $proContentConds[] = array(AppDelegationPeer::TAS_UID, 'C.CON_ID');
- $proContentConds[] = array('C.CON_CATEGORY', $del . 'TAS_TITLE' . $del);
- $proContentConds[] = array('C.CON_LANG', $del . SYS_LANG . $del);
- $oCriteria->addJoinMC($proContentConds, Criteria::LEFT_JOIN);
+ $oCriteria->addJoin( AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN );
- $oCriteria->add(AppDelegationPeer::PRO_UID, $PRO_UID);
+ $oCriteria->addAsColumn( 'TAS_TITLE', 'C.CON_VALUE' );
+ $oCriteria->addAlias( "C", 'CONTENT' );
- $oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID);
- $oCriteria->addGroupByColumn('C.CON_VALUE');
+ $proContentConds = array ();
+ $proContentConds[] = array (AppDelegationPeer::TAS_UID,'C.CON_ID'
+ );
+ $proContentConds[] = array ('C.CON_CATEGORY',$del . 'TAS_TITLE' . $del
+ );
+ $proContentConds[] = array ('C.CON_LANG',$del . SYS_LANG . $del
+ );
+ $oCriteria->addJoinMC( $proContentConds, Criteria::LEFT_JOIN );
+ $oCriteria->add( AppDelegationPeer::PRO_UID, $PRO_UID );
- $oDataset = AppDelegationPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
+ $oCriteria->addGroupByColumn( AppDelegationPeer::PRO_UID );
+ $oCriteria->addGroupByColumn( 'C.CON_VALUE' );
- $aProcess[] = array('TAS_TITLE' => 'char',
- 'MIN' => 'float',
- 'MAX' => 'float',
- 'TOTALDUR' => 'float',
- 'PROMEDIO' => 'float');
- while ($aRow = $oDataset->getRow()) {
- $aProcess[] = array('TAS_TITLE' => $aRow['TAS_TITLE'],
- 'MIN' => number_format($aRow['MIN'],2),
- 'MAX' => number_format($aRow['MAX'],2),
- 'TOTALDUR' => number_format($aRow['TOTALDUR'],2),
- 'PROMEDIO' => number_format($aRow['PROMEDIO'],2));
+ $oDataset = AppDelegationPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
- }
- global $_DBArray;
- $_DBArray['reports'] = $aProcess;
- $_SESSION['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('reports');
+ $aProcess[] = array ('TAS_TITLE' => 'char','MIN' => 'float','MAX' => 'float','TOTALDUR' => 'float','PROMEDIO' => 'float'
+ );
+ while ($aRow = $oDataset->getRow()) {
+ $aProcess[] = array ('TAS_TITLE' => $aRow['TAS_TITLE'],'MIN' => number_format( $aRow['MIN'], 2 ),'MAX' => number_format( $aRow['MAX'], 2 ),'TOTALDUR' => number_format( $aRow['TOTALDUR'], 2 ),'PROMEDIO' => number_format( $aRow['PROMEDIO'], 2 )
+ );
+ $oDataset->next();
+ }
- return $oCriteria;
- }
+ global $_DBArray;
+ $_DBArray['reports'] = $aProcess;
+ $_SESSION['_DBArray'] = $_DBArray;
+ G::LoadClass( 'ArrayPeer' );
+ $oCriteria = new Criteria( 'dbarray' );
+ $oCriteria->setDBArrayTable( 'reports' );
- /**
- * This function generates a other kind of report
- *
- *
- * @name generatedReport2
- *
- * param
- * @return object
- */
- function generatedReport2()
- {
- $this->reportsPatch();
- require_once 'classes/model/AppDelegation.php';
- require_once 'classes/model/Application.php';
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
- $oCriteria->addSelectColumn(AppDelegationPeer::PRO_UID);
- $oCriteria->addAsColumn("MIN", "MIN(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("MAX", "MAX(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn('PRO_TITLE', 'C1.CON_VALUE' );
- $oCriteria->addAlias("C1", 'CONTENT');
- $proTitleConds = array();
- $proTitleConds[] = array( AppDelegationPeer::PRO_UID , 'C1.CON_ID' );
- $proTitleConds[] = array( 'C1.CON_CATEGORY' , $del . 'PRO_TITLE' . $del );
- $proTitleConds[] = array( 'C1.CON_LANG' , $del . SYS_LANG . $del );
- $oCriteria->addJoinMC($proTitleConds , Criteria::LEFT_JOIN);
- $oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID);
+ return $oCriteria;
+ }
- $oDataset = AppDelegationPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
+ /**
+ * This function generates a other kind of report
+ *
+ *
+ * @name generatedReport2
+ *
+ * param
+ * @return object
+ */
+ public function generatedReport2 ()
+ {
+ $this->reportsPatch();
+ require_once 'classes/model/AppDelegation.php';
+ require_once 'classes/model/Application.php';
+ $oCriteria = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+ $oCriteria->addSelectColumn( AppDelegationPeer::PRO_UID );
+ $oCriteria->addAsColumn( "MIN", "MIN(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "MAX", "MAX(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( 'PRO_TITLE', 'C1.CON_VALUE' );
+ $oCriteria->addAlias( "C1", 'CONTENT' );
+ $proTitleConds = array ();
+ $proTitleConds[] = array (AppDelegationPeer::PRO_UID,'C1.CON_ID'
+ );
+ $proTitleConds[] = array ('C1.CON_CATEGORY',$del . 'PRO_TITLE' . $del
+ );
+ $proTitleConds[] = array ('C1.CON_LANG',$del . SYS_LANG . $del
+ );
+ $oCriteria->addJoinMC( $proTitleConds, Criteria::LEFT_JOIN );
+ $oCriteria->addGroupByColumn( AppDelegationPeer::PRO_UID );
- $month = date( 'Y-m-d' , mktime(0, 0, 0, date("m")-1 , date("d"), date("Y")) );
- $lastmonth = date( 'Y-m-d' , mktime(0, 0, 0, date("m")-2 , date("d"), date("Y")) );
-
- $day = mktime(0, 0, 0, date("m") , date("d")-1, date("Y"));
- $lastday = mktime(0, 0, 0, date("m") , date("d")-2, date("Y"));
-
- $aProcess[] = array('PRO_UID' => 'char',
- 'PRO_TITLE' => 'char',
- 'CANTCASES' => 'integer',
- 'MIN' => 'float',
- 'MAX' => 'float',
- 'CASELASTMONTH' => 'integer',
- 'CASELASTDAY' => 'integer'
- );
-
- while ($aRow = $oDataset->getRow()) {
- $oCriteria2 = new Criteria('workflow');
- $oCriteria2->addSelectColumn(ApplicationPeer::PRO_UID);
- $oCriteria2->addAsColumn("CANTCASES", "COUNT(*)");
- $oCriteria2->add(ApplicationPeer::PRO_UID, $aRow['PRO_UID']);
- $oCriteria2->addGroupByColumn(ApplicationPeer::PRO_UID);
- $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2);
- $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset2->next();
- $aRow2 = $oDataset2->getRow();
- $cant = $aRow2['CANTCASES'];
-
- $oCriteria2 = new Criteria('workflow');
- $oCriteria2->addSelectColumn(ApplicationPeer::PRO_UID);
- $oCriteria2->addAsColumn("CANTCASES", "COUNT(*)");
- $oCriteria2->add(ApplicationPeer::PRO_UID, $aRow['PRO_UID']);
- $oCriteria2->add(ApplicationPeer::APP_INIT_DATE, $lastmonth, Criteria::GREATER_EQUAL);
- $oCriteria2->add(ApplicationPeer::APP_INIT_DATE, $month, Criteria::LESS_EQUAL);
- $oCriteria2->addGroupByColumn(ApplicationPeer::PRO_UID);
- $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2);
- $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset2->next();
- $aRow2 = $oDataset2->getRow();
- $cant1 = $aRow2['CANTCASES'];
-
- $oCriteria2 = new Criteria('workflow');
- $oCriteria2->addSelectColumn(ApplicationPeer::PRO_UID);
- $oCriteria2->addAsColumn("CANTCASES", "COUNT(*)");
- $oCriteria2->add(ApplicationPeer::PRO_UID, $aRow['PRO_UID']);
- $oCriteria2->add(ApplicationPeer::APP_INIT_DATE, $lastday, Criteria::GREATER_EQUAL);
- $oCriteria2->add(ApplicationPeer::APP_INIT_DATE, $day, Criteria::LESS_EQUAL);
- $oCriteria2->addGroupByColumn(ApplicationPeer::PRO_UID);
- $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2);
- $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset2->next();
- $aRow2 = $oDataset2->getRow();
- $cant2 = $aRow2['CANTCASES'];
-
- $aProcess[] = array('PRO_UID' => $aRow['PRO_UID'],
- 'PRO_TITLE' => $aRow['PRO_TITLE'],
- 'CANTCASES' => $cant,
- 'MIN' => number_format($aRow['MIN'],2),
- 'MAX' => number_format($aRow['MAX'],2),
- 'CASELASTMONTH' => number_format($cant1,2),
- 'CASELASTDAY' => number_format($cant2,2)
- );
+ $oDataset = AppDelegationPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
- }
- global $_DBArray;
- $_DBArray['reports'] = $aProcess;
- $_SESSION['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('reports');
- return $oCriteria;
- }
+ $month = date( 'Y-m-d', mktime( 0, 0, 0, date( "m" ) - 1, date( "d" ), date( "Y" ) ) );
+ $lastmonth = date( 'Y-m-d', mktime( 0, 0, 0, date( "m" ) - 2, date( "d" ), date( "Y" ) ) );
- /**
- * This function generates the description about a report
- *
- *
- * @name reports_Description_filter
- *
- * @param string $from
- * @param string $to
- * @param string $startedby
- * @param string $PRO_UID
- * @return object
- */
- function reports_Description_filter($from, $to, $startedby, $PRO_UID)
- {
- $this->reportsPatch();
- require_once 'classes/model/AppDelegation.php';
- require_once 'classes/model/Task.php';
- require_once 'classes/model/Content.php';
- require_once 'classes/model/Users.php';
+ $day = mktime( 0, 0, 0, date( "m" ), date( "d" ) - 1, date( "Y" ) );
+ $lastday = mktime( 0, 0, 0, date( "m" ), date( "d" ) - 2, date( "Y" ) );
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
- $oCriteria->addSelectColumn(AppDelegationPeer::PRO_UID);
- $oCriteria->addAsColumn("MIN", "MIN(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("MAX", "MAX(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("TOTALDUR", "SUM(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("PROMEDIO", "AVG(".AppDelegationPeer::DEL_DURATION.")");
+ $aProcess[] = array ('PRO_UID' => 'char','PRO_TITLE' => 'char','CANTCASES' => 'integer','MIN' => 'float','MAX' => 'float','CASELASTMONTH' => 'integer','CASELASTDAY' => 'integer'
+ );
- $oCriteria->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
+ while ($aRow = $oDataset->getRow()) {
+ $oCriteria2 = new Criteria( 'workflow' );
+ $oCriteria2->addSelectColumn( ApplicationPeer::PRO_UID );
+ $oCriteria2->addAsColumn( "CANTCASES", "COUNT(*)" );
+ $oCriteria2->add( ApplicationPeer::PRO_UID, $aRow['PRO_UID'] );
+ $oCriteria2->addGroupByColumn( ApplicationPeer::PRO_UID );
+ $oDataset2 = AppDelegationPeer::doSelectRS( $oCriteria2 );
+ $oDataset2->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset2->next();
+ $aRow2 = $oDataset2->getRow();
+ $cant = $aRow2['CANTCASES'];
- $oCriteria->addAsColumn('TAS_TITLE', 'C.CON_VALUE');
- $oCriteria->addAlias("C", 'CONTENT');
+ $oCriteria2 = new Criteria( 'workflow' );
+ $oCriteria2->addSelectColumn( ApplicationPeer::PRO_UID );
+ $oCriteria2->addAsColumn( "CANTCASES", "COUNT(*)" );
+ $oCriteria2->add( ApplicationPeer::PRO_UID, $aRow['PRO_UID'] );
+ $oCriteria2->add( ApplicationPeer::APP_INIT_DATE, $lastmonth, Criteria::GREATER_EQUAL );
+ $oCriteria2->add( ApplicationPeer::APP_INIT_DATE, $month, Criteria::LESS_EQUAL );
+ $oCriteria2->addGroupByColumn( ApplicationPeer::PRO_UID );
+ $oDataset2 = AppDelegationPeer::doSelectRS( $oCriteria2 );
+ $oDataset2->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset2->next();
+ $aRow2 = $oDataset2->getRow();
+ $cant1 = $aRow2['CANTCASES'];
- $proContentConds = array();
- $proContentConds[] = array(AppDelegationPeer::TAS_UID, 'C.CON_ID');
- $proContentConds[] = array('C.CON_CATEGORY', $del . 'TAS_TITLE' . $del);
- $proContentConds[] = array('C.CON_LANG', $del . SYS_LANG . $del);
- $oCriteria->addJoinMC($proContentConds, Criteria::LEFT_JOIN);
+ $oCriteria2 = new Criteria( 'workflow' );
+ $oCriteria2->addSelectColumn( ApplicationPeer::PRO_UID );
+ $oCriteria2->addAsColumn( "CANTCASES", "COUNT(*)" );
+ $oCriteria2->add( ApplicationPeer::PRO_UID, $aRow['PRO_UID'] );
+ $oCriteria2->add( ApplicationPeer::APP_INIT_DATE, $lastday, Criteria::GREATER_EQUAL );
+ $oCriteria2->add( ApplicationPeer::APP_INIT_DATE, $day, Criteria::LESS_EQUAL );
+ $oCriteria2->addGroupByColumn( ApplicationPeer::PRO_UID );
+ $oDataset2 = AppDelegationPeer::doSelectRS( $oCriteria2 );
+ $oDataset2->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset2->next();
+ $aRow2 = $oDataset2->getRow();
+ $cant2 = $aRow2['CANTCASES'];
- $oCriteria->add($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $from.' 00:00:00', Criteria::GREATER_EQUAL)->addAnd($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $to.' 23:59:59', Criteria::LESS_EQUAL)));
+ $aProcess[] = array ('PRO_UID' => $aRow['PRO_UID'],'PRO_TITLE' => $aRow['PRO_TITLE'],'CANTCASES' => $cant,'MIN' => number_format( $aRow['MIN'], 2 ),'MAX' => number_format( $aRow['MAX'], 2 ),'CASELASTMONTH' => number_format( $cant1, 2 ),'CASELASTDAY' => number_format( $cant2, 2 )
+ );
+ $oDataset->next();
+ }
- if($startedby!='') $oCriteria->add(AppDelegationPeer::USR_UID, $startedby);
+ global $_DBArray;
+ $_DBArray['reports'] = $aProcess;
+ $_SESSION['_DBArray'] = $_DBArray;
+ G::LoadClass( 'ArrayPeer' );
+ $oCriteria = new Criteria( 'dbarray' );
+ $oCriteria->setDBArrayTable( 'reports' );
+ return $oCriteria;
+ }
- $oCriteria->add(AppDelegationPeer::PRO_UID, $PRO_UID);
+ /**
+ * This function generates the description about a report
+ *
+ *
+ * @name reports_Description_filter
+ *
+ * @param string $from
+ * @param string $to
+ * @param string $startedby
+ * @param string $PRO_UID
+ * @return object
+ */
+ public function reports_Description_filter ($from, $to, $startedby, $PRO_UID)
+ {
+ $this->reportsPatch();
+ require_once 'classes/model/AppDelegation.php';
+ require_once 'classes/model/Task.php';
+ require_once 'classes/model/Content.php';
+ require_once 'classes/model/Users.php';
- $oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID);
- $oCriteria->addGroupByColumn('C.CON_VALUE');
+ $oCriteria = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+ $oCriteria->addSelectColumn( AppDelegationPeer::PRO_UID );
+ $oCriteria->addAsColumn( "MIN", "MIN(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "MAX", "MAX(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "TOTALDUR", "SUM(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "PROMEDIO", "AVG(" . AppDelegationPeer::DEL_DURATION . ")" );
- return $oCriteria;
- }
+ $oCriteria->addJoin( AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN );
- /**
- * This function looks for an special case it has a condition
- *
- *
- * @name generatedReport2_filter
- *
- * @param string $from
- * @param string $to
- * @param string $startedby
- * @return object
- */
- function generatedReport2_filter($from, $to, $startedby)
- {
- $this->reportsPatch();
- require_once 'classes/model/AppDelegation.php';
- require_once 'classes/model/Application.php';
- require_once 'classes/model/Users.php';
+ $oCriteria->addAsColumn( 'TAS_TITLE', 'C.CON_VALUE' );
+ $oCriteria->addAlias( "C", 'CONTENT' );
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
- $oCriteria->addSelectColumn(AppDelegationPeer::PRO_UID);
- $oCriteria->addAsColumn("MIN", "MIN(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn("MAX", "MAX(".AppDelegationPeer::DEL_DURATION.")");
- $oCriteria->addAsColumn('PRO_TITLE', 'C1.CON_VALUE' );
- $oCriteria->addAlias("C1", 'CONTENT');
- $proTitleConds = array();
- $proTitleConds[] = array( AppDelegationPeer::PRO_UID , 'C1.CON_ID' );
- $proTitleConds[] = array( 'C1.CON_CATEGORY' , $del . 'PRO_TITLE' . $del );
- $proTitleConds[] = array( 'C1.CON_LANG' , $del . SYS_LANG . $del );
- $oCriteria->addJoinMC($proTitleConds , Criteria::LEFT_JOIN);
- $oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID);
- $oCriteria->addGroupByColumn('C1.CON_VALUE');
-
- $oCriteria->add($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $from.' 00:00:00', Criteria::GREATER_EQUAL)->addAnd($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $to.' 23:59:59', Criteria::LESS_EQUAL)));
+ $proContentConds = array ();
+ $proContentConds[] = array (AppDelegationPeer::TAS_UID,'C.CON_ID'
+ );
+ $proContentConds[] = array ('C.CON_CATEGORY',$del . 'TAS_TITLE' . $del
+ );
+ $proContentConds[] = array ('C.CON_LANG',$del . SYS_LANG . $del
+ );
+ $oCriteria->addJoinMC( $proContentConds, Criteria::LEFT_JOIN );
- if($startedby!='') $oCriteria->add(AppDelegationPeer::USR_UID, $startedby);
+ $oCriteria->add( $oCriteria->getNewCriterion( AppDelegationPeer::DEL_INIT_DATE, $from . ' 00:00:00', Criteria::GREATER_EQUAL )->addAnd( $oCriteria->getNewCriterion( AppDelegationPeer::DEL_INIT_DATE, $to . ' 23:59:59', Criteria::LESS_EQUAL ) ) );
- $oDataset = AppDelegationPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
+ if ($startedby != '')
+ $oCriteria->add( AppDelegationPeer::USR_UID, $startedby );
- $month = date( 'Y-m-d' , mktime(0, 0, 0, date("m")-1 , date("d"), date("Y")) );
- $lastmonth = date( 'Y-m-d' , mktime(0, 0, 0, date("m")-2 , date("d"), date("Y")) );
- $day = mktime(0, 0, 0, date("m") , date("d")-1, date("Y"));
- $lastday = mktime(0, 0, 0, date("m") , date("d")-2, date("Y"));
- $aProcess[] = array('PRO_UID' => 'char',
- 'PRO_TITLE' => 'char',
- 'CANTCASES' => 'integer',
- 'MIN' => 'float',
- 'MAX' => 'float',
- 'CASELASTMONTH' => 'integer',
- 'CASELASTDAY' => 'integer'
- );
+ $oCriteria->add( AppDelegationPeer::PRO_UID, $PRO_UID );
- while ($aRow = $oDataset->getRow()) {
- $oCriteria2 = new Criteria('workflow');
- $oCriteria2->addSelectColumn(ApplicationPeer::PRO_UID);
- $oCriteria2->addAsColumn("CANTCASES", "COUNT(*)");
- $oCriteria2->add(ApplicationPeer::PRO_UID, $aRow['PRO_UID']);
- if($startedby!='') $oCriteria2->add(ApplicationPeer::APP_INIT_USER, $startedby);
- $oCriteria2->addGroupByColumn(ApplicationPeer::PRO_UID);
- $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2);
- $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset2->next();
- $aRow2 = $oDataset2->getRow();
- $cant = $aRow2['CANTCASES'];
+ $oCriteria->addGroupByColumn( AppDelegationPeer::PRO_UID );
+ $oCriteria->addGroupByColumn( 'C.CON_VALUE' );
- $oCriteria2 = new Criteria('workflow');
- $oCriteria2->addSelectColumn(ApplicationPeer::PRO_UID);
- $oCriteria2->addAsColumn("CANTCASES", "COUNT(*)");
- $oCriteria2->add(ApplicationPeer::PRO_UID, $aRow['PRO_UID']);
- $oCriteria2->add(ApplicationPeer::APP_INIT_DATE, $lastmonth, Criteria::GREATER_EQUAL);
- $oCriteria2->add(ApplicationPeer::APP_INIT_DATE, $month, Criteria::LESS_EQUAL);
- if($startedby!='') $oCriteria2->add(ApplicationPeer::APP_INIT_USER, $startedby);
- $oCriteria2->addGroupByColumn(ApplicationPeer::PRO_UID);
- $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2);
- $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset2->next();
- $aRow2 = $oDataset2->getRow();
- $cant1 = $aRow2['CANTCASES'];
+ return $oCriteria;
+ }
- $oCriteria2 = new Criteria('workflow');
- $oCriteria2->addSelectColumn(ApplicationPeer::PRO_UID);
- $oCriteria2->addAsColumn("CANTCASES", "COUNT(*)");
- $oCriteria2->add(ApplicationPeer::PRO_UID, $aRow['PRO_UID']);
- $oCriteria2->add(ApplicationPeer::APP_INIT_DATE, $lastday, Criteria::GREATER_EQUAL);
- $oCriteria2->add(ApplicationPeer::APP_INIT_DATE, $day, Criteria::LESS_EQUAL);
- if($startedby!='') $oCriteria2->add(ApplicationPeer::APP_INIT_USER, $startedby);
- $oCriteria2->addGroupByColumn(ApplicationPeer::PRO_UID);
- $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2);
- $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset2->next();
- $aRow2 = $oDataset2->getRow();
- $cant2 = $aRow2['CANTCASES'];
+ /**
+ * This function looks for an special case it has a condition
+ *
+ *
+ * @name generatedReport2_filter
+ *
+ * @param string $from
+ * @param string $to
+ * @param string $startedby
+ * @return object
+ */
+ public function generatedReport2_filter ($from, $to, $startedby)
+ {
+ $this->reportsPatch();
+ require_once 'classes/model/AppDelegation.php';
+ require_once 'classes/model/Application.php';
+ require_once 'classes/model/Users.php';
- /*$aProcess[] = array('PRO_UID' => $aRow['PRO_UID'],
+ $oCriteria = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+ $oCriteria->addSelectColumn( AppDelegationPeer::PRO_UID );
+ $oCriteria->addAsColumn( "MIN", "MIN(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( "MAX", "MAX(" . AppDelegationPeer::DEL_DURATION . ")" );
+ $oCriteria->addAsColumn( 'PRO_TITLE', 'C1.CON_VALUE' );
+ $oCriteria->addAlias( "C1", 'CONTENT' );
+ $proTitleConds = array ();
+ $proTitleConds[] = array (AppDelegationPeer::PRO_UID,'C1.CON_ID'
+ );
+ $proTitleConds[] = array ('C1.CON_CATEGORY',$del . 'PRO_TITLE' . $del
+ );
+ $proTitleConds[] = array ('C1.CON_LANG',$del . SYS_LANG . $del
+ );
+ $oCriteria->addJoinMC( $proTitleConds, Criteria::LEFT_JOIN );
+ $oCriteria->addGroupByColumn( AppDelegationPeer::PRO_UID );
+ $oCriteria->addGroupByColumn( 'C1.CON_VALUE' );
+
+ $oCriteria->add( $oCriteria->getNewCriterion( AppDelegationPeer::DEL_INIT_DATE, $from . ' 00:00:00', Criteria::GREATER_EQUAL )->addAnd( $oCriteria->getNewCriterion( AppDelegationPeer::DEL_INIT_DATE, $to . ' 23:59:59', Criteria::LESS_EQUAL ) ) );
+
+ if ($startedby != '')
+ $oCriteria->add( AppDelegationPeer::USR_UID, $startedby );
+
+ $oDataset = AppDelegationPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+
+ $month = date( 'Y-m-d', mktime( 0, 0, 0, date( "m" ) - 1, date( "d" ), date( "Y" ) ) );
+ $lastmonth = date( 'Y-m-d', mktime( 0, 0, 0, date( "m" ) - 2, date( "d" ), date( "Y" ) ) );
+ $day = mktime( 0, 0, 0, date( "m" ), date( "d" ) - 1, date( "Y" ) );
+ $lastday = mktime( 0, 0, 0, date( "m" ), date( "d" ) - 2, date( "Y" ) );
+ $aProcess[] = array ('PRO_UID' => 'char','PRO_TITLE' => 'char','CANTCASES' => 'integer','MIN' => 'float','MAX' => 'float','CASELASTMONTH' => 'integer','CASELASTDAY' => 'integer'
+ );
+
+ while ($aRow = $oDataset->getRow()) {
+ $oCriteria2 = new Criteria( 'workflow' );
+ $oCriteria2->addSelectColumn( ApplicationPeer::PRO_UID );
+ $oCriteria2->addAsColumn( "CANTCASES", "COUNT(*)" );
+ $oCriteria2->add( ApplicationPeer::PRO_UID, $aRow['PRO_UID'] );
+ if ($startedby != '')
+ $oCriteria2->add( ApplicationPeer::APP_INIT_USER, $startedby );
+ $oCriteria2->addGroupByColumn( ApplicationPeer::PRO_UID );
+ $oDataset2 = AppDelegationPeer::doSelectRS( $oCriteria2 );
+ $oDataset2->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset2->next();
+ $aRow2 = $oDataset2->getRow();
+ $cant = $aRow2['CANTCASES'];
+
+ $oCriteria2 = new Criteria( 'workflow' );
+ $oCriteria2->addSelectColumn( ApplicationPeer::PRO_UID );
+ $oCriteria2->addAsColumn( "CANTCASES", "COUNT(*)" );
+ $oCriteria2->add( ApplicationPeer::PRO_UID, $aRow['PRO_UID'] );
+ $oCriteria2->add( ApplicationPeer::APP_INIT_DATE, $lastmonth, Criteria::GREATER_EQUAL );
+ $oCriteria2->add( ApplicationPeer::APP_INIT_DATE, $month, Criteria::LESS_EQUAL );
+ if ($startedby != '')
+ $oCriteria2->add( ApplicationPeer::APP_INIT_USER, $startedby );
+ $oCriteria2->addGroupByColumn( ApplicationPeer::PRO_UID );
+ $oDataset2 = AppDelegationPeer::doSelectRS( $oCriteria2 );
+ $oDataset2->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset2->next();
+ $aRow2 = $oDataset2->getRow();
+ $cant1 = $aRow2['CANTCASES'];
+
+ $oCriteria2 = new Criteria( 'workflow' );
+ $oCriteria2->addSelectColumn( ApplicationPeer::PRO_UID );
+ $oCriteria2->addAsColumn( "CANTCASES", "COUNT(*)" );
+ $oCriteria2->add( ApplicationPeer::PRO_UID, $aRow['PRO_UID'] );
+ $oCriteria2->add( ApplicationPeer::APP_INIT_DATE, $lastday, Criteria::GREATER_EQUAL );
+ $oCriteria2->add( ApplicationPeer::APP_INIT_DATE, $day, Criteria::LESS_EQUAL );
+ if ($startedby != '')
+ $oCriteria2->add( ApplicationPeer::APP_INIT_USER, $startedby );
+ $oCriteria2->addGroupByColumn( ApplicationPeer::PRO_UID );
+ $oDataset2 = AppDelegationPeer::doSelectRS( $oCriteria2 );
+ $oDataset2->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset2->next();
+ $aRow2 = $oDataset2->getRow();
+ $cant2 = $aRow2['CANTCASES'];
+
+ /*$aProcess[] = array('PRO_UID' => $aRow['PRO_UID'],
'PRO_TITLE' => $aRow['PRO_TITLE'],
'CANTCASES' => $cant,
'CASELASTMONTH' => $cant1,
'CASELASTDAY' => $cant2
);*/
- $aProcess[] = array('PRO_UID' => $aRow['PRO_UID'],
- 'PRO_TITLE' => $aRow['PRO_TITLE'],
- 'CANTCASES' => $cant,
- 'MIN' => number_format($aRow['MIN'],2),
- 'MAX' => number_format($aRow['MAX'],2),
- 'CASELASTMONTH' => number_format($cant1,2),
- 'CASELASTDAY' => number_format($cant2,2)
- );
- $oDataset->next();
- }
+ $aProcess[] = array ('PRO_UID' => $aRow['PRO_UID'],'PRO_TITLE' => $aRow['PRO_TITLE'],'CANTCASES' => $cant,'MIN' => number_format( $aRow['MIN'], 2 ),'MAX' => number_format( $aRow['MAX'], 2 ),'CASELASTMONTH' => number_format( $cant1, 2 ),'CASELASTDAY' => number_format( $cant2, 2 )
+ );
+ $oDataset->next();
+ }
- global $_DBArray;
- $_DBArray['reports'] = $aProcess;
- $_SESSION['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('reports');
- return $oCriteria;
- }
+ global $_DBArray;
+ $_DBArray['reports'] = $aProcess;
+ $_SESSION['_DBArray'] = $_DBArray;
+ G::LoadClass( 'ArrayPeer' );
+ $oCriteria = new Criteria( 'dbarray' );
+ $oCriteria->setDBArrayTable( 'reports' );
+ return $oCriteria;
+ }
- /**
- * This function looks for an special case it has a condition
- *
- *
- * @name generatedReport2_filter
- *
- * @param string $from
- * @param string $to
- * @param string $startedby
- * @return object
- */
- function generatedReport3()
- {
- $this->reportsPatch();
- require_once 'classes/model/AppDelegation.php';
- require_once 'classes/model/Application.php';
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
- $sql = "SELECT CONCAT(SUBSTRING(AD.DEL_INIT_DATE,6,2),'-', SUBSTRING(AD.DEL_INIT_DATE,1,4)) AS FECHA,
+ /**
+ * This function looks for an special case it has a condition
+ *
+ *
+ * @name generatedReport2_filter
+ *
+ * @param string $from
+ * @param string $to
+ * @param string $startedby
+ * @return object
+ */
+ public function generatedReport3 ()
+ {
+ $this->reportsPatch();
+ require_once 'classes/model/AppDelegation.php';
+ require_once 'classes/model/Application.php';
+ $oCriteria = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+ $sql = "SELECT CONCAT(SUBSTRING(AD.DEL_INIT_DATE,6,2),'-', SUBSTRING(AD.DEL_INIT_DATE,1,4)) AS FECHA,
COUNT(DISTINCT(AD.APP_UID)) AS CANTCASES,
MIN(AD.DEL_DURATION) AS MIN,
MAX(AD.DEL_DURATION) AS MAX,
@@ -558,73 +535,58 @@ class Report {
WHERE AD.APP_UID<>'' AND P.PRO_STATUS<>'DISABLED'
GROUP BY FECHA";
- $con = Propel::getConnection("workflow");
- $stmt = $con->prepareStatement($sql);
- $rs = $stmt->executeQuery();
+ $con = Propel::getConnection( "workflow" );
+ $stmt = $con->prepareStatement( $sql );
+ $rs = $stmt->executeQuery();
- $ROW[] = array('FECHA' => 'char',
- 'CANTCASES' => 'integer',
- 'MIN' => 'float',
- 'MAX' => 'float',
- 'TOTALDUR' => 'float',
- 'PROMEDIO' => 'float'
- );
+ $ROW[] = array ('FECHA' => 'char','CANTCASES' => 'integer','MIN' => 'float','MAX' => 'float','TOTALDUR' => 'float','PROMEDIO' => 'float'
+ );
- while($rs->next())
- {
- $ROW[] = array('FECHA' => $rs->getString('FECHA'),
- 'CANTCASES'=> $rs->getString('CANTCASES'),
- 'MIN' => number_format($rs->getString('MIN'),2),
- 'MAX' => number_format($rs->getString('MAX'),2),
- 'TOTALDUR' => number_format($rs->getString('TOTALDUR'),2),
- 'PROMEDIO' => number_format($rs->getString('PROMEDIO'),2)
- );
- }
+ while ($rs->next()) {
+ $ROW[] = array ('FECHA' => $rs->getString( 'FECHA' ),'CANTCASES' => $rs->getString( 'CANTCASES' ),'MIN' => number_format( $rs->getString( 'MIN' ), 2 ),'MAX' => number_format( $rs->getString( 'MAX' ), 2 ),'TOTALDUR' => number_format( $rs->getString( 'TOTALDUR' ), 2 ),'PROMEDIO' => number_format( $rs->getString( 'PROMEDIO' ), 2 )
+ );
+ }
- global $_DBArray;
- $_DBArray['reports'] = $ROW;
- $_SESSION['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('reports');
+ global $_DBArray;
+ $_DBArray['reports'] = $ROW;
+ $_SESSION['_DBArray'] = $_DBArray;
+ G::LoadClass( 'ArrayPeer' );
+ $oCriteria = new Criteria( 'dbarray' );
+ $oCriteria->setDBArrayTable( 'reports' );
- return $oCriteria;
+ return $oCriteria;
- }
-
- /**
- * This function looks for an special case it has a condition
- *
- *
- * @name generatedReport3_filter
- *
- * @param string $process
- * @param string $task
- * @return object
- */
- function generatedReport3_filter($process, $task)
- {
- $this->reportsPatch();
- require_once 'classes/model/AppDelegation.php';
- require_once 'classes/model/Application.php';
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
- if($process=='')
- { $var=" WHERE P.PRO_STATUS<>'DISABLED'";
}
- else
+
+ /**
+ * This function looks for an special case it has a condition
+ *
+ *
+ * @name generatedReport3_filter
+ *
+ * @param string $process
+ * @param string $task
+ * @return object
+ */
+ public function generatedReport3_filter ($process, $task)
{
- if($task=='')
- {
- $var=" LEFT JOIN TASK AS T ON (AD.TAS_UID = T.TAS_UID)
- WHERE P.PRO_STATUS<>'DISABLED' AND AD.PRO_UID='".$process."'";
- }
- else
- { $var=" LEFT JOIN TASK AS T ON (AD.TAS_UID = T.TAS_UID)
- WHERE P.PRO_STATUS<>'DISABLED' AND AD.PRO_UID='".$process."' AND AD.TAS_UID='".$task."' ";
- }
- }
- $sql = "SELECT CONCAT(SUBSTRING(AD.DEL_INIT_DATE,6,2),'-', SUBSTRING(AD.DEL_INIT_DATE,1,4)) AS FECHA,
+ $this->reportsPatch();
+ require_once 'classes/model/AppDelegation.php';
+ require_once 'classes/model/Application.php';
+ $oCriteria = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+ if ($process == '') {
+ $var = " WHERE P.PRO_STATUS<>'DISABLED'";
+ } else {
+ if ($task == '') {
+ $var = " LEFT JOIN TASK AS T ON (AD.TAS_UID = T.TAS_UID)
+ WHERE P.PRO_STATUS<>'DISABLED' AND AD.PRO_UID='" . $process . "'";
+ } else {
+ $var = " LEFT JOIN TASK AS T ON (AD.TAS_UID = T.TAS_UID)
+ WHERE P.PRO_STATUS<>'DISABLED' AND AD.PRO_UID='" . $process . "' AND AD.TAS_UID='" . $task . "' ";
+ }
+ }
+ $sql = "SELECT CONCAT(SUBSTRING(AD.DEL_INIT_DATE,6,2),'-', SUBSTRING(AD.DEL_INIT_DATE,1,4)) AS FECHA,
COUNT(DISTINCT(AD.APP_UID)) AS CANTCASES,
MIN(AD.DEL_DURATION) AS MIN,
MAX(AD.DEL_DURATION) AS MAX,
@@ -632,60 +594,49 @@ class Report {
AVG(AD.DEL_DURATION) AS PROMEDIO
FROM APP_DELEGATION AS AD
LEFT JOIN PROCESS AS P ON (P.PRO_UID = AD.PRO_UID)
- ".$var."
+ " . $var . "
GROUP BY FECHA";
- $con = Propel::getConnection("workflow");
- $stmt = $con->prepareStatement($sql);
- $rs = $stmt->executeQuery();
- $ROW[] = array('FECHA' => 'char',
- 'CANTCASES' => 'integer',
- 'MIN' => 'float',
- 'MAX' => 'float',
- 'TOTALDUR' => 'float',
- 'PROMEDIO' => 'float'
- );
+ $con = Propel::getConnection( "workflow" );
+ $stmt = $con->prepareStatement( $sql );
+ $rs = $stmt->executeQuery();
+ $ROW[] = array ('FECHA' => 'char','CANTCASES' => 'integer','MIN' => 'float','MAX' => 'float','TOTALDUR' => 'float','PROMEDIO' => 'float'
+ );
- while($rs->next())
- {
- $ROW[] = array('FECHA' => $rs->getString('FECHA'),
- 'CANTCASES' => $rs->getString('CANTCASES'),
- 'MIN' => number_format($rs->getString('MIN'),2),
- 'MAX' => number_format($rs->getString('MAX'),2),
- 'TOTALDUR' => number_format($rs->getString('TOTALDUR'),2),
- 'PROMEDIO' => number_format($rs->getString('PROMEDIO'),2)
- );
- }
+ while ($rs->next()) {
+ $ROW[] = array ('FECHA' => $rs->getString( 'FECHA' ),'CANTCASES' => $rs->getString( 'CANTCASES' ),'MIN' => number_format( $rs->getString( 'MIN' ), 2 ),'MAX' => number_format( $rs->getString( 'MAX' ), 2 ),'TOTALDUR' => number_format( $rs->getString( 'TOTALDUR' ), 2 ),'PROMEDIO' => number_format( $rs->getString( 'PROMEDIO' ), 2 )
+ );
+ }
- global $_DBArray;
- $_DBArray['reports'] = $ROW;
- $_SESSION['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('reports');
+ global $_DBArray;
+ $_DBArray['reports'] = $ROW;
+ $_SESSION['_DBArray'] = $_DBArray;
+ G::LoadClass( 'ArrayPeer' );
+ $oCriteria = new Criteria( 'dbarray' );
+ $oCriteria->setDBArrayTable( 'reports' );
- return $oCriteria;
- }
+ return $oCriteria;
+ }
- /**
- * This function generates a report
- *
- *
- * @name generatedReport4
- *
- * param
- * @return object
- */
- function generatedReport4()
- {
- $this->reportsPatch();
- require_once 'classes/model/AppDelegation.php';
- require_once 'classes/model/Application.php';
- require_once 'classes/model/Process.php';
- require_once 'classes/model/Users.php';
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
- $sql = "SELECT CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER,
+ /**
+ * This function generates a report
+ *
+ *
+ * @name generatedReport4
+ *
+ * param
+ * @return object
+ */
+ public function generatedReport4 ()
+ {
+ $this->reportsPatch();
+ require_once 'classes/model/AppDelegation.php';
+ require_once 'classes/model/Application.php';
+ require_once 'classes/model/Process.php';
+ require_once 'classes/model/Users.php';
+ $oCriteria = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+ $sql = "SELECT CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER,
COUNT(*) AS CANTCASES,
MIN(AD.DEL_DURATION) AS MIN,
MAX(AD.DEL_DURATION) AS MAX,
@@ -696,78 +647,62 @@ class Report {
LEFT JOIN USERS AS U ON(U.USR_UID = A.APP_INIT_USER)
WHERE A.APP_UID<>''
GROUP BY USER";
- // AND P.PRO_STATUS<>'DISABLED' that hapens when it is created to new version it exists at the moment to import
- $con = Propel::getConnection("workflow");
- $stmt = $con->prepareStatement($sql);
- $rs = $stmt->executeQuery();
+ // AND P.PRO_STATUS<>'DISABLED' that hapens when it is created to new version it exists at the moment to import
+ $con = Propel::getConnection( "workflow" );
+ $stmt = $con->prepareStatement( $sql );
+ $rs = $stmt->executeQuery();
- $ROW[] = array('USER' => 'char',
- 'CANTCASES' => 'integer',
- 'MIN' => 'float',
- 'MAX' => 'float',
- 'TOTALDUR' => 'float',
- 'PROMEDIO' => 'float'
- );
+ $ROW[] = array ('USER' => 'char','CANTCASES' => 'integer','MIN' => 'float','MAX' => 'float','TOTALDUR' => 'float','PROMEDIO' => 'float'
+ );
- while($rs->next())
- {
- $ROW[] = array('USER' => $rs->getString('USER'),
- 'CANTCASES'=> $rs->getString('CANTCASES'),
- 'MIN' => number_format($rs->getString('MIN'),2),
- 'MAX' => number_format($rs->getString('MAX'),2),
- 'TOTALDUR' => number_format($rs->getString('TOTALDUR'),2),
- 'PROMEDIO' => number_format($rs->getString('PROMEDIO'),2)
- );
- }
+ while ($rs->next()) {
+ $ROW[] = array ('USER' => $rs->getString( 'USER' ),'CANTCASES' => $rs->getString( 'CANTCASES' ),'MIN' => number_format( $rs->getString( 'MIN' ), 2 ),'MAX' => number_format( $rs->getString( 'MAX' ), 2 ),'TOTALDUR' => number_format( $rs->getString( 'TOTALDUR' ), 2 ),'PROMEDIO' => number_format( $rs->getString( 'PROMEDIO' ), 2 )
+ );
+ }
- global $_DBArray;
- $_DBArray['reports'] = $ROW;
- $_SESSION['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('reports');
+ global $_DBArray;
+ $_DBArray['reports'] = $ROW;
+ $_SESSION['_DBArray'] = $_DBArray;
+ G::LoadClass( 'ArrayPeer' );
+ $oCriteria = new Criteria( 'dbarray' );
+ $oCriteria->setDBArrayTable( 'reports' );
- return $oCriteria;
+ return $oCriteria;
- }
-
- /**
- * This function generates a filter to report 4
- *
- *
- * @name generatedReport4_filter
- *
- * @param string process
- * @param string task
- * @return object
- */
- function generatedReport4_filter($process, $task)
- {
- $this->reportsPatch();
- require_once 'classes/model/AppDelegation.php';
- require_once 'classes/model/Application.php';
- require_once 'classes/model/Process.php';
- require_once 'classes/model/Users.php';
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
- if($process=='')
- {
- $var=" ";
}
- else
+
+ /**
+ * This function generates a filter to report 4
+ *
+ *
+ * @name generatedReport4_filter
+ *
+ * @param string process
+ * @param string task
+ * @return object
+ */
+ public function generatedReport4_filter ($process, $task)
{
- if($task=='')
- {
- $var=" LEFT JOIN TASK AS T ON (AD.TAS_UID = T.TAS_UID)
- WHERE AD.PRO_UID='".$process."'";
- }
- else
- { $var=" LEFT JOIN TASK AS T ON (AD.TAS_UID = T.TAS_UID)
- WHERE AD.PRO_UID='".$process."' AND AD.TAS_UID='".$task."' ";
- }
- }
+ $this->reportsPatch();
+ require_once 'classes/model/AppDelegation.php';
+ require_once 'classes/model/Application.php';
+ require_once 'classes/model/Process.php';
+ require_once 'classes/model/Users.php';
+ $oCriteria = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+ if ($process == '') {
+ $var = " ";
+ } else {
+ if ($task == '') {
+ $var = " LEFT JOIN TASK AS T ON (AD.TAS_UID = T.TAS_UID)
+ WHERE AD.PRO_UID='" . $process . "'";
+ } else {
+ $var = " LEFT JOIN TASK AS T ON (AD.TAS_UID = T.TAS_UID)
+ WHERE AD.PRO_UID='" . $process . "' AND AD.TAS_UID='" . $task . "' ";
+ }
+ }
- $sql = "SELECT CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER,
+ $sql = "SELECT CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER,
COUNT(*) AS CANTCASES,
MIN(AD.DEL_DURATION) AS MIN,
MAX(AD.DEL_DURATION) AS MAX,
@@ -776,62 +711,51 @@ class Report {
FROM APPLICATION AS A
LEFT JOIN APP_DELEGATION AS AD ON(A.APP_UID = AD.APP_UID AND AD.DEL_INDEX=1)
LEFT JOIN USERS AS U ON(U.USR_UID = A.APP_INIT_USER)
- ".$var."
+ " . $var . "
GROUP BY USER";
- $con = Propel::getConnection("workflow");
- $stmt = $con->prepareStatement($sql);
- $rs = $stmt->executeQuery();
+ $con = Propel::getConnection( "workflow" );
+ $stmt = $con->prepareStatement( $sql );
+ $rs = $stmt->executeQuery();
- $ROW[] = array('USER' => 'char',
- 'CANTCASES' => 'integer',
- 'MIN' => 'float',
- 'MAX' => 'float',
- 'TOTALDUR' => 'float',
- 'PROMEDIO' => 'float'
- );
+ $ROW[] = array ('USER' => 'char','CANTCASES' => 'integer','MIN' => 'float','MAX' => 'float','TOTALDUR' => 'float','PROMEDIO' => 'float'
+ );
- while($rs->next())
- {
- $ROW[] = array('USER' => $rs->getString('USER'),
- 'CANTCASES' => $rs->getString('CANTCASES'),
- 'MIN' => number_format($rs->getString('MIN'),2),
- 'MAX' => number_format($rs->getString('MAX'),2),
- 'TOTALDUR' => number_format($rs->getString('TOTALDUR'),2),
- 'PROMEDIO' => number_format($rs->getString('PROMEDIO'),2)
- );
- }
+ while ($rs->next()) {
+ $ROW[] = array ('USER' => $rs->getString( 'USER' ),'CANTCASES' => $rs->getString( 'CANTCASES' ),'MIN' => number_format( $rs->getString( 'MIN' ), 2 ),'MAX' => number_format( $rs->getString( 'MAX' ), 2 ),'TOTALDUR' => number_format( $rs->getString( 'TOTALDUR' ), 2 ),'PROMEDIO' => number_format( $rs->getString( 'PROMEDIO' ), 2 )
+ );
+ }
- global $_DBArray;
- $_DBArray['reports'] = $ROW;
- $_SESSION['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('reports');
+ global $_DBArray;
+ $_DBArray['reports'] = $ROW;
+ $_SESSION['_DBArray'] = $_DBArray;
+ G::LoadClass( 'ArrayPeer' );
+ $oCriteria = new Criteria( 'dbarray' );
+ $oCriteria->setDBArrayTable( 'reports' );
- return $oCriteria;
- }
+ return $oCriteria;
+ }
- /**
- * This function generates a Report
- *
- *
- * @name generatedReport4_filter
- *
- * @param string process
- * @param string task
- * @return object
- */
- function generatedReport5()
- {
- $this->reportsPatch();
- require_once 'classes/model/AppDelegation.php';
- require_once 'classes/model/Application.php';
- require_once 'classes/model/Process.php';
- require_once 'classes/model/Users.php';
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
- $sql = "SELECT CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER,
+ /**
+ * This function generates a Report
+ *
+ *
+ * @name generatedReport4_filter
+ *
+ * @param string process
+ * @param string task
+ * @return object
+ */
+ public function generatedReport5 ()
+ {
+ $this->reportsPatch();
+ require_once 'classes/model/AppDelegation.php';
+ require_once 'classes/model/Application.php';
+ require_once 'classes/model/Process.php';
+ require_once 'classes/model/Users.php';
+ $oCriteria = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+ $sql = "SELECT CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER,
COUNT(*) AS CANTCASES,
MIN(AD.DEL_DURATION) AS MIN,
MAX(AD.DEL_DURATION) AS MAX,
@@ -843,75 +767,60 @@ class Report {
WHERE AD.APP_UID<>'' AND AD.DEL_FINISH_DATE IS NULL
GROUP BY USER";
- $con = Propel::getConnection("workflow");
- $stmt = $con->prepareStatement($sql);
- $rs = $stmt->executeQuery();
+ $con = Propel::getConnection( "workflow" );
+ $stmt = $con->prepareStatement( $sql );
+ $rs = $stmt->executeQuery();
- $ROW[] = array('USER' => 'char',
- 'CANTCASES' => 'integer',
- 'MIN' => 'float',
- 'MAX' => 'float',
- 'TOTALDUR' => 'float',
- 'PROMEDIO' => 'float'
- );
+ $ROW[] = array ('USER' => 'char','CANTCASES' => 'integer','MIN' => 'float','MAX' => 'float','TOTALDUR' => 'float','PROMEDIO' => 'float'
+ );
- while($rs->next())
- {
- $ROW[] = array('USER' => $rs->getString('USER'),
- 'CANTCASES'=> $rs->getString('CANTCASES'),
- 'MIN' => number_format($rs->getString('MIN'),2),
- 'MAX' => number_format($rs->getString('MAX'),2),
- 'TOTALDUR' => number_format($rs->getString('TOTALDUR'),2),
- 'PROMEDIO' => number_format($rs->getString('PROMEDIO'),2)
- );
- }
+ while ($rs->next()) {
+ $ROW[] = array ('USER' => $rs->getString( 'USER' ),'CANTCASES' => $rs->getString( 'CANTCASES' ),'MIN' => number_format( $rs->getString( 'MIN' ), 2 ),'MAX' => number_format( $rs->getString( 'MAX' ), 2 ),'TOTALDUR' => number_format( $rs->getString( 'TOTALDUR' ), 2 ),'PROMEDIO' => number_format( $rs->getString( 'PROMEDIO' ), 2 )
+ );
+ }
- global $_DBArray;
- $_DBArray['reports'] = $ROW;
- $_SESSION['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('reports');
+ global $_DBArray;
+ $_DBArray['reports'] = $ROW;
+ $_SESSION['_DBArray'] = $_DBArray;
+ G::LoadClass( 'ArrayPeer' );
+ $oCriteria = new Criteria( 'dbarray' );
+ $oCriteria->setDBArrayTable( 'reports' );
- return $oCriteria;
+ return $oCriteria;
- }
-
- /**
- * This function generates a filter to report 5
- *
- *
- * @name generatedReport5_filter
- *
- * @param string process
- * @param string task
- * @return object
- */
- function generatedReport5_filter($process, $task)
- {
- $this->reportsPatch();
- require_once 'classes/model/AppDelegation.php';
- require_once 'classes/model/Application.php';
- require_once 'classes/model/Process.php';
- require_once 'classes/model/Users.php';
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
- if($process=='')
- { $var=" WHERE AD.DEL_FINISH_DATE IS NULL";
}
- else
+
+ /**
+ * This function generates a filter to report 5
+ *
+ *
+ * @name generatedReport5_filter
+ *
+ * @param string process
+ * @param string task
+ * @return object
+ */
+ public function generatedReport5_filter ($process, $task)
{
- if($task=='')
- {
- $var=" LEFT JOIN TASK AS T ON (AD.TAS_UID = T.TAS_UID)
- WHERE AD.PRO_UID='".$process."' AND AD.DEL_FINISH_DATE IS NULL";
- }
- else
- { $var=" LEFT JOIN TASK AS T ON (AD.TAS_UID = T.TAS_UID)
- WHERE AD.PRO_UID='".$process."' AND AD.TAS_UID='".$task."' ";
- }
- }
- $sql = "SELECT CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER,
+ $this->reportsPatch();
+ require_once 'classes/model/AppDelegation.php';
+ require_once 'classes/model/Application.php';
+ require_once 'classes/model/Process.php';
+ require_once 'classes/model/Users.php';
+ $oCriteria = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+ if ($process == '') {
+ $var = " WHERE AD.DEL_FINISH_DATE IS NULL";
+ } else {
+ if ($task == '') {
+ $var = " LEFT JOIN TASK AS T ON (AD.TAS_UID = T.TAS_UID)
+ WHERE AD.PRO_UID='" . $process . "' AND AD.DEL_FINISH_DATE IS NULL";
+ } else {
+ $var = " LEFT JOIN TASK AS T ON (AD.TAS_UID = T.TAS_UID)
+ WHERE AD.PRO_UID='" . $process . "' AND AD.TAS_UID='" . $task . "' ";
+ }
+ }
+ $sql = "SELECT CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER,
COUNT(*) AS CANTCASES,
MIN(AD.DEL_DURATION) AS MIN,
MAX(AD.DEL_DURATION) AS MAX,
@@ -920,107 +829,96 @@ class Report {
FROM APP_DELEGATION AS AD
LEFT JOIN PROCESS AS P ON (P.PRO_UID = AD.PRO_UID)
LEFT JOIN USERS AS U ON(U.USR_UID = AD.USR_UID)
- ".$var."
+ " . $var . "
GROUP BY USER";
- $con = Propel::getConnection("workflow");
- $stmt = $con->prepareStatement($sql);
- $rs = $stmt->executeQuery();
+ $con = Propel::getConnection( "workflow" );
+ $stmt = $con->prepareStatement( $sql );
+ $rs = $stmt->executeQuery();
- $ROW[] = array('USER' => 'char',
- 'CANTCASES' => 'integer',
- 'MIN' => 'float',
- 'MAX' => 'float',
- 'TOTALDUR' => 'float',
- 'PROMEDIO' => 'float'
- );
+ $ROW[] = array ('USER' => 'char','CANTCASES' => 'integer','MIN' => 'float','MAX' => 'float','TOTALDUR' => 'float','PROMEDIO' => 'float'
+ );
- while($rs->next())
- {
- $ROW[] = array('USER' => $rs->getString('USER'),
- 'CANTCASES' => $rs->getString('CANTCASES'),
- 'MIN' => number_format($rs->getString('MIN'),2),
- 'MAX' => number_format($rs->getString('MAX'),2),
- 'TOTALDUR' => number_format($rs->getString('TOTALDUR'),2),
- 'PROMEDIO' => number_format($rs->getString('PROMEDIO'),2)
- );
- }
+ while ($rs->next()) {
+ $ROW[] = array ('USER' => $rs->getString( 'USER' ),'CANTCASES' => $rs->getString( 'CANTCASES' ),'MIN' => number_format( $rs->getString( 'MIN' ), 2 ),'MAX' => number_format( $rs->getString( 'MAX' ), 2 ),'TOTALDUR' => number_format( $rs->getString( 'TOTALDUR' ), 2 ),'PROMEDIO' => number_format( $rs->getString( 'PROMEDIO' ), 2 )
+ );
+ }
- global $_DBArray;
- $_DBArray['reports'] = $ROW;
- $_SESSION['_DBArray'] = $_DBArray;
- G::LoadClass('ArrayPeer');
- $oCriteria = new Criteria('dbarray');
- $oCriteria->setDBArrayTable('reports');
+ global $_DBArray;
+ $_DBArray['reports'] = $ROW;
+ $_SESSION['_DBArray'] = $_DBArray;
+ G::LoadClass( 'ArrayPeer' );
+ $oCriteria = new Criteria( 'dbarray' );
+ $oCriteria->setDBArrayTable( 'reports' );
- return $oCriteria;
- }
-
- /**
- * This function returns an array, it has the reports' names
- *
- *
- * @name getAvailableReports
- *
- * param
- * @return array
- */
- function getAvailableReports()
- {
- return array('ID_REPORT1', 'ID_REPORT2', 'ID_REPORT3', 'ID_REPORT4', 'ID_REPORT5');
- }
-
- /**
- * Patch for reports by The Answer (17-10-2k8)
- *
- *
- * @name reportsPatch
- *
- * param
- * @return void
- */
-
- function reportsPatch()
- {
- require_once 'classes/model/AppDelegation.php';
-
- $oCriteria = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
- $oCriteria->addSelectColumn(AppDelegationPeer::APP_UID);
- $oCriteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
- $oCriteria->addSelectColumn(AppDelegationPeer::TAS_UID);
- $oCriteria->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
- $oCriteria->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
- $oCriteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
- $oCriteria->addSelectColumn(AppDelegationPeer::DEL_DURATION);
- $oDataset = AppDelegationPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oAppDelegation = new AppDelegation();
-
- $aData['APP_UID']=$aRow['APP_UID'];
- $aData['DEL_INDEX']=$aRow['DEL_INDEX'];
- $aData['DEL_DELEGATE_DATE']=$aRow['DEL_DELEGATE_DATE'];
-
- if($aRow['DEL_INIT_DATE']==NULL)
- $aData['DEL_INIT_DATE']=$aRow['DEL_DELEGATE_DATE'];
- else
- $aData['DEL_INIT_DATE']=$aRow['DEL_INIT_DATE'];
-
- //$aData['DEL_FINISH_DATE']=$aRow['DEL_FINISH_DATE'];
- if($aRow['DEL_DURATION']!=0)
- {
- G::LoadClass('dates');
- $oDates = new dates();
- $aData['DEL_DURATION']= $oDates->calculateDuration($aData['DEL_INIT_DATE'], $aRow['DEL_FINISH_DATE'], null, null, $aRow['TAS_UID']);
+ return $oCriteria;
}
- $oAppDelegation->update($aData);
+ /**
+ * This function returns an array, it has the reports' names
+ *
+ *
+ * @name getAvailableReports
+ *
+ * param
+ * @return array
+ */
+ public function getAvailableReports ()
+ {
+ return array ('ID_REPORT1','ID_REPORT2','ID_REPORT3','ID_REPORT4','ID_REPORT5'
+ );
+ }
- $oDataset->next();
- }
- return;
- }
+ /**
+ * Patch for reports by The Answer (17-10-2k8)
+ *
+ *
+ * @name reportsPatch
+ *
+ * param
+ * @return void
+ */
+
+ public function reportsPatch ()
+ {
+ require_once 'classes/model/AppDelegation.php';
+
+ $oCriteria = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+ $oCriteria->addSelectColumn( AppDelegationPeer::APP_UID );
+ $oCriteria->addSelectColumn( AppDelegationPeer::DEL_INDEX );
+ $oCriteria->addSelectColumn( AppDelegationPeer::TAS_UID );
+ $oCriteria->addSelectColumn( AppDelegationPeer::DEL_DELEGATE_DATE );
+ $oCriteria->addSelectColumn( AppDelegationPeer::DEL_INIT_DATE );
+ $oCriteria->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );
+ $oCriteria->addSelectColumn( AppDelegationPeer::DEL_DURATION );
+ $oDataset = AppDelegationPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oAppDelegation = new AppDelegation();
+
+ $aData['APP_UID'] = $aRow['APP_UID'];
+ $aData['DEL_INDEX'] = $aRow['DEL_INDEX'];
+ $aData['DEL_DELEGATE_DATE'] = $aRow['DEL_DELEGATE_DATE'];
+
+ if ($aRow['DEL_INIT_DATE'] == NULL)
+ $aData['DEL_INIT_DATE'] = $aRow['DEL_DELEGATE_DATE'];
+ else
+ $aData['DEL_INIT_DATE'] = $aRow['DEL_INIT_DATE'];
+
+ //$aData['DEL_FINISH_DATE']=$aRow['DEL_FINISH_DATE'];
+ if ($aRow['DEL_DURATION'] != 0) {
+ G::LoadClass( 'dates' );
+ $oDates = new dates();
+ $aData['DEL_DURATION'] = $oDates->calculateDuration( $aData['DEL_INIT_DATE'], $aRow['DEL_FINISH_DATE'], null, null, $aRow['TAS_UID'] );
+ }
+
+ $oAppDelegation->update( $aData );
+
+ $oDataset->next();
+ }
+ return;
+ }
}// end Report class
\ No newline at end of file
diff --git a/workflow/engine/classes/class.reportTables.php b/workflow/engine/classes/class.reportTables.php
index a751f19c8..70ab7b461 100755
--- a/workflow/engine/classes/class.reportTables.php
+++ b/workflow/engine/classes/class.reportTables.php
@@ -1,6 +1,7 @@
.
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
-G::LoadClass('case');
+G::LoadClass( 'case' );
/**
* ReportTables - Report tables class
+ *
* @package workflow.engine.ProcessMaker
* @author Julio Cesar Laura Avenda�o
* @copyright 2007 COLOSA
@@ -35,798 +37,789 @@ G::LoadClass('case');
class ReportTables
{
- private $aDef = array('mysql' => array('number' => 'DOUBLE',
- 'char' => 'VARCHAR(255)',
- 'text' => 'TEXT',
- 'date' => 'DATETIME'),
- 'pgsql' => array('number' => 'DOUBLE',
- 'char' => 'VARCHAR(255)',
- 'text' => 'TEXT',
- 'date' => 'DATETIME'),
- 'mssql' => array('number' => 'FLOAT',
- 'char' => 'NVARCHAR(255)',
- 'text' => 'TEXT',
- 'date' => 'CHAR(19)') /* Changed DATETIME CHAR(19) for compatibility issues. */
+ private $aDef = array ('mysql' => array ('number' => 'DOUBLE','char' => 'VARCHAR(255)','text' => 'TEXT','date' => 'DATETIME'
+ ),'pgsql' => array ('number' => 'DOUBLE','char' => 'VARCHAR(255)','text' => 'TEXT','date' => 'DATETIME'
+ ),'mssql' => array ('number' => 'FLOAT','char' => 'NVARCHAR(255)','text' => 'TEXT','date' => 'CHAR(19)'
+ ) /* Changed DATETIME CHAR(19) for compatibility issues. */
);
- //private $sPrefix = 'REP_';
- private $sPrefix = '';
-
- /**
- * Function deleteAllReportVars
- * This function delete all reports
- * @access public
- * @param string $$sRepTabUid
- * @return void
- */
- public function deleteAllReportVars($sRepTabUid = '')
- {
- try {
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(ReportVarPeer::REP_TAB_UID, $sRepTabUid);
- ReportVarPeer::doDelete($oCriteria);
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Function prepareQuery
- * This function removes the table
- * @access public
- * @param string $sTableName Table name
- * @param string $sConnection Conexion
- * @return void
- */
- public function dropTable($sTableName, $sConnection = 'report')
- {
- $sTableName = $this->sPrefix . $sTableName;
- //we have to do the propel connection
- $PropelDatabase=$this->chooseDB($sConnection);
- $con = Propel::getConnection($PropelDatabase);
- $stmt = $con->createStatement();
- try {
- switch (DB_ADAPTER) {
- case 'mysql':
- $rs = $stmt->executeQuery( 'DROP TABLE IF EXISTS `' . $sTableName . '`');
- break;
- case 'mssql':
- $rs = $stmt->executeQuery( "IF OBJECT_ID (N'" . $sTableName . "', N'U') IS NOT NULL
- DROP TABLE [" . $sTableName . "]");
- break;
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Function createTable
- * This Function creates the table
- * @access public
- * @param string $sTableName Table name
- * @param string $sConnection Connection name
- * @param string $sType
- * @param array $aFields
- * @param string $bDefaultFields
- * @return void
- */
- public function createTable($sTableName, $sConnection = 'report', $sType = 'NORMAL', $aFields = array(), $bDefaultFields = true)
- {
- $sTableName = $this->sPrefix . $sTableName;
- //we have to do the propel connection
- $PropelDatabase=$this->chooseDB($sConnection);
- $con = Propel::getConnection($PropelDatabase);
- $stmt = $con->createStatement();
- try {
- switch (DB_ADAPTER) {
- case 'mysql':
- $sQuery = 'CREATE TABLE IF NOT EXISTS `' . $sTableName . '` (';
- if ($bDefaultFields) {
- $sQuery .= "`APP_UID` VARCHAR(32) NOT NULL DEFAULT '',`APP_NUMBER` INT NOT NULL,";
- if ($sType == 'GRID') {
- $sQuery .= "`ROW` INT NOT NULL,";
- }
- }
- foreach ($aFields as $aField) {
- switch ($aField['sType']) {
- case 'number':
- $sQuery .= '`' . $aField['sFieldName'] . '` ' . $this->aDef['mysql'][$aField['sType']] . " NOT NULL DEFAULT '0',";
- break;
- case 'char':
- $sQuery .= '`' . $aField['sFieldName'] . '` ' . $this->aDef['mysql'][$aField['sType']] . " NOT NULL DEFAULT '',";
- break;
- case 'text':
- $sQuery .= '`' . $aField['sFieldName'] . '` ' . $this->aDef['mysql'][$aField['sType']] . " ,";
- break;
- case 'date':
- $sQuery .= '`' . $aField['sFieldName'] . '` ' . $this->aDef['mysql'][$aField['sType']] . " NULL,";
- break;
- }
- }
- if ($bDefaultFields) {
- $sQuery .= 'PRIMARY KEY (APP_UID' . ($sType == 'GRID' ? ',ROW' : '') . ')) ';
- }
- $sQuery .= ' DEFAULT CHARSET=utf8;';
- $rs = $stmt->executeQuery( $sQuery );
- break;
+ //private $sPrefix = 'REP_';
+ private $sPrefix = '';
- case 'mssql':
- $sQuery = 'CREATE TABLE [' . $sTableName . '] (';
- if ($bDefaultFields) {
- $sQuery .= "[APP_UID] VARCHAR(32) NOT NULL DEFAULT '', [APP_NUMBER] INT NOT NULL,";
- if ($sType == 'GRID') {
- $sQuery .= "[ROW] INT NOT NULL,";
- }
- }
- foreach ($aFields as $aField) {
- switch ($aField['sType']) {
- case 'number':
- $sQuery .= '[' . $aField['sFieldName'] . '] ' . $this->aDef['mssql'][$aField['sType']] . " NOT NULL DEFAULT '0',";
- break;
- case 'char':
- $sQuery .= '[' . $aField['sFieldName'] . '] ' . $this->aDef['mssql'][$aField['sType']] . " NOT NULL DEFAULT '',";
- break;
- case 'text':
- $sQuery .= '[' . $aField['sFieldName'] . '] ' . $this->aDef['mssql'][$aField['sType']] . " NOT NULL DEFAULT '',";
- break;
- case 'date':
- $sQuery .= '[' . $aField['sFieldName'] . '] ' . $this->aDef['mssql'][$aField['sType']] . " NULL,";
- break;
- }
- }
- if ($bDefaultFields) {
- $sQuery .= 'PRIMARY KEY (APP_UID' . ($sType == 'GRID' ? ',ROW' : '') . ')) ';
- }
- else {
- $sQuery .= ' ';
- }
-
- $rs = $stmt->executeQuery( $sQuery );
- break;
-
- }
+ /**
+ * Function deleteAllReportVars
+ * This function delete all reports
+ *
+ * @access public
+ * @param string $$sRepTabUid
+ * @return void
+ */
+ public function deleteAllReportVars ($sRepTabUid = '')
+ {
+ try {
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( ReportVarPeer::REP_TAB_UID, $sRepTabUid );
+ ReportVarPeer::doDelete( $oCriteria );
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Function populateTable
- * This Function fills the table
- * @access public
- * @param string $sTableName Table name
- * @param string $sConnection Connection name
- * @param string $sType
- * @param array $aFields
- * @param string $sProcessUid
- * @param string $sGrid
- * @return void
- */
- public function populateTable($sTableName, $sConnection = 'report', $sType = 'NORMAL', $aFields = array(), $sProcessUid = '', $sGrid = '')
- {
- $sTableName = $this->sPrefix . $sTableName;
- //we have to do the propel connection
- $PropelDatabase=$this->chooseDB($sConnection);
- $con = Propel::getConnection($PropelDatabase);
- $stmt = $con->createStatement();
- if ($sType == 'GRID') {
- $aAux = explode('-', $sGrid);
- $sGrid = $aAux[0];
- }
- try {
- switch (DB_ADAPTER) {
- case 'mysql':
- //select cases for this Process, ordered by APP_NUMBER
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUid);
- $oCriteria->addAscendingOrderByColumn(ApplicationPeer::APP_NUMBER);
- $oDataset = ApplicationPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $aData = unserialize($aRow['APP_DATA']);
- //delete previous record from this report table ( previous records in case this is a grid )
- $deleteSql = 'DELETE FROM `' . $sTableName . "` WHERE APP_UID = '" . $aRow['APP_UID'] . "'";
- $rsDel = $stmt->executeQuery( $deleteSql );
- if ($sType == 'NORMAL') {
- $sQuery = 'INSERT INTO `' . $sTableName . '` (';
- $sQuery .= '`APP_UID`,`APP_NUMBER`';
- foreach ($aFields as $aField) {
- $sQuery .= ',`' . $aField['sFieldName'] . '`';
- }
- $sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int)$aRow['APP_NUMBER'];
- foreach ($aFields as $aField) {
- switch ($aField['sType']) {
- case 'number':
- $sQuery .= ',' . (isset($aData[$aField['sFieldName']]) ? (float)str_replace(',', '', $aData[$aField['sFieldName']]) : '0');
+
+ /**
+ * Function prepareQuery
+ * This function removes the table
+ *
+ * @access public
+ * @param string $sTableName Table name
+ * @param string $sConnection Conexion
+ * @return void
+ */
+ public function dropTable ($sTableName, $sConnection = 'report')
+ {
+ $sTableName = $this->sPrefix . $sTableName;
+ //we have to do the propel connection
+ $PropelDatabase = $this->chooseDB( $sConnection );
+ $con = Propel::getConnection( $PropelDatabase );
+ $stmt = $con->createStatement();
+ try {
+ switch (DB_ADAPTER) {
+ case 'mysql':
+ $rs = $stmt->executeQuery( 'DROP TABLE IF EXISTS `' . $sTableName . '`' );
break;
- case 'char':
- case 'text':
- if (!isset($aData[$aField['sFieldName']])) {
- $aData[$aField['sFieldName']] = '';
- }
- $sQuery .= ",'" . (isset($aData[$aField['sFieldName']]) ? mysql_real_escape_string($aData[$aField['sFieldName']]) : '') . "'";
+ case 'mssql':
+ $rs = $stmt->executeQuery( "IF OBJECT_ID (N'" . $sTableName . "', N'U') IS NOT NULL
+ DROP TABLE [" . $sTableName . "]" );
break;
- case 'date':
- $value = (isset($aData[$aField['sFieldName']]) && trim($aData[$aField['sFieldName']])) != '' ? "'" . $aData[$aField['sFieldName']] . "'" : 'NULL';
- $sQuery .= "," . $value;
- break;
- }
- }
- $sQuery .= ')';
- $rs = $stmt->executeQuery( $sQuery );
}
- else {
- if (isset($aData[$sGrid])) {
- foreach ($aData[$sGrid] as $iRow => $aGridRow) {
- $sQuery = 'INSERT INTO `' . $sTableName . '` (';
- $sQuery .= '`APP_UID`,`APP_NUMBER`,`ROW`';
- foreach ($aFields as $aField) {
- $sQuery .= ',`' . $aField['sFieldName'] . '`';
- }
- $sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int)$aRow['APP_NUMBER'] . ',' . $iRow;
- foreach ($aFields as $aField) {
- switch ($aField['sType']) {
- case 'number':
- $sQuery .= ',' . (isset($aGridRow[$aField['sFieldName']]) ? (float)str_replace(',', '', $aGridRow[$aField['sFieldName']]) : '0');
- break;
- case 'char':
- case 'text':
- if (!isset($aGridRow[$aField['sFieldName']])) {
- $aGridRow[$aField['sFieldName']] = '';
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * Function createTable
+ * This Function creates the table
+ *
+ * @access public
+ * @param string $sTableName Table name
+ * @param string $sConnection Connection name
+ * @param string $sType
+ * @param array $aFields
+ * @param string $bDefaultFields
+ * @return void
+ */
+ public function createTable ($sTableName, $sConnection = 'report', $sType = 'NORMAL', $aFields = array(), $bDefaultFields = true)
+ {
+ $sTableName = $this->sPrefix . $sTableName;
+ //we have to do the propel connection
+ $PropelDatabase = $this->chooseDB( $sConnection );
+ $con = Propel::getConnection( $PropelDatabase );
+ $stmt = $con->createStatement();
+ try {
+ switch (DB_ADAPTER) {
+ case 'mysql':
+ $sQuery = 'CREATE TABLE IF NOT EXISTS `' . $sTableName . '` (';
+ if ($bDefaultFields) {
+ $sQuery .= "`APP_UID` VARCHAR(32) NOT NULL DEFAULT '',`APP_NUMBER` INT NOT NULL,";
+ if ($sType == 'GRID') {
+ $sQuery .= "`ROW` INT NOT NULL,";
}
- $sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? mysql_real_escape_string($aGridRow[$aField['sFieldName']]) : '') . "'";
- break;
- case 'date':
- $value = (isset($aGridRow[$aField['sFieldName']]) && trim($aGridRow[$aField['sFieldName']])) != '' ? "'" . $aGridRow[$aField['sFieldName']] . "'" : 'NULL';
- $sQuery .= "," . $value;
- break;
}
- }
- $sQuery .= ')';
- $rs = $stmt->executeQuery( $sQuery );
- }
- }
- }
- $oDataset->next();
- }
- break;
-
- /**
- * For SQLServer code
- */
- case 'mssql':
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUid);
- $oCriteria->addAscendingOrderByColumn(ApplicationPeer::APP_NUMBER);
- $oDataset = ApplicationPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $aData = unserialize($aRow['APP_DATA']);
- mysql_query('DELETE FROM [' . $sTableName . "] WHERE APP_UID = '" . $aRow['APP_UID'] . "'");
- if ($sType == 'NORMAL') {
- $sQuery = 'INSERT INTO [' . $sTableName . '] (';
- $sQuery .= '[APP_UID],[APP_NUMBER]';
- foreach ($aFields as $aField) {
- $sQuery .= ',[' . $aField['sFieldName'] . ']';
- }
- $sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int)$aRow['APP_NUMBER'];
- foreach ($aFields as $aField) {
- switch ($aField['sType']) {
- case 'number':
- $sQuery .= ',' . (isset($aData[$aField['sFieldName']]) ? (float)str_replace(',', '', $aData[$aField['sFieldName']]) : '0');
- break;
- case 'char':
- case 'text':
- if (!isset($aData[$aField['sFieldName']])) {
- $aData[$aField['sFieldName']] = '';
- }
- $sQuery .= ",'" . (isset($aData[$aField['sFieldName']]) ? mysql_real_escape_string($aData[$aField['sFieldName']]) : '') . "'";
- break;
- case 'date':
- $sQuery .= ",'" . (isset($aData[$aField['sFieldName']]) ? $aData[$aField['sFieldName']] : '') . "'";
- break;
- }
- }
- $sQuery .= ')';
- $rs = $stmt->executeQuery( $sQuery );
- }
- else {
- if (isset($aData[$sGrid])) {
- foreach ($aData[$sGrid] as $iRow => $aGridRow) {
- $sQuery = 'INSERT INTO [' . $sTableName . '] (';
- $sQuery .= '`APP_UID`,`APP_NUMBER`,`ROW`';
foreach ($aFields as $aField) {
- $sQuery .= ',[' . $aField['sFieldName'] . ']';
+ switch ($aField['sType']) {
+ case 'number':
+ $sQuery .= '`' . $aField['sFieldName'] . '` ' . $this->aDef['mysql'][$aField['sType']] . " NOT NULL DEFAULT '0',";
+ break;
+ case 'char':
+ $sQuery .= '`' . $aField['sFieldName'] . '` ' . $this->aDef['mysql'][$aField['sType']] . " NOT NULL DEFAULT '',";
+ break;
+ case 'text':
+ $sQuery .= '`' . $aField['sFieldName'] . '` ' . $this->aDef['mysql'][$aField['sType']] . " ,";
+ break;
+ case 'date':
+ $sQuery .= '`' . $aField['sFieldName'] . '` ' . $this->aDef['mysql'][$aField['sType']] . " NULL,";
+ break;
+ }
}
- $sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int)$aRow['APP_NUMBER'] . ',' . $iRow;
- foreach ($aFields as $aField) {
- switch ($aField['sType']) {
- case 'number':
- $sQuery .= ',' . (isset($aGridRow[$aField['sFieldName']]) ? (float)str_replace(',', '', $aGridRow[$aField['sFieldName']]) : '0');
- break;
- case 'char':
- case 'text':
- if (!isset($aGridRow[$aField['sFieldName']])) {
- $aGridRow[$aField['sFieldName']] = '';
- }
- $sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? mysql_real_escape_string($aGridRow[$aField['sFieldName']]) : '') . "'";
- break;
- case 'date':
- $sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? $aGridRow[$aField['sFieldName']] : '') . "'";
- break;
- }
+ if ($bDefaultFields) {
+ $sQuery .= 'PRIMARY KEY (APP_UID' . ($sType == 'GRID' ? ',ROW' : '') . ')) ';
}
- $sQuery .= ')';
+ $sQuery .= ' DEFAULT CHARSET=utf8;';
$rs = $stmt->executeQuery( $sQuery );
- }
- }
- }
- $oDataset->next();
- }
- break;
-
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Function getTableVars
- * @access public
- * @param string $sRepTabUid
- * @param boolean $bWhitType
- * @return void
- */
- public function getTableVars($sRepTabUid, $bWhitType = false)
- {
- try {
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(ReportVarPeer::REP_TAB_UID, $sRepTabUid);
- $oDataset = ReportVarPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aVars = array();
- $aImportedVars = array();//This array will help to control if the variable already exist
- while ($aRow = $oDataset->getRow()) {
- if ($bWhitType) {
- if (!in_array($aRow['REP_VAR_NAME'], $aImportedVars)) {
- $aImportedVars[]=$aRow['REP_VAR_NAME'];
- $aVars[] = array('sFieldName' => $aRow['REP_VAR_NAME'], 'sType' => $aRow['REP_VAR_TYPE']);
- }
- }else {
- $aVars[] = $aRow['REP_VAR_NAME'];
- }
- $oDataset->next();
- }
- return $aVars;
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Function deleteReportTable
- * This Function deletes report table
- * @access public
- * @param string $sRepTabUid
- * @return void
- */
- public function deleteReportTable($sRepTabUid)
- {
- try {
- $oReportTable = new ReportTable();
- $aFields = $oReportTable->load($sRepTabUid);
- if(!(empty($aFields))){
- $this->dropTable($aFields['REP_TAB_NAME'], $aFields['REP_TAB_CONNECTION']);
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(ReportVarPeer::REP_TAB_UID, $sRepTabUid);
- $oDataset = ReportVarPeer::doDelete($oCriteria);
- $oReportTable->remove($sRepTabUid);
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Function getSplitDate
- * This function gets the split date
- * @access public
- * @param date $date
- * @param string $mask
- * @return array
- */
- function getSplitDate($date, $mask)
- {
- $sw1 = false;
- for($i=0; $i<3; $i++){
- $item = substr($mask, $i*2, 1);
- switch($item){
- case 'Y':
- switch($i){
- case 0:
- $d1 = substr($date, 0, 4);
- break;
- case 1:
- $d1 = substr($date, 3, 4);
- break;
- case 2:
- $d1 = substr($date, 6, 4);
- break;
- }
- $sw1 = true;
- break;
- case 'y':
- switch($i){
- case 0:
- $d1 = substr($date, 0, 2);
- break;
- case 1:
- $d1 = substr($date, 3, 2);
- break;
- case 2:
- $d1 = substr($date, 6, 2);
- break;
- }
- break;
- case 'm':
- switch($i){
- case 0:
- $d2 = substr($date, 0, 2);
- break;
- case 1:
- $d2 = ($sw1)? substr($date, 5, 2): substr($date, 3, 2);
- break;
- case 2:
- $d2 = ($sw1)? substr($date, 8, 2): substr($date, 5, 2);
- break;
- }
- break;
- case 'd':
- switch($i){
- case 0:
- $d3 = substr($date, 0, 2);
- break;
- case 1:
- $d3 = ($sw1)? substr($date, 5, 2): substr($date, 3, 2);
- break;
- case 2:
- $d3 = ($sw1)? substr($date, 8, 2): substr($date, 5, 2);
- break;
- }
- break;
- }
- }
- return Array(isset($d1)?$d1:'', isset($d2)?$d2:'', isset($d3)?$d3:'');
- }
-
- /**
- * Function getFormatDate
- * This function returns the date formated
- * @access public
- * @param date $sDate
- * @param date $sMask
- * @return date
- */
- function getFormatDate($sDate, $sMask)
- {
- //print $sDate." *** ". $sMask."
";
- $dateTime = explode(" ",$sDate); //To accept the Hour part
- $aDate = explode ( '-', str_replace("/", "-", $dateTime[0]) );
- $bResult = true;
- foreach($aDate as $sDate){
- if( !is_numeric($sDate) ){
- $bResult = false;
- break;
- }
- }
- if( $sMask != '' ){
- $aDate = $this->getSplitDate($dateTime[0], $sMask);
- $aDate[0] = ($aDate[0] == '')? date('Y'): $aDate[0];
- $aDate[1] = ($aDate[1] == '')? date('m'): $aDate[1];
- $aDate[2] = ($aDate[2] == '')? date('d'): $aDate[2];
- if( checkdate($aDate[1], $aDate[2], $aDate[0]) ){
- } else {
- return false;
- }
- }
- $sDateC='';
- for($i=0;$i< count($aDate);$i++){
- $sDateC.= (($i==0)?"":"-") .$aDate[$i];
- }
- return ($sDateC);
- }
-
- /**
- * Function updateTables
- * This function updated the Report Tables
- * @access public
- * @param string $sProcessUid
- * @param string $sApplicationUid
- * @param string $iApplicationNumber
- * @param string $aFields
- * @return void
- */
- public function updateTables($sProcessUid, $sApplicationUid, $iApplicationNumber, $aFields)
- {
- try {
- //get all Active Report Tables
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(ReportTablePeer::PRO_UID, $sProcessUid);
- $oCriteria->add(ReportTablePeer::REP_TAB_STATUS, 'ACTIVE');
- $oDataset = ReportTablePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aVars = array();
- while ($aRow = $oDataset->getRow()) {
- $aRow['REP_TAB_NAME'] = $this->sPrefix . $aRow['REP_TAB_NAME'];
- $PropelDatabase=$this->chooseDB($aRow['REP_TAB_CONNECTION']);
- $con = Propel::getConnection($PropelDatabase);
- $stmt = $con->createStatement();
- switch (DB_ADAPTER) {
+ break;
- case 'mysql':
- $aTableFields = $this->getTableVars($aRow['REP_TAB_UID'], true);
- if ($aRow['REP_TAB_TYPE'] == 'NORMAL') {
- $sqlExists = "SELECT * FROM `" . $aRow['REP_TAB_NAME'] . "` WHERE APP_UID = '" . $sApplicationUid . "'";
- $rsExists = $stmt->executeQuery( $sqlExists, ResultSet::FETCHMODE_ASSOC);
- $rsExists->next();
- $aRow2 = $rsExists->getRow();
-
- if ( is_array( $aRow2) ) {
- $sQuery = 'UPDATE `' . $aRow['REP_TAB_NAME'] . '` SET ';
- foreach ($aTableFields as $aField) {
- $sQuery .= '`' . $aField['sFieldName'] . '` = ';
- switch ($aField['sType']) {
- case 'number':
- $sQuery .= (isset($aFields[$aField['sFieldName']]) ? (float)str_replace(',', '', $aFields[$aField['sFieldName']]) : '0') . ',';
- break;
- case 'char':
- case 'text':
- if (!isset($aFields[$aField['sFieldName']])) {
- $aFields[$aField['sFieldName']] = '';
- }
- $sQuery .= "'" . (isset($aFields[$aField['sFieldName']]) ? mysql_real_escape_string($aFields[$aField['sFieldName']]) : '') . "',";
- break;
- case 'date':
- $mysqlDate = (isset($aFields[$aField['sFieldName']]) ? $aFields[$aField['sFieldName']] : '') ;
- if ($mysqlDate!='') {
- $mysqlDate = str_replace('/', '-', $mysqlDate);
- $mysqlDate = date( 'Y-m-d', strtotime($mysqlDate) );
- }
- $value = trim($mysqlDate) != '' ? "'".$mysqlDate."'" : 'NULL';
- $sQuery .= $value . ",";
- break;
- }
- }
- $sQuery = substr($sQuery, 0, -1);
- $sQuery .= " WHERE APP_UID = '" . $sApplicationUid . "'";
- }
- else {
- $sQuery = 'INSERT INTO `' . $aRow['REP_TAB_NAME'] . '` (';
- $sQuery .= '`APP_UID`,`APP_NUMBER`';
- foreach ($aTableFields as $aField) {
- $sQuery .= ',`' . $aField['sFieldName'] . '`';
- }
- $sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int)$iApplicationNumber;
- foreach ($aTableFields as $aField) {
- switch ($aField['sType']) {
- case 'number':
- $sQuery .= ',' . (isset($aFields[$aField['sFieldName']]) ? (float)str_replace(',', '', $aFields[$aField['sFieldName']]) : '0');
- break;
- case 'char':
- case 'text':
- if (!isset($aFields[$aField['sFieldName']])) {
- $aFields[$aField['sFieldName']] = '';
- }
- $sQuery .= ",'" . (isset($aFields[$aField['sFieldName']]) ? mysql_real_escape_string($aFields[$aField['sFieldName']]) : '') . "'";
- break;
- case 'date':
- $mysqlDate = ( isset($aFields[$aField['sFieldName']]) ? $aFields[$aField['sFieldName']] : '' );
- if ($mysqlDate!='') {
- $mysqlDate = str_replace( '/', '-', $mysqlDate );
- $mysqlDate = date( 'Y-m-d', strtotime($mysqlDate) );
- }
- $value = trim($mysqlDate) != '' ? "'".$mysqlDate."'" : 'NULL';
- $sQuery .= "," . $value;
- break;
- }
- }
- $sQuery .= ')';
- }
- $rs = $stmt->executeQuery( $sQuery );
- }
- else {
- //remove old rows from database
- $sqlDelete = 'DELETE FROM `' . $aRow['REP_TAB_NAME'] . "` WHERE APP_UID = '" . $sApplicationUid . "'";
- $rsDelete = $stmt->executeQuery( $sqlDelete );
-
- $aAux = explode('-', $aRow['REP_TAB_GRID']);
- if (isset($aFields[$aAux[0]])) {
- foreach ($aFields[$aAux[0]] as $iRow => $aGridRow) {
- $sQuery = 'INSERT INTO `' . $aRow['REP_TAB_NAME'] . '` (';
- $sQuery .= '`APP_UID`,`APP_NUMBER`,`ROW`';
- foreach ($aTableFields as $aField) {
- $sQuery .= ',`' . $aField['sFieldName'] . '`';
- }
- $sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int)$iApplicationNumber . ',' . $iRow;
- foreach ($aTableFields as $aField) {
- switch ($aField['sType']) {
- case 'number':
- $sQuery .= ',' . (isset($aGridRow[$aField['sFieldName']]) ? (float)str_replace(',', '', $aGridRow[$aField['sFieldName']]) : '0');
- break;
- case 'char':
- case 'text':
- if (!isset($aGridRow[$aField['sFieldName']])) {
- $aGridRow[$aField['sFieldName']] = '';
- }
- $sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? mysql_real_escape_string($aGridRow[$aField['sFieldName']]) : '') . "'";
- break;
- case 'date':
- $sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? $aGridRow[$aField['sFieldName']] : '') . "'";
- break;
- }
- }
- $sQuery .= ')';
- $rs =$stmt->executeQuery( $sQuery );
- }
- }
- }
- break;
-
- /**
- * For SQLServer code
- */
- case 'mssql':
- $aTableFields = $this->getTableVars($aRow['REP_TAB_UID'], true);
- if ($aRow['REP_TAB_TYPE'] == 'NORMAL') {
- $oDataset2 = mssql_query("SELECT * FROM [" . $aRow['REP_TAB_NAME'] . "] WHERE APP_UID = '" . $sApplicationUid . "'");
- if ($aRow2 = mssql_fetch_row($oDataset2)) {
- $sQuery = 'UPDATE [' . $aRow['REP_TAB_NAME'] . '] SET ';
- foreach ($aTableFields as $aField) {
- $sQuery .= '[' . $aField['sFieldName'] . '] = ';
- switch ($aField['sType']) {
- case 'number':
- $sQuery .= (isset($aFields[$aField['sFieldName']]) ? (float)str_replace(',', '', $aFields[$aField['sFieldName']]) : '0') . ',';
- break;
- case 'char':
- case 'text':
- if (!isset($aFields[$aField['sFieldName']])) {
- $aFields[$aField['sFieldName']] = '';
- }
- $sQuery .= "'" . (isset($aFields[$aField['sFieldName']]) ? mysql_real_escape_string($aFields[$aField['sFieldName']]) : '') . "',";
- break;
- case 'date':
- $sQuery .= "'" . (isset($aFields[$aField['sFieldName']]) ? $aFields[$aField['sFieldName']] : '') . "',";
- break;
- }
- }
- $sQuery = substr($sQuery, 0, -1);
- $sQuery .= " WHERE APP_UID = '" . $sApplicationUid . "'";
- }
- else {
- $sQuery = 'INSERT INTO [' . $aRow['REP_TAB_NAME'] . '] (';
- $sQuery .= '[APP_UID],[APP_NUMBER]';
- foreach ($aTableFields as $aField) {
- $sQuery .= ',[' . $aField['sFieldName'] . ']';
- }
- $sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int)$iApplicationNumber;
- foreach ($aTableFields as $aField) {
- switch ($aField['sType']) {
- case 'number':
- $sQuery .= ',' . (isset($aFields[$aField['sFieldName']]) ? (float)str_replace(',', '', $aFields[$aField['sFieldName']]) : '0');
- break;
- case 'char':
- case 'text':
- if (!isset($aFields[$aField['sFieldName']])) {
- $aFields[$aField['sFieldName']] = '';
- }
- $sQuery .= ",'" . (isset($aFields[$aField['sFieldName']]) ? mysql_real_escape_string($aFields[$aField['sFieldName']]) : '') . "'";
- break;
- case 'date':
- $sQuery .= ",'" . (isset($aFields[$aField['sFieldName']]) ? $aFields[$aField['sFieldName']] : '') . "'";
- break;
- }
- }
- $sQuery .= ')';
- }
- $rs = $stmt->executeQuery( $sQuery );
- }
- else {
- mysql_query('DELETE FROM [' . $aRow['REP_TAB_NAME'] . "] WHERE APP_UID = '" . $sApplicationUid . "'");
- $aAux = explode('-', $aRow['REP_TAB_GRID']);
- if (isset($aFields[$aAux[0]])) {
- foreach ($aFields[$aAux[0]] as $iRow => $aGridRow) {
- $sQuery = 'INSERT INTO [' . $aRow['REP_TAB_NAME'] . '] (';
- $sQuery .= '[APP_UID],[APP_NUMBER],[ROW]';
- foreach ($aTableFields as $aField) {
- $sQuery .= ',[' . $aField['sFieldName'] . ']';
- }
- $sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int)$iApplicationNumber . ',' . $iRow;
- foreach ($aTableFields as $aField) {
- switch ($aField['sType']) {
- case 'number':
- $sQuery .= ',' . (isset($aGridRow[$aField['sFieldName']]) ? (float)str_replace(',', '', $aGridRow[$aField['sFieldName']]) : '0');
- break;
- case 'char':
- case 'text':
- if (!isset($aGridRow[$aField['sFieldName']])) {
- $aGridRow[$aField['sFieldName']] = '';
+ case 'mssql':
+ $sQuery = 'CREATE TABLE [' . $sTableName . '] (';
+ if ($bDefaultFields) {
+ $sQuery .= "[APP_UID] VARCHAR(32) NOT NULL DEFAULT '', [APP_NUMBER] INT NOT NULL,";
+ if ($sType == 'GRID') {
+ $sQuery .= "[ROW] INT NOT NULL,";
}
- $sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? mysql_real_escape_string($aGridRow[$aField['sFieldName']]) : '') . "'";
- break;
- case 'date':
- $sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? $aGridRow[$aField['sFieldName']] : '') . "'";
- break;
}
- }
- $sQuery .= ')';
- $rs =$stmt->executeQuery( $sQuery );
- }
- }
+ foreach ($aFields as $aField) {
+ switch ($aField['sType']) {
+ case 'number':
+ $sQuery .= '[' . $aField['sFieldName'] . '] ' . $this->aDef['mssql'][$aField['sType']] . " NOT NULL DEFAULT '0',";
+ break;
+ case 'char':
+ $sQuery .= '[' . $aField['sFieldName'] . '] ' . $this->aDef['mssql'][$aField['sType']] . " NOT NULL DEFAULT '',";
+ break;
+ case 'text':
+ $sQuery .= '[' . $aField['sFieldName'] . '] ' . $this->aDef['mssql'][$aField['sType']] . " NOT NULL DEFAULT '',";
+ break;
+ case 'date':
+ $sQuery .= '[' . $aField['sFieldName'] . '] ' . $this->aDef['mssql'][$aField['sType']] . " NULL,";
+ break;
+ }
+ }
+ if ($bDefaultFields) {
+ $sQuery .= 'PRIMARY KEY (APP_UID' . ($sType == 'GRID' ? ',ROW' : '') . ')) ';
+ } else {
+ $sQuery .= ' ';
+ }
+
+ $rs = $stmt->executeQuery( $sQuery );
+ break;
+
}
- break;
-
- }
- $oDataset->next();
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Function tableExist
- * Check if table exists
- * @access public
- * @return boolean
- */
- function tableExist()
- {
- /*
+
+ /**
+ * Function populateTable
+ * This Function fills the table
+ *
+ * @access public
+ * @param string $sTableName Table name
+ * @param string $sConnection Connection name
+ * @param string $sType
+ * @param array $aFields
+ * @param string $sProcessUid
+ * @param string $sGrid
+ * @return void
+ */
+ public function populateTable ($sTableName, $sConnection = 'report', $sType = 'NORMAL', $aFields = array(), $sProcessUid = '', $sGrid = '')
+ {
+ $sTableName = $this->sPrefix . $sTableName;
+ //we have to do the propel connection
+ $PropelDatabase = $this->chooseDB( $sConnection );
+ $con = Propel::getConnection( $PropelDatabase );
+ $stmt = $con->createStatement();
+ if ($sType == 'GRID') {
+ $aAux = explode( '-', $sGrid );
+ $sGrid = $aAux[0];
+ }
+ try {
+ switch (DB_ADAPTER) {
+ case 'mysql':
+ //select cases for this Process, ordered by APP_NUMBER
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( ApplicationPeer::PRO_UID, $sProcessUid );
+ $oCriteria->addAscendingOrderByColumn( ApplicationPeer::APP_NUMBER );
+ $oDataset = ApplicationPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aData = unserialize( $aRow['APP_DATA'] );
+ //delete previous record from this report table ( previous records in case this is a grid )
+ $deleteSql = 'DELETE FROM `' . $sTableName . "` WHERE APP_UID = '" . $aRow['APP_UID'] . "'";
+ $rsDel = $stmt->executeQuery( $deleteSql );
+ if ($sType == 'NORMAL') {
+ $sQuery = 'INSERT INTO `' . $sTableName . '` (';
+ $sQuery .= '`APP_UID`,`APP_NUMBER`';
+ foreach ($aFields as $aField) {
+ $sQuery .= ',`' . $aField['sFieldName'] . '`';
+ }
+ $sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int) $aRow['APP_NUMBER'];
+ foreach ($aFields as $aField) {
+ switch ($aField['sType']) {
+ case 'number':
+ $sQuery .= ',' . (isset( $aData[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aData[$aField['sFieldName']] ) : '0');
+ break;
+ case 'char':
+ case 'text':
+ if (! isset( $aData[$aField['sFieldName']] )) {
+ $aData[$aField['sFieldName']] = '';
+ }
+ $sQuery .= ",'" . (isset( $aData[$aField['sFieldName']] ) ? mysql_real_escape_string( $aData[$aField['sFieldName']] ) : '') . "'";
+ break;
+ case 'date':
+ $value = (isset( $aData[$aField['sFieldName']] ) && trim( $aData[$aField['sFieldName']] )) != '' ? "'" . $aData[$aField['sFieldName']] . "'" : 'NULL';
+ $sQuery .= "," . $value;
+ break;
+ }
+ }
+ $sQuery .= ')';
+ $rs = $stmt->executeQuery( $sQuery );
+ } else {
+ if (isset( $aData[$sGrid] )) {
+ foreach ($aData[$sGrid] as $iRow => $aGridRow) {
+ $sQuery = 'INSERT INTO `' . $sTableName . '` (';
+ $sQuery .= '`APP_UID`,`APP_NUMBER`,`ROW`';
+ foreach ($aFields as $aField) {
+ $sQuery .= ',`' . $aField['sFieldName'] . '`';
+ }
+ $sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int) $aRow['APP_NUMBER'] . ',' . $iRow;
+ foreach ($aFields as $aField) {
+ switch ($aField['sType']) {
+ case 'number':
+ $sQuery .= ',' . (isset( $aGridRow[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aGridRow[$aField['sFieldName']] ) : '0');
+ break;
+ case 'char':
+ case 'text':
+ if (! isset( $aGridRow[$aField['sFieldName']] )) {
+ $aGridRow[$aField['sFieldName']] = '';
+ }
+ $sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? mysql_real_escape_string( $aGridRow[$aField['sFieldName']] ) : '') . "'";
+ break;
+ case 'date':
+ $value = (isset( $aGridRow[$aField['sFieldName']] ) && trim( $aGridRow[$aField['sFieldName']] )) != '' ? "'" . $aGridRow[$aField['sFieldName']] . "'" : 'NULL';
+ $sQuery .= "," . $value;
+ break;
+ }
+ }
+ $sQuery .= ')';
+ $rs = $stmt->executeQuery( $sQuery );
+ }
+ }
+ }
+ $oDataset->next();
+ }
+ break;
+
+ /**
+ * For SQLServer code
+ */
+ case 'mssql':
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( ApplicationPeer::PRO_UID, $sProcessUid );
+ $oCriteria->addAscendingOrderByColumn( ApplicationPeer::APP_NUMBER );
+ $oDataset = ApplicationPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aData = unserialize( $aRow['APP_DATA'] );
+ mysql_query( 'DELETE FROM [' . $sTableName . "] WHERE APP_UID = '" . $aRow['APP_UID'] . "'" );
+ if ($sType == 'NORMAL') {
+ $sQuery = 'INSERT INTO [' . $sTableName . '] (';
+ $sQuery .= '[APP_UID],[APP_NUMBER]';
+ foreach ($aFields as $aField) {
+ $sQuery .= ',[' . $aField['sFieldName'] . ']';
+ }
+ $sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int) $aRow['APP_NUMBER'];
+ foreach ($aFields as $aField) {
+ switch ($aField['sType']) {
+ case 'number':
+ $sQuery .= ',' . (isset( $aData[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aData[$aField['sFieldName']] ) : '0');
+ break;
+ case 'char':
+ case 'text':
+ if (! isset( $aData[$aField['sFieldName']] )) {
+ $aData[$aField['sFieldName']] = '';
+ }
+ $sQuery .= ",'" . (isset( $aData[$aField['sFieldName']] ) ? mysql_real_escape_string( $aData[$aField['sFieldName']] ) : '') . "'";
+ break;
+ case 'date':
+ $sQuery .= ",'" . (isset( $aData[$aField['sFieldName']] ) ? $aData[$aField['sFieldName']] : '') . "'";
+ break;
+ }
+ }
+ $sQuery .= ')';
+ $rs = $stmt->executeQuery( $sQuery );
+ } else {
+ if (isset( $aData[$sGrid] )) {
+ foreach ($aData[$sGrid] as $iRow => $aGridRow) {
+ $sQuery = 'INSERT INTO [' . $sTableName . '] (';
+ $sQuery .= '`APP_UID`,`APP_NUMBER`,`ROW`';
+ foreach ($aFields as $aField) {
+ $sQuery .= ',[' . $aField['sFieldName'] . ']';
+ }
+ $sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int) $aRow['APP_NUMBER'] . ',' . $iRow;
+ foreach ($aFields as $aField) {
+ switch ($aField['sType']) {
+ case 'number':
+ $sQuery .= ',' . (isset( $aGridRow[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aGridRow[$aField['sFieldName']] ) : '0');
+ break;
+ case 'char':
+ case 'text':
+ if (! isset( $aGridRow[$aField['sFieldName']] )) {
+ $aGridRow[$aField['sFieldName']] = '';
+ }
+ $sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? mysql_real_escape_string( $aGridRow[$aField['sFieldName']] ) : '') . "'";
+ break;
+ case 'date':
+ $sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? $aGridRow[$aField['sFieldName']] : '') . "'";
+ break;
+ }
+ }
+ $sQuery .= ')';
+ $rs = $stmt->executeQuery( $sQuery );
+ }
+ }
+ }
+ $oDataset->next();
+ }
+ break;
+
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * Function getTableVars
+ *
+ * @access public
+ * @param string $sRepTabUid
+ * @param boolean $bWhitType
+ * @return void
+ */
+ public function getTableVars ($sRepTabUid, $bWhitType = false)
+ {
+ try {
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( ReportVarPeer::REP_TAB_UID, $sRepTabUid );
+ $oDataset = ReportVarPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ $aVars = array ();
+ $aImportedVars = array (); //This array will help to control if the variable already exist
+ while ($aRow = $oDataset->getRow()) {
+ if ($bWhitType) {
+ if (! in_array( $aRow['REP_VAR_NAME'], $aImportedVars )) {
+ $aImportedVars[] = $aRow['REP_VAR_NAME'];
+ $aVars[] = array ('sFieldName' => $aRow['REP_VAR_NAME'],'sType' => $aRow['REP_VAR_TYPE']
+ );
+ }
+ } else {
+ $aVars[] = $aRow['REP_VAR_NAME'];
+ }
+ $oDataset->next();
+ }
+ return $aVars;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * Function deleteReportTable
+ * This Function deletes report table
+ *
+ * @access public
+ * @param string $sRepTabUid
+ * @return void
+ */
+ public function deleteReportTable ($sRepTabUid)
+ {
+ try {
+ $oReportTable = new ReportTable();
+ $aFields = $oReportTable->load( $sRepTabUid );
+ if (! (empty( $aFields ))) {
+ $this->dropTable( $aFields['REP_TAB_NAME'], $aFields['REP_TAB_CONNECTION'] );
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( ReportVarPeer::REP_TAB_UID, $sRepTabUid );
+ $oDataset = ReportVarPeer::doDelete( $oCriteria );
+ $oReportTable->remove( $sRepTabUid );
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * Function getSplitDate
+ * This function gets the split date
+ *
+ * @access public
+ * @param date $date
+ * @param string $mask
+ * @return array
+ */
+ public function getSplitDate ($date, $mask)
+ {
+ $sw1 = false;
+ for ($i = 0; $i < 3; $i ++) {
+ $item = substr( $mask, $i * 2, 1 );
+ switch ($item) {
+ case 'Y':
+ switch ($i) {
+ case 0:
+ $d1 = substr( $date, 0, 4 );
+ break;
+ case 1:
+ $d1 = substr( $date, 3, 4 );
+ break;
+ case 2:
+ $d1 = substr( $date, 6, 4 );
+ break;
+ }
+ $sw1 = true;
+ break;
+ case 'y':
+ switch ($i) {
+ case 0:
+ $d1 = substr( $date, 0, 2 );
+ break;
+ case 1:
+ $d1 = substr( $date, 3, 2 );
+ break;
+ case 2:
+ $d1 = substr( $date, 6, 2 );
+ break;
+ }
+ break;
+ case 'm':
+ switch ($i) {
+ case 0:
+ $d2 = substr( $date, 0, 2 );
+ break;
+ case 1:
+ $d2 = ($sw1) ? substr( $date, 5, 2 ) : substr( $date, 3, 2 );
+ break;
+ case 2:
+ $d2 = ($sw1) ? substr( $date, 8, 2 ) : substr( $date, 5, 2 );
+ break;
+ }
+ break;
+ case 'd':
+ switch ($i) {
+ case 0:
+ $d3 = substr( $date, 0, 2 );
+ break;
+ case 1:
+ $d3 = ($sw1) ? substr( $date, 5, 2 ) : substr( $date, 3, 2 );
+ break;
+ case 2:
+ $d3 = ($sw1) ? substr( $date, 8, 2 ) : substr( $date, 5, 2 );
+ break;
+ }
+ break;
+ }
+ }
+ return Array (isset( $d1 ) ? $d1 : '',isset( $d2 ) ? $d2 : '',isset( $d3 ) ? $d3 : ''
+ );
+ }
+
+ /**
+ * Function getFormatDate
+ * This function returns the date formated
+ *
+ * @access public
+ * @param date $sDate
+ * @param date $sMask
+ * @return date
+ */
+ public function getFormatDate ($sDate, $sMask)
+ {
+ //print $sDate." *** ". $sMask."
";
+ $dateTime = explode( " ", $sDate ); //To accept the Hour part
+ $aDate = explode( '-', str_replace( "/", "-", $dateTime[0] ) );
+ $bResult = true;
+ foreach ($aDate as $sDate) {
+ if (! is_numeric( $sDate )) {
+ $bResult = false;
+ break;
+ }
+ }
+ if ($sMask != '') {
+ $aDate = $this->getSplitDate( $dateTime[0], $sMask );
+ $aDate[0] = ($aDate[0] == '') ? date( 'Y' ) : $aDate[0];
+ $aDate[1] = ($aDate[1] == '') ? date( 'm' ) : $aDate[1];
+ $aDate[2] = ($aDate[2] == '') ? date( 'd' ) : $aDate[2];
+ if (checkdate( $aDate[1], $aDate[2], $aDate[0] )) {
+ } else {
+ return false;
+ }
+ }
+ $sDateC = '';
+ for ($i = 0; $i < count( $aDate ); $i ++) {
+ $sDateC .= (($i == 0) ? "" : "-") . $aDate[$i];
+ }
+ return ($sDateC);
+ }
+
+ /**
+ * Function updateTables
+ * This function updated the Report Tables
+ *
+ * @access public
+ * @param string $sProcessUid
+ * @param string $sApplicationUid
+ * @param string $iApplicationNumber
+ * @param string $aFields
+ * @return void
+ */
+ public function updateTables ($sProcessUid, $sApplicationUid, $iApplicationNumber, $aFields)
+ {
+ try {
+ //get all Active Report Tables
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( ReportTablePeer::PRO_UID, $sProcessUid );
+ $oCriteria->add( ReportTablePeer::REP_TAB_STATUS, 'ACTIVE' );
+ $oDataset = ReportTablePeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ $aVars = array ();
+ while ($aRow = $oDataset->getRow()) {
+ $aRow['REP_TAB_NAME'] = $this->sPrefix . $aRow['REP_TAB_NAME'];
+ $PropelDatabase = $this->chooseDB( $aRow['REP_TAB_CONNECTION'] );
+ $con = Propel::getConnection( $PropelDatabase );
+ $stmt = $con->createStatement();
+ switch (DB_ADAPTER) {
+
+ case 'mysql':
+ $aTableFields = $this->getTableVars( $aRow['REP_TAB_UID'], true );
+ if ($aRow['REP_TAB_TYPE'] == 'NORMAL') {
+ $sqlExists = "SELECT * FROM `" . $aRow['REP_TAB_NAME'] . "` WHERE APP_UID = '" . $sApplicationUid . "'";
+ $rsExists = $stmt->executeQuery( $sqlExists, ResultSet::FETCHMODE_ASSOC );
+ $rsExists->next();
+ $aRow2 = $rsExists->getRow();
+
+ if (is_array( $aRow2 )) {
+ $sQuery = 'UPDATE `' . $aRow['REP_TAB_NAME'] . '` SET ';
+ foreach ($aTableFields as $aField) {
+ $sQuery .= '`' . $aField['sFieldName'] . '` = ';
+ switch ($aField['sType']) {
+ case 'number':
+ $sQuery .= (isset( $aFields[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aFields[$aField['sFieldName']] ) : '0') . ',';
+ break;
+ case 'char':
+ case 'text':
+ if (! isset( $aFields[$aField['sFieldName']] )) {
+ $aFields[$aField['sFieldName']] = '';
+ }
+ $sQuery .= "'" . (isset( $aFields[$aField['sFieldName']] ) ? mysql_real_escape_string( $aFields[$aField['sFieldName']] ) : '') . "',";
+ break;
+ case 'date':
+ $mysqlDate = (isset( $aFields[$aField['sFieldName']] ) ? $aFields[$aField['sFieldName']] : '');
+ if ($mysqlDate != '') {
+ $mysqlDate = str_replace( '/', '-', $mysqlDate );
+ $mysqlDate = date( 'Y-m-d', strtotime( $mysqlDate ) );
+ }
+ $value = trim( $mysqlDate ) != '' ? "'" . $mysqlDate . "'" : 'NULL';
+ $sQuery .= $value . ",";
+ break;
+ }
+ }
+ $sQuery = substr( $sQuery, 0, - 1 );
+ $sQuery .= " WHERE APP_UID = '" . $sApplicationUid . "'";
+ } else {
+ $sQuery = 'INSERT INTO `' . $aRow['REP_TAB_NAME'] . '` (';
+ $sQuery .= '`APP_UID`,`APP_NUMBER`';
+ foreach ($aTableFields as $aField) {
+ $sQuery .= ',`' . $aField['sFieldName'] . '`';
+ }
+ $sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int) $iApplicationNumber;
+ foreach ($aTableFields as $aField) {
+ switch ($aField['sType']) {
+ case 'number':
+ $sQuery .= ',' . (isset( $aFields[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aFields[$aField['sFieldName']] ) : '0');
+ break;
+ case 'char':
+ case 'text':
+ if (! isset( $aFields[$aField['sFieldName']] )) {
+ $aFields[$aField['sFieldName']] = '';
+ }
+ $sQuery .= ",'" . (isset( $aFields[$aField['sFieldName']] ) ? mysql_real_escape_string( $aFields[$aField['sFieldName']] ) : '') . "'";
+ break;
+ case 'date':
+ $mysqlDate = (isset( $aFields[$aField['sFieldName']] ) ? $aFields[$aField['sFieldName']] : '');
+ if ($mysqlDate != '') {
+ $mysqlDate = str_replace( '/', '-', $mysqlDate );
+ $mysqlDate = date( 'Y-m-d', strtotime( $mysqlDate ) );
+ }
+ $value = trim( $mysqlDate ) != '' ? "'" . $mysqlDate . "'" : 'NULL';
+ $sQuery .= "," . $value;
+ break;
+ }
+ }
+ $sQuery .= ')';
+ }
+ $rs = $stmt->executeQuery( $sQuery );
+ } else {
+ //remove old rows from database
+ $sqlDelete = 'DELETE FROM `' . $aRow['REP_TAB_NAME'] . "` WHERE APP_UID = '" . $sApplicationUid . "'";
+ $rsDelete = $stmt->executeQuery( $sqlDelete );
+
+ $aAux = explode( '-', $aRow['REP_TAB_GRID'] );
+ if (isset( $aFields[$aAux[0]] )) {
+ foreach ($aFields[$aAux[0]] as $iRow => $aGridRow) {
+ $sQuery = 'INSERT INTO `' . $aRow['REP_TAB_NAME'] . '` (';
+ $sQuery .= '`APP_UID`,`APP_NUMBER`,`ROW`';
+ foreach ($aTableFields as $aField) {
+ $sQuery .= ',`' . $aField['sFieldName'] . '`';
+ }
+ $sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int) $iApplicationNumber . ',' . $iRow;
+ foreach ($aTableFields as $aField) {
+ switch ($aField['sType']) {
+ case 'number':
+ $sQuery .= ',' . (isset( $aGridRow[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aGridRow[$aField['sFieldName']] ) : '0');
+ break;
+ case 'char':
+ case 'text':
+ if (! isset( $aGridRow[$aField['sFieldName']] )) {
+ $aGridRow[$aField['sFieldName']] = '';
+ }
+ $sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? mysql_real_escape_string( $aGridRow[$aField['sFieldName']] ) : '') . "'";
+ break;
+ case 'date':
+ $sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? $aGridRow[$aField['sFieldName']] : '') . "'";
+ break;
+ }
+ }
+ $sQuery .= ')';
+ $rs = $stmt->executeQuery( $sQuery );
+ }
+ }
+ }
+ break;
+
+ /**
+ * For SQLServer code
+ */
+ case 'mssql':
+ $aTableFields = $this->getTableVars( $aRow['REP_TAB_UID'], true );
+ if ($aRow['REP_TAB_TYPE'] == 'NORMAL') {
+ $oDataset2 = mssql_query( "SELECT * FROM [" . $aRow['REP_TAB_NAME'] . "] WHERE APP_UID = '" . $sApplicationUid . "'" );
+ if ($aRow2 = mssql_fetch_row( $oDataset2 )) {
+ $sQuery = 'UPDATE [' . $aRow['REP_TAB_NAME'] . '] SET ';
+ foreach ($aTableFields as $aField) {
+ $sQuery .= '[' . $aField['sFieldName'] . '] = ';
+ switch ($aField['sType']) {
+ case 'number':
+ $sQuery .= (isset( $aFields[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aFields[$aField['sFieldName']] ) : '0') . ',';
+ break;
+ case 'char':
+ case 'text':
+ if (! isset( $aFields[$aField['sFieldName']] )) {
+ $aFields[$aField['sFieldName']] = '';
+ }
+ $sQuery .= "'" . (isset( $aFields[$aField['sFieldName']] ) ? mysql_real_escape_string( $aFields[$aField['sFieldName']] ) : '') . "',";
+ break;
+ case 'date':
+ $sQuery .= "'" . (isset( $aFields[$aField['sFieldName']] ) ? $aFields[$aField['sFieldName']] : '') . "',";
+ break;
+ }
+ }
+ $sQuery = substr( $sQuery, 0, - 1 );
+ $sQuery .= " WHERE APP_UID = '" . $sApplicationUid . "'";
+ } else {
+ $sQuery = 'INSERT INTO [' . $aRow['REP_TAB_NAME'] . '] (';
+ $sQuery .= '[APP_UID],[APP_NUMBER]';
+ foreach ($aTableFields as $aField) {
+ $sQuery .= ',[' . $aField['sFieldName'] . ']';
+ }
+ $sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int) $iApplicationNumber;
+ foreach ($aTableFields as $aField) {
+ switch ($aField['sType']) {
+ case 'number':
+ $sQuery .= ',' . (isset( $aFields[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aFields[$aField['sFieldName']] ) : '0');
+ break;
+ case 'char':
+ case 'text':
+ if (! isset( $aFields[$aField['sFieldName']] )) {
+ $aFields[$aField['sFieldName']] = '';
+ }
+ $sQuery .= ",'" . (isset( $aFields[$aField['sFieldName']] ) ? mysql_real_escape_string( $aFields[$aField['sFieldName']] ) : '') . "'";
+ break;
+ case 'date':
+ $sQuery .= ",'" . (isset( $aFields[$aField['sFieldName']] ) ? $aFields[$aField['sFieldName']] : '') . "'";
+ break;
+ }
+ }
+ $sQuery .= ')';
+ }
+ $rs = $stmt->executeQuery( $sQuery );
+ } else {
+ mysql_query( 'DELETE FROM [' . $aRow['REP_TAB_NAME'] . "] WHERE APP_UID = '" . $sApplicationUid . "'" );
+ $aAux = explode( '-', $aRow['REP_TAB_GRID'] );
+ if (isset( $aFields[$aAux[0]] )) {
+ foreach ($aFields[$aAux[0]] as $iRow => $aGridRow) {
+ $sQuery = 'INSERT INTO [' . $aRow['REP_TAB_NAME'] . '] (';
+ $sQuery .= '[APP_UID],[APP_NUMBER],[ROW]';
+ foreach ($aTableFields as $aField) {
+ $sQuery .= ',[' . $aField['sFieldName'] . ']';
+ }
+ $sQuery .= ") VALUES ('" . $sApplicationUid . "'," . (int) $iApplicationNumber . ',' . $iRow;
+ foreach ($aTableFields as $aField) {
+ switch ($aField['sType']) {
+ case 'number':
+ $sQuery .= ',' . (isset( $aGridRow[$aField['sFieldName']] ) ? (float) str_replace( ',', '', $aGridRow[$aField['sFieldName']] ) : '0');
+ break;
+ case 'char':
+ case 'text':
+ if (! isset( $aGridRow[$aField['sFieldName']] )) {
+ $aGridRow[$aField['sFieldName']] = '';
+ }
+ $sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? mysql_real_escape_string( $aGridRow[$aField['sFieldName']] ) : '') . "'";
+ break;
+ case 'date':
+ $sQuery .= ",'" . (isset( $aGridRow[$aField['sFieldName']] ) ? $aGridRow[$aField['sFieldName']] : '') . "'";
+ break;
+ }
+ }
+ $sQuery .= ')';
+ $rs = $stmt->executeQuery( $sQuery );
+ }
+ }
+ }
+ break;
+
+ }
+ $oDataset->next();
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * Function tableExist
+ * Check if table exists
+ *
+ * @access public
+ * @return boolean
+ */
+ public function tableExist ()
+ {
+ /*
$bExists = true;
$oConnection = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
$oDataset = mysql_query('SELECT COUNT(*) FROM REPORT_TABLE') || ($bExists = false);
return $bExists;
*/
- $bExists = true;
- $sDataBase = 'database_' . strtolower(DB_ADAPTER);
- if(G::LoadSystemExist($sDataBase)){
- G::LoadSystem($sDataBase);
- $oDataBase = new database();
- $bExists = $oDataBase->reportTableExist();
+ $bExists = true;
+ $sDataBase = 'database_' . strtolower( DB_ADAPTER );
+ if (G::LoadSystemExist( $sDataBase )) {
+ G::LoadSystem( $sDataBase );
+ $oDataBase = new database();
+ $bExists = $oDataBase->reportTableExist();
+ }
+ return $bExists;
+ }
+
+ /**
+ * Function chooseDB
+ * Choose the database to connect
+ *
+ * @access public
+ * @param string $TabConnectionk
+ * @return string
+ */
+ public function chooseDB ($TabConnectionk)
+ {
+ $repTabConnection = trim( strtoupper( $TabConnectionk ) );
+ $PropelDatabase = 'rp';
+ if ($repTabConnection == '' || $repTabConnection == 'REPORT')
+ $PropelDatabase = 'rp';
+ if ($repTabConnection == 'RBAC')
+ $PropelDatabase = 'rbac';
+ if ($repTabConnection == 'WF')
+ $PropelDatabase = 'workflow';
+ return ($PropelDatabase);
}
- return $bExists;
- }
-
- /**
- * Function chooseDB
- * Choose the database to connect
- * @access public
- * @param string $TabConnectionk
- * @return string
- */
- function chooseDB($TabConnectionk)
- {
- $repTabConnection = trim( strtoupper( $TabConnectionk ) );
- $PropelDatabase = 'rp';
- if ( $repTabConnection == '' || $repTabConnection == 'REPORT' )
- $PropelDatabase = 'rp';
- if ( $repTabConnection == 'RBAC' )
- $PropelDatabase = 'rbac';
- if ( $repTabConnection == 'WF' )
- $PropelDatabase = 'workflow';
- return ($PropelDatabase);
- }
}
diff --git a/workflow/engine/classes/class.searchIndex.php b/workflow/engine/classes/class.searchIndex.php
index 26888f28c..16815c66d 100644
--- a/workflow/engine/classes/class.searchIndex.php
+++ b/workflow/engine/classes/class.searchIndex.php
@@ -1,6 +1,6 @@
solrIsEnabled = $registry->isRegistered('solrEnabled') &&
- // $registry->get('solrEnabled') == 1;
- // $this->solrHost =
- // $registry->isRegistered('solrHost')?$registry->get('solrHost'):"";
- // }
- // else{
- // //use the parameters to initialize class
- $this->_solrIsEnabled = $solrIsEnabled;
- $this->_solrHost = $solrHost;
- // }
- }
- /**
- * Verify if the Solr service is available
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * no input parameters @param[in]
- *
- * @param
- * [out] bool true if index service is enabled false in other case
- */
- public function isEnabled()
- {
- // require_once (ROOT_PATH .
- // '/businessLogic/modules/SearchIndexAccess/Solr.php');
- require_once ('class.solr.php');
- $solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
- return $solr->isEnabled ();
- }
-
- /**
- * Get the list of facets in base to the specified query and filter
- * @gearman = true
- * @rest = false
- * @background = false
- *
- * @param
- * [in] Entity_FacetRequest facetRequestEntity Facet request entity
- * @param
- * [out] array FacetGroup
- */
- public function getFacetsList($facetRequestEntity)
- {
- require_once ('class.solr.php');
- // require_once (ROOT_PATH .
- // '/businessLogic/modules/SearchIndexAccess/Solr.php');
- require_once ('entities/FacetGroup.php');
- require_once ('entities/FacetItem.php');
- require_once ('entities/SelectedFacetGroupItem.php');
- require_once ('entities/FacetResult.php');
-
- /**
- * ***************************************************************
- */
- // get array of selected facet groups
- $facetRequestEntity->selectedFacetsString = str_replace (',,', ',', $facetRequestEntity->selectedFacetsString);
- // remove descriptions of selected facet groups
-
- $aGroups = explode (',', $facetRequestEntity->selectedFacetsString);
-
- $aGroups = array_filter ($aGroups); // remove empty items
-
- $aSelectedFacetGroups = array ();
- foreach ($aGroups as $i => $value) {
- $gi = explode (':::', $value);
- $gr = explode ('::', $gi [0]);
- $it = explode ('::', $gi [1]);
-
- // create string for remove condition
- $count = 0;
- $removeCondition = str_replace ($value . ',', '', $facetRequestEntity->selectedFacetsString, $count);
- if ($count == 0) {
- $removeCondition = str_replace ($value, '', $facetRequestEntity->selectedFacetsString, $count);
- }
- $selectedFacetGroupData = array (
- 'selectedFacetGroupName' => $gr [0],
- 'selectedFacetGroupPrintName' => $gr [1],
- 'selectedFacetItemName' => $it [0],
- 'selectedFacetItemPrintName' => $it [1],
- 'selectedFacetRemoveCondition' => $removeCondition
- );
-
- $aSelectedFacetGroups [] = Entity_SelectedFacetGroupItem::createForRequest ($selectedFacetGroupData);
- }
-
- /**
- * ***************************************************************
- */
- // convert request to index request
- // create filters
- $filters = array ();
- if (! empty ($aSelectedFacetGroups)) {
- // exclude facetFields and facetDates included in filter from the next
- // list of facets
- foreach ($aSelectedFacetGroups as $value) {
- $facetRequestEntity->facetFields = array_diff ($facetRequestEntity->facetFields, array (
- $value->selectedFacetGroupName
- ));
- $facetRequestEntity->facetDates = array_diff ($facetRequestEntity->facetDates, array (
- $value->selectedFacetGroupName
- ));
- }
-
- // $facetFields = array_diff($facetFields,
- // $facetInterfaceRequestEntity->selectedFacetGroups);
- // $facetDates = array_diff($facetDates,
- // $facetInterfaceRequestEntity->selectedFacetGroups);
- foreach ($aSelectedFacetGroups as $group) {
- $filters [] = $group->selectedFacetGroupName . ':' . urlencode ($group->selectedFacetItemName);
- }
- }
- $facetRequestEntity->filters = $filters;
-
- $solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
-
- // create list of facets
- $facetsList = $solr->getFacetsList ($facetRequestEntity);
-
- $numFound = $facetsList->response->numFound;
-
- $facetCounts = $facetsList->facet_counts;
-
- $facetGroups = array ();
- // convert facet fields result to objects
- /**
- * *********************************************************************
- */
- // include facet field results
- $facetFieldsResult = $facetsList->facet_counts->facet_fields;
- if (! empty ($facetFieldsResult)) {
- foreach ($facetFieldsResult as $facetGroup => $facetvalues) {
- if (count ($facetvalues) > 0) // if the group have facets included
- {
- $data = array (
- 'facetGroupName' => $facetGroup
- );
- $data ['facetGroupPrintName'] = $facetGroup;
- $data ['facetGroupType'] = 'field';
- $facetItems = array ();
- for ($i = 0; $i < count ($facetvalues); $i += 2) {
- $dataItem = array ();
- $dataItem ['facetName'] = $facetvalues [$i];
- $dataItem ['facetPrintName'] = $facetvalues [$i];
- $dataItem ['facetCount'] = $facetvalues [$i + 1];
- $dataItem ['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty ($facetRequestEntity->selectedFacetsString) ? '' : ',') . $data ['facetGroupName'] . '::' . $data ['facetGroupPrintName'] . ':::' . $dataItem ['facetName'] . '::' . $dataItem ['facetPrintName'];
- $newFacetItem = Entity_FacetItem::createForInsert ($dataItem);
- $facetItems [] = $newFacetItem;
- }
- $data ['facetItems'] = $facetItems;
- $newFacetGroup = Entity_FacetGroup::createForInsert ($data);
-
- $facetGroups [] = $newFacetGroup;
- }
- }
- }
- /**
- * *********************************************************************
- */
- // include facet date ranges results
- $facetDatesResult = $facetsList->facet_counts->facet_dates;
- if (! empty ($facetDatesResult)) {
- foreach ($facetDatesResult as $facetGroup => $facetvalues) {
- if (count ((array)$facetvalues) > 3) // if the group have any facets included
- // besides start, end and gap
- {
- $data = array (
- 'facetGroupName' => $facetGroup
- );
- $data ['facetGroupPrintName'] = $facetGroup;
- $data ['facetGroupType'] = 'daterange';
- $facetItems = array ();
- $facetvalueskeys = array_keys ((array)$facetvalues);
- foreach ($facetvalueskeys as $i => $k) {
- if ($k != 'gap' && $k != 'start' && $k != 'end') {
- $dataItem = array ();
- if ($i < count ($facetvalueskeys) - 4) {
-
- $dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalueskeys [$i + 1] . ']';
- $dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalueskeys [$i + 1] . ']';
- }
- else {
- // the last group
- $dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
- $dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
- }
-
- $dataItem ['facetCount'] = $facetvalues->$k;
- $dataItem ['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty ($facetRequestEntity->selectedFacetsString) ? '' : ',') . $data ['facetGroupName'] . '::' . $data ['facetGroupPrintName'] . ':::' . $dataItem ['facetName'] . '::' . $dataItem ['facetPrintName'];
- $newFacetItem = Entity_FacetItem::createForInsert ($dataItem);
- $facetItems [] = $newFacetItem;
- }
- }
-
- $data ['facetItems'] = $facetItems;
- $newFacetGroup = Entity_FacetGroup::createForInsert ($data);
-
- $facetGroups [] = $newFacetGroup;
- }
- }
- }
- // TODO:convert facet queries
- // -----
- /**
- * ***************************************************************
- */
- // Create a filter string used in the filter of results of a datatable
- $filterText = ''; // the list of selected filters used for filtering result,
- // send in ajax
- foreach ($aSelectedFacetGroups as $selectedFacetGroup) {
- $filterText .= $selectedFacetGroup->selectedFacetGroupName . ':' . urlencode ($selectedFacetGroup->selectedFacetItemName) . ',';
- }
- $filterText = substr_replace ($filterText, '', - 1);
- // $filterText = ($filterText == '')?'':'&filterText='.$filterText;
-
- /**
- * ***************************************************************
- */
- // Create result
- $dataFacetResult = array (
- 'aFacetGroups' => $facetGroups,
- 'aSelectedFacetGroups' => $aSelectedFacetGroups,
- 'sFilterText' => $filterText
- );
- $facetResult = Entity_FacetResult::createForRequest ($dataFacetResult);
-
- return $facetResult;
- }
-
- /**
- * Get the total number of documents in search server
- * @param string $workspace
- * @return integer number of documents
- *
- */
- public function getNumberDocuments($workspace)
- {
- require_once ('class.solr.php');
- // require_once (ROOT_PATH .
- // '/businessLogic/modules/SearchIndexAccess/Solr.php');
- $solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
-
- // create list of facets
- $numberDocuments = $solr->getNumberDocuments ($workspace);
-
- return $numberDocuments;
- }
-
- /**
- * Update document Index
- * @param SolrUpdateDocumentEntity $solrUpdateDocumentEntity
- */
- public function updateIndexDocument($solrUpdateDocumentEntity)
- {
- G::LoadClass ('solr');
-
- $solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
-
- // create list of facets
- $solr->updateDocument ($solrUpdateDocumentEntity);
- }
-
- /**
- * Delete document from index
- * @param string $workspace
- * @param string $idQuery
- */
- public function deleteDocumentFromIndex($workspace, $idQuery)
- {
- G::LoadClass ('solr');
-
- $solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
-
- // create list of facets
- $solr->deleteDocument ($workspace, $idQuery);
- }
-
- /**
- * Commit index changes
- * @param string $workspace
- */
- public function commitIndexChanges($workspace)
- {
- G::LoadClass ('solr');
-
- $solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
-
- // commit
- $solr->commitChanges ($workspace);
- }
-
- /**
- * Optimize index changes
- * @param string $workspace
- */
- public function optimizeIndexChanges($workspace)
- {
- G::LoadClass ('solr');
-
- $solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
-
- // commit
- $solr->optimizeChanges ($workspace);
- }
-
- /**
- * Call Solr server to return the list of paginated pages.
- * @param FacetRequest $solrRequestData
- * @return Entity_SolrQueryResult
- */
- public function getDataTablePaginatedList($solrRequestData)
- {
- require_once ('class.solr.php');
- require_once ('entities/SolrRequestData.php');
- require_once ('entities/SolrQueryResult.php');
-
- // prepare the list of sorted columns
- // verify if the data of sorting is available
- if (isset ($solrRequestData->sortCols [0])) {
- for ($i = 0; $i < $solrRequestData->numSortingCols; $i ++) {
- // verify if column is sortable
- if ($solrRequestData->includeCols [$solrRequestData->sortCols [$i]] != '' && $solrRequestData->sortableCols [$i] == "true") {
- // change sorting column index to column names
- $solrRequestData->sortCols [$i] = $solrRequestData->includeCols [$solrRequestData->sortCols [$i]];
- // define the direction of the sorting columns
- $solrRequestData->sortDir [$i] = $solrRequestData->sortDir [$i];
- }
- }
- }
- // remove placeholder fields
- // the placeholder doesn't affect the the solr's response
- // $solrRequestData->includeCols = array_diff($solrRequestData->includeCols,
- // array(''));
-
- // execute query
- $solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
- $solrPaginatedResult = $solr->executeQuery ($solrRequestData);
-
- // get total number of documents in index
- $numTotalDocs = $solr->getNumberDocuments ($solrRequestData->workspace);
-
- // create the Datatable response of the query
- $numFound = $solrPaginatedResult->response->numFound;
-
- $docs = $solrPaginatedResult->response->docs;
- // print_r($docs);
- // insert list of names in docs result
- $data = array (
- "sEcho" => '', // must be completed in response
- "iTotalRecords" => intval ($numTotalDocs), // we must get the
- // total number of
- // documents
- "iTotalDisplayRecords" => $numFound,
- "aaData" => array ()
- );
- // copy result document or add placeholders to result
- foreach ($docs as $i => $doc) {
- $data ['aaData'] [$i] = array ();
- foreach ($solrRequestData->includeCols as $columnName) {
- if ($columnName == '') {
- $data ['aaData'] [$i] [] = ''; // placeholder
- }
- else {
- if (isset ($doc->$columnName)) {
- $data ['aaData'] [$i] [] = $doc->$columnName;
- }
- else {
- $data ['aaData'] [$i] [] = '';
- }
- }
- }
- }
-
- $solrQueryResponse = Entity_SolrQueryResult::createForRequest ($data);
- //
-
- return $solrQueryResponse;
- }
-
- /**
- * Return the list of stored fields in the index.
- * @param string $workspace
- * @return array of index fields
- */
- public function getIndexFields($workspace)
- {
- require_once ('class.solr.php');
+ private $_solrIsEnabled = false;
+ private $_solrHost = "";
- $solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
-
- // print "SearchIndex!!!!";
- // create list of facets
- $solrFieldsData = $solr->getListIndexedStoredFields ($workspace);
- // copy list of arrays
- $listFields = array ();
- foreach ($solrFieldsData->fields as $key => $fieldData) {
- if (array_key_exists ('dynamicBase', $fieldData)) {
- $originalFieldName = substr ($key, 0, - strlen ($fieldData->dynamicBase) + 1);
- // $listFields[strtolower($originalFieldName)] = $key; //in case of case insentive strings
- // Maintain case sensitive variable names
- $listFields [$originalFieldName] = $key;
- }
- else {
- // $listFields[strtolower($key)] = $key;
- // Maintain case sensitive variable names
- $listFields [$key] = $key;
- }
+ public function __construct ($solrIsEnabled = false, $solrHost = "")
+ {
+ // check if Zend Library is available
+ // if(class_exists("Zend_Registry")){
+ // $registry = Zend_Registry::getInstance();
+ // //check if configuration is enabled
+ // $this->solrIsEnabled = $registry->isRegistered('solrEnabled') &&
+ // $registry->get('solrEnabled') == 1;
+ // $this->solrHost =
+ // $registry->isRegistered('solrHost')?$registry->get('solrHost'):"";
+ // }
+ // else{
+ // //use the parameters to initialize class
+ $this->_solrIsEnabled = $solrIsEnabled;
+ $this->_solrHost = $solrHost;
+ // }
+ }
+
+ /**
+ * Verify if the Solr service is available
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * no input parameters @param[in]
+ *
+ * @param [out] bool true if index service is enabled false in other case
+ */
+ public function isEnabled ()
+ {
+ // require_once (ROOT_PATH .
+ // '/businessLogic/modules/SearchIndexAccess/Solr.php');
+ require_once ('class.solr.php');
+ $solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
+ return $solr->isEnabled();
+ }
+
+ /**
+ * Get the list of facets in base to the specified query and filter
+ * @gearman = true
+ * @rest = false
+ * @background = false
+ *
+ * @param [in] Entity_FacetRequest facetRequestEntity Facet request entity
+ * @param [out] array FacetGroup
+ */
+ public function getFacetsList ($facetRequestEntity)
+ {
+ require_once ('class.solr.php');
+ // require_once (ROOT_PATH .
+ // '/businessLogic/modules/SearchIndexAccess/Solr.php');
+ require_once ('entities/FacetGroup.php');
+ require_once ('entities/FacetItem.php');
+ require_once ('entities/SelectedFacetGroupItem.php');
+ require_once ('entities/FacetResult.php');
+
+ /**
+ * ***************************************************************
+ */
+ // get array of selected facet groups
+ $facetRequestEntity->selectedFacetsString = str_replace( ',,', ',', $facetRequestEntity->selectedFacetsString );
+ // remove descriptions of selected facet groups
+
+
+ $aGroups = explode( ',', $facetRequestEntity->selectedFacetsString );
+
+ $aGroups = array_filter( $aGroups ); // remove empty items
+
+
+ $aSelectedFacetGroups = array ();
+ foreach ($aGroups as $i => $value) {
+ $gi = explode( ':::', $value );
+ $gr = explode( '::', $gi[0] );
+ $it = explode( '::', $gi[1] );
+
+ // create string for remove condition
+ $count = 0;
+ $removeCondition = str_replace( $value . ',', '', $facetRequestEntity->selectedFacetsString, $count );
+ if ($count == 0) {
+ $removeCondition = str_replace( $value, '', $facetRequestEntity->selectedFacetsString, $count );
+ }
+ $selectedFacetGroupData = array ('selectedFacetGroupName' => $gr[0],'selectedFacetGroupPrintName' => $gr[1],'selectedFacetItemName' => $it[0],'selectedFacetItemPrintName' => $it[1],'selectedFacetRemoveCondition' => $removeCondition
+ );
+
+ $aSelectedFacetGroups[] = Entity_SelectedFacetGroupItem::createForRequest( $selectedFacetGroupData );
+ }
+
+ /**
+ * ***************************************************************
+ */
+ // convert request to index request
+ // create filters
+ $filters = array ();
+ if (! empty( $aSelectedFacetGroups )) {
+ // exclude facetFields and facetDates included in filter from the next
+ // list of facets
+ foreach ($aSelectedFacetGroups as $value) {
+ $facetRequestEntity->facetFields = array_diff( $facetRequestEntity->facetFields, array ($value->selectedFacetGroupName
+ ) );
+ $facetRequestEntity->facetDates = array_diff( $facetRequestEntity->facetDates, array ($value->selectedFacetGroupName
+ ) );
+ }
+
+ // $facetFields = array_diff($facetFields,
+ // $facetInterfaceRequestEntity->selectedFacetGroups);
+ // $facetDates = array_diff($facetDates,
+ // $facetInterfaceRequestEntity->selectedFacetGroups);
+ foreach ($aSelectedFacetGroups as $group) {
+ $filters[] = $group->selectedFacetGroupName . ':' . urlencode( $group->selectedFacetItemName );
+ }
+ }
+ $facetRequestEntity->filters = $filters;
+
+ $solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
+
+ // create list of facets
+ $facetsList = $solr->getFacetsList( $facetRequestEntity );
+
+ $numFound = $facetsList->response->numFound;
+
+ $facetCounts = $facetsList->facet_counts;
+
+ $facetGroups = array ();
+ // convert facet fields result to objects
+ /**
+ * *********************************************************************
+ */
+ // include facet field results
+ $facetFieldsResult = $facetsList->facet_counts->facet_fields;
+ if (! empty( $facetFieldsResult )) {
+ foreach ($facetFieldsResult as $facetGroup => $facetvalues) {
+ if (count( $facetvalues ) > 0) // if the group have facets included
+{
+ $data = array ('facetGroupName' => $facetGroup
+ );
+ $data['facetGroupPrintName'] = $facetGroup;
+ $data['facetGroupType'] = 'field';
+ $facetItems = array ();
+ for ($i = 0; $i < count( $facetvalues ); $i += 2) {
+ $dataItem = array ();
+ $dataItem['facetName'] = $facetvalues[$i];
+ $dataItem['facetPrintName'] = $facetvalues[$i];
+ $dataItem['facetCount'] = $facetvalues[$i + 1];
+ $dataItem['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty( $facetRequestEntity->selectedFacetsString ) ? '' : ',') . $data['facetGroupName'] . '::' . $data['facetGroupPrintName'] . ':::' . $dataItem['facetName'] . '::' . $dataItem['facetPrintName'];
+ $newFacetItem = Entity_FacetItem::createForInsert( $dataItem );
+ $facetItems[] = $newFacetItem;
+ }
+ $data['facetItems'] = $facetItems;
+ $newFacetGroup = Entity_FacetGroup::createForInsert( $data );
+
+ $facetGroups[] = $newFacetGroup;
+ }
+ }
+ }
+ /**
+ * *********************************************************************
+ */
+ // include facet date ranges results
+ $facetDatesResult = $facetsList->facet_counts->facet_dates;
+ if (! empty( $facetDatesResult )) {
+ foreach ($facetDatesResult as $facetGroup => $facetvalues) {
+ if (count( (array) $facetvalues ) > 3) // if the group have any facets included
+ // besides start, end and gap
+ {
+ $data = array ('facetGroupName' => $facetGroup
+ );
+ $data['facetGroupPrintName'] = $facetGroup;
+ $data['facetGroupType'] = 'daterange';
+ $facetItems = array ();
+ $facetvalueskeys = array_keys( (array) $facetvalues );
+ foreach ($facetvalueskeys as $i => $k) {
+ if ($k != 'gap' && $k != 'start' && $k != 'end') {
+ $dataItem = array ();
+ if ($i < count( $facetvalueskeys ) - 4) {
+
+ $dataItem['facetName'] = '[' . $k . '%20TO%20' . $facetvalueskeys[$i + 1] . ']';
+ $dataItem['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalueskeys[$i + 1] . ']';
+ } else {
+ // the last group
+ $dataItem['facetName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
+ $dataItem['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
+ }
+
+ $dataItem['facetCount'] = $facetvalues->$k;
+ $dataItem['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty( $facetRequestEntity->selectedFacetsString ) ? '' : ',') . $data['facetGroupName'] . '::' . $data['facetGroupPrintName'] . ':::' . $dataItem['facetName'] . '::' . $dataItem['facetPrintName'];
+ $newFacetItem = Entity_FacetItem::createForInsert( $dataItem );
+ $facetItems[] = $newFacetItem;
+ }
+ }
+
+ $data['facetItems'] = $facetItems;
+ $newFacetGroup = Entity_FacetGroup::createForInsert( $data );
+
+ $facetGroups[] = $newFacetGroup;
+ }
+ }
+ }
+ // TODO:convert facet queries
+ // -----
+ /**
+ * ***************************************************************
+ */
+ // Create a filter string used in the filter of results of a datatable
+ $filterText = ''; // the list of selected filters used for filtering result,
+ // send in ajax
+ foreach ($aSelectedFacetGroups as $selectedFacetGroup) {
+ $filterText .= $selectedFacetGroup->selectedFacetGroupName . ':' . urlencode( $selectedFacetGroup->selectedFacetItemName ) . ',';
+ }
+ $filterText = substr_replace( $filterText, '', - 1 );
+ // $filterText = ($filterText == '')?'':'&filterText='.$filterText;
+
+
+ /**
+ * ***************************************************************
+ */
+ // Create result
+ $dataFacetResult = array ('aFacetGroups' => $facetGroups,'aSelectedFacetGroups' => $aSelectedFacetGroups,'sFilterText' => $filterText
+ );
+ $facetResult = Entity_FacetResult::createForRequest( $dataFacetResult );
+
+ return $facetResult;
+ }
+
+ /**
+ * Get the total number of documents in search server
+ *
+ * @param string $workspace
+ * @return integer number of documents
+ *
+ */
+ public function getNumberDocuments ($workspace)
+ {
+ require_once ('class.solr.php');
+ // require_once (ROOT_PATH .
+ // '/businessLogic/modules/SearchIndexAccess/Solr.php');
+ $solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
+
+ // create list of facets
+ $numberDocuments = $solr->getNumberDocuments( $workspace );
+
+ return $numberDocuments;
+ }
+
+ /**
+ * Update document Index
+ *
+ * @param SolrUpdateDocumentEntity $solrUpdateDocumentEntity
+ */
+ public function updateIndexDocument ($solrUpdateDocumentEntity)
+ {
+ G::LoadClass( 'solr' );
+
+ $solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
+
+ // create list of facets
+ $solr->updateDocument( $solrUpdateDocumentEntity );
+ }
+
+ /**
+ * Delete document from index
+ *
+ * @param string $workspace
+ * @param string $idQuery
+ */
+ public function deleteDocumentFromIndex ($workspace, $idQuery)
+ {
+ G::LoadClass( 'solr' );
+
+ $solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
+
+ // create list of facets
+ $solr->deleteDocument( $workspace, $idQuery );
+ }
+
+ /**
+ * Commit index changes
+ *
+ * @param string $workspace
+ */
+ public function commitIndexChanges ($workspace)
+ {
+ G::LoadClass( 'solr' );
+
+ $solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
+
+ // commit
+ $solr->commitChanges( $workspace );
+ }
+
+ /**
+ * Optimize index changes
+ *
+ * @param string $workspace
+ */
+ public function optimizeIndexChanges ($workspace)
+ {
+ G::LoadClass( 'solr' );
+
+ $solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
+
+ // commit
+ $solr->optimizeChanges( $workspace );
+ }
+
+ /**
+ * Call Solr server to return the list of paginated pages.
+ *
+ * @param FacetRequest $solrRequestData
+ * @return Entity_SolrQueryResult
+ */
+ public function getDataTablePaginatedList ($solrRequestData)
+ {
+ require_once ('class.solr.php');
+ require_once ('entities/SolrRequestData.php');
+ require_once ('entities/SolrQueryResult.php');
+
+ // prepare the list of sorted columns
+ // verify if the data of sorting is available
+ if (isset( $solrRequestData->sortCols[0] )) {
+ for ($i = 0; $i < $solrRequestData->numSortingCols; $i ++) {
+ // verify if column is sortable
+ if ($solrRequestData->includeCols[$solrRequestData->sortCols[$i]] != '' && $solrRequestData->sortableCols[$i] == "true") {
+ // change sorting column index to column names
+ $solrRequestData->sortCols[$i] = $solrRequestData->includeCols[$solrRequestData->sortCols[$i]];
+ // define the direction of the sorting columns
+ $solrRequestData->sortDir[$i] = $solrRequestData->sortDir[$i];
+ }
+ }
+ }
+ // remove placeholder fields
+ // the placeholder doesn't affect the the solr's response
+ // $solrRequestData->includeCols = array_diff($solrRequestData->includeCols,
+ // array(''));
+
+
+ // execute query
+ $solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
+ $solrPaginatedResult = $solr->executeQuery( $solrRequestData );
+
+ // get total number of documents in index
+ $numTotalDocs = $solr->getNumberDocuments( $solrRequestData->workspace );
+
+ // create the Datatable response of the query
+ $numFound = $solrPaginatedResult->response->numFound;
+
+ $docs = $solrPaginatedResult->response->docs;
+ // print_r($docs);
+ // insert list of names in docs result
+ $data = array ("sEcho" => '', // must be completed in response
+"iTotalRecords" => intval( $numTotalDocs ), // we must get the
+ // total number of
+ // documents
+ "iTotalDisplayRecords" => $numFound,"aaData" => array ()
+ );
+ // copy result document or add placeholders to result
+ foreach ($docs as $i => $doc) {
+ $data['aaData'][$i] = array ();
+ foreach ($solrRequestData->includeCols as $columnName) {
+ if ($columnName == '') {
+ $data['aaData'][$i][] = ''; // placeholder
+ } else {
+ if (isset( $doc->$columnName )) {
+ $data['aaData'][$i][] = $doc->$columnName;
+ } else {
+ $data['aaData'][$i][] = '';
+ }
+ }
+ }
+ }
+
+ $solrQueryResponse = Entity_SolrQueryResult::createForRequest( $data );
+ //
+
+
+ return $solrQueryResponse;
+ }
+
+ /**
+ * Return the list of stored fields in the index.
+ *
+ * @param string $workspace
+ * @return array of index fields
+ */
+ public function getIndexFields ($workspace)
+ {
+ require_once ('class.solr.php');
+
+ $solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
+
+ // print "SearchIndex!!!!";
+ // create list of facets
+ $solrFieldsData = $solr->getListIndexedStoredFields( $workspace );
+ // copy list of arrays
+ $listFields = array ();
+ foreach ($solrFieldsData->fields as $key => $fieldData) {
+ if (array_key_exists( 'dynamicBase', $fieldData )) {
+ $originalFieldName = substr( $key, 0, - strlen( $fieldData->dynamicBase ) + 1 );
+ // $listFields[strtolower($originalFieldName)] = $key; //in case of case insentive strings
+ // Maintain case sensitive variable names
+ $listFields[$originalFieldName] = $key;
+ } else {
+ // $listFields[strtolower($key)] = $key;
+ // Maintain case sensitive variable names
+ $listFields[$key] = $key;
+ }
+ }
+
+ return $listFields;
}
-
- return $listFields;
- }
}
\ No newline at end of file
diff --git a/workflow/engine/classes/class.serverConfiguration.php b/workflow/engine/classes/class.serverConfiguration.php
index d1e2a2926..399ca25eb 100755
--- a/workflow/engine/classes/class.serverConfiguration.php
+++ b/workflow/engine/classes/class.serverConfiguration.php
@@ -1,6 +1,8 @@
.
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
@@ -25,392 +27,442 @@
/**
* ServerConfiguration - serverConf class
+ *
* @author Hugo Loza
* @copyright 2010 COLOSA
* @license GNU Affero General Public License
* @package workflow.engine.ProcessMaker
*/
-class serverConf {
- private $_aProperties = array ();
- private $_aHeartbeatConfig = array ();
- private $_aWSapces = array ();
- private $aWSinfo = array ();
- private $pluginsA = array ();
- private $errors = array ();
- private static $instance = NULL;
- private $haveSetupData = false;
- private $beatType = 'starting';
- private $ip;
- private $index = 0;
- private $os;
- private $webserver;
- private $host;
- private $php;
- private $mysql;
- private $pmVersion;
- private $pmProduct = 'PMCE';
- private $nextBeatDate;
- public $logins;
- private $lanDirection;
- private $lanLanguage;
- public $workspaces = array();
- public $rtlLang = array('ar','iw','fa');
- public $filePath = '';
+class serverConf
+{
+ private $_aProperties = array ();
+ private $_aHeartbeatConfig = array ();
+ private $_aWSapces = array ();
+ private $aWSinfo = array ();
+ private $pluginsA = array ();
+ private $errors = array ();
+ private static $instance = NULL;
+ private $haveSetupData = false;
+ private $beatType = 'starting';
+ private $ip;
+ private $index = 0;
+ private $os;
+ private $webserver;
+ private $host;
+ private $php;
+ private $mysql;
+ private $pmVersion;
+ private $pmProduct = 'PMCE';
+ private $nextBeatDate;
+ public $logins;
+ private $lanDirection;
+ private $lanLanguage;
+ public $workspaces = array ();
+ public $rtlLang = array ('ar','iw','fa'
+ );
+ public $filePath = '';
-
- public function __construct() {
- if (defined('PATH_DATA')) {
- $this->filePath = PATH_DATA . 'srvConf.singleton';
- }
- }
-
- /**
- * This function is instancing to this object
- * param
- * @return object
- */
- function &getSingleton() {
- if (self::$instance == NULL) {
- self::$instance = new serverConf ( );
- if ((file_exists ( self::$instance->filePath ))&&(filesize(self::$instance->filePath)>0)){
- self::$instance->unSerializeInstance ( file_get_contents ( self::$instance->filePath ) );
- }
- }
- return self::$instance;
- }
-
- /**
- * This function generates a storable representation of this obejct
- * param
- * @return void
- */
- function serializeInstance() {
- return serialize ( self::$instance );
- }
-
- /**
- * This function takes a single serialized object and converts it back a object
- * @param string $serialized
- * @return void
- */
- function unSerializeInstance($serialized) {
- if (self::$instance == NULL) {
- self::$instance = new serverConf ( );
- }
-
- if($instance = @unserialize ( $serialized )){
- self::$instance = $instance;
- }
- }
-
- /**
- * This will save the object in the specified file (defined as a property of this class)
- * param
- * @return void
- */
-
- function saveSingleton() {
- if (defined('PATH_DATA')) {
- $this->filePath = PATH_DATA . 'srvConf.singleton';
- $size = file_put_contents ( $this->filePath, $this->serializeInstance () );
- }
- }
-
- /**
- * With this is possible to save a property that will be saved in the properties
- * array of this class.
- * @param string $propertyName
- * @param string $propertyValue
- */
- function setProperty($propertyName, $propertyValue) {
- $this->_aProperties [$propertyName] = $propertyValue;
- $this->saveSingleton ();
- }
-
- /**
- * To unset a defined property. If it doesn't exist then it does nothing.
- * @param string $propertyName
- * @return void
- */
- function unsetProperty($propertyName) {
- if (isset ( $this->_aProperties [$propertyName] )) {
- unset ( $this->_aProperties [$propertyName] );
- $this->saveSingleton ();
- }
- }
-
- /**
- * Returns the value of a defined property. If it doesn't exist then returns null
- * @param string $propertyName
- * @return string/null
- */
- function getProperty($propertyName) {
- if (isset ( $this->_aProperties [$propertyName] )) {
- return $this->_aProperties [$propertyName];
- }
- else {
- return null;
- }
- }
-
- /**
- * Used to have a record of succesful logins to the system (total and by WS)
- * param
- * @return void
- */
- function sucessfulLogin() {
- $this->logins ++;
- if ( isset ($this->workspaces[SYS_SYS]) && isset ($this->workspaces[SYS_SYS]['WSP_LOGINS']) )
- $this->workspaces[SYS_SYS]['WSP_LOGINS'] ++;
-
- if ( isset ($this->workspaces[SYS_SYS]) && !isset ($this->workspaces[SYS_SYS]['WSP_LOGINS']) )
- $this->workspaces[SYS_SYS]['WSP_LOGINS'] = 1;
-
- $this->saveSingleton ();
- }
-
- function setWsInfo($wsname,$info){
- $this->aWSinfo[$wsname]=$info;
- }
-
- /**
- * This will togle the status of a workspace (enabled,disabled)
- * @param string $wsName
- * @return void
- */
- function changeStatusWS($wsName) {
-
- if (isset ( $this->_aWSapces [$wsName] )) { //Enable WS
- unset ( $this->_aWSapces [$wsName] );
- }
- else {
- $this->_aWSapces [$wsName] = 'disabled';
- }
- $this->saveSingleton ();
- }
-
- /**
- * Return the status of a WS. If is disabled will return 1 otherwise 0
- * @param $wsname
- * @return boolean
- */
- function isWSDisabled($wsName) {
- return isset ( $this->_aWSapces [$wsName] );
- }
-
- /**
- * Check only if the server address or server name has changed,
- * to send another beat in next minute.
- * param
- * @return boolean
- */
- function checkIfHostNameHasChanged() {
- //removed the PM_VERSION control, because when an upgrade is done, the haveSetupData has to be changed.
- if ($this->ip != getenv ( 'SERVER_ADDR' ))
- return false;
-
- if ($this->host != getenv ( 'SERVER_NAME' ))
- return false;
-
- return $this->haveSetupData;
- }
-
-
- /**
- * Will return a list of all WS in this system and their related information.
- * @uses getWSList
- * param
- * @return array
- */
- function getWSList() {
- $dir = PATH_DB;
- $wsArray = array ();
- if (file_exists ( $dir )) {
- if ($handle = opendir ( $dir )) {
- while ( false !== ($file = readdir ( $handle )) ) {
- if (($file != ".") && ($file != "..")) {
- if (file_exists ( PATH_DB . $file . '/db.php' )) { //print $file."/db.php
";
- $statusl = ($this->isWSDisabled ( $file )) ? 'DISABLED' : 'ENABLED';
- if(isset($this->aWSinfo[$file])){
- $wsInfo = $this->aWSinfo[$file];
- }else{
- $wsInfo ['num_processes'] = "not gathered yet";
- $wsInfo ['num_cases'] = "not gathered yet";;
- $wsInfo ['num_users'] = "not gathered yet";
- }
- $wsArray [$file] = array ('WSP_ID' => $file, 'WSP_NAME' => $file, 'WSP_STATUS' => $statusl, 'WSP_PROCESS_COUNT' => $wsInfo ['num_processes'], 'WSP_CASES_COUNT' => $wsInfo ['num_cases'], 'WSP_USERS_COUNT' => isset($wsInfo ['num_users'])?$wsInfo ['num_users']:"" );
- if (isset ( $this->workspaces [$file] ['WSP_LOGINS'] ))
- $wsArray [$file] ['WSP_LOGINS'] = $this->workspaces [$file] ['WSP_LOGINS'];
-
- }
- }
+ public function __construct ()
+ {
+ if (defined( 'PATH_DATA' )) {
+ $this->filePath = PATH_DATA . 'srvConf.singleton';
}
- closedir ( $handle );
- }
}
- return $wsArray;
- }
- /**
- * Will return all the information of a WS.
- * - Status
- * - # of cases
- * - # of processes
- * - # of users
- * @param string $wsName
- * @return array
- */
- function getWorkspaceInfo($wsName) {
- $aResult = Array ('num_processes' => '0', 'num_cases' => '0' );
- $result = array();
- require_once 'classes/model/Process.php';
- require_once 'classes/model/Application.php';
- require_once 'classes/model/Users.php';
-
- $Criteria = new Criteria('workflow');
- $Criteria->add (ProcessPeer::PRO_STATUS, 'ACTIVE' , CRITERIA::EQUAL );
- $aResult['num_processes'] = ProcessPeer::doCount($Criteria);
-
- $Criteria = new Criteria('workflow');
- $Criteria->add (ApplicationPeer::APP_STATUS, 'COMPLETED' , CRITERIA::NOT_EQUAL );
- $aResult['num_cases'] = ApplicationPeer::doCount($Criteria);
-
- $Criteria = new Criteria('workflow');
- $Criteria->add (UsersPeer::USR_STATUS, array('DELETED','DISABLED') , CRITERIA::NOT_IN );
- $aResult['num_users'] = UsersPeer::doCount($Criteria);
- return $aResult;
- }
-
- /**
- * Will list the plugins of the system
- * param
- * @return array
- */
- function getPluginsList() {
- return $this->pluginsA;
- }
-
- /***
- * Register a PLugin
- */
- function addPlugin($workspace,$info){
- $this->pluginsA[$workspace]=$info;
- }
-
- function getDBVersion(){
- $sMySQLVersion = '?????';
- if (defined ( "DB_HOST" )) {
- G::LoadClass ( 'net' );
- G::LoadClass ( 'dbConnections' );
- $dbNetView = new NET ( DB_HOST );
- $dbNetView->loginDbServer ( DB_USER, DB_PASS );
-
- $dbConns = new dbConnections ( '' );
- $availdb = '';
- foreach ( $dbConns->getDbServicesAvailables () as $key => $val ) {
- if ($availdb != '')
- $availdb .= ', ';
- $availdb .= $val ['name'];
- }
-
- try {
- $sMySQLVersion = $dbNetView->getDbServerVersion ( 'mysql' );
- }
- catch ( Exception $oException ) {
- $sMySQLVersion = '?????';
- }
+ /**
+ * This function is instancing to this object
+ * param
+ *
+ * @return object
+ */
+ function &getSingleton ()
+ {
+ if (self::$instance == NULL) {
+ self::$instance = new serverConf();
+ if ((file_exists( self::$instance->filePath )) && (filesize( self::$instance->filePath ) > 0)) {
+ self::$instance->unSerializeInstance( file_get_contents( self::$instance->filePath ) );
+ }
+ }
+ return self::$instance;
}
- return $sMySQLVersion;
- }
- /**
- * Will reset all the logins' count
- * param
- * @return void
- */
- function resetLogins() {
- $this->logins = 0;
- if(is_array($this->workspaces)){
- foreach ( $this->workspaces as $wsName => $wsinfo ) {
- $this->workspaces [$wsName] ['WSP_LOGINS'] = 0;
+ /**
+ * This function generates a storable representation of this obejct
+ * param
+ *
+ * @return void
+ */
+ function serializeInstance ()
+ {
+ return serialize( self::$instance );
}
- }
- }
+ /**
+ * This function takes a single serialized object and converts it back a object
+ *
+ * @param string $serialized
+ * @return void
+ */
+ function unSerializeInstance ($serialized)
+ {
+ if (self::$instance == NULL) {
+ self::$instance = new serverConf();
+ }
- /**
- * Get the value of language direction property
- * @param void
- * @return string
- */
- function getLanDirection() {
- if (!isset($this->lanDirection) ) {
- $this->lanDirection = 'L';
- }
- if( defined('SYS_LANG') ) {
- //if we already have the landirection for this language, just return from serverConf
- if ( $this->lanLanguage == SYS_LANG )
- return $this->lanDirection;
+ if ($instance = @unserialize( $serialized )) {
+ self::$instance = $instance;
+ }
+ }
- //if not , we need to query Database, in order to get the direction
- $this->lanDirection = 'L'; //default value;
- $this->lanLanguage = SYS_LANG;
- require_once 'classes/model/Language.php';
- $oLang = new Language();
- try{
- $aLang = $oLang->load(SYS_LANG);
- if( isset($aLang['LAN_DIRECTION']) ){
- $this->lanDirection = strtoupper($aLang['LAN_DIRECTION']);
+ /**
+ * This will save the object in the specified file (defined as a property of this class)
+ * param
+ *
+ * @return void
+ */
+
+ function saveSingleton ()
+ {
+ if (defined( 'PATH_DATA' )) {
+ $this->filePath = PATH_DATA . 'srvConf.singleton';
+ $size = file_put_contents( $this->filePath, $this->serializeInstance() );
+ }
+ }
+
+ /**
+ * With this is possible to save a property that will be saved in the properties
+ * array of this class.
+ *
+ * @param string $propertyName
+ * @param string $propertyValue
+ */
+ function setProperty ($propertyName, $propertyValue)
+ {
+ $this->_aProperties[$propertyName] = $propertyValue;
+ $this->saveSingleton();
+ }
+
+ /**
+ * To unset a defined property.
+ * If it doesn't exist then it does nothing.
+ *
+ * @param string $propertyName
+ * @return void
+ */
+ function unsetProperty ($propertyName)
+ {
+ if (isset( $this->_aProperties[$propertyName] )) {
+ unset( $this->_aProperties[$propertyName] );
+ $this->saveSingleton();
+ }
+ }
+
+ /**
+ * Returns the value of a defined property.
+ * If it doesn't exist then returns null
+ *
+ * @param string $propertyName
+ * @return string/null
+ */
+ function getProperty ($propertyName)
+ {
+ if (isset( $this->_aProperties[$propertyName] )) {
+ return $this->_aProperties[$propertyName];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Used to have a record of succesful logins to the system (total and by WS)
+ * param
+ *
+ * @return void
+ */
+ function sucessfulLogin ()
+ {
+ $this->logins ++;
+ if (isset( $this->workspaces[SYS_SYS] ) && isset( $this->workspaces[SYS_SYS]['WSP_LOGINS'] ))
+ $this->workspaces[SYS_SYS]['WSP_LOGINS'] ++;
+
+ if (isset( $this->workspaces[SYS_SYS] ) && ! isset( $this->workspaces[SYS_SYS]['WSP_LOGINS'] ))
+ $this->workspaces[SYS_SYS]['WSP_LOGINS'] = 1;
+
+ $this->saveSingleton();
+ }
+
+ function setWsInfo ($wsname, $info)
+ {
+ $this->aWSinfo[$wsname] = $info;
+ }
+
+ /**
+ * This will togle the status of a workspace (enabled,disabled)
+ *
+ * @param string $wsName
+ * @return void
+ */
+ function changeStatusWS ($wsName)
+ {
+
+ if (isset( $this->_aWSapces[$wsName] )) { //Enable WS
+ unset( $this->_aWSapces[$wsName] );
+ } else {
+ $this->_aWSapces[$wsName] = 'disabled';
}
$this->saveSingleton();
- }
- catch(Exception $e){
- $this->lanDirection = 'L';
- }
}
- return $this->lanDirection;
- }
-/**
- * With this is possible to save a property that will be saved in the properties
- * array of this class.
- * @param string $propertyName
- * @param string $propertyValue
- * @param string $workspace
- */
- function setHeartbeatProperty($propertyName, $propertyValue, $workspace) {
- $this->_aHeartbeatConfig [$workspace][$propertyName] = $propertyValue;
- $this->saveSingleton ();
- }
- /**
- * To unset a defined property. If it doesn't exist then it does nothing.
- * @param string $propertyName
- * @param string $workspace
- * @return void
- */
- function unsetHeartbeatProperty($propertyName,$workspace) {
- if (isset ( $this->_aHeartbeatConfig [$workspace][$propertyName] ))
- unset ( $this->_aHeartbeatConfig [$workspace][$propertyName] );
- $this->saveSingleton ();
- }
-
- /**
- * Returns the value of a defined property. If it doesn't exist then returns null
- * @param string $propertyName
- * @return string/null
- */
- function getHeartbeatProperty($propertyName, $workspace) {
- if (isset ( $this->_aHeartbeatConfig [$workspace][$propertyName] )) {
- return $this->_aHeartbeatConfig [$workspace][$propertyName];
- } else {
- return null;
+ /**
+ * Return the status of a WS.
+ * If is disabled will return 1 otherwise 0
+ *
+ * @param $wsname
+ * @return boolean
+ */
+ function isWSDisabled ($wsName)
+ {
+ return isset( $this->_aWSapces[$wsName] );
}
- }
- function isRtl ($lang = SYS_LANG) {
- $lang = substr($lang, 0, 2);
- return in_array($lang, $this->rtlLang);
- }
+ /**
+ * Check only if the server address or server name has changed,
+ * to send another beat in next minute.
+ * param
+ *
+ * @return boolean
+ */
+ function checkIfHostNameHasChanged ()
+ {
+ //removed the PM_VERSION control, because when an upgrade is done, the haveSetupData has to be changed.
+ if ($this->ip != getenv( 'SERVER_ADDR' ))
+ return false;
+ if ($this->host != getenv( 'SERVER_NAME' ))
+ return false;
+
+ return $this->haveSetupData;
+ }
+
+ /**
+ * Will return a list of all WS in this system and their related information.
+ *
+ * @uses getWSList
+ * param
+ * @return array
+ */
+ function getWSList ()
+ {
+ $dir = PATH_DB;
+ $wsArray = array ();
+ if (file_exists( $dir )) {
+ if ($handle = opendir( $dir )) {
+ while (false !== ($file = readdir( $handle ))) {
+ if (($file != ".") && ($file != "..")) {
+ if (file_exists( PATH_DB . $file . '/db.php' )) { //print $file."/db.php
";
+ $statusl = ($this->isWSDisabled( $file )) ? 'DISABLED' : 'ENABLED';
+ if (isset( $this->aWSinfo[$file] )) {
+ $wsInfo = $this->aWSinfo[$file];
+ } else {
+ $wsInfo['num_processes'] = "not gathered yet";
+ $wsInfo['num_cases'] = "not gathered yet";
+ ;
+ $wsInfo['num_users'] = "not gathered yet";
+ }
+ $wsArray[$file] = array ('WSP_ID' => $file,'WSP_NAME' => $file,'WSP_STATUS' => $statusl,'WSP_PROCESS_COUNT' => $wsInfo['num_processes'],'WSP_CASES_COUNT' => $wsInfo['num_cases'],'WSP_USERS_COUNT' => isset( $wsInfo['num_users'] ) ? $wsInfo['num_users'] : ""
+ );
+ if (isset( $this->workspaces[$file]['WSP_LOGINS'] ))
+ $wsArray[$file]['WSP_LOGINS'] = $this->workspaces[$file]['WSP_LOGINS'];
+
+ }
+ }
+ }
+ closedir( $handle );
+ }
+ }
+ return $wsArray;
+
+ }
+
+ /**
+ * Will return all the information of a WS.
+ * - Status
+ * - # of cases
+ * - # of processes
+ * - # of users
+ *
+ * @param string $wsName
+ * @return array
+ */
+ function getWorkspaceInfo ($wsName)
+ {
+ $aResult = Array ('num_processes' => '0','num_cases' => '0'
+ );
+ $result = array ();
+ require_once 'classes/model/Process.php';
+ require_once 'classes/model/Application.php';
+ require_once 'classes/model/Users.php';
+
+ $Criteria = new Criteria( 'workflow' );
+ $Criteria->add( ProcessPeer::PRO_STATUS, 'ACTIVE', CRITERIA::EQUAL );
+ $aResult['num_processes'] = ProcessPeer::doCount( $Criteria );
+
+ $Criteria = new Criteria( 'workflow' );
+ $Criteria->add( ApplicationPeer::APP_STATUS, 'COMPLETED', CRITERIA::NOT_EQUAL );
+ $aResult['num_cases'] = ApplicationPeer::doCount( $Criteria );
+
+ $Criteria = new Criteria( 'workflow' );
+ $Criteria->add( UsersPeer::USR_STATUS, array ('DELETED','DISABLED'
+ ), CRITERIA::NOT_IN );
+ $aResult['num_users'] = UsersPeer::doCount( $Criteria );
+ return $aResult;
+ }
+
+ /**
+ * Will list the plugins of the system
+ * param
+ *
+ * @return array
+ */
+ function getPluginsList ()
+ {
+ return $this->pluginsA;
+ }
+
+ /**
+ * *
+ * Register a PLugin
+ */
+ function addPlugin ($workspace, $info)
+ {
+ $this->pluginsA[$workspace] = $info;
+ }
+
+ function getDBVersion ()
+ {
+ $sMySQLVersion = '?????';
+ if (defined( "DB_HOST" )) {
+ G::LoadClass( 'net' );
+ G::LoadClass( 'dbConnections' );
+ $dbNetView = new NET( DB_HOST );
+ $dbNetView->loginDbServer( DB_USER, DB_PASS );
+
+ $dbConns = new dbConnections( '' );
+ $availdb = '';
+ foreach ($dbConns->getDbServicesAvailables() as $key => $val) {
+ if ($availdb != '')
+ $availdb .= ', ';
+ $availdb .= $val['name'];
+ }
+
+ try {
+ $sMySQLVersion = $dbNetView->getDbServerVersion( 'mysql' );
+ } catch (Exception $oException) {
+ $sMySQLVersion = '?????';
+ }
+ }
+ return $sMySQLVersion;
+ }
+
+ /**
+ * Will reset all the logins' count
+ * param
+ *
+ * @return void
+ */
+ function resetLogins ()
+ {
+ $this->logins = 0;
+ if (is_array( $this->workspaces )) {
+ foreach ($this->workspaces as $wsName => $wsinfo) {
+ $this->workspaces[$wsName]['WSP_LOGINS'] = 0;
+ }
+ }
+ }
+
+ /**
+ * Get the value of language direction property
+ *
+ * @param void
+ * @return string
+ */
+ function getLanDirection ()
+ {
+ if (! isset( $this->lanDirection )) {
+ $this->lanDirection = 'L';
+ }
+ if (defined( 'SYS_LANG' )) {
+ //if we already have the landirection for this language, just return from serverConf
+ if ($this->lanLanguage == SYS_LANG)
+ return $this->lanDirection;
+
+ //if not , we need to query Database, in order to get the direction
+ $this->lanDirection = 'L'; //default value;
+ $this->lanLanguage = SYS_LANG;
+ require_once 'classes/model/Language.php';
+ $oLang = new Language();
+ try {
+ $aLang = $oLang->load( SYS_LANG );
+ if (isset( $aLang['LAN_DIRECTION'] )) {
+ $this->lanDirection = strtoupper( $aLang['LAN_DIRECTION'] );
+ }
+ $this->saveSingleton();
+ } catch (Exception $e) {
+ $this->lanDirection = 'L';
+ }
+ }
+ return $this->lanDirection;
+ }
+
+ /**
+ * With this is possible to save a property that will be saved in the properties
+ * array of this class.
+ *
+ * @param string $propertyName
+ * @param string $propertyValue
+ * @param string $workspace
+ */
+ function setHeartbeatProperty ($propertyName, $propertyValue, $workspace)
+ {
+ $this->_aHeartbeatConfig[$workspace][$propertyName] = $propertyValue;
+ $this->saveSingleton();
+ }
+
+ /**
+ * To unset a defined property.
+ * If it doesn't exist then it does nothing.
+ *
+ * @param string $propertyName
+ * @param string $workspace
+ * @return void
+ */
+ function unsetHeartbeatProperty ($propertyName, $workspace)
+ {
+ if (isset( $this->_aHeartbeatConfig[$workspace][$propertyName] ))
+ unset( $this->_aHeartbeatConfig[$workspace][$propertyName] );
+ $this->saveSingleton();
+ }
+
+ /**
+ * Returns the value of a defined property.
+ * If it doesn't exist then returns null
+ *
+ * @param string $propertyName
+ * @return string/null
+ */
+ function getHeartbeatProperty ($propertyName, $workspace)
+ {
+ if (isset( $this->_aHeartbeatConfig[$workspace][$propertyName] )) {
+ return $this->_aHeartbeatConfig[$workspace][$propertyName];
+ } else {
+ return null;
+ }
+ }
+
+ function isRtl ($lang = SYS_LANG)
+ {
+ $lang = substr( $lang, 0, 2 );
+ return in_array( $lang, $this->rtlLang );
+ }
}
\ No newline at end of file
diff --git a/workflow/engine/classes/class.sessions.php b/workflow/engine/classes/class.sessions.php
index 283ea6164..e4912f36b 100755
--- a/workflow/engine/classes/class.sessions.php
+++ b/workflow/engine/classes/class.sessions.php
@@ -1,11 +1,12 @@
.
- *
- * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
+ * along with this program. If not, see .
+ *
+ * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
- *
+ *
*/
require_once 'classes/model/Session.php';
+
/**
* Sessions - Sessions class
+ *
* @package workflow.engine.ProcessMaker
* @author Everth S. Berrios Morales
* @copyright 2008 COLOSA
*/
-class Sessions {
-
- protected $tmpfile;
- private $sessionId;
- private $globals;
-
- /**
- * This function is the constructor of the Sessions class
- * @param string $sSessionId
- * @return void
- */
- public function __construct($sSessionId=NULL){
- $this->sessionId = $sSessionId;
- }
-
- /**
- * This function gets the user session
- *
- *
- * @name getSessionUser
- *
- * @param string sSessionId
- * @return array
- */
- public function getSessionUser($sSessionId=NULL)
- {
- try
- {
- if($sSessionId != NULL){
- $this->sessionId = $sSessionId;
- } else if($this->sessionId == NULL){
- throw new Exception('session id was not set.');
- }
-
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(SessionPeer::USR_UID);
- $oCriteria->addSelectColumn(SessionPeer::SES_STATUS);
- $oCriteria->addSelectColumn(SessionPeer::SES_DUE_DATE);
- $oCriteria->add(SessionPeer::SES_UID, $this->sessionId);
-
- $oDataset = SessionPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aRow = $oDataset->getRow();
-
- if( !is_array($aRow) ){
- $this->deleteTmpfile();
- }
- return $aRow;
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * This function checks the user session
- *
- *
- * @name verifySession
- *
- * @param string sSessionId
- * @return array
- */
- public function verifySession($sSessionId=NULL)
- {
- try
- {
- if($sSessionId != NULL){
- $this->sessionId = $sSessionId;
- } else if($this->sessionId == NULL){
- throw new Exception('session id was not set.');
- }
-
- $date=date('Y-m-d H:i:s');
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(SessionPeer::USR_UID);
- $oCriteria->addSelectColumn(SessionPeer::SES_STATUS);
- $oCriteria->addSelectColumn(SessionPeer::SES_DUE_DATE);
- $oCriteria->add(SessionPeer::SES_UID, $this->sessionId);
- $oCriteria->add(SessionPeer::SES_STATUS, 'ACTIVE');
- $oCriteria->add(SessionPeer::SES_DUE_DATE, $date, Criteria::GREATER_EQUAL);
-
- $oDataset = SessionPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aRow = $oDataset->getRow();
+class Sessions
+{
- if( !is_array($aRow) ){
- $this->deleteTmpfile();
- }
-
- return $aRow;
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * This function registers into globals variables
- *
- *
- * @name registerGlobal
- *
- * @param string $name
- * @param string $value
- * @return void
- */
- public function registerGlobal($name, $value)
- {
- $this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
-
- if($this->sessionId == NULL){
- throw new Exception('session id was not set.');
- }
-
- $tmpfile_content = '';
- if( is_file($this->tmpfile) && trim(file_get_contents($this->tmpfile)) != '' ) {
- $tmpfile_content = file_get_contents($this->tmpfile);
- }
-
- //getting the global array
- if( $tmpfile_content != ''){
- $this->globals = unserialize($tmpfile_content);
- } else {
- $this->globals = Array();
- }
-
- //registering the new global variable
- $this->globals[$name] = $value;
-
- //saving the global array
- $tmpfile_content = serialize($this->globals);
- file_put_contents($this->tmpfile, $tmpfile_content);
-
- }
-
- /**
- * This function gets a global variable
- *
- *
- * @name getGlobal
- *
- * @param string $name
- * @return string
- */
- public function getGlobal($name)
- {
- $this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
-
- if($this->sessionId == NULL){
- throw new Exception('session id was not set.');
- }
-
- $tmpfile_content = '';
- if( is_file($this->tmpfile) && trim(file_get_contents($this->tmpfile)) != '' ) {
- $tmpfile_content = file_get_contents($this->tmpfile);
- }
-
- //getting the global array
- if( $tmpfile_content != ''){
- $this->globals = unserialize($tmpfile_content);
- } else {
- $this->globals = Array();
- }
-
- //getting the new global variable
- if( isset($this->globals[$name]) ){
- return $this->globals[$name];
- } else {
- return '';
- }
- }
-
- /**
- * This function gets all globals variables
- *
- *
- * @name getGlobals
- *
- * @param string $name
- * @return array
- */
- public function getGlobals()
- {
- $this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
-
- if($this->sessionId == NULL){
- throw new Exception('session id was not set.');
- }
-
- $tmpfile_content = '';
- if( is_file($this->tmpfile) && trim(file_get_contents($this->tmpfile)) != '' ) {
- $tmpfile_content = file_get_contents($this->tmpfile);
- }
-
- //getting the global array
- if( $tmpfile_content != ''){
- $this->globals = unserialize($tmpfile_content);
- } else {
- $this->globals = Array();
- }
- return $this->globals;
- }
-
- /**
- * This function removes a temporal file
- *
- *
- * @name deleteTmpfile
- *
- * param
- * @return void
- */
- private function deleteTmpfile(){
- if($this->sessionId == NULL){
- throw new Exception('session id was not set.');
+ protected $tmpfile;
+ private $sessionId;
+ private $globals;
+
+ /**
+ * This function is the constructor of the Sessions class
+ *
+ * @param string $sSessionId
+ * @return void
+ */
+ public function __construct ($sSessionId = NULL)
+ {
+ $this->sessionId = $sSessionId;
}
- $this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
- @unlink($this->tmpfile);
- }
-
+
+ /**
+ * This function gets the user session
+ *
+ *
+ * @name getSessionUser
+ *
+ * @param string sSessionId
+ * @return array
+ */
+ public function getSessionUser ($sSessionId = NULL)
+ {
+ try {
+ if ($sSessionId != NULL) {
+ $this->sessionId = $sSessionId;
+ } else if ($this->sessionId == NULL) {
+ throw new Exception( 'session id was not set.' );
+ }
+
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addSelectColumn( SessionPeer::USR_UID );
+ $oCriteria->addSelectColumn( SessionPeer::SES_STATUS );
+ $oCriteria->addSelectColumn( SessionPeer::SES_DUE_DATE );
+ $oCriteria->add( SessionPeer::SES_UID, $this->sessionId );
+
+ $oDataset = SessionPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ $aRow = $oDataset->getRow();
+
+ if (! is_array( $aRow )) {
+ $this->deleteTmpfile();
+ }
+ return $aRow;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * This function checks the user session
+ *
+ *
+ * @name verifySession
+ *
+ * @param string sSessionId
+ * @return array
+ */
+ public function verifySession ($sSessionId = NULL)
+ {
+ try {
+ if ($sSessionId != NULL) {
+ $this->sessionId = $sSessionId;
+ } else if ($this->sessionId == NULL) {
+ throw new Exception( 'session id was not set.' );
+ }
+
+ $date = date( 'Y-m-d H:i:s' );
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addSelectColumn( SessionPeer::USR_UID );
+ $oCriteria->addSelectColumn( SessionPeer::SES_STATUS );
+ $oCriteria->addSelectColumn( SessionPeer::SES_DUE_DATE );
+ $oCriteria->add( SessionPeer::SES_UID, $this->sessionId );
+ $oCriteria->add( SessionPeer::SES_STATUS, 'ACTIVE' );
+ $oCriteria->add( SessionPeer::SES_DUE_DATE, $date, Criteria::GREATER_EQUAL );
+
+ $oDataset = SessionPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ $aRow = $oDataset->getRow();
+
+ if (! is_array( $aRow )) {
+ $this->deleteTmpfile();
+ }
+
+ return $aRow;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * This function registers into globals variables
+ *
+ *
+ * @name registerGlobal
+ *
+ * @param string $name
+ * @param string $value
+ * @return void
+ */
+ public function registerGlobal ($name, $value)
+ {
+ $this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
+
+ if ($this->sessionId == NULL) {
+ throw new Exception( 'session id was not set.' );
+ }
+
+ $tmpfile_content = '';
+ if (is_file( $this->tmpfile ) && trim( file_get_contents( $this->tmpfile ) ) != '') {
+ $tmpfile_content = file_get_contents( $this->tmpfile );
+ }
+
+ //getting the global array
+ if ($tmpfile_content != '') {
+ $this->globals = unserialize( $tmpfile_content );
+ } else {
+ $this->globals = Array ();
+ }
+
+ //registering the new global variable
+ $this->globals[$name] = $value;
+
+ //saving the global array
+ $tmpfile_content = serialize( $this->globals );
+ file_put_contents( $this->tmpfile, $tmpfile_content );
+
+ }
+
+ /**
+ * This function gets a global variable
+ *
+ *
+ * @name getGlobal
+ *
+ * @param string $name
+ * @return string
+ */
+ public function getGlobal ($name)
+ {
+ $this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
+
+ if ($this->sessionId == NULL) {
+ throw new Exception( 'session id was not set.' );
+ }
+
+ $tmpfile_content = '';
+ if (is_file( $this->tmpfile ) && trim( file_get_contents( $this->tmpfile ) ) != '') {
+ $tmpfile_content = file_get_contents( $this->tmpfile );
+ }
+
+ //getting the global array
+ if ($tmpfile_content != '') {
+ $this->globals = unserialize( $tmpfile_content );
+ } else {
+ $this->globals = Array ();
+ }
+
+ //getting the new global variable
+ if (isset( $this->globals[$name] )) {
+ return $this->globals[$name];
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * This function gets all globals variables
+ *
+ *
+ * @name getGlobals
+ *
+ * @param string $name
+ * @return array
+ */
+ public function getGlobals ()
+ {
+ $this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
+
+ if ($this->sessionId == NULL) {
+ throw new Exception( 'session id was not set.' );
+ }
+
+ $tmpfile_content = '';
+ if (is_file( $this->tmpfile ) && trim( file_get_contents( $this->tmpfile ) ) != '') {
+ $tmpfile_content = file_get_contents( $this->tmpfile );
+ }
+
+ //getting the global array
+ if ($tmpfile_content != '') {
+ $this->globals = unserialize( $tmpfile_content );
+ } else {
+ $this->globals = Array ();
+ }
+ return $this->globals;
+ }
+
+ /**
+ * This function removes a temporal file
+ *
+ *
+ * @name deleteTmpfile
+ *
+ * param
+ * @return void
+ */
+ private function deleteTmpfile ()
+ {
+ if ($this->sessionId == NULL) {
+ throw new Exception( 'session id was not set.' );
+ }
+ $this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
+ @unlink( $this->tmpfile );
+ }
+
}
diff --git a/workflow/engine/classes/class.solr.php b/workflow/engine/classes/class.solr.php
index 52061bad4..6aa025006 100644
--- a/workflow/engine/classes/class.solr.php
+++ b/workflow/engine/classes/class.solr.php
@@ -1,6 +1,6 @@
_solrIsEnabled = $solrIsEnabled;
- $this->_solrHost = $solrHost;
- }
-
- /**
- * Verify if the Solr service is available
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return bool
- */
- public function isEnabled()
- {
- // verify solr server response
-
- return $this->_solrIsEnabled;
- }
-
- /**
- * Returns the total number of indexed documents
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @param
- * workspace: workspace name
- * @return total
- */
- public function getNumberDocuments($workspace)
- {
- if (! $this->_solrIsEnabled)
- return;
- // get configuration information in base to workspace parameter
-
- // get total number of documents in registry
- $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/select/?q=*:*";
- $solrIntruct .= self::SOLR_VERSION;
- $solrIntruct .= "&start=0&rows=0&echoParams=none&wt=json";
-
- $handlerTotal = curl_init ($solrIntruct);
- curl_setopt ($handlerTotal, CURLOPT_RETURNTRANSFER, true);
-
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handlerTotal, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handlerTotal, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handlerTotal, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handlerTotal, CURLOPT_HTTPHEADER, array('Expect:'));
+ public function __construct ($solrIsEnabled = false, $solrHost = "")
+ {
+ // use the parameters to initialize class
+ $this->_solrIsEnabled = $solrIsEnabled;
+ $this->_solrHost = $solrHost;
}
- $responseTotal = curl_exec ($handlerTotal);
- curl_close ($handlerTotal);
+ /**
+ * Verify if the Solr service is available
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return bool
+ */
+ public function isEnabled ()
+ {
+ // verify solr server response
- // verify the result of solr
- $responseSolrTotal = G::json_decode ($responseTotal);
- if ($responseSolrTotal->responseHeader->status != 0) {
- throw new Exception ("Error returning the total number of documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
- $numTotalDocs = $responseSolrTotal->response->numFound;
- return $numTotalDocs;
- }
- /**
- * Execute a query in base to Requested data
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function executeQuery($solrRequestData)
- {
- if (! $this->_solrIsEnabled)
- return;
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $workspace = $solrRequestData->workspace;
-
- // format request
- $query = empty ($solrRequestData->searchText) ? '*:*' : $solrRequestData->searchText;
- $query = rawurlencode ($query);
- $start = '&start=' . $solrRequestData->startAfter;
- $rows = '&rows=' . $solrRequestData->pageSize;
- $fieldList = '';
- $cols = $solrRequestData->includeCols;
- if (! empty ($cols)) {
- $fieldList = "&fl=" . implode (",", $cols);
- }
- $sort = '';
- if ($solrRequestData->numSortingCols > 0) {
- $sort = '&sort=';
- for ($i = 0; $i < $solrRequestData->numSortingCols; $i ++) {
- $sort .= $solrRequestData->sortCols [$i] . "%20" . $solrRequestData->sortDir [$i] . ",";
- }
-
- $sort = substr_replace ($sort, "", - 1);
- }
- $resultFormat = empty ($solrRequestData->resultFormat) ? '' : '&wt=' . $solrRequestData->resultFormat;
- $filters = '';
- $aFilters = explode (',', $solrRequestData->filterText);
- foreach ($aFilters as $value) {
- $filters .= '&fq=' . urlencode ($value);
+ return $this->_solrIsEnabled;
}
- $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/select/?q=$query";
- $solrIntruct .= "&echoParams=none";
- $solrIntruct .= self::SOLR_VERSION;
- $solrIntruct .= $start;
- $solrIntruct .= $rows;
- $solrIntruct .= $fieldList;
- $solrIntruct .= $sort;
- $solrIntruct .= $filters;
- $solrIntruct .= $resultFormat;
- // send query
- // search the cases in base to datatable parameters
- $handler = curl_init ($solrIntruct);
- curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
+ /**
+ * Returns the total number of indexed documents
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @param workspace: workspace name
+ * @return total
+ */
+ public function getNumberDocuments ($workspace)
+ {
+ if (! $this->_solrIsEnabled)
+ return;
+ // get configuration information in base to workspace parameter
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
+
+ // get total number of documents in registry
+ $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/select/?q=*:*";
+ $solrIntruct .= self::SOLR_VERSION;
+ $solrIntruct .= "&start=0&rows=0&echoParams=none&wt=json";
+
+ $handlerTotal = curl_init( $solrIntruct );
+ curl_setopt( $handlerTotal, CURLOPT_RETURNTRANSFER, true );
+
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt( $handlerTotal, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt( $handlerTotal, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt( $handlerTotal, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
+ }
+ curl_setopt( $handlerTotal, CURLOPT_HTTPHEADER, array ('Expect:'
+ ) );
+ }
+
+ $responseTotal = curl_exec( $handlerTotal );
+ curl_close( $handlerTotal );
+
+ // verify the result of solr
+ $responseSolrTotal = G::json_decode( $responseTotal );
+ if ($responseSolrTotal->responseHeader->status != 0) {
+ throw new Exception( "Error returning the total number of documents in Solr." . $solrIntruct . " response error: " . $response . "\n" );
+ }
+ $numTotalDocs = $responseSolrTotal->response->numFound;
+ return $numTotalDocs;
}
- $response = curl_exec ($handler);
- curl_close ($handler);
+ /**
+ * Execute a query in base to Requested data
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function executeQuery ($solrRequestData)
+ {
+ if (! $this->_solrIsEnabled)
+ return;
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $workspace = $solrRequestData->workspace;
- // decode
- $responseSolr = G::json_decode ($response);
- if ($responseSolr->responseHeader->status != 0) {
- throw new Exception ("Error executing query to Solr." . $solrIntruct . " response error: " . $response . "\n");
+ // format request
+ $query = empty( $solrRequestData->searchText ) ? '*:*' : $solrRequestData->searchText;
+ $query = rawurlencode( $query );
+ $start = '&start=' . $solrRequestData->startAfter;
+ $rows = '&rows=' . $solrRequestData->pageSize;
+ $fieldList = '';
+ $cols = $solrRequestData->includeCols;
+ if (! empty( $cols )) {
+ $fieldList = "&fl=" . implode( ",", $cols );
+ }
+ $sort = '';
+ if ($solrRequestData->numSortingCols > 0) {
+ $sort = '&sort=';
+ for ($i = 0; $i < $solrRequestData->numSortingCols; $i ++) {
+ $sort .= $solrRequestData->sortCols[$i] . "%20" . $solrRequestData->sortDir[$i] . ",";
+ }
+
+ $sort = substr_replace( $sort, "", - 1 );
+ }
+ $resultFormat = empty( $solrRequestData->resultFormat ) ? '' : '&wt=' . $solrRequestData->resultFormat;
+ $filters = '';
+ $aFilters = explode( ',', $solrRequestData->filterText );
+ foreach ($aFilters as $value) {
+ $filters .= '&fq=' . urlencode( $value );
+ }
+
+ $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/select/?q=$query";
+ $solrIntruct .= "&echoParams=none";
+ $solrIntruct .= self::SOLR_VERSION;
+ $solrIntruct .= $start;
+ $solrIntruct .= $rows;
+ $solrIntruct .= $fieldList;
+ $solrIntruct .= $sort;
+ $solrIntruct .= $filters;
+ $solrIntruct .= $resultFormat;
+ // send query
+ // search the cases in base to datatable parameters
+ $handler = curl_init( $solrIntruct );
+ curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
+
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
+ }
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
+ ) );
+ }
+
+ $response = curl_exec( $handler );
+ curl_close( $handler );
+
+ // decode
+ $responseSolr = G::json_decode( $response );
+ if ($responseSolr->responseHeader->status != 0) {
+ throw new Exception( "Error executing query to Solr." . $solrIntruct . " response error: " . $response . "\n" );
+ }
+
+ return $responseSolr;
}
- return $responseSolr;
- }
+ /**
+ * Insert or Update document index
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function updateDocument ($solrUpdateDocument)
+ {
+ if (! $this->_solrIsEnabled)
+ return;
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $solrUpdateDocument->workspace;
+ $solrIntruct .= "/update";
- /**
- * Insert or Update document index
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function updateDocument($solrUpdateDocument)
- {
- if (! $this->_solrIsEnabled)
- return;
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $solrUpdateDocument->workspace;
- $solrIntruct .= "/update";
+ $handler = curl_init( $solrIntruct );
+ curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml'
+ ) ); // -H
+ curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
+ curl_setopt( $handler, CURLOPT_POSTFIELDS, $solrUpdateDocument->document ); // data
- $handler = curl_init ($solrIntruct);
- curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
- curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
- 'Content-type:application/xml'
- )); // -H
- curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
- curl_setopt ($handler, CURLOPT_POSTFIELDS, $solrUpdateDocument->document); // data
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
+ }
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
+ ) );
+ }
+
+ $response = curl_exec( $handler );
+ curl_close( $handler );
+
+ $swOk = strpos( $response, '0' );
+ if (! $swOk) {
+ throw new Exception( "Error updating document in Solr." . $solrIntruct . " response error: " . $response . "\n" );
+ }
}
- $response = curl_exec ($handler);
- curl_close ($handler);
+ /**
+ * Commit the changes since the last commit
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function commitChanges ($workspace)
+ {
+ if (! $this->_solrIsEnabled)
+ return;
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/update";
- $swOk = strpos ($response, '0');
- if (! $swOk) {
- throw new Exception ("Error updating document in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
- }
+ $handler = curl_init( $solrIntruct );
+ curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml'
+ ) ); // -H
+ curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
+ curl_setopt( $handler, CURLOPT_POSTFIELDS, "" ); // data
- /**
- * Commit the changes since the last commit
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function commitChanges($workspace)
- {
- if (! $this->_solrIsEnabled)
- return;
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/update";
- $handler = curl_init ($solrIntruct);
- curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
- curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
- 'Content-type:application/xml'
- )); // -H
- curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
- curl_setopt ($handler, CURLOPT_POSTFIELDS, ""); // data
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
+ }
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
+ ) );
+ }
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
+ $response = curl_exec( $handler );
+ curl_close( $handler );
+
+ $swOk = strpos( $response, '0' );
+ if (! $swOk) {
+ throw new Exception( "Error commiting changes in Solr." . $solrIntruct . " response error: " . $response . "\n" );
+ }
}
- $response = curl_exec ($handler);
- curl_close ($handler);
+ /**
+ * Rollback the changes since the last commit
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function rollbackChanges ($workspace)
+ {
+ if (! $this->_solrIsEnabled)
+ return;
- $swOk = strpos ($response, '0');
- if (! $swOk) {
- throw new Exception ("Error commiting changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
- }
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/update";
- /**
- * Rollback the changes since the last commit
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function rollbackChanges($workspace)
- {
- if (! $this->_solrIsEnabled)
- return;
+ $handler = curl_init( $solrIntruct );
+ curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml'
+ ) ); // -H
+ curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
+ curl_setopt( $handler, CURLOPT_POSTFIELDS, "" ); // data
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/update";
- $handler = curl_init ($solrIntruct);
- curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
- curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
- 'Content-type:application/xml'
- )); // -H
- curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
- curl_setopt ($handler, CURLOPT_POSTFIELDS, ""); // data
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
+ }
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
+ ) );
+ }
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
+ $response = curl_exec( $handler );
+ curl_close( $handler );
+
+ $swOk = strpos( $response, '0' );
+ if (! $swOk) {
+ throw new Exception( "Error rolling back changes in Solr." . $solrIntruct . " response error: " . $response . "\n" );
+ }
}
- $response = curl_exec ($handler);
- curl_close ($handler);
+ /**
+ * Optimize Solr index
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function optimizeChanges ($workspace)
+ {
+ if (! $this->_solrIsEnabled)
+ return;
- $swOk = strpos ($response, '0');
- if (! $swOk) {
- throw new Exception ("Error rolling back changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
- }
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/update";
- /**
- * Optimize Solr index
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function optimizeChanges($workspace)
- {
- if (! $this->_solrIsEnabled)
- return;
+ $handler = curl_init( $solrIntruct );
+ curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml'
+ ) ); // -H
+ curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
+ curl_setopt( $handler, CURLOPT_POSTFIELDS, "" ); // data
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/update";
- $handler = curl_init ($solrIntruct);
- curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
- curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
- 'Content-type:application/xml'
- )); // -H
- curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
- curl_setopt ($handler, CURLOPT_POSTFIELDS, ""); // data
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
+ }
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
+ ) );
+ }
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
+ $response = curl_exec( $handler );
+ curl_close( $handler );
+
+ $swOk = strpos( $response, '0' );
+ if (! $swOk) {
+ throw new Exception( "Error optimizing changes in Solr." . $solrIntruct . " response error: " . $response . "\n" );
+ }
}
- $response = curl_exec ($handler);
- curl_close ($handler);
+ /**
+ * Return the list of the stored fields in Solr
+ *
+ * @param string $workspace Solr instance name
+ * @throws Exception
+ * @return void mixed of field names
+ */
+ public function getListIndexedStoredFields ($workspace)
+ {
+ if (! $this->_solrIsEnabled)
+ return;
- $swOk = strpos ($response, '0');
- if (! $swOk) {
- throw new Exception ("Error optimizing changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
- }
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/admin/luke?numTerms=0&wt=json";
- /**
- * Return the list of the stored fields in Solr
- *
- * @param string $workspace
- * Solr instance name
- * @throws Exception
- * @return void mixed of field names
- */
- public function getListIndexedStoredFields($workspace)
- {
- if (! $this->_solrIsEnabled)
- return;
+ $handler = curl_init( $solrIntruct );
+ curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/admin/luke?numTerms=0&wt=json";
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
+ }
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
+ ) );
+ }
- $handler = curl_init ($solrIntruct);
- curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
-
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
+ $response = curl_exec( $handler );
+ curl_close( $handler );
+ // decode
+ $responseSolr = G::json_decode( $response );
+ if ($responseSolr->responseHeader->status != 0) {
+ throw new Exception( "Error getting index fields in Solr." . $solrIntruct . " response error: " . $response . "\n" );
+ }
+ return $responseSolr;
}
- $response = curl_exec ($handler);
- curl_close ($handler);
- // decode
- $responseSolr = G::json_decode ($response);
- if ($responseSolr->responseHeader->status != 0) {
- throw new Exception ("Error getting index fields in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
- return $responseSolr;
- }
+ /**
+ * Delete all documents from index
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function deleteAllDocuments ($workspace)
+ {
+ if (! $this->_solrIsEnabled)
+ return;
+ // $registry = Zend_Registry::getInstance();
- /**
- * Delete all documents from index
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function deleteAllDocuments($workspace)
- {
- if (! $this->_solrIsEnabled)
- return;
- // $registry = Zend_Registry::getInstance();
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/update";
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/update";
- $handler = curl_init ($solrIntruct);
- curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
- curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
- 'Content-type:application/xml'
- )); // -H
- curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
- curl_setopt ($handler, CURLOPT_POSTFIELDS, "*:*"); // data
+ $handler = curl_init( $solrIntruct );
+ curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml'
+ ) ); // -H
+ curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
+ curl_setopt( $handler, CURLOPT_POSTFIELDS, "*:*" ); // data
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
+
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
+ }
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
+ ) );
+ }
+
+ $response = curl_exec( $handler );
+
+ curl_close( $handler );
+
+ $swOk = strpos( $response, '0' );
+ if (! $swOk) {
+ throw new Exception( "Error deleting all documents in Solr." . $solrIntruct . " response error: " . $response . "\n" );
+ }
}
- $response = curl_exec ($handler);
+ /**
+ * Delete specified documents from index
+ * @gearman = false
+ * @rest = false
+ * @background = false
+ *
+ * @return solr response
+ */
+ public function deleteDocument ($workspace, $idQuery)
+ {
+ if (! $this->_solrIsEnabled)
+ return;
+ // $registry = Zend_Registry::getInstance();
- curl_close ($handler);
- $swOk = strpos ($response, '0');
- if (! $swOk) {
- throw new Exception ("Error deleting all documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
- }
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/update";
- /**
- * Delete specified documents from index
- * @gearman = false
- * @rest = false
- * @background = false
- *
- * @return solr response
- */
- public function deleteDocument($workspace, $idQuery)
- {
- if (! $this->_solrIsEnabled)
- return;
- // $registry = Zend_Registry::getInstance();
+ $handler = curl_init( $solrIntruct );
+ curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Content-type:application/xml'
+ ) ); // -H
+ curl_setopt( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
+ curl_setopt( $handler, CURLOPT_POSTFIELDS, "" . $idQuery . "" ); // data
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/update";
- $handler = curl_init ($solrIntruct);
- curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
- curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
- 'Content-type:application/xml'
- )); // -H
- curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
- curl_setopt ($handler, CURLOPT_POSTFIELDS, "" . $idQuery . ""); // data
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
+ }
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
+ ) );
+ }
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
+ $response = curl_exec( $handler );
+
+ curl_close( $handler );
+
+ $swOk = strpos( $response, '0' );
+ if (! $swOk) {
+ throw new Exception( "Error deleting document in Solr." . $solrIntruct . " response error: " . $response . "\n" );
+ }
}
- $response = curl_exec ($handler);
+ /**
+ * Execute a query in base to Request data
+ *
+ * @param Entity_FacetRequest $facetRequestEntity
+ * @return solr response: list of facets array
+ */
+ public function getFacetsList ($facetRequest)
+ {
+ if (! $this->_solrIsEnabled)
+ return;
- curl_close ($handler);
+ $solrIntruct = '';
+ // get configuration information in base to workspace parameter
+ $workspace = $facetRequest->workspace;
- $swOk = strpos ($response, '0');
- if (! $swOk) {
- throw new Exception ("Error deleting document in Solr." . $solrIntruct . " response error: " . $response . "\n");
+ // format request
+ $query = empty( $facetRequest->searchText ) ? '*:*' : $facetRequest->searchText;
+ $query = rawurlencode( $query );
+ $start = '&start=0';
+ $rows = '&rows=0';
+ $facets = '&facet=on&facet.mincount=1&facet.limit=20'; // enable facet and
+ // only return facets
+ // with minimun one
+ // instance
+ foreach ($facetRequest->facetFields as $value) {
+ $facets .= '&facet.field=' . $value;
+ }
+ foreach ($facetRequest->facetQueries as $value) {
+ $facets .= '&facet.query=' . $value;
+ }
+ if (! empty( $facetRequest->facetDates )) {
+ foreach ($facetRequest->facetDates as $value) {
+ $facets .= '&facet.date=' . $value;
+ }
+ $facets .= '&facet.date.start=' . $facetRequest->facetDatesStart;
+ $facets .= '&facet.date.end=' . $facetRequest->facetDatesEnd;
+ $facets .= '&facet.date.gap=' . $facetRequest->facetDateGap;
+ }
+ $filters = '';
+ foreach ($facetRequest->filters as $value) {
+ $filters .= '&fq=' . $value;
+ }
+ // echo "";
+
+
+ $resultFormat = '&wt=json';
+
+ $solrIntruct = (substr( $this->_solrHost, - 1 ) == "/") ? $this->_solrHost : $this->_solrHost . "/";
+ $solrIntruct .= $workspace;
+ $solrIntruct .= "/select/?q=$query";
+ $solrIntruct .= "&echoParams=none";
+ $solrIntruct .= self::SOLR_VERSION;
+ $solrIntruct .= $start;
+ $solrIntruct .= $rows;
+ $solrIntruct .= $facets;
+ $solrIntruct .= $filters;
+ $solrIntruct .= $resultFormat;
+
+ // send query
+ // search the cases in base to datatable parameters
+ $handler = curl_init( $solrIntruct );
+ curl_setopt( $handler, CURLOPT_RETURNTRANSFER, true );
+
+ //Apply proxy settings
+ $sysConf = System::getSystemConfiguration();
+ if ($sysConf['proxy_host'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
+ if ($sysConf['proxy_port'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
+ }
+ if ($sysConf['proxy_user'] != '') {
+ curl_setopt( $handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
+ }
+ curl_setopt( $handler, CURLOPT_HTTPHEADER, array ('Expect:'
+ ) );
+ }
+
+ $response = curl_exec( $handler );
+ curl_close( $handler );
+
+ // decode
+ $responseSolr = G::json_decode( $response );
+ if ($responseSolr->responseHeader->status != 0) {
+ throw new Exception( "Error getting faceted list from Solr." . $solrIntruct . " response error: " . $response . "\n" );
+ }
+
+ return $responseSolr;
}
- }
-
- /**
- * Execute a query in base to Request data
- *
- * @param Entity_FacetRequest $facetRequestEntity
- * @return solr response: list of facets array
- */
- public function getFacetsList($facetRequest)
- {
- if (! $this->_solrIsEnabled)
- return;
-
- $solrIntruct = '';
- // get configuration information in base to workspace parameter
- $workspace = $facetRequest->workspace;
-
- // format request
- $query = empty ($facetRequest->searchText) ? '*:*' : $facetRequest->searchText;
- $query = rawurlencode ($query);
- $start = '&start=0';
- $rows = '&rows=0';
- $facets = '&facet=on&facet.mincount=1&facet.limit=20'; // enable facet and
- // only return facets
- // with minimun one
- // instance
- foreach ($facetRequest->facetFields as $value) {
- $facets .= '&facet.field=' . $value;
- }
- foreach ($facetRequest->facetQueries as $value) {
- $facets .= '&facet.query=' . $value;
- }
- if (! empty ($facetRequest->facetDates)) {
- foreach ($facetRequest->facetDates as $value) {
- $facets .= '&facet.date=' . $value;
- }
- $facets .= '&facet.date.start=' . $facetRequest->facetDatesStart;
- $facets .= '&facet.date.end=' . $facetRequest->facetDatesEnd;
- $facets .= '&facet.date.gap=' . $facetRequest->facetDateGap;
- }
- $filters = '';
- foreach ($facetRequest->filters as $value) {
- $filters .= '&fq=' . $value;
- }
- // echo "";
-
- $resultFormat = '&wt=json';
-
- $solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
- $solrIntruct .= $workspace;
- $solrIntruct .= "/select/?q=$query";
- $solrIntruct .= "&echoParams=none";
- $solrIntruct .= self::SOLR_VERSION;
- $solrIntruct .= $start;
- $solrIntruct .= $rows;
- $solrIntruct .= $facets;
- $solrIntruct .= $filters;
- $solrIntruct .= $resultFormat;
-
- // send query
- // search the cases in base to datatable parameters
- $handler = curl_init ($solrIntruct);
- curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
-
- //Apply proxy settings
- $sysConf = System::getSystemConfiguration();
- if ($sysConf['proxy_host'] != '') {
- curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
- if ($sysConf['proxy_port'] != '') {
- curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
- }
- if ($sysConf['proxy_user'] != '') {
- curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
- }
- curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
- }
-
- $response = curl_exec ($handler);
- curl_close ($handler);
-
- // decode
- $responseSolr = G::json_decode ($response);
- if ($responseSolr->responseHeader->status != 0) {
- throw new Exception ("Error getting faceted list from Solr." . $solrIntruct . " response error: " . $response . "\n");
- }
-
- return $responseSolr;
- }
}
diff --git a/workflow/engine/classes/class.spool.php b/workflow/engine/classes/class.spool.php
index c145addff..497728e6d 100755
--- a/workflow/engine/classes/class.spool.php
+++ b/workflow/engine/classes/class.spool.php
@@ -1,6 +1,7 @@
.
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
@@ -26,6 +27,7 @@
/**
* spoolRun - brief send email from the spool database, and see if we have all the addresses we send to.
+ *
* @author Ian K Armstrong
* @copyright Copyright (c) 2007, Ian K Armstrong
* @license http://www.opensource.org/licenses/gpl-3.0.html GNU Public License
@@ -36,7 +38,7 @@
* LOG FIXES
* =========
*
- * 24-03-2010 Erik A.O.
+ * 24-03-2010 Erik A.O.
* class: the $ExceptionCode and $aWarnings class attributes were added
* function handleFrom(): Validations for invalid data for {$this->fileData['from_email']} were added
* function resendEmails(): handler for warnings was added and fixes
@@ -46,472 +48,492 @@
require_once ('classes/model/AppMessage.php');
- /**
- * @package workflow.engine.ProcessMaker
- */
+/**
+ *
+ * @package workflow.engine.ProcessMaker
+ */
+
+class spoolRun
+{
+ public $config;
+ private $fileData;
+ private $spool_id;
+ public $status;
+ public $error;
+
+ private $ExceptionCode = Array (); //Array to define the Expetion codes
+ private $aWarnings = Array (); //Array to store the warning that were throws by the class
-class spoolRun {
- public $config;
- private $fileData;
- private $spool_id;
- public $status;
- public $error;
+ private $longMailEreg;
+ private $mailEreg;
- private $ExceptionCode = Array (); //Array to define the Expetion codes
- private $aWarnings = Array (); //Array to store the warning that were throws by the class
+ /**
+ * Class constructor - iniatilize default values
+ *
+ * @param none
+ * @return none
+ */
+ public function __construct ()
+ {
+ $this->config = array ();
+ $this->fileData = array ();
+ $this->spool_id = '';
+ $this->status = 'pending';
+ $this->error = '';
- private $longMailEreg;
- private $mailEreg;
+ $this->ExceptionCode['FATAL'] = 1;
+ $this->ExceptionCode['WARNING'] = 2;
+ $this->ExceptionCode['NOTICE'] = 3;
+ $this->longMailEreg = '/(.*)(<([\w\-\.]+@[\w\-_\.]+\.\w{2,3})+>)/';
+ $this->mailEreg = '/^([\w\-_\.]+@[\w\-_\.]+\.\w{2,3}+)$/';
+ }
- /**
- * Class constructor - iniatilize default values
- * @param none
- * @return none
- */
- function __construct() {
- $this->config = array ();
- $this->fileData = array ();
- $this->spool_id = '';
- $this->status = 'pending';
- $this->error = '';
+ /**
+ * get all files into spool in a list
+ *
+ * @param none
+ * @return none
+ */
+ public function getSpoolFilesList ()
+ {
+ $sql = "SELECT * FROM APP_MESSAGE WHERE APP_MSG_STATUS ='pending'";
- $this->ExceptionCode['FATAL'] = 1;
- $this->ExceptionCode['WARNING'] = 2;
- $this->ExceptionCode['NOTICE'] = 3;
+ $con = Propel::getConnection( "workflow" );
+ $stmt = $con->prepareStatement( $sql );
+ $rs = $stmt->executeQuery();
- $this->longMailEreg = '/(.*)(<([\w\-\.]+@[\w\-_\.]+\.\w{2,3})+>)/';
- $this->mailEreg = '/^([\w\-_\.]+@[\w\-_\.]+\.\w{2,3}+)$/';
- }
+ while ($rs->next()) {
+ $this->spool_id = $rs->getString( 'APP_MSG_UID' );
+ $this->fileData['subject'] = $rs->getString( 'APP_MSG_SUBJECT' );
+ $this->fileData['from'] = $rs->getString( 'APP_MSG_FROM' );
+ $this->fileData['to'] = $rs->getString( 'APP_MSG_TO' );
+ $this->fileData['body'] = $rs->getString( 'APP_MSG_BODY' );
+ $this->fileData['date'] = $rs->getString( 'APP_MSG_DATE' );
+ $this->fileData['cc'] = $rs->getString( 'APP_MSG_CC' );
+ $this->fileData['bcc'] = $rs->getString( 'APP_MSG_BCC' );
+ $this->fileData['template'] = $rs->getString( 'APP_MSG_TEMPLATE' );
+ $this->fileData['attachments'] = array (); //$rs->getString('APP_MSG_ATTACH');
+ if ($this->config['MESS_ENGINE'] == 'OPENMAIL') {
+ if ($this->config['MESS_SERVER'] != '') {
+ if (($sAux = @gethostbyaddr( $this->config['MESS_SERVER'] ))) {
+ $this->fileData['domain'] = $sAux;
+ } else {
+ $this->fileData['domain'] = $this->config['MESS_SERVER'];
+ }
+ } else {
+ $this->fileData['domain'] = gethostbyaddr( '127.0.0.1' );
+ }
+ }
+ $this->sendMail();
+ }
+ }
- /**
- * get all files into spool in a list
- * @param none
- * @return none
- */
- public function getSpoolFilesList() {
- $sql = "SELECT * FROM APP_MESSAGE WHERE APP_MSG_STATUS ='pending'";
+ /**
+ * create a msg record for spool
+ *
+ * @param array $aData
+ * @return none
+ */
+ public function create ($aData)
+ {
+ $sUID = $this->db_insert( $aData );
- $con = Propel::getConnection("workflow");
- $stmt = $con->prepareStatement($sql);
- $rs = $stmt->executeQuery();
+ $aData['app_msg_date'] = isset( $aData['app_msg_date'] ) ? $aData['app_msg_date'] : '';
- while( $rs->next() ) {
- $this->spool_id = $rs->getString('APP_MSG_UID');
- $this->fileData['subject'] = $rs->getString('APP_MSG_SUBJECT');
- $this->fileData['from'] = $rs->getString('APP_MSG_FROM');
- $this->fileData['to'] = $rs->getString('APP_MSG_TO');
- $this->fileData['body'] = $rs->getString('APP_MSG_BODY');
- $this->fileData['date'] = $rs->getString('APP_MSG_DATE');
- $this->fileData['cc'] = $rs->getString('APP_MSG_CC');
- $this->fileData['bcc'] = $rs->getString('APP_MSG_BCC');
- $this->fileData['template'] = $rs->getString('APP_MSG_TEMPLATE');
- $this->fileData['attachments'] = array (); //$rs->getString('APP_MSG_ATTACH');
- if( $this->config['MESS_ENGINE'] == 'OPENMAIL' ) {
- if( $this->config['MESS_SERVER'] != '' ) {
- if( ($sAux = @gethostbyaddr($this->config['MESS_SERVER'])) ) {
- $this->fileData['domain'] = $sAux;
- } else {
- $this->fileData['domain'] = $this->config['MESS_SERVER'];
- }
+ if (isset( $aData['app_msg_status'] )) {
+ $this->status = strtolower( $aData['app_msg_status'] );
+ }
+
+ $this->setData( $sUID, $aData['app_msg_subject'], $aData['app_msg_from'], $aData['app_msg_to'], $aData['app_msg_body'], $aData['app_msg_date'], $aData['app_msg_cc'], $aData['app_msg_bcc'], $aData['app_msg_template'], $aData['app_msg_attach'] );
+ }
+
+ /**
+ * set configuration
+ *
+ * @param array $aConfig
+ * @return none
+ */
+ public function setConfig ($aConfig)
+ {
+ $this->config = $aConfig;
+ }
+
+ /**
+ * set email parameters
+ *
+ * @param string $sAppMsgUid, $sSubject, $sFrom, $sTo, $sBody, $sDate, $sCC, $sBCC, $sTemplate
+ * @return none
+ */
+ public function setData ($sAppMsgUid, $sSubject, $sFrom, $sTo, $sBody, $sDate = '', $sCC = '', $sBCC = '', $sTemplate = '', $aAttachment = array())
+ {
+ $this->spool_id = $sAppMsgUid;
+ $this->fileData['subject'] = $sSubject;
+ $this->fileData['from'] = $sFrom;
+ $this->fileData['to'] = $sTo;
+ $this->fileData['body'] = $sBody;
+ $this->fileData['date'] = ($sDate != '' ? $sDate : date( 'Y-m-d H:i:s' ));
+ $this->fileData['cc'] = $sCC;
+ $this->fileData['bcc'] = $sBCC;
+ $this->fileData['template'] = $sTemplate;
+ $this->fileData['attachments'] = is_array( $aAttachment ) ? $aAttachment : ($aAttachment != '' ? explode( ',', $aAttachment ) : array ());
+ $this->fileData['envelope_to'] = array ();
+
+ if ($this->config['MESS_ENGINE'] == 'OPENMAIL') {
+ if ($this->config['MESS_SERVER'] != '') {
+ if (($sAux = @gethostbyaddr( $this->config['MESS_SERVER'] ))) {
+ $this->fileData['domain'] = $sAux;
+ } else {
+ $this->fileData['domain'] = $this->config['MESS_SERVER'];
+ }
+ } else {
+ $this->fileData['domain'] = gethostbyaddr( '127.0.0.1' );
+ }
+ }
+ }
+
+ /**
+ * send mail
+ *
+ * @param none
+ * @return boolean true or exception
+ */
+ public function sendMail ()
+ {
+ try {
+ $this->handleFrom();
+ $this->handleEnvelopeTo();
+ $this->handleMail();
+ $this->updateSpoolStatus();
+ return true;
+ } catch (Exception $e) {
+ throw $e;
+ }
+ }
+
+ /**
+ * update the status to spool
+ *
+ * @param none
+ * @return none
+ */
+ private function updateSpoolStatus ()
+ {
+ $oAppMessage = AppMessagePeer::retrieveByPK( $this->spool_id );
+ if (is_array( $this->fileData['attachments'] )) {
+ $attachment = implode( ",", $this->fileData['attachments'] );
+ $oAppMessage->setappMsgAttach( $attachment );
+ }
+ $oAppMessage->setappMsgstatus( $this->status );
+ $oAppMessage->setappMsgsenddate( date( 'Y-m-d H:i:s' ) );
+ $oAppMessage->save();
+ }
+
+ /**
+ * handle the email that was set in "TO" parameter
+ *
+ * @param none
+ * @return boolean true or exception
+ */
+ private function handleFrom ()
+ {
+ if (strpos( $this->fileData['from'], '<' ) !== false) {
+ //to validate complex email address i.e. Erik A. O
+ preg_match( $this->longMailEreg, $this->fileData['from'], $matches );
+ if (isset( $matches[1] ) && $matches[1] != '') {
+ //drop the " characters if they exist
+ $this->fileData['from_name'] = trim( str_replace( '"', '', $matches[1] ) );
+ } else {
+ //if the from name was not set
+ $this->fileData['from_name'] = '';
+ }
+
+ if (! isset( $matches[3] )) {
+ throw new Exception( 'Invalid email address in FROM parameter (' . $this->fileData['from'] . ')', $this->ExceptionCode['WARNING'] );
+ }
+
+ $this->fileData['from_email'] = trim( $matches[3] );
} else {
- $this->fileData['domain'] = gethostbyaddr('127.0.0.1');
+ //to validate simple email address i.e. erik@colosa.com
+ preg_match( $this->mailEreg, $this->fileData['from'], $matches );
+
+ if (! isset( $matches[0] )) {
+ throw new Exception( 'Invalid email address in FROM parameter (' . $this->fileData['from'] . ')', $this->ExceptionCode['WARNING'] );
+ }
+
+ $this->fileData['from_name'] = '';
+ $this->fileData['from_email'] = $matches[0];
}
- }
- $this->sendMail();
- }
- }
- /**
- * create a msg record for spool
- * @param array $aData
- * @return none
- */
- public function create($aData) {
- $sUID = $this->db_insert($aData);
-
- $aData['app_msg_date'] = isset($aData['app_msg_date']) ? $aData['app_msg_date'] : '';
-
- if( isset($aData['app_msg_status']) ) {
- $this->status = strtolower($aData['app_msg_status']);
}
- $this->setData($sUID, $aData['app_msg_subject'], $aData['app_msg_from'], $aData['app_msg_to'], $aData['app_msg_body'], $aData['app_msg_date'], $aData['app_msg_cc'], $aData['app_msg_bcc'], $aData['app_msg_template'], $aData['app_msg_attach']);
- }
+ /**
+ * handle all recipients to compose the mail
+ *
+ * @param none
+ * @return boolean true or exception
+ */
+ private function handleEnvelopeTo ()
+ {
+ $hold = array ();
+ $holdcc = array ();
+ $holdbcc = array ();
+ $text = trim( $this->fileData['to'] );
- /**
- * set configuration
- * @param array $aConfig
- * @return none
- */
- public function setConfig($aConfig) {
- $this->config = $aConfig;
- }
+ $textcc = '';
+ $textbcc = '';
+ if (isset( $this->fileData['cc'] ) && trim( $this->fileData['cc'] ) != '') {
+ $textcc = trim( $this->fileData['cc'] );
+ }
- /**
- * set email parameters
- * @param string $sAppMsgUid, $sSubject, $sFrom, $sTo, $sBody, $sDate, $sCC, $sBCC, $sTemplate
- * @return none
- */
- public function setData($sAppMsgUid, $sSubject, $sFrom, $sTo, $sBody, $sDate = '', $sCC = '', $sBCC = '', $sTemplate = '', $aAttachment = array()) {
- $this->spool_id = $sAppMsgUid;
- $this->fileData['subject'] = $sSubject;
- $this->fileData['from'] = $sFrom;
- $this->fileData['to'] = $sTo;
- $this->fileData['body'] = $sBody;
- $this->fileData['date'] = ($sDate != '' ? $sDate : date('Y-m-d H:i:s'));
- $this->fileData['cc'] = $sCC;
- $this->fileData['bcc'] = $sBCC;
- $this->fileData['template'] = $sTemplate;
- $this->fileData['attachments'] = is_array($aAttachment) ? $aAttachment : ($aAttachment != '' ? explode(',', $aAttachment) : array());
- $this->fileData['envelope_to'] = array();
+ if (isset( $this->fileData['bcc'] ) && trim( $this->fileData['bcc'] ) != '') {
+ $textbcc = trim( $this->fileData['bcc'] );
+ }
- if( $this->config['MESS_ENGINE'] == 'OPENMAIL' ) {
- if( $this->config['MESS_SERVER'] != '' ) {
- if( ($sAux = @gethostbyaddr($this->config['MESS_SERVER'])) ) {
- $this->fileData['domain'] = $sAux;
+ if (false !== (strpos( $text, ',' ))) {
+ $hold = explode( ',', $text );
+
+ foreach ($hold as $val) {
+ if (strlen( $val ) > 0) {
+ $this->fileData['envelope_to'][] = "$val";
+ }
+ }
+ } else if ($text != '') {
+ $this->fileData['envelope_to'][] = "$text";
} else {
- $this->fileData['domain'] = $this->config['MESS_SERVER'];
+ $this->fileData['envelope_to'] = Array ();
}
- } else {
- $this->fileData['domain'] = gethostbyaddr('127.0.0.1');
- }
- }
- }
- /**
- * send mail
- * @param none
- * @return boolean true or exception
- */
- public function sendMail() {
- try {
- $this->handleFrom();
- $this->handleEnvelopeTo();
- $this->handleMail();
- $this->updateSpoolStatus();
- return true;
- } catch( Exception $e ) {
- throw $e;
- }
- }
+ //CC
+ if (false !== (strpos( $textcc, ',' ))) {
+ $holdcc = explode( ',', $textcc );
- /**
- * update the status to spool
- * @param none
- * @return none
- */
- private function updateSpoolStatus() {
- $oAppMessage = AppMessagePeer::retrieveByPK($this->spool_id);
- if (is_array($this->fileData['attachments'])) {
- $attachment = implode(",", $this->fileData['attachments']);
- $oAppMessage->setappMsgAttach($attachment);
- }
- $oAppMessage->setappMsgstatus($this->status);
- $oAppMessage->setappMsgsenddate(date('Y-m-d H:i:s'));
- $oAppMessage->save();
- }
-
- /**
- * handle the email that was set in "TO" parameter
- * @param none
- * @return boolean true or exception
- */
- private function handleFrom() {
- if( strpos($this->fileData['from'], '<') !== false ) {
- //to validate complex email address i.e. Erik A. O
- preg_match($this->longMailEreg, $this->fileData['from'], $matches);
- if( isset($matches[1]) && $matches[1] != '' ) {
- //drop the " characters if they exist
- $this->fileData['from_name'] = trim(str_replace('"', '', $matches[1]));
- }
- else { //if the from name was not set
- $this->fileData['from_name'] = '';
- }
-
- if( ! isset($matches[3]) ) {
- throw new Exception('Invalid email address in FROM parameter (' . $this->fileData['from'] . ')', $this->ExceptionCode['WARNING']);
- }
-
- $this->fileData['from_email'] = trim($matches[3]);
- }
- else {
- //to validate simple email address i.e. erik@colosa.com
- preg_match($this->mailEreg, $this->fileData['from'], $matches);
-
- if( ! isset($matches[0]) ) {
- throw new Exception('Invalid email address in FROM parameter (' . $this->fileData['from'] . ')', $this->ExceptionCode['WARNING']);
- }
-
- $this->fileData['from_name'] = '';
- $this->fileData['from_email'] = $matches[0];
- }
-
- }
-
- /**
- * handle all recipients to compose the mail
- * @param none
- * @return boolean true or exception
- */
- private function handleEnvelopeTo() {
- $hold = array ();
- $holdcc = array ();
- $holdbcc = array ();
- $text = trim($this->fileData['to']);
-
- $textcc ='';
- $textbcc='';
- if( isset($this->fileData['cc']) && trim($this->fileData['cc']) != '' ) {
- $textcc = trim($this->fileData['cc']);
- }
-
- if( isset($this->fileData['bcc']) && trim($this->fileData['bcc']) != '' ) {
- $textbcc = trim($this->fileData['bcc']);
- }
-
- if( false !== (strpos($text, ',')) ) {
- $hold = explode(',', $text);
-
- foreach( $hold as $val ) {
- if( strlen($val) > 0 ) {
- $this->fileData['envelope_to'][] = "$val";
+ foreach ($holdcc as $valcc) {
+ if (strlen( $valcc ) > 0) {
+ $this->fileData['envelope_cc'][] = "$valcc";
+ }
+ }
+ } else if ($textcc != '') {
+ $this->fileData['envelope_cc'][] = "$textcc";
+ } else {
+ $this->fileData['envelope_cc'] = Array ();
}
- }
- } else if($text != '') {
- $this->fileData['envelope_to'][] = "$text";
- } else {
- $this->fileData['envelope_to'] = Array();
- }
- //CC
- if( false !== (strpos($textcc, ',')) ) {
- $holdcc = explode(',', $textcc);
+ //BCC
+ if (false !== (strpos( $textbcc, ',' ))) {
+ $holdbcc = explode( ',', $textbcc );
- foreach( $holdcc as $valcc ) {
- if( strlen($valcc) > 0 ) {
- $this->fileData['envelope_cc'][] = "$valcc";
+ foreach ($holdbcc as $valbcc) {
+ if (strlen( $valbcc ) > 0) {
+ $this->fileData['envelope_bcc'][] = "$valbcc";
+ }
+ }
+ } else if ($textbcc != '') {
+ $this->fileData['envelope_bcc'][] = "$textbcc";
+ } else {
+ $this->fileData['envelope_bcc'] = Array ();
}
- }
- } else if($textcc != '') {
- $this->fileData['envelope_cc'][] = "$textcc";
- } else {
- $this->fileData['envelope_cc'] = Array();
+
}
- //BCC
- if( false !== (strpos($textbcc, ',')) ) {
- $holdbcc = explode(',', $textbcc);
+ /**
+ * handle and compose the email content and parameters
+ *
+ * @param none
+ * @return none
+ */
+ private function handleMail ()
+ {
+ if (count( $this->fileData['envelope_to'] ) > 0) {
+ switch ($this->config['MESS_ENGINE']) {
+ case 'MAIL':
+ case 'PHPMAILER':
+ G::LoadThirdParty( 'phpmailer', 'class.phpmailer' );
- foreach( $holdbcc as $valbcc ) {
- if( strlen($valbcc) > 0 ) {
- $this->fileData['envelope_bcc'][] = "$valbcc";
+ switch ($this->config['MESS_ENGINE']) {
+ case 'MAIL':
+ $oPHPMailer = new PHPMailer();
+ $oPHPMailer->Mailer = 'mail';
+ break;
+ case 'PHPMAILER':
+ $oPHPMailer = new PHPMailer( true );
+ $oPHPMailer->Mailer = 'smtp';
+ break;
+ }
+
+ $oPHPMailer->SMTPAuth = (isset( $this->config['SMTPAuth'] ) ? $this->config['SMTPAuth'] : '');
+
+ switch ($this->config['MESS_ENGINE']) {
+ case 'MAIL':
+ break;
+ case 'PHPMAILER':
+ //Posible Options for SMTPSecure are: "", "ssl" or "tls"
+ if (isset( $this->config['SMTPSecure'] ) && preg_match( '/^(ssl|tls)$/', $this->config['SMTPSecure'] )) {
+ $oPHPMailer->SMTPSecure = $this->config['SMTPSecure'];
+ }
+ break;
+ }
+
+ $oPHPMailer->CharSet = "UTF-8";
+ $oPHPMailer->Encoding = "8bit";
+ $oPHPMailer->Host = $this->config['MESS_SERVER'];
+ $oPHPMailer->Port = $this->config['MESS_PORT'];
+ $oPHPMailer->Username = $this->config['MESS_ACCOUNT'];
+ $passwd = $this->config['MESS_PASSWORD'];
+ $passwdDec = G::decrypt( $passwd, 'EMAILENCRYPT' );
+ $auxPass = explode( 'hash:', $passwdDec );
+
+ if (count( $auxPass ) > 1) {
+ if (count( $auxPass ) == 2) {
+ $passwd = $auxPass[1];
+ } else {
+ array_shift( $auxPass );
+ $passwd = implode( '', $auxPass );
+ }
+ }
+
+ $this->config['MESS_PASSWORD'] = $passwd;
+ $oPHPMailer->Password = $this->config['MESS_PASSWORD'];
+ $oPHPMailer->From = $this->fileData['from_email'];
+ $oPHPMailer->FromName = utf8_decode( $this->fileData['from_name'] );
+
+ $msSubject = $this->fileData['subject'];
+
+ if (! (mb_detect_encoding( $msSubject, "UTF-8" ) == "UTF-8")) {
+ $msSubject = utf8_encode( $msSubject );
+ }
+
+ $oPHPMailer->Subject = $msSubject;
+
+ $msBody = $this->fileData['body'];
+
+ if (! (mb_detect_encoding( $msBody, "UTF-8" ) == "UTF-8")) {
+ $msBody = utf8_encode( $msBody );
+ }
+
+ $oPHPMailer->Body = $msBody;
+
+ if (is_array( $this->fileData['attachments'] )) {
+ foreach ($this->fileData['attachments'] as $key => $fileAttach) {
+ if (file_exists( $fileAttach )) {
+ $oPHPMailer->AddAttachment( $fileAttach, is_int( $key ) ? '' : $key );
+ }
+ }
+ }
+
+ foreach ($this->fileData['envelope_to'] as $sEmail) {
+ if (strpos( $sEmail, '<' ) !== false) {
+ preg_match( $this->longMailEreg, $sEmail, $matches );
+ $sTo = trim( $matches[3] );
+ $sToName = trim( $matches[1] );
+ $oPHPMailer->AddAddress( $sTo, $sToName );
+ } else {
+ $oPHPMailer->AddAddress( $sEmail );
+ }
+ }
+
+ //CC
+ foreach ($this->fileData['envelope_cc'] as $sEmail) {
+ if (strpos( $sEmail, '<' ) !== false) {
+ preg_match( $this->longMailEreg, $sEmail, $matches );
+ $sTo = trim( $matches[3] );
+ $sToName = trim( $matches[1] );
+ $oPHPMailer->AddCC( $sTo, $sToName );
+ } else {
+ $oPHPMailer->AddCC( $sEmail );
+ }
+ }
+
+ //BCC
+ foreach ($this->fileData['envelope_bcc'] as $sEmail) {
+ if (strpos( $sEmail, '<' ) !== false) {
+ preg_match( $this->longMailEreg, $sEmail, $matches );
+ $sTo = trim( $matches[3] );
+ $sToName = trim( $matches[1] );
+ $oPHPMailer->AddBCC( $sTo, $sToName );
+ } else {
+ $oPHPMailer->AddBCC( $sEmail );
+ }
+ }
+
+ $oPHPMailer->IsHTML( true );
+
+ if ($oPHPMailer->Send()) {
+ $this->error = '';
+ $this->status = 'sent';
+ } else {
+ $this->error = $oPHPMailer->ErrorInfo;
+ $this->status = 'failed';
+ }
+ break;
+ case 'OPENMAIL':
+ G::LoadClass( 'package' );
+ G::LoadClass( 'smtp' );
+ $pack = new package( $this->fileData );
+ $header = $pack->returnHeader();
+ $body = $pack->returnBody();
+ $send = new smtp();
+ $send->setServer( $this->config['MESS_SERVER'] );
+ $send->setPort( $this->config['MESS_PORT'] );
+ $send->setUsername( $this->config['MESS_ACCOUNT'] );
+
+ $passwd = $this->config['MESS_PASSWORD'];
+ $passwdDec = G::decrypt( $passwd, 'EMAILENCRYPT' );
+ $auxPass = explode( 'hash:', $passwdDec );
+
+ if (count( $auxPass ) > 1) {
+ if (count( $auxPass ) == 2) {
+ $passwd = $auxPass[1];
+ } else {
+ array_shift( $auxPass );
+ $passwd = implode( '', $auxPass );
+ }
+ }
+
+ $this->config['MESS_PASSWORD'] = $passwd;
+ $send->setPassword( $this->config['MESS_PASSWORD'] );
+ $send->setReturnPath( $this->fileData['from_email'] );
+ $send->setHeaders( $header );
+ $send->setBody( $body );
+ $send->setEnvelopeTo( $this->fileData['envelope_to'] );
+ if ($send->sendMessage()) {
+ $this->error = '';
+ $this->status = 'sent';
+ } else {
+ $this->error = implode( ', ', $send->returnErrors() );
+ $this->status = 'failed';
+ }
+ break;
+ }
}
- }
- } else if($textbcc != '') {
- $this->fileData['envelope_bcc'][] = "$textbcc";
- } else {
- $this->fileData['envelope_bcc'] = Array();
}
-
- }
-
- /**
- * handle and compose the email content and parameters
- * @param none
- * @return none
- */
- private function handleMail() {
- if( count($this->fileData['envelope_to']) > 0 ) {
- switch ($this->config['MESS_ENGINE']) {
- case 'MAIL':
- case 'PHPMAILER':
- G::LoadThirdParty('phpmailer', 'class.phpmailer');
-
- switch($this->config['MESS_ENGINE']) {
- case 'MAIL':
- $oPHPMailer = new PHPMailer();
- $oPHPMailer->Mailer = 'mail';
- break;
- case 'PHPMAILER':
- $oPHPMailer = new PHPMailer(true);
- $oPHPMailer->Mailer = 'smtp';
- break;
- }
-
- $oPHPMailer->SMTPAuth = (isset($this->config['SMTPAuth']) ? $this->config['SMTPAuth'] : '');
-
- switch($this->config['MESS_ENGINE']) {
- case 'MAIL':
- break;
- case 'PHPMAILER':
- //Posible Options for SMTPSecure are: "", "ssl" or "tls"
- if (isset($this->config['SMTPSecure']) && preg_match('/^(ssl|tls)$/', $this->config['SMTPSecure'])) {
- $oPHPMailer->SMTPSecure = $this->config['SMTPSecure'];
- }
- break;
- }
-
- $oPHPMailer->CharSet = "UTF-8";
- $oPHPMailer->Encoding = "8bit";
- $oPHPMailer->Host = $this->config['MESS_SERVER'];
- $oPHPMailer->Port = $this->config['MESS_PORT'];
- $oPHPMailer->Username = $this->config['MESS_ACCOUNT'];
- $passwd = $this->config['MESS_PASSWORD'];
- $passwdDec = G::decrypt($passwd,'EMAILENCRYPT');
- $auxPass = explode('hash:', $passwdDec);
-
- if (count($auxPass) > 1) {
- if (count($auxPass) == 2) {
- $passwd = $auxPass[1];
- } else {
- array_shift($auxPass);
- $passwd = implode('', $auxPass);
- }
- }
-
- $this->config['MESS_PASSWORD'] = $passwd;
- $oPHPMailer->Password = $this->config['MESS_PASSWORD'];
- $oPHPMailer->From = $this->fileData['from_email'];
- $oPHPMailer->FromName = utf8_decode($this->fileData['from_name']);
-
- $msSubject = $this->fileData['subject'];
-
- if(!(mb_detect_encoding($msSubject, "UTF-8") == "UTF-8")) {
- $msSubject = utf8_encode($msSubject);
- }
-
- $oPHPMailer->Subject = $msSubject;
-
- $msBody = $this->fileData['body'];
-
- if(!(mb_detect_encoding($msBody, "UTF-8") == "UTF-8")) {
- $msBody = utf8_encode($msBody);
- }
-
- $oPHPMailer->Body = $msBody;
-
- if(is_array($this->fileData['attachments'])){
- foreach($this->fileData['attachments'] as $key => $fileAttach){
- if (file_exists($fileAttach)) {
- $oPHPMailer->AddAttachment($fileAttach, is_int($key) ? '' : $key);
- }
- }
- }
-
- foreach ($this->fileData['envelope_to'] as $sEmail) {
- if( strpos($sEmail, '<') !== false ) {
- preg_match($this->longMailEreg, $sEmail, $matches);
- $sTo = trim($matches[3]);
- $sToName = trim($matches[1]);
- $oPHPMailer->AddAddress($sTo, $sToName);
- } else {
- $oPHPMailer->AddAddress($sEmail);
- }
- }
-
- //CC
- foreach ($this->fileData['envelope_cc'] as $sEmail) {
- if(strpos($sEmail, '<') !== false) {
- preg_match($this->longMailEreg, $sEmail, $matches);
- $sTo = trim($matches[3]);
- $sToName = trim($matches[1]);
- $oPHPMailer->AddCC($sTo, $sToName);
- } else {
- $oPHPMailer->AddCC($sEmail);
- }
- }
-
- //BCC
- foreach ($this->fileData['envelope_bcc'] as $sEmail) {
- if(strpos($sEmail, '<') !== false) {
- preg_match($this->longMailEreg, $sEmail, $matches);
- $sTo = trim($matches[3]);
- $sToName = trim($matches[1]);
- $oPHPMailer->AddBCC($sTo, $sToName);
- } else {
- $oPHPMailer->AddBCC($sEmail);
- }
- }
-
- $oPHPMailer->IsHTML(true);
-
- if($oPHPMailer->Send()) {
- $this->error = '';
- $this->status = 'sent';
- } else {
- $this->error = $oPHPMailer->ErrorInfo;
- $this->status = 'failed';
- }
- break;
- case 'OPENMAIL':
- G::LoadClass('package');
- G::LoadClass('smtp');
- $pack = new package($this->fileData);
- $header = $pack->returnHeader();
- $body = $pack->returnBody();
- $send = new smtp();
- $send->setServer($this->config['MESS_SERVER']);
- $send->setPort($this->config['MESS_PORT']);
- $send->setUsername($this->config['MESS_ACCOUNT']);
-
- $passwd = $this->config['MESS_PASSWORD'];
- $passwdDec = G::decrypt($passwd,'EMAILENCRYPT');
- $auxPass = explode('hash:', $passwdDec);
-
- if (count($auxPass) > 1) {
- if (count($auxPass) == 2) {
- $passwd = $auxPass[1];
- } else {
- array_shift($auxPass);
- $passwd = implode('', $auxPass);
- }
- }
-
- $this->config['MESS_PASSWORD'] = $passwd;
- $send->setPassword($this->config['MESS_PASSWORD']);
- $send->setReturnPath($this->fileData['from_email']);
- $send->setHeaders($header);
- $send->setBody($body);
- $send->setEnvelopeTo($this->fileData['envelope_to']);
- if( $send->sendMessage() ) {
- $this->error = '';
- $this->status = 'sent';
- } else {
- $this->error = implode(', ', $send->returnErrors());
- $this->status = 'failed';
- }
- break;
- }
- }
- }
-
/**
* try resend the emails from spool
+ *
* @param string $dateResend
* @return none or exception
*/
- public function resendEmails($dateResend=null, $cron=0)
+ public function resendEmails ($dateResend = null, $cron = 0)
{
require_once ("classes/model/Configuration.php");
$oConfiguration = new Configuration();
- $aConfiguration = $oConfiguration->load("Emails", "", "", "", "");
+ $aConfiguration = $oConfiguration->load( "Emails", "", "", "", "" );
- $aConfiguration = unserialize($aConfiguration["CFG_VALUE"]);
+ $aConfiguration = unserialize( $aConfiguration["CFG_VALUE"] );
$passwd = $aConfiguration["MESS_PASSWORD"];
- $passwdDec = G::decrypt($passwd,"EMAILENCRYPT");
- $auxPass = explode("hash:", $passwdDec);
+ $passwdDec = G::decrypt( $passwd, "EMAILENCRYPT" );
+ $auxPass = explode( "hash:", $passwdDec );
- if (count($auxPass) > 1) {
- if (count($auxPass) == 2) {
+ if (count( $auxPass ) > 1) {
+ if (count( $auxPass ) == 2) {
$passwd = $auxPass[1];
} else {
- array_shift($auxPass);
- $passwd = implode("", $auxPass);
+ array_shift( $auxPass );
+ $passwd = implode( "", $auxPass );
}
}
@@ -520,60 +542,37 @@ class spoolRun {
if ($aConfiguration["MESS_ENABLED"] == "1") {
require_once ("classes/model/AppMessage.php");
- $this->setConfig(array(
- "MESS_ENGINE" => $aConfiguration["MESS_ENGINE"],
- "MESS_SERVER" => $aConfiguration["MESS_SERVER"],
- "MESS_PORT" => $aConfiguration["MESS_PORT"],
- "MESS_ACCOUNT" => $aConfiguration["MESS_ACCOUNT"],
- "MESS_PASSWORD" => $aConfiguration["MESS_PASSWORD"],
- "SMTPAuth" => $aConfiguration["MESS_RAUTH"],
- "SMTPSecure" => $aConfiguration["SMTPSecure"]
- ));
+ $this->setConfig( array ("MESS_ENGINE" => $aConfiguration["MESS_ENGINE"],"MESS_SERVER" => $aConfiguration["MESS_SERVER"],"MESS_PORT" => $aConfiguration["MESS_PORT"],"MESS_ACCOUNT" => $aConfiguration["MESS_ACCOUNT"],"MESS_PASSWORD" => $aConfiguration["MESS_PASSWORD"],"SMTPAuth" => $aConfiguration["MESS_RAUTH"],"SMTPSecure" => $aConfiguration["SMTPSecure"]
+ ) );
- $criteria = new Criteria("workflow");
- $criteria->add(AppMessagePeer::APP_MSG_STATUS, "sent", Criteria::NOT_EQUAL);
+ $criteria = new Criteria( "workflow" );
+ $criteria->add( AppMessagePeer::APP_MSG_STATUS, "sent", Criteria::NOT_EQUAL );
if ($dateResend != null) {
- $criteria->add(AppMessagePeer::APP_MSG_DATE, $dateResend, Criteria::GREATER_EQUAL);
+ $criteria->add( AppMessagePeer::APP_MSG_DATE, $dateResend, Criteria::GREATER_EQUAL );
}
- $rsCriteria = AppMessagePeer::doSelectRS($criteria);
- $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $rsCriteria = AppMessagePeer::doSelectRS( $criteria );
+ $rsCriteria->setFetchmode( ResultSet::FETCHMODE_ASSOC );
while ($rsCriteria->next()) {
if ($cron == 1) {
- $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
+ $arrayCron = unserialize( trim( @file_get_contents( PATH_DATA . "cron" ) ) );
$arrayCron["processcTimeStart"] = time();
- @file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
+ @file_put_contents( PATH_DATA . "cron", serialize( $arrayCron ) );
}
$row = $rsCriteria->getRow();
try {
- $this->setData(
- $row["APP_MSG_UID"],
- $row["APP_MSG_SUBJECT"],
- $row["APP_MSG_FROM"],
- $row["APP_MSG_TO"],
- $row["APP_MSG_BODY"],
- date("Y-m-d H:i:s"),
- $row["APP_MSG_CC"],
- $row["APP_MSG_BCC"],
- $row["APP_MSG_TEMPLATE"],
- $row["APP_MSG_ATTACH"]
- );
+ $this->setData( $row["APP_MSG_UID"], $row["APP_MSG_SUBJECT"], $row["APP_MSG_FROM"], $row["APP_MSG_TO"], $row["APP_MSG_BODY"], date( "Y-m-d H:i:s" ), $row["APP_MSG_CC"], $row["APP_MSG_BCC"], $row["APP_MSG_TEMPLATE"], $row["APP_MSG_ATTACH"] );
$this->sendMail();
} catch (Exception $e) {
- $strAux = "Spool::resendEmails(): Using " .
- $aConfiguration["MESS_ENGINE"] .
- " for APP_MGS_UID=" .
- $row["APP_MSG_UID"] .
- " -> With message: " .
- $e->getMessage();
+ $strAux = "Spool::resendEmails(): Using " . $aConfiguration["MESS_ENGINE"] . " for APP_MGS_UID=" . $row["APP_MSG_UID"] . " -> With message: " . $e->getMessage();
if ($e->getCode() == $this->ExceptionCode["WARNING"]) {
- array_push($this->aWarnings, $strAux);
+ array_push( $this->aWarnings, $strAux );
continue;
} else {
throw $e;
@@ -585,12 +584,13 @@ class spoolRun {
/**
* gets all warnings
+ *
* @param none
* @return string $this->aWarnings
*/
- public function getWarnings()
+ public function getWarnings ()
{
- if (sizeof($this->aWarnings) != 0) {
+ if (sizeof( $this->aWarnings ) != 0) {
return $this->aWarnings;
}
@@ -600,36 +600,37 @@ class spoolRun {
/**
* db_insert
*
- * @param array $db_spool
+ * @param array $db_spool
* @return string $sUID;
*/
- public function db_insert($db_spool)
+ public function db_insert ($db_spool)
{
- $sUID = G::generateUniqueID();
+ $sUID = G::generateUniqueID();
$spool = new AppMessage();
- $spool->setAppMsgUid($sUID);
- $spool->setMsgUid($db_spool['msg_uid']);
- $spool->setAppUid($db_spool['app_uid']);
- $spool->setDelIndex($db_spool['del_index']);
- $spool->setAppMsgType($db_spool['app_msg_type']);
- $spool->setAppMsgSubject($db_spool['app_msg_subject']);
- $spool->setAppMsgFrom($db_spool['app_msg_from']);
- $spool->setAppMsgTo($db_spool['app_msg_to']);
- $spool->setAppMsgBody($db_spool['app_msg_body']);
- $spool->setAppMsgDate(date('Y-m-d H:i:s'));
- $spool->setAppMsgCc($db_spool['app_msg_cc']);
- $spool->setAppMsgBcc($db_spool['app_msg_bcc']);
- $spool->setappMsgAttach($db_spool['app_msg_attach']);
- $spool->setAppMsgTemplate($db_spool['app_msg_template']);
- $spool->setAppMsgStatus($db_spool['app_msg_status']);
- $spool->setAppMsgSendDate(date('Y-m-d H:i:s')); // Add by Ankit
+ $spool->setAppMsgUid( $sUID );
+ $spool->setMsgUid( $db_spool['msg_uid'] );
+ $spool->setAppUid( $db_spool['app_uid'] );
+ $spool->setDelIndex( $db_spool['del_index'] );
+ $spool->setAppMsgType( $db_spool['app_msg_type'] );
+ $spool->setAppMsgSubject( $db_spool['app_msg_subject'] );
+ $spool->setAppMsgFrom( $db_spool['app_msg_from'] );
+ $spool->setAppMsgTo( $db_spool['app_msg_to'] );
+ $spool->setAppMsgBody( $db_spool['app_msg_body'] );
+ $spool->setAppMsgDate( date( 'Y-m-d H:i:s' ) );
+ $spool->setAppMsgCc( $db_spool['app_msg_cc'] );
+ $spool->setAppMsgBcc( $db_spool['app_msg_bcc'] );
+ $spool->setappMsgAttach( $db_spool['app_msg_attach'] );
+ $spool->setAppMsgTemplate( $db_spool['app_msg_template'] );
+ $spool->setAppMsgStatus( $db_spool['app_msg_status'] );
+ $spool->setAppMsgSendDate( date( 'Y-m-d H:i:s' ) ); // Add by Ankit
- if (!$spool->validate()) {
+
+ if (! $spool->validate()) {
$errors = $spool->getValidationFailures();
$this->status = 'error';
foreach ($errors as $key => $value) {
- echo "Validation error - " . $value->getMessage($key) . "\n";
+ echo "Validation error - " . $value->getMessage( $key ) . "\n";
}
} else {
//echo "Saving - validation ok\n";
diff --git a/workflow/engine/classes/class.system.php b/workflow/engine/classes/class.system.php
index 2b157b717..d716e6647 100755
--- a/workflow/engine/classes/class.system.php
+++ b/workflow/engine/classes/class.system.php
@@ -1,6 +1,8 @@
.
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
@@ -29,1094 +31,1082 @@
*
* author Erik A.O.
* date May 12th, 2010
+ *
* @package workflow.engine.classes
*
*/
-class System {
+class System
+{
- var $sFilename;
- var $sFilesList;
- var $sUpgradeFileList;
- var $aErrors;
- var $aWorkspaces;
- var $sRevision;
- var $sPath;
- var $newSystemClass;
+ var $sFilename;
+ var $sFilesList;
+ var $sUpgradeFileList;
+ var $aErrors;
+ var $aWorkspaces;
+ var $sRevision;
+ var $sPath;
+ var $newSystemClass;
- /**
- * List currently installed plugins
- *
- * param
- * @return array with the names of the plugins
- */
- public static function getPlugins() {
- $plugins = array ();
+ /**
+ * List currently installed plugins
+ *
+ * param
+ *
+ * @return array with the names of the plugins
+ */
+ public static function getPlugins ()
+ {
+ $plugins = array ();
- foreach (glob(PATH_PLUGINS . "*") as $filename) {
- $info = pathinfo($filename);
- if (array_key_exists("extension", $info) && (strcmp($info["extension"], "php") == 0)) {
- $plugins[] = basename($filename, ".php");
- }
+ foreach (glob( PATH_PLUGINS . "*" ) as $filename) {
+ $info = pathinfo( $filename );
+ if (array_key_exists( "extension", $info ) && (strcmp( $info["extension"], "php" ) == 0)) {
+ $plugins[] = basename( $filename, ".php" );
+ }
+ }
+
+ sort( $plugins, SORT_STRING );
+ return $plugins;
}
- sort($plugins, SORT_STRING);
- return $plugins;
- }
-
- /**
- * Lists existing workspaces, returning an array of workspaceTools object
- * for each.
- * This is a class method, it does not require an instance.
- *
- * @author Alexandre Rosenfeld
- * @access public
- * @return array of workspace tools objects
- */
- public static function listWorkspaces() {
- $oDirectory = dir(PATH_DB);
- $aWorkspaces = array();
- foreach (glob(PATH_DB . "*") as $filename) {
- if (is_dir($filename) && file_exists($filename . "/db.php"))
- $aWorkspaces[] = new workspaceTools (basename($filename));
- }
- return $aWorkspaces;
- }
-
- /**
- * Get the ProcessMaker version. If version-pmos.php is not found, try to
- * retrieve the version from git.
- *
- * @author Alexandre Rosenfeld
- * @return string system
- */
- public static function getVersion() {
- if (! defined ( 'PM_VERSION' )) {
- if (file_exists ( PATH_METHODS . 'login/version-pmos.php' )) {
- include (PATH_METHODS . 'login/version-pmos.php');
- } else {
- $version = self::getVersionFromGit();
- if ($version === false)
- $version = 'Development Version';
- define ( 'PM_VERSION', $version );
- }
- }
- return PM_VERSION;
- }
-
- /**
- * Get the branch and tag information from a git repository.
- *
- * @author Alexandre Rosenfeld
- * @return string branch and tag information
- */
- public static function getVersionFromGit($dir = NULL) {
- if ($dir == NULL)
- $dir = PATH_TRUNK;
- if (!file_exists("$dir/.git"))
- return false;
- if (exec("cd $dir && git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/^* \(.*\)$/(Branch \\1)/'", $target)) {
- exec("cd $dir && git describe", $target);
- return implode(' ', $target);
- }
- return false;
- }
-
- /**
- * Get system information
- *
- * param
- * @return array with system information
- */
- public static function getSysInfo() {
- $ipe = explode(" ", $_SERVER['SSH_CONNECTION']);
-
- if( getenv('HTTP_CLIENT_IP') ) {
- $ip = getenv('HTTP_CLIENT_IP');
- } elseif( getenv('HTTP_X_FORWARDED_FOR') ) {
- $ip = getenv('HTTP_X_FORWARDED_FOR');
- } else {
- $ip = getenv('REMOTE_ADDR');
+ /**
+ * Lists existing workspaces, returning an array of workspaceTools object
+ * for each.
+ * This is a class method, it does not require an instance.
+ *
+ * @author Alexandre Rosenfeld
+ * @access public
+ * @return array of workspace tools objects
+ */
+ public static function listWorkspaces ()
+ {
+ $oDirectory = dir( PATH_DB );
+ $aWorkspaces = array ();
+ foreach (glob( PATH_DB . "*" ) as $filename) {
+ if (is_dir( $filename ) && file_exists( $filename . "/db.php" ))
+ $aWorkspaces[] = new workspaceTools( basename( $filename ) );
+ }
+ return $aWorkspaces;
}
- /* For distros with the lsb_release, this returns a one-line description of
+ /**
+ * Get the ProcessMaker version.
+ * If version-pmos.php is not found, try to
+ * retrieve the version from git.
+ *
+ * @author Alexandre Rosenfeld
+ * @return string system
+ */
+ public static function getVersion ()
+ {
+ if (! defined( 'PM_VERSION' )) {
+ if (file_exists( PATH_METHODS . 'login/version-pmos.php' )) {
+ include (PATH_METHODS . 'login/version-pmos.php');
+ } else {
+ $version = self::getVersionFromGit();
+ if ($version === false)
+ $version = 'Development Version';
+ define( 'PM_VERSION', $version );
+ }
+ }
+ return PM_VERSION;
+ }
+
+ /**
+ * Get the branch and tag information from a git repository.
+ *
+ * @author Alexandre Rosenfeld
+ * @return string branch and tag information
+ */
+ public static function getVersionFromGit ($dir = NULL)
+ {
+ if ($dir == NULL)
+ $dir = PATH_TRUNK;
+ if (! file_exists( "$dir/.git" ))
+ return false;
+ if (exec( "cd $dir && git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/^* \(.*\)$/(Branch \\1)/'", $target )) {
+ exec( "cd $dir && git describe", $target );
+ return implode( ' ', $target );
+ }
+ return false;
+ }
+
+ /**
+ * Get system information
+ *
+ * param
+ *
+ * @return array with system information
+ */
+ public static function getSysInfo ()
+ {
+ $ipe = explode( " ", $_SERVER['SSH_CONNECTION'] );
+
+ if (getenv( 'HTTP_CLIENT_IP' )) {
+ $ip = getenv( 'HTTP_CLIENT_IP' );
+ } elseif (getenv( 'HTTP_X_FORWARDED_FOR' )) {
+ $ip = getenv( 'HTTP_X_FORWARDED_FOR' );
+ } else {
+ $ip = getenv( 'REMOTE_ADDR' );
+ }
+
+ /* For distros with the lsb_release, this returns a one-line description of
* the distro name, such as "CentOS release 5.3 (Final)" or "Ubuntu 10.10"
*/
- $distro = exec("lsb_release -d -s 2> /dev/null");
+ $distro = exec( "lsb_release -d -s 2> /dev/null" );
- /* For distros without lsb_release, we look for *release (such as
+ /* For distros without lsb_release, we look for *release (such as
* redhat-release, gentoo-release, SuSE-release, etc) or *version (such as
* debian_version, slackware-version, etc)
*/
- if (empty($distro)) {
- foreach (glob("/etc/*release") as $filename) {
- $distro = trim(file_get_contents($filename));
- if (!empty($distro))
- break;
- }
- if (empty($distro)) {
- foreach (glob("/etc/*version") as $filename) {
- $distro = trim(file_get_contents($filename));
- if (!empty($distro))
- break;
+ if (empty( $distro )) {
+ foreach (glob( "/etc/*release" ) as $filename) {
+ $distro = trim( file_get_contents( $filename ) );
+ if (! empty( $distro ))
+ break;
+ }
+ if (empty( $distro )) {
+ foreach (glob( "/etc/*version" ) as $filename) {
+ $distro = trim( file_get_contents( $filename ) );
+ if (! empty( $distro ))
+ break;
+ }
+ }
}
- }
- }
- /* CentOS returns a string with quotes, remove them and append
+ /* CentOS returns a string with quotes, remove them and append
* the OS name (such as LINUX, WINNT, DARWIN, etc)
*/
- $distro = trim($distro, "\"") . " (" . PHP_OS . ")";
+ $distro = trim( $distro, "\"" ) . " (" . PHP_OS . ")";
- $Fields = array();
- $Fields['SYSTEM'] = $distro;
- $Fields['PHP'] = phpversion();
- $Fields['PM_VERSION'] = self::getVersion();
- $Fields['SERVER_ADDR'] = $ipe[2]; //lookup($ipe[2]);
- $Fields['IP'] = $ipe[0]; //lookup($ipe[0]);
+ $Fields = array ();
+ $Fields['SYSTEM'] = $distro;
+ $Fields['PHP'] = phpversion();
+ $Fields['PM_VERSION'] = self::getVersion();
+ $Fields['SERVER_ADDR'] = $ipe[2]; //lookup($ipe[2]);
+ $Fields['IP'] = $ipe[0]; //lookup($ipe[0]);
- $Fields['PLUGINS_LIST'] = System::getPlugins();
- return $Fields;
- }
+ $Fields['PLUGINS_LIST'] = System::getPlugins();
- public static function listPoFiles() {
- $folders = glob(PATH_CORE . '/content/translations/*');
-
- $items = glob(PATH_CORE . '/content/translations/*.po');
- foreach ($folders as $folder) {
- if (is_dir($folder)) {
- $add = glob($folder . "/*.po");
- $items = array_merge($items, $add);
- }
+ return $Fields;
}
- return $items;
- }
+ public static function listPoFiles ()
+ {
+ $folders = glob( PATH_CORE . '/content/translations/*' );
- public static function verifyChecksum() {
- if (!file_exists(PATH_TRUNK . "checksum.txt"))
- return false;
- $lines = explode("\n", file_get_contents(PATH_TRUNK . "checksum.txt"));
- $result = array("diff" => array(), "missing" => array());
- foreach ($lines as $line) {
- if (empty($line))
- continue;
- list($checksum, $empty, $filename) = explode(" ", $line);
- //Skip xmlform because these files always change.
- if (strpos($filename, "/xmlform/") !== false)
- continue;
- if (file_exists(realpath($filename))) {
- if (strcmp($checksum, md5_file(realpath($filename))) != 0) {
- $result['diff'][] = $filename;
+ $items = glob( PATH_CORE . '/content/translations/*.po' );
+ foreach ($folders as $folder) {
+ if (is_dir( $folder )) {
+ $add = glob( $folder . "/*.po" );
+ $items = array_merge( $items, $add );
+ }
}
- } else {
- $result['missing'][] = $filename;
- }
- }
- return $result;
- }
- /**
- * This function checks files to do updated to pm
- *
- *
- * @name verifyFileForUpgrade
- *
- * param
- * @return boolean
- */
- function verifyFileForUpgrade()
- {
- $upgradeFilename = isset($_FILES['form']['name']['UPGRADE_FILENAME']) ? $_FILES['form']['name']['UPGRADE_FILENAME'] : '';
- $tempFilename = isset($_FILES['form']['tmp_name']['UPGRADE_FILENAME']) ? $_FILES['form']['tmp_name']['UPGRADE_FILENAME'] : '';
- $this->sRevision = str_replace('.tar.gz', '', str_replace('pmos-patch-', '', $upgradeFilename));
- $sTemFilename = $tempFilename;
- $this->sFilename = PATH_DATA . 'upgrade' . PATH_SEP . $upgradeFilename;
- $this->sPath = dirname($this->sFilename) . PATH_SEP;
- G::mk_dir(PATH_DATA . 'upgrade');
- if( ! move_uploaded_file($sTemFilename, $this->sFilename) ) {
- return false;
- }
- return true;
- }
-
- /**
- * This function gets files to do updated to pm
- *
- *
- * @name getUpgradedFilesList
- *
- * param
- * @return void
- */
- function getUpgradedFilesList()
- {
- G::LoadClass('archive');
- $this->sFilesList = new gzip_file($this->sFilename);
- $this->sFilesList->set_options(array (
- 'basedir' => dirname($this->sFilename),
- 'overwrite' => 1
- ));
- $this->sFilesList->extract_files();
- if( count($this->sFilesList->error) > 0 ) {
- $msg = '';
- foreach( $this->sFilesList->error as $key => $val ) {
- $msg .= $val . "\n";
- }
- throw new Exception($msg);
- }
- if( count($this->sFilesList->files) == 0 ) {
- throw new Exception('The uploaded file is an invalid patch file.');
- }
- }
-
- /**
- * This function checks to do updated for boot
- *
- *
- * @name verifyForBootstrapUpgrade
- *
- * param
- * @return boolean
- */
- function verifyForBootstrapUpgrade()
- {
- foreach( $this->sFilesList->files as $sFile ) {
- if( basename($sFile) == 'schema.xml' ) {
- $this->newSystemClass = $sFile;
- return true;
- }
- }
- return false;
- }
-
- /**
- * This function updates to the files
- *
- *
- * @name upgrade
- *
- * param
- * @return array
- */
- function upgrade()
- {
- //get special files
- $sListFile = '';
- $sCheckListFile = '';
- $sPatchVersionFile = '';
- $sPoFile = '';
- $sSchemaFile = '';
- $sSchemaRBACFile = '';
- foreach( $this->sFilesList->files as $sFile ) {
- if( basename($sFile) == 'schema.xml' ) {
- if( strpos($sFile, '/rbac/engine/') === false ) {
- $sOldSchema = '';
- $sSchemaFile = $sFile;
- } else {
- $sOldSchemaRBAC = '';
- $sSchemaRBACFile = $sFile;
- }
+ return $items;
}
- //files.lst
- if( basename($sFile) == 'files.lst' ) {
- $this->sUpgradeFileList = $sFile;
- }
-
- //files.lst
- if( basename($sFile) == 'patch.version.txt' ) {
- $sPatchVersionFile = $sFile;
- }
-
- //files.rev.txt
- if( substr(basename($sFile), 0, 6) == 'files.' && substr(basename($sFile), - 4) == '.txt' ) {
- $sCheckListFile = $sFile;
- }
-
- //po files
- $sExtension = substr($sFile, strrpos($sFile, '.') + 1, strlen($sFile));
- if( $sExtension == 'po' ) {
- $sPoFile = $sFile;
- }
- }
-
- $pmVersion = explode('-', self::getVersion());
- array_shift($pmVersion);
- $patchVersion = explode('-', $this->sRevision);
-
- if( $sPatchVersionFile != '' && file_exists($sPatchVersionFile) ) {
- $this->sRevision = file_get_contents($sPatchVersionFile);
- $patchVersion = explode('-', $this->sRevision);
- }
-
- if( ! file_exists(PATH_DATA . 'log' . PATH_SEP) ) {
- G::mk_dir(PATH_DATA . 'log' . PATH_SEP);
- }
-
- //empty query log
- $sqlLog = PATH_DATA . 'log' . PATH_SEP . "query.log";
- $fp = fopen($sqlLog, "w+");
- fwrite($fp, "");
- fclose($fp);
-
- $aEnvironmentsUpdated = array ();
- $aEnvironmentsDiff = array ();
- $aErrors = array ();
-
- //now will verify each folder and file has permissions to write and add files.
- if( $this->sUpgradeFileList != '' ) {
- $bCopySchema = true;
- $oFile = fopen($this->sUpgradeFileList, 'r');
- while( $sLine = trim(fgets($oFile)) ) {
- $sLine = substr($sLine, 1);
- $aAux = explode(PATH_SEP, $sLine);
- array_shift($aAux);
- $sFilePath = implode(PATH_SEP, $aAux);
- $targetFileName = PATH_TRUNK . $sFilePath;
- if( ! is_dir($this->sPath . 'processmaker' . PATH_SEP . $sFilePath) ) {
- //if we are updating or deleting a file
- if( file_exists($this->sPath . 'processmaker' . PATH_SEP . $sFilePath) ) {
- if( file_exists($targetFileName) ) {
- if( ! is_writable($targetFileName) ) {
- throw (new Exception("File $targetFileName is not writable."));
+ public static function verifyChecksum ()
+ {
+ if (! file_exists( PATH_TRUNK . "checksum.txt" ))
+ return false;
+ $lines = explode( "\n", file_get_contents( PATH_TRUNK . "checksum.txt" ) );
+ $result = array ("diff" => array (),"missing" => array ()
+ );
+ foreach ($lines as $line) {
+ if (empty( $line ))
+ continue;
+ list ($checksum, $empty, $filename) = explode( " ", $line );
+ //Skip xmlform because these files always change.
+ if (strpos( $filename, "/xmlform/" ) !== false)
+ continue;
+ if (file_exists( realpath( $filename ) )) {
+ if (strcmp( $checksum, md5_file( realpath( $filename ) ) ) != 0) {
+ $result['diff'][] = $filename;
+ }
+ } else {
+ $result['missing'][] = $filename;
+ }
}
- } else {
- //verify parent folder, and ask if that folder is writable
- $auxDir = explode('/', $targetFileName);
- array_pop($auxDir);
- $parentDir = implode('/', $auxDir);
- if( ! is_dir($parentDir) ) {
- //throw (new Exception("File $parentDir is an invalid directory."));
- G::mk_dir($parentDir);
- }
- if( ! is_writable($parentDir) ) {
- throw (new Exception("Directory $parentDir is not writable."));
- }
- }
- } else {
- //delete unused files
- if( file_exists($targetFileName) && ! is_writable($targetFileName) ) {
- throw (new Exception("File $targetFileName is not writable."));
- }
- }
- } else {
- $dirName = PATH_TRUNK . $sFilePath;
- if( $dirName[strlen($dirName) - 1] == '/' )
- $dirName = substr($dirName, 0, strlen($dirName) - 1);
- $auxDir = explode('/', $dirName);
- array_pop($auxDir);
- $parentDir = implode('/', $auxDir);
- if( file_exists($dirName) ) {
- if( is_writable($dirName) ) {
- //print "e. ok $dirName
";
- } else {
- throw (new Exception("$dirName is not writable"));
- }
- } else {
- if( is_writable($parentDir) ) {
- mkdir($dirName, 0777);
- } else {
- throw (new Exception("$dirName does not exist and parent folder $parentDir is not writable"));
- }
- }
- }
+ return $result;
}
- }
-
- //processing list file files.lst
- if( $this->sUpgradeFileList != '' ) {
- $bCopySchema = true;
- $oFile = fopen($this->sUpgradeFileList, 'r');
- while( $sLine = trim(fgets($oFile)) ) {
- $action = substr($sLine, 0, 1);
- $sLine = substr($sLine, 1);
- $aAux = explode(PATH_SEP, $sLine);
- array_shift($aAux);
- $sFilePath = implode(PATH_SEP, $aAux);
- $targetFileName = PATH_TRUNK . $sFilePath;
- if( strtoupper($action) != 'D'){
- if( ! is_dir($this->sPath . 'processmaker' . PATH_SEP . $sFilePath) ) {
- if( file_exists($this->sPath . 'processmaker' . PATH_SEP . $sFilePath) ) {
- if( strpos($sFilePath, 'schema.xml') !== false && $bCopySchema ) {
- $bCopySchema = false;
- $sOldSchema = str_replace('schema.xml', 'schema_' . date('Ymd') . '.xml', PATH_TRUNK . $sFilePath);
- $this->pm_copy(PATH_TRUNK . $sFilePath, $sOldSchema);
- }
- if( file_exists($targetFileName) ) {
- if( is_writable($targetFileName) ) {
- $this->pm_copy($this->sPath . 'processmaker' . PATH_SEP . $sFilePath, $targetFileName);
- @chmod($targetFileName, 0666);
- } else
- throw (new Exception("Failed to open file: Permission denied in $targetFileName."));
- } else {
- $this->pm_copy($this->sPath . 'processmaker' . PATH_SEP . $sFilePath, $targetFileName);
- @chmod($targetFileName, 0666);
- }
- } else { //delete unused files
- if( file_exists($targetFileName) ) {
- @unlink($targetFileName);
- }
- }
- } else {
- if( ! file_exists(PATH_TRUNK . $sFilePath) ) {
- mkdir(PATH_TRUNK . $sFilePath, 0777);
- }
- }
- } else if( file_exists(PATH_TRUNK . $sFilePath) && $sFilePath != 'workflow/engine/gulliver' ) {
- @unlink(PATH_TRUNK . $sFilePath);
- }
- }
- }
-
- //end files copied.
- $missedFiles = '';
- $distinctFiles = '';
- $missed = 0;
- $distinct = 0;
- //checking files of this installation server with the files in Repository Code.
- if( $sCheckListFile != '' ) {
- $fp = fopen($sCheckListFile, 'r');
- while( ! feof($fp) ) {
- $line = explode(' ', fgets($fp));
- if( count($line) == 3 ) {
- $file = PATH_TRUNK . trim($line[2]);
- if( is_readable($file) ) {
- $size = sprintf("%07d", filesize($file));
- $checksum = sprintf("%010u", crc32(file_get_contents($file)));
- if( ! ($line[0] == $size && $line[1] == $checksum) && substr($file, - 4) != '.xml' ) {
- $distinctFiles .= $file . "\n";
- $distinct ++;
- }
- } else {
- $missedFiles .= $file . "\n";
- $missed ++;
- }
- }
- }
- fclose($fp);
- }
-
- if( $missed > 0 )
- $aErrors[] = "Warning: there are $missed missed files. ";
- $aErrors[] = $missedFiles;
-
- if( $distinct > 0 ) {
- $aErrors[] = "Warning: there are $distinct files with differences. ";
- $aErrors[] = $distinctFiles;
- }
-
- //now include the files and classes needed for upgrade databases, dont move this files, because we
- //are getting the last files in this point. Even the files was in the patch we will take the new ones.
- include PATH_METHODS . PATH_SEP . 'setup' . PATH_SEP . 'upgrade_RBAC.php';
- G::LoadClass('languages');
- G::LoadSystem('database_mysql');
-
- $bForceXml = true;
- $bParseSchema = true;
- $bParseSchemaRBAC = true;
- $oDirectory = dir(PATH_DB);
-
- //count db.php files ( workspaces )
- $aWorkspaces = array ();
- while( ($sObject = $oDirectory->read()) ) {
- if( is_dir(PATH_DB . $sObject) && substr($sObject, 0, 1) != '.' && file_exists(PATH_DB . $sObject . PATH_SEP . 'db.php') ) {
- $aWorkspaces[] = $sObject;
- }
- }
- $aUpgradeData = array ();
- $aUpgradeData['workspaces'] = $aWorkspaces;
- $aUpgradeData['wsQuantity'] = count($aWorkspaces);
- $aUpgradeData['sPoFile'] = $sPoFile;
- $aUpgradeData['bForceXmlPoFile'] = true;
- $aUpgradeData['sSchemaFile'] = $sSchemaFile;
- $aUpgradeData['sSchemaRBACFile'] = $sSchemaRBACFile;
-
- file_put_contents(PATH_DATA . 'log' . PATH_SEP . "upgrade.data.bin", serialize($aUpgradeData));
-
- $sSchemaFile = '';
- $sPoFile = '';
- $sSchemaRBACFile = '';
-
- $oDirectory = dir(PATH_DB);
- while( ($sObject = $oDirectory->read()) ) {
- if( is_dir(PATH_DB . $sObject) && substr($sObject, 0, 1) != '.' ) {
- if( file_exists(PATH_DB . $sObject . PATH_SEP . 'db.php') ) {
-
- eval($this->getDatabaseCredentials(PATH_DB . $sObject . PATH_SEP . 'db.php'));
-
- }
- $aEnvironmentsUpdated[] = $sObject;
- $aEnvironmentsDiff[] = $sObject;
- }
- }
- $oDirectory->close();
- @unlink(PATH_CORE . 'config/_databases_.php');
-
- //clean up smarty directory
- $oDirectory = dir(PATH_SMARTY_C);
- while( $sFilename = $oDirectory->read() ) {
- if( ($sFilename != '.') && ($sFilename != '..') ) {
- @unlink(PATH_SMARTY_C . PATH_SEP . $sFilename);
- }
- }
-
- //clean up xmlform folders
- $sDir = PATH_C . 'xmlform';
- if( file_exists($sDir) && is_dir($sDir) ) {
- $oDirectory = dir($sDir);
- while( $sObjectName = $oDirectory->read() ) {
- if( ($sObjectName != '.') && ($sObjectName != '..') ) {
- if (is_dir($sDir . PATH_SEP . $sObjectName)) {
- G::rm_dir($sDir . PATH_SEP . $sObjectName);
- }
- }
- }
- $oDirectory->close();
- }
-
- //changing the PM_VERSION according the patch file name
- $oFile = fopen(PATH_METHODS . 'login/version-pmos.php', 'w+');
- if( isset($this->sRevision) && $this->sRevision != '' ) {
- fwrite($oFile, "sRevision . "' ));\n?>");
- } else {
- fwrite($oFile, "");
- }
- fclose($oFile);
- $ver = explode("-", $this->sRevision);
- $this->aErrors = $aErrors;
- $this->aWorkspaces = $aWorkspaces;
-
- return $ver;
- }
/**
- * This function does to clean up to the upgrate directory
- *
- *
- * @name cleanupUpgradeDirectory
- *
- * param
- * @return array
- */
- public function cleanupUpgradeDirectory()
+ * This function checks files to do updated to pm
+ *
+ *
+ * @name verifyFileForUpgrade
+ *
+ * param
+ * @return boolean
+ */
+ function verifyFileForUpgrade ()
{
- G::rm_dir(PATH_DATA . "upgrade" . PATH_SEP . "processmaker");
+ $upgradeFilename = isset( $_FILES['form']['name']['UPGRADE_FILENAME'] ) ? $_FILES['form']['name']['UPGRADE_FILENAME'] : '';
+ $tempFilename = isset( $_FILES['form']['tmp_name']['UPGRADE_FILENAME'] ) ? $_FILES['form']['tmp_name']['UPGRADE_FILENAME'] : '';
+ $this->sRevision = str_replace( '.tar.gz', '', str_replace( 'pmos-patch-', '', $upgradeFilename ) );
+ $sTemFilename = $tempFilename;
+ $this->sFilename = PATH_DATA . 'upgrade' . PATH_SEP . $upgradeFilename;
+ $this->sPath = dirname( $this->sFilename ) . PATH_SEP;
+ G::mk_dir( PATH_DATA . 'upgrade' );
+ if (! move_uploaded_file( $sTemFilename, $this->sFilename )) {
+ return false;
+ }
+ return true;
}
- /**
- * This function creates a directory
- *
- *
- * @name pm_copy
- *
- * @param string $source
- * @param string $target
- * @return void
- */
- function pm_copy($source, $target)
- {
- if( ! is_dir(dirname($target)) ) {
- G::mk_dir(dirname($target));
+ /**
+ * This function gets files to do updated to pm
+ *
+ *
+ * @name getUpgradedFilesList
+ *
+ * param
+ * @return void
+ */
+ function getUpgradedFilesList ()
+ {
+ G::LoadClass( 'archive' );
+ $this->sFilesList = new gzip_file( $this->sFilename );
+ $this->sFilesList->set_options( array ('basedir' => dirname( $this->sFilename ),'overwrite' => 1
+ ) );
+ $this->sFilesList->extract_files();
+ if (count( $this->sFilesList->error ) > 0) {
+ $msg = '';
+ foreach ($this->sFilesList->error as $key => $val) {
+ $msg .= $val . "\n";
+ }
+ throw new Exception( $msg );
+ }
+ if (count( $this->sFilesList->files ) == 0) {
+ throw new Exception( 'The uploaded file is an invalid patch file.' );
+ }
}
- if( ! copy($source, $target) ) {
- krumo($source);
- krumo($target);
+
+ /**
+ * This function checks to do updated for boot
+ *
+ *
+ * @name verifyForBootstrapUpgrade
+ *
+ * param
+ * @return boolean
+ */
+ function verifyForBootstrapUpgrade ()
+ {
+ foreach ($this->sFilesList->files as $sFile) {
+ if (basename( $sFile ) == 'schema.xml') {
+ $this->newSystemClass = $sFile;
+ return true;
+ }
+ }
+ return false;
}
- }
- /**
- * This function gets info about db
- *
- *
- * @name getDatabaseCredentials
- *
- * @param string $dbFile
- * @return $sContent
- */
- function getDatabaseCredentials($dbFile)
- {
- $sContent = file_get_contents($dbFile);
- $sContent = str_replace('', '', $sContent);
- $sContent = str_replace('define', '', $sContent);
- $sContent = str_replace("('", '$', $sContent);
- $sContent = str_replace("',", '=', $sContent);
- $sContent = str_replace(");", ';', $sContent);
- return $sContent;
- }
+ /**
+ * This function updates to the files
+ *
+ *
+ * @name upgrade
+ *
+ * param
+ * @return array
+ */
+ function upgrade ()
+ {
+ //get special files
+ $sListFile = '';
+ $sCheckListFile = '';
+ $sPatchVersionFile = '';
+ $sPoFile = '';
+ $sSchemaFile = '';
+ $sSchemaRBACFile = '';
+ foreach ($this->sFilesList->files as $sFile) {
+ if (basename( $sFile ) == 'schema.xml') {
+ if (strpos( $sFile, '/rbac/engine/' ) === false) {
+ $sOldSchema = '';
+ $sSchemaFile = $sFile;
+ } else {
+ $sOldSchemaRBAC = '';
+ $sSchemaRBACFile = $sFile;
+ }
+ }
- /**
- * Retrieves the system schema.
- *
- * @return schema content in an array
- */
- public static function getSystemSchema() {
- return System::getSchema(PATH_TRUNK . "workflow/engine/config/schema.xml");
- }
+ //files.lst
+ if (basename( $sFile ) == 'files.lst') {
+ $this->sUpgradeFileList = $sFile;
+ }
- /**
- * Retrieves the schema for a plugin.
- *
- * @param string $pluginName name of the plugin
- * @return $sContent
- */
- public static function getPluginSchema($pluginName) {
- if (file_exists(PATH_PLUGINS . $pluginName . "/config/schema.xml"))
- return System::getSchema(PATH_PLUGINS . $pluginName . "/config/schema.xml");
- else
- return false;
- }
+ //files.lst
+ if (basename( $sFile ) == 'patch.version.txt') {
+ $sPatchVersionFile = $sFile;
+ }
- /**
- * Retrieves a schema array from a file.
- *
- * @param string $sSchemaFile schema filename
- * @return $sContent
- */
- public static function getSchema($sSchemaFile) {
- /* This is the MySQL mapping that Propel uses (from MysqlPlatform.php) */
- $mysqlTypes = array(
- 'NUMERIC' => "DECIMAL",
- 'LONGVARCHAR' => "MEDIUMTEXT",
- 'TIMESTAMP' => "DATETIME",
- 'BU_TIMESTAMP' => "DATETIME",
- 'BINARY' => "BLOB",
- 'VARBINARY' => "MEDIUMBLOB",
- 'LONGVARBINARY' => "LONGBLOB",
- 'BLOB' => "LONGBLOB",
- 'CLOB' => "LONGTEXT",
+ //files.rev.txt
+ if (substr( basename( $sFile ), 0, 6 ) == 'files.' && substr( basename( $sFile ), - 4 ) == '.txt') {
+ $sCheckListFile = $sFile;
+ }
+
+ //po files
+ $sExtension = substr( $sFile, strrpos( $sFile, '.' ) + 1, strlen( $sFile ) );
+ if ($sExtension == 'po') {
+ $sPoFile = $sFile;
+ }
+ }
+
+ $pmVersion = explode( '-', self::getVersion() );
+ array_shift( $pmVersion );
+ $patchVersion = explode( '-', $this->sRevision );
+
+ if ($sPatchVersionFile != '' && file_exists( $sPatchVersionFile )) {
+ $this->sRevision = file_get_contents( $sPatchVersionFile );
+ $patchVersion = explode( '-', $this->sRevision );
+ }
+
+ if (! file_exists( PATH_DATA . 'log' . PATH_SEP )) {
+ G::mk_dir( PATH_DATA . 'log' . PATH_SEP );
+ }
+
+ //empty query log
+ $sqlLog = PATH_DATA . 'log' . PATH_SEP . "query.log";
+ $fp = fopen( $sqlLog, "w+" );
+ fwrite( $fp, "" );
+ fclose( $fp );
+
+ $aEnvironmentsUpdated = array ();
+ $aEnvironmentsDiff = array ();
+ $aErrors = array ();
+
+ //now will verify each folder and file has permissions to write and add files.
+ if ($this->sUpgradeFileList != '') {
+ $bCopySchema = true;
+ $oFile = fopen( $this->sUpgradeFileList, 'r' );
+ while ($sLine = trim( fgets( $oFile ) )) {
+ $sLine = substr( $sLine, 1 );
+ $aAux = explode( PATH_SEP, $sLine );
+ array_shift( $aAux );
+ $sFilePath = implode( PATH_SEP, $aAux );
+ $targetFileName = PATH_TRUNK . $sFilePath;
+ if (! is_dir( $this->sPath . 'processmaker' . PATH_SEP . $sFilePath )) {
+ //if we are updating or deleting a file
+ if (file_exists( $this->sPath . 'processmaker' . PATH_SEP . $sFilePath )) {
+ if (file_exists( $targetFileName )) {
+ if (! is_writable( $targetFileName )) {
+ throw (new Exception( "File $targetFileName is not writable." ));
+ }
+ } else {
+ //verify parent folder, and ask if that folder is writable
+ $auxDir = explode( '/', $targetFileName );
+ array_pop( $auxDir );
+ $parentDir = implode( '/', $auxDir );
+ if (! is_dir( $parentDir )) {
+ //throw (new Exception("File $parentDir is an invalid directory."));
+ G::mk_dir( $parentDir );
+ }
+ if (! is_writable( $parentDir )) {
+ throw (new Exception( "Directory $parentDir is not writable." ));
+ }
+ }
+ } else {
+ //delete unused files
+ if (file_exists( $targetFileName ) && ! is_writable( $targetFileName )) {
+ throw (new Exception( "File $targetFileName is not writable." ));
+ }
+ }
+ } else {
+ $dirName = PATH_TRUNK . $sFilePath;
+ if ($dirName[strlen( $dirName ) - 1] == '/')
+ $dirName = substr( $dirName, 0, strlen( $dirName ) - 1 );
+ $auxDir = explode( '/', $dirName );
+ array_pop( $auxDir );
+ $parentDir = implode( '/', $auxDir );
+ if (file_exists( $dirName )) {
+ if (is_writable( $dirName )) {
+ //print "e. ok $dirName
";
+ } else {
+ throw (new Exception( "$dirName is not writable" ));
+ }
+ } else {
+ if (is_writable( $parentDir )) {
+ mkdir( $dirName, 0777 );
+ } else {
+ throw (new Exception( "$dirName does not exist and parent folder $parentDir is not writable" ));
+ }
+ }
+ }
+ }
+ }
+
+ //processing list file files.lst
+ if ($this->sUpgradeFileList != '') {
+ $bCopySchema = true;
+ $oFile = fopen( $this->sUpgradeFileList, 'r' );
+ while ($sLine = trim( fgets( $oFile ) )) {
+ $action = substr( $sLine, 0, 1 );
+ $sLine = substr( $sLine, 1 );
+ $aAux = explode( PATH_SEP, $sLine );
+ array_shift( $aAux );
+ $sFilePath = implode( PATH_SEP, $aAux );
+ $targetFileName = PATH_TRUNK . $sFilePath;
+ if (strtoupper( $action ) != 'D') {
+ if (! is_dir( $this->sPath . 'processmaker' . PATH_SEP . $sFilePath )) {
+ if (file_exists( $this->sPath . 'processmaker' . PATH_SEP . $sFilePath )) {
+ if (strpos( $sFilePath, 'schema.xml' ) !== false && $bCopySchema) {
+ $bCopySchema = false;
+ $sOldSchema = str_replace( 'schema.xml', 'schema_' . date( 'Ymd' ) . '.xml', PATH_TRUNK . $sFilePath );
+ $this->pm_copy( PATH_TRUNK . $sFilePath, $sOldSchema );
+ }
+ if (file_exists( $targetFileName )) {
+ if (is_writable( $targetFileName )) {
+ $this->pm_copy( $this->sPath . 'processmaker' . PATH_SEP . $sFilePath, $targetFileName );
+ @chmod( $targetFileName, 0666 );
+ } else
+ throw (new Exception( "Failed to open file: Permission denied in $targetFileName." ));
+ } else {
+ $this->pm_copy( $this->sPath . 'processmaker' . PATH_SEP . $sFilePath, $targetFileName );
+ @chmod( $targetFileName, 0666 );
+ }
+ } else { //delete unused files
+ if (file_exists( $targetFileName )) {
+ @unlink( $targetFileName );
+ }
+ }
+ } else {
+ if (! file_exists( PATH_TRUNK . $sFilePath )) {
+ mkdir( PATH_TRUNK . $sFilePath, 0777 );
+ }
+ }
+ } else if (file_exists( PATH_TRUNK . $sFilePath ) && $sFilePath != 'workflow/engine/gulliver') {
+ @unlink( PATH_TRUNK . $sFilePath );
+ }
+ }
+ }
+
+ //end files copied.
+ $missedFiles = '';
+ $distinctFiles = '';
+ $missed = 0;
+ $distinct = 0;
+ //checking files of this installation server with the files in Repository Code.
+ if ($sCheckListFile != '') {
+ $fp = fopen( $sCheckListFile, 'r' );
+ while (! feof( $fp )) {
+ $line = explode( ' ', fgets( $fp ) );
+ if (count( $line ) == 3) {
+ $file = PATH_TRUNK . trim( $line[2] );
+ if (is_readable( $file )) {
+ $size = sprintf( "%07d", filesize( $file ) );
+ $checksum = sprintf( "%010u", crc32( file_get_contents( $file ) ) );
+ if (! ($line[0] == $size && $line[1] == $checksum) && substr( $file, - 4 ) != '.xml') {
+ $distinctFiles .= $file . "\n";
+ $distinct ++;
+ }
+ } else {
+ $missedFiles .= $file . "\n";
+ $missed ++;
+ }
+ }
+ }
+ fclose( $fp );
+ }
+
+ if ($missed > 0)
+ $aErrors[] = "Warning: there are $missed missed files. ";
+ $aErrors[] = $missedFiles;
+
+ if ($distinct > 0) {
+ $aErrors[] = "Warning: there are $distinct files with differences. ";
+ $aErrors[] = $distinctFiles;
+ }
+
+ //now include the files and classes needed for upgrade databases, dont move this files, because we
+ //are getting the last files in this point. Even the files was in the patch we will take the new ones.
+ include PATH_METHODS . PATH_SEP . 'setup' . PATH_SEP . 'upgrade_RBAC.php';
+ G::LoadClass( 'languages' );
+ G::LoadSystem( 'database_mysql' );
+
+ $bForceXml = true;
+ $bParseSchema = true;
+ $bParseSchemaRBAC = true;
+ $oDirectory = dir( PATH_DB );
+
+ //count db.php files ( workspaces )
+ $aWorkspaces = array ();
+ while (($sObject = $oDirectory->read())) {
+ if (is_dir( PATH_DB . $sObject ) && substr( $sObject, 0, 1 ) != '.' && file_exists( PATH_DB . $sObject . PATH_SEP . 'db.php' )) {
+ $aWorkspaces[] = $sObject;
+ }
+ }
+ $aUpgradeData = array ();
+ $aUpgradeData['workspaces'] = $aWorkspaces;
+ $aUpgradeData['wsQuantity'] = count( $aWorkspaces );
+ $aUpgradeData['sPoFile'] = $sPoFile;
+ $aUpgradeData['bForceXmlPoFile'] = true;
+ $aUpgradeData['sSchemaFile'] = $sSchemaFile;
+ $aUpgradeData['sSchemaRBACFile'] = $sSchemaRBACFile;
+
+ file_put_contents( PATH_DATA . 'log' . PATH_SEP . "upgrade.data.bin", serialize( $aUpgradeData ) );
+
+ $sSchemaFile = '';
+ $sPoFile = '';
+ $sSchemaRBACFile = '';
+
+ $oDirectory = dir( PATH_DB );
+ while (($sObject = $oDirectory->read())) {
+ if (is_dir( PATH_DB . $sObject ) && substr( $sObject, 0, 1 ) != '.') {
+ if (file_exists( PATH_DB . $sObject . PATH_SEP . 'db.php' )) {
+
+ eval( $this->getDatabaseCredentials( PATH_DB . $sObject . PATH_SEP . 'db.php' ) );
+
+ }
+ $aEnvironmentsUpdated[] = $sObject;
+ $aEnvironmentsDiff[] = $sObject;
+ }
+ }
+ $oDirectory->close();
+ @unlink( PATH_CORE . 'config/_databases_.php' );
+
+ //clean up smarty directory
+ $oDirectory = dir( PATH_SMARTY_C );
+ while ($sFilename = $oDirectory->read()) {
+ if (($sFilename != '.') && ($sFilename != '..')) {
+ @unlink( PATH_SMARTY_C . PATH_SEP . $sFilename );
+ }
+ }
+
+ //clean up xmlform folders
+ $sDir = PATH_C . 'xmlform';
+ if (file_exists( $sDir ) && is_dir( $sDir )) {
+ $oDirectory = dir( $sDir );
+ while ($sObjectName = $oDirectory->read()) {
+ if (($sObjectName != '.') && ($sObjectName != '..')) {
+ if (is_dir( $sDir . PATH_SEP . $sObjectName )) {
+ G::rm_dir( $sDir . PATH_SEP . $sObjectName );
+ }
+ }
+ }
+ $oDirectory->close();
+ }
+
+ //changing the PM_VERSION according the patch file name
+ $oFile = fopen( PATH_METHODS . 'login/version-pmos.php', 'w+' );
+ if (isset( $this->sRevision ) && $this->sRevision != '') {
+ fwrite( $oFile, "sRevision . "' ));\n?>" );
+ } else {
+ fwrite( $oFile, "" );
+ }
+ fclose( $oFile );
+ $ver = explode( "-", $this->sRevision );
+ $this->aErrors = $aErrors;
+ $this->aWorkspaces = $aWorkspaces;
+
+ return $ver;
+ }
+
+ /**
+ * This function does to clean up to the upgrate directory
+ *
+ *
+ * @name cleanupUpgradeDirectory
+ *
+ * param
+ * @return array
+ */
+ public function cleanupUpgradeDirectory ()
+ {
+ G::rm_dir( PATH_DATA . "upgrade" . PATH_SEP . "processmaker" );
+ }
+
+ /**
+ * This function creates a directory
+ *
+ *
+ * @name pm_copy
+ *
+ * @param string $source
+ * @param string $target
+ * @return void
+ */
+ function pm_copy ($source, $target)
+ {
+ if (! is_dir( dirname( $target ) )) {
+ G::mk_dir( dirname( $target ) );
+ }
+ if (! copy( $source, $target )) {
+ krumo( $source );
+ krumo( $target );
+ }
+ }
+
+ /**
+ * This function gets info about db
+ *
+ *
+ * @name getDatabaseCredentials
+ *
+ * @param string $dbFile
+ * @return $sContent
+ */
+ function getDatabaseCredentials ($dbFile)
+ {
+ $sContent = file_get_contents( $dbFile );
+ $sContent = str_replace( '', '', $sContent );
+ $sContent = str_replace( 'define', '', $sContent );
+ $sContent = str_replace( "('", '$', $sContent );
+ $sContent = str_replace( "',", '=', $sContent );
+ $sContent = str_replace( ");", ';', $sContent );
+ return $sContent;
+ }
+
+ /**
+ * Retrieves the system schema.
+ *
+ * @return schema content in an array
+ */
+ public static function getSystemSchema ()
+ {
+ return System::getSchema( PATH_TRUNK . "workflow/engine/config/schema.xml" );
+ }
+
+ /**
+ * Retrieves the schema for a plugin.
+ *
+ * @param string $pluginName name of the plugin
+ * @return $sContent
+ */
+ public static function getPluginSchema ($pluginName)
+ {
+ if (file_exists( PATH_PLUGINS . $pluginName . "/config/schema.xml" ))
+ return System::getSchema( PATH_PLUGINS . $pluginName . "/config/schema.xml" );
+ else
+ return false;
+ }
+
+ /**
+ * Retrieves a schema array from a file.
+ *
+ * @param string $sSchemaFile schema filename
+ * @return $sContent
+ */
+ public static function getSchema ($sSchemaFile)
+ {
+ /* This is the MySQL mapping that Propel uses (from MysqlPlatform.php) */
+ $mysqlTypes = array ('NUMERIC' => "DECIMAL",'LONGVARCHAR' => "MEDIUMTEXT",'TIMESTAMP' => "DATETIME",'BU_TIMESTAMP' => "DATETIME",'BINARY' => "BLOB",'VARBINARY' => "MEDIUMBLOB",'LONGVARBINARY' => "LONGBLOB",'BLOB' => "LONGBLOB",'CLOB' => "LONGTEXT",
/* This is not from Propel, but is required to get INT right */
- 'INTEGER' => "INT");
-
- $aSchema = array();
- $oXml = new DomDocument();
- $oXml->load($sSchemaFile);
- $aTables = $oXml->getElementsByTagName('table');
- foreach ($aTables as $oTable) {
- $aPrimaryKeys = array();
- $sTableName = $oTable->getAttribute('name');
- $aSchema[$sTableName] = array();
- $aColumns = $oTable->getElementsByTagName('column');
- foreach ($aColumns as $oColumn) {
- $sColumName = $oColumn->getAttribute('name');
-
- /* Get the field type. Propel uses VARCHAR if nothing else is specified */
- $type = $oColumn->hasAttribute('type') ? strtoupper($oColumn->getAttribute('type')) : "VARCHAR";
-
- /* Convert type to MySQL type according to Propel */
- if (array_key_exists($type, $mysqlTypes))
- $type = $mysqlTypes[$type];
-
- $size = $oColumn->hasAttribute('size') ? $oColumn->getAttribute('size') : NULL;
- /* Add default sizes from MySQL */
- if ($type == "TINYINT" && !$size)
- $size = "4";
- if ($type == "INT" && !$size)
- $size = "11";
-
- if ($size)
- $type = "$type($size)";
-
- $required = $oColumn->hasAttribute('required') ? $oColumn->getAttribute('required') : NULL;
- /* Convert $required to a bool */
- $required = (in_array (strtolower ($required), array('1', 'true')));
-
- $default = $oColumn->hasAttribute('default') ? $oColumn->getAttribute('default') : NULL;
-
- $primaryKey = $oColumn->hasAttribute('primaryKey') ? $oColumn->getAttribute('primaryKey') : NULL;
- /* Convert $primaryKey to a bool */
- $primaryKey = (in_array (strtolower ($primaryKey), array('1', 'true')));
- if ($primaryKey)
- $aPrimaryKeys[] = $sColumName;
-
- $aSchema[$sTableName][$sColumName] = array(
- 'Field' => $sColumName,
- 'Type' => $type,
- 'Null' => $required ? "NO" : "YES",
- 'Default' => $default
+ 'INTEGER' => "INT"
);
- }
- if ( is_array($aPrimaryKeys) && count($aPrimaryKeys) > 0 ) {
- $aSchema[$sTableName]['INDEXES']['PRIMARY'] = $aPrimaryKeys;
- }
- $aIndexes = $oTable->getElementsByTagName('index');
- foreach ($aIndexes as $oIndex) {
- $aIndex = array();
- $aIndexesColumns = $oIndex->getElementsByTagName('index-column');
- foreach ($aIndexesColumns as $oIndexColumn) {
- $aIndex[] = $oIndexColumn->getAttribute('name');
- }
- $aSchema[$sTableName]['INDEXES'][ $oIndex->getAttribute('name') ] = $aIndex;
- }
- }
- return $aSchema;
- }
+ $aSchema = array ();
+ $oXml = new DomDocument();
+ $oXml->load( $sSchemaFile );
+ $aTables = $oXml->getElementsByTagName( 'table' );
+ foreach ($aTables as $oTable) {
+ $aPrimaryKeys = array ();
+ $sTableName = $oTable->getAttribute( 'name' );
+ $aSchema[$sTableName] = array ();
+ $aColumns = $oTable->getElementsByTagName( 'column' );
+ foreach ($aColumns as $oColumn) {
+ $sColumName = $oColumn->getAttribute( 'name' );
- /**
- * Returns the difference between two schema arrays
- *
- * @param array $aOldSchema original schema array
- * @param array $aNewSchema new schema array
- * @return array with tablesToAdd, tablesToAlter, tablesWithNewIndex and tablesToAlterIndex
- */
- public static function compareSchema($aOldSchema, $aNewSchema) {
- //$aChanges = array('tablesToDelete' => array(), 'tablesToAdd' => array(), 'tablesToAlter' => array());
- //Tables to delete, but this is disabled
- //foreach ($aOldSchema as $sTableName => $aColumns) {
- // if ( !isset($aNewSchema[$sTableName])) {
- // if (!in_array($sTableName, array('KT_APPLICATION', 'KT_DOCUMENT', 'KT_PROCESS'))) {
- // $aChanges['tablesToDelete'][] = $sTableName;
- // }
- // }
- //}
+ /* Get the field type. Propel uses VARCHAR if nothing else is specified */
+ $type = $oColumn->hasAttribute( 'type' ) ? strtoupper( $oColumn->getAttribute( 'type' ) ) : "VARCHAR";
- $aChanges = array('tablesToAdd' => array(), 'tablesToAlter' => array(), 'tablesWithNewIndex' => array(), 'tablesToAlterIndex'=> array());
+ /* Convert type to MySQL type according to Propel */
+ if (array_key_exists( $type, $mysqlTypes ))
+ $type = $mysqlTypes[$type];
- //new tables to create and alter
- foreach ($aNewSchema as $sTableName => $aColumns) {
- if (!isset($aOldSchema[$sTableName])) {
- $aChanges['tablesToAdd'][$sTableName] = $aColumns;
- }
- else {
- //drop old columns
- foreach ($aOldSchema[$sTableName] as $sColumName => $aParameters) {
- if (!isset($aNewSchema[$sTableName][$sColumName])) {
- if (!isset($aChanges['tablesToAlter'][$sTableName])) {
- $aChanges['tablesToAlter'][$sTableName] = array('DROP' => array(), 'ADD' => array(), 'CHANGE' => array());
+ $size = $oColumn->hasAttribute( 'size' ) ? $oColumn->getAttribute( 'size' ) : NULL;
+ /* Add default sizes from MySQL */
+ if ($type == "TINYINT" && ! $size)
+ $size = "4";
+ if ($type == "INT" && ! $size)
+ $size = "11";
+
+ if ($size)
+ $type = "$type($size)";
+
+ $required = $oColumn->hasAttribute( 'required' ) ? $oColumn->getAttribute( 'required' ) : NULL;
+ /* Convert $required to a bool */
+ $required = (in_array( strtolower( $required ), array ('1','true'
+ ) ));
+
+ $default = $oColumn->hasAttribute( 'default' ) ? $oColumn->getAttribute( 'default' ) : NULL;
+
+ $primaryKey = $oColumn->hasAttribute( 'primaryKey' ) ? $oColumn->getAttribute( 'primaryKey' ) : NULL;
+ /* Convert $primaryKey to a bool */
+ $primaryKey = (in_array( strtolower( $primaryKey ), array ('1','true'
+ ) ));
+ if ($primaryKey)
+ $aPrimaryKeys[] = $sColumName;
+
+ $aSchema[$sTableName][$sColumName] = array ('Field' => $sColumName,'Type' => $type,'Null' => $required ? "NO" : "YES",'Default' => $default
+ );
}
- $aChanges['tablesToAlter'][$sTableName]['DROP'][$sColumName] = $sColumName;
- }
- }
- //create new columns
- //foreach ($aNewSchema[$sTableName] as $sColumName => $aParameters) {
- foreach ($aColumns as $sColumName => $aParameters) {
- if ($sColumName != 'INDEXES') {
- if (!isset($aOldSchema[$sTableName][$sColumName])) { //this column doesnt exist in oldschema
- if (!isset($aChanges['tablesToAlter'][$sTableName])) {
- $aChanges['tablesToAlter'][$sTableName] = array('DROP' => array(), 'ADD' => array(), 'CHANGE' => array());
- }
- $aChanges['tablesToAlter'][$sTableName]['ADD'][$sColumName] = $aParameters;
+ if (is_array( $aPrimaryKeys ) && count( $aPrimaryKeys ) > 0) {
+ $aSchema[$sTableName]['INDEXES']['PRIMARY'] = $aPrimaryKeys;
}
- else { //the column exists
- $newField = $aNewSchema[$sTableName][$sColumName];
- $oldField = $aOldSchema[$sTableName][$sColumName];
- //both are null, no change is required
- if ( !isset($newField['Default']) && !isset($oldField['Default'])) $changeDefaultAttr = false;
- //one of them is null, change IS required
- if ( !isset($newField['Default']) && isset($oldField['Default']) && $oldField['Default']!= '') $changeDefaultAttr = true;
- if ( isset($newField['Default']) && !isset($oldField['Default'])) $changeDefaultAttr = true;
- //both are defined and they are different.
- if ( isset($newField['Default']) && isset($oldField['Default']) ) {
- if ( $newField['Default'] != $oldField['Default'] )
- $changeDefaultAttr = true;
- else
- $changeDefaultAttr = false;
- }
- //special cases
- // BLOB and TEXT columns cannot have DEFAULT values. http://dev.mysql.com/doc/refman/5.0/en/blob.html
- if ( in_array(strtolower($newField['Type']), array('text','mediumtext') ) )
- $changeDefaultAttr = false;
-
- //#1067 - Invalid default value for datetime field
- if ( in_array($newField['Type'], array('datetime')) && isset($newField['Default']) && $newField['Default']== '' )
- $changeDefaultAttr = false;
-
- //#1067 - Invalid default value for int field
- if ( substr($newField['Type'], 0, 3 ) == "int" && isset($newField['Default']) && $newField['Default']== '' )
- $changeDefaultAttr = false;
-
- //if any difference exists, then insert the difference in aChanges
- if ( strcasecmp($newField['Field'], $oldField['Field']) !== 0 ||
- strcasecmp($newField['Type'], $oldField['Type']) !== 0 ||
- strcasecmp($newField['Null'], $oldField['Null']) !== 0 ||
- $changeDefaultAttr ) {
- if (!isset($aChanges['tablesToAlter'][$sTableName])) {
- $aChanges['tablesToAlter'][$sTableName] = array('DROP' => array(), 'ADD' => array(), 'CHANGE' => array());
+ $aIndexes = $oTable->getElementsByTagName( 'index' );
+ foreach ($aIndexes as $oIndex) {
+ $aIndex = array ();
+ $aIndexesColumns = $oIndex->getElementsByTagName( 'index-column' );
+ foreach ($aIndexesColumns as $oIndexColumn) {
+ $aIndex[] = $oIndexColumn->getAttribute( 'name' );
}
- $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Field'] = $newField['Field'];
- $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Type'] = $newField['Type'];
- $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Null'] = $newField['Null'];
- if ( isset($newField['Default']) )
- $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Default'] = $newField['Default'];
- else
- $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Default'] = null;
-
- }
+ $aSchema[$sTableName]['INDEXES'][$oIndex->getAttribute( 'name' )] = $aIndex;
}
- } //only columns, no the indexes column
- }//foreach $aColumns
-
- //now check the indexes of table
- if ( isset($aNewSchema[$sTableName]['INDEXES']) ) {
- foreach ( $aNewSchema[$sTableName]['INDEXES'] as $indexName => $indexFields ) {
- if (!isset( $aOldSchema[$sTableName]['INDEXES'][$indexName]) ) {
- if (!isset($aChanges['tablesWithNewIndex'][$sTableName])) {
- $aChanges['tablesWithNewIndex'][$sTableName] = array();
- }
- $aChanges['tablesWithNewIndex'][$sTableName][$indexName] = $indexFields;
- }
- else {
- if ( $aOldSchema[$sTableName]['INDEXES'][$indexName] != $indexFields ) {
- if (!isset($aChanges['tablesToAlterIndex'][$sTableName])) {
- $aChanges['tablesToAlterIndex'][$sTableName] = array();
- }
- $aChanges['tablesToAlterIndex'][$sTableName][$indexName] = $indexFields;
- }
- }
- }
}
- } //for-else table exists
- } //for new schema
- return $aChanges;
- }
-
-
- function getEmailConfiguration()
- {
- G::LoadClass('configuration');
- $conf = new Configurations();
- $config = $conf->load('Emails');
-
- return $config;
- }
-
- function getSkingList()
- {
- //Create Skins custom folder if it doesn't exists
- if(!is_dir(PATH_CUSTOM_SKINS)){
- G::verifyPath(PATH_CUSTOM_SKINS, true);
+ return $aSchema;
}
- //Get Skin Config files
- $skinListArray = array();
- $customSkins = glob(PATH_CUSTOM_SKINS . "*/config.xml");
-
- // getting al base skins
- $baseSkins = glob(G::ExpandPath("skinEngine") . '*/config.xml');
-
- // filtering no public skins (uxs, simplified)
- foreach ($baseSkins as $i => $skinName) {
- if (strpos($skinName, 'simplified') !== false || strpos($skinName, 'uxs') !== false) {
- unset($baseSkins[$i]);
- }
- }
-
- $customSkins = array_merge($baseSkins, $customSkins);
-
- //Read and parse each Configuration File
- foreach ($customSkins as $key => $configInformation) {
- $folderId = basename(dirname($configInformation));
-
- if ($folderId == 'base') {
- $folderId = 'classic';
- }
-
- $xmlConfiguration = file_get_contents($configInformation);
- $xmlConfigurationObj = G::xmlParser($xmlConfiguration);
-
- if (isset($xmlConfigurationObj->result['skinConfiguration'])) {
- $skinInformationArray = $skinFilesArray = $xmlConfigurationObj->result['skinConfiguration']['__CONTENT__']['information']['__CONTENT__'];
- $res = array();
- $res['SKIN_FOLDER_ID'] = strtolower($folderId);
-
- foreach ($skinInformationArray as $keyInfo => $infoValue) {
- $res['SKIN_' . strtoupper($keyInfo)] = $infoValue['__VALUE__'];
- }
-
- $skinListArray['skins'][] = $res;
- }
- }
-
- $skinListArray['currentSkin'] = SYS_SKIN;
-
- return $skinListArray;
- }
-
- function getAllTimeZones()
- {
- $timezones = DateTimeZone::listAbbreviations();
-
- $cities = array();
- foreach( $timezones as $key => $zones )
+ /**
+ * Returns the difference between two schema arrays
+ *
+ * @param array $aOldSchema original schema array
+ * @param array $aNewSchema new schema array
+ * @return array with tablesToAdd, tablesToAlter, tablesWithNewIndex and tablesToAlterIndex
+ */
+ public static function compareSchema ($aOldSchema, $aNewSchema)
{
- foreach( $zones as $id => $zone )
- {
- /**
- * Only get timezones explicitely not part of "Others".
- * @see http://www.php.net/manual/en/timezones.others.php
- */
- if ( preg_match( '/^(America|Antartica|Arctic|Asia|Atlantic|Africa|Europe|Indian|Pacific)\//', $zone['timezone_id'] )
- && $zone['timezone_id']) {
- $cities[$zone['timezone_id']][] = $key;
+ //$aChanges = array('tablesToDelete' => array(), 'tablesToAdd' => array(), 'tablesToAlter' => array());
+ //Tables to delete, but this is disabled
+ //foreach ($aOldSchema as $sTableName => $aColumns) {
+ // if ( !isset($aNewSchema[$sTableName])) {
+ // if (!in_array($sTableName, array('KT_APPLICATION', 'KT_DOCUMENT', 'KT_PROCESS'))) {
+ // $aChanges['tablesToDelete'][] = $sTableName;
+ // }
+ // }
+ //}
+
+
+ $aChanges = array ('tablesToAdd' => array (),'tablesToAlter' => array (),'tablesWithNewIndex' => array (),'tablesToAlterIndex' => array ()
+ );
+
+ //new tables to create and alter
+ foreach ($aNewSchema as $sTableName => $aColumns) {
+ if (! isset( $aOldSchema[$sTableName] )) {
+ $aChanges['tablesToAdd'][$sTableName] = $aColumns;
+ } else {
+ //drop old columns
+ foreach ($aOldSchema[$sTableName] as $sColumName => $aParameters) {
+ if (! isset( $aNewSchema[$sTableName][$sColumName] )) {
+ if (! isset( $aChanges['tablesToAlter'][$sTableName] )) {
+ $aChanges['tablesToAlter'][$sTableName] = array ('DROP' => array (),'ADD' => array (),'CHANGE' => array ()
+ );
+ }
+ $aChanges['tablesToAlter'][$sTableName]['DROP'][$sColumName] = $sColumName;
+ }
+ }
+
+ //create new columns
+ //foreach ($aNewSchema[$sTableName] as $sColumName => $aParameters) {
+ foreach ($aColumns as $sColumName => $aParameters) {
+ if ($sColumName != 'INDEXES') {
+ if (! isset( $aOldSchema[$sTableName][$sColumName] )) { //this column doesnt exist in oldschema
+ if (! isset( $aChanges['tablesToAlter'][$sTableName] )) {
+ $aChanges['tablesToAlter'][$sTableName] = array ('DROP' => array (),'ADD' => array (),'CHANGE' => array ()
+ );
+ }
+ $aChanges['tablesToAlter'][$sTableName]['ADD'][$sColumName] = $aParameters;
+ } else { //the column exists
+ $newField = $aNewSchema[$sTableName][$sColumName];
+ $oldField = $aOldSchema[$sTableName][$sColumName];
+ //both are null, no change is required
+ if (! isset( $newField['Default'] ) && ! isset( $oldField['Default'] ))
+ $changeDefaultAttr = false;
+ //one of them is null, change IS required
+ if (! isset( $newField['Default'] ) && isset( $oldField['Default'] ) && $oldField['Default'] != '')
+ $changeDefaultAttr = true;
+ if (isset( $newField['Default'] ) && ! isset( $oldField['Default'] ))
+ $changeDefaultAttr = true;
+ //both are defined and they are different.
+ if (isset( $newField['Default'] ) && isset( $oldField['Default'] )) {
+ if ($newField['Default'] != $oldField['Default'])
+ $changeDefaultAttr = true;
+ else
+ $changeDefaultAttr = false;
+ }
+ //special cases
+ // BLOB and TEXT columns cannot have DEFAULT values. http://dev.mysql.com/doc/refman/5.0/en/blob.html
+ if (in_array( strtolower( $newField['Type'] ), array ('text','mediumtext'
+ ) ))
+ $changeDefaultAttr = false;
+
+ //#1067 - Invalid default value for datetime field
+ if (in_array( $newField['Type'], array ('datetime'
+ ) ) && isset( $newField['Default'] ) && $newField['Default'] == '')
+ $changeDefaultAttr = false;
+
+ //#1067 - Invalid default value for int field
+ if (substr( $newField['Type'], 0, 3 ) == "int" && isset( $newField['Default'] ) && $newField['Default'] == '')
+ $changeDefaultAttr = false;
+
+ //if any difference exists, then insert the difference in aChanges
+ if (strcasecmp( $newField['Field'], $oldField['Field'] ) !== 0 || strcasecmp( $newField['Type'], $oldField['Type'] ) !== 0 || strcasecmp( $newField['Null'], $oldField['Null'] ) !== 0 || $changeDefaultAttr) {
+ if (! isset( $aChanges['tablesToAlter'][$sTableName] )) {
+ $aChanges['tablesToAlter'][$sTableName] = array ('DROP' => array (),'ADD' => array (),'CHANGE' => array ()
+ );
+ }
+ $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Field'] = $newField['Field'];
+ $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Type'] = $newField['Type'];
+ $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Null'] = $newField['Null'];
+ if (isset( $newField['Default'] ))
+ $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Default'] = $newField['Default'];
+ else
+ $aChanges['tablesToAlter'][$sTableName]['CHANGE'][$sColumName]['Default'] = null;
+
+ }
+ }
+ } //only columns, no the indexes column
+ } //foreach $aColumns
+
+
+ //now check the indexes of table
+ if (isset( $aNewSchema[$sTableName]['INDEXES'] )) {
+ foreach ($aNewSchema[$sTableName]['INDEXES'] as $indexName => $indexFields) {
+ if (! isset( $aOldSchema[$sTableName]['INDEXES'][$indexName] )) {
+ if (! isset( $aChanges['tablesWithNewIndex'][$sTableName] )) {
+ $aChanges['tablesWithNewIndex'][$sTableName] = array ();
+ }
+ $aChanges['tablesWithNewIndex'][$sTableName][$indexName] = $indexFields;
+ } else {
+ if ($aOldSchema[$sTableName]['INDEXES'][$indexName] != $indexFields) {
+ if (! isset( $aChanges['tablesToAlterIndex'][$sTableName] )) {
+ $aChanges['tablesToAlterIndex'][$sTableName] = array ();
+ }
+ $aChanges['tablesToAlterIndex'][$sTableName][$indexName] = $indexFields;
+ }
+ }
+ }
+ }
+ } //for-else table exists
+ } //for new schema
+ return $aChanges;
+ }
+
+ function getEmailConfiguration ()
+ {
+ G::LoadClass( 'configuration' );
+ $conf = new Configurations();
+ $config = $conf->load( 'Emails' );
+
+ return $config;
+ }
+
+ function getSkingList ()
+ {
+ //Create Skins custom folder if it doesn't exists
+ if (! is_dir( PATH_CUSTOM_SKINS )) {
+ G::verifyPath( PATH_CUSTOM_SKINS, true );
+ }
+
+ //Get Skin Config files
+ $skinListArray = array ();
+ $customSkins = glob( PATH_CUSTOM_SKINS . "*/config.xml" );
+
+ // getting al base skins
+ $baseSkins = glob( G::ExpandPath( "skinEngine" ) . '*/config.xml' );
+
+ // filtering no public skins (uxs, simplified)
+ foreach ($baseSkins as $i => $skinName) {
+ if (strpos( $skinName, 'simplified' ) !== false || strpos( $skinName, 'uxs' ) !== false) {
+ unset( $baseSkins[$i] );
}
}
- }
- // For each city, have a comma separated list of all possible timezones for that city.
- foreach( $cities as $key => $value )
- $cities[$key] = join( ', ', $value);
+ $customSkins = array_merge( $baseSkins, $customSkins );
- // Only keep one city (the first and also most important) for each set of possibilities.
- $cities = array_unique( $cities );
+ //Read and parse each Configuration File
+ foreach ($customSkins as $key => $configInformation) {
+ $folderId = basename( dirname( $configInformation ) );
- // Sort by area/city name.
- ksort( $cities );
-
- return $cities;
- }
-
- public static function getSystemConfiguration($globalIniFile = '', $wsIniFile = '', $wsName = '')
- {
- $readGlobalIniFile = false;
- $readWsIniFile = false;
-
- if (empty($globalIniFile)) {
- $globalIniFile = PATH_CORE . 'config' . PATH_SEP . 'env.ini';
- }
-
- if (empty($wsIniFile)) {
- if (defined('PATH_DB')) { // if we're on a valid workspace env.
- if (empty($wsName)) {
- $uriParts = explode('/', getenv("REQUEST_URI"));
-
- if (isset($uriParts[1])) {
- if (substr($uriParts[1], 0, 3 ) == 'sys') {
- $wsName = substr($uriParts[1], 3);
+ if ($folderId == 'base') {
+ $folderId = 'classic';
+ }
+
+ $xmlConfiguration = file_get_contents( $configInformation );
+ $xmlConfigurationObj = G::xmlParser( $xmlConfiguration );
+
+ if (isset( $xmlConfigurationObj->result['skinConfiguration'] )) {
+ $skinInformationArray = $skinFilesArray = $xmlConfigurationObj->result['skinConfiguration']['__CONTENT__']['information']['__CONTENT__'];
+ $res = array ();
+ $res['SKIN_FOLDER_ID'] = strtolower( $folderId );
+
+ foreach ($skinInformationArray as $keyInfo => $infoValue) {
+ $res['SKIN_' . strtoupper( $keyInfo )] = $infoValue['__VALUE__'];
+ }
+
+ $skinListArray['skins'][] = $res;
}
- }
}
- $wsIniFile = PATH_DB . $wsName . PATH_SEP . 'env.ini';
- }
+
+ $skinListArray['currentSkin'] = SYS_SKIN;
+
+ return $skinListArray;
}
- $readGlobalIniFile = file_exists($globalIniFile) ? true : false;
- $readWsIniFile = file_exists($wsIniFile) ? true : false;
+ function getAllTimeZones ()
+ {
+ $timezones = DateTimeZone::listAbbreviations();
- if (isset($_SESSION['PROCESSMAKER_ENV'])) {
- $md5 = array();
+ $cities = array ();
+ foreach ($timezones as $key => $zones) {
+ foreach ($zones as $id => $zone) {
+ /**
+ * Only get timezones explicitely not part of "Others".
+ *
+ * @see http://www.php.net/manual/en/timezones.others.php
+ */
+ if (preg_match( '/^(America|Antartica|Arctic|Asia|Atlantic|Africa|Europe|Indian|Pacific)\//', $zone['timezone_id'] ) && $zone['timezone_id']) {
+ $cities[$zone['timezone_id']][] = $key;
+ }
+ }
+ }
- if ($readGlobalIniFile)
- $md5[] = md5_file($globalIniFile);
+ // For each city, have a comma separated list of all possible timezones for that city.
+ foreach ($cities as $key => $value)
+ $cities[$key] = join( ', ', $value );
- if ($readWsIniFile)
- $md5[] = md5_file($wsIniFile);
+ // Only keep one city (the first and also most important) for each set of possibilities.
+ $cities = array_unique( $cities );
- $hash = implode('-', $md5);
+ // Sort by area/city name.
+ ksort( $cities );
- if ($_SESSION['PROCESSMAKER_ENV_HASH'] === $hash) {
- $_SESSION['PROCESSMAKER_ENV']['from_cache'] = 1;
- return $_SESSION['PROCESSMAKER_ENV'];
- }
+ return $cities;
}
- // default configuration
- $config = array(
- 'debug' => 0,
- 'debug_sql' => 0,
- 'debug_time' => 0,
- 'debug_calendar' => 0,
- 'wsdl_cache' => 1,
- 'memory_limit' => '128M',
- 'time_zone' => 'America/New_York',
- 'memcached' => 0,
- 'memcached_server' => '',
- 'default_skin' => 'classic',
- 'default_lang' => 'en',
- 'proxy_host' => '',
- 'proxy_port' => '',
- 'proxy_user' => '',
- 'proxy_pass' => ''
- );
+ public static function getSystemConfiguration ($globalIniFile = '', $wsIniFile = '', $wsName = '')
+ {
+ $readGlobalIniFile = false;
+ $readWsIniFile = false;
- // read the global env.ini configuration file
- if ($readGlobalIniFile && ($globalConf = @parse_ini_file($globalIniFile)) !== false) {
- $config = array_merge($config, $globalConf);
+ if (empty( $globalIniFile )) {
+ $globalIniFile = PATH_CORE . 'config' . PATH_SEP . 'env.ini';
+ }
+
+ if (empty( $wsIniFile )) {
+ if (defined( 'PATH_DB' )) { // if we're on a valid workspace env.
+ if (empty( $wsName )) {
+ $uriParts = explode( '/', getenv( "REQUEST_URI" ) );
+
+ if (isset( $uriParts[1] )) {
+ if (substr( $uriParts[1], 0, 3 ) == 'sys') {
+ $wsName = substr( $uriParts[1], 3 );
+ }
+ }
+ }
+ $wsIniFile = PATH_DB . $wsName . PATH_SEP . 'env.ini';
+ }
+ }
+
+ $readGlobalIniFile = file_exists( $globalIniFile ) ? true : false;
+ $readWsIniFile = file_exists( $wsIniFile ) ? true : false;
+
+ if (isset( $_SESSION['PROCESSMAKER_ENV'] )) {
+ $md5 = array ();
+
+ if ($readGlobalIniFile)
+ $md5[] = md5_file( $globalIniFile );
+
+ if ($readWsIniFile)
+ $md5[] = md5_file( $wsIniFile );
+
+ $hash = implode( '-', $md5 );
+
+ if ($_SESSION['PROCESSMAKER_ENV_HASH'] === $hash) {
+ $_SESSION['PROCESSMAKER_ENV']['from_cache'] = 1;
+ return $_SESSION['PROCESSMAKER_ENV'];
+ }
+ }
+
+ // default configuration
+ $config = array ('debug' => 0,'debug_sql' => 0,'debug_time' => 0,'debug_calendar' => 0,'wsdl_cache' => 1,'memory_limit' => '128M','time_zone' => 'America/New_York','memcached' => 0,'memcached_server' => '','default_skin' => 'classic','default_lang' => 'en','proxy_host' => '','proxy_port' => '','proxy_user' => '','proxy_pass' => ''
+ );
+
+ // read the global env.ini configuration file
+ if ($readGlobalIniFile && ($globalConf = @parse_ini_file( $globalIniFile )) !== false) {
+ $config = array_merge( $config, $globalConf );
+ }
+
+ // Workspace environment configuration
+ if ($readWsIniFile && ($wsConf = @parse_ini_file( $wsIniFile )) !== false) {
+ $config = array_merge( $config, $wsConf );
+ }
+
+ // validation debug config, only binary value is valid; debug = 1, to enable
+ $config['debug'] = $config['debug'] == 1 ? 1 : 0;
+
+ if ($config['proxy_pass'] != '') {
+ $config['proxy_pass'] = G::decrypt( $config['proxy_pass'], 'proxy_pass' );
+ }
+
+ $md5 = array ();
+ if ($readGlobalIniFile)
+ $md5[] = md5_file( $globalIniFile );
+
+ if ($readWsIniFile)
+ $md5[] = md5_file( $wsIniFile );
+
+ $hash = implode( '-', $md5 );
+
+ $_SESSION['PROCESSMAKER_ENV'] = $config;
+ $_SESSION['PROCESSMAKER_ENV_HASH'] = $hash;
+
+ return $config;
}
- // Workspace environment configuration
- if ($readWsIniFile && ($wsConf = @parse_ini_file($wsIniFile)) !== false) {
- $config = array_merge($config, $wsConf);
+ function updateIndexFile ($conf)
+ {
+ if (! file_exists( PATH_HTML . 'index.html' )) {
+ throw new Exception( 'The public index file "' . PATH_HTML . 'index.html" does not exist!' );
+ } else {
+ if (! is_writable( PATH_HTML . 'index.html' )) {
+ throw new Exception( 'The index.html file is not writable on workflow/public_html directory.' );
+ }
+ }
+
+ $content = file_get_contents( PATH_HTML . 'index.html' );
+ $result = false;
+
+ $patt = '//';
+
+ @preg_match( $patt, $content, $match );
+
+ if (is_array( $match ) && count( $match ) > 0 && isset( $match[1] )) {
+ $newUrl = 'sys/' . $conf['lang'] . '/' . $conf['skin'] . '/login/login';
+
+ $newMetaStr = str_replace( $match[1], $newUrl, $match[0] );
+ $newContent = str_replace( $match[0], $newMetaStr, $content );
+
+ $result = (@file_put_contents( PATH_HTML . 'index.html', $newContent ) !== false);
+ }
+
+ return $result;
}
- // validation debug config, only binary value is valid; debug = 1, to enable
- $config['debug'] = $config['debug'] == 1 ? 1 : 0;
+ function solrEnv ($sysName = '')
+ {
+ if (empty( $sysName )) {
+ $conf = System::getSystemConfiguration();
+ } else {
+ $conf = System::getSystemConfiguration( '', '', $sysName );
+ }
- if ($config['proxy_pass'] != '') {
- $config['proxy_pass'] = G::decrypt($config['proxy_pass'], 'proxy_pass');
+ if (! isset( $conf['solr_enabled'] ) || ! isset( $conf['solr_host'] ) || ! isset( $conf['solr_instance'] )) {
+ return false;
+ }
+
+ if ($conf['solr_enabled']) {
+ return array ('solr_enabled' => $conf['solr_enabled'],'solr_host' => $conf['solr_host'],'solr_instance' => $conf['solr_instance']
+ );
+ }
+
+ return false;
}
- $md5 = array();
- if ($readGlobalIniFile)
- $md5[] = md5_file($globalIniFile);
-
- if ($readWsIniFile)
- $md5[] = md5_file($wsIniFile);
-
- $hash = implode('-', $md5);
-
- $_SESSION['PROCESSMAKER_ENV'] = $config;
- $_SESSION['PROCESSMAKER_ENV_HASH'] = $hash;
-
- return $config;
- }
-
- function updateIndexFile($conf)
- {
- if (!file_exists(PATH_HTML . 'index.html')) {
- throw new Exception('The public index file "'.PATH_HTML . 'index.html" does not exist!');
- }
- else {
- if (!is_writable(PATH_HTML . 'index.html')) {
- throw new Exception('The index.html file is not writable on workflow/public_html directory.');
- }
- }
-
- $content = file_get_contents(PATH_HTML . 'index.html');
- $result = false;
-
- $patt = '//';
-
- @preg_match($patt, $content, $match);
-
- if (is_array($match) && count($match) > 0 && isset($match[1])) {
- $newUrl = 'sys/'.$conf['lang'].'/'.$conf['skin'].'/login/login';
-
- $newMetaStr = str_replace($match[1], $newUrl, $match[0]);
- $newContent = str_replace($match[0], $newMetaStr, $content);
-
- $result = (@file_put_contents(PATH_HTML . 'index.html', $newContent) !== false);
- }
-
- return $result;
- }
-
- function solrEnv($sysName = '')
- {
- if (empty($sysName)) {
- $conf = System::getSystemConfiguration();
- }
- else {
- $conf = System::getSystemConfiguration('', '', $sysName);
- }
-
- if (!isset($conf['solr_enabled']) || !isset($conf['solr_host']) || !isset($conf['solr_instance'])) {
- return false;
- }
-
- if ($conf['solr_enabled']) {
- return array(
- 'solr_enabled' => $conf['solr_enabled'],
- 'solr_host' => $conf['solr_host'],
- 'solr_instance' => $conf['solr_instance']
- );
- }
-
- return false;
- }
-
}// end System class
diff --git a/workflow/engine/classes/class.tasks.php b/workflow/engine/classes/class.tasks.php
index f15786669..fbb2eda83 100755
--- a/workflow/engine/classes/class.tasks.php
+++ b/workflow/engine/classes/class.tasks.php
@@ -1,6 +1,7 @@
.
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
@@ -38,322 +39,329 @@ require_once 'classes/model/Gateway.php';
/**
* Tasks - Tasks class
+ *
* @package workflow.engine.ProcessMaker
* @author Julio Cesar Laura Avenda�o
* @copyright 2007 COLOSA
*/
-class Tasks
+class Tasks
{
- /**
- * Get the assigned groups of a task
- * @param string $sTaskUID
- * @param integer $iType
- * @return array
- */
- public function getGroupsOfTask($sTaskUID, $iType)
- {
- try {
- $aGroups = array();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addJoin(GroupwfPeer::GRP_UID, TaskUserPeer::USR_UID, Criteria::LEFT_JOIN);
- $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID);
- $oCriteria->add(TaskUserPeer::TU_TYPE, $iType);
- $oCriteria->add(TaskUserPeer::TU_RELATION, 2);
- $oCriteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
- $oDataset = GroupwfPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $aGroups[] = $aRow;
- $oDataset->next();
- }
- return $aGroups;
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Get all tasks for any Process
- * @param string $sProUid
- * @return array
- */
- public function getAllTasks($sProUid)
- {
- try {
- $aTasks = array();
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(TaskPeer::PRO_UID, $sProUid);
- $oDataset = TaskPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oTask = new Task();
- $aTasks[] = $oTask->Load($aRow['TAS_UID']);
- $oDataset->next();
- }
- return $aTasks;
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * creates row tasks from an Task Array
- * @param string $aTasks
- * @return array
- */
- public function createTaskRows( $aTask )
- {
- foreach ( $aTask as $key => $row ) {
- $oTask = new Task();
- if($oTask->taskExists ($row['TAS_UID']))
- $oTask->remove($row['TAS_UID']);
- $res = $oTask->createRow($row);
- }
- return;
- }
-
- /**
- * updates row tasks from an Task Array
- * @param string $aTasks
- * @return array
- */
- public function updateTaskRows( $aTask )
- {
- foreach ( $aTask as $key => $row ) {
- $oTask = new Task();
- if($oTask->taskExists ($row['TAS_UID']))
- $oTask->remove($row['TAS_UID']);
- else
- $res = $oTask->update($row);
- }
- return;
- }
-
- /**
- * Get all Routes for any Process
- * @param string $sProUid
- * @return array
- */
- public function getAllRoutes($sProUid)
- {
- try {
- $aRoutes = array();
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(RoutePeer::PRO_UID, $sProUid);
- $oDataset = RoutePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $aRoutes[] = $aRow;
- $oDataset->next();
- }
- return $aRoutes;
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * creates row tasks from an Route Array
- * @param string $aTasks
- * @return array
- */
- public function createRouteRows( $aRoutes )
- {
- $routeID = array();
- $aField = array();
- $taskParallel = '';
- $taskSecJoin = '';
- $taskEvaluate = '';
- $taskParallelEv = '';
- $taskSelect = '';
- $taskDiscriminator = '';
- foreach ( $aRoutes as $key => $row ) {
- $sRouteType = $row['ROU_TYPE'];
- $oRoute = new Route();
- $oProcessMap = new processMap();
- $oTask = new Task();
- $oEvent = new Event();
- //unset ($row['ROU_UID']);
-
- //Saving Gateway into the GATEWAY table
- $idTask = $row['TAS_UID'];
- $nextTask = $row['ROU_NEXT_TASK'];
- if($nextTask == "-1"){
- $end=1;
- }
- if($sRouteType != 'SEQUENTIAL'){
- switch($sRouteType){
- case 'PARALLEL':
- if($idTask != $taskParallel){
- $taskParallel = $idTask;
-
- $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']);
+ /**
+ * Get the assigned groups of a task
+ *
+ * @param string $sTaskUID
+ * @param integer $iType
+ * @return array
+ */
+ public function getGroupsOfTask ($sTaskUID, $iType)
+ {
+ try {
+ $aGroups = array ();
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addJoin( GroupwfPeer::GRP_UID, TaskUserPeer::USR_UID, Criteria::LEFT_JOIN );
+ $oCriteria->add( TaskUserPeer::TAS_UID, $sTaskUID );
+ $oCriteria->add( TaskUserPeer::TU_TYPE, $iType );
+ $oCriteria->add( TaskUserPeer::TU_RELATION, 2 );
+ $oCriteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' );
+ $oDataset = GroupwfPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aGroups[] = $aRow;
+ $oDataset->next();
}
- break;
- case 'SEC-JOIN':
- if($nextTask != $taskSecJoin){
- $taskSecJoin = $nextTask;
- $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']);
- }
- break;
- case 'EVALUATE':
- if($idTask != $taskEvaluate){
- $taskEvaluate = $idTask;
- $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']);
- }
- break;
- case 'PARALLEL-BY-EVALUATION':
- if($idTask != $taskParallelEv){
- $taskParallelEv = $idTask;
- $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']);
- }
- break;
- case 'SELECT':
- if($idTask != $taskSelect){
- $taskSelect = $idTask;
- $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']);
- }
- break;
- case 'DISCRIMINATOR':
- if($nextTask != $taskDiscriminator){
- $taskDiscriminator = $nextTask;
- $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']);
- }
- break;
- }
- $row['GAT_UID'] = $sGatewayUID;
- }
-
- if($oRoute->routeExists($row['ROU_UID']))
- $oRoute->remove($row['ROU_UID']);
-
- $routeID = $oRoute->create($row);
-
- //saving end event while import old processes
- if(isset($end) && $end==1){
- if(! $oEvent->existsByTaskUidFrom($idTask)) {
- if($sRouteType == "SEQUENTIAL"){
- $aTaskDetails = $oTask->load($idTask);
- $positionX = $aTaskDetails['TAS_POSX'] + $aTaskDetails['TAS_WIDTH']/2;
- $positionY = $aTaskDetails['TAS_POSY'] + $aTaskDetails['TAS_HEIGHT'] + 10;
-
- $aData['PRO_UID'] = $row['PRO_UID'];
- $aData['EVN_TYPE'] = 'bpmnEventEmptyEnd';
- $aData['EVN_POSX'] = $positionX;
- $aData['EVN_POSY'] = $positionY;
- $aData['EVN_TAS_UID_FROM'] = $idTask;
- $aData['EVN_STATUS'] = 'ACTIVE';
- $aData['EVN_RELATED_TO'] = 'MULTIPLE';
- $aData['EVN_WHEN'] = '1';
- $aData['EVN_ACTION'] = '';
- $sEvn_uid = $oEvent->create($aData);
-
- $aField['ROU_UID'] = $routeID;
- $aField['ROU_EVN_UID'] = $sEvn_uid;
- $oRoute->update($aField);
- $end = 0;
- }
+ return $aGroups;
+ } catch (Exception $oError) {
+ throw ($oError);
}
- }
-
}
- return;
- }
- /**
- * updates row tasks from an Route Array
- * @param string $aTasks
- * @return array
- */
- public function updateRouteRows( $aRoutes )
- {
- foreach ( $aRoutes as $key => $row ) {
- $oRoute = new Route();
- //krumo ($row);
- if(is_array($oRoute->load($row['ROU_UID'])))
- $oRoute->remove($row['ROU_UID']);
- else
- $res = $oRoute->update($row);
+ /**
+ * Get all tasks for any Process
+ *
+ * @param string $sProUid
+ * @return array
+ */
+ public function getAllTasks ($sProUid)
+ {
+ try {
+ $aTasks = array ();
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( TaskPeer::PRO_UID, $sProUid );
+ $oDataset = TaskPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oTask = new Task();
+ $aTasks[] = $oTask->Load( $aRow['TAS_UID'] );
+ $oDataset->next();
+ }
+ return $aTasks;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- return;
- }
- /**
- * Get the assigned users of a task
- * @param string $sTaskUID
- * @param integer $iType
- * @return array
- */
- public function getUsersOfTask($sTaskUID, $iType)
- {
- try {
- $aUsers = array();
- $oCriteria = new Criteria('workflow');
- $oCriteria->addJoin(UsersPeer::USR_UID, TaskUserPeer::USR_UID, Criteria::LEFT_JOIN);
- $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID);
- $oCriteria->add(TaskUserPeer::TU_TYPE, $iType);
- $oCriteria->add(TaskUserPeer::TU_RELATION, 1);
- $oDataset = UsersPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $aUsers[] = $aRow;
- $oDataset->next();
- }
- return $aUsers;
+ /**
+ * creates row tasks from an Task Array
+ *
+ * @param string $aTasks
+ * @return array
+ */
+ public function createTaskRows ($aTask)
+ {
+ foreach ($aTask as $key => $row) {
+ $oTask = new Task();
+ if ($oTask->taskExists( $row['TAS_UID'] ))
+ $oTask->remove( $row['TAS_UID'] );
+ $res = $oTask->createRow( $row );
+ }
+ return;
}
- catch (Exception $oError) {
- throw($oError);
- }
- }
- /**
- * Delete a task
- * @param string $sTaskUID
- * @return void
- */
- function deleteTask($sTaskUID = '')
- {
- try {
- //Instance classes
- $oTask = new Task();
- $oTasks = new Tasks();
- $oTaskUser = new TaskUser();
- $oStep = new Step();
- $oStepTrigger = new StepTrigger();
- //Get task information
- $aFields = $oTask->load($sTaskUID);
- //Delete routes
- $oTasks->deleteAllRoutesOfTask($aFields['PRO_UID'], $sTaskUID, true);
- //Delete gateways
- $oTasks->deleteAllGatewayOfTask($aFields['PRO_UID'], $sTaskUID, true);
- //Delete the users assigned to task
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID);
- $oDataset1 = TaskUserPeer::doSelectRS($oCriteria);
- $oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset1->next();
- while ($aRow1 = $oDataset1->getRow()) {
- $oTaskUser->remove($aRow1['TAS_UID'], $aRow1['USR_UID'], $aRow1['TU_TYPE'], $aRow1['TU_RELATION']);
- $oDataset1->next();
- }
- //Delete the steps of task
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(StepPeer::TAS_UID, $sTaskUID);
- $oDataset1 = StepPeer::doSelectRS($oCriteria);
- $oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset1->next();
- while ($aRow1 = $oDataset1->getRow()) {
- //Delete the triggers assigned to step
- /*$oCriteria = new Criteria('workflow');
+ /**
+ * updates row tasks from an Task Array
+ *
+ * @param string $aTasks
+ * @return array
+ */
+ public function updateTaskRows ($aTask)
+ {
+ foreach ($aTask as $key => $row) {
+ $oTask = new Task();
+ if ($oTask->taskExists( $row['TAS_UID'] ))
+ $oTask->remove( $row['TAS_UID'] );
+ else
+ $res = $oTask->update( $row );
+ }
+ return;
+ }
+
+ /**
+ * Get all Routes for any Process
+ *
+ * @param string $sProUid
+ * @return array
+ */
+ public function getAllRoutes ($sProUid)
+ {
+ try {
+ $aRoutes = array ();
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( RoutePeer::PRO_UID, $sProUid );
+ $oDataset = RoutePeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aRoutes[] = $aRow;
+ $oDataset->next();
+ }
+ return $aRoutes;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * creates row tasks from an Route Array
+ *
+ * @param string $aTasks
+ * @return array
+ */
+ public function createRouteRows ($aRoutes)
+ {
+ $routeID = array ();
+ $aField = array ();
+ $taskParallel = '';
+ $taskSecJoin = '';
+ $taskEvaluate = '';
+ $taskParallelEv = '';
+ $taskSelect = '';
+ $taskDiscriminator = '';
+ foreach ($aRoutes as $key => $row) {
+ $sRouteType = $row['ROU_TYPE'];
+ $oRoute = new Route();
+ $oProcessMap = new processMap();
+ $oTask = new Task();
+ $oEvent = new Event();
+ //unset ($row['ROU_UID']);
+
+
+ //Saving Gateway into the GATEWAY table
+ $idTask = $row['TAS_UID'];
+ $nextTask = $row['ROU_NEXT_TASK'];
+ if ($nextTask == "-1") {
+ $end = 1;
+ }
+ if ($sRouteType != 'SEQUENTIAL') {
+ switch ($sRouteType) {
+ case 'PARALLEL':
+ if ($idTask != $taskParallel) {
+ $taskParallel = $idTask;
+
+ $sGatewayUID = $oProcessMap->saveNewGateway( $row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK'] );
+ }
+ break;
+ case 'SEC-JOIN':
+ if ($nextTask != $taskSecJoin) {
+ $taskSecJoin = $nextTask;
+ $sGatewayUID = $oProcessMap->saveNewGateway( $row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK'] );
+ }
+ break;
+ case 'EVALUATE':
+ if ($idTask != $taskEvaluate) {
+ $taskEvaluate = $idTask;
+ $sGatewayUID = $oProcessMap->saveNewGateway( $row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK'] );
+ }
+ break;
+ case 'PARALLEL-BY-EVALUATION':
+ if ($idTask != $taskParallelEv) {
+ $taskParallelEv = $idTask;
+ $sGatewayUID = $oProcessMap->saveNewGateway( $row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK'] );
+ }
+ break;
+ case 'SELECT':
+ if ($idTask != $taskSelect) {
+ $taskSelect = $idTask;
+ $sGatewayUID = $oProcessMap->saveNewGateway( $row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK'] );
+ }
+ break;
+ case 'DISCRIMINATOR':
+ if ($nextTask != $taskDiscriminator) {
+ $taskDiscriminator = $nextTask;
+ $sGatewayUID = $oProcessMap->saveNewGateway( $row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK'] );
+ }
+ break;
+ }
+ $row['GAT_UID'] = $sGatewayUID;
+ }
+
+ if ($oRoute->routeExists( $row['ROU_UID'] ))
+ $oRoute->remove( $row['ROU_UID'] );
+
+ $routeID = $oRoute->create( $row );
+
+ //saving end event while import old processes
+ if (isset( $end ) && $end == 1) {
+ if (! $oEvent->existsByTaskUidFrom( $idTask )) {
+ if ($sRouteType == "SEQUENTIAL") {
+ $aTaskDetails = $oTask->load( $idTask );
+ $positionX = $aTaskDetails['TAS_POSX'] + $aTaskDetails['TAS_WIDTH'] / 2;
+ $positionY = $aTaskDetails['TAS_POSY'] + $aTaskDetails['TAS_HEIGHT'] + 10;
+
+ $aData['PRO_UID'] = $row['PRO_UID'];
+ $aData['EVN_TYPE'] = 'bpmnEventEmptyEnd';
+ $aData['EVN_POSX'] = $positionX;
+ $aData['EVN_POSY'] = $positionY;
+ $aData['EVN_TAS_UID_FROM'] = $idTask;
+ $aData['EVN_STATUS'] = 'ACTIVE';
+ $aData['EVN_RELATED_TO'] = 'MULTIPLE';
+ $aData['EVN_WHEN'] = '1';
+ $aData['EVN_ACTION'] = '';
+ $sEvn_uid = $oEvent->create( $aData );
+
+ $aField['ROU_UID'] = $routeID;
+ $aField['ROU_EVN_UID'] = $sEvn_uid;
+ $oRoute->update( $aField );
+ $end = 0;
+ }
+ }
+ }
+
+ }
+ return;
+ }
+
+ /**
+ * updates row tasks from an Route Array
+ *
+ * @param string $aTasks
+ * @return array
+ */
+ public function updateRouteRows ($aRoutes)
+ {
+ foreach ($aRoutes as $key => $row) {
+ $oRoute = new Route();
+ //krumo ($row);
+ if (is_array( $oRoute->load( $row['ROU_UID'] ) ))
+ $oRoute->remove( $row['ROU_UID'] );
+ else
+ $res = $oRoute->update( $row );
+ }
+ return;
+ }
+
+ /**
+ * Get the assigned users of a task
+ *
+ * @param string $sTaskUID
+ * @param integer $iType
+ * @return array
+ */
+ public function getUsersOfTask ($sTaskUID, $iType)
+ {
+ try {
+ $aUsers = array ();
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addJoin( UsersPeer::USR_UID, TaskUserPeer::USR_UID, Criteria::LEFT_JOIN );
+ $oCriteria->add( TaskUserPeer::TAS_UID, $sTaskUID );
+ $oCriteria->add( TaskUserPeer::TU_TYPE, $iType );
+ $oCriteria->add( TaskUserPeer::TU_RELATION, 1 );
+ $oDataset = UsersPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aUsers[] = $aRow;
+ $oDataset->next();
+ }
+ return $aUsers;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * Delete a task
+ *
+ * @param string $sTaskUID
+ * @return void
+ */
+ function deleteTask ($sTaskUID = '')
+ {
+ try {
+ //Instance classes
+ $oTask = new Task();
+ $oTasks = new Tasks();
+ $oTaskUser = new TaskUser();
+ $oStep = new Step();
+ $oStepTrigger = new StepTrigger();
+ //Get task information
+ $aFields = $oTask->load( $sTaskUID );
+ //Delete routes
+ $oTasks->deleteAllRoutesOfTask( $aFields['PRO_UID'], $sTaskUID, true );
+ //Delete gateways
+ $oTasks->deleteAllGatewayOfTask( $aFields['PRO_UID'], $sTaskUID, true );
+ //Delete the users assigned to task
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( TaskUserPeer::TAS_UID, $sTaskUID );
+ $oDataset1 = TaskUserPeer::doSelectRS( $oCriteria );
+ $oDataset1->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset1->next();
+ while ($aRow1 = $oDataset1->getRow()) {
+ $oTaskUser->remove( $aRow1['TAS_UID'], $aRow1['USR_UID'], $aRow1['TU_TYPE'], $aRow1['TU_RELATION'] );
+ $oDataset1->next();
+ }
+ //Delete the steps of task
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( StepPeer::TAS_UID, $sTaskUID );
+ $oDataset1 = StepPeer::doSelectRS( $oCriteria );
+ $oDataset1->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset1->next();
+ while ($aRow1 = $oDataset1->getRow()) {
+ //Delete the triggers assigned to step
+ /*$oCriteria = new Criteria('workflow');
$oCriteria->add(StepTriggerPeer::STEP_UID, $aRow1['STEP_UID']);
$oDataset2 = StepTriggerPeer::doSelectRS($oCriteria);
$oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
@@ -362,168 +370,170 @@ class Tasks
$oStepTrigger->remove($aRow2['STEP_UID'], $aRow2['TAS_UID'], $aRow2['TRI_UID'], $aRow2['ST_TYPE']);
$oDataset2->next();
}*/
- $oStep->remove($aRow1['STEP_UID']);
- $oDataset1->next();
- }
- //Delete step triggers
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(StepTriggerPeer::TAS_UID, $sTaskUID);
- StepTriggerPeer::doDelete($oCriteria);
- //Delete permissions
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(ObjectPermissionPeer::TAS_UID, $sTaskUID);
- ObjectPermissionPeer::doDelete($oCriteria);
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(ObjectPermissionPeer::OP_TASK_SOURCE, $sTaskUID);
- ObjectPermissionPeer::doDelete($oCriteria);
- //Delete task
- $oTask->remove($sTaskUID);
- //Delete cases schedulers added by krlos
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(CaseSchedulerPeer::TAS_UID, $sTaskUID);
- CaseSchedulerPeer::doDelete($oCriteria);
+ $oStep->remove( $aRow1['STEP_UID'] );
+ $oDataset1->next();
+ }
+ //Delete step triggers
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( StepTriggerPeer::TAS_UID, $sTaskUID );
+ StepTriggerPeer::doDelete( $oCriteria );
+ //Delete permissions
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( ObjectPermissionPeer::TAS_UID, $sTaskUID );
+ ObjectPermissionPeer::doDelete( $oCriteria );
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( ObjectPermissionPeer::OP_TASK_SOURCE, $sTaskUID );
+ ObjectPermissionPeer::doDelete( $oCriteria );
+ //Delete task
+ $oTask->remove( $sTaskUID );
+ //Delete cases schedulers added by krlos
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( CaseSchedulerPeer::TAS_UID, $sTaskUID );
+ CaseSchedulerPeer::doDelete( $oCriteria );
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- catch (Exception $oError) {
- throw($oError);
- }
- }
- /**
- * Delete all routes from a task
- * @param string $sProcessUID
- * @param string $sTaskUID
- * @return boolean
- */
- public function deleteAllRoutesOfTask($sProcessUID = '', $sTaskUID = '', $bAll = false)
- {
- try {
- $oProcess = new Process();
- $aFields = $oProcess->load($sProcessUID);
- $oTask = new Task();
- $aFields = $oTask->load($sTaskUID);
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
- $oCriteria->add(RoutePeer::TAS_UID, $sTaskUID);
- RoutePeer::doDelete($oCriteria);
- if ($bAll) {
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
- $oCriteria->add(RoutePeer::ROU_NEXT_TASK, $sTaskUID);
- RoutePeer::doDelete($oCriteria);
- }
- return true;
+ /**
+ * Delete all routes from a task
+ *
+ * @param string $sProcessUID
+ * @param string $sTaskUID
+ * @return boolean
+ */
+ public function deleteAllRoutesOfTask ($sProcessUID = '', $sTaskUID = '', $bAll = false)
+ {
+ try {
+ $oProcess = new Process();
+ $aFields = $oProcess->load( $sProcessUID );
+ $oTask = new Task();
+ $aFields = $oTask->load( $sTaskUID );
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( RoutePeer::PRO_UID, $sProcessUID );
+ $oCriteria->add( RoutePeer::TAS_UID, $sTaskUID );
+ RoutePeer::doDelete( $oCriteria );
+ if ($bAll) {
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( RoutePeer::PRO_UID, $sProcessUID );
+ $oCriteria->add( RoutePeer::ROU_NEXT_TASK, $sTaskUID );
+ RoutePeer::doDelete( $oCriteria );
+ }
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- catch (Exception $oError) {
- throw($oError);
- }
- }
- /**
- * Get all gateways for any Process
- * @param string $sProUid
- * @return array
- */
- public function getAllGateways($sProUid)
- {
- try {
- $aGateways = array();
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(GatewayPeer::PRO_UID, $sProUid);
- $oDataset = GatewayPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oGateway = new Gateway();
- $aGateways[] = $oGateway->load($aRow['GAT_UID']);
- $oDataset->next();
- }
- return $aGateways;
+ /**
+ * Get all gateways for any Process
+ *
+ * @param string $sProUid
+ * @return array
+ */
+ public function getAllGateways ($sProUid)
+ {
+ try {
+ $aGateways = array ();
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( GatewayPeer::PRO_UID, $sProUid );
+ $oDataset = GatewayPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oGateway = new Gateway();
+ $aGateways[] = $oGateway->load( $aRow['GAT_UID'] );
+ $oDataset->next();
+ }
+ return $aGateways;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- catch (Exception $oError) {
- throw($oError);
- }
- }
- /**
- * creates row tasks from an Task Array
- * @param string $aTasks
- * @return array
- */
- public function createGatewayRows( $aGateway )
- {
- foreach ( $aGateway as $key => $row ) {
- $oGateway = new Gateway();
- if($oGateway->gatewayExists ($row['GAT_UID']))
- $oGateway->remove($row['GAT_UID']);
+ /**
+ * creates row tasks from an Task Array
+ *
+ * @param string $aTasks
+ * @return array
+ */
+ public function createGatewayRows ($aGateway)
+ {
+ foreach ($aGateway as $key => $row) {
+ $oGateway = new Gateway();
+ if ($oGateway->gatewayExists( $row['GAT_UID'] ))
+ $oGateway->remove( $row['GAT_UID'] );
- if($row['TAS_UID'] != '' && $row['GAT_NEXT_TASK'] != '')
- continue;
- else
- $res = $oGateway->createRow($row);
+ if ($row['TAS_UID'] != '' && $row['GAT_NEXT_TASK'] != '')
+ continue;
+ else
+ $res = $oGateway->createRow( $row );
+ }
+ return;
}
- return;
- }
- /**
- * Delete all routes from a task
- * @param string $sProcessUID
- * @param string $sTaskUID
- * @return boolean
- */
- public function deleteAllGatewayOfTask($sProcessUID = '', $sTaskUID = '', $bAll = false)
- {
- try {
- $oProcess = new Process();
- $aFields = $oProcess->load($sProcessUID);
- $oTask = new Task();
- $aFields = $oTask->load($sTaskUID);
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(GatewayPeer::PRO_UID, $sProcessUID);
- $oCriteria->add(GatewayPeer::TAS_UID, $sTaskUID);
- GatewayPeer::doDelete($oCriteria);
- if ($bAll) {
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(GatewayPeer::PRO_UID, $sProcessUID);
- $oCriteria->add(GatewayPeer::GAT_NEXT_TASK, $sTaskUID);
- GatewayPeer::doDelete($oCriteria);
- }
- return true;
+ /**
+ * Delete all routes from a task
+ *
+ * @param string $sProcessUID
+ * @param string $sTaskUID
+ * @return boolean
+ */
+ public function deleteAllGatewayOfTask ($sProcessUID = '', $sTaskUID = '', $bAll = false)
+ {
+ try {
+ $oProcess = new Process();
+ $aFields = $oProcess->load( $sProcessUID );
+ $oTask = new Task();
+ $aFields = $oTask->load( $sTaskUID );
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( GatewayPeer::PRO_UID, $sProcessUID );
+ $oCriteria->add( GatewayPeer::TAS_UID, $sTaskUID );
+ GatewayPeer::doDelete( $oCriteria );
+ if ($bAll) {
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( GatewayPeer::PRO_UID, $sProcessUID );
+ $oCriteria->add( GatewayPeer::GAT_NEXT_TASK, $sTaskUID );
+ GatewayPeer::doDelete( $oCriteria );
+ }
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Assign a user to task
- * @param string $sTaskUID
- * @param string $sUserUID
- * @param string $iType
- * @return integer
- */
- public function assignUser($sTaskUID = '', $sUserUID = '', $iType = '')
- {
- try {
- $oTaskUser = new TaskUser();
- return $oTaskUser->create(array('TAS_UID' => $sTaskUID, 'USR_UID' => $sUserUID, 'TU_TYPE' => $iType, 'TU_RELATION' => 1));
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
- /**
- * Assign a group to task
- * @param string $sTaskUID
- * @param string $sGroupUID
- * @param string $iType
- * @return integer
- */
- public function assignGroup($sTaskUID = '', $sGroupUID = '', $iType = '')
- {
- try {
- $oTaskUser = new TaskUser();
- /*$oCriteria = new Criteria('workflow');
+ /**
+ * Assign a user to task
+ *
+ * @param string $sTaskUID
+ * @param string $sUserUID
+ * @param string $iType
+ * @return integer
+ */
+ public function assignUser ($sTaskUID = '', $sUserUID = '', $iType = '')
+ {
+ try {
+ $oTaskUser = new TaskUser();
+ return $oTaskUser->create( array ('TAS_UID' => $sTaskUID,'USR_UID' => $sUserUID,'TU_TYPE' => $iType,'TU_RELATION' => 1
+ ) );
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * Assign a group to task
+ *
+ * @param string $sTaskUID
+ * @param string $sGroupUID
+ * @param string $iType
+ * @return integer
+ */
+ public function assignGroup ($sTaskUID = '', $sGroupUID = '', $iType = '')
+ {
+ try {
+ $oTaskUser = new TaskUser();
+ /*$oCriteria = new Criteria('workflow');
$oCriteria->add(GroupUserPeer::GRP_UID, $sGroupUID);
$oDataset = GroupUserPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
@@ -541,318 +551,317 @@ class Tasks
}
$oDataset->next();
}*/
- return $oTaskUser->create(array('TAS_UID' => $sTaskUID, 'USR_UID' => $sGroupUID, 'TU_TYPE' => $iType, 'TU_RELATION' => 2));
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
- /**
- * of the assign user of all the tasks
- * @param string $sUserUID
- * @return void
- */
- public function ofToAssignUserOfAllTasks($sUserUID = '')
- {
- try {
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(TaskUserPeer::USR_UID, $sUserUID);
- TaskUserPeer::doDelete($oCriteria);
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Of to assign a user from a task
- * @param string $sTaskUID
- * @param string $sUserUID
- * @param integer $iType
- * @return boolean
- */
- public function ofToAssignUser($sTaskUID = '', $sUserUID = '', $iType = 0)
- {
- try {
- $oTaskUser = new TaskUser();
- $oTaskUser->remove($sTaskUID, $sUserUID, $iType, 1);
- return true;
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Of to assign a group from a task
- * @param string $sTaskUID
- * @param string $sGroupUID
- * @param integer $iType
- * @return boolean
- */
- public function ofToAssignGroup($sTaskUID = '', $sGroupUID = '', $iType = 0)
- {
- try {
- $oTaskUser = new TaskUser();
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(GroupUserPeer::GRP_UID, $sGroupUID);
- $oDataset = GroupUserPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aGroupUser = $oDataset->getRow()) {
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID);
- $oCriteria->add(TaskUserPeer::USR_UID, $aGroupUser['USR_UID']);
- $oDataset2 = TaskUserPeer::doSelectRS($oCriteria);
- $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset2->next();
- $aRow = $oDataset2->getRow();
- if (is_array($aRow)) {
- $this->ofToAssignUser($sTaskUID, $aGroupUser['USR_UID'], $iType);
+ return $oTaskUser->create( array ('TAS_UID' => $sTaskUID,'USR_UID' => $sGroupUID,'TU_TYPE' => $iType,'TU_RELATION' => 2
+ ) );
+ } catch (Exception $oError) {
+ throw ($oError);
}
- $oDataset->next();
- }
- return $oTaskUser->remove($sTaskUID, $sGroupUID, $iType, 2);
}
- catch (Exception $oError) {
- throw($oError);
- }
- }
- /**
- * Get the assigned steps of a task
- * @param string $sTaskUID
- * @return array
- */
- public function getStepsOfTask($sTaskUID)
- {
- try {
- $aSteps = array();
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(StepPeer::TAS_UID, $sTaskUID);
- $oCriteria->addAscendingOrderByColumn(StepPeer::STEP_POSITION);
- $oDataset = StepPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $aSteps[] = $aRow;
- $oDataset->next();
- }
- return $aSteps;
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Return if exists building elements to add steps
- * @param string $sProcessUID
- * @return boolean
- */
- public function existsBuildingElements($sProcessUID)
- {
- try {
- $oCriteria = new Criteria('workflow');
- //$oCriteria->add(StepPeer::PRO_UID, $sProcessUID);
- //$oDataset = StepPeer::doSelectRS($oCriteria);
- //$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- //$oDataset->next();
- return true;
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Get all tasks for any Process
- * @param string $sProUid
- * @return array
- */
- public function getStartingTaskForUser($sProUid, $sUsrUid)
- {
- try {
- $aTasks = array();
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(TaskPeer::PRO_UID, $sProUid);
- //$oCriteria->add(TaskPeer::TAS_USER, $sUsrUid);
- $oCriteria->add(TaskPeer::TAS_START, 'TRUE');
- $oDataset = TaskPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $oTask = new Task();
- $aTasks[] = $oTask->Load($aRow['TAS_UID']);
- $oDataset->next();
- }
- return $aTasks;
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Verify the user assig in any task
- * @param string $sTaskUID
- * @return array
- */
- public function assignUsertoTask($sTaskUID)
- {
- try {
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(TaskUserPeer::USR_UID);
- $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID);
- $oDataset = TaskUserPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aRow = $oDataset->getRow();
- if(is_array($aRow))
- return 1;
- else
- return 0;
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Verify the user assig in task
- * @param string $sUsrUid, $sTaskUID
- * @return array
- */
- public function verifyUsertoTask($sUsrUid, $sTaskUID)
- {
- try {
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(TaskUserPeer::USR_UID);
- $oCriteria->addSelectColumn(TaskUserPeer::TAS_UID);
- $oCriteria->addSelectColumn(TaskUserPeer::TU_RELATION);
- $oCriteria->add(TaskUserPeer::TAS_UID, $sTaskUID);
- $oCriteria->add(TaskUserPeer::USR_UID, $sUsrUid);
- $oDataset = TaskUserPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aRow = $oDataset->getRow();
- if(is_array($aRow))
- return $aRow;
- else
- return $aRow;
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Get tasks that the usser is assigned
- * @param string $sUsrUID
- * @return array
- */
- public function getTasksThatUserIsAssigned($sUserUID)
- {
- try {
- $aTasks = array();
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(TaskUserPeer::USR_UID, $sUserUID);
- $oCriteria->add(TaskUserPeer::TU_RELATION, 1);
- $oDataset = TaskUserPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $aTasks[] = $aRow['TAS_UID'];
- $oDataset->next();
- }
- $aGroups = array();
- $oCriteria = new Criteria();
- $oCriteria->add(GroupwfPeer::GRP_UID, '', Criteria::NOT_EQUAL);
- $oCriteria->add(GroupUserPeer::USR_UID, $sUserUID);
- $oCriteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
- $oCriteria->addJoin(GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN);
- $oDataset = GroupwfPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $aGroups[] = $aRow['GRP_UID'];
- $oDataset->next();
- }
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(TaskUserPeer::USR_UID, $aGroups, Criteria::IN);
- $oCriteria->add(TaskUserPeer::TU_RELATION, 2);
- $oDataset = TaskUserPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- if (!in_array($aRow['TAS_UID'], $aTasks)) {
- $aTasks[] = $aRow['TAS_UID'];
+ /**
+ * of the assign user of all the tasks
+ *
+ * @param string $sUserUID
+ * @return void
+ */
+ public function ofToAssignUserOfAllTasks ($sUserUID = '')
+ {
+ try {
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( TaskUserPeer::USR_UID, $sUserUID );
+ TaskUserPeer::doDelete( $oCriteria );
+ } catch (Exception $oError) {
+ throw ($oError);
}
- $oDataset->next();
- }
- return $aTasks;
}
- catch (Exception $oError) {
- throw($oError);
- }
- }
- /**
- * Get Routes for any Process and any Task
- * @param string $sProUid, $sTaskUid
- * @return array
- * by Everth
- */
- public function getRoute($sProUid, $sTaskUid)
- {
- try {
- $aRoutes = array();
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(RoutePeer::PRO_UID, $sProUid);
- $oCriteria->add(RoutePeer::TAS_UID, $sTaskUid);
- $oDataset = RoutePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $aRoutes[] = $aRow;
- $oDataset->next();
- }
+ /**
+ * Of to assign a user from a task
+ *
+ * @param string $sTaskUID
+ * @param string $sUserUID
+ * @param integer $iType
+ * @return boolean
+ */
+ public function ofToAssignUser ($sTaskUID = '', $sUserUID = '', $iType = 0)
+ {
+ try {
+ $oTaskUser = new TaskUser();
+ $oTaskUser->remove( $sTaskUID, $sUserUID, $iType, 1 );
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
- return $aRoutes;
+ /**
+ * Of to assign a group from a task
+ *
+ * @param string $sTaskUID
+ * @param string $sGroupUID
+ * @param integer $iType
+ * @return boolean
+ */
+ public function ofToAssignGroup ($sTaskUID = '', $sGroupUID = '', $iType = 0)
+ {
+ try {
+ $oTaskUser = new TaskUser();
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( GroupUserPeer::GRP_UID, $sGroupUID );
+ $oDataset = GroupUserPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aGroupUser = $oDataset->getRow()) {
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( TaskUserPeer::TAS_UID, $sTaskUID );
+ $oCriteria->add( TaskUserPeer::USR_UID, $aGroupUser['USR_UID'] );
+ $oDataset2 = TaskUserPeer::doSelectRS( $oCriteria );
+ $oDataset2->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset2->next();
+ $aRow = $oDataset2->getRow();
+ if (is_array( $aRow )) {
+ $this->ofToAssignUser( $sTaskUID, $aGroupUser['USR_UID'], $iType );
+ }
+ $oDataset->next();
+ }
+ return $oTaskUser->remove( $sTaskUID, $sGroupUID, $iType, 2 );
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- catch (Exception $oError) {
- throw($oError);
- }
- }
-/**
- * Get Routes for any Process,route type,route next task
- * @param string $sProUid, $sTaskUid
- * @return array
- * by Girish
- */
- public function getRouteByType($sProUid, $sRouteNextTaskUid,$sRouteType)
- {
- try {
- $aRoutes = array();
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(RoutePeer::PRO_UID, $sProUid);
- $oCriteria->add(RoutePeer::ROU_NEXT_TASK, $sRouteNextTaskUid);
- $oCriteria->add(RoutePeer::ROU_TYPE, $sRouteType);
- $oDataset = RoutePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- $aRoutes[] = $aRow;
- $oDataset->next();
- }
+ /**
+ * Get the assigned steps of a task
+ *
+ * @param string $sTaskUID
+ * @return array
+ */
+ public function getStepsOfTask ($sTaskUID)
+ {
+ try {
+ $aSteps = array ();
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( StepPeer::TAS_UID, $sTaskUID );
+ $oCriteria->addAscendingOrderByColumn( StepPeer::STEP_POSITION );
+ $oDataset = StepPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aSteps[] = $aRow;
+ $oDataset->next();
+ }
+ return $aSteps;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
- return $aRoutes;
+ /**
+ * Return if exists building elements to add steps
+ *
+ * @param string $sProcessUID
+ * @return boolean
+ */
+ public function existsBuildingElements ($sProcessUID)
+ {
+ try {
+ $oCriteria = new Criteria( 'workflow' );
+ //$oCriteria->add(StepPeer::PRO_UID, $sProcessUID);
+ //$oDataset = StepPeer::doSelectRS($oCriteria);
+ //$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ //$oDataset->next();
+ return true;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- catch (Exception $oError) {
- throw($oError);
+
+ /**
+ * Get all tasks for any Process
+ *
+ * @param string $sProUid
+ * @return array
+ */
+ public function getStartingTaskForUser ($sProUid, $sUsrUid)
+ {
+ try {
+ $aTasks = array ();
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( TaskPeer::PRO_UID, $sProUid );
+ //$oCriteria->add(TaskPeer::TAS_USER, $sUsrUid);
+ $oCriteria->add( TaskPeer::TAS_START, 'TRUE' );
+ $oDataset = TaskPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $oTask = new Task();
+ $aTasks[] = $oTask->Load( $aRow['TAS_UID'] );
+ $oDataset->next();
+ }
+ return $aTasks;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * Verify the user assig in any task
+ *
+ * @param string $sTaskUID
+ * @return array
+ */
+ public function assignUsertoTask ($sTaskUID)
+ {
+ try {
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addSelectColumn( TaskUserPeer::USR_UID );
+ $oCriteria->add( TaskUserPeer::TAS_UID, $sTaskUID );
+ $oDataset = TaskUserPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ $aRow = $oDataset->getRow();
+ if (is_array( $aRow ))
+ return 1;
+ else
+ return 0;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * Verify the user assig in task
+ *
+ * @param string $sUsrUid, $sTaskUID
+ * @return array
+ */
+ public function verifyUsertoTask ($sUsrUid, $sTaskUID)
+ {
+ try {
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addSelectColumn( TaskUserPeer::USR_UID );
+ $oCriteria->addSelectColumn( TaskUserPeer::TAS_UID );
+ $oCriteria->addSelectColumn( TaskUserPeer::TU_RELATION );
+ $oCriteria->add( TaskUserPeer::TAS_UID, $sTaskUID );
+ $oCriteria->add( TaskUserPeer::USR_UID, $sUsrUid );
+ $oDataset = TaskUserPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ $aRow = $oDataset->getRow();
+ if (is_array( $aRow ))
+ return $aRow;
+ else
+ return $aRow;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * Get tasks that the usser is assigned
+ *
+ * @param string $sUsrUID
+ * @return array
+ */
+ public function getTasksThatUserIsAssigned ($sUserUID)
+ {
+ try {
+ $aTasks = array ();
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( TaskUserPeer::USR_UID, $sUserUID );
+ $oCriteria->add( TaskUserPeer::TU_RELATION, 1 );
+ $oDataset = TaskUserPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aTasks[] = $aRow['TAS_UID'];
+ $oDataset->next();
+ }
+ $aGroups = array ();
+ $oCriteria = new Criteria();
+ $oCriteria->add( GroupwfPeer::GRP_UID, '', Criteria::NOT_EQUAL );
+ $oCriteria->add( GroupUserPeer::USR_UID, $sUserUID );
+ $oCriteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' );
+ $oCriteria->addJoin( GroupUserPeer::GRP_UID, GroupwfPeer::GRP_UID, Criteria::LEFT_JOIN );
+ $oDataset = GroupwfPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aGroups[] = $aRow['GRP_UID'];
+ $oDataset->next();
+ }
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( TaskUserPeer::USR_UID, $aGroups, Criteria::IN );
+ $oCriteria->add( TaskUserPeer::TU_RELATION, 2 );
+ $oDataset = TaskUserPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ if (! in_array( $aRow['TAS_UID'], $aTasks )) {
+ $aTasks[] = $aRow['TAS_UID'];
+ }
+ $oDataset->next();
+ }
+ return $aTasks;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * Get Routes for any Process and any Task
+ *
+ * @param string $sProUid, $sTaskUid
+ * @return array by Everth
+ */
+ public function getRoute ($sProUid, $sTaskUid)
+ {
+ try {
+ $aRoutes = array ();
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( RoutePeer::PRO_UID, $sProUid );
+ $oCriteria->add( RoutePeer::TAS_UID, $sTaskUid );
+ $oDataset = RoutePeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aRoutes[] = $aRow;
+ $oDataset->next();
+ }
+
+ return $aRoutes;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * Get Routes for any Process,route type,route next task
+ *
+ * @param string $sProUid, $sTaskUid
+ * @return array by Girish
+ */
+ public function getRouteByType ($sProUid, $sRouteNextTaskUid, $sRouteType)
+ {
+ try {
+ $aRoutes = array ();
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->add( RoutePeer::PRO_UID, $sProUid );
+ $oCriteria->add( RoutePeer::ROU_NEXT_TASK, $sRouteNextTaskUid );
+ $oCriteria->add( RoutePeer::ROU_TYPE, $sRouteType );
+ $oDataset = RoutePeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ $aRoutes[] = $aRow;
+ $oDataset->next();
+ }
+
+ return $aRoutes;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- }
}
?>
diff --git a/workflow/engine/classes/class.toolBar.php b/workflow/engine/classes/class.toolBar.php
index 22628101a..46336aed4 100755
--- a/workflow/engine/classes/class.toolBar.php
+++ b/workflow/engine/classes/class.toolBar.php
@@ -1,6 +1,8 @@
.
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
-
+
/**
* ToolBar - ToolBar class
+ *
* @package workflow.engine.ProcessMaker
*/
-class ToolBar extends form
+class ToolBar extends form
{
- var $type = 'toolbar';
- var $align = 'left';
+ var $type = 'toolbar';
+ var $align = 'left';
}
-
- /**
+
+/**
* XmlForm_Field_ToolBar - XmlForm_Field_ToolBar class
+ *
* @package workflow.engine.ProcessMaker
*/
-class XmlForm_Field_ToolBar extends XmlForm_Field
+class XmlForm_Field_ToolBar extends XmlForm_Field
{
- var $xmlfile = '';
- var $type = 'toolbar';
- var $toolBar;
- var $home='';
- var $withoutLabel = true;
-
- /**
- * Constructor of the class XmlForm_Field_ToolBar
- * @param string $xmlNode
- * @param string $lang
- * @param string $home
- * @param string $owner
- * @return void
- */
- function XmlForm_Field_ToolBar($xmlNode, $lang='en', $home='', $owner)
- {
- parent::XmlForm_Field($xmlNode, $lang, $home, $owner);
- $this->home = $home;
- }
-
- /**
- * Prints the ToolBar
- * @param string $value
- * @return string
- */
- function render( $value )
- {
- $this->toolBar = new toolBar( $this->xmlfile , $this->home );
- $template = PATH_CORE . 'templates/' . $this->type . '.html';
- $out = $this->toolBar->render( $template , $scriptCode ) ;
- $oHeadPublisher =& headPublisher::getSingleton();
- $oHeadPublisher->addScriptFile( $this->toolBar->scriptURL );
- $oHeadPublisher->addScriptCode( $scriptCode );
- return $out;
- }
+ var $xmlfile = '';
+ var $type = 'toolbar';
+ var $toolBar;
+ var $home = '';
+ var $withoutLabel = true;
+
+ /**
+ * Constructor of the class XmlForm_Field_ToolBar
+ *
+ * @param string $xmlNode
+ * @param string $lang
+ * @param string $home
+ * @param string $owner
+ * @return void
+ */
+ function XmlForm_Field_ToolBar ($xmlNode, $lang = 'en', $home = '', $owner)
+ {
+ parent::XmlForm_Field( $xmlNode, $lang, $home, $owner );
+ $this->home = $home;
+ }
+
+ /**
+ * Prints the ToolBar
+ *
+ * @param string $value
+ * @return string
+ */
+ function render ($value)
+ {
+ $this->toolBar = new toolBar( $this->xmlfile, $this->home );
+ $template = PATH_CORE . 'templates/' . $this->type . '.html';
+ $out = $this->toolBar->render( $template, $scriptCode );
+ $oHeadPublisher = & headPublisher::getSingleton();
+ $oHeadPublisher->addScriptFile( $this->toolBar->scriptURL );
+ $oHeadPublisher->addScriptCode( $scriptCode );
+ return $out;
+ }
}
/**
* XmlForm_Field_toolButton - XmlForm_Field_toolButton class
+ *
* @package workflow.engine.ProcessMaker
*/
class XmlForm_Field_toolButton extends XmlForm_Field
{
- var $file = '';
- var $fileAlt = '';
- var $url = '';
- var $urlAlt = '';
- var $home = 'public_html';
- /* types of buttons:
+ var $file = '';
+ var $fileAlt = '';
+ var $url = '';
+ var $urlAlt = '';
+ var $home = 'public_html';
+ /* types of buttons:
* image
* text
* image/text
* text/image
*/
- var $buttonType = 'image';
- var $withoutLabel = false;
- var $buttonStyle = '';
+ var $buttonType = 'image';
+ var $withoutLabel = false;
+ var $buttonStyle = '';
/*$hoverMethod : back | switch*/
- var $hoverMethod='back';
- var $class;
-
- /**
- * Prints the components of the toolBar
- * @param string $value
- * @return string
- */
- function render( $value )
- {
- $url = $this->file;
- if ($this->home === "methods")
- $url = G::encryptlink( SYS_URI . $url );
- if ($this->home === "public_html")
- $url ='/' . $url ;
- $urlAlt = $this->fileAlt;
- if ($this->fileAlt!=='') {
- if ($this->home === "methods")
- $urlAlt = G::encryptlink( SYS_URI . $urlAlt );
- if ($this->home === "public_html")
- $urlAlt ='/' . $urlAlt ;
- }
- $this->url=$url;
- $this->urlAlt=$urlAlt;
- switch($this->buttonType){
- case 'image':
- $html='';
- if ($this->hoverMethod==='back') {
- $html='
style)?' style="'.$this->style.'"':'').' onmouseover=\'backImage(this,"url('.htmlentities( $urlAlt, ENT_QUOTES, 'utf-8').') no-repeat")\' onmouseout=\'backImage(this,"")\' title=\'' . addslashes($this->label) . '\' />';
- }
- elseif($this->hoverMethod==='switch'){
- $html='
style)?' style="'.$this->style.'"':'').' onmouseover=\'switchImage(this,"'.htmlentities( $url, ENT_QUOTES, 'utf-8').'","'.htmlentities( $urlAlt, ENT_QUOTES, 'utf-8').'")\' onmouseout=\'switchImage(this,"'.htmlentities( $url, ENT_QUOTES, 'utf-8').'","'.htmlentities( $urlAlt, ENT_QUOTES, 'utf-8').'")\'/>';
- }
- else {
- $html='
style)?' style="'.$this->style.'"':'').'/>';
+ var $hoverMethod = 'back';
+ var $class;
+
+ /**
+ * Prints the components of the toolBar
+ *
+ * @param string $value
+ * @return string
+ */
+ function render ($value)
+ {
+ $url = $this->file;
+ if ($this->home === "methods")
+ $url = G::encryptlink( SYS_URI . $url );
+ if ($this->home === "public_html")
+ $url = '/' . $url;
+ $urlAlt = $this->fileAlt;
+ if ($this->fileAlt !== '') {
+ if ($this->home === "methods")
+ $urlAlt = G::encryptlink( SYS_URI . $urlAlt );
+ if ($this->home === "public_html")
+ $urlAlt = '/' . $urlAlt;
}
- break;
- case 'text':
- $html=$this->htmlentities($this->label, ENT_QUOTES,'utf-8');
- break;
- case 'html':
- $html=''.
- $this->label.'
';
-
- //$html=$this->label;
- break;
- case 'image/text':
- $html='
style)?' style="'.$this->style.'"':'').'/>
'.
- $this->htmlentities($this->label, ENT_QUOTES,'utf-8');
- break;
- case 'text/image':
- $html=$this->htmlentities($this->label, ENT_QUOTES,'utf-8').
- '
style)?' style="'.$this->style.'"':'').'/>';
- break;
- case 'class':
- $html='
-
+ $this->url = $url;
+ $this->urlAlt = $urlAlt;
+ switch ($this->buttonType) {
+ case 'image':
+ $html = '';
+ if ($this->hoverMethod === 'back') {
+ $html = '
style) ? ' style="' . $this->style . '"' : '') . ' onmouseover=\'backImage(this,"url(' . htmlentities( $urlAlt, ENT_QUOTES, 'utf-8' ) . ') no-repeat")\' onmouseout=\'backImage(this,"")\' title=\'' . addslashes( $this->label ) . '\' />';
+ } elseif ($this->hoverMethod === 'switch') {
+ $html = '
style) ? ' style="' . $this->style . '"' : '') . ' onmouseover=\'switchImage(this,"' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '","' . htmlentities( $urlAlt, ENT_QUOTES, 'utf-8' ) . '")\' onmouseout=\'switchImage(this,"' . htmlentities( $url, ENT_QUOTES, 'utf-8' ) . '","' . htmlentities( $urlAlt, ENT_QUOTES, 'utf-8' ) . '")\'/>';
+ } else {
+ $html = '
style) ? ' style="' . $this->style . '"' : '') . '/>';
+ }
+ break;
+ case 'text':
+ $html = $this->htmlentities( $this->label, ENT_QUOTES, 'utf-8' );
+ break;
+ case 'html':
+ $html = '' . $this->label . '
';
+
+ //$html=$this->label;
+ break;
+ case 'image/text':
+ $html = '
style) ? ' style="' . $this->style . '"' : '') . '/>
' . $this->htmlentities( $this->label, ENT_QUOTES, 'utf-8' );
+ break;
+ case 'text/image':
+ $html = $this->htmlentities( $this->label, ENT_QUOTES, 'utf-8' ) . '
style) ? ' style="' . $this->style . '"' : '') . '/>';
+ break;
+ case 'class':
+ $html = '
+
';
- return $html;
-
+ return $html;
+
+ }
+ return 'buttonStyle) ? ' style="' . $this->buttonStyle . '"' : '') . (($this->onclick) ? ' onclick="' . htmlentities( $this->onclick, ENT_QUOTES, 'utf-8' ) . '"' : '') . '>' . $html . '';
}
- return 'buttonStyle)?' style="'.$this->buttonStyle.'"':'').
- (($this->onclick)?' onclick="'. htmlentities($this->onclick, ENT_QUOTES,'utf-8').'"':'').
- '>'.$html.'';
- }
}
?>
diff --git a/workflow/engine/classes/class.triggerLibrary.php b/workflow/engine/classes/class.triggerLibrary.php
index 6da1845c4..91173e38f 100755
--- a/workflow/engine/classes/class.triggerLibrary.php
+++ b/workflow/engine/classes/class.triggerLibrary.php
@@ -1,165 +1,169 @@
*
- * This class Helps registering and implementing Wizard for Triggers
+ * This class Helps registering and implementing Wizard for Triggers
*/
-G::LoadThirdParty ( 'html2ps_pdf/classes', 'include' );
-G::LoadThirdParty ( 'html2ps_pdf/classes/org/active-link/doc', 'PHPClass' );
+G::LoadThirdParty( 'html2ps_pdf/classes', 'include' );
+G::LoadThirdParty( 'html2ps_pdf/classes/org/active-link/doc', 'PHPClass' );
- /**
- * @package workflow.engine.ProcessMaker
- */
+/**
+ *
+ * @package workflow.engine.ProcessMaker
+ */
-class triggerLibrary {
+class triggerLibrary
+{
- private $_aTriggerClasses_ = array ();
+ private $_aTriggerClasses_ = array ();
- private static $instance = NULL;
+ private static $instance = NULL;
- /**
- * __construct
- *
- * @return void
- */
- function __construct()
- {
- //Initialize the Library and register the Default
- $this->registerFunctionsFileToLibrary ( PATH_CORE . "classes" . PATH_SEP . "class.pmFunctions.php", "ProcessMaker Functions" );
+ /**
+ * __construct
+ *
+ * @return void
+ */
+ function __construct ()
+ {
+ //Initialize the Library and register the Default
+ $this->registerFunctionsFileToLibrary( PATH_CORE . "classes" . PATH_SEP . "class.pmFunctions.php", "ProcessMaker Functions" );
+
+ //Register all registered PLugin Functions
+ if (class_exists( 'folderData' )) {
+ //$folderData = new folderData($sProUid, $proFields['PRO_TITLE'], $sAppUid, $Fields['APP_TITLE'], $sUsrUid);
+ $oPluginRegistry = &PMPluginRegistry::getSingleton();
+ $aAvailablePmFunctions = $oPluginRegistry->getPmFunctions();
+ foreach ($aAvailablePmFunctions as $key => $class) {
+ $filePlugin = PATH_PLUGINS . $class . PATH_SEP . 'classes' . PATH_SEP . 'class.pmFunctions.php';
+
+ if (file_exists( $filePlugin ) && ! is_dir( $filePlugin )) {
+ $this->registerFunctionsFileToLibrary( $filePlugin, "ProcessMaker Functions" );
+ }
+ }
- //Register all registered PLugin Functions
- if (class_exists ( 'folderData' )) {
- //$folderData = new folderData($sProUid, $proFields['PRO_TITLE'], $sAppUid, $Fields['APP_TITLE'], $sUsrUid);
- $oPluginRegistry = &PMPluginRegistry::getSingleton ();
- $aAvailablePmFunctions = $oPluginRegistry->getPmFunctions ();
- foreach ( $aAvailablePmFunctions as $key => $class ) {
- $filePlugin = PATH_PLUGINS . $class . PATH_SEP . 'classes' . PATH_SEP . 'class.pmFunctions.php';
-
- if ( file_exists($filePlugin) && !is_dir($filePlugin)) {
- $this->registerFunctionsFileToLibrary ( $filePlugin, "ProcessMaker Functions" );
}
- }
+ //Add External Triggers
+ $dir = G::ExpandPath( "classes" ) . 'triggers';
+ $filesArray = array ();
- }
- //Add External Triggers
- $dir = G::ExpandPath( "classes" ).'triggers';
- $filesArray = array();
-
- if (file_exists($dir)){
- if ($handle = opendir($dir)) {
- while (false !== ($file = readdir($handle))) {
- if( $file != "." && $file != ".." && !is_dir($dir . PATH_SEP . $file)){
- $this->registerFunctionsFileToLibrary( $dir . PATH_SEP . $file, "ProcessMaker External Functions");
- }
+ if (file_exists( $dir )) {
+ if ($handle = opendir( $dir )) {
+ while (false !== ($file = readdir( $handle ))) {
+ if ($file != "." && $file != ".." && ! is_dir( $dir . PATH_SEP . $file )) {
+ $this->registerFunctionsFileToLibrary( $dir . PATH_SEP . $file, "ProcessMaker External Functions" );
+ }
+ }
+ closedir( $handle );
+ }
}
- closedir($handle);
- }
- }
- }
-
- /**
- * &getSingleton
- *
- * @return self::$instance;
- */
- function &getSingleton()
- {
- if (self::$instance == NULL) {
- self::$instance = new triggerLibrary ( );
- }
- return self::$instance;
- }
-
- /**
- * serializeInstance
- *
- * @return serialize ( self::$instance );
- */
- function serializeInstance()
- {
- return serialize ( self::$instance );
- }
-
- /**
- * unSerializeInstance
- *
- * @param integer $serialized
- * @return void
- */
- function unSerializeInstance($serialized)
- {
- if (self::$instance == NULL) {
- self::$instance = new PMPluginRegistry ( );
}
- $instance = unserialize ( $serialized );
- self::$instance = $instance;
- }
-
- /**
- * registerFunctionsFileToLibrary
- *
- * @param string $filePath
- * @param string $libraryName
- * @return void
- */
- function registerFunctionsFileToLibrary($filePath, $libraryName)
- {
- $aLibrary = $this->getMethodsFromLibraryFile ( $filePath );
- $aLibrary->libraryFile = $filePath;
- $aLibrary->libraryName = $libraryName;
- if(isset($aLibrary->info['className'])){
- $this->_aTriggerClasses_ [$aLibrary->info['className']] = $aLibrary;
+ /**
+ * &getSingleton
+ *
+ * @return self::$instance;
+ */
+ function &getSingleton ()
+ {
+ if (self::$instance == NULL) {
+ self::$instance = new triggerLibrary();
+ }
+ return self::$instance;
}
- }
+ /**
+ * serializeInstance
+ *
+ * @return serialize ( self::$instance );
+ */
+ function serializeInstance ()
+ {
+ return serialize( self::$instance );
+ }
- /**
- * getMethodsFromLibraryFile
- *
- * @param string $file
- * @return object(PHPClass) $parsedLibrary
- */
- function getMethodsFromLibraryFile($file)
- {
- // parse class comments from file
- $parsedLibrary = new PHPClass ( );
- //$success = $parsedLibrary->parseFromFile ( PATH_CORE . "classes" . PATH_SEP . $file );
- $success = $parsedLibrary->parseFromFile ( $file );
+ /**
+ * unSerializeInstance
+ *
+ * @param integer $serialized
+ * @return void
+ */
+ function unSerializeInstance ($serialized)
+ {
+ if (self::$instance == NULL) {
+ self::$instance = new PMPluginRegistry();
+ }
- return $parsedLibrary;
- }
+ $instance = unserialize( $serialized );
+ self::$instance = $instance;
+ }
- /**
- * getRegisteredClasses
- *
- * @return array ($this->_aTriggerClasses_)
- */
- function getRegisteredClasses()
- {
- return ($this->_aTriggerClasses_);
- }
+ /**
+ * registerFunctionsFileToLibrary
+ *
+ * @param string $filePath
+ * @param string $libraryName
+ * @return void
+ */
+ function registerFunctionsFileToLibrary ($filePath, $libraryName)
+ {
+ $aLibrary = $this->getMethodsFromLibraryFile( $filePath );
+ $aLibrary->libraryFile = $filePath;
+ $aLibrary->libraryName = $libraryName;
+ if (isset( $aLibrary->info['className'] )) {
+ $this->_aTriggerClasses_[$aLibrary->info['className']] = $aLibrary;
+ }
- /**
- * getLibraryDefinition
- *
- * @param string $libraryClassName
- * @return array ($this->_aTriggerClasses_[$libraryClassName])
- */
- function getLibraryDefinition($libraryClassName)
- {
- return ($this->_aTriggerClasses_[$libraryClassName]);
- }
+ }
- /**
- * __destruct
- *
- * @return void
- */ function __destruct()
- {
+ /**
+ * getMethodsFromLibraryFile
+ *
+ * @param string $file
+ * @return object(PHPClass) $parsedLibrary
+ */
+ function getMethodsFromLibraryFile ($file)
+ {
+ // parse class comments from file
+ $parsedLibrary = new PHPClass();
+ //$success = $parsedLibrary->parseFromFile ( PATH_CORE . "classes" . PATH_SEP . $file );
+ $success = $parsedLibrary->parseFromFile( $file );
- //TODO - Insert your code here
- }
+ return $parsedLibrary;
+ }
+
+ /**
+ * getRegisteredClasses
+ *
+ * @return array ($this->_aTriggerClasses_)
+ */
+ function getRegisteredClasses ()
+ {
+ return ($this->_aTriggerClasses_);
+ }
+
+ /**
+ * getLibraryDefinition
+ *
+ * @param string $libraryClassName
+ * @return array ($this->_aTriggerClasses_[$libraryClassName])
+ */
+ function getLibraryDefinition ($libraryClassName)
+ {
+ return ($this->_aTriggerClasses_[$libraryClassName]);
+ }
+
+ /**
+ * __destruct
+ *
+ * @return void
+ */
+ function __destruct ()
+ {
+
+ //TODO - Insert your code here
+ }
}
?>
\ No newline at end of file
diff --git a/workflow/engine/classes/class.webdav.php b/workflow/engine/classes/class.webdav.php
index 9f6c496ed..1564bed9a 100755
--- a/workflow/engine/classes/class.webdav.php
+++ b/workflow/engine/classes/class.webdav.php
@@ -1,252 +1,271 @@
base = '/';
- $this->uriBase = '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/webdav/';
-
- // let the base class do all the work
- parent::ServeRequest();
- }
+ /**
+ * Serve a webdav request
+ *
+ * @access public
+ * @param string
+ */
+ function ServeRequest ($base = false)
+ {
+ //$this->base = '/';
+ $this->uriBase = '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/webdav/';
- /**
- * No authentication is needed here
- *
- * @access private
- * @param string HTTP Authentication type (Basic, Digest, ...)
- * @param string Username
- * @param string Password
- * @return bool true on successful authentication
- */
- function check_auth($type, $user, $pass)
- {
- return true;
- }
-
- /**
- * PROPFIND method handler
- *
- * @param array general parameter passing array
- * @param array return array for file properties
- * @return bool true on success
- */
- function PROPFIND(&$options, &$files)
- {
- $paths = $this->paths;
- // prepare property array
- $files["files"] = array();
-
- $pathClasses = PATH_DB . PATH_SEP . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
- if ( count($paths) == 0 && is_dir( $pathClasses ) ) {
- $props = array ();
- $props[] = $this->mkprop("displayname", 'Classes' );
- $props[] = $this->mkprop("creationdate", filectime($pathClasses) );
- $props[] = $this->mkprop("getlastmodified", filemtime($pathClasses) );
- $props[] = $this->mkprop("lastaccessed", filemtime($pathClasses) );
- $props[] = $this->mkprop("resourcetype", 'collection' );
- $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory' );
- $files["files"][] = array ( 'path' => 'classes' , 'props' => $props);
+ // let the base class do all the work
+ parent::ServeRequest();
}
- if ( count($paths) > 0 && $paths[0] == 'classes' && is_dir( $pathClasses ) ) {
- // try to open directory
- $handle = @opendir($pathClasses);
- if ($handle) {
- while ($filename = readdir($handle)) {
- $ext = array_pop ( explode ( '.', $filename) );
- if ($filename != "." && $filename != ".." && !is_dir($pathClasses.$filename) && $ext == 'php' ) {
- $props = array ();
- $props[] = $this->mkprop("displayname", $filename );
- $props[] = $this->mkprop("creationdate", filectime($pathClasses.$filename) );
- $props[] = $this->mkprop("getlastmodified", filemtime($pathClasses.$filename) );
- $props[] = $this->mkprop("getetag", fileatime($pathClasses.$filename) );
- $props[] = $this->mkprop("lastaccessed", filemtime($pathClasses.$filename) );
- $props[] = $this->mkprop("resourcetype", '' );
- $props[] = $this->mkprop("getcontenttype", 'text/plain' );
- $props[] = $this->mkprop("getcontentlength", filesize($pathClasses.$filename) );
- if ( count( $paths ) == 1 || ( count( $paths ) == 2 && $paths[1] == $filename ) )
- $files["files"][] = array ( 'path' => "classes/$filename" , 'props' => $props);
- }
- }
- }
-
- }//path classes
-
- $pathProcesses = PATH_DB . SYS_SYS . PATH_SEP ;
- if ( count($paths) == 0 && is_dir( $pathProcesses ) ) {
- $props = array ();
- $props[] = $this->mkprop("displayname", 'Processes' );
- $props[] = $this->mkprop("creationdate", filectime($pathProcesses) );
- $props[] = $this->mkprop("getlastmodified", filemtime($pathProcesses) );
- $props[] = $this->mkprop("resourcetype", 'collection' );
- $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory' );
- $files["files"][] = array ( 'path' => 'processes' , 'props' => $props);
+ /**
+ * No authentication is needed here
+ *
+ * @access private
+ * @param string HTTP Authentication type (Basic, Digest, ...)
+ * @param string Username
+ * @param string Password
+ * @return bool true on successful authentication
+ */
+ function check_auth ($type, $user, $pass)
+ {
+ return true;
}
-
- //list all active processes
- if ( count($paths) == 1 && $paths[0] == 'processes' && is_dir( $pathProcesses ) ) {
- // try to get the process directory list
- G::LoadClass ( 'processMap');
- G::LoadClass ( 'model/Process');
- $oProcessMap = new processMap();
- $oProcess = new Process();
- $c = $oProcessMap->getConditionProcessList();
- $oDataset = ProcessPeer::doSelectRS($c);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- while ($aRow = $oDataset->getRow()) {
- if ($aRow['PRO_STATUS'] == 'ACTIVE' ) {
- $aProcess = $oProcess->load($aRow['PRO_UID']);
- $props = array ();
- $props[] = $this->mkprop("displayname", $aProcess['PRO_TITLE'] );
- $props[] = $this->mkprop("creationdate", filectime($pathProcesses) );
- $props[] = $this->mkprop("getlastmodified", filemtime($pathProcesses) );
- $props[] = $this->mkprop("lastaccessed", filemtime($pathProcesses) );
- $props[] = $this->mkprop("resourcetype", 'collection' );
- $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory' );
- $files["files"][] = array ( 'path' => "processes/". $aRow['PRO_UID'] , 'props' => $props);
+
+ /**
+ * PROPFIND method handler
+ *
+ * @param array general parameter passing array
+ * @param array return array for file properties
+ * @return bool true on success
+ */
+ function PROPFIND (&$options, &$files)
+ {
+ $paths = $this->paths;
+ // prepare property array
+ $files["files"] = array ();
+
+ $pathClasses = PATH_DB . PATH_SEP . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
+ if (count( $paths ) == 0 && is_dir( $pathClasses )) {
+ $props = array ();
+ $props[] = $this->mkprop( "displayname", 'Classes' );
+ $props[] = $this->mkprop( "creationdate", filectime( $pathClasses ) );
+ $props[] = $this->mkprop( "getlastmodified", filemtime( $pathClasses ) );
+ $props[] = $this->mkprop( "lastaccessed", filemtime( $pathClasses ) );
+ $props[] = $this->mkprop( "resourcetype", 'collection' );
+ $props[] = $this->mkprop( "getcontenttype", 'httpd/unix-directory' );
+ $files["files"][] = array ('path' => 'classes','props' => $props
+ );
}
- $oDataset->next();
- }
- }//dir of processes
- //content of any process ( the three major folders of Processes )
- $pathXmlform = $pathProcesses . 'xmlForms' . PATH_SEP;
- if ( count($paths) == 2 && $paths[0] == 'processes' && is_dir( $pathProcesses ) ) {
- $props = array ();
- $props[] = $this->mkprop("displayname", 'xmlforms' );
- $props[] = $this->mkprop("creationdate", filectime($pathXmlform) );
- $props[] = $this->mkprop("getlastmodified", filemtime($pathXmlform) );
- $props[] = $this->mkprop("lastaccessed", filemtime($pathXmlform) );
- $props[] = $this->mkprop("resourcetype", 'collection' );
- $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory' );
- $files["files"][] = array ( 'path' => 'processes/' . $paths[1] . '/xmlforms' , 'props' => $props);
+ if (count( $paths ) > 0 && $paths[0] == 'classes' && is_dir( $pathClasses )) {
+ // try to open directory
+ $handle = @opendir( $pathClasses );
+ if ($handle) {
+ while ($filename = readdir( $handle )) {
+ $ext = array_pop( explode( '.', $filename ) );
+ if ($filename != "." && $filename != ".." && ! is_dir( $pathClasses . $filename ) && $ext == 'php') {
+ $props = array ();
+ $props[] = $this->mkprop( "displayname", $filename );
+ $props[] = $this->mkprop( "creationdate", filectime( $pathClasses . $filename ) );
+ $props[] = $this->mkprop( "getlastmodified", filemtime( $pathClasses . $filename ) );
+ $props[] = $this->mkprop( "getetag", fileatime( $pathClasses . $filename ) );
+ $props[] = $this->mkprop( "lastaccessed", filemtime( $pathClasses . $filename ) );
+ $props[] = $this->mkprop( "resourcetype", '' );
+ $props[] = $this->mkprop( "getcontenttype", 'text/plain' );
+ $props[] = $this->mkprop( "getcontentlength", filesize( $pathClasses . $filename ) );
+ if (count( $paths ) == 1 || (count( $paths ) == 2 && $paths[1] == $filename))
+ $files["files"][] = array ('path' => "classes/$filename",'props' => $props
+ );
+ }
+ }
+ }
- $props[] = $this->mkprop("displayname", 'mailTemplates' );
- $props[] = $this->mkprop("creationdate", filectime($pathProcesses) );
- $props[] = $this->mkprop("getlastmodified", filemtime($pathProcesses) );
- $props[] = $this->mkprop("lastaccessed", filemtime($pathProcesses) );
- $props[] = $this->mkprop("resourcetype", 'collection' );
- $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory' );
- $files["files"][] = array ( 'path' => 'processes/' . $paths[1] . '/mailTemplates' , 'props' => $props);
+ } //path classes
- $props[] = $this->mkprop("displayname", 'public_html' );
- $props[] = $this->mkprop("creationdate", filectime($pathProcesses) );
- $props[] = $this->mkprop("getlastmodified", filemtime($pathProcesses) );
- $props[] = $this->mkprop("lastaccessed", filemtime($pathProcesses) );
- $props[] = $this->mkprop("resourcetype", 'collection' );
- $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory' );
- $files["files"][] = array ( 'path' => 'processes/' . $paths[1] . '/public_html' , 'props' => $props);
- }//content of any processes
- //list available xmlforms
- if ( count($paths) == 3 && $paths[0] == 'processes' && $paths[2] == 'xmlforms' && is_dir( $pathXmlform ) ) {
- $pathXmlform = $pathProcesses . 'xmlForms' . PATH_SEP . $paths[1] . PATH_SEP;
-
- $handle = @opendir($pathXmlform);
- if ($handle) {
- while ($filename = readdir($handle)) {
- $ext = array_pop ( explode ( '.', $filename) );
- if ($filename != "." && $filename != ".." && !is_dir($pathXmlform.$filename) && ( $ext == 'xml' || $ext == 'html' ) ) {
- $props = array ();
- $props[] = $this->mkprop("displayname", $filename );
- $props[] = $this->mkprop("creationdate", filectime($pathXmlform.$filename) );
- $props[] = $this->mkprop("getlastmodified", filemtime($pathXmlform.$filename) );
- $props[] = $this->mkprop("getetag", fileatime($pathXmlform.$filename) );
- $props[] = $this->mkprop("lastaccessed", filemtime($pathXmlform.$filename) );
- $props[] = $this->mkprop("resourcetype", '' );
- $props[] = $this->mkprop("getcontenttype", 'text/plain' );
- $props[] = $this->mkprop("getcontentlength", filesize($pathXmlform.$filename) );
- //if ( count( $paths ) == 1 || ( count( $paths ) == 2 && $paths[1] == $filename ) )
- $files["files"][] = array ( 'path' => 'processes/' . $paths[1] . '/xmlforms/' . $filename , 'props' => $props);
- }
+ $pathProcesses = PATH_DB . SYS_SYS . PATH_SEP;
+ if (count( $paths ) == 0 && is_dir( $pathProcesses )) {
+ $props = array ();
+ $props[] = $this->mkprop( "displayname", 'Processes' );
+ $props[] = $this->mkprop( "creationdate", filectime( $pathProcesses ) );
+ $props[] = $this->mkprop( "getlastmodified", filemtime( $pathProcesses ) );
+ $props[] = $this->mkprop( "resourcetype", 'collection' );
+ $props[] = $this->mkprop( "getcontenttype", 'httpd/unix-directory' );
+ $files["files"][] = array ('path' => 'processes','props' => $props
+ );
}
- }
- }//content of xmlforms
- //list available mailTemplates
- $pathTemplates = $pathProcesses . 'mailTemplates' . PATH_SEP;
- if ( count($paths) == 3 && $paths[0] == 'processes' && $paths[2] == 'mailTemplates' && is_dir( $pathTemplates ) ) {
- $pathTemplates = $pathProcesses . 'mailTemplates' . PATH_SEP . $paths[1] . PATH_SEP;
-
- $handle = @opendir($pathTemplates);
- if ($handle) {
- while ($filename = readdir($handle)) {
- $ext = array_pop ( explode ( '.', $filename) );
- if ($filename != "." && $filename != ".." && !is_dir($pathTemplates.$filename) /* && ( $ext == 'xml' || $ext == 'html' ) */ ) {
- $props = array ();
- $props[] = $this->mkprop("displayname", $filename );
- $props[] = $this->mkprop("creationdate", filectime($pathTemplates.$filename) );
- $props[] = $this->mkprop("getlastmodified", filemtime($pathTemplates.$filename) );
- $props[] = $this->mkprop("getetag", fileatime($pathTemplates.$filename) );
- $props[] = $this->mkprop("lastaccessed", filemtime($pathTemplates.$filename) );
- $props[] = $this->mkprop("resourcetype", '' );
- $props[] = $this->mkprop("getcontenttype", 'text/plain' );
- $props[] = $this->mkprop("getcontentlength", filesize($pathTemplates.$filename) );
- //if ( count( $paths ) == 1 || ( count( $paths ) == 2 && $paths[1] == $filename ) )
- $files["files"][] = array ( 'path' => 'processes/' . $paths[1] . '/mailTemplates/' . $filename , 'props' => $props);
- }
- }
- }
- }//content of mailTemplates
+ //list all active processes
+ if (count( $paths ) == 1 && $paths[0] == 'processes' && is_dir( $pathProcesses )) {
+ // try to get the process directory list
+ G::LoadClass( 'processMap' );
+ G::LoadClass( 'model/Process' );
+ $oProcessMap = new processMap();
+ $oProcess = new Process();
+ $c = $oProcessMap->getConditionProcessList();
+ $oDataset = ProcessPeer::doSelectRS( $c );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ while ($aRow = $oDataset->getRow()) {
+ if ($aRow['PRO_STATUS'] == 'ACTIVE') {
+ $aProcess = $oProcess->load( $aRow['PRO_UID'] );
+ $props = array ();
+ $props[] = $this->mkprop( "displayname", $aProcess['PRO_TITLE'] );
+ $props[] = $this->mkprop( "creationdate", filectime( $pathProcesses ) );
+ $props[] = $this->mkprop( "getlastmodified", filemtime( $pathProcesses ) );
+ $props[] = $this->mkprop( "lastaccessed", filemtime( $pathProcesses ) );
+ $props[] = $this->mkprop( "resourcetype", 'collection' );
+ $props[] = $this->mkprop( "getcontenttype", 'httpd/unix-directory' );
+ $files["files"][] = array ('path' => "processes/" . $aRow['PRO_UID'],'props' => $props
+ );
+ }
+ $oDataset->next();
+ }
+ } //dir of processes
- //list available public_html files
- $pathPublic = $pathProcesses . 'public' . PATH_SEP;
- if ( count($paths) == 3 && $paths[0] == 'processes' && $paths[2] == 'public_html' && is_dir( $pathTemplates ) ) {
- $pathPublic = $pathProcesses . 'public' . PATH_SEP . $paths[1] . PATH_SEP;
-
- $handle = @opendir($pathPublic);
- if ($handle) {
- while ($filename = readdir($handle)) {
- $ext = array_pop ( explode ( '.', $filename) );
- if ($filename != "." && $filename != ".." && !is_dir($pathPublic.$filename) /* && ( $ext == 'xml' || $ext == 'html' ) */ ) {
- $props = array ();
- $props[] = $this->mkprop("displayname", $filename );
- $props[] = $this->mkprop("creationdate", filectime($pathPublic.$filename) );
- $props[] = $this->mkprop("getlastmodified", filemtime($pathPublic.$filename) );
- $props[] = $this->mkprop("getetag", fileatime($pathPublic.$filename) );
- $props[] = $this->mkprop("lastaccessed", filemtime($pathPublic.$filename) );
- $props[] = $this->mkprop("resourcetype", '' );
- $props[] = $this->mkprop("getcontenttype", 'text/plain' );
- $props[] = $this->mkprop("getcontentlength", filesize($pathPublic.$filename) );
- //if ( count( $paths ) == 1 || ( count( $paths ) == 2 && $paths[1] == $filename ) )
- $files["files"][] = array ( 'path' => 'processes/' . $paths[1] . '/public_html/' . $filename , 'props' => $props);
- }
- }
- }
- }//content of public_html files
- /*
+ //content of any process ( the three major folders of Processes )
+ $pathXmlform = $pathProcesses . 'xmlForms' . PATH_SEP;
+ if (count( $paths ) == 2 && $paths[0] == 'processes' && is_dir( $pathProcesses )) {
+ $props = array ();
+ $props[] = $this->mkprop( "displayname", 'xmlforms' );
+ $props[] = $this->mkprop( "creationdate", filectime( $pathXmlform ) );
+ $props[] = $this->mkprop( "getlastmodified", filemtime( $pathXmlform ) );
+ $props[] = $this->mkprop( "lastaccessed", filemtime( $pathXmlform ) );
+ $props[] = $this->mkprop( "resourcetype", 'collection' );
+ $props[] = $this->mkprop( "getcontenttype", 'httpd/unix-directory' );
+ $files["files"][] = array ('path' => 'processes/' . $paths[1] . '/xmlforms','props' => $props
+ );
+
+ $props[] = $this->mkprop( "displayname", 'mailTemplates' );
+ $props[] = $this->mkprop( "creationdate", filectime( $pathProcesses ) );
+ $props[] = $this->mkprop( "getlastmodified", filemtime( $pathProcesses ) );
+ $props[] = $this->mkprop( "lastaccessed", filemtime( $pathProcesses ) );
+ $props[] = $this->mkprop( "resourcetype", 'collection' );
+ $props[] = $this->mkprop( "getcontenttype", 'httpd/unix-directory' );
+ $files["files"][] = array ('path' => 'processes/' . $paths[1] . '/mailTemplates','props' => $props
+ );
+
+ $props[] = $this->mkprop( "displayname", 'public_html' );
+ $props[] = $this->mkprop( "creationdate", filectime( $pathProcesses ) );
+ $props[] = $this->mkprop( "getlastmodified", filemtime( $pathProcesses ) );
+ $props[] = $this->mkprop( "lastaccessed", filemtime( $pathProcesses ) );
+ $props[] = $this->mkprop( "resourcetype", 'collection' );
+ $props[] = $this->mkprop( "getcontenttype", 'httpd/unix-directory' );
+ $files["files"][] = array ('path' => 'processes/' . $paths[1] . '/public_html','props' => $props
+ );
+ } //content of any processes
+
+
+ //list available xmlforms
+ if (count( $paths ) == 3 && $paths[0] == 'processes' && $paths[2] == 'xmlforms' && is_dir( $pathXmlform )) {
+ $pathXmlform = $pathProcesses . 'xmlForms' . PATH_SEP . $paths[1] . PATH_SEP;
+
+ $handle = @opendir( $pathXmlform );
+ if ($handle) {
+ while ($filename = readdir( $handle )) {
+ $ext = array_pop( explode( '.', $filename ) );
+ if ($filename != "." && $filename != ".." && ! is_dir( $pathXmlform . $filename ) && ($ext == 'xml' || $ext == 'html')) {
+ $props = array ();
+ $props[] = $this->mkprop( "displayname", $filename );
+ $props[] = $this->mkprop( "creationdate", filectime( $pathXmlform . $filename ) );
+ $props[] = $this->mkprop( "getlastmodified", filemtime( $pathXmlform . $filename ) );
+ $props[] = $this->mkprop( "getetag", fileatime( $pathXmlform . $filename ) );
+ $props[] = $this->mkprop( "lastaccessed", filemtime( $pathXmlform . $filename ) );
+ $props[] = $this->mkprop( "resourcetype", '' );
+ $props[] = $this->mkprop( "getcontenttype", 'text/plain' );
+ $props[] = $this->mkprop( "getcontentlength", filesize( $pathXmlform . $filename ) );
+ //if ( count( $paths ) == 1 || ( count( $paths ) == 2 && $paths[1] == $filename ) )
+ $files["files"][] = array ('path' => 'processes/' . $paths[1] . '/xmlforms/' . $filename,'props' => $props
+ );
+ }
+ }
+ }
+ } //content of xmlforms
+
+
+ //list available mailTemplates
+ $pathTemplates = $pathProcesses . 'mailTemplates' . PATH_SEP;
+ if (count( $paths ) == 3 && $paths[0] == 'processes' && $paths[2] == 'mailTemplates' && is_dir( $pathTemplates )) {
+ $pathTemplates = $pathProcesses . 'mailTemplates' . PATH_SEP . $paths[1] . PATH_SEP;
+
+ $handle = @opendir( $pathTemplates );
+ if ($handle) {
+ while ($filename = readdir( $handle )) {
+ $ext = array_pop( explode( '.', $filename ) );
+ if ($filename != "." && $filename != ".." && ! is_dir( $pathTemplates . $filename ) /* && ( $ext == 'xml' || $ext == 'html' ) */ ) {
+ $props = array ();
+ $props[] = $this->mkprop( "displayname", $filename );
+ $props[] = $this->mkprop( "creationdate", filectime( $pathTemplates . $filename ) );
+ $props[] = $this->mkprop( "getlastmodified", filemtime( $pathTemplates . $filename ) );
+ $props[] = $this->mkprop( "getetag", fileatime( $pathTemplates . $filename ) );
+ $props[] = $this->mkprop( "lastaccessed", filemtime( $pathTemplates . $filename ) );
+ $props[] = $this->mkprop( "resourcetype", '' );
+ $props[] = $this->mkprop( "getcontenttype", 'text/plain' );
+ $props[] = $this->mkprop( "getcontentlength", filesize( $pathTemplates . $filename ) );
+ //if ( count( $paths ) == 1 || ( count( $paths ) == 2 && $paths[1] == $filename ) )
+ $files["files"][] = array ('path' => 'processes/' . $paths[1] . '/mailTemplates/' . $filename,'props' => $props
+ );
+ }
+ }
+ }
+ } //content of mailTemplates
+
+
+ //list available public_html files
+ $pathPublic = $pathProcesses . 'public' . PATH_SEP;
+ if (count( $paths ) == 3 && $paths[0] == 'processes' && $paths[2] == 'public_html' && is_dir( $pathTemplates )) {
+ $pathPublic = $pathProcesses . 'public' . PATH_SEP . $paths[1] . PATH_SEP;
+
+ $handle = @opendir( $pathPublic );
+ if ($handle) {
+ while ($filename = readdir( $handle )) {
+ $ext = array_pop( explode( '.', $filename ) );
+ if ($filename != "." && $filename != ".." && ! is_dir( $pathPublic . $filename ) /* && ( $ext == 'xml' || $ext == 'html' ) */ ) {
+ $props = array ();
+ $props[] = $this->mkprop( "displayname", $filename );
+ $props[] = $this->mkprop( "creationdate", filectime( $pathPublic . $filename ) );
+ $props[] = $this->mkprop( "getlastmodified", filemtime( $pathPublic . $filename ) );
+ $props[] = $this->mkprop( "getetag", fileatime( $pathPublic . $filename ) );
+ $props[] = $this->mkprop( "lastaccessed", filemtime( $pathPublic . $filename ) );
+ $props[] = $this->mkprop( "resourcetype", '' );
+ $props[] = $this->mkprop( "getcontenttype", 'text/plain' );
+ $props[] = $this->mkprop( "getcontentlength", filesize( $pathPublic . $filename ) );
+ //if ( count( $paths ) == 1 || ( count( $paths ) == 2 && $paths[1] == $filename ) )
+ $files["files"][] = array ('path' => 'processes/' . $paths[1] . '/public_html/' . $filename,'props' => $props
+ );
+ }
+ }
+ }
+ } //content of public_html files
+
+
+ /*
if ( 1 ) {
$props = array ();
$props[] = $this->mkprop("displayname", print_r ($pathPublic, 1) );
@@ -257,741 +276,736 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
$files["files"][] = array ( 'path' => '/' , 'props' => $props);
} */
- // ok, all done
- return true;
- }
-
- /**
- * detect if a given program is found in the search PATH
- *
- * helper function used by _mimetype() to detect if the
- * external 'file' utility is available
- *
- * @param string program name
- * @param string optional search path, defaults to $PATH
- * @return bool true if executable program found in path
- */
- function _can_execute($name, $path = false)
- {
- // path defaults to PATH from environment if not set
- if ($path === false) {
- $path = getenv("PATH");
- }
-
- // check method depends on operating system
- if (!strncmp(PHP_OS, "WIN", 3)) {
- // on Windows an appropriate COM or EXE file needs to exist
- $exts = array(".exe", ".com");
- $check_fn = "file_exists";
- } else {
- // anywhere else we look for an executable file of that name
- $exts = array("");
- $check_fn = "is_executable";
- }
-
- // now check the directories in the path for the program
- foreach (explode(PATH_SEPARATOR, $path) as $dir) {
- // skip invalid path entries
- if (!file_exists($dir)) continue;
- if (!is_dir($dir)) continue;
-
- // and now look for the file
- foreach ($exts as $ext) {
- if ($check_fn("$dir/$name".$ext)) return true;
- }
- }
-
- return false;
- }
-
- /**
- * try to detect the mime type of a file
- *
- * @param string file path
- * @return string guessed mime type
- */
- function _mimetype($fspath)
- {
- if (@is_dir($fspath)) {
- // directories are easy
- return "httpd/unix-directory";
- } else if (function_exists("mime_content_type")) {
- // use mime magic extension if available
- $mime_type = mime_content_type($fspath);
- } else if ($this->_can_execute("file")) {
- // it looks like we have a 'file' command,
- // lets see it it does have mime support
- $fp = popen("file -i '$fspath' 2>/dev/null", "r");
- $reply = fgets($fp);
- pclose($fp);
-
- // popen will not return an error if the binary was not found
- // and find may not have mime support using "-i"
- // so we test the format of the returned string
-
- // the reply begins with the requested filename
- if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) {
- $reply = substr($reply, strlen($fspath)+2);
- // followed by the mime type (maybe including options)
- if (preg_match('/^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*/', $reply, $matches)) {
- $mime_type = $matches[0];
- }
- }
- }
-
- if (empty($mime_type)) {
- // Fallback solution: try to guess the type by the file extension
- // TODO: add more ...
- // TODO: it has been suggested to delegate mimetype detection
- // to apache but this has at least three issues:
- // - works only with apache
- // - needs file to be within the document tree
- // - requires apache mod_magic
- // TODO: can we use the registry for this on Windows?
- // OTOH if the server is Windos the clients are likely to
- // be Windows, too, and tend do ignore the Content-Type
- // anyway (overriding it with information taken from
- // the registry)
- // TODO: have a seperate PEAR class for mimetype detection?
- switch (strtolower(strrchr(basename($fspath), "."))) {
- case ".html":
- $mime_type = "text/html";
- break;
- case ".gif":
- $mime_type = "image/gif";
- break;
- case ".jpg":
- $mime_type = "image/jpeg";
- break;
- default:
- $mime_type = "application/octet-stream";
- break;
- }
- }
-
- return $mime_type;
- }
-
- /**
- * GET method handler
- *
- * @param array parameter passing array
- * @return bool true on success
- */
- function GET(&$options) {
- $paths = $this->paths;
-
- $pathClasses = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
- if ( count($paths) > 0 && $paths[0] == 'classes' && is_dir( $pathClasses ) ) {
- $fsFile = $pathClasses. $paths[1];
- if ( count($paths) == 2 && file_exists( $fsFile ) ) {
- $content = file_get_contents ($fsFile);
- print $content;
- header("Content-Type: " . mime_content_type($fsFile ) );
- header("Last-Modified: " . date("D, j M Y H:m:s ", file_mtime($fsFile )) . "GMT");
- header("Content-Length: ". filesize($fsFile));
+ // ok, all done
return true;
- }
}
- $pathProcesses = PATH_DB . SYS_SYS . PATH_SEP;
- if ( count($paths) > 0 && $paths[0] == 'processes' && is_dir( $pathProcesses ) ) {
- if ( count($paths) == 4 && $paths[2] == 'xmlforms' ) {
- $pathXmlform = $pathProcesses . 'xmlForms' . PATH_SEP . $paths[1] . PATH_SEP;
- $fsFile = $pathXmlform. $paths[3];
- if ( count($paths) == 4 && file_exists( $fsFile ) ) {
- $content = file_get_contents ($fsFile);
- print $content;
- header("Content-Type: " . mime_content_type($fsFile ) );
- header("Last-Modified: " . date("D, j M Y H:m:s ", file_mtime($fsFile )) . "GMT");
- header("Content-Length: ". filesize($fsFile));
- return true;
+ /**
+ * detect if a given program is found in the search PATH
+ *
+ * helper function used by _mimetype() to detect if the
+ * external 'file' utility is available
+ *
+ * @param string program name
+ * @param string optional search path, defaults to $PATH
+ * @return bool true if executable program found in path
+ */
+ function _can_execute ($name, $path = false)
+ {
+ // path defaults to PATH from environment if not set
+ if ($path === false) {
+ $path = getenv( "PATH" );
}
- }
-
- if ( count($paths) == 4 && $paths[2] == 'mailTemplates' ) {
- $pathTemplates = $pathProcesses . 'mailTemplates' . PATH_SEP . $paths[1] . PATH_SEP;
- $fsFile = $pathTemplates. $paths[3];
- if ( count($paths) == 4 && file_exists( $fsFile ) ) {
- $content = file_get_contents ($fsFile);
- print $content;
- header("Content-Type: " . mime_content_type($fsFile ) );
- header("Last-Modified: " . date("D, j M Y H:m:s ", file_mtime($fsFile )) . "GMT");
- header("Content-Length: ". filesize($fsFile));
- return true;
+
+ // check method depends on operating system
+ if (! strncmp( PHP_OS, "WIN", 3 )) {
+ // on Windows an appropriate COM or EXE file needs to exist
+ $exts = array (".exe",".com"
+ );
+ $check_fn = "file_exists";
+ } else {
+ // anywhere else we look for an executable file of that name
+ $exts = array (""
+ );
+ $check_fn = "is_executable";
}
- }
-
- if ( count($paths) == 4 && $paths[2] == 'public_html' ) {
- $pathPublic = $pathProcesses . 'public' . PATH_SEP . $paths[1] . PATH_SEP;
- $fsFile = $pathPublic. $paths[3];
- if ( count($paths) == 4 && file_exists( $fsFile ) ) {
- $content = file_get_contents ($fsFile);
- print $content;
- header("Content-Type: " . mime_content_type($fsFile ) );
- header("Last-Modified: " . date("D, j M Y H:m:s ", file_mtime($fsFile )) . "GMT");
- header("Content-Length: ". filesize($fsFile));
- return true;
+
+ // now check the directories in the path for the program
+ foreach (explode( PATH_SEPARATOR, $path ) as $dir) {
+ // skip invalid path entries
+ if (! file_exists( $dir ))
+ continue;
+ if (! is_dir( $dir ))
+ continue;
+
+ // and now look for the file
+ foreach ($exts as $ext) {
+ if ($check_fn( "$dir/$name" . $ext ))
+ return true;
+ }
}
- }
- }
-
- print_r ( $paths );
- return true;
-
- if ( $options["path"] == '/' ) {
- return $this->getRoot( $options );
- }
- //print_r ($options);
-
-
- // get absolute fs path to requested resource
- $fspath = $this->base . $options["path"];
-
- // sanity check
- if (!file_exists($fspath)) return false;
-
- // is this a collection?
- if (is_dir($fspath)) {
- return $this->GetDir($fspath, $options);
- }
-
- // detect resource type
- $options['mimetype'] = $this->_mimetype($fspath);
-
- // detect modification time
- // see rfc2518, section 13.7
- // some clients seem to treat this as a reverse rule
- // requiering a Last-Modified header if the getlastmodified header was set
- $options['mtime'] = filemtime($fspath);
-
- // detect resource size
- $options['size'] = filesize($fspath);
-
- // no need to check result here, it is handled by the base class
- $options['stream'] = fopen($fspath, "r");
-
- return true;
- }
-
- /**
- * getRoot
- *
- * @param string &$options
- * @return boolean false
- */
- function getRoot (&$options)
- {
- $path = $this->_slashify($options["path"]);
- // fixed width directory column format
- $format = "%15s %-19s %-s\n";
-
- echo "Index of " . htmlspecialchars($options['path']) . "\n";
- echo "Index of " . htmlspecialchars($options['path']) . "
\n";
-
- echo "";
- printf($format, "Size", "Last modified", "Filename");
- echo "
";
-
- $pathRoot = array ( 'xmlforms', 'public_html', 'dir1', 'dir2' );
-
- foreach ( $pathRoot as $key => $val ) {
- $fullpath = $fspath."/".$filename;
- $name = htmlspecialchars($val);
- printf($format, number_format(filesize($fullpath)),
- strftime("%Y-%m-%d %H:%M:%S", filemtime($fullpath)),
- "$name");
- }
-
- echo "
";
- echo "\n";
-
- die;
-
- $handle = @opendir($fspath);
- if (!$handle) {
- return false;
- }
-
-
- while ($filename = readdir($handle)) {
- if ($filename != "." && $filename != "..") {
- $fullpath = $fspath."/".$filename;
- $name = htmlspecialchars($filename);
- printf($format,
- number_format(filesize($fullpath)),
- strftime("%Y-%m-%d %H:%M:%S", filemtime($fullpath)),
- "$name");
- }
- }
-
- echo "";
-
- closedir($handle);
-
- echo "