diff --git a/classes/migration/install/RolesAndUserGroupsMigration.php b/classes/migration/install/RolesAndUserGroupsMigration.php index 7512a9937af..b27dfe56ebf 100644 --- a/classes/migration/install/RolesAndUserGroupsMigration.php +++ b/classes/migration/install/RolesAndUserGroupsMigration.php @@ -34,6 +34,7 @@ public function up(): void $table->smallInteger('show_title')->default(1); $table->smallInteger('permit_self_registration')->default(0); $table->smallInteger('permit_metadata_edit')->default(0); + $table->smallInteger('masthead')->default(0); $table->index(['user_group_id'], 'user_groups_user_group_id'); $table->index(['context_id'], 'user_groups_context_id'); $table->index(['role_id'], 'user_groups_role_id'); diff --git a/classes/migration/upgrade/v3_5_0/I9552_UserGroupsMasthead.php b/classes/migration/upgrade/v3_5_0/I9552_UserGroupsMasthead.php new file mode 100644 index 00000000000..400ae463990 --- /dev/null +++ b/classes/migration/upgrade/v3_5_0/I9552_UserGroupsMasthead.php @@ -0,0 +1,44 @@ +smallInteger('masthead')->default(0); + }); + } + + /** + * Reverse the downgrades + */ + public function down(): void + { + Schema::table('user_groups', function (Blueprint $table) { + if (Schema::hasColumn($table->getTable(), 'masthead')) { + $table->dropColumn('masthead'); + }; + }); + } +} diff --git a/classes/userGroup/Collector.php b/classes/userGroup/Collector.php index 095771d84d3..a4fcdba1ad6 100644 --- a/classes/userGroup/Collector.php +++ b/classes/userGroup/Collector.php @@ -30,7 +30,7 @@ class Collector implements CollectorInterface public const ORDERBY_ROLE_ID = 'roleId'; public const ORDERBY_ID = 'id'; - public ?string $orderBy = null; + public ?string $orderBy = self::ORDERBY_ID; /** @var DAO */ public $dao; @@ -63,6 +63,8 @@ class Collector implements CollectorInterface public UserUserGroupStatus $userUserGroupStatus = UserUserGroupStatus::STATUS_ACTIVE; + public ?bool $masthead = null; + public function __construct(DAO $dao) { @@ -173,6 +175,15 @@ public function filterByPermitMetadataEdit(?bool $permitMetadataEdit): self return $this; } + /** + * Filter by masthead + */ + public function filterByMasthead(?bool $masthead): self + { + $this->masthead = $masthead; + return $this; + } + /** * Filter by permit metadata edit */ @@ -304,6 +315,10 @@ public function getQueryBuilder(): Builder $q->where('ug.permit_metadata_edit', $this->permitMetadataEdit ? 1 : 0); }); + $q->when($this->masthead !== null, function (Builder $q) { + $q->where('ug.masthead', $this->masthead ? 1 : 0); + }); + $q->when($this->showTitle !== null, function (Builder $q) { $q->where('ug.show_title', $this->showTitle ? 1 : 0); }); diff --git a/classes/userGroup/DAO.php b/classes/userGroup/DAO.php index 1814464e9a7..89a40891e75 100644 --- a/classes/userGroup/DAO.php +++ b/classes/userGroup/DAO.php @@ -55,6 +55,7 @@ class DAO extends EntityDAO 'showTitle' => 'show_title', 'permitSelfRegistration' => 'permit_self_registration', 'permitMetadataEdit' => 'permit_metadata_edit', + 'masthead' => 'masthead', ]; /** diff --git a/classes/userGroup/Repository.php b/classes/userGroup/Repository.php index d57299247a5..bbcf3c6d987 100644 --- a/classes/userGroup/Repository.php +++ b/classes/userGroup/Repository.php @@ -400,6 +400,7 @@ public function installSettings($contextId, $filename) $abbrevKey = $setting->getAttribute('abbrev'); $permitSelfRegistration = $setting->getAttribute('permitSelfRegistration'); $permitMetadataEdit = $setting->getAttribute('permitMetadataEdit'); + $masthead = $setting->getAttribute('masthead'); // If has manager role then permitMetadataEdit can't be overridden if (in_array($roleId, [Role::ROLE_ID_MANAGER])) { @@ -416,6 +417,7 @@ public function installSettings($contextId, $filename) $userGroup->setPermitMetadataEdit($permitMetadataEdit ?? false); $userGroup->setDefault(true); $userGroup->setShowTitle(true); + $userGroup->setMasthead($masthead ?? false); // insert the group into the DB $userGroupId = $this->add($userGroup); diff --git a/classes/userGroup/UserGroup.php b/classes/userGroup/UserGroup.php index 94ee3e81dab..526429bb604 100644 --- a/classes/userGroup/UserGroup.php +++ b/classes/userGroup/UserGroup.php @@ -244,6 +244,22 @@ public function setPermitMetadataEdit(bool $permitMetadataEdit) { $this->setData('permitMetadataEdit', $permitMetadataEdit); } + + /** + * Get the masthead flag + */ + public function getMasthead(): bool + { + return $this->getData('masthead'); + } + + /** + * Set the masthead flag + */ + public function setMasthead(bool $masthead) + { + $this->setData('masthead', $masthead); + } } if (!PKP_STRICT_MODE) { diff --git a/controllers/grid/settings/roles/form/UserGroupForm.php b/controllers/grid/settings/roles/form/UserGroupForm.php index 1a25c992036..bbecc7869fd 100644 --- a/controllers/grid/settings/roles/form/UserGroupForm.php +++ b/controllers/grid/settings/roles/form/UserGroupForm.php @@ -124,6 +124,7 @@ public function initData() 'permitSelfRegistration' => $userGroup->getPermitSelfRegistration(), 'permitMetadataEdit' => $userGroup->getPermitMetadataEdit(), 'recommendOnly' => $userGroup->getRecommendOnly(), + 'masthead' => $userGroup->getMasthead(), ]; foreach ($data as $field => $value) { @@ -137,7 +138,7 @@ public function initData() */ public function readInputData() { - $this->readUserVars(['roleId', 'name', 'abbrev', 'assignedStages', 'showTitle', 'permitSelfRegistration', 'recommendOnly', 'permitMetadataEdit']); + $this->readUserVars(['roleId', 'name', 'abbrev', 'assignedStages', 'showTitle', 'permitSelfRegistration', 'recommendOnly', 'permitMetadataEdit', 'masthead']); } /** @@ -210,7 +211,7 @@ public function execute(...$functionParams) $userGroup->setRecommendOnly($this->getData('recommendOnly') && in_array($userGroup->getRoleId(), $this->getRecommendOnlyRoles())); $userGroup = $this->_setUserGroupLocaleFields($userGroup, $request); - + $userGroup->setMasthead($this->getData('masthead') ?? false); $userGroupId = Repo::userGroup()->add($userGroup); } else { $userGroup = Repo::userGroup()->get($userGroupId); @@ -233,7 +234,7 @@ public function execute(...$functionParams) } $userGroup->setRecommendOnly($this->getData('recommendOnly') && in_array($userGroup->getRoleId(), $this->getRecommendOnlyRoles())); - + $userGroup->setMasthead($this->getData('masthead') ?? false); Repo::userGroup()->edit($userGroup, []); } diff --git a/locale/en/manager.po b/locale/en/manager.po index 3db82af2ee0..820c8b921a2 100644 --- a/locale/en/manager.po +++ b/locale/en/manager.po @@ -1678,6 +1678,9 @@ msgstr "Payment Method" msgid "manager.paymentMethod.currency" msgstr "Currency" +msgid "settings.roles.masthead" +msgstr "Consider role in masthead list" + msgid "settings.roles.roleOptions" msgstr "Role Options" diff --git a/schemas/userGroup.json b/schemas/userGroup.json index fd2d25f1600..ea266ea8553 100644 --- a/schemas/userGroup.json +++ b/schemas/userGroup.json @@ -8,6 +8,9 @@ "apiSummary": true, "multilingual": true }, + "masthead": { + "type": "boolean" + }, "name": { "type": "string", "description": "The name of the user group.", diff --git a/templates/controllers/grid/settings/roles/form/userGroupForm.tpl b/templates/controllers/grid/settings/roles/form/userGroupForm.tpl index 247a6a61d6c..f1b9e393727 100644 --- a/templates/controllers/grid/settings/roles/form/userGroupForm.tpl +++ b/templates/controllers/grid/settings/roles/form/userGroupForm.tpl @@ -56,6 +56,7 @@ {fbvElement type="checkbox" name="permitSelfRegistration" id="permitSelfRegistration" checked=$permitSelfRegistration label="settings.roles.permitSelfRegistration"} {fbvElement type="checkbox" name="recommendOnly" id="recommendOnly" checked=$recommendOnly label="settings.roles.recommendOnly"} {fbvElement type="checkbox" name="permitMetadataEdit" id="permitMetadataEdit" checked=$permitMetadataEdit label="settings.roles.permitMetadataEdit"} + {fbvElement type="checkbox" name="masthead" id="masthead" checked=$masthead label="settings.roles.masthead"} {/fbvFormSection} {/fbvFormArea}