Merge remote branch 'upstream/master'

This commit is contained in:
jennylee
2012-10-19 16:54:43 -04:00
26 changed files with 8611 additions and 9859 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,467 +1,455 @@
<?php <?php
/** /**
* CalendarDefinition.php * CalendarDefinition.php
* @package workflow.engine.classes.model *
*/ * @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseCalendarDefinition.php';
require_once 'classes/model/CalendarBusinessHours.php'; require_once 'classes/model/om/BaseCalendarDefinition.php';
require_once 'classes/model/CalendarHolidays.php'; require_once 'classes/model/CalendarBusinessHours.php';
require_once 'classes/model/CalendarAssignments.php'; require_once 'classes/model/CalendarHolidays.php';
require_once 'classes/model/CalendarAssignments.php';
/**
* Skeleton subclass for representing a row from the 'CALENDAR_DEFINITION' table. /**
* * Skeleton subclass for representing a row from the 'CALENDAR_DEFINITION' table.
* *
* *
* You should add additional methods to this class to meet the *
* application requirements. This class will only be generated as * You should add additional methods to this class to meet the
* long as it does not already exist in the output directory. * application requirements. This class will only be generated as
* * long as it does not already exist in the output directory.
* @package workflow.engine.classes.model *
*/ * @package workflow.engine.classes.model
class CalendarDefinition extends BaseCalendarDefinition { */
public $calendarLog = ''; class CalendarDefinition extends BaseCalendarDefinition
function getCalendarList($onlyActive = false, $arrayMode = false) { {
$Criteria = new Criteria ( 'workflow' ); public $calendarLog = '';
$Criteria->clearSelectColumns ();
public function getCalendarList ($onlyActive = false, $arrayMode = false)
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UID ); {
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_NAME ); $Criteria = new Criteria( 'workflow' );
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); $Criteria->clearSelectColumns();
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE );
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID );
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_STATUS ); $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME );
// $Criteria->addAsColumn('DELETABLE', "IF (CALENDAR_UID <> '00000000000000000000000000000001', '".G::LoadTranslation('ID_DELETE')."','') "); $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE );
$Criteria->addAsColumn('DELETABLE', "CASE WHEN CALENDAR_UID <> '00000000000000000000000000000001' THEN '".G::LoadTranslation('ID_DELETE')."' ELSE '' END "); $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE );
// Note: This list doesn't show deleted items (STATUS = DELETED) $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION );
if ($onlyActive) { // Show only active. Used on assignment lists $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS );
$Criteria->add ( calendarDefinitionPeer::CALENDAR_STATUS, "ACTIVE", CRITERIA::EQUAL ); // $Criteria->addAsColumn('DELETABLE', "IF (CALENDAR_UID <> '00000000000000000000000000000001', '".G::LoadTranslation('ID_DELETE')."','') ");
} else { // Show Active and Inactive calendars. USed in main list $Criteria->addAsColumn( 'DELETABLE', "CASE WHEN CALENDAR_UID <> '00000000000000000000000000000001' THEN '" . G::LoadTranslation( 'ID_DELETE' ) . "' ELSE '' END " );
$Criteria->add ( calendarDefinitionPeer::CALENDAR_STATUS, array ("ACTIVE", "INACTIVE" ), CRITERIA::IN ); // Note: This list doesn't show deleted items (STATUS = DELETED)
} if ($onlyActive) {
// Show only active. Used on assignment lists
$Criteria->add ( calendarDefinitionPeer::CALENDAR_UID, "xx", CRITERIA::NOT_EQUAL ); $Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, "ACTIVE", CRITERIA::EQUAL );
} else {
if (! $arrayMode) { // Show Active and Inactive calendars. USed in main list
return $Criteria; $Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, array ("ACTIVE","INACTIVE"), CRITERIA::IN );
} else { }
$oDataset = calendarDefinitionPeer::doSelectRS ( $Criteria );
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); $Criteria->add( calendarDefinitionPeer::CALENDAR_UID, "xx", CRITERIA::NOT_EQUAL );
$oDataset->next ();
$calendarA = array (0 => 'dummy' ); if (! $arrayMode) {
$calendarCount = 0; return $Criteria;
while ( is_array ( $aRow = $oDataset->getRow () ) ) { } else {
$calendarCount ++; $oDataset = calendarDefinitionPeer::doSelectRS( $Criteria );
$calendarA [$calendarCount] = $aRow; $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next (); $oDataset->next();
} $calendarA = array (0 => 'dummy');
$return ['criteria'] = $Criteria; $calendarCount = 0;
$return ['array'] = $calendarA; while (is_array( $aRow = $oDataset->getRow() )) {
return $return; $calendarCount ++;
} $calendarA[$calendarCount] = $aRow;
} $oDataset->next();
//Added by qennix }
//Gets criteria for listing $return['criteria'] = $Criteria;
function getCalendarCriterias($filter, $start, $limit){ $return['array'] = $calendarA;
$Criteria = new Criteria ( 'workflow' ); return $return;
$Criteria->clearSelectColumns (); }
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UID ); }
if ($filter !=''){ //Added by qennix
$Criteria->add( //Gets criteria for listing
$Criteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_NAME,'%'.$filter.'%',Criteria::LIKE)->addOr( public function getCalendarCriterias ($filter, $start, $limit)
$Criteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_DESCRIPTION,'%'.$filter.'%',Criteria::LIKE))); {
} $Criteria = new Criteria( 'workflow' );
$Criteria->add(CalendarDefinitionPeer::CALENDAR_STATUS,'DELETED',Criteria::NOT_EQUAL); $Criteria->clearSelectColumns();
$Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID );
$oCriteria = new Criteria ( 'workflow' ); if ($filter != '') {
$oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UID ); $Criteria->add( $Criteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE ) ) );
$oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_NAME ); }
$oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); $Criteria->add( CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL );
$oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE );
$oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); $oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_STATUS ); $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID );
if ($filter !=''){ $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME );
$oCriteria->add( $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE );
$oCriteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_NAME,'%'.$filter.'%',Criteria::LIKE)->addOr( $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE );
$oCriteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_DESCRIPTION,'%'.$filter.'%',Criteria::LIKE))); $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION );
} $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS );
$oCriteria->add(CalendarDefinitionPeer::CALENDAR_STATUS,'DELETED',Criteria::NOT_EQUAL); if ($filter != '') {
$oCriteria->setLimit($limit); $oCriteria->add( $oCriteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE ) ) );
$oCriteria->setOffset($start); }
$oCriteria->add( CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL );
$criterias = array(); $oCriteria->setLimit( $limit );
$criterias['COUNTER'] = $Criteria; $oCriteria->setOffset( $start );
$criterias['LIST'] = $oCriteria;
return $criterias; $criterias = array ();
} $criterias['COUNTER'] = $Criteria;
function getCalendarInfo($CalendarUid) { $criterias['LIST'] = $oCriteria;
//if exists the row in the database propel will update it, otherwise will insert. return $criterias;
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid ); }
$defaultCalendar ['CALENDAR_UID'] = "00000000000000000000000000000001"; public function getCalendarInfo ($CalendarUid)
$defaultCalendar ['CALENDAR_NAME'] = "Default"; {
$defaultCalendar ['CALENDAR_CREATE_DATE'] = date ( "Y-m-d" ); //if exists the row in the database propel will update it, otherwise will insert.
$defaultCalendar ['CALENDAR_UPDATE_DATE'] = date ( "Y-m-d" ); $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid );
$defaultCalendar ['CALENDAR_DESCRIPTION'] = "Default";
$defaultCalendar ['CALENDAR_STATUS'] = "ACTIVE"; $defaultCalendar['CALENDAR_UID'] = "00000000000000000000000000000001";
$defaultCalendar ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; $defaultCalendar['CALENDAR_NAME'] = "Default";
$defaultCalendar ['CALENDAR_WORK_DAYS'] = explode ( "|", "1|2|3|4|5" ); $defaultCalendar['CALENDAR_CREATE_DATE'] = date( "Y-m-d" );
$defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_DAY'] = 7; $defaultCalendar['CALENDAR_UPDATE_DATE'] = date( "Y-m-d" );
$defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_START'] = "09:00"; $defaultCalendar['CALENDAR_DESCRIPTION'] = "Default";
$defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_END'] = "17:00"; $defaultCalendar['CALENDAR_STATUS'] = "ACTIVE";
$defaultCalendar ['HOLIDAY'] = array (); $defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$defaultCalendar['CALENDAR_WORK_DAYS'] = explode( "|", "1|2|3|4|5" );
if ((is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) { $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_DAY'] = 7;
$fields ['CALENDAR_UID'] = $tr->getCalendarUid (); $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_START'] = "09:00";
$fields ['CALENDAR_NAME'] = $tr->getCalendarName (); $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_END'] = "17:00";
$fields ['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate (); $defaultCalendar['HOLIDAY'] = array ();
$fields ['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate ();
$fields ['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription (); if ((is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) {
$fields ['CALENDAR_STATUS'] = $tr->getCalendarStatus (); $fields['CALENDAR_UID'] = $tr->getCalendarUid();
$fields ['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays (); $fields['CALENDAR_NAME'] = $tr->getCalendarName();
$fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", $tr->getCalendarWorkDays () ); $fields['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate();
} else { $fields['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate();
$fields=$defaultCalendar; $fields['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription();
$this->saveCalendarInfo ( $fields ); $fields['CALENDAR_STATUS'] = $tr->getCalendarStatus();
$fields ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; $fields['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays();
$fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", "1|2|3|4|5" ); $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", $tr->getCalendarWorkDays() );
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid ); } else {
} $fields = $defaultCalendar;
$CalendarBusinessHoursObj = new CalendarBusinessHours ( ); $this->saveCalendarInfo( $fields );
$CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours ( $CalendarUid ); $fields['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$fields ['BUSINESS_DAY'] = $CalendarBusinessHours; $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" );
$tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid );
$CalendarHolidaysObj = new CalendarHolidays ( ); }
$CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays ( $CalendarUid ); $CalendarBusinessHoursObj = new CalendarBusinessHours();
$fields ['HOLIDAY'] = $CalendarHolidays; $CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours( $CalendarUid );
$fields=$this->validateCalendarInfo($fields, $defaultCalendar); //******************** $fields['BUSINESS_DAY'] = $CalendarBusinessHours;
$CalendarHolidaysObj = new CalendarHolidays();
return $fields; $CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays( $CalendarUid );
$fields['HOLIDAY'] = $CalendarHolidays;
} $fields = $this->validateCalendarInfo( $fields, $defaultCalendar );
//for edit //********************
function getCalendarInfoE($CalendarUid) { return $fields;
//if exists the row in the database propel will update it, otherwise will insert. }
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid ); //for edit
public function getCalendarInfoE ($CalendarUid)
$defaultCalendar ['CALENDAR_UID'] = "00000000000000000000000000000001"; {
$defaultCalendar ['CALENDAR_NAME'] = "Default"; //if exists the row in the database propel will update it, otherwise will insert.
$defaultCalendar ['CALENDAR_CREATE_DATE'] = date ( "Y-m-d" ); $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid );
$defaultCalendar ['CALENDAR_UPDATE_DATE'] = date ( "Y-m-d" ); $defaultCalendar['CALENDAR_UID'] = "00000000000000000000000000000001";
$defaultCalendar ['CALENDAR_DESCRIPTION'] = "Default"; $defaultCalendar['CALENDAR_NAME'] = "Default";
$defaultCalendar ['CALENDAR_STATUS'] = "ACTIVE"; $defaultCalendar['CALENDAR_CREATE_DATE'] = date( "Y-m-d" );
$defaultCalendar ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; $defaultCalendar['CALENDAR_UPDATE_DATE'] = date( "Y-m-d" );
$defaultCalendar ['CALENDAR_WORK_DAYS'] = explode ( "|", "1|2|3|4|5" ); $defaultCalendar['CALENDAR_DESCRIPTION'] = "Default";
$defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_DAY'] = 7; $defaultCalendar['CALENDAR_STATUS'] = "ACTIVE";
$defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_START'] = "09:00"; $defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_END'] = "17:00"; $defaultCalendar['CALENDAR_WORK_DAYS'] = explode( "|", "1|2|3|4|5" );
$defaultCalendar ['HOLIDAY'] = array (); $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_DAY'] = 7;
$defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_START'] = "09:00";
if ((is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) { $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_END'] = "17:00";
$fields ['CALENDAR_UID'] = $tr->getCalendarUid (); $defaultCalendar['HOLIDAY'] = array ();
$fields ['CALENDAR_NAME'] = $tr->getCalendarName ();
$fields ['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate (); if ((is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) {
$fields ['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate (); $fields['CALENDAR_UID'] = $tr->getCalendarUid();
$fields ['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription (); $fields['CALENDAR_NAME'] = $tr->getCalendarName();
$fields ['CALENDAR_STATUS'] = $tr->getCalendarStatus (); $fields['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate();
$fields ['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays (); $fields['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate();
$fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", $tr->getCalendarWorkDays () ); $fields['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription();
} else { $fields['CALENDAR_STATUS'] = $tr->getCalendarStatus();
$fields=$defaultCalendar; $fields['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays();
$this->saveCalendarInfo ( $fields ); $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", $tr->getCalendarWorkDays() );
$fields ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; } else {
$fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", "1|2|3|4|5" ); $fields = $defaultCalendar;
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid ); $this->saveCalendarInfo( $fields );
} $fields['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$CalendarBusinessHoursObj = new CalendarBusinessHours ( ); $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" );
$CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours ( $CalendarUid ); $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid );
$fields ['BUSINESS_DAY'] = $CalendarBusinessHours; }
$CalendarBusinessHoursObj = new CalendarBusinessHours();
$CalendarHolidaysObj = new CalendarHolidays ( ); $CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours( $CalendarUid );
$CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays ( $CalendarUid ); $fields['BUSINESS_DAY'] = $CalendarBusinessHours;
$fields ['HOLIDAY'] = $CalendarHolidays; $CalendarHolidaysObj = new CalendarHolidays();
// $fields=$this->validateCalendarInfo($fields, $defaultCalendar); //******************** $CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays( $CalendarUid );
$fields['HOLIDAY'] = $CalendarHolidays;
return $fields; // $fields=$this->validateCalendarInfo($fields, $defaultCalendar); //********************
return $fields;
} }
//end for edit //end for edit
function validateCalendarInfo($fields,$defaultCalendar){ public function validateCalendarInfo ($fields, $defaultCalendar)
try { {
//Validate if Working days are Correct try {
//Minimun 3 ? //Validate if Working days are Correct
$workingDays=explode ( "|", $fields['CALENDAR_WORK_DAYS'] ); //Minimun 3 ?
if(count($workingDays)<3){ $workingDays = explode( "|", $fields['CALENDAR_WORK_DAYS'] );
throw (new Exception ( "You must define at least 3 Working Days!" )); if (count( $workingDays ) < 3) {
} throw (new Exception( "You must define at least 3 Working Days!" ));
//Validate that all Working Days have Bussines Hours }
if(count($fields ['BUSINESS_DAY'])<1){ //Validate that all Working Days have Bussines Hours
throw (new Exception ( "You must define at least one Business Day for all days" )); if (count( $fields['BUSINESS_DAY'] ) < 1) {
} throw (new Exception( "You must define at least one Business Day for all days" ));
$workingDaysOK=array(); }
foreach($workingDays as $key => $day){ $workingDaysOK = array ();
$workingDaysOK[$day]=false; foreach ($workingDays as $key => $day) {
} $workingDaysOK[$day] = false;
$sw_all=false; }
foreach($fields ['BUSINESS_DAY'] as $keyB => $businessHours){ $sw_all = false;
if(($businessHours['CALENDAR_BUSINESS_DAY']==7)){ foreach ($fields['BUSINESS_DAY'] as $keyB => $businessHours) {
$sw_all=true; if (($businessHours['CALENDAR_BUSINESS_DAY'] == 7)) {
}elseif((in_array($businessHours['CALENDAR_BUSINESS_DAY'],$workingDays))){ $sw_all = true;
$workingDaysOK[$businessHours['CALENDAR_BUSINESS_DAY']]=true; } elseif ((in_array( $businessHours['CALENDAR_BUSINESS_DAY'], $workingDays ))) {
} $workingDaysOK[$businessHours['CALENDAR_BUSINESS_DAY']] = true;
} }
$sw_days=true; }
$sw_days = true;
foreach($workingDaysOK as $day =>$sw_day){
$sw_days=$sw_days && $sw_day; foreach ($workingDaysOK as $day => $sw_day) {
} $sw_days = $sw_days && $sw_day;
if(!($sw_all || $sw_days)){ }
throw (new Exception ( "Not all working days have their correspondent business day" )); if (! ($sw_all || $sw_days)) {
} throw (new Exception( "Not all working days have their correspondent business day" ));
//Validate Holidays }
//Validate Holidays
return $fields; return $fields;
} catch (Exception $e) { } catch (Exception $e) {
//print $e->getMessage(); //print $e->getMessage();
$this->addCalendarLog("!!!!!!! BAD CALENDAR DEFINITION. ".$e->getMessage()); $this->addCalendarLog( "!!!!!!! BAD CALENDAR DEFINITION. " . $e->getMessage() );
$defaultCalendar ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; $defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$defaultCalendar ['CALENDAR_WORK_DAYS_A'] = explode ( "|", "1|2|3|4|5" ); $defaultCalendar['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" );
return $defaultCalendar; return $defaultCalendar;
} }
}
}
function saveCalendarInfo($aData) { public function saveCalendarInfo ($aData)
$CalendarUid = $aData ['CALENDAR_UID']; {
$CalendarName = $aData ['CALENDAR_NAME']; $CalendarUid = $aData['CALENDAR_UID'];
$CalendarDescription = $aData ['CALENDAR_DESCRIPTION']; $CalendarName = $aData['CALENDAR_NAME'];
$CalendarStatus = isset ( $aData ['CALENDAR_STATUS'] ) ? $aData ['CALENDAR_STATUS'] : "INACTIVE"; $CalendarDescription = $aData['CALENDAR_DESCRIPTION'];
$defaultCalendars [] = '00000000000000000000000000000001'; $CalendarStatus = isset( $aData['CALENDAR_STATUS'] ) ? $aData['CALENDAR_STATUS'] : "INACTIVE";
if (in_array ( $aData ['CALENDAR_UID'], $defaultCalendars )) { $defaultCalendars[] = '00000000000000000000000000000001';
$CalendarStatus = 'ACTIVE'; if (in_array( $aData['CALENDAR_UID'], $defaultCalendars )) {
$CalendarName = 'Default'; $CalendarStatus = 'ACTIVE';
} $CalendarName = 'Default';
$CalendarWorkDays = isset ( $aData ['CALENDAR_WORK_DAYS'] ) ? implode ( "|", $aData ['CALENDAR_WORK_DAYS'] ) : ""; }
$CalendarWorkDays = isset( $aData['CALENDAR_WORK_DAYS'] ) ? implode( "|", $aData['CALENDAR_WORK_DAYS'] ) : "";
//if exists the row in the database propel will update it, otherwise will insert.
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid ); //if exists the row in the database propel will update it, otherwise will insert.
if (! (is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) { $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid );
$tr = new CalendarDefinition ( ); if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) {
$tr->setCalendarCreateDate ( 'now' ); $tr = new CalendarDefinition();
} $tr->setCalendarCreateDate( 'now' );
$tr->setCalendarUid ( $CalendarUid ); }
$tr->setCalendarName ( $CalendarName ); $tr->setCalendarUid( $CalendarUid );
$tr->setCalendarName( $CalendarName );
$tr->setCalendarUpdateDate ( 'now' ); $tr->setCalendarUpdateDate( 'now' );
$tr->setCalendarDescription ( $CalendarDescription ); $tr->setCalendarDescription( $CalendarDescription );
$tr->setCalendarStatus ( $CalendarStatus ); $tr->setCalendarStatus( $CalendarStatus );
$tr->setCalendarWorkDays ( $CalendarWorkDays ); $tr->setCalendarWorkDays( $CalendarWorkDays );
if ($tr->validate ()) { if ($tr->validate()) {
// we save it, since we get no validation errors, or do whatever else you like. // we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save (); $res = $tr->save();
//Calendar Business Hours Save code. //Calendar Business Hours Save code.
//First Delete all current records //First Delete all current records
$CalendarBusinessHoursObj = new CalendarBusinessHours ( ); $CalendarBusinessHoursObj = new CalendarBusinessHours();
$CalendarBusinessHoursObj->deleteAllCalendarBusinessHours ( $CalendarUid ); $CalendarBusinessHoursObj->deleteAllCalendarBusinessHours( $CalendarUid );
//Save all the sent records //Save all the sent records
foreach ( $aData ['BUSINESS_DAY'] as $key => $objData ) { foreach ($aData['BUSINESS_DAY'] as $key => $objData) {
$objData ['CALENDAR_UID'] = $CalendarUid; $objData['CALENDAR_UID'] = $CalendarUid;
$CalendarBusinessHoursObj->saveCalendarBusinessHours ( $objData ); $CalendarBusinessHoursObj->saveCalendarBusinessHours( $objData );
} }
//Holiday Save code.
//Holiday Save code. //First Delete all current records
//First Delete all current records $CalendarHolidayObj = new CalendarHolidays();
$CalendarHolidayObj = new CalendarHolidays ( ); $CalendarHolidayObj->deleteAllCalendarHolidays( $CalendarUid );
$CalendarHolidayObj->deleteAllCalendarHolidays ( $CalendarUid ); //Save all the sent records
//Save all the sent records foreach ($aData['HOLIDAY'] as $key => $objData) {
foreach ( $aData ['HOLIDAY'] as $key => $objData ) { if (($objData['CALENDAR_HOLIDAY_NAME'] != "") && ($objData['CALENDAR_HOLIDAY_START'] != "") && ($objData['CALENDAR_HOLIDAY_END'] != "")) {
if (($objData ['CALENDAR_HOLIDAY_NAME'] != "") && ($objData ['CALENDAR_HOLIDAY_START'] != "") && ($objData ['CALENDAR_HOLIDAY_END'] != "")) { $objData['CALENDAR_UID'] = $CalendarUid;
$objData ['CALENDAR_UID'] = $CalendarUid; $CalendarHolidayObj->saveCalendarHolidays( $objData );
$CalendarHolidayObj->saveCalendarHolidays ( $objData ); }
} }
} } else {
} else { // Something went wrong. We can now get the validationFailures and handle them.
// Something went wrong. We can now get the validationFailures and handle them. $msg = '';
$msg = ''; $validationFailuresArray = $tr->getValidationFailures();
$validationFailuresArray = $tr->getValidationFailures (); foreach ($validationFailuresArray as $objValidationFailure) {
foreach ( $validationFailuresArray as $objValidationFailure ) { $msg .= $objValidationFailure->getMessage() . "<br/>";
$msg .= $objValidationFailure->getMessage () . "<br/>"; }
} //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); }
} //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); //to do: uniform coderror structures for all classes
//if ( $res['codError'] < 0 ) {
// G::SendMessageText ( $res['message'] , 'error' );
//to do: uniform coderror structures for all classes //}
}
//if ( $res['codError'] < 0 ) { public function deleteCalendar ($CalendarUid)
// G::SendMessageText ( $res['message'] , 'error' ); {
//} //if exists the row in the database propel will update it, otherwise will insert.
$tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid );
} if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) {
function deleteCalendar($CalendarUid) { //
//if exists the row in the database propel will update it, otherwise will insert. return false;
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid ); }
if (! (is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) { $defaultCalendars[] = '00000000000000000000000000000001';
// if (in_array( $tr->getCalendarUid(), $defaultCalendars )) {
return false; return false;
} }
$defaultCalendars [] = '00000000000000000000000000000001'; $tr->setCalendarStatus( 'DELETED' );
if (in_array ( $tr->getCalendarUid(), $defaultCalendars )) { $tr->setCalendarUpdateDate( 'now' );
return false; if ($tr->validate()) {
} // we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save();
$tr->setCalendarStatus ( 'DELETED' ); } else {
$tr->setCalendarUpdateDate ( 'now' ); // Something went wrong. We can now get the validationFailures and handle them.
if ($tr->validate ()) { $msg = '';
// we save it, since we get no validation errors, or do whatever else you like. $validationFailuresArray = $tr->getValidationFailures();
$res = $tr->save (); foreach ($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>";
} else { }
// Something went wrong. We can now get the validationFailures and handle them. G::SendMessage( "ERROR", $msg );
$msg = ''; //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
$validationFailuresArray = $tr->getValidationFailures (); }
foreach ( $validationFailuresArray as $objValidationFailure ) { //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
$msg .= $objValidationFailure->getMessage () . "<br/>"; //to do: uniform coderror structures for all classes
} //if ( $res['codError'] < 0 ) {
G::SendMessage ( "ERROR", $msg ); // G::SendMessageText ( $res['message'] , 'error' );
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); //}
} }
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
public function getCalendarFor ($userUid, $proUid, $tasUid, $sw_validate = true)
{
//to do: uniform coderror structures for all classes $Criteria = new Criteria( 'workflow' );
//Default Calendar
$calendarUid = "00000000000000000000000000000001";
//if ( $res['codError'] < 0 ) { $calendarOwner = "DEFAULT";
// G::SendMessageText ( $res['message'] , 'error' ); //Load User,Task and Process calendars (if exist)
//} $Criteria->addSelectColumn( CalendarAssignmentsPeer::CALENDAR_UID );
$Criteria->addSelectColumn( CalendarAssignmentsPeer::OBJECT_UID );
$Criteria->addSelectColumn( CalendarAssignmentsPeer::OBJECT_TYPE );
} $Criteria->add( CalendarAssignmentsPeer::OBJECT_UID, array ($userUid,$proUid,$tasUid), CRITERIA::IN );
function getCalendarFor($userUid, $proUid, $tasUid, $sw_validate=true) { $oDataset = CalendarAssignmentsPeer::doSelectRS( $Criteria );
$Criteria = new Criteria ( 'workflow' ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
//Default Calendar $calendarArray = array ();
$calendarUid = "00000000000000000000000000000001"; while (is_array( $aRow = $oDataset->getRow() )) {
$calendarOwner = "DEFAULT"; if ($aRow['OBJECT_UID'] == $userUid) {
$calendarArray['USER'] = $aRow['CALENDAR_UID'];
//Load User,Task and Process calendars (if exist) }
$Criteria->addSelectColumn ( CalendarAssignmentsPeer::CALENDAR_UID ); if ($aRow['OBJECT_UID'] == $proUid) {
$Criteria->addSelectColumn ( CalendarAssignmentsPeer::OBJECT_UID ); $calendarArray['PROCESS'] = $aRow['CALENDAR_UID'];
$Criteria->addSelectColumn ( CalendarAssignmentsPeer::OBJECT_TYPE ); }
$Criteria->add ( CalendarAssignmentsPeer::OBJECT_UID, array($userUid, $proUid, $tasUid), CRITERIA::IN ); if ($aRow['OBJECT_UID'] == $tasUid) {
$oDataset = CalendarAssignmentsPeer::doSelectRS ( $Criteria ); $calendarArray['TASK'] = $aRow['CALENDAR_UID'];
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); }
$oDataset->next (); $oDataset->next();
$calendarArray=array(); }
while(is_array($aRow = $oDataset->getRow ())){
if($aRow['OBJECT_UID']==$userUid){ if (isset( $calendarArray['USER'] )) {
$calendarArray['USER']=$aRow ['CALENDAR_UID']; $calendarUid = $calendarArray['USER'];
} $calendarOwner = "USER";
if($aRow['OBJECT_UID']==$proUid){ } elseif (isset( $calendarArray['PROCESS'] )) {
$calendarArray['PROCESS']=$aRow ['CALENDAR_UID']; $calendarUid = $calendarArray['PROCESS'];
} $calendarOwner = "PROCESS";
if($aRow['OBJECT_UID']==$tasUid){ } elseif (isset( $calendarArray['TASK'] )) {
$calendarArray['TASK']=$aRow ['CALENDAR_UID']; $calendarUid = $calendarArray['TASK'];
} $calendarOwner = "TASK";
$oDataset->next (); }
}
if(isset($calendarArray['USER'])){ //print "<h1>$calendarUid</h1>";
$calendarUid = $calendarArray['USER']; if ($sw_validate) {
$calendarOwner = "USER"; $calendarDefinition = $this->getCalendarInfo( $calendarUid );
}elseif (isset($calendarArray['PROCESS'])){ } else {
$calendarUid = $calendarArray['PROCESS']; $calendarDefinition = $this->getCalendarInfoE( $calendarUid );
$calendarOwner = "PROCESS"; }
}elseif (isset($calendarArray['TASK'])){ $calendarDefinition['CALENDAR_APPLIED'] = $calendarOwner;
$calendarUid = $calendarArray['TASK']; $this->addCalendarLog( "--=== Calendar Applied: " . $calendarDefinition['CALENDAR_NAME'] . " -> $calendarOwner" );
$calendarOwner = "TASK"; return $calendarDefinition;
} }
//print "<h1>$calendarUid</h1>"; public function assignCalendarTo ($objectUid, $calendarUid, $objectType)
if($sw_validate){ {
$calendarDefinition = $this->getCalendarInfo ( $calendarUid ); //if exists the row in the database propel will update it, otherwise will insert.
}else{ $tr = CalendarAssignmentsPeer::retrieveByPK( $objectUid );
$calendarDefinition = $this->getCalendarInfoE ( $calendarUid ); if ($calendarUid != "") {
} if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarAssignments')) {
$calendarDefinition ['CALENDAR_APPLIED'] = $calendarOwner; $tr = new CalendarAssignments();
$this->addCalendarLog ( "--=== Calendar Applied: " . $calendarDefinition ['CALENDAR_NAME'] . " -> $calendarOwner" ); }
return $calendarDefinition; $tr->setObjectUid( $objectUid );
} $tr->setCalendarUid( $calendarUid );
$tr->setObjectType( $objectType );
function assignCalendarTo($objectUid, $calendarUid, $objectType) {
//if exists the row in the database propel will update it, otherwise will insert. if ($tr->validate()) {
$tr = CalendarAssignmentsPeer::retrieveByPK ( $objectUid ); // we save it, since we get no validation errors, or do whatever else you like.
if ($calendarUid != "") { $res = $tr->save();
if (! (is_object ( $tr ) && get_class ( $tr ) == 'CalendarAssignments')) { } else {
$tr = new CalendarAssignments ( ); // Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
} $validationFailuresArray = $tr->getValidationFailures();
$tr->setObjectUid ( $objectUid ); foreach ($validationFailuresArray as $objValidationFailure) {
$tr->setCalendarUid ( $calendarUid ); $msg .= $objValidationFailure->getMessage() . "<br/>";
$tr->setObjectType ( $objectType ); }
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
if ($tr->validate ()) { }
// we save it, since we get no validation errors, or do whatever else you like. } else {
$res = $tr->save (); //Delete record
if ((is_object( $tr ) && get_class( $tr ) == 'CalendarAssignments')) {
} else { $tr->delete();
// Something went wrong. We can now get the validationFailures and handle them. }
$msg = ''; }
$validationFailuresArray = $tr->getValidationFailures (); }
foreach ( $validationFailuresArray as $objValidationFailure ) { //Added by Qennix
$msg .= $objValidationFailure->getMessage () . "<br/>"; //Counts all users,task,process by calendar
} public function getAllCounterByCalendar ($type)
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); {
} $oCriteria = new Criteria( 'workflow' );
} else { //Delete record $oCriteria->addSelectColumn( CalendarAssignmentsPeer::CALENDAR_UID );
if ((is_object ( $tr ) && get_class ( $tr ) == 'CalendarAssignments')) { $oCriteria->addSelectColumn( 'COUNT(*) AS CNT' );
$tr->delete (); $oCriteria->addGroupByColumn( CalendarAssignmentsPeer::CALENDAR_UID );
} $oCriteria->add( CalendarAssignmentsPeer::OBJECT_TYPE, $type );
} $oDataset = CalendarAssignmentsPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
} $aCounter = Array ();
//Added by Qennix while ($oDataset->next()) {
//Counts all users,task,process by calendar $row = $oDataset->getRow();
function getAllCounterByCalendar($type){ $aCounter[$row['CALENDAR_UID']] = $row['CNT'];
$oCriteria = new Criteria('workflow'); }
$oCriteria->addSelectColumn(CalendarAssignmentsPeer::CALENDAR_UID); return $aCounter;
$oCriteria->addSelectColumn('COUNT(*) AS CNT'); }
$oCriteria->addGroupByColumn(CalendarAssignmentsPeer::CALENDAR_UID);
$oCriteria->add(CalendarAssignmentsPeer::OBJECT_TYPE,$type); public function loadByCalendarName ($calendarName)
$oDataset = CalendarAssignmentsPeer::doSelectRS($oCriteria); {
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $Criteria = new Criteria( 'workflow' );
$aCounter = Array(); $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID );
while($oDataset->next()){ $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME );
$row = $oDataset->getRow(); $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE );
$aCounter[$row['CALENDAR_UID']] = $row['CNT']; $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE );
} $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION );
return $aCounter; $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS );
} $Criteria->add( calendarDefinitionPeer::CALENDAR_NAME, $calendarName, CRITERIA::EQUAL );
$oDataset = calendarDefinitionPeer::doSelectRS( $Criteria );
function loadByCalendarName($calendarName) $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
{ $oDataset->next();
$Criteria = new Criteria('workflow'); return $oDataset->getRow();
$Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_UID); }
$Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_NAME); }
$Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_CREATE_DATE); // CalendarDefinition
$Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_UPDATE_DATE);
$Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_DESCRIPTION);
$Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_STATUS);
$Criteria->add(calendarDefinitionPeer::CALENDAR_NAME, $calendarName, CRITERIA::EQUAL);
$oDataset = calendarDefinitionPeer::doSelectRS ($Criteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
return $oDataset->getRow();
}
} // CalendarDefinition

View File

@@ -1,479 +1,485 @@
<?php <?php
/** /**
* Content.php * Content.php
* @package workflow.engine.classes.model *
* * @package workflow.engine.classes.model
* ProcessMaker Open Source Edition *
* Copyright (C) 2004 - 2011 Colosa Inc. * ProcessMaker Open Source Edition
* * Copyright (C) 2004 - 2011 Colosa Inc.
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * This program is free software: you can redistribute it and/or modify
* published by the Free Software Foundation, either version 3 of the * it under the terms of the GNU Affero General Public License as
* License, or (at your option) any later version. * published by the Free Software Foundation, either version 3 of the
* * License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * This program is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU Affero General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. * You should have received a copy of the GNU Affero General Public License
* * along with this program. If not, see <http://www.gnu.org/licenses/>.
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., *
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ *
*/
require_once 'classes/model/om/BaseContent.php';
require_once 'classes/model/om/BaseContent.php';
/**
* Skeleton subclass for representing a row from the 'CONTENT' table. /**
* * Skeleton subclass for representing a row from the 'CONTENT' table.
* *
* *
* You should add additional methods to this class to meet the *
* application requirements. This class will only be generated as * You should add additional methods to this class to meet the
* long as it does not already exist in the output directory. * application requirements. This class will only be generated as
* * long as it does not already exist in the output directory.
* @package workflow.engine.classes.model *
*/ * @package workflow.engine.classes.model
class Content extends BaseContent { */
class Content extends BaseContent
public $langs; {
public $rowsProcessed; public $langs;
public $rowsInserted; public $rowsProcessed;
public $rowsUnchanged; public $rowsInserted;
public $rowsClustered; public $rowsUnchanged;
public $langsAsoc; public $rowsClustered;
/* public $langsAsoc;
* Load the content row specified by the parameters: /*
* Load the content row specified by the parameters:
* @param string $sUID * @param string $sUID
* @return variant * @return variant
*/ */
function load($ConCategory, $ConParent, $ConId, $ConLang) { public function load ($ConCategory, $ConParent, $ConId, $ConLang)
$content = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $ConLang ); {
if (is_null ( $content )) { $content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $ConLang );
//we dont find any value for this field and language in CONTENT table if (is_null( $content )) {
$ConValue = Content::autoLoadSave ( $ConCategory, $ConParent, $ConId, $ConLang ); //we dont find any value for this field and language in CONTENT table;
} else { $ConValue = Content::autoLoadSave( $ConCategory, $ConParent, $ConId, $ConLang );
//krumo($content); } else {
$ConValue = $content->getConValue (); //krumo($content);
if ($ConValue == "") { //try to find a valid translation $ConValue = $content->getConValue();
$ConValue = Content::autoLoadSave ( $ConCategory, $ConParent, $ConId, $ConLang ); if ($ConValue == "") {
} //try to find a valid translation
} $ConValue = Content::autoLoadSave( $ConCategory, $ConParent, $ConId, $ConLang );
return $ConValue; }
} }
/* return $ConValue;
* Find a valid Lang for current Content. The most recent }
/*
* Find a valid Lang for current Content. The most recent
* @param string $ConCategory * @param string $ConCategory
* @param string $ConParent * @param string $ConParent
* @param string $ConId * @param string $ConId
* @return string * @return string
* *
*/ */
function getDefaultContentLang($ConCategory, $ConParent, $ConId, $destConLang) { public function getDefaultContentLang ($ConCategory, $ConParent, $ConId, $destConLang)
$Criteria = new Criteria ( 'workflow' ); {
$Criteria->clearSelectColumns ()->clearOrderByColumns (); $Criteria = new Criteria( 'workflow' );
$Criteria->clearSelectColumns()->clearOrderByColumns();
$Criteria->addSelectColumn ( ContentPeer::CON_CATEGORY );
$Criteria->addSelectColumn ( ContentPeer::CON_PARENT ); $Criteria->addSelectColumn( ContentPeer::CON_CATEGORY );
$Criteria->addSelectColumn ( ContentPeer::CON_ID ); $Criteria->addSelectColumn( ContentPeer::CON_PARENT );
$Criteria->addSelectColumn ( ContentPeer::CON_LANG ); $Criteria->addSelectColumn( ContentPeer::CON_ID );
$Criteria->addSelectColumn ( ContentPeer::CON_VALUE ); $Criteria->addSelectColumn( ContentPeer::CON_LANG );
$Criteria->addSelectColumn( ContentPeer::CON_VALUE );
$Criteria->add ( ContentPeer::CON_CATEGORY, $ConCategory, CRITERIA::EQUAL );
$Criteria->add ( ContentPeer::CON_PARENT, $ConParent, CRITERIA::EQUAL ); $Criteria->add( ContentPeer::CON_CATEGORY, $ConCategory, CRITERIA::EQUAL );
$Criteria->add ( ContentPeer::CON_ID, $ConId, CRITERIA::EQUAL ); $Criteria->add( ContentPeer::CON_PARENT, $ConParent, CRITERIA::EQUAL );
$Criteria->add( ContentPeer::CON_ID, $ConId, CRITERIA::EQUAL );
$Criteria->add ( ContentPeer::CON_LANG, $destConLang, CRITERIA::NOT_EQUAL ); $Criteria->add( ContentPeer::CON_LANG, $destConLang, CRITERIA::NOT_EQUAL );
$rs = ContentPeer::doSelectRS ( $Criteria ); $rs = ContentPeer::doSelectRS( $Criteria );
$rs->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rs->next (); $rs->next();
if (is_array ( $row = $rs->getRow () )) { if (is_array( $row = $rs->getRow() )) {
$defaultLang = $row ['CON_LANG']; $defaultLang = $row['CON_LANG'];
} else {
} else { $defaultLang = "";
$defaultLang = ""; }
} return ($defaultLang);
return ($defaultLang); }
} /*
/* * Load the content row and the Save automatically the row for the destination language
* Load the content row and the Save automatically the row for the destination language * @param string $ConCategory
* @param string $ConCategory * @param string $ConParent
* @param string $ConParent * @param string $ConId
* @param string $ConId * @param string $destConLang
* @param string $destConLang * @return string
* @return string * if the row doesn't exist, it will be created automatically, even the default 'en' language
* if the row doesn't exist, it will be created automatically, even the default 'en' language */
*/ public function autoLoadSave ($ConCategory, $ConParent, $ConId, $destConLang)
function autoLoadSave($ConCategory, $ConParent, $ConId, $destConLang) { {
//search in 'en' language, the default language //search in 'en' language, the default language
$content = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, 'en' ); $content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, 'en' );
if ((is_null ( $content )) || ($content->getConValue () == "")) { if ((is_null( $content )) || ($content->getConValue() == "")) {
$differentLang = Content::getDefaultContentLang ( $ConCategory, $ConParent, $ConId, $destConLang ); $differentLang = Content::getDefaultContentLang( $ConCategory, $ConParent, $ConId, $destConLang );
$content = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $differentLang ); $content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $differentLang );
} }
//to do: review if the $destConLang is a valid language/ //to do: review if the $destConLang is a valid language/
if (is_null ( $content )) if (is_null( $content )) {
$ConValue = ''; //we dont find any value for this field and language in CONTENT table $ConValue = '';
else //we dont find any value for this field and language in CONTENT table
$ConValue = $content->getConValue (); } else {
$ConValue = $content->getConValue();
try { }
$con = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $destConLang );
if (is_null ( $con )) { try {
$con = new Content ( ); $con = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $destConLang );
} if (is_null( $con )) {
$con->setConCategory ( $ConCategory ); $con = new Content();
$con->setConParent ( $ConParent ); }
$con->setConId ( $ConId ); $con->setConCategory( $ConCategory );
$con->setConLang ( $destConLang ); $con->setConParent( $ConParent );
$con->setConValue ( $ConValue ); $con->setConId( $ConId );
if ($con->validate ()) { $con->setConLang( $destConLang );
$res = $con->save (); $con->setConValue( $ConValue );
} if ($con->validate()) {
} catch ( Exception $e ) { $res = $con->save();
throw ($e); }
} } catch (Exception $e) {
throw ($e);
return $ConValue; }
}
return $ConValue;
/* }
* Insert a content row
/*
* Insert a content row
* @param string $ConCategory * @param string $ConCategory
* @param string $ConParent * @param string $ConParent
* @param string $ConId * @param string $ConId
* @param string $ConLang * @param string $ConLang
* @param string $ConValue * @param string $ConValue
* @return variant * @return variant
*/ */
function addContent($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) { public function addContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue)
try { {
if ($ConLang != 'en') { try {
$baseLangContent = ContentPeer::retrieveByPk($ConCategory, $ConParent, $ConId, 'en'); if ($ConLang != 'en') {
if ($baseLangContent === null) { $baseLangContent = ContentPeer::retrieveByPk( $ConCategory, $ConParent, $ConId, 'en' );
Content::addContent($ConCategory, $ConParent, $ConId, 'en', $ConValue); if ($baseLangContent === null) {
} Content::addContent( $ConCategory, $ConParent, $ConId, 'en', $ConValue );
} }
}
$con = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $ConLang );
$con = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $ConLang );
if (is_null ( $con )) {
$con = new Content ( ); if (is_null( $con )) {
} else { $con = new Content();
if ($con->getConParent () == $ConParent && $con->getConCategory () == $ConCategory && $con->getConValue () == $ConValue && $con->getConLang () == $ConLang && $con->getConId () == $ConId) } else {
return true; if ($con->getConParent() == $ConParent && $con->getConCategory() == $ConCategory && $con->getConValue() == $ConValue && $con->getConLang() == $ConLang && $con->getConId() == $ConId) {
} return true;
$con->setConCategory ( $ConCategory ); }
if ($con->getConParent () != $ConParent) }
$con->setConParent ( $ConParent ); $con->setConCategory( $ConCategory );
$con->setConId ( $ConId ); if ($con->getConParent() != $ConParent) {
$con->setConLang ( $ConLang ); $con->setConParent( $ConParent );
$con->setConValue ( $ConValue ); }
if ($con->validate ()) { $con->setConId( $ConId );
$res = $con->save (); $con->setConLang( $ConLang );
return $res; $con->setConValue( $ConValue );
} else { if ($con->validate()) {
$e = new Exception ( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" ); $res = $con->save();
throw ($e); return $res;
} } else {
} catch ( Exception $e ) { $e = new Exception( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" );
throw ($e); throw ($e);
} }
} } catch (Exception $e) {
throw ($e);
/* }
* Insert a content row }
/*
* Insert a content row
* @param string $ConCategory * @param string $ConCategory
* @param string $ConParent * @param string $ConParent
* @param string $ConId * @param string $ConId
* @param string $ConLang * @param string $ConLang
* @param string $ConValue * @param string $ConValue
* @return variant * @return variant
*/ */
function insertContent($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) { public function insertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue)
try { {
$con = new Content ( ); try {
$con->setConCategory ( $ConCategory ); $con = new Content();
$con->setConParent ( $ConParent ); $con->setConCategory( $ConCategory );
$con->setConId ( $ConId ); $con->setConParent( $ConParent );
$con->setConLang ( $ConLang ); $con->setConId( $ConId );
$con->setConValue ( $ConValue ); $con->setConLang( $ConLang );
if ($con->validate ()) { $con->setConValue( $ConValue );
$res = $con->save (); if ($con->validate()) {
return $res; $res = $con->save();
} else { return $res;
$e = new Exception ( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" ); } else {
throw ($e); $e = new Exception( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" );
} throw ($e);
} catch ( Exception $e ) { }
throw ($e); } catch (Exception $e) {
} throw ($e);
} }
}
/*
* remove a content row /*
* remove a content row
* @param string $ConCategory * @param string $ConCategory
* @param string $ConParent * @param string $ConParent
* @param string $ConId * @param string $ConId
* @param string $ConLang * @param string $ConLang
* @param string $ConValue * @param string $ConValue
* @return variant * @return variant
*/ */
function removeContent($ConCategory, $ConParent, $ConId) { public function removeContent ($ConCategory, $ConParent, $ConId)
try { {
$c = new Criteria ( ); try {
$c->add ( ContentPeer::CON_CATEGORY, $ConCategory ); $c = new Criteria();
$c->add ( ContentPeer::CON_PARENT, $ConParent ); $c->add( ContentPeer::CON_CATEGORY, $ConCategory );
$c->add ( ContentPeer::CON_ID, $ConId ); $c->add( ContentPeer::CON_PARENT, $ConParent );
$result = ContentPeer::doSelectRS ( $c ); $c->add( ContentPeer::CON_ID, $ConId );
$result->next (); $result = ContentPeer::doSelectRS( $c );
$row = $result->getRow (); $result->next();
while ( is_array ( $row ) ) { $row = $result->getRow();
ContentPeer::doDelete ( array ($ConCategory, $ConParent, $ConId, $row [3] ) ); while (is_array( $row )) {
$result->next (); ContentPeer::doDelete( array ($ConCategory,$ConParent,$ConId,$row[3]) );
$row = $result->getRow (); $result->next();
} $row = $result->getRow();
} catch ( Exception $e ) { }
throw ($e); } catch (Exception $e) {
} throw ($e);
}
}
}
/*
/*
* Reasons if the record already exists * Reasons if the record already exists
* *
* @param string $ConCategory * @param string $ConCategory
* @param string $ConParent * @param string $ConParent
* @param string $ConId * @param string $ConId
* @param string $ConLang * @param string $ConLang
* @param string $ConValue * @param string $ConValue
* @return boolean true or false * @return boolean true or false
*/ */
function Exists ($ConCategory, $ConParent, $ConId, $ConLang) public function Exists ($ConCategory, $ConParent, $ConId, $ConLang)
{ {
try { try {
$oPro = ContentPeer::retrieveByPk($ConCategory, $ConParent, $ConId, $ConLang); $oPro = ContentPeer::retrieveByPk( $ConCategory, $ConParent, $ConId, $ConLang );
if (is_object($oPro) && get_class ($oPro) == 'Content' ) { if (is_object( $oPro ) && get_class( $oPro ) == 'Content') {
return true; return true;
} else { } else {
return false; return false;
} }
} } catch (Exception $oError) {
catch (Exception $oError) { throw ($oError);
throw($oError); }
} }
}
/* /*
* Regenerate Table Content * Regenerate Table Content
* *
* @param array $langs * @param array $langs
*/ */
function regenerateContent($langs, $workSpace=SYS_SYS) public function regenerateContent ($langs, $workSpace = SYS_SYS)
{ {
//Search the language //Search the language
$key = array_search('en',$langs); $key = array_search( 'en', $langs );
if ($key === false) { if ($key === false) {
$key = array_search(SYS_LANG,$langs); $key = array_search( SYS_LANG, $langs );
if ($key === false) { if ($key === false) {
$key = '0'; $key = '0';
} }
} }
$this->langsAsoc = array(); $this->langsAsoc = array ();
foreach ($langs as $key=>$value) { foreach ($langs as $key => $value) {
$this->langsAsoc[$value] = $value; $this->langsAsoc[$value] = $value;
} }
$this->langs = $langs; $this->langs = $langs;
$this->rowsProcessed = 0; $this->rowsProcessed = 0;
$this->rowsInserted = 0; $this->rowsInserted = 0;
$this->rowsUnchanged = 0; $this->rowsUnchanged = 0;
$this->rowsClustered = 0; $this->rowsClustered = 0;
//Creating table CONTENT_BACKUP //Creating table CONTENT_BACKUP
$oConnection = Propel::getConnection('workflow'); $oConnection = Propel::getConnection( 'workflow' );
$oStatement = $oConnection->prepareStatement("CREATE TABLE IF NOT EXISTS `CONTENT_BACKUP` ( $oStatement = $oConnection->prepareStatement( "CREATE TABLE IF NOT EXISTS `CONTENT_BACKUP` (
`CON_CATEGORY` VARCHAR(30) default '' NOT NULL, `CON_CATEGORY` VARCHAR(30) default '' NOT NULL,
`CON_PARENT` VARCHAR(32) default '' NOT NULL, `CON_PARENT` VARCHAR(32) default '' NOT NULL,
`CON_ID` VARCHAR(100) default '' NOT NULL, `CON_ID` VARCHAR(100) default '' NOT NULL,
`CON_LANG` VARCHAR(10) default '' NOT NULL, `CON_LANG` VARCHAR(10) default '' NOT NULL,
`CON_VALUE` MEDIUMTEXT NOT NULL, `CON_VALUE` MEDIUMTEXT NOT NULL,
CONSTRAINT CONTENT_BACKUP_PK PRIMARY KEY (CON_CATEGORY,CON_PARENT,CON_ID,CON_LANG) CONSTRAINT CONTENT_BACKUP_PK PRIMARY KEY (CON_CATEGORY,CON_PARENT,CON_ID,CON_LANG)
)Engine=MyISAM DEFAULT CHARSET='utf8' COMMENT='Table for add content';"); )Engine=MyISAM DEFAULT CHARSET='utf8' COMMENT='Table for add content';" );
$oStatement->executeQuery(); $oStatement->executeQuery();
$con = Propel::getConnection('workflow'); $con = Propel::getConnection( 'workflow' );
$sql = " SELECT DISTINCT CON_LANG $sql = " SELECT DISTINCT CON_LANG
FROM CONTENT "; FROM CONTENT ";
$stmt = $con->createStatement(); $stmt = $con->createStatement();
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC); $rs = $stmt->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC );
while ($rs->next()) { while ($rs->next()) {
$row = $rs->getRow(); $row = $rs->getRow();
$language = $row['CON_LANG']; $language = $row['CON_LANG'];
if (array_search($row['CON_LANG'],$langs) === false) { if (array_search( $row['CON_LANG'], $langs ) === false) {
Content::removeLanguageContent($row['CON_LANG']); Content::removeLanguageContent( $row['CON_LANG'] );
} }
} }
$sql = " SELECT CON_ID, CON_CATEGORY, CON_LANG, CON_PARENT, CON_VALUE $sql = " SELECT CON_ID, CON_CATEGORY, CON_LANG, CON_PARENT, CON_VALUE
FROM CONTENT FROM CONTENT
ORDER BY CON_ID, CON_CATEGORY, CON_PARENT, CON_LANG"; ORDER BY CON_ID, CON_CATEGORY, CON_PARENT, CON_LANG";
G::LoadClass("wsTools"); G::LoadClass( "wsTools" );
$workSpace = new workspaceTools($workSpace); $workSpace = new workspaceTools( $workSpace );
$workSpace->getDBInfo(); $workSpace->getDBInfo();
$link = mysql_pconnect($workSpace->dbHost, $workSpace->dbUser, $workSpace->dbPass) $link = mysql_pconnect( $workSpace->dbHost, $workSpace->dbUser, $workSpace->dbPass ) or die( "Could not connect" );
or die ("Could not connect");
mysql_select_db( $workSpace->dbName, $link );
mysql_select_db($workSpace->dbName, $link); mysql_query( "SET NAMES 'utf8';" );
mysql_query("SET NAMES 'utf8';"); mysql_query( 'SET OPTION SQL_BIG_SELECTS=1' );
mysql_query('SET OPTION SQL_BIG_SELECTS=1'); $result = mysql_unbuffered_query( $sql, $link );
$result = mysql_unbuffered_query($sql, $link); $list = array ();
$list = array(); $default = array ();
$default = array(); $sw = array ('CON_ID' => '','CON_CATEGORY' => '','CON_PARENT' => ''
$sw = array('CON_ID'=>'','CON_CATEGORY'=>'','CON_PARENT'=>''); );
while ($row = mysql_fetch_assoc($result)) { while ($row = mysql_fetch_assoc( $result )) {
if ($sw['CON_ID'] == $row['CON_ID'] && if ($sw['CON_ID'] == $row['CON_ID'] && $sw['CON_CATEGORY'] == $row['CON_CATEGORY'] && $sw['CON_PARENT'] == $row['CON_PARENT']) {
$sw['CON_CATEGORY'] == $row['CON_CATEGORY'] && $list[] = $row;
$sw['CON_PARENT'] == $row['CON_PARENT']) { } else {
$list[] = $row; $this->rowsClustered ++;
} else { if (count( $langs ) != count( $list )) {
$this->rowsClustered++; $this->checkLanguage( $list, $default );
if (count($langs) != count($list)) { } else {
$this->checkLanguage($list, $default); $this->rowsUnchanged = $this->rowsUnchanged + count( $langs );
} else { }
$this->rowsUnchanged = $this->rowsUnchanged + count($langs); $sw = array ();
} $sw['CON_ID'] = $row['CON_ID'];
$sw = array(); $sw['CON_CATEGORY'] = $row['CON_CATEGORY'];
$sw['CON_ID'] = $row['CON_ID']; $sw['CON_LANG'] = $row['CON_LANG'];
$sw['CON_CATEGORY'] = $row['CON_CATEGORY']; $sw['CON_PARENT'] = $row['CON_PARENT'];
$sw['CON_LANG'] = $row['CON_LANG']; unset( $list );
$sw['CON_PARENT'] = $row['CON_PARENT']; unset( $default );
unset($list); $list = array ();
unset($default); $default = array ();
$list = array(); $list[] = $row;
$default = array(); }
$list[] = $row; if ($sw['CON_LANG'] == $langs[$key]) {
} $default = $row;
if ($sw['CON_LANG'] == $langs[$key]) { }
$default = $row; $this->rowsProcessed ++;
} }
$this->rowsProcessed++; if (count( $langs ) != count( $list )) {
} $this->checkLanguage( $list, $default );
if (count($langs) != count($list)) { } else {
$this->checkLanguage($list, $default); $this->rowsUnchanged = $this->rowsUnchanged + count( $langs );
} else { }
$this->rowsUnchanged = $this->rowsUnchanged + count($langs); mysql_free_result( $result );
} $total = $this->rowsProcessed + $this->rowsInserted;
mysql_free_result($result); $connection = Propel::getConnection( 'workflow' );
$total = $this->rowsProcessed + $this->rowsInserted; $statement = $connection->prepareStatement( "INSERT INTO CONTENT
$connection = Propel::getConnection('workflow');
$statement = $connection->prepareStatement("INSERT INTO CONTENT
SELECT CON_CATEGORY, CON_PARENT, CON_ID , CON_LANG, CON_VALUE SELECT CON_CATEGORY, CON_PARENT, CON_ID , CON_LANG, CON_VALUE
FROM CONTENT_BACKUP"); FROM CONTENT_BACKUP" );
$statement->executeQuery(); $statement->executeQuery();
$statement = $connection->prepareStatement("DROP TABLE CONTENT_BACKUP"); $statement = $connection->prepareStatement( "DROP TABLE CONTENT_BACKUP" );
$statement->executeQuery(); $statement->executeQuery();
if (!isset($_SERVER['SERVER_NAME'])) { if (! isset( $_SERVER['SERVER_NAME'] )) {
CLI::logging("Rows Processed ---> $this->rowsProcessed ..... \n"); CLI::logging( "Rows Processed ---> $this->rowsProcessed ..... \n" );
CLI::logging("Rows Clustered ---> $this->rowsClustered ..... \n"); CLI::logging( "Rows Clustered ---> $this->rowsClustered ..... \n" );
CLI::logging("Rows Unchanged ---> $this->rowsUnchanged ..... \n"); CLI::logging( "Rows Unchanged ---> $this->rowsUnchanged ..... \n" );
CLI::logging("Rows Inserted ---> $this->rowsInserted ..... \n"); CLI::logging( "Rows Inserted ---> $this->rowsInserted ..... \n" );
CLI::logging("Rows Total ---> $total ..... \n"); CLI::logging( "Rows Total ---> $total ..... \n" );
} }
} }
function checkLanguage($content, $default) public function checkLanguage ($content, $default)
{ {
if (count($content)>0) { if (count( $content ) > 0) {
$langs = $this->langs; $langs = $this->langs;
$langsAsoc = $this->langsAsoc; $langsAsoc = $this->langsAsoc;
//Element default //Element default
$default = (count($default)>0) ? $default : $content[0]; $default = (count( $default ) > 0) ? $default : $content[0];
foreach ($content as $key => $value) { foreach ($content as $key => $value) {
unset($langsAsoc[$value['CON_LANG']]); unset( $langsAsoc[$value['CON_LANG']] );
} }
foreach ($langsAsoc as $key => $value) { foreach ($langsAsoc as $key => $value) {
$this->rowsInserted++; $this->rowsInserted ++;
$this->fastInsertContent( $this->fastInsertContent( $default['CON_CATEGORY'], $default['CON_PARENT'], $default['CON_ID'], $value, $default['CON_VALUE'] );
$default['CON_CATEGORY'], }
$default['CON_PARENT'], }
$default['CON_ID'], }
$value,
$default['CON_VALUE'] public function fastInsertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue)
); {
} $ConValue = mysql_real_escape_string( $ConValue );
} $connection = Propel::getConnection( 'workflow' );
} $statement = $connection->prepareStatement( "INSERT INTO CONTENT_BACKUP (
function fastInsertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) {
$ConValue = mysql_real_escape_string($ConValue);
$connection = Propel::getConnection('workflow');
$statement = $connection->prepareStatement("INSERT INTO CONTENT_BACKUP (
CON_CATEGORY, CON_PARENT, CON_ID , CON_LANG, CON_VALUE) CON_CATEGORY, CON_PARENT, CON_ID , CON_LANG, CON_VALUE)
VALUES ('$ConCategory', '$ConParent', '$ConId', '$ConLang', '$ConValue');"); VALUES ('$ConCategory', '$ConParent', '$ConId', '$ConLang', '$ConValue');" );
$statement->executeQuery(); $statement->executeQuery();
} }
function removeLanguageContent($lanId) { public function removeLanguageContent ($lanId)
try { {
$c = new Criteria ( ); try {
$c->addSelectColumn(ContentPeer::CON_CATEGORY); $c = new Criteria();
$c->addSelectColumn(ContentPeer::CON_PARENT); $c->addSelectColumn( ContentPeer::CON_CATEGORY );
$c->addSelectColumn(ContentPeer::CON_ID); $c->addSelectColumn( ContentPeer::CON_PARENT );
$c->addSelectColumn(ContentPeer::CON_LANG); $c->addSelectColumn( ContentPeer::CON_ID );
$c->addSelectColumn( ContentPeer::CON_LANG );
$c->add ( ContentPeer::CON_LANG, $lanId );
$c->add( ContentPeer::CON_LANG, $lanId );
$result = ContentPeer::doSelectRS ( $c );
$result->setFetchmode(ResultSet::FETCHMODE_ASSOC); $result = ContentPeer::doSelectRS( $c );
$result->next (); $result->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$row = $result->getRow (); $result->next();
$row = $result->getRow();
while ( is_array ( $row ) ) {
$content = ContentPeer::retrieveByPK( $row['CON_CATEGORY'], $row['CON_PARENT'], $row['CON_ID'], $lanId); while (is_array( $row )) {
$content = ContentPeer::retrieveByPK( $row['CON_CATEGORY'], $row['CON_PARENT'], $row['CON_ID'], $lanId );
if( $content !== null )
$content->delete(); if ($content !== null) {
$content->delete();
$result->next (); }
$row = $result->getRow (); $result->next();
} $row = $result->getRow();
}
} catch ( Exception $e ) {
throw ($e); } catch (Exception $e) {
} throw ($e);
} }
//Added by Enrique at Feb 9th,2011 }
//Gets all Role Names by Role //Added by Enrique at Feb 9th,2011
function getAllContentsByRole($sys_lang=SYS_LANG){ //Gets all Role Names by Role
if (!isset($sys_lang)) $sys_lang = 'en'; public function getAllContentsByRole ($sys_lang = SYS_LANG)
$oCriteria = new Criteria('workflow'); {
$oCriteria->clearSelectColumns(); if (! isset( $sys_lang )) {
$oCriteria->addSelectColumn(ContentPeer::CON_ID); $sys_lang = 'en';
$oCriteria->addAsColumn('ROL_NAME', ContentPeer::CON_VALUE); }
//$oCriteria->addAsColumn('ROL_UID', ContentPeer::CON_ID); $oCriteria = new Criteria( 'workflow' );
$oCriteria->add(ContentPeer::CON_CATEGORY,'ROL_NAME'); $oCriteria->clearSelectColumns();
$oCriteria->add(ContentPeer::CON_LANG, $sys_lang); $oCriteria->addSelectColumn( ContentPeer::CON_ID );
$oDataset = ContentPeer::doSelectRS($oCriteria); $oCriteria->addAsColumn( 'ROL_NAME', ContentPeer::CON_VALUE );
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); //$oCriteria->addAsColumn('ROL_UID', ContentPeer::CON_ID);
$aRoles = Array(); $oCriteria->add( ContentPeer::CON_CATEGORY, 'ROL_NAME' );
while ($oDataset->next()){ $oCriteria->add( ContentPeer::CON_LANG, $sys_lang );
$xRow = $oDataset->getRow(); $oDataset = ContentPeer::doSelectRS( $oCriteria );
$aRoles[$xRow['CON_ID']] = $xRow['ROL_NAME']; $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
} $aRoles = Array ();
return $aRoles; while ($oDataset->next()) {
} $xRow = $oDataset->getRow();
$aRoles[$xRow['CON_ID']] = $xRow['ROL_NAME'];
} // Content }
return $aRoles;
}
}
// Content

View File

@@ -1,231 +1,227 @@
<?php <?php
/** /**
* ReportTable.php * ReportTable.php
* @package workflow.engine.classes.model *
* * @package workflow.engine.classes.model
* ProcessMaker Open Source Edition *
* Copyright (C) 2004 - 2011 Colosa Inc. * ProcessMaker Open Source Edition
* * Copyright (C) 2004 - 2011 Colosa Inc.
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * This program is free software: you can redistribute it and/or modify
* published by the Free Software Foundation, either version 3 of the * it under the terms of the GNU Affero General Public License as
* License, or (at your option) any later version. * published by the Free Software Foundation, either version 3 of the
* * License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * This program is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU Affero General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. * You should have received a copy of the GNU Affero General Public License
* * along with this program. If not, see <http://www.gnu.org/licenses/>.
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., *
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ *
*/
require_once 'classes/model/Content.php';
require_once 'classes/model/om/BaseReportTable.php'; require_once 'classes/model/Content.php';
require_once 'classes/model/om/BaseReportTable.php';
/** /**
* Skeleton subclass for representing a row from the 'REPORT_TABLE' table. * Skeleton subclass for representing a row from the 'REPORT_TABLE' table.
* *
* *
* *
* You should add additional methods to this class to meet the * You should add additional methods to this class to meet the
* application requirements. This class will only be generated as * application requirements. This class will only be generated as
* long as it does not already exist in the output directory. * long as it does not already exist in the output directory.
* *
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
*/ */
class ReportTable extends BaseReportTable { class ReportTable extends BaseReportTable
/** {
* This value goes in the content table /**
* @var string * This value goes in the content table
*/ *
protected $rep_tab_title = ''; * @var string
*/
/** protected $rep_tab_title = '';
* Get the rep_tab_title column value.
* @return string /**
*/ * Get the rep_tab_title column value.
public function getRepTabTitle() { *
if ( $this->getRepTabUid() == "" ) { * @return string
throw ( new Exception( "Error in getRepTabTitle, the getRepTabUid() can't be blank") ); */
} public function getRepTabTitle ()
$lang = defined ( 'SYS_LANG' ) ? SYS_LANG : 'en'; {
$this->rep_tab_title = Content::load ( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang ); if ($this->getRepTabUid() == "") {
return $this->rep_tab_title; throw (new Exception( "Error in getRepTabTitle, the getRepTabUid() can't be blank" ));
} }
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
/** $this->rep_tab_title = Content::load( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang );
* Set the rep_tab_title column value. return $this->rep_tab_title;
* }
* @param string $v new value
* @return void /**
*/ * Set the rep_tab_title column value.
public function setRepTabTitle($v) *
{ * @param string $v new value
if ( $this->getRepTabUid() == "" ) { * @return void
throw ( new Exception( "Error in setRepTabTitle, the setRepTabUid() can't be blank") ); */
} public function setRepTabTitle ($v)
$v=isset($v)?((string)$v):''; {
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; if ($this->getRepTabUid() == "") {
if ($this->rep_tab_title !== $v || $v==="") { throw (new Exception( "Error in setRepTabTitle, the setRepTabUid() can't be blank" ));
$this->rep_tab_title = $v; }
$res = Content::addContent( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang, $this->rep_tab_title ); $v = isset( $v ) ? ((string) $v) : '';
return $res; $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
} if ($this->rep_tab_title !== $v || $v === "") {
return 0; $this->rep_tab_title = $v;
} $res = Content::addContent( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang, $this->rep_tab_title );
return $res;
public function load($RepTabUid) }
{ return 0;
try { }
$oRow = ReportTablePeer::retrieveByPK( $RepTabUid );
if (!is_null($oRow)) public function load ($RepTabUid)
{ {
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME); try {
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); $oRow = ReportTablePeer::retrieveByPK( $RepTabUid );
$this->setNew(false); if (! is_null( $oRow )) {
$this->setRepTabTitle($aFields['REP_TAB_TITLE']=$this->getRepTabTitle()); $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
return $aFields; $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
} $this->setNew( false );
else { $this->setRepTabTitle( $aFields['REP_TAB_TITLE'] = $this->getRepTabTitle() );
//throw( new Exception( "The row '$RepTabUid' in table ReportTable doesn't exist!" )); return $aFields;
return array(); } else {
} //throw( new Exception( "The row '$RepTabUid' in table ReportTable doesn't exist!" ));
} return array ();
catch (Exception $oError) { }
throw($oError); } catch (Exception $oError) {
} throw ($oError);
} }
public function create($aData) }
{
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME); public function create ($aData)
try {
{ $con = Propel::getConnection( ReportTablePeer::DATABASE_NAME );
$con->begin(); try {
if ( isset ( $aData['REP_TAB_UID'] ) && $aData['REP_TAB_UID']== '' ) $con->begin();
unset ( $aData['REP_TAB_UID'] ); if (isset( $aData['REP_TAB_UID'] ) && $aData['REP_TAB_UID'] == '') {
if ( !isset ( $aData['REP_TAB_UID'] ) ) unset( $aData['REP_TAB_UID'] );
$this->setRepTabUid(G::generateUniqueID()); }
else if (! isset( $aData['REP_TAB_UID'] )) {
$this->setRepTabUid($aData['REP_TAB_UID'] ); $this->setRepTabUid( G::generateUniqueID() );
} else {
$this->setProUid($aData['PRO_UID']); $this->setRepTabUid( $aData['REP_TAB_UID'] );
$this->setRepTabName($aData['REP_TAB_NAME']); }
$this->setRepTabType($aData['REP_TAB_TYPE']);
if ( !isset ( $aData['REP_TAB_GRID'] ) ) $this->setProUid( $aData['PRO_UID'] );
$this->setRepTabGrid(""); $this->setRepTabName( $aData['REP_TAB_NAME'] );
else $this->setRepTabType( $aData['REP_TAB_TYPE'] );
$this->setRepTabGrid( $aData['REP_TAB_GRID'] ); if (! isset( $aData['REP_TAB_GRID'] )) {
if ( !isset ( $aData['REP_TAB_CONNECTION'] ) ) $this->setRepTabGrid( "" );
$this->setRepTabConnection("report"); } else {
else $this->setRepTabGrid( $aData['REP_TAB_GRID'] );
$this->setRepTabConnection( $aData['REP_TAB_CONNECTION'] ); }
$this->setRepTabCreateDate(date('Y-m-d H:i:s')); if (! isset( $aData['REP_TAB_CONNECTION'] )) {
$this->setRepTabStatus('ACTIVE'); $this->setRepTabConnection( "report" );
} else {
if($this->validate()) $this->setRepTabConnection( $aData['REP_TAB_CONNECTION'] );
{ }
if ( !isset ( $aData['REP_TAB_TITLE'] ) ) $this->setRepTabCreateDate( date( 'Y-m-d H:i:s' ) );
$this->setRepTabTitle(""); $this->setRepTabStatus( 'ACTIVE' );
else
$this->setRepTabTitle( $aData['REP_TAB_TITLE'] ); if ($this->validate()) {
if (! isset( $aData['REP_TAB_TITLE'] )) {
$result=$this->save(); $this->setRepTabTitle( "" );
$con->commit(); } else {
return $result; $this->setRepTabTitle( $aData['REP_TAB_TITLE'] );
} }
else $result = $this->save();
{ $con->commit();
$con->rollback(); return $result;
throw(new Exception("Failed Validation in class ".get_class($this).".")); } else {
} $con->rollback();
} throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
catch(Exception $e) }
{ } catch (Exception $e) {
$con->rollback(); $con->rollback();
throw($e); throw ($e);
} }
} }
public function update($fields)
{ public function update ($fields)
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME); {
try $con = Propel::getConnection( ReportTablePeer::DATABASE_NAME );
{ try {
$con->begin(); $con->begin();
$this->load($fields['REP_TAB_UID']); $this->load( $fields['REP_TAB_UID'] );
$this->fromArray($fields,BasePeer::TYPE_FIELDNAME); $this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
$sDataBase = 'database_' . strtolower(DB_ADAPTER); $sDataBase = 'database_' . strtolower( DB_ADAPTER );
if(G::LoadSystemExist($sDataBase)){ if (G::LoadSystemExist( $sDataBase )) {
G::LoadSystem($sDataBase); G::LoadSystem( $sDataBase );
$oDataBase = new database(); $oDataBase = new database();
$oValidate = $oDataBase->getValidate($this->validate()); $oValidate = $oDataBase->getValidate( $this->validate() );
} else { } else {
$oValidate = $this->validate(); $oValidate = $this->validate();
} }
// if($this->validate()) // if($this->validate())
if($oValidate) if ($oValidate) {
{ $contentResult = 0;
$contentResult=0; if (array_key_exists( "REP_TAB_TITLE", $fields )) {
if (array_key_exists("REP_TAB_TITLE", $fields)) $contentResult+=$this->setRepTabTitle($fields["REP_TAB_TITLE"]); $contentResult += $this->setRepTabTitle( $fields["REP_TAB_TITLE"] );
$result=$this->save(); }
$result=($result==0)?($contentResult>0?1:0):$result; $result = $this->save();
$con->commit(); $result = ($result == 0) ? ($contentResult > 0 ? 1 : 0) : $result;
return $result; $con->commit();
} return $result;
else } else {
{ $con->rollback();
$con->rollback(); $validationE = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
$validationE=new Exception("Failed Validation in class ".get_class($this)."."); $validationE->aValidationFailures = $this->getValidationFailures();
$validationE->aValidationFailures = $this->getValidationFailures(); throw ($validationE);
throw($validationE); }
} } catch (Exception $e) {
} $con->rollback();
catch(Exception $e) throw ($e);
{ }
$con->rollback(); }
throw($e);
} public function remove ($RepTabUid)
} {
public function remove($RepTabUid) $con = Propel::getConnection( ReportTablePeer::DATABASE_NAME );
{ try {
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME); $con->begin();
try $oRepTab = ReportTablePeer::retrieveByPK( $RepTabUid );
{ if (! is_null( $oRepTab )) {
$con->begin(); Content::removeContent( 'REP_TAB_TITLE', '', $this->getRepTabUid() );
$oRepTab = ReportTablePeer::retrieveByPK( $RepTabUid ); $result = $oRepTab->delete();
if (!is_null($oRepTab)) { $con->commit();
Content::removeContent( 'REP_TAB_TITLE', '', $this->getRepTabUid()); }
$result = $oRepTab->delete(); return $result;
$con->commit(); } catch (Exception $e) {
} $con->rollback();
return $result; throw ($e);
} }
catch(Exception $e) }
{
$con->rollback(); public function reportTableExists ($RepTabUid)
throw($e); {
} $con = Propel::getConnection( ReportTablePeer::DATABASE_NAME );
} try {
$oRepTabUid = ReportTablePeer::retrieveByPk( $RepTabUid );
function reportTableExists ( $RepTabUid ) { if (is_object( $oRepTabUid ) && get_class( $oRepTabUid ) == 'ReportTable') {
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME); return true;
try { } else {
$oRepTabUid = ReportTablePeer::retrieveByPk( $RepTabUid ); return false;
if (is_object($oRepTabUid) && get_class ($oRepTabUid) == 'ReportTable' ) { }
return true; } catch (Exception $oError) {
} throw ($oError);
else { }
return false; }
} }
} // ReportTable
catch (Exception $oError) {
throw($oError);
}
}
} // ReportTable

View File

@@ -1,216 +1,217 @@
<?php <?php
/** /**
* Route.php * Route.php
* @package workflow.engine.classes.model *
* * @package workflow.engine.classes.model
* ProcessMaker Open Source Edition *
* Copyright (C) 2004 - 2011 Colosa Inc. * ProcessMaker Open Source Edition
* * Copyright (C) 2004 - 2011 Colosa Inc.
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * This program is free software: you can redistribute it and/or modify
* published by the Free Software Foundation, either version 3 of the * it under the terms of the GNU Affero General Public License as
* License, or (at your option) any later version. * published by the Free Software Foundation, either version 3 of the
* * License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * This program is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU Affero General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. * You should have received a copy of the GNU Affero General Public License
* * along with this program. If not, see <http://www.gnu.org/licenses/>.
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., *
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ *
*/
require_once 'classes/model/om/BaseRoute.php';
require_once 'classes/model/Content.php'; require_once 'classes/model/om/BaseRoute.php';
require_once 'classes/model/Content.php';
/**
* Skeleton subclass for representing a row from the 'ROUTE' table. /**
* * Skeleton subclass for representing a row from the 'ROUTE' table.
* *
* *
* You should add additional methods to this class to meet the *
* application requirements. This class will only be generated as * You should add additional methods to this class to meet the
* long as it does not already exist in the output directory. * application requirements. This class will only be generated as
* * long as it does not already exist in the output directory.
* @package workflow.engine.classes.model *
*/ * @package workflow.engine.classes.model
class Route extends BaseRoute { */
class Route extends BaseRoute
/* {
/*
* Load the application document registry * Load the application document registry
* @param string $sRouUid * @param string $sRouUid
* @return variant * @return variant
*/ */
public function load($sRouUid) public function load ($sRouUid)
{ {
try { try {
$oRoute = RoutePeer::retrieveByPK($sRouUid); $oRoute = RoutePeer::retrieveByPK( $sRouUid );
if (!is_null($oRoute)) if (! is_null( $oRoute )) {
{ $aFields = $oRoute->toArray( BasePeer::TYPE_FIELDNAME );
$aFields = $oRoute->toArray(BasePeer::TYPE_FIELDNAME); $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); return $aFields;
return $aFields; } else {
} throw (new Exception( 'This row doesn\'t exist!' ));
else { }
throw(new Exception('This row doesn\'t exist!')); } catch (Exception $oError) {
} throw ($oError);
} }
catch (Exception $oError) { }
throw($oError);
} /**
} * Create the application document registry
*
/** * @param array $aData
* Create the application document registry * @return string
* @param array $aData *
* @return string */
**/ public function create ($aData)
public function create($aData) {
{ $oConnection = Propel::getConnection( RoutePeer::DATABASE_NAME );
$oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME); try {
try { $sRouteUID = G::generateUniqueID();
$sRouteUID = G::generateUniqueID(); $aData['ROU_UID'] = $sRouteUID;
$aData['ROU_UID'] = $sRouteUID; $oRoute = new Route();
$oRoute = new Route();
// validating default values
// validating default values $aData['ROU_TO_LAST_USER'] = $this->validateValue( isset( $aData['ROU_TO_LAST_USER'] ) ? $aData['ROU_TO_LAST_USER'] : '', array ('TRUE','FALSE'
$aData['ROU_TO_LAST_USER'] = $this->validateValue(isset($aData['ROU_TO_LAST_USER']) ? $aData['ROU_TO_LAST_USER'] : '', array('TRUE', 'FALSE'), 'FALSE'); ), 'FALSE' );
$aData['ROU_OPTIONAL'] = $this->validateValue(isset($aData['ROU_OPTIONAL']) ? $aData['ROU_OPTIONAL'] : '', array('TRUE', 'FALSE'), 'FALSE'); $aData['ROU_OPTIONAL'] = $this->validateValue( isset( $aData['ROU_OPTIONAL'] ) ? $aData['ROU_OPTIONAL'] : '', array ('TRUE','FALSE'
$aData['ROU_SEND_EMAIL'] = $this->validateValue(isset($aData['ROU_SEND_EMAIL']) ? $aData['ROU_SEND_EMAIL']: '', array('TRUE', 'FALSE'), 'TRUE'); ), 'FALSE' );
$aData['ROU_SEND_EMAIL'] = $this->validateValue( isset( $aData['ROU_SEND_EMAIL'] ) ? $aData['ROU_SEND_EMAIL'] : '', array ('TRUE','FALSE'
$oRoute->fromArray($aData, BasePeer::TYPE_FIELDNAME); ), 'TRUE' );
if ($oRoute->validate()) { $oRoute->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
$oConnection->begin();
$iResult = $oRoute->save(); if ($oRoute->validate()) {
$oConnection->commit(); $oConnection->begin();
return $sRouteUID; $iResult = $oRoute->save();
} $oConnection->commit();
else { return $sRouteUID;
$sMessage = ''; } else {
$aValidationFailures = $oRoute->getValidationFailures(); $sMessage = '';
foreach($aValidationFailures as $oValidationFailure) { $aValidationFailures = $oRoute->getValidationFailures();
$sMessage .= $oValidationFailure->getMessage() . '<br />'; foreach ($aValidationFailures as $oValidationFailure) {
} $sMessage .= $oValidationFailure->getMessage() . '<br />';
throw(new Exception('The registry cannot be created!<br />'.$sMessage)); }
} throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
} }
catch (Exception $oError) { } catch (Exception $oError) {
$oConnection->rollback(); $oConnection->rollback();
throw($oError); throw ($oError);
} }
} }
/**
/** * Update the application document registry
* Update the application document registry *
* @param array $aData * @param array $aData
* @return string * @return string
**/ *
public function update($aData) */
{ public function update ($aData)
$oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME); {
try { $oConnection = Propel::getConnection( RoutePeer::DATABASE_NAME );
$oRoute = RoutePeer::retrieveByPK($aData['ROU_UID']); try {
if (!is_null($oRoute)) $oRoute = RoutePeer::retrieveByPK( $aData['ROU_UID'] );
{ if (! is_null( $oRoute )) {
// validating default values // validating default values
if (isset($aData['ROU_TO_LAST_USER'])) { if (isset( $aData['ROU_TO_LAST_USER'] )) {
$aData['ROU_TO_LAST_USER'] = $this->validateValue($aData['ROU_TO_LAST_USER'], array('TRUE', 'FALSE'), 'FALSE'); $aData['ROU_TO_LAST_USER'] = $this->validateValue( $aData['ROU_TO_LAST_USER'], array ('TRUE','FALSE'
} ), 'FALSE' );
if (isset($aData['ROU_OPTIONAL'])) { }
$aData['ROU_OPTIONAL'] = $this->validateValue($aData['ROU_OPTIONAL'], array('TRUE', 'FALSE'), 'FALSE'); if (isset( $aData['ROU_OPTIONAL'] )) {
} $aData['ROU_OPTIONAL'] = $this->validateValue( $aData['ROU_OPTIONAL'], array ('TRUE','FALSE'
if (isset($aData['ROU_SEND_EMAIL'])) { ), 'FALSE' );
$aData['ROU_SEND_EMAIL'] = $this->validateValue($aData['ROU_SEND_EMAIL'], array('TRUE', 'FALSE'), 'TRUE'); }
} if (isset( $aData['ROU_SEND_EMAIL'] )) {
$aData['ROU_SEND_EMAIL'] = $this->validateValue( $aData['ROU_SEND_EMAIL'], array ('TRUE','FALSE'
$oRoute->fromArray($aData, BasePeer::TYPE_FIELDNAME); ), 'TRUE' );
if ($oRoute->validate()) { }
$oConnection->begin();
$iResult = $oRoute->save(); $oRoute->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
$oConnection->commit(); if ($oRoute->validate()) {
return $iResult; $oConnection->begin();
} $iResult = $oRoute->save();
else { $oConnection->commit();
$sMessage = ''; return $iResult;
$aValidationFailures = $oRoute->getValidationFailures(); } else {
foreach($aValidationFailures as $oValidationFailure) { $sMessage = '';
$sMessage .= $oValidationFailure->getMessage() . '<br />'; $aValidationFailures = $oRoute->getValidationFailures();
} foreach ($aValidationFailures as $oValidationFailure) {
throw(new Exception('The ROUTE tables cannot be updated!<br />'.$sMessage)); $sMessage .= $oValidationFailure->getMessage() . '<br />';
} }
} throw (new Exception( 'The ROUTE tables cannot be updated!<br />' . $sMessage ));
else { }
throw(new Exception( "The row " . $aData['ROU_UID'] . " doesn't exist!" )); } else {
} throw (new Exception( "The row " . $aData['ROU_UID'] . " doesn't exist!" ));
} }
catch (Exception $oError) { } catch (Exception $oError) {
$oConnection->rollback(); $oConnection->rollback();
throw($oError); throw ($oError);
} }
} }
/** /**
* Remove the application document registry * Remove the application document registry
* @param array $aData *
* @return string * @param array $aData
**/ * @return string
public function remove($sRouUid) *
{ */
$oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME); public function remove ($sRouUid)
try { {
$oRoute = RoutePeer::retrieveByPK($sRouUid); $oConnection = Propel::getConnection( RoutePeer::DATABASE_NAME );
if (!is_null($oRoute)) try {
{ $oRoute = RoutePeer::retrieveByPK( $sRouUid );
$oConnection->begin(); if (! is_null( $oRoute )) {
$iResult = $oRoute->delete(); $oConnection->begin();
$oConnection->commit(); $iResult = $oRoute->delete();
return $iResult; $oConnection->commit();
} return $iResult;
else { } else {
throw(new Exception('This row doesn\'t exist!')); throw (new Exception( 'This row doesn\'t exist!' ));
} }
} } catch (Exception $oError) {
catch (Exception $oError) { $oConnection->rollback();
$oConnection->rollback(); throw ($oError);
throw($oError); }
} }
}
public function routeExists ($sRouUid)
function routeExists ( $sRouUid ) { {
$con = Propel::getConnection(RoutePeer::DATABASE_NAME); $con = Propel::getConnection( RoutePeer::DATABASE_NAME );
try { try {
$oRouUid = RoutePeer::retrieveByPk( $sRouUid ); $oRouUid = RoutePeer::retrieveByPk( $sRouUid );
if (is_object($oRouUid) && get_class ($oRouUid) == 'Route' ) { if (is_object( $oRouUid ) && get_class( $oRouUid ) == 'Route') {
return true; return true;
} } else {
else { return false;
return false; }
} } catch (Exception $oError) {
} throw ($oError);
catch (Exception $oError) { }
throw($oError); }
}
} /**
* Validate value for a variable that only accepts some determinated values
/** *
* Validate value for a variable that only accepts some determinated values * @param $value string - value to test
* * @param $validValues array - list of valid values
* @param $value string - value to test * @param $default string default value, if the tested value is not valid the default value is returned
* @param $validValues array - list of valid values * @return the tested and accepted value
* @param $default string default value, if the tested value is not valid the default value is returned */
* @return the tested and accepted value public function validateValue ($value, $validValues, $default)
*/ {
function validateValue($value, $validValues, $default) if (! in_array( $value, $validValues )) {
{ $value = $default;
if (!in_array($value, $validValues)) { }
$value = $default; return $value;
} }
}
return $value; // Route
}
} // Route

View File

@@ -1,200 +1,193 @@
<?php <?php
/** /**
* Stage.php * Stage.php
* @package workflow.engine.classes.model *
*/ * @package workflow.engine.classes.model
*/
require_once 'classes/model/Content.php';
require_once 'classes/model/om/BaseStage.php'; require_once 'classes/model/Content.php';
require_once 'classes/model/om/BaseStage.php';
/** /**
* Skeleton subclass for representing a row from the 'STAGE' table. * Skeleton subclass for representing a row from the 'STAGE' table.
* *
* *
* *
* You should add additional methods to this class to meet the * You should add additional methods to this class to meet the
* application requirements. This class will only be generated as * application requirements. This class will only be generated as
* long as it does not already exist in the output directory. * long as it does not already exist in the output directory.
* *
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
*/ */
class Stage extends BaseStage { class Stage extends BaseStage
{
/** /**
* This value goes in the content table * This value goes in the content table
* @var string *
*/ * @var string
protected $stg_title = ''; */
protected $stg_title = '';
/**
* Get the stg_title column value. /**
* @return string * Get the stg_title column value.
*/ *
public function getStgTitle() { * @return string
if ( $this->getStgUid() == "" ) { */
throw ( new Exception( "Error in getStgTitle, the getStgUid() can't be blank") ); public function getStgTitle ()
} {
$lang = defined ( 'SYS_LANG' ) ? SYS_LANG : 'en'; if ($this->getStgUid() == "") {
$this->stg_title = Content::load ( 'STG_TITLE', '', $this->getStgUid(), $lang ); throw (new Exception( "Error in getStgTitle, the getStgUid() can't be blank" ));
return $this->stg_title; }
} $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
$this->stg_title = Content::load( 'STG_TITLE', '', $this->getStgUid(), $lang );
/** return $this->stg_title;
* Set the stg_title column value. }
*
* @param string $v new value /**
* @return void * Set the stg_title column value.
*/ *
public function setStgTitle($v) * @param string $v new value
{ * @return void
if ( $this->getStgUid() == "" ) { */
throw ( new Exception( "Error in setStgTitle, the setStgUid() can't be blank") ); public function setStgTitle ($v)
} {
$v=isset($v)?((string)$v):''; if ($this->getStgUid() == "") {
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; throw (new Exception( "Error in setStgTitle, the setStgUid() can't be blank" ));
if ($this->stg_title !== $v || $v==="") { }
$this->stg_title = $v; $v = isset( $v ) ? ((string) $v) : '';
$res = Content::addContent( 'STG_TITLE', '', $this->getStgUid(), $lang, $this->stg_title ); $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
return $res; if ($this->stg_title !== $v || $v === "") {
} $this->stg_title = $v;
return 0; $res = Content::addContent( 'STG_TITLE', '', $this->getStgUid(), $lang, $this->stg_title );
} return $res;
}
public function load($StgUid) return 0;
{ }
try {
$oRow = StagePeer::retrieveByPK( $StgUid ); public function load ($StgUid)
if (!is_null($oRow)) {
{ try {
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME); $oRow = StagePeer::retrieveByPK( $StgUid );
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); if (! is_null( $oRow )) {
$this->setNew(false); $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
$this->setStgTitle($aFields['STG_TITLE'] = $this->getStgTitle()); $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
return $aFields; $this->setNew( false );
} $this->setStgTitle( $aFields['STG_TITLE'] = $this->getStgTitle() );
else { return $aFields;
throw( new Exception( "The row '$StgUid' in table Stage doesn't exist!" )); } else {
} throw (new Exception( "The row '$StgUid' in table Stage doesn't exist!" ));
} }
catch (Exception $oError) { } catch (Exception $oError) {
throw($oError); throw ($oError);
} }
} }
public function create($aData) { public function create ($aData)
$oConnection = Propel::getConnection(StagePeer::DATABASE_NAME); {
try { $oConnection = Propel::getConnection( StagePeer::DATABASE_NAME );
if ( isset ( $aData['STG_UID'] ) && $aData['STG_UID']== '' ) try {
unset ( $aData['STG_UID'] ); if (isset( $aData['STG_UID'] ) && $aData['STG_UID'] == '') {
if ( !isset ( $aData['STG_UID'] ) ) unset( $aData['STG_UID'] );
$aData['STG_UID'] = G::generateUniqueID(); }
$oStage = new Stage(); if (! isset( $aData['STG_UID'] )) {
$oStage->fromArray($aData, BasePeer::TYPE_FIELDNAME); $aData['STG_UID'] = G::generateUniqueID();
$oStage->setStgTitle($aData['STG_TITLE']); }
if ($oStage->validate()) { $oStage = new Stage();
$oConnection->begin(); $oStage->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
$iResult = $oStage->save(); $oStage->setStgTitle( $aData['STG_TITLE'] );
$oConnection->commit(); if ($oStage->validate()) {
return $aData['STG_UID']; $oConnection->begin();
} $iResult = $oStage->save();
else { $oConnection->commit();
$sMessage = ''; return $aData['STG_UID'];
$aValidationFailures = $oStage->getValidationFailures(); } else {
foreach($aValidationFailures as $oValidationFailure) { $sMessage = '';
$sMessage .= $oValidationFailure->getMessage() . '<br />'; $aValidationFailures = $oStage->getValidationFailures();
} foreach ($aValidationFailures as $oValidationFailure) {
throw(new Exception('The registry cannot be created!<br />'.$sMessage)); $sMessage .= $oValidationFailure->getMessage() . '<br />';
} }
} throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
catch (Exception $oError) { }
$oConnection->rollback(); } catch (Exception $oError) {
throw($oError); $oConnection->rollback();
} throw ($oError);
} }
}
public function update($fields)
{ public function update ($fields)
$con = Propel::getConnection(StagePeer::DATABASE_NAME); {
try $con = Propel::getConnection( StagePeer::DATABASE_NAME );
{ try {
$con->begin(); $con->begin();
$this->load($fields['STG_UID']); $this->load( $fields['STG_UID'] );
$this->fromArray($fields, BasePeer::TYPE_FIELDNAME); $this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
if($this->validate()) if ($this->validate()) {
{ $contentResult = 0;
$contentResult=0; if (array_key_exists( "STG_TITLE", $fields )) {
if (array_key_exists("STG_TITLE", $fields)) $contentResult+=$this->setStgTitle($fields["STG_TITLE"]); $contentResult += $this->setStgTitle( $fields["STG_TITLE"] );
$result=$this->save(); }
$result=($result==0)?($contentResult>0?1:0):$result; $result = $this->save();
$con->commit(); $result = ($result == 0) ? ($contentResult > 0 ? 1 : 0) : $result;
return $result; $con->commit();
} return $result;
else } else {
{ $con->rollback();
$con->rollback(); $validationE = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
$validationE=new Exception("Failed Validation in class ".get_class($this)."."); $validationE->aValidationFailures = $this->getValidationFailures();
$validationE->aValidationFailures = $this->getValidationFailures(); throw ($validationE);
throw($validationE); }
} } catch (Exception $e) {
} $con->rollback();
catch(Exception $e) throw ($e);
{ }
$con->rollback(); }
throw($e);
} public function remove ($StgUid)
} {
$con = Propel::getConnection( StagePeer::DATABASE_NAME );
public function remove($StgUid) try {
{ $con->begin();
$con = Propel::getConnection(StagePeer::DATABASE_NAME); $oStage = StagePeer::retrieveByPK( $StgUid );
try if (! is_null( $oStage )) {
{ Content::removeContent( 'STG_TITLE', '', $this->getStgUid() );
$con->begin(); $result = $oStage->delete();
$oStage = StagePeer::retrieveByPK( $StgUid ); $con->commit();
if (!is_null($oStage)) { }
Content::removeContent( 'STG_TITLE', '', $this->getStgUid()); return $result;
$result = $oStage->delete(); } catch (Exception $e) {
$con->commit(); $con->rollback();
} throw ($e);
return $result; }
} }
catch(Exception $e)
{ public function reorderPositions ($sProcessUID, $iIndex)
$con->rollback(); {
throw($e); try {
} $oCriteria = new Criteria( 'workflow' );
} $oCriteria->add( StagePeer::PRO_UID, $sProcessUID );
$oCriteria->add( StagePeer::STG_INDEX, $iIndex, '>' );
function reorderPositions($sProcessUID, $iIndex) { $oDataset = StagePeer::doSelectRS( $oCriteria );
try { $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oCriteria = new Criteria('workflow'); $oDataset->next();
$oCriteria->add(StagePeer::PRO_UID, $sProcessUID); while ($aRow = $oDataset->getRow()) {
$oCriteria->add(StagePeer::STG_INDEX, $iIndex, '>'); $this->update( array ('STG_UID' => $aRow['STG_UID'],'PRO_UID' => $aRow['PRO_UID'],'STG_POSX' => $aRow['STG_POSX'],'STG_POSY' => $aRow['STG_POSY'],'STG_INDEX' => $aRow['STG_INDEX'] - 1
$oDataset = StagePeer::doSelectRS($oCriteria); ) );
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next();
$oDataset->next(); }
while ($aRow = $oDataset->getRow()) { } catch (Exception $oException) {
$this->update(array('STG_UID' => $aRow['STG_UID'], throw $Exception;
'PRO_UID' => $aRow['PRO_UID'], }
'STG_POSX' => $aRow['STG_POSX'], }
'STG_POSY' => $aRow['STG_POSY'],
'STG_INDEX' => $aRow['STG_INDEX'] - 1)); public function Exists ($sUid)
$oDataset->next(); {
} try {
} $oObj = StagePeer::retrieveByPk( $sUid );
catch (Exception $oException) { return (is_object( $oObj ) && get_class( $oObj ) == 'Stage');
throw $Exception; } catch (Exception $oError) {
} throw ($oError);
} }
}
function Exists ( $sUid ) { }
try { // Stage
$oObj = StagePeer::retrieveByPk($sUid);
return (is_object($oObj) && get_class($oObj) == 'Stage');
}
catch (Exception $oError) {
throw($oError);
}
}
} // Stage

View File

@@ -1,230 +1,229 @@
<?php <?php
/** /**
* StepSupervisor.php * StepSupervisor.php
* @package workflow.engine.classes.model *
*/ * @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseStepSupervisor.php';
require_once 'classes/model/om/BaseStepSupervisor.php';
/** /**
* Skeleton subclass for representing a row from the 'STEP_SUPERVISOR' table. * Skeleton subclass for representing a row from the 'STEP_SUPERVISOR' table.
* *
* *
* *
* You should add additional methods to this class to meet the * You should add additional methods to this class to meet the
* application requirements. This class will only be generated as * application requirements. This class will only be generated as
* long as it does not already exist in the output directory. * long as it does not already exist in the output directory.
* *
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
*/ */
class StepSupervisor extends BaseStepSupervisor { class StepSupervisor extends BaseStepSupervisor
{
public function load($Uid) public function load ($Uid)
{ {
try { try {
$oRow = StepSupervisorPeer::retrieveByPK( $Uid ); $oRow = StepSupervisorPeer::retrieveByPK( $Uid );
if (!is_null($oRow)) if (! is_null( $oRow )) {
{ $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME); $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME); $this->setNew( false );
$this->setNew(false); return $aFields;
return $aFields; } else {
} throw (new Exception( "The row '$Uid' in table StepSupervisor doesn't exist!" ));
else { }
throw( new Exception( "The row '$Uid' in table StepSupervisor doesn't exist!" )); } catch (Exception $oError) {
} throw ($oError);
} }
catch (Exception $oError) { }
throw($oError);
} public function Exists ($Uid)
} {
try {
function Exists ( $Uid ) { $oPro = StepSupervisorPeer::retrieveByPk( $Uid );
try { if (is_object( $oPro ) && get_class( $oPro ) == 'StepSupervisor') {
$oPro = StepSupervisorPeer::retrieveByPk( $Uid ); return true;
if (is_object($oPro) && get_class ($oPro) == 'StepSupervisor' ) { } else {
return true; return false;
} }
else { } catch (Exception $oError) {
return false; throw ($oError);
} }
} }
catch (Exception $oError) {
throw($oError); /**
} * Create the step supervisor registry
} *
* @param array $aData
/** * @return boolean
* Create the step supervisor registry *
* @param array $aData */
* @return boolean public function create ($aData)
**/ {
public function create($aData) $oConnection = Propel::getConnection( StepSupervisorPeer::DATABASE_NAME );
{ try {
$oConnection = Propel::getConnection(StepSupervisorPeer::DATABASE_NAME); if (isset( $aData['STEP_UID'] ) && $aData['STEP_UID'] == '') {
try { unset( $aData['STEP_UID'] );
if ( isset ( $aData['STEP_UID'] ) && $aData['STEP_UID']== '' ) }
unset ( $aData['STEP_UID'] ); if (! isset( $aData['STEP_UID'] )) {
if ( !isset ( $aData['STEP_UID'] ) ) $aData['STEP_UID'] = G::generateUniqueID();
$aData['STEP_UID'] = G::generateUniqueID(); }
$oStepSupervisor = new StepSupervisor(); $oStepSupervisor = new StepSupervisor();
$oStepSupervisor->fromArray($aData, BasePeer::TYPE_FIELDNAME); $oStepSupervisor->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oStepSupervisor->validate()) { if ($oStepSupervisor->validate()) {
$oConnection->begin(); $oConnection->begin();
$iResult = $oStepSupervisor->save(); $iResult = $oStepSupervisor->save();
$oConnection->commit(); $oConnection->commit();
return true; return true;
} } else {
else { $sMessage = '';
$sMessage = ''; $aValidationFailures = $oStepSupervisor->getValidationFailures();
$aValidationFailures = $oStepSupervisor->getValidationFailures(); foreach ($aValidationFailures as $oValidationFailure) {
foreach($aValidationFailures as $oValidationFailure) { $sMessage .= $oValidationFailure->getMessage() . '<br />';
$sMessage .= $oValidationFailure->getMessage() . '<br />'; }
} throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
throw(new Exception('The registry cannot be created!<br />'.$sMessage)); }
} } catch (Exception $oError) {
} $oConnection->rollback();
catch (Exception $oError) { throw ($oError);
$oConnection->rollback(); }
throw($oError); }
}
} /**
* Update the step supervisor registry
/** *
* Update the step supervisor registry * @param array $aData
* @param array $aData * @return integer
* @return integer *
**/ */
public function update($aData) public function update ($aData)
{ {
$oConnection = Propel::getConnection(StepSupervisorPeer::DATABASE_NAME); $oConnection = Propel::getConnection( StepSupervisorPeer::DATABASE_NAME );
try { try {
$oStepSupervisor = StepSupervisorPeer::retrieveByPK($aData['STEP_UID']); $oStepSupervisor = StepSupervisorPeer::retrieveByPK( $aData['STEP_UID'] );
if (!is_null($oStepSupervisor)) if (! is_null( $oStepSupervisor )) {
{ $oStepSupervisor->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
$oStepSupervisor->fromArray($aData, BasePeer::TYPE_FIELDNAME); if ($oStepSupervisor->validate()) {
if ($oStepSupervisor->validate()) { $oConnection->begin();
$oConnection->begin(); $iResult = $oStepSupervisor->save();
$iResult = $oStepSupervisor->save(); $oConnection->commit();
$oConnection->commit(); return $iResult;
return $iResult; } else {
} $sMessage = '';
else { $aValidationFailures = $oStepSupervisor->getValidationFailures();
$sMessage = ''; foreach ($aValidationFailures as $oValidationFailure) {
$aValidationFailures = $oStepSupervisor->getValidationFailures(); $sMessage .= $oValidationFailure->getMessage() . '<br />';
foreach($aValidationFailures as $oValidationFailure) { }
$sMessage .= $oValidationFailure->getMessage() . '<br />'; throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
} }
throw(new Exception('The registry cannot be updated!<br />'.$sMessage)); } else {
} throw (new Exception( 'This row doesn\'t exist!' ));
} }
else { } catch (Exception $oError) {
throw(new Exception('This row doesn\'t exist!')); $oConnection->rollback();
} throw ($oError);
} }
catch (Exception $oError) { }
$oConnection->rollback();
throw($oError); /**
} * Remove the step supervisor registry
} *
* @param string $sStepUID
/** * @return integer
* Remove the step supervisor registry *
* @param string $sStepUID */
* @return integer public function remove ($sStepUID)
**/ {
public function remove($sStepUID) $oConnection = Propel::getConnection( StepSupervisorPeer::DATABASE_NAME );
{ try {
$oConnection = Propel::getConnection(StepSupervisorPeer::DATABASE_NAME); $oConnection->begin();
try { $this->setStepUid( $sStepUID );
$oConnection->begin(); $iResult = $this->delete();
$this->setStepUid($sStepUID); $oConnection->commit();
$iResult = $this->delete(); return $iResult;
$oConnection->commit(); } catch (Exception $oError) {
return $iResult; $oConnection->rollback();
} throw ($oError);
catch (Exception $oError) { }
$oConnection->rollback(); }
throw($oError);
} /**
} * Get the next position for a atep
*
/** * @param string $sProcessUID
* Get the next position for a atep * @return integer
* @param string $sProcessUID *
* @return integer */
**/ public function getNextPosition ($sProcessUID, $sType)
function getNextPosition($sProcessUID, $sType) { {
try { try {
$oCriteria = new Criteria('workflow'); $oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn('(COUNT(*) + 1) AS POSITION'); $oCriteria->addSelectColumn( '(COUNT(*) + 1) AS POSITION' );
$oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID); $oCriteria->add( StepSupervisorPeer::PRO_UID, $sProcessUID );
$oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, $sType); $oCriteria->add( StepSupervisorPeer::STEP_TYPE_OBJ, $sType );
$oDataset = StepSupervisorPeer::doSelectRS($oCriteria); $oDataset = StepSupervisorPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next(); $oDataset->next();
$aRow = $oDataset->getRow(); $aRow = $oDataset->getRow();
return (int)$aRow['POSITION']; return (int) $aRow['POSITION'];
} } catch (Exception $oException) {
catch (Exception $oException) { throw $Exception;
throw $Exception; }
} }
}
/**
/** * Reorder the steps positions
* Reorder the steps positions *
* @param string $sProcessUID * @param string $sProcessUID
* @param string $iPosition * @param string $iPosition
**/ *
function reorderPositions($sProcessUID, $iPosition, $sType) { */
try { public function reorderPositions ($sProcessUID, $iPosition, $sType)
$oCriteria = new Criteria('workflow'); {
$oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID); try {
$oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, $sType); $oCriteria = new Criteria( 'workflow' );
$oCriteria->add(StepSupervisorPeer::STEP_POSITION, $iPosition, '>'); $oCriteria->add( StepSupervisorPeer::PRO_UID, $sProcessUID );
$oDataset = StepSupervisorPeer::doSelectRS($oCriteria); $oCriteria->add( StepSupervisorPeer::STEP_TYPE_OBJ, $sType );
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oCriteria->add( StepSupervisorPeer::STEP_POSITION, $iPosition, '>' );
$oDataset->next();var_dump(StepSupervisorPeer::doCount($oCriteria)); $oDataset = StepSupervisorPeer::doSelectRS( $oCriteria );
while ($aRow = $oDataset->getRow()) {var_dump($aRow);echo "\n"; $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$this->update(array('STEP_UID' => $aRow['STEP_UID'], $oDataset->next();
'PRO_UID' => $aRow['PRO_UID'], var_dump( StepSupervisorPeer::doCount( $oCriteria ) );
'STEP_TYPE_OBJ' => $aRow['STEP_TYPE_OBJ'], while ($aRow = $oDataset->getRow()) {
'STEP_UID_OBJ' => $aRow['STEP_UID_OBJ'], var_dump( $aRow );
'STEP_POSITION' => $aRow['STEP_POSITION'] - 1)); echo "\n";
$oDataset->next(); $this->update( array ('STEP_UID' => $aRow['STEP_UID'],'PRO_UID' => $aRow['PRO_UID'],'STEP_TYPE_OBJ' => $aRow['STEP_TYPE_OBJ'],'STEP_UID_OBJ' => $aRow['STEP_UID_OBJ'],'STEP_POSITION' => $aRow['STEP_POSITION'] - 1
} ) );
} $oDataset->next();
catch (Exception $oException) { }
throw $Exception; } catch (Exception $oException) {
} throw $Exception;
} }
}
function removeByObject($sType, $sObjUid) { public function removeByObject ($sType, $sObjUid)
try { {
$oCriteria = new Criteria('workflow'); try {
$oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, $sType); $oCriteria = new Criteria( 'workflow' );
$oCriteria->add(StepSupervisorPeer::STEP_UID_OBJ, $sObjUid); $oCriteria->add( StepSupervisorPeer::STEP_TYPE_OBJ, $sType );
StepSupervisorPeer::doDelete($oCriteria); $oCriteria->add( StepSupervisorPeer::STEP_UID_OBJ, $sObjUid );
} StepSupervisorPeer::doDelete( $oCriteria );
catch(Exception $e) { } catch (Exception $e) {
throw($e); throw ($e);
} }
} }
function loadInfo($sObjUID){ public function loadInfo ($sObjUID)
{
$oCriteria = new Criteria('workflow');
$oCriteria->add(StepSupervisorPeer::STEP_UID_OBJ, $sObjUID); $oCriteria = new Criteria( 'workflow' );
$oDataset = StepSupervisorPeer::doSelectRS($oCriteria); $oCriteria->add( StepSupervisorPeer::STEP_UID_OBJ, $sObjUID );
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset = StepSupervisorPeer::doSelectRS( $oCriteria );
$oDataset->next(); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$aRow = $oDataset->getRow(); $oDataset->next();
return($aRow); $aRow = $oDataset->getRow();
return ($aRow);
}
} }
// StepSupervisor
} // StepSupervisor

View File

@@ -1,461 +1,455 @@
<?php <?php
/** /**
* Translation.php * Translation.php
* @package workflow.engine.classes.model *
* * @package workflow.engine.classes.model
* ProcessMaker Open Source Edition *
* Copyright (C) 2004 - 2011 Colosa Inc. * ProcessMaker Open Source Edition
* * Copyright (C) 2004 - 2011 Colosa Inc.
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as * This program is free software: you can redistribute it and/or modify
* published by the Free Software Foundation, either version 3 of the * it under the terms of the GNU Affero General Public License as
* License, or (at your option) any later version. * published by the Free Software Foundation, either version 3 of the
* * License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * This program is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU Affero General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. * You should have received a copy of the GNU Affero General Public License
* * along with this program. If not, see <http://www.gnu.org/licenses/>.
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., *
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ *
*/
require_once 'classes/model/om/BaseTranslation.php';
require_once 'classes/model/om/BaseTranslation.php';
/** /**
* Skeleton subclass for representing a row from the 'TRANSLATION' table. * Skeleton subclass for representing a row from the 'TRANSLATION' table.
* *
* *
* *
* You should add additional methods to this class to meet the * You should add additional methods to this class to meet the
* application requirements. This class will only be generated as * application requirements. This class will only be generated as
* long as it does not already exist in the output directory. * long as it does not already exist in the output directory.
* *
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
*/ */
class Translation extends BaseTranslation { class Translation extends BaseTranslation
{
public static $meta;
public static $localeSeparator = '-'; public static $meta;
public static $localeSeparator = '-';
private $envFilePath;
private $envFilePath;
function __construct(){
$this->envFilePath = PATH_DATA . "META-INF" . PATH_SEP . "translations.env"; public function __construct ()
} {
$this->envFilePath = PATH_DATA . "META-INF" . PATH_SEP . "translations.env";
function getAllCriteria(){ }
//SELECT * from TRANSLATION WHERE TRN_LANG = 'en' order by TRN_CATEGORY, TRN_ID public function getAllCriteria ()
$oCriteria = new Criteria('workflow'); {
$oCriteria->addSelectColumn(TranslationPeer::TRN_ID);
$oCriteria->addSelectColumn(TranslationPeer::TRN_CATEGORY); //SELECT * from TRANSLATION WHERE TRN_LANG = 'en' order by TRN_CATEGORY, TRN_ID
$oCriteria->addSelectColumn(TranslationPeer::TRN_LANG); $oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn(TranslationPeer::TRN_VALUE); $oCriteria->addSelectColumn( TranslationPeer::TRN_ID );
//$c->add(TranslationPeer::TRN_LANG, 'en'); $oCriteria->addSelectColumn( TranslationPeer::TRN_CATEGORY );
$oCriteria->addSelectColumn( TranslationPeer::TRN_LANG );
return $oCriteria; $oCriteria->addSelectColumn( TranslationPeer::TRN_VALUE );
} //$c->add(TranslationPeer::TRN_LANG, 'en');
function getAll($lang='en', $start=null, $limit=null, $search=null, $dateFrom=null, $dateTo=null){
$totalCount = 0; return $oCriteria;
}
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(TranslationPeer::TRN_ID); public function getAll ($lang = 'en', $start = null, $limit = null, $search = null, $dateFrom = null, $dateTo = null)
$oCriteria->addSelectColumn(TranslationPeer::TRN_CATEGORY); {
$oCriteria->addSelectColumn(TranslationPeer::TRN_LANG); $totalCount = 0;
$oCriteria->addSelectColumn(TranslationPeer::TRN_VALUE);
$oCriteria->addSelectColumn(TranslationPeer::TRN_UPDATE_DATE); $oCriteria = new Criteria( 'workflow' );
$oCriteria->add(TranslationPeer::TRN_LANG, $lang); $oCriteria->addSelectColumn( TranslationPeer::TRN_ID );
$oCriteria->add(TranslationPeer::TRN_CATEGORY, 'LABEL'); $oCriteria->addSelectColumn( TranslationPeer::TRN_CATEGORY );
//$oCriteria->addAscendingOrderByColumn ( 'TRN_CATEGORY' ); $oCriteria->addSelectColumn( TranslationPeer::TRN_LANG );
$oCriteria->addAscendingOrderByColumn ( 'TRN_ID' ); $oCriteria->addSelectColumn( TranslationPeer::TRN_VALUE );
$oCriteria->addSelectColumn( TranslationPeer::TRN_UPDATE_DATE );
$oCriteria->add( TranslationPeer::TRN_LANG, $lang );
if( $search ) { $oCriteria->add( TranslationPeer::TRN_CATEGORY, 'LABEL' );
$oCriteria->add( //$oCriteria->addAscendingOrderByColumn ( 'TRN_CATEGORY' );
$oCriteria->getNewCriterion( $oCriteria->addAscendingOrderByColumn( 'TRN_ID' );
TranslationPeer::TRN_ID,
"%$search%", Criteria::LIKE if ($search) {
)->addOr($oCriteria->getNewCriterion( $oCriteria->add( $oCriteria->getNewCriterion( TranslationPeer::TRN_ID, "%$search%", Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( TranslationPeer::TRN_VALUE, "%$search%", Criteria::LIKE ) ) );
TranslationPeer::TRN_VALUE, }
"%$search%", Criteria::LIKE // for date filter
)) if (($dateFrom) && ($dateTo)) {
); $oCriteria->add( $oCriteria->getNewCriterion( TranslationPeer::TRN_UPDATE_DATE, "$dateFrom", Criteria::GREATER_EQUAL ) //LESS_EQUAL
} ->addAnd( $oCriteria->getNewCriterion( TranslationPeer::TRN_UPDATE_DATE, "$dateTo", Criteria::LESS_EQUAL ) //GREATER_EQUAL
// for date filter ) );
if( ($dateFrom)&&($dateTo) ) { }
$oCriteria->add( // end filter
$oCriteria->getNewCriterion( $c = clone $oCriteria;
TranslationPeer::TRN_UPDATE_DATE, $c->clearSelectColumns();
"$dateFrom", Criteria::GREATER_EQUAL//LESS_EQUAL $c->addSelectColumn( 'COUNT(*)' );
)->addAnd($oCriteria->getNewCriterion( $oDataset = TranslationPeer::doSelectRS( $c );
TranslationPeer::TRN_UPDATE_DATE, $oDataset->next();
"$dateTo", Criteria::LESS_EQUAL//GREATER_EQUAL $aRow = $oDataset->getRow();
))
); if (is_array( $aRow )) {
} $totalCount = $aRow[0];
// end filter }
$c = clone $oCriteria; if ($start) {
$c->clearSelectColumns(); $oCriteria->setOffset( $start );
$c->addSelectColumn('COUNT(*)'); }
$oDataset = TranslationPeer::doSelectRS($c); if ($limit) {
$oDataset->next(); //&& !isset($seach) && !isset($search))
$aRow = $oDataset->getRow(); $oCriteria->setLimit( $limit );
}
if( is_array($aRow) ) $rs = TranslationPeer::doSelectRS( $oCriteria );
$totalCount = $aRow[0]; $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rows = Array ();
if($start) while ($rs->next()) {
$oCriteria->setOffset($start); $rows[] = $rs->getRow();
if($limit) //&& !isset($seach) && !isset($search)) }
$oCriteria->setLimit($limit);
$result->data = $rows;
$rs = TranslationPeer::doSelectRS($oCriteria); $result->totalCount = $totalCount;
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rows = Array(); return $result;
while( $rs->next() ) { }
$rows[] = $rs->getRow();
} /* Load strings from a Database .
$result->data = $rows;
$result->totalCount = $totalCount;
return $result;
}
/* Load strings from a Database .
* @author Fernando Ontiveros <fernando@colosa.com> * @author Fernando Ontiveros <fernando@colosa.com>
* @parameter $languageId (es|en|...). * @parameter $languageId (es|en|...).
*/ */
function generateFileTranslation ($languageId = '') { public function generateFileTranslation ($languageId = '')
$translation = Array(); {
$translationJS = Array(); $translation = Array ();
$translationJS = Array ();
if ($languageId === '')
$languageId = defined('SYS_LANG') ? SYS_LANG : 'en'; if ($languageId === '') {
$languageId = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
$c = new Criteria(); }
$c->add(TranslationPeer::TRN_LANG, $languageId ); $c = new Criteria();
$c->addAscendingOrderByColumn ( 'TRN_CATEGORY' ); $c->add( TranslationPeer::TRN_LANG, $languageId );
$c->addAscendingOrderByColumn ( 'TRN_ID' ); $c->addAscendingOrderByColumn( 'TRN_CATEGORY' );
$tranlations = TranslationPeer::doSelect($c); $c->addAscendingOrderByColumn( 'TRN_ID' );
$tranlations = TranslationPeer::doSelect( $c );
$cacheFile = PATH_LANGUAGECONT . "translation." . $languageId;
$cacheFileJS = PATH_CORE . 'js' . PATH_SEP . 'labels' . PATH_SEP . $languageId.".js"; $cacheFile = PATH_LANGUAGECONT . "translation." . $languageId;
$cacheFileJS = PATH_CORE . 'js' . PATH_SEP . 'labels' . PATH_SEP . $languageId . ".js";
foreach ( $tranlations as $key => $row ) {
if ( $row->getTrnCategory() === 'LABEL' ) { foreach ($tranlations as $key => $row) {
$translation[ $row->getTrnId() ] = $row->getTrnValue(); if ($row->getTrnCategory() === 'LABEL') {
} $translation[$row->getTrnId()] = $row->getTrnValue();
if ( $row->getTrnCategory() === 'JAVASCRIPT') { }
$translationJS[ $row->getTrnId() ] = $row->getTrnValue(); if ($row->getTrnCategory() === 'JAVASCRIPT') {
} $translationJS[$row->getTrnId()] = $row->getTrnValue();
} }
}
try {
try {
if( ! is_dir(dirname($cacheFile)) )
G::mk_dir(dirname($cacheFile)); if (! is_dir( dirname( $cacheFile ) )) {
G::mk_dir( dirname( $cacheFile ) );
if( ! is_dir(dirname($cacheFileJS)) ) }
G::mk_dir(dirname($cacheFileJS)); if (! is_dir( dirname( $cacheFileJS ) )) {
G::mk_dir( dirname( $cacheFileJS ) );
$f = fopen( $cacheFile , 'w+'); }
fwrite( $f , "<?php\n" ); $f = fopen( $cacheFile, 'w+' );
fwrite( $f , '$translation =' . 'unserialize(\'' . addcslashes( serialize ( $translation ), '\\\'' ) . "');\n"); fwrite( $f, "<?php\n" );
fwrite( $f , "?>" ); fwrite( $f, '$translation =' . 'unserialize(\'' . addcslashes( serialize( $translation ), '\\\'' ) . "');\n" );
fclose( $f ); fwrite( $f, "?>" );
fclose( $f );
$json=new Services_JSON();
$json = new Services_JSON();
$f = fopen( $cacheFileJS , 'w');
fwrite( $f , "var G_STRINGS =". $json->encode( $translationJS ) . ";\n"); $f = fopen( $cacheFileJS, 'w' );
fclose( $f ); fwrite( $f, "var G_STRINGS =" . $json->encode( $translationJS ) . ";\n" );
fclose( $f );
$res['cacheFile'] = $cacheFile;
$res['cacheFileJS'] = $cacheFileJS; $res['cacheFile'] = $cacheFile;
$res['rows'] = count ( $translation ); $res['cacheFileJS'] = $cacheFileJS;
$res['rowsJS'] = count ( $translationJS ); $res['rows'] = count( $translation );
return $res; $res['rowsJS'] = count( $translationJS );
} catch( Exception $e ) { return $res;
echo $e->getMessage(); } catch (Exception $e) {
} echo $e->getMessage();
} }
}
/**
* returns an array with /**
* codError 0 - no error, < 0 error * returns an array with
* rowsAffected 0,1 the number of rows affected * codError 0 - no error, < 0 error
* message message error. * rowsAffected 0,1 the number of rows affected
*/ * message message error.
function addTranslation ( $category, $id, $languageId, $value ) { */
//if exists the row in the database propel will update it, otherwise will insert. public function addTranslation ($category, $id, $languageId, $value)
$tr = TranslationPeer::retrieveByPK( $category, $id, $languageId ); {
if ( ! ( is_object ( $tr ) && get_class ($tr) == 'Translation' ) ) { //if exists the row in the database propel will update it, otherwise will insert.
$tr = new Translation(); $tr = TranslationPeer::retrieveByPK( $category, $id, $languageId );
} if (! (is_object( $tr ) && get_class( $tr ) == 'Translation')) {
$tr->setTrnCategory( $category ); $tr = new Translation();
$tr->setTrnId( $id ); }
$tr->setTrnLang( $languageId); $tr->setTrnCategory( $category );
$tr->setTrnValue( $value ); $tr->setTrnId( $id );
$tr->setTrnUpdateDate( date('Y-m-d') ); $tr->setTrnLang( $languageId );
$tr->setTrnValue( $value );
if ($tr->validate() ) { $tr->setTrnUpdateDate( date( 'Y-m-d' ) );
// we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save(); if ($tr->validate()) {
} // we save it, since we get no validation errors, or do whatever else you like.
else { $res = $tr->save();
// Something went wrong. We can now get the validationFailures and handle them. } else {
$msg = ''; // Something went wrong. We can now get the validationFailures and handle them.
$validationFailuresArray = $tr->getValidationFailures(); $msg = '';
foreach($validationFailuresArray as $objValidationFailure) { $validationFailuresArray = $tr->getValidationFailures();
$msg .= $objValidationFailure->getMessage() . "\n"; foreach ($validationFailuresArray as $objValidationFailure) {
} $msg .= $objValidationFailure->getMessage() . "\n";
return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); }
} return array ('codError' => - 100,'rowsAffected' => 0,'message' => $msg);
return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); }
//to do: uniform coderror structures for all classes return array ('codError' => 0,'rowsAffected' => $res,'message' => '');
} //to do: uniform coderror structures for all classes
}
function remove($sCategory, $sId, $sLang) {
$oTranslation = TranslationPeer::retrieveByPK($sCategory, $sId, $sLang); public function remove ($sCategory, $sId, $sLang)
if ( ( is_object ( $oTranslation ) && get_class ($oTranslation) == 'Translation' ) ) { {
$oTranslation->delete(); $oTranslation = TranslationPeer::retrieveByPK( $sCategory, $sId, $sLang );
} if ((is_object( $oTranslation ) && get_class( $oTranslation ) == 'Translation')) {
} $oTranslation->delete();
}
function addTranslationEnvironment($locale, $headers, $numRecords) }
{
$filePath = $this->envFilePath; public function addTranslationEnvironment ($locale, $headers, $numRecords)
$environments = Array(); {
$filePath = $this->envFilePath;
if( file_exists($filePath) ) { $environments = Array ();
$environments = unserialize(file_get_contents($filePath));
} if (file_exists( $filePath )) {
$environments = unserialize( file_get_contents( $filePath ) );
$environment['LOCALE'] = $locale; }
$environment['HEADERS'] = $headers;
$environment['DATE'] = date('Y-m-d H:i:s'); $environment['LOCALE'] = $locale;
$environment['NUM_RECORDS'] = $numRecords; $environment['HEADERS'] = $headers;
$environment['LANGUAGE'] = $headers['X-Poedit-Language']; $environment['DATE'] = date( 'Y-m-d H:i:s' );
$environment['COUNTRY'] = $headers['X-Poedit-Country']; $environment['NUM_RECORDS'] = $numRecords;
$environment['LANGUAGE'] = $headers['X-Poedit-Language'];
if( strpos($locale, self::$localeSeparator) !== false ) { $environment['COUNTRY'] = $headers['X-Poedit-Country'];
list($environment['LAN_ID'], $environment['IC_UID']) = explode(self::$localeSeparator, strtoupper($locale));
$environments[$environment['LAN_ID']][$environment['IC_UID']] = $environment; if (strpos( $locale, self::$localeSeparator ) !== false) {
} else { list ($environment['LAN_ID'], $environment['IC_UID']) = explode( self::$localeSeparator, strtoupper( $locale ) );
$environment['LAN_ID'] = strtoupper($locale); $environments[$environment['LAN_ID']][$environment['IC_UID']] = $environment;
$environment['IC_UID'] = ''; } else {
$environments[$locale]['__INTERNATIONAL__'] = $environment; $environment['LAN_ID'] = strtoupper( $locale );
} $environment['IC_UID'] = '';
$environments[$locale]['__INTERNATIONAL__'] = $environment;
}
file_put_contents($filePath, serialize($environments));
} file_put_contents( $filePath, serialize( $environments ) );
}
function removeTranslationEnvironment($locale)
{ public function removeTranslationEnvironment ($locale)
$filePath = $this->envFilePath; {
if (strpos($locale, self::$localeSeparator) !== false) { $filePath = $this->envFilePath;
list($LAN_ID, $IC_UID) = explode('-', strtoupper($locale)); if (strpos( $locale, self::$localeSeparator ) !== false) {
} else { list ($LAN_ID, $IC_UID) = explode( '-', strtoupper( $locale ) );
$LAN_ID = $locale; } else {
$IC_UID = '__INTERNATIONAL__'; $LAN_ID = $locale;
$IC_UID = '__INTERNATIONAL__';
}
if (file_exists( $filePath )) {
$environments = unserialize( file_get_contents( $filePath ) );
if (! isset( $environments[$LAN_ID][$IC_UID] )) {
return null;
}
unset( $environments[$LAN_ID][$IC_UID] );
file_put_contents( $filePath, serialize( $environments ) );
if (file_exists( PATH_CORE . "META-INF" . PATH_SEP . "translation." . $locale )) {
G::rm_dir( PATH_DATA . "META-INF" . PATH_SEP . "translation." . $locale );
}
if (file_exists( PATH_CORE . PATH_SEP . 'content' . PATH_SEP . 'translations' . PATH_SEP . 'processmaker' . $locale . '.po' )) {
G::rm_dir( PATH_CORE . PATH_SEP . 'content' . PATH_SEP . 'translations' . PATH_SEP . 'processmaker' . $locale . '.po' );
}
}
}
public function getTranslationEnvironments ()
{
$filePath = $this->envFilePath;
$envs = Array ();
if (! file_exists( $filePath )) {
//the transaltions table file doesn't exist, then build it
if (! is_dir( dirname( $this->envFilePath ) )) {
G::mk_dir( dirname( $this->envFilePath ) );
}
$translationsPath = PATH_CORE . "content" . PATH_SEP . 'translations' . PATH_SEP;
$basePOFile = $translationsPath . 'english' . PATH_SEP . 'processmaker.en.po';
$params = self::getInfoFromPOFile( $basePOFile );
$this->addTranslationEnvironment( $params['LOCALE'], $params['HEADERS'], $params['COUNT'] );
//getting more lanuguage translations
$files = glob( $translationsPath . "*.po" );
foreach ($files as $file) {
$params = self::getInfoFromPOFile( $file );
$this->addTranslationEnvironment( $params['LOCALE'], $params['HEADERS'], $params['COUNT'] );
}
}
$envs = unserialize( file_get_contents( $filePath ) );
$environments = Array ();
foreach ($envs as $LAN_ID => $rec1) {
foreach ($rec1 as $IC_UID => $rec2) {
$environments[] = $rec2;
}
}
return $environments;
/*
G::LoadSystem('dbMaintenance');
$o = new DataBaseMaintenance('localhost', 'root', 'atopml2005');
$o->connect('wf_os');
$r = $o->query('select * from ISO_COUNTRY');
foreach ($r as $i=>$v) {
$r[$i]['IC_NAME'] = utf8_encode($r[$i]['IC_NAME']);
unset($r[$i]['IC_SORT_ORDER']);
}
$r1 = $o->query('select * from LANGUAGE');
$r2 = Array();
foreach ($r1 as $i=>$v) {
$r2[$i]['LAN_NAME'] = utf8_encode($r1[$i]['LAN_NAME']);
$r2[$i]['LAN_ID'] = utf8_encode($r1[$i]['LAN_ID']);
} }
$s = Array('ISO_COUNTRY'=>$r, 'LANGUAGE'=>$r2);
if (file_exists($filePath)) { file_put_contents($translationsPath . 'pmos-translations.meta', serialize($s));
$environments = unserialize(file_get_contents($filePath)); */
if (!isset($environments[$LAN_ID][$IC_UID])) { }
return NULL;
} public function getInfoFromPOFile ($file)
{
unset($environments[$LAN_ID][$IC_UID]); G::loadClass( 'i18n_po' );
file_put_contents($filePath, serialize($environments)); $POFile = new i18n_PO( $file );
$POFile->readInit();
if (file_exists(PATH_CORE . "META-INF" . PATH_SEP . "translation.".$locale)) { $POHeaders = $POFile->getHeaders();
G::rm_dir(PATH_DATA . "META-INF" . PATH_SEP . "translation.".$locale);
} if ($POHeaders['X-Poedit-Country'] != '.') {
if (file_exists(PATH_CORE . PATH_SEP . 'content' . PATH_SEP . 'translations' . PATH_SEP . 'processmaker' . $locale . '.po')) { $country = self::getTranslationMetaByCountryName( $POHeaders['X-Poedit-Country'] );
G::rm_dir(PATH_CORE . PATH_SEP . 'content' . PATH_SEP . 'translations' . PATH_SEP . 'processmaker' . $locale . '.po'); } else {
} $country = '.';
} }
} $language = self::getTranslationMetaByLanguageName( $POHeaders['X-Poedit-Language'] );
function getTranslationEnvironments(){ if ($language !== false) {
$filePath = $this->envFilePath; if ($country !== false) {
$envs = Array(); if ($country != '.') {
$LOCALE = $language['LAN_ID'] . '-' . $country['IC_UID'];
if( ! file_exists($filePath) ) { } else if ($country == '.') {
//the transaltions table file doesn't exist, then build it //this a trsnlation file with a language international, no country name was set
$LOCALE = $language['LAN_ID'];
if( ! is_dir(dirname($this->envFilePath)) ) } else
G::mk_dir(dirname($this->envFilePath)); throw new Exception( 'PO File Error: "' . $file . '" has a invalid country definition!' );
} else
$translationsPath = PATH_CORE . "content" . PATH_SEP . 'translations' . PATH_SEP; throw new Exception( 'PO File Error: "' . $file . '" has a invalid country definition!' );
$basePOFile = $translationsPath . 'english' . PATH_SEP . 'processmaker.en.po'; } else
throw new Exception( 'PO File Error: "' . $file . '" has a invalid language definition!' );
$params = self::getInfoFromPOFile($basePOFile);
$this->addTranslationEnvironment($params['LOCALE'], $params['HEADERS'], $params['COUNT']); $countItems = 0;
try {
//getting more lanuguage translations while ($rowTranslation = $POFile->getTranslation()) {
$files = glob($translationsPath . "*.po"); $countItems ++;
foreach( $files as $file ){ }
$params = self::getInfoFromPOFile($file); } catch (Exception $e) {
$this->addTranslationEnvironment($params['LOCALE'], $params['HEADERS'], $params['COUNT']); $countItems = '-';
} }
} return Array ('LOCALE' => $LOCALE,'HEADERS' => $POHeaders,'COUNT' => $countItems);
$envs = unserialize(file_get_contents($filePath)); }
$environments = Array(); public function getTranslationEnvironment ($locale)
foreach($envs as $LAN_ID => $rec1 ){ {
foreach($rec1 as $IC_UID => $rec2 ){ $filePath = $this->envFilePath;
$environments[] = $rec2; $environments = Array ();
}
} if (! file_exists( $filePath )) {
throw new Exception( "The file $filePath doesn't exist" );
return $environments; }
/*G::LoadSystem('dbMaintenance'); $environments = unserialize( file_get_contents( $filePath ) );
$o = new DataBaseMaintenance('localhost', 'root', 'atopml2005'); if (strpos( $locale, self::$localeSeparator ) !== false) {
$o->connect('wf_os'); list ($LAN_ID, $IC_UID) = explode( self::localeSeparator, strtoupper( $locale ) );
$r = $o->query('select * from ISO_COUNTRY'); } else {
foreach($r as $i=>$v){ $LAN_ID = $locale;
$r[$i]['IC_NAME'] = utf8_encode($r[$i]['IC_NAME']); $IC_UID = '__INTERNATIONAL__';
unset($r[$i]['IC_SORT_ORDER']); }
}
$r1 = $o->query('select * from LANGUAGE'); if (isset( $environments[$LAN_ID][$IC_UID] )) {
$r2 = Array(); return $environments[$LAN_ID][$IC_UID];
foreach($r1 as $i=>$v){ } else {
$r2[$i]['LAN_NAME'] = utf8_encode($r1[$i]['LAN_NAME']); return false;
$r2[$i]['LAN_ID'] = utf8_encode($r1[$i]['LAN_ID']); }
} }
$s = Array('ISO_COUNTRY'=>$r, 'LANGUAGE'=>$r2);
file_put_contents($translationsPath . 'pmos-translations.meta', serialize($s)); public function saveTranslationEnvironment ($locale, $data)
*/ {
} $filePath = $this->envFilePath;
$environments = Array ();
function getInfoFromPOFile($file){
G::loadClass('i18n_po'); if (! file_exists( $filePath )) {
$POFile = new i18n_PO($file); throw new Exception( "The file $filePath doesn't exist" );
$POFile->readInit(); }
$POHeaders = $POFile->getHeaders();
$environments = unserialize( file_get_contents( $filePath ) );
if( $POHeaders['X-Poedit-Country'] != '.' ) { if (strpos( $locale, self::$localeSeparator ) !== false) {
$country = self::getTranslationMetaByCountryName($POHeaders['X-Poedit-Country']); list ($LAN_ID, $IC_UID) = explode( self::localeSeparator, strtoupper( $locale ) );
} else { } else {
$country = '.'; $LAN_ID = $locale;
} $IC_UID = '__INTERNATIONAL__';
$language = self::getTranslationMetaByLanguageName($POHeaders['X-Poedit-Language']); }
if( $language !== false ) { $environments[$LAN_ID][$IC_UID] = $data;
if( $country !== false ) { file_put_contents( $filePath, serialize( $environments ) );
if( $country != '.') { }
$LOCALE = $language['LAN_ID'] . '-' . $country['IC_UID'];
} else if( $country == '.' ) { public function getTranslationMeta ()
//this a trsnlation file with a language international, no country name was set {
$LOCALE = $language['LAN_ID']; $translationsPath = PATH_CORE . "content" . PATH_SEP . 'translations' . PATH_SEP;
} else $translationsTable = unserialize( file_get_contents( $translationsPath . 'pmos-translations.meta' ) );
throw new Exception('PO File Error: "'.$file.'" has a invalid country definition!'); return $translationsTable;
} else }
throw new Exception('PO File Error: "'.$file.'" has a invalid country definition!');
} else public function getTranslationMetaByCountryName ($IC_NAME)
throw new Exception('PO File Error: "'.$file.'" has a invalid language definition!'); {
$translationsTable = self::getTranslationMeta();
$countItems = 0;
try { foreach ($translationsTable['ISO_COUNTRY'] as $row) {
while( $rowTranslation = $POFile->getTranslation() ) { if ($row['IC_NAME'] == $IC_NAME) {
$countItems++; return $row;
} }
} catch(Exception $e) { }
$countItems = '-'; return false;
} }
return Array('LOCALE'=>$LOCALE, 'HEADERS'=>$POHeaders , 'COUNT'=>$countItems); public function getTranslationMetaByLanguageName ($LAN_NAME)
} {
$translationsTable = self::getTranslationMeta();
function getTranslationEnvironment($locale){
$filePath = $this->envFilePath; foreach ($translationsTable['LANGUAGE'] as $row) {
$environments = Array(); if ($row['LAN_NAME'] == $LAN_NAME) {
return $row;
if( ! file_exists($filePath) ) { }
throw new Exception("The file $filePath doesn't exist"); }
} return false;
}
$environments = unserialize(file_get_contents($filePath)); }
if( strpos($locale, self::$localeSeparator) !== false ) { // Translation
list($LAN_ID, $IC_UID) = explode(self::localeSeparator, strtoupper($locale));
} else {
$LAN_ID = $locale;
$IC_UID = '__INTERNATIONAL__';
}
if( isset($environments[$LAN_ID][$IC_UID]) )
return $environments[$LAN_ID][$IC_UID];
else
return false;
}
function saveTranslationEnvironment($locale, $data){
$filePath = $this->envFilePath;
$environments = Array();
if( ! file_exists($filePath) ) {
throw new Exception("The file $filePath doesn't exist");
}
$environments = unserialize(file_get_contents($filePath));
if( strpos($locale, self::$localeSeparator) !== false ) {
list($LAN_ID, $IC_UID) = explode(self::localeSeparator, strtoupper($locale));
} else {
$LAN_ID = $locale;
$IC_UID = '__INTERNATIONAL__';
}
$environments[$LAN_ID][$IC_UID] = $data;
file_put_contents($filePath, serialize($environments));
}
function getTranslationMeta(){
$translationsPath = PATH_CORE . "content" . PATH_SEP . 'translations' . PATH_SEP;
$translationsTable = unserialize(file_get_contents($translationsPath . 'pmos-translations.meta'));
return $translationsTable;
}
function getTranslationMetaByCountryName($IC_NAME){
$translationsTable = self::getTranslationMeta();
foreach ($translationsTable['ISO_COUNTRY'] as $row) {
if( $row['IC_NAME'] == $IC_NAME )
return $row;
}
return false;
}
function getTranslationMetaByLanguageName($LAN_NAME){
$translationsTable = self::getTranslationMeta();
foreach ($translationsTable['LANGUAGE'] as $row) {
if( $row['LAN_NAME'] == $LAN_NAME )
return $row;
}
return false;
}
} // Translation

View File

@@ -1,12 +1,13 @@
<?php <?php
/**
* class.pmSugar.pmFunctions.php /**
* * class.pmSugar.pmFunctions.php
* ProcessMaker Open Source Edition *
* Copyright (C) 2004 - 2008 Colosa Inc. * ProcessMaker Open Source Edition
* * * Copyright (C) 2004 - 2008 Colosa Inc.
*/ * *
*/
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
// pmSugar PM Functions // pmSugar PM Functions
// //
@@ -14,454 +15,482 @@
// //
// License: LGPL, see LICENSE // License: LGPL, see LICENSE
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
function getSoapClientOptions() { function getSoapClientOptions ()
$options = array('trace' => 1); {
$options = array ('trace' => 1);
//Apply proxy settings
$sysConf = System::getSystemConfiguration(); //Apply proxy settings
if ($sysConf['proxy_host'] != '') { $sysConf = System::getSystemConfiguration();
$options['proxy_host'] = $sysConf['proxy_host']; if ($sysConf['proxy_host'] != '') {
if ($sysConf['proxy_port'] != '') { $options['proxy_host'] = $sysConf['proxy_host'];
$options['proxy_port'] = $sysConf['proxy_port']; if ($sysConf['proxy_port'] != '') {
} $options['proxy_port'] = $sysConf['proxy_port'];
if ($sysConf['proxy_user'] != '') { }
$options['proxy_login'] = $sysConf['proxy_user']; if ($sysConf['proxy_user'] != '') {
} $options['proxy_login'] = $sysConf['proxy_user'];
if ($sysConf['proxy_pass'] != '') { }
$options['proxy_password'] = $sysConf['proxy_pass']; if ($sysConf['proxy_pass'] != '') {
} $options['proxy_password'] = $sysConf['proxy_pass'];
} }
}
return $options;
} return $options;
}
/**
* This collection of triggers allows to interact by getting and sending information to SugarCRM /**
* @class pmSugar * This collection of triggers allows to interact by getting and sending information to SugarCRM
* @name Sugar CRM Triggers * @class pmSugar
* @icon /images/triggers/icon_SugarCRM.gif *
* @className class.pmSugar.pmFunctions.php * @name Sugar CRM Triggers
*/ * @icon /images/triggers/icon_SugarCRM.gif
* @className class.pmSugar.pmFunctions.php
function sugarLogin($sugarSoap, $user, $password) { */
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() );
$auth_array = array ('user_auth' => array ('user_name' => $user, 'password' => md5 ( $password ), 'version' => '1.0' ) ); function sugarLogin ($sugarSoap, $user, $password)
$login_results = $client->__SoapCall ( 'login', $auth_array ); {
$client = new SoapClient( $sugarSoap, getSoapClientOptions() );
$session_id = $login_results->id; $auth_array = array ('user_auth' => array ('user_name' => $user,'password' => md5( $password ),'version' => '1.0') );
$user_guid = $client->__SoapCall ( 'get_user_id', array ($session_id ) ); $login_results = $client->__SoapCall( 'login', $auth_array );
return $session_id; $session_id = $login_results->id;
} $user_guid = $client->__SoapCall( 'get_user_id', array ($session_id) );
return $session_id;
function objectToArray($object) { }
if (! is_object ( $object ) && ! is_array ( $object )) {
return $object; function objectToArray ($object)
} {
if (is_object ( $object )) { if (! is_object( $object ) && ! is_array( $object )) {
$object = get_object_vars ( $object ); return $object;
} }
return array_map ( "objectToArray", $object ); if (is_object( $object )) {
} $object = get_object_vars( $object );
}
/** return array_map( "objectToArray", $object );
* @method }
*
* Gets SugarCRM entry using get_entry web service. /**
* *
* @name GetSugarEntry * @method Gets SugarCRM entry using get_entry web service.
* @label Get SugarCRM Entry *
* * @name GetSugarEntry
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl [^] * @label Get SugarCRM Entry
* @param string | $user | User *
* @param string | $password | Password * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl [^]
* @param string | $module | The name of the module from which to retrieve records. * @param string | $user | User
* @param string | $id | The SugarBeans ID. * @param string | $password | Password
* @param string | $selectedFields | Optional. The list of fields to be returned in the results. * @param string | $module | The name of the module from which to retrieve records.
* @param string | $linkNameToFieldsArray | A list of link names and the fields to be returned for each link name. * @param string | $id | The SugarBeans ID.
* @param string | $resultType=array | Result type (array or object) * @param string | $selectedFields | Optional. The list of fields to be returned in the results.
* * @param string | $linkNameToFieldsArray | A list of link names and the fields to be returned for each link name.
* @return array/object | $sugarEntries | Sugar Entries (array or object) * @param string | $resultType=array | Result type (array or object)
* *
*/ * @return array/object | $sugarEntries | Sugar Entries (array or object)
*
function GetSugarEntry($sugarSoap, $user, $password, $module, $id, $selectFields, $linkNameToFieldsArray, $resultType = 'array') { */
$sessionId = sugarLogin ( $sugarSoap, $user, $password );
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() ); function GetSugarEntry ($sugarSoap, $user, $password, $module, $id, $selectFields, $linkNameToFieldsArray, $resultType = 'array')
$request_array = array ('session' => $sessionId, 'module_name' => $module, 'id' => $id, {
'select_fields' => $select_fields, 'link_name_to_fields_array' => $linkNameToFieldsArray); $sessionId = sugarLogin( $sugarSoap, $user, $password );
$sugarEntry = $client->__SoapCall ( 'get_entry', $request_array ); $client = new SoapClient( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId,'module_name' => $module,'id' => $id,'select_fields' => $select_fields,'link_name_to_fields_array' => $linkNameToFieldsArray);
if($resultType == 'array'){ $sugarEntry = $client->__SoapCall( 'get_entry', $request_array );
$sugarEntry = objectToArray ( $sugarEntry );
} if ($resultType == 'array') {
$sugarEntry = objectToArray( $sugarEntry );
return $sugarEntry; }
}
return $sugarEntry;
/** }
* @method
* /**
* Gets SugarCRM entries from the indicated module. *
* * @method Gets SugarCRM entries from the indicated module.
* @name GetSugarEntries *
* @label Get SugarCRM Entries * @name GetSugarEntries
* * @label Get SugarCRM Entries
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl *
* @param string | $user | User * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
* @param string | $password | Password * @param string | $user | User
* @param string | $module | Module * @param string | $password | Password
* @param string | $query | Query * @param string | $module | Module
* @param string | $orderBy | Order By * @param string | $query | Query
* @param string | $selectedFields | Selected Fields * @param string | $orderBy | Order By
* @param string | $maxResults=50 | Max Results * @param string | $selectedFields | Selected Fields
* @param string | $resultType=array | Result type (array or object) * @param string | $maxResults=50 | Max Results
* * @param string | $resultType=array | Result type (array or object)
* @return array/object | $sugarEntries | Sugar Entries (array or object) *
* * @return array/object | $sugarEntries | Sugar Entries (array or object)
*/ *
*/
function GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") {
$sessionId = sugarLogin ( $sugarSoap, $user, $password ); function GetSugarEntries ($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() ); {
$request_array = array ('session' => $sessionId, 'module_name' => $module, 'query' => $query, 'order_by' => $orderBy, 'offset'=>"", 'select_fields'=>"", 'max_result'=>$maxResults ); $sessionId = sugarLogin( $sugarSoap, $user, $password );
$sugarEntriesO = $client->__SoapCall ( 'get_entry_list', $request_array ); $client = new SoapClient( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId,'module_name' => $module,'query' => $query,'order_by' => $orderBy,'offset' => "",'select_fields' => "",'max_result' => $maxResults);
switch($resultType){ $sugarEntriesO = $client->__SoapCall( 'get_entry_list', $request_array );
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break;
case 'object':$sugarEntries = $sugarEntriesO; break; switch ($resultType) {
default: $sugarEntries = objectToArray ( $sugarEntries ); case 'array':
} $sugarEntries = objectToArray( $sugarEntriesO );
break;
return $sugarEntries; case 'object':
$sugarEntries = $sugarEntriesO;
} break;
/** default:
* @method $sugarEntries = objectToArray( $sugarEntries );
* }
* Gets SugarCRM entries from the Calls module
* return $sugarEntries;
* @name GetSugarCalls
* @label Gets SugarCRM entries from the Calls module }
*
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl /**
* @param string | $user | User *
* @param string | $password | Password * @method Gets SugarCRM entries from the Calls module
* @param string | $query | Query *
* @param string | $orderBy | Order By * @name GetSugarCalls
* @param string | $selectedFields | Selected Fields * @label Gets SugarCRM entries from the Calls module
* @param string | $maxResults=50 | Max Results *
* @param string | $resultType=array | Result type (array or object) * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
* * @param string | $user | User
* @return array/object | $sugarCalls | Sugar Calls (array or object) * @param string | $password | Password
* * @param string | $query | Query
*/ * @param string | $orderBy | Order By
* @param string | $selectedFields | Selected Fields
function GetSugarCalls($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") { * @param string | $maxResults=50 | Max Results
$module="Calls"; * @param string | $resultType=array | Result type (array or object)
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType); *
} * @return array/object | $sugarCalls | Sugar Calls (array or object)
/** *
* @method */
*
* Gets SugarCRM entries from the Leads module. function GetSugarCalls ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
* {
* @name GetSugarLeads $module = "Calls";
* @label Gets SugarCRM entries from the Leads module. return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
* }
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
* @param string | $user | User /**
* @param string | $password | Password *
* @param string | $query | Query * @method Gets SugarCRM entries from the Leads module.
* @param string | $orderBy | Order By *
* @param string | $selectedFields | Selected Fields * @name GetSugarLeads
* @param string | $maxResults=50 | Max Results * @label Gets SugarCRM entries from the Leads module.
* @param string | $resultType=array | Result type (array or object) *
* * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
* @return array/object | $sugarLeads | Sugar Leads (array or object) * @param string | $user | User
* * @param string | $password | Password
*/ * @param string | $query | Query
* @param string | $orderBy | Order By
function GetSugarLeads($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") { * @param string | $selectedFields | Selected Fields
$module="Leads"; * @param string | $maxResults=50 | Max Results
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType); * @param string | $resultType=array | Result type (array or object)
} *
/** * @return array/object | $sugarLeads | Sugar Leads (array or object)
* @method *
* */
* Gets SugarCRM entries from the Contacts module.
* function GetSugarLeads ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
* @name GetSugarContacts {
* @label Gets SugarCRM entries from the Contacts module. $module = "Leads";
* return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl }
* @param string | $user | User
* @param string | $password | Password /**
* @param string | $query | Query *
* @param string | $orderBy | Order By * @method Gets SugarCRM entries from the Contacts module.
* @param string | $selectedFields | Selected Fields *
* @param string | $maxResults=50 | Max Results * @name GetSugarContacts
* @param string | $resultType=array | Result type (array or object) * @label Gets SugarCRM entries from the Contacts module.
* *
* @return array/object | $sugarContacts | Sugar Contacts (array or object) * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
* * @param string | $user | User
*/ * @param string | $password | Password
* @param string | $query | Query
function GetSugarContacts($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") { * @param string | $orderBy | Order By
$module="Contacts"; * @param string | $selectedFields | Selected Fields
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType); * @param string | $maxResults=50 | Max Results
} * @param string | $resultType=array | Result type (array or object)
/** *
* @method * @return array/object | $sugarContacts | Sugar Contacts (array or object)
* *
* Gets SugarCRM entries from the Opportunities module. */
*
* @name GetSugarOpportunities function GetSugarContacts ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
* @label Gets SugarCRM entries from the Opportunities module. {
* $module = "Contacts";
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
* @param string | $user | User }
* @param string | $password | Password
* @param string | $query | Query /**
* @param string | $orderBy | Order By *
* @param string | $selectedFields | Selected Fields * @method Gets SugarCRM entries from the Opportunities module.
* @param string | $maxResults=50 | Max Results *
* @param string | $resultType=array | Result type (array or object) * @name GetSugarOpportunities
* * @label Gets SugarCRM entries from the Opportunities module.
* @return array/object | $sugarAccount | Sugar Opportunities (array or object) *
* * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
*/ * @param string | $user | User
* @param string | $password | Password
function GetSugarOpportunities($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") { * @param string | $query | Query
$module="Opportunities"; * @param string | $orderBy | Order By
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType); * @param string | $selectedFields | Selected Fields
} * @param string | $maxResults=50 | Max Results
* @param string | $resultType=array | Result type (array or object)
/** *
* @method * @return array/object | $sugarAccount | Sugar Opportunities (array or object)
* *
* Gets SugarCRM entries from the Account module. */
*
* @name GetSugarAccount function GetSugarOpportunities ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
* @label Gets SugarCRM entries from the Account module. {
* $module = "Opportunities";
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
* @param string | $user | User }
* @param string | $password | Password
* @param string | $query | Query /**
* @param string | $orderBy | Order By *
* @param string | $selectedFields | Selected Fields * @method Gets SugarCRM entries from the Account module.
* @param string | $maxResults=50 | Max Results *
* @param string | $resultType=array | Result type (array or object) * @name GetSugarAccount
* * @label Gets SugarCRM entries from the Account module.
* @return array/object | $sugarAccount | Sugar Opportunities (array or object) *
* * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
*/ * @param string | $user | User
* @param string | $password | Password
function GetSugarAccount($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") { * @param string | $query | Query
$module="Accounts"; * @param string | $orderBy | Order By
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType); * @param string | $selectedFields | Selected Fields
} * @param string | $maxResults=50 | Max Results
* @param string | $resultType=array | Result type (array or object)
*
/** * @return array/object | $sugarAccount | Sugar Opportunities (array or object)
* @method *
* */
* Creates SugarCRM entries from the Account module.
* function GetSugarAccount ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
* @name CreateSugarAccount {
* $module = "Accounts";
* @label Creates SugarCRM entries from the Account module. return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
* }
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
* @param string | $user | User /**
* @param string | $password | Password *
* @param string | $name | Account name * @method Creates SugarCRM entries from the Account module.
* @param string | $resultType=array | Result type (array or object) *
* * @name CreateSugarAccount
* @return array/object | $sugarAccount | Sugar Opportunities (array or object) *
* * @label Creates SugarCRM entries from the Account module.
*/ *
function CreateSugarAccount($sugarSoap, $user, $password, $name, $resultType="array") { * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
* @param string | $user | User
$module = "Accounts"; * @param string | $password | Password
$sessionId = sugarLogin ( $sugarSoap, $user, $password ); * @param string | $name | Account name
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() ); * @param string | $resultType=array | Result type (array or object)
$request_array = array ('session' => $sessionId, 'module_name' => $module, 'name_value_list' => array( *
array("name" => 'name', "value" => $name ) * @return array/object | $sugarAccount | Sugar Opportunities (array or object)
) ); *
$sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array ); */
$account_id = $sugarEntriesO ->id; function CreateSugarAccount ($sugarSoap, $user, $password, $name, $resultType = "array")
{
switch($resultType){
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO );break; $module = "Accounts";
case 'object':$sugarEntries = $sugarEntries ;break; $sessionId = sugarLogin( $sugarSoap, $user, $password );
default: $sugarEntries = objectToArray ( $sugarEntries ); $client = new SoapClient( $sugarSoap, getSoapClientOptions() );
} $request_array = array ('session' => $sessionId,'module_name' => $module,'name_value_list' => array (array ("name" => 'name',"value" => $name)));
//return $sugarEntries; $sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array );
return $account_id; $account_id = $sugarEntriesO->id;
}
switch ($resultType) {
/** case 'array':
* @method $sugarEntries = objectToArray( $sugarEntriesO );
* break;
* Creates SugarCRM entries from the Account module case 'object':
* $sugarEntries = $sugarEntries;
* @name CreateSugarContact break;
* default:
* @label Creates SugarCRM entries from the Account module $sugarEntries = objectToArray( $sugarEntries );
* }
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl //return $sugarEntries;
* @param string | $user | User return $account_id;
* @param string | $password | Password }
* @param string | $first_name | First Name
* @param string | $last_name | Last Name /**
* @param string | $email | Email *
* @param string | $title | Title * @method Creates SugarCRM entries from the Account module
* @param string | $phone | Phone Work *
* @param string | $account_id | Valid id account * @name CreateSugarContact
* @param string | $resultType=array | Result type (array or object) *
* * @label Creates SugarCRM entries from the Account module
* @return array/object | $sugarContact | Sugar Opportunities (array or object) *
* * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
*/ * @param string | $user | User
function CreateSugarContact($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType="array") { * @param string | $password | Password
* @param string | $first_name | First Name
$module = "Contacts"; * @param string | $last_name | Last Name
/* $aValue = array( * @param string | $email | Email
* @param string | $title | Title
* @param string | $phone | Phone Work
* @param string | $account_id | Valid id account
* @param string | $resultType=array | Result type (array or object)
*
* @return array/object | $sugarContact | Sugar Opportunities (array or object)
*
*/
function CreateSugarContact ($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType = "array")
{
$module = "Contacts";
/* $aValue = array(
array("name" => 'id', "value" => G::generateUniqueID()), array("name" => 'id', "value" => G::generateUniqueID()),
array("name" => 'first_name', "value" => $first_name), array("name" => 'first_name', "value" => $first_name),
array("name" => 'last_name', "value" => $last_name), array("name" => 'last_name', "value" => $last_name),
); );
*/ */
$sessionId = sugarLogin ( $sugarSoap, $user, $password ); $sessionId = sugarLogin( $sugarSoap, $user, $password );
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() ); $client = new SoapClient( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId, 'module_name' => $module, array( $request_array = array ('session' => $sessionId,'module_name' => $module,array (array ("name" => 'first_name',"value" => $first_name
array("name" => 'first_name',"value" => $first_name), ),array ("name" => 'last_name',"value" => $last_name
array("name" => 'last_name',"value" => $last_name), ),array ("name" => 'email1',"value" => $email
array("name" => 'email1',"value" => $email), ),array ("name" => 'title',"value" => $title
array("name" => 'title',"value" => $title), ),array ("name" => 'phone_work',"value" => $phone
array("name" => 'phone_work',"value" => $phone), ),
// array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e') // array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e')
array("name" => 'account_id',"value" => $account_id) array ("name" => 'account_id',"value" => $account_id
)); )));
$sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array ); $sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array );
switch($resultType){ switch ($resultType) {
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break; case 'array':
case 'object':$sugarEntries = $sugarEntries; break; $sugarEntries = objectToArray( $sugarEntriesO );
default: $sugarEntries = objectToArray ( $sugarEntries ); break;
} case 'object':
return $sugarEntries; $sugarEntries = $sugarEntries;
} break;
default:
$sugarEntries = objectToArray( $sugarEntries );
/** }
* @method return $sugarEntries;
* }
* Creates SugarCRM entries from the Opportunities module.
* /**
* @name CreateSugarOpportunity *
* @method Creates SugarCRM entries from the Opportunities module.
* @label Creates SugarCRM entries from the Opportunities module. *
* * @name CreateSugarOpportunity
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl *
* @param string | $user | User * @label Creates SugarCRM entries from the Opportunities module.
* @param string | $password | Password *
* @param string | $name | Name * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
* @param string | $account_id | Valid id account * @param string | $user | User
* @param string | $amount | Amount * @param string | $password | Password
* @param string | $date_closed | Date Closed * @param string | $name | Name
* @param string | $sales_stage | Prospecting, Qualification, Needs Analysis, Value Proposition, Id. Decision Makers, Perception Analysis, Proposal/Price Quote, Negotiation/Review, Closed Won, Closed Lost * @param string | $account_id | Valid id account
* @param string | $resultType=array | Result type (array or object) * @param string | $amount | Amount
* * @param string | $date_closed | Date Closed
* @return array/object | $sugarOpportunity | Sugar Opportunities (array or object) * @param string | $sales_stage | Prospecting, Qualification, Needs Analysis, Value Proposition, Id. Decision Makers, Perception Analysis, Proposal/Price Quote, Negotiation/Review, Closed Won, Closed Lost
* * @param string | $resultType=array | Result type (array or object)
*/ *
function CreateSugarOpportunity($sugarSoap, $user, $password, $name,$account_id,$amount, $date_closed, $sales_stage,$resultType="array") { * @return array/object | $sugarOpportunity | Sugar Opportunities (array or object)
// * @param string | $account_id | Account Id *
$module = "Opportunities"; */
function CreateSugarOpportunity ($sugarSoap, $user, $password, $name, $account_id, $amount, $date_closed, $sales_stage, $resultType = "array")
/* $aValue = array( {
// * @param string | $account_id | Account Id
$module = "Opportunities";
/* $aValue = array(
array("name" => 'id', "value" => G::generateUniqueID()), array("name" => 'id', "value" => G::generateUniqueID()),
array("name" => 'name', "value" => $name), array("name" => 'name', "value" => $name),
array("name" => 'account_name', "value" => $account_name), array("name" => 'account_name', "value" => $account_name),
array("name" => 'amount', "value" => $amount), array("name" => 'amount', "value" => $amount),
array("name" => 'date_closed', "value" => $date_closed), array("name" => 'date_closed', "value" => $date_closed),
array("name" => 'sales_stage', "value" => $sales_stage) array("name" => 'sales_stage', "value" => $sales_stage)
);*/ );*/
$sessionId = sugarLogin ( $sugarSoap, $user, $password ); $sessionId = sugarLogin( $sugarSoap, $user, $password );
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() ); $client = new SoapClient( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId, 'module_name' => $module, 'name_value_list' =>array( $request_array = array ('session' => $sessionId,'module_name' => $module,'name_value_list' => array (array ('name' => 'name','value' => $name
array('name' => 'name','value' => $name), ),array ("name" => 'account_id',"value" => $account_id
array("name" => 'account_id',"value" => $account_id), ),array ('name' => 'amount','value' => $amount
array('name' => 'amount','value' => $amount), ),array ('name' => 'date_closed','value' => $date_closed
array('name' => 'date_closed','value' => $date_closed), ),array ('name' => 'sales_stage','value' => $sales_stage
array('name' => 'sales_stage','value' => $sales_stage), )
)); )
);
$sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array );
$sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array );
switch($resultType){
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break; switch ($resultType) {
case 'object':$sugarEntries = $sugarEntries; break; case 'array':
default: $sugarEntries = objectToArray ( $sugarEntries ); $sugarEntries = objectToArray( $sugarEntriesO );
} break;
return $sugarEntries; case 'object':
} $sugarEntries = $sugarEntries;
break;
default:
$sugarEntries = objectToArray( $sugarEntries );
/** }
* @method return $sugarEntries;
* }
* Creates SugarCRM entries from the Account module
* /**
* @name CreateSugarLeads *
* * @method Creates SugarCRM entries from the Account module
* @label Creates SugarCRM entries from the Account module *
* * @name CreateSugarLeads
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl *
* @param string | $user | User * @label Creates SugarCRM entries from the Account module
* @param string | $password | Password *
* @param string | $first_name | First Name * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
* @param string | $last_name | Last Name * @param string | $user | User
* @param string | $email | Email * @param string | $password | Password
* @param string | $title | Title * @param string | $first_name | First Name
* @param string | $phone | Phone Work * @param string | $last_name | Last Name
* @param string | $account_id | Valid id account * @param string | $email | Email
* @param string | $resultType=array | Result type (array or object) * @param string | $title | Title
* * @param string | $phone | Phone Work
* @return array/object | $sugarContact | Sugar Opportunities (array or object) * @param string | $account_id | Valid id account
* * @param string | $resultType=array | Result type (array or object)
*/ *
function CreateSugarLeads($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType="array") { * @return array/object | $sugarContact | Sugar Opportunities (array or object)
*
$module = "Leads"; */
$sessionId = sugarLogin ( $sugarSoap, $user, $password ); function CreateSugarLeads ($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType = "array")
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() ); {
$request_array = array ('session' => $sessionId, 'module_name' => $module, array( $module = "Leads";
array("name" => 'first_name',"value" => $first_name), $sessionId = sugarLogin( $sugarSoap, $user, $password );
array("name" => 'last_name',"value" => $last_name), $client = new SoapClient( $sugarSoap, getSoapClientOptions() );
array("name" => 'email1',"value" => $email),
array("name" => 'title',"value" => $title), $request_array = array ('session' => $sessionId,'module_name' => $module,array (array ("name" => 'first_name',"value" => $first_name
array("name" => 'phone_work',"value" => $phone), ),array ("name" => 'last_name',"value" => $last_name
// array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e') ),array ("name" => 'email1',"value" => $email
array("name" => 'account_id',"value" => $account_id) ),array ("name" => 'title',"value" => $title
)); ),array ("name" => 'phone_work',"value" => $phone
),
$sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array ); // array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e')
array ("name" => 'account_id',"value" => $account_id
switch($resultType){ )
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break; )
case 'object':$sugarEntries = $sugarEntries; break; );
default: $sugarEntries = objectToArray ( $sugarEntries );
} $sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array );
return $sugarEntries;
} switch ($resultType) {
case 'array':
$sugarEntries = objectToArray( $sugarEntriesO );
break;
case 'object':
$sugarEntries = $sugarEntries;
break;
default:
$sugarEntries = objectToArray( $sugarEntries );
}
return $sugarEntries;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,65 +1,65 @@
<?php <?php
/** /**
* cases_CatchExecute.php * cases_CatchExecute.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
/* Permissions */ /* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) { switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2: case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
case - 1: case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
} }
if (isset( $_POST['form']['BTN_CANCEL'] )) { if (isset( $_POST['form']['BTN_CANCEL'] )) {
header( "Location: ../cases/main" ); header( "Location: ../cases/main" );
die(); die();
} }
/* Includes */ /* Includes */
G::LoadClass( 'case' ); G::LoadClass( 'case' );
$oCase = new Cases(); $oCase = new Cases();
$sAppUid = $_SESSION['APPLICATION']; $sAppUid = $_SESSION['APPLICATION'];
$iDelIndex = $_SESSION['INDEX']; $iDelIndex = $_SESSION['INDEX'];
$oAppDelegation = new AppDelegation(); $oAppDelegation = new AppDelegation();
$aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex ); $aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex );
//if there are no user in the delegation row, this case is still in selfservice //if there are no user in the delegation row, this case is still in selfservice
if ($aDelegation['USR_UID'] == "") { if ($aDelegation['USR_UID'] == "") {
$oCase->setCatchUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'] ); $oCase->setCatchUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'] );
} else { } else {
G::SendMessageText( G::LoadTranslation( 'ID_CASE_ALREADY_DERIVATED' ), 'error' ); G::SendMessageText( G::LoadTranslation( 'ID_CASE_ALREADY_DERIVATED' ), 'error' );
} }
$validation = (SYS_SKIN != 'uxs') ? 'true' : 'false'; $validation = (SYS_SKIN != 'uxs') ? 'true' : 'false';
die( '<script type="text/javascript"> die( '<script type="text/javascript">
if (' . $validation . ') { if (' . $validation . ') {
if (window.parent.frames.length != 0) { if (window.parent.frames.length != 0) {
@@ -70,5 +70,5 @@ die( '<script type="text/javascript">
} else { } else {
window.location = "../cases/cases_Open?APP_UID=' . $_SESSION['APPLICATION'] . '&DEL_INDEX=' . $_SESSION['INDEX'] . '&action=unassigned"; window.location = "../cases/cases_Open?APP_UID=' . $_SESSION['APPLICATION'] . '&DEL_INDEX=' . $_SESSION['INDEX'] . '&action=unassigned";
} }
</script>' ); </script>' );

View File

@@ -1,90 +1,90 @@
<?php <?php
/** /**
* cases_Resume.php * cases_Resume.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
/* Permissions */ /* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) { switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2: case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
case - 1: case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
} }
/* Includes */ /* Includes */
G::LoadClass( 'case' ); G::LoadClass( 'case' );
$oCase = new Cases(); $oCase = new Cases();
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); $Fields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] );
/* Render page */ /* Render page */
require_once 'classes/model/Process.php'; require_once 'classes/model/Process.php';
require_once 'classes/model/Task.php'; require_once 'classes/model/Task.php';
$objProc = new Process(); $objProc = new Process();
$aProc = $objProc->load( $Fields['PRO_UID'] ); $aProc = $objProc->load( $Fields['PRO_UID'] );
$Fields['PRO_TITLE'] = $aProc['PRO_TITLE']; $Fields['PRO_TITLE'] = $aProc['PRO_TITLE'];
$objTask = new Task(); $objTask = new Task();
$aTask = $objTask->load( $Fields['TAS_UID'] ); $aTask = $objTask->load( $Fields['TAS_UID'] );
$Fields['TAS_TITLE'] = $aTask['TAS_TITLE']; $Fields['TAS_TITLE'] = $aTask['TAS_TITLE'];
$Fields['STATUS'] .= ' ( ' . G::LoadTranslation( 'ID_UNASSIGNED' ) . ' )'; $Fields['STATUS'] .= ' ( ' . G::LoadTranslation( 'ID_UNASSIGNED' ) . ' )';
//now getting information about the PREVIOUS task. If is the first task then no preious, use 1 //now getting information about the PREVIOUS task. If is the first task then no preious, use 1
$oAppDel = new AppDelegation(); $oAppDel = new AppDelegation();
$oAppDel->Load( $Fields['APP_UID'], ($Fields['DEL_PREVIOUS'] == 0 ? $Fields['DEL_PREVIOUS'] = 1 : $Fields['DEL_PREVIOUS']) ); $oAppDel->Load( $Fields['APP_UID'], ($Fields['DEL_PREVIOUS'] == 0 ? $Fields['DEL_PREVIOUS'] = 1 : $Fields['DEL_PREVIOUS']) );
$aAppDel = $oAppDel->toArray( BasePeer::TYPE_FIELDNAME ); $aAppDel = $oAppDel->toArray( BasePeer::TYPE_FIELDNAME );
try { try {
$oCurUser = new Users(); $oCurUser = new Users();
$oCurUser->load( $aAppDel['USR_UID'] ); $oCurUser->load( $aAppDel['USR_UID'] );
$Fields['PREVIOUS_USER'] = $oCurUser->getUsrFirstname() . ' ' . $oCurUser->getUsrLastname(); $Fields['PREVIOUS_USER'] = $oCurUser->getUsrFirstname() . ' ' . $oCurUser->getUsrLastname();
} catch (Exception $oError) { } catch (Exception $oError) {
$Fields['PREVIOUS_USER'] = ''; $Fields['PREVIOUS_USER'] = '';
} }
$objTask = new Task(); $objTask = new Task();
$aTask = $objTask->load( $aAppDel['TAS_UID'] ); $aTask = $objTask->load( $aAppDel['TAS_UID'] );
$Fields['PREVIOUS_TASK'] = $aTask['TAS_TITLE']; $Fields['PREVIOUS_TASK'] = $aTask['TAS_TITLE'];
//To enable information (dynaforms, steps) before claim a case //To enable information (dynaforms, steps) before claim a case
$_SESSION['bNoShowSteps'] = true; $_SESSION['bNoShowSteps'] = true;
$G_MAIN_MENU = 'processmaker'; $G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'caseOptions'; $G_SUB_MENU = 'caseOptions';
$G_ID_MENU_SELECTED = 'CASES'; $G_ID_MENU_SELECTED = 'CASES';
$G_ID_SUB_MENU_SELECTED = '_'; $G_ID_SUB_MENU_SELECTED = '_';
$oHeadPublisher = & headPublisher::getSingleton(); $oHeadPublisher = & headPublisher::getSingleton();
$oHeadPublisher->addScriptCode( " $oHeadPublisher->addScriptCode( "
if (typeof parent != 'undefined') { if (typeof parent != 'undefined') {
if (parent.showCaseNavigatorPanel) { if (parent.showCaseNavigatorPanel) {
parent.showCaseNavigatorPanel('{$Fields['APP_STATUS']}'); parent.showCaseNavigatorPanel('{$Fields['APP_STATUS']}');
} }
}" ); }" );
$oHeadPublisher->addScriptCode( ' $oHeadPublisher->addScriptCode( '
var Cse = {}; var Cse = {};
Cse.panels = {}; Cse.panels = {};
@@ -96,11 +96,11 @@ $oHeadPublisher->addScriptCode( '
leimnud.Package.Load("cases_Step",{Type:"file",Absolute:true,Path:"/jscore/cases/core/cases_Step.js"}); leimnud.Package.Load("cases_Step",{Type:"file",Absolute:true,Path:"/jscore/cases/core/cases_Step.js"});
leimnud.Package.Load("processmap",{Type:"file",Absolute:true,Path:"/jscore/processmap/core/processmap.js"}); leimnud.Package.Load("processmap",{Type:"file",Absolute:true,Path:"/jscore/processmap/core/processmap.js"});
leimnud.exec(leimnud.fix.memoryLeak); leimnud.exec(leimnud.fix.memoryLeak);
' ); ' );
$oHeadPublisher = & headPublisher::getSingleton(); $oHeadPublisher = & headPublisher::getSingleton();
$oHeadPublisher->addScriptFile( '/jscore/cases/core/cases_Step.js' ); $oHeadPublisher->addScriptFile( '/jscore/cases/core/cases_Step.js' );
$G_PUBLISH = new Publisher(); $G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_CatchSelfService.xml', '', $Fields, 'cases_CatchExecute' ); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_CatchSelfService.xml', '', $Fields, 'cases_CatchExecute' );
G::RenderPage( 'publish', 'blank' ); G::RenderPage( 'publish', 'blank' );

View File

@@ -1,57 +1,59 @@
<?php <?php
/** /**
* cases_Delete.php * cases_Delete.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
/* Permissions */ /* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) { switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2: case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
case - 1: case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
} }
/* Includes */ /* Includes */
G::LoadClass( 'case' ); G::LoadClass( 'case' );
/* Process the info */ /* Process the info */
try { try {
$oCase = new Cases(); $oCase = new Cases();
if (isset( $_POST['APP_UIDS'] )) { if (isset( $_POST['APP_UIDS'] )) {
$ids = explode( ',', $_POST['APP_UIDS'] ); $ids = explode( ',', $_POST['APP_UIDS'] );
foreach ($ids as $id) foreach ($ids as $id) {
$oCase->removeCase( $id ); $oCase->removeCase( $id );
}
if (count( $_POST['APP_UIDS'] ) > 1)
echo 'The Case was deleted successfully'; if (count( $_POST['APP_UIDS'] ) > 1) {
else echo 'The Case was deleted successfully';
echo 'All Cases were deleted successfully'; } else {
} echo 'All Cases were deleted successfully';
} catch (Exception $e) { }
echo $e->getMessage(); }
} catch (Exception $e) {
echo $e->getMessage();
} }

View File

@@ -1,59 +1,59 @@
<?php <?php
/** /**
* cases_DeleteDocument.php * cases_DeleteDocument.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
/* Permissions */ /* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) { switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2: case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
case - 1: case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
} }
/* Includes */ /* Includes */
require_once ("classes/model/AppDocumentPeer.php"); require_once ("classes/model/AppDocumentPeer.php");
G::LoadClass( 'case' ); G::LoadClass( 'case' );
/* GET , POST & $_SESSION Vars */ /* GET , POST & $_SESSION Vars */
/* Process the info */ /* Process the info */
$oAppDocument = new AppDocument(); $oAppDocument = new AppDocument();
$oAppDocument->remove( $_GET['DOC'] ); $oAppDocument->remove( $_GET['DOC'] );
$oCase = new Cases(); $oCase = new Cases();
$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List' ); $oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List' );
if ($_GET['TYPE'] == 'INPUT') { if ($_GET['TYPE'] == 'INPUT') {
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] - 1 ); $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] - 1 );
} }
if ($_GET['TYPE'] == 'OUTPUT') { if ($_GET['TYPE'] == 'OUTPUT') {
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
} }
$_SESSION['STEP_POSITION'] = $aNextStep['POSITION']; $_SESSION['STEP_POSITION'] = $aNextStep['POSITION'];
/* Redirect */ /* Redirect */
G::header( 'location: ' . $aNextStep['PAGE'] ); G::header( 'location: ' . $aNextStep['PAGE'] );

View File

@@ -1,50 +1,50 @@
<?php <?php
/** /**
* cases_DeleteDocumentToRevise.php * cases_DeleteDocumentToRevise.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
/* Permissions */ /* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) { switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2: case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
case - 1: case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
} }
/* Includes */ /* Includes */
require_once ("classes/model/AppDocumentPeer.php"); require_once ("classes/model/AppDocumentPeer.php");
G::LoadClass( 'case' ); G::LoadClass( 'case' );
/* GET , POST & $_SESSION Vars */ /* GET , POST & $_SESSION Vars */
/* Process the info */ /* Process the info */
$oAppDocument = new AppDocument(); $oAppDocument = new AppDocument();
$oAppDocument->remove( $_GET['DOC'] ); $oAppDocument->remove( $_GET['DOC'] );
/* Redirect */ /* Redirect */
G::header( 'location: ' . $_SERVER['HTTP_REFERER'] ); G::header( 'location: ' . $_SERVER['HTTP_REFERER'] );

View File

@@ -1,185 +1,185 @@
<?php <?php
/** /**
* cases_Derivate.php * cases_Derivate.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
/* Permissions */ /* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) { switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2: case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
case - 1: case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
} }
/* Includes */ /* Includes */
G::LoadClass( 'pmScript' ); G::LoadClass( 'pmScript' );
G::LoadClass( 'case' ); G::LoadClass( 'case' );
G::LoadClass( 'derivation' ); G::LoadClass( 'derivation' );
require_once 'classes/model/Event.php'; require_once 'classes/model/Event.php';
/* GET , POST & $_SESSION Vars */ /* GET , POST & $_SESSION Vars */
/* Process the info */ /* Process the info */
$sStatus = 'TO_DO'; $sStatus = 'TO_DO';
foreach ($_POST['form']['TASKS'] as $aValues) { foreach ($_POST['form']['TASKS'] as $aValues) {
} }
try { try {
//load data //load data
$oCase = new Cases(); $oCase = new Cases();
//warning: we are not using the result value of function thisIsTheCurrentUser, so I'm commenting to optimize speed. //warning: we are not using the result value of function thisIsTheCurrentUser, so I'm commenting to optimize speed.
//$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List'); //$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List');
$appFields = $oCase->loadCase( $_SESSION['APPLICATION'] ); $appFields = $oCase->loadCase( $_SESSION['APPLICATION'] );
$appFields['APP_DATA'] = array_merge( $appFields['APP_DATA'], G::getSystemConstants() ); $appFields['APP_DATA'] = array_merge( $appFields['APP_DATA'], G::getSystemConstants() );
//cleaning debug variables //cleaning debug variables
$_SESSION['TRIGGER_DEBUG']['DATA'] = Array (); $_SESSION['TRIGGER_DEBUG']['DATA'] = Array ();
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = Array (); $_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = Array ();
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = Array (); $_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = Array ();
$triggers = $oCase->loadTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'BEFORE' ); $triggers = $oCase->loadTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'BEFORE' );
//if there are some triggers to execute //if there are some triggers to execute
if (sizeof( $triggers ) > 0) { if (sizeof( $triggers ) > 0) {
//Execute triggers before derivation //Execute triggers before derivation
$appFields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'BEFORE', $appFields['APP_DATA'] ); $appFields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'BEFORE', $appFields['APP_DATA'] );
//save trigger variables for debugger //save trigger variables for debugger
$_SESSION['TRIGGER_DEBUG']['info'][0]['NUM_TRIGGERS'] = sizeof( $triggers ); $_SESSION['TRIGGER_DEBUG']['info'][0]['NUM_TRIGGERS'] = sizeof( $triggers );
$_SESSION['TRIGGER_DEBUG']['info'][0]['TIME'] = 'BEFORE'; $_SESSION['TRIGGER_DEBUG']['info'][0]['TIME'] = 'BEFORE';
$_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers ); $_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers );
$_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_VALUES'] = $triggers; $_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_VALUES'] = $triggers;
} }
$appFields['DEL_INDEX'] = $_SESSION['INDEX']; $appFields['DEL_INDEX'] = $_SESSION['INDEX'];
$appFields['TAS_UID'] = $_SESSION['TASK']; $appFields['TAS_UID'] = $_SESSION['TASK'];
$oCase->updateCase( $_SESSION['APPLICATION'], $appFields ); //Save data $oCase->updateCase( $_SESSION['APPLICATION'], $appFields ); //Save data
//derivate case //derivate case
$oDerivation = new Derivation(); $oDerivation = new Derivation();
$aCurrentDerivation = array ('APP_UID' => $_SESSION['APPLICATION'],'DEL_INDEX' => $_SESSION['INDEX'],'APP_STATUS' => $sStatus,'TAS_UID' => $_SESSION['TASK'],'ROU_TYPE' => $_POST['form']['ROU_TYPE'] $aCurrentDerivation = array ('APP_UID' => $_SESSION['APPLICATION'],'DEL_INDEX' => $_SESSION['INDEX'],'APP_STATUS' => $sStatus,'TAS_UID' => $_SESSION['TASK'],'ROU_TYPE' => $_POST['form']['ROU_TYPE']
); );
$oDerivation->derivate( $aCurrentDerivation, $_POST['form']['TASKS'] ); $oDerivation->derivate( $aCurrentDerivation, $_POST['form']['TASKS'] );
$appFields = $oCase->loadCase( $_SESSION['APPLICATION'] ); //refresh appFields, because in derivations should change some values $appFields = $oCase->loadCase( $_SESSION['APPLICATION'] ); //refresh appFields, because in derivations should change some values
$triggers = $oCase->loadTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'AFTER' ); //load the triggers after derivation $triggers = $oCase->loadTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'AFTER' ); //load the triggers after derivation
if (sizeof( $triggers ) > 0) { if (sizeof( $triggers ) > 0) {
$appFields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'AFTER', $appFields['APP_DATA'] ); //Execute triggers after derivation $appFields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'AFTER', $appFields['APP_DATA'] ); //Execute triggers after derivation
$_SESSION['TRIGGER_DEBUG']['info'][1]['NUM_TRIGGERS'] = sizeof( $triggers ); $_SESSION['TRIGGER_DEBUG']['info'][1]['NUM_TRIGGERS'] = sizeof( $triggers );
$_SESSION['TRIGGER_DEBUG']['info'][1]['TIME'] = 'AFTER'; $_SESSION['TRIGGER_DEBUG']['info'][1]['TIME'] = 'AFTER';
$_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers ); $_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers );
$_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_VALUES'] = $triggers; $_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_VALUES'] = $triggers;
} }
$oCase->updateCase( $_SESSION['APPLICATION'], $appFields ); $oCase->updateCase( $_SESSION['APPLICATION'], $appFields );
// Send notifications - Start // Send notifications - Start
$oUser = new Users(); $oUser = new Users();
$aUser = $oUser->load( $_SESSION['USER_LOGGED'] ); $aUser = $oUser->load( $_SESSION['USER_LOGGED'] );
if (trim( $aUser['USR_EMAIL'] ) == '') { if (trim( $aUser['USR_EMAIL'] ) == '') {
$aUser['USR_EMAIL'] = 'info@' . $_SERVER['HTTP_HOST']; $aUser['USR_EMAIL'] = 'info@' . $_SERVER['HTTP_HOST'];
} }
$sFromName = '"' . $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . '" <' . $aUser['USR_EMAIL'] . '>'; $sFromName = '"' . $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . '" <' . $aUser['USR_EMAIL'] . '>';
try { try {
$oCase->sendNotifications( $_SESSION['TASK'], $_POST['form']['TASKS'], $appFields['APP_DATA'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $sFromName ); $oCase->sendNotifications( $_SESSION['TASK'], $_POST['form']['TASKS'], $appFields['APP_DATA'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $sFromName );
} catch (Exception $e) { } catch (Exception $e) {
G::SendTemporalMessage( G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . ' - ' . $e->getMessage(), 'warning', 'string', null, '100%' ); G::SendTemporalMessage( G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . ' - ' . $e->getMessage(), 'warning', 'string', null, '100%' );
} }
// Send notifications - End // Send notifications - End
// Events - Start // Events - Start
$oEvent = new Event(); $oEvent = new Event();
$oEvent->closeAppEvents( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['TASK'] ); $oEvent->closeAppEvents( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['TASK'] );
$oCurrentAppDel = AppDelegationPeer::retrieveByPk( $_SESSION['APPLICATION'], $_SESSION['INDEX'] + 1 ); $oCurrentAppDel = AppDelegationPeer::retrieveByPk( $_SESSION['APPLICATION'], $_SESSION['INDEX'] + 1 );
$multipleDelegation = false; $multipleDelegation = false;
// check if there are multiple derivations // check if there are multiple derivations
if (count( $_POST['form']['TASKS'] ) > 1) { if (count( $_POST['form']['TASKS'] ) > 1) {
$multipleDelegation = true; $multipleDelegation = true;
} }
// If the case has been delegated // If the case has been delegated
if (isset( $oCurrentAppDel )) { if (isset( $oCurrentAppDel )) {
// if there is just a single derivation the TASK_UID can be set by the delegation data // if there is just a single derivation the TASK_UID can be set by the delegation data
if (! $multipleDelegation) { if (! $multipleDelegation) {
$aCurrentAppDel = $oCurrentAppDel->toArray( BasePeer::TYPE_FIELDNAME ); $aCurrentAppDel = $oCurrentAppDel->toArray( BasePeer::TYPE_FIELDNAME );
$oEvent->createAppEvents( $aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'], $aCurrentAppDel['DEL_INDEX'], $aCurrentAppDel['TAS_UID'] ); $oEvent->createAppEvents( $aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'], $aCurrentAppDel['DEL_INDEX'], $aCurrentAppDel['TAS_UID'] );
} else { } else {
// else we need to check every task and create the events if it have any // else we need to check every task and create the events if it have any
foreach ($_POST['form']['TASKS'] as $taskDelegated) { foreach ($_POST['form']['TASKS'] as $taskDelegated) {
$aCurrentAppDel = $oCurrentAppDel->toArray( BasePeer::TYPE_FIELDNAME ); $aCurrentAppDel = $oCurrentAppDel->toArray( BasePeer::TYPE_FIELDNAME );
$oEvent->createAppEvents( $aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'], $aCurrentAppDel['DEL_INDEX'], $taskDelegated['TAS_UID'] ); $oEvent->createAppEvents( $aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'], $aCurrentAppDel['DEL_INDEX'], $taskDelegated['TAS_UID'] );
} }
} }
} }
//Events - End //Events - End
$debuggerAvailable = true; $debuggerAvailable = true;
if (isset( $_SESSION['user_experience'] )) { if (isset( $_SESSION['user_experience'] )) {
$aNextStep['PAGE'] = 'casesListExtJsRedirector?ux=' . $_SESSION['user_experience']; $aNextStep['PAGE'] = 'casesListExtJsRedirector?ux=' . $_SESSION['user_experience'];
$debuggerAvailable = false; $debuggerAvailable = false;
} else { } else {
$aNextStep['PAGE'] = 'casesListExtJsRedirector'; $aNextStep['PAGE'] = 'casesListExtJsRedirector';
} }
if (isset( $_SESSION['PMDEBUGGER'] ) && $_SESSION['PMDEBUGGER'] && $debuggerAvailable) { if (isset( $_SESSION['PMDEBUGGER'] ) && $_SESSION['PMDEBUGGER'] && $debuggerAvailable) {
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE']; $_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
$loc = 'cases_Step?' . 'breakpoint=triggerdebug'; $loc = 'cases_Step?' . 'breakpoint=triggerdebug';
} else { } else {
$loc = $aNextStep['PAGE']; $loc = $aNextStep['PAGE'];
} }
//Triggers After //Triggers After
if (isset( $_SESSION['TRIGGER_DEBUG']['ISSET'] )) { if (isset( $_SESSION['TRIGGER_DEBUG']['ISSET'] )) {
if ($_SESSION['TRIGGER_DEBUG']['ISSET'] == 1) { if ($_SESSION['TRIGGER_DEBUG']['ISSET'] == 1) {
$oTemplatePower = new TemplatePower( PATH_TPL . 'cases/cases_Step.html' ); $oTemplatePower = new TemplatePower( PATH_TPL . 'cases/cases_Step.html' );
$oTemplatePower->prepare(); $oTemplatePower->prepare();
$G_PUBLISH = new Publisher(); $G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower ); $G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower );
$_POST['NextStep'] = $loc; $_POST['NextStep'] = $loc;
$G_PUBLISH->AddContent( 'view', 'cases/showDebugFrameLoader' ); $G_PUBLISH->AddContent( 'view', 'cases/showDebugFrameLoader' );
$G_PUBLISH->AddContent( 'view', 'cases/showDebugFrameBreaker' ); $G_PUBLISH->AddContent( 'view', 'cases/showDebugFrameBreaker' );
$_SESSION['TRIGGER_DEBUG']['ISSET'] == 0; $_SESSION['TRIGGER_DEBUG']['ISSET'] == 0;
G::RenderPage( 'publish', 'blank' ); G::RenderPage( 'publish', 'blank' );
exit(); exit();
} else { } else {
unset( $_SESSION['TRIGGER_DEBUG'] ); unset( $_SESSION['TRIGGER_DEBUG'] );
} }
} }
G::header( "location: $loc" ); G::header( "location: $loc" );
} catch (Exception $e) { } catch (Exception $e) {
$aMessage = array (); $aMessage = array ();
$aMessage['MESSAGE'] = $e->getMessage() . '<br>' . $e->getTraceAsString(); $aMessage['MESSAGE'] = $e->getMessage() . '<br>' . $e->getTraceAsString();
$G_PUBLISH = new Publisher(); $G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage( 'publish', 'blank' ); G::RenderPage( 'publish', 'blank' );
} }

View File

@@ -1,111 +1,113 @@
<?php <?php
/** /**
* cases_List.php * cases_List.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
/** /**
* Cases list (Refactored) * Cases list (Refactored)
* By Erik A. * By Erik A.
* O. <erik@colosa.com, aortiz.erik@gmail.com> * O. <erik@colosa.com, aortiz.erik@gmail.com>
*/ */
/* Permissions */ /* Permissions */
if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1) if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1) {
return $RBAC_Response; return $RBAC_Response;
}
/* Includes */
G::LoadClass( 'case' ); /* Includes */
G::LoadClass( 'configuration' ); G::LoadClass( 'case' );
G::LoadClass( 'configuration' );
// $_GET['l'] has the type of cases list like todo,pause,cancel, all // $_GET['l'] has the type of cases list like todo,pause,cancel, all
$conf = new Configurations(); $conf = new Configurations();
if (! isset( $_GET['l'] )) { if (! isset( $_GET['l'] )) {
$confCasesList = $conf->loadObject( 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' ); $confCasesList = $conf->loadObject( 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' );
if (is_array( $confCasesList )) { if (is_array( $confCasesList )) {
$sTypeList = $confCasesList['sTypeList']; $sTypeList = $confCasesList['sTypeList'];
} else { } else {
$sTypeList = 'to_do'; $sTypeList = 'to_do';
} }
} else { } else {
$sTypeList = $_GET['l']; $sTypeList = $_GET['l'];
$confCasesList = array ('sTypeList' => $sTypeList $confCasesList = array ('sTypeList' => $sTypeList
); );
$conf->saveObject( $confCasesList, 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' ); $conf->saveObject( $confCasesList, 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' );
} }
$sUIDUserLogged = $_SESSION['USER_LOGGED']; $sUIDUserLogged = $_SESSION['USER_LOGGED'];
$_SESSION['CASES_MENU_OPTION'] = $sTypeList; $_SESSION['CASES_MENU_OPTION'] = $sTypeList;
$oCases = new Cases(); $oCases = new Cases();
/** /**
* here we verify if there is a any case with a unpause on this day * here we verify if there is a any case with a unpause on this day
*/ */
if ($sTypeList === 'to_do' or $sTypeList === 'draft' or $sTypeList === 'paused') { if ($sTypeList === 'to_do' or $sTypeList === 'draft' or $sTypeList === 'paused') {
$oCases->ThrowUnpauseDaemon( date( 'Y-m-d' ) ); $oCases->ThrowUnpauseDaemon( date( 'Y-m-d' ) );
} }
/* * /* *
* Prepare the addtional filters before to show * Prepare the addtional filters before to show
* By Erik * By Erik
*/ */
$aAdditionalFilter = Array (); $aAdditionalFilter = Array ();
if (isset( $_GET['PROCESS_UID'] ) and $_GET['PROCESS_UID'] != "0" && $_GET['PROCESS_UID'] != "") { if (isset( $_GET['PROCESS_UID'] ) and $_GET['PROCESS_UID'] != "0" && $_GET['PROCESS_UID'] != "") {
$PRO_UID = $_GET['PROCESS_UID']; $PRO_UID = $_GET['PROCESS_UID'];
$aAdditionalFilter['PRO_UID'] = $PRO_UID; $aAdditionalFilter['PRO_UID'] = $PRO_UID;
} else { } else {
$PRO_UID = "0"; $PRO_UID = "0";
} }
if (isset( $_GET['READ'] ) and $_GET['READ'] == "1") { if (isset( $_GET['READ'] ) and $_GET['READ'] == "1") {
$aAdditionalFilter['READ'] = $_GET['READ']; $aAdditionalFilter['READ'] = $_GET['READ'];
} }
if (isset( $_GET['UNREAD'] ) and $_GET['UNREAD'] == "1") { if (isset( $_GET['UNREAD'] ) and $_GET['UNREAD'] == "1") {
$aAdditionalFilter['UNREAD'] = $_GET['UNREAD']; $aAdditionalFilter['UNREAD'] = $_GET['UNREAD'];
} }
if (isset( $_GET['APP_STATUS_FILTER'] ) and $_GET['APP_STATUS_FILTER'] != "ALL") { if (isset( $_GET['APP_STATUS_FILTER'] ) and $_GET['APP_STATUS_FILTER'] != "ALL") {
$aAdditionalFilter['APP_STATUS_FILTER'] = $_GET['APP_STATUS_FILTER']; $aAdditionalFilter['APP_STATUS_FILTER'] = $_GET['APP_STATUS_FILTER'];
} }
if (isset( $_GET['MINE'] ) and $_GET['MINE'] == "1") { if (isset( $_GET['MINE'] ) and $_GET['MINE'] == "1") {
$aAdditionalFilter['MINE'] = $_GET['MINE']; $aAdditionalFilter['MINE'] = $_GET['MINE'];
} }
switch ($sTypeList) { switch ($sTypeList) {
case 'to_do': case 'to_do':
if (defined( 'ENABLE_CASE_LIST_OPTIMIZATION' )) { if (defined( 'ENABLE_CASE_LIST_OPTIMIZATION' )) {
$aCriteria = $oCases->prepareCriteriaForToDo( $sUIDUserLogged ); $aCriteria = $oCases->prepareCriteriaForToDo( $sUIDUserLogged );
$xmlfile = 'cases/cases_ListTodoNew'; $xmlfile = 'cases/cases_ListTodoNew';
} else } else {
list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter ); list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter );
break; }
default: break;
list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter ); default:
} list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter );
}
/* /*
$rs = ApplicationPeer::doSelectRS($aCriteria); $rs = ApplicationPeer::doSelectRS($aCriteria);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
@@ -118,52 +120,52 @@ $rs = ApplicationPeer::doSelectRS($aCriteria);
g::pr($aRows1);die;*/ g::pr($aRows1);die;*/
/* GET , POST & $_SESSION Vars */ /* GET , POST & $_SESSION Vars */
if (! isset( $_GET['PROCESS_UID'] )) { if (! isset( $_GET['PROCESS_UID'] )) {
$oCase = new Cases(); $oCase = new Cases();
$rs = ApplicationPeer::doSelectRS( $aCriteria ); $rs = ApplicationPeer::doSelectRS( $aCriteria );
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$aProcess = Array ();
while ($rs->next()) {
$aRow = $rs->getRow();
//g::pr($aRow); die;
if (! InAssocArray( $aRow, 'PRO_UID', $aRow['PRO_UID'] )) {
array_push( $aProcess, Array ('PRO_UID' => $aRow['PRO_UID'],'PRO_TITLE' => $aRow['APP_PRO_TITLE'] ) );
}
}
$_DBArray['_PROCESSES'] = array_merge( Array (Array ('PRO_UID' => 'char','PRO_TITLE' => 'char' ) ), $aProcess );
$_SESSION['_DBArray'] = $_DBArray;
} else {
$_DBArray = $_SESSION['_DBArray'];
}
/* Render page */
$G_PUBLISH = new Publisher();
$G_PUBLISH->ROWS_PER_PAGE = 12;
if ($sTypeList == 'to_reassign') {
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_ReassignBy', '', array ('REASSIGN_BY' => 1 ) );
}
$aData = Array ('PROCESS_FILTER' => $PRO_UID,'APP_STATUS_FILTER' => (isset( $_GET['APP_STATUS_FILTER'] ) ? $_GET['APP_STATUS_FILTER'] : '0')
);
$G_PUBLISH->AddContent( 'propeltable', 'paged-table', $xmlfile, $aCriteria, $aData );
G::RenderPage( 'publish', 'blank' );
function InAssocArray ($a, $k, $v)
{
foreach ($a as $item) {
if (isset( $item[$k] ) && $v == $item[$k])
return true;
}
return false;
}
?>
$aProcess = Array ();
while ($rs->next()) {
$aRow = $rs->getRow();
//g::pr($aRow); die;
if (! InAssocArray( $aRow, 'PRO_UID', $aRow['PRO_UID'] )) {
array_push( $aProcess, Array ('PRO_UID' => $aRow['PRO_UID'],'PRO_TITLE' => $aRow['APP_PRO_TITLE'] ) );
}
}
$_DBArray['_PROCESSES'] = array_merge( Array (Array ('PRO_UID' => 'char','PRO_TITLE' => 'char' ) ), $aProcess );
$_SESSION['_DBArray'] = $_DBArray;
} else {
$_DBArray = $_SESSION['_DBArray'];
}
/* Render page */
$G_PUBLISH = new Publisher();
$G_PUBLISH->ROWS_PER_PAGE = 12;
if ($sTypeList == 'to_reassign') {
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_ReassignBy', '', array ('REASSIGN_BY' => 1 ) );
}
$aData = Array ('PROCESS_FILTER' => $PRO_UID,'APP_STATUS_FILTER' => (isset( $_GET['APP_STATUS_FILTER'] ) ? $_GET['APP_STATUS_FILTER'] : '0')
);
$G_PUBLISH->AddContent( 'propeltable', 'paged-table', $xmlfile, $aCriteria, $aData );
G::RenderPage( 'publish', 'blank' );
function InAssocArray ($a, $k, $v)
{
foreach ($a as $item) {
if (isset( $item[$k] ) && $v == $item[$k]) {
return true;
}
}
return false;
}
?>
<script> <script>
try{ try{
oPropelTable = document.getElementById('publisherContent[0]'); oPropelTable = document.getElementById('publisherContent[0]');
@@ -175,5 +177,6 @@ function InAssocArray ($a, $k, $v)
parent.PANEL_EAST_OPEN = false; parent.PANEL_EAST_OPEN = false;
if(parent.refreshCountFolders) parent.refreshCountFolders(); if(parent.refreshCountFolders) parent.refreshCountFolders();
}catch(e){} }catch(e){}
</script> </script>
<?php

View File

@@ -1,162 +1,166 @@
<?php <?php
/** /**
* cases_New.php * cases_New.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
//we're looking for the type of view //we're looking for the type of view
function putTypeView () function putTypeView ()
{ {
require_once 'classes/model/Configuration.php'; require_once 'classes/model/Configuration.php';
$oConfiguration = new Configuration(); $oConfiguration = new Configuration();
$oCriteria = new Criteria( 'workflow' ); $oCriteria = new Criteria( 'workflow' );
$oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' ); $oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' );
$oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] ); $oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] );
if (ConfigurationPeer::doCount( $oCriteria )) { if (ConfigurationPeer::doCount( $oCriteria )) {
$conf = ConfigurationPeer::doSelect( $oCriteria ); $conf = ConfigurationPeer::doSelect( $oCriteria );
return $conf[0]->getCfgValue(); return $conf[0]->getCfgValue();
} else { } else {
return 'dropdown'; return 'dropdown';
} }
} }
$_GET['change'] = (isset( $_GET['change'] )) ? $_GET['change'] : putTypeView(); $_GET['change'] = (isset( $_GET['change'] )) ? $_GET['change'] : putTypeView();
/* Permissions */ /* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) { switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2: case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
case - 1:
case - 1: G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); G::header( 'location: ../login/login' );
G::header( 'location: ../login/login' ); die();
die(); break;
break; }
}
/* Includes */
/* Includes */ G::LoadClass( 'case' );
G::LoadClass( 'case' );
/* GET , POST & $_SESSION Vars */ /* GET , POST & $_SESSION Vars */
/* Menues */ /* Menues */
$G_MAIN_MENU = 'processmaker'; $G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'cases'; $G_SUB_MENU = 'cases';
$G_ID_MENU_SELECTED = 'CASES'; $G_ID_MENU_SELECTED = 'CASES';
$G_ID_SUB_MENU_SELECTED = 'CASES_DRAFT'; $G_ID_SUB_MENU_SELECTED = 'CASES_DRAFT';
/* Prepare page before to show */ /* Prepare page before to show */
$aFields = array (); $aFields = array ();
$oCase = new Cases(); $oCase = new Cases();
$bCanStart = $oCase->canStartCase( $_SESSION['USER_LOGGED'] ); $bCanStart = $oCase->canStartCase( $_SESSION['USER_LOGGED'] );
if ($bCanStart) { if ($bCanStart) {
$aFields['LANG'] = SYS_LANG; $aFields['LANG'] = SYS_LANG;
$aFields['USER'] = $_SESSION['USER_LOGGED']; $aFields['USER'] = $_SESSION['USER_LOGGED'];
$sXmlForm = 'cases/cases_New.xml'; $sXmlForm = 'cases/cases_New.xml';
//$_DBArray['NewCase'] = $oCase->getStartCases( $_SESSION['USER_LOGGED'] ); //$_DBArray['NewCase'] = $oCase->getStartCases( $_SESSION['USER_LOGGED'] );
$_DBArray['NewCase'] = $oCase->getStartCasesPerType( $_SESSION['USER_LOGGED'], $_GET['change'] ); $_DBArray['NewCase'] = $oCase->getStartCasesPerType( $_SESSION['USER_LOGGED'], $_GET['change'] );
} else { } else {
$sXmlForm = 'cases/cases_CannotInitiateCase.xml'; $sXmlForm = 'cases/cases_CannotInitiateCase.xml';
} }
if (isset( $_SESSION['G_MESSAGE'] ) && strlen( $_SESSION['G_MESSAGE'] ) > 0) { if (isset( $_SESSION['G_MESSAGE'] ) && strlen( $_SESSION['G_MESSAGE'] ) > 0) {
$aMessage = array (); $aMessage = array ();
$aMessage['MESSAGE'] = $_SESSION['G_MESSAGE']; $aMessage['MESSAGE'] = $_SESSION['G_MESSAGE'];
//$_SESSION['G_MESSAGE_TYPE']; //$_SESSION['G_MESSAGE_TYPE'];
unset( $_SESSION['G_MESSAGE'] ); unset( $_SESSION['G_MESSAGE'] );
unset( $_SESSION['G_MESSAGE_TYPE'] ); unset( $_SESSION['G_MESSAGE_TYPE'] );
} }
//get the config parameter to show in dropdown or list //get the config parameter to show in dropdown or list
require_once 'classes/model/Configuration.php'; require_once 'classes/model/Configuration.php';
$oConfiguration = new Configuration(); $oConfiguration = new Configuration();
$oCriteria = new Criteria( 'workflow' ); $oCriteria = new Criteria( 'workflow' );
$oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' ); $oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' );
$oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] ); $oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] );
if (ConfigurationPeer::doCount( $oCriteria ) == 0) { if (ConfigurationPeer::doCount( $oCriteria ) == 0) {
$aData['CFG_UID'] = 'StartNewCase'; $aData['CFG_UID'] = 'StartNewCase';
$aData['OBJ_UID'] = ''; $aData['OBJ_UID'] = '';
$aData['CFG_VALUE'] = 'dropdown'; $aData['CFG_VALUE'] = 'dropdown';
$aData['PRO_UID'] = ''; $aData['PRO_UID'] = '';
$aData['USR_UID'] = $_SESSION['USER_LOGGED']; $aData['USR_UID'] = $_SESSION['USER_LOGGED'];
$aData['APP_UID'] = ''; $aData['APP_UID'] = '';
$oConfig = new Configuration(); $oConfig = new Configuration();
$oConfig->create( $aData ); $oConfig->create( $aData );
$listType = 'dropdown'; $listType = 'dropdown';
} else { } else {
$oConfiguration = new Configuration(); $oConfiguration = new Configuration();
$oCriteria = new Criteria( 'workflow' ); $oCriteria = new Criteria( 'workflow' );
$oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' ); $oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' );
$oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] ); $oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] );
$conf = ConfigurationPeer::doSelect( $oCriteria ); $conf = ConfigurationPeer::doSelect( $oCriteria );
$listType = $conf[0]->getCfgValue(); $listType = $conf[0]->getCfgValue();
} }
if (isset( $_GET['change'] )) { if (isset( $_GET['change'] )) {
$listType = $_GET['change']; $listType = $_GET['change'];
$aData['CFG_UID'] = 'StartNewCase'; $aData['CFG_UID'] = 'StartNewCase';
$aData['OBJ_UID'] = ''; $aData['OBJ_UID'] = '';
$aData['CFG_VALUE'] = $listType; $aData['CFG_VALUE'] = $listType;
$aData['PRO_UID'] = ''; $aData['PRO_UID'] = '';
$aData['USR_UID'] = $_SESSION['USER_LOGGED']; $aData['USR_UID'] = $_SESSION['USER_LOGGED'];
$aData['APP_UID'] = ''; $aData['APP_UID'] = '';
$oConfig = new Configuration(); $oConfig = new Configuration();
$oConfig->update( $aData ); $oConfig->update( $aData );
} }
/* Render page */ /* Render page */
$G_PUBLISH = new Publisher(); $G_PUBLISH = new Publisher();
$aFields['CHANGE_LINK'] = G::LoadTranslation( 'ID_CHANGE_VIEW' ); $aFields['CHANGE_LINK'] = G::LoadTranslation( 'ID_CHANGE_VIEW' );
if (isset( $aMessage )) { if (isset( $aMessage )) {
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
} }
if ($listType == 'dropdown') if ($listType == 'dropdown') {
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', $aFields, 'cases_Save' ); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', $aFields, 'cases_Save' );
}
if ($listType == 'link') {
if ($bCanStart) if ($listType == 'link') {
$sXmlForm = 'cases/cases_NewRadioGroup.xml'; if ($bCanStart) {
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', $aFields, 'cases_Save' ); $sXmlForm = 'cases/cases_NewRadioGroup.xml';
} }
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', $aFields, 'cases_Save' );
if ($listType == 'category') { }
if ($bCanStart)
$sXmlForm = 'cases/cases_NewCategory.xml'; if ($listType == 'category') {
$G_PUBLISH->AddContent( 'view', 'cases/cases_NewCategory' ); if ($bCanStart) {
} $sXmlForm = 'cases/cases_NewCategory.xml';
}
G::RenderPage( 'publish', 'blank' ); $G_PUBLISH->AddContent( 'view', 'cases/cases_NewCategory' );
}
G::RenderPage( 'publish', 'blank' );
?> ?>
<script> <script>
parent.outerLayout.hide('east'); parent.outerLayout.hide('east');
parent.PANEL_EAST_OPEN = false; parent.PANEL_EAST_OPEN = false;
</script> </script>
<?php

View File

@@ -1,32 +1,33 @@
<?php <?php
/** /**
* cases_NextStep.php * cases_NextStep.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1) if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1) {
return $RBAC_Response; return $RBAC_Response;
}
//go to the next step //go to the next step
G::LoadClass( 'case' ); G::LoadClass( 'case' );
$oCase = new Cases(); $oCase = new Cases();
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
$_SESSION['STEP_POSITION'] = $aNextStep['POSITION']; $_SESSION['STEP_POSITION'] = $aNextStep['POSITION'];
G::header( 'location: ' . $aNextStep['PAGE'] ); G::header( 'location: ' . $aNextStep['PAGE'] );

View File

@@ -1,203 +1,202 @@
<?php <?php
/** /**
* cases_Open.php * cases_Open.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc. * Copyright (C) 2004 - 2008 Colosa Inc.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
/* Permissions */ /* Permissions */
if ($RBAC->userCanAccess( 'PM_CASES' ) != 1) { if ($RBAC->userCanAccess( 'PM_CASES' ) != 1) {
switch ($RBAC->userCanAccess( 'PM_CASES' )) { switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2: case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
break; break;
case - 1: case - 1:
default: default:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
break; break;
} }
} }
/* Includes */ /* Includes */
require_once 'classes/model/AppDelay.php'; require_once 'classes/model/AppDelay.php';
G::LoadClass( 'case' ); G::LoadClass( 'case' );
$oCase = new Cases(); $oCase = new Cases();
//cleaning the case session data //cleaning the case session data
Cases::clearCaseSessionData(); Cases::clearCaseSessionData();
try { try {
//Loading data for a Jump request //Loading data for a Jump request
if (! isset( $_GET['APP_UID'] ) && isset( $_GET['APP_NUMBER'] )) { if (! isset( $_GET['APP_UID'] ) && isset( $_GET['APP_NUMBER'] )) {
$_GET['APP_UID'] = $oCase->getApplicationUIDByNumber( $_GET['APP_NUMBER'] ); $_GET['APP_UID'] = $oCase->getApplicationUIDByNumber( $_GET['APP_NUMBER'] );
$_GET['DEL_INDEX'] = $oCase->getCurrentDelegation( $_GET['APP_UID'], $_SESSION['USER_LOGGED'] ); $_GET['DEL_INDEX'] = $oCase->getCurrentDelegation( $_GET['APP_UID'], $_SESSION['USER_LOGGED'] );
//if the application doesn't exist //if the application doesn't exist
if (is_null( $_GET['APP_UID'] )) { if (is_null( $_GET['APP_UID'] )) {
G::SendMessageText( G::LoadTranslation( 'ID_CASE_DOES_NOT_EXISTS' ), 'info' ); G::SendMessageText( G::LoadTranslation( 'ID_CASE_DOES_NOT_EXISTS' ), 'info' );
G::header( 'location: casesListExtJs' ); G::header( 'location: casesListExtJs' );
exit(); exit();
} }
//if the application exists but the //if the application exists but the
if (is_null( $_GET['DEL_INDEX'] )) { if (is_null( $_GET['DEL_INDEX'] )) {
G::SendMessageText( G::LoadTranslation( 'ID_CASE_IS_CURRENTLY_WITH_ANOTHER_USER' ), 'info' ); G::SendMessageText( G::LoadTranslation( 'ID_CASE_IS_CURRENTLY_WITH_ANOTHER_USER' ), 'info' );
G::header( 'location: casesListExtJs' ); G::header( 'location: casesListExtJs' );
exit(); exit();
} }
//wrong implemented, need refactored //wrong implemented, need refactored
//$participated = $oCase->userParticipatedInCase($_GET['APP_UID'], $_SESSION['USER_LOGGED']); ??????? //$participated = $oCase->userParticipatedInCase($_GET['APP_UID'], $_SESSION['USER_LOGGED']); ???????
} }
$sAppUid = $_GET['APP_UID']; $sAppUid = $_GET['APP_UID'];
$iDelIndex = $_GET['DEL_INDEX']; $iDelIndex = $_GET['DEL_INDEX'];
$_action = isset( $_GET['action'] ) ? $_GET['action'] : ''; $_action = isset( $_GET['action'] ) ? $_GET['action'] : '';
//loading application data //loading application data
$aFields = $oCase->loadCase( $sAppUid, $iDelIndex ); $aFields = $oCase->loadCase( $sAppUid, $iDelIndex );
// g::pr($aFields); // g::pr($aFields);
// die; // die;
switch ($aFields['APP_STATUS']) { switch ($aFields['APP_STATUS']) {
case 'DRAFT': case 'DRAFT':
case 'TO_DO': case 'TO_DO':
//check if the case is in pause, check a valid record in table APP_DELAY //check if the case is in pause, check a valid record in table APP_DELAY
if (AppDelay::isPaused( $sAppUid, $iDelIndex )) { if (AppDelay::isPaused( $sAppUid, $iDelIndex )) {
//the case is paused show only the resume //the case is paused show only the resume
$_SESSION['APPLICATION'] = $sAppUid; $_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex; $_SESSION['INDEX'] = $iDelIndex;
$_SESSION['PROCESS'] = $aFields['PRO_UID']; $_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1; $_SESSION['TASK'] = - 1;
$_SESSION['STEP_POSITION'] = 0; $_SESSION['STEP_POSITION'] = 0;
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
exit(); exit();
} }
/** /**
* these routine is to verify if the case was acceded from advaced search list * these routine is to verify if the case was acceded from advaced search list
*/ */
if ($_action == 'search') { if ($_action == 'search') {
//verify if the case is with teh current user //verify if the case is with teh current user
$c = new Criteria( 'workflow' ); $c = new Criteria( 'workflow' );
$c->add( AppDelegationPeer::APP_UID, $sAppUid ); $c->add( AppDelegationPeer::APP_UID, $sAppUid );
$c->addDescendingOrderByColumn( AppDelegationPeer::DEL_INDEX ); $c->addDescendingOrderByColumn( AppDelegationPeer::DEL_INDEX );
$oDataset = AppDelegationPeer::doSelectRs( $c ); $oDataset = AppDelegationPeer::doSelectRs( $c );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next(); $oDataset->next();
$aData = $oDataset->getRow(); $aData = $oDataset->getRow();
if ($aData['USR_UID'] != $_SESSION['USER_LOGGED'] && $aData['USR_UID'] != "") //distinct "" for selfservice if ($aData['USR_UID'] != $_SESSION['USER_LOGGED'] && $aData['USR_UID'] != "") {
{ //distinct "" for selfservice
//so we show just the resume //so we show just the resume
$_SESSION['alreadyDerivated'] = true; $_SESSION['alreadyDerivated'] = true;
//the case is paused show only the resume //the case is paused show only the resume
$_SESSION['APPLICATION'] = $sAppUid; $_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex; $_SESSION['INDEX'] = $iDelIndex;
$_SESSION['PROCESS'] = $aFields['PRO_UID']; $_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1; $_SESSION['TASK'] = - 1;
$_SESSION['STEP_POSITION'] = 0; $_SESSION['STEP_POSITION'] = 0;
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
exit(); exit();
} }
} }
//proceed and try to open the case //proceed and try to open the case
$oAppDelegation = new AppDelegation(); $oAppDelegation = new AppDelegation();
$aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex ); $aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex );
//if there are no user in the delegation row, this case is in selfservice //if there are no user in the delegation row, this case is in selfservice
if ($aDelegation['USR_UID'] == "" /*&& $aDelegation['DEL_THREAD_STATUS'] == 'SELFSERVICE'*/ ) { if ($aDelegation['USR_UID'] == "" /*&& $aDelegation['DEL_THREAD_STATUS'] == 'SELFSERVICE'*/ ) {
$_SESSION['APPLICATION'] = $sAppUid; $_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex; $_SESSION['INDEX'] = $iDelIndex;
$_SESSION['PROCESS'] = $aFields['PRO_UID']; $_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1; $_SESSION['TASK'] = - 1;
$_SESSION['STEP_POSITION'] = 0; $_SESSION['STEP_POSITION'] = 0;
$_SESSION['CURRENT_TASK'] = $aFields['TAS_UID']; $_SESSION['CURRENT_TASK'] = $aFields['TAS_UID'];
//if the task is in the valid selfservice tasks for this user, then catch the case, else just view the resume //if the task is in the valid selfservice tasks for this user, then catch the case, else just view the resume
if ($oCase->isSelfService( $_SESSION['USER_LOGGED'], $aFields['TAS_UID'], $sAppUid )) { if ($oCase->isSelfService( $_SESSION['USER_LOGGED'], $aFields['TAS_UID'], $sAppUid )) {
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_CatchSelfService.php'); require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_CatchSelfService.php');
} else { } else {
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
} }
exit(); exit();
} }
//if the current users is in the AppDelegation row, then open the case //if the current users is in the AppDelegation row, then open the case
if (($aDelegation['USR_UID'] == $_SESSION['USER_LOGGED']) && $_action != 'sent') { if (($aDelegation['USR_UID'] == $_SESSION['USER_LOGGED']) && $_action != 'sent') {
$_SESSION['APPLICATION'] = $sAppUid; $_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex; $_SESSION['INDEX'] = $iDelIndex;
if (is_null( $aFields['DEL_INIT_DATE'] )) { if (is_null( $aFields['DEL_INIT_DATE'] )) {
$oCase->setDelInitDate( $sAppUid, $iDelIndex ); $oCase->setDelInitDate( $sAppUid, $iDelIndex );
$aFields = $oCase->loadCase( $sAppUid, $iDelIndex ); $aFields = $oCase->loadCase( $sAppUid, $iDelIndex );
} }
$_SESSION['PROCESS'] = $aFields['PRO_UID']; $_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = $aFields['TAS_UID']; $_SESSION['TASK'] = $aFields['TAS_UID'];
$_SESSION['STEP_POSITION'] = 0; $_SESSION['STEP_POSITION'] = 0;
/* Redirect to next step */ /* Redirect to next step */
unset( $_SESSION['bNoShowSteps'] ); unset( $_SESSION['bNoShowSteps'] );
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
$sPage = $aNextStep['PAGE']; $sPage = $aNextStep['PAGE'];
G::header( 'location: ' . $sPage ); G::header( 'location: ' . $sPage );
} else { } else {
//when the case have another user or current user doesnt have rights to this selfservice, //when the case have another user or current user doesnt have rights to this selfservice,
//just view the case Resume //just view the case Resume
$_SESSION['APPLICATION'] = $sAppUid; $_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex; $_SESSION['INDEX'] = $iDelIndex;
$_SESSION['PROCESS'] = $aFields['PRO_UID']; $_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1; $_SESSION['TASK'] = - 1;
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); $Fields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] );
$_SESSION['CURRENT_TASK'] = $Fields['TAS_UID']; $_SESSION['CURRENT_TASK'] = $Fields['TAS_UID'];
$_SESSION['STEP_POSITION'] = 0; $_SESSION['STEP_POSITION'] = 0;
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
} }
break; break;
default: //APP_STATUS <> DRAFT and TO_DO
default: //APP_STATUS <> DRAFT and TO_DO $_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['APPLICATION'] = $sAppUid; $_SESSION['INDEX'] = $iDelIndex != "" ? $iDelIndex : $oCase->getCurrentDelegationCase( $_GET['APP_UID'] );
$_SESSION['INDEX'] = $iDelIndex != "" ? $iDelIndex : $oCase->getCurrentDelegationCase( $_GET['APP_UID'] ); $_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['PROCESS'] = $aFields['PRO_UID']; $_SESSION['TASK'] = - 1;
$_SESSION['TASK'] = - 1; $_SESSION['STEP_POSITION'] = 0;
$_SESSION['STEP_POSITION'] = 0;
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); }
} } catch (Exception $e) {
} catch (Exception $e) { $aMessage = array ();
$aMessage = array (); $aMessage['MESSAGE'] = $e->getMessage();
$aMessage['MESSAGE'] = $e->getMessage(); $G_PUBLISH = new Publisher();
$G_PUBLISH = new Publisher(); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); G::RenderPage( 'publishBlank', 'blank' );
G::RenderPage( 'publishBlank', 'blank' );
} }

View File

@@ -1,75 +1,76 @@
<?php <?php
/** /**
* cases_Open.php * cases_Open.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
/* Permissions */ /* Permissions */
if ($RBAC->userCanAccess( 'PM_SUPERVISOR' ) != 1) if ($RBAC->userCanAccess( 'PM_SUPERVISOR' ) != 1) {
switch ($RBAC->userCanAccess( 'PM_SUPERVISOR' )) { switch ($RBAC->userCanAccess( 'PM_SUPERVISOR' )) {
case - 2: case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
default: default:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' ); G::header( 'location: ../login/login' );
die(); die();
break; break;
} }
}
/* Includes */
G::LoadClass( 'case' ); /* Includes */
G::LoadClass( 'case' );
/* GET , POST & $_SESSION Vars */
if (isset( $_SESSION['APPLICATION'] )) { /* GET , POST & $_SESSION Vars */
unset( $_SESSION['APPLICATION'] ); if (isset( $_SESSION['APPLICATION'] )) {
} unset( $_SESSION['APPLICATION'] );
if (isset( $_SESSION['PROCESS'] )) { }
unset( $_SESSION['PROCESS'] ); if (isset( $_SESSION['PROCESS'] )) {
} unset( $_SESSION['PROCESS'] );
if (isset( $_SESSION['INDEX'] )) { }
unset( $_SESSION['INDEX'] ); if (isset( $_SESSION['INDEX'] )) {
} unset( $_SESSION['INDEX'] );
if (isset( $_SESSION['STEP_POSITION'] )) { }
unset( $_SESSION['STEP_POSITION'] ); if (isset( $_SESSION['STEP_POSITION'] )) {
} unset( $_SESSION['STEP_POSITION'] );
}
/* Process the info */
$oCase = new Cases(); /* Process the info */
$sAppUid = $_GET['APP_UID']; $oCase = new Cases();
$iDelIndex = $_GET['DEL_INDEX']; $sAppUid = $_GET['APP_UID'];
$iDelIndex = $_GET['DEL_INDEX'];
$_SESSION['APPLICATION'] = $_GET['APP_UID'];
$_SESSION['INDEX'] = $_GET['DEL_INDEX']; $_SESSION['APPLICATION'] = $_GET['APP_UID'];
$_SESSION['INDEX'] = $_GET['DEL_INDEX'];
$aFields = $oCase->loadCase( $sAppUid, $iDelIndex );
$aFields = $oCase->loadCase( $sAppUid, $iDelIndex );
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = $aFields['TAS_UID']; $_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['STEP_POSITION'] = 0; $_SESSION['TASK'] = $aFields['TAS_UID'];
$_SESSION['STEP_POSITION'] = 0;
/* Redirect to next step */
$aNextStep = $oCase->getNextSupervisorStep( $_SESSION['PROCESS'], 0 ); /* Redirect to next step */
$aNextStep = $oCase->getNextSupervisorStep( $_SESSION['PROCESS'], 0 );
$sPage = "cases_StepToRevise?type=DYNAFORM&PRO_UID=" . $aFields['PRO_UID'] . "&DYN_UID=" . $aNextStep['UID'] . "&APP_UID=$sAppUid&DEL_INDEX=$iDelIndex&position=1"; //$aNextStep['PAGE']; $sPage = "cases_StepToRevise?type=DYNAFORM&PRO_UID=" . $aFields['PRO_UID'] . "&DYN_UID=" . $aNextStep['UID'] . "&APP_UID=$sAppUid&DEL_INDEX=$iDelIndex&position=1"; //$aNextStep['PAGE'];
G::header( 'location: ' . $sPage ); G::header( 'location: ' . $sPage );

View File

@@ -1,96 +1,96 @@
<?php <?php
/** /**
* Cases_PrintPreview.php * Cases_PrintPreview.php
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23 * Copyright (C) 2004 - 2008 Colosa Inc.23
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
try { try {
require_once 'classes/model/Dynaform.php'; require_once 'classes/model/Dynaform.php';
require_once 'classes/model/Process.php'; require_once 'classes/model/Process.php';
$currentDynUid = ''; $currentDynUid = '';
if (isset( $_GET['DYNUIDPRINT'] ) && $_GET['DYNUIDPRINT'] != '') { if (isset( $_GET['DYNUIDPRINT'] ) && $_GET['DYNUIDPRINT'] != '') {
$currentDynUid = $_GET['DYNUIDPRINT']; $currentDynUid = $_GET['DYNUIDPRINT'];
} elseif (isset( $_SESSION['DYN_UID_PRINT'] )) { } elseif (isset( $_SESSION['DYN_UID_PRINT'] )) {
$currentDynUid = $_SESSION['DYN_UID_PRINT']; $currentDynUid = $_SESSION['DYN_UID_PRINT'];
} elseif (isset( $_SESSION['CURRENT_DYN_UID'] )) { } elseif (isset( $_SESSION['CURRENT_DYN_UID'] )) {
$currentDynUid = $_SESSION['CURRENT_DYN_UID']; $currentDynUid = $_SESSION['CURRENT_DYN_UID'];
} }
$oDynaform = new Dynaform(); $oDynaform = new Dynaform();
$aDyn = $oDynaform->load( $currentDynUid ); $aDyn = $oDynaform->load( $currentDynUid );
G::LoadClass( 'case' ); G::LoadClass( 'case' );
$oCase = new Cases(); $oCase = new Cases();
if (isset( $_SESSION['APPLICATION'] )) { if (isset( $_SESSION['APPLICATION'] )) {
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'] ); $Fields = $oCase->loadCase( $_SESSION['APPLICATION'] );
$Fields['APP_DATA'] = array_merge( $Fields['APP_DATA'], G::getSystemConstants() ); $Fields['APP_DATA'] = array_merge( $Fields['APP_DATA'], G::getSystemConstants() );
} else { } else {
$Fields['APP_DATA'] = Array (); $Fields['APP_DATA'] = Array ();
} }
$G_MAIN_MENU = 'processmaker'; $G_MAIN_MENU = 'processmaker';
$G_ID_MENU_SELECTED = 'USERS'; $G_ID_MENU_SELECTED = 'USERS';
$G_PUBLISH = new Publisher(); $G_PUBLISH = new Publisher();
$idProcess = (isset( $Fields['APP_DATA']['PROCESS'] )) ? $Fields['APP_DATA']['PROCESS'] : $_SESSION['PROCESS']; $idProcess = (isset( $Fields['APP_DATA']['PROCESS'] )) ? $Fields['APP_DATA']['PROCESS'] : $_SESSION['PROCESS'];
$oProcess = new Process(); $oProcess = new Process();
$aProcessFieds = $oProcess->load( $idProcess ); $aProcessFieds = $oProcess->load( $idProcess );
$sProcess = $oProcess->getProTitle(); $sProcess = $oProcess->getProTitle();
$noShowTitle = 0; $noShowTitle = 0;
if (isset( $aProcessFieds['PRO_SHOW_MESSAGE'] )) { if (isset( $aProcessFieds['PRO_SHOW_MESSAGE'] )) {
$noShowTitle = $aProcessFieds['PRO_SHOW_MESSAGE']; $noShowTitle = $aProcessFieds['PRO_SHOW_MESSAGE'];
} }
//Add content content step - Start //Add content content step - Start
if (isset( $_SESSION['APPLICATION'] )) { if (isset( $_SESSION['APPLICATION'] )) {
$array['CASE'] = G::LoadTranslation( 'ID_CASE' ); $array['CASE'] = G::LoadTranslation( 'ID_CASE' );
$array['USER'] = G::LoadTranslation( 'ID_USER' ); $array['USER'] = G::LoadTranslation( 'ID_USER' );
$array['WORKSPACE'] = G::LoadTranslation( 'ID_WORKSPACE' ); $array['WORKSPACE'] = G::LoadTranslation( 'ID_WORKSPACE' );
$array['APP_NUMBER'] = $Fields['APP_NUMBER']; $array['APP_NUMBER'] = $Fields['APP_NUMBER'];
$array['APP_TITLE'] = $Fields['TITLE']; $array['APP_TITLE'] = $Fields['TITLE'];
$array['USR_USERNAME'] = $Fields['APP_DATA']['USR_USERNAME']; $array['USR_USERNAME'] = $Fields['APP_DATA']['USR_USERNAME'];
$array['USER_ENV'] = $Fields['APP_DATA']['SYS_SYS']; $array['USER_ENV'] = $Fields['APP_DATA']['SYS_SYS'];
$array['DATEPRINT'] = date( 'Y-m-d H:m:s' ); $array['DATEPRINT'] = date( 'Y-m-d H:m:s' );
} }
$array['APP_PROCESS'] = $sProcess; $array['APP_PROCESS'] = $sProcess;
if (isset( $Fields['TITLE'] ) && strlen( $Fields['TITLE'] ) > 0) { if (isset( $Fields['TITLE'] ) && strlen( $Fields['TITLE'] ) > 0) {
$array['TITLE'] = G::LoadTranslation( 'ID_TITLE' ); $array['TITLE'] = G::LoadTranslation( 'ID_TITLE' );
} else { } else {
$array['TITLE'] = ''; $array['TITLE'] = '';
} }
$array['PROCESS'] = G::LoadTranslation( 'ID_PROCESS' ); $array['PROCESS'] = G::LoadTranslation( 'ID_PROCESS' );
$array['DATELABEL'] = G::LoadTranslation( 'DATE_LABEL' ); $array['DATELABEL'] = G::LoadTranslation( 'DATE_LABEL' );
$aDyn['DYN_UID'] = $currentDynUid; $aDyn['DYN_UID'] = $currentDynUid;
if ($noShowTitle == 0) { if ($noShowTitle == 0) {
$G_PUBLISH->AddContent( 'smarty', 'cases/cases_PrintViewTitle', '', '', $array ); $G_PUBLISH->AddContent( 'smarty', 'cases/cases_PrintViewTitle', '', '', $array );
} }
$G_PUBLISH->AddContent( 'dynaform', 'xmlform', $aDyn['PRO_UID'] . '/' . $aDyn['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view' ); $G_PUBLISH->AddContent( 'dynaform', 'xmlform', $aDyn['PRO_UID'] . '/' . $aDyn['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view' );
G::RenderPage( 'publish', 'blank' ); G::RenderPage( 'publish', 'blank' );
} catch (Exception $oException) { } catch (Exception $oException) {
die( $oException->getMessage() ); die( $oException->getMessage() );
} }
?> ?>
<script> <script>
@@ -121,5 +121,7 @@ try {
window.print(); window.print();
} catch(e){} } catch(e){}
</script> </script>
<?php

View File

@@ -1,100 +1,98 @@
<?php <?php
/** /**
* To change this template, choose Tools | Templates * To change this template, choose Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */
require_once ("classes/model/AdditionalTables.php"); require_once ("classes/model/AdditionalTables.php");
require_once ("classes/model/Fields.php"); require_once ("classes/model/Fields.php");
// passing the parameters // passing the parameters
$pmTableName = (isset( $_POST['tableName'] )) ? $_POST['tableName'] : 'contenders'; $pmTableName = (isset( $_POST['tableName'] )) ? $_POST['tableName'] : 'contenders';
$pmTableFields = (isset( $_POST['tableFields'] )) ? G::json_decode( $_POST['tableFields'] ) : array (); $pmTableFields = (isset( $_POST['tableFields'] )) ? G::json_decode( $_POST['tableFields'] ) : array ();
// default parameters // default parameters
//$pmTableName = 'Sender'; //$pmTableName = 'Sender';
$pmTableFields = array (array ('FLD_NAME' => 'APP_UID' $pmTableFields = array (array ('FLD_NAME' => 'APP_UID'
),array ('FLD_NAME' => 'CON_NAME' ),array ('FLD_NAME' => 'CON_NAME'
),array ('FLD_NAME' => 'CON_ADDR' ),array ('FLD_NAME' => 'CON_ADDR'
),array ('FLD_NAME' => '_cedula' ),array ('FLD_NAME' => '_cedula'
) )
); );
// setting the data to assemble the table // setting the data to assemble the table
$aData = array (); $aData = array ();
$aData['ADD_TAB_NAME'] = $pmTableName; $aData['ADD_TAB_NAME'] = $pmTableName;
// creating the objects to create the table and records // creating the objects to create the table and records
$oFields = new Fields(); $oFields = new Fields();
$oAdditionalTables = new AdditionalTables(); $oAdditionalTables = new AdditionalTables();
$sAddTabUid = $oAdditionalTables->create( $aData, $pmTableFields ); $sAddTabUid = $oAdditionalTables->create( $aData, $pmTableFields );
foreach ($pmTableFields as $iRow => $aRow) { foreach ($pmTableFields as $iRow => $aRow) {
$pmTableFields[$iRow]['FLD_NAME'] = strtoupper( $aRow['FLD_NAME'] ); $pmTableFields[$iRow]['FLD_NAME'] = strtoupper( $aRow['FLD_NAME'] );
$pmTableFields[$iRow]['FLD_DESCRIPTION'] = isset( $aRow['FLD_DESCRIPTION'] ) ? $aRow['FLD_DESCRIPTION'] : $aRow['FLD_NAME']; $pmTableFields[$iRow]['FLD_DESCRIPTION'] = isset( $aRow['FLD_DESCRIPTION'] ) ? $aRow['FLD_DESCRIPTION'] : $aRow['FLD_NAME'];
$pmTableFields[$iRow]['FLD_TYPE'] = isset( $aRow['FLD_TYPE'] ) ? $aRow['FLD_TYPE'] : 'VARCHAR'; $pmTableFields[$iRow]['FLD_TYPE'] = isset( $aRow['FLD_TYPE'] ) ? $aRow['FLD_TYPE'] : 'VARCHAR';
$pmTableFields[$iRow]['FLD_SIZE'] = isset( $aRow['FLD_SIZE'] ) ? $aRow['FLD_SIZE'] : '32'; $pmTableFields[$iRow]['FLD_SIZE'] = isset( $aRow['FLD_SIZE'] ) ? $aRow['FLD_SIZE'] : '32';
$pmTableFields[$iRow]['FLD_NULL'] = isset( $aRow['FLD_NULL'] ) ? $aRow['FLD_NULL'] : 'off'; $pmTableFields[$iRow]['FLD_NULL'] = isset( $aRow['FLD_NULL'] ) ? $aRow['FLD_NULL'] : 'off';
$pmTableFields[$iRow]['FLD_AUTO_INCREMENT'] = isset( $aRow['FLD_AUTO_INCREMENT'] ) ? $aRow['FLD_AUTO_INCREMENT'] : 'off'; $pmTableFields[$iRow]['FLD_AUTO_INCREMENT'] = isset( $aRow['FLD_AUTO_INCREMENT'] ) ? $aRow['FLD_AUTO_INCREMENT'] : 'off';
$pmTableFields[$iRow]['FLD_KEY'] = isset( $aRow['FLD_KEY'] ) ? $aRow['FLD_KEY'] : 'off'; $pmTableFields[$iRow]['FLD_KEY'] = isset( $aRow['FLD_KEY'] ) ? $aRow['FLD_KEY'] : 'off';
$pmTableFields[$iRow]['FLD_FOREIGN_KEY'] = isset( $aRow['FLD_FOREIGN_KEY'] ) ? $aRow['FLD_FOREIGN_KEY'] : 'off'; $pmTableFields[$iRow]['FLD_FOREIGN_KEY'] = isset( $aRow['FLD_FOREIGN_KEY'] ) ? $aRow['FLD_FOREIGN_KEY'] : 'off';
$pmTableFields[$iRow]['FLD_FOREIGN_KEY_TABLE'] = isset( $aRow['FLD_FOREIGN_KEY_TABLE'] ) ? $aRow['FLD_FOREIGN_KEY_TABLE'] : ''; $pmTableFields[$iRow]['FLD_FOREIGN_KEY_TABLE'] = isset( $aRow['FLD_FOREIGN_KEY_TABLE'] ) ? $aRow['FLD_FOREIGN_KEY_TABLE'] : '';
} }
foreach ($pmTableFields as $iRow => $aRow) { foreach ($pmTableFields as $iRow => $aRow) {
$oFields->create( array ('FLD_INDEX' => $iRow + 1,'ADD_TAB_UID' => $sAddTabUid,'FLD_NAME' => $aRow['FLD_NAME'],'FLD_DESCRIPTION' => isset( $aRow['FLD_DESCRIPTION'] ) ? $aRow['FLD_DESCRIPTION'] : '','FLD_TYPE' => isset( $aRow['FLD_TYPE'] ) ? $aRow['FLD_TYPE'] : 'VARCHAR','FLD_SIZE' => isset( $aRow['FLD_SIZE'] ) ? $aRow['FLD_SIZE'] : '32','FLD_NULL' => ($aRow['FLD_NULL'] == 'on' ? 1 : 0),'FLD_AUTO_INCREMENT' => ($aRow['FLD_AUTO_INCREMENT'] == 'on' ? 1 : 0),'FLD_KEY' => ($aRow['FLD_KEY'] == 'on' ? 1 : 0),'FLD_FOREIGN_KEY' => ($aRow['FLD_FOREIGN_KEY'] == 'on' ? 1 : 0),'FLD_FOREIGN_KEY_TABLE' => isset( $aRow['FLD_FOREIGN_KEY_TABLE'] ) ? $aRow['FLD_FOREIGN_KEY_TABLE'] : '' $oFields->create( array ('FLD_INDEX' => $iRow + 1,'ADD_TAB_UID' => $sAddTabUid,'FLD_NAME' => $aRow['FLD_NAME'],'FLD_DESCRIPTION' => isset( $aRow['FLD_DESCRIPTION'] ) ? $aRow['FLD_DESCRIPTION'] : '','FLD_TYPE' => isset( $aRow['FLD_TYPE'] ) ? $aRow['FLD_TYPE'] : 'VARCHAR','FLD_SIZE' => isset( $aRow['FLD_SIZE'] ) ? $aRow['FLD_SIZE'] : '32','FLD_NULL' => ($aRow['FLD_NULL'] == 'on' ? 1 : 0),'FLD_AUTO_INCREMENT' => ($aRow['FLD_AUTO_INCREMENT'] == 'on' ? 1 : 0),'FLD_KEY' => ($aRow['FLD_KEY'] == 'on' ? 1 : 0),'FLD_FOREIGN_KEY' => ($aRow['FLD_FOREIGN_KEY'] == 'on' ? 1 : 0),'FLD_FOREIGN_KEY_TABLE' => isset( $aRow['FLD_FOREIGN_KEY_TABLE'] ) ? $aRow['FLD_FOREIGN_KEY_TABLE'] : '') );
) );
$aFields[] = array ('sType' => isset( $aRow['FLD_TYPE'] ) ? $aRow['FLD_TYPE'] : 'VARCHAR','iSize' => isset( $aRow['FLD_SIZE'] ) ? $aRow['FLD_SIZE'] : '32','sFieldName' => $aRow['FLD_NAME'],'bNull' => ($aRow['FLD_NULL'] == 'on' ? 1 : 0),'bAI' => ($aRow['FLD_AUTO_INCREMENT'] == 'on' ? 1 : 0),'bPrimaryKey' => ($aRow['FLD_KEY'] == 'on' ? 1 : 0));
$aFields[] = array ('sType' => isset( $aRow['FLD_TYPE'] ) ? $aRow['FLD_TYPE'] : 'VARCHAR','iSize' => isset( $aRow['FLD_SIZE'] ) ? $aRow['FLD_SIZE'] : '32','sFieldName' => $aRow['FLD_NAME'],'bNull' => ($aRow['FLD_NULL'] == 'on' ? 1 : 0),'bAI' => ($aRow['FLD_AUTO_INCREMENT'] == 'on' ? 1 : 0),'bPrimaryKey' => ($aRow['FLD_KEY'] == 'on' ? 1 : 0) }
);
} $oAdditionalTables->createTable( strtoupper( $pmTableName ), 'wf', $aFields );
$oAdditionalTables->createPropelClasses( strtoupper( $pmTableName ), $pmTableName, $pmTableFields, $sAddTabUid );
$oAdditionalTables->createTable( strtoupper( $pmTableName ), 'wf', $aFields );
$oAdditionalTables->createPropelClasses( strtoupper( $pmTableName ), $pmTableName, $pmTableFields, $sAddTabUid ); require_once ("classes/model/Application.php");
require_once ("classes/model/AdditionalTables.php");
require_once ("classes/model/Application.php"); require_once ("classes/model/Fields.php");
require_once ("classes/model/AdditionalTables.php");
require_once ("classes/model/Fields.php"); $Criteria = new Criteria( 'workflow' );
$Criteria->addSelectColumn( ApplicationPeer::APP_UID );
$Criteria = new Criteria( 'workflow' ); $Criteria->addSelectColumn( ApplicationPeer::APP_DATA );
$Criteria->addSelectColumn( ApplicationPeer::APP_UID );
$Criteria->addSelectColumn( ApplicationPeer::APP_DATA );
// $Criteria->add (AppCacheViewPeer::DEL_THREAD_STATUS, 'OPEN'); // $Criteria->add (AppCacheViewPeer::DEL_THREAD_STATUS, 'OPEN');
$oDataset = ApplicationPeer::doSelectRS( $Criteria ); $oDataset = ApplicationPeer::doSelectRS( $Criteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next(); $oDataset->next();
$aProcesses = array (); $aProcesses = array ();
$i = 0; $i = 0;
while ($aRow = $oDataset->getRow()) { while ($aRow = $oDataset->getRow()) {
$appuid = $aRow['APP_UID']; $appuid = $aRow['APP_UID'];
$data = unserialize( $aRow['APP_DATA'] ); $data = unserialize( $aRow['APP_DATA'] );
$cedula = '234' . rand( 1000, 999999 ); $cedula = '234' . rand( 1000, 999999 );
$nombre = 'nombre ' . rand( 1000, 999999 ); $nombre = 'nombre ' . rand( 1000, 999999 );
$direccion = 'direccion ' . rand( 1000, 999999 ); $direccion = 'direccion ' . rand( 1000, 999999 );
if (isset( $data['_cedula'] )) { if (isset( $data['_cedula'] )) {
$cedula = $data['_cedula']; $cedula = $data['_cedula'];
$nombre = isset( $data['_nombre'] ) ? $data['_nombre'] : ''; $nombre = isset( $data['_nombre'] ) ? $data['_nombre'] : '';
$direccion = isset( $data['_direccion'] ) ? $data['_direccion'] : ''; $direccion = isset( $data['_direccion'] ) ? $data['_direccion'] : '';
print "$i $appuid $cedula <br>"; print "$i $appuid $cedula <br>";
} }
// print_r ( $aRow); // print_r ( $aRow);
$sql = "insert CONTENDERS VALUES ( '$appuid', '$nombre', '$direccion', '$cedula' )"; $sql = "insert CONTENDERS VALUES ( '$appuid', '$nombre', '$direccion', '$cedula' )";
$con = Propel::getConnection( 'workflow' ); $con = Propel::getConnection( 'workflow' );
$stmt = $con->createStatement(); $stmt = $con->createStatement();
$rs = $stmt->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC ); $rs = $stmt->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC );
$i ++; $i ++;
// if ( $i == 100 ) die; // if ( $i == 100 ) die;
/* if ( strpos ( $aRow['APP_DATA'], 'cedula' ) !== false ) { /* if ( strpos ( $aRow['APP_DATA'], 'cedula' ) !== false ) {
print_r ( $aRow ); print_r ( $aRow );
print "<hr>"; print "<hr>";
$i++; $i++;
if ( $i == 10 ) die; if ( $i == 10 ) die;
} }
*/ */
$oDataset->next(); $oDataset->next();
} }
print "--$i--"; print "--$i--";

View File

@@ -1,675 +0,0 @@
var installer=function()
{
this.make=function(options)
{
this.options={
target:inst.elements.content,
vdef:{
wf:'wf_workflow',
rb:'rb_workflow',
rp:'rp_workflow'
}
}.concat(options || {});
this.html();
this.check();
};
this.html=function()
{
this.titleBar = document.createElement("div");
this.titleBar.className="app_grid_headerBar___gray";
leimnud.dom.setStyle(this.titleBar,{
height:"auto",
textAlign:"right"
});
this.options.target.appendChild(this.titleBar);
this.options.button0 = document.createElement("input");
this.options.button0.type="button";
this.options.button0.value="Test";
this.titleBar.appendChild(this.options.button0);
this.options.button1 = document.createElement("input");
this.options.button1.type="button";
this.options.button1.value="Install";
this.titleBar.appendChild(this.options.button1);
this.options.button2 = document.createElement("input");
this.options.button2.type="button";
this.options.button2.value="Reset";
this.titleBar.appendChild(this.options.button2);
this.options.phpinfo = document.createElement("input");
this.options.phpinfo.type="button";
this.options.phpinfo.style.fontWeight="bold";
this.options.phpinfo.value="phpinfo()";
this.titleBar.appendChild(this.options.phpinfo);
this.options.phpinfo.onmouseup=this.showPhpinfo;
this.options.button1.disabled=true;
this.options.button0.onmouseup=this.check;
this.options.button1.onmouseup=function(){inst.selectTab(1);}.extend(this);
this.options.button2.onmouseup=this.reset;
this.buttonFun(this.options.button0);
this.buttonFun(this.options.button1);
this.buttonFun(this.options.button2);
this.buttonFun(this.options.phpinfo);
//this.phpVersion =
this.table = $(document.createElement("table"));
/* this.table.setStyle({
cellpadding:23
});*/
this.table.className="inst_table";
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"<b>Requirements</b>",className:"app_grid_title___gray title",colSpan:4})
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"PHP Version > 5.1.0",className:"inst_td0",colSpan:2}),
this.phpVersion = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2})
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"MySQL",className:"inst_td0",colSpan:2}),
this.mysqlVersion = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2})
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"Maximum amount of memory a script may consume (memory_limit) >= 40M",className:"inst_td0",colSpan:2}),
this.checkMemory = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2})
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"Directory "+this.options.path_trunk+"config/<br> permissions: <b>writable</b>",className:"inst_td0",colSpan:2}),
this.checkPI = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2})
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"Directory "+this.options.path_trunk+"content/languages/<br> permissions: <b>writable</b>",className:"inst_td0",colSpan:2}),
this.checkDL = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2})
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"File "+this.options.path_trunk+"js/labels/<br> permissions: <b>writable</b>",className:"inst_td0",colSpan:2}),
this.checkDLJ = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2})
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"File "+this.options.path_trunk+"plugins/<br> permissions: <b>writable</b>",className:"inst_td0",colSpan:2}),
this.checkPL = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2})
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"File "+this.options.path_trunk+"xmlform/<br> permissions: <b>writable</b>",className:"inst_td0",colSpan:2}),
this.checkXF = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2})
);
/* Database */
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"<b>Database</b>",className:"app_grid_title___gray title",colSpan:2}),
new DOM('td',{className:"app_grid_title___gray title",colSpan:2}).append(
this.select_ao_db = new select({data:[
{value:1,text:"Advanced options by default"},
{value:2,text:"Change Advanced options"}
],
style:{width:"100%",border:"1px solid #919B9C"},
properties:{onchange:function(){
if(this.select_ao_db.selected().value==1)
{
this.ed_advanced_options({
sta:"disabled",
act:'usr',
def:true
});
this.ao_db_wf.passed().value=this.options.vdef.wf;
this.ao_db_rb.passed().value=this.options.vdef.rb;
this.ao_db_rp.passed().value=this.options.vdef.rp;
this.ao_db_drop.checked=false;
}
else
{
this.ed_advanced_options({
act:'usr',
sta:"enabled"
});
this.ao_db_wf.focus();
}
}.extend(this)}
})
)
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"Database server Hostname",className:"inst_td0"},{width:"30%"}),
new DOM('td',{className:"inst_td1"},{width:"30%"}).append(
// this.databaseHostname =new DOM("input",{value:'localhost',type:"text",onkeyup:this.submit,className:"inputNormal"})
this.databaseHostname = new input({label:'localhost',properties:{onkeyup:this.submit},style:{width:"100%"}})
),
new DOM('td',{innerHTML:"Workflow Database:",className:"inst_td0"},{width:"20%"}),
new DOM('td',{className:"inst_td1"},{width:"20%"}).append(
this.ao_db_wf = new input({label:this.options.vdef.wf,properties:{onkeyup:this.submit},style:{width:"100%"},maxlength:16}).passed().disable()
)
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"Username",className:"inst_td0"},{width:"30%"}),
new DOM('td',{className:"inst_td1"},{width:"30%"}).append(
// this.databaseUsername =new DOM("input",{value:'root',type:"text",onkeyup:this.submit,className:"inputNormal"})
this.databaseUsername = new input({label:'root',properties:{onkeyup:this.submit},style:{width:"100%"}})
),
new DOM('td',{innerHTML:"Rbac Database:",className:"inst_td0"},{width:"20%"}),
new DOM('td',{className:"inst_td1"},{width:"20%"}).append(
this.ao_db_rb = new input({label:this.options.vdef.rb,properties:{onkeyup:this.submit},style:{width:"100%"},maxlength:16}).passed().disable()
)
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"Password",className:"inst_td0"},{width:"30%"}),
new DOM('td',{className:"inst_td1"},{width:"30%"}).append(
// this.databasePassword =new DOM("input",{type:"text",onkeyup:this.submit,className:"inputNormal"})
this.databasePassword = new input({properties:{type:'password',onkeyup:this.submit},style:{width:"100%"}})
),
new DOM('td',{innerHTML:"Report Database:",className:"inst_td0"},{width:"20%"}),
new DOM('td',{className:"inst_td1"},{width:"20%"}).append(
this.ao_db_rp = new input({label:this.options.vdef.rp,properties:{onkeyup:this.submit},style:{width:"100%"},maxlength:16}).passed().disable()
)
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"Database Access",className:"inst_td0"},{width:"30%"}),
this.databaseGrant = new DOM('td',{className:"inst_td1"},{width:"30%"}),
new DOM('td',{innerHTML:"DROP DATABASE IF EXISTS",className:"inst_td0"},{width:"20%"}),
new DOM('td',{className:"inst_td0"},{width:"20%",textAlign:'left'}).append(
this.ao_db_drop = new input({
properties:{type:'checkbox',disabled:true,className:''},style:{border:"1px solid #666"}
})
)
);
var tr = this.table.insertRow(-1);
$(tr).append(
this.databaseStatus = new DOM('td',{innerHTML:"<br>",className:"tdNormal",colSpan:4},{height:50})
);
/* Database End */
/* Directories Begin */
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"<b>Processmaker Configuration</b>",className:"app_grid_title___gray title",colSpan:2}),
new DOM('td',{className:"app_grid_title___gray title",colSpan:2}).append(
this.select_ao_pm = new select({data:[
{value:1,text:"Advanced options by default"},
{value:2,text:"Change Advanced options"}
],
style:{width:"100%",border:"1px solid #919B9C"},
properties:{onchange:function(){
if(this.select_ao_pm.selected().value==1)
{
this.ed_advanced_options({
act:'pm',
sta:"disabled",
def:true
});
this.ao_admin.passed().value="admin";
this.ao_admin_pass1.passed().value="admin";
this.ao_admin_pass2.passed().value="admin";
}
else
{
this.ed_advanced_options({
act:'pm',
sta:"enabled"
});
this.ao_admin.focus();
}
}.extend(this)}
})
)
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"Workflow Data Directory (permissions: <b>writable</b>): ",className:"inst_td0"},{width:"30%"}),
new DOM('td',{className:"inst_td1"},{width:"30%"}).append(
this.workflowData = new input({label:this.options.path_data,properties:{onkeyup:this.submit},style:{width:"100%"},maxlength:200})
),
new DOM('td',{innerHTML:"Username (Default: admin):",className:"inst_td0"},{width:"20%"}),
new DOM('td',{className:"inst_td1"},{width:"20%"}).append(
this.ao_admin = new input({label:'admin',properties:{onkeyup:this.submit},style:{width:"100%"}}).passed().disable()
)
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"",className:"inst_td0"},{width:"30%"}),
new DOM('td',{className:"inst_td1"},{width:"30%"}).append(
this.compiled = new input({label:this.options.path_compiled,properties:{onkeyup:this.submit},style:{width:"100%", display:'none'},maxlength:200})
),
new DOM('td',{innerHTML:"Username (Default: admin):",className:"inst_td0"},{width:"20%"}),
new DOM('td',{className:"inst_td1"},{width:"20%"}).append(
this.ao_admin_pass1 = new input({label:'admin',properties:{onkeyup:this.submit,type:'password'},style:{width:"100%"}}).passed().disable()
)
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{className:"inst_td0",colSpan:2}),
new DOM('td',{innerHTML:"Re-type Password:",className:"inst_td0"},{width:"20%"}),
new DOM('td',{className:"inst_td1"},{width:"20%"}).append(
this.ao_admin_pass2 = new input({label:'admin',properties:{onkeyup:this.submit,type:'password'},style:{width:"100%"}}).passed().disable()
)
);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"<b>HeartBeat Configuration</b><br><i>Heartbeat is an anonymous statistics collector for ProcessMaker. It runs in the background and if you have internet enabled, it will periodically send anonymous information to ProcessMaker servers.<br />No sensitive or private information is collected.<br /><br /> The information collected will allow us to keep improving our software to offer everyone a better user experience</i>",className:"app_grid_title___gray title",colSpan:4})
);
this.heartBeatTitle=tr;
var tr = this.table.insertRow(-1);
$(tr).append(
this.heartBeat =
new DOM('td',{innerHTML:"Enable HeartBeat",className:"inst_td0"},{width:"20%"}),
new DOM('td',{className:"inst_td0",colSpan:2},{textAlign:'left'}).append(
this.ao_hb_status = new input({
properties:{type:'checkbox',disabled:false,checked:true,className:''},style:{border:"1px solid #666"}
})
)
);
this.heartBeatRow=tr;
//alert(this.options.availableProcess);
//alert(this.options.availableProcess.length);
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"<b>Available Processes (auto install)</b>",className:"app_grid_title___gray title",colSpan:4})
);
this.availableProcessTitle=tr;
var tr = this.table.insertRow(-1);
$(tr).append(
this.availableProcess = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2})
);
this.availableProcessRow=tr;
var tr = this.table.insertRow(-1);
$(tr).append(
new DOM('td',{innerHTML:"<b>Available Plugins (auto install)</b>",className:"app_grid_title___gray title",colSpan:4})
);
this.availablePluginsTitle=tr;
var tr = this.table.insertRow(-1);
$(tr).append(
this.availablePlugins = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2})
);
this.availablePluginsRow=tr;
leimnud.dom.setStyle([this.workflowData,this.compiled],{
textAlign:"left"
});
this.options.target.appendChild(this.table);
};
this.formData=function()
{
//alert(this.databaseExe.value.eplace("\\","/"))
return {
mysqlH :escape(this.databaseHostname.value),
mysqlU :escape(this.databaseUsername.value),
mysqlP :escape(this.databasePassword.value),
// port :this.port.value,
path_data:this.workflowData.value,
path_compiled:this.compiled.value,
ao_admin :escape(this.ao_admin.value),
ao_admin_pass1 :escape(this.ao_admin_pass1.value),
ao_admin_pass2 :escape(this.ao_admin_pass2.value),
ao_db_wf :this.ao_db_wf.value,
ao_db_rb :this.ao_db_rb.value,
ao_db_rp :this.ao_db_rp.value,
ao_db :parseInt(this.select_ao_db.selected().value),
ao_pm :parseInt(this.select_ao_pm.selected().value),
ao_db_drop :this.ao_db_drop.checked,
heartbeatEnabled :this.ao_hb_status.checked
};
};
this.check=function()
{
inst.loader.show();
this.disabled(true);
this.ed_advanced_options({sta:'disabled',act:'all'});
var r = new leimnud.module.rpc.xmlhttp({
url :this.options.server,
method :"POST",
args :"action=check&data="+this.formData().toJSONString()
});
r.callback=function(rpc)
{
try
{
this.cstatus = rpc.xmlhttp.responseText.parseJSON();
}
catch(e)
{
this.cstatus={
ao_db_wf:false,
ao_db_rb:false,
ao_db_rp:false
};
}
this.phpVersion.className = (!this.cstatus.phpVersion)?"inst_td1 tdFailed":"inst_td1 tdOk";
this.phpVersion.innerHTML = (!this.cstatus.phpVersion)?"FAILED":"PASSED";
this.mysqlVersion.className = (!this.cstatus.mysqlVersion)?"inst_td1 tdFailed":"inst_td1 tdOk";
this.mysqlVersion.innerHTML = (!this.cstatus.mysqlVersion)?"FAILED":"PASSED";
this.checkMemory.className = (!this.cstatus.checkMemory)?"inst_td1 tdFailed":"inst_td1 tdOk";
this.checkMemory.innerHTML = (!this.cstatus.checkMemory)?"FAILED":"PASSED";
// this.checkmqgpc.className = (!this.cstatus.checkmqgpc)?"inst_td1 tdFailed":"inst_td1 tdOk";
// this.checkmqgpc.innerHTML = (!this.cstatus.checkmqgpc)?"FAILED":"PASSED";
this.checkPI.className = (!this.cstatus.checkPI)?"inst_td1 tdFailed":"inst_td1 tdOk";
this.checkPI.innerHTML = (!this.cstatus.checkPI)?"FAILED":"PASSED";
this.checkDL.className = (!this.cstatus.checkDL)?"inst_td1 tdFailed":"inst_td1 tdOk";
this.checkDL.innerHTML = (!this.cstatus.checkDL)?"FAILED":"PASSED";
this.checkDLJ.className = (!this.cstatus.checkDLJ)?"inst_td1 tdFailed":"inst_td1 tdOk";
this.checkDLJ.innerHTML = (!this.cstatus.checkDLJ)?"FAILED":"PASSED";
this.checkPL.className = (!this.cstatus.checkPL)?"inst_td1 tdFailed":"inst_td1 tdOk";
this.checkPL.innerHTML = (!this.cstatus.checkPL)?"FAILED":"PASSED";
this.checkXF.className = (!this.cstatus.checkXF)?"inst_td1 tdFailed":"inst_td1 tdOk";
this.checkXF.innerHTML = (!this.cstatus.checkXF)?"FAILED":"PASSED";
this.databaseHostname[(!this.cstatus.mysqlConnection)?"failed":"passed"]();
this.databaseUsername[(!this.cstatus.mysqlConnection)?"failed":"passed"]();
this.databasePassword[(!this.cstatus.mysqlConnection)?"failed":"passed"]();
this.databaseGrant.className = (!this.cstatus.grantPriv && this.select_ao_db.selected().value==1)?"inst_td1 tdFailed":"inst_td1 tdOk";
this.databaseGrant.innerHTML = (!this.cstatus.grantPriv)?"FAILED":((this.cstatus.grantPriv==1)?'ALL PRIVILEGES':'USAGE');
this.databaseStatus.className = (!this.cstatus.grantPriv || !this.cstatus.mysqlConnection)?"tdFailed":"tdOk";
this.databaseStatus.innerHTML = this.cstatus.databaseMessage;
this.workflowData[(!this.cstatus.path_data)?"failed":"passed"]();
this.compiled[(!this.cstatus.path_compiled)?"failed":"passed"]();
this.ao_db_wf[((!this.cstatus.ao_db_wf['status'])?"failed":"passed")]();
this.ao_db_rb[((!this.cstatus.ao_db_rb['status'])?"failed":"passed")]();
this.ao_db_rp[((!this.cstatus.ao_db_rp['status'])?"failed":"passed")]();
this.ao_admin[(!this.cstatus.ao_admin && this.select_ao_pm.selected().value==2)?"failed":"passed"]();
this.ao_admin_pass1[(!this.cstatus.ao_admin_pass && this.select_ao_pm.selected().value==2)?"failed":"passed"]();
this.ao_admin_pass2[(!this.cstatus.ao_admin_pass && this.select_ao_pm.selected().value==2)?"failed":"passed"]();
if(this.cstatus.ao_db_wf['status'] && this.cstatus.ao_db_rb['status'] && this.cstatus.ao_db_rp['status'] && this.cstatus.ao_admin && this.cstatus.ao_admin_pass && this.cstatus.checkMemory && this.cstatus.checkPI && this.cstatus.checkDL && this.cstatus.checkDLJ && this.cstatus.checkPL && this.cstatus.checkXF && this.cstatus.phpVersion && this.cstatus.mysqlVersion && this.cstatus.mysqlConnection && this.cstatus.grantPriv && this.cstatus.path_data && this.cstatus.path_compiled)
{
this.options.button0.disabled=true;
this.options.button1.disabled=false;
this.disabled(true);
}
else
{
this.options.button0.disabled=false;
this.options.button1.disabled=true;
this.disabled(false);
try {
this.compiled.focus();
} catch(err) {}
this.ed_advanced_options({sta:((this.select_ao_db.selected().value==2)?'enabled':'disabled'),act:'usr'});
this.ed_advanced_options({sta:((this.select_ao_pm.selected().value==2)?'enabled':'disabled'),act:'pm'});
}
this.buttonFun(this.options.button0);
this.buttonFun(this.options.button1);
this.ao_db_wf.title=this.cstatus.ao_db_wf.message;
this.ao_db_rb.title=this.cstatus.ao_db_rb.message;
this.ao_db_rp.title=this.cstatus.ao_db_rp.message;
this.ao_admin.title=(this.cstatus.ao_admin)?'Username invalid':'PASSED';
//*Autoinstall Process and Plugins. By JHL
// March 11th. 2009
// To enable the way of aoutoinstall process and/or plugins
// at same time of initial PM setup
if(this.cstatus.availableProcess.length>0){
this.availableProcess.className = "inst_td1 tdOk";
this.availableProcess.innerHTML="";
for(i_process=0;i_process<this.cstatus.availableProcess.length;i_process++){
this.availableProcess.innerHTML+=this.cstatus.availableProcess[i_process]+"<br />";
}
}else{
//Hide entire Group
this.availableProcessTitle.style.display="none";
this.availableProcessRow.style.display="none";
}
if(this.cstatus.availablePlugins.length>0){
this.availablePlugins.className = "inst_td1 tdOk";
this.availablePlugins.innerHTML="";
for(i_plugin=0;i_plugin<this.cstatus.availablePlugins.length;i_plugin++){
this.availablePlugins.innerHTML+=this.cstatus.availablePlugins[i_plugin]+"<br />";
}
}else{
//Hide entire Group
this.availablePluginsTitle.style.display="none";
this.availablePluginsRow.style.display="none";
}
//End Autoinstall
inst.loader.hide();
}.extend(this);
r.make();
};
this.reset=function()
{
this.options.button1.disabled=true;
this.buttonFun(this.options.button1);
this.disabled(false);
};
this.disabled=function(dis)
{
this.databaseHostname[(dis===true)?'disable':'enable']();
this.databaseUsername[(dis===true)?'disable':'enable']();
this.databasePassword[(dis===true)?'disable':'enable']();
this.workflowData[(dis===true)?'disable':'enable']();
this.compiled[(dis===true)?'disable':'enable']();
if(this.compiled.disabled===false)
{
try {
this.compiled.focus();
} catch(err) {}
}
this.options.button0.disabled=dis;
this.buttonFun(this.options.button0);
};
this.ed_advanced_options=function(options)
{
options = {
sta:"disabled",
act:"all",
def:false
}.concat(options || {});
if(options.act=='pm' || options.act=="all")
{
this.ao_admin[(options.sta=="disabled")?'disable':'enable']();
this.ao_admin_pass1[(options.sta=="disabled")?'disable':'enable']();
this.ao_admin_pass2[(options.sta=="disabled")?'disable':'enable']();
}
if(options.act=='usr' || options.act=="all")
{
this.ao_db_wf[(options.sta=="disabled")?'disable':'enable']();
this.ao_db_rb[(options.sta=="disabled")?'disable':'enable']();
this.ao_db_rp[(options.sta=="disabled")?'disable':'enable']();
this.ao_db_drop.disabled=(options.sta=="disabled")?true:false;
}
};
this.submit=function(evt)
{
var evt = (window.event)?window.event:evt;
var key = (evt.which)?evt.which:evt.keyCode;
if(key==13)
{
this.check();
}
return false;
};
this.install=function()
{
this.values = this.formData();
inst.clearContent();
inst.loader.show();
this.options.button2.disabled=true;
this.options.button1.disabled=true;
var r = new leimnud.module.rpc.xmlhttp({
url :this.options.server,
method :"POST",
args :"action=install&data="+this.values.toJSONString()
});
r.callback=this.installation;
r.make();
};
this.installation=function(rpc)
{
/* var r = new leimnud.module.rpc.xmlhttp({
url :"/sysworkflow/en/classic/tools/updateTranslation",
method :"GET"
});
r.callback=function(rpc)
{*/
inst.loader.hide();
this.table = document.createElement("table");
this.table.className="inst_table";
var success = (rpc.xmlhttp.status == 200);
var tr = this.table.insertRow(-1);
var tdtitle = tr.insertCell(0);
tdtitle.innerHTML="Status";
tdtitle.className="app_grid_title___gray title";
var tr = this.table.insertRow(-1);
var td0 = tr.insertCell(0);
td0.innerHTML=(success) ? "Success" : "Failed (Check log below)";
td0.className=(success) ? "tdOk" : "tdFailed";
this.options.target.appendChild(this.table);
if (success) {
var tr = this.table.insertRow(-1);
var tdS = tr.insertCell(0);
tdS.colSpan = 2;
tdS.innerHTML="<br><br>";
tdS.className="tdNormal";
this.options.buttong = document.createElement("input");
this.options.buttong.type="button";
this.options.buttong.value="Finish Installation";
this.options.buttong.onmouseup=function()
{
window.location = "/sysworkflow/en/classic/login/login";
}.extend(this);
tdS.appendChild(this.options.buttong);
this.buttonFun(this.options.buttong);
tdS.appendChild(document.createElement("br"));
tdS.appendChild(document.createElement("br"));
}
var tr = this.table.insertRow(-1);
var tdtitle = tr.insertCell(0);
tdtitle.innerHTML="Installation Log";
tdtitle.className="app_grid_title___gray title";
var tr = this.table.insertRow(-1);
var td0 = tr.insertCell(0);
var pre = document.createElement('pre');
pre.style.overflow='scroll';
pre.style.width=(this.options.target.clientWidth-10)+"px";
pre.style.height=((this.options.target.clientHeight-this.table.clientHeight)-15)+'px';
pre.innerHTML=rpc.xmlhttp.responseText;
td0.appendChild(pre);
// }.extend(this);
// r.make();
};
this.buttonFun=function(but)
{
if(but.disabled==true)
{
but.className="app_grid_title___gray button buttonDisabled";
but.onmouseover=function(){ this.className="app_grid_title___gray button buttonDisabled"};
but.onmouseout=function(){ this.className="app_grid_title___gray button buttonDisabled"};
but.onblur=function(){ this.className="app_grid_title___gray button buttonDisabled"};
}
else
{
but.className="app_grid_title___gray button";
but.onmouseover=function(){ this.className="app_grid_title___gray button buttonHover"};
but.onmouseout=function(){ this.className="app_grid_title___gray button"};
but.onblur=function(){ this.className="app_grid_title___gray button"};
}
};
this.showPhpinfo=function()
{
var panel = new leimnud.module.panel();
panel.options={
title:"PHP info",
position:{center:true},
size:{w:700,h:document.body.clientHeight-50},
fx:{modal:true}
};
panel.make();
var r = new leimnud.module.rpc.xmlhttp({
url :"install.php",
method :"POST",
args :"phpinfo=true"
});
r.callback=function(rpc)
{
panel.addContent(rpc.xmlhttp.responseText);
};
r.make();
};
this.expand(this);
}

View File

@@ -1,209 +0,0 @@
<?php
/**
* install.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
/**
* Default home page view
*
* @author MaBoRaK
* @version 0.1
*/
if ($_POST && isset( $_POST['phpinfo'] )) {
phpinfo();
die();
}
echo '<?xml version="1.0" encoding="UTF-8" ?>';
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Processmaker Installer</title>
<script type='text/javascript' src='/js/maborak/core/maborak.js'></script>
<link rel="stylesheet" type="text/css"
href="/js/maborak/samples/style.css" />
<script type='text/javascript' src='/sys/en/classic/install/install.js'></script>
<script type='text/javascript'>
var ifr;
var forceCssLoad = true;
var grid,winGrill, leimnud = new maborak(forceCssLoad);
var inWIN = false;
leimnud.make();
leimnud.Package.Load("dom,validator,app,rpc,fx,drag,drop,panel,grid,abbr",{Instance:leimnud,Type:"module"});
leimnud.Package.Load("json",{Type:"file"});
leimnud.exec(leimnud.fix.memoryLeak);
var inst;
leimnud.event.add(window,'load',function(){myload();});
var myload = function() {
if (typeof(DOM) === 'undefined') {
setTimeout("myload();", 1000);
return;
}
inst = new leimnud.module.panel();
inst.options={
size:{w:document.body.offsetWidth-50,h:825},
title :"",
position:{x:2,y:2,center:true},
statusBar:false,
control:{
roll :false,
close :false
},
fx:{
shadow:false,
fadeIn:false
}
};
inst.setStyle={
content:{padding:2}
};
var classInstaller = new installer();
inst.tab={
optWidth:190,
manualDisabled:true,
step :(leimnud.browser.isIE?-1:5),
options:[{
title :"Configuration",
content :function()
{
classInstaller.make({
server :"installServer.php",
path_data:"<?php echo defined('PATH_DATA')?PATH_DATA:PATH_TRUNK.'shared';?>",
path_compiled:"<?php echo defined('PATH_C')?PATH_C:PATH_TRUNK.'compiled';?>",
path_trunk:"<?php echo PATH_CORE;?>"
});
},
selected:true
},
{
title :"Installation",
noClear : true,
content :classInstaller.install
}
]
};
inst.make();
};
</script>
<style>
input {
font: normal 8pt sans-serif, Tahoma, MiscFixed;
}
body {
background-color: white;
font: normal 8pt sans-serif, Tahoma;
}
.inst_table {
width: 100%;
border-collapse: collapse;
font: normal 8pt Tahoma, sans-serif;
}
.inst_td0 {
width: 60%;
text-align: right;
border: 1px solid #CCC;
padding: 5px;
}
.inst_td1 {
font-weight: bold;
width: 40%;
padding: 5px;
border: 1px solid #CCC;
text-align: center;
}
.tdNormal,.tdOk,.tdFailed {
font-weight: bold;
border: 1px solid #CCC;
text-align: center;
}
.tdOk {
font-weight: bold;
color: green;
padding: 6px;
}
.tdFailed {
font-weight: bold;
color: red;
}
.title {
text-align: left;
padding-left: 10px;
}
.inputNormal,.inputOk,.inputFailed {
width: 100%;
border: 1px solid #666;
border-left: 3px solid #666;
font: normal 8pt Tahoma, sans-serif;
text-align: center;
}
.inputOk {
border: 1px solid green;
border-left: 3px solid green;
}
.inputFailed {
border: 1px solid red;
border-left: 3px solid red;
}
.button {
font: normal 8pt Tahoma, MiscFixed, sans-serif;
border: 1px solid #afafaf;
margin-left: 2px;
color: black;
cursor: pointer;
}
.buttonHover {
border: 1px solid #666;
background-position: 0 -8;
}
.buttonDisabled {
border: 1px solid #9f9f9f;
background-position: 0 -10;
color: #9f9f9f;
cursor: default;
}
</style>
</head>
<body>
<?php
//exec("mkdir /var/www/html/asas",$console);
?>
</body>
</html>

View File

@@ -1,380 +0,0 @@
<?php
/**
* installServer.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
$isWindows = PHP_OS == 'WINNT' ? true : false;
$oJSON = new Services_JSON();
$action = $_POST['action'];
$dataClient = $oJSON->decode( stripslashes( $_POST['data'] ) );
function find_SQL_Version ($my = 'mysql', $infExe = null)
{
if (PHP_OS == "WINNT" && ! $infExe) {
return false;
}
$output = shell_exec( $my . ' -V' );
preg_match( '@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version );
return $version[0];
}
if ($action === "check") {
/* TODO: Check if this space is required */
print " ";
G::LoadClass( 'Installer' );
$inst = new Installer();
$siteName = "workflow";
$p1 = (isset( $dataClient->ao_admin_pass1 )) ? $dataClient->ao_admin_pass1 : 'admin';
$p2 = (isset( $dataClient->ao_admin_pass2 )) ? $dataClient->ao_admin_pass2 : 'admin';
$s = $inst->create_site( Array ('name' => 'workflow','path_data' => $dataClient->path_data,'path_compiled' => $dataClient->path_compiled,'admin' => Array ('username' => (isset( $dataClient->ao_admin )) ? $dataClient->ao_admin : 'admin','password' => $p1
),'advanced' => Array ('ao_db' => (isset( $dataClient->ao_db ) && $dataClient->ao_db === 2) ? false : true,'ao_db_drop' => (isset( $dataClient->ao_db_drop ) && $dataClient->ao_db_drop === true) ? true : false,'ao_db_wf' => (isset( $dataClient->ao_db_wf )) ? $dataClient->ao_db_wf : 'wf_' . $siteName,'ao_db_rb' => (isset( $dataClient->ao_db_rb )) ? $dataClient->ao_db_rb : 'rb_' . $siteName,'ao_db_rp' => (isset( $dataClient->ao_db_rp )) ? $dataClient->ao_db_rp : 'rp_' . $siteName
),'database' => Array ('hostname' => $dataClient->mysqlH,'username' => $dataClient->mysqlU,'password' => $dataClient->mysqlP
)
) );
$data = null;
$data->phpVersion = (version_compare( PHP_VERSION, "5.1.0", ">" )) ? true : false;
if (trim( $dataClient->mysqlH ) == '' || trim( $dataClient->mysqlU ) == '') {
$con = array ('connection' => false,'grant' => false,'message' => 'Please complete the input fields (Hostname/Username)'
);
}
$data->mysqlConnection = $s['result']['database']['connection'];
$data->grantPriv = $s['result']['database']['grant'];
$data->databaseMessage = $s['result']['database']['message'];
$data->mysqlVersion = $s['result']['database']['version'];
$data->path_data = $s['result']['path_data'];
$data->path_compiled = true;
$data->checkMemory = (((int) ini_get( "memory_limit" )) >= 40) ? true : false;
#$data->checkmqgpc =(get_magic_quotes_gpc())?false:true;
$data->checkPI = $inst->is_dir_writable( PATH_CORE . "config/" );
$data->checkDL = $inst->is_dir_writable( PATH_CORE . "content/languages/" );
$data->checkDLJ = $inst->is_dir_writable( PATH_CORE . "js/labels/" );
$data->checkPL = $inst->is_dir_writable( PATH_CORE . "plugins/" );
$data->checkXF = $inst->is_dir_writable( PATH_CORE . "xmlform/" );
$data->ao_db_wf = $s['result']['database']['ao']['ao_db_wf'];
$data->ao_db_rb = $s['result']['database']['ao']['ao_db_rb'];
$data->ao_db_rp = $s['result']['database']['ao']['ao_db_rp'];
$data->ao_admin = $s['result']['admin']['username'];
$data->ao_admin_pass = ($p1 !== $p2) ? false : true;
//*Autoinstall Process and Plugins. By JHL
// March 11th. 2009
// To enable the way of aoutoinstall process and/or plugins
// at same time of initial PM setup
//Get Available autoinstall process
$data->availableProcess = $inst->getDirectoryFiles( PATH_OUTTRUNK . "autoinstall", "pm" );
//Get Available autoinstall plugins
$data->availablePlugins = $inst->getDirectoryFiles( PATH_OUTTRUNK . "autoinstall", "tar" );
//End autoinstall
$data->microtime = microtime( true );
echo $oJSON->encode( $data );
} elseif ($action === "install") {
/*
* Installation with SIMPLE POST
*
* Data necessary for the POST:
*
*
* action=install
* data= {"mysqlE":"Path/to/mysql.exe",
* "mysqlH":"Mysqlhostname",
* "mysqlU":"mysqlUsername",
* "mysqlP":"mysqlPassword",
* "path_data":"/path/to/workflow_data/",
* "path_compiled":"/path/to/compiled/",
* "heartbeatEnabled":"1"}
*
*--------------------------------------------------------------------------------------------------------------
*
* Steps to install.
* 1) This data is required:
* $HOSTNAME
* $USERNAME
* $PASSWORD
* $PATH_TO_WORKFLOW_DATA
* $PATH_TO_COMPILED DATA
* 2) create $PATH_TO_WORKFLOW_DATA
* 3) create $PATH_TO_COMPILED_DATA
* 4) Create the site workflow
*
* 4.1 Create user (mysql) wf_workflow , password: sample
* 4.1.1 Create database wf_workflow with user wf_workflow
* 4.1.2 Give all priviledges to database wf_workflow for user wf_workflow
* 4.1.3 Dump file processmaker/workflow/engine/data/mysql/schema.sql
* 4.1.4 Dump file processmaker/workflow/engine/data/mysql/insert.sql
*
* 4.2 Create user (mysql) wf_rbac, password: sample
* 4.2.1 Create database wf_rbac with user wf_rbac
* 4.2.2 Give all priviledges to databse wf_rbac for user wf_rbac
* 4.2.3 Dump file processmaker/rbac/engine/data/mysql/schema.sql
* 4.2.4 Dump file processmaker/rbac/engine/data/mysql/insert.sql
*
* 4.3 Create configuratoin file and directories to site workflow
*
* 4.3.1 Create directories:
*
* $PATH_TO_WORKFLOW_DATA./sites/workflow/
* $PATH_TO_WORKFLOW_DATA./sites/workflow/cutomFunctions/
* $PATH_TO_WORKFLOW_DATA./sites/workflow/rtfs/
* $PATH_TO_WORKFLOW_DATA./sites/workflow/xmlforms/
* $PATH_TO_WORKFLOW_DATA./sites/workflow/processesImages/
* $PATH_TO_WORKFLOW_DATA./sites/workflow/files/
* 4.3.2 Create file.
*
* $PATH_TO_WORKFLOW_DATA./sites/workflow/db.php
*
* with these contents replacing $HOSTNAME.
*
<?php
// Processmaker configuration
define ('DB_ADAPTER', 'mysql' );
define ('DB_HOST', $HOSTNAME );
define ('DB_NAME', 'wf_workflow' );
define ('DB_USER', 'wf_workflow' );
define ('DB_PASS', 'sample' );
define ('DB_RBAC_HOST', $HOSTNAME );
define ('DB_RBAC_NAME', 'rbac_workflow' );
define ('DB_RBAC_USER', 'rbac_workflow' );
define ('DB_RBAC_PASS', 'sample' );
?>
* 4.4 Create file workflow/engine/config/paths_installed.php with these contents.
*
* <?php
define( 'PATH_DATA', '$PATH_TO_WORKFLOW_DATA' );
define( 'PATH_C', '$PATH_TO_COMPILED_DATA' );
?>
* Restarting:
* $PATH_TO_WORKFLOW_DATA
* $PATH_TO_COMPILED DATA
*
* 4.2 Update translation from this url (background)
*
* http://ProcessmakerHostname/sysworkflow/en/classic/tools/updateTranslation
*
*
*
*
*5) Auto install processes and plugins
*5.1 Install processes
*5.2 Install plugins
* */
$report = null;
try {
require_once 'Log.php';
$sp = "/";
$dir_data = $dataClient->path_data;
$dir_data = (substr( $dir_data, - 1 ) == $sp) ? $dir_data : $dir_data . "/";
$dir_compiled = $dir_data . "compiled/";
$dir_log = "{$dir_data}log/";
global $isWindows;
@mkdir( $dir_data . "sites", 0777, true );
@mkdir( $dir_compiled, 0777, true );
@mkdir( $dir_log, 0777, true );
$logFilename = "{$dir_log}install.log";
$displayLog = Log::singleton( 'display', '', 'INSTALLER', array ('lineFormat' => "%{message}"
) );
$fileLog = Log::singleton( 'file', $logFilename, 'INSTALLER' );
global $logger;
$logger = Log::singleton( 'composite' );
$logger->addChild( $displayLog );
$create_db = "create-db.sql";
$schema = "schema.sql";
G::LoadClass( 'Installer' );
/* Create default workspace called workflow */
$inst = new Installer();
$siteName = "workflow";
$p1 = (isset( $dataClient->ao_admin_pass1 )) ? $dataClient->ao_admin_pass1 : 'admin';
$p2 = (isset( $dataClient->ao_admin_pass2 )) ? $dataClient->ao_admin_pass2 : 'admin';
$s = $inst->create_site( Array ('name' => 'workflow','path_data' => $dataClient->path_data,'path_compiled' => $dataClient->path_compiled,'admin' => Array ('username' => (isset( $dataClient->ao_admin )) ? $dataClient->ao_admin : 'admin','password' => $p1
),'advanced' => Array ('ao_db' => (isset( $dataClient->ao_db ) && $dataClient->ao_db === 2) ? false : true,'ao_db_drop' => (isset( $dataClient->ao_db_drop ) && $dataClient->ao_db_drop === true) ? true : false,'ao_db_wf' => (isset( $dataClient->ao_db_wf )) ? $dataClient->ao_db_wf : 'wf_' . $siteName,'ao_db_rb' => (isset( $dataClient->ao_db_rb )) ? $dataClient->ao_db_rb : 'rb_' . $siteName,'ao_db_rp' => (isset( $dataClient->ao_db_rp )) ? $dataClient->ao_db_rp : 'rp_' . $siteName
),'database' => Array ('hostname' => $dataClient->mysqlH,'username' => $dataClient->mysqlU,'password' => $dataClient->mysqlP
)
), true );
if ($s['created']) {
$report = $inst->report;
} else {
/* On a failed install, $inst->report is blank because the
* installation didnt occured at all. So we use the test report
* instead.
*/
$report = $s['result'];
}
$installError = (! $s['created']);
} catch (Exception $e) {
$installError = ($e->getMessage() ? $e->getMessage() : true);
}
if ($installError) {
header( 'HTTP', true, 500 );
}
/* Status is used in the Windows installer, do not change this */
print_r( "Status: " . (($installError) ? 'FAILED' : 'SUCCESS') . "\n\n" );
/* Try to open the file log, if it fails, set it to NULL, so we don't try to
* write to it again afterwards. If it succeeds, add to the logger.
* Only open the log after writing status, otherwise a warning can be issued
* which will affect the Windows installer.
*/
if (! $fileLog->open()) {
$fileLog = null;
$displayLog->log( "Failed to create file log in $logFilename" );
} else {
$logger->addChild( $fileLog );
$fileLog->log( " ** Starting installation ** " );
$fileLog->log( "Status: " . (($installError) ? 'FAILED' : 'SUCCESS') );
$displayLog->log( "This log is also available in $logFilename" );
}
$installArgs = (array) $dataClient;
$hiddenFields = array ('mysqlP','ao_admin_pass1','ao_admin_pass2');
foreach ($installArgs as $arg => $param) {
if (in_array( $arg, $hiddenFields )) {
$installArgs[$arg] = "********";
}
}
$logger->log( "Installation arguments\n" . neat_r( array ($installArgs) ) );
if (isset( $report )) {
$logger->log( "Installation report\n" . neat_r( array ($report ) ) );
} else {
$logger->log( "** Installation crashed **" );
}
if (is_string( $installError )) {
$logger->log( "Error message: $installError" );
}
if ($installError) {
$logger->log( "Installation ending with errors" );
die();
}
$sh = md5( filemtime( PATH_GULLIVER . "/class.g.php" ) );
$h = G::encrypt( $dataClient->mysqlH . $sh . $dataClient->mysqlU . $sh . $dataClient->mysqlP . $sh . $inst->cc_status, $sh );
$db_text = "<?php\n" . "define( 'PATH_DATA', '" . $dir_data . "' );\n" . "define( 'PATH_C', '" . $dir_compiled . "' );\n" . "define( 'HASH_INSTALLATION','" . $h . "' );\n" . "define( 'SYSTEM_HASH','" . $sh . "' );\n" . "?>";
$fp = fopen( FILE_PATHS_INSTALLED, "w" );
fputs( $fp, $db_text, strlen( $db_text ) );
fclose( $fp );
/* Update languages */
$update = file_get_contents( "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "/sysworkflow/en/classic/tools/updateTranslation" );
$logger->log( "Update language => " . ((! $update) ? $update : "OK") );
/* Heartbeat Enable/Disable */
if (! isset( $dataClient->heartbeatEnabled )) {
$dataClient->heartbeatEnabled = true;
}
$update = file_get_contents( "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "/sysworkflow/en/classic/install/heartbeatStatus?status=" . $dataClient->heartbeatEnabled );
$logger->log( "Heartbeat Status => " . str_replace( "<br>", "\n", $update ) );
/* Autoinstall Process */
$update = file_get_contents( "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "/sysworkflow/en/classic/install/autoinstallProcesses" );
if (trim( str_replace( "<br>", "", $update ) ) == "") {
$update = "Nothing to do.";
}
$logger->log( "Process AutoInstall => " . str_replace( "<br>", "\n", $update ) );
/* Autoinstall Plugins */
$update = file_get_contents( "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "/sysworkflow/en/classic/install/autoinstallPlugins" );
if (trim( str_replace( "<br>", "", $update ) ) == "") {
$update = "Nothing to do.";
}
$logger->log( "Plugin AutoInstall => " . str_replace( "<br>", "\n", $update ) );
$logger->log( "Installation finished successfuly" );
}
/*
neat_r works like print_r but with much less visual clutter.
By Jake Lodwick. Copy freely.
*/
function neat_r ($arr, $return = false)
{
$out = array ();
$oldtab = " ";
$newtab = " ";
$lines = explode( "\n", print_r( $arr, true ) );
foreach ($lines as $line) {
//remove numeric indexes like "[0] =>" unless the value is an array
//if (substr($line, -5) != "Array") {
$line = preg_replace( "/^(\s*)\[[0-9]+\] => /", "$1", $line, 1 );
//}
//garbage symbols
foreach (array ("Array" => "","[" => "","]" => ""
) as
//" =>" => ":",
$old => $new) {
$out = str_replace( $old, $new, $out );
}
//garbage lines
if (in_array( trim( $line ), array ("Array","(",")",""
) )) {
continue;
}
//indents
$indent = "";
$indents = floor( (substr_count( $line, $oldtab ) - 1) / 2 );
if ($indents > 0) {
for ($i = 0; $i < $indents; $i ++) {
$indent .= $newtab;
}
}
$out[] = $indent . trim( $line );
}
$out = implode( "\n", $out );
if ($return == true) {
return $out;
}
return $out;
}