Skip to content

Commit 190f0d0

Browse files
authored
Merge pull request #9603 from bozana/9552
#9552 add masthead option to user roles
2 parents bce6816 + 66004b5 commit 190f0d0

File tree

10 files changed

+91
-4
lines changed

10 files changed

+91
-4
lines changed

classes/migration/install/RolesAndUserGroupsMigration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function up(): void
3434
$table->smallInteger('show_title')->default(1);
3535
$table->smallInteger('permit_self_registration')->default(0);
3636
$table->smallInteger('permit_metadata_edit')->default(0);
37+
$table->smallInteger('masthead')->default(0);
3738
$table->index(['user_group_id'], 'user_groups_user_group_id');
3839
$table->index(['context_id'], 'user_groups_context_id');
3940
$table->index(['role_id'], 'user_groups_role_id');
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/**
4+
* @file classes/migration/upgrade/v3_5_0/I9552_UserGroupsMasthead.php
5+
*
6+
* Copyright (c) 2024 Simon Fraser University
7+
* Copyright (c) 2024 John Willinsky
8+
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
9+
*
10+
* @class I9552_UserGroupsMasthead
11+
*
12+
* @brief Add masthead column to the user_groups table.
13+
*/
14+
15+
namespace PKP\migration\upgrade\v3_5_0;
16+
17+
use Illuminate\Database\Schema\Blueprint;
18+
use Illuminate\Support\Facades\Schema;
19+
use PKP\migration\Migration;
20+
21+
class I9552_UserGroupsMasthead extends Migration
22+
{
23+
/**
24+
* Run the migration.
25+
*/
26+
public function up(): void
27+
{
28+
Schema::table('user_groups', function (Blueprint $table) {
29+
$table->smallInteger('masthead')->default(0);
30+
});
31+
}
32+
33+
/**
34+
* Reverse the downgrades
35+
*/
36+
public function down(): void
37+
{
38+
Schema::table('user_groups', function (Blueprint $table) {
39+
if (Schema::hasColumn($table->getTable(), 'masthead')) {
40+
$table->dropColumn('masthead');
41+
};
42+
});
43+
}
44+
}

classes/userGroup/Collector.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Collector implements CollectorInterface
3030
public const ORDERBY_ROLE_ID = 'roleId';
3131
public const ORDERBY_ID = 'id';
3232

33-
public ?string $orderBy = null;
33+
public ?string $orderBy = self::ORDERBY_ID;
3434

3535
/** @var DAO */
3636
public $dao;
@@ -63,6 +63,8 @@ class Collector implements CollectorInterface
6363

6464
public UserUserGroupStatus $userUserGroupStatus = UserUserGroupStatus::STATUS_ACTIVE;
6565

66+
public ?bool $masthead = null;
67+
6668

6769
public function __construct(DAO $dao)
6870
{
@@ -173,6 +175,15 @@ public function filterByPermitMetadataEdit(?bool $permitMetadataEdit): self
173175
return $this;
174176
}
175177

178+
/**
179+
* Filter by masthead
180+
*/
181+
public function filterByMasthead(?bool $masthead): self
182+
{
183+
$this->masthead = $masthead;
184+
return $this;
185+
}
186+
176187
/**
177188
* Filter by permit metadata edit
178189
*/
@@ -304,6 +315,10 @@ public function getQueryBuilder(): Builder
304315
$q->where('ug.permit_metadata_edit', $this->permitMetadataEdit ? 1 : 0);
305316
});
306317

318+
$q->when($this->masthead !== null, function (Builder $q) {
319+
$q->where('ug.masthead', $this->masthead ? 1 : 0);
320+
});
321+
307322
$q->when($this->showTitle !== null, function (Builder $q) {
308323
$q->where('ug.show_title', $this->showTitle ? 1 : 0);
309324
});

classes/userGroup/DAO.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class DAO extends EntityDAO
5555
'showTitle' => 'show_title',
5656
'permitSelfRegistration' => 'permit_self_registration',
5757
'permitMetadataEdit' => 'permit_metadata_edit',
58+
'masthead' => 'masthead',
5859
];
5960

6061
/**

classes/userGroup/Repository.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ public function installSettings($contextId, $filename)
400400
$abbrevKey = $setting->getAttribute('abbrev');
401401
$permitSelfRegistration = $setting->getAttribute('permitSelfRegistration');
402402
$permitMetadataEdit = $setting->getAttribute('permitMetadataEdit');
403+
$masthead = $setting->getAttribute('masthead');
403404

404405
// If has manager role then permitMetadataEdit can't be overridden
405406
if (in_array($roleId, [Role::ROLE_ID_MANAGER])) {
@@ -416,6 +417,7 @@ public function installSettings($contextId, $filename)
416417
$userGroup->setPermitMetadataEdit($permitMetadataEdit ?? false);
417418
$userGroup->setDefault(true);
418419
$userGroup->setShowTitle(true);
420+
$userGroup->setMasthead($masthead ?? false);
419421

420422
// insert the group into the DB
421423
$userGroupId = $this->add($userGroup);

classes/userGroup/UserGroup.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,22 @@ public function setPermitMetadataEdit(bool $permitMetadataEdit)
244244
{
245245
$this->setData('permitMetadataEdit', $permitMetadataEdit);
246246
}
247+
248+
/**
249+
* Get the masthead flag
250+
*/
251+
public function getMasthead(): bool
252+
{
253+
return $this->getData('masthead');
254+
}
255+
256+
/**
257+
* Set the masthead flag
258+
*/
259+
public function setMasthead(bool $masthead)
260+
{
261+
$this->setData('masthead', $masthead);
262+
}
247263
}
248264

249265
if (!PKP_STRICT_MODE) {

controllers/grid/settings/roles/form/UserGroupForm.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public function initData()
124124
'permitSelfRegistration' => $userGroup->getPermitSelfRegistration(),
125125
'permitMetadataEdit' => $userGroup->getPermitMetadataEdit(),
126126
'recommendOnly' => $userGroup->getRecommendOnly(),
127+
'masthead' => $userGroup->getMasthead(),
127128
];
128129

129130
foreach ($data as $field => $value) {
@@ -137,7 +138,7 @@ public function initData()
137138
*/
138139
public function readInputData()
139140
{
140-
$this->readUserVars(['roleId', 'name', 'abbrev', 'assignedStages', 'showTitle', 'permitSelfRegistration', 'recommendOnly', 'permitMetadataEdit']);
141+
$this->readUserVars(['roleId', 'name', 'abbrev', 'assignedStages', 'showTitle', 'permitSelfRegistration', 'recommendOnly', 'permitMetadataEdit', 'masthead']);
141142
}
142143

143144
/**
@@ -210,7 +211,7 @@ public function execute(...$functionParams)
210211

211212
$userGroup->setRecommendOnly($this->getData('recommendOnly') && in_array($userGroup->getRoleId(), $this->getRecommendOnlyRoles()));
212213
$userGroup = $this->_setUserGroupLocaleFields($userGroup, $request);
213-
214+
$userGroup->setMasthead($this->getData('masthead') ?? false);
214215
$userGroupId = Repo::userGroup()->add($userGroup);
215216
} else {
216217
$userGroup = Repo::userGroup()->get($userGroupId);
@@ -233,7 +234,7 @@ public function execute(...$functionParams)
233234
}
234235

235236
$userGroup->setRecommendOnly($this->getData('recommendOnly') && in_array($userGroup->getRoleId(), $this->getRecommendOnlyRoles()));
236-
237+
$userGroup->setMasthead($this->getData('masthead') ?? false);
237238
Repo::userGroup()->edit($userGroup, []);
238239
}
239240

locale/en/manager.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,9 @@ msgstr "Payment Method"
16781678
msgid "manager.paymentMethod.currency"
16791679
msgstr "Currency"
16801680

1681+
msgid "settings.roles.masthead"
1682+
msgstr "Consider role in masthead list"
1683+
16811684
msgid "settings.roles.roleOptions"
16821685
msgstr "Role Options"
16831686

schemas/userGroup.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"apiSummary": true,
99
"multilingual": true
1010
},
11+
"masthead": {
12+
"type": "boolean"
13+
},
1114
"name": {
1215
"type": "string",
1316
"description": "The name of the user group.",

templates/controllers/grid/settings/roles/form/userGroupForm.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
{fbvElement type="checkbox" name="permitSelfRegistration" id="permitSelfRegistration" checked=$permitSelfRegistration label="settings.roles.permitSelfRegistration"}
5757
{fbvElement type="checkbox" name="recommendOnly" id="recommendOnly" checked=$recommendOnly label="settings.roles.recommendOnly"}
5858
{fbvElement type="checkbox" name="permitMetadataEdit" id="permitMetadataEdit" checked=$permitMetadataEdit label="settings.roles.permitMetadataEdit"}
59+
{fbvElement type="checkbox" name="masthead" id="masthead" checked=$masthead label="settings.roles.masthead"}
5960
{/fbvFormSection}
6061
{/fbvFormArea}
6162
</div>

0 commit comments

Comments
 (0)