Merge pull request #836 from Jennydmz/master
CODE STYLE, checking in detail (PART 2)
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* InputDocument.php
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
@@ -13,15 +14,15 @@
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseInputDocument.php';
|
||||
@@ -33,288 +34,283 @@ 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 input directory.
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
class InputDocument extends BaseInputDocument {
|
||||
class InputDocument extends BaseInputDocument
|
||||
{
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $inp_doc_title = '';
|
||||
/**
|
||||
* This value goes in the content table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $inp_doc_title = '';
|
||||
|
||||
/**
|
||||
* This value goes in the content table
|
||||
* @var string
|
||||
*/
|
||||
protected $inp_doc_description = '';
|
||||
/**
|
||||
* This value goes in the content table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $inp_doc_description = '';
|
||||
|
||||
/*
|
||||
* Load the application document registry
|
||||
* @param string $sAppDocUid
|
||||
* @return variant
|
||||
*/
|
||||
public function load($sInpDocUid)
|
||||
{
|
||||
try {
|
||||
$oInputDocument = InputDocumentPeer::retrieveByPK($sInpDocUid);
|
||||
if (!is_null($oInputDocument))
|
||||
{
|
||||
$aFields = $oInputDocument->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$aFields['INP_DOC_TITLE'] = $oInputDocument->getInpDocTitle();
|
||||
$aFields['INP_DOC_DESCRIPTION'] = $oInputDocument->getInpDocDescription();
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function getByUid($sInpDocUid)
|
||||
{
|
||||
try {
|
||||
$oInputDocument = InputDocumentPeer::retrieveByPK($sInpDocUid);
|
||||
if( is_null($oInputDocument))
|
||||
return false;
|
||||
|
||||
$aFields = $oInputDocument->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$aFields['INP_DOC_TITLE'] = $oInputDocument->getInpDocTitle();
|
||||
$aFields['INP_DOC_DESCRIPTION'] = $oInputDocument->getInpDocDescription();
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
return $aFields;
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function create($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(InputDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
if ( isset ( $aData['INP_DOC_UID'] ) && $aData['INP_DOC_UID']== '' )
|
||||
unset ( $aData['INP_DOC_UID'] );
|
||||
if ( !isset ( $aData['INP_DOC_UID'] ) )
|
||||
$aData['INP_DOC_UID'] = G::generateUniqueID();
|
||||
$oInputDocument = new InputDocument();
|
||||
$oInputDocument->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oInputDocument->validate()) {
|
||||
$oConnection->begin();
|
||||
if (isset($aData['INP_DOC_TITLE'])) {
|
||||
$oInputDocument->setInpDocTitle($aData['INP_DOC_TITLE']);
|
||||
/*
|
||||
* Load the application document registry
|
||||
* @param string $sAppDocUid
|
||||
* @return variant
|
||||
*/
|
||||
public function load ($sInpDocUid)
|
||||
{
|
||||
try {
|
||||
$oInputDocument = InputDocumentPeer::retrieveByPK( $sInpDocUid );
|
||||
if (! is_null( $oInputDocument )) {
|
||||
$aFields = $oInputDocument->toArray( BasePeer::TYPE_FIELDNAME );
|
||||
$aFields['INP_DOC_TITLE'] = $oInputDocument->getInpDocTitle();
|
||||
$aFields['INP_DOC_DESCRIPTION'] = $oInputDocument->getInpDocDescription();
|
||||
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
|
||||
return $aFields;
|
||||
} else {
|
||||
throw (new Exception( 'This row doesn\'t exist!' ));
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
if (isset($aData['INP_DOC_DESCRIPTION'])) {
|
||||
$oInputDocument->setInpDocDescription($aData['INP_DOC_DESCRIPTION']);
|
||||
}
|
||||
|
||||
public function getByUid ($sInpDocUid)
|
||||
{
|
||||
try {
|
||||
$oInputDocument = InputDocumentPeer::retrieveByPK( $sInpDocUid );
|
||||
if (is_null( $oInputDocument )) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$aFields = $oInputDocument->toArray( BasePeer::TYPE_FIELDNAME );
|
||||
$aFields['INP_DOC_TITLE'] = $oInputDocument->getInpDocTitle();
|
||||
$aFields['INP_DOC_DESCRIPTION'] = $oInputDocument->getInpDocDescription();
|
||||
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
|
||||
return $aFields;
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
$iResult = $oInputDocument->save();
|
||||
$oConnection->commit();
|
||||
return $aData['INP_DOC_UID'];
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oInputDocument->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the application document registry
|
||||
*
|
||||
* @param array $aData
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function create ($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection( InputDocumentPeer::DATABASE_NAME );
|
||||
try {
|
||||
if (isset( $aData['INP_DOC_UID'] ) && $aData['INP_DOC_UID'] == '') {
|
||||
unset( $aData['INP_DOC_UID'] );
|
||||
}
|
||||
if (! isset( $aData['INP_DOC_UID'] )) {
|
||||
$aData['INP_DOC_UID'] = G::generateUniqueID();
|
||||
}
|
||||
$oInputDocument = new InputDocument();
|
||||
$oInputDocument->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oInputDocument->validate()) {
|
||||
$oConnection->begin();
|
||||
if (isset( $aData['INP_DOC_TITLE'] )) {
|
||||
$oInputDocument->setInpDocTitle( $aData['INP_DOC_TITLE'] );
|
||||
}
|
||||
if (isset( $aData['INP_DOC_DESCRIPTION'] )) {
|
||||
$oInputDocument->setInpDocDescription( $aData['INP_DOC_DESCRIPTION'] );
|
||||
}
|
||||
$iResult = $oInputDocument->save();
|
||||
$oConnection->commit();
|
||||
return $aData['INP_DOC_UID'];
|
||||
} else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oInputDocument->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);
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />'.$sMessage));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function update($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection(InputDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oInputDocument = InputDocumentPeer::retrieveByPK($aData['INP_DOC_UID']);
|
||||
if (!is_null($oInputDocument))
|
||||
{
|
||||
$oInputDocument->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($oInputDocument->validate()) {
|
||||
$oConnection->begin();
|
||||
if (isset($aData['INP_DOC_TITLE']))
|
||||
{
|
||||
$oInputDocument->setInpDocTitle($aData['INP_DOC_TITLE']);
|
||||
}
|
||||
if (isset($aData['INP_DOC_DESCRIPTION']))
|
||||
{
|
||||
$oInputDocument->setInpDocDescription($aData['INP_DOC_DESCRIPTION']);
|
||||
}
|
||||
$iResult = $oInputDocument->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
/**
|
||||
* Update the application document registry
|
||||
*
|
||||
* @param array $aData
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function update ($aData)
|
||||
{
|
||||
$oConnection = Propel::getConnection( InputDocumentPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oInputDocument = InputDocumentPeer::retrieveByPK( $aData['INP_DOC_UID'] );
|
||||
if (! is_null( $oInputDocument )) {
|
||||
$oInputDocument->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oInputDocument->validate()) {
|
||||
$oConnection->begin();
|
||||
if (isset( $aData['INP_DOC_TITLE'] )) {
|
||||
$oInputDocument->setInpDocTitle( $aData['INP_DOC_TITLE'] );
|
||||
}
|
||||
if (isset( $aData['INP_DOC_DESCRIPTION'] )) {
|
||||
$oInputDocument->setInpDocDescription( $aData['INP_DOC_DESCRIPTION'] );
|
||||
}
|
||||
$iResult = $oInputDocument->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
} else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oInputDocument->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);
|
||||
}
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oInputDocument->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be updated!<br />'.$sMessage));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the application document registry
|
||||
*
|
||||
* @param array $aData
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function remove ($sInpDocUid)
|
||||
{
|
||||
$oConnection = Propel::getConnection( InputDocumentPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oInputDocument = InputDocumentPeer::retrieveByPK( $sInpDocUid );
|
||||
if (! is_null( $oInputDocument )) {
|
||||
$oConnection->begin();
|
||||
Content::removeContent( 'INP_DOC_TITLE', '', $oInputDocument->getInpDocUid() );
|
||||
Content::removeContent( 'INP_DOC_DESCRIPTION', '', $oInputDocument->getInpDocUid() );
|
||||
$iResult = $oInputDocument->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
} else {
|
||||
throw (new Exception( 'This row doesn\'t exist!' ));
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the application document registry
|
||||
* @param array $aData
|
||||
* @return string
|
||||
**/
|
||||
public function remove($sInpDocUid)
|
||||
{
|
||||
$oConnection = Propel::getConnection(InputDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oInputDocument = InputDocumentPeer::retrieveByPK($sInpDocUid);
|
||||
if (!is_null($oInputDocument))
|
||||
{
|
||||
$oConnection->begin();
|
||||
Content::removeContent('INP_DOC_TITLE', '', $oInputDocument->getInpDocUid());
|
||||
Content::removeContent('INP_DOC_DESCRIPTION', '', $oInputDocument->getInpDocUid());
|
||||
$iResult = $oInputDocument->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
/**
|
||||
* Get the [inp_doc_title] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInpDocTitle ()
|
||||
{
|
||||
if ($this->inp_doc_title == '') {
|
||||
try {
|
||||
$this->inp_doc_title = Content::load( 'INP_DOC_TITLE', '', $this->getInpDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') );
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
return $this->inp_doc_title;
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [inp_doc_title] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getInpDocTitle()
|
||||
{
|
||||
if ($this->inp_doc_title == '') {
|
||||
try {
|
||||
$this->inp_doc_title = Content::load('INP_DOC_TITLE', '', $this->getInpDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'));
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
return $this->inp_doc_title;
|
||||
}
|
||||
/**
|
||||
* Set the [inp_doc_title] column value.
|
||||
*
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setInpDocTitle ($sValue)
|
||||
{
|
||||
if ($sValue !== null && ! is_string( $sValue )) {
|
||||
$sValue = (string) $sValue;
|
||||
}
|
||||
if ($this->inp_doc_title !== $sValue || $sValue === '') {
|
||||
try {
|
||||
$this->inp_doc_title = $sValue;
|
||||
|
||||
/**
|
||||
* Set the [inp_doc_title] column value.
|
||||
*
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setInpDocTitle($sValue)
|
||||
{
|
||||
if ($sValue !== null && !is_string($sValue)) {
|
||||
$sValue = (string)$sValue;
|
||||
$iResult = Content::addContent( 'INP_DOC_TITLE', '', $this->getInpDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->inp_doc_title );
|
||||
} catch (Exception $oError) {
|
||||
$this->inp_doc_title = '';
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->inp_doc_title !== $sValue || $sValue === '') {
|
||||
try {
|
||||
$this->inp_doc_title = $sValue;
|
||||
|
||||
$iResult = Content::addContent('INP_DOC_TITLE', '', $this->getInpDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->inp_doc_title);
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$this->inp_doc_title = '';
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [inp_doc_comment] column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getInpDocDescription()
|
||||
{
|
||||
if ($this->inp_doc_description == '') {
|
||||
try {
|
||||
$this->inp_doc_description = Content::load('INP_DOC_DESCRIPTION', '', $this->getInpDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'));
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
/**
|
||||
* Get the [inp_doc_comment] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInpDocDescription ()
|
||||
{
|
||||
if ($this->inp_doc_description == '') {
|
||||
try {
|
||||
$this->inp_doc_description = Content::load( 'INP_DOC_DESCRIPTION', '', $this->getInpDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en') );
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
return $this->inp_doc_description;
|
||||
}
|
||||
return $this->inp_doc_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [inp_doc_comment] column value.
|
||||
*
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setInpDocDescription($sValue)
|
||||
{
|
||||
if ($sValue !== null && !is_string($sValue)) {
|
||||
$sValue = (string)$sValue;
|
||||
}
|
||||
if ($this->inp_doc_description !== $sValue || $sValue === '') {
|
||||
try {
|
||||
$this->inp_doc_description = $sValue;
|
||||
|
||||
$iResult = Content::addContent('INP_DOC_DESCRIPTION', '', $this->getInpDocUid(), (defined('SYS_LANG') ? SYS_LANG : 'en'), $this->inp_doc_description);
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$this->inp_doc_description = '';
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the [inp_doc_comment] column value.
|
||||
*
|
||||
* @param string $sValue new value
|
||||
* @return void
|
||||
*/
|
||||
public function setInpDocDescription ($sValue)
|
||||
{
|
||||
if ($sValue !== null && ! is_string( $sValue )) {
|
||||
$sValue = (string) $sValue;
|
||||
}
|
||||
if ($this->inp_doc_description !== $sValue || $sValue === '') {
|
||||
try {
|
||||
$this->inp_doc_description = $sValue;
|
||||
|
||||
/**
|
||||
* verify if Input row specified in [DynUid] exists.
|
||||
*
|
||||
* @param string $sUid the uid of the Prolication
|
||||
*/
|
||||
|
||||
function InputExists ( $sUid ) {
|
||||
$con = Propel::getConnection(InputDocumentPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oObj = InputDocumentPeer::retrieveByPk( $sUid );
|
||||
if (is_object($oObj) && get_class ($oObj) == 'InputDocument' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
$iResult = Content::addContent( 'INP_DOC_DESCRIPTION', '', $this->getInpDocUid(), (defined( 'SYS_LANG' ) ? SYS_LANG : 'en'), $this->inp_doc_description );
|
||||
} catch (Exception $oError) {
|
||||
$this->inp_doc_description = '';
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
} // InputDocument
|
||||
/**
|
||||
* verify if Input row specified in [DynUid] exists.
|
||||
*
|
||||
* @param string $sUid the uid of the Prolication
|
||||
*/
|
||||
|
||||
function InputExists ($sUid)
|
||||
{
|
||||
$con = Propel::getConnection( InputDocumentPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oObj = InputDocumentPeer::retrieveByPk( $sUid );
|
||||
if (is_object( $oObj ) && get_class( $oObj ) == 'InputDocument') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
// InputDocument
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* StepTrigger.php
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
@@ -13,313 +14,293 @@
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/om/BaseStepTrigger.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'STEP_TRIGGER' 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 StepTrigger extends BaseStepTrigger {
|
||||
function create($aData)
|
||||
{
|
||||
$con = Propel::getConnection(StepTriggerPeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
//delete old StepTrigger Rows, because is not safe insert previous verify old rows.
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(StepTriggerPeer::STEP_UID, $aData['STEP_UID'] );
|
||||
$criteria->add(StepTriggerPeer::TAS_UID, $aData['TAS_UID'] );
|
||||
$criteria->add(StepTriggerPeer::TRI_UID, $aData['TRI_UID'] );
|
||||
$criteria->add(StepTriggerPeer::ST_TYPE, $aData['ST_TYPE'] );
|
||||
$objects = StepTriggerPeer::doSelect($criteria, $con);
|
||||
$con->begin();
|
||||
foreach($objects as $row) {
|
||||
$this->remove($row->getStepUid(), $row->getTasUid(), $row->getTriUid(), $row->getStType() );
|
||||
}
|
||||
$con->commit();
|
||||
|
||||
$con->begin();
|
||||
$this->setStepUid($aData['STEP_UID']);
|
||||
$this->setTasUid($aData['TAS_UID']);
|
||||
$this->setTriUid($aData['TRI_UID']);
|
||||
$this->setStType($aData['ST_TYPE']);
|
||||
$this->setStCondition("");
|
||||
$this->setStPosition("");
|
||||
if($this->validate())
|
||||
{
|
||||
$result=$this->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$con->rollback();
|
||||
throw( new Exception("Failed Validation in class ".get_class($this)."."));
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
public function load($StepUid, $TasUid, $TriUid, $StType)
|
||||
{
|
||||
try {
|
||||
$oRow = StepTriggerPeer::retrieveByPK( $StepUid, $TasUid, $TriUid, $StType );
|
||||
if (!is_null($oRow))
|
||||
{
|
||||
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$StepUid, $TasUid, $TriUid, $StType' in table StepTrigger doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
function update($fields)
|
||||
{
|
||||
$con = Propel::getConnection(StepTriggerPeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
$con->begin();
|
||||
$this->load($fields['STEP_UID'],$fields['TAS_UID'],$fields['TRI_UID'],$fields['ST_TYPE']);
|
||||
$this->fromArray($fields,BasePeer::TYPE_FIELDNAME);
|
||||
if($this->validate())
|
||||
{
|
||||
$result=$this->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$con->rollback();
|
||||
throw(new Exception("Failed Validation in class ".get_class($this)."."));
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
function remove($StepUid, $TasUid, $TriUid, $StType)
|
||||
{
|
||||
$oConnection = Propel::getConnection(StepTriggerPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oStepTrigger = StepTriggerPeer::retrieveByPK($StepUid, $TasUid, $TriUid, $StType);
|
||||
if (!is_null($oStepTrigger))
|
||||
{
|
||||
$oConnection->begin();
|
||||
$iResult = $oStepTrigger->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '$StepUid, $TasUid, $TriUid, $StType' in table StepTrigger doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function stepTriggerExists ($StepUid, $TasUid, $TriUid, $StType) {
|
||||
$con = Propel::getConnection(StepTriggerPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oObj = StepTriggerPeer::retrieveByPk($StepUid, $TasUid, $TriUid, $StType);
|
||||
if (is_object($oObj) && get_class ($oObj) == 'StepTrigger' ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function removeTrigger($TriUid)
|
||||
{
|
||||
$con = Propel::getConnection(StepTriggerPeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
//$criteria->add(StepTriggerPeer::STEP_UID, $step_uid);
|
||||
//$criteria->add(StepTriggerPeer::TAS_UID, $tas_uid);
|
||||
$criteria->add(StepTriggerPeer::TRI_UID, $TriUid);
|
||||
//$criteria->add(StepTriggerPeer::ST_TYPE, $st_type);
|
||||
$objects = StepTriggerPeer::doSelect($criteria, $con);
|
||||
$con->begin();
|
||||
foreach($objects as $v)
|
||||
{
|
||||
$this->remove($v->getStepUid,$v->getTasUid,$v->getTriUid,$v->getStType);
|
||||
}
|
||||
$con->commit();
|
||||
return count($objects);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
function getNextPosition($sStepUID, $sType) {
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn('(COUNT(*) + 1) AS POSITION');
|
||||
$oCriteria->add(StepTriggerPeer::STEP_UID, $sStepUID);
|
||||
$oCriteria->add(StepTriggerPeer::ST_TYPE, $sType);
|
||||
$oDataset = StepTriggerPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
return (int)$aRow['POSITION'];
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
function reOrder($sStepUID, $sTaskUID, $sType, $iPosition) {
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(StepTriggerPeer::STEP_UID, $sStepUID);
|
||||
$oCriteria->add(StepTriggerPeer::TAS_UID, $sTaskUID);
|
||||
$oCriteria->add(StepTriggerPeer::ST_TYPE, $sType);
|
||||
$oCriteria->add(StepTriggerPeer::ST_POSITION, $iPosition, '>');
|
||||
$oDataset = StepTriggerPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oStep = StepTriggerPeer::retrieveByPK($aRow['STEP_UID'], $aRow['TAS_UID'], $aRow['TRI_UID'], $aRow['ST_TYPE']);
|
||||
$oStep->setStPosition(($aRow['ST_POSITION']) - 1);
|
||||
$oStep->save();
|
||||
$oDataset->next();
|
||||
}
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
function up($sStepUID = '', $sTaskUID = '', $sTriggerUID = '', $sType = '', $iPosition = 0) {
|
||||
try {
|
||||
if ($iPosition > 1) {
|
||||
$oCriteria1 = new Criteria('workflow');
|
||||
$oCriteria1->add(StepTriggerPeer::ST_POSITION, $iPosition);
|
||||
$oCriteria2 = new Criteria('workflow');
|
||||
$oCriteria2->add(StepTriggerPeer::STEP_UID, $sStepUID);
|
||||
$oCriteria2->add(StepTriggerPeer::TAS_UID, $sTaskUID);
|
||||
$oCriteria2->add(StepTriggerPeer::ST_TYPE, $sType);
|
||||
$oCriteria2->add(StepTriggerPeer::ST_POSITION, ($iPosition - 1));
|
||||
BasePeer::doUpdate($oCriteria2, $oCriteria1, Propel::getConnection('workflow'));
|
||||
$oCriteria1 = new Criteria('workflow');
|
||||
$oCriteria1->add(StepTriggerPeer::ST_POSITION, ($iPosition - 1));
|
||||
$oCriteria2 = new Criteria('workflow');
|
||||
$oCriteria2->add(StepTriggerPeer::STEP_UID, $sStepUID);
|
||||
$oCriteria2->add(StepTriggerPeer::TAS_UID, $sTaskUID);
|
||||
$oCriteria2->add(StepTriggerPeer::TRI_UID, $sTriggerUID);
|
||||
$oCriteria2->add(StepTriggerPeer::ST_TYPE, $sType);
|
||||
BasePeer::doUpdate($oCriteria2, $oCriteria1, Propel::getConnection('workflow'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
class StepTrigger extends BaseStepTrigger
|
||||
{
|
||||
|
||||
function down($sStepUID = '', $sTaskUID = '', $sTriggerUID = '', $sType = '', $iPosition = 0) {
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn('COUNT(*) AS MAX_POSITION');
|
||||
$oCriteria->add(StepTriggerPeer::STEP_UID, $sStepUID);
|
||||
$oCriteria->add(StepTriggerPeer::TAS_UID, $sTaskUID);
|
||||
$oCriteria->add(StepTriggerPeer::ST_TYPE, $sType);
|
||||
$oDataset = StepTriggerPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
if ($iPosition < (int)$aRow['MAX_POSITION']) {
|
||||
$oCriteria1 = new Criteria('workflow');
|
||||
$oCriteria1->add(StepTriggerPeer::ST_POSITION, $iPosition);
|
||||
$oCriteria2 = new Criteria('workflow');
|
||||
$oCriteria2->add(StepTriggerPeer::STEP_UID, $sStepUID);
|
||||
$oCriteria2->add(StepTriggerPeer::TAS_UID, $sTaskUID);
|
||||
$oCriteria2->add(StepTriggerPeer::ST_TYPE, $sType);
|
||||
$oCriteria2->add(StepTriggerPeer::ST_POSITION, ($iPosition + 1));
|
||||
BasePeer::doUpdate($oCriteria2, $oCriteria1, Propel::getConnection('workflow'));
|
||||
$oCriteria1 = new Criteria('workflow');
|
||||
$oCriteria1->add(StepTriggerPeer::ST_POSITION, ($iPosition + 1));
|
||||
$oCriteria2 = new Criteria('workflow');
|
||||
$oCriteria2->add(StepTriggerPeer::STEP_UID, $sStepUID);
|
||||
$oCriteria2->add(StepTriggerPeer::TAS_UID, $sTaskUID);
|
||||
$oCriteria2->add(StepTriggerPeer::TRI_UID, $sTriggerUID);
|
||||
$oCriteria2->add(StepTriggerPeer::ST_TYPE, $sType);
|
||||
BasePeer::doUpdate($oCriteria2, $oCriteria1, Propel::getConnection('workflow'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
|
||||
function createRow($aData)
|
||||
{
|
||||
$con = Propel::getConnection(StepTriggerPeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
$con->begin();
|
||||
$this->fromArray($aData,BasePeer::TYPE_FIELDNAME);
|
||||
if($this->validate())
|
||||
{
|
||||
$this->setStepUid($aData['STEP_UID']);
|
||||
$this->setTasUid($aData['TAS_UID']);
|
||||
$this->setTriUid($aData['TRI_UID']);
|
||||
$this->setStType($aData['ST_TYPE']);
|
||||
$this->setStCondition($aData['ST_CONDITION']);
|
||||
$this->setStPosition($aData['ST_POSITION']);
|
||||
|
||||
$result=$this->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$con->rollback();
|
||||
throw( new Exception("Failed Validation in class ".get_class($this)."."));
|
||||
$e->aValidationFailures=$this->getValidationFailures();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
function create ($aData)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
$con = Propel::getConnection( StepTriggerPeer::DATABASE_NAME );
|
||||
try {
|
||||
//delete old StepTrigger Rows, because is not safe insert previous verify old rows.
|
||||
$criteria = new Criteria();
|
||||
$criteria->add( StepTriggerPeer::STEP_UID, $aData['STEP_UID'] );
|
||||
$criteria->add( StepTriggerPeer::TAS_UID, $aData['TAS_UID'] );
|
||||
$criteria->add( StepTriggerPeer::TRI_UID, $aData['TRI_UID'] );
|
||||
$criteria->add( StepTriggerPeer::ST_TYPE, $aData['ST_TYPE'] );
|
||||
$objects = StepTriggerPeer::doSelect( $criteria, $con );
|
||||
$con->begin();
|
||||
foreach ($objects as $row) {
|
||||
$this->remove( $row->getStepUid(), $row->getTasUid(), $row->getTriUid(), $row->getStType() );
|
||||
}
|
||||
$con->commit();
|
||||
|
||||
$con->begin();
|
||||
$this->setStepUid( $aData['STEP_UID'] );
|
||||
$this->setTasUid( $aData['TAS_UID'] );
|
||||
$this->setTriUid( $aData['TRI_UID'] );
|
||||
$this->setStType( $aData['ST_TYPE'] );
|
||||
$this->setStCondition( "" );
|
||||
$this->setStPosition( "" );
|
||||
if ($this->validate()) {
|
||||
$result = $this->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
} else {
|
||||
$con->rollback();
|
||||
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // StepTrigger
|
||||
|
||||
public function load ($StepUid, $TasUid, $TriUid, $StType)
|
||||
{
|
||||
try {
|
||||
$oRow = StepTriggerPeer::retrieveByPK( $StepUid, $TasUid, $TriUid, $StType );
|
||||
if (! is_null( $oRow )) {
|
||||
$aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
|
||||
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
|
||||
$this->setNew( false );
|
||||
return $aFields;
|
||||
} else {
|
||||
throw (new Exception( "The row '$StepUid, $TasUid, $TriUid, $StType' in table StepTrigger doesn't exist!" ));
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function update ($fields)
|
||||
{
|
||||
$con = Propel::getConnection( StepTriggerPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$this->load( $fields['STEP_UID'], $fields['TAS_UID'], $fields['TRI_UID'], $fields['ST_TYPE'] );
|
||||
$this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
|
||||
if ($this->validate()) {
|
||||
$result = $this->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
} else {
|
||||
$con->rollback();
|
||||
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
function remove ($StepUid, $TasUid, $TriUid, $StType)
|
||||
{
|
||||
$oConnection = Propel::getConnection( StepTriggerPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oStepTrigger = StepTriggerPeer::retrieveByPK( $StepUid, $TasUid, $TriUid, $StType );
|
||||
if (! is_null( $oStepTrigger )) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oStepTrigger->delete();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
} else {
|
||||
throw (new Exception( "The row '$StepUid, $TasUid, $TriUid, $StType' in table StepTrigger doesn't exist!" ));
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function stepTriggerExists ($StepUid, $TasUid, $TriUid, $StType)
|
||||
{
|
||||
$con = Propel::getConnection( StepTriggerPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oObj = StepTriggerPeer::retrieveByPk( $StepUid, $TasUid, $TriUid, $StType );
|
||||
if (is_object( $oObj ) && get_class( $oObj ) == 'StepTrigger') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
function removeTrigger ($TriUid)
|
||||
{
|
||||
$con = Propel::getConnection( StepTriggerPeer::DATABASE_NAME );
|
||||
try {
|
||||
$criteria = new Criteria();
|
||||
//$criteria->add(StepTriggerPeer::STEP_UID, $step_uid);
|
||||
//$criteria->add(StepTriggerPeer::TAS_UID, $tas_uid);
|
||||
$criteria->add( StepTriggerPeer::TRI_UID, $TriUid );
|
||||
//$criteria->add(StepTriggerPeer::ST_TYPE, $st_type);
|
||||
$objects = StepTriggerPeer::doSelect( $criteria, $con );
|
||||
$con->begin();
|
||||
foreach ($objects as $v) {
|
||||
$this->remove( $v->getStepUid, $v->getTasUid, $v->getTriUid, $v->getStType );
|
||||
}
|
||||
$con->commit();
|
||||
return count( $objects );
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
function getNextPosition ($sStepUID, $sType)
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( '(COUNT(*) + 1) AS POSITION' );
|
||||
$oCriteria->add( StepTriggerPeer::STEP_UID, $sStepUID );
|
||||
$oCriteria->add( StepTriggerPeer::ST_TYPE, $sType );
|
||||
$oDataset = StepTriggerPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
return (int) $aRow['POSITION'];
|
||||
} catch (Exception $oException) {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
|
||||
function reOrder ($sStepUID, $sTaskUID, $sType, $iPosition)
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->add( StepTriggerPeer::STEP_UID, $sStepUID );
|
||||
$oCriteria->add( StepTriggerPeer::TAS_UID, $sTaskUID );
|
||||
$oCriteria->add( StepTriggerPeer::ST_TYPE, $sType );
|
||||
$oCriteria->add( StepTriggerPeer::ST_POSITION, $iPosition, '>' );
|
||||
$oDataset = StepTriggerPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oStep = StepTriggerPeer::retrieveByPK( $aRow['STEP_UID'], $aRow['TAS_UID'], $aRow['TRI_UID'], $aRow['ST_TYPE'] );
|
||||
$oStep->setStPosition( ($aRow['ST_POSITION']) - 1 );
|
||||
$oStep->save();
|
||||
$oDataset->next();
|
||||
}
|
||||
} catch (Exception $oException) {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
|
||||
function up ($sStepUID = '', $sTaskUID = '', $sTriggerUID = '', $sType = '', $iPosition = 0)
|
||||
{
|
||||
try {
|
||||
if ($iPosition > 1) {
|
||||
$oCriteria1 = new Criteria( 'workflow' );
|
||||
$oCriteria1->add( StepTriggerPeer::ST_POSITION, $iPosition );
|
||||
$oCriteria2 = new Criteria( 'workflow' );
|
||||
$oCriteria2->add( StepTriggerPeer::STEP_UID, $sStepUID );
|
||||
$oCriteria2->add( StepTriggerPeer::TAS_UID, $sTaskUID );
|
||||
$oCriteria2->add( StepTriggerPeer::ST_TYPE, $sType );
|
||||
$oCriteria2->add( StepTriggerPeer::ST_POSITION, ($iPosition - 1) );
|
||||
BasePeer::doUpdate( $oCriteria2, $oCriteria1, Propel::getConnection( 'workflow' ) );
|
||||
$oCriteria1 = new Criteria( 'workflow' );
|
||||
$oCriteria1->add( StepTriggerPeer::ST_POSITION, ($iPosition - 1) );
|
||||
$oCriteria2 = new Criteria( 'workflow' );
|
||||
$oCriteria2->add( StepTriggerPeer::STEP_UID, $sStepUID );
|
||||
$oCriteria2->add( StepTriggerPeer::TAS_UID, $sTaskUID );
|
||||
$oCriteria2->add( StepTriggerPeer::TRI_UID, $sTriggerUID );
|
||||
$oCriteria2->add( StepTriggerPeer::ST_TYPE, $sType );
|
||||
BasePeer::doUpdate( $oCriteria2, $oCriteria1, Propel::getConnection( 'workflow' ) );
|
||||
}
|
||||
} catch (Exception $oException) {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
|
||||
function down ($sStepUID = '', $sTaskUID = '', $sTriggerUID = '', $sType = '', $iPosition = 0)
|
||||
{
|
||||
try {
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( 'COUNT(*) AS MAX_POSITION' );
|
||||
$oCriteria->add( StepTriggerPeer::STEP_UID, $sStepUID );
|
||||
$oCriteria->add( StepTriggerPeer::TAS_UID, $sTaskUID );
|
||||
$oCriteria->add( StepTriggerPeer::ST_TYPE, $sType );
|
||||
$oDataset = StepTriggerPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
if ($iPosition < (int) $aRow['MAX_POSITION']) {
|
||||
$oCriteria1 = new Criteria( 'workflow' );
|
||||
$oCriteria1->add( StepTriggerPeer::ST_POSITION, $iPosition );
|
||||
$oCriteria2 = new Criteria( 'workflow' );
|
||||
$oCriteria2->add( StepTriggerPeer::STEP_UID, $sStepUID );
|
||||
$oCriteria2->add( StepTriggerPeer::TAS_UID, $sTaskUID );
|
||||
$oCriteria2->add( StepTriggerPeer::ST_TYPE, $sType );
|
||||
$oCriteria2->add( StepTriggerPeer::ST_POSITION, ($iPosition + 1) );
|
||||
BasePeer::doUpdate( $oCriteria2, $oCriteria1, Propel::getConnection( 'workflow' ) );
|
||||
$oCriteria1 = new Criteria( 'workflow' );
|
||||
$oCriteria1->add( StepTriggerPeer::ST_POSITION, ($iPosition + 1) );
|
||||
$oCriteria2 = new Criteria( 'workflow' );
|
||||
$oCriteria2->add( StepTriggerPeer::STEP_UID, $sStepUID );
|
||||
$oCriteria2->add( StepTriggerPeer::TAS_UID, $sTaskUID );
|
||||
$oCriteria2->add( StepTriggerPeer::TRI_UID, $sTriggerUID );
|
||||
$oCriteria2->add( StepTriggerPeer::ST_TYPE, $sType );
|
||||
BasePeer::doUpdate( $oCriteria2, $oCriteria1, Propel::getConnection( 'workflow' ) );
|
||||
}
|
||||
} catch (Exception $oException) {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
|
||||
function createRow ($aData)
|
||||
{
|
||||
$con = Propel::getConnection( StepTriggerPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$this->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($this->validate()) {
|
||||
$this->setStepUid( $aData['STEP_UID'] );
|
||||
$this->setTasUid( $aData['TAS_UID'] );
|
||||
$this->setTriUid( $aData['TRI_UID'] );
|
||||
$this->setStType( $aData['ST_TYPE'] );
|
||||
$this->setStCondition( $aData['ST_CONDITION'] );
|
||||
$this->setStPosition( $aData['ST_POSITION'] );
|
||||
|
||||
$result = $this->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
} else {
|
||||
$con->rollback();
|
||||
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
|
||||
$e->aValidationFailures = $this->getValidationFailures();
|
||||
throw ($e);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
// StepTrigger
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Users.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.
|
||||
@@ -35,126 +36,110 @@ require_once 'classes/model/IsoLocation.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 Users extends BaseUsers {
|
||||
function create ($aData)
|
||||
{
|
||||
$con = Propel::getConnection(UsersPeer::DATABASE_NAME);
|
||||
try
|
||||
class Users extends BaseUsers
|
||||
{
|
||||
|
||||
function create ($aData)
|
||||
{
|
||||
$this->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if($this->validate())
|
||||
{
|
||||
$result=$this->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
$e=new Exception("Failed Validation in class ".get_class($this).".");
|
||||
$e->aValidationFailures=$this->getValidationFailures();
|
||||
throw($e);
|
||||
}
|
||||
$con->commit();
|
||||
return $result;
|
||||
$con = Propel::getConnection( UsersPeer::DATABASE_NAME );
|
||||
try {
|
||||
$this->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($this->validate()) {
|
||||
$result = $this->save();
|
||||
} else {
|
||||
$e = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
|
||||
$e->aValidationFailures = $this->getValidationFailures();
|
||||
throw ($e);
|
||||
}
|
||||
$con->commit();
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
|
||||
public function userExists($UsrUid)
|
||||
{
|
||||
try {
|
||||
$oRow = UsersPeer::retrieveByPK( $UsrUid );
|
||||
if (!is_null($oRow))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function load($UsrUid)
|
||||
{
|
||||
try {
|
||||
$oRow = UsersPeer::retrieveByPK( $UsrUid );
|
||||
if (!is_null($oRow))
|
||||
{
|
||||
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception( "The row '" . $UsrUid . "' in table USER doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (PropelException $e){ //capture invalid birthday date and replace by null
|
||||
$msg = $e->getMessage();
|
||||
if (strpos('Unable to parse value of [usr_birthday]', $msg) != -1) {
|
||||
$oRow->setUsrBirthday(null);
|
||||
$oRow->save();
|
||||
return $this->load($UsrUid);
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function loadDetails($UsrUid)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$oUser = UsersPeer::retrieveByPK( $UsrUid );
|
||||
if (!is_null($oUser)) {
|
||||
$result['USR_UID'] = $oUser->getUsrUid();
|
||||
$result['USR_USERNAME'] = $oUser->getUsrUsername();
|
||||
$result['USR_FULLNAME'] = $oUser->getUsrFirstname() . ' ' . $oUser->getUsrLastname() ;
|
||||
$result['USR_EMAIL'] = $oUser->getUsrEmail();
|
||||
return $result;
|
||||
}
|
||||
else {
|
||||
// return $result;
|
||||
throw(new Exception( "The row '" . $UsrUid . "' in table USER doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function loadDetailed($UsrUid)
|
||||
public function userExists ($UsrUid)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$oUser = UsersPeer::retrieveByPK($UsrUid);
|
||||
$oRow = UsersPeer::retrieveByPK( $UsrUid );
|
||||
if (! is_null( $oRow )) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_null($oUser)) {
|
||||
$aFields = $oUser->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
public function load ($UsrUid)
|
||||
{
|
||||
try {
|
||||
$oRow = UsersPeer::retrieveByPK( $UsrUid );
|
||||
if (! is_null( $oRow )) {
|
||||
$aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
|
||||
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
|
||||
$this->setNew( false );
|
||||
return $aFields;
|
||||
} else {
|
||||
throw (new Exception( "The row '" . $UsrUid . "' in table USER doesn't exist!" ));
|
||||
}
|
||||
} catch (PropelException $e) {
|
||||
//capture invalid birthday date and replace by null
|
||||
$msg = $e->getMessage();
|
||||
if (strpos( 'Unable to parse value of [usr_birthday]', $msg ) != - 1) {
|
||||
$oRow->setUsrBirthday( null );
|
||||
$oRow->save();
|
||||
return $this->load( $UsrUid );
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
$aIsoCountry = IsoCountry::findById($aFields['USR_COUNTRY']);
|
||||
$aIsoSubdivision = IsoSubdivision::findById($aFields['USR_COUNTRY'], $aFields['USR_CITY']);
|
||||
$aIsoLocation = IsoLocation::findById(
|
||||
$aFields['USR_COUNTRY'],
|
||||
$aFields['USR_CITY'],
|
||||
$aFields['USR_LOCATION']
|
||||
);
|
||||
public function loadDetails ($UsrUid)
|
||||
{
|
||||
try {
|
||||
$result = array ();
|
||||
$oUser = UsersPeer::retrieveByPK( $UsrUid );
|
||||
if (! is_null( $oUser )) {
|
||||
$result['USR_UID'] = $oUser->getUsrUid();
|
||||
$result['USR_USERNAME'] = $oUser->getUsrUsername();
|
||||
$result['USR_FULLNAME'] = $oUser->getUsrFirstname() . ' ' . $oUser->getUsrLastname();
|
||||
$result['USR_EMAIL'] = $oUser->getUsrEmail();
|
||||
return $result;
|
||||
} else {
|
||||
// return $result;
|
||||
throw (new Exception( "The row '" . $UsrUid . "' in table USER doesn't exist!" ));
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
$aFields['USR_COUNTRY_NAME'] = $aIsoCountry['IC_NAME'];
|
||||
$aFields['USR_CITY_NAME'] = $aIsoSubdivision['IS_NAME'];
|
||||
public function loadDetailed ($UsrUid)
|
||||
{
|
||||
try {
|
||||
$result = array ();
|
||||
$oUser = UsersPeer::retrieveByPK( $UsrUid );
|
||||
|
||||
if (! is_null( $oUser )) {
|
||||
$aFields = $oUser->toArray( BasePeer::TYPE_FIELDNAME );
|
||||
$this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME );
|
||||
$this->setNew( false );
|
||||
|
||||
$aIsoCountry = IsoCountry::findById( $aFields['USR_COUNTRY'] );
|
||||
$aIsoSubdivision = IsoSubdivision::findById( $aFields['USR_COUNTRY'], $aFields['USR_CITY'] );
|
||||
$aIsoLocation = IsoLocation::findById( $aFields['USR_COUNTRY'], $aFields['USR_CITY'], $aFields['USR_LOCATION'] );
|
||||
|
||||
$aFields['USR_COUNTRY_NAME'] = $aIsoCountry['IC_NAME'];
|
||||
$aFields['USR_CITY_NAME'] = $aIsoSubdivision['IS_NAME'];
|
||||
$aFields['USR_LOCATION_NAME'] = $aIsoLocation['IL_NAME'];
|
||||
|
||||
$result = $aFields;
|
||||
@@ -162,84 +147,77 @@ public function userExists($UsrUid)
|
||||
return $result;
|
||||
} else {
|
||||
//return $result;
|
||||
throw (new Exception("The row '" . $UsrUid . "' in table USER doesn't exist!"));
|
||||
throw (new Exception( "The row '" . $UsrUid . "' in table USER doesn't exist!" ));
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($fields)
|
||||
{
|
||||
$con = Propel::getConnection(UsersPeer::DATABASE_NAME);
|
||||
try
|
||||
public function update ($fields)
|
||||
{
|
||||
$con->begin();
|
||||
$this->load($fields['USR_UID']);
|
||||
$this->fromArray($fields,BasePeer::TYPE_FIELDNAME);
|
||||
if($this->validate())
|
||||
{
|
||||
$result=$this->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$con->rollback();
|
||||
throw(new Exception("Failed Validation in class ".get_class($this)."."));
|
||||
}
|
||||
$con = Propel::getConnection( UsersPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$this->load( $fields['USR_UID'] );
|
||||
$this->fromArray( $fields, BasePeer::TYPE_FIELDNAME );
|
||||
if ($this->validate()) {
|
||||
$result = $this->save();
|
||||
$con->commit();
|
||||
return $result;
|
||||
} else {
|
||||
$con->rollback();
|
||||
throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." ));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
|
||||
function remove ($UsrUid)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
$con = Propel::getConnection( UsersPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$this->setUsrUid( $UsrUid );
|
||||
$result = $this->delete();
|
||||
$con->commit();
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function remove($UsrUid)
|
||||
{
|
||||
$con = Propel::getConnection(UsersPeer::DATABASE_NAME);
|
||||
try
|
||||
|
||||
function loadByUsername ($sUsername)
|
||||
{
|
||||
$con->begin();
|
||||
$this->setUsrUid($UsrUid);
|
||||
$result=$this->delete();
|
||||
$con->commit();
|
||||
return $result;
|
||||
$c = new Criteria( 'workflow' );
|
||||
$del = DBAdapter::getStringDelimiter();
|
||||
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( UsersPeer::USR_UID );
|
||||
$c->addSelectColumn( UsersPeer::USR_USERNAME );
|
||||
$c->addSelectColumn( UsersPeer::USR_STATUS );
|
||||
|
||||
$c->add( UsersPeer::USR_USERNAME, $sUsername );
|
||||
return $c;
|
||||
}
|
||||
catch(Exception $e)
|
||||
|
||||
function loadByUsernameInArray ($sUsername)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
$c = $this->loadByUsername( $sUsername );
|
||||
$rs = UsersPeer::doSelectRS( $c );
|
||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
function loadByUsername($sUsername)
|
||||
{
|
||||
$c = new Criteria('workflow');
|
||||
$del = DBAdapter::getStringDelimiter();
|
||||
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( UsersPeer::USR_UID );
|
||||
$c->addSelectColumn( UsersPeer::USR_USERNAME );
|
||||
$c->addSelectColumn( UsersPeer::USR_STATUS );
|
||||
|
||||
$c->add(UsersPeer::USR_USERNAME, $sUsername);
|
||||
return $c;
|
||||
}
|
||||
|
||||
function loadByUsernameInArray($sUsername){
|
||||
$c = $this->loadByUsername($sUsername);
|
||||
$rs = UsersPeer::doSelectRS($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function getAllInformation($userUid)
|
||||
public function getAllInformation ($userUid)
|
||||
{
|
||||
if (!isset($userUid) || $userUid == "") {
|
||||
throw (new Exception("$userUid is empty."));
|
||||
if (! isset( $userUid ) || $userUid == "") {
|
||||
throw (new Exception( "$userUid is empty." ));
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -248,69 +226,69 @@ public function userExists($UsrUid)
|
||||
require_once ("classes/model/IsoSubdivision.php");
|
||||
require_once ("classes/model/Language.php");
|
||||
|
||||
G::LoadClass("calendar");
|
||||
G::LoadClass( "calendar" );
|
||||
|
||||
$aFields = $this->load($userUid);
|
||||
$aFields = $this->load( $userUid );
|
||||
|
||||
$c = new Criteria("workflow");
|
||||
$c->add(IsoCountryPeer::IC_UID, $aFields["USR_COUNTRY"]);
|
||||
$rs = IsoCountryPeer::doSelectRS($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$c = new Criteria( "workflow" );
|
||||
$c->add( IsoCountryPeer::IC_UID, $aFields["USR_COUNTRY"] );
|
||||
$rs = IsoCountryPeer::doSelectRS( $c );
|
||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next();
|
||||
$rowC = $rs->getRow();
|
||||
|
||||
$c->clearSelectColumns();
|
||||
$c->add(IsoSubdivisionPeer::IC_UID, $aFields["USR_COUNTRY"]);
|
||||
$c->add(IsoSubdivisionPeer::IS_UID, $aFields["USR_CITY"]);
|
||||
$rs = IsoSubdivisionPeer::doSelectRS($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$c->add( IsoSubdivisionPeer::IC_UID, $aFields["USR_COUNTRY"] );
|
||||
$c->add( IsoSubdivisionPeer::IS_UID, $aFields["USR_CITY"] );
|
||||
$rs = IsoSubdivisionPeer::doSelectRS( $c );
|
||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next();
|
||||
$rowS = $rs->getRow();
|
||||
|
||||
$c->clearSelectColumns();
|
||||
$c->add(IsoLocationPeer::IC_UID, $aFields["USR_COUNTRY"]);
|
||||
$c->add(IsoLocationPeer::IL_UID, $aFields["USR_LOCATION"]);
|
||||
$rs = IsoLocationPeer::doSelectRS($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$c->add( IsoLocationPeer::IC_UID, $aFields["USR_COUNTRY"] );
|
||||
$c->add( IsoLocationPeer::IL_UID, $aFields["USR_LOCATION"] );
|
||||
$rs = IsoLocationPeer::doSelectRS( $c );
|
||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$rs->next();
|
||||
$rowL = $rs->getRow();
|
||||
|
||||
//Calendar
|
||||
$calendar = new Calendar();
|
||||
$calendarInfo = $calendar->getCalendarFor($userUid, $userUid, $userUid);
|
||||
$aFields["USR_CALENDAR"] = ($calendarInfo["CALENDAR_APPLIED"] != "DEFAULT")? $calendarInfo["CALENDAR_UID"] : "";
|
||||
$calendarInfo = $calendar->getCalendarFor( $userUid, $userUid, $userUid );
|
||||
$aFields["USR_CALENDAR"] = ($calendarInfo["CALENDAR_APPLIED"] != "DEFAULT") ? $calendarInfo["CALENDAR_UID"] : "";
|
||||
|
||||
//Photo
|
||||
$pathPhoto = PATH_IMAGES_ENVIRONMENT_USERS . $userUid . ".gif";
|
||||
|
||||
if (!file_exists($pathPhoto)) {
|
||||
if (! file_exists( $pathPhoto )) {
|
||||
$pathPhoto = PATH_HOME . "public_html" . PATH_SEP . "images" . PATH_SEP . "user.gif";
|
||||
}
|
||||
|
||||
//Data
|
||||
$arrayData = array();
|
||||
$arrayData["username"] = $aFields["USR_USERNAME"];
|
||||
$arrayData = array ();
|
||||
$arrayData["username"] = $aFields["USR_USERNAME"];
|
||||
$arrayData["firstname"] = $aFields["USR_FIRSTNAME"];
|
||||
$arrayData["lastname"] = $aFields["USR_LASTNAME"];
|
||||
$arrayData["mail"] = $aFields["USR_EMAIL"];
|
||||
$arrayData["address"] = $aFields["USR_ADDRESS"];
|
||||
$arrayData["zipcode"] = $aFields["USR_ZIP_CODE"];
|
||||
$arrayData["country"] = $rowC["IC_NAME"];
|
||||
$arrayData["state"] = $rowS["IS_NAME"];
|
||||
$arrayData["location"] = $rowL["IL_NAME"];
|
||||
$arrayData["phone"] = $aFields["USR_PHONE"];
|
||||
$arrayData["fax"] = $aFields["USR_FAX"];
|
||||
$arrayData["cellular"] = $aFields["USR_CELLULAR"];
|
||||
$arrayData["birthday"] = $aFields["USR_BIRTHDAY"];
|
||||
$arrayData["position"] = $aFields["USR_POSITION"];
|
||||
$arrayData["lastname"] = $aFields["USR_LASTNAME"];
|
||||
$arrayData["mail"] = $aFields["USR_EMAIL"];
|
||||
$arrayData["address"] = $aFields["USR_ADDRESS"];
|
||||
$arrayData["zipcode"] = $aFields["USR_ZIP_CODE"];
|
||||
$arrayData["country"] = $rowC["IC_NAME"];
|
||||
$arrayData["state"] = $rowS["IS_NAME"];
|
||||
$arrayData["location"] = $rowL["IL_NAME"];
|
||||
$arrayData["phone"] = $aFields["USR_PHONE"];
|
||||
$arrayData["fax"] = $aFields["USR_FAX"];
|
||||
$arrayData["cellular"] = $aFields["USR_CELLULAR"];
|
||||
$arrayData["birthday"] = $aFields["USR_BIRTHDAY"];
|
||||
$arrayData["position"] = $aFields["USR_POSITION"];
|
||||
$arrayData["replacedby"] = $aFields["USR_REPLACED_BY"];
|
||||
$arrayData["duedate"] = $aFields["USR_DUE_DATE"];
|
||||
$arrayData["calendar"] = $aFields["USR_CALENDAR"];
|
||||
$arrayData["status"] = $aFields["USR_STATUS"];
|
||||
$arrayData["duedate"] = $aFields["USR_DUE_DATE"];
|
||||
$arrayData["calendar"] = $aFields["USR_CALENDAR"];
|
||||
$arrayData["status"] = $aFields["USR_STATUS"];
|
||||
$arrayData["department"] = $aFields["DEP_UID"];
|
||||
$arrayData["reportsto"] = $aFields["USR_REPORTS_TO"];
|
||||
$arrayData["reportsto"] = $aFields["USR_REPORTS_TO"];
|
||||
$arrayData["userexperience"] = $aFields["USR_UX"];
|
||||
$arrayData["photo"] = $pathPhoto;
|
||||
$arrayData["photo"] = $pathPhoto;
|
||||
|
||||
return $arrayData;
|
||||
} catch (Exception $e) {
|
||||
@@ -318,102 +296,89 @@ public function userExists($UsrUid)
|
||||
}
|
||||
}
|
||||
|
||||
function getAvailableUsersCriteria($sGroupUID = '')
|
||||
{
|
||||
try {
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_UID);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
|
||||
|
||||
return $oCriteria;
|
||||
}
|
||||
catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all Active users
|
||||
*
|
||||
* @return array of all active users
|
||||
*/
|
||||
function getAll($start=null, $limit=null, $search=null)
|
||||
{
|
||||
$totalCount = 0;
|
||||
$criteria = new Criteria('workflow');
|
||||
$criteria->addSelectColumn(UsersPeer::USR_UID);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_USERNAME);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_LASTNAME);
|
||||
$criteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
|
||||
$criteria->addAscendingOrderByColumn ( UsersPeer::USR_LASTNAME );
|
||||
|
||||
if( $search ) {
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(
|
||||
UsersPeer::USR_USERNAME,
|
||||
"%$search%", Criteria::LIKE
|
||||
)->addOr(
|
||||
$criteria->getNewCriterion(
|
||||
UsersPeer::USR_FIRSTNAME,
|
||||
"%$search%", Criteria::LIKE
|
||||
)
|
||||
)->addOr(
|
||||
$criteria->getNewCriterion(
|
||||
UsersPeer::USR_LASTNAME,
|
||||
"%$search%", Criteria::LIKE
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$c = clone $criteria;
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn('COUNT(*)');
|
||||
$dataset = UsersPeer::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 = UsersPeer::doSelectRS($criteria);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$rows = Array();
|
||||
while( $rs->next() )
|
||||
$rows[] = $rs->getRow();
|
||||
|
||||
$result->data = $rows;
|
||||
$result->totalCount = $totalCount;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function userVacation($UsrUid = "")
|
||||
function getAvailableUsersCriteria ($sGroupUID = '')
|
||||
{
|
||||
$aFields = array();
|
||||
try {
|
||||
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_UID );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME );
|
||||
$oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' );
|
||||
|
||||
return $oCriteria;
|
||||
} catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Active users
|
||||
*
|
||||
* @return array of all active users
|
||||
*/
|
||||
function getAll ($start = null, $limit = null, $search = null)
|
||||
{
|
||||
$totalCount = 0;
|
||||
$criteria = new Criteria( 'workflow' );
|
||||
$criteria->addSelectColumn( UsersPeer::USR_UID );
|
||||
$criteria->addSelectColumn( UsersPeer::USR_USERNAME );
|
||||
$criteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
|
||||
$criteria->addSelectColumn( UsersPeer::USR_LASTNAME );
|
||||
$criteria->add( UsersPeer::USR_STATUS, 'ACTIVE' );
|
||||
$criteria->addAscendingOrderByColumn( UsersPeer::USR_LASTNAME );
|
||||
|
||||
if ($search) {
|
||||
$criteria->add( $criteria->getNewCriterion( UsersPeer::USR_USERNAME, "%$search%", Criteria::LIKE )->addOr( $criteria->getNewCriterion( UsersPeer::USR_FIRSTNAME, "%$search%", Criteria::LIKE ) )->addOr( $criteria->getNewCriterion( UsersPeer::USR_LASTNAME, "%$search%", Criteria::LIKE ) ) );
|
||||
}
|
||||
|
||||
$c = clone $criteria;
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn( 'COUNT(*)' );
|
||||
$dataset = UsersPeer::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 = UsersPeer::doSelectRS( $criteria );
|
||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
$rows = Array ();
|
||||
while ($rs->next()) {
|
||||
$rows[] = $rs->getRow();
|
||||
}
|
||||
|
||||
$result->data = $rows;
|
||||
$result->totalCount = $totalCount;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function userVacation ($UsrUid = "")
|
||||
{
|
||||
$aFields = array ();
|
||||
$cnt = 0;
|
||||
do {
|
||||
if ($UsrUid != "" && $cnt < 100) {
|
||||
$aFields = $this->load($UsrUid);
|
||||
$aFields = $this->load( $UsrUid );
|
||||
$UsrUid = $aFields['USR_REPLACED_BY'];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
$cnt++;
|
||||
$cnt ++;
|
||||
} while ($aFields['USR_STATUS'] != 'ACTIVE');
|
||||
return $aFields;
|
||||
}
|
||||
} // Users
|
||||
}
|
||||
// Users
|
||||
|
||||
?>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user