HOR-1300 Performance Issue in PMFGroupList function
This commit is contained in:
@@ -1897,20 +1897,20 @@ function PMFGenerateOutputDocument ($outputID, $sApplication = null, $index = nu
|
|||||||
* @label PMF Group List
|
* @label PMF Group List
|
||||||
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFGroupList.28.29
|
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFGroupList.28.29
|
||||||
*
|
*
|
||||||
|
* @param string | $search = null | String to search | Optional parameter.
|
||||||
|
* @param int | $start = null | Start | Optional parameter.
|
||||||
|
* @param int | $limit = null | Limit | Optional parameter.
|
||||||
* @return array | $rows | List of groups | An array of groups
|
* @return array | $rows | List of groups | An array of groups
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function PMFGroupList () //its test was successfull
|
function PMFGroupList ($search = null, $start = null, $limit = null) //its test was successfull
|
||||||
{
|
{
|
||||||
G::LoadClass( 'wsBase' );
|
G::LoadClass( 'wsBase' );
|
||||||
$ws = new wsBase();
|
$ws = new wsBase();
|
||||||
$result = $ws->groupList();
|
$result = $ws->groupList($search, $start, $limit);
|
||||||
$rows = Array ();
|
$rows = array();
|
||||||
$i = 1;
|
|
||||||
if (isset( $result )) {
|
if (isset( $result )) {
|
||||||
foreach ($result as $item) {
|
$rows = array_combine(range(1, count($result)), array_values($result));
|
||||||
$rows[$i ++] = $item;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,32 +229,41 @@ class wsBase
|
|||||||
/**
|
/**
|
||||||
* get all groups
|
* get all groups
|
||||||
*
|
*
|
||||||
* @param none
|
* @param null $search
|
||||||
* @return $result will return an object
|
* @param null $start
|
||||||
|
* @param null $limit
|
||||||
|
* @return array|stdClass
|
||||||
*/
|
*/
|
||||||
public function groupList ()
|
public function groupList($search = null, $start = null, $limit = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$result = array ();
|
$criteria = new Criteria('workflow');
|
||||||
$oCriteria = new Criteria( 'workflow' );
|
$criteria->addSelectColumn(GroupwfPeer::GRP_UID);
|
||||||
$oCriteria->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' );
|
$criteria->addSelectColumn(GroupwfPeer::GRP_TITLE);
|
||||||
$oDataset = GroupwfPeer::doSelectRS( $oCriteria );
|
$criteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
|
||||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
$criteria->addAscendingOrderByColumn(GroupwfPeer::GRP_TITLE);
|
||||||
$oDataset->next();
|
if ($search) {
|
||||||
|
$criteria->add(GroupwfPeer::GRP_TITLE, $search, Criteria::EQUAL);
|
||||||
while ($aRow = $oDataset->getRow()) {
|
$criteria->addOr(GroupwfPeer::GRP_TITLE, $search . '%', Criteria::LIKE);
|
||||||
$oGroupwf = new Groupwf();
|
$criteria->addOr(GroupwfPeer::GRP_TITLE, '%' . $search, Criteria::LIKE);
|
||||||
$arrayGroupwf = $oGroupwf->Load( $aRow['GRP_UID'] );
|
$criteria->addOr(GroupwfPeer::GRP_TITLE, '%' . $search . '%', Criteria::LIKE);
|
||||||
$result[] = array ('guid' => $aRow['GRP_UID'],'name' => $arrayGroupwf['GRP_TITLE']
|
}
|
||||||
);
|
if ($start) {
|
||||||
$oDataset->next();
|
$criteria->setOffset($start);
|
||||||
|
}
|
||||||
|
if ($limit) {
|
||||||
|
$criteria->setLimit($limit);
|
||||||
|
}
|
||||||
|
$rs = GroupwfPeer::doSelectRS($criteria);
|
||||||
|
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
$result = array();
|
||||||
|
while ($rs->next()) {
|
||||||
|
$rows = $rs->getRow();
|
||||||
|
$result[] = array('guid' => $rows['GRP_UID'], 'name' => $rows['GRP_TITLE']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$result[] = array ('guid' => $e->getMessage(),'name' => $e->getMessage()
|
$result[] = array('guid' => $e->getMessage(), 'name' => $e->getMessage());
|
||||||
);
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user