CODE STYLE, checking in detail...
FILES: workflow/engine/classes/model/AppDelegation.php workflow/engine/classes/model/Dynaform.php workflow/engine/classes/model/Groupwf.php workflow/engine/classes/model/Language.php workflow/engine/classes/model/UsersProperties.php workflow/engine/classes/triggers/class.pmTrSharepoint.php
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* AppDelegation.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -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.
|
||||
@@ -41,10 +42,12 @@ G::LoadClass("dates");
|
||||
*
|
||||
* @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
|
||||
@@ -56,95 +59,94 @@ class AppDelegation extends BaseAppDelegation {
|
||||
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( $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( $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( $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( $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.' ) );
|
||||
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 = new Criteria();
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn ( 'MAX(' . AppDelegationPeer::DEL_INDEX . ') ' );
|
||||
$c->add ( AppDelegationPeer::APP_UID, $sAppUid );
|
||||
$c->addSelectColumn( 'MAX(' . AppDelegationPeer::DEL_INDEX . ') ' );
|
||||
$c->add( AppDelegationPeer::APP_UID, $sAppUid );
|
||||
|
||||
$rs = AppDelegationPeer::doSelectRS ( $c );
|
||||
$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' );
|
||||
$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);
|
||||
$delTaskDueDate = $this->calculateDueDate( $sNextTasParam );
|
||||
|
||||
$this->setDelTaskDueDate ( $delTaskDueDate['DUE_DATE'] ); // Due date formatted
|
||||
$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 ( '' );
|
||||
|
||||
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 ($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);
|
||||
}
|
||||
catch ( PropelException $e ) {
|
||||
throw ( $e );
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
$msg = '';
|
||||
$validationFailuresArray = $this->getValidationFailures();
|
||||
foreach($validationFailuresArray as $objValidationFailure) {
|
||||
foreach ($validationFailuresArray as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
}
|
||||
throw ( new Exception ( 'Failed Data validation. ' . $msg ) );
|
||||
throw (new Exception( 'Failed Data validation. ' . $msg ));
|
||||
}
|
||||
|
||||
$delIndex = $this->getDelIndex();
|
||||
|
||||
// Hook for the trigger PM_CREATE_NEW_DELEGATION
|
||||
if (defined('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);
|
||||
$oPluginRegistry->executeTriggers( PM_CREATE_NEW_DELEGATION, $data );
|
||||
}
|
||||
|
||||
return $delIndex;
|
||||
@@ -157,106 +159,102 @@ class AppDelegation extends BaseAppDelegation {
|
||||
* @return array $Fields the fields
|
||||
*/
|
||||
|
||||
function Load ( $AppUid, $sDelIndex ) {
|
||||
$con = Propel::getConnection(AppDelegationPeer::DATABASE_NAME);
|
||||
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 );
|
||||
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!" ));
|
||||
}
|
||||
else {
|
||||
throw( new Exception( "The row '$AppUid, $sDelIndex' in table AppDelegation doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the application row
|
||||
*
|
||||
* @param array $aData
|
||||
* @return variant
|
||||
**/
|
||||
*
|
||||
*/
|
||||
|
||||
public function update($aData)
|
||||
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' ) {
|
||||
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 {
|
||||
} else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
foreach ($this->getValidationFailures() as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
}
|
||||
|
||||
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
|
||||
throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$con->rollback();
|
||||
throw(new Exception( "This AppDelegation row doesn't exist!" ));
|
||||
throw (new Exception( "This AppDelegation row doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function remove($sApplicationUID, $iDelegationIndex) {
|
||||
$oConnection = Propel::getConnection(StepTriggerPeer::DATABASE_NAME);
|
||||
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' ) {
|
||||
if (is_object( $oApp ) && get_class( $oApp ) == 'AppDelegation') {
|
||||
$result = $oApp->delete();
|
||||
}
|
||||
$oConnection->commit();
|
||||
return $result;
|
||||
}
|
||||
catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$oConnection->rollback();
|
||||
throw($e);
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
// TasTypeDay = 1 => working days
|
||||
// TasTypeDay = 2 => calendar days
|
||||
function calculateDueDate($sNextTasParam)
|
||||
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')
|
||||
{
|
||||
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'] != '') {
|
||||
if (isset( $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'] ) && $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'] != '') {
|
||||
$aCalendarUID = $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'];
|
||||
}
|
||||
else {
|
||||
} 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)) {
|
||||
$oTask->update( $aData );
|
||||
} else {
|
||||
if (is_null( $task )) {
|
||||
return 0;
|
||||
}
|
||||
$aData['TAS_DURATION'] = $task->getTasDuration();
|
||||
@@ -267,57 +265,52 @@ class AppDelegation extends BaseAppDelegation {
|
||||
|
||||
//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
|
||||
$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
|
||||
);
|
||||
$this->getUsrUid(), $task->getProUid(), $aData['TAS_UID'], $aCalendarUID );
|
||||
|
||||
return $iDueDate;
|
||||
}
|
||||
|
||||
function getDiffDate ( $date1, $date2 )
|
||||
function getDiffDate ($date1, $date2)
|
||||
{
|
||||
return ( $date1 - $date2 )/(24*60*60); //days
|
||||
return ( $date1 - $date2 ) / 3600;
|
||||
return ($date1 - $date2) / (24 * 60 * 60); //days
|
||||
return ($date1 - $date2) / 3600;
|
||||
}
|
||||
|
||||
public function calculateDuration($cron=0)
|
||||
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->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 = AppDelegationPeer::doSelectRS( $c );
|
||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
|
||||
while (is_array($row)) {
|
||||
while (is_array( $row )) {
|
||||
if ($cron == 1) {
|
||||
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
|
||||
$arrayCron = unserialize( trim( @file_get_contents( PATH_DATA . "cron" ) ) );
|
||||
$arrayCron["processcTimeStart"] = time();
|
||||
@file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
|
||||
@file_put_contents( PATH_DATA . "cron", serialize( $arrayCron ) );
|
||||
}
|
||||
|
||||
$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 = 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();
|
||||
@@ -325,123 +318,125 @@ class AppDelegation extends BaseAppDelegation {
|
||||
}
|
||||
//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 = 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);
|
||||
$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;
|
||||
$i = 0;
|
||||
//print "<table colspacing='2' border='1'>";
|
||||
//print "<tr><td>iDelegateDate </td><td>iInitDate </td><td>iDueDate </td><td>iFinishDate </td><td>isStarted </td><td>isFinished </td><td>isDelayed </td><td>queueDuration </td><td>delDuration </td><td>delayDuration</td></tr>";
|
||||
|
||||
$now = strtotime ( 'now' );
|
||||
while ( is_array($row) ) {
|
||||
|
||||
$now = strtotime( 'now' );
|
||||
while (is_array( $row )) {
|
||||
if ($cron == 1) {
|
||||
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
|
||||
$arrayCron = unserialize( trim( @file_get_contents( PATH_DATA . "cron" ) ) );
|
||||
$arrayCron["processcTimeStart"] = time();
|
||||
@file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
|
||||
@file_put_contents( PATH_DATA . "cron", serialize( $arrayCron ) );
|
||||
}
|
||||
|
||||
$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);
|
||||
$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'] );
|
||||
$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);
|
||||
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) {
|
||||
$delayDuration = $this->getDiffDate( $now, $iDueDate );
|
||||
$oAppDel->setDelDelayDuration( $delayDuration );
|
||||
if ($fTaskDuration != 0) {
|
||||
$overduePercentage = $delayDuration / $fTaskDuration;
|
||||
$oAppDel->setAppOverduePercentage( $overduePercentage);
|
||||
if ( $iDueDate < $now ) {
|
||||
$oAppDel->setDelDelayed(1);
|
||||
$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);
|
||||
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);
|
||||
$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);
|
||||
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 );
|
||||
}
|
||||
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);
|
||||
$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) {
|
||||
$delayDuration = $this->getDiffDate( $now, $iDueDate );
|
||||
$oAppDel->setDelDelayDuration( $delayDuration );
|
||||
if ($fTaskDuration != 0) {
|
||||
$overduePercentage = $delayDuration / $fTaskDuration;
|
||||
$oAppDel->setAppOverduePercentage($overduePercentage );
|
||||
if ( $iDueDate < $now ) {
|
||||
$oAppDel->setDelDelayed(1);
|
||||
$oAppDel->setAppOverduePercentage( $overduePercentage );
|
||||
if ($iDueDate < $now) {
|
||||
$oAppDel->setDelDelayed( 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -453,6 +448,7 @@ class AppDelegation extends BaseAppDelegation {
|
||||
//print "<tr><td>$iDelegateDate </td><td>$iInitDate </td><td>$iDueDate </td><td>$iFinishDate </td><td>$isStarted </td><td>$isFinished </td><td>$isDelayed</td><td>$queueDuration </td><td>$delDuration </td>" .
|
||||
// "<td>$delayDuration</td><td>$overduePercentage</td><td>" . $row['DEL_INDEX'] . " $RES </td></tr>";
|
||||
|
||||
|
||||
//UPDATE APP_DELEGATION SET DEL_DELAYED = 0
|
||||
//where
|
||||
// APP_OVERDUE_PERCENTAGE < 0
|
||||
@@ -460,33 +456,35 @@ class AppDelegation extends BaseAppDelegation {
|
||||
$row = $rs->getRow();
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
error_log( $oError->getMessage());
|
||||
} 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);
|
||||
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);
|
||||
$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
|
||||
}
|
||||
// AppDelegation
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Dynaform.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -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.
|
||||
@@ -40,24 +41,27 @@ G::LoadClass('dynaFormField');
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
class Dynaform extends BaseDynaform {
|
||||
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()
|
||||
public function getDynTitle ()
|
||||
{
|
||||
if ( $this->getDynUid() == '' ) {
|
||||
throw ( new Exception( "Error in getDynTitle, the DYN_UID can't be blank") );
|
||||
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 );
|
||||
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
$this->dyn_title = Content::load( 'DYN_TITLE', '', $this->getDynUid(), $lang );
|
||||
return $this->dyn_title;
|
||||
}
|
||||
|
||||
@@ -67,43 +71,46 @@ class Dynaform extends BaseDynaform {
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDynTitle($v)
|
||||
public function setDynTitle ($v)
|
||||
{
|
||||
if ( $this->getDynUid() == '' ) {
|
||||
throw ( new Exception( "Error in setDynTitle, the DYN_UID can't be blank") );
|
||||
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)) {
|
||||
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';
|
||||
$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()
|
||||
public function getDynDescription ()
|
||||
{
|
||||
if ( $this->getDynUid() == '' ) {
|
||||
throw ( new Exception( "Error in getDynDescription, the DYN_UID can't be blank") );
|
||||
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 );
|
||||
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
$this->dyn_description = Content::load( 'DYN_DESCRIPTION', '', $this->getDynUid(), $lang );
|
||||
return $this->dyn_description;
|
||||
}
|
||||
|
||||
@@ -113,26 +120,27 @@ class Dynaform extends BaseDynaform {
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDynDescription($v)
|
||||
public function setDynDescription ($v)
|
||||
{
|
||||
if ( $this->getDynUid() == '' ) {
|
||||
throw ( new Exception( "Error in setDynDescription, the DYN_UID can't be blank") );
|
||||
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)) {
|
||||
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';
|
||||
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
|
||||
$res = Content::addContent( 'DYN_DESCRIPTION', '', $this->getDynUid(), $lang, $this->dyn_description );
|
||||
}
|
||||
|
||||
} // set()
|
||||
|
||||
|
||||
/**
|
||||
* Creates the Dynaform
|
||||
*
|
||||
@@ -142,62 +150,67 @@ class Dynaform extends BaseDynaform {
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function create ($aData ) {
|
||||
if ( !isset ( $aData['PRO_UID'] ) ) {
|
||||
throw ( new PropelException ( 'The dynaform cannot be created. The PRO_UID is empty.' ) );
|
||||
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
|
||||
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 );
|
||||
}
|
||||
$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() ) {
|
||||
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_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' );
|
||||
if (isset( $aData['DYN_DESCRIPTION'] )) {
|
||||
$this->setDynDescription( $aData['DYN_DESCRIPTION'] );
|
||||
} else {
|
||||
$this->setDynDescription( 'Default Dynaform Description' );
|
||||
}
|
||||
|
||||
$con->commit();
|
||||
$sXml = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
|
||||
$sXml .= '<dynaForm type="' . $this->getDynType() . '" name="' . $this->getProUid() . '/' . $this->getDynUid() . '" width="500" enabletemplate="0" mode="" nextstepsave="prompt">'."\n";
|
||||
$sXml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||
$sXml .= '<dynaForm type="' . $this->getDynType() . '" name="' . $this->getProUid() . '/' . $this->getDynUid() . '" width="500" enabletemplate="0" mode="" nextstepsave="prompt">' . "\n";
|
||||
$sXml .= '</dynaForm>';
|
||||
G::verifyPath(PATH_DYNAFORM . $this->getProUid(), true);
|
||||
$oFile = fopen(PATH_DYNAFORM . $this->getProUid() . '/' . $this->getDynUid() . '.xml', 'w');
|
||||
fwrite($oFile, $sXml);
|
||||
fclose($oFile);
|
||||
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 {
|
||||
} else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
foreach ($this->getValidationFailures() as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Creates a Dynaform based on a PMTable
|
||||
*
|
||||
@@ -210,86 +223,90 @@ class Dynaform extends BaseDynaform {
|
||||
*
|
||||
*/
|
||||
|
||||
function createFromPMTable ( $aData, $pmTableUid ) {
|
||||
$this->create($aData);
|
||||
$aData['DYN_UID']=$this->getDynUid();
|
||||
function createFromPMTable ($aData, $pmTableUid)
|
||||
{
|
||||
$this->create( $aData );
|
||||
$aData['DYN_UID'] = $this->getDynUid();
|
||||
//krumo(BasePeer::getFieldnames('Content'));
|
||||
$fields = array();
|
||||
$fields = array ();
|
||||
//$oCriteria = new Criteria('workflow');
|
||||
$pmTable = AdditionalTablesPeer::retrieveByPK($pmTableUid);
|
||||
$pmTable = AdditionalTablesPeer::retrieveByPK( $pmTableUid );
|
||||
$addTabName = $pmTable->getAddTabName();
|
||||
$keys = '';
|
||||
if (isset($aData['FIELDS'])){
|
||||
if (isset( $aData['FIELDS'] )) {
|
||||
foreach ($aData['FIELDS'] as $iRow => $row) {
|
||||
if ($keys!='')
|
||||
$keys = $keys.'|'.$row['PRO_VARIABLE'];
|
||||
else
|
||||
if ($keys != '') {
|
||||
$keys = $keys . '|' . $row['PRO_VARIABLE'];
|
||||
} else {
|
||||
$keys = $row['PRO_VARIABLE'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$keys = ' ';
|
||||
}
|
||||
|
||||
// $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'];
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// $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);
|
||||
$sDataBase = 'database_' . strtolower( DB_ADAPTER );
|
||||
if (G::LoadSystemExist( $sDataBase )) {
|
||||
G::LoadSystem( $sDataBase );
|
||||
$oDataBase = new database();
|
||||
$sql = $oDataBase->getTableDescription($addTabName);
|
||||
$sql = $oDataBase->getTableDescription( $addTabName );
|
||||
} else {
|
||||
$sql = 'DESC '.$addTabName;
|
||||
$sql = 'DESC ' . $addTabName;
|
||||
}
|
||||
|
||||
$dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
|
||||
$dbh = Propel::getConnection( AdditionalTablesPeer::DATABASE_NAME );
|
||||
$sth = $dbh->createStatement();
|
||||
$res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||
$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);
|
||||
$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';
|
||||
$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);
|
||||
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++;
|
||||
if ($res->get( 'Key' ) != '') {
|
||||
$countKeys ++;
|
||||
}
|
||||
if ($res->get('Extra') == 'auto_increment') {
|
||||
$keyRequered .= $res->get('Field');
|
||||
if ($res->get( 'Extra' ) == 'auto_increment') {
|
||||
$keyRequered .= $res->get( 'Field' );
|
||||
}
|
||||
}
|
||||
|
||||
$dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
|
||||
$dbh = Propel::getConnection( AdditionalTablesPeer::DATABASE_NAME );
|
||||
$sth = $dbh->createStatement();
|
||||
$res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||
$res = $sth->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
while ($res->next()){
|
||||
while ($res->next()) {
|
||||
// if(strtoupper($res->get('Null'))=='NO') {
|
||||
if(strtoupper($res->get($oDataBase->getFieldNull() ))=='NO'){
|
||||
if ($countKeys == 1 && $res->get('Field') == $keyRequered) {
|
||||
if (strtoupper( $res->get( $oDataBase->getFieldNull() ) ) == 'NO') {
|
||||
if ($countKeys == 1 && $res->get( 'Field' ) == $keyRequered) {
|
||||
$required = '0';
|
||||
} else {
|
||||
$required = '1';
|
||||
@@ -297,13 +314,14 @@ class Dynaform extends BaseDynaform {
|
||||
} else {
|
||||
$required = '0';
|
||||
}
|
||||
$fieldName = $res->get('Field');
|
||||
$defaultValue = $res->get('Default');
|
||||
$labels = array ( SYS_LANG => $fieldName );
|
||||
$options = array();
|
||||
$type = explode('(',$res->get('Type'));
|
||||
$fieldName = $res->get( 'Field' );
|
||||
$defaultValue = $res->get( 'Default' );
|
||||
$labels = array (SYS_LANG => $fieldName
|
||||
);
|
||||
$options = array ();
|
||||
$type = explode( '(', $res->get( 'Type' ) );
|
||||
|
||||
switch ($type[0]){
|
||||
switch ($type[0]) {
|
||||
case 'text':
|
||||
$type = 'textarea';
|
||||
break;
|
||||
@@ -314,31 +332,22 @@ class Dynaform extends BaseDynaform {
|
||||
$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
|
||||
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
|
||||
$attributes = array ('XMLNODE_NAME_OLD' => '','XMLNODE_NAME' => $fieldName,'TYPE' => $type,'REQUIRED' => $required,'DEFAULTVALUE' => $defaultValue
|
||||
);
|
||||
}
|
||||
$fieldXML->Save($attributes, $labels, $options);
|
||||
$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);
|
||||
$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.
|
||||
*
|
||||
@@ -346,111 +355,111 @@ class Dynaform extends BaseDynaform {
|
||||
* @return array $Fields the fields
|
||||
*/
|
||||
|
||||
function Load ( $ProUid ) {
|
||||
$con = Propel::getConnection(DynaformPeer::DATABASE_NAME);
|
||||
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 );
|
||||
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() );
|
||||
$this->setDynTitle( $oPro->getDynTitle() );
|
||||
$this->setDynDescription( $oPro->getDynDescription() );
|
||||
return $aFields;
|
||||
} else {
|
||||
throw (new Exception( "The row '$ProUid' in table Dynaform doesn't exist!" ));
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$ProUid' in table Dynaform doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Prolication row
|
||||
*
|
||||
* @param array $aData
|
||||
* @return variant
|
||||
**/
|
||||
*
|
||||
*/
|
||||
|
||||
public function update($aData)
|
||||
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' ) {
|
||||
if (is_object( $oPro ) && get_class( $oPro ) == 'Dynaform') {
|
||||
$oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oPro->validate()) {
|
||||
if ( isset ( $aData['DYN_TITLE'] ) )
|
||||
if (isset( $aData['DYN_TITLE'] )) {
|
||||
$oPro->setDynTitle( $aData['DYN_TITLE'] );
|
||||
if ( isset ( $aData['DYN_DESCRIPTION'] ) )
|
||||
}
|
||||
if (isset( $aData['DYN_DESCRIPTION'] )) {
|
||||
$oPro->setDynDescription( $aData['DYN_DESCRIPTION'] );
|
||||
}
|
||||
$res = $oPro->save();
|
||||
$con->commit();
|
||||
return $res;
|
||||
}
|
||||
else {
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
} else {
|
||||
foreach ($this->getValidationFailures() as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$con->rollback();
|
||||
throw(new Exception( "The row '" . $aData['DYN_UID'] . "' in table Dynaform doesn't exist!" ));
|
||||
throw (new Exception( "The row '" . $aData['DYN_UID'] . "' in table Dynaform doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the Prolication document registry
|
||||
*
|
||||
* @param array $aData or string $ProUid
|
||||
* @return string
|
||||
**/
|
||||
public function remove($ProUid)
|
||||
*
|
||||
*/
|
||||
public function remove ($ProUid)
|
||||
{
|
||||
if ( is_array ( $ProUid ) ) {
|
||||
$ProUid = ( isset ( $ProUid['DYN_UID'] ) ? $ProUid['DYN_UID'] : '' );
|
||||
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());
|
||||
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() . '.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() . '_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() . '.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');
|
||||
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!" ));
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$ProUid' in table Dynaform doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function exists($DynUid)
|
||||
public function exists ($DynUid)
|
||||
{
|
||||
$oPro = DynaformPeer::retrieveByPk( $DynUid );
|
||||
return (is_object($oPro) && get_class ($oPro) == 'Dynaform' );
|
||||
return (is_object( $oPro ) && get_class( $oPro ) == 'Dynaform');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -459,74 +468,77 @@ class Dynaform extends BaseDynaform {
|
||||
* @param string $sProUid the uid of the Prolication
|
||||
*/
|
||||
|
||||
function dynaformExists ( $DynUid ) {
|
||||
$con = Propel::getConnection(TaskPeer::DATABASE_NAME);
|
||||
function dynaformExists ($DynUid)
|
||||
{
|
||||
$con = Propel::getConnection( TaskPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oDyn = DynaformPeer::retrieveByPk( $DynUid );
|
||||
if (is_object($oDyn) && get_class ($oDyn) == 'Dynaform' ) {
|
||||
if (is_object( $oDyn ) && get_class( $oDyn ) == 'Dynaform') {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function getDynaformContent( $dynaformUid) {
|
||||
function getDynaformContent ($dynaformUid)
|
||||
{
|
||||
$content = '';
|
||||
$fields = $this->Load ( $dynaformUid);
|
||||
$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 );
|
||||
$content = file_get_contents( $filename );
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
function getDynaformFields( $dynaformUid) {
|
||||
function getDynaformFields ($dynaformUid)
|
||||
{
|
||||
$content = '';
|
||||
$fields = $this->Load ( $dynaformUid);
|
||||
$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 );
|
||||
$content = file_get_contents( $filename );
|
||||
}
|
||||
|
||||
$G_FORM = new xmlform ( $fields['DYN_FILENAME'] , PATH_DYNAFORM );
|
||||
$G_FORM->parseFile( $filename , SYS_LANG, true );
|
||||
$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 );
|
||||
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;
|
||||
$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);
|
||||
$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;
|
||||
if ($aRow1['DYNAFORMS']) {
|
||||
$flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $flag;
|
||||
}
|
||||
}
|
||||
// Dynaform
|
||||
|
||||
} // Dynaform
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Groupwf.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -38,9 +39,11 @@ require_once 'classes/model/Content.php';
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
class Groupwf extends BaseGroupwf {
|
||||
class Groupwf extends BaseGroupwf
|
||||
{
|
||||
/**
|
||||
* This value goes in the content table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
//protected $grp_title = '';
|
||||
@@ -48,15 +51,16 @@ class Groupwf extends BaseGroupwf {
|
||||
|
||||
/**
|
||||
* Get the [grp_title] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGrpTitle()
|
||||
public function getGrpTitle ()
|
||||
{
|
||||
if ( $this->getGrpUid() == '' ) {
|
||||
throw ( new Exception( "Error in getGrpTitle, the GRP_UID can't be blank") );
|
||||
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 );
|
||||
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
$this->grp_title = Content::load( 'GRP_TITLE', '', $this->getGrpUid(), $lang );
|
||||
return $this->grp_title;
|
||||
}
|
||||
|
||||
@@ -66,25 +70,26 @@ class Groupwf extends BaseGroupwf {
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setGrpTitle($v)
|
||||
public function setGrpTitle ($v)
|
||||
{
|
||||
if ( $this->getGrpUid() == '' ) {
|
||||
throw ( new Exception( "Error in setGrpTitle, the GRP_UID can't be blank") );
|
||||
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)) {
|
||||
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';
|
||||
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
$res = Content::addContent( 'GRP_TITLE', '', $this->getGrpUid(), $lang, $this->grp_title );
|
||||
}
|
||||
|
||||
} // set()
|
||||
|
||||
|
||||
/**
|
||||
* Creates the Group
|
||||
*
|
||||
@@ -92,47 +97,51 @@ class Groupwf extends BaseGroupwf {
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function create ($aData ) {
|
||||
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_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_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 (isset( $aData['GRP_LDAP_DN'] )) {
|
||||
$this->setGrpLdapDn( $aData['GRP_LDAP_DN'] );
|
||||
} else {
|
||||
$this->setGrpLdapDn( '' );
|
||||
}
|
||||
|
||||
if ( $this->validate() ) {
|
||||
if ($this->validate()) {
|
||||
$con->begin();
|
||||
$res = $this->save();
|
||||
|
||||
if (isset ( $aData['GRP_TITLE'] ) )
|
||||
$this->setGrpTitle ( $aData['GRP_TITLE'] );
|
||||
else
|
||||
$this->setGrpTitle ( 'Default Group Title' );
|
||||
if (isset( $aData['GRP_TITLE'] )) {
|
||||
$this->setGrpTitle( $aData['GRP_TITLE'] );
|
||||
} else {
|
||||
$this->setGrpTitle( 'Default Group Title' );
|
||||
}
|
||||
|
||||
$con->commit();
|
||||
return $this->getGrpUid();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
foreach ($this->getValidationFailures() as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
|
||||
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
|
||||
}
|
||||
|
||||
throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
@@ -145,89 +154,88 @@ class Groupwf extends BaseGroupwf {
|
||||
* @return array $Fields the fields
|
||||
*/
|
||||
|
||||
function Load ( $ProUid ) {
|
||||
$con = Propel::getConnection(GroupwfPeer::DATABASE_NAME);
|
||||
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 );
|
||||
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() );
|
||||
$this->setGrpTitle( $oPro->getGrpTitle() );
|
||||
return $aFields;
|
||||
} else {
|
||||
throw (new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Group row
|
||||
*
|
||||
* @param array $aData
|
||||
* @return variant
|
||||
**/
|
||||
*
|
||||
*/
|
||||
|
||||
public function update($aData)
|
||||
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' ) {
|
||||
if (is_object( $oPro ) && get_class( $oPro ) == 'Groupwf') {
|
||||
$oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oPro->validate()) {
|
||||
if ( isset ( $aData['GRP_TITLE'] ) )
|
||||
if (isset( $aData['GRP_TITLE'] )) {
|
||||
$oPro->setGrpTitle( $aData['GRP_TITLE'] );
|
||||
}
|
||||
$res = $oPro->save();
|
||||
$con->commit();
|
||||
return $res;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$msg = '';
|
||||
foreach($this->getValidationFailures() as $objValidationFailure)
|
||||
foreach ($this->getValidationFailures() as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
}
|
||||
|
||||
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
|
||||
throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$con->rollback();
|
||||
throw(new Exception( "The row '" . $aData['GRP_UID'] . "' in table Group doesn't exist!" ));
|
||||
throw (new Exception( "The row '" . $aData['GRP_UID'] . "' in table Group doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the Prolication document registry
|
||||
*
|
||||
* @param array $aData or string $ProUid
|
||||
* @return string
|
||||
**/
|
||||
public function remove($ProUid)
|
||||
*
|
||||
*/
|
||||
public function remove ($ProUid)
|
||||
{
|
||||
if ( is_array ( $ProUid ) ) {
|
||||
$ProUid = ( isset ( $ProUid['GRP_UID'] ) ? $ProUid['GRP_UID'] : '' );
|
||||
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());
|
||||
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!" ));
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,75 +245,79 @@ class Groupwf extends BaseGroupwf {
|
||||
* @param string $sProUid the uid of the Prolication
|
||||
*/
|
||||
|
||||
function GroupwfExists ( $GrpUid ) {
|
||||
$con = Propel::getConnection(GroupwfPeer::DATABASE_NAME);
|
||||
function GroupwfExists ($GrpUid)
|
||||
{
|
||||
$con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oPro = GroupwfPeer::retrieveByPk( $GrpUid );
|
||||
if (is_object($oPro) && get_class ($oPro) == 'Groupwf' ) {
|
||||
if (is_object( $oPro ) && get_class( $oPro ) == 'Groupwf') {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function loadByGroupname ( $Groupname ) {
|
||||
$c = new Criteria('workflow');
|
||||
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 );
|
||||
$c->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
|
||||
$c->add( ContentPeer::CON_VALUE, $Groupname );
|
||||
$c->add( ContentPeer::CON_LANG, SYS_LANG );
|
||||
return $c;
|
||||
}
|
||||
|
||||
function getAll($start=null, $limit=null, $search=null)
|
||||
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);
|
||||
$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);
|
||||
if ($search) {
|
||||
$criteria->add( ContentPeer::CON_VALUE, '%' . $search . '%', Criteria::LIKE );
|
||||
}
|
||||
|
||||
$c = clone $criteria;
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn('COUNT(*)');
|
||||
$dataset = GroupwfPeer::doSelectRS($c);
|
||||
$c->addSelectColumn( 'COUNT(*)' );
|
||||
$dataset = GroupwfPeer::doSelectRS( $c );
|
||||
$dataset->next();
|
||||
$rowCount = $dataset->getRow();
|
||||
|
||||
if( is_array($rowCount) )
|
||||
if (is_array( $rowCount )) {
|
||||
$totalCount = $rowCount[0];
|
||||
}
|
||||
|
||||
if( $start )
|
||||
$criteria->setOffset($start);
|
||||
if( $limit )
|
||||
$criteria->setLimit($limit);
|
||||
if ($start) {
|
||||
$criteria->setOffset( $start );
|
||||
}
|
||||
if ($limit) {
|
||||
$criteria->setLimit( $limit );
|
||||
}
|
||||
|
||||
$rs = GroupwfPeer::doSelectRS($criteria);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs = GroupwfPeer::doSelectRS( $criteria );
|
||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
$rows = Array();
|
||||
while( $rs->next() )
|
||||
$rows = Array ();
|
||||
while ($rs->next()) {
|
||||
$rows[] = $rs->getRow();
|
||||
}
|
||||
|
||||
$result->data = $rows;
|
||||
$result->totalCount = $totalCount;
|
||||
@@ -313,107 +325,108 @@ class Groupwf extends BaseGroupwf {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getAllGroup($start=null, $limit=null, $search=null)
|
||||
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);
|
||||
$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);
|
||||
$criteria->add( ContentPeer::CON_VALUE, '%' . $search . '%', Criteria::LIKE );
|
||||
}
|
||||
|
||||
$totalRows = GroupwfPeer::doCount($criteria);
|
||||
$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);
|
||||
$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);
|
||||
$criteria->setOffset( $start );
|
||||
}
|
||||
|
||||
if ($limit != '') {
|
||||
$criteria->setLimit($limit);
|
||||
$criteria->setLimit( $limit );
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$criteria->add(ContentPeer::CON_VALUE,'%'.$search.'%',Criteria::LIKE);
|
||||
$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() ) {
|
||||
$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);
|
||||
return array ('rows' => $groups,'totalCount' => $totalRows
|
||||
);
|
||||
}
|
||||
|
||||
function filterGroup($filter,$start,$limit)
|
||||
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');
|
||||
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'] : '';
|
||||
$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);
|
||||
$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);
|
||||
$totalRows = GroupwfPeer::doCount( $oCriteria );
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$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->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);
|
||||
$oCriteria->setOffset( $start );
|
||||
$oCriteria->setLimit( $limit );
|
||||
|
||||
$oDataset = GroupwfPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset = GroupwfPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
}
|
||||
}
|
||||
// Groupwf
|
||||
|
||||
|
||||
} // Groupwf
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Language.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -41,88 +42,86 @@ require_once 'classes/model/Translation.php';
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
class Language extends BaseLanguage {
|
||||
class Language extends BaseLanguage
|
||||
{
|
||||
|
||||
function load($sLanUid)
|
||||
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);
|
||||
$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!' ));
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function update($aFields)
|
||||
function update ($aFields)
|
||||
{
|
||||
$oConnection = Propel::getConnection(LanguagePeer::DATABASE_NAME);
|
||||
$oConnection = Propel::getConnection( LanguagePeer::DATABASE_NAME );
|
||||
try {
|
||||
$oConnection->begin();
|
||||
$this->load($aFields['LAN_ID']);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
$this->load( $aFields['LAN_ID'] );
|
||||
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
|
||||
if ($this->validate()) {
|
||||
$iResult = $this->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$oConnection->rollback();
|
||||
throw(new Exception('Failed Validation in class ' . get_class($this) . '.'));
|
||||
throw (new Exception( 'Failed Validation in class ' . get_class( $this ) . '.' ));
|
||||
}
|
||||
}
|
||||
catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$oConnection->rollback();
|
||||
throw($e);
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
//SELECT LAN_ID, LAN_NAME FROM LANGUAGE WHERE LAN_ENABLED = '1' ORDER BY LAN_WEIGHT DESC
|
||||
function getActiveLanguages()
|
||||
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);
|
||||
$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);
|
||||
$oDataset = ContentPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
$oContent = new Content();
|
||||
$rows = Array();
|
||||
while ($oDataset->next())
|
||||
array_push($rows, $oDataset->getRow());
|
||||
$rows = Array ();
|
||||
while ($oDataset->next()) {
|
||||
array_push( $rows, $oDataset->getRow() );
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function findById($LAN_ID)
|
||||
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);
|
||||
$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)
|
||||
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);
|
||||
$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();
|
||||
}
|
||||
@@ -135,11 +134,11 @@ class Language extends BaseLanguage {
|
||||
* @param string $bXml
|
||||
* @return void
|
||||
*/
|
||||
public function import($sLanguageFile, $updateXml = true, $updateDB = true)
|
||||
public function import ($sLanguageFile, $updateXml = true, $updateDB = true)
|
||||
{
|
||||
try {
|
||||
G::LoadSystem('i18n_po');
|
||||
$POFile = new i18n_PO($sLanguageFile);
|
||||
G::LoadSystem( 'i18n_po' );
|
||||
$POFile = new i18n_PO( $sLanguageFile );
|
||||
$POFile->readInit();
|
||||
$POHeaders = $POFile->getHeaders();
|
||||
|
||||
@@ -147,21 +146,25 @@ class Language extends BaseLanguage {
|
||||
$langName = $POHeaders['X-Poedit-Language'];
|
||||
//find the lang id
|
||||
$language = new Language();
|
||||
$langRecord = $language->findByLanName($langName);
|
||||
$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!');
|
||||
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 != '.' ) {
|
||||
if ($countryName != '.') {
|
||||
$isoCountry = new IsoCountry();
|
||||
$countryRecord = $isoCountry->findByIcName($countryName);
|
||||
$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!');
|
||||
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
|
||||
@@ -175,98 +178,99 @@ class Language extends BaseLanguage {
|
||||
$countItemsSuccess = 0;
|
||||
$errorMsg = '';
|
||||
|
||||
while( $rowTranslation = $POFile->getTranslation() ) {
|
||||
while ($rowTranslation = $POFile->getTranslation()) {
|
||||
|
||||
$countItems++;
|
||||
$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!');
|
||||
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')
|
||||
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')
|
||||
} else {
|
||||
$var = explode( '/', $aux );
|
||||
if ($var[0] == 'LABEL') {
|
||||
$context = $aux;
|
||||
}
|
||||
if (preg_match('/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml\?)/', $aux, $match))
|
||||
$identifier = $aux;
|
||||
else{
|
||||
if (preg_match('/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml$)/', $aux, $match))
|
||||
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 ($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++;
|
||||
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";
|
||||
$errorMsg .= $id . ': ' . $result['message'] . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
// is a Xml update
|
||||
else if( $updateXml ) {
|
||||
} // 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);
|
||||
preg_match( '/^([\w_]+)\s-\s([\w_]+)\s*-*\s*([\w\W]*)$/', $reference, $match );
|
||||
|
||||
if( ! file_exists(PATH_XMLFORM . $xmlForm) ) {
|
||||
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";
|
||||
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);
|
||||
G::LoadSystem( 'dynaformhandler' );
|
||||
$dynaform = new dynaFormHandler( PATH_XMLFORM . $xmlForm );
|
||||
$fieldName = $match[2];
|
||||
|
||||
$codes = explode('-', $reference);
|
||||
$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
|
||||
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))
|
||||
$childNode = Array (Array ('name' => 'option','value' => $rowTranslation['msgstr'],'attributes' => Array ('name' => $name
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$dynaform->addChilds($fieldName, Array($LOCALE=>NULL), $childNode);
|
||||
$dynaform->addChilds( $fieldName, Array ($LOCALE => null
|
||||
), $childNode );
|
||||
}
|
||||
$countItemsSuccess++;
|
||||
$countItemsSuccess ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$oLanguage = new Language();
|
||||
$oLanguage->update(array('LAN_ID' => $languageID, 'LAN_ENABLED' => '1'));
|
||||
$oLanguage->update( array ('LAN_ID' => $languageID,'LAN_ENABLED' => '1'
|
||||
) );
|
||||
|
||||
$trn = new Translation();
|
||||
$trn->generateFileTranslation($LOCALE);
|
||||
$trn->addTranslationEnvironment($LOCALE, $POHeaders, $countItemsSuccess);
|
||||
$trn->generateFileTranslation( $LOCALE );
|
||||
$trn->addTranslationEnvironment( $LOCALE, $POHeaders, $countItemsSuccess );
|
||||
|
||||
//fill the results
|
||||
$results = new stdClass();
|
||||
@@ -277,27 +281,27 @@ class Language extends BaseLanguage {
|
||||
$results->errMsg = $errorMsg;
|
||||
|
||||
return $results;
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
//export
|
||||
function export()
|
||||
function export ()
|
||||
{
|
||||
//G::LoadThirdParty('pear', 'Benchmark/Timer');
|
||||
G::LoadSystem('i18n_po');
|
||||
G::LoadClass("system");
|
||||
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 = new i18n_PO( $sPOFile );
|
||||
$poFile->buildInit();
|
||||
|
||||
$language = new Language();
|
||||
@@ -306,13 +310,14 @@ class Language extends BaseLanguage {
|
||||
$_TARGET_LANG = $_GET['LOCALE'];
|
||||
$_BASE_LANG = 'en';
|
||||
|
||||
if( strpos($locale, Translation::$localeSeparator) !== false ) {
|
||||
list($LAN_ID, $IC_UID) = explode(Translation::$localeSeparator, $_GET['LOCALE']);
|
||||
if (strpos( $locale, Translation::$localeSeparator ) !== false) {
|
||||
list ($LAN_ID, $IC_UID) = explode( Translation::$localeSeparator, $_GET['LOCALE'] );
|
||||
$iCountry = new IsoCountry();
|
||||
$iCountryRecord = $iCountry->findById($IC_UID);
|
||||
$iCountryRecord = $iCountry->findById( $IC_UID );
|
||||
|
||||
if( ! isset($iCountryRecord['IC_UID']) )
|
||||
throw new Exception("Country Target ID '{$_GET['LAN_ID']}' doesn't exist!");
|
||||
if (! isset( $iCountryRecord['IC_UID'] )) {
|
||||
throw new Exception( "Country Target ID '{$_GET['LAN_ID']}' doesn't exist!" );
|
||||
}
|
||||
|
||||
$sCountry = $iCountryRecord['IC_NAME'];
|
||||
} else {
|
||||
@@ -320,130 +325,133 @@ class Language extends BaseLanguage {
|
||||
$sCountry = $IC_UID = '';
|
||||
}
|
||||
|
||||
$langRecord = $language->findById($LAN_ID);
|
||||
$langRecord = $language->findById( $LAN_ID );
|
||||
|
||||
if( ! isset($langRecord['LAN_NAME']) )
|
||||
throw new Exception("Language Target ID \"{$LAN_ID}\" doesn't exist!");
|
||||
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 <developers@colosa.com>');
|
||||
$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');
|
||||
$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 <developers@colosa.com>' );
|
||||
$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);
|
||||
|
||||
$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);
|
||||
$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();
|
||||
$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);
|
||||
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'];
|
||||
$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']);
|
||||
|
||||
$trnCategory = trim( $aRow1['TRN_CATEGORY'] );
|
||||
|
||||
# Validation, validate that the TRN_CATEGORY contains valid characteres
|
||||
preg_match("/^[0-9a-zA-Z_-]+/", $trnCategory, $sTestResult);
|
||||
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
|
||||
$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'];
|
||||
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
|
||||
} else {
|
||||
//if not just copy the same
|
||||
$msgstr = $aRow1['TRN_VALUE'];
|
||||
}
|
||||
|
||||
$msgid = trim( $aRow1['TRN_VALUE'] );
|
||||
$msgstr = trim( $msgstr );
|
||||
|
||||
$msgid = trim($aRow1['TRN_VALUE']);
|
||||
$msgstr = trim($msgstr);
|
||||
|
||||
if ( isset($aMsgids[$msgid]) ) {
|
||||
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->addTranslatorComment( 'TRANSLATION' );
|
||||
$poFile->addTranslatorComment( $aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID'] );
|
||||
$poFile->addReference( $aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID'] );
|
||||
|
||||
$poFile->addTranslation(stripcslashes($msgid), stripcslashes($msgstr));
|
||||
$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');
|
||||
/**
|
||||
* *********
|
||||
*/
|
||||
$aExceptionFields = array ('','javascript','hidden','phpvariable','private','toolbar','xmlmenu','toolbutton','cellmark','grid','CheckboxTable'
|
||||
);
|
||||
|
||||
//find all xml files into PATH_XMLFORM
|
||||
$aXMLForms = glob(PATH_XMLFORM . '*/*.xml');
|
||||
$aXMLForms = glob( PATH_XMLFORM . '*/*.xml' );
|
||||
//from a sublevel to
|
||||
$aXMLForms2 = glob(PATH_XMLFORM . '*/*/*.xml');
|
||||
$aXMLForms = array_merge($aXMLForms, $aXMLForms2);
|
||||
$aXMLForms2 = glob( PATH_XMLFORM . '*/*/*.xml' );
|
||||
$aXMLForms = array_merge( $aXMLForms, $aXMLForms2 );
|
||||
|
||||
$aEnglishLabel = array();
|
||||
$aOptions = array();
|
||||
$nodesNames = Array();
|
||||
$aEnglishLabel = array ();
|
||||
$aOptions = array ();
|
||||
$nodesNames = Array ();
|
||||
|
||||
G::loadSystem('dynaformhandler');
|
||||
G::loadSystem( 'dynaformhandler' );
|
||||
|
||||
foreach ($aXMLForms as $xmlFormPath) {
|
||||
$xmlFormFile = str_replace( chr(92), '/', $xmlFormPath);
|
||||
$xmlFormFile = str_replace( PATH_XMLFORM, '', $xmlFormPath);
|
||||
$xmlFormFile = str_replace( chr( 92 ), '/', $xmlFormPath );
|
||||
$xmlFormFile = str_replace( PATH_XMLFORM, '', $xmlFormPath );
|
||||
|
||||
$dynaForm = new dynaFormHandler($xmlFormPath);
|
||||
$dynaForm = new dynaFormHandler( $xmlFormPath );
|
||||
|
||||
$dynaNodes = $dynaForm->getFields();
|
||||
|
||||
@@ -452,25 +460,25 @@ class Language extends BaseLanguage {
|
||||
|
||||
$sNodeName = $oNode->nodeName;
|
||||
//$arrayNode = $dynaForm->getArray($oNode, Array('type', $_BASE_LANG, $_BASE_LANG));
|
||||
$arrayNode = $dynaForm->getArray($oNode);
|
||||
$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)) ){
|
||||
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 {
|
||||
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 {
|
||||
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__'];
|
||||
}
|
||||
@@ -484,43 +492,44 @@ class Language extends BaseLanguage {
|
||||
$msgid = $originNodeText;
|
||||
|
||||
// if the nodeName already exists in the po file, we need to create other msgid
|
||||
if( isset($aMsgids[$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));
|
||||
}
|
||||
$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']) ){
|
||||
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']) ) {
|
||||
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));
|
||||
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 ) {
|
||||
foreach ($originOptionNode as $optionNode) {
|
||||
$optionName = $optionNode['name'];
|
||||
$originOptionValue = $optionNode['__nodeText__'];
|
||||
|
||||
if( $targetOptionExists ){
|
||||
if ($targetOptionExists) {
|
||||
|
||||
$targetOptionValue = getMatchDropdownOptionValue($optionName, $targetOptionNode);
|
||||
if( $targetOptionValue === false ){
|
||||
$targetOptionValue = getMatchDropdownOptionValue( $optionName, $targetOptionNode );
|
||||
if ($targetOptionValue === false) {
|
||||
$targetOptionValue = $originOptionValue;
|
||||
}
|
||||
} else {
|
||||
@@ -528,15 +537,16 @@ class Language extends BaseLanguage {
|
||||
}
|
||||
|
||||
$msgid = '[' . $xmlFormFile . '?' . $nodeName . '-' . $optionName . ']';
|
||||
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-'. $optionName);
|
||||
$poFile->addTranslatorComment($xmlFormFile);
|
||||
$poFile->addReference($nodeType . ' - ' . $nodeName . ' - ' . $optionName);
|
||||
$poFile->addTranslation($msgid, stripslashes($targetOptionValue));
|
||||
$poFile->addTranslatorComment( $xmlFormFile . '?' . $nodeName . '-' . $optionName );
|
||||
$poFile->addTranslatorComment( $xmlFormFile );
|
||||
$poFile->addReference( $nodeType . ' - ' . $nodeName . ' - ' . $optionName );
|
||||
$poFile->addTranslation( $msgid, stripslashes( $targetOptionValue ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
} //end foreach
|
||||
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
@@ -547,19 +557,21 @@ class Language extends BaseLanguage {
|
||||
//die;
|
||||
//g::pr($profiling);
|
||||
|
||||
G::streamFile($sPOFile, true);
|
||||
|
||||
G::streamFile( $sPOFile, true );
|
||||
|
||||
}
|
||||
|
||||
} // Language
|
||||
}
|
||||
// Language
|
||||
|
||||
|
||||
function getMatchDropdownOptionValue($name, $options){
|
||||
foreach($options as $option){
|
||||
if($name == $option['name']){
|
||||
function getMatchDropdownOptionValue ($name, $options)
|
||||
{
|
||||
foreach ($options as $option) {
|
||||
if ($name == $option['name']) {
|
||||
return $option['__nodeText__'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
require_once 'classes/model/om/BaseUsersProperties.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'USERS_PROPERTIES' table.
|
||||
*
|
||||
@@ -14,6 +13,7 @@ require_once 'classes/model/om/BaseUsersProperties.php';
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
class UsersProperties extends BaseUsersProperties
|
||||
@@ -22,145 +22,136 @@ class UsersProperties extends BaseUsersProperties
|
||||
public $usrID = '';
|
||||
public $lang = 'en';
|
||||
|
||||
function __construct()
|
||||
function __construct ()
|
||||
{
|
||||
$this->lang = defined('SYS_LANG') ? SYS_LANG : 'en';
|
||||
$this->lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
}
|
||||
|
||||
function UserPropertyExists($sUserUID)
|
||||
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);
|
||||
$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 {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function load($sUserUID)
|
||||
public function load ($sUserUID)
|
||||
{
|
||||
$oUserProperty = UsersPropertiesPeer::retrieveByPK($sUserUID);
|
||||
if (!is_null($oUserProperty)) {
|
||||
$aFields = $oUserProperty->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
$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 {
|
||||
throw new Exception( "User with $sUserUID does not exist!" );
|
||||
}
|
||||
}
|
||||
|
||||
public function create($aData)
|
||||
public function create ($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(UsersPropertiesPeer::DATABASE_NAME);
|
||||
$oConnection = Propel::getConnection( UsersPropertiesPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oUserProperty = new UsersProperties();
|
||||
$oUserProperty->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
$oUserProperty->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oUserProperty->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oUserProperty->save();
|
||||
$oConnection->commit();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oUserProperty->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
foreach ($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($aData)
|
||||
public function update ($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(UsersPropertiesPeer::DATABASE_NAME);
|
||||
$oConnection = Propel::getConnection( UsersPropertiesPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oUserProperty = UsersPropertiesPeer::retrieveByPK($aData['USR_UID']);
|
||||
if (!is_null($oUserProperty)) {
|
||||
$oUserProperty->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
$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 {
|
||||
} else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oUserProperty->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
foreach ($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
||||
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
|
||||
}
|
||||
} else {
|
||||
throw (new Exception( 'This row doesn\'t exist!' ));
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function loadOrCreateIfNotExists($sUserUID, $aUserProperty = array())
|
||||
public function loadOrCreateIfNotExists ($sUserUID, $aUserProperty = array())
|
||||
{
|
||||
if (!$this->UserPropertyExists($sUserUID)) {
|
||||
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_LAST_UPDATE_DATE'] )) {
|
||||
$aUserProperty['USR_LAST_UPDATE_DATE'] = date( 'Y-m-d H:i:s' );
|
||||
}
|
||||
if (!isset($aUserProperty['USR_LOGGED_NEXT_TIME'])) {
|
||||
if (! isset( $aUserProperty['USR_LOGGED_NEXT_TIME'] )) {
|
||||
$aUserProperty['USR_LOGGED_NEXT_TIME'] = 0;
|
||||
}
|
||||
$this->create($aUserProperty);
|
||||
}
|
||||
else {
|
||||
$this->create( $aUserProperty );
|
||||
} else {
|
||||
$aUserProperty = $this->fields;
|
||||
}
|
||||
|
||||
return $aUserProperty;
|
||||
}
|
||||
|
||||
public function validatePassword($sPassword, $sLastUpdate, $iChangePasswordNextTime)
|
||||
public function validatePassword ($sPassword, $sLastUpdate, $iChangePasswordNextTime)
|
||||
{
|
||||
if (!defined('PPP_MINIMUM_LENGTH')) {
|
||||
define('PPP_MINIMUM_LENGTH', 5);
|
||||
if (! defined( 'PPP_MINIMUM_LENGTH' )) {
|
||||
define( 'PPP_MINIMUM_LENGTH', 5 );
|
||||
}
|
||||
if (!defined('PPP_MAXIMUM_LENGTH')) {
|
||||
define('PPP_MAXIMUM_LENGTH', 20);
|
||||
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_NUMERICAL_CHARACTER_REQUIRED' )) {
|
||||
define( 'PPP_NUMERICAL_CHARACTER_REQUIRED', 0 );
|
||||
}
|
||||
if (!defined('PPP_UPPERCASE_CHARACTER_REQUIRED')) {
|
||||
define('PPP_UPPERCASE_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_SPECIAL_CHARACTER_REQUIRED' )) {
|
||||
define( 'PPP_SPECIAL_CHARACTER_REQUIRED', 0 );
|
||||
}
|
||||
if (!defined('PPP_EXPIRATION_IN')) {
|
||||
define('PPP_EXPIRATION_IN', 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 (! defined( 'PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN' )) {
|
||||
define( 'PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN', 0 );
|
||||
}
|
||||
if (function_exists('mb_strlen')) {
|
||||
$iLength = mb_strlen($sPassword);
|
||||
if (function_exists( 'mb_strlen' )) {
|
||||
$iLength = mb_strlen( $sPassword );
|
||||
} else {
|
||||
$iLength = strlen( $sPassword );
|
||||
}
|
||||
else {
|
||||
$iLength = strlen($sPassword);
|
||||
}
|
||||
$aErrors = array();
|
||||
$aErrors = array ();
|
||||
if ($iLength < PPP_MINIMUM_LENGTH) {
|
||||
$aErrors[] = 'ID_PPP_MINIMUM_LENGTH';
|
||||
}
|
||||
@@ -168,25 +159,25 @@ class UsersProperties extends BaseUsersProperties
|
||||
$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) {
|
||||
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) {
|
||||
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('/[<5B><>\\!|"@<40>#$~%<25>&<26>\/()=\'?<3F><>*+\-_.:,;]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) == 0) {
|
||||
if (preg_match_all( '/[<5B><>\\!|"@<40>#$~%<25>&<26>\/()=\'?<3F><>*+\-_.:,;]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) == 0) {
|
||||
$aErrors[] = 'ID_PPP_SPECIAL_CHARACTER_REQUIRED';
|
||||
}
|
||||
}
|
||||
if (PPP_EXPIRATION_IN > 0) {
|
||||
G::LoadClass('dates');
|
||||
G::LoadClass( 'dates' );
|
||||
$oDates = new dates();
|
||||
$fDays = $oDates->calculateDuration(date('Y-m-d H:i:s'), $sLastUpdate);
|
||||
if ($fDays > (PPP_EXPIRATION_IN*24)) {
|
||||
$fDays = $oDates->calculateDuration( date( 'Y-m-d H:i:s' ), $sLastUpdate );
|
||||
if ($fDays > (PPP_EXPIRATION_IN * 24)) {
|
||||
$aErrors[] = 'ID_PPP_EXPIRATION_IN';
|
||||
}
|
||||
}
|
||||
@@ -198,29 +189,28 @@ class UsersProperties extends BaseUsersProperties
|
||||
return $aErrors;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get user location
|
||||
* defined by precedence plugin->ux->default
|
||||
*/
|
||||
public function redirectTo($usrID, $lang='')
|
||||
public function redirectTo ($usrID, $lang = '')
|
||||
{
|
||||
$this->usrID = $usrID;
|
||||
$this->lang = empty($lang) ? $this->lang : $lang;
|
||||
$this->lang = empty( $lang ) ? $this->lang : $lang;
|
||||
|
||||
$url = $this->_getPluginLocation();
|
||||
|
||||
if (empty($url)) {
|
||||
if (empty( $url )) {
|
||||
$url = $this->_getUXLocation();
|
||||
}
|
||||
|
||||
$urlUx = $this->_getUXSkinVariant();
|
||||
if (empty($url) && !empty($urlUx)) {
|
||||
if (empty( $url ) && ! empty( $urlUx )) {
|
||||
$_SESSION['_defaultUserLocation'] = $url;
|
||||
$url = $urlUx;
|
||||
}
|
||||
|
||||
if (empty($url)) {
|
||||
if (empty( $url )) {
|
||||
$url = $this->_getDefaultLocation();
|
||||
}
|
||||
|
||||
@@ -232,19 +222,19 @@ class UsersProperties extends BaseUsersProperties
|
||||
* defined by precedence plugin->default
|
||||
* note that is getting location without User Inbox Simplified varification
|
||||
*/
|
||||
public function getUserLocation($usrID, $lang = 'en')
|
||||
public function getUserLocation ($usrID, $lang = 'en')
|
||||
{
|
||||
$this->usrID = $usrID;
|
||||
$this->lang = empty($lang) ? $this->lang : $lang;
|
||||
$this->lang = empty( $lang ) ? $this->lang : $lang;
|
||||
|
||||
$url = $this->_getPluginLocation();
|
||||
|
||||
if (empty($url)) {
|
||||
if (empty( $url )) {
|
||||
$url = $this->_getDefaultLocation();
|
||||
}
|
||||
|
||||
$urlUx = $this->_getUXSkinVariant();
|
||||
if (!empty($urlUx)) {
|
||||
if (! empty( $urlUx )) {
|
||||
$_SESSION['_defaultUserLocation'] = $url;
|
||||
$url = $urlUx;
|
||||
}
|
||||
@@ -256,17 +246,17 @@ class UsersProperties extends BaseUsersProperties
|
||||
* 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()
|
||||
public function _getUXSkinVariant ()
|
||||
{
|
||||
$url = '';
|
||||
|
||||
if (substr(SYS_SKIN, 0, 2) == 'ux' && SYS_SKIN != 'uxs') {
|
||||
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) {
|
||||
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';
|
||||
}
|
||||
@@ -275,33 +265,33 @@ class UsersProperties extends BaseUsersProperties
|
||||
|
||||
switch ($oConf->aConfig['DEFAULT_MENU']) {
|
||||
case 'PM_SETUP':
|
||||
if ($RBAC->userCanAccess('PM_SETUP') == 1) {
|
||||
if ($RBAC->userCanAccess( 'PM_SETUP' ) == 1) {
|
||||
$getUrl = 'admin';
|
||||
}
|
||||
break;
|
||||
case 'PM_FACTORY':
|
||||
if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
|
||||
if ($RBAC->userCanAccess( 'PM_FACTORY' ) == 1) {
|
||||
$getUrl = 'designer';
|
||||
}
|
||||
break;
|
||||
case 'PM_CASES':
|
||||
if ($RBAC->userCanAccess('PM_CASES') == 1) {
|
||||
if ($RBAC->userCanAccess( 'PM_CASES' ) == 1) {
|
||||
$getUrl = 'home';
|
||||
}
|
||||
break;
|
||||
case 'PM_USERS':
|
||||
if ($RBAC->userCanAccess('PM_USERS') == 1) {
|
||||
if ($RBAC->userCanAccess( 'PM_USERS' ) == 1) {
|
||||
$getUrl = 'admin';
|
||||
}
|
||||
break;
|
||||
case 'PM_DASHBOARD':
|
||||
if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
|
||||
if ($RBAC->userCanAccess( 'PM_DASHBOARD' ) == 1) {
|
||||
$getUrl = 'dashboard';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$url = $url . (($getUrl != null)? "?st=" . $getUrl : null);
|
||||
$url = $url . (($getUrl != null) ? "?st=" . $getUrl : null);
|
||||
}
|
||||
}
|
||||
return $url;
|
||||
@@ -311,21 +301,22 @@ class UsersProperties extends BaseUsersProperties
|
||||
* get the plugins, and check if there is redirectLogins
|
||||
* if yes, then redirect goes according his Role
|
||||
*/
|
||||
public function _getPluginLocation()
|
||||
public function _getPluginLocation ()
|
||||
{
|
||||
global $RBAC;
|
||||
$url = '';
|
||||
|
||||
if ( class_exists('redirectDetail')) {
|
||||
if (class_exists( 'redirectDetail' )) {
|
||||
//to do: complete the validation
|
||||
if(isset($RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE']))
|
||||
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 ) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -337,12 +328,13 @@ class UsersProperties extends BaseUsersProperties
|
||||
|
||||
/**
|
||||
* New feature - User Experience Redirector
|
||||
*
|
||||
* @author Erik Amaru Ortiz <erik@colosa.com>
|
||||
*/
|
||||
public function _getUXLocation()
|
||||
public function _getUXLocation ()
|
||||
{
|
||||
require_once 'classes/model/Users.php';
|
||||
$u = UsersPeer::retrieveByPK($this->usrID);
|
||||
$u = UsersPeer::retrieveByPK( $this->usrID );
|
||||
$url = '';
|
||||
|
||||
$uxType = $u->getUsrUx();
|
||||
@@ -352,7 +344,7 @@ class UsersProperties extends BaseUsersProperties
|
||||
if ($uxType == '' || $uxType == 'NORMAL') {
|
||||
require_once 'classes/model/GroupUser.php';
|
||||
$gu = new GroupUser();
|
||||
$ugList = $gu->getAllUserGroups($this->usrID);
|
||||
$ugList = $gu->getAllUserGroups( $this->usrID );
|
||||
|
||||
foreach ($ugList as $row) {
|
||||
if ($row['GRP_UX'] != 'NORMAL' && $row['GRP_UX'] != '') {
|
||||
@@ -379,17 +371,18 @@ class UsersProperties extends BaseUsersProperties
|
||||
* get user preferences for default redirect
|
||||
* verifying if it has any preferences on configurations table
|
||||
*/
|
||||
public function _getDefaultLocation()
|
||||
public function _getDefaultLocation ()
|
||||
{
|
||||
global $RBAC;
|
||||
G::loadClass('configuration');
|
||||
$oConf = new Configurations;
|
||||
$oConf->loadConfig($x, 'USER_PREFERENCES','','',$_SESSION['USER_LOGGED'],'');
|
||||
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
|
||||
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';
|
||||
@@ -397,54 +390,51 @@ class UsersProperties extends BaseUsersProperties
|
||||
|
||||
switch ($oConf->aConfig['DEFAULT_MENU']) {
|
||||
case 'PM_SETUP':
|
||||
if ($RBAC->userCanAccess('PM_SETUP') == 1) {
|
||||
if ($RBAC->userCanAccess( 'PM_SETUP' ) == 1) {
|
||||
$url = 'setup/main';
|
||||
}
|
||||
break;
|
||||
case 'PM_FACTORY':
|
||||
if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
|
||||
if ($RBAC->userCanAccess( 'PM_FACTORY' ) == 1) {
|
||||
$url = 'processes/main';
|
||||
}
|
||||
break;
|
||||
case 'PM_CASES':
|
||||
if ($RBAC->userCanAccess('PM_CASES') == 1) {
|
||||
if ($RBAC->userCanAccess( 'PM_CASES' ) == 1) {
|
||||
$url = 'cases/main';
|
||||
}
|
||||
break;
|
||||
case 'PM_USERS':
|
||||
if ($RBAC->userCanAccess('PM_USERS') == 1) {
|
||||
if ($RBAC->userCanAccess( 'PM_USERS' ) == 1) {
|
||||
$url = 'setup/main';
|
||||
}
|
||||
break;
|
||||
case 'PM_DASHBOARD':
|
||||
if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
|
||||
if ($RBAC->userCanAccess( 'PM_DASHBOARD' ) == 1) {
|
||||
$url = 'dashboard/main';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($url)) {
|
||||
if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
|
||||
if (empty( $url )) {
|
||||
if ($RBAC->userCanAccess( 'PM_FACTORY' ) == 1) {
|
||||
$url = 'processes/main';
|
||||
}
|
||||
else if ($RBAC->userCanAccess('PM_SETUP') == 1) {
|
||||
} elseif ($RBAC->userCanAccess( 'PM_SETUP' ) == 1) {
|
||||
$url = 'setup/main';
|
||||
}
|
||||
else if ($RBAC->userCanAccess('PM_CASES') == 1) {
|
||||
} elseif ($RBAC->userCanAccess( 'PM_CASES' ) == 1) {
|
||||
$url = 'cases/main';
|
||||
}
|
||||
else if ($RBAC->userCanAccess('PM_USERS') == 1) {
|
||||
} elseif ($RBAC->userCanAccess( 'PM_USERS' ) == 1) {
|
||||
$url = 'setup/main';
|
||||
}
|
||||
else if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
|
||||
} elseif ($RBAC->userCanAccess( 'PM_DASHBOARD' ) == 1) {
|
||||
$url = 'dashboard/dashboard';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$url = 'users/myInfo';
|
||||
}
|
||||
}
|
||||
|
||||
return $baseUrl . $url;
|
||||
}
|
||||
} // UsersProperties
|
||||
}
|
||||
// UsersProperties
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
/**
|
||||
* class.pmTrSharepoint.php
|
||||
*
|
||||
*/
|
||||
G::LoadSystem("soapNtlm");
|
||||
G::LoadSystem( "soapNtlm" );
|
||||
|
||||
class wscaller {
|
||||
class wscaller
|
||||
{
|
||||
|
||||
private $wsdlurl;
|
||||
private $soapObj;
|
||||
@@ -14,102 +14,105 @@ class wscaller {
|
||||
private $auth;
|
||||
private $clientStream;
|
||||
|
||||
function setAuthUser($auth) {
|
||||
function setAuthUser ($auth)
|
||||
{
|
||||
//print "<br>- auth Setup";
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
function setwsdlurl($wsdl) {
|
||||
function setwsdlurl ($wsdl)
|
||||
{
|
||||
//print "<br>- wsdl Setup";
|
||||
$this->wsdlurl = $wsdl;
|
||||
//var_dump($wsdl);
|
||||
}
|
||||
|
||||
function loadSOAPClient() {
|
||||
function loadSOAPClient ()
|
||||
{
|
||||
try {
|
||||
// we unregister the current HTTP wrapper
|
||||
stream_wrapper_unregister('http');
|
||||
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");
|
||||
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);
|
||||
// $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;
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
function callWsMethod($methodName, $paramArray) {
|
||||
function callWsMethod ($methodName, $paramArray)
|
||||
{
|
||||
|
||||
try {
|
||||
if ($methodName == 'DeleteDws' || $methodName == 'GetListCollection') {
|
||||
$strResult = "";
|
||||
$strResult = $this->client->$methodName($paramArray = "");
|
||||
$strResult = $this->client->$methodName( $paramArray = "" );
|
||||
return $strResult;
|
||||
} else {
|
||||
$strResult = "";
|
||||
$strResult = $this->client->$methodName($paramArray);
|
||||
$strResult = $this->client->$methodName( $paramArray );
|
||||
return $strResult;
|
||||
}
|
||||
} catch (SoapFault $fault) {
|
||||
echo 'Fault code: ' . $fault->faultcode;
|
||||
echo 'Fault string: ' . $fault->faultstring;
|
||||
}
|
||||
stream_wrapper_restore('http');
|
||||
stream_wrapper_restore( 'http' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DestinationUrlCollection {
|
||||
class DestinationUrlCollection
|
||||
{
|
||||
|
||||
public $string;
|
||||
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
class FieldInformation {
|
||||
|
||||
class FieldInformation
|
||||
{
|
||||
}
|
||||
|
||||
class FieldInformationCollection {
|
||||
|
||||
class FieldInformationCollection
|
||||
{
|
||||
public $FieldInformation;
|
||||
|
||||
}
|
||||
|
||||
class pmTrSharepointClass{
|
||||
|
||||
function __construct($server, $auth) {
|
||||
set_include_path(
|
||||
PATH_PLUGINS . 'pmTrSharepoint' . PATH_SEPARATOR .
|
||||
get_include_path()
|
||||
);
|
||||
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);
|
||||
$this->dwsObj->setAuthUser( $this->auth );
|
||||
}
|
||||
|
||||
function createDWS($name, $users, $title, $documents) {
|
||||
function createDWS ($name, $users, $title, $documents)
|
||||
{
|
||||
//print "<br>- Method createDWS";
|
||||
$this->dwsObj->setwsdlurl($this->server . "/_vti_bin/Dws.asmx?WSDL");
|
||||
$this->dwsObj->setwsdlurl( $this->server . "/_vti_bin/Dws.asmx?WSDL" );
|
||||
|
||||
$this->dwsObj->loadSOAPClient();
|
||||
|
||||
$paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => '');
|
||||
$paramArray = array ('name' => '','users' => '','title' => $name,'documents' => ''
|
||||
);
|
||||
|
||||
$methodName = 'CreateDws';
|
||||
|
||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||
$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
|
||||
$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";
|
||||
|
||||
@@ -124,95 +127,107 @@ class pmTrSharepointClass{
|
||||
return $result; */
|
||||
}
|
||||
|
||||
function deleteDWS($dwsname) {
|
||||
function deleteDWS ($dwsname)
|
||||
{
|
||||
//print "<br>- Method createDWS";
|
||||
$url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
|
||||
$this->dwsObj->setwsdlurl($url);
|
||||
$this->dwsObj->setwsdlurl( $url );
|
||||
|
||||
$this->dwsObj->loadSOAPClient();
|
||||
$paramArray = null;
|
||||
$methodName = 'DeleteDws';
|
||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray = null);
|
||||
var_dump($result);
|
||||
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray = null );
|
||||
var_dump( $result );
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
function createFolderDWS($dwsname, $dwsFolderName) {
|
||||
function createFolderDWS ($dwsname, $dwsFolderName)
|
||||
{
|
||||
//print "<br>- Method createDWS";
|
||||
$this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL");
|
||||
$this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL" );
|
||||
|
||||
$this->dwsObj->loadSOAPClient();
|
||||
|
||||
$url = "Shared Documents/$dwsFolderName";
|
||||
$paramArray = array('url' => $url);
|
||||
$paramArray = array ('url' => $url
|
||||
);
|
||||
|
||||
# $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => '');
|
||||
|
||||
|
||||
$methodName = 'CreateFolder';
|
||||
|
||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||
var_dump($result);
|
||||
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
|
||||
var_dump( $result );
|
||||
return $result;
|
||||
}
|
||||
|
||||
function deleteFolderDWS($dwsname, $folderName) {
|
||||
function deleteFolderDWS ($dwsname, $folderName)
|
||||
{
|
||||
//print "<br>- Method createDWS";
|
||||
$this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL");
|
||||
$this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL" );
|
||||
|
||||
$this->dwsObj->loadSOAPClient();
|
||||
|
||||
$url = "Shared Documents/$folderName";
|
||||
$paramArray = array('url' => $url);
|
||||
$paramArray = array ('url' => $url
|
||||
);
|
||||
|
||||
# $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => '');
|
||||
|
||||
|
||||
$methodName = 'DeleteFolder';
|
||||
|
||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||
var_dump($result);
|
||||
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
|
||||
var_dump( $result );
|
||||
return $result;
|
||||
}
|
||||
|
||||
function findDWSdoc($dwsname, $guid) {
|
||||
function findDWSdoc ($dwsname, $guid)
|
||||
{
|
||||
//print "<br>- Method createDWS";
|
||||
$this->dwsObj->setwsdlurl($this->server . $dwsName . "/_vti_bin/Dws.asmx?WSDL");
|
||||
$this->dwsObj->setwsdlurl( $this->server . $dwsName . "/_vti_bin/Dws.asmx?WSDL" );
|
||||
|
||||
$this->dwsObj->loadSOAPClient();
|
||||
|
||||
$paramArray = array('id' => '$guid');
|
||||
$paramArray = array ('id' => '$guid'
|
||||
);
|
||||
|
||||
$methodName = 'FindDwsDoc';
|
||||
|
||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||
var_dump($result);
|
||||
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
|
||||
var_dump( $result );
|
||||
}
|
||||
|
||||
function getDWSData($newFileName, $dwsname, $lastUpdate) {
|
||||
function getDWSData ($newFileName, $dwsname, $lastUpdate)
|
||||
{
|
||||
//print "<br>- Method getDWSData<br />";
|
||||
$url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
|
||||
$this->dwsObj->setwsdlurl($url);
|
||||
$this->dwsObj->setwsdlurl( $url );
|
||||
if ($this->dwsObj->loadSOAPClient()) {
|
||||
$doc = "Shared Documents";
|
||||
$paramArray = array('document' => '', 'lastUpdate' => '');
|
||||
$paramArray = array ('document' => '','lastUpdate' => ''
|
||||
);
|
||||
$methodName = 'GetDwsData';
|
||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||
var_dump($result);
|
||||
$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);
|
||||
$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) {
|
||||
function uploadDocumentDWS ($dwsname, $folderName, $sourceUrl, $filename)
|
||||
{
|
||||
//print "<br>- Method createDWS";
|
||||
$url = $this->server ."/". $dwsname . "/_vti_bin/Copy.asmx?WSDL";
|
||||
$this->dwsObj->setwsdlurl($url);
|
||||
$url = $this->server . "/" . $dwsname . "/_vti_bin/Copy.asmx?WSDL";
|
||||
$this->dwsObj->setwsdlurl( $url );
|
||||
$this->dwsObj->loadSOAPClient();
|
||||
|
||||
$destUrlObj = new DestinationUrlCollection();
|
||||
@@ -229,15 +244,17 @@ class pmTrSharepointClass{
|
||||
$fieldInfoCollObj->FieldInformation = $fieldInfoObj;
|
||||
|
||||
$imgfile = $sourceUrl . "/" . $filename;
|
||||
$filep = fopen($imgfile, "r");
|
||||
$fileLength = filesize($imgfile);
|
||||
$content = fread($filep, $fileLength);
|
||||
$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);
|
||||
|
||||
$paramArray = array ('SourceUrl' => $imgfile,'DestinationUrls' => $destUrlObj,'Fields' => $fieldInfoCollObj,'Stream' => $content
|
||||
);
|
||||
$methodName = 'CopyIntoItems';
|
||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||
var_dump($result);
|
||||
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
|
||||
var_dump( $result );
|
||||
$newResult = $result->Results->CopyResult->ErrorCode;
|
||||
if ($newResult == 'Success') {
|
||||
return "The document has been uploaded Successfully";
|
||||
@@ -246,99 +263,104 @@ class pmTrSharepointClass{
|
||||
}
|
||||
}
|
||||
|
||||
function getDWSMetaData($newFileName, $dwsname, $id) {
|
||||
function getDWSMetaData ($newFileName, $dwsname, $id)
|
||||
{
|
||||
//print "<br>- Method createDWS";
|
||||
$url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
|
||||
$this->dwsObj->setwsdlurl($url);
|
||||
$this->dwsObj->setwsdlurl( $url );
|
||||
|
||||
$this->dwsObj->loadSOAPClient();
|
||||
|
||||
$doc = "Shared Documents/$newFileName";
|
||||
$paramArray = array('document' => $doc, 'id' => '', 'minimal' => False);
|
||||
$paramArray = array ('document' => $doc,'id' => '','minimal' => false
|
||||
);
|
||||
|
||||
$methodName = 'GetDwsMetaData';
|
||||
|
||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||
$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);
|
||||
$errorReturn = strpos( $sResult, "Error" );
|
||||
if (isset( $sResult ) && ! $errorReturn) {
|
||||
$serializeResult = serialize( $sResult ); // serializing the Array for Returning.
|
||||
var_dump( $serializeResult );
|
||||
return $serializeResult;
|
||||
} else {
|
||||
return $sResult;
|
||||
}
|
||||
else return $sResult;
|
||||
}
|
||||
|
||||
function getDWSDocumentVersions($newFileName, $dwsname) {
|
||||
function getDWSDocumentVersions ($newFileName, $dwsname)
|
||||
{
|
||||
//print "<br>- Method createDWS";
|
||||
$this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL");
|
||||
$this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL" );
|
||||
|
||||
$this->dwsObj->loadSOAPClient();
|
||||
|
||||
$doc = "Shared Documents/$newFileName";
|
||||
$paramArray = array('fileName' => $doc);
|
||||
$paramArray = array ('fileName' => $doc
|
||||
);
|
||||
|
||||
$methodName = 'GetVersions';
|
||||
|
||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||
var_dump($result);
|
||||
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
|
||||
var_dump( $result );
|
||||
return $result;
|
||||
}
|
||||
|
||||
function deleteDWSDocVersion($newFileName, $dwsname, $versionNum) {
|
||||
function deleteDWSDocVersion ($newFileName, $dwsname, $versionNum)
|
||||
{
|
||||
//print "<br>- Method createDWS";
|
||||
$this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL");
|
||||
$this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL" );
|
||||
|
||||
$this->dwsObj->loadSOAPClient();
|
||||
|
||||
$doc = "Shared Documents/$newFileName";
|
||||
$paramArray = array('fileName' => $doc, 'fileVersion' => $versionNum);
|
||||
$paramArray = array ('fileName' => $doc,'fileVersion' => $versionNum
|
||||
);
|
||||
|
||||
$methodName = 'DeleteVersion';
|
||||
|
||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||
$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']);
|
||||
$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++)
|
||||
{
|
||||
if ($versionCount > 1) {
|
||||
for ($i = 0; $i < $versionCount; $i ++) {
|
||||
$version[] = $xmlArray['result'][$i]['@attributes']['version'];
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$version[] = $xmlArray['result']['@attributes']['version'];
|
||||
}
|
||||
|
||||
$serializeResult = serialize($version); // serializing the Array for Returning.
|
||||
var_dump($serializeResult);
|
||||
$serializeResult = serialize( $version ); // serializing the Array for Returning.
|
||||
var_dump( $serializeResult );
|
||||
return $serializeResult;
|
||||
} else {
|
||||
return"The given Version could not be deleted.";
|
||||
return "The given Version could not be deleted.";
|
||||
}
|
||||
}
|
||||
|
||||
function deleteAllDWSDocVersion($newFileName, $dwsname) {
|
||||
function deleteAllDWSDocVersion ($newFileName, $dwsname)
|
||||
{
|
||||
//print "<br>- Method createDWS";
|
||||
$this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL");
|
||||
$this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL" );
|
||||
|
||||
$this->dwsObj->loadSOAPClient();
|
||||
|
||||
$doc = "Shared Documents/$newFileName";
|
||||
$paramArray = array('fileName' => $doc);
|
||||
$paramArray = array ('fileName' => $doc
|
||||
);
|
||||
|
||||
$methodName = 'DeleteAllVersions';
|
||||
|
||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||
$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
|
||||
$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 {
|
||||
@@ -346,88 +368,92 @@ class pmTrSharepointClass{
|
||||
}
|
||||
}
|
||||
|
||||
function getDWSFolderItems($dwsname, $strFolderUrl) {
|
||||
function getDWSFolderItems ($dwsname, $strFolderUrl)
|
||||
{
|
||||
$pmTrSharepointClassObj = new pmTrSharepointClass();
|
||||
//print "<br>- Method getDWSFolderItems";
|
||||
$url = $this->server . "/" . $dwsname . "/_vti_bin/SiteData.asmx?WSDL";
|
||||
$this->dwsObj->setwsdlurl($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);
|
||||
$paramArray = array ('strFolderUrl' => $strFolderUrl
|
||||
);
|
||||
|
||||
$methodName = 'EnumerateFolder';
|
||||
|
||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||
$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);
|
||||
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++) {
|
||||
} 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)";
|
||||
$returnContent[] = $pmTrSharepointClassObj->getFolderUrlContent( $listArr ) . "(Is a Folder)";
|
||||
} else {
|
||||
$listArr = $result->vUrls->_sFPUrl[$i]->Url;
|
||||
$returnContent[] = $pmTrSharepointClassObj->getFolderUrlContent($listArr) . "(Is a File)";
|
||||
$returnContent[] = $pmTrSharepointClassObj->getFolderUrlContent( $listArr ) . "(Is a File)";
|
||||
}
|
||||
}
|
||||
$serializeResult = serialize($returnContent);
|
||||
$serializeResult = serialize( $returnContent );
|
||||
return $serializeResult;
|
||||
}
|
||||
return "There is some error";
|
||||
}
|
||||
|
||||
function downloadDocumentDWS($dwsname, $fileName, $fileLocation) {
|
||||
function downloadDocumentDWS ($dwsname, $fileName, $fileLocation)
|
||||
{
|
||||
//print "<br>- Method createDWS";
|
||||
$url = $this->server . "/" . $dwsname . "/_vti_bin/Copy.asmx?WSDL";
|
||||
$this->dwsObj->setwsdlurl($url);
|
||||
$this->dwsObj->setwsdlurl( $url );
|
||||
|
||||
$this->dwsObj->loadSOAPClient();
|
||||
|
||||
$CompleteUrl = $this->server . "/" . $dwsname . "/Shared Documents/" . $fileName;
|
||||
$paramArray = array('Url' => $CompleteUrl);
|
||||
$paramArray = array ('Url' => $CompleteUrl
|
||||
);
|
||||
|
||||
$methodName = 'GetItem';
|
||||
|
||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||
$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');
|
||||
$filep = fopen( $imgfile, 'w' );
|
||||
//$content = fwrite($filep, $latestResult);
|
||||
$content = fwrite($filep, $newResult);
|
||||
$content = fwrite( $filep, $newResult );
|
||||
return $content;
|
||||
}
|
||||
|
||||
function getFolderUrlContent($newResult) {
|
||||
function getFolderUrlContent ($newResult)
|
||||
{
|
||||
$needleStart = '/';
|
||||
$needleCount = substr_count($newResult, $needleStart);
|
||||
$needleCount = substr_count( $newResult, $needleStart );
|
||||
|
||||
$urlStartPos = strpos($newResult, $needleStart);
|
||||
$urlStartPos++;
|
||||
$urlStartPos = strpos( $newResult, $needleStart );
|
||||
$urlStartPos ++;
|
||||
|
||||
if ($needleCount == '2') {
|
||||
$newResultPos = strpos($newResult, $needleStart, $urlStartPos);
|
||||
$newResultPos++;
|
||||
$actualResult = substr($newResult, $newResultPos);
|
||||
$newResultPos = strpos( $newResult, $needleStart, $urlStartPos );
|
||||
$newResultPos ++;
|
||||
$actualResult = substr( $newResult, $newResultPos );
|
||||
return $actualResult;
|
||||
}
|
||||
else{
|
||||
$actualResult = substr($newResult,$urlStartPos);
|
||||
} else {
|
||||
$actualResult = substr( $newResult, $urlStartPos );
|
||||
return $actualResult;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user