2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
2011-01-31 14:14:55 +00:00
|
|
|
/**
|
|
|
|
|
* ProcessUser.php
|
|
|
|
|
* @package workflow.engine.classes.model
|
|
|
|
|
*/
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-11-16 17:13:48 -04:00
|
|
|
//require_once 'classes/model/om/BaseProcessUser.php';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Skeleton subclass for representing a row from the 'PROCESS_USER' table.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* You should add additional methods to this class to meet the
|
|
|
|
|
* application requirements. This class will only be generated as
|
|
|
|
|
* long as it does not already exist in the output directory.
|
|
|
|
|
*
|
2011-01-31 14:14:55 +00:00
|
|
|
* @package workflow.engine.classes.model
|
2010-12-02 23:34:41 +00:00
|
|
|
*/
|
2012-10-20 16:52:15 -04:00
|
|
|
class ProcessUser extends BaseProcessUser
|
|
|
|
|
{
|
|
|
|
|
public function create($aData)
|
|
|
|
|
{
|
|
|
|
|
$oConnection = Propel::getConnection(ProcessUserPeer::DATABASE_NAME);
|
|
|
|
|
try {
|
|
|
|
|
$criteria = new Criteria('workflow');
|
|
|
|
|
$criteria->add(ProcessUserPeer::PU_UID, $aData['PU_UID'] );
|
|
|
|
|
$criteria->add(ProcessUserPeer::PRO_UID, $aData['PRO_UID'] );
|
|
|
|
|
$criteria->add(ProcessUserPeer::USR_UID, $aData['USR_UID'] );
|
|
|
|
|
$criteria->add(ProcessUserPeer::PU_TYPE, $aData['PU_TYPE'] );
|
|
|
|
|
$objects = ProcessUserPeer::doSelect($criteria, $oConnection);
|
|
|
|
|
$oConnection->begin();
|
|
|
|
|
foreach ($objects as $row) {
|
|
|
|
|
$this->remove($row->getTasUid(), $row->getUsrUid(), $row->getTuType(), $row->getTuRelation() );
|
|
|
|
|
}
|
|
|
|
|
$oConnection->commit();
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-20 16:52:15 -04:00
|
|
|
$oProcessUser = new ProcessUser();
|
|
|
|
|
$oProcessUser->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
|
|
|
|
if ($oProcessUser->validate()) {
|
|
|
|
|
$oConnection->begin();
|
|
|
|
|
$iResult = $oProcessUser->save();
|
|
|
|
|
$oConnection->commit();
|
|
|
|
|
return $iResult;
|
|
|
|
|
} else {
|
|
|
|
|
$sMessage = '';
|
|
|
|
|
$aValidationFailures = $oProcessUser->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);
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-20 16:52:15 -04:00
|
|
|
/**
|
|
|
|
|
* Remove the application document registry
|
|
|
|
|
* @param string $sPuUid
|
|
|
|
|
* @param string $sProUid
|
|
|
|
|
* @param string $sUserUid
|
|
|
|
|
* @return string
|
|
|
|
|
**/
|
|
|
|
|
public function remove($sPuUid)
|
|
|
|
|
{
|
|
|
|
|
$oConnection = Propel::getConnection(ProcessUserPeer::DATABASE_NAME);
|
|
|
|
|
try {
|
|
|
|
|
$oProcessUser = ProcessUserPeer::retrieveByPK($sPuUid);
|
|
|
|
|
if (!is_null($oProcessUser)) {
|
|
|
|
|
$oConnection->begin();
|
|
|
|
|
$iResult = $oProcessUser->delete();
|
|
|
|
|
$oConnection->commit();
|
|
|
|
|
return $iResult;
|
|
|
|
|
} else {
|
|
|
|
|
throw(new Exception('This row doesn\'t exist!'));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
$oConnection->rollback();
|
|
|
|
|
throw($oError);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-20 16:52:15 -04:00
|
|
|
public function Exists ($sUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$oObj = ProcessUserPeer::retrieveByPk($sUid);
|
|
|
|
|
return (is_object($oObj) && get_class($oObj) == 'ProcessUser');
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
throw($oError);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2016-06-08 10:46:58 -04:00
|
|
|
|
2016-10-07 14:27:54 -04:00
|
|
|
public function validateUserAccess($proUid, $usrUid)
|
2016-06-08 10:46:58 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$oCriteria = new Criteria();
|
2017-01-17 14:49:09 -04:00
|
|
|
$oCriteria->add(ProcessUserPeer::PRO_UID, $proUid);
|
|
|
|
|
$oCriteria->add(ProcessUserPeer::PU_TYPE, 'SUPERVISOR');
|
|
|
|
|
$oCriteria->add(ProcessUserPeer::USR_UID, $usrUid);
|
|
|
|
|
$dataset = ProcessUserPeer::doSelectRS($oCriteria);
|
|
|
|
|
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2016-10-07 14:27:54 -04:00
|
|
|
//If the user is in Assigned supervisors list
|
2017-01-17 14:49:09 -04:00
|
|
|
if ($dataset->next()) {
|
2016-06-08 10:46:58 -04:00
|
|
|
return true;
|
|
|
|
|
} else {
|
2016-10-07 14:27:54 -04:00
|
|
|
//If the user is in a group in Assigned supervisors list
|
|
|
|
|
$oCriteria = new Criteria();
|
2017-01-17 14:49:09 -04:00
|
|
|
$oCriteria->add(ProcessUserPeer::PRO_UID, $proUid);
|
|
|
|
|
$oCriteria->add(ProcessUserPeer::PU_TYPE, 'GROUP_SUPERVISOR');
|
|
|
|
|
$dataset = ProcessUserPeer::doSelectRS($oCriteria);
|
|
|
|
|
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2016-10-07 14:27:54 -04:00
|
|
|
$oGroups = new Groups();
|
|
|
|
|
$aGroups = $oGroups->getActiveGroupsForAnUser($usrUid);
|
|
|
|
|
while ($dataset->next()) {
|
|
|
|
|
$row = $dataset->getRow();
|
|
|
|
|
$groupUid = $row['USR_UID'];
|
|
|
|
|
if (in_array($groupUid, $aGroups)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-06-08 10:46:58 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
throw ($oError);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-10-20 16:52:15 -04:00
|
|
|
}
|
|
|
|
|
|