Skip to content
Snippets Groups Projects
Verified Commit 91316d06 authored by Florian Azizian's avatar Florian Azizian
Browse files

Merge branch 'develop' of labs.maarch.org:maarch/MaarchCourrier into develop

parents e3c8e2f2 0a7cf22a
No related branches found
No related tags found
No related merge requests found
......@@ -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$$;
......@@ -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']]
]);
......
......@@ -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']]
......
......@@ -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
]);
}
......
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