From 2d4073fd2b5adb5d81695c50b4f4b3bda0656ed0 Mon Sep 17 00:00:00 2001 From: olatechpro Date: Mon, 27 May 2024 10:33:24 +0100 Subject: [PATCH] Grant Calendar, Overview and Boards screens access to editors and authors #1640 --- modules/calendar/calendar.php | 10 ++++++++++ modules/content-board/content-board.php | 9 +++++++++ modules/content-overview/content-overview.php | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/modules/calendar/calendar.php b/modules/calendar/calendar.php index d182ab08..d9120655 100644 --- a/modules/calendar/calendar.php +++ b/modules/calendar/calendar.php @@ -440,6 +440,16 @@ public function action_admin_submenu() */ public function install() { + + $viewCapability = $this->getViewCapability(); + $eligible_roles = ['administrator', 'editor', 'author']; + + foreach ($eligible_roles as $eligible_role) { + $role = get_role($eligible_role); + if (is_object($role) && !$role->has_cap($viewCapability)) { + $role->add_cap($viewCapability); + } + } } /** diff --git a/modules/content-board/content-board.php b/modules/content-board/content-board.php index 2d325a23..d00038ba 100644 --- a/modules/content-board/content-board.php +++ b/modules/content-board/content-board.php @@ -358,6 +358,15 @@ public function print_configure_view() */ public function install() { + $viewCapability = $this->getViewCapability(); + $eligible_roles = ['administrator', 'editor', 'author']; + + foreach ($eligible_roles as $eligible_role) { + $role = get_role($eligible_role); + if (is_object($role) && !$role->has_cap($viewCapability)) { + $role->add_cap($viewCapability); + } + } } /** diff --git a/modules/content-overview/content-overview.php b/modules/content-overview/content-overview.php index 1ee13eb3..d61ea848 100644 --- a/modules/content-overview/content-overview.php +++ b/modules/content-overview/content-overview.php @@ -361,6 +361,15 @@ public function print_configure_view() */ public function install() { + $viewCapability = $this->getViewCapability(); + $eligible_roles = ['administrator', 'editor', 'author']; + + foreach ($eligible_roles as $eligible_role) { + $role = get_role($eligible_role); + if (is_object($role) && !$role->has_cap($viewCapability)) { + $role->add_cap($viewCapability); + } + } } /**