Merge pull request #832 from Jennydmz/master

CODE STYLE, checking in detail...
This commit is contained in:
ferOnti
2012-10-19 07:33:42 -07:00
6 changed files with 2574 additions and 2523 deletions

View File

@@ -1,7 +1,8 @@
<?php
/**
* AppDelegation.php
* @package workflow.engine.classes.model
*
* @package workflow.engine.classes.model
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.
@@ -13,11 +14,11 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
@@ -25,10 +26,10 @@
*/
require_once 'classes/model/om/BaseAppDelegation.php';
require_once ( "classes/model/HolidayPeer.php" );
require_once ( "classes/model/TaskPeer.php" );
require_once ( "classes/model/Task.php" );
G::LoadClass("dates");
require_once ("classes/model/HolidayPeer.php");
require_once ("classes/model/TaskPeer.php");
require_once ("classes/model/Task.php");
G::LoadClass( "dates" );
/**
* Skeleton subclass for representing a row from the 'APP_DELEGATION' table.
@@ -36,457 +37,454 @@ G::LoadClass("dates");
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
* @package workflow.engine.classes.model
*/
class AppDelegation extends BaseAppDelegation {
class AppDelegation extends BaseAppDelegation
{
/**
* create an application delegation
* @param $sProUid process Uid
* @param $sAppUid Application Uid
* @param $sTasUid Task Uid
* @param $sUsrUid User Uid
* @param $iPriority delegation priority
* @param $isSubprocess is a subprocess inside a process?
* @return delegation index of the application delegation.
*/
function createAppDelegation ($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess = false, $sPrevious = -1, $sNextTasParam = null)
{
if (!isset($sProUid) || strlen($sProUid) == 0 ) {
throw ( new Exception ( 'Column "PRO_UID" cannot be null.' ) );
}
if (!isset($sAppUid) || strlen($sAppUid ) == 0 ) {
throw ( new Exception ( 'Column "APP_UID" cannot be null.' ) );
}
if (!isset($sTasUid) || strlen($sTasUid ) == 0 ) {
throw ( new Exception ( 'Column "TAS_UID" cannot be null.' ) );
}
if (!isset($sUsrUid) /*|| strlen($sUsrUid ) == 0*/ ) {
throw ( new Exception ( 'Column "USR_UID" cannot be null.' ) );
}
if (!isset($sAppThread) || strlen($sAppThread ) == 0 ) {
throw ( new Exception ( 'Column "APP_THREAD" cannot be null.' ) );
}
//get max DEL_INDEX SELECT MAX(DEL_INDEX) AS M FROM APP_DELEGATION WHERE APP_UID="'.$Fields['APP_UID'].'"'
$c = new Criteria ();
$c->clearSelectColumns();
$c->addSelectColumn ( 'MAX(' . AppDelegationPeer::DEL_INDEX . ') ' );
$c->add ( AppDelegationPeer::APP_UID, $sAppUid );
$rs = AppDelegationPeer::doSelectRS ( $c );
$rs->next();
$row = $rs->getRow();
$delIndex = $row[0] + 1;
$this->setAppUid ( $sAppUid );
$this->setProUid ( $sProUid );
$this->setTasUid ( $sTasUid );
$this->setDelIndex ( $delIndex );
$this->setDelPrevious ( $sPrevious == -1 ? 0 : $sPrevious );
$this->setUsrUid ( $sUsrUid );
$this->setDelType ( 'NORMAL' );
$this->setDelPriority ( ($iPriority != '' ? $iPriority : '3') );
$this->setDelThread ( $sAppThread );
$this->setDelThreadStatus ( 'OPEN' );
$this->setDelDelegateDate ( 'now' );
//The function return an array now. By JHL
$delTaskDueDate = $this->calculateDueDate($sNextTasParam);
$this->setDelTaskDueDate ( $delTaskDueDate['DUE_DATE'] ); // Due date formatted
if((defined("DEBUG_CALENDAR_LOG"))&&(DEBUG_CALENDAR_LOG)){
$this->setDelData ($delTaskDueDate['DUE_DATE_LOG'] ); // Log of actions made by Calendar Engine
}
else{
$this->setDelData ( '' );
}
// this condition assures that an internal delegation like a subprocess dont have an initial date setted
if ( $delIndex == 1 && !$isSubprocess ) { //the first delegation, init date this should be now for draft applications, in other cases, should be null.
$this->setDelInitDate('now' );
}
if ($this->validate()) {
try {
$res = $this->save();
}
catch ( PropelException $e ) {
throw ( $e );
}
}
else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $this->getValidationFailures();
foreach($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>";
}
throw ( new Exception ( 'Failed Data validation. ' . $msg ) );
}
$delIndex = $this->getDelIndex();
// Hook for the trigger PM_CREATE_NEW_DELEGATION
if (defined('PM_CREATE_NEW_DELEGATION')) {
$data = new stdclass();
$data->TAS_UID = $sTasUid;
$data->APP_UID = $sAppUid;
$data->DEL_INDEX = $delIndex;
$data->USR_UID = $sUsrUid;
$oPluginRegistry = &PMPluginRegistry::getSingleton();
$oPluginRegistry->executeTriggers(PM_CREATE_NEW_DELEGATION, $data);
}
return $delIndex;
}
/**
* Load the Application Delegation row specified in [app_id] column value.
*
* @param string $AppUid the uid of the application
* @return array $Fields the fields
*/
function Load ( $AppUid, $sDelIndex ) {
$con = Propel::getConnection(AppDelegationPeer::DATABASE_NAME);
try {
$oAppDel = AppDelegationPeer::retrieveByPk( $AppUid, $sDelIndex );
if (is_object($oAppDel) && get_class ($oAppDel) == 'AppDelegation' ) {
$aFields = $oAppDel->toArray( BasePeer::TYPE_FIELDNAME);
$this->fromArray ($aFields, BasePeer::TYPE_FIELDNAME );
return $aFields;
}
else {
throw( new Exception( "The row '$AppUid, $sDelIndex' in table AppDelegation doesn't exist!" ));
}
}
catch (Exception $oError) {
throw($oError);
}
}
/**
* Update the application row
* @param array $aData
* @return variant
**/
public function update($aData)
{
$con = Propel::getConnection( AppDelegationPeer::DATABASE_NAME );
try {
$con->begin();
$oApp = AppDelegationPeer::retrieveByPK( $aData['APP_UID'], $aData['DEL_INDEX'] );
if (is_object($oApp) && get_class ($oApp) == 'AppDelegation' ) {
$oApp->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oApp->validate()) {
$res = $oApp->save();
$con->commit();
return $res;
}
else {
$msg = '';
foreach($this->getValidationFailures() as $objValidationFailure)
$msg .= $objValidationFailure->getMessage() . "<br/>";
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
}
}
else {
$con->rollback();
throw(new Exception( "This AppDelegation row doesn't exist!" ));
}
}
catch (Exception $oError) {
throw($oError);
}
}
function remove($sApplicationUID, $iDelegationIndex) {
$oConnection = Propel::getConnection(StepTriggerPeer::DATABASE_NAME);
try {
$oConnection->begin();
$oApp = AppDelegationPeer::retrieveByPK( $sApplicationUID, $iDelegationIndex );
if (is_object($oApp) && get_class ($oApp) == 'AppDelegation' ) {
$result = $oApp->delete();
}
$oConnection->commit();
return $result;
}
catch(Exception $e) {
$oConnection->rollback();
throw($e);
}
}
// TasTypeDay = 1 => working days
// TasTypeDay = 2 => calendar days
function calculateDueDate($sNextTasParam)
{
//Get Task properties
$task = TaskPeer::retrieveByPK( $this->getTasUid() );
$aData['TAS_UID'] = $this->getTasUid();
//Added to allow User defined Timing Control at Run time from Derivation screen
if(isset($sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY']) && $sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] == 'true')
/**
* create an application delegation
*
* @param $sProUid process Uid
* @param $sAppUid Application Uid
* @param $sTasUid Task Uid
* @param $sUsrUid User Uid
* @param $iPriority delegation priority
* @param $isSubprocess is a subprocess inside a process?
* @return delegation index of the application delegation.
*/
function createAppDelegation ($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess = false, $sPrevious = -1, $sNextTasParam = null)
{
$aData['TAS_DURATION'] = $sNextTasParam['NEXT_TASK']['TAS_DURATION'];
$aData['TAS_TIMEUNIT'] = $sNextTasParam['NEXT_TASK']['TAS_TIMEUNIT'];
$aData['TAS_TYPE_DAY'] = $sNextTasParam['NEXT_TASK']['TAS_TYPE_DAY'];
if(isset($sNextTasParam['NEXT_TASK']['TAS_CALENDAR']) && $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'] != '') {
$aCalendarUID = $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'];
}
else {
$aCalendarUID = '';
}
//Updating the task Table , so that user will see updated values in the assign screen in consequent cases
$oTask = new Task();
$oTask->update($aData);
}
else {
if (is_null($task)) {
return 0;
}
$aData['TAS_DURATION'] = $task->getTasDuration();
$aData['TAS_TIMEUNIT'] = $task->getTasTimeUnit();
$aData['TAS_TYPE_DAY'] = $task->getTasTypeDay();
$aCalendarUID = '';
}
//use the dates class to calculate dates
$dates = new dates();
$iDueDate = $dates->calculateDate(
$this->getDelDelegateDate(),
$aData['TAS_DURATION'],
$aData['TAS_TIMEUNIT'], //hours or days, ( we only accept this two types or maybe weeks
$aData['TAS_TYPE_DAY'], //working or calendar days
$this->getUsrUid(),
$task->getProUid(),
$aData['TAS_UID'],
$aCalendarUID
);
return $iDueDate;
}
function getDiffDate ( $date1, $date2 )
{
return ( $date1 - $date2 )/(24*60*60); //days
return ( $date1 - $date2 ) / 3600;
}
public function calculateDuration($cron=0)
{
try {
//patch rows with initdate = null and finish_date
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn(AppDelegationPeer::APP_UID );
$c->addSelectColumn(AppDelegationPeer::DEL_INDEX );
$c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
$c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
$c->add(AppDelegationPeer::DEL_INIT_DATE, NULL, Criteria::ISNULL);
$c->add(AppDelegationPeer::DEL_FINISH_DATE, NULL, Criteria::ISNOTNULL);
//$c->add(AppDelegationPeer::DEL_INDEX, 1);
$rs = AppDelegationPeer::doSelectRS($c);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rs->next();
$row = $rs->getRow();
while (is_array($row)) {
if ($cron == 1) {
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
$arrayCron["processcTimeStart"] = time();
@file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
if (! isset( $sProUid ) || strlen( $sProUid ) == 0) {
throw (new Exception( 'Column "PRO_UID" cannot be null.' ));
}
$oAppDel = AppDelegationPeer::retrieveByPk($row['APP_UID'], $row['DEL_INDEX'] );
if ( isset ($row['DEL_FINISH_DATE']) )
$oAppDel->setDelInitDate($row['DEL_FINISH_DATE']);
else
$oAppDel->setDelInitDate($row['DEL_INIT_DATE']);
$oAppDel->save();
if (! isset( $sAppUid ) || strlen( $sAppUid ) == 0) {
throw (new Exception( 'Column "APP_UID" cannot be null.' ));
}
if (! isset( $sTasUid ) || strlen( $sTasUid ) == 0) {
throw (new Exception( 'Column "TAS_UID" cannot be null.' ));
}
if (! isset( $sUsrUid ) /*|| strlen($sUsrUid ) == 0*/ ) {
throw (new Exception( 'Column "USR_UID" cannot be null.' ));
}
if (! isset( $sAppThread ) || strlen( $sAppThread ) == 0) {
throw (new Exception( 'Column "APP_THREAD" cannot be null.' ));
}
//get max DEL_INDEX SELECT MAX(DEL_INDEX) AS M FROM APP_DELEGATION WHERE APP_UID="'.$Fields['APP_UID'].'"'
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn( 'MAX(' . AppDelegationPeer::DEL_INDEX . ') ' );
$c->add( AppDelegationPeer::APP_UID, $sAppUid );
$rs = AppDelegationPeer::doSelectRS( $c );
$rs->next();
$row = $rs->getRow();
}
//walk in all rows with DEL_STARTED = 0 or DEL_FINISHED = 0
$delIndex = $row[0] + 1;
$c = new Criteria('workflow');
$c->clearSelectColumns();
$c->addSelectColumn(AppDelegationPeer::APP_UID );
$c->addSelectColumn(AppDelegationPeer::DEL_INDEX );
$c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
$c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
$c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
$c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
$c->addSelectColumn(AppDelegationPeer::DEL_DURATION);
$c->addSelectColumn(AppDelegationPeer::DEL_QUEUE_DURATION);
$c->addSelectColumn(AppDelegationPeer::DEL_DELAY_DURATION);
$c->addSelectColumn(AppDelegationPeer::DEL_STARTED);
$c->addSelectColumn(AppDelegationPeer::DEL_FINISHED);
$c->addSelectColumn(AppDelegationPeer::DEL_DELAYED);
$c->addSelectColumn(TaskPeer::TAS_DURATION);
$c->addSelectColumn(TaskPeer::TAS_TIMEUNIT);
$c->addSelectColumn(TaskPeer::TAS_TYPE_DAY);
$this->setAppUid( $sAppUid );
$this->setProUid( $sProUid );
$this->setTasUid( $sTasUid );
$this->setDelIndex( $delIndex );
$this->setDelPrevious( $sPrevious == - 1 ? 0 : $sPrevious );
$this->setUsrUid( $sUsrUid );
$this->setDelType( 'NORMAL' );
$this->setDelPriority( ($iPriority != '' ? $iPriority : '3') );
$this->setDelThread( $sAppThread );
$this->setDelThreadStatus( 'OPEN' );
$this->setDelDelegateDate( 'now' );
$c->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN );
//$c->add(AppDelegationPeer::DEL_INIT_DATE, NULL, Criteria::ISNULL);
//$c->add(AppDelegationPeer::APP_UID, '7694483844a37bfeb0931b1063501289');
//$c->add(AppDelegationPeer::DEL_STARTED, 0);
//The function return an array now. By JHL
$delTaskDueDate = $this->calculateDueDate( $sNextTasParam );
$cton1 = $c->getNewCriterion(AppDelegationPeer::DEL_STARTED, 0);
$cton2 = $c->getNewCriterion(AppDelegationPeer::DEL_FINISHED, 0);
$cton1->addOR($cton2);
$c->add($cton1);
$this->setDelTaskDueDate( $delTaskDueDate['DUE_DATE'] ); // Due date formatted
$rs = AppDelegationPeer::doSelectRS($c);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rs->next();
$row = $rs->getRow();
$i =0;
//print "<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) ) {
if ($cron == 1) {
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
$arrayCron["processcTimeStart"] = time();
@file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
if ((defined( "DEBUG_CALENDAR_LOG" )) && (DEBUG_CALENDAR_LOG)) {
$this->setDelData( $delTaskDueDate['DUE_DATE_LOG'] ); // Log of actions made by Calendar Engine
} else {
$this->setDelData( '' );
}
$fTaskDuration = $row['TAS_DURATION'];
$iDelegateDate = strtotime ( $row['DEL_DELEGATE_DATE'] );
$iInitDate = strtotime ( $row['DEL_INIT_DATE'] );
$iDueDate = strtotime ( $row['DEL_TASK_DUE_DATE'] );
$iFinishDate = strtotime ( $row['DEL_FINISH_DATE'] );
$isStarted = intval ( $row['DEL_STARTED'] );
$isFinished = intval ( $row['DEL_FINISHED'] );
$isDelayed = intval ( $row['DEL_DELAYED'] );
$queueDuration = $this->getDiffDate ($iInitDate, $iDelegateDate);
$delDuration = 0;
$delayDuration = 0;
$overduePercentage = 0.0;
//get the object,
$oAppDel = AppDelegationPeer::retrieveByPk($row['APP_UID'], $row['DEL_INDEX'] );
//if the task is not started
if ( $isStarted == 0 ) {
if ( $row['DEL_INIT_DATE'] != NULL && $row['DEL_INIT_DATE'] != '' ) {
$oAppDel->setDelStarted(1);
$queueDuration = $this->getDiffDate ($iInitDate, $iDelegateDate );
$oAppDel->setDelQueueDuration( $queueDuration);
}
else {//the task was not started
$queueDuration = $this->getDiffDate ( $now, $iDelegateDate );
$oAppDel->setDelQueueDuration( $queueDuration);
//we are putting negative number if the task is not delayed, and positive number for the time the task is delayed
$delayDuration = $this->getDiffDate ($now, $iDueDate );
$oAppDel->setDelDelayDuration( $delayDuration);
if ( $fTaskDuration != 0) {
$overduePercentage = $delayDuration / $fTaskDuration;
$oAppDel->setAppOverduePercentage( $overduePercentage);
if ( $iDueDate < $now ) {
$oAppDel->setDelDelayed(1);
}
}
}
// this condition assures that an internal delegation like a subprocess dont have an initial date setted
if ($delIndex == 1 && ! $isSubprocess) {
//the first delegation, init date this should be now for draft applications, in other cases, should be null.
$this->setDelInitDate( 'now' );
}
//if the task was not finished
if ( $isFinished == 0 ) {
if ( $row['DEL_FINISH_DATE'] != NULL && $row['DEL_FINISH_DATE'] != '') {
$oAppDel->setAppOverduePercentage($overduePercentage);
$oAppDel->setDelFinished(1);
$delDuration = $this->getDiffDate ($iFinishDate, $iInitDate );
$oAppDel->setDelDuration( $delDuration);
//calculate due date if correspond
if ( $iDueDate < $iFinishDate ) {
$oAppDel->setDelDelayed(1);
$delayDuration = $this->getDiffDate ($iFinishDate, $iDueDate );
if ($this->validate()) {
try {
$res = $this->save();
} catch (PropelException $e) {
throw ($e);
}
else {
$oAppDel->setDelDelayed(0);
$delayDuration = 0;
} else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $this->getValidationFailures();
foreach ($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>";
}
}
else { //the task was not completed
if ( $row['DEL_INIT_DATE'] != NULL && $row['DEL_INIT_DATE'] != '' ) {
$delDuration = $this->getDiffDate ($now, $iInitDate );
}
else
$delDuration = $this->getDiffDate ($now, $iDelegateDate);
$oAppDel->setDelDuration( $delDuration);
//we are putting negative number if the task is not delayed, and positive number for the time the task is delayed
$delayDuration = $this->getDiffDate ($now, $iDueDate );
$oAppDel->setDelDelayDuration( $delayDuration);
if ( $fTaskDuration != 0) {
$overduePercentage = $delayDuration / $fTaskDuration;
$oAppDel->setAppOverduePercentage($overduePercentage );
if ( $iDueDate < $now ) {
$oAppDel->setDelDelayed(1);
}
}
}
throw (new Exception( 'Failed Data validation. ' . $msg ));
}
//and finally save the record
$RES = $oAppDel->save();
//print "<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>";
$delIndex = $this->getDelIndex();
//UPDATE APP_DELEGATION SET DEL_DELAYED = 0
//where
// APP_OVERDUE_PERCENTAGE < 0
// Hook for the trigger PM_CREATE_NEW_DELEGATION
if (defined( 'PM_CREATE_NEW_DELEGATION' )) {
$data = new stdclass();
$data->TAS_UID = $sTasUid;
$data->APP_UID = $sAppUid;
$data->DEL_INDEX = $delIndex;
$data->USR_UID = $sUsrUid;
$oPluginRegistry = &PMPluginRegistry::getSingleton();
$oPluginRegistry->executeTriggers( PM_CREATE_NEW_DELEGATION, $data );
}
return $delIndex;
}
/**
* Load the Application Delegation row specified in [app_id] column value.
*
* @param string $AppUid the uid of the application
* @return array $Fields the fields
*/
function Load ($AppUid, $sDelIndex)
{
$con = Propel::getConnection( AppDelegationPeer::DATABASE_NAME );
try {
$oAppDel = AppDelegationPeer::retrieveByPk( $AppUid, $sDelIndex );
if (is_object( $oAppDel ) && get_class( $oAppDel ) == 'AppDelegation') {
$aFields = $oAppDel->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
return $aFields;
} else {
throw (new Exception( "The row '$AppUid, $sDelIndex' in table AppDelegation doesn't exist!" ));
}
} catch (Exception $oError) {
throw ($oError);
}
}
/**
* Update the application row
*
* @param array $aData
* @return variant
*
*/
public function update ($aData)
{
$con = Propel::getConnection( AppDelegationPeer::DATABASE_NAME );
try {
$con->begin();
$oApp = AppDelegationPeer::retrieveByPK( $aData['APP_UID'], $aData['DEL_INDEX'] );
if (is_object( $oApp ) && get_class( $oApp ) == 'AppDelegation') {
$oApp->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oApp->validate()) {
$res = $oApp->save();
$con->commit();
return $res;
} else {
$msg = '';
foreach ($this->getValidationFailures() as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>";
}
throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
}
} else {
$con->rollback();
throw (new Exception( "This AppDelegation row doesn't exist!" ));
}
} catch (Exception $oError) {
throw ($oError);
}
}
function remove ($sApplicationUID, $iDelegationIndex)
{
$oConnection = Propel::getConnection( StepTriggerPeer::DATABASE_NAME );
try {
$oConnection->begin();
$oApp = AppDelegationPeer::retrieveByPK( $sApplicationUID, $iDelegationIndex );
if (is_object( $oApp ) && get_class( $oApp ) == 'AppDelegation') {
$result = $oApp->delete();
}
$oConnection->commit();
return $result;
} catch (Exception $e) {
$oConnection->rollback();
throw ($e);
}
}
// TasTypeDay = 1 => working days
// TasTypeDay = 2 => calendar days
function calculateDueDate ($sNextTasParam)
{
//Get Task properties
$task = TaskPeer::retrieveByPK( $this->getTasUid() );
$aData['TAS_UID'] = $this->getTasUid();
//Added to allow User defined Timing Control at Run time from Derivation screen
if (isset( $sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] ) && $sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] == 'true') {
$aData['TAS_DURATION'] = $sNextTasParam['NEXT_TASK']['TAS_DURATION'];
$aData['TAS_TIMEUNIT'] = $sNextTasParam['NEXT_TASK']['TAS_TIMEUNIT'];
$aData['TAS_TYPE_DAY'] = $sNextTasParam['NEXT_TASK']['TAS_TYPE_DAY'];
if (isset( $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'] ) && $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'] != '') {
$aCalendarUID = $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'];
} else {
$aCalendarUID = '';
}
//Updating the task Table , so that user will see updated values in the assign screen in consequent cases
$oTask = new Task();
$oTask->update( $aData );
} else {
if (is_null( $task )) {
return 0;
}
$aData['TAS_DURATION'] = $task->getTasDuration();
$aData['TAS_TIMEUNIT'] = $task->getTasTimeUnit();
$aData['TAS_TYPE_DAY'] = $task->getTasTypeDay();
$aCalendarUID = '';
}
//use the dates class to calculate dates
$dates = new dates();
$iDueDate = $dates->calculateDate( $this->getDelDelegateDate(), $aData['TAS_DURATION'], $aData['TAS_TIMEUNIT'], //hours or days, ( we only accept this two types or maybe weeks
$aData['TAS_TYPE_DAY'], //working or calendar days
$this->getUsrUid(), $task->getProUid(), $aData['TAS_UID'], $aCalendarUID );
return $iDueDate;
}
function getDiffDate ($date1, $date2)
{
return ($date1 - $date2) / (24 * 60 * 60); //days
return ($date1 - $date2) / 3600;
}
public function calculateDuration ($cron = 0)
{
try {
//patch rows with initdate = null and finish_date
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn( AppDelegationPeer::APP_UID );
$c->addSelectColumn( AppDelegationPeer::DEL_INDEX );
$c->addSelectColumn( AppDelegationPeer::DEL_DELEGATE_DATE );
$c->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );
$c->add( AppDelegationPeer::DEL_INIT_DATE, null, Criteria::ISNULL );
$c->add( AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNOTNULL );
//$c->add(AppDelegationPeer::DEL_INDEX, 1);
$rs = AppDelegationPeer::doSelectRS( $c );
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rs->next();
$row = $rs->getRow();
while (is_array( $row )) {
if ($cron == 1) {
$arrayCron = unserialize( trim( @file_get_contents( PATH_DATA . "cron" ) ) );
$arrayCron["processcTimeStart"] = time();
@file_put_contents( PATH_DATA . "cron", serialize( $arrayCron ) );
}
$oAppDel = AppDelegationPeer::retrieveByPk( $row['APP_UID'], $row['DEL_INDEX'] );
if (isset( $row['DEL_FINISH_DATE'] )) {
$oAppDel->setDelInitDate( $row['DEL_FINISH_DATE'] );
} else {
$oAppDel->setDelInitDate( $row['DEL_INIT_DATE'] );
}
$oAppDel->save();
$rs->next();
$row = $rs->getRow();
}
//walk in all rows with DEL_STARTED = 0 or DEL_FINISHED = 0
$c = new Criteria( 'workflow' );
$c->clearSelectColumns();
$c->addSelectColumn( AppDelegationPeer::APP_UID );
$c->addSelectColumn( AppDelegationPeer::DEL_INDEX );
$c->addSelectColumn( AppDelegationPeer::DEL_DELEGATE_DATE );
$c->addSelectColumn( AppDelegationPeer::DEL_INIT_DATE );
$c->addSelectColumn( AppDelegationPeer::DEL_TASK_DUE_DATE );
$c->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );
$c->addSelectColumn( AppDelegationPeer::DEL_DURATION );
$c->addSelectColumn( AppDelegationPeer::DEL_QUEUE_DURATION );
$c->addSelectColumn( AppDelegationPeer::DEL_DELAY_DURATION );
$c->addSelectColumn( AppDelegationPeer::DEL_STARTED );
$c->addSelectColumn( AppDelegationPeer::DEL_FINISHED );
$c->addSelectColumn( AppDelegationPeer::DEL_DELAYED );
$c->addSelectColumn( TaskPeer::TAS_DURATION );
$c->addSelectColumn( TaskPeer::TAS_TIMEUNIT );
$c->addSelectColumn( TaskPeer::TAS_TYPE_DAY );
$c->addJoin( AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN );
//$c->add(AppDelegationPeer::DEL_INIT_DATE, NULL, Criteria::ISNULL);
//$c->add(AppDelegationPeer::APP_UID, '7694483844a37bfeb0931b1063501289');
//$c->add(AppDelegationPeer::DEL_STARTED, 0);
$cton1 = $c->getNewCriterion( AppDelegationPeer::DEL_STARTED, 0 );
$cton2 = $c->getNewCriterion( AppDelegationPeer::DEL_FINISHED, 0 );
$cton1->addOR( $cton2 );
$c->add( $cton1 );
$rs = AppDelegationPeer::doSelectRS( $c );
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rs->next();
$row = $rs->getRow();
$i = 0;
//print "<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 )) {
if ($cron == 1) {
$arrayCron = unserialize( trim( @file_get_contents( PATH_DATA . "cron" ) ) );
$arrayCron["processcTimeStart"] = time();
@file_put_contents( PATH_DATA . "cron", serialize( $arrayCron ) );
}
$fTaskDuration = $row['TAS_DURATION'];
$iDelegateDate = strtotime( $row['DEL_DELEGATE_DATE'] );
$iInitDate = strtotime( $row['DEL_INIT_DATE'] );
$iDueDate = strtotime( $row['DEL_TASK_DUE_DATE'] );
$iFinishDate = strtotime( $row['DEL_FINISH_DATE'] );
$isStarted = intval( $row['DEL_STARTED'] );
$isFinished = intval( $row['DEL_FINISHED'] );
$isDelayed = intval( $row['DEL_DELAYED'] );
$queueDuration = $this->getDiffDate( $iInitDate, $iDelegateDate );
$delDuration = 0;
$delayDuration = 0;
$overduePercentage = 0.0;
//get the object,
$oAppDel = AppDelegationPeer::retrieveByPk( $row['APP_UID'], $row['DEL_INDEX'] );
//if the task is not started
if ($isStarted == 0) {
if ($row['DEL_INIT_DATE'] != null && $row['DEL_INIT_DATE'] != '') {
$oAppDel->setDelStarted( 1 );
$queueDuration = $this->getDiffDate( $iInitDate, $iDelegateDate );
$oAppDel->setDelQueueDuration( $queueDuration );
} else {
//the task was not started
$queueDuration = $this->getDiffDate( $now, $iDelegateDate );
$oAppDel->setDelQueueDuration( $queueDuration );
//we are putting negative number if the task is not delayed, and positive number for the time the task is delayed
$delayDuration = $this->getDiffDate( $now, $iDueDate );
$oAppDel->setDelDelayDuration( $delayDuration );
if ($fTaskDuration != 0) {
$overduePercentage = $delayDuration / $fTaskDuration;
$oAppDel->setAppOverduePercentage( $overduePercentage );
if ($iDueDate < $now) {
$oAppDel->setDelDelayed( 1 );
}
}
}
}
//if the task was not finished
if ($isFinished == 0) {
if ($row['DEL_FINISH_DATE'] != null && $row['DEL_FINISH_DATE'] != '') {
$oAppDel->setAppOverduePercentage( $overduePercentage );
$oAppDel->setDelFinished( 1 );
$delDuration = $this->getDiffDate( $iFinishDate, $iInitDate );
$oAppDel->setDelDuration( $delDuration );
//calculate due date if correspond
if ($iDueDate < $iFinishDate) {
$oAppDel->setDelDelayed( 1 );
$delayDuration = $this->getDiffDate( $iFinishDate, $iDueDate );
} else {
$oAppDel->setDelDelayed( 0 );
$delayDuration = 0;
}
} else {
//the task was not completed
if ($row['DEL_INIT_DATE'] != null && $row['DEL_INIT_DATE'] != '') {
$delDuration = $this->getDiffDate( $now, $iInitDate );
} else {
$delDuration = $this->getDiffDate( $now, $iDelegateDate );
}
$oAppDel->setDelDuration( $delDuration );
//we are putting negative number if the task is not delayed, and positive number for the time the task is delayed
$delayDuration = $this->getDiffDate( $now, $iDueDate );
$oAppDel->setDelDelayDuration( $delayDuration );
if ($fTaskDuration != 0) {
$overduePercentage = $delayDuration / $fTaskDuration;
$oAppDel->setAppOverduePercentage( $overduePercentage );
if ($iDueDate < $now) {
$oAppDel->setDelDelayed( 1 );
}
}
}
}
//and finally save the record
$RES = $oAppDel->save();
//print "<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
$rs->next();
$row = $rs->getRow();
}
} catch (Exception $oError) {
error_log( $oError->getMessage() );
}
}
function getLastDeleration ($APP_UID)
{
$c = new Criteria( 'workflow' );
$c->addSelectColumn( AppDelegationPeer::APP_UID );
$c->addSelectColumn( AppDelegationPeer::DEL_INDEX );
$c->addSelectColumn( AppDelegationPeer::DEL_DELEGATE_DATE );
$c->addSelectColumn( AppDelegationPeer::DEL_INIT_DATE );
$c->addSelectColumn( AppDelegationPeer::DEL_TASK_DUE_DATE );
$c->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE );
$c->addSelectColumn( AppDelegationPeer::DEL_DURATION );
$c->addSelectColumn( AppDelegationPeer::DEL_QUEUE_DURATION );
$c->addSelectColumn( AppDelegationPeer::DEL_DELAY_DURATION );
$c->addSelectColumn( AppDelegationPeer::DEL_STARTED );
$c->addSelectColumn( AppDelegationPeer::DEL_FINISHED );
$c->addSelectColumn( AppDelegationPeer::DEL_DELAYED );
$c->addSelectColumn( AppDelegationPeer::USR_UID );
$c->add( AppDelegationPeer::APP_UID, $APP_UID );
$c->addDescendingOrderByColumn( AppDelegationPeer::DEL_INDEX );
$rs = AppDelegationPeer::doSelectRS( $c );
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rs->next();
$row = $rs->getRow();
}
return $rs->getRow();
}
catch (Exception $oError) {
error_log( $oError->getMessage());
}
}
}
// AppDelegation
function getLastDeleration($APP_UID){
$c = new Criteria('workflow');
$c->addSelectColumn(AppDelegationPeer::APP_UID );
$c->addSelectColumn(AppDelegationPeer::DEL_INDEX );
$c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
$c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
$c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
$c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
$c->addSelectColumn(AppDelegationPeer::DEL_DURATION);
$c->addSelectColumn(AppDelegationPeer::DEL_QUEUE_DURATION);
$c->addSelectColumn(AppDelegationPeer::DEL_DELAY_DURATION);
$c->addSelectColumn(AppDelegationPeer::DEL_STARTED);
$c->addSelectColumn(AppDelegationPeer::DEL_FINISHED);
$c->addSelectColumn(AppDelegationPeer::DEL_DELAYED);
$c->addSelectColumn(AppDelegationPeer::USR_UID);
$c->add(AppDelegationPeer::APP_UID, $APP_UID);
$c->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
$rs = AppDelegationPeer::doSelectRS($c);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rs->next();
return $rs->getRow();
}
} // AppDelegation

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,8 @@
<?php
/**
* Groupwf.php
* @package workflow.engine.classes.model
*
* @package workflow.engine.classes.model
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.
@@ -13,11 +14,11 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
@@ -33,387 +34,399 @@ require_once 'classes/model/Content.php';
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package workflow.engine.classes.model
* @package workflow.engine.classes.model
*/
class Groupwf extends BaseGroupwf {
/**
* This value goes in the content table
* @var string
*/
//protected $grp_title = '';
protected $grp_title = '';
class Groupwf extends BaseGroupwf
{
/**
* This value goes in the content table
*
* @var string
*/
//protected $grp_title = '';
protected $grp_title = '';
/**
* Get the [grp_title] column value.
* @return string
*/
public function getGrpTitle()
{
if ( $this->getGrpUid() == '' ) {
throw ( new Exception( "Error in getGrpTitle, the GRP_UID can't be blank") );
}
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$this->grp_title = Content::load ( 'GRP_TITLE', '', $this->getGrpUid(), $lang );
return $this->grp_title;
}
/**
* Set the [grp_title] column value.
*
* @param string $v new value
* @return void
*/
public function setGrpTitle($v)
{
if ( $this->getGrpUid() == '' ) {
throw ( new Exception( "Error in setGrpTitle, the GRP_UID can't be blank") );
}
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->grp_title !== $v || $v === '') {
$this->grp_title = $v;
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$res = Content::addContent( 'GRP_TITLE', '', $this->getGrpUid(), $lang, $this->grp_title );
}
} // set()
/**
* Creates the Group
*
* @param array $aData $oData is not necessary
* @return void
*/
function create ($aData ) {
//$oData is not necessary
$con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
try {
if ( isset ( $aData['GRP_UID'] ) )
$this->setGrpUid ( $aData['GRP_UID'] );
else
$this->setGrpUid ( G::generateUniqueID() );
if ( isset ( $aData['GRP_STATUS'] ) )
$this->setGrpStatus ( $aData['GRP_STATUS'] );
else
$this->setGrpStatus ( 'ACTIVE' );
if ( isset ( $aData['GRP_LDAP_DN'] ) )
$this->setGrpLdapDn ( $aData['GRP_LDAP_DN'] );
else
$this->setGrpLdapDn ( '' );
if ( $this->validate() ) {
$con->begin();
$res = $this->save();
if (isset ( $aData['GRP_TITLE'] ) )
$this->setGrpTitle ( $aData['GRP_TITLE'] );
else
$this->setGrpTitle ( 'Default Group Title' );
$con->commit();
return $this->getGrpUid();
}
else {
$msg = '';
foreach($this->getValidationFailures() as $objValidationFailure)
$msg .= $objValidationFailure->getMessage() . "<br/>";
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
}
}
catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
/**
* Load the Process row specified in [grp_id] column value.
*
* @param string $ProUid the uid of the Prolication
* @return array $Fields the fields
*/
function Load ( $ProUid ) {
$con = Propel::getConnection(GroupwfPeer::DATABASE_NAME);
try {
$oPro = GroupwfPeer::retrieveByPk( $ProUid );
if (is_object($oPro) && get_class ($oPro) == 'Groupwf' ) {
$aFields = $oPro->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray ($aFields, BasePeer::TYPE_FIELDNAME );
$aFields['GRP_TITLE'] = $oPro->getGrpTitle();
$this->setGrpTitle ( $oPro->getGrpTitle() );
return $aFields;
}
else {
throw(new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
}
}
catch (Exception $oError) {
throw($oError);
}
}
/**
* Update the Group row
* @param array $aData
* @return variant
**/
public function update($aData)
{
$con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
try {
$con->begin();
$oPro = GroupwfPeer::retrieveByPK( $aData['GRP_UID'] );
if (is_object($oPro) && get_class ($oPro) == 'Groupwf' ) {
$oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oPro->validate()) {
if ( isset ( $aData['GRP_TITLE'] ) )
$oPro->setGrpTitle( $aData['GRP_TITLE'] );
$res = $oPro->save();
$con->commit();
return $res;
/**
* Get the [grp_title] column value.
*
* @return string
*/
public function getGrpTitle ()
{
if ($this->getGrpUid() == '') {
throw (new Exception( "Error in getGrpTitle, the GRP_UID can't be blank" ));
}
else {
$msg = '';
foreach($this->getValidationFailures() as $objValidationFailure)
$msg .= $objValidationFailure->getMessage() . "<br/>";
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
$this->grp_title = Content::load( 'GRP_TITLE', '', $this->getGrpUid(), $lang );
return $this->grp_title;
}
throw ( new PropelException ( 'The row cannot be created!', new PropelException ( $msg ) ) );
/**
* Set the [grp_title] column value.
*
* @param string $v new value
* @return void
*/
public function setGrpTitle ($v)
{
if ($this->getGrpUid() == '') {
throw (new Exception( "Error in setGrpTitle, the GRP_UID can't be blank" ));
}
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && ! is_string( $v )) {
$v = (string) $v;
}
}
else {
$con->rollback();
throw(new Exception( "The row '" . $aData['GRP_UID'] . "' in table Group doesn't exist!" ));
}
}
catch (Exception $oError) {
throw($oError);
}
}
/**
* Remove the Prolication document registry
* @param array $aData or string $ProUid
* @return string
**/
public function remove($ProUid)
{
if ( is_array ( $ProUid ) ) {
$ProUid = ( isset ( $ProUid['GRP_UID'] ) ? $ProUid['GRP_UID'] : '' );
}
try {
$oPro = GroupwfPeer::retrieveByPK( $ProUid );
if (!is_null($oPro))
{
Content::removeContent('GRP_TITLE', '', $oPro->getGrpUid());
Content::removeContent('GRP_DESCRIPTION', '', $oPro->getGrpUid());
return $oPro->delete();
}
else {
throw(new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
}
}
catch (Exception $oError) {
throw($oError);
}
}
if ($this->grp_title !== $v || $v === '') {
$this->grp_title = $v;
$lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
$res = Content::addContent( 'GRP_TITLE', '', $this->getGrpUid(), $lang, $this->grp_title );
}
/**
* verify if row specified in [GrpUid] exists.
*
* @param string $sProUid the uid of the Prolication
*/
} // set()
function GroupwfExists ( $GrpUid ) {
$con = Propel::getConnection(GroupwfPeer::DATABASE_NAME);
try {
$oPro = GroupwfPeer::retrieveByPk( $GrpUid );
if (is_object($oPro) && get_class ($oPro) == 'Groupwf' ) {
return true;
}
else {
return false;
}
}
catch (Exception $oError) {
throw($oError);
}
}
function loadByGroupname ( $Groupname ) {
$c = new Criteria('workflow');
$del = DBAdapter::getStringDelimiter();
/**
* Creates the Group
*
* @param array $aData $oData is not necessary
* @return void
*/
$c->clearSelectColumns();
$c->addSelectColumn( ContentPeer::CON_CATEGORY );
$c->addSelectColumn( ContentPeer::CON_VALUE );
function create ($aData)
{
//$oData is not necessary
$con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
try {
if (isset( $aData['GRP_UID'] )) {
$this->setGrpUid( $aData['GRP_UID'] );
} else {
$this->setGrpUid( G::generateUniqueID() );
}
$c->add(ContentPeer::CON_CATEGORY, 'GRP_TITLE');
$c->add(ContentPeer::CON_VALUE, $Groupname);
$c->add(ContentPeer::CON_LANG, SYS_LANG );
return $c;
}
if (isset( $aData['GRP_STATUS'] )) {
$this->setGrpStatus( $aData['GRP_STATUS'] );
} else {
$this->setGrpStatus( 'ACTIVE' );
}
function getAll($start=null, $limit=null, $search=null)
{
$totalCount = 0;
$criteria = new Criteria('workflow');
$criteria->addSelectColumn(GroupwfPeer::GRP_UID);
$criteria->addSelectColumn(GroupwfPeer::GRP_STATUS);
$criteria->addSelectColumn(GroupwfPeer::GRP_LDAP_DN);
$criteria->addSelectColumn(ContentPeer::CON_VALUE);
$criteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
$criteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
$criteria->add(ContentPeer::CON_CATEGORY,'GRP_TITLE');
$criteria->add(ContentPeer::CON_LANG,SYS_LANG);
$criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
if (isset( $aData['GRP_LDAP_DN'] )) {
$this->setGrpLdapDn( $aData['GRP_LDAP_DN'] );
} else {
$this->setGrpLdapDn( '' );
}
if ( $search ){
$criteria->add(ContentPeer::CON_VALUE,'%'.$search.'%',Criteria::LIKE);
if ($this->validate()) {
$con->begin();
$res = $this->save();
if (isset( $aData['GRP_TITLE'] )) {
$this->setGrpTitle( $aData['GRP_TITLE'] );
} else {
$this->setGrpTitle( 'Default Group Title' );
}
$con->commit();
return $this->getGrpUid();
} else {
$msg = '';
foreach ($this->getValidationFailures() as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>";
}
throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
}
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
$c = clone $criteria;
$c->clearSelectColumns();
$c->addSelectColumn('COUNT(*)');
$dataset = GroupwfPeer::doSelectRS($c);
$dataset->next();
$rowCount = $dataset->getRow();
/**
* Load the Process row specified in [grp_id] column value.
*
* @param string $ProUid the uid of the Prolication
* @return array $Fields the fields
*/
if( is_array($rowCount) )
$totalCount = $rowCount[0];
if( $start )
$criteria->setOffset($start);
if( $limit )
$criteria->setLimit($limit);
$rs = GroupwfPeer::doSelectRS($criteria);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rows = Array();
while( $rs->next() )
$rows[] = $rs->getRow();
$result->data = $rows;
$result->totalCount = $totalCount;
return $result;
}
function getAllGroup($start=null, $limit=null, $search=null)
{
require_once PATH_RBAC . "model/RbacUsers.php";
require_once 'classes/model/TaskUser.php';
require_once 'classes/model/GroupUser.php';
$totalCount = 0;
$criteria = new Criteria('workflow');
$criteria->addSelectColumn(GroupwfPeer::GRP_UID);
$criteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
$criteria->add(ContentPeer::CON_CATEGORY,'GRP_TITLE');
$criteria->add(ContentPeer::CON_LANG,SYS_LANG);
$criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
if ($search) {
$criteria->add(ContentPeer::CON_VALUE,'%'.$search.'%',Criteria::LIKE);
function Load ($ProUid)
{
$con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
try {
$oPro = GroupwfPeer::retrieveByPk( $ProUid );
if (is_object( $oPro ) && get_class( $oPro ) == 'Groupwf') {
$aFields = $oPro->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
$aFields['GRP_TITLE'] = $oPro->getGrpTitle();
$this->setGrpTitle( $oPro->getGrpTitle() );
return $aFields;
} else {
throw (new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
}
} catch (Exception $oError) {
throw ($oError);
}
}
$totalRows = GroupwfPeer::doCount($criteria);
/**
* Update the Group row
*
* @param array $aData
* @return variant
*
*/
$criteria = new Criteria('workflow');
$criteria->addSelectColumn(GroupwfPeer::GRP_UID);
$criteria->addSelectColumn(GroupwfPeer::GRP_STATUS);
$criteria->addSelectColumn(GroupwfPeer::GRP_UX);
$criteria->addAsColumn('GRP_TITLE',ContentPeer::CON_VALUE);
$criteria->addSelectColumn(ContentPeer::CON_VALUE, 'COCHALO');
$criteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
$criteria->add(ContentPeer::CON_CATEGORY,'GRP_TITLE');
$criteria->add(ContentPeer::CON_LANG,SYS_LANG);
$criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
if ($start != '') {
$criteria->setOffset($start);
public function update ($aData)
{
$con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
try {
$con->begin();
$oPro = GroupwfPeer::retrieveByPK( $aData['GRP_UID'] );
if (is_object( $oPro ) && get_class( $oPro ) == 'Groupwf') {
$oPro->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oPro->validate()) {
if (isset( $aData['GRP_TITLE'] )) {
$oPro->setGrpTitle( $aData['GRP_TITLE'] );
}
$res = $oPro->save();
$con->commit();
return $res;
} else {
$msg = '';
foreach ($this->getValidationFailures() as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>";
}
throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) ));
}
} else {
$con->rollback();
throw (new Exception( "The row '" . $aData['GRP_UID'] . "' in table Group doesn't exist!" ));
}
} catch (Exception $oError) {
throw ($oError);
}
}
if ($limit != '') {
$criteria->setLimit($limit);
}
if ($search) {
$criteria->add(ContentPeer::CON_VALUE,'%'.$search.'%',Criteria::LIKE);
}
$oDataset = GroupwfPeer::doSelectRS ( $criteria );
$oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC );
$processes = Array();
$uids=array();
$groups = array();
$aGroups = array();
while( $oDataset->next() ) {
$groups[] = $oDataset->getRow();
/**
* Remove the Prolication document registry
*
* @param array $aData or string $ProUid
* @return string
*
*/
public function remove ($ProUid)
{
if (is_array( $ProUid )) {
$ProUid = (isset( $ProUid['GRP_UID'] ) ? $ProUid['GRP_UID'] : '');
}
try {
$oPro = GroupwfPeer::retrieveByPK( $ProUid );
if (! is_null( $oPro )) {
Content::removeContent( 'GRP_TITLE', '', $oPro->getGrpUid() );
Content::removeContent( 'GRP_DESCRIPTION', '', $oPro->getGrpUid() );
return $oPro->delete();
} else {
throw (new Exception( "The row '$ProUid' in table Group doesn't exist!" ));
}
} catch (Exception $oError) {
throw ($oError);
}
}
return array('rows' => $groups, 'totalCount'=>$totalRows);
}
/**
* verify if row specified in [GrpUid] exists.
*
* @param string $sProUid the uid of the Prolication
*/
function filterGroup($filter,$start,$limit)
{
require_once 'classes/model/Groupwf.php';
require_once 'classes/model/TaskUser.php';
require_once 'classes/model/GroupUser.php';
G::LoadClass('configuration');
$co = new Configurations();
$config = $co->getConfiguration('groupList', 'pageSize','',$_SESSION['USER_LOGGED']);
$env = $co->getConfiguration('ENVIRONMENT_SETTINGS', '');
$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size;
$filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : '';
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(GroupwfPeer::GRP_UID);
$oCriteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
$oCriteria->add(ContentPeer::CON_CATEGORY,'GRP_TITLE');
$oCriteria->add(ContentPeer::CON_LANG,SYS_LANG);
if ($filter != ''){
$oCriteria->add(ContentPeer::CON_VALUE, '%'.$filter.'%', Criteria::LIKE);
function GroupwfExists ($GrpUid)
{
$con = Propel::getConnection( GroupwfPeer::DATABASE_NAME );
try {
$oPro = GroupwfPeer::retrieveByPk( $GrpUid );
if (is_object( $oPro ) && get_class( $oPro ) == 'Groupwf') {
return true;
} else {
return false;
}
} catch (Exception $oError) {
throw ($oError);
}
}
$totalRows = GroupwfPeer::doCount($oCriteria);
$oCriteria = new Criteria('workflow');
$oCriteria->clearSelectColumns();
$oCriteria->addSelectColumn(GroupwfPeer::GRP_UID);
$oCriteria->addSelectColumn(GroupwfPeer::GRP_STATUS);
$oCriteria->addSelectColumn(ContentPeer::CON_VALUE);
$oCriteria->addAsColumn('GRP_TASKS', 0);
$oCriteria->addAsColumn('GRP_USERS', 0);
$oCriteria->addJoin(GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN);
$oCriteria->add(ContentPeer::CON_CATEGORY,'GRP_TITLE');
$oCriteria->add(ContentPeer::CON_LANG,SYS_LANG);
if ($filter != ''){
$oCriteria->add(ContentPeer::CON_VALUE, '%'.$filter.'%', Criteria::LIKE);
function loadByGroupname ($Groupname)
{
$c = new Criteria( 'workflow' );
$del = DBAdapter::getStringDelimiter();
$c->clearSelectColumns();
$c->addSelectColumn( ContentPeer::CON_CATEGORY );
$c->addSelectColumn( ContentPeer::CON_VALUE );
$c->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
$c->add( ContentPeer::CON_VALUE, $Groupname );
$c->add( ContentPeer::CON_LANG, SYS_LANG );
return $c;
}
$oCriteria->setOffset($start);
$oCriteria->setLimit($limit);
$oDataset = GroupwfPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
}
} // Groupwf
function getAll ($start = null, $limit = null, $search = null)
{
$totalCount = 0;
$criteria = new Criteria( 'workflow' );
$criteria->addSelectColumn( GroupwfPeer::GRP_UID );
$criteria->addSelectColumn( GroupwfPeer::GRP_STATUS );
$criteria->addSelectColumn( GroupwfPeer::GRP_LDAP_DN );
$criteria->addSelectColumn( ContentPeer::CON_VALUE );
$criteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
$criteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' );
$criteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
$criteria->add( ContentPeer::CON_LANG, SYS_LANG );
$criteria->addAscendingOrderByColumn( ContentPeer::CON_VALUE );
if ($search) {
$criteria->add( ContentPeer::CON_VALUE, '%' . $search . '%', Criteria::LIKE );
}
$c = clone $criteria;
$c->clearSelectColumns();
$c->addSelectColumn( 'COUNT(*)' );
$dataset = GroupwfPeer::doSelectRS( $c );
$dataset->next();
$rowCount = $dataset->getRow();
if (is_array( $rowCount )) {
$totalCount = $rowCount[0];
}
if ($start) {
$criteria->setOffset( $start );
}
if ($limit) {
$criteria->setLimit( $limit );
}
$rs = GroupwfPeer::doSelectRS( $criteria );
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rows = Array ();
while ($rs->next()) {
$rows[] = $rs->getRow();
}
$result->data = $rows;
$result->totalCount = $totalCount;
return $result;
}
function getAllGroup ($start = null, $limit = null, $search = null)
{
require_once PATH_RBAC . "model/RbacUsers.php";
require_once 'classes/model/TaskUser.php';
require_once 'classes/model/GroupUser.php';
$totalCount = 0;
$criteria = new Criteria( 'workflow' );
$criteria->addSelectColumn( GroupwfPeer::GRP_UID );
$criteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
$criteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
$criteria->add( ContentPeer::CON_LANG, SYS_LANG );
$criteria->addAscendingOrderByColumn( ContentPeer::CON_VALUE );
if ($search) {
$criteria->add( ContentPeer::CON_VALUE, '%' . $search . '%', Criteria::LIKE );
}
$totalRows = GroupwfPeer::doCount( $criteria );
$criteria = new Criteria( 'workflow' );
$criteria->addSelectColumn( GroupwfPeer::GRP_UID );
$criteria->addSelectColumn( GroupwfPeer::GRP_STATUS );
$criteria->addSelectColumn( GroupwfPeer::GRP_UX );
$criteria->addAsColumn( 'GRP_TITLE', ContentPeer::CON_VALUE );
$criteria->addSelectColumn( ContentPeer::CON_VALUE, 'COCHALO' );
$criteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
$criteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
$criteria->add( ContentPeer::CON_LANG, SYS_LANG );
$criteria->addAscendingOrderByColumn( ContentPeer::CON_VALUE );
if ($start != '') {
$criteria->setOffset( $start );
}
if ($limit != '') {
$criteria->setLimit( $limit );
}
if ($search) {
$criteria->add( ContentPeer::CON_VALUE, '%' . $search . '%', Criteria::LIKE );
}
$oDataset = GroupwfPeer::doSelectRS( $criteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$processes = Array ();
$uids = array ();
$groups = array ();
$aGroups = array ();
while ($oDataset->next()) {
$groups[] = $oDataset->getRow();
}
return array ('rows' => $groups,'totalCount' => $totalRows
);
}
function filterGroup ($filter, $start, $limit)
{
require_once 'classes/model/Groupwf.php';
require_once 'classes/model/TaskUser.php';
require_once 'classes/model/GroupUser.php';
G::LoadClass( 'configuration' );
$co = new Configurations();
$config = $co->getConfiguration( 'groupList', 'pageSize', '', $_SESSION['USER_LOGGED'] );
$env = $co->getConfiguration( 'ENVIRONMENT_SETTINGS', '' );
$limit_size = isset( $config['pageSize'] ) ? $config['pageSize'] : 20;
$start = isset( $_REQUEST['start'] ) ? $_REQUEST['start'] : 0;
$limit = isset( $_REQUEST['limit'] ) ? $_REQUEST['limit'] : $limit_size;
$filter = isset( $_REQUEST['textFilter'] ) ? $_REQUEST['textFilter'] : '';
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( GroupwfPeer::GRP_UID );
$oCriteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
$oCriteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
$oCriteria->add( ContentPeer::CON_LANG, SYS_LANG );
if ($filter != '') {
$oCriteria->add( ContentPeer::CON_VALUE, '%' . $filter . '%', Criteria::LIKE );
}
$totalRows = GroupwfPeer::doCount( $oCriteria );
$oCriteria = new Criteria( 'workflow' );
$oCriteria->clearSelectColumns();
$oCriteria->addSelectColumn( GroupwfPeer::GRP_UID );
$oCriteria->addSelectColumn( GroupwfPeer::GRP_STATUS );
$oCriteria->addSelectColumn( ContentPeer::CON_VALUE );
$oCriteria->addAsColumn( 'GRP_TASKS', 0 );
$oCriteria->addAsColumn( 'GRP_USERS', 0 );
$oCriteria->addJoin( GroupwfPeer::GRP_UID, ContentPeer::CON_ID, Criteria::LEFT_JOIN );
$oCriteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' );
$oCriteria->add( ContentPeer::CON_LANG, SYS_LANG );
if ($filter != '') {
$oCriteria->add( ContentPeer::CON_VALUE, '%' . $filter . '%', Criteria::LIKE );
}
$oCriteria->setOffset( $start );
$oCriteria->setLimit( $limit );
$oDataset = GroupwfPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
}
}
// Groupwf

File diff suppressed because it is too large Load Diff

View File

@@ -2,449 +2,439 @@
require_once 'classes/model/om/BaseUsersProperties.php';
/**
* Skeleton subclass for representing a row from the 'USERS_PROPERTIES' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
/**
* @package workflow.engine.classes.model
*
* @package workflow.engine.classes.model
*/
class UsersProperties extends BaseUsersProperties
{
public $fields = null;
public $usrID = '';
public $lang = 'en';
public $fields = null;
public $usrID = '';
public $lang = 'en';
function __construct()
{
$this->lang = defined('SYS_LANG') ? SYS_LANG : 'en';
}
function __construct ()
{
$this->lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
}
function UserPropertyExists($sUserUID)
{
$oUserProperty = UsersPropertiesPeer::retrieveByPk($sUserUID);
if (!is_null($oUserProperty) && is_object($oUserProperty) && get_class($oUserProperty) == 'UsersProperties') {
$this->fields = $oUserProperty->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($this->fields, BasePeer::TYPE_FIELDNAME);
return true;
}
else {
return false;
}
}
public function load($sUserUID)
{
$oUserProperty = UsersPropertiesPeer::retrieveByPK($sUserUID);
if (!is_null($oUserProperty)) {
$aFields = $oUserProperty->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
return $aFields;
}
else {
throw new Exception("User with $sUserUID does not exist!");
}
}
public function create($aData)
{
$oConnection = Propel::getConnection(UsersPropertiesPeer::DATABASE_NAME);
try {
$oUserProperty = new UsersProperties();
$oUserProperty->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oUserProperty->validate()) {
$oConnection->begin();
$iResult = $oUserProperty->save();
$oConnection->commit();
return true;
}
else {
$sMessage = '';
$aValidationFailures = $oUserProperty->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
function UserPropertyExists ($sUserUID)
{
$oUserProperty = UsersPropertiesPeer::retrieveByPk( $sUserUID );
if (! is_null( $oUserProperty ) && is_object( $oUserProperty ) && get_class( $oUserProperty ) == 'UsersProperties') {
$this->fields = $oUserProperty->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $this->fields, BasePeer::TYPE_FIELDNAME );
return true;
} else {
return false;
}
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
}
}
catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
public function update($aData)
{
$oConnection = Propel::getConnection(UsersPropertiesPeer::DATABASE_NAME);
try {
$oUserProperty = UsersPropertiesPeer::retrieveByPK($aData['USR_UID']);
if (!is_null($oUserProperty)) {
$oUserProperty->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oUserProperty->validate()) {
$oConnection->begin();
$iResult = $oUserProperty->save();
$oConnection->commit();
return $iResult;
public function load ($sUserUID)
{
$oUserProperty = UsersPropertiesPeer::retrieveByPK( $sUserUID );
if (! is_null( $oUserProperty )) {
$aFields = $oUserProperty->toArray( BasePeer::TYPE_FIELDNAME );
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
return $aFields;
} else {
throw new Exception( "User with $sUserUID does not exist!" );
}
else {
$sMessage = '';
$aValidationFailures = $oUserProperty->getValidationFailures();
foreach($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
}
public function create ($aData)
{
$oConnection = Propel::getConnection( UsersPropertiesPeer::DATABASE_NAME );
try {
$oUserProperty = new UsersProperties();
$oUserProperty->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oUserProperty->validate()) {
$oConnection->begin();
$iResult = $oUserProperty->save();
$oConnection->commit();
return true;
} else {
$sMessage = '';
$aValidationFailures = $oUserProperty->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
else {
throw(new Exception('This row doesn\'t exist!'));
}
}
catch (Exception $oError) {
$oConnection->rollback();
throw($oError);
}
}
public function loadOrCreateIfNotExists($sUserUID, $aUserProperty = array())
{
if (!$this->UserPropertyExists($sUserUID)) {
$aUserProperty['USR_UID'] = $sUserUID;
if (!isset($aUserProperty['USR_LAST_UPDATE_DATE'])) {
$aUserProperty['USR_LAST_UPDATE_DATE'] = date('Y-m-d H:i:s');
}
if (!isset($aUserProperty['USR_LOGGED_NEXT_TIME'])) {
$aUserProperty['USR_LOGGED_NEXT_TIME'] = 0;
}
$this->create($aUserProperty);
}
else {
$aUserProperty = $this->fields;
}
return $aUserProperty;
}
public function validatePassword($sPassword, $sLastUpdate, $iChangePasswordNextTime)
{
if (!defined('PPP_MINIMUM_LENGTH')) {
define('PPP_MINIMUM_LENGTH', 5);
}
if (!defined('PPP_MAXIMUM_LENGTH')) {
define('PPP_MAXIMUM_LENGTH', 20);
}
if (!defined('PPP_NUMERICAL_CHARACTER_REQUIRED')) {
define('PPP_NUMERICAL_CHARACTER_REQUIRED', 0);
}
if (!defined('PPP_UPPERCASE_CHARACTER_REQUIRED')) {
define('PPP_UPPERCASE_CHARACTER_REQUIRED', 0);
}
if (!defined('PPP_SPECIAL_CHARACTER_REQUIRED')) {
define('PPP_SPECIAL_CHARACTER_REQUIRED', 0);
}
if (!defined('PPP_EXPIRATION_IN')) {
define('PPP_EXPIRATION_IN', 0);
}
if (!defined('PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN')) {
define('PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN', 0);
}
if (function_exists('mb_strlen')) {
$iLength = mb_strlen($sPassword);
}
else {
$iLength = strlen($sPassword);
}
$aErrors = array();
if ($iLength < PPP_MINIMUM_LENGTH) {
$aErrors[] = 'ID_PPP_MINIMUM_LENGTH';
}
if ($iLength > PPP_MAXIMUM_LENGTH) {
$aErrors[] = 'ID_PPP_MAXIMUM_LENGTH';
}
if (PPP_NUMERICAL_CHARACTER_REQUIRED == 1) {
if (preg_match_all('/[0-9]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) == 0) {
$aErrors[] = 'ID_PPP_NUMERICAL_CHARACTER_REQUIRED';
}
}
if (PPP_UPPERCASE_CHARACTER_REQUIRED == 1) {
if (preg_match_all('/[A-Z]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) == 0) {
$aErrors[] = 'ID_PPP_UPPERCASE_CHARACTER_REQUIRED';
}
}
if (PPP_SPECIAL_CHARACTER_REQUIRED == 1) {
if (preg_match_all('/[<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');
$oDates = new dates();
$fDays = $oDates->calculateDuration(date('Y-m-d H:i:s'), $sLastUpdate);
if ($fDays > (PPP_EXPIRATION_IN*24)) {
$aErrors[] = 'ID_PPP_EXPIRATION_IN';
}
}
if (PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN == 1) {
if ($iChangePasswordNextTime == 1) {
$aErrors[] = 'ID_PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN';
}
}
return $aErrors;
}
/**
* get user location
* defined by precedence plugin->ux->default
*/
public function redirectTo($usrID, $lang='')
{
$this->usrID = $usrID;
$this->lang = empty($lang) ? $this->lang : $lang;
$url = $this->_getPluginLocation();
if (empty($url)) {
$url = $this->_getUXLocation();
public function update ($aData)
{
$oConnection = Propel::getConnection( UsersPropertiesPeer::DATABASE_NAME );
try {
$oUserProperty = UsersPropertiesPeer::retrieveByPK( $aData['USR_UID'] );
if (! is_null( $oUserProperty )) {
$oUserProperty->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oUserProperty->validate()) {
$oConnection->begin();
$iResult = $oUserProperty->save();
$oConnection->commit();
return $iResult;
} else {
$sMessage = '';
$aValidationFailures = $oUserProperty->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
}
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
$urlUx = $this->_getUXSkinVariant();
if (empty($url) && !empty($urlUx)) {
$_SESSION['_defaultUserLocation'] = $url;
$url = $urlUx;
public function loadOrCreateIfNotExists ($sUserUID, $aUserProperty = array())
{
if (! $this->UserPropertyExists( $sUserUID )) {
$aUserProperty['USR_UID'] = $sUserUID;
if (! isset( $aUserProperty['USR_LAST_UPDATE_DATE'] )) {
$aUserProperty['USR_LAST_UPDATE_DATE'] = date( 'Y-m-d H:i:s' );
}
if (! isset( $aUserProperty['USR_LOGGED_NEXT_TIME'] )) {
$aUserProperty['USR_LOGGED_NEXT_TIME'] = 0;
}
$this->create( $aUserProperty );
} else {
$aUserProperty = $this->fields;
}
return $aUserProperty;
}
if (empty($url)) {
$url = $this->_getDefaultLocation();
public function validatePassword ($sPassword, $sLastUpdate, $iChangePasswordNextTime)
{
if (! defined( 'PPP_MINIMUM_LENGTH' )) {
define( 'PPP_MINIMUM_LENGTH', 5 );
}
if (! defined( 'PPP_MAXIMUM_LENGTH' )) {
define( 'PPP_MAXIMUM_LENGTH', 20 );
}
if (! defined( 'PPP_NUMERICAL_CHARACTER_REQUIRED' )) {
define( 'PPP_NUMERICAL_CHARACTER_REQUIRED', 0 );
}
if (! defined( 'PPP_UPPERCASE_CHARACTER_REQUIRED' )) {
define( 'PPP_UPPERCASE_CHARACTER_REQUIRED', 0 );
}
if (! defined( 'PPP_SPECIAL_CHARACTER_REQUIRED' )) {
define( 'PPP_SPECIAL_CHARACTER_REQUIRED', 0 );
}
if (! defined( 'PPP_EXPIRATION_IN' )) {
define( 'PPP_EXPIRATION_IN', 0 );
}
if (! defined( 'PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN' )) {
define( 'PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN', 0 );
}
if (function_exists( 'mb_strlen' )) {
$iLength = mb_strlen( $sPassword );
} else {
$iLength = strlen( $sPassword );
}
$aErrors = array ();
if ($iLength < PPP_MINIMUM_LENGTH) {
$aErrors[] = 'ID_PPP_MINIMUM_LENGTH';
}
if ($iLength > PPP_MAXIMUM_LENGTH) {
$aErrors[] = 'ID_PPP_MAXIMUM_LENGTH';
}
if (PPP_NUMERICAL_CHARACTER_REQUIRED == 1) {
if (preg_match_all( '/[0-9]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) == 0) {
$aErrors[] = 'ID_PPP_NUMERICAL_CHARACTER_REQUIRED';
}
}
if (PPP_UPPERCASE_CHARACTER_REQUIRED == 1) {
if (preg_match_all( '/[A-Z]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) == 0) {
$aErrors[] = 'ID_PPP_UPPERCASE_CHARACTER_REQUIRED';
}
}
if (PPP_SPECIAL_CHARACTER_REQUIRED == 1) {
if (preg_match_all( '/[<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' );
$oDates = new dates();
$fDays = $oDates->calculateDuration( date( 'Y-m-d H:i:s' ), $sLastUpdate );
if ($fDays > (PPP_EXPIRATION_IN * 24)) {
$aErrors[] = 'ID_PPP_EXPIRATION_IN';
}
}
if (PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN == 1) {
if ($iChangePasswordNextTime == 1) {
$aErrors[] = 'ID_PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN';
}
}
return $aErrors;
}
return $url;
}
/**
* get user location
* defined by precedence plugin->ux->default
*/
public function redirectTo ($usrID, $lang = '')
{
$this->usrID = $usrID;
$this->lang = empty( $lang ) ? $this->lang : $lang;
/**
* get user location
* defined by precedence plugin->default
* note that is getting location without User Inbox Simplified varification
*/
public function getUserLocation($usrID, $lang = 'en')
{
$this->usrID = $usrID;
$this->lang = empty($lang) ? $this->lang : $lang;
$url = $this->_getPluginLocation();
$url = $this->_getPluginLocation();
if (empty( $url )) {
$url = $this->_getUXLocation();
}
if (empty($url)) {
$url = $this->_getDefaultLocation();
$urlUx = $this->_getUXSkinVariant();
if (empty( $url ) && ! empty( $urlUx )) {
$_SESSION['_defaultUserLocation'] = $url;
$url = $urlUx;
}
if (empty( $url )) {
$url = $this->_getDefaultLocation();
}
return $url;
}
$urlUx = $this->_getUXSkinVariant();
if (!empty($urlUx)) {
$_SESSION['_defaultUserLocation'] = $url;
$url = $urlUx;
/**
* get user location
* defined by precedence plugin->default
* note that is getting location without User Inbox Simplified varification
*/
public function getUserLocation ($usrID, $lang = 'en')
{
$this->usrID = $usrID;
$this->lang = empty( $lang ) ? $this->lang : $lang;
$url = $this->_getPluginLocation();
if (empty( $url )) {
$url = $this->_getDefaultLocation();
}
$urlUx = $this->_getUXSkinVariant();
if (! empty( $urlUx )) {
$_SESSION['_defaultUserLocation'] = $url;
$url = $urlUx;
}
return $url;
}
return $url;
}
/**
* to verify if the user is using some "ux..." skin variant
* if that is the case, the redirection will change to 'main' controller
*/
public function _getUXSkinVariant ()
{
$url = '';
/**
* to verify if the user is using some "ux..." skin variant
* if that is the case, the redirection will change to 'main' controller
*/
public function _getUXSkinVariant()
{
$url = '';
if (substr( SYS_SKIN, 0, 2 ) == 'ux' && SYS_SKIN != 'uxs') {
$url = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/main';
global $RBAC;
G::loadClass( 'configuration' );
$oConf = new Configurations();
$oConf->loadConfig( $x, 'USER_PREFERENCES', '', '', $_SESSION['USER_LOGGED'], '' );
if (sizeof( $oConf->aConfig ) > 0) {
if ($oConf->aConfig['DEFAULT_MENU'] == 'PM_USERS') {
$oConf->aConfig['DEFAULT_MENU'] = 'PM_SETUP';
}
if (substr(SYS_SKIN, 0, 2) == 'ux' && SYS_SKIN != 'uxs') {
$url = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/main';
$getUrl = null;
switch ($oConf->aConfig['DEFAULT_MENU']) {
case 'PM_SETUP':
if ($RBAC->userCanAccess( 'PM_SETUP' ) == 1) {
$getUrl = 'admin';
}
break;
case 'PM_FACTORY':
if ($RBAC->userCanAccess( 'PM_FACTORY' ) == 1) {
$getUrl = 'designer';
}
break;
case 'PM_CASES':
if ($RBAC->userCanAccess( 'PM_CASES' ) == 1) {
$getUrl = 'home';
}
break;
case 'PM_USERS':
if ($RBAC->userCanAccess( 'PM_USERS' ) == 1) {
$getUrl = 'admin';
}
break;
case 'PM_DASHBOARD':
if ($RBAC->userCanAccess( 'PM_DASHBOARD' ) == 1) {
$getUrl = 'dashboard';
}
break;
}
$url = $url . (($getUrl != null) ? "?st=" . $getUrl : null);
}
}
return $url;
}
/**
* get the plugins, and check if there is redirectLogins
* if yes, then redirect goes according his Role
*/
public function _getPluginLocation ()
{
global $RBAC;
G::loadClass('configuration');
$oConf = new Configurations;
$oConf->loadConfig($x, 'USER_PREFERENCES','','',$_SESSION['USER_LOGGED'],'');
if ( sizeof($oConf->aConfig) > 0) {
$url = '';
if (class_exists( 'redirectDetail' )) {
//to do: complete the validation
if (isset( $RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE'] )) {
$userRole = $RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE'];
}
$oPluginRegistry = &PMPluginRegistry::getSingleton();
$aRedirectLogin = $oPluginRegistry->getRedirectLogins();
if (isset( $aRedirectLogin ) && is_array( $aRedirectLogin )) {
foreach ($aRedirectLogin as $key => $detail) {
if (isset( $detail->sPathMethod ) && $detail->sRoleCode == $userRole) {
$url = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/' . $detail->sPathMethod;
}
}
}
}
return $url;
}
/**
* New feature - User Experience Redirector
*
* @author Erik Amaru Ortiz <erik@colosa.com>
*/
public function _getUXLocation ()
{
require_once 'classes/model/Users.php';
$u = UsersPeer::retrieveByPK( $this->usrID );
$url = '';
$uxType = $u->getUsrUx();
$_SESSION['user_experience'] = 'NORMAL';
// find a group setting
if ($uxType == '' || $uxType == 'NORMAL') {
require_once 'classes/model/GroupUser.php';
$gu = new GroupUser();
$ugList = $gu->getAllUserGroups( $this->usrID );
foreach ($ugList as $row) {
if ($row['GRP_UX'] != 'NORMAL' && $row['GRP_UX'] != '') {
$uxType = $row['GRP_UX'];
break;
}
}
}
switch ($uxType) {
case 'SIMPLIFIED':
case 'SWITCHABLE':
case 'SINGLE':
$_SESSION['user_experience'] = $uxType;
$_SESSION['user_last_skin'] = SYS_SKIN;
$url = '/sys' . SYS_SYS . '/' . $this->lang . '/uxs/' . 'home';
break;
}
return $url;
}
/**
* get user preferences for default redirect
* verifying if it has any preferences on configurations table
*/
public function _getDefaultLocation ()
{
global $RBAC;
G::loadClass( 'configuration' );
$oConf = new Configurations();
$oConf->loadConfig( $x, 'USER_PREFERENCES', '', '', $_SESSION['USER_LOGGED'], '' );
$baseUrl = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/';
$url = '';
if (sizeof( $oConf->aConfig ) > 0) {
// this user has a configuration record
// backward compatibility, because now, we don't have user and dashboard menu.
if ($oConf->aConfig['DEFAULT_MENU'] == 'PM_USERS') {
$oConf->aConfig['DEFAULT_MENU'] = 'PM_SETUP';
}
$getUrl = null;
switch ($oConf->aConfig['DEFAULT_MENU']) {
case 'PM_SETUP':
if ($RBAC->userCanAccess('PM_SETUP') == 1) {
$getUrl = 'admin';
if ($RBAC->userCanAccess( 'PM_SETUP' ) == 1) {
$url = 'setup/main';
}
break;
case 'PM_FACTORY':
if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
$getUrl = 'designer';
if ($RBAC->userCanAccess( 'PM_FACTORY' ) == 1) {
$url = 'processes/main';
}
break;
case 'PM_CASES':
if ($RBAC->userCanAccess('PM_CASES') == 1) {
$getUrl = 'home';
if ($RBAC->userCanAccess( 'PM_CASES' ) == 1) {
$url = 'cases/main';
}
break;
case 'PM_USERS':
if ($RBAC->userCanAccess('PM_USERS') == 1) {
$getUrl = 'admin';
if ($RBAC->userCanAccess( 'PM_USERS' ) == 1) {
$url = 'setup/main';
}
break;
case 'PM_DASHBOARD':
if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
$getUrl = 'dashboard';
if ($RBAC->userCanAccess( 'PM_DASHBOARD' ) == 1) {
$url = 'dashboard/main';
}
break;
}
$url = $url . (($getUrl != null)? "?st=" . $getUrl : null);
}
}
return $url;
}
/**
* get the plugins, and check if there is redirectLogins
* if yes, then redirect goes according his Role
*/
public function _getPluginLocation()
{
global $RBAC;
$url = '';
if ( class_exists('redirectDetail')) {
//to do: complete the validation
if(isset($RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE']))
$userRole = $RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE'];
$oPluginRegistry = &PMPluginRegistry::getSingleton();
$aRedirectLogin = $oPluginRegistry->getRedirectLogins();
if (isset($aRedirectLogin) && is_array($aRedirectLogin) ) {
foreach ($aRedirectLogin as $key=>$detail) {
if (isset($detail->sPathMethod) && $detail->sRoleCode == $userRole ) {
$url = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/' . $detail->sPathMethod;
}
}
}
}
return $url;
}
/**
* New feature - User Experience Redirector
* @author Erik Amaru Ortiz <erik@colosa.com>
*/
public function _getUXLocation()
{
require_once 'classes/model/Users.php';
$u = UsersPeer::retrieveByPK($this->usrID);
$url = '';
$uxType = $u->getUsrUx();
$_SESSION['user_experience'] = 'NORMAL';
// find a group setting
if ($uxType == '' || $uxType == 'NORMAL') {
require_once 'classes/model/GroupUser.php';
$gu = new GroupUser();
$ugList = $gu->getAllUserGroups($this->usrID);
foreach ($ugList as $row) {
if ($row['GRP_UX'] != 'NORMAL' && $row['GRP_UX'] != '') {
$uxType = $row['GRP_UX'];
break;
}
}
}
switch ($uxType) {
case 'SIMPLIFIED':
case 'SWITCHABLE':
case 'SINGLE':
$_SESSION['user_experience'] = $uxType;
$_SESSION['user_last_skin'] = SYS_SKIN;
$url = '/sys' . SYS_SYS . '/' . $this->lang . '/uxs/' . 'home';
break;
}
return $url;
}
/**
* get user preferences for default redirect
* verifying if it has any preferences on configurations table
*/
public function _getDefaultLocation()
{
global $RBAC;
G::loadClass('configuration');
$oConf = new Configurations;
$oConf->loadConfig($x, 'USER_PREFERENCES','','',$_SESSION['USER_LOGGED'],'');
$baseUrl = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/';
$url = '';
if( sizeof($oConf->aConfig) > 0) { // this user has a configuration record
// backward compatibility, because now, we don't have user and dashboard menu.
if ($oConf->aConfig['DEFAULT_MENU'] == 'PM_USERS') {
$oConf->aConfig['DEFAULT_MENU'] = 'PM_SETUP';
}
switch ($oConf->aConfig['DEFAULT_MENU']) {
case 'PM_SETUP':
if ($RBAC->userCanAccess('PM_SETUP') == 1) {
$url = 'setup/main';
}
break;
case 'PM_FACTORY':
if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
$url = 'processes/main';
}
break;
case 'PM_CASES':
if ($RBAC->userCanAccess('PM_CASES') == 1) {
$url = 'cases/main';
}
break;
case 'PM_USERS':
if ($RBAC->userCanAccess('PM_USERS') == 1) {
$url = 'setup/main';
}
break;
case 'PM_DASHBOARD':
if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
$url = 'dashboard/main';
}
break;
if (empty( $url )) {
if ($RBAC->userCanAccess( 'PM_FACTORY' ) == 1) {
$url = 'processes/main';
} elseif ($RBAC->userCanAccess( 'PM_SETUP' ) == 1) {
$url = 'setup/main';
} elseif ($RBAC->userCanAccess( 'PM_CASES' ) == 1) {
$url = 'cases/main';
} elseif ($RBAC->userCanAccess( 'PM_USERS' ) == 1) {
$url = 'setup/main';
} elseif ($RBAC->userCanAccess( 'PM_DASHBOARD' ) == 1) {
$url = 'dashboard/dashboard';
} else {
$url = 'users/myInfo';
}
}
}
if (empty($url)) {
if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
$url = 'processes/main';
}
else if ($RBAC->userCanAccess('PM_SETUP') == 1) {
$url = 'setup/main';
}
else if ($RBAC->userCanAccess('PM_CASES') == 1) {
$url = 'cases/main';
}
else if ($RBAC->userCanAccess('PM_USERS') == 1) {
$url = 'setup/main';
}
else if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
$url = 'dashboard/dashboard';
}
else {
$url = 'users/myInfo';
}
return $baseUrl . $url;
}
}
// UsersProperties
return $baseUrl . $url;
}
} // UsersProperties

View File

@@ -2,432 +2,458 @@
/**
* class.pmTrSharepoint.php
*
*/
G::LoadSystem("soapNtlm");
G::LoadSystem( "soapNtlm" );
class wscaller {
class wscaller
{
private $wsdlurl;
private $soapObj;
private $client;
private $auth;
private $clientStream;
private $wsdlurl;
private $soapObj;
private $client;
private $auth;
private $clientStream;
function setAuthUser($auth) {
//print "<br>- auth Setup";
$this->auth = $auth;
}
function setwsdlurl($wsdl) {
//print "<br>- wsdl Setup";
$this->wsdlurl = $wsdl;
//var_dump($wsdl);
}
function loadSOAPClient() {
try {
// we unregister the current HTTP wrapper
stream_wrapper_unregister('http');
// we register the new HTTP wrapper
//$client = new PMServiceProviderNTLMStream($this->auth);
PMServiceProviderNTLMStream::setAuthStream($this->auth);
stream_wrapper_register('http', 'PMServiceProviderNTLMStream') or die("Failed to register protocol");
// $this->client = new PMServiceNTLMSoapClient($this->wsdlurl, array('trace' => 1, 'auth' => $this->auth));// Hugo's code
$this->client = new PMServiceNTLMSoapClient($this->wsdlurl, array('trace' => 1)); // Ankit's Code
$this->client->setAuthClient($this->auth);
return true;
} catch (Exception $e) {
echo $e;
exit;
function setAuthUser ($auth)
{
//print "<br>- auth Setup";
$this->auth = $auth;
}
}
function callWsMethod($methodName, $paramArray) {
try {
if ($methodName == 'DeleteDws' || $methodName == 'GetListCollection') {
$strResult = "";
$strResult = $this->client->$methodName($paramArray = "");
return $strResult;
} else {
$strResult = "";
$strResult = $this->client->$methodName($paramArray);
return $strResult;
}
} catch (SoapFault $fault) {
echo 'Fault code: ' . $fault->faultcode;
echo 'Fault string: ' . $fault->faultstring;
function setwsdlurl ($wsdl)
{
//print "<br>- wsdl Setup";
$this->wsdlurl = $wsdl;
//var_dump($wsdl);
}
stream_wrapper_restore('http');
}
function loadSOAPClient ()
{
try {
// we unregister the current HTTP wrapper
stream_wrapper_unregister( 'http' );
// we register the new HTTP wrapper
//$client = new PMServiceProviderNTLMStream($this->auth);
PMServiceProviderNTLMStream::setAuthStream( $this->auth );
stream_wrapper_register( 'http', 'PMServiceProviderNTLMStream' ) or die( "Failed to register protocol" );
// $this->client = new PMServiceNTLMSoapClient($this->wsdlurl, array('trace' => 1, 'auth' => $this->auth));// Hugo's code
$this->client = new PMServiceNTLMSoapClient( $this->wsdlurl, array ('trace' => 1
) ); // Ankit's Code
$this->client->setAuthClient( $this->auth );
return true;
} catch (Exception $e) {
echo $e;
exit();
}
}
function callWsMethod ($methodName, $paramArray)
{
try {
if ($methodName == 'DeleteDws' || $methodName == 'GetListCollection') {
$strResult = "";
$strResult = $this->client->$methodName( $paramArray = "" );
return $strResult;
} else {
$strResult = "";
$strResult = $this->client->$methodName( $paramArray );
return $strResult;
}
} catch (SoapFault $fault) {
echo 'Fault code: ' . $fault->faultcode;
echo 'Fault string: ' . $fault->faultstring;
}
stream_wrapper_restore( 'http' );
}
}
class DestinationUrlCollection {
public $string;
class DestinationUrlCollection
{
public $string;
}
;
class FieldInformation {
class FieldInformation
{
}
class FieldInformationCollection {
public $FieldInformation;
class FieldInformationCollection
{
public $FieldInformation;
}
class pmTrSharepointClass{
function __construct($server, $auth) {
set_include_path(
PATH_PLUGINS . 'pmTrSharepoint' . PATH_SEPARATOR .
get_include_path()
);
$this->server = $server;
$this->auth = $auth;
$this->dwsObj = new wscaller();
$this->dwsObj->setAuthUser($this->auth);
}
function createDWS($name, $users, $title, $documents) {
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl($this->server . "/_vti_bin/Dws.asmx?WSDL");
$this->dwsObj->loadSOAPClient();
$paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => '');
$methodName = 'CreateDws';
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
$xml = $result->CreateDwsResult; // in Result we get string in Xml format
$xmlNew = simplexml_load_string($xml); // used to parse string to xml
$xmlArray = @G::json_decode(@G::json_encode($xmlNew), 1); // used to convert Objects to array
$dwsUrl = $xmlArray['Url'];
return "Dws with following Url is created:$dwsUrl";
/* $newResult = $result->CreateDwsResult;
$needleStart='<Url>';
$urlStartPos = strpos($newResult, $needleStart);
$urlStart = $urlStartPos + 5;
$needleEnd='</Url>';
$urlEndPos = strpos($newResult, $needleEnd);
$length = $urlEndPos - $urlStart;
$result = substr($newResult, $urlStart, $length);
return $result; */
}
function deleteDWS($dwsname) {
//print "<br>- Method createDWS";
$url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
$this->dwsObj->setwsdlurl($url);
$this->dwsObj->loadSOAPClient();
$paramArray = null;
$methodName = 'DeleteDws';
$result = $this->dwsObj->callWsMethod($methodName, $paramArray = null);
var_dump($result);
return $result;
}
function createFolderDWS($dwsname, $dwsFolderName) {
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL");
$this->dwsObj->loadSOAPClient();
$url = "Shared Documents/$dwsFolderName";
$paramArray = array('url' => $url);
# $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => '');
$methodName = 'CreateFolder';
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
var_dump($result);
return $result;
}
function deleteFolderDWS($dwsname, $folderName) {
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL");
$this->dwsObj->loadSOAPClient();
$url = "Shared Documents/$folderName";
$paramArray = array('url' => $url);
# $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => '');
$methodName = 'DeleteFolder';
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
var_dump($result);
return $result;
}
function findDWSdoc($dwsname, $guid) {
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl($this->server . $dwsName . "/_vti_bin/Dws.asmx?WSDL");
$this->dwsObj->loadSOAPClient();
$paramArray = array('id' => '$guid');
$methodName = 'FindDwsDoc';
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
var_dump($result);
}
function getDWSData($newFileName, $dwsname, $lastUpdate) {
//print "<br>- Method getDWSData<br />";
$url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
$this->dwsObj->setwsdlurl($url);
if ($this->dwsObj->loadSOAPClient()) {
$doc = "Shared Documents";
$paramArray = array('document' => '', 'lastUpdate' => '');
$methodName = 'GetDwsData';
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
var_dump($result);
$sResult = $result->GetDwsDataResult;
/* $xmlNew = simplexml_load_string($sResult);// used to parse string to xml
$xmlArray = @G::json_decode(@G::json_encode($xmlNew),1);// used to convert Objects to array */
$serializeResult = serialize($sResult); // serializing the Array for Returning.
var_dump($serializeResult);
return $serializeResult;
} else {
return "The enter the Correct Dws Name";
}
}
function uploadDocumentDWS($dwsname, $folderName, $sourceUrl, $filename) {
//print "<br>- Method createDWS";
$url = $this->server ."/". $dwsname . "/_vti_bin/Copy.asmx?WSDL";
$this->dwsObj->setwsdlurl($url);
$this->dwsObj->loadSOAPClient();
$destUrlObj = new DestinationUrlCollection();
if ($folderName != '') {
$destUrl = $this->server . "/$dwsname/Shared%20Documents/$folderName/$filename";
} else {
$destUrl = $this->server . "/$dwsname/Shared%20Documents/$filename";
}
$destUrlObj->string = $destUrl;
$fieldInfoObj = new FieldInformation();
$fieldInfoCollObj = new FieldInformationCollection();
$fieldInfoCollObj->FieldInformation = $fieldInfoObj;
$imgfile = $sourceUrl . "/" . $filename;
$filep = fopen($imgfile, "r");
$fileLength = filesize($imgfile);
$content = fread($filep, $fileLength);
//$content = base64_encode($content);
$paramArray = array('SourceUrl' => $imgfile, 'DestinationUrls' => $destUrlObj, 'Fields' => $fieldInfoCollObj, 'Stream' => $content);
$methodName = 'CopyIntoItems';
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
var_dump($result);
$newResult = $result->Results->CopyResult->ErrorCode;
if ($newResult == 'Success') {
return "The document has been uploaded Successfully";
} else {
return "Could not Upload the Document due to some Error";
}
}
function getDWSMetaData($newFileName, $dwsname, $id) {
//print "<br>- Method createDWS";
$url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
$this->dwsObj->setwsdlurl($url);
$this->dwsObj->loadSOAPClient();
$doc = "Shared Documents/$newFileName";
$paramArray = array('document' => $doc, 'id' => '', 'minimal' => False);
$methodName = 'GetDwsMetaData';
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
$sResult = $result->GetDwsMetaDataResult;
$errorReturn = strpos($sResult, "Error");
if(isset($sResult) && !$errorReturn)
class pmTrSharepointClass
{
function __construct ($server, $auth)
{
$serializeResult = serialize($sResult); // serializing the Array for Returning.
var_dump($serializeResult);
return $serializeResult;
set_include_path( PATH_PLUGINS . 'pmTrSharepoint' . PATH_SEPARATOR . get_include_path() );
$this->server = $server;
$this->auth = $auth;
$this->dwsObj = new wscaller();
$this->dwsObj->setAuthUser( $this->auth );
}
else return $sResult;
}
function getDWSDocumentVersions($newFileName, $dwsname) {
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL");
function createDWS ($name, $users, $title, $documents)
{
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl( $this->server . "/_vti_bin/Dws.asmx?WSDL" );
$this->dwsObj->loadSOAPClient();
$this->dwsObj->loadSOAPClient();
$doc = "Shared Documents/$newFileName";
$paramArray = array('fileName' => $doc);
$paramArray = array ('name' => '','users' => '','title' => $name,'documents' => ''
);
$methodName = 'GetVersions';
$methodName = 'CreateDws';
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
var_dump($result);
return $result;
}
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
$xml = $result->CreateDwsResult; // in Result we get string in Xml format
$xmlNew = simplexml_load_string( $xml ); // used to parse string to xml
$xmlArray = @G::json_decode( @G::json_encode( $xmlNew ), 1 ); // used to convert Objects to array
$dwsUrl = $xmlArray['Url'];
return "Dws with following Url is created:$dwsUrl";
function deleteDWSDocVersion($newFileName, $dwsname, $versionNum) {
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL");
$this->dwsObj->loadSOAPClient();
$doc = "Shared Documents/$newFileName";
$paramArray = array('fileName' => $doc, 'fileVersion' => $versionNum);
$methodName = 'DeleteVersion';
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
if ($result) {
$sResult = $result->DeleteVersionResult->any;
$xmlNew = simplexml_load_string($sResult); // used to parse string to xml
$xmlArray = @G::json_decode(@G::json_encode($xmlNew), 1); // used to convert Objects to array
$versionCount = count($xmlArray['result']);
if($versionCount>1)
{
for($i=0;$i<$versionCount;$i++)
{
$version[] = $xmlArray['result'][$i]['@attributes']['version'];
}
}
else{
$version[] = $xmlArray['result']['@attributes']['version'];
}
$serializeResult = serialize($version); // serializing the Array for Returning.
var_dump($serializeResult);
return $serializeResult;
} else {
return"The given Version could not be deleted.";
/* $newResult = $result->CreateDwsResult;
$needleStart='<Url>';
$urlStartPos = strpos($newResult, $needleStart);
$urlStart = $urlStartPos + 5;
$needleEnd='</Url>';
$urlEndPos = strpos($newResult, $needleEnd);
$length = $urlEndPos - $urlStart;
$result = substr($newResult, $urlStart, $length);
return $result; */
}
}
function deleteAllDWSDocVersion($newFileName, $dwsname) {
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL");
function deleteDWS ($dwsname)
{
//print "<br>- Method createDWS";
$url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
$this->dwsObj->setwsdlurl( $url );
$this->dwsObj->loadSOAPClient();
$this->dwsObj->loadSOAPClient();
$paramArray = null;
$methodName = 'DeleteDws';
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray = null );
var_dump( $result );
return $result;
$doc = "Shared Documents/$newFileName";
$paramArray = array('fileName' => $doc);
$methodName = 'DeleteAllVersions';
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
if ($result) {
$xml = $result->DeleteAllVersionsResult->any; // in Result we get string in Xml format
$xmlNew = simplexml_load_string($xml); // used to parse string to xml
$xmlArray = @G::json_decode(@G::json_encode($xmlNew), 1); // used to convert Objects to array
$latestVersion = $xmlArray['result']['@attributes']['version'];
return "All Versions are Deleted, except the latest i.e $latestVersion";
} else {
return "The Version/ File name/ Dws Name is incorrect";
}
}
function getDWSFolderItems($dwsname, $strFolderUrl) {
$pmTrSharepointClassObj = new pmTrSharepointClass();
//print "<br>- Method getDWSFolderItems";
$url = $this->server . "/" . $dwsname . "/_vti_bin/SiteData.asmx?WSDL";
$this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/SiteData.asmx?WSDL");
function createFolderDWS ($dwsname, $dwsFolderName)
{
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL" );
$this->dwsObj->loadSOAPClient();
$this->dwsObj->loadSOAPClient();
#$doc = "Shared Documents/$newFileName";
$paramArray = array('strFolderUrl' => $strFolderUrl);
$url = "Shared Documents/$dwsFolderName";
$paramArray = array ('url' => $url
);
$methodName = 'EnumerateFolder';
# $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => '');
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
//$newResult = $result->vUrls->_sFPUrl->Url;
if (isset($result->vUrls->_sFPUrl->Url)) {
$returnContent = $pmTrSharepointClassObj->getFolderUrlContent($result->vUrls->_sFPUrl->Url);
$serializeResult = serialize($returnContent);
return $serializeResult;
} else if (isset($result->vUrls->_sFPUrl)) {
$itemCount = count($result->vUrls->_sFPUrl);
for ($i = 0; $i < $itemCount; $i++) {
$aObjects = $result->vUrls->_sFPUrl[$i]->IsFolder;
//$booleanStatus = $aObjects[$i]->IsFolder;
if ($aObjects) {
$listArr = $result->vUrls->_sFPUrl[$i]->Url;
$returnContent[] = $pmTrSharepointClassObj->getFolderUrlContent($listArr) . "(Is a Folder)";
$methodName = 'CreateFolder';
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
var_dump( $result );
return $result;
}
function deleteFolderDWS ($dwsname, $folderName)
{
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL" );
$this->dwsObj->loadSOAPClient();
$url = "Shared Documents/$folderName";
$paramArray = array ('url' => $url
);
# $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => '');
$methodName = 'DeleteFolder';
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
var_dump( $result );
return $result;
}
function findDWSdoc ($dwsname, $guid)
{
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl( $this->server . $dwsName . "/_vti_bin/Dws.asmx?WSDL" );
$this->dwsObj->loadSOAPClient();
$paramArray = array ('id' => '$guid'
);
$methodName = 'FindDwsDoc';
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
var_dump( $result );
}
function getDWSData ($newFileName, $dwsname, $lastUpdate)
{
//print "<br>- Method getDWSData<br />";
$url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
$this->dwsObj->setwsdlurl( $url );
if ($this->dwsObj->loadSOAPClient()) {
$doc = "Shared Documents";
$paramArray = array ('document' => '','lastUpdate' => ''
);
$methodName = 'GetDwsData';
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
var_dump( $result );
$sResult = $result->GetDwsDataResult;
/* $xmlNew = simplexml_load_string($sResult);// used to parse string to xml
$xmlArray = @G::json_decode(@G::json_encode($xmlNew),1);// used to convert Objects to array */
$serializeResult = serialize( $sResult ); // serializing the Array for Returning.
var_dump( $serializeResult );
return $serializeResult;
} else {
$listArr = $result->vUrls->_sFPUrl[$i]->Url;
$returnContent[] = $pmTrSharepointClassObj->getFolderUrlContent($listArr) . "(Is a File)";
return "The enter the Correct Dws Name";
}
}
$serializeResult = serialize($returnContent);
return $serializeResult;
}
return "There is some error";
}
function downloadDocumentDWS($dwsname, $fileName, $fileLocation) {
//print "<br>- Method createDWS";
$url = $this->server . "/" . $dwsname . "/_vti_bin/Copy.asmx?WSDL";
$this->dwsObj->setwsdlurl($url);
function uploadDocumentDWS ($dwsname, $folderName, $sourceUrl, $filename)
{
//print "<br>- Method createDWS";
$url = $this->server . "/" . $dwsname . "/_vti_bin/Copy.asmx?WSDL";
$this->dwsObj->setwsdlurl( $url );
$this->dwsObj->loadSOAPClient();
$this->dwsObj->loadSOAPClient();
$destUrlObj = new DestinationUrlCollection();
if ($folderName != '') {
$destUrl = $this->server . "/$dwsname/Shared%20Documents/$folderName/$filename";
} else {
$destUrl = $this->server . "/$dwsname/Shared%20Documents/$filename";
}
$destUrlObj->string = $destUrl;
$CompleteUrl = $this->server . "/" . $dwsname . "/Shared Documents/" . $fileName;
$paramArray = array('Url' => $CompleteUrl);
$fieldInfoObj = new FieldInformation();
$methodName = 'GetItem';
$fieldInfoCollObj = new FieldInformationCollection();
$fieldInfoCollObj->FieldInformation = $fieldInfoObj;
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
$newResult = $result->Stream;
$imgfile = $sourceUrl . "/" . $filename;
$filep = fopen( $imgfile, "r" );
$fileLength = filesize( $imgfile );
$content = fread( $filep, $fileLength );
//$content = base64_encode($content);
//$latestResult = base64_decode($newResult);
/**
* In the Below line of code, we are coping the files at our local Directory using the php file methods.
* */
$imgfile = $fileLocation . "/" . $fileName;
$filep = fopen($imgfile, 'w');
//$content = fwrite($filep, $latestResult);
$content = fwrite($filep, $newResult);
return $content;
}
function getFolderUrlContent($newResult) {
$needleStart = '/';
$needleCount = substr_count($newResult, $needleStart);
$urlStartPos = strpos($newResult, $needleStart);
$urlStartPos++;
if ($needleCount == '2') {
$newResultPos = strpos($newResult, $needleStart, $urlStartPos);
$newResultPos++;
$actualResult = substr($newResult, $newResultPos);
return $actualResult;
$paramArray = array ('SourceUrl' => $imgfile,'DestinationUrls' => $destUrlObj,'Fields' => $fieldInfoCollObj,'Stream' => $content
);
$methodName = 'CopyIntoItems';
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
var_dump( $result );
$newResult = $result->Results->CopyResult->ErrorCode;
if ($newResult == 'Success') {
return "The document has been uploaded Successfully";
} else {
return "Could not Upload the Document due to some Error";
}
}
else{
$actualResult = substr($newResult,$urlStartPos);
function getDWSMetaData ($newFileName, $dwsname, $id)
{
//print "<br>- Method createDWS";
$url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
$this->dwsObj->setwsdlurl( $url );
$this->dwsObj->loadSOAPClient();
$doc = "Shared Documents/$newFileName";
$paramArray = array ('document' => $doc,'id' => '','minimal' => false
);
$methodName = 'GetDwsMetaData';
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
$sResult = $result->GetDwsMetaDataResult;
$errorReturn = strpos( $sResult, "Error" );
if (isset( $sResult ) && ! $errorReturn) {
$serializeResult = serialize( $sResult ); // serializing the Array for Returning.
var_dump( $serializeResult );
return $serializeResult;
} else {
return $sResult;
}
}
function getDWSDocumentVersions ($newFileName, $dwsname)
{
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL" );
$this->dwsObj->loadSOAPClient();
$doc = "Shared Documents/$newFileName";
$paramArray = array ('fileName' => $doc
);
$methodName = 'GetVersions';
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
var_dump( $result );
return $result;
}
function deleteDWSDocVersion ($newFileName, $dwsname, $versionNum)
{
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL" );
$this->dwsObj->loadSOAPClient();
$doc = "Shared Documents/$newFileName";
$paramArray = array ('fileName' => $doc,'fileVersion' => $versionNum
);
$methodName = 'DeleteVersion';
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
if ($result) {
$sResult = $result->DeleteVersionResult->any;
$xmlNew = simplexml_load_string( $sResult ); // used to parse string to xml
$xmlArray = @G::json_decode( @G::json_encode( $xmlNew ), 1 ); // used to convert Objects to array
$versionCount = count( $xmlArray['result'] );
if ($versionCount > 1) {
for ($i = 0; $i < $versionCount; $i ++) {
$version[] = $xmlArray['result'][$i]['@attributes']['version'];
}
} else {
$version[] = $xmlArray['result']['@attributes']['version'];
}
$serializeResult = serialize( $version ); // serializing the Array for Returning.
var_dump( $serializeResult );
return $serializeResult;
} else {
return "The given Version could not be deleted.";
}
}
function deleteAllDWSDocVersion ($newFileName, $dwsname)
{
//print "<br>- Method createDWS";
$this->dwsObj->setwsdlurl( $this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL" );
$this->dwsObj->loadSOAPClient();
$doc = "Shared Documents/$newFileName";
$paramArray = array ('fileName' => $doc
);
$methodName = 'DeleteAllVersions';
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
if ($result) {
$xml = $result->DeleteAllVersionsResult->any; // in Result we get string in Xml format
$xmlNew = simplexml_load_string( $xml ); // used to parse string to xml
$xmlArray = @G::json_decode( @G::json_encode( $xmlNew ), 1 ); // used to convert Objects to array
$latestVersion = $xmlArray['result']['@attributes']['version'];
return "All Versions are Deleted, except the latest i.e $latestVersion";
} else {
return "The Version/ File name/ Dws Name is incorrect";
}
}
function getDWSFolderItems ($dwsname, $strFolderUrl)
{
$pmTrSharepointClassObj = new pmTrSharepointClass();
//print "<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->loadSOAPClient();
#$doc = "Shared Documents/$newFileName";
$paramArray = array ('strFolderUrl' => $strFolderUrl
);
$methodName = 'EnumerateFolder';
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
//$newResult = $result->vUrls->_sFPUrl->Url;
if (isset( $result->vUrls->_sFPUrl->Url )) {
$returnContent = $pmTrSharepointClassObj->getFolderUrlContent( $result->vUrls->_sFPUrl->Url );
$serializeResult = serialize( $returnContent );
return $serializeResult;
} elseif (isset( $result->vUrls->_sFPUrl )) {
$itemCount = count( $result->vUrls->_sFPUrl );
for ($i = 0; $i < $itemCount; $i ++) {
$aObjects = $result->vUrls->_sFPUrl[$i]->IsFolder;
//$booleanStatus = $aObjects[$i]->IsFolder;
if ($aObjects) {
$listArr = $result->vUrls->_sFPUrl[$i]->Url;
$returnContent[] = $pmTrSharepointClassObj->getFolderUrlContent( $listArr ) . "(Is a Folder)";
} else {
$listArr = $result->vUrls->_sFPUrl[$i]->Url;
$returnContent[] = $pmTrSharepointClassObj->getFolderUrlContent( $listArr ) . "(Is a File)";
}
}
$serializeResult = serialize( $returnContent );
return $serializeResult;
}
return "There is some error";
}
function downloadDocumentDWS ($dwsname, $fileName, $fileLocation)
{
//print "<br>- Method createDWS";
$url = $this->server . "/" . $dwsname . "/_vti_bin/Copy.asmx?WSDL";
$this->dwsObj->setwsdlurl( $url );
$this->dwsObj->loadSOAPClient();
$CompleteUrl = $this->server . "/" . $dwsname . "/Shared Documents/" . $fileName;
$paramArray = array ('Url' => $CompleteUrl
);
$methodName = 'GetItem';
$result = $this->dwsObj->callWsMethod( $methodName, $paramArray );
$newResult = $result->Stream;
//$latestResult = base64_decode($newResult);
/**
* In the Below line of code, we are coping the files at our local Directory using the php file methods.
*/
$imgfile = $fileLocation . "/" . $fileName;
$filep = fopen( $imgfile, 'w' );
//$content = fwrite($filep, $latestResult);
$content = fwrite( $filep, $newResult );
return $content;
}
function getFolderUrlContent ($newResult)
{
$needleStart = '/';
$needleCount = substr_count( $newResult, $needleStart );
$urlStartPos = strpos( $newResult, $needleStart );
$urlStartPos ++;
if ($needleCount == '2') {
$newResultPos = strpos( $newResult, $needleStart, $urlStartPos );
$newResultPos ++;
$actualResult = substr( $newResult, $newResultPos );
return $actualResult;
} else {
$actualResult = substr( $newResult, $urlStartPos );
return $actualResult;
}
}
}
}
}