Merged in bugfix/HOR-4201 (pull request #6245)
HOR-4201 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
parent
fbd4438ddd
commit
ae28e48861
@@ -401,6 +401,38 @@ class RbacUsers extends BaseRbacUsers
|
|||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify if user have the permission
|
||||||
|
*
|
||||||
|
* @param string $userUid
|
||||||
|
* @param string $permission
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function verifyPermission($userUid, $permission)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$criteria = new Criteria('rbac');
|
||||||
|
$criteria->clearSelectColumns();
|
||||||
|
$criteria->add(PermissionsPeer::PER_CODE, $permission, Criteria::EQUAL);
|
||||||
|
$criteria->addJoin(UsersRolesPeer::ROL_UID, RolesPermissionsPeer::ROL_UID, Criteria::LEFT_JOIN);
|
||||||
|
$criteria->addJoin(RolesPermissionsPeer::PER_UID, PermissionsPeer::PER_UID, Criteria::LEFT_JOIN);
|
||||||
|
$criteria->add(UsersRolesPeer::USR_UID, $userUid, Criteria::EQUAL);
|
||||||
|
|
||||||
|
$response = false;
|
||||||
|
$permission = PermissionsPeer::doSelectOne($criteria);
|
||||||
|
if ($permission) {
|
||||||
|
$response = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
} catch (Exception $error) {
|
||||||
|
throw($error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Users
|
// Users
|
||||||
|
|||||||
@@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\BusinessModel;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class GroupTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Group
|
||||||
|
*/
|
||||||
|
protected $group;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return instance Group
|
||||||
|
*
|
||||||
|
* @return Group
|
||||||
|
*/
|
||||||
|
public function getInstanceGroup()
|
||||||
|
{
|
||||||
|
return $this->group;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set instance group
|
||||||
|
*
|
||||||
|
* @param Group $group
|
||||||
|
*/
|
||||||
|
public function setInstanceGroup(Group $group)
|
||||||
|
{
|
||||||
|
$this->group = $group;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the unit tests.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
//Move section
|
||||||
|
global $RBAC;
|
||||||
|
$RBAC->initRBAC();
|
||||||
|
$RBAC->loadUserRolePermission($RBAC->sSystem, '00000000000000000000000000000001');
|
||||||
|
|
||||||
|
$this->setInstanceGroup(new Group());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information Group
|
||||||
|
*
|
||||||
|
* @return array Definition Data Group
|
||||||
|
*/
|
||||||
|
public function testDataGroup()
|
||||||
|
{
|
||||||
|
$response = [
|
||||||
|
'GRP_TITLE' => 'Group Test Unit',
|
||||||
|
'GRP_STATUS' => 'ACTIVE'
|
||||||
|
];
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create group
|
||||||
|
*
|
||||||
|
* @depends testDataGroup
|
||||||
|
*
|
||||||
|
* @param array $dataGroup Information Group
|
||||||
|
*
|
||||||
|
* @return string group Uid
|
||||||
|
*/
|
||||||
|
public function testCreate($dataGroup)
|
||||||
|
{
|
||||||
|
$response = $this->getInstanceGroup()->create($dataGroup);
|
||||||
|
|
||||||
|
$this->assertArrayHasKey('GRP_UID', $response);
|
||||||
|
|
||||||
|
return $response['GRP_UID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get users from a group created recently.
|
||||||
|
*
|
||||||
|
* @depends testCreate
|
||||||
|
* @param string $groupUid Uid group
|
||||||
|
*/
|
||||||
|
public function testGetUsersOfGroup($groupUid)
|
||||||
|
{
|
||||||
|
$response = $this->getInstanceGroup()->getUsers('USERS', $groupUid);
|
||||||
|
$this->assertCount(0, $response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get available users for assign to a group
|
||||||
|
*
|
||||||
|
* @depends testCreate
|
||||||
|
* @param string $groupUid Uid group
|
||||||
|
*/
|
||||||
|
public function testGetUsersAvailable($groupUid)
|
||||||
|
{
|
||||||
|
$response = $this->getInstanceGroup()->getUsers('AVAILABLE-USERS', $groupUid);
|
||||||
|
$this->assertCount(1, $response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain assigned supervisors
|
||||||
|
*
|
||||||
|
* @depends testCreate
|
||||||
|
* @param string $groupUid Uid group
|
||||||
|
*/
|
||||||
|
public function testGetUsersSupervisor($groupUid)
|
||||||
|
{
|
||||||
|
$response = $this->getInstanceGroup()->getUsers('SUPERVISOR', $groupUid);
|
||||||
|
$this->assertCount(0, $response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete group
|
||||||
|
*
|
||||||
|
* @depends testCreate
|
||||||
|
* @expectedException Exception
|
||||||
|
*
|
||||||
|
* @param string $groupUid Uid Group
|
||||||
|
*/
|
||||||
|
public function testDelete($groupUid)
|
||||||
|
{
|
||||||
|
$this->getInstanceGroup()->delete($groupUid);
|
||||||
|
$this->getInstanceGroup()->getGroup($groupUid);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -217,5 +217,99 @@ class GroupUser extends BaseGroupUser
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load All users by groupUid
|
||||||
|
*
|
||||||
|
* @param $groupUid
|
||||||
|
* @param string $type
|
||||||
|
* @param string $filter
|
||||||
|
* @param string $sortField
|
||||||
|
* @param string $sortDir
|
||||||
|
* @param int $start
|
||||||
|
* @param int $limit
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function getUsersbyGroup($groupUid, $type = 'USERS', $filter = '', $sortField = 'USR_USERNAME', $sortDir = 'ASC', $start = 0, $limit = null)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$validSorting = ['USR_UID', 'USR_USERNAME', 'USR_FIRSTNAME', 'USR_LASTNAME', 'USR_EMAIL', 'USR_STATUS'];
|
||||||
|
$response = [
|
||||||
|
'start' => !empty($start) ? $start : 0,
|
||||||
|
'limit' => !empty($limit) ? $limit : 0,
|
||||||
|
'filter' => !empty($filter) ? $filter : '',
|
||||||
|
'data' => []
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$criteria = new Criteria('workflow');
|
||||||
|
$criteria->add(UsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL);
|
||||||
|
if ($type === 'AVAILABLE-USERS') {
|
||||||
|
$subQuery = 'SELECT ' . GroupUserPeer::USR_UID .
|
||||||
|
' FROM ' . GroupUserPeer::TABLE_NAME .
|
||||||
|
' WHERE ' . GroupUserPeer::GRP_UID . ' = "' . $groupUid . '" ' .
|
||||||
|
'UNION SELECT "' . RBAC::GUEST_USER_UID . '"';
|
||||||
|
|
||||||
|
$criteria->add(UsersPeer::USR_UID, UsersPeer::USR_UID . " NOT IN ($subQuery)", Criteria::CUSTOM);
|
||||||
|
} else {
|
||||||
|
//USERS - SUPERVISOR
|
||||||
|
$criteria->addJoin(GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
|
||||||
|
$criteria->add(GroupUserPeer::GRP_UID, $groupUid, Criteria::EQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($filter)) {
|
||||||
|
$criteria->add($criteria->getNewCriterion(UsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE)->
|
||||||
|
addOr($criteria->getNewCriterion(UsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE)->
|
||||||
|
addOr($criteria->getNewCriterion(UsersPeer::USR_LASTNAME, '%' . $filter . '%', Criteria::LIKE))));
|
||||||
|
}
|
||||||
|
$response['total'] = UsersPeer::doCount($criteria);
|
||||||
|
|
||||||
|
$criteria->addSelectColumn(UsersPeer::USR_UID);
|
||||||
|
$criteria->addSelectColumn(UsersPeer::USR_USERNAME);
|
||||||
|
$criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
||||||
|
$criteria->addSelectColumn(UsersPeer::USR_LASTNAME);
|
||||||
|
$criteria->addSelectColumn(UsersPeer::USR_EMAIL);
|
||||||
|
$criteria->addSelectColumn(UsersPeer::USR_STATUS);
|
||||||
|
|
||||||
|
$sort = UsersPeer::USR_USERNAME;
|
||||||
|
if (!empty($sortField) && in_array($sortField, $validSorting, true)) {
|
||||||
|
$sort = UsersPeer::TABLE_NAME . '.' . $sortField;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($sortDir) && strtoupper($sortDir) === 'DESC') {
|
||||||
|
$criteria->addDescendingOrderByColumn($sort);
|
||||||
|
} else {
|
||||||
|
$criteria->addAscendingOrderByColumn($sort);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($start)) {
|
||||||
|
$criteria->setOffset((int)$start);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($limit)) {
|
||||||
|
$criteria->setLimit((int)$limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
$dataSet = UsersPeer::doSelectRS($criteria);
|
||||||
|
$dataSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
$userRbac = new RbacUsers();
|
||||||
|
while ($dataSet->next()) {
|
||||||
|
$row = $dataSet->getRow();
|
||||||
|
if ($type === 'SUPERVISOR') {
|
||||||
|
if ($userRbac->verifyPermission($row['USR_UID'], 'PM_SUPERVISOR')) {
|
||||||
|
$response['data'][] = $row;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$response['data'][] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
|
||||||
|
} catch (Exception $error) {
|
||||||
|
throw $error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,59 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* groups_Ajax.php
|
|
||||||
*
|
|
||||||
* ProcessMaker Open Source Edition
|
|
||||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* 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.,
|
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
|
||||||
*/
|
|
||||||
if (($RBAC_Response = $RBAC->userCanAccess("PM_USERS")) != 1) {
|
if (($RBAC_Response = $RBAC->userCanAccess("PM_USERS")) != 1) {
|
||||||
return $RBAC_Response;
|
return $RBAC_Response;
|
||||||
}
|
}
|
||||||
$_POST['action'] = get_ajax_value('action');
|
$_POST['action'] = get_ajax_value('action');
|
||||||
|
|
||||||
|
$groups = new Groups();
|
||||||
|
$groupWf = new Groupwf();
|
||||||
|
|
||||||
switch ($_POST['action']) {
|
switch ($_POST['action']) {
|
||||||
case 'showUsers':
|
case 'showUsers':
|
||||||
|
$fields = $groupWf->load($_POST['sGroupUID']);
|
||||||
$oGroups = new Groups();
|
|
||||||
$oGroup = new Groupwf();
|
|
||||||
$aFields = $oGroup->load($_POST['sGroupUID']);
|
|
||||||
global $G_PUBLISH;
|
global $G_PUBLISH;
|
||||||
$G_PUBLISH = new Publisher();
|
$G_PUBLISH = new Publisher();
|
||||||
//$G_PUBLISH->AddContent('xmlform', 'xmlform', 'groups/groups_UsersListTitle', '', array('GRP_NAME' => $aFields['GRP_TITLE']));
|
$G_PUBLISH->AddContent('propeltable', 'groups/paged-table2', 'groups/groups_UsersList', $groups->getUsersGroupCriteria($_POST['sGroupUID']), array('GRP_UID' => $_POST['sGroupUID'], 'GRP_NAME' => $fields['GRP_TITLE']));
|
||||||
$G_PUBLISH->AddContent('propeltable', 'groups/paged-table2', 'groups/groups_UsersList', $oGroups->getUsersGroupCriteria($_POST['sGroupUID']), array('GRP_UID' => $_POST['sGroupUID'],'GRP_NAME' => $aFields['GRP_TITLE']));
|
|
||||||
$oHeadPublisher = headPublisher::getSingleton();
|
$oHeadPublisher = headPublisher::getSingleton();
|
||||||
$oHeadPublisher->addScriptCode("groupname=\"{$aFields["GRP_TITLE"]}\";");
|
$oHeadPublisher->addScriptCode("groupname=\"{$fields["GRP_TITLE"]}\";");
|
||||||
G::RenderPage('publish', 'raw');
|
G::RenderPage('publish', 'raw');
|
||||||
break;
|
break;
|
||||||
case 'assignUser':
|
case 'assignUser':
|
||||||
$oGroup = new Groups();
|
$groups->addUserToGroup($_POST['GRP_UID'], $_POST['USR_UID']);
|
||||||
$oGroup->addUserToGroup($_POST['GRP_UID'], $_POST['USR_UID']);
|
|
||||||
break;
|
break;
|
||||||
case 'assignAllUsers':
|
case 'assignAllUsers':
|
||||||
$oGroup = new Groups();
|
foreach (explode(',', $_POST['aUsers']) as $user) {
|
||||||
$aUsers = explode(',', $_POST['aUsers']);
|
$groups->addUserToGroup($_POST['GRP_UID'], $user);
|
||||||
for ($i = 0; $i < count($aUsers); $i ++) {
|
|
||||||
$oGroup->addUserToGroup($_POST['GRP_UID'], $aUsers[$i]);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'ofToAssignUser':
|
case 'ofToAssignUser':
|
||||||
$oGroup = new Groups();
|
$groups->removeUserOfGroup($_POST['GRP_UID'], $_POST['USR_UID']);
|
||||||
$oGroup->removeUserOfGroup($_POST['GRP_UID'], $_POST['USR_UID']);
|
|
||||||
break;
|
break;
|
||||||
case 'verifyGroupname':
|
case 'verifyGroupname':
|
||||||
$_POST['sOriginalGroupname'] = get_ajax_value('sOriginalGroupname');
|
$_POST['sOriginalGroupname'] = get_ajax_value('sOriginalGroupname');
|
||||||
@@ -61,13 +35,12 @@ switch ($_POST['action']) {
|
|||||||
if ($_POST['sOriginalGroupname'] == $_POST['sGroupname']) {
|
if ($_POST['sOriginalGroupname'] == $_POST['sGroupname']) {
|
||||||
echo '0';
|
echo '0';
|
||||||
} else {
|
} else {
|
||||||
$oGroup = new Groupwf();
|
$oCriteria = $groupWf->loadByGroupname($_POST['sGroupname']);
|
||||||
$oCriteria = $oGroup->loadByGroupname($_POST['sGroupname']);
|
|
||||||
$oDataset = GroupwfPeer::doSelectRS($oCriteria);
|
$oDataset = GroupwfPeer::doSelectRS($oCriteria);
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
$oDataset->next();
|
$oDataset->next();
|
||||||
$aRow = $oDataset->getRow();
|
$aRow = $oDataset->getRow();
|
||||||
if (! $aRow) {
|
if (!$aRow) {
|
||||||
echo '0';
|
echo '0';
|
||||||
} else {
|
} else {
|
||||||
echo '1';
|
echo '1';
|
||||||
@@ -75,16 +48,15 @@ switch ($_POST['action']) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'groupsList':
|
case 'groupsList':
|
||||||
$co = new Configurations();
|
$config = new Configurations();
|
||||||
$config = $co->getConfiguration('groupList', 'pageSize', '', $_SESSION['USER_LOGGED']);
|
$config = $config->getConfiguration('groupList', 'pageSize', '', $_SESSION['USER_LOGGED']);
|
||||||
$env = $co->getConfiguration('ENVIRONMENT_SETTINGS', '');
|
|
||||||
$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
|
$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
|
||||||
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
|
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
|
||||||
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size;
|
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size;
|
||||||
$filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : '';
|
$filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : '';
|
||||||
|
|
||||||
$sortField = isset($_REQUEST["sort"])? $_REQUEST["sort"] : "";
|
$sortField = isset($_REQUEST["sort"]) ? $_REQUEST["sort"] : "";
|
||||||
$sortDir = isset($_REQUEST["dir"])? $_REQUEST["dir"] : "";
|
$sortDir = isset($_REQUEST["dir"]) ? $_REQUEST["dir"] : "";
|
||||||
|
|
||||||
global $RBAC;
|
global $RBAC;
|
||||||
if ($limit == $start) {
|
if ($limit == $start) {
|
||||||
@@ -96,17 +68,15 @@ switch ($_POST['action']) {
|
|||||||
require_once PATH_CONTROLLERS . 'adminProxy.php';
|
require_once PATH_CONTROLLERS . 'adminProxy.php';
|
||||||
$uxList = adminProxy::getUxTypesList();
|
$uxList = adminProxy::getUxTypesList();
|
||||||
|
|
||||||
$groups = new Groupwf();
|
$data = $groupWf->getAllGroup($start, $limit, $filter, $sortField, $sortDir, true);
|
||||||
|
|
||||||
$data = $groups->getAllGroup($start, $limit, $filter, $sortField, $sortDir, true);
|
|
||||||
$result = $data['rows'];
|
$result = $data['rows'];
|
||||||
|
|
||||||
$totalRows = 0;
|
$totalRows = 0;
|
||||||
$arrData = array();
|
$arrData = array();
|
||||||
foreach ($result as $results) {
|
foreach ($result as $results) {
|
||||||
$totalRows ++;
|
$totalRows++;
|
||||||
$results['CON_VALUE'] = str_replace(array("<",">"
|
$results['CON_VALUE'] = str_replace(array("<", ">"
|
||||||
), array("<",">"
|
), array("<", ">"
|
||||||
), $results['GRP_TITLE']);
|
), $results['GRP_TITLE']);
|
||||||
$results['GRP_TASKS'] = isset($aTask[$results['GRP_UID']]) ? $aTask[$results['GRP_UID']] : 0;
|
$results['GRP_TASKS'] = isset($aTask[$results['GRP_UID']]) ? $aTask[$results['GRP_UID']] : 0;
|
||||||
$arrData[] = $results;
|
$arrData[] = $results;
|
||||||
@@ -120,8 +90,7 @@ switch ($_POST['action']) {
|
|||||||
echo G::json_encode($result);
|
echo G::json_encode($result);
|
||||||
break;
|
break;
|
||||||
case 'exitsGroupName':
|
case 'exitsGroupName':
|
||||||
$oGroup = new Groupwf();
|
$oCriteria = $groupWf->loadByGroupname($_POST['GRP_NAME']);
|
||||||
$oCriteria = $oGroup->loadByGroupname($_POST['GRP_NAME']);
|
|
||||||
$oDataset = GroupwfPeer::doSelectRS($oCriteria);
|
$oDataset = GroupwfPeer::doSelectRS($oCriteria);
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
$oDataset->next();
|
$oDataset->next();
|
||||||
@@ -134,9 +103,8 @@ switch ($_POST['action']) {
|
|||||||
$newGroup['GRP_STATUS'] = ($_POST['status'] == '1') ? 'ACTIVE' : 'INACTIVE';
|
$newGroup['GRP_STATUS'] = ($_POST['status'] == '1') ? 'ACTIVE' : 'INACTIVE';
|
||||||
$newGroup['GRP_TITLE'] = trim($_POST['name']);
|
$newGroup['GRP_TITLE'] = trim($_POST['name']);
|
||||||
unset($newGroup['GRP_UID']);
|
unset($newGroup['GRP_UID']);
|
||||||
$group = new Groupwf();
|
$groupWf->create($newGroup);
|
||||||
$group->create($newGroup);
|
G::auditLog("CreateGroup", "Group Name: " . $newGroup['GRP_TITLE'] . " - Group Status: " . $newGroup['GRP_STATUS']);
|
||||||
G::auditLog("CreateGroup", "Group Name: ".$newGroup['GRP_TITLE']." - Group Status: ".$newGroup['GRP_STATUS']);
|
|
||||||
|
|
||||||
echo '{success: true}';
|
echo '{success: true}';
|
||||||
|
|
||||||
@@ -145,18 +113,16 @@ switch ($_POST['action']) {
|
|||||||
$editGroup['GRP_UID'] = $_POST['grp_uid'];
|
$editGroup['GRP_UID'] = $_POST['grp_uid'];
|
||||||
$editGroup['GRP_STATUS'] = ($_POST['status'] == '1') ? 'ACTIVE' : 'INACTIVE';
|
$editGroup['GRP_STATUS'] = ($_POST['status'] == '1') ? 'ACTIVE' : 'INACTIVE';
|
||||||
$editGroup['GRP_TITLE'] = trim($_POST['name']);
|
$editGroup['GRP_TITLE'] = trim($_POST['name']);
|
||||||
$group = new Groupwf();
|
$groupWf->update($editGroup);
|
||||||
$group->update($editGroup);
|
G::auditLog("UpdateGroup", "Group Name: " . $editGroup['GRP_TITLE'] . " - Group ID: (" . $_POST['grp_uid'] . ") - Group Status: " . $editGroup['GRP_STATUS']);
|
||||||
G::auditLog("UpdateGroup", "Group Name: ".$editGroup['GRP_TITLE']." - Group ID: (".$_POST['grp_uid'].") - Group Status: ".$editGroup['GRP_STATUS']);
|
|
||||||
echo '{success: true}';
|
echo '{success: true}';
|
||||||
break;
|
break;
|
||||||
case 'deleteGroup':
|
case 'deleteGroup':
|
||||||
$group = new Groupwf();
|
if (!isset($_POST['GRP_UID'])) {
|
||||||
if (! isset($_POST['GRP_UID'])) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$group->remove(urldecode($_POST['GRP_UID']));
|
$groupWf->remove(urldecode($_POST['GRP_UID']));
|
||||||
G::auditLog("DeleteGroup", "Group Name: ".$_POST['GRP_NAME']." Group ID: (".$_POST['GRP_UID'].") ");
|
G::auditLog("DeleteGroup", "Group Name: " . $_POST['GRP_NAME'] . " Group ID: (" . $_POST['GRP_UID'] . ") ");
|
||||||
require_once 'classes/model/TaskUser.php';
|
require_once 'classes/model/TaskUser.php';
|
||||||
$oProcess = new TaskUser();
|
$oProcess = new TaskUser();
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria('workflow');
|
||||||
@@ -175,7 +141,7 @@ switch ($_POST['action']) {
|
|||||||
$criteria->add(ProcessUserPeer::USR_UID, $_POST['GRP_UID']);
|
$criteria->add(ProcessUserPeer::USR_UID, $_POST['GRP_UID']);
|
||||||
$criteria->add(ProcessUserPeer::PU_TYPE, 'GROUP_SUPERVISOR');
|
$criteria->add(ProcessUserPeer::PU_TYPE, 'GROUP_SUPERVISOR');
|
||||||
ProcessUserPeer::doDelete($criteria);
|
ProcessUserPeer::doDelete($criteria);
|
||||||
|
|
||||||
//Delete group users
|
//Delete group users
|
||||||
require_once 'classes/model/GroupUser.php';
|
require_once 'classes/model/GroupUser.php';
|
||||||
$criteria = new Criteria('workflow');
|
$criteria = new Criteria('workflow');
|
||||||
@@ -185,130 +151,36 @@ switch ($_POST['action']) {
|
|||||||
echo '{success: true}';
|
echo '{success: true}';
|
||||||
break;
|
break;
|
||||||
case 'assignedMembers':
|
case 'assignedMembers':
|
||||||
|
|
||||||
$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'] : '';
|
|
||||||
|
|
||||||
$sGroupUID = $_REQUEST['gUID'];
|
|
||||||
|
|
||||||
$aUsers = array();
|
|
||||||
$oCriteria = new Criteria('workflow');
|
|
||||||
$oCriteria->addSelectColumn('COUNT(*) AS CNT');
|
|
||||||
$oCriteria->addJoin(GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
|
|
||||||
$oCriteria->add(GroupUserPeer::GRP_UID, $sGroupUID);
|
|
||||||
$oCriteria->add(UsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL);
|
|
||||||
$filter = (isset($_POST['textFilter'])) ? $_POST['textFilter'] : '';
|
|
||||||
if ($filter != '') {
|
|
||||||
$oCriteria->add($oCriteria->getNewCriterion(UsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_LASTNAME, '%' . $filter . '%', Criteria::LIKE))));
|
|
||||||
}
|
|
||||||
$oDataset = UsersPeer::DoSelectRs($oCriteria);
|
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
||||||
$oDataset->next();
|
|
||||||
$row = $oDataset->getRow();
|
|
||||||
$totalRows = $row['CNT'];
|
|
||||||
|
|
||||||
$oCriteria = new Criteria('workflow');
|
|
||||||
$oCriteria->addSelectColumn(GroupUserPeer::GRP_UID);
|
|
||||||
$oCriteria->addSelectColumn(UsersPeer::USR_UID);
|
|
||||||
$oCriteria->addSelectColumn(UsersPeer::USR_USERNAME);
|
|
||||||
$oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
|
||||||
$oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
|
|
||||||
$oCriteria->addSelectColumn(UsersPeer::USR_EMAIL);
|
|
||||||
$oCriteria->addSelectColumn(UsersPeer::USR_STATUS);
|
|
||||||
$oCriteria->addJoin(GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
|
|
||||||
$oCriteria->add(GroupUserPeer::GRP_UID, $sGroupUID);
|
|
||||||
$oCriteria->add(UsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL);
|
|
||||||
$filter = (isset($_POST['textFilter'])) ? $_POST['textFilter'] : '';
|
|
||||||
if ($filter != '') {
|
|
||||||
$oCriteria->add($oCriteria->getNewCriterion(UsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_LASTNAME, '%' . $filter . '%', Criteria::LIKE))));
|
|
||||||
}
|
|
||||||
$oCriteria->setOffset($start);
|
|
||||||
$oCriteria->setLimit($limit);
|
|
||||||
|
|
||||||
$oDataset = UsersPeer::doSelectRS($oCriteria);
|
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
||||||
$arrData = array();
|
|
||||||
while ($oDataset->next()) {
|
|
||||||
$arrData[] = $oDataset->getRow();
|
|
||||||
}
|
|
||||||
G::header('Content-Type: application/json');
|
|
||||||
echo '{success: true, members: ' . G::json_encode($arrData) . ', total_users: ' . $totalRows . '}';
|
|
||||||
break;
|
|
||||||
case 'availableMembers':
|
case 'availableMembers':
|
||||||
$co = new Configurations();
|
$config = new Configurations();
|
||||||
$config = $co->getConfiguration('groupList', 'pageSize', '', $_SESSION['USER_LOGGED']);
|
$inputFilter = new InputFilter();
|
||||||
$env = $co->getConfiguration('ENVIRONMENT_SETTINGS', '');
|
|
||||||
|
$config = $config->getConfiguration('groupList', 'pageSize', '', $_SESSION['USER_LOGGED']);
|
||||||
$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
|
$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
|
||||||
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
|
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
|
||||||
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size;
|
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size;
|
||||||
$filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : '';
|
$filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : '';
|
||||||
|
$groupUid = $inputFilter->quoteSmart($_REQUEST['gUID'], Propel::getConnection("workflow")->getResource());
|
||||||
|
|
||||||
$inputFilter = new InputFilter();
|
$groupUsers = new GroupUser();
|
||||||
$subQuery = "SELECT " . GroupUserPeer::USR_UID .
|
$type = $_POST['action'] === 'assignedMembers' ? 'USERS' : 'AVAILABLE-USERS';
|
||||||
" FROM " . GroupUserPeer::TABLE_NAME .
|
$data = $groupUsers->getUsersbyGroup($groupUid, $type, $filter, 'USR_USERNAME', 'ASC', $start, $limit);
|
||||||
" WHERE " . GroupUserPeer::GRP_UID . " = '" .
|
|
||||||
$inputFilter->quoteSmart($_REQUEST['gUID'], Propel::getConnection("workflow")) . "'\n" .
|
|
||||||
"UNION SELECT '" . RBAC::GUEST_USER_UID . "'";
|
|
||||||
|
|
||||||
$aUsers = array();
|
|
||||||
$oCriteria = new Criteria('workflow');
|
|
||||||
$oCriteria->addSelectColumn('COUNT(*) AS CNT');
|
|
||||||
$oCriteria->add(UsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL);
|
|
||||||
$oCriteria->add(UsersPeer::USR_UID, UsersPeer::USR_UID . " NOT IN ($subQuery)", Criteria::CUSTOM);
|
|
||||||
$filter = (isset($_POST['textFilter'])) ? $_POST['textFilter'] : '';
|
|
||||||
if ($filter != '') {
|
|
||||||
$oCriteria->add($oCriteria->getNewCriterion(UsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_LASTNAME, '%' . $filter . '%', Criteria::LIKE))));
|
|
||||||
}
|
|
||||||
$oDataset = UsersPeer::DoSelectRs($oCriteria);
|
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
||||||
$oDataset->next();
|
|
||||||
$row = $oDataset->getRow();
|
|
||||||
$totalRows = $row['CNT'];
|
|
||||||
|
|
||||||
$oCriteria = new Criteria('workflow');
|
|
||||||
$oCriteria->addSelectColumn(UsersPeer::USR_UID);
|
|
||||||
$oCriteria->addSelectColumn(UsersPeer::USR_USERNAME);
|
|
||||||
$oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
|
||||||
$oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
|
|
||||||
$oCriteria->addSelectColumn(UsersPeer::USR_EMAIL);
|
|
||||||
$oCriteria->addSelectColumn(UsersPeer::USR_STATUS);
|
|
||||||
$oCriteria->add(UsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL);
|
|
||||||
$oCriteria->add(UsersPeer::USR_UID, UsersPeer::USR_UID . " NOT IN ($subQuery)", Criteria::CUSTOM);
|
|
||||||
$filter = (isset($_POST['textFilter'])) ? $_POST['textFilter'] : '';
|
|
||||||
if ($filter != '') {
|
|
||||||
$oCriteria->add($oCriteria->getNewCriterion(UsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_LASTNAME, '%' . $filter . '%', Criteria::LIKE))));
|
|
||||||
}
|
|
||||||
$oCriteria->addAscendingOrderByColumn(UsersPeer::USR_USERNAME);
|
|
||||||
$oCriteria->setOffset($start);
|
|
||||||
$oCriteria->setLimit($limit);
|
|
||||||
$oDataset = UsersPeer::doSelectRS($oCriteria);
|
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
||||||
$arrData = array();
|
|
||||||
while ($oDataset->next()) {
|
|
||||||
$arrData[] = $oDataset->getRow();
|
|
||||||
}
|
|
||||||
G::header('Content-Type: application/json');
|
G::header('Content-Type: application/json');
|
||||||
echo '{success: true, members: ' . G::json_encode($arrData) . ', total_users: ' . $totalRows . '}';
|
echo '{success: true, members: ' . G::json_encode($data["data"]) . ', total_users: ' . $data["total"] . '}';
|
||||||
break;
|
break;
|
||||||
case 'assignUsersToGroupsMultiple':
|
case 'assignUsersToGroupsMultiple':
|
||||||
$GRP_UID = $_POST['GRP_UID'];
|
$GRP_UID = $_POST['GRP_UID'];
|
||||||
$uUIDs = explode(',', $_POST['USR_UID']);
|
$uUIDs = explode(',', $_POST['USR_UID']);
|
||||||
$oGroup = new Groups();
|
|
||||||
foreach ($uUIDs as $USR_UID) {
|
foreach ($uUIDs as $USR_UID) {
|
||||||
$oGroup->addUserToGroup($GRP_UID, $USR_UID);
|
$groups->addUserToGroup($GRP_UID, $USR_UID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'deleteUsersToGroupsMultiple':
|
case 'deleteUsersToGroupsMultiple':
|
||||||
$GRP_UID = $_POST['GRP_UID'];
|
$GRP_UID = $_POST['GRP_UID'];
|
||||||
$uUIDs = explode(',', $_POST['USR_UID']);
|
$uUIDs = explode(',', $_POST['USR_UID']);
|
||||||
$oGroup = new Groups();
|
|
||||||
foreach ($uUIDs as $USR_UID) {
|
foreach ($uUIDs as $USR_UID) {
|
||||||
$oGroup->removeUserOfGroup($GRP_UID, $USR_UID);
|
$groups->removeUserOfGroup($GRP_UID, $USR_UID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'updatePageSize':
|
case 'updatePageSize':
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ProcessMaker\BusinessModel;
|
namespace ProcessMaker\BusinessModel;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use GroupUser;
|
||||||
|
use Groupwf;
|
||||||
|
use ProcessMaker\BusinessModel\Process;
|
||||||
|
|
||||||
class Group
|
class Group
|
||||||
{
|
{
|
||||||
private $arrayFieldDefinition = array(
|
private $arrayFieldDefinition = array(
|
||||||
@@ -29,7 +35,7 @@ class Group
|
|||||||
foreach ($this->arrayFieldDefinition as $key => $value) {
|
foreach ($this->arrayFieldDefinition as $key => $value) {
|
||||||
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
|
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,7 +53,7 @@ class Group
|
|||||||
$this->formatFieldNameInUppercase = $flag;
|
$this->formatFieldNameInUppercase = $flag;
|
||||||
|
|
||||||
$this->setArrayFieldNameForException($this->arrayFieldNameForException);
|
$this->setArrayFieldNameForException($this->arrayFieldNameForException);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +71,7 @@ class Group
|
|||||||
foreach ($arrayData as $key => $value) {
|
foreach ($arrayData as $key => $value) {
|
||||||
$this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value);
|
$this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,7 +87,7 @@ class Group
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
|
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +123,7 @@ class Group
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,12 +139,12 @@ class Group
|
|||||||
public function throwExceptionIfNotExistsGroup($groupUid, $fieldNameForException)
|
public function throwExceptionIfNotExistsGroup($groupUid, $fieldNameForException)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$group = new \Groupwf();
|
$group = new Groupwf();
|
||||||
|
|
||||||
if (!$group->GroupwfExists($groupUid)) {
|
if (!$group->GroupwfExists($groupUid)) {
|
||||||
throw new \Exception(\G::LoadTranslation("ID_GROUP_DOES_NOT_EXIST", array($fieldNameForException, $groupUid)));
|
throw new Exception(\G::LoadTranslation("ID_GROUP_DOES_NOT_EXIST", array($fieldNameForException, $groupUid)));
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,9 +162,9 @@ class Group
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($this->existsTitle($groupTitle, $groupUidExclude)) {
|
if ($this->existsTitle($groupTitle, $groupUidExclude)) {
|
||||||
throw new \Exception(\G::LoadTranslation("ID_GROUP_TITLE_ALREADY_EXISTS", array($fieldNameForException, $groupTitle)));
|
throw new Exception(\G::LoadTranslation("ID_GROUP_TITLE_ALREADY_EXISTS", array($fieldNameForException, $groupTitle)));
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,38 +172,39 @@ class Group
|
|||||||
/**
|
/**
|
||||||
* Create Group
|
* Create Group
|
||||||
*
|
*
|
||||||
* @param array $arrayData Data
|
* @param array $arrayData Information of group
|
||||||
*
|
*
|
||||||
* return array Return data of the new Group created
|
* @return array Return data of the new Group created
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function create($arrayData)
|
public function create($arrayData)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||||
|
|
||||||
unset($arrayData["GRP_UID"]);
|
unset($arrayData['GRP_UID']);
|
||||||
|
|
||||||
//Verify data
|
//Verify data
|
||||||
$process = new \ProcessMaker\BusinessModel\Process();
|
$process = new Process();
|
||||||
|
|
||||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
|
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
|
||||||
|
|
||||||
$this->throwExceptionIfExistsTitle($arrayData["GRP_TITLE"], $this->arrayFieldNameForException["groupTitle"]);
|
$this->throwExceptionIfExistsTitle($arrayData['GRP_TITLE'], $this->arrayFieldNameForException['groupTitle']);
|
||||||
|
|
||||||
//Create
|
//Create
|
||||||
$group = new \Groupwf();
|
$group = new Groupwf();
|
||||||
|
|
||||||
$groupUid = $group->create($arrayData);
|
$groupUid = $group->create($arrayData);
|
||||||
|
|
||||||
//Return
|
//Return
|
||||||
$arrayData = array_merge(array("GRP_UID" => $groupUid), $arrayData);
|
$arrayData = array_merge(['GRP_UID' => $groupUid], $arrayData);
|
||||||
|
|
||||||
if (!$this->formatFieldNameInUppercase) {
|
if (!$this->formatFieldNameInUppercase) {
|
||||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $arrayData;
|
return $arrayData;
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,10 +212,11 @@ class Group
|
|||||||
/**
|
/**
|
||||||
* Update Group
|
* Update Group
|
||||||
*
|
*
|
||||||
* @param string $groupUid Unique id of Group
|
* @param string $groupUid Unique id of group
|
||||||
* @param array $arrayData Data
|
* @param array $arrayData information of group
|
||||||
*
|
*
|
||||||
* return array Return data of the Group updated
|
* @return array Return data of the Group updated
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function update($groupUid, $arrayData)
|
public function update($groupUid, $arrayData)
|
||||||
{
|
{
|
||||||
@@ -216,32 +224,32 @@ class Group
|
|||||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||||
|
|
||||||
//Verify data
|
//Verify data
|
||||||
$process = new \ProcessMaker\BusinessModel\Process();
|
$process = new Process();
|
||||||
|
|
||||||
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
|
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException['groupUid']);
|
||||||
|
|
||||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false);
|
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false);
|
||||||
|
|
||||||
if (isset($arrayData["GRP_TITLE"])) {
|
if (isset($arrayData['GRP_TITLE'])) {
|
||||||
$this->throwExceptionIfExistsTitle($arrayData["GRP_TITLE"], $this->arrayFieldNameForException["groupTitle"], $groupUid);
|
$this->throwExceptionIfExistsTitle($arrayData['GRP_TITLE'], $this->arrayFieldNameForException['groupTitle'], $groupUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update
|
//Update
|
||||||
$group = new \Groupwf();
|
$group = new Groupwf();
|
||||||
|
|
||||||
$arrayData["GRP_UID"] = $groupUid;
|
$arrayData['GRP_UID'] = $groupUid;
|
||||||
|
|
||||||
$result = $group->update($arrayData);
|
$result = $group->update($arrayData);
|
||||||
|
|
||||||
//Return
|
//Return
|
||||||
unset($arrayData["GRP_UID"]);
|
unset($arrayData['GRP_UID']);
|
||||||
|
|
||||||
if (!$this->formatFieldNameInUppercase) {
|
if (!$this->formatFieldNameInUppercase) {
|
||||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $arrayData;
|
return $arrayData;
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,11 +270,11 @@ class Group
|
|||||||
$arrayTotalTasksByGroup = $this->getTotalTasksByGroup($groupUid);
|
$arrayTotalTasksByGroup = $this->getTotalTasksByGroup($groupUid);
|
||||||
|
|
||||||
if (isset($arrayTotalTasksByGroup[$groupUid]) && $arrayTotalTasksByGroup[$groupUid] > 0) {
|
if (isset($arrayTotalTasksByGroup[$groupUid]) && $arrayTotalTasksByGroup[$groupUid] > 0) {
|
||||||
throw new \Exception(\G::LoadTranslation("ID_GROUP_CANNOT_DELETE_WHILE_ASSIGNED_TO_TASK"));
|
throw new Exception(\G::LoadTranslation("ID_GROUP_CANNOT_DELETE_WHILE_ASSIGNED_TO_TASK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete
|
//Delete
|
||||||
$group = new \Groupwf();
|
$group = new Groupwf();
|
||||||
|
|
||||||
$result = $group->remove($groupUid);
|
$result = $group->remove($groupUid);
|
||||||
|
|
||||||
@@ -291,7 +299,7 @@ class Group
|
|||||||
$criteria->add(\ProcessUserPeer::PU_TYPE, "GROUP_SUPERVISOR");
|
$criteria->add(\ProcessUserPeer::PU_TYPE, "GROUP_SUPERVISOR");
|
||||||
|
|
||||||
\ProcessUserPeer::doDelete($criteria);
|
\ProcessUserPeer::doDelete($criteria);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -312,7 +320,7 @@ class Group
|
|||||||
$criteria->addSelectColumn(\GroupwfPeer::GRP_LDAP_DN);
|
$criteria->addSelectColumn(\GroupwfPeer::GRP_LDAP_DN);
|
||||||
$criteria->addSelectColumn(\GroupwfPeer::GRP_UX);
|
$criteria->addSelectColumn(\GroupwfPeer::GRP_UX);
|
||||||
return $criteria;
|
return $criteria;
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -359,7 +367,7 @@ class Group
|
|||||||
|
|
||||||
//Return
|
//Return
|
||||||
return $arrayData;
|
return $arrayData;
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -406,7 +414,7 @@ class Group
|
|||||||
|
|
||||||
//Return
|
//Return
|
||||||
return $arrayData;
|
return $arrayData;
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -428,7 +436,7 @@ class Group
|
|||||||
$this->getFieldNameByFormatFieldName("GRP_USERS") => $record["GRP_USERS"],
|
$this->getFieldNameByFormatFieldName("GRP_USERS") => $record["GRP_USERS"],
|
||||||
$this->getFieldNameByFormatFieldName("GRP_TASKS") => $record["GRP_TASKS"]
|
$this->getFieldNameByFormatFieldName("GRP_TASKS") => $record["GRP_TASKS"]
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -452,7 +460,7 @@ class Group
|
|||||||
$numRecTotal = 0;
|
$numRecTotal = 0;
|
||||||
|
|
||||||
//Verify data
|
//Verify data
|
||||||
$process = new \ProcessMaker\BusinessModel\Process();
|
$process = new Process();
|
||||||
|
|
||||||
$process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException);
|
$process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException);
|
||||||
|
|
||||||
@@ -561,7 +569,7 @@ class Group
|
|||||||
$filterName => (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]))? $arrayFilterData["filter"] : "",
|
$filterName => (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]))? $arrayFilterData["filter"] : "",
|
||||||
"data" => $arrayGroup
|
"data" => $arrayGroup
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -600,7 +608,7 @@ class Group
|
|||||||
|
|
||||||
//Return
|
//Return
|
||||||
return $this->getGroupDataFromRecord($row);
|
return $this->getGroupDataFromRecord($row);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -656,7 +664,7 @@ class Group
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $criteria;
|
return $criteria;
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -679,7 +687,7 @@ class Group
|
|||||||
$this->getFieldNameByFormatFieldName("USR_EMAIL") => $record["USR_EMAIL"] . "",
|
$this->getFieldNameByFormatFieldName("USR_EMAIL") => $record["USR_EMAIL"] . "",
|
||||||
$this->getFieldNameByFormatFieldName("USR_STATUS") => $record["USR_STATUS"]
|
$this->getFieldNameByFormatFieldName("USR_STATUS") => $record["USR_STATUS"]
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -708,123 +716,41 @@ class Group
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all Users of a Group
|
* Get all users of a group
|
||||||
*
|
*
|
||||||
* @param string $option Option (USERS, AVAILABLE-USERS)
|
* @param string $option types USERS|AVAILABLE-USERS|SUPERVISOR
|
||||||
* @param string $groupUid Unique id of Group
|
* @param string $groupUid Unique id of Group
|
||||||
* @param array $arrayFilterData Data of the filters
|
* @param array $arrayFilterData Data of the filters
|
||||||
* @param string $sortField Field name to sort
|
* @param string $sortField Field name to sort
|
||||||
* @param string $sortDir Direction of sorting (ASC, DESC)
|
* @param string $sortDir Direction of sorting (ASC, DESC)
|
||||||
* @param int $start Start
|
* @param int $start start
|
||||||
* @param int $limit Limit
|
* @param int $limit limit
|
||||||
*
|
*
|
||||||
* return array Return an array with all Users of a Group
|
* @return array Return an array with all Users of a Group
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function getUsers($option, $groupUid, $arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
|
public function getUsers($option, $groupUid, $arrayFilterData = [], $sortField = 'USR_USERNAME', $sortDir = 'ASC', $start = 0, $limit = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$arrayUser = array();
|
|
||||||
|
|
||||||
//Verify data
|
//Verify data
|
||||||
$process = new \ProcessMaker\BusinessModel\Process();
|
$process = new Process();
|
||||||
|
|
||||||
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
|
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException['groupUid']);
|
||||||
|
$process->throwExceptionIfDataNotMetPagerVarDefinition(['start' => $start, 'limit' => $limit], $this->arrayFieldNameForException);
|
||||||
|
|
||||||
$process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException);
|
$filter = isset($arrayFilterData['filter']) ? $arrayFilterData['filter'] : '';
|
||||||
|
|
||||||
//Get data
|
$groupUsers = new GroupUser();
|
||||||
if (!is_null($limit) && $limit . "" == "0") {
|
$data = $groupUsers->getUsersbyGroup($groupUid, $option, $filter, $sortField, $sortDir, $start, $limit);
|
||||||
return $arrayUser;
|
|
||||||
|
$response = [];
|
||||||
|
foreach ($data['data'] as $user)
|
||||||
|
{
|
||||||
|
$response[] = $this->getUserDataFromRecord($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
//SQL
|
return $response;
|
||||||
switch ($option) {
|
} catch (Exception $e) {
|
||||||
case "SUPERVISOR":
|
|
||||||
$flagPermission = true;
|
|
||||||
//Criteria for Supervisor
|
|
||||||
$criteria = $this->getUserCriteria($groupUid, $arrayFilterData);
|
|
||||||
break;
|
|
||||||
case "USERS":
|
|
||||||
//Criteria
|
|
||||||
$criteria = $this->getUserCriteria($groupUid, $arrayFilterData);
|
|
||||||
break;
|
|
||||||
case "AVAILABLE-USERS":
|
|
||||||
//Get Uids
|
|
||||||
$arrayUid = array();
|
|
||||||
|
|
||||||
$criteria = $this->getUserCriteria($groupUid);
|
|
||||||
|
|
||||||
$rsCriteria = \UsersPeer::doSelectRS($criteria);
|
|
||||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
||||||
|
|
||||||
while ($rsCriteria->next()) {
|
|
||||||
$row = $rsCriteria->getRow();
|
|
||||||
|
|
||||||
$arrayUid[] = $row["USR_UID"];
|
|
||||||
}
|
|
||||||
|
|
||||||
//Criteria
|
|
||||||
$criteria = $this->getUserCriteria("", $arrayFilterData, $arrayUid);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//SQL
|
|
||||||
if (!is_null($sortField) && trim($sortField) != "") {
|
|
||||||
$sortField = strtoupper($sortField);
|
|
||||||
|
|
||||||
if (in_array($sortField, array("USR_UID", "USR_USERNAME", "USR_FIRSTNAME", "USR_LASTNAME", "USR_EMAIL", "USR_STATUS"))) {
|
|
||||||
$sortField = \UsersPeer::TABLE_NAME . "." . $sortField;
|
|
||||||
} else {
|
|
||||||
$sortField = \UsersPeer::USR_USERNAME;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$sortField = \UsersPeer::USR_USERNAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_null($sortDir) && trim($sortDir) != "" && strtoupper($sortDir) == "DESC") {
|
|
||||||
$criteria->addDescendingOrderByColumn($sortField);
|
|
||||||
} else {
|
|
||||||
$criteria->addAscendingOrderByColumn($sortField);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_null($start)) {
|
|
||||||
$criteria->setOffset((int)($start));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_null($limit)) {
|
|
||||||
$criteria->setLimit((int)($limit));
|
|
||||||
}
|
|
||||||
|
|
||||||
$rsCriteria = \UsersPeer::doSelectRS($criteria);
|
|
||||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
||||||
|
|
||||||
if (isset($flagPermission) && $flagPermission) {
|
|
||||||
|
|
||||||
while ($rsCriteria->next()) {
|
|
||||||
$row = $rsCriteria->getRow();
|
|
||||||
|
|
||||||
$aPermissions = $this->loadUserRolePermission("PROCESSMAKER", $row['USR_UID']);
|
|
||||||
$bInclude = false;
|
|
||||||
|
|
||||||
foreach ($aPermissions as $aPermission) {
|
|
||||||
if ($aPermission['PER_CODE'] == 'PM_SUPERVISOR') {
|
|
||||||
$bInclude = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($bInclude) {
|
|
||||||
$arrayUser[] = $this->getUserDataFromRecord($row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while ($rsCriteria->next()) {
|
|
||||||
$row = $rsCriteria->getRow();
|
|
||||||
|
|
||||||
$arrayUser[] = $this->getUserDataFromRecord($row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Return
|
|
||||||
return $arrayUser;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user