diff --git a/workflow/engine/classes/model/AppDelegation.php b/workflow/engine/classes/model/AppDelegation.php
index 8cc5d75d2..3f1c85164 100755
--- a/workflow/engine/classes/model/AppDelegation.php
+++ b/workflow/engine/classes/model/AppDelegation.php
@@ -1,7 +1,8 @@
.
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
@@ -25,10 +26,10 @@
*/
require_once 'classes/model/om/BaseAppDelegation.php';
-require_once ( "classes/model/HolidayPeer.php" );
-require_once ( "classes/model/TaskPeer.php" );
-require_once ( "classes/model/Task.php" );
-G::LoadClass("dates");
+require_once ("classes/model/HolidayPeer.php");
+require_once ("classes/model/TaskPeer.php");
+require_once ("classes/model/Task.php");
+G::LoadClass( "dates" );
/**
* Skeleton subclass for representing a row from the 'APP_DELEGATION' table.
@@ -36,457 +37,454 @@ G::LoadClass("dates");
*
*
* You should add additional methods to this class to meet the
- * application requirements. This class will only be generated as
+ * application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
- * @package workflow.engine.classes.model
+ * @package workflow.engine.classes.model
*/
-class AppDelegation extends BaseAppDelegation {
+class AppDelegation extends BaseAppDelegation
+{
- /**
- * create an application delegation
- * @param $sProUid process Uid
- * @param $sAppUid Application Uid
- * @param $sTasUid Task Uid
- * @param $sUsrUid User Uid
- * @param $iPriority delegation priority
- * @param $isSubprocess is a subprocess inside a process?
- * @return delegation index of the application delegation.
- */
- function createAppDelegation ($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess = false, $sPrevious = -1, $sNextTasParam = null)
- {
-
- if (!isset($sProUid) || strlen($sProUid) == 0 ) {
- throw ( new Exception ( 'Column "PRO_UID" cannot be null.' ) );
- }
-
- if (!isset($sAppUid) || strlen($sAppUid ) == 0 ) {
- throw ( new Exception ( 'Column "APP_UID" cannot be null.' ) );
- }
-
- if (!isset($sTasUid) || strlen($sTasUid ) == 0 ) {
- throw ( new Exception ( 'Column "TAS_UID" cannot be null.' ) );
- }
-
- if (!isset($sUsrUid) /*|| strlen($sUsrUid ) == 0*/ ) {
- throw ( new Exception ( 'Column "USR_UID" cannot be null.' ) );
- }
-
- if (!isset($sAppThread) || strlen($sAppThread ) == 0 ) {
- throw ( new Exception ( 'Column "APP_THREAD" cannot be null.' ) );
- }
-
- //get max DEL_INDEX SELECT MAX(DEL_INDEX) AS M FROM APP_DELEGATION WHERE APP_UID="'.$Fields['APP_UID'].'"'
- $c = new Criteria ();
- $c->clearSelectColumns();
- $c->addSelectColumn ( 'MAX(' . AppDelegationPeer::DEL_INDEX . ') ' );
- $c->add ( AppDelegationPeer::APP_UID, $sAppUid );
-
- $rs = AppDelegationPeer::doSelectRS ( $c );
- $rs->next();
- $row = $rs->getRow();
- $delIndex = $row[0] + 1;
-
- $this->setAppUid ( $sAppUid );
- $this->setProUid ( $sProUid );
- $this->setTasUid ( $sTasUid );
- $this->setDelIndex ( $delIndex );
- $this->setDelPrevious ( $sPrevious == -1 ? 0 : $sPrevious );
- $this->setUsrUid ( $sUsrUid );
- $this->setDelType ( 'NORMAL' );
- $this->setDelPriority ( ($iPriority != '' ? $iPriority : '3') );
- $this->setDelThread ( $sAppThread );
- $this->setDelThreadStatus ( 'OPEN' );
- $this->setDelDelegateDate ( 'now' );
-
- //The function return an array now. By JHL
- $delTaskDueDate = $this->calculateDueDate($sNextTasParam);
-
- $this->setDelTaskDueDate ( $delTaskDueDate['DUE_DATE'] ); // Due date formatted
-
- if((defined("DEBUG_CALENDAR_LOG"))&&(DEBUG_CALENDAR_LOG)){
- $this->setDelData ($delTaskDueDate['DUE_DATE_LOG'] ); // Log of actions made by Calendar Engine
- }
- else{
- $this->setDelData ( '' );
- }
-
- // this condition assures that an internal delegation like a subprocess dont have an initial date setted
- if ( $delIndex == 1 && !$isSubprocess ) { //the first delegation, init date this should be now for draft applications, in other cases, should be null.
- $this->setDelInitDate('now' );
- }
-
- if ($this->validate()) {
- try {
- $res = $this->save();
- }
- catch ( PropelException $e ) {
- throw ( $e );
- }
- }
- else {
- // Something went wrong. We can now get the validationFailures and handle them.
- $msg = '';
- $validationFailuresArray = $this->getValidationFailures();
- foreach($validationFailuresArray as $objValidationFailure) {
- $msg .= $objValidationFailure->getMessage() . "
";
- }
- throw ( new Exception ( 'Failed Data validation. ' . $msg ) );
- }
-
- $delIndex = $this->getDelIndex();
-
- // Hook for the trigger PM_CREATE_NEW_DELEGATION
- if (defined('PM_CREATE_NEW_DELEGATION')) {
- $data = new stdclass();
- $data->TAS_UID = $sTasUid;
- $data->APP_UID = $sAppUid;
- $data->DEL_INDEX = $delIndex;
- $data->USR_UID = $sUsrUid;
- $oPluginRegistry = &PMPluginRegistry::getSingleton();
- $oPluginRegistry->executeTriggers(PM_CREATE_NEW_DELEGATION, $data);
- }
-
- return $delIndex;
- }
-
- /**
- * Load the Application Delegation row specified in [app_id] column value.
- *
- * @param string $AppUid the uid of the application
- * @return array $Fields the fields
- */
-
- function Load ( $AppUid, $sDelIndex ) {
- $con = Propel::getConnection(AppDelegationPeer::DATABASE_NAME);
- try {
- $oAppDel = AppDelegationPeer::retrieveByPk( $AppUid, $sDelIndex );
- if (is_object($oAppDel) && get_class ($oAppDel) == 'AppDelegation' ) {
- $aFields = $oAppDel->toArray( BasePeer::TYPE_FIELDNAME);
- $this->fromArray ($aFields, BasePeer::TYPE_FIELDNAME );
- return $aFields;
- }
- else {
- throw( new Exception( "The row '$AppUid, $sDelIndex' in table AppDelegation doesn't exist!" ));
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Update the application row
- * @param array $aData
- * @return variant
- **/
-
- public function update($aData)
- {
- $con = Propel::getConnection( AppDelegationPeer::DATABASE_NAME );
- try {
- $con->begin();
- $oApp = AppDelegationPeer::retrieveByPK( $aData['APP_UID'], $aData['DEL_INDEX'] );
- if (is_object($oApp) && get_class ($oApp) == 'AppDelegation' ) {
- $oApp->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
- if ($oApp->validate()) {
- $res = $oApp->save();
- $con->commit();
- return $res;
- }
- else {
- $msg = '';
- foreach($this->getValidationFailures() as $objValidationFailure)
- $msg .= $objValidationFailure->getMessage() . "
";
-
- throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
- }
- }
- else {
- $con->rollback();
- throw(new Exception( "This AppDelegation row doesn't exist!" ));
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- function remove($sApplicationUID, $iDelegationIndex) {
- $oConnection = Propel::getConnection(StepTriggerPeer::DATABASE_NAME);
- try {
- $oConnection->begin();
- $oApp = AppDelegationPeer::retrieveByPK( $sApplicationUID, $iDelegationIndex );
- if (is_object($oApp) && get_class ($oApp) == 'AppDelegation' ) {
- $result = $oApp->delete();
- }
- $oConnection->commit();
- return $result;
- }
- catch(Exception $e) {
- $oConnection->rollback();
- throw($e);
- }
- }
-
- // TasTypeDay = 1 => working days
- // TasTypeDay = 2 => calendar days
- function calculateDueDate($sNextTasParam)
- {
- //Get Task properties
- $task = TaskPeer::retrieveByPK( $this->getTasUid() );
-
- $aData['TAS_UID'] = $this->getTasUid();
- //Added to allow User defined Timing Control at Run time from Derivation screen
- if(isset($sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY']) && $sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] == 'true')
+ /**
+ * create an application delegation
+ *
+ * @param $sProUid process Uid
+ * @param $sAppUid Application Uid
+ * @param $sTasUid Task Uid
+ * @param $sUsrUid User Uid
+ * @param $iPriority delegation priority
+ * @param $isSubprocess is a subprocess inside a process?
+ * @return delegation index of the application delegation.
+ */
+ function createAppDelegation ($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess = false, $sPrevious = -1, $sNextTasParam = null)
{
- $aData['TAS_DURATION'] = $sNextTasParam['NEXT_TASK']['TAS_DURATION'];
- $aData['TAS_TIMEUNIT'] = $sNextTasParam['NEXT_TASK']['TAS_TIMEUNIT'];
- $aData['TAS_TYPE_DAY'] = $sNextTasParam['NEXT_TASK']['TAS_TYPE_DAY'];
- if(isset($sNextTasParam['NEXT_TASK']['TAS_CALENDAR']) && $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'] != '') {
- $aCalendarUID = $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'];
- }
- else {
- $aCalendarUID = '';
- }
-
- //Updating the task Table , so that user will see updated values in the assign screen in consequent cases
- $oTask = new Task();
- $oTask->update($aData);
- }
- else {
- if (is_null($task)) {
- return 0;
- }
- $aData['TAS_DURATION'] = $task->getTasDuration();
- $aData['TAS_TIMEUNIT'] = $task->getTasTimeUnit();
- $aData['TAS_TYPE_DAY'] = $task->getTasTypeDay();
- $aCalendarUID = '';
- }
-
- //use the dates class to calculate dates
- $dates = new dates();
- $iDueDate = $dates->calculateDate(
- $this->getDelDelegateDate(),
- $aData['TAS_DURATION'],
- $aData['TAS_TIMEUNIT'], //hours or days, ( we only accept this two types or maybe weeks
- $aData['TAS_TYPE_DAY'], //working or calendar days
- $this->getUsrUid(),
- $task->getProUid(),
- $aData['TAS_UID'],
- $aCalendarUID
- );
-
- return $iDueDate;
- }
-
- function getDiffDate ( $date1, $date2 )
- {
- return ( $date1 - $date2 )/(24*60*60); //days
- return ( $date1 - $date2 ) / 3600;
- }
-
- public function calculateDuration($cron=0)
- {
- try {
- //patch rows with initdate = null and finish_date
- $c = new Criteria();
- $c->clearSelectColumns();
- $c->addSelectColumn(AppDelegationPeer::APP_UID );
- $c->addSelectColumn(AppDelegationPeer::DEL_INDEX );
- $c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
- $c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
- $c->add(AppDelegationPeer::DEL_INIT_DATE, NULL, Criteria::ISNULL);
- $c->add(AppDelegationPeer::DEL_FINISH_DATE, NULL, Criteria::ISNOTNULL);
- //$c->add(AppDelegationPeer::DEL_INDEX, 1);
-
- $rs = AppDelegationPeer::doSelectRS($c);
- $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $rs->next();
- $row = $rs->getRow();
-
- while (is_array($row)) {
- if ($cron == 1) {
- $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
- $arrayCron["processcTimeStart"] = time();
- @file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
+ if (! isset( $sProUid ) || strlen( $sProUid ) == 0) {
+ throw (new Exception( 'Column "PRO_UID" cannot be null.' ));
}
- $oAppDel = AppDelegationPeer::retrieveByPk($row['APP_UID'], $row['DEL_INDEX'] );
- if ( isset ($row['DEL_FINISH_DATE']) )
- $oAppDel->setDelInitDate($row['DEL_FINISH_DATE']);
- else
- $oAppDel->setDelInitDate($row['DEL_INIT_DATE']);
- $oAppDel->save();
+ if (! isset( $sAppUid ) || strlen( $sAppUid ) == 0) {
+ throw (new Exception( 'Column "APP_UID" cannot be null.' ));
+ }
+ if (! isset( $sTasUid ) || strlen( $sTasUid ) == 0) {
+ throw (new Exception( 'Column "TAS_UID" cannot be null.' ));
+ }
+
+ if (! isset( $sUsrUid ) /*|| strlen($sUsrUid ) == 0*/ ) {
+ throw (new Exception( 'Column "USR_UID" cannot be null.' ));
+ }
+
+ if (! isset( $sAppThread ) || strlen( $sAppThread ) == 0) {
+ throw (new Exception( 'Column "APP_THREAD" cannot be null.' ));
+ }
+
+ //get max DEL_INDEX SELECT MAX(DEL_INDEX) AS M FROM APP_DELEGATION WHERE APP_UID="'.$Fields['APP_UID'].'"'
+ $c = new Criteria();
+ $c->clearSelectColumns();
+ $c->addSelectColumn( 'MAX(' . AppDelegationPeer::DEL_INDEX . ') ' );
+ $c->add( AppDelegationPeer::APP_UID, $sAppUid );
+
+ $rs = AppDelegationPeer::doSelectRS( $c );
$rs->next();
$row = $rs->getRow();
- }
- //walk in all rows with DEL_STARTED = 0 or DEL_FINISHED = 0
+ $delIndex = $row[0] + 1;
- $c = new Criteria('workflow');
- $c->clearSelectColumns();
- $c->addSelectColumn(AppDelegationPeer::APP_UID );
- $c->addSelectColumn(AppDelegationPeer::DEL_INDEX );
- $c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
- $c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
- $c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
- $c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
- $c->addSelectColumn(AppDelegationPeer::DEL_DURATION);
- $c->addSelectColumn(AppDelegationPeer::DEL_QUEUE_DURATION);
- $c->addSelectColumn(AppDelegationPeer::DEL_DELAY_DURATION);
- $c->addSelectColumn(AppDelegationPeer::DEL_STARTED);
- $c->addSelectColumn(AppDelegationPeer::DEL_FINISHED);
- $c->addSelectColumn(AppDelegationPeer::DEL_DELAYED);
- $c->addSelectColumn(TaskPeer::TAS_DURATION);
- $c->addSelectColumn(TaskPeer::TAS_TIMEUNIT);
- $c->addSelectColumn(TaskPeer::TAS_TYPE_DAY);
+ $this->setAppUid( $sAppUid );
+ $this->setProUid( $sProUid );
+ $this->setTasUid( $sTasUid );
+ $this->setDelIndex( $delIndex );
+ $this->setDelPrevious( $sPrevious == - 1 ? 0 : $sPrevious );
+ $this->setUsrUid( $sUsrUid );
+ $this->setDelType( 'NORMAL' );
+ $this->setDelPriority( ($iPriority != '' ? $iPriority : '3') );
+ $this->setDelThread( $sAppThread );
+ $this->setDelThreadStatus( 'OPEN' );
+ $this->setDelDelegateDate( 'now' );
- $c->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN );
- //$c->add(AppDelegationPeer::DEL_INIT_DATE, NULL, Criteria::ISNULL);
- //$c->add(AppDelegationPeer::APP_UID, '7694483844a37bfeb0931b1063501289');
- //$c->add(AppDelegationPeer::DEL_STARTED, 0);
+ //The function return an array now. By JHL
+ $delTaskDueDate = $this->calculateDueDate( $sNextTasParam );
- $cton1 = $c->getNewCriterion(AppDelegationPeer::DEL_STARTED, 0);
- $cton2 = $c->getNewCriterion(AppDelegationPeer::DEL_FINISHED, 0);
- $cton1->addOR($cton2);
- $c->add($cton1);
+ $this->setDelTaskDueDate( $delTaskDueDate['DUE_DATE'] ); // Due date formatted
- $rs = AppDelegationPeer::doSelectRS($c);
- $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $rs->next();
- $row = $rs->getRow();
- $i =0;
- //print "
";
- //print "| iDelegateDate | iInitDate | iDueDate | iFinishDate | isStarted | isFinished | isDelayed | queueDuration | delDuration | delayDuration |
";
- $now = strtotime ( 'now' );
- while ( is_array($row) ) {
- if ($cron == 1) {
- $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
- $arrayCron["processcTimeStart"] = time();
- @file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
+ if ((defined( "DEBUG_CALENDAR_LOG" )) && (DEBUG_CALENDAR_LOG)) {
+ $this->setDelData( $delTaskDueDate['DUE_DATE_LOG'] ); // Log of actions made by Calendar Engine
+ } else {
+ $this->setDelData( '' );
}
- $fTaskDuration = $row['TAS_DURATION'];
- $iDelegateDate = strtotime ( $row['DEL_DELEGATE_DATE'] );
- $iInitDate = strtotime ( $row['DEL_INIT_DATE'] );
- $iDueDate = strtotime ( $row['DEL_TASK_DUE_DATE'] );
- $iFinishDate = strtotime ( $row['DEL_FINISH_DATE'] );
- $isStarted = intval ( $row['DEL_STARTED'] );
- $isFinished = intval ( $row['DEL_FINISHED'] );
- $isDelayed = intval ( $row['DEL_DELAYED'] );
- $queueDuration = $this->getDiffDate ($iInitDate, $iDelegateDate);
- $delDuration = 0;
- $delayDuration = 0;
- $overduePercentage = 0.0;
- //get the object,
- $oAppDel = AppDelegationPeer::retrieveByPk($row['APP_UID'], $row['DEL_INDEX'] );
-
- //if the task is not started
- if ( $isStarted == 0 ) {
- if ( $row['DEL_INIT_DATE'] != NULL && $row['DEL_INIT_DATE'] != '' ) {
- $oAppDel->setDelStarted(1);
- $queueDuration = $this->getDiffDate ($iInitDate, $iDelegateDate );
- $oAppDel->setDelQueueDuration( $queueDuration);
- }
- else {//the task was not started
- $queueDuration = $this->getDiffDate ( $now, $iDelegateDate );
- $oAppDel->setDelQueueDuration( $queueDuration);
-
- //we are putting negative number if the task is not delayed, and positive number for the time the task is delayed
- $delayDuration = $this->getDiffDate ($now, $iDueDate );
- $oAppDel->setDelDelayDuration( $delayDuration);
- if ( $fTaskDuration != 0) {
- $overduePercentage = $delayDuration / $fTaskDuration;
- $oAppDel->setAppOverduePercentage( $overduePercentage);
- if ( $iDueDate < $now ) {
- $oAppDel->setDelDelayed(1);
- }
- }
- }
+ // this condition assures that an internal delegation like a subprocess dont have an initial date setted
+ if ($delIndex == 1 && ! $isSubprocess) {
+ //the first delegation, init date this should be now for draft applications, in other cases, should be null.
+ $this->setDelInitDate( 'now' );
}
- //if the task was not finished
- if ( $isFinished == 0 ) {
- if ( $row['DEL_FINISH_DATE'] != NULL && $row['DEL_FINISH_DATE'] != '') {
- $oAppDel->setAppOverduePercentage($overduePercentage);
- $oAppDel->setDelFinished(1);
-
- $delDuration = $this->getDiffDate ($iFinishDate, $iInitDate );
- $oAppDel->setDelDuration( $delDuration);
- //calculate due date if correspond
- if ( $iDueDate < $iFinishDate ) {
- $oAppDel->setDelDelayed(1);
- $delayDuration = $this->getDiffDate ($iFinishDate, $iDueDate );
+ if ($this->validate()) {
+ try {
+ $res = $this->save();
+ } catch (PropelException $e) {
+ throw ($e);
}
- else {
- $oAppDel->setDelDelayed(0);
- $delayDuration = 0;
+ } else {
+ // Something went wrong. We can now get the validationFailures and handle them.
+ $msg = '';
+ $validationFailuresArray = $this->getValidationFailures();
+ foreach ($validationFailuresArray as $objValidationFailure) {
+ $msg .= $objValidationFailure->getMessage() . "
";
}
- }
- else { //the task was not completed
- if ( $row['DEL_INIT_DATE'] != NULL && $row['DEL_INIT_DATE'] != '' ) {
- $delDuration = $this->getDiffDate ($now, $iInitDate );
- }
- else
- $delDuration = $this->getDiffDate ($now, $iDelegateDate);
- $oAppDel->setDelDuration( $delDuration);
-
- //we are putting negative number if the task is not delayed, and positive number for the time the task is delayed
- $delayDuration = $this->getDiffDate ($now, $iDueDate );
- $oAppDel->setDelDelayDuration( $delayDuration);
- if ( $fTaskDuration != 0) {
- $overduePercentage = $delayDuration / $fTaskDuration;
- $oAppDel->setAppOverduePercentage($overduePercentage );
- if ( $iDueDate < $now ) {
- $oAppDel->setDelDelayed(1);
- }
- }
- }
-
+ throw (new Exception( 'Failed Data validation. ' . $msg ));
}
- //and finally save the record
- $RES = $oAppDel->save();
- //print "| $iDelegateDate | $iInitDate | $iDueDate | $iFinishDate | $isStarted | $isFinished | $isDelayed | $queueDuration | $delDuration | " .
- // "$delayDuration | $overduePercentage | " . $row['DEL_INDEX'] . " $RES |
";
+ $delIndex = $this->getDelIndex();
- //UPDATE APP_DELEGATION SET DEL_DELAYED = 0
- //where
- // APP_OVERDUE_PERCENTAGE < 0
+ // Hook for the trigger PM_CREATE_NEW_DELEGATION
+ if (defined( 'PM_CREATE_NEW_DELEGATION' )) {
+ $data = new stdclass();
+ $data->TAS_UID = $sTasUid;
+ $data->APP_UID = $sAppUid;
+ $data->DEL_INDEX = $delIndex;
+ $data->USR_UID = $sUsrUid;
+ $oPluginRegistry = &PMPluginRegistry::getSingleton();
+ $oPluginRegistry->executeTriggers( PM_CREATE_NEW_DELEGATION, $data );
+ }
+
+ return $delIndex;
+ }
+
+ /**
+ * Load the Application Delegation row specified in [app_id] column value.
+ *
+ * @param string $AppUid the uid of the application
+ * @return array $Fields the fields
+ */
+
+ function Load ($AppUid, $sDelIndex)
+ {
+ $con = Propel::getConnection( AppDelegationPeer::DATABASE_NAME );
+ try {
+ $oAppDel = AppDelegationPeer::retrieveByPk( $AppUid, $sDelIndex );
+ if (is_object( $oAppDel ) && get_class( $oAppDel ) == 'AppDelegation') {
+ $aFields = $oAppDel->toArray( BasePeer::TYPE_FIELDNAME );
+ $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
+ return $aFields;
+ } else {
+ throw (new Exception( "The row '$AppUid, $sDelIndex' in table AppDelegation doesn't exist!" ));
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ /**
+ * Update the application row
+ *
+ * @param array $aData
+ * @return variant
+ *
+ */
+
+ public function update ($aData)
+ {
+ $con = Propel::getConnection( AppDelegationPeer::DATABASE_NAME );
+ try {
+ $con->begin();
+ $oApp = AppDelegationPeer::retrieveByPK( $aData['APP_UID'], $aData['DEL_INDEX'] );
+ if (is_object( $oApp ) && get_class( $oApp ) == 'AppDelegation') {
+ $oApp->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
+ if ($oApp->validate()) {
+ $res = $oApp->save();
+ $con->commit();
+ return $res;
+ } else {
+ $msg = '';
+ foreach ($this->getValidationFailures() as $objValidationFailure) {
+ $msg .= $objValidationFailure->getMessage() . "
";
+ }
+
+ throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
+ }
+ } else {
+ $con->rollback();
+ throw (new Exception( "This AppDelegation row doesn't exist!" ));
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
+ }
+
+ function remove ($sApplicationUID, $iDelegationIndex)
+ {
+ $oConnection = Propel::getConnection( StepTriggerPeer::DATABASE_NAME );
+ try {
+ $oConnection->begin();
+ $oApp = AppDelegationPeer::retrieveByPK( $sApplicationUID, $iDelegationIndex );
+ if (is_object( $oApp ) && get_class( $oApp ) == 'AppDelegation') {
+ $result = $oApp->delete();
+ }
+ $oConnection->commit();
+ return $result;
+ } catch (Exception $e) {
+ $oConnection->rollback();
+ throw ($e);
+ }
+ }
+
+ // TasTypeDay = 1 => working days
+ // TasTypeDay = 2 => calendar days
+ function calculateDueDate ($sNextTasParam)
+ {
+ //Get Task properties
+ $task = TaskPeer::retrieveByPK( $this->getTasUid() );
+
+ $aData['TAS_UID'] = $this->getTasUid();
+ //Added to allow User defined Timing Control at Run time from Derivation screen
+ if (isset( $sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] ) && $sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] == 'true') {
+ $aData['TAS_DURATION'] = $sNextTasParam['NEXT_TASK']['TAS_DURATION'];
+ $aData['TAS_TIMEUNIT'] = $sNextTasParam['NEXT_TASK']['TAS_TIMEUNIT'];
+ $aData['TAS_TYPE_DAY'] = $sNextTasParam['NEXT_TASK']['TAS_TYPE_DAY'];
+
+ if (isset( $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'] ) && $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'] != '') {
+ $aCalendarUID = $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'];
+ } else {
+ $aCalendarUID = '';
+ }
+
+ //Updating the task Table , so that user will see updated values in the assign screen in consequent cases
+ $oTask = new Task();
+ $oTask->update( $aData );
+ } else {
+ if (is_null( $task )) {
+ return 0;
+ }
+ $aData['TAS_DURATION'] = $task->getTasDuration();
+ $aData['TAS_TIMEUNIT'] = $task->getTasTimeUnit();
+ $aData['TAS_TYPE_DAY'] = $task->getTasTypeDay();
+ $aCalendarUID = '';
+ }
+
+ //use the dates class to calculate dates
+ $dates = new dates();
+ $iDueDate = $dates->calculateDate( $this->getDelDelegateDate(), $aData['TAS_DURATION'], $aData['TAS_TIMEUNIT'], //hours or days, ( we only accept this two types or maybe weeks
+ $aData['TAS_TYPE_DAY'], //working or calendar days
+ $this->getUsrUid(), $task->getProUid(), $aData['TAS_UID'], $aCalendarUID );
+
+ return $iDueDate;
+ }
+
+ function getDiffDate ($date1, $date2)
+ {
+ return ($date1 - $date2) / (24 * 60 * 60); //days
+ return ($date1 - $date2) / 3600;
+ }
+
+ public function calculateDuration ($cron = 0)
+ {
+ try {
+ //patch rows with initdate = null and finish_date
+ $c = new Criteria();
+ $c->clearSelectColumns();
+ $c->addSelectColumn( AppDelegationPeer::APP_UID );
+ $c->addSelectColumn( AppDelegationPeer::DEL_INDEX );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DELEGATE_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );
+ $c->add( AppDelegationPeer::DEL_INIT_DATE, null, Criteria::ISNULL );
+ $c->add( AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNOTNULL );
+ //$c->add(AppDelegationPeer::DEL_INDEX, 1);
+
+
+ $rs = AppDelegationPeer::doSelectRS( $c );
+ $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $rs->next();
+ $row = $rs->getRow();
+
+ while (is_array( $row )) {
+ if ($cron == 1) {
+ $arrayCron = unserialize( trim( @file_get_contents( PATH_DATA . "cron" ) ) );
+ $arrayCron["processcTimeStart"] = time();
+ @file_put_contents( PATH_DATA . "cron", serialize( $arrayCron ) );
+ }
+
+ $oAppDel = AppDelegationPeer::retrieveByPk( $row['APP_UID'], $row['DEL_INDEX'] );
+ if (isset( $row['DEL_FINISH_DATE'] )) {
+ $oAppDel->setDelInitDate( $row['DEL_FINISH_DATE'] );
+ } else {
+ $oAppDel->setDelInitDate( $row['DEL_INIT_DATE'] );
+ }
+ $oAppDel->save();
+
+ $rs->next();
+ $row = $rs->getRow();
+ }
+ //walk in all rows with DEL_STARTED = 0 or DEL_FINISHED = 0
+
+
+ $c = new Criteria( 'workflow' );
+ $c->clearSelectColumns();
+ $c->addSelectColumn( AppDelegationPeer::APP_UID );
+ $c->addSelectColumn( AppDelegationPeer::DEL_INDEX );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DELEGATE_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_INIT_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_TASK_DUE_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DURATION );
+ $c->addSelectColumn( AppDelegationPeer::DEL_QUEUE_DURATION );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DELAY_DURATION );
+ $c->addSelectColumn( AppDelegationPeer::DEL_STARTED );
+ $c->addSelectColumn( AppDelegationPeer::DEL_FINISHED );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DELAYED );
+ $c->addSelectColumn( TaskPeer::TAS_DURATION );
+ $c->addSelectColumn( TaskPeer::TAS_TIMEUNIT );
+ $c->addSelectColumn( TaskPeer::TAS_TYPE_DAY );
+
+ $c->addJoin( AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN );
+ //$c->add(AppDelegationPeer::DEL_INIT_DATE, NULL, Criteria::ISNULL);
+ //$c->add(AppDelegationPeer::APP_UID, '7694483844a37bfeb0931b1063501289');
+ //$c->add(AppDelegationPeer::DEL_STARTED, 0);
+
+
+ $cton1 = $c->getNewCriterion( AppDelegationPeer::DEL_STARTED, 0 );
+ $cton2 = $c->getNewCriterion( AppDelegationPeer::DEL_FINISHED, 0 );
+ $cton1->addOR( $cton2 );
+ $c->add( $cton1 );
+
+ $rs = AppDelegationPeer::doSelectRS( $c );
+ $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $rs->next();
+ $row = $rs->getRow();
+ $i = 0;
+ //print "";
+ //print "| iDelegateDate | iInitDate | iDueDate | iFinishDate | isStarted | isFinished | isDelayed | queueDuration | delDuration | delayDuration |
";
+
+
+ $now = strtotime( 'now' );
+ while (is_array( $row )) {
+ if ($cron == 1) {
+ $arrayCron = unserialize( trim( @file_get_contents( PATH_DATA . "cron" ) ) );
+ $arrayCron["processcTimeStart"] = time();
+ @file_put_contents( PATH_DATA . "cron", serialize( $arrayCron ) );
+ }
+
+ $fTaskDuration = $row['TAS_DURATION'];
+ $iDelegateDate = strtotime( $row['DEL_DELEGATE_DATE'] );
+ $iInitDate = strtotime( $row['DEL_INIT_DATE'] );
+ $iDueDate = strtotime( $row['DEL_TASK_DUE_DATE'] );
+ $iFinishDate = strtotime( $row['DEL_FINISH_DATE'] );
+ $isStarted = intval( $row['DEL_STARTED'] );
+ $isFinished = intval( $row['DEL_FINISHED'] );
+ $isDelayed = intval( $row['DEL_DELAYED'] );
+ $queueDuration = $this->getDiffDate( $iInitDate, $iDelegateDate );
+ $delDuration = 0;
+ $delayDuration = 0;
+ $overduePercentage = 0.0;
+ //get the object,
+ $oAppDel = AppDelegationPeer::retrieveByPk( $row['APP_UID'], $row['DEL_INDEX'] );
+
+ //if the task is not started
+ if ($isStarted == 0) {
+ if ($row['DEL_INIT_DATE'] != null && $row['DEL_INIT_DATE'] != '') {
+ $oAppDel->setDelStarted( 1 );
+ $queueDuration = $this->getDiffDate( $iInitDate, $iDelegateDate );
+ $oAppDel->setDelQueueDuration( $queueDuration );
+ } else {
+ //the task was not started
+ $queueDuration = $this->getDiffDate( $now, $iDelegateDate );
+ $oAppDel->setDelQueueDuration( $queueDuration );
+
+ //we are putting negative number if the task is not delayed, and positive number for the time the task is delayed
+ $delayDuration = $this->getDiffDate( $now, $iDueDate );
+ $oAppDel->setDelDelayDuration( $delayDuration );
+ if ($fTaskDuration != 0) {
+ $overduePercentage = $delayDuration / $fTaskDuration;
+ $oAppDel->setAppOverduePercentage( $overduePercentage );
+ if ($iDueDate < $now) {
+ $oAppDel->setDelDelayed( 1 );
+ }
+ }
+ }
+ }
+
+ //if the task was not finished
+ if ($isFinished == 0) {
+ if ($row['DEL_FINISH_DATE'] != null && $row['DEL_FINISH_DATE'] != '') {
+ $oAppDel->setAppOverduePercentage( $overduePercentage );
+ $oAppDel->setDelFinished( 1 );
+
+ $delDuration = $this->getDiffDate( $iFinishDate, $iInitDate );
+ $oAppDel->setDelDuration( $delDuration );
+ //calculate due date if correspond
+ if ($iDueDate < $iFinishDate) {
+ $oAppDel->setDelDelayed( 1 );
+ $delayDuration = $this->getDiffDate( $iFinishDate, $iDueDate );
+ } else {
+ $oAppDel->setDelDelayed( 0 );
+ $delayDuration = 0;
+ }
+ } else {
+ //the task was not completed
+ if ($row['DEL_INIT_DATE'] != null && $row['DEL_INIT_DATE'] != '') {
+ $delDuration = $this->getDiffDate( $now, $iInitDate );
+ } else {
+ $delDuration = $this->getDiffDate( $now, $iDelegateDate );
+ }
+ $oAppDel->setDelDuration( $delDuration );
+
+ //we are putting negative number if the task is not delayed, and positive number for the time the task is delayed
+ $delayDuration = $this->getDiffDate( $now, $iDueDate );
+ $oAppDel->setDelDelayDuration( $delayDuration );
+ if ($fTaskDuration != 0) {
+ $overduePercentage = $delayDuration / $fTaskDuration;
+ $oAppDel->setAppOverduePercentage( $overduePercentage );
+ if ($iDueDate < $now) {
+ $oAppDel->setDelDelayed( 1 );
+ }
+ }
+ }
+
+ }
+
+ //and finally save the record
+ $RES = $oAppDel->save();
+ //print "| $iDelegateDate | $iInitDate | $iDueDate | $iFinishDate | $isStarted | $isFinished | $isDelayed | $queueDuration | $delDuration | " .
+ // "$delayDuration | $overduePercentage | " . $row['DEL_INDEX'] . " $RES |
";
+
+
+ //UPDATE APP_DELEGATION SET DEL_DELAYED = 0
+ //where
+ // APP_OVERDUE_PERCENTAGE < 0
+ $rs->next();
+ $row = $rs->getRow();
+
+ }
+ } catch (Exception $oError) {
+ error_log( $oError->getMessage() );
+ }
+ }
+
+ function getLastDeleration ($APP_UID)
+ {
+ $c = new Criteria( 'workflow' );
+ $c->addSelectColumn( AppDelegationPeer::APP_UID );
+ $c->addSelectColumn( AppDelegationPeer::DEL_INDEX );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DELEGATE_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_INIT_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_TASK_DUE_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DURATION );
+ $c->addSelectColumn( AppDelegationPeer::DEL_QUEUE_DURATION );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DELAY_DURATION );
+ $c->addSelectColumn( AppDelegationPeer::DEL_STARTED );
+ $c->addSelectColumn( AppDelegationPeer::DEL_FINISHED );
+ $c->addSelectColumn( AppDelegationPeer::DEL_DELAYED );
+ $c->addSelectColumn( AppDelegationPeer::USR_UID );
+
+ $c->add( AppDelegationPeer::APP_UID, $APP_UID );
+ $c->addDescendingOrderByColumn( AppDelegationPeer::DEL_INDEX );
+ $rs = AppDelegationPeer::doSelectRS( $c );
+ $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rs->next();
- $row = $rs->getRow();
-
- }
+ return $rs->getRow();
}
- catch (Exception $oError) {
- error_log( $oError->getMessage());
- }
- }
+}
+// AppDelegation
- function getLastDeleration($APP_UID){
- $c = new Criteria('workflow');
- $c->addSelectColumn(AppDelegationPeer::APP_UID );
- $c->addSelectColumn(AppDelegationPeer::DEL_INDEX );
- $c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
- $c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
- $c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
- $c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
- $c->addSelectColumn(AppDelegationPeer::DEL_DURATION);
- $c->addSelectColumn(AppDelegationPeer::DEL_QUEUE_DURATION);
- $c->addSelectColumn(AppDelegationPeer::DEL_DELAY_DURATION);
- $c->addSelectColumn(AppDelegationPeer::DEL_STARTED);
- $c->addSelectColumn(AppDelegationPeer::DEL_FINISHED);
- $c->addSelectColumn(AppDelegationPeer::DEL_DELAYED);
- $c->addSelectColumn(AppDelegationPeer::USR_UID);
-
- $c->add(AppDelegationPeer::APP_UID, $APP_UID);
- $c->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
- $rs = AppDelegationPeer::doSelectRS($c);
- $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $rs->next();
- return $rs->getRow();
- }
-} // AppDelegation
diff --git a/workflow/engine/classes/model/Dynaform.php b/workflow/engine/classes/model/Dynaform.php
index 30bc1b172..ed6bab459 100755
--- a/workflow/engine/classes/model/Dynaform.php
+++ b/workflow/engine/classes/model/Dynaform.php
@@ -1,7 +1,8 @@
.
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
@@ -26,8 +27,8 @@
require_once 'classes/model/om/BaseDynaform.php';
require_once 'classes/model/Content.php';
-require_once('classes/model/AdditionalTables.php');
-G::LoadClass('dynaFormField');
+require_once ('classes/model/AdditionalTables.php');
+G::LoadClass( 'dynaFormField' );
/**
* Skeleton subclass for representing a row from the 'DYNAFORM' table.
@@ -35,498 +36,509 @@ G::LoadClass('dynaFormField');
*
*
* You should add additional methods to this class to meet the
- * application requirements. This class will only be generated as
+ * application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
- * @package workflow.engine.classes.model
+ * @package workflow.engine.classes.model
*/
-class Dynaform extends BaseDynaform {
- /**
- * This value goes in the content table
- * @var string
- */
- protected $dyn_title = '';
+class Dynaform extends BaseDynaform
+{
+ /**
+ * This value goes in the content table
+ *
+ * @var string
+ */
+ protected $dyn_title = '';
- /**
- * Get the [Dyn_title] column value.
- * @return string
- */
- public function getDynTitle()
- {
- if ( $this->getDynUid() == '' ) {
- throw ( new Exception( "Error in getDynTitle, the DYN_UID can't be blank") );
- }
- $lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
- $this->dyn_title = Content::load ( 'DYN_TITLE', '', $this->getDynUid(), $lang );
- return $this->dyn_title;
- }
-
- /**
- * Set the [Dyn_title] column value.
- *
- * @param string $v new value
- * @return void
- */
- public function setDynTitle($v)
- {
- if ( $this->getDynUid() == '' ) {
- throw ( new Exception( "Error in setDynTitle, the DYN_UID can't be blank") );
- }
- // Since the native PHP type for this column is string,
- // we will cast the input to a string (if it is not).
- if ($v !== null && !is_string($v)) {
- $v = (string) $v;
- }
-
- if ($this->dyn_title !== $v || $v === '') {
- $this->dyn_title = $v;
- $lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
-
- $res = Content::addContent( 'DYN_TITLE', '', $this->getDynUid(), $lang, $this->dyn_title );
- }
-
- } // set()
-
- /**
- * This value goes in the content table
- * @var string
- */
- protected $dyn_description = '';
-
- /**
- * Get the [Dyn_description] column value.
- * @return string
- */
- public function getDynDescription()
- {
- if ( $this->getDynUid() == '' ) {
- throw ( new Exception( "Error in getDynDescription, the DYN_UID can't be blank") );
- }
- $lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
- $this->dyn_description = Content::load ( 'DYN_DESCRIPTION', '', $this->getDynUid(), $lang );
- return $this->dyn_description;
- }
-
- /**
- * Set the [Dyn_description] column value.
- *
- * @param string $v new value
- * @return void
- */
- public function setDynDescription($v)
- {
- if ( $this->getDynUid() == '' ) {
- throw ( new Exception( "Error in setDynDescription, the DYN_UID can't be blank") );
- }
- // Since the native PHP type for this column is string,
- // we will cast the input to a string (if it is not).
- if ($v !== null && !is_string($v)) {
- $v = (string) $v;
- }
-
- if ($this->dyn_description !== $v || $v === '') {
- $this->dyn_description = $v;
- $lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
-
- $res = Content::addContent( 'DYN_DESCRIPTION', '', $this->getDynUid(), $lang, $this->dyn_description );
- }
-
- } // set()
-
- /**
- * Creates the Dynaform
- *
- * @param array $aData Fields with :
- * $aData['DYN_UID'] the dynaform id
- * $aData['USR_UID'] the userid
- * @return void
- */
-
- function create ($aData ) {
- if ( !isset ( $aData['PRO_UID'] ) ) {
- throw ( new PropelException ( 'The dynaform cannot be created. The PRO_UID is empty.' ) );
- }
- $con = Propel::getConnection( DynaformPeer::DATABASE_NAME );
- try {
- if ( isset ( $aData['DYN_UID'] ) && $aData['DYN_UID']== '' )
- unset ( $aData['DYN_UID'] );
- if ( !isset ( $aData['DYN_UID'] ) )
- $dynUid = ( G::generateUniqueID() );
- else
- $dynUid = $aData['DYN_UID'];
- $this->setDynUid ( $dynUid );
- $this->setProUid ( $aData['PRO_UID'] );
- $this->setDynType ( isset($aData['DYN_TYPE'])?$aData['DYN_TYPE']:'xmlform' );
- $this->setDynFilename ( $aData['PRO_UID'] . PATH_SEP . $dynUid );
-
- if ( $this->validate() ) {
- $con->begin();
- $res = $this->save();
-
- if (isset ( $aData['DYN_TITLE'] ) )
- $this->setDynTitle ( $aData['DYN_TITLE'] );
- else
- $this->setDynTitle ( 'Default Dynaform Title' );
-
- if (isset ( $aData['DYN_DESCRIPTION'] ) )
- $this->setDynDescription ( $aData['DYN_DESCRIPTION'] );
- else
- $this->setDynDescription ( 'Default Dynaform Description' );
-
- $con->commit();
- $sXml = ''."\n";
- $sXml .= ''."\n";
- $sXml .= '';
- G::verifyPath(PATH_DYNAFORM . $this->getProUid(), true);
- $oFile = fopen(PATH_DYNAFORM . $this->getProUid() . '/' . $this->getDynUid() . '.xml', 'w');
- fwrite($oFile, $sXml);
- fclose($oFile);
- return $this->getDynUid();
- }
- else {
- $msg = '';
- foreach($this->getValidationFailures() as $objValidationFailure)
- $msg .= $objValidationFailure->getMessage() . "
";
- throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
- }
-
- }
- catch (Exception $e) {
- $con->rollback();
- throw ($e);
- }
- }
-
- /**
- *
- * Creates a Dynaform based on a PMTable
- *
- * @name createFromPMTable
- * @author gustavo cruz gustavo[at]colosa[dot]com
- * @param array $aData Fields with :
- * $aData['DYN_UID'] the dynaform id
- * $aData['USR_UID'] the userid
- * string $pmTableUid uid of the PMTable
- *
- */
-
- function createFromPMTable ( $aData, $pmTableUid ) {
- $this->create($aData);
- $aData['DYN_UID']=$this->getDynUid();
- //krumo(BasePeer::getFieldnames('Content'));
- $fields = array();
- //$oCriteria = new Criteria('workflow');
- $pmTable = AdditionalTablesPeer::retrieveByPK($pmTableUid);
- $addTabName = $pmTable->getAddTabName();
- $keys = '';
- if (isset($aData['FIELDS'])){
- foreach ($aData['FIELDS'] as $iRow => $row) {
- if ($keys!='')
- $keys = $keys.'|'.$row['PRO_VARIABLE'];
- else
- $keys = $row['PRO_VARIABLE'];
+ /**
+ * Get the [Dyn_title] column value.
+ *
+ * @return string
+ */
+ public function getDynTitle ()
+ {
+ if ($this->getDynUid() == '') {
+ throw (new Exception( "Error in getDynTitle, the DYN_UID can't be blank" ));
}
- } else {
- $keys = ' ';
- }
+ $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
+ $this->dyn_title = Content::load( 'DYN_TITLE', '', $this->getDynUid(), $lang );
+ return $this->dyn_title;
+ }
-// $addTabKeys = $pmTable->getAddTabDynavars();
-// $addTabKeys = unserialize($addTabKeys);
-// $keys = '';
-// foreach ( $addTabKeys as $addTabKey ){
-// if (trim($addTabKey['CASE_VARIABLE'])!=''&&$keys!=''){
-// $keys = $keys.'|'.$addTabKey['CASE_VARIABLE'];
-// } else {
-// $keys = $addTabKey['CASE_VARIABLE'];
-// }
-//
-// }
-
- // Determines the engine to use
- // For a description of a table
- $sDataBase = 'database_' . strtolower(DB_ADAPTER);
- if(G::LoadSystemExist($sDataBase)){
- G::LoadSystem($sDataBase);
- $oDataBase = new database();
- $sql = $oDataBase->getTableDescription($addTabName);
- } else {
- $sql = 'DESC '.$addTabName;
- }
-
- $dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
- $sth = $dbh->createStatement();
- $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
-
- $file = $aData['PRO_UID'].'/'.$aData['DYN_UID'];
- $dbc = new DBConnection( PATH_DYNAFORM . $file . '.xml' ,'','','','myxml' );
- $ses = new DBSession($dbc);
- $fieldXML = new DynaFormField( $dbc );
-
- $pmConnectionName = $addTabName.'_CONNECTION';
-
- if ($aData['DYN_TYPE']=='xmlform'){
- $labels = array();
- $options = array();
- $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $pmConnectionName, 'TYPE' => 'pmconnection', 'PMTABLE' => $pmTableUid, 'KEYS'=>$keys);
- $fieldXML->Save($attributes, $labels, $options);
- }
-
- $keyRequered = '';
- $countKeys = 0;
- while ($res->next()) {
- if ($res->get('Key') != '') {
- $countKeys++;
+ /**
+ * Set the [Dyn_title] column value.
+ *
+ * @param string $v new value
+ * @return void
+ */
+ public function setDynTitle ($v)
+ {
+ if ($this->getDynUid() == '') {
+ throw (new Exception( "Error in setDynTitle, the DYN_UID can't be blank" ));
}
- if ($res->get('Extra') == 'auto_increment') {
- $keyRequered .= $res->get('Field');
+ // Since the native PHP type for this column is string,
+ // we will cast the input to a string (if it is not).
+ if ($v !== null && ! is_string( $v )) {
+ $v = (string) $v;
}
- }
- $dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
- $sth = $dbh->createStatement();
- $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
+ if ($this->dyn_title !== $v || $v === '') {
+ $this->dyn_title = $v;
+ $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
- while ($res->next()){
- // if(strtoupper($res->get('Null'))=='NO') {
- if(strtoupper($res->get($oDataBase->getFieldNull() ))=='NO'){
- if ($countKeys == 1 && $res->get('Field') == $keyRequered) {
- $required = '0';
- } else {
- $required = '1';
- }
+ $res = Content::addContent( 'DYN_TITLE', '', $this->getDynUid(), $lang, $this->dyn_title );
+ }
+
+ } // set()
+
+
+ /**
+ * This value goes in the content table
+ *
+ * @var string
+ */
+ protected $dyn_description = '';
+
+ /**
+ * Get the [Dyn_description] column value.
+ *
+ * @return string
+ */
+ public function getDynDescription ()
+ {
+ if ($this->getDynUid() == '') {
+ throw (new Exception( "Error in getDynDescription, the DYN_UID can't be blank" ));
+ }
+ $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
+ $this->dyn_description = Content::load( 'DYN_DESCRIPTION', '', $this->getDynUid(), $lang );
+ return $this->dyn_description;
+ }
+
+ /**
+ * Set the [Dyn_description] column value.
+ *
+ * @param string $v new value
+ * @return void
+ */
+ public function setDynDescription ($v)
+ {
+ if ($this->getDynUid() == '') {
+ throw (new Exception( "Error in setDynDescription, the DYN_UID can't be blank" ));
+ }
+ // Since the native PHP type for this column is string,
+ // we will cast the input to a string (if it is not).
+ if ($v !== null && ! is_string( $v )) {
+ $v = (string) $v;
+ }
+
+ if ($this->dyn_description !== $v || $v === '') {
+ $this->dyn_description = $v;
+ $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
+
+ $res = Content::addContent( 'DYN_DESCRIPTION', '', $this->getDynUid(), $lang, $this->dyn_description );
+ }
+
+ } // set()
+
+
+ /**
+ * Creates the Dynaform
+ *
+ * @param array $aData Fields with :
+ * $aData['DYN_UID'] the dynaform id
+ * $aData['USR_UID'] the userid
+ * @return void
+ */
+
+ function create ($aData)
+ {
+ if (! isset( $aData['PRO_UID'] )) {
+ throw (new PropelException( 'The dynaform cannot be created. The PRO_UID is empty.' ));
+ }
+ $con = Propel::getConnection( DynaformPeer::DATABASE_NAME );
+ try {
+ if (isset( $aData['DYN_UID'] ) && $aData['DYN_UID'] == '') {
+ unset( $aData['DYN_UID'] );
+ }
+ if (! isset( $aData['DYN_UID'] )) {
+ $dynUid = (G::generateUniqueID());
+ } else {
+ $dynUid = $aData['DYN_UID'];
+ }
+ $this->setDynUid( $dynUid );
+ $this->setProUid( $aData['PRO_UID'] );
+ $this->setDynType( isset( $aData['DYN_TYPE'] ) ? $aData['DYN_TYPE'] : 'xmlform' );
+ $this->setDynFilename( $aData['PRO_UID'] . PATH_SEP . $dynUid );
+
+ if ($this->validate()) {
+ $con->begin();
+ $res = $this->save();
+
+ if (isset( $aData['DYN_TITLE'] )) {
+ $this->setDynTitle( $aData['DYN_TITLE'] );
+ } else {
+ $this->setDynTitle( 'Default Dynaform Title' );
+ }
+
+ if (isset( $aData['DYN_DESCRIPTION'] )) {
+ $this->setDynDescription( $aData['DYN_DESCRIPTION'] );
+ } else {
+ $this->setDynDescription( 'Default Dynaform Description' );
+ }
+
+ $con->commit();
+ $sXml = '' . "\n";
+ $sXml .= '' . "\n";
+ $sXml .= '';
+ G::verifyPath( PATH_DYNAFORM . $this->getProUid(), true );
+ $oFile = fopen( PATH_DYNAFORM . $this->getProUid() . '/' . $this->getDynUid() . '.xml', 'w' );
+ fwrite( $oFile, $sXml );
+ fclose( $oFile );
+ return $this->getDynUid();
+ } else {
+ $msg = '';
+ foreach ($this->getValidationFailures() as $objValidationFailure) {
+ $msg .= $objValidationFailure->getMessage() . "
";
+ }
+ throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
+ }
+
+ } catch (Exception $e) {
+ $con->rollback();
+ throw ($e);
+ }
+ }
+
+ /**
+ *
+ *
+ * Creates a Dynaform based on a PMTable
+ *
+ * @name createFromPMTable
+ * @author gustavo cruz gustavo[at]colosa[dot]com
+ * @param array $aData Fields with :
+ * $aData['DYN_UID'] the dynaform id
+ * $aData['USR_UID'] the userid
+ * string $pmTableUid uid of the PMTable
+ *
+ */
+
+ function createFromPMTable ($aData, $pmTableUid)
+ {
+ $this->create( $aData );
+ $aData['DYN_UID'] = $this->getDynUid();
+ //krumo(BasePeer::getFieldnames('Content'));
+ $fields = array ();
+ //$oCriteria = new Criteria('workflow');
+ $pmTable = AdditionalTablesPeer::retrieveByPK( $pmTableUid );
+ $addTabName = $pmTable->getAddTabName();
+ $keys = '';
+ if (isset( $aData['FIELDS'] )) {
+ foreach ($aData['FIELDS'] as $iRow => $row) {
+ if ($keys != '') {
+ $keys = $keys . '|' . $row['PRO_VARIABLE'];
+ } else {
+ $keys = $row['PRO_VARIABLE'];
+ }
+ }
} else {
- $required = '0';
+ $keys = ' ';
}
- $fieldName = $res->get('Field');
- $defaultValue = $res->get('Default');
- $labels = array ( SYS_LANG => $fieldName );
- $options = array();
- $type = explode('(',$res->get('Type'));
- switch ($type[0]){
- case 'text':
- $type = 'textarea';
- break;
- case 'date':
- $type = 'date';
- break;
- default:
- $type = 'text';
- break;
- }
- if ($aData['DYN_TYPE']=='xmlform'){
- $attributes = array(
- 'XMLNODE_NAME_OLD' => '',
- 'XMLNODE_NAME' => $fieldName,
- 'TYPE' => $type,
- 'PMCONNECTION' => $pmConnectionName,
- 'PMFIELD' => $fieldName,
- 'REQUIRED' => $required,
- 'DEFAULTVALUE' => $defaultValue
- );
+ // $addTabKeys = $pmTable->getAddTabDynavars();
+ // $addTabKeys = unserialize($addTabKeys);
+ // $keys = '';
+ // foreach ( $addTabKeys as $addTabKey ){
+ // if (trim($addTabKey['CASE_VARIABLE'])!=''&&$keys!=''){
+ // $keys = $keys.'|'.$addTabKey['CASE_VARIABLE'];
+ // } else {
+ // $keys = $addTabKey['CASE_VARIABLE'];
+ // }
+ //
+ // }
+
+
+ // Determines the engine to use
+ // For a description of a table
+ $sDataBase = 'database_' . strtolower( DB_ADAPTER );
+ if (G::LoadSystemExist( $sDataBase )) {
+ G::LoadSystem( $sDataBase );
+ $oDataBase = new database();
+ $sql = $oDataBase->getTableDescription( $addTabName );
} else {
- $attributes = array(
- 'XMLNODE_NAME_OLD' => '',
- 'XMLNODE_NAME' => $fieldName,
- 'TYPE' => $type,
- 'REQUIRED' => $required,
- 'DEFAULTVALUE' => $defaultValue
- );
+ $sql = 'DESC ' . $addTabName;
}
- $fieldXML->Save($attributes, $labels, $options);
- }
- $labels = array ( SYS_LANG => 'Submit' );
- $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => 'SUBMIT', 'TYPE' => 'submit');
- $fieldXML->Save($attributes, $labels, $options);
- }
- /**
- * Load the Dynaform row specified in [dyn_id] column value.
- *
- * @param string $ProUid the uid of the Prolication
- * @return array $Fields the fields
- */
- function Load ( $ProUid ) {
- $con = Propel::getConnection(DynaformPeer::DATABASE_NAME);
- try {
- $oPro = DynaformPeer::retrieveByPk( $ProUid );
- if (is_object($oPro) && get_class ($oPro) == 'Dynaform' ) {
- $aFields = $oPro->toArray(BasePeer::TYPE_FIELDNAME);
- $this->fromArray ($aFields, BasePeer::TYPE_FIELDNAME );
- $aFields['DYN_TITLE'] = $oPro->getDynTitle();
- $aFields['DYN_DESCRIPTION'] = $oPro->getDynDescription();
- $this->setDynTitle ( $oPro->getDynTitle() );
- $this->setDynDescription ( $oPro->getDynDescription() );
- return $aFields;
- }
- else {
- throw(new Exception( "The row '$ProUid' in table Dynaform doesn't exist!" ));
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
+ $dbh = Propel::getConnection( AdditionalTablesPeer::DATABASE_NAME );
+ $sth = $dbh->createStatement();
+ $res = $sth->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC );
- /**
- * Update the Prolication row
- * @param array $aData
- * @return variant
- **/
+ $file = $aData['PRO_UID'] . '/' . $aData['DYN_UID'];
+ $dbc = new DBConnection( PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml' );
+ $ses = new DBSession( $dbc );
+ $fieldXML = new DynaFormField( $dbc );
- public function update($aData)
- {
- $con = Propel::getConnection( DynaformPeer::DATABASE_NAME );
- try {
- $con->begin();
- $oPro = DynaformPeer::retrieveByPK( $aData['DYN_UID'] );
- if (is_object($oPro) && get_class ($oPro) == 'Dynaform' ) {
- $oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
- if ($oPro->validate()) {
- if ( isset ( $aData['DYN_TITLE'] ) )
- $oPro->setDynTitle( $aData['DYN_TITLE'] );
- if ( isset ( $aData['DYN_DESCRIPTION'] ) )
- $oPro->setDynDescription( $aData['DYN_DESCRIPTION'] );
- $res = $oPro->save();
- $con->commit();
- return $res;
+ $pmConnectionName = $addTabName . '_CONNECTION';
+
+ if ($aData['DYN_TYPE'] == 'xmlform') {
+ $labels = array ();
+ $options = array ();
+ $attributes = array ('XMLNODE_NAME_OLD' => '','XMLNODE_NAME' => $pmConnectionName,'TYPE' => 'pmconnection','PMTABLE' => $pmTableUid,'KEYS' => $keys
+ );
+ $fieldXML->Save( $attributes, $labels, $options );
}
- else {
- foreach($this->getValidationFailures() as $objValidationFailure)
- $msg .= $objValidationFailure->getMessage() . "
";
- throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
+
+ $keyRequered = '';
+ $countKeys = 0;
+ while ($res->next()) {
+ if ($res->get( 'Key' ) != '') {
+ $countKeys ++;
+ }
+ if ($res->get( 'Extra' ) == 'auto_increment') {
+ $keyRequered .= $res->get( 'Field' );
+ }
}
- }
- else {
- $con->rollback();
- throw(new Exception( "The row '" . $aData['DYN_UID'] . "' in table Dynaform doesn't exist!" ));
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
- /**
- * Remove the Prolication document registry
- * @param array $aData or string $ProUid
- * @return string
- **/
- public function remove($ProUid)
- {
- if ( is_array ( $ProUid ) ) {
- $ProUid = ( isset ( $ProUid['DYN_UID'] ) ? $ProUid['DYN_UID'] : '' );
- }
- try {
- $oPro = DynaformPeer::retrieveByPK( $ProUid );
- if (!is_null($oPro))
- {
- Content::removeContent('DYN_TITLE', '', $oPro->getDynUid());
- Content::removeContent('DYN_DESCRIPTION', '', $oPro->getDynUid());
- $iResult = $oPro->delete();
- if (file_exists(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.xml')) {
- unlink(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.xml');
+ $dbh = Propel::getConnection( AdditionalTablesPeer::DATABASE_NAME );
+ $sth = $dbh->createStatement();
+ $res = $sth->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC );
+
+ while ($res->next()) {
+ // if(strtoupper($res->get('Null'))=='NO') {
+ if (strtoupper( $res->get( $oDataBase->getFieldNull() ) ) == 'NO') {
+ if ($countKeys == 1 && $res->get( 'Field' ) == $keyRequered) {
+ $required = '0';
+ } else {
+ $required = '1';
+ }
+ } else {
+ $required = '0';
+ }
+ $fieldName = $res->get( 'Field' );
+ $defaultValue = $res->get( 'Default' );
+ $labels = array (SYS_LANG => $fieldName
+ );
+ $options = array ();
+ $type = explode( '(', $res->get( 'Type' ) );
+
+ switch ($type[0]) {
+ case 'text':
+ $type = 'textarea';
+ break;
+ case 'date':
+ $type = 'date';
+ break;
+ default:
+ $type = 'text';
+ break;
+ }
+ if ($aData['DYN_TYPE'] == 'xmlform') {
+ $attributes = array ('XMLNODE_NAME_OLD' => '','XMLNODE_NAME' => $fieldName,'TYPE' => $type,'PMCONNECTION' => $pmConnectionName,'PMFIELD' => $fieldName,'REQUIRED' => $required,'DEFAULTVALUE' => $defaultValue
+ );
+ } else {
+ $attributes = array ('XMLNODE_NAME_OLD' => '','XMLNODE_NAME' => $fieldName,'TYPE' => $type,'REQUIRED' => $required,'DEFAULTVALUE' => $defaultValue
+ );
+ }
+ $fieldXML->Save( $attributes, $labels, $options );
}
- if (file_exists(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '_tmp0.xml')) {
- unlink(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '_tmp0.xml');
+ $labels = array (SYS_LANG => 'Submit'
+ );
+ $attributes = array ('XMLNODE_NAME_OLD' => '','XMLNODE_NAME' => 'SUBMIT','TYPE' => 'submit'
+ );
+ $fieldXML->Save( $attributes, $labels, $options );
+ }
+
+ /**
+ * Load the Dynaform row specified in [dyn_id] column value.
+ *
+ * @param string $ProUid the uid of the Prolication
+ * @return array $Fields the fields
+ */
+
+ function Load ($ProUid)
+ {
+ $con = Propel::getConnection( DynaformPeer::DATABASE_NAME );
+ try {
+ $oPro = DynaformPeer::retrieveByPk( $ProUid );
+ if (is_object( $oPro ) && get_class( $oPro ) == 'Dynaform') {
+ $aFields = $oPro->toArray( BasePeer::TYPE_FIELDNAME );
+ $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
+ $aFields['DYN_TITLE'] = $oPro->getDynTitle();
+ $aFields['DYN_DESCRIPTION'] = $oPro->getDynDescription();
+ $this->setDynTitle( $oPro->getDynTitle() );
+ $this->setDynDescription( $oPro->getDynDescription() );
+ return $aFields;
+ } else {
+ throw (new Exception( "The row '$ProUid' in table Dynaform doesn't exist!" ));
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
}
- if (file_exists(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.html')) {
- unlink(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.html');
+ }
+
+ /**
+ * Update the Prolication row
+ *
+ * @param array $aData
+ * @return variant
+ *
+ */
+
+ public function update ($aData)
+ {
+ $con = Propel::getConnection( DynaformPeer::DATABASE_NAME );
+ try {
+ $con->begin();
+ $oPro = DynaformPeer::retrieveByPK( $aData['DYN_UID'] );
+ if (is_object( $oPro ) && get_class( $oPro ) == 'Dynaform') {
+ $oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
+ if ($oPro->validate()) {
+ if (isset( $aData['DYN_TITLE'] )) {
+ $oPro->setDynTitle( $aData['DYN_TITLE'] );
+ }
+ if (isset( $aData['DYN_DESCRIPTION'] )) {
+ $oPro->setDynDescription( $aData['DYN_DESCRIPTION'] );
+ }
+ $res = $oPro->save();
+ $con->commit();
+ return $res;
+ } else {
+ foreach ($this->getValidationFailures() as $objValidationFailure) {
+ $msg .= $objValidationFailure->getMessage() . "
";
+ }
+ throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
+ }
+ } else {
+ $con->rollback();
+ throw (new Exception( "The row '" . $aData['DYN_UID'] . "' in table Dynaform doesn't exist!" ));
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
}
- if (file_exists(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '_tmp0.html')) {
- unlink(PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '_tmp0.html');
+ }
+
+ /**
+ * Remove the Prolication document registry
+ *
+ * @param array $aData or string $ProUid
+ * @return string
+ *
+ */
+ public function remove ($ProUid)
+ {
+ if (is_array( $ProUid )) {
+ $ProUid = (isset( $ProUid['DYN_UID'] ) ? $ProUid['DYN_UID'] : '');
+ }
+ try {
+ $oPro = DynaformPeer::retrieveByPK( $ProUid );
+ if (! is_null( $oPro )) {
+ Content::removeContent( 'DYN_TITLE', '', $oPro->getDynUid() );
+ Content::removeContent( 'DYN_DESCRIPTION', '', $oPro->getDynUid() );
+ $iResult = $oPro->delete();
+ if (file_exists( PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.xml' )) {
+ unlink( PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.xml' );
+ }
+ if (file_exists( PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '_tmp0.xml' )) {
+ unlink( PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '_tmp0.xml' );
+ }
+ if (file_exists( PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.html' )) {
+ unlink( PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '.html' );
+ }
+ if (file_exists( PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '_tmp0.html' )) {
+ unlink( PATH_DYNAFORM . $oPro->getProUid() . PATH_SEP . $oPro->getDynUid() . '_tmp0.html' );
+ }
+ return $iResult;
+ } else {
+ throw (new Exception( "The row '$ProUid' in table Dynaform doesn't exist!" ));
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
}
- return $iResult;
- }
- else {
- throw(new Exception( "The row '$ProUid' in table Dynaform doesn't exist!" ));
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- public function exists($DynUid)
- {
- $oPro = DynaformPeer::retrieveByPk( $DynUid );
- return (is_object($oPro) && get_class ($oPro) == 'Dynaform' );
- }
-
- /**
- * verify if Dynaform row specified in [DynUid] exists.
- *
- * @param string $sProUid the uid of the Prolication
- */
-
- function dynaformExists ( $DynUid ) {
- $con = Propel::getConnection(TaskPeer::DATABASE_NAME);
- try {
- $oDyn = DynaformPeer::retrieveByPk( $DynUid );
- if (is_object($oDyn) && get_class ($oDyn) == 'Dynaform' ) {
- return true;
- }
- else {
- return false;
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- function getDynaformContent( $dynaformUid) {
- $content = '';
- $fields = $this->Load ( $dynaformUid);
- $filename = PATH_DYNAFORM . $fields['PRO_UID'] . PATH_SEP . $fields['DYN_UID'] . '.xml';
- if (file_exists( $filename )) {
- $content = file_get_contents ( $filename );
}
- return $content;
- }
-
- function getDynaformFields( $dynaformUid) {
- $content = '';
- $fields = $this->Load ( $dynaformUid);
- $filename = PATH_DYNAFORM . $fields['PRO_UID'] . PATH_SEP . $fields['DYN_UID'] . '.xml';
- if (file_exists( $filename )) {
- $content = file_get_contents ( $filename );
+ public function exists ($DynUid)
+ {
+ $oPro = DynaformPeer::retrieveByPk( $DynUid );
+ return (is_object( $oPro ) && get_class( $oPro ) == 'Dynaform');
}
- $G_FORM = new xmlform ( $fields['DYN_FILENAME'] , PATH_DYNAFORM );
- $G_FORM->parseFile( $filename , SYS_LANG, true );
+ /**
+ * verify if Dynaform row specified in [DynUid] exists.
+ *
+ * @param string $sProUid the uid of the Prolication
+ */
- return $G_FORM->fields;
- }
-
- function verifyExistingName($sName,$sProUid){
- $sNameDyanform=urldecode($sName);
- $sProUid=urldecode($sProUid);
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn ( DynaformPeer::DYN_UID );
- $oCriteria->add( DynaformPeer::PRO_UID, $sProUid );
- $oDataset = DynaformPeer::doSelectRS( $oCriteria );
- $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
- $flag=true;
- while ($oDataset->next() && $flag) {
- $aRow = $oDataset->getRow();
- $oCriteria1 = new Criteria('workflow');
- $oCriteria1->addSelectColumn('COUNT(*) AS DYNAFORMS');
- $oCriteria1->add(ContentPeer::CON_CATEGORY, 'DYN_TITLE');
- $oCriteria1->add(ContentPeer::CON_ID, $aRow['DYN_UID']);
- $oCriteria1->add(ContentPeer::CON_VALUE, $sNameDyanform);
- $oCriteria1->add(ContentPeer::CON_LANG, SYS_LANG);
- $oDataset1 = ContentPeer::doSelectRS($oCriteria1);
- $oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset1->next();
- $aRow1 = $oDataset1->getRow();
- if($aRow1['DYNAFORMS']) {
- $flag =false;
- break;
- }
+ function dynaformExists ($DynUid)
+ {
+ $con = Propel::getConnection( TaskPeer::DATABASE_NAME );
+ try {
+ $oDyn = DynaformPeer::retrieveByPk( $DynUid );
+ if (is_object( $oDyn ) && get_class( $oDyn ) == 'Dynaform') {
+ return true;
+ } else {
+ return false;
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- return $flag;
- }
-} // Dynaform
+ function getDynaformContent ($dynaformUid)
+ {
+ $content = '';
+ $fields = $this->Load( $dynaformUid );
+ $filename = PATH_DYNAFORM . $fields['PRO_UID'] . PATH_SEP . $fields['DYN_UID'] . '.xml';
+ if (file_exists( $filename )) {
+ $content = file_get_contents( $filename );
+ }
+
+ return $content;
+ }
+
+ function getDynaformFields ($dynaformUid)
+ {
+ $content = '';
+ $fields = $this->Load( $dynaformUid );
+ $filename = PATH_DYNAFORM . $fields['PRO_UID'] . PATH_SEP . $fields['DYN_UID'] . '.xml';
+ if (file_exists( $filename )) {
+ $content = file_get_contents( $filename );
+ }
+
+ $G_FORM = new xmlform( $fields['DYN_FILENAME'], PATH_DYNAFORM );
+ $G_FORM->parseFile( $filename, SYS_LANG, true );
+
+ return $G_FORM->fields;
+ }
+
+ function verifyExistingName ($sName, $sProUid)
+ {
+ $sNameDyanform = urldecode( $sName );
+ $sProUid = urldecode( $sProUid );
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addSelectColumn( DynaformPeer::DYN_UID );
+ $oCriteria->add( DynaformPeer::PRO_UID, $sProUid );
+ $oDataset = DynaformPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $flag = true;
+ while ($oDataset->next() && $flag) {
+ $aRow = $oDataset->getRow();
+ $oCriteria1 = new Criteria( 'workflow' );
+ $oCriteria1->addSelectColumn( 'COUNT(*) AS DYNAFORMS' );
+ $oCriteria1->add( ContentPeer::CON_CATEGORY, 'DYN_TITLE' );
+ $oCriteria1->add( ContentPeer::CON_ID, $aRow['DYN_UID'] );
+ $oCriteria1->add( ContentPeer::CON_VALUE, $sNameDyanform );
+ $oCriteria1->add( ContentPeer::CON_LANG, SYS_LANG );
+ $oDataset1 = ContentPeer::doSelectRS( $oCriteria1 );
+ $oDataset1->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset1->next();
+ $aRow1 = $oDataset1->getRow();
+ if ($aRow1['DYNAFORMS']) {
+ $flag = false;
+ break;
+ }
+ }
+ return $flag;
+ }
+}
+// Dynaform
+
diff --git a/workflow/engine/classes/model/Groupwf.php b/workflow/engine/classes/model/Groupwf.php
index 91189ecbb..b36e60918 100755
--- a/workflow/engine/classes/model/Groupwf.php
+++ b/workflow/engine/classes/model/Groupwf.php
@@ -1,7 +1,8 @@
.
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
@@ -33,387 +34,399 @@ require_once 'classes/model/Content.php';
*
*
* You should add additional methods to this class to meet the
- * application requirements. This class will only be generated as
+ * application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
- * @package workflow.engine.classes.model
+ * @package workflow.engine.classes.model
*/
-class Groupwf extends BaseGroupwf {
- /**
- * This value goes in the content table
- * @var string
- */
- //protected $grp_title = '';
- protected $grp_title = '';
+class Groupwf extends BaseGroupwf
+{
+ /**
+ * This value goes in the content table
+ *
+ * @var string
+ */
+ //protected $grp_title = '';
+ protected $grp_title = '';
- /**
- * Get the [grp_title] column value.
- * @return string
- */
- public function getGrpTitle()
- {
- if ( $this->getGrpUid() == '' ) {
- throw ( new Exception( "Error in getGrpTitle, the GRP_UID can't be blank") );
- }
- $lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
- $this->grp_title = Content::load ( 'GRP_TITLE', '', $this->getGrpUid(), $lang );
- return $this->grp_title;
- }
-
- /**
- * Set the [grp_title] column value.
- *
- * @param string $v new value
- * @return void
- */
- public function setGrpTitle($v)
- {
- if ( $this->getGrpUid() == '' ) {
- throw ( new Exception( "Error in setGrpTitle, the GRP_UID can't be blank") );
- }
- // Since the native PHP type for this column is string,
- // we will cast the input to a string (if it is not).
- if ($v !== null && !is_string($v)) {
- $v = (string) $v;
- }
-
- if ($this->grp_title !== $v || $v === '') {
- $this->grp_title = $v;
- $lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
- $res = Content::addContent( 'GRP_TITLE', '', $this->getGrpUid(), $lang, $this->grp_title );
- }
-
- } // set()
-
- /**
- * Creates the Group
- *
- * @param array $aData $oData is not necessary
- * @return void
- */
-
- function create ($aData ) {
- //$oData is not necessary
- $con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
- try {
- if ( isset ( $aData['GRP_UID'] ) )
- $this->setGrpUid ( $aData['GRP_UID'] );
- else
- $this->setGrpUid ( G::generateUniqueID() );
-
- if ( isset ( $aData['GRP_STATUS'] ) )
- $this->setGrpStatus ( $aData['GRP_STATUS'] );
- else
- $this->setGrpStatus ( 'ACTIVE' );
-
- if ( isset ( $aData['GRP_LDAP_DN'] ) )
- $this->setGrpLdapDn ( $aData['GRP_LDAP_DN'] );
- else
- $this->setGrpLdapDn ( '' );
-
- if ( $this->validate() ) {
- $con->begin();
- $res = $this->save();
-
- if (isset ( $aData['GRP_TITLE'] ) )
- $this->setGrpTitle ( $aData['GRP_TITLE'] );
- else
- $this->setGrpTitle ( 'Default Group Title' );
-
- $con->commit();
- return $this->getGrpUid();
- }
- else {
- $msg = '';
- foreach($this->getValidationFailures() as $objValidationFailure)
- $msg .= $objValidationFailure->getMessage() . "
";
-
- throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
- }
-
- }
- catch (Exception $e) {
- $con->rollback();
- throw ($e);
- }
- }
-
- /**
- * Load the Process row specified in [grp_id] column value.
- *
- * @param string $ProUid the uid of the Prolication
- * @return array $Fields the fields
- */
-
- function Load ( $ProUid ) {
- $con = Propel::getConnection(GroupwfPeer::DATABASE_NAME);
- try {
- $oPro = GroupwfPeer::retrieveByPk( $ProUid );
- if (is_object($oPro) && get_class ($oPro) == 'Groupwf' ) {
- $aFields = $oPro->toArray(BasePeer::TYPE_FIELDNAME);
- $this->fromArray ($aFields, BasePeer::TYPE_FIELDNAME );
- $aFields['GRP_TITLE'] = $oPro->getGrpTitle();
- $this->setGrpTitle ( $oPro->getGrpTitle() );
- return $aFields;
- }
- else {
- throw(new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- /**
- * Update the Group row
- * @param array $aData
- * @return variant
- **/
-
- public function update($aData)
- {
- $con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
- try {
- $con->begin();
- $oPro = GroupwfPeer::retrieveByPK( $aData['GRP_UID'] );
- if (is_object($oPro) && get_class ($oPro) == 'Groupwf' ) {
- $oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
- if ($oPro->validate()) {
- if ( isset ( $aData['GRP_TITLE'] ) )
- $oPro->setGrpTitle( $aData['GRP_TITLE'] );
- $res = $oPro->save();
- $con->commit();
- return $res;
+ /**
+ * Get the [grp_title] column value.
+ *
+ * @return string
+ */
+ public function getGrpTitle ()
+ {
+ if ($this->getGrpUid() == '') {
+ throw (new Exception( "Error in getGrpTitle, the GRP_UID can't be blank" ));
}
- else {
- $msg = '';
- foreach($this->getValidationFailures() as $objValidationFailure)
- $msg .= $objValidationFailure->getMessage() . "
";
+ $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
+ $this->grp_title = Content::load( 'GRP_TITLE', '', $this->getGrpUid(), $lang );
+ return $this->grp_title;
+ }
- throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
+ /**
+ * Set the [grp_title] column value.
+ *
+ * @param string $v new value
+ * @return void
+ */
+ public function setGrpTitle ($v)
+ {
+ if ($this->getGrpUid() == '') {
+ throw (new Exception( "Error in setGrpTitle, the GRP_UID can't be blank" ));
+ }
+ // Since the native PHP type for this column is string,
+ // we will cast the input to a string (if it is not).
+ if ($v !== null && ! is_string( $v )) {
+ $v = (string) $v;
}
- }
- else {
- $con->rollback();
- throw(new Exception( "The row '" . $aData['GRP_UID'] . "' in table Group doesn't exist!" ));
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
- /**
- * Remove the Prolication document registry
- * @param array $aData or string $ProUid
- * @return string
- **/
- public function remove($ProUid)
- {
- if ( is_array ( $ProUid ) ) {
- $ProUid = ( isset ( $ProUid['GRP_UID'] ) ? $ProUid['GRP_UID'] : '' );
- }
- try {
- $oPro = GroupwfPeer::retrieveByPK( $ProUid );
- if (!is_null($oPro))
- {
- Content::removeContent('GRP_TITLE', '', $oPro->getGrpUid());
- Content::removeContent('GRP_DESCRIPTION', '', $oPro->getGrpUid());
- return $oPro->delete();
- }
- else {
- throw(new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
+ if ($this->grp_title !== $v || $v === '') {
+ $this->grp_title = $v;
+ $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
+ $res = Content::addContent( 'GRP_TITLE', '', $this->getGrpUid(), $lang, $this->grp_title );
+ }
- /**
- * verify if row specified in [GrpUid] exists.
- *
- * @param string $sProUid the uid of the Prolication
- */
+ } // set()
- function GroupwfExists ( $GrpUid ) {
- $con = Propel::getConnection(GroupwfPeer::DATABASE_NAME);
- try {
- $oPro = GroupwfPeer::retrieveByPk( $GrpUid );
- if (is_object($oPro) && get_class ($oPro) == 'Groupwf' ) {
- return true;
- }
- else {
- return false;
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
- function loadByGroupname ( $Groupname ) {
- $c = new Criteria('workflow');
- $del = DBAdapter::getStringDelimiter();
+ /**
+ * Creates the Group
+ *
+ * @param array $aData $oData is not necessary
+ * @return void
+ */
- $c->clearSelectColumns();
- $c->addSelectColumn( ContentPeer::CON_CATEGORY );
- $c->addSelectColumn( ContentPeer::CON_VALUE );
+ function create ($aData)
+ {
+ //$oData is not necessary
+ $con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
+ try {
+ if (isset( $aData['GRP_UID'] )) {
+ $this->setGrpUid( $aData['GRP_UID'] );
+ } else {
+ $this->setGrpUid( G::generateUniqueID() );
+ }
- $c->add(ContentPeer::CON_CATEGORY, 'GRP_TITLE');
- $c->add(ContentPeer::CON_VALUE, $Groupname);
- $c->add(ContentPeer::CON_LANG, SYS_LANG );
- return $c;
- }
+ if (isset( $aData['GRP_STATUS'] )) {
+ $this->setGrpStatus( $aData['GRP_STATUS'] );
+ } else {
+ $this->setGrpStatus( 'ACTIVE' );
+ }
- function getAll($start=null, $limit=null, $search=null)
- {
- $totalCount = 0;
- $criteria = new Criteria('workflow');
- $criteria->addSelectColumn(GroupwfPeer::GRP_UID);
- $criteria->addSelectColumn(GroupwfPeer::GRP_STATUS);
- $criteria->addSelectColumn(GroupwfPeer::GRP_LDAP_DN);
- $criteria->addSelectColumn(ContentPeer::CON_VALUE);
- $criteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
- $criteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
- $criteria->add(ContentPeer::CON_CATEGORY,'GRP_TITLE');
- $criteria->add(ContentPeer::CON_LANG,SYS_LANG);
- $criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
+ if (isset( $aData['GRP_LDAP_DN'] )) {
+ $this->setGrpLdapDn( $aData['GRP_LDAP_DN'] );
+ } else {
+ $this->setGrpLdapDn( '' );
+ }
- if ( $search ){
- $criteria->add(ContentPeer::CON_VALUE,'%'.$search.'%',Criteria::LIKE);
+ if ($this->validate()) {
+ $con->begin();
+ $res = $this->save();
+
+ if (isset( $aData['GRP_TITLE'] )) {
+ $this->setGrpTitle( $aData['GRP_TITLE'] );
+ } else {
+ $this->setGrpTitle( 'Default Group Title' );
+ }
+
+ $con->commit();
+ return $this->getGrpUid();
+ } else {
+ $msg = '';
+ foreach ($this->getValidationFailures() as $objValidationFailure) {
+ $msg .= $objValidationFailure->getMessage() . "
";
+ }
+
+ throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
+ }
+
+ } catch (Exception $e) {
+ $con->rollback();
+ throw ($e);
+ }
}
- $c = clone $criteria;
- $c->clearSelectColumns();
- $c->addSelectColumn('COUNT(*)');
- $dataset = GroupwfPeer::doSelectRS($c);
- $dataset->next();
- $rowCount = $dataset->getRow();
+ /**
+ * Load the Process row specified in [grp_id] column value.
+ *
+ * @param string $ProUid the uid of the Prolication
+ * @return array $Fields the fields
+ */
- if( is_array($rowCount) )
- $totalCount = $rowCount[0];
-
- if( $start )
- $criteria->setOffset($start);
- if( $limit )
- $criteria->setLimit($limit);
-
- $rs = GroupwfPeer::doSelectRS($criteria);
- $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
-
- $rows = Array();
- while( $rs->next() )
- $rows[] = $rs->getRow();
-
- $result->data = $rows;
- $result->totalCount = $totalCount;
-
- return $result;
- }
-
- function getAllGroup($start=null, $limit=null, $search=null)
- {
- require_once PATH_RBAC . "model/RbacUsers.php";
- require_once 'classes/model/TaskUser.php';
- require_once 'classes/model/GroupUser.php';
-
- $totalCount = 0;
- $criteria = new Criteria('workflow');
- $criteria->addSelectColumn(GroupwfPeer::GRP_UID);
- $criteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
- $criteria->add(ContentPeer::CON_CATEGORY,'GRP_TITLE');
- $criteria->add(ContentPeer::CON_LANG,SYS_LANG);
- $criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
-
- if ($search) {
- $criteria->add(ContentPeer::CON_VALUE,'%'.$search.'%',Criteria::LIKE);
+ function Load ($ProUid)
+ {
+ $con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
+ try {
+ $oPro = GroupwfPeer::retrieveByPk( $ProUid );
+ if (is_object( $oPro ) && get_class( $oPro ) == 'Groupwf') {
+ $aFields = $oPro->toArray( BasePeer::TYPE_FIELDNAME );
+ $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
+ $aFields['GRP_TITLE'] = $oPro->getGrpTitle();
+ $this->setGrpTitle( $oPro->getGrpTitle() );
+ return $aFields;
+ } else {
+ throw (new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- $totalRows = GroupwfPeer::doCount($criteria);
+ /**
+ * Update the Group row
+ *
+ * @param array $aData
+ * @return variant
+ *
+ */
- $criteria = new Criteria('workflow');
- $criteria->addSelectColumn(GroupwfPeer::GRP_UID);
- $criteria->addSelectColumn(GroupwfPeer::GRP_STATUS);
- $criteria->addSelectColumn(GroupwfPeer::GRP_UX);
- $criteria->addAsColumn('GRP_TITLE',ContentPeer::CON_VALUE);
- $criteria->addSelectColumn(ContentPeer::CON_VALUE, 'COCHALO');
- $criteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
- $criteria->add(ContentPeer::CON_CATEGORY,'GRP_TITLE');
- $criteria->add(ContentPeer::CON_LANG,SYS_LANG);
- $criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
-
- if ($start != '') {
- $criteria->setOffset($start);
+ public function update ($aData)
+ {
+ $con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
+ try {
+ $con->begin();
+ $oPro = GroupwfPeer::retrieveByPK( $aData['GRP_UID'] );
+ if (is_object( $oPro ) && get_class( $oPro ) == 'Groupwf') {
+ $oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
+ if ($oPro->validate()) {
+ if (isset( $aData['GRP_TITLE'] )) {
+ $oPro->setGrpTitle( $aData['GRP_TITLE'] );
+ }
+ $res = $oPro->save();
+ $con->commit();
+ return $res;
+ } else {
+ $msg = '';
+ foreach ($this->getValidationFailures() as $objValidationFailure) {
+ $msg .= $objValidationFailure->getMessage() . "
";
+ }
+
+ throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
+ }
+ } else {
+ $con->rollback();
+ throw (new Exception( "The row '" . $aData['GRP_UID'] . "' in table Group doesn't exist!" ));
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- if ($limit != '') {
- $criteria->setLimit($limit);
- }
-
- if ($search) {
- $criteria->add(ContentPeer::CON_VALUE,'%'.$search.'%',Criteria::LIKE);
- }
-
- $oDataset = GroupwfPeer::doSelectRS ( $criteria );
- $oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
- $processes = Array();
- $uids=array();
- $groups = array();
- $aGroups = array();
- while( $oDataset->next() ) {
- $groups[] = $oDataset->getRow();
+ /**
+ * Remove the Prolication document registry
+ *
+ * @param array $aData or string $ProUid
+ * @return string
+ *
+ */
+ public function remove ($ProUid)
+ {
+ if (is_array( $ProUid )) {
+ $ProUid = (isset( $ProUid['GRP_UID'] ) ? $ProUid['GRP_UID'] : '');
+ }
+ try {
+ $oPro = GroupwfPeer::retrieveByPK( $ProUid );
+ if (! is_null( $oPro )) {
+ Content::removeContent( 'GRP_TITLE', '', $oPro->getGrpUid() );
+ Content::removeContent( 'GRP_DESCRIPTION', '', $oPro->getGrpUid() );
+ return $oPro->delete();
+ } else {
+ throw (new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- return array('rows' => $groups, 'totalCount'=>$totalRows);
- }
+ /**
+ * verify if row specified in [GrpUid] exists.
+ *
+ * @param string $sProUid the uid of the Prolication
+ */
- function filterGroup($filter,$start,$limit)
- {
- require_once 'classes/model/Groupwf.php';
- require_once 'classes/model/TaskUser.php';
- require_once 'classes/model/GroupUser.php';
- G::LoadClass('configuration');
-
- $co = new Configurations();
- $config = $co->getConfiguration('groupList', 'pageSize','',$_SESSION['USER_LOGGED']);
- $env = $co->getConfiguration('ENVIRONMENT_SETTINGS', '');
- $limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
- $start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
- $limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size;
- $filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : '';
-
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(GroupwfPeer::GRP_UID);
- $oCriteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
- $oCriteria->add(ContentPeer::CON_CATEGORY,'GRP_TITLE');
- $oCriteria->add(ContentPeer::CON_LANG,SYS_LANG);
- if ($filter != ''){
- $oCriteria->add(ContentPeer::CON_VALUE, '%'.$filter.'%', Criteria::LIKE);
+ function GroupwfExists ($GrpUid)
+ {
+ $con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
+ try {
+ $oPro = GroupwfPeer::retrieveByPk( $GrpUid );
+ if (is_object( $oPro ) && get_class( $oPro ) == 'Groupwf') {
+ return true;
+ } else {
+ return false;
+ }
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- $totalRows = GroupwfPeer::doCount($oCriteria);
-
- $oCriteria = new Criteria('workflow');
- $oCriteria->clearSelectColumns();
- $oCriteria->addSelectColumn(GroupwfPeer::GRP_UID);
- $oCriteria->addSelectColumn(GroupwfPeer::GRP_STATUS);
- $oCriteria->addSelectColumn(ContentPeer::CON_VALUE);
- $oCriteria->addAsColumn('GRP_TASKS', 0);
- $oCriteria->addAsColumn('GRP_USERS', 0);
- $oCriteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
- $oCriteria->add(ContentPeer::CON_CATEGORY,'GRP_TITLE');
- $oCriteria->add(ContentPeer::CON_LANG,SYS_LANG);
- if ($filter != ''){
- $oCriteria->add(ContentPeer::CON_VALUE, '%'.$filter.'%', Criteria::LIKE);
+
+ function loadByGroupname ($Groupname)
+ {
+ $c = new Criteria( 'workflow' );
+ $del = DBAdapter::getStringDelimiter();
+
+ $c->clearSelectColumns();
+ $c->addSelectColumn( ContentPeer::CON_CATEGORY );
+ $c->addSelectColumn( ContentPeer::CON_VALUE );
+
+ $c->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
+ $c->add( ContentPeer::CON_VALUE, $Groupname );
+ $c->add( ContentPeer::CON_LANG, SYS_LANG );
+ return $c;
}
- $oCriteria->setOffset($start);
- $oCriteria->setLimit($limit);
-
- $oDataset = GroupwfPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
-
- }
-
-
-} // Groupwf
+
+ function getAll ($start = null, $limit = null, $search = null)
+ {
+ $totalCount = 0;
+ $criteria = new Criteria( 'workflow' );
+ $criteria->addSelectColumn( GroupwfPeer::GRP_UID );
+ $criteria->addSelectColumn( GroupwfPeer::GRP_STATUS );
+ $criteria->addSelectColumn( GroupwfPeer::GRP_LDAP_DN );
+ $criteria->addSelectColumn( ContentPeer::CON_VALUE );
+ $criteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
+ $criteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' );
+ $criteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
+ $criteria->add( ContentPeer::CON_LANG, SYS_LANG );
+ $criteria->addAscendingOrderByColumn( ContentPeer::CON_VALUE );
+
+ if ($search) {
+ $criteria->add( ContentPeer::CON_VALUE, '%' . $search . '%', Criteria::LIKE );
+ }
+
+ $c = clone $criteria;
+ $c->clearSelectColumns();
+ $c->addSelectColumn( 'COUNT(*)' );
+ $dataset = GroupwfPeer::doSelectRS( $c );
+ $dataset->next();
+ $rowCount = $dataset->getRow();
+
+ if (is_array( $rowCount )) {
+ $totalCount = $rowCount[0];
+ }
+
+ if ($start) {
+ $criteria->setOffset( $start );
+ }
+ if ($limit) {
+ $criteria->setLimit( $limit );
+ }
+
+ $rs = GroupwfPeer::doSelectRS( $criteria );
+ $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+
+ $rows = Array ();
+ while ($rs->next()) {
+ $rows[] = $rs->getRow();
+ }
+
+ $result->data = $rows;
+ $result->totalCount = $totalCount;
+
+ return $result;
+ }
+
+ function getAllGroup ($start = null, $limit = null, $search = null)
+ {
+ require_once PATH_RBAC . "model/RbacUsers.php";
+ require_once 'classes/model/TaskUser.php';
+ require_once 'classes/model/GroupUser.php';
+
+ $totalCount = 0;
+ $criteria = new Criteria( 'workflow' );
+ $criteria->addSelectColumn( GroupwfPeer::GRP_UID );
+ $criteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
+ $criteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
+ $criteria->add( ContentPeer::CON_LANG, SYS_LANG );
+ $criteria->addAscendingOrderByColumn( ContentPeer::CON_VALUE );
+
+ if ($search) {
+ $criteria->add( ContentPeer::CON_VALUE, '%' . $search . '%', Criteria::LIKE );
+ }
+
+ $totalRows = GroupwfPeer::doCount( $criteria );
+
+ $criteria = new Criteria( 'workflow' );
+ $criteria->addSelectColumn( GroupwfPeer::GRP_UID );
+ $criteria->addSelectColumn( GroupwfPeer::GRP_STATUS );
+ $criteria->addSelectColumn( GroupwfPeer::GRP_UX );
+ $criteria->addAsColumn( 'GRP_TITLE', ContentPeer::CON_VALUE );
+ $criteria->addSelectColumn( ContentPeer::CON_VALUE, 'COCHALO' );
+ $criteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
+ $criteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
+ $criteria->add( ContentPeer::CON_LANG, SYS_LANG );
+ $criteria->addAscendingOrderByColumn( ContentPeer::CON_VALUE );
+
+ if ($start != '') {
+ $criteria->setOffset( $start );
+ }
+
+ if ($limit != '') {
+ $criteria->setLimit( $limit );
+ }
+
+ if ($search) {
+ $criteria->add( ContentPeer::CON_VALUE, '%' . $search . '%', Criteria::LIKE );
+ }
+
+ $oDataset = GroupwfPeer::doSelectRS( $criteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $processes = Array ();
+ $uids = array ();
+ $groups = array ();
+ $aGroups = array ();
+ while ($oDataset->next()) {
+ $groups[] = $oDataset->getRow();
+ }
+
+ return array ('rows' => $groups,'totalCount' => $totalRows
+ );
+ }
+
+ function filterGroup ($filter, $start, $limit)
+ {
+ require_once 'classes/model/Groupwf.php';
+ require_once 'classes/model/TaskUser.php';
+ require_once 'classes/model/GroupUser.php';
+ G::LoadClass( 'configuration' );
+
+ $co = new Configurations();
+ $config = $co->getConfiguration( 'groupList', 'pageSize', '', $_SESSION['USER_LOGGED'] );
+ $env = $co->getConfiguration( 'ENVIRONMENT_SETTINGS', '' );
+ $limit_size = isset( $config['pageSize'] ) ? $config['pageSize'] : 20;
+ $start = isset( $_REQUEST['start'] ) ? $_REQUEST['start'] : 0;
+ $limit = isset( $_REQUEST['limit'] ) ? $_REQUEST['limit'] : $limit_size;
+ $filter = isset( $_REQUEST['textFilter'] ) ? $_REQUEST['textFilter'] : '';
+
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addSelectColumn( GroupwfPeer::GRP_UID );
+ $oCriteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
+ $oCriteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
+ $oCriteria->add( ContentPeer::CON_LANG, SYS_LANG );
+ if ($filter != '') {
+ $oCriteria->add( ContentPeer::CON_VALUE, '%' . $filter . '%', Criteria::LIKE );
+ }
+ $totalRows = GroupwfPeer::doCount( $oCriteria );
+
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->clearSelectColumns();
+ $oCriteria->addSelectColumn( GroupwfPeer::GRP_UID );
+ $oCriteria->addSelectColumn( GroupwfPeer::GRP_STATUS );
+ $oCriteria->addSelectColumn( ContentPeer::CON_VALUE );
+ $oCriteria->addAsColumn( 'GRP_TASKS', 0 );
+ $oCriteria->addAsColumn( 'GRP_USERS', 0 );
+ $oCriteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
+ $oCriteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
+ $oCriteria->add( ContentPeer::CON_LANG, SYS_LANG );
+ if ($filter != '') {
+ $oCriteria->add( ContentPeer::CON_VALUE, '%' . $filter . '%', Criteria::LIKE );
+ }
+ $oCriteria->setOffset( $start );
+ $oCriteria->setLimit( $limit );
+
+ $oDataset = GroupwfPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+
+ }
+}
+// Groupwf
+
diff --git a/workflow/engine/classes/model/Language.php b/workflow/engine/classes/model/Language.php
index 2f60442be..9165f8306 100755
--- a/workflow/engine/classes/model/Language.php
+++ b/workflow/engine/classes/model/Language.php
@@ -1,7 +1,8 @@
.
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
@@ -36,530 +37,541 @@ require_once 'classes/model/Translation.php';
*
*
* You should add additional methods to this class to meet the
- * application requirements. This class will only be generated as
+ * application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
- * @package workflow.engine.classes.model
+ * @package workflow.engine.classes.model
*/
-class Language extends BaseLanguage {
+class Language extends BaseLanguage
+{
- function load($sLanUid)
- {
- try {
- $oRow = LanguagePeer::retrieveByPK($sLanUid);
- 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('This row doesn\'t exist!'));
- }
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- function update($aFields)
- {
- $oConnection = Propel::getConnection(LanguagePeer::DATABASE_NAME);
- try {
- $oConnection->begin();
- $this->load($aFields['LAN_ID']);
- $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
- if ($this->validate()) {
- $iResult = $this->save();
- $oConnection->commit();
- return $iResult;
- }
- else {
- $oConnection->rollback();
- throw(new Exception('Failed Validation in class ' . get_class($this) . '.'));
- }
- }
- catch(Exception $e) {
- $oConnection->rollback();
- throw($e);
- }
- }
- //SELECT LAN_ID, LAN_NAME FROM LANGUAGE WHERE LAN_ENABLED = '1' ORDER BY LAN_WEIGHT DESC
- function getActiveLanguages()
- {
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(LanguagePeer::LAN_ID);
- $oCriteria->addSelectColumn(LanguagePeer::LAN_NAME);
- $oCriteria->add(LanguagePeer::LAN_ENABLED , '1');
- $oCriteria->addDescendingOrderByColumn(LanguagePeer::LAN_WEIGHT);
-
- $oDataset = ContentPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
-
- $oContent = new Content();
- $rows = Array();
- while ($oDataset->next())
- array_push($rows, $oDataset->getRow());
-
- return $rows;
- }
-
- function findById($LAN_ID)
- {
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(LanguagePeer::LAN_NAME);
- $oCriteria->add(LanguagePeer::LAN_ID, $LAN_ID);
- $oDataset = LanguagePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- return $oDataset->getRow();
- }
-
- function findByLanName($LAN_NAME)
- {
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(LanguagePeer::LAN_ID);
- $oCriteria->addSelectColumn(LanguagePeer::LAN_NAME);
- $oCriteria->add(LanguagePeer::LAN_NAME, $LAN_NAME, Criteria::LIKE);
- $oDataset = LanguagePeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- return $oDataset->getRow();
- }
-
- /*
- * Import a language file
- *
- * @author Erik Amaru Ortiz
- * @param string $sLanguageFile
- * @param string $bXml
- * @return void
- */
- public function import($sLanguageFile, $updateXml = true, $updateDB = true)
- {
- try {
- G::LoadSystem('i18n_po');
- $POFile = new i18n_PO($sLanguageFile);
- $POFile->readInit();
- $POHeaders = $POFile->getHeaders();
-
- /*getting the PO Language definition*/
- $langName = $POHeaders['X-Poedit-Language'];
- //find the lang id
- $language = new Language();
- $langRecord = $language->findByLanName($langName);
-
- if( ! isset($langRecord['LAN_ID']) ) //if the language doesn't exist abort
- throw new Exception('The .po file has a invalid X-Poedit-Language definition!');
-
- $languageID = $langRecord['LAN_ID'];
-
- /*getting the PO Language definition*/
- $countryName = $POHeaders['X-Poedit-Country'];
- if( $countryName != '.' ) {
- $isoCountry = new IsoCountry();
- $countryRecord = $isoCountry->findByIcName($countryName);
-
- if( ! isset($countryRecord['IC_UID']) ) //if the language doesn't exist abort
- throw new Exception('The .po file has a invalid X-Poedit-Country definition!');
-
- $countryID = $countryRecord['IC_UID'];
- //define locale
- $LOCALE = "$languageID-$countryID";
- } else {
- $LOCALE = $languageID;
- }
-
- $oTranslation = new Translation();
- $countItems = 0;
- $countItemsSuccess = 0;
- $errorMsg = '';
-
- while( $rowTranslation = $POFile->getTranslation() ) {
-
- $countItems++;
-
- if ( ! isset($POFile->translatorComments[0]) || ! isset($POFile->translatorComments[1]) || ! isset($POFile->references[0]) ) {
- throw new Exception('The .po file doesn\'t have valid directives for Processmaker!');
- }
-
- foreach($POFile->translatorComments as $a=>$aux){
- $aux = trim($aux);
- if ( $aux == 'TRANSLATION')
- $identifier = $aux;
- else {
- $var = explode('/',$aux);
- if ($var[0]=='LABEL')
- $context = $aux;
- if ($var[0]=='JAVASCRIPT')
- $context = $aux;
- }
- if (preg_match('/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml\?)/', $aux, $match))
- $identifier = $aux;
- else{
- if (preg_match('/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml$)/', $aux, $match))
- $context = $aux;
- }
- }
-
- $reference = $POFile->references[0];
-
- // it is a Sql insert on TRANSLATIONS TAble
- if( $identifier == 'TRANSLATION') {
- if ($updateDB) {
- list($category, $id) = explode('/', $context);
- $result = $oTranslation->addTranslation(
- $category,
- $id,
- $LOCALE,
- trim(stripcslashes(str_replace(chr(10), '', $rowTranslation['msgstr'])))
- );
- if( $result['codError'] == 0 ) {
- $countItemsSuccess++;
+ function load ($sLanUid)
+ {
+ try {
+ $oRow = LanguagePeer::retrieveByPK( $sLanUid );
+ if (! is_null( $oRow )) {
+ $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
+ $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
+ $this->setNew( false );
+ return $aFields;
} else {
- $errorMsg .= $id .': ' . $result['message'] . "\n";
+ throw (new Exception( 'This row doesn\'t exist!' ));
}
- }
+ } catch (Exception $oError) {
+ throw ($oError);
}
- // is a Xml update
- else if( $updateXml ) {
-
- $xmlForm = $context;
- //erik: expresion to prevent and hable correctly dropdown values like -1, -2 etc.
- preg_match('/^([\w_]+)\s-\s([\w_]+)\s*-*\s*([\w\W]*)$/', $reference, $match);
-
- if( ! file_exists(PATH_XMLFORM . $xmlForm) ) {
- $errorMsg .= 'file doesn\'t exist: ' . PATH_XMLFORM . $xmlForm . "\n";
- continue;
- }
-
- if (count($match) < 4) {
- $near = isset($rowTranslation['msgid']) ? $rowTranslation['msgid'] :
- (isset($rowTranslation['msgstr']) ? $rowTranslation['msgstr'] : '');
- $errorMsg .= "Invalid Translation reference: \"$reference\", near -> ".$near."\n";
- continue;
- }
-
- G::LoadSystem('dynaformhandler');
- $dynaform = new dynaFormHandler(PATH_XMLFORM . $xmlForm);
- $fieldName = $match[2];
-
- $codes = explode('-', $reference);
-
- if( sizeof($codes) == 2 ) { //is a normal node
- $dynaform->addChilds($fieldName, Array($LOCALE=>stripcslashes(str_replace(chr(10), '', $rowTranslation['msgstr']))));
- } else if( sizeof($codes) > 2 ) { //is a node child for a language node
- $name = $match[3] == "''" ? '' : $match[3];
- $childNode = Array(
- Array('name'=>'option', 'value'=>$rowTranslation['msgstr'], 'attributes'=>Array('name'=>$name))
- );
-
- $dynaform->addChilds($fieldName, Array($LOCALE=>NULL), $childNode);
- }
- $countItemsSuccess++;
- }
- }
-
-
- $oLanguage = new Language();
- $oLanguage->update(array('LAN_ID' => $languageID, 'LAN_ENABLED' => '1'));
-
- $trn = new Translation();
- $trn->generateFileTranslation($LOCALE);
- $trn->addTranslationEnvironment($LOCALE, $POHeaders, $countItemsSuccess);
-
- //fill the results
- $results = new stdClass();
- $results->recordsCount = $countItems;
- $results->recordsCountSuccess = $countItemsSuccess;
- $results->lang = $languageID;
- $results->headers = $POHeaders;
- $results->errMsg = $errorMsg;
-
- return $results;
- }
- catch (Exception $oError) {
- throw($oError);
- }
- }
-
- //export
- function export()
- {
- //G::LoadThirdParty('pear', 'Benchmark/Timer');
- G::LoadSystem('i18n_po');
- G::LoadClass("system");
-
- //echo G::getMemoryUsage();
- //$timer = new Benchmark_Timer();
- //$timer->start();
-
- //creating the .po file
- $sPOFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . MAIN_POFILE . '.' . $_GET['LOCALE'] . '.po';
-
- $poFile = new i18n_PO($sPOFile);
- $poFile->buildInit();
-
- $language = new Language();
-
- $locale = $_GET['LOCALE'];
- $_TARGET_LANG = $_GET['LOCALE'];
- $_BASE_LANG = 'en';
-
- if( strpos($locale, Translation::$localeSeparator) !== false ) {
- list($LAN_ID, $IC_UID) = explode(Translation::$localeSeparator, $_GET['LOCALE']);
- $iCountry = new IsoCountry();
- $iCountryRecord = $iCountry->findById($IC_UID);
-
- if( ! isset($iCountryRecord['IC_UID']) )
- throw new Exception("Country Target ID '{$_GET['LAN_ID']}' doesn't exist!");
-
- $sCountry = $iCountryRecord['IC_NAME'];
- } else {
- $LAN_ID = $locale;
- $sCountry = $IC_UID = '';
}
- $langRecord = $language->findById($LAN_ID);
-
- if( ! isset($langRecord['LAN_NAME']) )
- throw new Exception("Language Target ID \"{$LAN_ID}\" doesn't exist!");
-
- $sLanguage = $langRecord['LAN_NAME'];
-
- //setting headers
- $poFile->addHeader('Project-Id-Version' , 'ProcessMaker ' . System::getVersion());
- $poFile->addHeader('POT-Creation-Date' , '');
- $poFile->addHeader('PO-Revision-Date' , date('Y-m-d H:i:s'));
- $poFile->addHeader('Last-Translator' , '');
- $poFile->addHeader('Language-Team' , 'Colosa Developers Team ');
- $poFile->addHeader('MIME-Version' , '1.0');
- $poFile->addHeader('Content-Type' , 'text/plain; charset=utf-8');
- $poFile->addHeader('Content-Transfer_Encoding' , '8bit');
- $poFile->addHeader('X-Poedit-Language' , ucwords($sLanguage));
- $poFile->addHeader('X-Poedit-Country' , ucwords($sCountry));
- $poFile->addHeader('X-Poedit-SourceCharset' , 'utf-8');
- $poFile->addHeader('Content-Transfer-Encoding' , '8bit');
-
- //$timer->setMarker('end making po headers');
- //export translation
-
- $aLabels = array();
- $aMsgids = array('' => true);
-
- // selecting all translations records of base language 'en' on TRANSLATIONS table
- $oCriteria = new Criteria('workflow');
- $oCriteria->addSelectColumn(TranslationPeer::TRN_CATEGORY);
- $oCriteria->addSelectColumn(TranslationPeer::TRN_ID);
- $oCriteria->addSelectColumn(TranslationPeer::TRN_VALUE);
- $oCriteria->add(TranslationPeer::TRN_LANG, 'en');
- $oDataset = TranslationPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
-
- $targetLangRecords = array();
- // retrieve the translation for the target language
- if( $LAN_ID != 'en' ) { // only if it is different language than base language 'en'
- $c = new Criteria('workflow');
- $c->addSelectColumn(TranslationPeer::TRN_CATEGORY);
- $c->addSelectColumn(TranslationPeer::TRN_ID);
- $c->addSelectColumn(TranslationPeer::TRN_VALUE);
- $c->add(TranslationPeer::TRN_LANG, $_GET['LOCALE']);
- $ds = TranslationPeer::doSelectRS($c);
- $ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
-
- while ($ds->next()) {
- $row = $ds->getRow();
- $targetLangRecords[$row['TRN_CATEGORY'].'/'.$row['TRN_ID']] = $row['TRN_VALUE'];
- }
- }
-
-
- // get the respective translation for each english label
- while ($oDataset->next()) {
- $aRow1 = $oDataset->getRow();
- $trnCategory = trim($aRow1['TRN_CATEGORY']);
-
-
- # Validation, validate that the TRN_CATEGORY contains valid characteres
- preg_match("/^[0-9a-zA-Z_-]+/", $trnCategory, $sTestResult);
-
- // IF the translations id "TRN_ID" has invalid characteres or has not accepted categories
- if ($sTestResult[0] !== $trnCategory || ($trnCategory != 'LABEL' && $trnCategory != 'JAVASCRIPT')) {
- $oTranslation = new Translation;
- $oTranslation->remove($aRow1['TRN_CATEGORY'], $aRow1['TRN_ID'], 'en'); //remove not accepted translations
- continue; //jump to next iteration
- }
-
-
-
-
- // retrieve the translation for the target language
- if( $LAN_ID != 'en' ){ // only if it is different language than base language 'en'
- if (isset($targetLangRecords[$aRow1['TRN_CATEGORY'].'/'.$aRow1['TRN_ID']])) {
- $msgstr = $targetLangRecords[$aRow1['TRN_CATEGORY'].'/'.$aRow1['TRN_ID']] != ''
- ? $targetLangRecords[$aRow1['TRN_CATEGORY'].'/'.$aRow1['TRN_ID']]: $aRow1['TRN_VALUE'];
- } else {
- $msgstr = $aRow1['TRN_VALUE'];
- }
- } else { //if not just copy the same
- $msgstr = $aRow1['TRN_VALUE'];
- }
-
-
- $msgid = trim($aRow1['TRN_VALUE']);
- $msgstr = trim($msgstr);
-
- if ( isset($aMsgids[$msgid]) ) {
- $msgid = '[' . $aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID'] . '] ' . $msgid;
- }
-
- $poFile->addTranslatorComment('TRANSLATION');
- $poFile->addTranslatorComment($aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']);
- $poFile->addReference($aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']);
-
- $poFile->addTranslation(stripcslashes($msgid), stripcslashes($msgstr));
- $aMsgids[$msgid] = true;
- }
-
- //$timer->setMarker('end making 1th .po from db');
-
- //now find labels in xmlforms
- /************/
- $aExceptionFields = array('', 'javascript', 'hidden', 'phpvariable', 'private', 'toolbar', 'xmlmenu', 'toolbutton', 'cellmark', 'grid', 'CheckboxTable');
-
- //find all xml files into PATH_XMLFORM
- $aXMLForms = glob(PATH_XMLFORM . '*/*.xml');
- //from a sublevel to
- $aXMLForms2 = glob(PATH_XMLFORM . '*/*/*.xml');
- $aXMLForms = array_merge($aXMLForms, $aXMLForms2);
-
- $aEnglishLabel = array();
- $aOptions = array();
- $nodesNames = Array();
-
- G::loadSystem('dynaformhandler');
-
- foreach ($aXMLForms as $xmlFormPath) {
- $xmlFormFile = str_replace( chr(92), '/', $xmlFormPath);
- $xmlFormFile = str_replace( PATH_XMLFORM, '', $xmlFormPath);
-
- $dynaForm = new dynaFormHandler($xmlFormPath);
-
- $dynaNodes = $dynaForm->getFields();
-
- //get all fields of each xmlform
- foreach ($dynaNodes as $oNode) {
-
- $sNodeName = $oNode->nodeName;
- //$arrayNode = $dynaForm->getArray($oNode, Array('type', $_BASE_LANG, $_BASE_LANG));
- $arrayNode = $dynaForm->getArray($oNode);
- //if has not native language translation
- if( ! isset($arrayNode[$_BASE_LANG]) || ! isset($arrayNode['type']) || ( isset($arrayNode['type']) && in_array($arrayNode['type'], $aExceptionFields)) ){
- continue; //just continue with the next node
- }
-
- // Getting the Base Origin Text
- if( ! is_array($arrayNode[$_BASE_LANG]) )
- $originNodeText = trim($arrayNode[$_BASE_LANG]);
- else {
- $langNode = $arrayNode[$_BASE_LANG][0];
- $originNodeText = $langNode['__nodeText__'];
- }
-
- // Getting the Base Target Text
- if( isset($arrayNode[$_TARGET_LANG]) ) {
- if( ! is_array($arrayNode[$_TARGET_LANG]) )
- $targetNodeText = trim($arrayNode[$_TARGET_LANG]);
- else {
- $langNode = $arrayNode[$_TARGET_LANG][0];
- $targetNodeText = $langNode['__nodeText__'];
- }
- } else {
- $targetNodeText = $originNodeText;
- }
-
- $nodeName = $arrayNode['__nodeName__'];
- $nodeType = $arrayNode['type'];
-
- $msgid = $originNodeText;
-
- // if the nodeName already exists in the po file, we need to create other msgid
- if( isset($aMsgids[$msgid]) )
- $msgid = '[' . $xmlFormFile . '?' . $nodeName . '] ' . $originNodeText;
-
- $poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName);
- $poFile->addTranslatorComment($xmlFormFile);
- $poFile->addReference($nodeType . ' - ' . $nodeName);
- $poFile->addTranslation(stripslashes($msgid), stripslashes($targetNodeText));
-
- $aMsgids[$msgid] = true;
-
- //if this node has options child nodes
- if( isset($arrayNode[$_BASE_LANG]) && isset($arrayNode[$_BASE_LANG][0]) && isset($arrayNode[$_BASE_LANG][0]['option']) ){
-
- $originOptionNode = $arrayNode[$_BASE_LANG][0]['option']; //get the options
-
- $targetOptionExists = false;
- if( isset($arrayNode[$_TARGET_LANG]) && isset($arrayNode[$_TARGET_LANG][0]) && isset($arrayNode[$_TARGET_LANG][0]['option']) ) {
- $targetOptionNode = $arrayNode[$_TARGET_LANG][0]['option'];
- $targetOptionExists = true;
- }
-
- if ( ! is_array($originOptionNode) ){
- if( is_string($originOptionNode) ){
- $poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-'. $originOptionNode);
- $poFile->addTranslatorComment($xmlFormFile);
- $poFile->addReference($nodeType . ' - ' . $nodeName . ' - ' . $originOptionNode);
- $poFile->addTranslation(stripslashes($msgid), stripslashes($originOptionNode));
+ function update ($aFields)
+ {
+ $oConnection = Propel::getConnection( LanguagePeer::DATABASE_NAME );
+ try {
+ $oConnection->begin();
+ $this->load( $aFields['LAN_ID'] );
+ $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
+ if ($this->validate()) {
+ $iResult = $this->save();
+ $oConnection->commit();
+ return $iResult;
+ } else {
+ $oConnection->rollback();
+ throw (new Exception( 'Failed Validation in class ' . get_class( $this ) . '.' ));
}
- } else {
- foreach( $originOptionNode as $optionNode ) {
- $optionName = $optionNode['name'];
- $originOptionValue = $optionNode['__nodeText__'];
+ } catch (Exception $e) {
+ $oConnection->rollback();
+ throw ($e);
+ }
+ }
+ //SELECT LAN_ID, LAN_NAME FROM LANGUAGE WHERE LAN_ENABLED = '1' ORDER BY LAN_WEIGHT DESC
+ function getActiveLanguages ()
+ {
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addSelectColumn( LanguagePeer::LAN_ID );
+ $oCriteria->addSelectColumn( LanguagePeer::LAN_NAME );
+ $oCriteria->add( LanguagePeer::LAN_ENABLED, '1' );
+ $oCriteria->addDescendingOrderByColumn( LanguagePeer::LAN_WEIGHT );
- if( $targetOptionExists ){
+ $oDataset = ContentPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
- $targetOptionValue = getMatchDropdownOptionValue($optionName, $targetOptionNode);
- if( $targetOptionValue === false ){
- $targetOptionValue = $originOptionValue;
+ $oContent = new Content();
+ $rows = Array ();
+ while ($oDataset->next()) {
+ array_push( $rows, $oDataset->getRow() );
+ }
+
+ return $rows;
+ }
+
+ function findById ($LAN_ID)
+ {
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addSelectColumn( LanguagePeer::LAN_NAME );
+ $oCriteria->add( LanguagePeer::LAN_ID, $LAN_ID );
+ $oDataset = LanguagePeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ return $oDataset->getRow();
+ }
+
+ function findByLanName ($LAN_NAME)
+ {
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addSelectColumn( LanguagePeer::LAN_ID );
+ $oCriteria->addSelectColumn( LanguagePeer::LAN_NAME );
+ $oCriteria->add( LanguagePeer::LAN_NAME, $LAN_NAME, Criteria::LIKE );
+ $oDataset = LanguagePeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset->next();
+ return $oDataset->getRow();
+ }
+
+ /*
+ * Import a language file
+ *
+ * @author Erik Amaru Ortiz
+ * @param string $sLanguageFile
+ * @param string $bXml
+ * @return void
+ */
+ public function import ($sLanguageFile, $updateXml = true, $updateDB = true)
+ {
+ try {
+ G::LoadSystem( 'i18n_po' );
+ $POFile = new i18n_PO( $sLanguageFile );
+ $POFile->readInit();
+ $POHeaders = $POFile->getHeaders();
+
+ /*getting the PO Language definition*/
+ $langName = $POHeaders['X-Poedit-Language'];
+ //find the lang id
+ $language = new Language();
+ $langRecord = $language->findByLanName( $langName );
+
+ if (! isset( $langRecord['LAN_ID'] )) {
+ //if the language doesn't exist abort
+ throw new Exception( 'The .po file has a invalid X-Poedit-Language definition!' );
+ }
+
+ $languageID = $langRecord['LAN_ID'];
+
+ /*getting the PO Language definition*/
+ $countryName = $POHeaders['X-Poedit-Country'];
+ if ($countryName != '.') {
+ $isoCountry = new IsoCountry();
+ $countryRecord = $isoCountry->findByIcName( $countryName );
+
+ if (! isset( $countryRecord['IC_UID'] )) {
+ //if the language doesn't exist abort
+ throw new Exception( 'The .po file has a invalid X-Poedit-Country definition!' );
}
- } else {
- $targetOptionValue = $originOptionValue;
- }
- $msgid = '[' . $xmlFormFile . '?' . $nodeName . '-' . $optionName . ']';
- $poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-'. $optionName);
- $poFile->addTranslatorComment($xmlFormFile);
- $poFile->addReference($nodeType . ' - ' . $nodeName . ' - ' . $optionName);
- $poFile->addTranslation($msgid, stripslashes($targetOptionValue));
+ $countryID = $countryRecord['IC_UID'];
+ //define locale
+ $LOCALE = "$languageID-$countryID";
+ } else {
+ $LOCALE = $languageID;
}
- }
- }
- } //end foreach
+ $oTranslation = new Translation();
+ $countItems = 0;
+ $countItemsSuccess = 0;
+ $errorMsg = '';
+
+ while ($rowTranslation = $POFile->getTranslation()) {
+
+ $countItems ++;
+
+ if (! isset( $POFile->translatorComments[0] ) || ! isset( $POFile->translatorComments[1] ) || ! isset( $POFile->references[0] )) {
+ throw new Exception( 'The .po file doesn\'t have valid directives for Processmaker!' );
+ }
+
+ foreach ($POFile->translatorComments as $a => $aux) {
+ $aux = trim( $aux );
+ if ($aux == 'TRANSLATION') {
+ $identifier = $aux;
+ } else {
+ $var = explode( '/', $aux );
+ if ($var[0] == 'LABEL') {
+ $context = $aux;
+ }
+ if ($var[0] == 'JAVASCRIPT') {
+ $context = $aux;
+ }
+ }
+ if (preg_match( '/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml\?)/', $aux, $match )) {
+ $identifier = $aux;
+ } else {
+ if (preg_match( '/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml$)/', $aux, $match )) {
+ $context = $aux;
+ }
+ }
+ }
+
+ $reference = $POFile->references[0];
+
+ // it is a Sql insert on TRANSLATIONS TAble
+ if ($identifier == 'TRANSLATION') {
+ if ($updateDB) {
+ list ($category, $id) = explode( '/', $context );
+ $result = $oTranslation->addTranslation( $category, $id, $LOCALE, trim( stripcslashes( str_replace( chr( 10 ), '', $rowTranslation['msgstr'] ) ) ) );
+ if ($result['codError'] == 0) {
+ $countItemsSuccess ++;
+ } else {
+ $errorMsg .= $id . ': ' . $result['message'] . "\n";
+ }
+ }
+ } // is a Xml update
+ elseif ($updateXml) {
+
+ $xmlForm = $context;
+ //erik: expresion to prevent and hable correctly dropdown values like -1, -2 etc.
+ preg_match( '/^([\w_]+)\s-\s([\w_]+)\s*-*\s*([\w\W]*)$/', $reference, $match );
+
+ if (! file_exists( PATH_XMLFORM . $xmlForm )) {
+ $errorMsg .= 'file doesn\'t exist: ' . PATH_XMLFORM . $xmlForm . "\n";
+ continue;
+ }
+
+ if (count( $match ) < 4) {
+ $near = isset( $rowTranslation['msgid'] ) ? $rowTranslation['msgid'] : (isset( $rowTranslation['msgstr'] ) ? $rowTranslation['msgstr'] : '');
+ $errorMsg .= "Invalid Translation reference: \"$reference\", near -> " . $near . "\n";
+ continue;
+ }
+
+ G::LoadSystem( 'dynaformhandler' );
+ $dynaform = new dynaFormHandler( PATH_XMLFORM . $xmlForm );
+ $fieldName = $match[2];
+
+ $codes = explode( '-', $reference );
+
+ if (sizeof( $codes ) == 2) {
+ //is a normal node
+ $dynaform->addChilds( $fieldName, Array ($LOCALE => stripcslashes( str_replace( chr( 10 ), '', $rowTranslation['msgstr'] ) )
+ ) );
+ } elseif (sizeof( $codes ) > 2) {
+ //is a node child for a language node
+ $name = $match[3] == "''" ? '' : $match[3];
+ $childNode = Array (Array ('name' => 'option','value' => $rowTranslation['msgstr'],'attributes' => Array ('name' => $name
+ )
+ )
+ );
+
+ $dynaform->addChilds( $fieldName, Array ($LOCALE => null
+ ), $childNode );
+ }
+ $countItemsSuccess ++;
+ }
+ }
+
+ $oLanguage = new Language();
+ $oLanguage->update( array ('LAN_ID' => $languageID,'LAN_ENABLED' => '1'
+ ) );
+
+ $trn = new Translation();
+ $trn->generateFileTranslation( $LOCALE );
+ $trn->addTranslationEnvironment( $LOCALE, $POHeaders, $countItemsSuccess );
+
+ //fill the results
+ $results = new stdClass();
+ $results->recordsCount = $countItems;
+ $results->recordsCountSuccess = $countItemsSuccess;
+ $results->lang = $languageID;
+ $results->headers = $POHeaders;
+ $results->errMsg = $errorMsg;
+
+ return $results;
+ } catch (Exception $oError) {
+ throw ($oError);
+ }
}
- //
- //$timer->setMarker('end xml files processed');
- //$profiling = $timer->getProfiling();
- //$timer->stop(); $timer->display();
- //echo G::getMemoryUsage();
- //die;
- //g::pr($profiling);
+ //export
+ function export ()
+ {
+ //G::LoadThirdParty('pear', 'Benchmark/Timer');
+ G::LoadSystem( 'i18n_po' );
+ G::LoadClass( "system" );
- G::streamFile($sPOFile, true);
+ //echo G::getMemoryUsage();
+ //$timer = new Benchmark_Timer();
+ //$timer->start();
- }
+ //creating the .po file
+ $sPOFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . MAIN_POFILE . '.' . $_GET['LOCALE'] . '.po';
-} // Language
+ $poFile = new i18n_PO( $sPOFile );
+ $poFile->buildInit();
+ $language = new Language();
- function getMatchDropdownOptionValue($name, $options){
- foreach($options as $option){
- if($name == $option['name']){
- return $option['__nodeText__'];
+ $locale = $_GET['LOCALE'];
+ $_TARGET_LANG = $_GET['LOCALE'];
+ $_BASE_LANG = 'en';
+
+ if (strpos( $locale, Translation::$localeSeparator ) !== false) {
+ list ($LAN_ID, $IC_UID) = explode( Translation::$localeSeparator, $_GET['LOCALE'] );
+ $iCountry = new IsoCountry();
+ $iCountryRecord = $iCountry->findById( $IC_UID );
+
+ if (! isset( $iCountryRecord['IC_UID'] )) {
+ throw new Exception( "Country Target ID '{$_GET['LAN_ID']}' doesn't exist!" );
+ }
+
+ $sCountry = $iCountryRecord['IC_NAME'];
+ } else {
+ $LAN_ID = $locale;
+ $sCountry = $IC_UID = '';
}
- }
- return false;
+
+ $langRecord = $language->findById( $LAN_ID );
+
+ if (! isset( $langRecord['LAN_NAME'] )) {
+ throw new Exception( "Language Target ID \"{$LAN_ID}\" doesn't exist!" );
+ }
+
+ $sLanguage = $langRecord['LAN_NAME'];
+
+ //setting headers
+ $poFile->addHeader( 'Project-Id-Version', 'ProcessMaker ' . System::getVersion() );
+ $poFile->addHeader( 'POT-Creation-Date', '' );
+ $poFile->addHeader( 'PO-Revision-Date', date( 'Y-m-d H:i:s' ) );
+ $poFile->addHeader( 'Last-Translator', '' );
+ $poFile->addHeader( 'Language-Team', 'Colosa Developers Team ' );
+ $poFile->addHeader( 'MIME-Version', '1.0' );
+ $poFile->addHeader( 'Content-Type', 'text/plain; charset=utf-8' );
+ $poFile->addHeader( 'Content-Transfer_Encoding', '8bit' );
+ $poFile->addHeader( 'X-Poedit-Language', ucwords( $sLanguage ) );
+ $poFile->addHeader( 'X-Poedit-Country', ucwords( $sCountry ) );
+ $poFile->addHeader( 'X-Poedit-SourceCharset', 'utf-8' );
+ $poFile->addHeader( 'Content-Transfer-Encoding', '8bit' );
+
+ //$timer->setMarker('end making po headers');
+ //export translation
+
+
+ $aLabels = array ();
+ $aMsgids = array ('' => true
+ );
+
+ // selecting all translations records of base language 'en' on TRANSLATIONS table
+ $oCriteria = new Criteria( 'workflow' );
+ $oCriteria->addSelectColumn( TranslationPeer::TRN_CATEGORY );
+ $oCriteria->addSelectColumn( TranslationPeer::TRN_ID );
+ $oCriteria->addSelectColumn( TranslationPeer::TRN_VALUE );
+ $oCriteria->add( TranslationPeer::TRN_LANG, 'en' );
+ $oDataset = TranslationPeer::doSelectRS( $oCriteria );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+
+ $targetLangRecords = array ();
+ // retrieve the translation for the target language
+ if ($LAN_ID != 'en') {
+ // only if it is different language than base language 'en'
+ $c = new Criteria( 'workflow' );
+ $c->addSelectColumn( TranslationPeer::TRN_CATEGORY );
+ $c->addSelectColumn( TranslationPeer::TRN_ID );
+ $c->addSelectColumn( TranslationPeer::TRN_VALUE );
+ $c->add( TranslationPeer::TRN_LANG, $_GET['LOCALE'] );
+ $ds = TranslationPeer::doSelectRS( $c );
+ $ds->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+
+ while ($ds->next()) {
+ $row = $ds->getRow();
+ $targetLangRecords[$row['TRN_CATEGORY'] . '/' . $row['TRN_ID']] = $row['TRN_VALUE'];
+ }
+ }
+
+ // get the respective translation for each english label
+ while ($oDataset->next()) {
+ $aRow1 = $oDataset->getRow();
+ $trnCategory = trim( $aRow1['TRN_CATEGORY'] );
+
+ # Validation, validate that the TRN_CATEGORY contains valid characteres
+ preg_match( "/^[0-9a-zA-Z_-]+/", $trnCategory, $sTestResult );
+
+ // IF the translations id "TRN_ID" has invalid characteres or has not accepted categories
+ if ($sTestResult[0] !== $trnCategory || ($trnCategory != 'LABEL' && $trnCategory != 'JAVASCRIPT')) {
+ $oTranslation = new Translation();
+ $oTranslation->remove( $aRow1['TRN_CATEGORY'], $aRow1['TRN_ID'], 'en' ); //remove not accepted translations
+ continue; //jump to next iteration
+ }
+
+ // retrieve the translation for the target language
+ if ($LAN_ID != 'en') {
+ // only if it is different language than base language 'en'
+ if (isset( $targetLangRecords[$aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']] )) {
+ $msgstr = $targetLangRecords[$aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']] != '' ? $targetLangRecords[$aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']] : $aRow1['TRN_VALUE'];
+ } else {
+ $msgstr = $aRow1['TRN_VALUE'];
+ }
+ } else {
+ //if not just copy the same
+ $msgstr = $aRow1['TRN_VALUE'];
+ }
+
+ $msgid = trim( $aRow1['TRN_VALUE'] );
+ $msgstr = trim( $msgstr );
+
+ if (isset( $aMsgids[$msgid] )) {
+ $msgid = '[' . $aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID'] . '] ' . $msgid;
+ }
+
+ $poFile->addTranslatorComment( 'TRANSLATION' );
+ $poFile->addTranslatorComment( $aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID'] );
+ $poFile->addReference( $aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID'] );
+
+ $poFile->addTranslation( stripcslashes( $msgid ), stripcslashes( $msgstr ) );
+ $aMsgids[$msgid] = true;
+ }
+
+ //$timer->setMarker('end making 1th .po from db');
+
+
+ //now find labels in xmlforms
+ /**
+ * *********
+ */
+ $aExceptionFields = array ('','javascript','hidden','phpvariable','private','toolbar','xmlmenu','toolbutton','cellmark','grid','CheckboxTable'
+ );
+
+ //find all xml files into PATH_XMLFORM
+ $aXMLForms = glob( PATH_XMLFORM . '*/*.xml' );
+ //from a sublevel to
+ $aXMLForms2 = glob( PATH_XMLFORM . '*/*/*.xml' );
+ $aXMLForms = array_merge( $aXMLForms, $aXMLForms2 );
+
+ $aEnglishLabel = array ();
+ $aOptions = array ();
+ $nodesNames = Array ();
+
+ G::loadSystem( 'dynaformhandler' );
+
+ foreach ($aXMLForms as $xmlFormPath) {
+ $xmlFormFile = str_replace( chr( 92 ), '/', $xmlFormPath );
+ $xmlFormFile = str_replace( PATH_XMLFORM, '', $xmlFormPath );
+
+ $dynaForm = new dynaFormHandler( $xmlFormPath );
+
+ $dynaNodes = $dynaForm->getFields();
+
+ //get all fields of each xmlform
+ foreach ($dynaNodes as $oNode) {
+
+ $sNodeName = $oNode->nodeName;
+ //$arrayNode = $dynaForm->getArray($oNode, Array('type', $_BASE_LANG, $_BASE_LANG));
+ $arrayNode = $dynaForm->getArray( $oNode );
+ //if has not native language translation
+ if (! isset( $arrayNode[$_BASE_LANG] ) || ! isset( $arrayNode['type'] ) || (isset( $arrayNode['type'] ) && in_array( $arrayNode['type'], $aExceptionFields ))) {
+ continue; //just continue with the next node
+ }
+
+ // Getting the Base Origin Text
+ if (! is_array( $arrayNode[$_BASE_LANG] )) {
+ $originNodeText = trim( $arrayNode[$_BASE_LANG] );
+ } else {
+ $langNode = $arrayNode[$_BASE_LANG][0];
+ $originNodeText = $langNode['__nodeText__'];
+ }
+
+ // Getting the Base Target Text
+ if (isset( $arrayNode[$_TARGET_LANG] )) {
+ if (! is_array( $arrayNode[$_TARGET_LANG] )) {
+ $targetNodeText = trim( $arrayNode[$_TARGET_LANG] );
+ } else {
+ $langNode = $arrayNode[$_TARGET_LANG][0];
+ $targetNodeText = $langNode['__nodeText__'];
+ }
+ } else {
+ $targetNodeText = $originNodeText;
+ }
+
+ $nodeName = $arrayNode['__nodeName__'];
+ $nodeType = $arrayNode['type'];
+
+ $msgid = $originNodeText;
+
+ // if the nodeName already exists in the po file, we need to create other msgid
+ if (isset( $aMsgids[$msgid] )) {
+ $msgid = '[' . $xmlFormFile . '?' . $nodeName . '] ' . $originNodeText;
+ }
+ $poFile->addTranslatorComment( $xmlFormFile . '?' . $nodeName );
+ $poFile->addTranslatorComment( $xmlFormFile );
+ $poFile->addReference( $nodeType . ' - ' . $nodeName );
+ $poFile->addTranslation( stripslashes( $msgid ), stripslashes( $targetNodeText ) );
+
+ $aMsgids[$msgid] = true;
+
+ //if this node has options child nodes
+ if (isset( $arrayNode[$_BASE_LANG] ) && isset( $arrayNode[$_BASE_LANG][0] ) && isset( $arrayNode[$_BASE_LANG][0]['option'] )) {
+
+ $originOptionNode = $arrayNode[$_BASE_LANG][0]['option']; //get the options
+
+
+ $targetOptionExists = false;
+ if (isset( $arrayNode[$_TARGET_LANG] ) && isset( $arrayNode[$_TARGET_LANG][0] ) && isset( $arrayNode[$_TARGET_LANG][0]['option'] )) {
+ $targetOptionNode = $arrayNode[$_TARGET_LANG][0]['option'];
+ $targetOptionExists = true;
+ }
+
+ if (! is_array( $originOptionNode )) {
+ if (is_string( $originOptionNode )) {
+ $poFile->addTranslatorComment( $xmlFormFile . '?' . $nodeName . '-' . $originOptionNode );
+ $poFile->addTranslatorComment( $xmlFormFile );
+ $poFile->addReference( $nodeType . ' - ' . $nodeName . ' - ' . $originOptionNode );
+ $poFile->addTranslation( stripslashes( $msgid ), stripslashes( $originOptionNode ) );
+ }
+ } else {
+ foreach ($originOptionNode as $optionNode) {
+ $optionName = $optionNode['name'];
+ $originOptionValue = $optionNode['__nodeText__'];
+
+ if ($targetOptionExists) {
+
+ $targetOptionValue = getMatchDropdownOptionValue( $optionName, $targetOptionNode );
+ if ($targetOptionValue === false) {
+ $targetOptionValue = $originOptionValue;
+ }
+ } else {
+ $targetOptionValue = $originOptionValue;
+ }
+
+ $msgid = '[' . $xmlFormFile . '?' . $nodeName . '-' . $optionName . ']';
+ $poFile->addTranslatorComment( $xmlFormFile . '?' . $nodeName . '-' . $optionName );
+ $poFile->addTranslatorComment( $xmlFormFile );
+ $poFile->addReference( $nodeType . ' - ' . $nodeName . ' - ' . $optionName );
+ $poFile->addTranslation( $msgid, stripslashes( $targetOptionValue ) );
+ }
+ }
+ }
+ } //end foreach
+
+
+ }
+
+ //
+ //$timer->setMarker('end xml files processed');
+ //$profiling = $timer->getProfiling();
+ //$timer->stop(); $timer->display();
+ //echo G::getMemoryUsage();
+ //die;
+ //g::pr($profiling);
+
+
+ G::streamFile( $sPOFile, true );
+
}
+}
+// Language
+
+
+function getMatchDropdownOptionValue ($name, $options)
+{
+ foreach ($options as $option) {
+ if ($name == $option['name']) {
+ return $option['__nodeText__'];
+ }
+ }
+ return false;
+}
+
diff --git a/workflow/engine/classes/model/UsersProperties.php b/workflow/engine/classes/model/UsersProperties.php
index 3c96381b2..3bea83334 100755
--- a/workflow/engine/classes/model/UsersProperties.php
+++ b/workflow/engine/classes/model/UsersProperties.php
@@ -2,449 +2,439 @@
require_once 'classes/model/om/BaseUsersProperties.php';
-
/**
* Skeleton subclass for representing a row from the 'USERS_PROPERTIES' table.
*
*
*
* You should add additional methods to this class to meet the
- * application requirements. This class will only be generated as
+ * application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
/**
- * @package workflow.engine.classes.model
+ *
+ * @package workflow.engine.classes.model
*/
class UsersProperties extends BaseUsersProperties
{
- public $fields = null;
- public $usrID = '';
- public $lang = 'en';
+ public $fields = null;
+ public $usrID = '';
+ public $lang = 'en';
- function __construct()
- {
- $this->lang = defined('SYS_LANG') ? SYS_LANG : 'en';
- }
+ function __construct ()
+ {
+ $this->lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
+ }
- function UserPropertyExists($sUserUID)
- {
- $oUserProperty = UsersPropertiesPeer::retrieveByPk($sUserUID);
- if (!is_null($oUserProperty) && is_object($oUserProperty) && get_class($oUserProperty) == 'UsersProperties') {
- $this->fields = $oUserProperty->toArray(BasePeer::TYPE_FIELDNAME);
- $this->fromArray($this->fields, BasePeer::TYPE_FIELDNAME);
- return true;
- }
- else {
- return false;
- }
- }
-
- public function load($sUserUID)
- {
- $oUserProperty = UsersPropertiesPeer::retrieveByPK($sUserUID);
- if (!is_null($oUserProperty)) {
- $aFields = $oUserProperty->toArray(BasePeer::TYPE_FIELDNAME);
- $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
- return $aFields;
- }
- else {
- throw new Exception("User with $sUserUID does not exist!");
- }
- }
-
- public function create($aData)
- {
- $oConnection = Propel::getConnection(UsersPropertiesPeer::DATABASE_NAME);
- try {
- $oUserProperty = new UsersProperties();
- $oUserProperty->fromArray($aData, BasePeer::TYPE_FIELDNAME);
- if ($oUserProperty->validate()) {
- $oConnection->begin();
- $iResult = $oUserProperty->save();
- $oConnection->commit();
- return true;
- }
- else {
- $sMessage = '';
- $aValidationFailures = $oUserProperty->getValidationFailures();
- foreach($aValidationFailures as $oValidationFailure) {
- $sMessage .= $oValidationFailure->getMessage() . '
';
+ function UserPropertyExists ($sUserUID)
+ {
+ $oUserProperty = UsersPropertiesPeer::retrieveByPk( $sUserUID );
+ if (! is_null( $oUserProperty ) && is_object( $oUserProperty ) && get_class( $oUserProperty ) == 'UsersProperties') {
+ $this->fields = $oUserProperty->toArray( BasePeer::TYPE_FIELDNAME );
+ $this->fromArray( $this->fields, BasePeer::TYPE_FIELDNAME );
+ return true;
+ } else {
+ return false;
}
- throw(new Exception('The registry cannot be created!
'.$sMessage));
- }
}
- catch (Exception $oError) {
- $oConnection->rollback();
- throw($oError);
- }
- }
- public function update($aData)
- {
- $oConnection = Propel::getConnection(UsersPropertiesPeer::DATABASE_NAME);
- try {
- $oUserProperty = UsersPropertiesPeer::retrieveByPK($aData['USR_UID']);
- if (!is_null($oUserProperty)) {
- $oUserProperty->fromArray($aData, BasePeer::TYPE_FIELDNAME);
- if ($oUserProperty->validate()) {
- $oConnection->begin();
- $iResult = $oUserProperty->save();
- $oConnection->commit();
- return $iResult;
+ public function load ($sUserUID)
+ {
+ $oUserProperty = UsersPropertiesPeer::retrieveByPK( $sUserUID );
+ if (! is_null( $oUserProperty )) {
+ $aFields = $oUserProperty->toArray( BasePeer::TYPE_FIELDNAME );
+ $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
+ return $aFields;
+ } else {
+ throw new Exception( "User with $sUserUID does not exist!" );
}
- else {
- $sMessage = '';
- $aValidationFailures = $oUserProperty->getValidationFailures();
- foreach($aValidationFailures as $oValidationFailure) {
- $sMessage .= $oValidationFailure->getMessage() . '
';
- }
- throw(new Exception('The registry cannot be updated!
'.$sMessage));
+ }
+
+ public function create ($aData)
+ {
+ $oConnection = Propel::getConnection( UsersPropertiesPeer::DATABASE_NAME );
+ try {
+ $oUserProperty = new UsersProperties();
+ $oUserProperty->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
+ if ($oUserProperty->validate()) {
+ $oConnection->begin();
+ $iResult = $oUserProperty->save();
+ $oConnection->commit();
+ return true;
+ } else {
+ $sMessage = '';
+ $aValidationFailures = $oUserProperty->getValidationFailures();
+ foreach ($aValidationFailures as $oValidationFailure) {
+ $sMessage .= $oValidationFailure->getMessage() . '
';
+ }
+ throw (new Exception( 'The registry cannot be created!
' . $sMessage ));
+ }
+ } catch (Exception $oError) {
+ $oConnection->rollback();
+ throw ($oError);
}
- }
- else {
- throw(new Exception('This row doesn\'t exist!'));
- }
- }
- catch (Exception $oError) {
- $oConnection->rollback();
- throw($oError);
- }
- }
-
- public function loadOrCreateIfNotExists($sUserUID, $aUserProperty = array())
- {
- if (!$this->UserPropertyExists($sUserUID)) {
- $aUserProperty['USR_UID'] = $sUserUID;
- if (!isset($aUserProperty['USR_LAST_UPDATE_DATE'])) {
- $aUserProperty['USR_LAST_UPDATE_DATE'] = date('Y-m-d H:i:s');
- }
- if (!isset($aUserProperty['USR_LOGGED_NEXT_TIME'])) {
- $aUserProperty['USR_LOGGED_NEXT_TIME'] = 0;
- }
- $this->create($aUserProperty);
- }
- else {
- $aUserProperty = $this->fields;
}
- return $aUserProperty;
- }
-
- public function validatePassword($sPassword, $sLastUpdate, $iChangePasswordNextTime)
- {
- if (!defined('PPP_MINIMUM_LENGTH')) {
- define('PPP_MINIMUM_LENGTH', 5);
- }
- if (!defined('PPP_MAXIMUM_LENGTH')) {
- define('PPP_MAXIMUM_LENGTH', 20);
- }
- if (!defined('PPP_NUMERICAL_CHARACTER_REQUIRED')) {
- define('PPP_NUMERICAL_CHARACTER_REQUIRED', 0);
- }
- if (!defined('PPP_UPPERCASE_CHARACTER_REQUIRED')) {
- define('PPP_UPPERCASE_CHARACTER_REQUIRED', 0);
- }
- if (!defined('PPP_SPECIAL_CHARACTER_REQUIRED')) {
- define('PPP_SPECIAL_CHARACTER_REQUIRED', 0);
- }
- if (!defined('PPP_EXPIRATION_IN')) {
- define('PPP_EXPIRATION_IN', 0);
- }
- if (!defined('PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN')) {
- define('PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN', 0);
- }
- if (function_exists('mb_strlen')) {
- $iLength = mb_strlen($sPassword);
- }
- else {
- $iLength = strlen($sPassword);
- }
- $aErrors = array();
- if ($iLength < PPP_MINIMUM_LENGTH) {
- $aErrors[] = 'ID_PPP_MINIMUM_LENGTH';
- }
- if ($iLength > PPP_MAXIMUM_LENGTH) {
- $aErrors[] = 'ID_PPP_MAXIMUM_LENGTH';
- }
- if (PPP_NUMERICAL_CHARACTER_REQUIRED == 1) {
- if (preg_match_all('/[0-9]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) == 0) {
- $aErrors[] = 'ID_PPP_NUMERICAL_CHARACTER_REQUIRED';
- }
- }
- if (PPP_UPPERCASE_CHARACTER_REQUIRED == 1) {
- if (preg_match_all('/[A-Z]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) == 0) {
- $aErrors[] = 'ID_PPP_UPPERCASE_CHARACTER_REQUIRED';
- }
- }
- if (PPP_SPECIAL_CHARACTER_REQUIRED == 1) {
- if (preg_match_all('/[��\\!|"@�#$~%�&�\/()=\'?��*+\-_.:,;]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) == 0) {
- $aErrors[] = 'ID_PPP_SPECIAL_CHARACTER_REQUIRED';
- }
- }
- if (PPP_EXPIRATION_IN > 0) {
- G::LoadClass('dates');
- $oDates = new dates();
- $fDays = $oDates->calculateDuration(date('Y-m-d H:i:s'), $sLastUpdate);
- if ($fDays > (PPP_EXPIRATION_IN*24)) {
- $aErrors[] = 'ID_PPP_EXPIRATION_IN';
- }
- }
- if (PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN == 1) {
- if ($iChangePasswordNextTime == 1) {
- $aErrors[] = 'ID_PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN';
- }
- }
- return $aErrors;
- }
-
-
- /**
- * get user location
- * defined by precedence plugin->ux->default
- */
- public function redirectTo($usrID, $lang='')
- {
- $this->usrID = $usrID;
- $this->lang = empty($lang) ? $this->lang : $lang;
-
- $url = $this->_getPluginLocation();
-
- if (empty($url)) {
- $url = $this->_getUXLocation();
+ public function update ($aData)
+ {
+ $oConnection = Propel::getConnection( UsersPropertiesPeer::DATABASE_NAME );
+ try {
+ $oUserProperty = UsersPropertiesPeer::retrieveByPK( $aData['USR_UID'] );
+ if (! is_null( $oUserProperty )) {
+ $oUserProperty->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
+ if ($oUserProperty->validate()) {
+ $oConnection->begin();
+ $iResult = $oUserProperty->save();
+ $oConnection->commit();
+ return $iResult;
+ } else {
+ $sMessage = '';
+ $aValidationFailures = $oUserProperty->getValidationFailures();
+ foreach ($aValidationFailures as $oValidationFailure) {
+ $sMessage .= $oValidationFailure->getMessage() . '
';
+ }
+ throw (new Exception( 'The registry cannot be updated!
' . $sMessage ));
+ }
+ } else {
+ throw (new Exception( 'This row doesn\'t exist!' ));
+ }
+ } catch (Exception $oError) {
+ $oConnection->rollback();
+ throw ($oError);
+ }
}
- $urlUx = $this->_getUXSkinVariant();
- if (empty($url) && !empty($urlUx)) {
- $_SESSION['_defaultUserLocation'] = $url;
- $url = $urlUx;
+ public function loadOrCreateIfNotExists ($sUserUID, $aUserProperty = array())
+ {
+ if (! $this->UserPropertyExists( $sUserUID )) {
+ $aUserProperty['USR_UID'] = $sUserUID;
+ if (! isset( $aUserProperty['USR_LAST_UPDATE_DATE'] )) {
+ $aUserProperty['USR_LAST_UPDATE_DATE'] = date( 'Y-m-d H:i:s' );
+ }
+ if (! isset( $aUserProperty['USR_LOGGED_NEXT_TIME'] )) {
+ $aUserProperty['USR_LOGGED_NEXT_TIME'] = 0;
+ }
+ $this->create( $aUserProperty );
+ } else {
+ $aUserProperty = $this->fields;
+ }
+
+ return $aUserProperty;
}
- if (empty($url)) {
- $url = $this->_getDefaultLocation();
+ public function validatePassword ($sPassword, $sLastUpdate, $iChangePasswordNextTime)
+ {
+ if (! defined( 'PPP_MINIMUM_LENGTH' )) {
+ define( 'PPP_MINIMUM_LENGTH', 5 );
+ }
+ if (! defined( 'PPP_MAXIMUM_LENGTH' )) {
+ define( 'PPP_MAXIMUM_LENGTH', 20 );
+ }
+ if (! defined( 'PPP_NUMERICAL_CHARACTER_REQUIRED' )) {
+ define( 'PPP_NUMERICAL_CHARACTER_REQUIRED', 0 );
+ }
+ if (! defined( 'PPP_UPPERCASE_CHARACTER_REQUIRED' )) {
+ define( 'PPP_UPPERCASE_CHARACTER_REQUIRED', 0 );
+ }
+ if (! defined( 'PPP_SPECIAL_CHARACTER_REQUIRED' )) {
+ define( 'PPP_SPECIAL_CHARACTER_REQUIRED', 0 );
+ }
+ if (! defined( 'PPP_EXPIRATION_IN' )) {
+ define( 'PPP_EXPIRATION_IN', 0 );
+ }
+ if (! defined( 'PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN' )) {
+ define( 'PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN', 0 );
+ }
+ if (function_exists( 'mb_strlen' )) {
+ $iLength = mb_strlen( $sPassword );
+ } else {
+ $iLength = strlen( $sPassword );
+ }
+ $aErrors = array ();
+ if ($iLength < PPP_MINIMUM_LENGTH) {
+ $aErrors[] = 'ID_PPP_MINIMUM_LENGTH';
+ }
+ if ($iLength > PPP_MAXIMUM_LENGTH) {
+ $aErrors[] = 'ID_PPP_MAXIMUM_LENGTH';
+ }
+ if (PPP_NUMERICAL_CHARACTER_REQUIRED == 1) {
+ if (preg_match_all( '/[0-9]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) == 0) {
+ $aErrors[] = 'ID_PPP_NUMERICAL_CHARACTER_REQUIRED';
+ }
+ }
+ if (PPP_UPPERCASE_CHARACTER_REQUIRED == 1) {
+ if (preg_match_all( '/[A-Z]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) == 0) {
+ $aErrors[] = 'ID_PPP_UPPERCASE_CHARACTER_REQUIRED';
+ }
+ }
+ if (PPP_SPECIAL_CHARACTER_REQUIRED == 1) {
+ if (preg_match_all( '/[��\\!|"@�#$~%�&�\/()=\'?��*+\-_.:,;]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) == 0) {
+ $aErrors[] = 'ID_PPP_SPECIAL_CHARACTER_REQUIRED';
+ }
+ }
+ if (PPP_EXPIRATION_IN > 0) {
+ G::LoadClass( 'dates' );
+ $oDates = new dates();
+ $fDays = $oDates->calculateDuration( date( 'Y-m-d H:i:s' ), $sLastUpdate );
+ if ($fDays > (PPP_EXPIRATION_IN * 24)) {
+ $aErrors[] = 'ID_PPP_EXPIRATION_IN';
+ }
+ }
+ if (PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN == 1) {
+ if ($iChangePasswordNextTime == 1) {
+ $aErrors[] = 'ID_PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN';
+ }
+ }
+ return $aErrors;
}
- return $url;
- }
+ /**
+ * get user location
+ * defined by precedence plugin->ux->default
+ */
+ public function redirectTo ($usrID, $lang = '')
+ {
+ $this->usrID = $usrID;
+ $this->lang = empty( $lang ) ? $this->lang : $lang;
- /**
- * get user location
- * defined by precedence plugin->default
- * note that is getting location without User Inbox Simplified varification
- */
- public function getUserLocation($usrID, $lang = 'en')
- {
- $this->usrID = $usrID;
- $this->lang = empty($lang) ? $this->lang : $lang;
+ $url = $this->_getPluginLocation();
- $url = $this->_getPluginLocation();
+ if (empty( $url )) {
+ $url = $this->_getUXLocation();
+ }
- if (empty($url)) {
- $url = $this->_getDefaultLocation();
+ $urlUx = $this->_getUXSkinVariant();
+ if (empty( $url ) && ! empty( $urlUx )) {
+ $_SESSION['_defaultUserLocation'] = $url;
+ $url = $urlUx;
+ }
+
+ if (empty( $url )) {
+ $url = $this->_getDefaultLocation();
+ }
+
+ return $url;
}
- $urlUx = $this->_getUXSkinVariant();
- if (!empty($urlUx)) {
- $_SESSION['_defaultUserLocation'] = $url;
- $url = $urlUx;
+ /**
+ * get user location
+ * defined by precedence plugin->default
+ * note that is getting location without User Inbox Simplified varification
+ */
+ public function getUserLocation ($usrID, $lang = 'en')
+ {
+ $this->usrID = $usrID;
+ $this->lang = empty( $lang ) ? $this->lang : $lang;
+
+ $url = $this->_getPluginLocation();
+
+ if (empty( $url )) {
+ $url = $this->_getDefaultLocation();
+ }
+
+ $urlUx = $this->_getUXSkinVariant();
+ if (! empty( $urlUx )) {
+ $_SESSION['_defaultUserLocation'] = $url;
+ $url = $urlUx;
+ }
+
+ return $url;
}
- return $url;
- }
+ /**
+ * to verify if the user is using some "ux..." skin variant
+ * if that is the case, the redirection will change to 'main' controller
+ */
+ public function _getUXSkinVariant ()
+ {
+ $url = '';
- /**
- * to verify if the user is using some "ux..." skin variant
- * if that is the case, the redirection will change to 'main' controller
- */
- public function _getUXSkinVariant()
- {
- $url = '';
+ if (substr( SYS_SKIN, 0, 2 ) == 'ux' && SYS_SKIN != 'uxs') {
+ $url = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/main';
+ global $RBAC;
+ G::loadClass( 'configuration' );
+ $oConf = new Configurations();
+ $oConf->loadConfig( $x, 'USER_PREFERENCES', '', '', $_SESSION['USER_LOGGED'], '' );
+ if (sizeof( $oConf->aConfig ) > 0) {
+ if ($oConf->aConfig['DEFAULT_MENU'] == 'PM_USERS') {
+ $oConf->aConfig['DEFAULT_MENU'] = 'PM_SETUP';
+ }
- if (substr(SYS_SKIN, 0, 2) == 'ux' && SYS_SKIN != 'uxs') {
- $url = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/main';
+ $getUrl = null;
+
+ switch ($oConf->aConfig['DEFAULT_MENU']) {
+ case 'PM_SETUP':
+ if ($RBAC->userCanAccess( 'PM_SETUP' ) == 1) {
+ $getUrl = 'admin';
+ }
+ break;
+ case 'PM_FACTORY':
+ if ($RBAC->userCanAccess( 'PM_FACTORY' ) == 1) {
+ $getUrl = 'designer';
+ }
+ break;
+ case 'PM_CASES':
+ if ($RBAC->userCanAccess( 'PM_CASES' ) == 1) {
+ $getUrl = 'home';
+ }
+ break;
+ case 'PM_USERS':
+ if ($RBAC->userCanAccess( 'PM_USERS' ) == 1) {
+ $getUrl = 'admin';
+ }
+ break;
+ case 'PM_DASHBOARD':
+ if ($RBAC->userCanAccess( 'PM_DASHBOARD' ) == 1) {
+ $getUrl = 'dashboard';
+ }
+ break;
+ }
+
+ $url = $url . (($getUrl != null) ? "?st=" . $getUrl : null);
+ }
+ }
+ return $url;
+ }
+
+ /**
+ * get the plugins, and check if there is redirectLogins
+ * if yes, then redirect goes according his Role
+ */
+ public function _getPluginLocation ()
+ {
global $RBAC;
- G::loadClass('configuration');
- $oConf = new Configurations;
- $oConf->loadConfig($x, 'USER_PREFERENCES','','',$_SESSION['USER_LOGGED'],'');
- if ( sizeof($oConf->aConfig) > 0) {
+ $url = '';
+
+ if (class_exists( 'redirectDetail' )) {
+ //to do: complete the validation
+ if (isset( $RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE'] )) {
+ $userRole = $RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE'];
+ }
+
+ $oPluginRegistry = &PMPluginRegistry::getSingleton();
+ $aRedirectLogin = $oPluginRegistry->getRedirectLogins();
+ if (isset( $aRedirectLogin ) && is_array( $aRedirectLogin )) {
+ foreach ($aRedirectLogin as $key => $detail) {
+ if (isset( $detail->sPathMethod ) && $detail->sRoleCode == $userRole) {
+ $url = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/' . $detail->sPathMethod;
+ }
+ }
+ }
+ }
+
+ return $url;
+ }
+
+ /**
+ * New feature - User Experience Redirector
+ *
+ * @author Erik Amaru Ortiz
+ */
+ public function _getUXLocation ()
+ {
+ require_once 'classes/model/Users.php';
+ $u = UsersPeer::retrieveByPK( $this->usrID );
+ $url = '';
+
+ $uxType = $u->getUsrUx();
+ $_SESSION['user_experience'] = 'NORMAL';
+
+ // find a group setting
+ if ($uxType == '' || $uxType == 'NORMAL') {
+ require_once 'classes/model/GroupUser.php';
+ $gu = new GroupUser();
+ $ugList = $gu->getAllUserGroups( $this->usrID );
+
+ foreach ($ugList as $row) {
+ if ($row['GRP_UX'] != 'NORMAL' && $row['GRP_UX'] != '') {
+ $uxType = $row['GRP_UX'];
+ break;
+ }
+ }
+ }
+
+ switch ($uxType) {
+ case 'SIMPLIFIED':
+ case 'SWITCHABLE':
+ case 'SINGLE':
+ $_SESSION['user_experience'] = $uxType;
+ $_SESSION['user_last_skin'] = SYS_SKIN;
+ $url = '/sys' . SYS_SYS . '/' . $this->lang . '/uxs/' . 'home';
+ break;
+ }
+
+ return $url;
+ }
+
+ /**
+ * get user preferences for default redirect
+ * verifying if it has any preferences on configurations table
+ */
+ public function _getDefaultLocation ()
+ {
+ global $RBAC;
+ G::loadClass( 'configuration' );
+ $oConf = new Configurations();
+ $oConf->loadConfig( $x, 'USER_PREFERENCES', '', '', $_SESSION['USER_LOGGED'], '' );
+
+ $baseUrl = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/';
+ $url = '';
+
+ if (sizeof( $oConf->aConfig ) > 0) {
+ // this user has a configuration record
+ // backward compatibility, because now, we don't have user and dashboard menu.
if ($oConf->aConfig['DEFAULT_MENU'] == 'PM_USERS') {
$oConf->aConfig['DEFAULT_MENU'] = 'PM_SETUP';
}
- $getUrl = null;
-
switch ($oConf->aConfig['DEFAULT_MENU']) {
case 'PM_SETUP':
- if ($RBAC->userCanAccess('PM_SETUP') == 1) {
- $getUrl = 'admin';
+ if ($RBAC->userCanAccess( 'PM_SETUP' ) == 1) {
+ $url = 'setup/main';
}
break;
case 'PM_FACTORY':
- if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
- $getUrl = 'designer';
+ if ($RBAC->userCanAccess( 'PM_FACTORY' ) == 1) {
+ $url = 'processes/main';
}
break;
case 'PM_CASES':
- if ($RBAC->userCanAccess('PM_CASES') == 1) {
- $getUrl = 'home';
+ if ($RBAC->userCanAccess( 'PM_CASES' ) == 1) {
+ $url = 'cases/main';
}
break;
case 'PM_USERS':
- if ($RBAC->userCanAccess('PM_USERS') == 1) {
- $getUrl = 'admin';
+ if ($RBAC->userCanAccess( 'PM_USERS' ) == 1) {
+ $url = 'setup/main';
}
break;
case 'PM_DASHBOARD':
- if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
- $getUrl = 'dashboard';
+ if ($RBAC->userCanAccess( 'PM_DASHBOARD' ) == 1) {
+ $url = 'dashboard/main';
}
break;
}
-
- $url = $url . (($getUrl != null)? "?st=" . $getUrl : null);
- }
- }
- return $url;
- }
-
- /**
- * get the plugins, and check if there is redirectLogins
- * if yes, then redirect goes according his Role
- */
- public function _getPluginLocation()
- {
- global $RBAC;
- $url = '';
-
- if ( class_exists('redirectDetail')) {
- //to do: complete the validation
- if(isset($RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE']))
- $userRole = $RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE'];
-
- $oPluginRegistry = &PMPluginRegistry::getSingleton();
- $aRedirectLogin = $oPluginRegistry->getRedirectLogins();
- if (isset($aRedirectLogin) && is_array($aRedirectLogin) ) {
- foreach ($aRedirectLogin as $key=>$detail) {
- if (isset($detail->sPathMethod) && $detail->sRoleCode == $userRole ) {
- $url = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/' . $detail->sPathMethod;
- }
- }
- }
- }
-
- return $url;
- }
-
- /**
- * New feature - User Experience Redirector
- * @author Erik Amaru Ortiz
- */
- public function _getUXLocation()
- {
- require_once 'classes/model/Users.php';
- $u = UsersPeer::retrieveByPK($this->usrID);
- $url = '';
-
- $uxType = $u->getUsrUx();
- $_SESSION['user_experience'] = 'NORMAL';
-
- // find a group setting
- if ($uxType == '' || $uxType == 'NORMAL') {
- require_once 'classes/model/GroupUser.php';
- $gu = new GroupUser();
- $ugList = $gu->getAllUserGroups($this->usrID);
-
- foreach ($ugList as $row) {
- if ($row['GRP_UX'] != 'NORMAL' && $row['GRP_UX'] != '') {
- $uxType = $row['GRP_UX'];
- break;
- }
- }
- }
-
- switch ($uxType) {
- case 'SIMPLIFIED':
- case 'SWITCHABLE':
- case 'SINGLE':
- $_SESSION['user_experience'] = $uxType;
- $_SESSION['user_last_skin'] = SYS_SKIN;
- $url = '/sys' . SYS_SYS . '/' . $this->lang . '/uxs/' . 'home';
- break;
- }
-
- return $url;
- }
-
- /**
- * get user preferences for default redirect
- * verifying if it has any preferences on configurations table
- */
- public function _getDefaultLocation()
- {
- global $RBAC;
- G::loadClass('configuration');
- $oConf = new Configurations;
- $oConf->loadConfig($x, 'USER_PREFERENCES','','',$_SESSION['USER_LOGGED'],'');
-
- $baseUrl = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/';
- $url = '';
-
- if( sizeof($oConf->aConfig) > 0) { // this user has a configuration record
- // backward compatibility, because now, we don't have user and dashboard menu.
- if ($oConf->aConfig['DEFAULT_MENU'] == 'PM_USERS') {
- $oConf->aConfig['DEFAULT_MENU'] = 'PM_SETUP';
}
- switch ($oConf->aConfig['DEFAULT_MENU']) {
- case 'PM_SETUP':
- if ($RBAC->userCanAccess('PM_SETUP') == 1) {
- $url = 'setup/main';
- }
- break;
- case 'PM_FACTORY':
- if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
- $url = 'processes/main';
- }
- break;
- case 'PM_CASES':
- if ($RBAC->userCanAccess('PM_CASES') == 1) {
- $url = 'cases/main';
- }
- break;
- case 'PM_USERS':
- if ($RBAC->userCanAccess('PM_USERS') == 1) {
- $url = 'setup/main';
- }
- break;
- case 'PM_DASHBOARD':
- if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
- $url = 'dashboard/main';
- }
- break;
+ if (empty( $url )) {
+ if ($RBAC->userCanAccess( 'PM_FACTORY' ) == 1) {
+ $url = 'processes/main';
+ } elseif ($RBAC->userCanAccess( 'PM_SETUP' ) == 1) {
+ $url = 'setup/main';
+ } elseif ($RBAC->userCanAccess( 'PM_CASES' ) == 1) {
+ $url = 'cases/main';
+ } elseif ($RBAC->userCanAccess( 'PM_USERS' ) == 1) {
+ $url = 'setup/main';
+ } elseif ($RBAC->userCanAccess( 'PM_DASHBOARD' ) == 1) {
+ $url = 'dashboard/dashboard';
+ } else {
+ $url = 'users/myInfo';
+ }
}
- }
- if (empty($url)) {
- if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
- $url = 'processes/main';
- }
- else if ($RBAC->userCanAccess('PM_SETUP') == 1) {
- $url = 'setup/main';
- }
- else if ($RBAC->userCanAccess('PM_CASES') == 1) {
- $url = 'cases/main';
- }
- else if ($RBAC->userCanAccess('PM_USERS') == 1) {
- $url = 'setup/main';
- }
- else if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
- $url = 'dashboard/dashboard';
- }
- else {
- $url = 'users/myInfo';
- }
+ return $baseUrl . $url;
}
+}
+// UsersProperties
- return $baseUrl . $url;
- }
-} // UsersProperties
diff --git a/workflow/engine/classes/triggers/class.pmTrSharepoint.php b/workflow/engine/classes/triggers/class.pmTrSharepoint.php
index 04589a293..bdeef6bb7 100755
--- a/workflow/engine/classes/triggers/class.pmTrSharepoint.php
+++ b/workflow/engine/classes/triggers/class.pmTrSharepoint.php
@@ -2,432 +2,458 @@
/**
* class.pmTrSharepoint.php
- *
*/
-G::LoadSystem("soapNtlm");
+G::LoadSystem( "soapNtlm" );
-class wscaller {
+class wscaller
+{
- private $wsdlurl;
- private $soapObj;
- private $client;
- private $auth;
- private $clientStream;
+ private $wsdlurl;
+ private $soapObj;
+ private $client;
+ private $auth;
+ private $clientStream;
- function setAuthUser($auth) {
- //print "
- auth Setup";
- $this->auth = $auth;
- }
-
- function setwsdlurl($wsdl) {
- //print "
- wsdl Setup";
- $this->wsdlurl = $wsdl;
- //var_dump($wsdl);
- }
-
- function loadSOAPClient() {
- try {
- // we unregister the current HTTP wrapper
- stream_wrapper_unregister('http');
- // we register the new HTTP wrapper
- //$client = new PMServiceProviderNTLMStream($this->auth);
- PMServiceProviderNTLMStream::setAuthStream($this->auth);
- stream_wrapper_register('http', 'PMServiceProviderNTLMStream') or die("Failed to register protocol");
-
-// $this->client = new PMServiceNTLMSoapClient($this->wsdlurl, array('trace' => 1, 'auth' => $this->auth));// Hugo's code
- $this->client = new PMServiceNTLMSoapClient($this->wsdlurl, array('trace' => 1)); // Ankit's Code
- $this->client->setAuthClient($this->auth);
- return true;
- } catch (Exception $e) {
- echo $e;
- exit;
+ function setAuthUser ($auth)
+ {
+ //print "
- auth Setup";
+ $this->auth = $auth;
}
- }
- function callWsMethod($methodName, $paramArray) {
-
- try {
- if ($methodName == 'DeleteDws' || $methodName == 'GetListCollection') {
- $strResult = "";
- $strResult = $this->client->$methodName($paramArray = "");
- return $strResult;
- } else {
- $strResult = "";
- $strResult = $this->client->$methodName($paramArray);
- return $strResult;
- }
- } catch (SoapFault $fault) {
- echo 'Fault code: ' . $fault->faultcode;
- echo 'Fault string: ' . $fault->faultstring;
+ function setwsdlurl ($wsdl)
+ {
+ //print "
- wsdl Setup";
+ $this->wsdlurl = $wsdl;
+ //var_dump($wsdl);
}
- stream_wrapper_restore('http');
- }
+ function loadSOAPClient ()
+ {
+ try {
+ // we unregister the current HTTP wrapper
+ stream_wrapper_unregister( 'http' );
+ // we register the new HTTP wrapper
+ //$client = new PMServiceProviderNTLMStream($this->auth);
+ PMServiceProviderNTLMStream::setAuthStream( $this->auth );
+ stream_wrapper_register( 'http', 'PMServiceProviderNTLMStream' ) or die( "Failed to register protocol" );
+
+ // $this->client = new PMServiceNTLMSoapClient($this->wsdlurl, array('trace' => 1, 'auth' => $this->auth));// Hugo's code
+ $this->client = new PMServiceNTLMSoapClient( $this->wsdlurl, array ('trace' => 1
+ ) ); // Ankit's Code
+ $this->client->setAuthClient( $this->auth );
+ return true;
+ } catch (Exception $e) {
+ echo $e;
+ exit();
+ }
+ }
+
+ function callWsMethod ($methodName, $paramArray)
+ {
+
+ try {
+ if ($methodName == 'DeleteDws' || $methodName == 'GetListCollection') {
+ $strResult = "";
+ $strResult = $this->client->$methodName( $paramArray = "" );
+ return $strResult;
+ } else {
+ $strResult = "";
+ $strResult = $this->client->$methodName( $paramArray );
+ return $strResult;
+ }
+ } catch (SoapFault $fault) {
+ echo 'Fault code: ' . $fault->faultcode;
+ echo 'Fault string: ' . $fault->faultstring;
+ }
+ stream_wrapper_restore( 'http' );
+ }
}
-class DestinationUrlCollection {
-
- public $string;
+class DestinationUrlCollection
+{
+ public $string;
}
;
-class FieldInformation {
-
+class FieldInformation
+{
}
-class FieldInformationCollection {
-
- public $FieldInformation;
-
+class FieldInformationCollection
+{
+ public $FieldInformation;
}
-class pmTrSharepointClass{
-
- function __construct($server, $auth) {
- set_include_path(
- PATH_PLUGINS . 'pmTrSharepoint' . PATH_SEPARATOR .
- get_include_path()
- );
- $this->server = $server;
- $this->auth = $auth;
- $this->dwsObj = new wscaller();
- $this->dwsObj->setAuthUser($this->auth);
- }
-
- function createDWS($name, $users, $title, $documents) {
- //print "
- Method createDWS";
- $this->dwsObj->setwsdlurl($this->server . "/_vti_bin/Dws.asmx?WSDL");
-
- $this->dwsObj->loadSOAPClient();
-
- $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => '');
-
- $methodName = 'CreateDws';
-
- $result = $this->dwsObj->callWsMethod($methodName, $paramArray);
- $xml = $result->CreateDwsResult; // in Result we get string in Xml format
- $xmlNew = simplexml_load_string($xml); // used to parse string to xml
- $xmlArray = @G::json_decode(@G::json_encode($xmlNew), 1); // used to convert Objects to array
- $dwsUrl = $xmlArray['Url'];
- return "Dws with following Url is created:$dwsUrl";
-
- /* $newResult = $result->CreateDwsResult;
- $needleStart='';
- $urlStartPos = strpos($newResult, $needleStart);
- $urlStart = $urlStartPos + 5;
- $needleEnd='';
- $urlEndPos = strpos($newResult, $needleEnd);
- $length = $urlEndPos - $urlStart;
- $result = substr($newResult, $urlStart, $length);
- return $result; */
- }
-
- function deleteDWS($dwsname) {
- //print "
- Method createDWS";
- $url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
- $this->dwsObj->setwsdlurl($url);
-
- $this->dwsObj->loadSOAPClient();
- $paramArray = null;
- $methodName = 'DeleteDws';
- $result = $this->dwsObj->callWsMethod($methodName, $paramArray = null);
- var_dump($result);
- return $result;
-
- }
-
- function createFolderDWS($dwsname, $dwsFolderName) {
- //print "
- Method createDWS";
- $this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL");
-
- $this->dwsObj->loadSOAPClient();
-
- $url = "Shared Documents/$dwsFolderName";
- $paramArray = array('url' => $url);
-
- # $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => '');
-
- $methodName = 'CreateFolder';
-
- $result = $this->dwsObj->callWsMethod($methodName, $paramArray);
- var_dump($result);
- return $result;
- }
-
- function deleteFolderDWS($dwsname, $folderName) {
- //print "
- Method createDWS";
- $this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL");
-
- $this->dwsObj->loadSOAPClient();
-
- $url = "Shared Documents/$folderName";
- $paramArray = array('url' => $url);
-
- # $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => '');
-
- $methodName = 'DeleteFolder';
-
- $result = $this->dwsObj->callWsMethod($methodName, $paramArray);
- var_dump($result);
- return $result;
- }
-
- function findDWSdoc($dwsname, $guid) {
- //print "
- Method createDWS";
- $this->dwsObj->setwsdlurl($this->server . $dwsName . "/_vti_bin/Dws.asmx?WSDL");
-
- $this->dwsObj->loadSOAPClient();
-
- $paramArray = array('id' => '$guid');
-
- $methodName = 'FindDwsDoc';
-
- $result = $this->dwsObj->callWsMethod($methodName, $paramArray);
- var_dump($result);
- }
-
- function getDWSData($newFileName, $dwsname, $lastUpdate) {
- //print "
- Method getDWSData
";
- $url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
- $this->dwsObj->setwsdlurl($url);
- if ($this->dwsObj->loadSOAPClient()) {
- $doc = "Shared Documents";
- $paramArray = array('document' => '', 'lastUpdate' => '');
- $methodName = 'GetDwsData';
- $result = $this->dwsObj->callWsMethod($methodName, $paramArray);
- var_dump($result);
- $sResult = $result->GetDwsDataResult;
- /* $xmlNew = simplexml_load_string($sResult);// used to parse string to xml
- $xmlArray = @G::json_decode(@G::json_encode($xmlNew),1);// used to convert Objects to array */
- $serializeResult = serialize($sResult); // serializing the Array for Returning.
- var_dump($serializeResult);
- return $serializeResult;
- } else {
- return "The enter the Correct Dws Name";
- }
- }
-
- function uploadDocumentDWS($dwsname, $folderName, $sourceUrl, $filename) {
- //print "
- Method createDWS";
- $url = $this->server ."/". $dwsname . "/_vti_bin/Copy.asmx?WSDL";
- $this->dwsObj->setwsdlurl($url);
- $this->dwsObj->loadSOAPClient();
-
- $destUrlObj = new DestinationUrlCollection();
- if ($folderName != '') {
- $destUrl = $this->server . "/$dwsname/Shared%20Documents/$folderName/$filename";
- } else {
- $destUrl = $this->server . "/$dwsname/Shared%20Documents/$filename";
- }
- $destUrlObj->string = $destUrl;
-
- $fieldInfoObj = new FieldInformation();
-
- $fieldInfoCollObj = new FieldInformationCollection();
- $fieldInfoCollObj->FieldInformation = $fieldInfoObj;
-
- $imgfile = $sourceUrl . "/" . $filename;
- $filep = fopen($imgfile, "r");
- $fileLength = filesize($imgfile);
- $content = fread($filep, $fileLength);
- //$content = base64_encode($content);
-
- $paramArray = array('SourceUrl' => $imgfile, 'DestinationUrls' => $destUrlObj, 'Fields' => $fieldInfoCollObj, 'Stream' => $content);
- $methodName = 'CopyIntoItems';
- $result = $this->dwsObj->callWsMethod($methodName, $paramArray);
- var_dump($result);
- $newResult = $result->Results->CopyResult->ErrorCode;
- if ($newResult == 'Success') {
- return "The document has been uploaded Successfully";
- } else {
- return "Could not Upload the Document due to some Error";
- }
- }
-
- function getDWSMetaData($newFileName, $dwsname, $id) {
- //print "
- Method createDWS";
- $url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
- $this->dwsObj->setwsdlurl($url);
-
- $this->dwsObj->loadSOAPClient();
-
- $doc = "Shared Documents/$newFileName";
- $paramArray = array('document' => $doc, 'id' => '', 'minimal' => False);
-
- $methodName = 'GetDwsMetaData';
-
- $result = $this->dwsObj->callWsMethod($methodName, $paramArray);
- $sResult = $result->GetDwsMetaDataResult;
- $errorReturn = strpos($sResult, "Error");
- if(isset($sResult) && !$errorReturn)
+class pmTrSharepointClass
+{
+ function __construct ($server, $auth)
{
- $serializeResult = serialize($sResult); // serializing the Array for Returning.
- var_dump($serializeResult);
- return $serializeResult;
+ set_include_path( PATH_PLUGINS . 'pmTrSharepoint' . PATH_SEPARATOR . get_include_path() );
+ $this->server = $server;
+ $this->auth = $auth;
+ $this->dwsObj = new wscaller();
+ $this->dwsObj->setAuthUser( $this->auth );
}
- else return $sResult;
- }
- function getDWSDocumentVersions($newFileName, $dwsname) {
- //print "
- Method createDWS";
- $this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL");
+ function createDWS ($name, $users, $title, $documents)
+ {
+ //print "
- Method createDWS";
+ $this->dwsObj->setwsdlurl( $this->server . "/_vti_bin/Dws.asmx?WSDL" );
- $this->dwsObj->loadSOAPClient();
+ $this->dwsObj->loadSOAPClient();
- $doc = "Shared Documents/$newFileName";
- $paramArray = array('fileName' => $doc);
+ $paramArray = array ('name' => '','users' => '','title' => $name,'documents' => ''
+ );
- $methodName = 'GetVersions';
+ $methodName = 'CreateDws';
- $result = $this->dwsObj->callWsMethod($methodName, $paramArray);
- var_dump($result);
- return $result;
- }
+ $result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
+ $xml = $result->CreateDwsResult; // in Result we get string in Xml format
+ $xmlNew = simplexml_load_string( $xml ); // used to parse string to xml
+ $xmlArray = @G::json_decode( @G::json_encode( $xmlNew ), 1 ); // used to convert Objects to array
+ $dwsUrl = $xmlArray['Url'];
+ return "Dws with following Url is created:$dwsUrl";
- function deleteDWSDocVersion($newFileName, $dwsname, $versionNum) {
- //print "
- Method createDWS";
- $this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL");
-
- $this->dwsObj->loadSOAPClient();
-
- $doc = "Shared Documents/$newFileName";
- $paramArray = array('fileName' => $doc, 'fileVersion' => $versionNum);
-
- $methodName = 'DeleteVersion';
-
- $result = $this->dwsObj->callWsMethod($methodName, $paramArray);
- if ($result) {
- $sResult = $result->DeleteVersionResult->any;
- $xmlNew = simplexml_load_string($sResult); // used to parse string to xml
- $xmlArray = @G::json_decode(@G::json_encode($xmlNew), 1); // used to convert Objects to array
- $versionCount = count($xmlArray['result']);
-
- if($versionCount>1)
- {
- for($i=0;$i<$versionCount;$i++)
- {
- $version[] = $xmlArray['result'][$i]['@attributes']['version'];
- }
- }
- else{
- $version[] = $xmlArray['result']['@attributes']['version'];
- }
-
- $serializeResult = serialize($version); // serializing the Array for Returning.
- var_dump($serializeResult);
- return $serializeResult;
- } else {
- return"The given Version could not be deleted.";
+ /* $newResult = $result->CreateDwsResult;
+ $needleStart='';
+ $urlStartPos = strpos($newResult, $needleStart);
+ $urlStart = $urlStartPos + 5;
+ $needleEnd='';
+ $urlEndPos = strpos($newResult, $needleEnd);
+ $length = $urlEndPos - $urlStart;
+ $result = substr($newResult, $urlStart, $length);
+ return $result; */
}
- }
- function deleteAllDWSDocVersion($newFileName, $dwsname) {
- //print "
- Method createDWS";
- $this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL");
+ function deleteDWS ($dwsname)
+ {
+ //print "
- Method createDWS";
+ $url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
+ $this->dwsObj->setwsdlurl( $url );
- $this->dwsObj->loadSOAPClient();
+ $this->dwsObj->loadSOAPClient();
+ $paramArray = null;
+ $methodName = 'DeleteDws';
+ $result = $this->dwsObj->callWsMethod( $methodName, $paramArray = null );
+ var_dump( $result );
+ return $result;
- $doc = "Shared Documents/$newFileName";
- $paramArray = array('fileName' => $doc);
-
- $methodName = 'DeleteAllVersions';
-
- $result = $this->dwsObj->callWsMethod($methodName, $paramArray);
- if ($result) {
- $xml = $result->DeleteAllVersionsResult->any; // in Result we get string in Xml format
- $xmlNew = simplexml_load_string($xml); // used to parse string to xml
- $xmlArray = @G::json_decode(@G::json_encode($xmlNew), 1); // used to convert Objects to array
- $latestVersion = $xmlArray['result']['@attributes']['version'];
- return "All Versions are Deleted, except the latest i.e $latestVersion";
- } else {
- return "The Version/ File name/ Dws Name is incorrect";
}
- }
- function getDWSFolderItems($dwsname, $strFolderUrl) {
- $pmTrSharepointClassObj = new pmTrSharepointClass();
- //print "
- Method getDWSFolderItems";
- $url = $this->server . "/" . $dwsname . "/_vti_bin/SiteData.asmx?WSDL";
- $this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/SiteData.asmx?WSDL");
+ function createFolderDWS ($dwsname, $dwsFolderName)
+ {
+ //print "
- Method createDWS";
+ $this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL" );
- $this->dwsObj->loadSOAPClient();
+ $this->dwsObj->loadSOAPClient();
- #$doc = "Shared Documents/$newFileName";
- $paramArray = array('strFolderUrl' => $strFolderUrl);
+ $url = "Shared Documents/$dwsFolderName";
+ $paramArray = array ('url' => $url
+ );
- $methodName = 'EnumerateFolder';
+ # $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => '');
- $result = $this->dwsObj->callWsMethod($methodName, $paramArray);
- //$newResult = $result->vUrls->_sFPUrl->Url;
- if (isset($result->vUrls->_sFPUrl->Url)) {
- $returnContent = $pmTrSharepointClassObj->getFolderUrlContent($result->vUrls->_sFPUrl->Url);
- $serializeResult = serialize($returnContent);
- return $serializeResult;
- } else if (isset($result->vUrls->_sFPUrl)) {
- $itemCount = count($result->vUrls->_sFPUrl);
- for ($i = 0; $i < $itemCount; $i++) {
- $aObjects = $result->vUrls->_sFPUrl[$i]->IsFolder;
- //$booleanStatus = $aObjects[$i]->IsFolder;
- if ($aObjects) {
- $listArr = $result->vUrls->_sFPUrl[$i]->Url;
- $returnContent[] = $pmTrSharepointClassObj->getFolderUrlContent($listArr) . "(Is a Folder)";
+
+ $methodName = 'CreateFolder';
+
+ $result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
+ var_dump( $result );
+ return $result;
+ }
+
+ function deleteFolderDWS ($dwsname, $folderName)
+ {
+ //print "
- Method createDWS";
+ $this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL" );
+
+ $this->dwsObj->loadSOAPClient();
+
+ $url = "Shared Documents/$folderName";
+ $paramArray = array ('url' => $url
+ );
+
+ # $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => '');
+
+
+ $methodName = 'DeleteFolder';
+
+ $result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
+ var_dump( $result );
+ return $result;
+ }
+
+ function findDWSdoc ($dwsname, $guid)
+ {
+ //print "
- Method createDWS";
+ $this->dwsObj->setwsdlurl( $this->server . $dwsName . "/_vti_bin/Dws.asmx?WSDL" );
+
+ $this->dwsObj->loadSOAPClient();
+
+ $paramArray = array ('id' => '$guid'
+ );
+
+ $methodName = 'FindDwsDoc';
+
+ $result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
+ var_dump( $result );
+ }
+
+ function getDWSData ($newFileName, $dwsname, $lastUpdate)
+ {
+ //print "
- Method getDWSData
";
+ $url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
+ $this->dwsObj->setwsdlurl( $url );
+ if ($this->dwsObj->loadSOAPClient()) {
+ $doc = "Shared Documents";
+ $paramArray = array ('document' => '','lastUpdate' => ''
+ );
+ $methodName = 'GetDwsData';
+ $result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
+ var_dump( $result );
+ $sResult = $result->GetDwsDataResult;
+ /* $xmlNew = simplexml_load_string($sResult);// used to parse string to xml
+ $xmlArray = @G::json_decode(@G::json_encode($xmlNew),1);// used to convert Objects to array */
+ $serializeResult = serialize( $sResult ); // serializing the Array for Returning.
+ var_dump( $serializeResult );
+ return $serializeResult;
} else {
- $listArr = $result->vUrls->_sFPUrl[$i]->Url;
- $returnContent[] = $pmTrSharepointClassObj->getFolderUrlContent($listArr) . "(Is a File)";
+ return "The enter the Correct Dws Name";
}
- }
- $serializeResult = serialize($returnContent);
- return $serializeResult;
}
- return "There is some error";
- }
- function downloadDocumentDWS($dwsname, $fileName, $fileLocation) {
- //print "
- Method createDWS";
- $url = $this->server . "/" . $dwsname . "/_vti_bin/Copy.asmx?WSDL";
- $this->dwsObj->setwsdlurl($url);
+ function uploadDocumentDWS ($dwsname, $folderName, $sourceUrl, $filename)
+ {
+ //print "
- Method createDWS";
+ $url = $this->server . "/" . $dwsname . "/_vti_bin/Copy.asmx?WSDL";
+ $this->dwsObj->setwsdlurl( $url );
+ $this->dwsObj->loadSOAPClient();
- $this->dwsObj->loadSOAPClient();
+ $destUrlObj = new DestinationUrlCollection();
+ if ($folderName != '') {
+ $destUrl = $this->server . "/$dwsname/Shared%20Documents/$folderName/$filename";
+ } else {
+ $destUrl = $this->server . "/$dwsname/Shared%20Documents/$filename";
+ }
+ $destUrlObj->string = $destUrl;
- $CompleteUrl = $this->server . "/" . $dwsname . "/Shared Documents/" . $fileName;
- $paramArray = array('Url' => $CompleteUrl);
+ $fieldInfoObj = new FieldInformation();
- $methodName = 'GetItem';
+ $fieldInfoCollObj = new FieldInformationCollection();
+ $fieldInfoCollObj->FieldInformation = $fieldInfoObj;
- $result = $this->dwsObj->callWsMethod($methodName, $paramArray);
- $newResult = $result->Stream;
+ $imgfile = $sourceUrl . "/" . $filename;
+ $filep = fopen( $imgfile, "r" );
+ $fileLength = filesize( $imgfile );
+ $content = fread( $filep, $fileLength );
+ //$content = base64_encode($content);
- //$latestResult = base64_decode($newResult);
- /**
- * In the Below line of code, we are coping the files at our local Directory using the php file methods.
- * */
- $imgfile = $fileLocation . "/" . $fileName;
- $filep = fopen($imgfile, 'w');
- //$content = fwrite($filep, $latestResult);
- $content = fwrite($filep, $newResult);
- return $content;
- }
-
- function getFolderUrlContent($newResult) {
- $needleStart = '/';
- $needleCount = substr_count($newResult, $needleStart);
-
- $urlStartPos = strpos($newResult, $needleStart);
- $urlStartPos++;
-
- if ($needleCount == '2') {
- $newResultPos = strpos($newResult, $needleStart, $urlStartPos);
- $newResultPos++;
- $actualResult = substr($newResult, $newResultPos);
- return $actualResult;
+ $paramArray = array ('SourceUrl' => $imgfile,'DestinationUrls' => $destUrlObj,'Fields' => $fieldInfoCollObj,'Stream' => $content
+ );
+ $methodName = 'CopyIntoItems';
+ $result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
+ var_dump( $result );
+ $newResult = $result->Results->CopyResult->ErrorCode;
+ if ($newResult == 'Success') {
+ return "The document has been uploaded Successfully";
+ } else {
+ return "Could not Upload the Document due to some Error";
+ }
}
- else{
- $actualResult = substr($newResult,$urlStartPos);
+
+ function getDWSMetaData ($newFileName, $dwsname, $id)
+ {
+ //print "
- Method createDWS";
+ $url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
+ $this->dwsObj->setwsdlurl( $url );
+
+ $this->dwsObj->loadSOAPClient();
+
+ $doc = "Shared Documents/$newFileName";
+ $paramArray = array ('document' => $doc,'id' => '','minimal' => false
+ );
+
+ $methodName = 'GetDwsMetaData';
+
+ $result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
+ $sResult = $result->GetDwsMetaDataResult;
+ $errorReturn = strpos( $sResult, "Error" );
+ if (isset( $sResult ) && ! $errorReturn) {
+ $serializeResult = serialize( $sResult ); // serializing the Array for Returning.
+ var_dump( $serializeResult );
+ return $serializeResult;
+ } else {
+ return $sResult;
+ }
+ }
+
+ function getDWSDocumentVersions ($newFileName, $dwsname)
+ {
+ //print "
- Method createDWS";
+ $this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL" );
+
+ $this->dwsObj->loadSOAPClient();
+
+ $doc = "Shared Documents/$newFileName";
+ $paramArray = array ('fileName' => $doc
+ );
+
+ $methodName = 'GetVersions';
+
+ $result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
+ var_dump( $result );
+ return $result;
+ }
+
+ function deleteDWSDocVersion ($newFileName, $dwsname, $versionNum)
+ {
+ //print "
- Method createDWS";
+ $this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL" );
+
+ $this->dwsObj->loadSOAPClient();
+
+ $doc = "Shared Documents/$newFileName";
+ $paramArray = array ('fileName' => $doc,'fileVersion' => $versionNum
+ );
+
+ $methodName = 'DeleteVersion';
+
+ $result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
+ if ($result) {
+ $sResult = $result->DeleteVersionResult->any;
+ $xmlNew = simplexml_load_string( $sResult ); // used to parse string to xml
+ $xmlArray = @G::json_decode( @G::json_encode( $xmlNew ), 1 ); // used to convert Objects to array
+ $versionCount = count( $xmlArray['result'] );
+
+ if ($versionCount > 1) {
+ for ($i = 0; $i < $versionCount; $i ++) {
+ $version[] = $xmlArray['result'][$i]['@attributes']['version'];
+ }
+ } else {
+ $version[] = $xmlArray['result']['@attributes']['version'];
+ }
+
+ $serializeResult = serialize( $version ); // serializing the Array for Returning.
+ var_dump( $serializeResult );
+ return $serializeResult;
+ } else {
+ return "The given Version could not be deleted.";
+ }
+ }
+
+ function deleteAllDWSDocVersion ($newFileName, $dwsname)
+ {
+ //print "
- Method createDWS";
+ $this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL" );
+
+ $this->dwsObj->loadSOAPClient();
+
+ $doc = "Shared Documents/$newFileName";
+ $paramArray = array ('fileName' => $doc
+ );
+
+ $methodName = 'DeleteAllVersions';
+
+ $result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
+ if ($result) {
+ $xml = $result->DeleteAllVersionsResult->any; // in Result we get string in Xml format
+ $xmlNew = simplexml_load_string( $xml ); // used to parse string to xml
+ $xmlArray = @G::json_decode( @G::json_encode( $xmlNew ), 1 ); // used to convert Objects to array
+ $latestVersion = $xmlArray['result']['@attributes']['version'];
+ return "All Versions are Deleted, except the latest i.e $latestVersion";
+ } else {
+ return "The Version/ File name/ Dws Name is incorrect";
+ }
+ }
+
+ function getDWSFolderItems ($dwsname, $strFolderUrl)
+ {
+ $pmTrSharepointClassObj = new pmTrSharepointClass();
+ //print "
- Method getDWSFolderItems";
+ $url = $this->server . "/" . $dwsname . "/_vti_bin/SiteData.asmx?WSDL";
+ $this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/SiteData.asmx?WSDL" );
+
+ $this->dwsObj->loadSOAPClient();
+
+ #$doc = "Shared Documents/$newFileName";
+ $paramArray = array ('strFolderUrl' => $strFolderUrl
+ );
+
+ $methodName = 'EnumerateFolder';
+
+ $result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
+ //$newResult = $result->vUrls->_sFPUrl->Url;
+ if (isset( $result->vUrls->_sFPUrl->Url )) {
+ $returnContent = $pmTrSharepointClassObj->getFolderUrlContent( $result->vUrls->_sFPUrl->Url );
+ $serializeResult = serialize( $returnContent );
+ return $serializeResult;
+ } elseif (isset( $result->vUrls->_sFPUrl )) {
+ $itemCount = count( $result->vUrls->_sFPUrl );
+ for ($i = 0; $i < $itemCount; $i ++) {
+ $aObjects = $result->vUrls->_sFPUrl[$i]->IsFolder;
+ //$booleanStatus = $aObjects[$i]->IsFolder;
+ if ($aObjects) {
+ $listArr = $result->vUrls->_sFPUrl[$i]->Url;
+ $returnContent[] = $pmTrSharepointClassObj->getFolderUrlContent( $listArr ) . "(Is a Folder)";
+ } else {
+ $listArr = $result->vUrls->_sFPUrl[$i]->Url;
+ $returnContent[] = $pmTrSharepointClassObj->getFolderUrlContent( $listArr ) . "(Is a File)";
+ }
+ }
+ $serializeResult = serialize( $returnContent );
+ return $serializeResult;
+ }
+ return "There is some error";
+ }
+
+ function downloadDocumentDWS ($dwsname, $fileName, $fileLocation)
+ {
+ //print "
- Method createDWS";
+ $url = $this->server . "/" . $dwsname . "/_vti_bin/Copy.asmx?WSDL";
+ $this->dwsObj->setwsdlurl( $url );
+
+ $this->dwsObj->loadSOAPClient();
+
+ $CompleteUrl = $this->server . "/" . $dwsname . "/Shared Documents/" . $fileName;
+ $paramArray = array ('Url' => $CompleteUrl
+ );
+
+ $methodName = 'GetItem';
+
+ $result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
+ $newResult = $result->Stream;
+
+ //$latestResult = base64_decode($newResult);
+
+ /**
+ * In the Below line of code, we are coping the files at our local Directory using the php file methods.
+ */
+ $imgfile = $fileLocation . "/" . $fileName;
+ $filep = fopen( $imgfile, 'w' );
+ //$content = fwrite($filep, $latestResult);
+ $content = fwrite( $filep, $newResult );
+ return $content;
+ }
+
+ function getFolderUrlContent ($newResult)
+ {
+ $needleStart = '/';
+ $needleCount = substr_count( $newResult, $needleStart );
+
+ $urlStartPos = strpos( $newResult, $needleStart );
+ $urlStartPos ++;
+
+ if ($needleCount == '2') {
+ $newResultPos = strpos( $newResult, $needleStart, $urlStartPos );
+ $newResultPos ++;
+ $actualResult = substr( $newResult, $newResultPos );
+ return $actualResult;
+ } else {
+ $actualResult = substr( $newResult, $urlStartPos );
return $actualResult;
}
- }
+ }
+}
-}
\ No newline at end of file