From 2ebd23fb1444eafb292bc7c9f1303261240232ca Mon Sep 17 00:00:00 2001 From: Bozana Bokan Date: Wed, 12 Jun 2024 14:07:12 +0200 Subject: [PATCH] pkp/pkp-lib#10041 Consider existing default masthead roles and all user-role assignments to be displayed on masthead --- ...rGroupsAndUserUserGroupsMastheadValues.php | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 classes/migration/upgrade/v3_5_0/I10041_UserGroupsAndUserUserGroupsMastheadValues.php diff --git a/classes/migration/upgrade/v3_5_0/I10041_UserGroupsAndUserUserGroupsMastheadValues.php b/classes/migration/upgrade/v3_5_0/I10041_UserGroupsAndUserUserGroupsMastheadValues.php new file mode 100644 index 00000000000..126f3b8bf1c --- /dev/null +++ b/classes/migration/upgrade/v3_5_0/I10041_UserGroupsAndUserUserGroupsMastheadValues.php @@ -0,0 +1,64 @@ +where('setting_name', 'nameLocaleKey') + ->where( + fn (Builder $q) => + $q->where('setting_value', 'default.groups.name.editor') + ->orWhere('setting_value', 'default.groups.name.sectionEditor') + ->orWhere('setting_value', 'default.groups.name.externalReviewer') + ) + ->pluck('user_group_id'); + DB::table('user_groups') + ->whereIn('user_group_id', $userGroupIds) + ->update(['masthead' => 1]); + DB::table('user_user_groups') + ->update(['masthead' => 1]); + } + + /** + * Reverse the migration. + */ + public function down(): void + { + $userGroupIds = DB::table('user_group_settings') + ->where('setting_name', 'nameLocaleKey') + ->where( + fn (Builder $q) => + $q->where('setting_value', 'default.groups.name.editor') + ->orWhere('setting_value', 'default.groups.name.sectionEditor') + ->orWhere('setting_value', 'default.groups.name.externalReviewer') + ) + ->pluck('user_group_id'); + DB::table('user_groups') + ->whereIn('user_group_id', $userGroupIds) + ->update(['masthead' => 0]); + DB::table('user_user_groups') + ->update(['masthead' => null]); + } +}