Skip to content
Snippets Groups Projects
Verified Commit a906c825 authored by Damien's avatar Damien
Browse files

FEAT #8425 Get groups for indexing

parent 1eba262c
No related branches found
No related tags found
No related merge requests found
......@@ -109,4 +109,23 @@ abstract class GroupBasketModelAbstract
return $aGroupsBaskets;
}
public static function hasBasketByGroupId(array $aArgs)
{
ValidatorModel::notEmpty($aArgs, ['groupId', 'basketId']);
ValidatorModel::stringType($aArgs, ['groupId', 'basketId']);
$aGroupBasket = DatabaseModel::select([
'select' => [1],
'table' => ['groupbasket'],
'where' => ['group_id = ?', 'basket_id = ?'],
'data' => [$aArgs['groupId'], $aArgs['basketId']]
]);
if (empty($aGroupBasket)) {
return false;
}
return true;
}
}
......@@ -14,6 +14,7 @@
namespace SrcCore\controllers;
use Basket\models\GroupBasketModel;
use Group\controllers\ServiceController;
use Group\models\ServiceModel;
use Slim\Http\Request;
......@@ -33,8 +34,6 @@ class CoreController
$aInit['applicationMinorVersion'] = CoreConfigModel::getApplicationVersion()['applicationMinorVersion'];
$aInit['lang'] = CoreConfigModel::getLanguage();
$aInit['user'] = UserModel::getByUserId(['userId' => $GLOBALS['userId'], 'select' => ['id', 'user_id', 'firstname', 'lastname']]);
// $aInit['user']['groups'] = UserModel::getGroupsByUserId(['userId' => $GLOBALS['userId']]);
// $aInit['user']['entities'] = UserModel::getEntitiesById(['userId' => $GLOBALS['userId']]);
$aInit['scriptsToinject'] = [];
$scriptsToInject = [];
......@@ -69,6 +68,7 @@ class CoreController
$user = UserModel::getByUserId(['userId' => $GLOBALS['userId'], 'select' => ['id', 'user_id', 'firstname', 'lastname']]);
$user['groups'] = UserModel::getGroupsByUserId(['userId' => $GLOBALS['userId']]);
$user['entities'] = UserModel::getEntitiesById(['userId' => $GLOBALS['userId']]);
$user['indexingGroups'] = [];
if ($GLOBALS['userId'] == 'superadmin') {
$menu = ServiceModel::getApplicationServicesByXML(['type' => 'menu']);
......@@ -76,6 +76,15 @@ class CoreController
$menu = array_merge($menu, $menuModules);
} else {
$menu = ServiceController::getMenuServicesByUserId(['userId' => $GLOBALS['userId']]);
foreach ($menu as $value) {
if ($value['name'] == _INDEXING_MLB) {
foreach ($user['groups'] as $group) {
if (GroupBasketModel::hasBasketByGroupId(['groupId' => $group['group_id'], 'basketId' => 'IndexingBasket'])) {
$user['indexingGroups'][] = ['groupId' => $group['group_id'], 'label' => $group['group_desc']];
}
}
}
}
}
return $response->withJson([
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment