diff --git a/sql/develop.sql b/sql/develop.sql index 513bce53078c0834ea9753efebe5681c60b21214..35edb1c9a34161e3a12aaa11ae627ea606ef8961 100755 --- a/sql/develop.sql +++ b/sql/develop.sql @@ -7,14 +7,6 @@ -- *************************************************************************-- UPDATE parameters SET param_value_string = '19.12' WHERE id = 'database_version'; -ALTER TABLE notif_email_stack ALTER COLUMN attachments TYPE text; - -DO $$ BEGIN - IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'users') AND attname = 'enabled') THEN - UPDATE users SET status = 'SPD' WHERE enabled = 'N' and (status = 'OK' or status = 'ABS'); - ALTER TABLE users DROP COLUMN IF EXISTS enabled; - END IF; -END$$; /* FULL TEXT */ DELETE FROM docservers where docserver_type_id = 'FULLTEXT'; @@ -39,10 +31,39 @@ ALTER TABLE usergroups ADD COLUMN can_index boolean NOT NULL DEFAULT FALSE; ALTER TABLE usergroups DROP COLUMN IF EXISTS indexation_parameters; ALTER TABLE usergroups ADD COLUMN indexation_parameters jsonb NOT NULL DEFAULT '{"actions" : [], "entities" : [], "keywords" : []}'; +/* BASKETS LIST EVENT */ ALTER TABLE groupbasket DROP COLUMN IF EXISTS list_event; ALTER TABLE groupbasket ADD COLUMN list_event character varying(255); -/* REFACTORING */ +/* FOLDERS */ +ALTER TABLE folders RENAME TO folder_tmp; +CREATE TABLE folders +( + id serial NOT NULL, + label character varying(255) NOT NULL, + public boolean NOT NULL, + sharing jsonb DEFAULT '{"entities" : []}', + user_id INTEGER NOT NULL, + parent_id INTEGER, + CONSTRAINT folders_pkey PRIMARY KEY (id) +) +WITH (OIDS=FALSE); + +/* REFACTORING DATA */ +DELETE FROM usergroup_content WHERE group_id in (SELECT group_id FROM usergroups WHERE enabled = 'N'); +DELETE FROM usergroups_reports WHERE group_id in (SELECT group_id FROM usergroups WHERE enabled = 'N'); +DELETE FROM usergroups_services WHERE group_id in (SELECT group_id FROM usergroups WHERE enabled = 'N'); +DELETE FROM security WHERE group_id in (SELECT group_id FROM usergroups WHERE enabled = 'N'); +DELETE FROM groupbasket WHERE group_id in (SELECT group_id FROM usergroups WHERE enabled = 'N'); +DELETE FROM groupbasket_redirect WHERE group_id in (SELECT group_id FROM usergroups WHERE enabled = 'N'); +DELETE FROM groupbasket_status WHERE group_id in (SELECT group_id FROM usergroups WHERE enabled = 'N'); +DELETE FROM users_baskets_preferences WHERE group_serial_id in (SELECT id FROM usergroups WHERE enabled = 'N'); +DELETE FROM usergroups WHERE enabled = 'N'; + +/* REFACTORING MODIFICATION */ +ALTER TABLE notif_email_stack ALTER COLUMN attachments TYPE text; + +/* REFACTORING SUPPRESSION */ ALTER TABLE res_letterbox DROP COLUMN IF EXISTS converter_result; ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS converter_result; ALTER TABLE res_letterbox DROP COLUMN IF EXISTS convert_result; @@ -105,6 +126,12 @@ FROM ( ) AS subquery WHERE groupbasket.basket_id = subquery.basket_id AND groupbasket.group_id = subquery.group_id; - UPDATE actions SET component = 'confirmAction', action_page = 'confirm_status' WHERE action_page in ('validate_mail', 'process', 'visa_mail'); DELETE FROM actions WHERE action_page = 'view' OR component = 'viewDoc'; + +DO $$ BEGIN + IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'users') AND attname = 'enabled') THEN + UPDATE users SET status = 'SPD' WHERE enabled = 'N' and (status = 'OK' or status = 'ABS'); + ALTER TABLE users DROP COLUMN IF EXISTS enabled; + END IF; +END$$; diff --git a/src/app/group/controllers/GroupController.php b/src/app/group/controllers/GroupController.php index a94a80488d3dc8b4f9739d6f8e63c398fd472207..f76ccf3f86751dadc23a2681902604b5385f0573 100755 --- a/src/app/group/controllers/GroupController.php +++ b/src/app/group/controllers/GroupController.php @@ -268,8 +268,8 @@ class GroupController } $body = $request->getParsedBody(); - if (!Validator::boolType()->validate($body['canIndex'])) { - return $response->withStatus(400)->withJson(['errors' => 'Body canIndex is empty or not a boolean']); + if (!Validator::arrayType()->notEmpty()->validate($body)) { + return $response->withStatus(400)->withJson(['errors' => 'Body is empty or not an array']); } $group = GroupModel::getById(['id' => $args['id'], 'select' => ['indexation_parameters']]); @@ -277,28 +277,37 @@ class GroupController return $response->withStatus(400)->withJson(['errors' => 'Group not found']); } + $set = []; $indexationParameters = json_decode($group['indexation_parameters'], true); - if (!empty($body['actions']) && is_array($body['actions'])) { - $countActions = ActionModel::get(['select' => ['count(1)'], 'where' => ['id in (?)'], 'data' => [$body['actions']]]); - if ($countActions[0]['count'] != count($body['actions'])) { - return $response->withStatus(400)->withJson(['errors' => 'Body actions contains invalid actions']); + if (isset($body['canIndex']) && is_bool($body['canIndex'])) { + $set['can_index'] = $body['canIndex'] ? 'true' : 'false'; + } + if (isset($body['actions']) && is_array($body['actions'])) { + if (!empty($body['actions'])) { + $countActions = ActionModel::get(['select' => ['count(1)'], 'where' => ['id in (?)'], 'data' => [$body['actions']]]); + if ($countActions[0]['count'] != count($body['actions'])) { + return $response->withStatus(400)->withJson(['errors' => 'Body actions contains invalid actions']); + } } $indexationParameters['actions'] = $body['actions']; } - if (!empty($body['entities']) && is_array($body['entities'])) { - $countEntities = EntityModel::get(['select' => ['count(1)'], 'where' => ['id in (?)'], 'data' => [$body['entities']]]); - if ($countEntities[0]['count'] != count($body['entities'])) { - return $response->withStatus(400)->withJson(['errors' => 'Body entities contains invalid entities']); + if (isset($body['entities']) && is_array($body['entities'])) { + if (!empty($body['entities'])) { + $countEntities = EntityModel::get(['select' => ['count(1)'], 'where' => ['id in (?)'], 'data' => [$body['entities']]]); + if ($countEntities[0]['count'] != count($body['entities'])) { + return $response->withStatus(400)->withJson(['errors' => 'Body entities contains invalid entities']); + } } $indexationParameters['entities'] = $body['entities']; } - if (!empty($body['keywords']) && is_array($body['keywords'])) { + if (isset($body['keywords']) && is_array($body['keywords'])) { $indexationParameters['keywords'] = $body['keywords']; } - + $set['indexation_parameters'] = json_encode($indexationParameters); + GroupModel::update([ - 'set' => ['can_index' => $body['canIndex'], 'indexation_parameters' => json_encode($indexationParameters)], + 'set' => $set, 'where' => ['id = ?'], 'data' => [$args['id']] ]); diff --git a/src/app/user/models/UserModelAbstract.php b/src/app/user/models/UserModelAbstract.php index fdf0702ce0f99edda617fbb91602f3df12007613..7f1830e3438f39eee5e1c6bb1ed49e42b26370d3 100755 --- a/src/app/user/models/UserModelAbstract.php +++ b/src/app/user/models/UserModelAbstract.php @@ -422,7 +422,7 @@ abstract class UserModelAbstract ValidatorModel::stringType($aArgs, ['userId']); $aGroups = DatabaseModel::select([ - 'select' => ['usergroups.id', 'usergroup_content.group_id', 'usergroups.group_desc', 'usergroup_content.primary_group', 'usergroup_content.role', 'security.maarch_comment', 'security.where_clause'], + 'select' => ['usergroups.id', 'usergroups.can_index', 'usergroup_content.group_id', 'usergroups.group_desc', 'usergroup_content.primary_group', 'usergroup_content.role', 'security.maarch_comment', 'security.where_clause'], 'table' => ['usergroup_content, usergroups, security'], 'where' => ['usergroup_content.group_id = usergroups.group_id', 'usergroup_content.user_id = ?','usergroups.group_id = security.group_id'], 'data' => [$aArgs['userId']] diff --git a/src/core/controllers/CoreController.php b/src/core/controllers/CoreController.php index 63d9d54d58b112ca5e5614d50ded820755699fc3..2cd812e0d0a5bd24bb2793b981a6e382a9d30b69 100755 --- a/src/core/controllers/CoreController.php +++ b/src/core/controllers/CoreController.php @@ -85,6 +85,10 @@ class CoreController $user['entities'] = UserModel::getEntitiesById(['userId' => $GLOBALS['userId']]); $user['indexingGroups'] = []; + $shortcuts = [ + ['id' => 'home'] + ]; + if ($GLOBALS['userId'] == 'superadmin') { $menu = ServiceModel::getApplicationServicesByXML(['type' => 'menu']); foreach ($menu as $key => $value) { @@ -96,20 +100,32 @@ class CoreController $menu = array_merge($menu, $menuModules); } else { $menu = ServiceController::getMenuServicesByUserId(['userId' => $GLOBALS['userId']]); - foreach ($menu as $value) { - if ($value['id'] == 'index_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']]; - } - } - } + } + + foreach ($menu as $value) { + if ($value['id'] == 'admin') { + $shortcuts[] = ['id' => 'administration']; + } elseif ($value['id'] == 'adv_search_mlb') { + $shortcuts[] = ['id' => 'search']; + } + } + $indexingGroups = []; + foreach ($user['groups'] as $group) { + if ($group['can_index']) { + $indexingGroups[] = ['id' => $group['id'], 'label' => $group['group_desc']]; } } + if (!empty($indexingGroups)) { + $shortcuts[] = [ + 'id' => 'indexing', + 'groups' => $indexingGroups + ]; + } return $response->withJson([ - 'user' => $user, - 'menu' => $menu + 'user' => $user, + 'menu' => $menu, + 'shortcuts' => $shortcuts ]); }