diff --git a/workflow/engine/classes/Processes.php b/workflow/engine/classes/Processes.php index b4a2b66d7..e5feaa43d 100644 --- a/workflow/engine/classes/Processes.php +++ b/workflow/engine/classes/Processes.php @@ -3083,32 +3083,37 @@ class Processes /** * Get Groupwf Rows for a Process form an array * - * @param array $aGroups - * @return array $aGroupwf + * @param array $groups + * + * @return array $groupList + * @throws Exception */ - public function getGroupwfRows($aGroups) + public function getGroupwfRows($groups) { try { - $aInGroups = array(); - foreach ($aGroups as $key => $val) { - $aInGroups[] = $val['USR_UID']; + $inGroups = []; + foreach ($groups as $key => $val) { + $inGroups[] = $val['USR_UID']; } - $aGroupwf = array(); - $oCriteria = new Criteria('workflow'); - $oCriteria->add(GroupwfPeer::GRP_UID, $aInGroups, Criteria::IN); - $oDataset = GroupwfPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oGroupwf = new Groupwf(); - $aGroupwf[] = $oGroupwf->Load($aRow['GRP_UID']); - $oDataset->next(); + $groupList = []; + $criteria = new Criteria('workflow'); + $criteria->add(GroupwfPeer::GRP_UID, $inGroups, Criteria::IN); + $dataset = GroupwfPeer::doSelectRS($criteria); + $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $dataset->next(); + while ($row = $dataset->getRow()) { + $groupWf = new Groupwf(); + $infoGroup = $groupWf->Load($row['GRP_UID']); + unset($infoGroup['GRP_ID']); + $groupList[] = $infoGroup; + + $dataset->next(); } - return $aGroupwf; - } catch (Exception $oError) { - throw ($oError); + return $groupList; + } catch (Exception $error) { + throw ($error); } } @@ -3783,19 +3788,24 @@ class Processes } /** - * Get Task User Rows from an array of data + * Get Task User rows from an array of data * - * @param array $aTaskUser + * @param array $group * @return array $aStepTrigger */ - public function createGroupRow($aGroupwf) + public function createGroupRow($group) { - foreach ($aGroupwf as $key => $row) { - $oGroupwf = new Groupwf(); - if ($oGroupwf->GroupwfExists($row['GRP_UID'])) { - $oGroupwf->remove($row['GRP_UID']); + foreach ($group as $key => $row) { + $groupWf = new Groupwf(); + if ($groupWf->GroupwfExists($row['GRP_UID'])) { + $groupInfo = $groupWf->Load($row['GRP_UID']); + $groupWf->remove($row['GRP_UID']); } - $res = $oGroupwf->create($row); + //We will to keep the GRP_ID + if (!empty($groupInfo['GRP_ID'])) { + $row['GRP_ID'] = $groupInfo['GRP_ID']; + } + $res = $groupWf->create($row); } } diff --git a/workflow/engine/classes/model/Groupwf.php b/workflow/engine/classes/model/Groupwf.php index eee05771f..989c0fca2 100644 --- a/workflow/engine/classes/model/Groupwf.php +++ b/workflow/engine/classes/model/Groupwf.php @@ -72,47 +72,54 @@ class Groupwf extends BaseGroupwf /** * Creates the Group * - * @param array $aData $oData is not necessary + * @param array $data is not necessary + * * @return void + * + * @throws Exception */ - public function create ($aData) + public function create($data) { //$oData is not necessary - $con = Propel::getConnection( GroupwfPeer::DATABASE_NAME ); + $con = Propel::getConnection(GroupwfPeer::DATABASE_NAME); try { - if (isset( $aData['GRP_UID'] )) { - $this->setGrpUid( $aData['GRP_UID'] ); + if (!empty($data['GRP_UID'])) { + $this->setGrpUid($data['GRP_UID']); } else { - $this->setGrpUid( G::generateUniqueID() ); + $this->setGrpUid(G::generateUniqueID()); + } + if(!empty($data['GRP_ID'])){ + $this->setGrpId($data['GRP_ID']); } - if (isset( $aData['GRP_TITLE'] )) { - $this->setGrpTitle( $aData['GRP_TITLE'] ); + if (!empty($data['GRP_TITLE'])) { + $this->setGrpTitle($data['GRP_TITLE']); } else { - $this->setGrpTitle( 'Default Group Title' ); + $this->setGrpTitle('Default Group Title'); } - if (isset( $aData['GRP_STATUS'] )) { - $this->setGrpStatus( $aData['GRP_STATUS'] ); + if (!empty($aData['GRP_STATUS'])) { + $this->setGrpStatus($data['GRP_STATUS']); } else { - $this->setGrpStatus( 'ACTIVE' ); + $this->setGrpStatus('ACTIVE'); } - if (isset( $aData['GRP_LDAP_DN'] )) { - $this->setGrpLdapDn( $aData['GRP_LDAP_DN'] ); + if (!empty($aData['GRP_LDAP_DN'])) { + $this->setGrpLdapDn($data['GRP_LDAP_DN']); } else { - $this->setGrpLdapDn( '' ); + $this->setGrpLdapDn(''); } if ($this->validate()) { $con->begin(); - if (isset( $aData['GRP_TITLE'] )) { - $this->setGrpTitleContent( $aData['GRP_TITLE'] ); + if (!empty($data['GRP_TITLE'])) { + $this->setGrpTitleContent($data['GRP_TITLE']); } else { - $this->setGrpTitleContent( 'Default Group Title' ); + $this->setGrpTitleContent('Default Group Title'); } $res = $this->save(); $con->commit(); + return $this->getGrpUid(); } else { $msg = ''; @@ -120,7 +127,7 @@ class Groupwf extends BaseGroupwf $msg .= $objValidationFailure->getMessage() . "
"; } - throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) )); + throw (new PropelException('The row cannot be created!', new PropelException($msg))); } } catch (Exception $e) {