Skip to content

Commit

Permalink
pkp#9253 Hide site announcements behind feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
NateWr committed Aug 28, 2023
1 parent fe7138c commit 638f4af
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/v1/announcements/PKPAnnouncementHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use APP\facades\Repo;
use Exception;
use Illuminate\Support\Facades\Bus;
use PKP\config\Config;
use PKP\context\Context;
use PKP\db\DAORegistry;
use PKP\facades\Locale;
Expand Down Expand Up @@ -94,6 +95,10 @@ public function __construct()
*/
public function authorize($request, &$args, $roleAssignments)
{
if (!Config::getVar('features', 'site_announcements') && !$request->getContext()) {
return false;
}

if (!$request->getContext()) {
$roleAssignments = $this->getSiteRoleAssignments($roleAssignments);
}
Expand Down
7 changes: 7 additions & 0 deletions pages/admin/AdminHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ private function siteSettingsAvailability($request)
'announcements',
];

if (!Config::getVar('features', 'site_announcements')) {
$tabs = array_filter(
$tabs,
function($tab) { return $tab !== 'announcements'; }
);
}

$singleContextSite = (Services::get('context')->getCount() == 1);

$tabsAvailability = [];
Expand Down
5 changes: 5 additions & 0 deletions pages/announcement/AnnouncementHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use APP\facades\Repo;
use APP\handler\Handler;
use APP\template\TemplateManager;
use PKP\config\Config;
use PKP\core\PKPRequest;
use PKP\security\authorization\ContextRequiredPolicy;

Expand Down Expand Up @@ -100,6 +101,10 @@ protected function getContextId(Request $request): int

protected function isAnnouncementsEnabled(Request $request): bool
{
if (!Config::getVar('features', 'site_announcements') && !$request->getContext()) {
return false;
}

$contextOrSite = $request->getContext() ?? $request->getSite();
return $contextOrSite->getData('enableAnnouncements');
}
Expand Down

0 comments on commit 638f4af

Please sign in to comment.