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
/**
* CalendarDefinition.php
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseCalendarDefinition.php';
require_once 'classes/model/CalendarBusinessHours.php';
require_once 'classes/model/CalendarHolidays.php';
require_once 'classes/model/CalendarAssignments.php';
/**
* 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
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
*/
class CalendarDefinition extends BaseCalendarDefinition {
public $calendarLog = '';
function getCalendarList($onlyActive = false, $arrayMode = false) {
$Criteria = new Criteria ( 'workflow' );
$Criteria->clearSelectColumns ();
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UID );
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_NAME );
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_CREATE_DATE );
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE );
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_DESCRIPTION );
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_STATUS );
// $Criteria->addAsColumn('DELETABLE', "IF (CALENDAR_UID <> '00000000000000000000000000000001', '".G::LoadTranslation('ID_DELETE')."','') ");
$Criteria->addAsColumn('DELETABLE', "CASE WHEN CALENDAR_UID <> '00000000000000000000000000000001' THEN '".G::LoadTranslation('ID_DELETE')."' ELSE '' END ");
// Note: This list doesn't show deleted items (STATUS = DELETED)
if ($onlyActive) { // Show only active. Used on assignment lists
$Criteria->add ( calendarDefinitionPeer::CALENDAR_STATUS, "ACTIVE", CRITERIA::EQUAL );
} else { // Show Active and Inactive calendars. USed in main list
$Criteria->add ( calendarDefinitionPeer::CALENDAR_STATUS, array ("ACTIVE", "INACTIVE" ), CRITERIA::IN );
}
$Criteria->add ( calendarDefinitionPeer::CALENDAR_UID, "xx", CRITERIA::NOT_EQUAL );
if (! $arrayMode) {
return $Criteria;
} else {
$oDataset = calendarDefinitionPeer::doSelectRS ( $Criteria );
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
$oDataset->next ();
$calendarA = array (0 => 'dummy' );
$calendarCount = 0;
while ( is_array ( $aRow = $oDataset->getRow () ) ) {
$calendarCount ++;
$calendarA [$calendarCount] = $aRow;
$oDataset->next ();
}
$return ['criteria'] = $Criteria;
$return ['array'] = $calendarA;
return $return;
}
}
//Added by qennix
//Gets criteria for listing
function getCalendarCriterias($filter, $start, $limit){
$Criteria = new Criteria ( 'workflow' );
$Criteria->clearSelectColumns ();
$Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UID );
if ($filter !=''){
$Criteria->add(
$Criteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_NAME,'%'.$filter.'%',Criteria::LIKE)->addOr(
$Criteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_DESCRIPTION,'%'.$filter.'%',Criteria::LIKE)));
}
$Criteria->add(CalendarDefinitionPeer::CALENDAR_STATUS,'DELETED',Criteria::NOT_EQUAL);
$oCriteria = new Criteria ( 'workflow' );
$oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UID );
$oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_NAME );
$oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_CREATE_DATE );
$oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE );
$oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_DESCRIPTION );
$oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_STATUS );
if ($filter !=''){
$oCriteria->add(
$oCriteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_NAME,'%'.$filter.'%',Criteria::LIKE)->addOr(
$oCriteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_DESCRIPTION,'%'.$filter.'%',Criteria::LIKE)));
}
$oCriteria->add(CalendarDefinitionPeer::CALENDAR_STATUS,'DELETED',Criteria::NOT_EQUAL);
$oCriteria->setLimit($limit);
$oCriteria->setOffset($start);
$criterias = array();
$criterias['COUNTER'] = $Criteria;
$criterias['LIST'] = $oCriteria;
return $criterias;
}
function getCalendarInfo($CalendarUid) {
//if exists the row in the database propel will update it, otherwise will insert.
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid );
$defaultCalendar ['CALENDAR_UID'] = "00000000000000000000000000000001";
$defaultCalendar ['CALENDAR_NAME'] = "Default";
$defaultCalendar ['CALENDAR_CREATE_DATE'] = date ( "Y-m-d" );
$defaultCalendar ['CALENDAR_UPDATE_DATE'] = date ( "Y-m-d" );
$defaultCalendar ['CALENDAR_DESCRIPTION'] = "Default";
$defaultCalendar ['CALENDAR_STATUS'] = "ACTIVE";
$defaultCalendar ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$defaultCalendar ['CALENDAR_WORK_DAYS'] = explode ( "|", "1|2|3|4|5" );
$defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_DAY'] = 7;
$defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_START'] = "09:00";
$defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_END'] = "17:00";
$defaultCalendar ['HOLIDAY'] = array ();
if ((is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) {
$fields ['CALENDAR_UID'] = $tr->getCalendarUid ();
$fields ['CALENDAR_NAME'] = $tr->getCalendarName ();
$fields ['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate ();
$fields ['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate ();
$fields ['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription ();
$fields ['CALENDAR_STATUS'] = $tr->getCalendarStatus ();
$fields ['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays ();
$fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", $tr->getCalendarWorkDays () );
} else {
$fields=$defaultCalendar;
$this->saveCalendarInfo ( $fields );
$fields ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", "1|2|3|4|5" );
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid );
}
$CalendarBusinessHoursObj = new CalendarBusinessHours ( );
$CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours ( $CalendarUid );
$fields ['BUSINESS_DAY'] = $CalendarBusinessHours;
$CalendarHolidaysObj = new CalendarHolidays ( );
$CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays ( $CalendarUid );
$fields ['HOLIDAY'] = $CalendarHolidays;
$fields=$this->validateCalendarInfo($fields, $defaultCalendar); //********************
return $fields;
}
//for edit
function getCalendarInfoE($CalendarUid) {
//if exists the row in the database propel will update it, otherwise will insert.
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid );
$defaultCalendar ['CALENDAR_UID'] = "00000000000000000000000000000001";
$defaultCalendar ['CALENDAR_NAME'] = "Default";
$defaultCalendar ['CALENDAR_CREATE_DATE'] = date ( "Y-m-d" );
$defaultCalendar ['CALENDAR_UPDATE_DATE'] = date ( "Y-m-d" );
$defaultCalendar ['CALENDAR_DESCRIPTION'] = "Default";
$defaultCalendar ['CALENDAR_STATUS'] = "ACTIVE";
$defaultCalendar ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$defaultCalendar ['CALENDAR_WORK_DAYS'] = explode ( "|", "1|2|3|4|5" );
$defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_DAY'] = 7;
$defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_START'] = "09:00";
$defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_END'] = "17:00";
$defaultCalendar ['HOLIDAY'] = array ();
if ((is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) {
$fields ['CALENDAR_UID'] = $tr->getCalendarUid ();
$fields ['CALENDAR_NAME'] = $tr->getCalendarName ();
$fields ['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate ();
$fields ['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate ();
$fields ['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription ();
$fields ['CALENDAR_STATUS'] = $tr->getCalendarStatus ();
$fields ['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays ();
$fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", $tr->getCalendarWorkDays () );
} else {
$fields=$defaultCalendar;
$this->saveCalendarInfo ( $fields );
$fields ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", "1|2|3|4|5" );
$tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid );
}
$CalendarBusinessHoursObj = new CalendarBusinessHours ( );
$CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours ( $CalendarUid );
$fields ['BUSINESS_DAY'] = $CalendarBusinessHours;
$CalendarHolidaysObj = new CalendarHolidays ( );
$CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays ( $CalendarUid );
$fields ['HOLIDAY'] = $CalendarHolidays;
// $fields=$this->validateCalendarInfo($fields, $defaultCalendar); //********************
return $fields;
}
//end for edit
function validateCalendarInfo($fields,$defaultCalendar){
try {
//Validate if Working days are Correct
//Minimun 3 ?
$workingDays=explode ( "|", $fields['CALENDAR_WORK_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){
throw (new Exception ( "You must define at least one Business Day for all days" ));
}
$workingDaysOK=array();
foreach($workingDays as $key => $day){
$workingDaysOK[$day]=false;
}
$sw_all=false;
foreach($fields ['BUSINESS_DAY'] as $keyB => $businessHours){
if(($businessHours['CALENDAR_BUSINESS_DAY']==7)){
$sw_all=true;
}elseif((in_array($businessHours['CALENDAR_BUSINESS_DAY'],$workingDays))){
$workingDaysOK[$businessHours['CALENDAR_BUSINESS_DAY']]=true;
}
}
$sw_days=true;
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" ));
}
//Validate Holidays
return $fields;
} catch (Exception $e) {
//print $e->getMessage();
$this->addCalendarLog("!!!!!!! BAD CALENDAR DEFINITION. ".$e->getMessage());
$defaultCalendar ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$defaultCalendar ['CALENDAR_WORK_DAYS_A'] = explode ( "|", "1|2|3|4|5" );
return $defaultCalendar;
}
}
function saveCalendarInfo($aData) {
$CalendarUid = $aData ['CALENDAR_UID'];
$CalendarName = $aData ['CALENDAR_NAME'];
$CalendarDescription = $aData ['CALENDAR_DESCRIPTION'];
$CalendarStatus = isset ( $aData ['CALENDAR_STATUS'] ) ? $aData ['CALENDAR_STATUS'] : "INACTIVE";
$defaultCalendars [] = '00000000000000000000000000000001';
if (in_array ( $aData ['CALENDAR_UID'], $defaultCalendars )) {
$CalendarStatus = 'ACTIVE';
$CalendarName = 'Default';
}
$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 (! (is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) {
$tr = new CalendarDefinition ( );
$tr->setCalendarCreateDate ( 'now' );
}
$tr->setCalendarUid ( $CalendarUid );
$tr->setCalendarName ( $CalendarName );
$tr->setCalendarUpdateDate ( 'now' );
$tr->setCalendarDescription ( $CalendarDescription );
$tr->setCalendarStatus ( $CalendarStatus );
$tr->setCalendarWorkDays ( $CalendarWorkDays );
if ($tr->validate ()) {
// we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save ();
//Calendar Business Hours Save code.
//First Delete all current records
$CalendarBusinessHoursObj = new CalendarBusinessHours ( );
$CalendarBusinessHoursObj->deleteAllCalendarBusinessHours ( $CalendarUid );
//Save all the sent records
foreach ( $aData ['BUSINESS_DAY'] as $key => $objData ) {
$objData ['CALENDAR_UID'] = $CalendarUid;
$CalendarBusinessHoursObj->saveCalendarBusinessHours ( $objData );
}
//Holiday Save code.
//First Delete all current records
$CalendarHolidayObj = new CalendarHolidays ( );
$CalendarHolidayObj->deleteAllCalendarHolidays ( $CalendarUid );
//Save all the sent records
foreach ( $aData ['HOLIDAY'] as $key => $objData ) {
if (($objData ['CALENDAR_HOLIDAY_NAME'] != "") && ($objData ['CALENDAR_HOLIDAY_START'] != "") && ($objData ['CALENDAR_HOLIDAY_END'] != "")) {
$objData ['CALENDAR_UID'] = $CalendarUid;
$CalendarHolidayObj->saveCalendarHolidays ( $objData );
}
}
} else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $tr->getValidationFailures ();
foreach ( $validationFailuresArray as $objValidationFailure ) {
$msg .= $objValidationFailure->getMessage () . "<br/>";
}
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
}
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
//to do: uniform coderror structures for all classes
//if ( $res['codError'] < 0 ) {
// G::SendMessageText ( $res['message'] , 'error' );
//}
}
function deleteCalendar($CalendarUid) {
//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')) {
//
return false;
}
$defaultCalendars [] = '00000000000000000000000000000001';
if (in_array ( $tr->getCalendarUid(), $defaultCalendars )) {
return false;
}
$tr->setCalendarStatus ( 'DELETED' );
$tr->setCalendarUpdateDate ( 'now' );
if ($tr->validate ()) {
// we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save ();
} else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $tr->getValidationFailures ();
foreach ( $validationFailuresArray as $objValidationFailure ) {
$msg .= $objValidationFailure->getMessage () . "<br/>";
}
G::SendMessage ( "ERROR", $msg );
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
}
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
//to do: uniform coderror structures for all classes
//if ( $res['codError'] < 0 ) {
// G::SendMessageText ( $res['message'] , 'error' );
//}
}
function getCalendarFor($userUid, $proUid, $tasUid, $sw_validate=true) {
$Criteria = new Criteria ( 'workflow' );
//Default Calendar
$calendarUid = "00000000000000000000000000000001";
$calendarOwner = "DEFAULT";
//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 );
$oDataset = CalendarAssignmentsPeer::doSelectRS ( $Criteria );
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
$oDataset->next ();
$calendarArray=array();
while(is_array($aRow = $oDataset->getRow ())){
if($aRow['OBJECT_UID']==$userUid){
$calendarArray['USER']=$aRow ['CALENDAR_UID'];
}
if($aRow['OBJECT_UID']==$proUid){
$calendarArray['PROCESS']=$aRow ['CALENDAR_UID'];
}
if($aRow['OBJECT_UID']==$tasUid){
$calendarArray['TASK']=$aRow ['CALENDAR_UID'];
}
$oDataset->next ();
}
if(isset($calendarArray['USER'])){
$calendarUid = $calendarArray['USER'];
$calendarOwner = "USER";
}elseif (isset($calendarArray['PROCESS'])){
$calendarUid = $calendarArray['PROCESS'];
$calendarOwner = "PROCESS";
}elseif (isset($calendarArray['TASK'])){
$calendarUid = $calendarArray['TASK'];
$calendarOwner = "TASK";
}
//print "<h1>$calendarUid</h1>";
if($sw_validate){
$calendarDefinition = $this->getCalendarInfo ( $calendarUid );
}else{
$calendarDefinition = $this->getCalendarInfoE ( $calendarUid );
}
$calendarDefinition ['CALENDAR_APPLIED'] = $calendarOwner;
$this->addCalendarLog ( "--=== Calendar Applied: " . $calendarDefinition ['CALENDAR_NAME'] . " -> $calendarOwner" );
return $calendarDefinition;
}
function assignCalendarTo($objectUid, $calendarUid, $objectType) {
//if exists the row in the database propel will update it, otherwise will insert.
$tr = CalendarAssignmentsPeer::retrieveByPK ( $objectUid );
if ($calendarUid != "") {
if (! (is_object ( $tr ) && get_class ( $tr ) == 'CalendarAssignments')) {
$tr = new CalendarAssignments ( );
}
$tr->setObjectUid ( $objectUid );
$tr->setCalendarUid ( $calendarUid );
$tr->setObjectType ( $objectType );
if ($tr->validate ()) {
// we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save ();
} else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $tr->getValidationFailures ();
foreach ( $validationFailuresArray as $objValidationFailure ) {
$msg .= $objValidationFailure->getMessage () . "<br/>";
}
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
}
} else { //Delete record
if ((is_object ( $tr ) && get_class ( $tr ) == 'CalendarAssignments')) {
$tr->delete ();
}
}
}
//Added by Qennix
//Counts all users,task,process by calendar
function getAllCounterByCalendar($type){
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(CalendarAssignmentsPeer::CALENDAR_UID);
$oCriteria->addSelectColumn('COUNT(*) AS CNT');
$oCriteria->addGroupByColumn(CalendarAssignmentsPeer::CALENDAR_UID);
$oCriteria->add(CalendarAssignmentsPeer::OBJECT_TYPE,$type);
$oDataset = CalendarAssignmentsPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$aCounter = Array();
while($oDataset->next()){
$row = $oDataset->getRow();
$aCounter[$row['CALENDAR_UID']] = $row['CNT'];
}
return $aCounter;
}
function loadByCalendarName($calendarName)
{
$Criteria = new Criteria('workflow');
$Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_UID);
$Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_NAME);
$Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_CREATE_DATE);
$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
<?php
/**
* CalendarDefinition.php
*
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseCalendarDefinition.php';
require_once 'classes/model/CalendarBusinessHours.php';
require_once 'classes/model/CalendarHolidays.php';
require_once 'classes/model/CalendarAssignments.php';
/**
* 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
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
*/
class CalendarDefinition extends BaseCalendarDefinition
{
public $calendarLog = '';
public function getCalendarList ($onlyActive = false, $arrayMode = false)
{
$Criteria = new Criteria( 'workflow' );
$Criteria->clearSelectColumns();
$Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID );
$Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME );
$Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE );
$Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE );
$Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION );
$Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS );
// $Criteria->addAsColumn('DELETABLE', "IF (CALENDAR_UID <> '00000000000000000000000000000001', '".G::LoadTranslation('ID_DELETE')."','') ");
$Criteria->addAsColumn( 'DELETABLE', "CASE WHEN CALENDAR_UID <> '00000000000000000000000000000001' THEN '" . G::LoadTranslation( 'ID_DELETE' ) . "' ELSE '' END " );
// Note: This list doesn't show deleted items (STATUS = DELETED)
if ($onlyActive) {
// Show only active. Used on assignment lists
$Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, "ACTIVE", CRITERIA::EQUAL );
} else {
// Show Active and Inactive calendars. USed in main list
$Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, array ("ACTIVE","INACTIVE"), CRITERIA::IN );
}
$Criteria->add( calendarDefinitionPeer::CALENDAR_UID, "xx", CRITERIA::NOT_EQUAL );
if (! $arrayMode) {
return $Criteria;
} else {
$oDataset = calendarDefinitionPeer::doSelectRS( $Criteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
$calendarA = array (0 => 'dummy');
$calendarCount = 0;
while (is_array( $aRow = $oDataset->getRow() )) {
$calendarCount ++;
$calendarA[$calendarCount] = $aRow;
$oDataset->next();
}
$return['criteria'] = $Criteria;
$return['array'] = $calendarA;
return $return;
}
}
//Added by qennix
//Gets criteria for listing
public function getCalendarCriterias ($filter, $start, $limit)
{
$Criteria = new Criteria( 'workflow' );
$Criteria->clearSelectColumns();
$Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID );
if ($filter != '') {
$Criteria->add( $Criteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE ) ) );
}
$Criteria->add( CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL );
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID );
$oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME );
$oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE );
$oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE );
$oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION );
$oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS );
if ($filter != '') {
$oCriteria->add( $oCriteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE ) ) );
}
$oCriteria->add( CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL );
$oCriteria->setLimit( $limit );
$oCriteria->setOffset( $start );
$criterias = array ();
$criterias['COUNTER'] = $Criteria;
$criterias['LIST'] = $oCriteria;
return $criterias;
}
public function getCalendarInfo ($CalendarUid)
{
//if exists the row in the database propel will update it, otherwise will insert.
$tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid );
$defaultCalendar['CALENDAR_UID'] = "00000000000000000000000000000001";
$defaultCalendar['CALENDAR_NAME'] = "Default";
$defaultCalendar['CALENDAR_CREATE_DATE'] = date( "Y-m-d" );
$defaultCalendar['CALENDAR_UPDATE_DATE'] = date( "Y-m-d" );
$defaultCalendar['CALENDAR_DESCRIPTION'] = "Default";
$defaultCalendar['CALENDAR_STATUS'] = "ACTIVE";
$defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$defaultCalendar['CALENDAR_WORK_DAYS'] = explode( "|", "1|2|3|4|5" );
$defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_DAY'] = 7;
$defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_START'] = "09:00";
$defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_END'] = "17:00";
$defaultCalendar['HOLIDAY'] = array ();
if ((is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) {
$fields['CALENDAR_UID'] = $tr->getCalendarUid();
$fields['CALENDAR_NAME'] = $tr->getCalendarName();
$fields['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate();
$fields['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate();
$fields['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription();
$fields['CALENDAR_STATUS'] = $tr->getCalendarStatus();
$fields['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays();
$fields['CALENDAR_WORK_DAYS_A'] = explode( "|", $tr->getCalendarWorkDays() );
} else {
$fields = $defaultCalendar;
$this->saveCalendarInfo( $fields );
$fields['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$fields['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" );
$tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid );
}
$CalendarBusinessHoursObj = new CalendarBusinessHours();
$CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours( $CalendarUid );
$fields['BUSINESS_DAY'] = $CalendarBusinessHours;
$CalendarHolidaysObj = new CalendarHolidays();
$CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays( $CalendarUid );
$fields['HOLIDAY'] = $CalendarHolidays;
$fields = $this->validateCalendarInfo( $fields, $defaultCalendar );
//********************
return $fields;
}
//for edit
public function getCalendarInfoE ($CalendarUid)
{
//if exists the row in the database propel will update it, otherwise will insert.
$tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid );
$defaultCalendar['CALENDAR_UID'] = "00000000000000000000000000000001";
$defaultCalendar['CALENDAR_NAME'] = "Default";
$defaultCalendar['CALENDAR_CREATE_DATE'] = date( "Y-m-d" );
$defaultCalendar['CALENDAR_UPDATE_DATE'] = date( "Y-m-d" );
$defaultCalendar['CALENDAR_DESCRIPTION'] = "Default";
$defaultCalendar['CALENDAR_STATUS'] = "ACTIVE";
$defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$defaultCalendar['CALENDAR_WORK_DAYS'] = explode( "|", "1|2|3|4|5" );
$defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_DAY'] = 7;
$defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_START'] = "09:00";
$defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_END'] = "17:00";
$defaultCalendar['HOLIDAY'] = array ();
if ((is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) {
$fields['CALENDAR_UID'] = $tr->getCalendarUid();
$fields['CALENDAR_NAME'] = $tr->getCalendarName();
$fields['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate();
$fields['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate();
$fields['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription();
$fields['CALENDAR_STATUS'] = $tr->getCalendarStatus();
$fields['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays();
$fields['CALENDAR_WORK_DAYS_A'] = explode( "|", $tr->getCalendarWorkDays() );
} else {
$fields = $defaultCalendar;
$this->saveCalendarInfo( $fields );
$fields['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$fields['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" );
$tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid );
}
$CalendarBusinessHoursObj = new CalendarBusinessHours();
$CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours( $CalendarUid );
$fields['BUSINESS_DAY'] = $CalendarBusinessHours;
$CalendarHolidaysObj = new CalendarHolidays();
$CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays( $CalendarUid );
$fields['HOLIDAY'] = $CalendarHolidays;
// $fields=$this->validateCalendarInfo($fields, $defaultCalendar); //********************
return $fields;
}
//end for edit
public function validateCalendarInfo ($fields, $defaultCalendar)
{
try {
//Validate if Working days are Correct
//Minimun 3 ?
$workingDays = explode( "|", $fields['CALENDAR_WORK_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) {
throw (new Exception( "You must define at least one Business Day for all days" ));
}
$workingDaysOK = array ();
foreach ($workingDays as $key => $day) {
$workingDaysOK[$day] = false;
}
$sw_all = false;
foreach ($fields['BUSINESS_DAY'] as $keyB => $businessHours) {
if (($businessHours['CALENDAR_BUSINESS_DAY'] == 7)) {
$sw_all = true;
} elseif ((in_array( $businessHours['CALENDAR_BUSINESS_DAY'], $workingDays ))) {
$workingDaysOK[$businessHours['CALENDAR_BUSINESS_DAY']] = true;
}
}
$sw_days = true;
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" ));
}
//Validate Holidays
return $fields;
} catch (Exception $e) {
//print $e->getMessage();
$this->addCalendarLog( "!!!!!!! BAD CALENDAR DEFINITION. " . $e->getMessage() );
$defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
$defaultCalendar['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" );
return $defaultCalendar;
}
}
public function saveCalendarInfo ($aData)
{
$CalendarUid = $aData['CALENDAR_UID'];
$CalendarName = $aData['CALENDAR_NAME'];
$CalendarDescription = $aData['CALENDAR_DESCRIPTION'];
$CalendarStatus = isset( $aData['CALENDAR_STATUS'] ) ? $aData['CALENDAR_STATUS'] : "INACTIVE";
$defaultCalendars[] = '00000000000000000000000000000001';
if (in_array( $aData['CALENDAR_UID'], $defaultCalendars )) {
$CalendarStatus = 'ACTIVE';
$CalendarName = 'Default';
}
$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 (! (is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) {
$tr = new CalendarDefinition();
$tr->setCalendarCreateDate( 'now' );
}
$tr->setCalendarUid( $CalendarUid );
$tr->setCalendarName( $CalendarName );
$tr->setCalendarUpdateDate( 'now' );
$tr->setCalendarDescription( $CalendarDescription );
$tr->setCalendarStatus( $CalendarStatus );
$tr->setCalendarWorkDays( $CalendarWorkDays );
if ($tr->validate()) {
// we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save();
//Calendar Business Hours Save code.
//First Delete all current records
$CalendarBusinessHoursObj = new CalendarBusinessHours();
$CalendarBusinessHoursObj->deleteAllCalendarBusinessHours( $CalendarUid );
//Save all the sent records
foreach ($aData['BUSINESS_DAY'] as $key => $objData) {
$objData['CALENDAR_UID'] = $CalendarUid;
$CalendarBusinessHoursObj->saveCalendarBusinessHours( $objData );
}
//Holiday Save code.
//First Delete all current records
$CalendarHolidayObj = new CalendarHolidays();
$CalendarHolidayObj->deleteAllCalendarHolidays( $CalendarUid );
//Save all the sent records
foreach ($aData['HOLIDAY'] as $key => $objData) {
if (($objData['CALENDAR_HOLIDAY_NAME'] != "") && ($objData['CALENDAR_HOLIDAY_START'] != "") && ($objData['CALENDAR_HOLIDAY_END'] != "")) {
$objData['CALENDAR_UID'] = $CalendarUid;
$CalendarHolidayObj->saveCalendarHolidays( $objData );
}
}
} else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $tr->getValidationFailures();
foreach ($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>";
}
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
}
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
//to do: uniform coderror structures for all classes
//if ( $res['codError'] < 0 ) {
// G::SendMessageText ( $res['message'] , 'error' );
//}
}
public function deleteCalendar ($CalendarUid)
{
//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')) {
//
return false;
}
$defaultCalendars[] = '00000000000000000000000000000001';
if (in_array( $tr->getCalendarUid(), $defaultCalendars )) {
return false;
}
$tr->setCalendarStatus( 'DELETED' );
$tr->setCalendarUpdateDate( 'now' );
if ($tr->validate()) {
// we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save();
} else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $tr->getValidationFailures();
foreach ($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>";
}
G::SendMessage( "ERROR", $msg );
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
}
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
//to do: uniform coderror structures for all classes
//if ( $res['codError'] < 0 ) {
// G::SendMessageText ( $res['message'] , 'error' );
//}
}
public function getCalendarFor ($userUid, $proUid, $tasUid, $sw_validate = true)
{
$Criteria = new Criteria( 'workflow' );
//Default Calendar
$calendarUid = "00000000000000000000000000000001";
$calendarOwner = "DEFAULT";
//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 );
$oDataset = CalendarAssignmentsPeer::doSelectRS( $Criteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
$calendarArray = array ();
while (is_array( $aRow = $oDataset->getRow() )) {
if ($aRow['OBJECT_UID'] == $userUid) {
$calendarArray['USER'] = $aRow['CALENDAR_UID'];
}
if ($aRow['OBJECT_UID'] == $proUid) {
$calendarArray['PROCESS'] = $aRow['CALENDAR_UID'];
}
if ($aRow['OBJECT_UID'] == $tasUid) {
$calendarArray['TASK'] = $aRow['CALENDAR_UID'];
}
$oDataset->next();
}
if (isset( $calendarArray['USER'] )) {
$calendarUid = $calendarArray['USER'];
$calendarOwner = "USER";
} elseif (isset( $calendarArray['PROCESS'] )) {
$calendarUid = $calendarArray['PROCESS'];
$calendarOwner = "PROCESS";
} elseif (isset( $calendarArray['TASK'] )) {
$calendarUid = $calendarArray['TASK'];
$calendarOwner = "TASK";
}
//print "<h1>$calendarUid</h1>";
if ($sw_validate) {
$calendarDefinition = $this->getCalendarInfo( $calendarUid );
} else {
$calendarDefinition = $this->getCalendarInfoE( $calendarUid );
}
$calendarDefinition['CALENDAR_APPLIED'] = $calendarOwner;
$this->addCalendarLog( "--=== Calendar Applied: " . $calendarDefinition['CALENDAR_NAME'] . " -> $calendarOwner" );
return $calendarDefinition;
}
public function assignCalendarTo ($objectUid, $calendarUid, $objectType)
{
//if exists the row in the database propel will update it, otherwise will insert.
$tr = CalendarAssignmentsPeer::retrieveByPK( $objectUid );
if ($calendarUid != "") {
if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarAssignments')) {
$tr = new CalendarAssignments();
}
$tr->setObjectUid( $objectUid );
$tr->setCalendarUid( $calendarUid );
$tr->setObjectType( $objectType );
if ($tr->validate()) {
// we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save();
} else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $tr->getValidationFailures();
foreach ($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>";
}
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
}
} else {
//Delete record
if ((is_object( $tr ) && get_class( $tr ) == 'CalendarAssignments')) {
$tr->delete();
}
}
}
//Added by Qennix
//Counts all users,task,process by calendar
public function getAllCounterByCalendar ($type)
{
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( CalendarAssignmentsPeer::CALENDAR_UID );
$oCriteria->addSelectColumn( 'COUNT(*) AS CNT' );
$oCriteria->addGroupByColumn( CalendarAssignmentsPeer::CALENDAR_UID );
$oCriteria->add( CalendarAssignmentsPeer::OBJECT_TYPE, $type );
$oDataset = CalendarAssignmentsPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$aCounter = Array ();
while ($oDataset->next()) {
$row = $oDataset->getRow();
$aCounter[$row['CALENDAR_UID']] = $row['CNT'];
}
return $aCounter;
}
public function loadByCalendarName ($calendarName)
{
$Criteria = new Criteria( 'workflow' );
$Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID );
$Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME );
$Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE );
$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
/**
* Content.php
* @package workflow.engine.classes.model
*
* 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
* 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.
*
*/
require_once 'classes/model/om/BaseContent.php';
/**
* 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
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
*/
class Content extends BaseContent {
public $langs;
public $rowsProcessed;
public $rowsInserted;
public $rowsUnchanged;
public $rowsClustered;
public $langsAsoc;
/*
* Load the content row specified by the parameters:
<?php
/**
* Content.php
*
* @package workflow.engine.classes.model
*
* 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
* 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.
*
*/
require_once 'classes/model/om/BaseContent.php';
/**
* 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
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
*/
class Content extends BaseContent
{
public $langs;
public $rowsProcessed;
public $rowsInserted;
public $rowsUnchanged;
public $rowsClustered;
public $langsAsoc;
/*
* Load the content row specified by the parameters:
* @param string $sUID
* @return variant
*/
function load($ConCategory, $ConParent, $ConId, $ConLang) {
$content = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $ConLang );
if (is_null ( $content )) {
//we dont find any value for this field and language in CONTENT table
$ConValue = Content::autoLoadSave ( $ConCategory, $ConParent, $ConId, $ConLang );
} else {
//krumo($content);
$ConValue = $content->getConValue ();
if ($ConValue == "") { //try to find a valid translation
$ConValue = Content::autoLoadSave ( $ConCategory, $ConParent, $ConId, $ConLang );
}
}
return $ConValue;
}
/*
* Find a valid Lang for current Content. The most recent
*/
public function load ($ConCategory, $ConParent, $ConId, $ConLang)
{
$content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $ConLang );
if (is_null( $content )) {
//we dont find any value for this field and language in CONTENT table;
$ConValue = Content::autoLoadSave( $ConCategory, $ConParent, $ConId, $ConLang );
} else {
//krumo($content);
$ConValue = $content->getConValue();
if ($ConValue == "") {
//try to find a valid translation
$ConValue = Content::autoLoadSave( $ConCategory, $ConParent, $ConId, $ConLang );
}
}
return $ConValue;
}
/*
* Find a valid Lang for current Content. The most recent
* @param string $ConCategory
* @param string $ConParent
* @param string $ConId
* @param string $ConId
* @return string
*
*/
function getDefaultContentLang($ConCategory, $ConParent, $ConId, $destConLang) {
$Criteria = new Criteria ( 'workflow' );
$Criteria->clearSelectColumns ()->clearOrderByColumns ();
$Criteria->addSelectColumn ( ContentPeer::CON_CATEGORY );
$Criteria->addSelectColumn ( ContentPeer::CON_PARENT );
$Criteria->addSelectColumn ( ContentPeer::CON_ID );
$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_ID, $ConId, CRITERIA::EQUAL );
$Criteria->add ( ContentPeer::CON_LANG, $destConLang, CRITERIA::NOT_EQUAL );
$rs = ContentPeer::doSelectRS ( $Criteria );
$rs->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
$rs->next ();
if (is_array ( $row = $rs->getRow () )) {
$defaultLang = $row ['CON_LANG'];
} else {
$defaultLang = "";
}
return ($defaultLang);
}
/*
* Load the content row and the Save automatically the row for the destination language
* @param string $ConCategory
* @param string $ConParent
* @param string $ConId
* @param string $destConLang
* @return string
* if the row doesn't exist, it will be created automatically, even the default 'en' language
*/
function autoLoadSave($ConCategory, $ConParent, $ConId, $destConLang) {
//search in 'en' language, the default language
$content = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, 'en' );
if ((is_null ( $content )) || ($content->getConValue () == "")) {
$differentLang = Content::getDefaultContentLang ( $ConCategory, $ConParent, $ConId, $destConLang );
$content = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $differentLang );
}
//to do: review if the $destConLang is a valid language/
if (is_null ( $content ))
$ConValue = ''; //we dont find any value for this field and language in CONTENT table
else
$ConValue = $content->getConValue ();
try {
$con = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $destConLang );
if (is_null ( $con )) {
$con = new Content ( );
}
$con->setConCategory ( $ConCategory );
$con->setConParent ( $ConParent );
$con->setConId ( $ConId );
$con->setConLang ( $destConLang );
$con->setConValue ( $ConValue );
if ($con->validate ()) {
$res = $con->save ();
}
} catch ( Exception $e ) {
throw ($e);
}
return $ConValue;
}
/*
* Insert a content row
*
*/
public function getDefaultContentLang ($ConCategory, $ConParent, $ConId, $destConLang)
{
$Criteria = new Criteria( 'workflow' );
$Criteria->clearSelectColumns()->clearOrderByColumns();
$Criteria->addSelectColumn( ContentPeer::CON_CATEGORY );
$Criteria->addSelectColumn( ContentPeer::CON_PARENT );
$Criteria->addSelectColumn( ContentPeer::CON_ID );
$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_ID, $ConId, CRITERIA::EQUAL );
$Criteria->add( ContentPeer::CON_LANG, $destConLang, CRITERIA::NOT_EQUAL );
$rs = ContentPeer::doSelectRS( $Criteria );
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rs->next();
if (is_array( $row = $rs->getRow() )) {
$defaultLang = $row['CON_LANG'];
} else {
$defaultLang = "";
}
return ($defaultLang);
}
/*
* Load the content row and the Save automatically the row for the destination language
* @param string $ConCategory
* @param string $ConParent
* @param string $ConId
* @param string $destConLang
* @return string
* if the row doesn't exist, it will be created automatically, even the default 'en' language
*/
public function autoLoadSave ($ConCategory, $ConParent, $ConId, $destConLang)
{
//search in 'en' language, the default language
$content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, 'en' );
if ((is_null( $content )) || ($content->getConValue() == "")) {
$differentLang = Content::getDefaultContentLang( $ConCategory, $ConParent, $ConId, $destConLang );
$content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $differentLang );
}
//to do: review if the $destConLang is a valid language/
if (is_null( $content )) {
$ConValue = '';
//we dont find any value for this field and language in CONTENT table
} else {
$ConValue = $content->getConValue();
}
try {
$con = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $destConLang );
if (is_null( $con )) {
$con = new Content();
}
$con->setConCategory( $ConCategory );
$con->setConParent( $ConParent );
$con->setConId( $ConId );
$con->setConLang( $destConLang );
$con->setConValue( $ConValue );
if ($con->validate()) {
$res = $con->save();
}
} catch (Exception $e) {
throw ($e);
}
return $ConValue;
}
/*
* Insert a content row
* @param string $ConCategory
* @param string $ConParent
* @param string $ConId
* @param string $ConLang
* @param string $ConValue
* @param string $ConValue
* @return variant
*/
function addContent($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) {
try {
if ($ConLang != 'en') {
$baseLangContent = ContentPeer::retrieveByPk($ConCategory, $ConParent, $ConId, 'en');
if ($baseLangContent === null) {
Content::addContent($ConCategory, $ConParent, $ConId, 'en', $ConValue);
}
}
$con = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $ConLang );
if (is_null ( $con )) {
$con = new Content ( );
} else {
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->setConId ( $ConId );
$con->setConLang ( $ConLang );
$con->setConValue ( $ConValue );
if ($con->validate ()) {
$res = $con->save ();
return $res;
} else {
$e = new Exception ( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" );
throw ($e);
}
} catch ( Exception $e ) {
throw ($e);
}
}
/*
* Insert a content row
*/
public function addContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue)
{
try {
if ($ConLang != 'en') {
$baseLangContent = ContentPeer::retrieveByPk( $ConCategory, $ConParent, $ConId, 'en' );
if ($baseLangContent === null) {
Content::addContent( $ConCategory, $ConParent, $ConId, 'en', $ConValue );
}
}
$con = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $ConLang );
if (is_null( $con )) {
$con = new Content();
} else {
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->setConId( $ConId );
$con->setConLang( $ConLang );
$con->setConValue( $ConValue );
if ($con->validate()) {
$res = $con->save();
return $res;
} else {
$e = new Exception( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" );
throw ($e);
}
} catch (Exception $e) {
throw ($e);
}
}
/*
* Insert a content row
* @param string $ConCategory
* @param string $ConParent
* @param string $ConId
* @param string $ConLang
* @param string $ConValue
* @param string $ConValue
* @return variant
*/
function insertContent($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) {
try {
$con = new Content ( );
$con->setConCategory ( $ConCategory );
$con->setConParent ( $ConParent );
$con->setConId ( $ConId );
$con->setConLang ( $ConLang );
$con->setConValue ( $ConValue );
if ($con->validate ()) {
$res = $con->save ();
return $res;
} else {
$e = new Exception ( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" );
throw ($e);
}
} catch ( Exception $e ) {
throw ($e);
}
}
/*
* remove a content row
*/
public function insertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue)
{
try {
$con = new Content();
$con->setConCategory( $ConCategory );
$con->setConParent( $ConParent );
$con->setConId( $ConId );
$con->setConLang( $ConLang );
$con->setConValue( $ConValue );
if ($con->validate()) {
$res = $con->save();
return $res;
} else {
$e = new Exception( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" );
throw ($e);
}
} catch (Exception $e) {
throw ($e);
}
}
/*
* remove a content row
* @param string $ConCategory
* @param string $ConParent
* @param string $ConId
* @param string $ConLang
* @param string $ConValue
* @param string $ConValue
* @return variant
*/
function removeContent($ConCategory, $ConParent, $ConId) {
try {
$c = new Criteria ( );
$c->add ( ContentPeer::CON_CATEGORY, $ConCategory );
$c->add ( ContentPeer::CON_PARENT, $ConParent );
$c->add ( ContentPeer::CON_ID, $ConId );
$result = ContentPeer::doSelectRS ( $c );
$result->next ();
$row = $result->getRow ();
while ( is_array ( $row ) ) {
ContentPeer::doDelete ( array ($ConCategory, $ConParent, $ConId, $row [3] ) );
$result->next ();
$row = $result->getRow ();
}
} catch ( Exception $e ) {
throw ($e);
}
}
/*
*/
public function removeContent ($ConCategory, $ConParent, $ConId)
{
try {
$c = new Criteria();
$c->add( ContentPeer::CON_CATEGORY, $ConCategory );
$c->add( ContentPeer::CON_PARENT, $ConParent );
$c->add( ContentPeer::CON_ID, $ConId );
$result = ContentPeer::doSelectRS( $c );
$result->next();
$row = $result->getRow();
while (is_array( $row )) {
ContentPeer::doDelete( array ($ConCategory,$ConParent,$ConId,$row[3]) );
$result->next();
$row = $result->getRow();
}
} catch (Exception $e) {
throw ($e);
}
}
/*
* Reasons if the record already exists
*
* @param string $ConCategory
* @param string $ConParent
* @param string $ConId
* @param string $ConLang
* @param string $ConValue
* @param string $ConValue
* @return boolean true or false
*/
function Exists ($ConCategory, $ConParent, $ConId, $ConLang)
{
try {
$oPro = ContentPeer::retrieveByPk($ConCategory, $ConParent, $ConId, $ConLang);
if (is_object($oPro) && get_class ($oPro) == 'Content' ) {
return true;
} else {
return false;
}
}
catch (Exception $oError) {
throw($oError);
}
}
*/
public function Exists ($ConCategory, $ConParent, $ConId, $ConLang)
{
try {
$oPro = ContentPeer::retrieveByPk( $ConCategory, $ConParent, $ConId, $ConLang );
if (is_object( $oPro ) && get_class( $oPro ) == 'Content') {
return true;
} else {
return false;
}
} catch (Exception $oError) {
throw ($oError);
}
}
/*
* Regenerate Table Content
*
* @param array $langs
*/
function regenerateContent($langs, $workSpace=SYS_SYS)
{
*/
public function regenerateContent ($langs, $workSpace = SYS_SYS)
{
//Search the language
$key = array_search('en',$langs);
if ($key === false) {
$key = array_search(SYS_LANG,$langs);
if ($key === false) {
$key = '0';
}
}
$this->langsAsoc = array();
foreach ($langs as $key=>$value) {
$this->langsAsoc[$value] = $value;
}
$this->langs = $langs;
$this->rowsProcessed = 0;
$this->rowsInserted = 0;
$this->rowsUnchanged = 0;
$this->rowsClustered = 0;
$key = array_search( 'en', $langs );
if ($key === false) {
$key = array_search( SYS_LANG, $langs );
if ($key === false) {
$key = '0';
}
}
$this->langsAsoc = array ();
foreach ($langs as $key => $value) {
$this->langsAsoc[$value] = $value;
}
$this->langs = $langs;
$this->rowsProcessed = 0;
$this->rowsInserted = 0;
$this->rowsUnchanged = 0;
$this->rowsClustered = 0;
//Creating table CONTENT_BACKUP
$oConnection = Propel::getConnection('workflow');
$oStatement = $oConnection->prepareStatement("CREATE TABLE IF NOT EXISTS `CONTENT_BACKUP` (
$oConnection = Propel::getConnection( 'workflow' );
$oStatement = $oConnection->prepareStatement( "CREATE TABLE IF NOT EXISTS `CONTENT_BACKUP` (
`CON_CATEGORY` VARCHAR(30) default '' NOT NULL,
`CON_PARENT` VARCHAR(32) default '' NOT NULL,
`CON_ID` VARCHAR(100) default '' NOT NULL,
`CON_LANG` VARCHAR(10) default '' NOT NULL,
`CON_VALUE` MEDIUMTEXT NOT NULL,
CONSTRAINT CONTENT_BACKUP_PK PRIMARY KEY (CON_CATEGORY,CON_PARENT,CON_ID,CON_LANG)
)Engine=MyISAM DEFAULT CHARSET='utf8' COMMENT='Table for add content';");
$oStatement->executeQuery();
$con = Propel::getConnection('workflow');
)Engine=MyISAM DEFAULT CHARSET='utf8' COMMENT='Table for add content';" );
$oStatement->executeQuery();
$con = Propel::getConnection( 'workflow' );
$sql = " SELECT DISTINCT CON_LANG
FROM CONTENT ";
$stmt = $con->createStatement();
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
while ($rs->next()) {
$row = $rs->getRow();
$language = $row['CON_LANG'];
if (array_search($row['CON_LANG'],$langs) === false) {
Content::removeLanguageContent($row['CON_LANG']);
}
}
FROM CONTENT ";
$stmt = $con->createStatement();
$rs = $stmt->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC );
while ($rs->next()) {
$row = $rs->getRow();
$language = $row['CON_LANG'];
if (array_search( $row['CON_LANG'], $langs ) === false) {
Content::removeLanguageContent( $row['CON_LANG'] );
}
}
$sql = " SELECT CON_ID, CON_CATEGORY, CON_LANG, CON_PARENT, CON_VALUE
FROM CONTENT
ORDER BY CON_ID, CON_CATEGORY, CON_PARENT, CON_LANG";
G::LoadClass("wsTools");
$workSpace = new workspaceTools($workSpace);
$workSpace->getDBInfo();
$link = mysql_pconnect($workSpace->dbHost, $workSpace->dbUser, $workSpace->dbPass)
or die ("Could not connect");
mysql_select_db($workSpace->dbName, $link);
mysql_query("SET NAMES 'utf8';");
mysql_query('SET OPTION SQL_BIG_SELECTS=1');
$result = mysql_unbuffered_query($sql, $link);
$list = array();
$default = array();
$sw = array('CON_ID'=>'','CON_CATEGORY'=>'','CON_PARENT'=>'');
while ($row = mysql_fetch_assoc($result)) {
if ($sw['CON_ID'] == $row['CON_ID'] &&
$sw['CON_CATEGORY'] == $row['CON_CATEGORY'] &&
$sw['CON_PARENT'] == $row['CON_PARENT']) {
$list[] = $row;
} else {
$this->rowsClustered++;
if (count($langs) != count($list)) {
$this->checkLanguage($list, $default);
} else {
$this->rowsUnchanged = $this->rowsUnchanged + count($langs);
}
$sw = array();
$sw['CON_ID'] = $row['CON_ID'];
$sw['CON_CATEGORY'] = $row['CON_CATEGORY'];
$sw['CON_LANG'] = $row['CON_LANG'];
$sw['CON_PARENT'] = $row['CON_PARENT'];
unset($list);
unset($default);
$list = array();
$default = array();
$list[] = $row;
}
if ($sw['CON_LANG'] == $langs[$key]) {
$default = $row;
}
$this->rowsProcessed++;
}
if (count($langs) != count($list)) {
$this->checkLanguage($list, $default);
} else {
$this->rowsUnchanged = $this->rowsUnchanged + count($langs);
}
mysql_free_result($result);
$total = $this->rowsProcessed + $this->rowsInserted;
$connection = Propel::getConnection('workflow');
$statement = $connection->prepareStatement("INSERT INTO CONTENT
ORDER BY CON_ID, CON_CATEGORY, CON_PARENT, CON_LANG";
G::LoadClass( "wsTools" );
$workSpace = new workspaceTools( $workSpace );
$workSpace->getDBInfo();
$link = mysql_pconnect( $workSpace->dbHost, $workSpace->dbUser, $workSpace->dbPass ) or die( "Could not connect" );
mysql_select_db( $workSpace->dbName, $link );
mysql_query( "SET NAMES 'utf8';" );
mysql_query( 'SET OPTION SQL_BIG_SELECTS=1' );
$result = mysql_unbuffered_query( $sql, $link );
$list = array ();
$default = array ();
$sw = array ('CON_ID' => '','CON_CATEGORY' => '','CON_PARENT' => ''
);
while ($row = mysql_fetch_assoc( $result )) {
if ($sw['CON_ID'] == $row['CON_ID'] && $sw['CON_CATEGORY'] == $row['CON_CATEGORY'] && $sw['CON_PARENT'] == $row['CON_PARENT']) {
$list[] = $row;
} else {
$this->rowsClustered ++;
if (count( $langs ) != count( $list )) {
$this->checkLanguage( $list, $default );
} else {
$this->rowsUnchanged = $this->rowsUnchanged + count( $langs );
}
$sw = array ();
$sw['CON_ID'] = $row['CON_ID'];
$sw['CON_CATEGORY'] = $row['CON_CATEGORY'];
$sw['CON_LANG'] = $row['CON_LANG'];
$sw['CON_PARENT'] = $row['CON_PARENT'];
unset( $list );
unset( $default );
$list = array ();
$default = array ();
$list[] = $row;
}
if ($sw['CON_LANG'] == $langs[$key]) {
$default = $row;
}
$this->rowsProcessed ++;
}
if (count( $langs ) != count( $list )) {
$this->checkLanguage( $list, $default );
} else {
$this->rowsUnchanged = $this->rowsUnchanged + count( $langs );
}
mysql_free_result( $result );
$total = $this->rowsProcessed + $this->rowsInserted;
$connection = Propel::getConnection( 'workflow' );
$statement = $connection->prepareStatement( "INSERT INTO CONTENT
SELECT CON_CATEGORY, CON_PARENT, CON_ID , CON_LANG, CON_VALUE
FROM CONTENT_BACKUP");
$statement->executeQuery();
$statement = $connection->prepareStatement("DROP TABLE CONTENT_BACKUP");
$statement->executeQuery();
if (!isset($_SERVER['SERVER_NAME'])) {
CLI::logging("Rows Processed ---> $this->rowsProcessed ..... \n");
CLI::logging("Rows Clustered ---> $this->rowsClustered ..... \n");
CLI::logging("Rows Unchanged ---> $this->rowsUnchanged ..... \n");
CLI::logging("Rows Inserted ---> $this->rowsInserted ..... \n");
CLI::logging("Rows Total ---> $total ..... \n");
}
}
function checkLanguage($content, $default)
{
if (count($content)>0) {
$langs = $this->langs;
$langsAsoc = $this->langsAsoc;
FROM CONTENT_BACKUP" );
$statement->executeQuery();
$statement = $connection->prepareStatement( "DROP TABLE CONTENT_BACKUP" );
$statement->executeQuery();
if (! isset( $_SERVER['SERVER_NAME'] )) {
CLI::logging( "Rows Processed ---> $this->rowsProcessed ..... \n" );
CLI::logging( "Rows Clustered ---> $this->rowsClustered ..... \n" );
CLI::logging( "Rows Unchanged ---> $this->rowsUnchanged ..... \n" );
CLI::logging( "Rows Inserted ---> $this->rowsInserted ..... \n" );
CLI::logging( "Rows Total ---> $total ..... \n" );
}
}
public function checkLanguage ($content, $default)
{
if (count( $content ) > 0) {
$langs = $this->langs;
$langsAsoc = $this->langsAsoc;
//Element default
$default = (count($default)>0) ? $default : $content[0];
foreach ($content as $key => $value) {
unset($langsAsoc[$value['CON_LANG']]);
}
foreach ($langsAsoc as $key => $value) {
$this->rowsInserted++;
$this->fastInsertContent(
$default['CON_CATEGORY'],
$default['CON_PARENT'],
$default['CON_ID'],
$value,
$default['CON_VALUE']
);
}
}
}
function fastInsertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) {
$ConValue = mysql_real_escape_string($ConValue);
$connection = Propel::getConnection('workflow');
$statement = $connection->prepareStatement("INSERT INTO CONTENT_BACKUP (
$default = (count( $default ) > 0) ? $default : $content[0];
foreach ($content as $key => $value) {
unset( $langsAsoc[$value['CON_LANG']] );
}
foreach ($langsAsoc as $key => $value) {
$this->rowsInserted ++;
$this->fastInsertContent( $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 (
CON_CATEGORY, CON_PARENT, CON_ID , CON_LANG, CON_VALUE)
VALUES ('$ConCategory', '$ConParent', '$ConId', '$ConLang', '$ConValue');");
$statement->executeQuery();
}
function removeLanguageContent($lanId) {
try {
$c = new Criteria ( );
$c->addSelectColumn(ContentPeer::CON_CATEGORY);
$c->addSelectColumn(ContentPeer::CON_PARENT);
$c->addSelectColumn(ContentPeer::CON_ID);
$c->addSelectColumn(ContentPeer::CON_LANG);
$c->add ( ContentPeer::CON_LANG, $lanId );
$result = ContentPeer::doSelectRS ( $c );
$result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$result->next ();
$row = $result->getRow ();
while ( is_array ( $row ) ) {
$content = ContentPeer::retrieveByPK( $row['CON_CATEGORY'], $row['CON_PARENT'], $row['CON_ID'], $lanId);
if( $content !== null )
$content->delete();
$result->next ();
$row = $result->getRow ();
}
} catch ( Exception $e ) {
throw ($e);
}
}
//Added by Enrique at Feb 9th,2011
//Gets all Role Names by Role
function getAllContentsByRole($sys_lang=SYS_LANG){
if (!isset($sys_lang)) $sys_lang = 'en';
$oCriteria = new Criteria('workflow');
$oCriteria->clearSelectColumns();
$oCriteria->addSelectColumn(ContentPeer::CON_ID);
$oCriteria->addAsColumn('ROL_NAME', ContentPeer::CON_VALUE);
//$oCriteria->addAsColumn('ROL_UID', ContentPeer::CON_ID);
$oCriteria->add(ContentPeer::CON_CATEGORY,'ROL_NAME');
$oCriteria->add(ContentPeer::CON_LANG, $sys_lang);
$oDataset = ContentPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$aRoles = Array();
while ($oDataset->next()){
$xRow = $oDataset->getRow();
$aRoles[$xRow['CON_ID']] = $xRow['ROL_NAME'];
}
return $aRoles;
}
} // Content
VALUES ('$ConCategory', '$ConParent', '$ConId', '$ConLang', '$ConValue');" );
$statement->executeQuery();
}
public function removeLanguageContent ($lanId)
{
try {
$c = new Criteria();
$c->addSelectColumn( ContentPeer::CON_CATEGORY );
$c->addSelectColumn( ContentPeer::CON_PARENT );
$c->addSelectColumn( ContentPeer::CON_ID );
$c->addSelectColumn( ContentPeer::CON_LANG );
$c->add( ContentPeer::CON_LANG, $lanId );
$result = ContentPeer::doSelectRS( $c );
$result->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$result->next();
$row = $result->getRow();
while (is_array( $row )) {
$content = ContentPeer::retrieveByPK( $row['CON_CATEGORY'], $row['CON_PARENT'], $row['CON_ID'], $lanId );
if ($content !== null) {
$content->delete();
}
$result->next();
$row = $result->getRow();
}
} catch (Exception $e) {
throw ($e);
}
}
//Added by Enrique at Feb 9th,2011
//Gets all Role Names by Role
public function getAllContentsByRole ($sys_lang = SYS_LANG)
{
if (! isset( $sys_lang )) {
$sys_lang = 'en';
}
$oCriteria = new Criteria( 'workflow' );
$oCriteria->clearSelectColumns();
$oCriteria->addSelectColumn( ContentPeer::CON_ID );
$oCriteria->addAsColumn( 'ROL_NAME', ContentPeer::CON_VALUE );
//$oCriteria->addAsColumn('ROL_UID', ContentPeer::CON_ID);
$oCriteria->add( ContentPeer::CON_CATEGORY, 'ROL_NAME' );
$oCriteria->add( ContentPeer::CON_LANG, $sys_lang );
$oDataset = ContentPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$aRoles = Array ();
while ($oDataset->next()) {
$xRow = $oDataset->getRow();
$aRoles[$xRow['CON_ID']] = $xRow['ROL_NAME'];
}
return $aRoles;
}
}
// Content

View File

@@ -1,231 +1,227 @@
<?php
/**
* ReportTable.php
* @package workflow.engine.classes.model
*
* 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
* 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.
*
*/
require_once 'classes/model/Content.php';
require_once 'classes/model/om/BaseReportTable.php';
/**
* Skeleton subclass for representing a row from the 'REPORT_TABLE' table.
*
*
*
* You should add additional methods to this class to meet the
* 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
*/
class ReportTable extends BaseReportTable {
/**
* This value goes in the content table
* @var string
*/
protected $rep_tab_title = '';
/**
* Get the rep_tab_title column value.
* @return string
*/
public function getRepTabTitle() {
if ( $this->getRepTabUid() == "" ) {
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 );
return $this->rep_tab_title;
}
/**
* Set the rep_tab_title column value.
*
* @param string $v new value
* @return void
*/
public function setRepTabTitle($v)
{
if ( $this->getRepTabUid() == "" ) {
throw ( new Exception( "Error in setRepTabTitle, the setRepTabUid() can't be blank") );
}
$v=isset($v)?((string)$v):'';
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
if ($this->rep_tab_title !== $v || $v==="") {
$this->rep_tab_title = $v;
$res = Content::addContent( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang, $this->rep_tab_title );
return $res;
}
return 0;
}
public function load($RepTabUid)
{
try {
$oRow = ReportTablePeer::retrieveByPK( $RepTabUid );
if (!is_null($oRow))
{
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
$this->setNew(false);
$this->setRepTabTitle($aFields['REP_TAB_TITLE']=$this->getRepTabTitle());
return $aFields;
}
else {
//throw( new Exception( "The row '$RepTabUid' in table ReportTable doesn't exist!" ));
return array();
}
}
catch (Exception $oError) {
throw($oError);
}
}
public function create($aData)
{
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME);
try
{
$con->begin();
if ( isset ( $aData['REP_TAB_UID'] ) && $aData['REP_TAB_UID']== '' )
unset ( $aData['REP_TAB_UID'] );
if ( !isset ( $aData['REP_TAB_UID'] ) )
$this->setRepTabUid(G::generateUniqueID());
else
$this->setRepTabUid($aData['REP_TAB_UID'] );
$this->setProUid($aData['PRO_UID']);
$this->setRepTabName($aData['REP_TAB_NAME']);
$this->setRepTabType($aData['REP_TAB_TYPE']);
if ( !isset ( $aData['REP_TAB_GRID'] ) )
$this->setRepTabGrid("");
else
$this->setRepTabGrid( $aData['REP_TAB_GRID'] );
if ( !isset ( $aData['REP_TAB_CONNECTION'] ) )
$this->setRepTabConnection("report");
else
$this->setRepTabConnection( $aData['REP_TAB_CONNECTION'] );
$this->setRepTabCreateDate(date('Y-m-d H:i:s'));
$this->setRepTabStatus('ACTIVE');
if($this->validate())
{
if ( !isset ( $aData['REP_TAB_TITLE'] ) )
$this->setRepTabTitle("");
else
$this->setRepTabTitle( $aData['REP_TAB_TITLE'] );
$result=$this->save();
$con->commit();
return $result;
}
else
{
$con->rollback();
throw(new Exception("Failed Validation in class ".get_class($this)."."));
}
}
catch(Exception $e)
{
$con->rollback();
throw($e);
}
}
public function update($fields)
{
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME);
try
{
$con->begin();
$this->load($fields['REP_TAB_UID']);
$this->fromArray($fields,BasePeer::TYPE_FIELDNAME);
$sDataBase = 'database_' . strtolower(DB_ADAPTER);
if(G::LoadSystemExist($sDataBase)){
G::LoadSystem($sDataBase);
$oDataBase = new database();
$oValidate = $oDataBase->getValidate($this->validate());
} else {
$oValidate = $this->validate();
}
// if($this->validate())
if($oValidate)
{
$contentResult=0;
if (array_key_exists("REP_TAB_TITLE", $fields)) $contentResult+=$this->setRepTabTitle($fields["REP_TAB_TITLE"]);
$result=$this->save();
$result=($result==0)?($contentResult>0?1:0):$result;
$con->commit();
return $result;
}
else
{
$con->rollback();
$validationE=new Exception("Failed Validation in class ".get_class($this).".");
$validationE->aValidationFailures = $this->getValidationFailures();
throw($validationE);
}
}
catch(Exception $e)
{
$con->rollback();
throw($e);
}
}
public function remove($RepTabUid)
{
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME);
try
{
$con->begin();
$oRepTab = ReportTablePeer::retrieveByPK( $RepTabUid );
if (!is_null($oRepTab)) {
Content::removeContent( 'REP_TAB_TITLE', '', $this->getRepTabUid());
$result = $oRepTab->delete();
$con->commit();
}
return $result;
}
catch(Exception $e)
{
$con->rollback();
throw($e);
}
}
function reportTableExists ( $RepTabUid ) {
$con = Propel::getConnection(ReportTablePeer::DATABASE_NAME);
try {
$oRepTabUid = ReportTablePeer::retrieveByPk( $RepTabUid );
if (is_object($oRepTabUid) && get_class ($oRepTabUid) == 'ReportTable' ) {
return true;
}
else {
return false;
}
}
catch (Exception $oError) {
throw($oError);
}
}
} // ReportTable
<?php
/**
* ReportTable.php
*
* @package workflow.engine.classes.model
*
* 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
* 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.
*
*/
require_once 'classes/model/Content.php';
require_once 'classes/model/om/BaseReportTable.php';
/**
* Skeleton subclass for representing a row from the 'REPORT_TABLE' table.
*
*
*
* You should add additional methods to this class to meet the
* 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
*/
class ReportTable extends BaseReportTable
{
/**
* This value goes in the content table
*
* @var string
*/
protected $rep_tab_title = '';
/**
* Get the rep_tab_title column value.
*
* @return string
*/
public function getRepTabTitle ()
{
if ($this->getRepTabUid() == "") {
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 );
return $this->rep_tab_title;
}
/**
* Set the rep_tab_title column value.
*
* @param string $v new value
* @return void
*/
public function setRepTabTitle ($v)
{
if ($this->getRepTabUid() == "") {
throw (new Exception( "Error in setRepTabTitle, the setRepTabUid() can't be blank" ));
}
$v = isset( $v ) ? ((string) $v) : '';
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
if ($this->rep_tab_title !== $v || $v === "") {
$this->rep_tab_title = $v;
$res = Content::addContent( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang, $this->rep_tab_title );
return $res;
}
return 0;
}
public function load ($RepTabUid)
{
try {
$oRow = ReportTablePeer::retrieveByPK( $RepTabUid );
if (! is_null( $oRow )) {
$aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$this->setNew( false );
$this->setRepTabTitle( $aFields['REP_TAB_TITLE'] = $this->getRepTabTitle() );
return $aFields;
} else {
//throw( new Exception( "The row '$RepTabUid' in table ReportTable doesn't exist!" ));
return array ();
}
} catch (Exception $oError) {
throw ($oError);
}
}
public function create ($aData)
{
$con = Propel::getConnection( ReportTablePeer::DATABASE_NAME );
try {
$con->begin();
if (isset( $aData['REP_TAB_UID'] ) && $aData['REP_TAB_UID'] == '') {
unset( $aData['REP_TAB_UID'] );
}
if (! isset( $aData['REP_TAB_UID'] )) {
$this->setRepTabUid( G::generateUniqueID() );
} else {
$this->setRepTabUid( $aData['REP_TAB_UID'] );
}
$this->setProUid( $aData['PRO_UID'] );
$this->setRepTabName( $aData['REP_TAB_NAME'] );
$this->setRepTabType( $aData['REP_TAB_TYPE'] );
if (! isset( $aData['REP_TAB_GRID'] )) {
$this->setRepTabGrid( "" );
} else {
$this->setRepTabGrid( $aData['REP_TAB_GRID'] );
}
if (! isset( $aData['REP_TAB_CONNECTION'] )) {
$this->setRepTabConnection( "report" );
} else {
$this->setRepTabConnection( $aData['REP_TAB_CONNECTION'] );
}
$this->setRepTabCreateDate( date( 'Y-m-d H:i:s' ) );
$this->setRepTabStatus( 'ACTIVE' );
if ($this->validate()) {
if (! isset( $aData['REP_TAB_TITLE'] )) {
$this->setRepTabTitle( "" );
} else {
$this->setRepTabTitle( $aData['REP_TAB_TITLE'] );
}
$result = $this->save();
$con->commit();
return $result;
} else {
$con->rollback();
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
}
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
public function update ($fields)
{
$con = Propel::getConnection( ReportTablePeer::DATABASE_NAME );
try {
$con->begin();
$this->load( $fields['REP_TAB_UID'] );
$this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
$sDataBase = 'database_' . strtolower( DB_ADAPTER );
if (G::LoadSystemExist( $sDataBase )) {
G::LoadSystem( $sDataBase );
$oDataBase = new database();
$oValidate = $oDataBase->getValidate( $this->validate() );
} else {
$oValidate = $this->validate();
}
// if($this->validate())
if ($oValidate) {
$contentResult = 0;
if (array_key_exists( "REP_TAB_TITLE", $fields )) {
$contentResult += $this->setRepTabTitle( $fields["REP_TAB_TITLE"] );
}
$result = $this->save();
$result = ($result == 0) ? ($contentResult > 0 ? 1 : 0) : $result;
$con->commit();
return $result;
} else {
$con->rollback();
$validationE = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
$validationE->aValidationFailures = $this->getValidationFailures();
throw ($validationE);
}
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
public function remove ($RepTabUid)
{
$con = Propel::getConnection( ReportTablePeer::DATABASE_NAME );
try {
$con->begin();
$oRepTab = ReportTablePeer::retrieveByPK( $RepTabUid );
if (! is_null( $oRepTab )) {
Content::removeContent( 'REP_TAB_TITLE', '', $this->getRepTabUid() );
$result = $oRepTab->delete();
$con->commit();
}
return $result;
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
public function reportTableExists ($RepTabUid)
{
$con = Propel::getConnection( ReportTablePeer::DATABASE_NAME );
try {
$oRepTabUid = ReportTablePeer::retrieveByPk( $RepTabUid );
if (is_object( $oRepTabUid ) && get_class( $oRepTabUid ) == 'ReportTable') {
return true;
} else {
return false;
}
} catch (Exception $oError) {
throw ($oError);
}
}
}
// ReportTable

View File

@@ -1,216 +1,217 @@
<?php
/**
* Route.php
* @package workflow.engine.classes.model
*
* 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
* 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.
*
*/
require_once 'classes/model/om/BaseRoute.php';
require_once 'classes/model/Content.php';
/**
* 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
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
*/
class Route extends BaseRoute {
/*
<?php
/**
* Route.php
*
* @package workflow.engine.classes.model
*
* 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
* 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.
*
*/
require_once 'classes/model/om/BaseRoute.php';
require_once 'classes/model/Content.php';
/**
* 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
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
*/
class Route extends BaseRoute
{
/*
* Load the application document registry
* @param string $sRouUid
* @return variant
*/
public function load($sRouUid)
{
try {
$oRoute = RoutePeer::retrieveByPK($sRouUid);
if (!is_null($oRoute))
{
$aFields = $oRoute->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
return $aFields;
}
else {
throw(new Exception('This row doesn\'t exist!'));
}
}
catch (Exception $oError) {
throw($oError);
}
}
/**
* Create the application document registry
* @param array $aData
* @return string
**/
public function create($aData)
{
$oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME);
try {
$sRouteUID = G::generateUniqueID();
$aData['ROU_UID'] = $sRouteUID;
$oRoute = new Route();
// validating default values
$aData['ROU_TO_LAST_USER'] = $this->validateValue(isset($aData['ROU_TO_LAST_USER']) ? $aData['ROU_TO_LAST_USER'] : '', array('TRUE', 'FALSE'), 'FALSE');
$aData['ROU_OPTIONAL'] = $this->validateValue(isset($aData['ROU_OPTIONAL']) ? $aData['ROU_OPTIONAL'] : '', array('TRUE', 'FALSE'), 'FALSE');
$aData['ROU_SEND_EMAIL'] = $this->validateValue(isset($aData['ROU_SEND_EMAIL']) ? $aData['ROU_SEND_EMAIL']: '', array('TRUE', 'FALSE'), 'TRUE');
$oRoute->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oRoute->validate()) {
$oConnection->begin();
$iResult = $oRoute->save();
$oConnection->commit();
return $sRouteUID;
}
else {
$sMessage = '';
$aValidationFailures = $oRoute->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
}
}
catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
/**
* Update the application document registry
* @param array $aData
* @return string
**/
public function update($aData)
{
$oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME);
try {
$oRoute = RoutePeer::retrieveByPK($aData['ROU_UID']);
if (!is_null($oRoute))
{
// validating default values
if (isset($aData['ROU_TO_LAST_USER'])) {
$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_SEND_EMAIL'])) {
$aData['ROU_SEND_EMAIL'] = $this->validateValue($aData['ROU_SEND_EMAIL'], array('TRUE', 'FALSE'), 'TRUE');
}
$oRoute->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oRoute->validate()) {
$oConnection->begin();
$iResult = $oRoute->save();
$oConnection->commit();
return $iResult;
}
else {
$sMessage = '';
$aValidationFailures = $oRoute->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
$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!" ));
}
}
catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
/**
* Remove the application document registry
* @param array $aData
* @return string
**/
public function remove($sRouUid)
{
$oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME);
try {
$oRoute = RoutePeer::retrieveByPK($sRouUid);
if (!is_null($oRoute))
{
$oConnection->begin();
$iResult = $oRoute->delete();
$oConnection->commit();
return $iResult;
}
else {
throw(new Exception('This row doesn\'t exist!'));
}
}
catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
function routeExists ( $sRouUid ) {
$con = Propel::getConnection(RoutePeer::DATABASE_NAME);
try {
$oRouUid = RoutePeer::retrieveByPk( $sRouUid );
if (is_object($oRouUid) && get_class ($oRouUid) == 'Route' ) {
return true;
}
else {
return false;
}
}
catch (Exception $oError) {
throw($oError);
}
}
/**
* 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 $default string default value, if the tested value is not valid the default value is returned
* @return the tested and accepted value
*/
function validateValue($value, $validValues, $default)
{
if (!in_array($value, $validValues)) {
$value = $default;
}
return $value;
}
} // Route
*/
public function load ($sRouUid)
{
try {
$oRoute = RoutePeer::retrieveByPK( $sRouUid );
if (! is_null( $oRoute )) {
$aFields = $oRoute->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
return $aFields;
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Create the application document registry
*
* @param array $aData
* @return string
*
*/
public function create ($aData)
{
$oConnection = Propel::getConnection( RoutePeer::DATABASE_NAME );
try {
$sRouteUID = G::generateUniqueID();
$aData['ROU_UID'] = $sRouteUID;
$oRoute = new Route();
// validating default values
$aData['ROU_TO_LAST_USER'] = $this->validateValue( isset( $aData['ROU_TO_LAST_USER'] ) ? $aData['ROU_TO_LAST_USER'] : '', array ('TRUE','FALSE'
), 'FALSE' );
$aData['ROU_OPTIONAL'] = $this->validateValue( isset( $aData['ROU_OPTIONAL'] ) ? $aData['ROU_OPTIONAL'] : '', array ('TRUE','FALSE'
), 'FALSE' );
$aData['ROU_SEND_EMAIL'] = $this->validateValue( isset( $aData['ROU_SEND_EMAIL'] ) ? $aData['ROU_SEND_EMAIL'] : '', array ('TRUE','FALSE'
), 'TRUE' );
$oRoute->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oRoute->validate()) {
$oConnection->begin();
$iResult = $oRoute->save();
$oConnection->commit();
return $sRouteUID;
} else {
$sMessage = '';
$aValidationFailures = $oRoute->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
/**
* Update the application document registry
*
* @param array $aData
* @return string
*
*/
public function update ($aData)
{
$oConnection = Propel::getConnection( RoutePeer::DATABASE_NAME );
try {
$oRoute = RoutePeer::retrieveByPK( $aData['ROU_UID'] );
if (! is_null( $oRoute )) {
// validating default values
if (isset( $aData['ROU_TO_LAST_USER'] )) {
$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_SEND_EMAIL'] )) {
$aData['ROU_SEND_EMAIL'] = $this->validateValue( $aData['ROU_SEND_EMAIL'], array ('TRUE','FALSE'
), 'TRUE' );
}
$oRoute->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oRoute->validate()) {
$oConnection->begin();
$iResult = $oRoute->save();
$oConnection->commit();
return $iResult;
} else {
$sMessage = '';
$aValidationFailures = $oRoute->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$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!" ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
/**
* Remove the application document registry
*
* @param array $aData
* @return string
*
*/
public function remove ($sRouUid)
{
$oConnection = Propel::getConnection( RoutePeer::DATABASE_NAME );
try {
$oRoute = RoutePeer::retrieveByPK( $sRouUid );
if (! is_null( $oRoute )) {
$oConnection->begin();
$iResult = $oRoute->delete();
$oConnection->commit();
return $iResult;
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
public function routeExists ($sRouUid)
{
$con = Propel::getConnection( RoutePeer::DATABASE_NAME );
try {
$oRouUid = RoutePeer::retrieveByPk( $sRouUid );
if (is_object( $oRouUid ) && get_class( $oRouUid ) == 'Route') {
return true;
} else {
return false;
}
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* 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 $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)
{
if (! in_array( $value, $validValues )) {
$value = $default;
}
return $value;
}
}
// Route

View File

@@ -1,200 +1,193 @@
<?php
/**
* Stage.php
* @package workflow.engine.classes.model
*/
require_once 'classes/model/Content.php';
require_once 'classes/model/om/BaseStage.php';
/**
* Skeleton subclass for representing a row from the 'STAGE' table.
*
*
*
* You should add additional methods to this class to meet the
* 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
*/
class Stage extends BaseStage {
/**
* This value goes in the content table
* @var string
*/
protected $stg_title = '';
/**
* Get the stg_title column value.
* @return string
*/
public function getStgTitle() {
if ( $this->getStgUid() == "" ) {
throw ( new Exception( "Error in getStgTitle, the getStgUid() can't be blank") );
}
$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
*/
public function setStgTitle($v)
{
if ( $this->getStgUid() == "" ) {
throw ( new Exception( "Error in setStgTitle, the setStgUid() can't be blank") );
}
$v=isset($v)?((string)$v):'';
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
if ($this->stg_title !== $v || $v==="") {
$this->stg_title = $v;
$res = Content::addContent( 'STG_TITLE', '', $this->getStgUid(), $lang, $this->stg_title );
return $res;
}
return 0;
}
public function load($StgUid)
{
try {
$oRow = StagePeer::retrieveByPK( $StgUid );
if (!is_null($oRow))
{
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
$this->setNew(false);
$this->setStgTitle($aFields['STG_TITLE'] = $this->getStgTitle());
return $aFields;
}
else {
throw( new Exception( "The row '$StgUid' in table Stage doesn't exist!" ));
}
}
catch (Exception $oError) {
throw($oError);
}
}
public function create($aData) {
$oConnection = Propel::getConnection(StagePeer::DATABASE_NAME);
try {
if ( isset ( $aData['STG_UID'] ) && $aData['STG_UID']== '' )
unset ( $aData['STG_UID'] );
if ( !isset ( $aData['STG_UID'] ) )
$aData['STG_UID'] = G::generateUniqueID();
$oStage = new Stage();
$oStage->fromArray($aData, BasePeer::TYPE_FIELDNAME);
$oStage->setStgTitle($aData['STG_TITLE']);
if ($oStage->validate()) {
$oConnection->begin();
$iResult = $oStage->save();
$oConnection->commit();
return $aData['STG_UID'];
}
else {
$sMessage = '';
$aValidationFailures = $oStage->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
}
}
catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
public function update($fields)
{
$con = Propel::getConnection(StagePeer::DATABASE_NAME);
try
{
$con->begin();
$this->load($fields['STG_UID']);
$this->fromArray($fields, BasePeer::TYPE_FIELDNAME);
if($this->validate())
{
$contentResult=0;
if (array_key_exists("STG_TITLE", $fields)) $contentResult+=$this->setStgTitle($fields["STG_TITLE"]);
$result=$this->save();
$result=($result==0)?($contentResult>0?1:0):$result;
$con->commit();
return $result;
}
else
{
$con->rollback();
$validationE=new Exception("Failed Validation in class ".get_class($this).".");
$validationE->aValidationFailures = $this->getValidationFailures();
throw($validationE);
}
}
catch(Exception $e)
{
$con->rollback();
throw($e);
}
}
public function remove($StgUid)
{
$con = Propel::getConnection(StagePeer::DATABASE_NAME);
try
{
$con->begin();
$oStage = StagePeer::retrieveByPK( $StgUid );
if (!is_null($oStage)) {
Content::removeContent( 'STG_TITLE', '', $this->getStgUid());
$result = $oStage->delete();
$con->commit();
}
return $result;
}
catch(Exception $e)
{
$con->rollback();
throw($e);
}
}
function reorderPositions($sProcessUID, $iIndex) {
try {
$oCriteria = new Criteria('workflow');
$oCriteria->add(StagePeer::PRO_UID, $sProcessUID);
$oCriteria->add(StagePeer::STG_INDEX, $iIndex, '>');
$oDataset = StagePeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$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->next();
}
}
catch (Exception $oException) {
throw $Exception;
}
}
function Exists ( $sUid ) {
try {
$oObj = StagePeer::retrieveByPk($sUid);
return (is_object($oObj) && get_class($oObj) == 'Stage');
}
catch (Exception $oError) {
throw($oError);
}
}
} // Stage
<?php
/**
* Stage.php
*
* @package workflow.engine.classes.model
*/
require_once 'classes/model/Content.php';
require_once 'classes/model/om/BaseStage.php';
/**
* Skeleton subclass for representing a row from the 'STAGE' table.
*
*
*
* You should add additional methods to this class to meet the
* 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
*/
class Stage extends BaseStage
{
/**
* This value goes in the content table
*
* @var string
*/
protected $stg_title = '';
/**
* Get the stg_title column value.
*
* @return string
*/
public function getStgTitle ()
{
if ($this->getStgUid() == "") {
throw (new Exception( "Error in getStgTitle, the getStgUid() can't be blank" ));
}
$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
*/
public function setStgTitle ($v)
{
if ($this->getStgUid() == "") {
throw (new Exception( "Error in setStgTitle, the setStgUid() can't be blank" ));
}
$v = isset( $v ) ? ((string) $v) : '';
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
if ($this->stg_title !== $v || $v === "") {
$this->stg_title = $v;
$res = Content::addContent( 'STG_TITLE', '', $this->getStgUid(), $lang, $this->stg_title );
return $res;
}
return 0;
}
public function load ($StgUid)
{
try {
$oRow = StagePeer::retrieveByPK( $StgUid );
if (! is_null( $oRow )) {
$aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$this->setNew( false );
$this->setStgTitle( $aFields['STG_TITLE'] = $this->getStgTitle() );
return $aFields;
} else {
throw (new Exception( "The row '$StgUid' in table Stage doesn't exist!" ));
}
} catch (Exception $oError) {
throw ($oError);
}
}
public function create ($aData)
{
$oConnection = Propel::getConnection( StagePeer::DATABASE_NAME );
try {
if (isset( $aData['STG_UID'] ) && $aData['STG_UID'] == '') {
unset( $aData['STG_UID'] );
}
if (! isset( $aData['STG_UID'] )) {
$aData['STG_UID'] = G::generateUniqueID();
}
$oStage = new Stage();
$oStage->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
$oStage->setStgTitle( $aData['STG_TITLE'] );
if ($oStage->validate()) {
$oConnection->begin();
$iResult = $oStage->save();
$oConnection->commit();
return $aData['STG_UID'];
} else {
$sMessage = '';
$aValidationFailures = $oStage->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
public function update ($fields)
{
$con = Propel::getConnection( StagePeer::DATABASE_NAME );
try {
$con->begin();
$this->load( $fields['STG_UID'] );
$this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
if ($this->validate()) {
$contentResult = 0;
if (array_key_exists( "STG_TITLE", $fields )) {
$contentResult += $this->setStgTitle( $fields["STG_TITLE"] );
}
$result = $this->save();
$result = ($result == 0) ? ($contentResult > 0 ? 1 : 0) : $result;
$con->commit();
return $result;
} else {
$con->rollback();
$validationE = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
$validationE->aValidationFailures = $this->getValidationFailures();
throw ($validationE);
}
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
public function remove ($StgUid)
{
$con = Propel::getConnection( StagePeer::DATABASE_NAME );
try {
$con->begin();
$oStage = StagePeer::retrieveByPK( $StgUid );
if (! is_null( $oStage )) {
Content::removeContent( 'STG_TITLE', '', $this->getStgUid() );
$result = $oStage->delete();
$con->commit();
}
return $result;
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
public function reorderPositions ($sProcessUID, $iIndex)
{
try {
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( StagePeer::PRO_UID, $sProcessUID );
$oCriteria->add( StagePeer::STG_INDEX, $iIndex, '>' );
$oDataset = StagePeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$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->next();
}
} catch (Exception $oException) {
throw $Exception;
}
}
public function Exists ($sUid)
{
try {
$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
/**
* StepSupervisor.php
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseStepSupervisor.php';
/**
* Skeleton subclass for representing a row from the 'STEP_SUPERVISOR' table.
*
*
*
* You should add additional methods to this class to meet the
* 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
*/
class StepSupervisor extends BaseStepSupervisor {
public function load($Uid)
{
try {
$oRow = StepSupervisorPeer::retrieveByPK( $Uid );
if (!is_null($oRow))
{
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
$this->setNew(false);
return $aFields;
}
else {
throw( new Exception( "The row '$Uid' in table StepSupervisor doesn't exist!" ));
}
}
catch (Exception $oError) {
throw($oError);
}
}
function Exists ( $Uid ) {
try {
$oPro = StepSupervisorPeer::retrieveByPk( $Uid );
if (is_object($oPro) && get_class ($oPro) == 'StepSupervisor' ) {
return true;
}
else {
return false;
}
}
catch (Exception $oError) {
throw($oError);
}
}
/**
* Create the step supervisor registry
* @param array $aData
* @return boolean
**/
public function create($aData)
{
$oConnection = Propel::getConnection(StepSupervisorPeer::DATABASE_NAME);
try {
if ( isset ( $aData['STEP_UID'] ) && $aData['STEP_UID']== '' )
unset ( $aData['STEP_UID'] );
if ( !isset ( $aData['STEP_UID'] ) )
$aData['STEP_UID'] = G::generateUniqueID();
$oStepSupervisor = new StepSupervisor();
$oStepSupervisor->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oStepSupervisor->validate()) {
$oConnection->begin();
$iResult = $oStepSupervisor->save();
$oConnection->commit();
return true;
}
else {
$sMessage = '';
$aValidationFailures = $oStepSupervisor->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
}
}
catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
/**
* Update the step supervisor registry
* @param array $aData
* @return integer
**/
public function update($aData)
{
$oConnection = Propel::getConnection(StepSupervisorPeer::DATABASE_NAME);
try {
$oStepSupervisor = StepSupervisorPeer::retrieveByPK($aData['STEP_UID']);
if (!is_null($oStepSupervisor))
{
$oStepSupervisor->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oStepSupervisor->validate()) {
$oConnection->begin();
$iResult = $oStepSupervisor->save();
$oConnection->commit();
return $iResult;
}
else {
$sMessage = '';
$aValidationFailures = $oStepSupervisor->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
}
}
else {
throw(new Exception('This row doesn\'t exist!'));
}
}
catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
/**
* Remove the step supervisor registry
* @param string $sStepUID
* @return integer
**/
public function remove($sStepUID)
{
$oConnection = Propel::getConnection(StepSupervisorPeer::DATABASE_NAME);
try {
$oConnection->begin();
$this->setStepUid($sStepUID);
$iResult = $this->delete();
$oConnection->commit();
return $iResult;
}
catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
/**
* Get the next position for a atep
* @param string $sProcessUID
* @return integer
**/
function getNextPosition($sProcessUID, $sType) {
try {
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn('(COUNT(*) + 1) AS POSITION');
$oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
$oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, $sType);
$oDataset = StepSupervisorPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aRow = $oDataset->getRow();
return (int)$aRow['POSITION'];
}
catch (Exception $oException) {
throw $Exception;
}
}
/**
* Reorder the steps positions
* @param string $sProcessUID
* @param string $iPosition
**/
function reorderPositions($sProcessUID, $iPosition, $sType) {
try {
$oCriteria = new Criteria('workflow');
$oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
$oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, $sType);
$oCriteria->add(StepSupervisorPeer::STEP_POSITION, $iPosition, '>');
$oDataset = StepSupervisorPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();var_dump(StepSupervisorPeer::doCount($oCriteria));
while ($aRow = $oDataset->getRow()) {var_dump($aRow);echo "\n";
$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;
}
}
function removeByObject($sType, $sObjUid) {
try {
$oCriteria = new Criteria('workflow');
$oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, $sType);
$oCriteria->add(StepSupervisorPeer::STEP_UID_OBJ, $sObjUid);
StepSupervisorPeer::doDelete($oCriteria);
}
catch(Exception $e) {
throw($e);
}
}
function loadInfo($sObjUID){
$oCriteria = new Criteria('workflow');
$oCriteria->add(StepSupervisorPeer::STEP_UID_OBJ, $sObjUID);
$oDataset = StepSupervisorPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aRow = $oDataset->getRow();
return($aRow);
}
} // StepSupervisor
<?php
/**
* StepSupervisor.php
*
* @package workflow.engine.classes.model
*/
require_once 'classes/model/om/BaseStepSupervisor.php';
/**
* Skeleton subclass for representing a row from the 'STEP_SUPERVISOR' table.
*
*
*
* You should add additional methods to this class to meet the
* 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
*/
class StepSupervisor extends BaseStepSupervisor
{
public function load ($Uid)
{
try {
$oRow = StepSupervisorPeer::retrieveByPK( $Uid );
if (! is_null( $oRow )) {
$aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$this->setNew( false );
return $aFields;
} else {
throw (new Exception( "The row '$Uid' in table StepSupervisor doesn't exist!" ));
}
} catch (Exception $oError) {
throw ($oError);
}
}
public function Exists ($Uid)
{
try {
$oPro = StepSupervisorPeer::retrieveByPk( $Uid );
if (is_object( $oPro ) && get_class( $oPro ) == 'StepSupervisor') {
return true;
} else {
return false;
}
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Create the step supervisor registry
*
* @param array $aData
* @return boolean
*
*/
public function create ($aData)
{
$oConnection = Propel::getConnection( StepSupervisorPeer::DATABASE_NAME );
try {
if (isset( $aData['STEP_UID'] ) && $aData['STEP_UID'] == '') {
unset( $aData['STEP_UID'] );
}
if (! isset( $aData['STEP_UID'] )) {
$aData['STEP_UID'] = G::generateUniqueID();
}
$oStepSupervisor = new StepSupervisor();
$oStepSupervisor->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oStepSupervisor->validate()) {
$oConnection->begin();
$iResult = $oStepSupervisor->save();
$oConnection->commit();
return true;
} else {
$sMessage = '';
$aValidationFailures = $oStepSupervisor->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
/**
* Update the step supervisor registry
*
* @param array $aData
* @return integer
*
*/
public function update ($aData)
{
$oConnection = Propel::getConnection( StepSupervisorPeer::DATABASE_NAME );
try {
$oStepSupervisor = StepSupervisorPeer::retrieveByPK( $aData['STEP_UID'] );
if (! is_null( $oStepSupervisor )) {
$oStepSupervisor->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oStepSupervisor->validate()) {
$oConnection->begin();
$iResult = $oStepSupervisor->save();
$oConnection->commit();
return $iResult;
} else {
$sMessage = '';
$aValidationFailures = $oStepSupervisor->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
}
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
/**
* Remove the step supervisor registry
*
* @param string $sStepUID
* @return integer
*
*/
public function remove ($sStepUID)
{
$oConnection = Propel::getConnection( StepSupervisorPeer::DATABASE_NAME );
try {
$oConnection->begin();
$this->setStepUid( $sStepUID );
$iResult = $this->delete();
$oConnection->commit();
return $iResult;
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
/**
* Get the next position for a atep
*
* @param string $sProcessUID
* @return integer
*
*/
public function getNextPosition ($sProcessUID, $sType)
{
try {
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( '(COUNT(*) + 1) AS POSITION' );
$oCriteria->add( StepSupervisorPeer::PRO_UID, $sProcessUID );
$oCriteria->add( StepSupervisorPeer::STEP_TYPE_OBJ, $sType );
$oDataset = StepSupervisorPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
$aRow = $oDataset->getRow();
return (int) $aRow['POSITION'];
} catch (Exception $oException) {
throw $Exception;
}
}
/**
* Reorder the steps positions
*
* @param string $sProcessUID
* @param string $iPosition
*
*/
public function reorderPositions ($sProcessUID, $iPosition, $sType)
{
try {
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( StepSupervisorPeer::PRO_UID, $sProcessUID );
$oCriteria->add( StepSupervisorPeer::STEP_TYPE_OBJ, $sType );
$oCriteria->add( StepSupervisorPeer::STEP_POSITION, $iPosition, '>' );
$oDataset = StepSupervisorPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
var_dump( StepSupervisorPeer::doCount( $oCriteria ) );
while ($aRow = $oDataset->getRow()) {
var_dump( $aRow );
echo "\n";
$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;
}
}
public function removeByObject ($sType, $sObjUid)
{
try {
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( StepSupervisorPeer::STEP_TYPE_OBJ, $sType );
$oCriteria->add( StepSupervisorPeer::STEP_UID_OBJ, $sObjUid );
StepSupervisorPeer::doDelete( $oCriteria );
} catch (Exception $e) {
throw ($e);
}
}
public function loadInfo ($sObjUID)
{
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( StepSupervisorPeer::STEP_UID_OBJ, $sObjUID );
$oDataset = StepSupervisorPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
$aRow = $oDataset->getRow();
return ($aRow);
}
}
// StepSupervisor

View File

@@ -1,461 +1,455 @@
<?php
/**
* Translation.php
* @package workflow.engine.classes.model
*
* 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
* 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.
*
*/
require_once 'classes/model/om/BaseTranslation.php';
/**
* Skeleton subclass for representing a row from the 'TRANSLATION' table.
*
*
*
* You should add additional methods to this class to meet the
* 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
*/
class Translation extends BaseTranslation {
public static $meta;
public static $localeSeparator = '-';
private $envFilePath;
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
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(TranslationPeer::TRN_ID);
$oCriteria->addSelectColumn(TranslationPeer::TRN_CATEGORY);
$oCriteria->addSelectColumn(TranslationPeer::TRN_LANG);
$oCriteria->addSelectColumn(TranslationPeer::TRN_VALUE);
//$c->add(TranslationPeer::TRN_LANG, 'en');
return $oCriteria;
}
function getAll($lang='en', $start=null, $limit=null, $search=null, $dateFrom=null, $dateTo=null){
$totalCount = 0;
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(TranslationPeer::TRN_ID);
$oCriteria->addSelectColumn(TranslationPeer::TRN_CATEGORY);
$oCriteria->addSelectColumn(TranslationPeer::TRN_LANG);
$oCriteria->addSelectColumn(TranslationPeer::TRN_VALUE);
$oCriteria->addSelectColumn(TranslationPeer::TRN_UPDATE_DATE);
$oCriteria->add(TranslationPeer::TRN_LANG, $lang);
$oCriteria->add(TranslationPeer::TRN_CATEGORY, 'LABEL');
//$oCriteria->addAscendingOrderByColumn ( 'TRN_CATEGORY' );
$oCriteria->addAscendingOrderByColumn ( 'TRN_ID' );
if( $search ) {
$oCriteria->add(
$oCriteria->getNewCriterion(
TranslationPeer::TRN_ID,
"%$search%", Criteria::LIKE
)->addOr($oCriteria->getNewCriterion(
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
))
);
}
// end filter
$c = clone $oCriteria;
$c->clearSelectColumns();
$c->addSelectColumn('COUNT(*)');
$oDataset = TranslationPeer::doSelectRS($c);
$oDataset->next();
$aRow = $oDataset->getRow();
if( is_array($aRow) )
$totalCount = $aRow[0];
if($start)
$oCriteria->setOffset($start);
if($limit) //&& !isset($seach) && !isset($search))
$oCriteria->setLimit($limit);
$rs = TranslationPeer::doSelectRS($oCriteria);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rows = Array();
while( $rs->next() ) {
$rows[] = $rs->getRow();
}
$result->data = $rows;
$result->totalCount = $totalCount;
return $result;
}
/* Load strings from a Database .
<?php
/**
* Translation.php
*
* @package workflow.engine.classes.model
*
* 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
* 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.
*
*/
require_once 'classes/model/om/BaseTranslation.php';
/**
* Skeleton subclass for representing a row from the 'TRANSLATION' table.
*
*
*
* You should add additional methods to this class to meet the
* 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
*/
class Translation extends BaseTranslation
{
public static $meta;
public static $localeSeparator = '-';
private $envFilePath;
public function __construct ()
{
$this->envFilePath = PATH_DATA . "META-INF" . PATH_SEP . "translations.env";
}
public function getAllCriteria ()
{
//SELECT * from TRANSLATION WHERE TRN_LANG = 'en' order by TRN_CATEGORY, TRN_ID
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( TranslationPeer::TRN_ID );
$oCriteria->addSelectColumn( TranslationPeer::TRN_CATEGORY );
$oCriteria->addSelectColumn( TranslationPeer::TRN_LANG );
$oCriteria->addSelectColumn( TranslationPeer::TRN_VALUE );
//$c->add(TranslationPeer::TRN_LANG, 'en');
return $oCriteria;
}
public function getAll ($lang = 'en', $start = null, $limit = null, $search = null, $dateFrom = null, $dateTo = null)
{
$totalCount = 0;
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( TranslationPeer::TRN_ID );
$oCriteria->addSelectColumn( TranslationPeer::TRN_CATEGORY );
$oCriteria->addSelectColumn( TranslationPeer::TRN_LANG );
$oCriteria->addSelectColumn( TranslationPeer::TRN_VALUE );
$oCriteria->addSelectColumn( TranslationPeer::TRN_UPDATE_DATE );
$oCriteria->add( TranslationPeer::TRN_LANG, $lang );
$oCriteria->add( TranslationPeer::TRN_CATEGORY, 'LABEL' );
//$oCriteria->addAscendingOrderByColumn ( 'TRN_CATEGORY' );
$oCriteria->addAscendingOrderByColumn( 'TRN_ID' );
if ($search) {
$oCriteria->add( $oCriteria->getNewCriterion( TranslationPeer::TRN_ID, "%$search%", Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( 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
) );
}
// end filter
$c = clone $oCriteria;
$c->clearSelectColumns();
$c->addSelectColumn( 'COUNT(*)' );
$oDataset = TranslationPeer::doSelectRS( $c );
$oDataset->next();
$aRow = $oDataset->getRow();
if (is_array( $aRow )) {
$totalCount = $aRow[0];
}
if ($start) {
$oCriteria->setOffset( $start );
}
if ($limit) {
//&& !isset($seach) && !isset($search))
$oCriteria->setLimit( $limit );
}
$rs = TranslationPeer::doSelectRS( $oCriteria );
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rows = Array ();
while ($rs->next()) {
$rows[] = $rs->getRow();
}
$result->data = $rows;
$result->totalCount = $totalCount;
return $result;
}
/* Load strings from a Database .
* @author Fernando Ontiveros <fernando@colosa.com>
* @parameter $languageId (es|en|...).
*/
function generateFileTranslation ($languageId = '') {
$translation = Array();
$translationJS = Array();
if ($languageId === '')
$languageId = defined('SYS_LANG') ? SYS_LANG : 'en';
$c = new Criteria();
$c->add(TranslationPeer::TRN_LANG, $languageId );
$c->addAscendingOrderByColumn ( 'TRN_CATEGORY' );
$c->addAscendingOrderByColumn ( 'TRN_ID' );
$tranlations = TranslationPeer::doSelect($c);
$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' ) {
$translation[ $row->getTrnId() ] = $row->getTrnValue();
}
if ( $row->getTrnCategory() === 'JAVASCRIPT') {
$translationJS[ $row->getTrnId() ] = $row->getTrnValue();
}
}
try {
if( ! is_dir(dirname($cacheFile)) )
G::mk_dir(dirname($cacheFile));
if( ! is_dir(dirname($cacheFileJS)) )
G::mk_dir(dirname($cacheFileJS));
$f = fopen( $cacheFile , 'w+');
fwrite( $f , "<?php\n" );
fwrite( $f , '$translation =' . 'unserialize(\'' . addcslashes( serialize ( $translation ), '\\\'' ) . "');\n");
fwrite( $f , "?>" );
fclose( $f );
$json=new Services_JSON();
$f = fopen( $cacheFileJS , 'w');
fwrite( $f , "var G_STRINGS =". $json->encode( $translationJS ) . ";\n");
fclose( $f );
$res['cacheFile'] = $cacheFile;
$res['cacheFileJS'] = $cacheFileJS;
$res['rows'] = count ( $translation );
$res['rowsJS'] = count ( $translationJS );
return $res;
} catch( Exception $e ) {
echo $e->getMessage();
}
}
/**
* returns an array with
* codError 0 - no error, < 0 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.
$tr = TranslationPeer::retrieveByPK( $category, $id, $languageId );
if ( ! ( is_object ( $tr ) && get_class ($tr) == 'Translation' ) ) {
$tr = new Translation();
}
$tr->setTrnCategory( $category );
$tr->setTrnId( $id );
$tr->setTrnLang( $languageId);
$tr->setTrnValue( $value );
$tr->setTrnUpdateDate( date('Y-m-d') );
if ($tr->validate() ) {
// we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save();
}
else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $tr->getValidationFailures();
foreach($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "\n";
}
return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
}
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);
if ( ( is_object ( $oTranslation ) && get_class ($oTranslation) == 'Translation' ) ) {
$oTranslation->delete();
}
}
function addTranslationEnvironment($locale, $headers, $numRecords)
{
$filePath = $this->envFilePath;
$environments = Array();
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['NUM_RECORDS'] = $numRecords;
$environment['LANGUAGE'] = $headers['X-Poedit-Language'];
$environment['COUNTRY'] = $headers['X-Poedit-Country'];
if( strpos($locale, self::$localeSeparator) !== false ) {
list($environment['LAN_ID'], $environment['IC_UID']) = explode(self::$localeSeparator, strtoupper($locale));
$environments[$environment['LAN_ID']][$environment['IC_UID']] = $environment;
} else {
$environment['LAN_ID'] = strtoupper($locale);
$environment['IC_UID'] = '';
$environments[$locale]['__INTERNATIONAL__'] = $environment;
}
file_put_contents($filePath, serialize($environments));
}
function removeTranslationEnvironment($locale)
{
$filePath = $this->envFilePath;
if (strpos($locale, self::$localeSeparator) !== false) {
list($LAN_ID, $IC_UID) = explode('-', strtoupper($locale));
} else {
$LAN_ID = $locale;
$IC_UID = '__INTERNATIONAL__';
*/
public function generateFileTranslation ($languageId = '')
{
$translation = Array ();
$translationJS = Array ();
if ($languageId === '') {
$languageId = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
}
$c = new Criteria();
$c->add( TranslationPeer::TRN_LANG, $languageId );
$c->addAscendingOrderByColumn( 'TRN_CATEGORY' );
$c->addAscendingOrderByColumn( 'TRN_ID' );
$tranlations = TranslationPeer::doSelect( $c );
$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') {
$translation[$row->getTrnId()] = $row->getTrnValue();
}
if ($row->getTrnCategory() === 'JAVASCRIPT') {
$translationJS[$row->getTrnId()] = $row->getTrnValue();
}
}
try {
if (! is_dir( dirname( $cacheFile ) )) {
G::mk_dir( dirname( $cacheFile ) );
}
if (! is_dir( dirname( $cacheFileJS ) )) {
G::mk_dir( dirname( $cacheFileJS ) );
}
$f = fopen( $cacheFile, 'w+' );
fwrite( $f, "<?php\n" );
fwrite( $f, '$translation =' . 'unserialize(\'' . addcslashes( serialize( $translation ), '\\\'' ) . "');\n" );
fwrite( $f, "?>" );
fclose( $f );
$json = new Services_JSON();
$f = fopen( $cacheFileJS, 'w' );
fwrite( $f, "var G_STRINGS =" . $json->encode( $translationJS ) . ";\n" );
fclose( $f );
$res['cacheFile'] = $cacheFile;
$res['cacheFileJS'] = $cacheFileJS;
$res['rows'] = count( $translation );
$res['rowsJS'] = count( $translationJS );
return $res;
} catch (Exception $e) {
echo $e->getMessage();
}
}
/**
* returns an array with
* codError 0 - no error, < 0 error
* rowsAffected 0,1 the number of rows affected
* message message error.
*/
public function addTranslation ($category, $id, $languageId, $value)
{
//if exists the row in the database propel will update it, otherwise will insert.
$tr = TranslationPeer::retrieveByPK( $category, $id, $languageId );
if (! (is_object( $tr ) && get_class( $tr ) == 'Translation')) {
$tr = new Translation();
}
$tr->setTrnCategory( $category );
$tr->setTrnId( $id );
$tr->setTrnLang( $languageId );
$tr->setTrnValue( $value );
$tr->setTrnUpdateDate( date( 'Y-m-d' ) );
if ($tr->validate()) {
// we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save();
} else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $tr->getValidationFailures();
foreach ($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "\n";
}
return array ('codError' => - 100,'rowsAffected' => 0,'message' => $msg);
}
return array ('codError' => 0,'rowsAffected' => $res,'message' => '');
//to do: uniform coderror structures for all classes
}
public function remove ($sCategory, $sId, $sLang)
{
$oTranslation = TranslationPeer::retrieveByPK( $sCategory, $sId, $sLang );
if ((is_object( $oTranslation ) && get_class( $oTranslation ) == 'Translation')) {
$oTranslation->delete();
}
}
public function addTranslationEnvironment ($locale, $headers, $numRecords)
{
$filePath = $this->envFilePath;
$environments = Array ();
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['NUM_RECORDS'] = $numRecords;
$environment['LANGUAGE'] = $headers['X-Poedit-Language'];
$environment['COUNTRY'] = $headers['X-Poedit-Country'];
if (strpos( $locale, self::$localeSeparator ) !== false) {
list ($environment['LAN_ID'], $environment['IC_UID']) = explode( self::$localeSeparator, strtoupper( $locale ) );
$environments[$environment['LAN_ID']][$environment['IC_UID']] = $environment;
} else {
$environment['LAN_ID'] = strtoupper( $locale );
$environment['IC_UID'] = '';
$environments[$locale]['__INTERNATIONAL__'] = $environment;
}
file_put_contents( $filePath, serialize( $environments ) );
}
public function removeTranslationEnvironment ($locale)
{
$filePath = $this->envFilePath;
if (strpos( $locale, self::$localeSeparator ) !== false) {
list ($LAN_ID, $IC_UID) = explode( '-', strtoupper( $locale ) );
} else {
$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']);
}
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');
}
}
}
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);
file_put_contents($translationsPath . 'pmos-translations.meta', serialize($s));
*/
}
function getInfoFromPOFile($file){
G::loadClass('i18n_po');
$POFile = new i18n_PO($file);
$POFile->readInit();
$POHeaders = $POFile->getHeaders();
if( $POHeaders['X-Poedit-Country'] != '.' ) {
$country = self::getTranslationMetaByCountryName($POHeaders['X-Poedit-Country']);
} else {
$country = '.';
}
$language = self::getTranslationMetaByLanguageName($POHeaders['X-Poedit-Language']);
if( $language !== false ) {
if( $country !== false ) {
if( $country != '.') {
$LOCALE = $language['LAN_ID'] . '-' . $country['IC_UID'];
} else if( $country == '.' ) {
//this a trsnlation file with a language international, no country name was set
$LOCALE = $language['LAN_ID'];
} else
throw new Exception('PO File Error: "'.$file.'" has a invalid country definition!');
} else
throw new Exception('PO File Error: "'.$file.'" has a invalid country definition!');
} else
throw new Exception('PO File Error: "'.$file.'" has a invalid language definition!');
$countItems = 0;
try {
while( $rowTranslation = $POFile->getTranslation() ) {
$countItems++;
}
} catch(Exception $e) {
$countItems = '-';
}
return Array('LOCALE'=>$LOCALE, 'HEADERS'=>$POHeaders , 'COUNT'=>$countItems);
}
function getTranslationEnvironment($locale){
$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__';
}
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
$s = Array('ISO_COUNTRY'=>$r, 'LANGUAGE'=>$r2);
file_put_contents($translationsPath . 'pmos-translations.meta', serialize($s));
*/
}
public function getInfoFromPOFile ($file)
{
G::loadClass( 'i18n_po' );
$POFile = new i18n_PO( $file );
$POFile->readInit();
$POHeaders = $POFile->getHeaders();
if ($POHeaders['X-Poedit-Country'] != '.') {
$country = self::getTranslationMetaByCountryName( $POHeaders['X-Poedit-Country'] );
} else {
$country = '.';
}
$language = self::getTranslationMetaByLanguageName( $POHeaders['X-Poedit-Language'] );
if ($language !== false) {
if ($country !== false) {
if ($country != '.') {
$LOCALE = $language['LAN_ID'] . '-' . $country['IC_UID'];
} else if ($country == '.') {
//this a trsnlation file with a language international, no country name was set
$LOCALE = $language['LAN_ID'];
} else
throw new Exception( 'PO File Error: "' . $file . '" has a invalid country definition!' );
} else
throw new Exception( 'PO File Error: "' . $file . '" has a invalid country definition!' );
} else
throw new Exception( 'PO File Error: "' . $file . '" has a invalid language definition!' );
$countItems = 0;
try {
while ($rowTranslation = $POFile->getTranslation()) {
$countItems ++;
}
} catch (Exception $e) {
$countItems = '-';
}
return Array ('LOCALE' => $LOCALE,'HEADERS' => $POHeaders,'COUNT' => $countItems);
}
public function getTranslationEnvironment ($locale)
{
$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__';
}
if (isset( $environments[$LAN_ID][$IC_UID] )) {
return $environments[$LAN_ID][$IC_UID];
} else {
return false;
}
}
public 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 ) );
}
public function getTranslationMeta ()
{
$translationsPath = PATH_CORE . "content" . PATH_SEP . 'translations' . PATH_SEP;
$translationsTable = unserialize( file_get_contents( $translationsPath . 'pmos-translations.meta' ) );
return $translationsTable;
}
public function getTranslationMetaByCountryName ($IC_NAME)
{
$translationsTable = self::getTranslationMeta();
foreach ($translationsTable['ISO_COUNTRY'] as $row) {
if ($row['IC_NAME'] == $IC_NAME) {
return $row;
}
}
return false;
}
public 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
/**
* class.pmSugar.pmFunctions.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.
* *
*/
<?php
/**
* class.pmSugar.pmFunctions.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.
* *
*/
////////////////////////////////////////////////////
// pmSugar PM Functions
//
@@ -14,454 +15,482 @@
//
// License: LGPL, see LICENSE
////////////////////////////////////////////////////
function getSoapClientOptions() {
$options = array('trace' => 1);
//Apply proxy settings
$sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') {
$options['proxy_host'] = $sysConf['proxy_host'];
if ($sysConf['proxy_port'] != '') {
$options['proxy_port'] = $sysConf['proxy_port'];
}
if ($sysConf['proxy_user'] != '') {
$options['proxy_login'] = $sysConf['proxy_user'];
}
if ($sysConf['proxy_pass'] != '') {
$options['proxy_password'] = $sysConf['proxy_pass'];
}
}
return $options;
}
/**
* This collection of triggers allows to interact by getting and sending information to SugarCRM
* @class pmSugar
* @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' ) );
$login_results = $client->__SoapCall ( 'login', $auth_array );
$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;
}
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
* @label Get SugarCRM Entry
*
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl [^]
* @param string | $user | User
* @param string | $password | Password
* @param string | $module | The name of the module from which to retrieve records.
* @param string | $id | The SugarBeans ID.
* @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.
* @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() );
$request_array = array ('session' => $sessionId, 'module_name' => $module, 'id' => $id,
'select_fields' => $select_fields, 'link_name_to_fields_array' => $linkNameToFieldsArray);
$sugarEntry = $client->__SoapCall ( 'get_entry', $request_array );
if($resultType == 'array'){
$sugarEntry = objectToArray ( $sugarEntry );
}
return $sugarEntry;
}
/**
* @method
*
* Gets SugarCRM entries from the indicated module.
*
* @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 | $password | Password
* @param string | $module | Module
* @param string | $query | Query
* @param string | $orderBy | Order By
* @param string | $selectedFields | Selected Fields
* @param string | $maxResults=50 | Max Results
* @param string | $resultType=array | Result type (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 );
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId, 'module_name' => $module, 'query' => $query, 'order_by' => $orderBy, 'offset'=>"", 'select_fields'=>"", 'max_result'=>$maxResults );
$sugarEntriesO = $client->__SoapCall ( 'get_entry_list', $request_array );
switch($resultType){
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break;
case 'object':$sugarEntries = $sugarEntriesO; break;
default: $sugarEntries = objectToArray ( $sugarEntries );
}
return $sugarEntries;
}
/**
* @method
*
* Gets SugarCRM entries from the Calls module
*
* @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
* @param string | $query | Query
* @param string | $orderBy | Order By
* @param string | $selectedFields | Selected Fields
* @param string | $maxResults=50 | Max Results
* @param string | $resultType=array | Result type (array or object)
*
* @return array/object | $sugarCalls | Sugar Calls (array or object)
*
*/
function GetSugarCalls($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") {
$module="Calls";
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType);
}
/**
* @method
*
* Gets SugarCRM entries from the Leads module.
*
* @name GetSugarLeads
* @label Gets SugarCRM entries from the Leads module.
*
* @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
* @param string | $selectedFields | Selected Fields
* @param string | $maxResults=50 | Max Results
* @param string | $resultType=array | Result type (array or object)
*
* @return array/object | $sugarLeads | Sugar Leads (array or object)
*
*/
function GetSugarLeads($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") {
$module="Leads";
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType);
}
/**
* @method
*
* Gets SugarCRM entries from the Contacts module.
*
* @name GetSugarContacts
* @label Gets SugarCRM entries from the Contacts module.
*
* @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
* @param string | $selectedFields | Selected Fields
* @param string | $maxResults=50 | Max Results
* @param string | $resultType=array | Result type (array or object)
*
* @return array/object | $sugarContacts | Sugar Contacts (array or object)
*
*/
function GetSugarContacts($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") {
$module="Contacts";
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType);
}
/**
* @method
*
* Gets SugarCRM entries from the Opportunities module.
*
* @name GetSugarOpportunities
* @label Gets SugarCRM entries from the Opportunities module.
*
* @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
* @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)
*
*/
function GetSugarOpportunities($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") {
$module="Opportunities";
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType);
}
/**
* @method
*
* Gets SugarCRM entries from the Account module.
*
* @name GetSugarAccount
* @label Gets SugarCRM entries from the Account module.
*
* @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
* @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)
*
*/
function GetSugarAccount($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") {
$module="Accounts";
return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType);
}
/**
* @method
*
* Creates SugarCRM entries from the Account module.
*
* @name CreateSugarAccount
*
* @label Creates SugarCRM entries from the Account module.
*
* @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
* @param string | $resultType=array | Result type (array or object)
*
* @return array/object | $sugarAccount | Sugar Opportunities (array or object)
*
*/
function CreateSugarAccount($sugarSoap, $user, $password, $name, $resultType="array") {
$module = "Accounts";
$sessionId = sugarLogin ( $sugarSoap, $user, $password );
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId, 'module_name' => $module, 'name_value_list' => array(
array("name" => 'name', "value" => $name )
) );
$sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array );
$account_id = $sugarEntriesO ->id;
switch($resultType){
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO );break;
case 'object':$sugarEntries = $sugarEntries ;break;
default: $sugarEntries = objectToArray ( $sugarEntries );
}
//return $sugarEntries;
return $account_id;
}
/**
* @method
*
* Creates SugarCRM entries from the Account module
*
* @name CreateSugarContact
*
* @label Creates SugarCRM entries from the Account module
*
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
* @param string | $user | User
* @param string | $password | Password
* @param string | $first_name | First Name
* @param string | $last_name | Last Name
* @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(
function getSoapClientOptions ()
{
$options = array ('trace' => 1);
//Apply proxy settings
$sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') {
$options['proxy_host'] = $sysConf['proxy_host'];
if ($sysConf['proxy_port'] != '') {
$options['proxy_port'] = $sysConf['proxy_port'];
}
if ($sysConf['proxy_user'] != '') {
$options['proxy_login'] = $sysConf['proxy_user'];
}
if ($sysConf['proxy_pass'] != '') {
$options['proxy_password'] = $sysConf['proxy_pass'];
}
}
return $options;
}
/**
* This collection of triggers allows to interact by getting and sending information to SugarCRM
* @class pmSugar
*
* @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') );
$login_results = $client->__SoapCall( 'login', $auth_array );
$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;
}
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
* @label Get SugarCRM Entry
*
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl [^]
* @param string | $user | User
* @param string | $password | Password
* @param string | $module | The name of the module from which to retrieve records.
* @param string | $id | The SugarBeans ID.
* @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.
* @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() );
$request_array = array ('session' => $sessionId,'module_name' => $module,'id' => $id,'select_fields' => $select_fields,'link_name_to_fields_array' => $linkNameToFieldsArray);
$sugarEntry = $client->__SoapCall( 'get_entry', $request_array );
if ($resultType == 'array') {
$sugarEntry = objectToArray( $sugarEntry );
}
return $sugarEntry;
}
/**
*
* @method Gets SugarCRM entries from the indicated module.
*
* @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 | $password | Password
* @param string | $module | Module
* @param string | $query | Query
* @param string | $orderBy | Order By
* @param string | $selectedFields | Selected Fields
* @param string | $maxResults=50 | Max Results
* @param string | $resultType=array | Result type (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 );
$client = new SoapClient( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId,'module_name' => $module,'query' => $query,'order_by' => $orderBy,'offset' => "",'select_fields' => "",'max_result' => $maxResults);
$sugarEntriesO = $client->__SoapCall( 'get_entry_list', $request_array );
switch ($resultType) {
case 'array':
$sugarEntries = objectToArray( $sugarEntriesO );
break;
case 'object':
$sugarEntries = $sugarEntriesO;
break;
default:
$sugarEntries = objectToArray( $sugarEntries );
}
return $sugarEntries;
}
/**
*
* @method Gets SugarCRM entries from the Calls module
*
* @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
* @param string | $query | Query
* @param string | $orderBy | Order By
* @param string | $selectedFields | Selected Fields
* @param string | $maxResults=50 | Max Results
* @param string | $resultType=array | Result type (array or object)
*
* @return array/object | $sugarCalls | Sugar Calls (array or object)
*
*/
function GetSugarCalls ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
{
$module = "Calls";
return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
}
/**
*
* @method Gets SugarCRM entries from the Leads module.
*
* @name GetSugarLeads
* @label Gets SugarCRM entries from the Leads module.
*
* @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
* @param string | $selectedFields | Selected Fields
* @param string | $maxResults=50 | Max Results
* @param string | $resultType=array | Result type (array or object)
*
* @return array/object | $sugarLeads | Sugar Leads (array or object)
*
*/
function GetSugarLeads ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
{
$module = "Leads";
return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
}
/**
*
* @method Gets SugarCRM entries from the Contacts module.
*
* @name GetSugarContacts
* @label Gets SugarCRM entries from the Contacts module.
*
* @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
* @param string | $selectedFields | Selected Fields
* @param string | $maxResults=50 | Max Results
* @param string | $resultType=array | Result type (array or object)
*
* @return array/object | $sugarContacts | Sugar Contacts (array or object)
*
*/
function GetSugarContacts ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
{
$module = "Contacts";
return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
}
/**
*
* @method Gets SugarCRM entries from the Opportunities module.
*
* @name GetSugarOpportunities
* @label Gets SugarCRM entries from the Opportunities module.
*
* @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
* @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)
*
*/
function GetSugarOpportunities ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
{
$module = "Opportunities";
return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
}
/**
*
* @method Gets SugarCRM entries from the Account module.
*
* @name GetSugarAccount
* @label Gets SugarCRM entries from the Account module.
*
* @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
* @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)
*
*/
function GetSugarAccount ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array")
{
$module = "Accounts";
return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType );
}
/**
*
* @method Creates SugarCRM entries from the Account module.
*
* @name CreateSugarAccount
*
* @label Creates SugarCRM entries from the Account module.
*
* @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
* @param string | $resultType=array | Result type (array or object)
*
* @return array/object | $sugarAccount | Sugar Opportunities (array or object)
*
*/
function CreateSugarAccount ($sugarSoap, $user, $password, $name, $resultType = "array")
{
$module = "Accounts";
$sessionId = sugarLogin( $sugarSoap, $user, $password );
$client = new SoapClient( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId,'module_name' => $module,'name_value_list' => array (array ("name" => 'name',"value" => $name)));
$sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array );
$account_id = $sugarEntriesO->id;
switch ($resultType) {
case 'array':
$sugarEntries = objectToArray( $sugarEntriesO );
break;
case 'object':
$sugarEntries = $sugarEntries;
break;
default:
$sugarEntries = objectToArray( $sugarEntries );
}
//return $sugarEntries;
return $account_id;
}
/**
*
* @method Creates SugarCRM entries from the Account module
*
* @name CreateSugarContact
*
* @label Creates SugarCRM entries from the Account module
*
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
* @param string | $user | User
* @param string | $password | Password
* @param string | $first_name | First Name
* @param string | $last_name | Last Name
* @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" => 'first_name', "value" => $first_name),
array("name" => 'last_name', "value" => $last_name),
);
*/
$sessionId = sugarLogin ( $sugarSoap, $user, $password );
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId, 'module_name' => $module, array(
array("name" => 'first_name',"value" => $first_name),
array("name" => 'last_name',"value" => $last_name),
array("name" => 'email1',"value" => $email),
array("name" => 'title',"value" => $title),
array("name" => 'phone_work',"value" => $phone),
// array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e')
array("name" => 'account_id',"value" => $account_id)
));
$sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array );
switch($resultType){
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break;
case 'object':$sugarEntries = $sugarEntries; break;
default: $sugarEntries = objectToArray ( $sugarEntries );
}
return $sugarEntries;
}
/**
* @method
*
* Creates SugarCRM entries from the Opportunities module.
*
* @name CreateSugarOpportunity
* @label Creates SugarCRM entries from the Opportunities module.
*
* @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 | Name
* @param string | $account_id | Valid id account
* @param string | $amount | Amount
* @param string | $date_closed | Date Closed
* @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)
*
* @return array/object | $sugarOpportunity | Sugar Opportunities (array or object)
*
*/
function CreateSugarOpportunity($sugarSoap, $user, $password, $name,$account_id,$amount, $date_closed, $sales_stage,$resultType="array") {
// * @param string | $account_id | Account Id
$module = "Opportunities";
/* $aValue = array(
*/
$sessionId = sugarLogin( $sugarSoap, $user, $password );
$client = new SoapClient( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId,'module_name' => $module,array (array ("name" => 'first_name',"value" => $first_name
),array ("name" => 'last_name',"value" => $last_name
),array ("name" => 'email1',"value" => $email
),array ("name" => 'title',"value" => $title
),array ("name" => 'phone_work',"value" => $phone
),
// array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e')
array ("name" => 'account_id',"value" => $account_id
)));
$sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array );
switch ($resultType) {
case 'array':
$sugarEntries = objectToArray( $sugarEntriesO );
break;
case 'object':
$sugarEntries = $sugarEntries;
break;
default:
$sugarEntries = objectToArray( $sugarEntries );
}
return $sugarEntries;
}
/**
*
* @method Creates SugarCRM entries from the Opportunities module.
*
* @name CreateSugarOpportunity
*
* @label Creates SugarCRM entries from the Opportunities module.
*
* @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 | Name
* @param string | $account_id | Valid id account
* @param string | $amount | Amount
* @param string | $date_closed | Date Closed
* @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)
*
* @return array/object | $sugarOpportunity | Sugar Opportunities (array or object)
*
*/
function CreateSugarOpportunity ($sugarSoap, $user, $password, $name, $account_id, $amount, $date_closed, $sales_stage, $resultType = "array")
{
// * @param string | $account_id | Account Id
$module = "Opportunities";
/* $aValue = array(
array("name" => 'id', "value" => G::generateUniqueID()),
array("name" => 'name', "value" => $name),
array("name" => 'account_name', "value" => $account_name),
array("name" => 'amount', "value" => $amount),
array("name" => 'date_closed', "value" => $date_closed),
array("name" => 'sales_stage', "value" => $sales_stage)
);*/
$sessionId = sugarLogin ( $sugarSoap, $user, $password );
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId, 'module_name' => $module, 'name_value_list' =>array(
array('name' => 'name','value' => $name),
array("name" => 'account_id',"value" => $account_id),
array('name' => 'amount','value' => $amount),
array('name' => 'date_closed','value' => $date_closed),
array('name' => 'sales_stage','value' => $sales_stage),
));
$sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array );
switch($resultType){
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break;
case 'object':$sugarEntries = $sugarEntries; break;
default: $sugarEntries = objectToArray ( $sugarEntries );
}
return $sugarEntries;
}
/**
* @method
*
* Creates SugarCRM entries from the Account module
*
* @name CreateSugarLeads
*
* @label Creates SugarCRM entries from the Account module
*
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
* @param string | $user | User
* @param string | $password | Password
* @param string | $first_name | First Name
* @param string | $last_name | Last Name
* @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 CreateSugarLeads($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType="array") {
$module = "Leads";
$sessionId = sugarLogin ( $sugarSoap, $user, $password );
$client = new SoapClient ( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId, 'module_name' => $module, array(
array("name" => 'first_name',"value" => $first_name),
array("name" => 'last_name',"value" => $last_name),
array("name" => 'email1',"value" => $email),
array("name" => 'title',"value" => $title),
array("name" => 'phone_work',"value" => $phone),
// array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e')
array("name" => 'account_id',"value" => $account_id)
));
$sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array );
switch($resultType){
case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break;
case 'object':$sugarEntries = $sugarEntries; break;
default: $sugarEntries = objectToArray ( $sugarEntries );
}
return $sugarEntries;
}
);*/
$sessionId = sugarLogin( $sugarSoap, $user, $password );
$client = new SoapClient( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId,'module_name' => $module,'name_value_list' => array (array ('name' => 'name','value' => $name
),array ("name" => 'account_id',"value" => $account_id
),array ('name' => 'amount','value' => $amount
),array ('name' => 'date_closed','value' => $date_closed
),array ('name' => 'sales_stage','value' => $sales_stage
)
)
);
$sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array );
switch ($resultType) {
case 'array':
$sugarEntries = objectToArray( $sugarEntriesO );
break;
case 'object':
$sugarEntries = $sugarEntries;
break;
default:
$sugarEntries = objectToArray( $sugarEntries );
}
return $sugarEntries;
}
/**
*
* @method Creates SugarCRM entries from the Account module
*
* @name CreateSugarLeads
*
* @label Creates SugarCRM entries from the Account module
*
* @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl
* @param string | $user | User
* @param string | $password | Password
* @param string | $first_name | First Name
* @param string | $last_name | Last Name
* @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 CreateSugarLeads ($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType = "array")
{
$module = "Leads";
$sessionId = sugarLogin( $sugarSoap, $user, $password );
$client = new SoapClient( $sugarSoap, getSoapClientOptions() );
$request_array = array ('session' => $sessionId,'module_name' => $module,array (array ("name" => 'first_name',"value" => $first_name
),array ("name" => 'last_name',"value" => $last_name
),array ("name" => 'email1',"value" => $email
),array ("name" => 'title',"value" => $title
),array ("name" => 'phone_work',"value" => $phone
),
// array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e')
array ("name" => 'account_id',"value" => $account_id
)
)
);
$sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array );
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
/**
* cases_CatchExecute.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.
*/
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
if (isset( $_POST['form']['BTN_CANCEL'] )) {
header( "Location: ../cases/main" );
die();
}
/* Includes */
G::LoadClass( 'case' );
$oCase = new Cases();
$sAppUid = $_SESSION['APPLICATION'];
$iDelIndex = $_SESSION['INDEX'];
$oAppDelegation = new AppDelegation();
$aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex );
<?php
/**
* cases_CatchExecute.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.
*/
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
if (isset( $_POST['form']['BTN_CANCEL'] )) {
header( "Location: ../cases/main" );
die();
}
/* Includes */
G::LoadClass( 'case' );
$oCase = new Cases();
$sAppUid = $_SESSION['APPLICATION'];
$iDelIndex = $_SESSION['INDEX'];
$oAppDelegation = new AppDelegation();
$aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex );
//if there are no user in the delegation row, this case is still in selfservice
if ($aDelegation['USR_UID'] == "") {
$oCase->setCatchUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'] );
} else {
G::SendMessageText( G::LoadTranslation( 'ID_CASE_ALREADY_DERIVATED' ), 'error' );
}
$validation = (SYS_SKIN != 'uxs') ? 'true' : 'false';
if ($aDelegation['USR_UID'] == "") {
$oCase->setCatchUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'] );
} else {
G::SendMessageText( G::LoadTranslation( 'ID_CASE_ALREADY_DERIVATED' ), 'error' );
}
$validation = (SYS_SKIN != 'uxs') ? 'true' : 'false';
die( '<script type="text/javascript">
if (' . $validation . ') {
if (window.parent.frames.length != 0) {
@@ -70,5 +70,5 @@ die( '<script type="text/javascript">
} else {
window.location = "../cases/cases_Open?APP_UID=' . $_SESSION['APPLICATION'] . '&DEL_INDEX=' . $_SESSION['INDEX'] . '&action=unassigned";
}
</script>' );
</script>' );

View File

@@ -1,90 +1,90 @@
<?php
/**
* cases_Resume.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.
*/
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
/* Includes */
G::LoadClass( 'case' );
$oCase = new Cases();
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] );
/* Render page */
require_once 'classes/model/Process.php';
require_once 'classes/model/Task.php';
$objProc = new Process();
$aProc = $objProc->load( $Fields['PRO_UID'] );
$Fields['PRO_TITLE'] = $aProc['PRO_TITLE'];
$objTask = new Task();
$aTask = $objTask->load( $Fields['TAS_UID'] );
$Fields['TAS_TITLE'] = $aTask['TAS_TITLE'];
$Fields['STATUS'] .= ' ( ' . G::LoadTranslation( 'ID_UNASSIGNED' ) . ' )';
<?php
/**
* cases_Resume.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.
*/
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
/* Includes */
G::LoadClass( 'case' );
$oCase = new Cases();
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] );
/* Render page */
require_once 'classes/model/Process.php';
require_once 'classes/model/Task.php';
$objProc = new Process();
$aProc = $objProc->load( $Fields['PRO_UID'] );
$Fields['PRO_TITLE'] = $aProc['PRO_TITLE'];
$objTask = new Task();
$aTask = $objTask->load( $Fields['TAS_UID'] );
$Fields['TAS_TITLE'] = $aTask['TAS_TITLE'];
$Fields['STATUS'] .= ' ( ' . G::LoadTranslation( 'ID_UNASSIGNED' ) . ' )';
//now getting information about the PREVIOUS task. If is the first task then no preious, use 1
$oAppDel = new AppDelegation();
$oAppDel->Load( $Fields['APP_UID'], ($Fields['DEL_PREVIOUS'] == 0 ? $Fields['DEL_PREVIOUS'] = 1 : $Fields['DEL_PREVIOUS']) );
$aAppDel = $oAppDel->toArray( BasePeer::TYPE_FIELDNAME );
try {
$oCurUser = new Users();
$oCurUser->load( $aAppDel['USR_UID'] );
$Fields['PREVIOUS_USER'] = $oCurUser->getUsrFirstname() . ' ' . $oCurUser->getUsrLastname();
} catch (Exception $oError) {
$Fields['PREVIOUS_USER'] = '';
}
$objTask = new Task();
$aTask = $objTask->load( $aAppDel['TAS_UID'] );
$Fields['PREVIOUS_TASK'] = $aTask['TAS_TITLE'];
$oAppDel = new AppDelegation();
$oAppDel->Load( $Fields['APP_UID'], ($Fields['DEL_PREVIOUS'] == 0 ? $Fields['DEL_PREVIOUS'] = 1 : $Fields['DEL_PREVIOUS']) );
$aAppDel = $oAppDel->toArray( BasePeer::TYPE_FIELDNAME );
try {
$oCurUser = new Users();
$oCurUser->load( $aAppDel['USR_UID'] );
$Fields['PREVIOUS_USER'] = $oCurUser->getUsrFirstname() . ' ' . $oCurUser->getUsrLastname();
} catch (Exception $oError) {
$Fields['PREVIOUS_USER'] = '';
}
$objTask = new Task();
$aTask = $objTask->load( $aAppDel['TAS_UID'] );
$Fields['PREVIOUS_TASK'] = $aTask['TAS_TITLE'];
//To enable information (dynaforms, steps) before claim a case
$_SESSION['bNoShowSteps'] = true;
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'caseOptions';
$G_ID_MENU_SELECTED = 'CASES';
$G_ID_SUB_MENU_SELECTED = '_';
$oHeadPublisher = & headPublisher::getSingleton();
$_SESSION['bNoShowSteps'] = true;
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'caseOptions';
$G_ID_MENU_SELECTED = 'CASES';
$G_ID_SUB_MENU_SELECTED = '_';
$oHeadPublisher = & headPublisher::getSingleton();
$oHeadPublisher->addScriptCode( "
if (typeof parent != 'undefined') {
if (parent.showCaseNavigatorPanel) {
parent.showCaseNavigatorPanel('{$Fields['APP_STATUS']}');
}
}" );
}" );
$oHeadPublisher->addScriptCode( '
var Cse = {};
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("processmap",{Type:"file",Absolute:true,Path:"/jscore/processmap/core/processmap.js"});
leimnud.exec(leimnud.fix.memoryLeak);
' );
$oHeadPublisher = & headPublisher::getSingleton();
$oHeadPublisher->addScriptFile( '/jscore/cases/core/cases_Step.js' );
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_CatchSelfService.xml', '', $Fields, 'cases_CatchExecute' );
G::RenderPage( 'publish', 'blank' );
' );
$oHeadPublisher = & headPublisher::getSingleton();
$oHeadPublisher->addScriptFile( '/jscore/cases/core/cases_Step.js' );
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_CatchSelfService.xml', '', $Fields, 'cases_CatchExecute' );
G::RenderPage( 'publish', 'blank' );

View File

@@ -1,57 +1,59 @@
<?php
/**
* cases_Delete.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.
*/
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
/* Includes */
G::LoadClass( 'case' );
/* Process the info */
try {
$oCase = new Cases();
if (isset( $_POST['APP_UIDS'] )) {
$ids = explode( ',', $_POST['APP_UIDS'] );
foreach ($ids as $id)
$oCase->removeCase( $id );
if (count( $_POST['APP_UIDS'] ) > 1)
echo 'The Case was deleted successfully';
else
echo 'All Cases were deleted successfully';
}
} catch (Exception $e) {
echo $e->getMessage();
<?php
/**
* cases_Delete.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.
*/
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
/* Includes */
G::LoadClass( 'case' );
/* Process the info */
try {
$oCase = new Cases();
if (isset( $_POST['APP_UIDS'] )) {
$ids = explode( ',', $_POST['APP_UIDS'] );
foreach ($ids as $id) {
$oCase->removeCase( $id );
}
if (count( $_POST['APP_UIDS'] ) > 1) {
echo 'The Case was deleted successfully';
} else {
echo 'All Cases were deleted successfully';
}
}
} catch (Exception $e) {
echo $e->getMessage();
}

View File

@@ -1,59 +1,59 @@
<?php
/**
* cases_DeleteDocument.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.
*/
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
/* Includes */
require_once ("classes/model/AppDocumentPeer.php");
G::LoadClass( 'case' );
<?php
/**
* cases_DeleteDocument.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.
*/
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
/* Includes */
require_once ("classes/model/AppDocumentPeer.php");
G::LoadClass( 'case' );
/* GET , POST & $_SESSION Vars */
/* Process the info */
$oAppDocument = new AppDocument();
$oAppDocument->remove( $_GET['DOC'] );
$oCase = new Cases();
$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List' );
if ($_GET['TYPE'] == 'INPUT') {
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] - 1 );
}
if ($_GET['TYPE'] == 'OUTPUT') {
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
}
$_SESSION['STEP_POSITION'] = $aNextStep['POSITION'];
/* Redirect */
G::header( 'location: ' . $aNextStep['PAGE'] );
$oAppDocument = new AppDocument();
$oAppDocument->remove( $_GET['DOC'] );
$oCase = new Cases();
$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List' );
if ($_GET['TYPE'] == 'INPUT') {
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] - 1 );
}
if ($_GET['TYPE'] == 'OUTPUT') {
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
}
$_SESSION['STEP_POSITION'] = $aNextStep['POSITION'];
/* Redirect */
G::header( 'location: ' . $aNextStep['PAGE'] );

View File

@@ -1,50 +1,50 @@
<?php
/**
* cases_DeleteDocumentToRevise.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.
*/
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
/* Includes */
require_once ("classes/model/AppDocumentPeer.php");
G::LoadClass( 'case' );
<?php
/**
* cases_DeleteDocumentToRevise.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.
*/
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
/* Includes */
require_once ("classes/model/AppDocumentPeer.php");
G::LoadClass( 'case' );
/* GET , POST & $_SESSION Vars */
/* Process the info */
$oAppDocument = new AppDocument();
$oAppDocument->remove( $_GET['DOC'] );
/* Redirect */
G::header( 'location: ' . $_SERVER['HTTP_REFERER'] );
$oAppDocument = new AppDocument();
$oAppDocument->remove( $_GET['DOC'] );
/* Redirect */
G::header( 'location: ' . $_SERVER['HTTP_REFERER'] );

View File

@@ -1,185 +1,185 @@
<?php
/**
* cases_Derivate.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.
*/
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
/* Includes */
G::LoadClass( 'pmScript' );
G::LoadClass( 'case' );
G::LoadClass( 'derivation' );
require_once 'classes/model/Event.php';
<?php
/**
* cases_Derivate.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.
*/
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
/* Includes */
G::LoadClass( 'pmScript' );
G::LoadClass( 'case' );
G::LoadClass( 'derivation' );
require_once 'classes/model/Event.php';
/* GET , POST & $_SESSION Vars */
/* Process the info */
$sStatus = 'TO_DO';
foreach ($_POST['form']['TASKS'] as $aValues) {
}
try {
$sStatus = 'TO_DO';
foreach ($_POST['form']['TASKS'] as $aValues) {
}
try {
//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.
//$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List');
$appFields = $oCase->loadCase( $_SESSION['APPLICATION'] );
$appFields['APP_DATA'] = array_merge( $appFields['APP_DATA'], G::getSystemConstants() );
$appFields = $oCase->loadCase( $_SESSION['APPLICATION'] );
$appFields['APP_DATA'] = array_merge( $appFields['APP_DATA'], G::getSystemConstants() );
//cleaning debug variables
$_SESSION['TRIGGER_DEBUG']['DATA'] = Array ();
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = Array ();
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = Array ();
$triggers = $oCase->loadTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'BEFORE' );
$_SESSION['TRIGGER_DEBUG']['DATA'] = Array ();
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = Array ();
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = Array ();
$triggers = $oCase->loadTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'BEFORE' );
//if there are some triggers to execute
if (sizeof( $triggers ) > 0) {
if (sizeof( $triggers ) > 0) {
//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
$_SESSION['TRIGGER_DEBUG']['info'][0]['NUM_TRIGGERS'] = sizeof( $triggers );
$_SESSION['TRIGGER_DEBUG']['info'][0]['TIME'] = 'BEFORE';
$_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers );
$_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_VALUES'] = $triggers;
}
$appFields['DEL_INDEX'] = $_SESSION['INDEX'];
$appFields['TAS_UID'] = $_SESSION['TASK'];
$_SESSION['TRIGGER_DEBUG']['info'][0]['NUM_TRIGGERS'] = sizeof( $triggers );
$_SESSION['TRIGGER_DEBUG']['info'][0]['TIME'] = 'BEFORE';
$_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers );
$_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_VALUES'] = $triggers;
}
$appFields['DEL_INDEX'] = $_SESSION['INDEX'];
$appFields['TAS_UID'] = $_SESSION['TASK'];
$oCase->updateCase( $_SESSION['APPLICATION'], $appFields ); //Save data
//derivate case
$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']
);
$oDerivation->derivate( $aCurrentDerivation, $_POST['form']['TASKS'] );
$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']
);
$oDerivation->derivate( $aCurrentDerivation, $_POST['form']['TASKS'] );
$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
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
$_SESSION['TRIGGER_DEBUG']['info'][1]['NUM_TRIGGERS'] = sizeof( $triggers );
$_SESSION['TRIGGER_DEBUG']['info'][1]['TIME'] = 'AFTER';
$_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers );
$_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_VALUES'] = $triggers;
}
$oCase->updateCase( $_SESSION['APPLICATION'], $appFields );
$_SESSION['TRIGGER_DEBUG']['info'][1]['NUM_TRIGGERS'] = sizeof( $triggers );
$_SESSION['TRIGGER_DEBUG']['info'][1]['TIME'] = 'AFTER';
$_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers );
$_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_VALUES'] = $triggers;
}
$oCase->updateCase( $_SESSION['APPLICATION'], $appFields );
// Send notifications - Start
$oUser = new Users();
$aUser = $oUser->load( $_SESSION['USER_LOGGED'] );
if (trim( $aUser['USR_EMAIL'] ) == '') {
$aUser['USR_EMAIL'] = 'info@' . $_SERVER['HTTP_HOST'];
}
$sFromName = '"' . $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . '" <' . $aUser['USR_EMAIL'] . '>';
try {
$oCase->sendNotifications( $_SESSION['TASK'], $_POST['form']['TASKS'], $appFields['APP_DATA'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $sFromName );
} catch (Exception $e) {
G::SendTemporalMessage( G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . ' - ' . $e->getMessage(), 'warning', 'string', null, '100%' );
}
$oUser = new Users();
$aUser = $oUser->load( $_SESSION['USER_LOGGED'] );
if (trim( $aUser['USR_EMAIL'] ) == '') {
$aUser['USR_EMAIL'] = 'info@' . $_SERVER['HTTP_HOST'];
}
$sFromName = '"' . $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . '" <' . $aUser['USR_EMAIL'] . '>';
try {
$oCase->sendNotifications( $_SESSION['TASK'], $_POST['form']['TASKS'], $appFields['APP_DATA'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $sFromName );
} catch (Exception $e) {
G::SendTemporalMessage( G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . ' - ' . $e->getMessage(), 'warning', 'string', null, '100%' );
}
// Send notifications - End
// Events - Start
$oEvent = new Event();
$oEvent->closeAppEvents( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['TASK'] );
$oCurrentAppDel = AppDelegationPeer::retrieveByPk( $_SESSION['APPLICATION'], $_SESSION['INDEX'] + 1 );
$multipleDelegation = false;
$oEvent = new Event();
$oEvent->closeAppEvents( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['TASK'] );
$oCurrentAppDel = AppDelegationPeer::retrieveByPk( $_SESSION['APPLICATION'], $_SESSION['INDEX'] + 1 );
$multipleDelegation = false;
// check if there are multiple derivations
if (count( $_POST['form']['TASKS'] ) > 1) {
$multipleDelegation = true;
}
if (count( $_POST['form']['TASKS'] ) > 1) {
$multipleDelegation = true;
}
// 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 (! $multipleDelegation) {
$aCurrentAppDel = $oCurrentAppDel->toArray( BasePeer::TYPE_FIELDNAME );
$oEvent->createAppEvents( $aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'], $aCurrentAppDel['DEL_INDEX'], $aCurrentAppDel['TAS_UID'] );
} else {
if (! $multipleDelegation) {
$aCurrentAppDel = $oCurrentAppDel->toArray( BasePeer::TYPE_FIELDNAME );
$oEvent->createAppEvents( $aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'], $aCurrentAppDel['DEL_INDEX'], $aCurrentAppDel['TAS_UID'] );
} else {
// else we need to check every task and create the events if it have any
foreach ($_POST['form']['TASKS'] as $taskDelegated) {
$aCurrentAppDel = $oCurrentAppDel->toArray( BasePeer::TYPE_FIELDNAME );
$oEvent->createAppEvents( $aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'], $aCurrentAppDel['DEL_INDEX'], $taskDelegated['TAS_UID'] );
}
}
}
foreach ($_POST['form']['TASKS'] as $taskDelegated) {
$aCurrentAppDel = $oCurrentAppDel->toArray( BasePeer::TYPE_FIELDNAME );
$oEvent->createAppEvents( $aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'], $aCurrentAppDel['DEL_INDEX'], $taskDelegated['TAS_UID'] );
}
}
}
//Events - End
$debuggerAvailable = true;
if (isset( $_SESSION['user_experience'] )) {
$aNextStep['PAGE'] = 'casesListExtJsRedirector?ux=' . $_SESSION['user_experience'];
$debuggerAvailable = false;
} else {
$aNextStep['PAGE'] = 'casesListExtJsRedirector';
}
if (isset( $_SESSION['PMDEBUGGER'] ) && $_SESSION['PMDEBUGGER'] && $debuggerAvailable) {
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
$loc = 'cases_Step?' . 'breakpoint=triggerdebug';
} else {
$loc = $aNextStep['PAGE'];
}
$debuggerAvailable = true;
if (isset( $_SESSION['user_experience'] )) {
$aNextStep['PAGE'] = 'casesListExtJsRedirector?ux=' . $_SESSION['user_experience'];
$debuggerAvailable = false;
} else {
$aNextStep['PAGE'] = 'casesListExtJsRedirector';
}
if (isset( $_SESSION['PMDEBUGGER'] ) && $_SESSION['PMDEBUGGER'] && $debuggerAvailable) {
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
$loc = 'cases_Step?' . 'breakpoint=triggerdebug';
} else {
$loc = $aNextStep['PAGE'];
}
//Triggers After
if (isset( $_SESSION['TRIGGER_DEBUG']['ISSET'] )) {
if ($_SESSION['TRIGGER_DEBUG']['ISSET'] == 1) {
$oTemplatePower = new TemplatePower( PATH_TPL . 'cases/cases_Step.html' );
$oTemplatePower->prepare();
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower );
$_POST['NextStep'] = $loc;
$G_PUBLISH->AddContent( 'view', 'cases/showDebugFrameLoader' );
$G_PUBLISH->AddContent( 'view', 'cases/showDebugFrameBreaker' );
$_SESSION['TRIGGER_DEBUG']['ISSET'] == 0;
G::RenderPage( 'publish', 'blank' );
exit();
} else {
unset( $_SESSION['TRIGGER_DEBUG'] );
}
}
G::header( "location: $loc" );
} catch (Exception $e) {
$aMessage = array ();
$aMessage['MESSAGE'] = $e->getMessage() . '<br>' . $e->getTraceAsString();
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage( 'publish', 'blank' );
}
if (isset( $_SESSION['TRIGGER_DEBUG']['ISSET'] )) {
if ($_SESSION['TRIGGER_DEBUG']['ISSET'] == 1) {
$oTemplatePower = new TemplatePower( PATH_TPL . 'cases/cases_Step.html' );
$oTemplatePower->prepare();
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower );
$_POST['NextStep'] = $loc;
$G_PUBLISH->AddContent( 'view', 'cases/showDebugFrameLoader' );
$G_PUBLISH->AddContent( 'view', 'cases/showDebugFrameBreaker' );
$_SESSION['TRIGGER_DEBUG']['ISSET'] == 0;
G::RenderPage( 'publish', 'blank' );
exit();
} else {
unset( $_SESSION['TRIGGER_DEBUG'] );
}
}
G::header( "location: $loc" );
} catch (Exception $e) {
$aMessage = array ();
$aMessage['MESSAGE'] = $e->getMessage() . '<br>' . $e->getTraceAsString();
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage( 'publish', 'blank' );
}

View File

@@ -1,111 +1,113 @@
<?php
/**
* cases_List.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.
*/
/**
* Cases list (Refactored)
* By Erik A.
* O. <erik@colosa.com, aortiz.erik@gmail.com>
*/
/* Permissions */
if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1)
return $RBAC_Response;
/* Includes */
G::LoadClass( 'case' );
G::LoadClass( 'configuration' );
<?php
/**
* cases_List.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.
*/
/**
* Cases list (Refactored)
* By Erik A.
* O. <erik@colosa.com, aortiz.erik@gmail.com>
*/
/* Permissions */
if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1) {
return $RBAC_Response;
}
/* Includes */
G::LoadClass( 'case' );
G::LoadClass( 'configuration' );
// $_GET['l'] has the type of cases list like todo,pause,cancel, all
$conf = new Configurations();
if (! isset( $_GET['l'] )) {
$confCasesList = $conf->loadObject( 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' );
if (is_array( $confCasesList )) {
$sTypeList = $confCasesList['sTypeList'];
} else {
$sTypeList = 'to_do';
}
} else {
$sTypeList = $_GET['l'];
$confCasesList = array ('sTypeList' => $sTypeList
);
$conf->saveObject( $confCasesList, 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' );
}
$sUIDUserLogged = $_SESSION['USER_LOGGED'];
$_SESSION['CASES_MENU_OPTION'] = $sTypeList;
$oCases = new Cases();
/**
* 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') {
$oCases->ThrowUnpauseDaemon( date( 'Y-m-d' ) );
}
$conf = new Configurations();
if (! isset( $_GET['l'] )) {
$confCasesList = $conf->loadObject( 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' );
if (is_array( $confCasesList )) {
$sTypeList = $confCasesList['sTypeList'];
} else {
$sTypeList = 'to_do';
}
} else {
$sTypeList = $_GET['l'];
$confCasesList = array ('sTypeList' => $sTypeList
);
$conf->saveObject( $confCasesList, 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' );
}
$sUIDUserLogged = $_SESSION['USER_LOGGED'];
$_SESSION['CASES_MENU_OPTION'] = $sTypeList;
$oCases = new Cases();
/**
* 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') {
$oCases->ThrowUnpauseDaemon( date( 'Y-m-d' ) );
}
/* *
* Prepare the addtional filters before to show
* By Erik
*/
$aAdditionalFilter = Array ();
if (isset( $_GET['PROCESS_UID'] ) and $_GET['PROCESS_UID'] != "0" && $_GET['PROCESS_UID'] != "") {
$PRO_UID = $_GET['PROCESS_UID'];
$aAdditionalFilter['PRO_UID'] = $PRO_UID;
} else {
$PRO_UID = "0";
}
if (isset( $_GET['READ'] ) and $_GET['READ'] == "1") {
$aAdditionalFilter['READ'] = $_GET['READ'];
}
if (isset( $_GET['UNREAD'] ) and $_GET['UNREAD'] == "1") {
$aAdditionalFilter['UNREAD'] = $_GET['UNREAD'];
}
if (isset( $_GET['APP_STATUS_FILTER'] ) and $_GET['APP_STATUS_FILTER'] != "ALL") {
$aAdditionalFilter['APP_STATUS_FILTER'] = $_GET['APP_STATUS_FILTER'];
}
if (isset( $_GET['MINE'] ) and $_GET['MINE'] == "1") {
$aAdditionalFilter['MINE'] = $_GET['MINE'];
}
switch ($sTypeList) {
case 'to_do':
if (defined( 'ENABLE_CASE_LIST_OPTIMIZATION' )) {
$aCriteria = $oCases->prepareCriteriaForToDo( $sUIDUserLogged );
$xmlfile = 'cases/cases_ListTodoNew';
} else
list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter );
break;
default:
list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter );
}
*/
$aAdditionalFilter = Array ();
if (isset( $_GET['PROCESS_UID'] ) and $_GET['PROCESS_UID'] != "0" && $_GET['PROCESS_UID'] != "") {
$PRO_UID = $_GET['PROCESS_UID'];
$aAdditionalFilter['PRO_UID'] = $PRO_UID;
} else {
$PRO_UID = "0";
}
if (isset( $_GET['READ'] ) and $_GET['READ'] == "1") {
$aAdditionalFilter['READ'] = $_GET['READ'];
}
if (isset( $_GET['UNREAD'] ) and $_GET['UNREAD'] == "1") {
$aAdditionalFilter['UNREAD'] = $_GET['UNREAD'];
}
if (isset( $_GET['APP_STATUS_FILTER'] ) and $_GET['APP_STATUS_FILTER'] != "ALL") {
$aAdditionalFilter['APP_STATUS_FILTER'] = $_GET['APP_STATUS_FILTER'];
}
if (isset( $_GET['MINE'] ) and $_GET['MINE'] == "1") {
$aAdditionalFilter['MINE'] = $_GET['MINE'];
}
switch ($sTypeList) {
case 'to_do':
if (defined( 'ENABLE_CASE_LIST_OPTIMIZATION' )) {
$aCriteria = $oCases->prepareCriteriaForToDo( $sUIDUserLogged );
$xmlfile = 'cases/cases_ListTodoNew';
} else {
list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter );
}
break;
default:
list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter );
}
/*
$rs = ApplicationPeer::doSelectRS($aCriteria);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
@@ -118,52 +120,52 @@ $rs = ApplicationPeer::doSelectRS($aCriteria);
g::pr($aRows1);die;*/
/* GET , POST & $_SESSION Vars */
if (! isset( $_GET['PROCESS_UID'] )) {
$oCase = new Cases();
$rs = ApplicationPeer::doSelectRS( $aCriteria );
$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;
}
?>
if (! isset( $_GET['PROCESS_UID'] )) {
$oCase = new Cases();
$rs = ApplicationPeer::doSelectRS( $aCriteria );
$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;
}
?>
<script>
try{
oPropelTable = document.getElementById('publisherContent[0]');
@@ -175,5 +177,6 @@ function InAssocArray ($a, $k, $v)
parent.PANEL_EAST_OPEN = false;
if(parent.refreshCountFolders) parent.refreshCountFolders();
}catch(e){}
</script>
</script>
<?php

View File

@@ -1,162 +1,166 @@
<?php
/**
* cases_New.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.
*/
<?php
/**
* cases_New.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.
*/
//we're looking for the type of view
function putTypeView ()
{
require_once 'classes/model/Configuration.php';
$oConfiguration = new Configuration();
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' );
$oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] );
if (ConfigurationPeer::doCount( $oCriteria )) {
$conf = ConfigurationPeer::doSelect( $oCriteria );
return $conf[0]->getCfgValue();
} else {
return 'dropdown';
}
}
$_GET['change'] = (isset( $_GET['change'] )) ? $_GET['change'] : putTypeView();
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
/* Includes */
G::LoadClass( 'case' );
function putTypeView ()
{
require_once 'classes/model/Configuration.php';
$oConfiguration = new Configuration();
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' );
$oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] );
if (ConfigurationPeer::doCount( $oCriteria )) {
$conf = ConfigurationPeer::doSelect( $oCriteria );
return $conf[0]->getCfgValue();
} else {
return 'dropdown';
}
}
$_GET['change'] = (isset( $_GET['change'] )) ? $_GET['change'] : putTypeView();
/* Permissions */
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
case - 1:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
/* Includes */
G::LoadClass( 'case' );
/* GET , POST & $_SESSION Vars */
/* Menues */
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'cases';
$G_ID_MENU_SELECTED = 'CASES';
$G_ID_SUB_MENU_SELECTED = 'CASES_DRAFT';
/* Prepare page before to show */
$aFields = array ();
$oCase = new Cases();
$bCanStart = $oCase->canStartCase( $_SESSION['USER_LOGGED'] );
if ($bCanStart) {
$aFields['LANG'] = SYS_LANG;
$aFields['USER'] = $_SESSION['USER_LOGGED'];
$sXmlForm = 'cases/cases_New.xml';
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'cases';
$G_ID_MENU_SELECTED = 'CASES';
$G_ID_SUB_MENU_SELECTED = 'CASES_DRAFT';
/* Prepare page before to show */
$aFields = array ();
$oCase = new Cases();
$bCanStart = $oCase->canStartCase( $_SESSION['USER_LOGGED'] );
if ($bCanStart) {
$aFields['LANG'] = SYS_LANG;
$aFields['USER'] = $_SESSION['USER_LOGGED'];
$sXmlForm = 'cases/cases_New.xml';
//$_DBArray['NewCase'] = $oCase->getStartCases( $_SESSION['USER_LOGGED'] );
$_DBArray['NewCase'] = $oCase->getStartCasesPerType( $_SESSION['USER_LOGGED'], $_GET['change'] );
} else {
$sXmlForm = 'cases/cases_CannotInitiateCase.xml';
}
if (isset( $_SESSION['G_MESSAGE'] ) && strlen( $_SESSION['G_MESSAGE'] ) > 0) {
$aMessage = array ();
$aMessage['MESSAGE'] = $_SESSION['G_MESSAGE'];
$_DBArray['NewCase'] = $oCase->getStartCasesPerType( $_SESSION['USER_LOGGED'], $_GET['change'] );
} else {
$sXmlForm = 'cases/cases_CannotInitiateCase.xml';
}
if (isset( $_SESSION['G_MESSAGE'] ) && strlen( $_SESSION['G_MESSAGE'] ) > 0) {
$aMessage = array ();
$aMessage['MESSAGE'] = $_SESSION['G_MESSAGE'];
//$_SESSION['G_MESSAGE_TYPE'];
unset( $_SESSION['G_MESSAGE'] );
unset( $_SESSION['G_MESSAGE_TYPE'] );
}
unset( $_SESSION['G_MESSAGE'] );
unset( $_SESSION['G_MESSAGE_TYPE'] );
}
//get the config parameter to show in dropdown or list
require_once 'classes/model/Configuration.php';
$oConfiguration = new Configuration();
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' );
$oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] );
if (ConfigurationPeer::doCount( $oCriteria ) == 0) {
$aData['CFG_UID'] = 'StartNewCase';
$aData['OBJ_UID'] = '';
$aData['CFG_VALUE'] = 'dropdown';
$aData['PRO_UID'] = '';
$aData['USR_UID'] = $_SESSION['USER_LOGGED'];
$aData['APP_UID'] = '';
$oConfig = new Configuration();
$oConfig->create( $aData );
$listType = 'dropdown';
} else {
$oConfiguration = new Configuration();
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' );
$oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] );
$conf = ConfigurationPeer::doSelect( $oCriteria );
$listType = $conf[0]->getCfgValue();
}
if (isset( $_GET['change'] )) {
$listType = $_GET['change'];
$aData['CFG_UID'] = 'StartNewCase';
$aData['OBJ_UID'] = '';
$aData['CFG_VALUE'] = $listType;
$aData['PRO_UID'] = '';
$aData['USR_UID'] = $_SESSION['USER_LOGGED'];
$aData['APP_UID'] = '';
$oConfig = new Configuration();
$oConfig->update( $aData );
}
/* Render page */
$G_PUBLISH = new Publisher();
$aFields['CHANGE_LINK'] = G::LoadTranslation( 'ID_CHANGE_VIEW' );
if (isset( $aMessage )) {
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
}
if ($listType == 'dropdown')
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', $aFields, 'cases_Save' );
if ($listType == 'link') {
if ($bCanStart)
$sXmlForm = 'cases/cases_NewRadioGroup.xml';
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', $aFields, 'cases_Save' );
}
if ($listType == 'category') {
if ($bCanStart)
$sXmlForm = 'cases/cases_NewCategory.xml';
$G_PUBLISH->AddContent( 'view', 'cases/cases_NewCategory' );
}
G::RenderPage( 'publish', 'blank' );
require_once 'classes/model/Configuration.php';
$oConfiguration = new Configuration();
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' );
$oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] );
if (ConfigurationPeer::doCount( $oCriteria ) == 0) {
$aData['CFG_UID'] = 'StartNewCase';
$aData['OBJ_UID'] = '';
$aData['CFG_VALUE'] = 'dropdown';
$aData['PRO_UID'] = '';
$aData['USR_UID'] = $_SESSION['USER_LOGGED'];
$aData['APP_UID'] = '';
$oConfig = new Configuration();
$oConfig->create( $aData );
$listType = 'dropdown';
} else {
$oConfiguration = new Configuration();
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' );
$oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] );
$conf = ConfigurationPeer::doSelect( $oCriteria );
$listType = $conf[0]->getCfgValue();
}
if (isset( $_GET['change'] )) {
$listType = $_GET['change'];
$aData['CFG_UID'] = 'StartNewCase';
$aData['OBJ_UID'] = '';
$aData['CFG_VALUE'] = $listType;
$aData['PRO_UID'] = '';
$aData['USR_UID'] = $_SESSION['USER_LOGGED'];
$aData['APP_UID'] = '';
$oConfig = new Configuration();
$oConfig->update( $aData );
}
/* Render page */
$G_PUBLISH = new Publisher();
$aFields['CHANGE_LINK'] = G::LoadTranslation( 'ID_CHANGE_VIEW' );
if (isset( $aMessage )) {
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
}
if ($listType == 'dropdown') {
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', $aFields, 'cases_Save' );
}
if ($listType == 'link') {
if ($bCanStart) {
$sXmlForm = 'cases/cases_NewRadioGroup.xml';
}
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', $aFields, 'cases_Save' );
}
if ($listType == 'category') {
if ($bCanStart) {
$sXmlForm = 'cases/cases_NewCategory.xml';
}
$G_PUBLISH->AddContent( 'view', 'cases/cases_NewCategory' );
}
G::RenderPage( 'publish', 'blank' );
?>
<script>
parent.outerLayout.hide('east');
parent.PANEL_EAST_OPEN = false;
</script>
</script>
<?php

View File

@@ -1,32 +1,33 @@
<?php
/**
* cases_NextStep.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.
*/
if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1)
return $RBAC_Response;
<?php
/**
* cases_NextStep.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.
*/
if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1) {
return $RBAC_Response;
}
//go to the next step
G::LoadClass( 'case' );
$oCase = new Cases();
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
$_SESSION['STEP_POSITION'] = $aNextStep['POSITION'];
G::header( 'location: ' . $aNextStep['PAGE'] );
G::LoadClass( 'case' );
$oCase = new Cases();
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
$_SESSION['STEP_POSITION'] = $aNextStep['POSITION'];
G::header( 'location: ' . $aNextStep['PAGE'] );

View File

@@ -1,203 +1,202 @@
<?php
/**
* cases_Open.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 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
* 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.
*/
/* Permissions */
if ($RBAC->userCanAccess( 'PM_CASES' ) != 1) {
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
break;
case - 1:
default:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
break;
}
}
/* Includes */
require_once 'classes/model/AppDelay.php';
G::LoadClass( 'case' );
$oCase = new Cases();
//cleaning the case session data
Cases::clearCaseSessionData();
try {
//Loading data for a Jump request
if (! isset( $_GET['APP_UID'] ) && isset( $_GET['APP_NUMBER'] )) {
$_GET['APP_UID'] = $oCase->getApplicationUIDByNumber( $_GET['APP_NUMBER'] );
$_GET['DEL_INDEX'] = $oCase->getCurrentDelegation( $_GET['APP_UID'], $_SESSION['USER_LOGGED'] );
//if the application doesn't exist
if (is_null( $_GET['APP_UID'] )) {
G::SendMessageText( G::LoadTranslation( 'ID_CASE_DOES_NOT_EXISTS' ), 'info' );
G::header( 'location: casesListExtJs' );
exit();
}
//if the application exists but the
if (is_null( $_GET['DEL_INDEX'] )) {
G::SendMessageText( G::LoadTranslation( 'ID_CASE_IS_CURRENTLY_WITH_ANOTHER_USER' ), 'info' );
G::header( 'location: casesListExtJs' );
exit();
}
//wrong implemented, need refactored
//$participated = $oCase->userParticipatedInCase($_GET['APP_UID'], $_SESSION['USER_LOGGED']); ???????
}
$sAppUid = $_GET['APP_UID'];
$iDelIndex = $_GET['DEL_INDEX'];
$_action = isset( $_GET['action'] ) ? $_GET['action'] : '';
//loading application data
$aFields = $oCase->loadCase( $sAppUid, $iDelIndex );
// g::pr($aFields);
// die;
switch ($aFields['APP_STATUS']) {
case 'DRAFT':
case 'TO_DO':
//check if the case is in pause, check a valid record in table APP_DELAY
if (AppDelay::isPaused( $sAppUid, $iDelIndex )) {
//the case is paused show only the resume
$_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex;
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1;
$_SESSION['STEP_POSITION'] = 0;
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
exit();
}
/**
* these routine is to verify if the case was acceded from advaced search list
*/
if ($_action == 'search') {
//verify if the case is with teh current user
$c = new Criteria( 'workflow' );
$c->add( AppDelegationPeer::APP_UID, $sAppUid );
$c->addDescendingOrderByColumn( AppDelegationPeer::DEL_INDEX );
$oDataset = AppDelegationPeer::doSelectRs( $c );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
$aData = $oDataset->getRow();
if ($aData['USR_UID'] != $_SESSION['USER_LOGGED'] && $aData['USR_UID'] != "") //distinct "" for selfservice
{
//so we show just the resume
$_SESSION['alreadyDerivated'] = true;
//the case is paused show only the resume
$_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex;
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1;
$_SESSION['STEP_POSITION'] = 0;
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
exit();
}
}
//proceed and try to open the case
$oAppDelegation = new AppDelegation();
$aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex );
//if there are no user in the delegation row, this case is in selfservice
if ($aDelegation['USR_UID'] == "" /*&& $aDelegation['DEL_THREAD_STATUS'] == 'SELFSERVICE'*/ ) {
$_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex;
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1;
$_SESSION['STEP_POSITION'] = 0;
$_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 ($oCase->isSelfService( $_SESSION['USER_LOGGED'], $aFields['TAS_UID'], $sAppUid )) {
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_CatchSelfService.php');
} else {
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
}
exit();
}
//if the current users is in the AppDelegation row, then open the case
if (($aDelegation['USR_UID'] == $_SESSION['USER_LOGGED']) && $_action != 'sent') {
$_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex;
if (is_null( $aFields['DEL_INIT_DATE'] )) {
$oCase->setDelInitDate( $sAppUid, $iDelIndex );
$aFields = $oCase->loadCase( $sAppUid, $iDelIndex );
}
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = $aFields['TAS_UID'];
$_SESSION['STEP_POSITION'] = 0;
/* Redirect to next step */
unset( $_SESSION['bNoShowSteps'] );
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
$sPage = $aNextStep['PAGE'];
G::header( 'location: ' . $sPage );
} else {
//when the case have another user or current user doesnt have rights to this selfservice,
//just view the case Resume
$_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex;
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1;
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] );
$_SESSION['CURRENT_TASK'] = $Fields['TAS_UID'];
$_SESSION['STEP_POSITION'] = 0;
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
}
break;
default: //APP_STATUS <> DRAFT and TO_DO
$_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex != "" ? $iDelIndex : $oCase->getCurrentDelegationCase( $_GET['APP_UID'] );
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1;
$_SESSION['STEP_POSITION'] = 0;
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
}
} catch (Exception $e) {
$aMessage = array ();
$aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage( 'publishBlank', 'blank' );
<?php
/**
* cases_Open.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 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
* 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.
*/
/* Permissions */
if ($RBAC->userCanAccess( 'PM_CASES' ) != 1) {
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
break;
case - 1:
default:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
break;
}
}
/* Includes */
require_once 'classes/model/AppDelay.php';
G::LoadClass( 'case' );
$oCase = new Cases();
//cleaning the case session data
Cases::clearCaseSessionData();
try {
//Loading data for a Jump request
if (! isset( $_GET['APP_UID'] ) && isset( $_GET['APP_NUMBER'] )) {
$_GET['APP_UID'] = $oCase->getApplicationUIDByNumber( $_GET['APP_NUMBER'] );
$_GET['DEL_INDEX'] = $oCase->getCurrentDelegation( $_GET['APP_UID'], $_SESSION['USER_LOGGED'] );
//if the application doesn't exist
if (is_null( $_GET['APP_UID'] )) {
G::SendMessageText( G::LoadTranslation( 'ID_CASE_DOES_NOT_EXISTS' ), 'info' );
G::header( 'location: casesListExtJs' );
exit();
}
//if the application exists but the
if (is_null( $_GET['DEL_INDEX'] )) {
G::SendMessageText( G::LoadTranslation( 'ID_CASE_IS_CURRENTLY_WITH_ANOTHER_USER' ), 'info' );
G::header( 'location: casesListExtJs' );
exit();
}
//wrong implemented, need refactored
//$participated = $oCase->userParticipatedInCase($_GET['APP_UID'], $_SESSION['USER_LOGGED']); ???????
}
$sAppUid = $_GET['APP_UID'];
$iDelIndex = $_GET['DEL_INDEX'];
$_action = isset( $_GET['action'] ) ? $_GET['action'] : '';
//loading application data
$aFields = $oCase->loadCase( $sAppUid, $iDelIndex );
// g::pr($aFields);
// die;
switch ($aFields['APP_STATUS']) {
case 'DRAFT':
case 'TO_DO':
//check if the case is in pause, check a valid record in table APP_DELAY
if (AppDelay::isPaused( $sAppUid, $iDelIndex )) {
//the case is paused show only the resume
$_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex;
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1;
$_SESSION['STEP_POSITION'] = 0;
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
exit();
}
/**
* these routine is to verify if the case was acceded from advaced search list
*/
if ($_action == 'search') {
//verify if the case is with teh current user
$c = new Criteria( 'workflow' );
$c->add( AppDelegationPeer::APP_UID, $sAppUid );
$c->addDescendingOrderByColumn( AppDelegationPeer::DEL_INDEX );
$oDataset = AppDelegationPeer::doSelectRs( $c );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
$aData = $oDataset->getRow();
if ($aData['USR_UID'] != $_SESSION['USER_LOGGED'] && $aData['USR_UID'] != "") {
//distinct "" for selfservice
//so we show just the resume
$_SESSION['alreadyDerivated'] = true;
//the case is paused show only the resume
$_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex;
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1;
$_SESSION['STEP_POSITION'] = 0;
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
exit();
}
}
//proceed and try to open the case
$oAppDelegation = new AppDelegation();
$aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex );
//if there are no user in the delegation row, this case is in selfservice
if ($aDelegation['USR_UID'] == "" /*&& $aDelegation['DEL_THREAD_STATUS'] == 'SELFSERVICE'*/ ) {
$_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex;
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1;
$_SESSION['STEP_POSITION'] = 0;
$_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 ($oCase->isSelfService( $_SESSION['USER_LOGGED'], $aFields['TAS_UID'], $sAppUid )) {
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_CatchSelfService.php');
} else {
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
}
exit();
}
//if the current users is in the AppDelegation row, then open the case
if (($aDelegation['USR_UID'] == $_SESSION['USER_LOGGED']) && $_action != 'sent') {
$_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex;
if (is_null( $aFields['DEL_INIT_DATE'] )) {
$oCase->setDelInitDate( $sAppUid, $iDelIndex );
$aFields = $oCase->loadCase( $sAppUid, $iDelIndex );
}
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = $aFields['TAS_UID'];
$_SESSION['STEP_POSITION'] = 0;
/* Redirect to next step */
unset( $_SESSION['bNoShowSteps'] );
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
$sPage = $aNextStep['PAGE'];
G::header( 'location: ' . $sPage );
} else {
//when the case have another user or current user doesnt have rights to this selfservice,
//just view the case Resume
$_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex;
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1;
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] );
$_SESSION['CURRENT_TASK'] = $Fields['TAS_UID'];
$_SESSION['STEP_POSITION'] = 0;
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
}
break;
default: //APP_STATUS <> DRAFT and TO_DO
$_SESSION['APPLICATION'] = $sAppUid;
$_SESSION['INDEX'] = $iDelIndex != "" ? $iDelIndex : $oCase->getCurrentDelegationCase( $_GET['APP_UID'] );
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = - 1;
$_SESSION['STEP_POSITION'] = 0;
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
}
} catch (Exception $e) {
$aMessage = array ();
$aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage( 'publishBlank', 'blank' );
}

View File

@@ -1,75 +1,76 @@
<?php
/**
* cases_Open.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.
*/
/* Permissions */
if ($RBAC->userCanAccess( 'PM_SUPERVISOR' ) != 1)
switch ($RBAC->userCanAccess( 'PM_SUPERVISOR' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
default:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
/* Includes */
G::LoadClass( 'case' );
/* GET , POST & $_SESSION Vars */
if (isset( $_SESSION['APPLICATION'] )) {
unset( $_SESSION['APPLICATION'] );
}
if (isset( $_SESSION['PROCESS'] )) {
unset( $_SESSION['PROCESS'] );
}
if (isset( $_SESSION['INDEX'] )) {
unset( $_SESSION['INDEX'] );
}
if (isset( $_SESSION['STEP_POSITION'] )) {
unset( $_SESSION['STEP_POSITION'] );
}
/* Process the info */
$oCase = new Cases();
$sAppUid = $_GET['APP_UID'];
$iDelIndex = $_GET['DEL_INDEX'];
$_SESSION['APPLICATION'] = $_GET['APP_UID'];
$_SESSION['INDEX'] = $_GET['DEL_INDEX'];
$aFields = $oCase->loadCase( $sAppUid, $iDelIndex );
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = $aFields['TAS_UID'];
$_SESSION['STEP_POSITION'] = 0;
/* Redirect to next step */
$aNextStep = $oCase->getNextSupervisorStep( $_SESSION['PROCESS'], 0 );
<?php
/**
* cases_Open.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.
*/
/* Permissions */
if ($RBAC->userCanAccess( 'PM_SUPERVISOR' ) != 1) {
switch ($RBAC->userCanAccess( 'PM_SUPERVISOR' )) {
case - 2:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
default:
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
break;
}
}
/* Includes */
G::LoadClass( 'case' );
/* GET , POST & $_SESSION Vars */
if (isset( $_SESSION['APPLICATION'] )) {
unset( $_SESSION['APPLICATION'] );
}
if (isset( $_SESSION['PROCESS'] )) {
unset( $_SESSION['PROCESS'] );
}
if (isset( $_SESSION['INDEX'] )) {
unset( $_SESSION['INDEX'] );
}
if (isset( $_SESSION['STEP_POSITION'] )) {
unset( $_SESSION['STEP_POSITION'] );
}
/* Process the info */
$oCase = new Cases();
$sAppUid = $_GET['APP_UID'];
$iDelIndex = $_GET['DEL_INDEX'];
$_SESSION['APPLICATION'] = $_GET['APP_UID'];
$_SESSION['INDEX'] = $_GET['DEL_INDEX'];
$aFields = $oCase->loadCase( $sAppUid, $iDelIndex );
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
$_SESSION['TASK'] = $aFields['TAS_UID'];
$_SESSION['STEP_POSITION'] = 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'];
G::header( 'location: ' . $sPage );
G::header( 'location: ' . $sPage );

View File

@@ -1,96 +1,96 @@
<?php
/**
* Cases_PrintPreview.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.
*/
try {
require_once 'classes/model/Dynaform.php';
require_once 'classes/model/Process.php';
$currentDynUid = '';
if (isset( $_GET['DYNUIDPRINT'] ) && $_GET['DYNUIDPRINT'] != '') {
$currentDynUid = $_GET['DYNUIDPRINT'];
} elseif (isset( $_SESSION['DYN_UID_PRINT'] )) {
$currentDynUid = $_SESSION['DYN_UID_PRINT'];
} elseif (isset( $_SESSION['CURRENT_DYN_UID'] )) {
$currentDynUid = $_SESSION['CURRENT_DYN_UID'];
}
$oDynaform = new Dynaform();
$aDyn = $oDynaform->load( $currentDynUid );
G::LoadClass( 'case' );
$oCase = new Cases();
if (isset( $_SESSION['APPLICATION'] )) {
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'] );
$Fields['APP_DATA'] = array_merge( $Fields['APP_DATA'], G::getSystemConstants() );
} else {
$Fields['APP_DATA'] = Array ();
}
$G_MAIN_MENU = 'processmaker';
$G_ID_MENU_SELECTED = 'USERS';
$G_PUBLISH = new Publisher();
$idProcess = (isset( $Fields['APP_DATA']['PROCESS'] )) ? $Fields['APP_DATA']['PROCESS'] : $_SESSION['PROCESS'];
$oProcess = new Process();
$aProcessFieds = $oProcess->load( $idProcess );
$sProcess = $oProcess->getProTitle();
$noShowTitle = 0;
if (isset( $aProcessFieds['PRO_SHOW_MESSAGE'] )) {
$noShowTitle = $aProcessFieds['PRO_SHOW_MESSAGE'];
}
<?php
/**
* Cases_PrintPreview.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.
*/
try {
require_once 'classes/model/Dynaform.php';
require_once 'classes/model/Process.php';
$currentDynUid = '';
if (isset( $_GET['DYNUIDPRINT'] ) && $_GET['DYNUIDPRINT'] != '') {
$currentDynUid = $_GET['DYNUIDPRINT'];
} elseif (isset( $_SESSION['DYN_UID_PRINT'] )) {
$currentDynUid = $_SESSION['DYN_UID_PRINT'];
} elseif (isset( $_SESSION['CURRENT_DYN_UID'] )) {
$currentDynUid = $_SESSION['CURRENT_DYN_UID'];
}
$oDynaform = new Dynaform();
$aDyn = $oDynaform->load( $currentDynUid );
G::LoadClass( 'case' );
$oCase = new Cases();
if (isset( $_SESSION['APPLICATION'] )) {
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'] );
$Fields['APP_DATA'] = array_merge( $Fields['APP_DATA'], G::getSystemConstants() );
} else {
$Fields['APP_DATA'] = Array ();
}
$G_MAIN_MENU = 'processmaker';
$G_ID_MENU_SELECTED = 'USERS';
$G_PUBLISH = new Publisher();
$idProcess = (isset( $Fields['APP_DATA']['PROCESS'] )) ? $Fields['APP_DATA']['PROCESS'] : $_SESSION['PROCESS'];
$oProcess = new Process();
$aProcessFieds = $oProcess->load( $idProcess );
$sProcess = $oProcess->getProTitle();
$noShowTitle = 0;
if (isset( $aProcessFieds['PRO_SHOW_MESSAGE'] )) {
$noShowTitle = $aProcessFieds['PRO_SHOW_MESSAGE'];
}
//Add content content step - Start
if (isset( $_SESSION['APPLICATION'] )) {
$array['CASE'] = G::LoadTranslation( 'ID_CASE' );
$array['USER'] = G::LoadTranslation( 'ID_USER' );
$array['WORKSPACE'] = G::LoadTranslation( 'ID_WORKSPACE' );
$array['APP_NUMBER'] = $Fields['APP_NUMBER'];
$array['APP_TITLE'] = $Fields['TITLE'];
$array['USR_USERNAME'] = $Fields['APP_DATA']['USR_USERNAME'];
$array['USER_ENV'] = $Fields['APP_DATA']['SYS_SYS'];
$array['DATEPRINT'] = date( 'Y-m-d H:m:s' );
}
$array['APP_PROCESS'] = $sProcess;
if (isset( $Fields['TITLE'] ) && strlen( $Fields['TITLE'] ) > 0) {
$array['TITLE'] = G::LoadTranslation( 'ID_TITLE' );
} else {
$array['TITLE'] = '';
}
$array['PROCESS'] = G::LoadTranslation( 'ID_PROCESS' );
$array['DATELABEL'] = G::LoadTranslation( 'DATE_LABEL' );
$aDyn['DYN_UID'] = $currentDynUid;
if ($noShowTitle == 0) {
$G_PUBLISH->AddContent( 'smarty', 'cases/cases_PrintViewTitle', '', '', $array );
}
$G_PUBLISH->AddContent( 'dynaform', 'xmlform', $aDyn['PRO_UID'] . '/' . $aDyn['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view' );
G::RenderPage( 'publish', 'blank' );
} catch (Exception $oException) {
die( $oException->getMessage() );
}
if (isset( $_SESSION['APPLICATION'] )) {
$array['CASE'] = G::LoadTranslation( 'ID_CASE' );
$array['USER'] = G::LoadTranslation( 'ID_USER' );
$array['WORKSPACE'] = G::LoadTranslation( 'ID_WORKSPACE' );
$array['APP_NUMBER'] = $Fields['APP_NUMBER'];
$array['APP_TITLE'] = $Fields['TITLE'];
$array['USR_USERNAME'] = $Fields['APP_DATA']['USR_USERNAME'];
$array['USER_ENV'] = $Fields['APP_DATA']['SYS_SYS'];
$array['DATEPRINT'] = date( 'Y-m-d H:m:s' );
}
$array['APP_PROCESS'] = $sProcess;
if (isset( $Fields['TITLE'] ) && strlen( $Fields['TITLE'] ) > 0) {
$array['TITLE'] = G::LoadTranslation( 'ID_TITLE' );
} else {
$array['TITLE'] = '';
}
$array['PROCESS'] = G::LoadTranslation( 'ID_PROCESS' );
$array['DATELABEL'] = G::LoadTranslation( 'DATE_LABEL' );
$aDyn['DYN_UID'] = $currentDynUid;
if ($noShowTitle == 0) {
$G_PUBLISH->AddContent( 'smarty', 'cases/cases_PrintViewTitle', '', '', $array );
}
$G_PUBLISH->AddContent( 'dynaform', 'xmlform', $aDyn['PRO_UID'] . '/' . $aDyn['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view' );
G::RenderPage( 'publish', 'blank' );
} catch (Exception $oException) {
die( $oException->getMessage() );
}
?>
<script>
@@ -121,5 +121,7 @@ try {
window.print();
} catch(e){}
</script>
</script>
<?php

View File

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