diff --git a/composer.json b/composer.json
index e134f948b..50cb10447 100644
--- a/composer.json
+++ b/composer.json
@@ -101,6 +101,7 @@
"drupal/page_manager": "^4.0@beta",
"drupal/pathauto": "^1.8",
"drupal/phpexcel": "^4.0",
+ "drupal/protected_pages": "^1.6",
"drupal/publishcontent": "^1.6",
"drupal/queue_ui": "^3.1",
"drupal/rabbit_hole": "^1.0@beta",
diff --git a/composer.lock b/composer.lock
index 1a44dcb12..5906b68ef 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "27620658ab209048be292c03468b4a9b",
+ "content-hash": "19d7923cac9e077a2517fa71dc1c5da4",
"packages": [
{
"name": "asm89/stack-cors",
@@ -4333,6 +4333,55 @@
"issues": "https://www.drupal.org/project/issues/phpexcel"
}
},
+ {
+ "name": "drupal/protected_pages",
+ "version": "1.6.0",
+ "source": {
+ "type": "git",
+ "url": "https://git.drupalcode.org/project/protected_pages.git",
+ "reference": "8.x-1.6"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://ftp.drupal.org/files/projects/protected_pages-8.x-1.6.zip",
+ "reference": "8.x-1.6",
+ "shasum": "d55172cec155ee08618c2817c9b3d3e1ce8f9f63"
+ },
+ "require": {
+ "drupal/core": "^8.8 || ^9 || ^10"
+ },
+ "type": "drupal-module",
+ "extra": {
+ "drupal": {
+ "version": "8.x-1.6",
+ "datestamp": "1681317610",
+ "security-coverage": {
+ "status": "covered",
+ "message": "Covered by Drupal's security advisory policy"
+ }
+ }
+ },
+ "notification-url": "https://packages.drupal.org/8/downloads",
+ "license": [
+ "GPL-2.0-or-later"
+ ],
+ "authors": [
+ {
+ "name": "markdorison",
+ "homepage": "https://www.drupal.org/user/346106"
+ },
+ {
+ "name": "oksana-c",
+ "homepage": "https://www.drupal.org/user/2916547"
+ }
+ ],
+ "description": "Protected Pages modules allows the administrator to secure any page or private file in your website by password.",
+ "homepage": "https://www.drupal.org/project/protected_pages",
+ "support": {
+ "source": "https://git.drupalcode.org/project/protected_pages",
+ "issues": "https://www.drupal.org/project/issues/protected_pages"
+ }
+ },
{
"name": "drupal/publishcontent",
"version": "1.6.0",
@@ -17518,5 +17567,5 @@
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
- "plugin-api-version": "2.6.0"
+ "plugin-api-version": "2.3.0"
}
diff --git a/composer.patches.json b/composer.patches.json
index 6878c368b..8153b1981 100644
--- a/composer.patches.json
+++ b/composer.patches.json
@@ -29,6 +29,9 @@
"drupal/page_manager": {
"Issue #3176661: Allow to edit page title when using Layout Builder variant": "https://www.drupal.org/files/issues/2022-11-15/page_manager-lb-title-3176661-15.patch"
},
+ "drupal/protected_pages": {
+ "Issue #3024997: Global password is requested multiple times for every protected page": "https://www.drupal.org/files/issues/2023-11-20/3024997-11-reroll-8.patch"
+ },
"drupal/publishcontent": {
"Issue #2820867: Bulk operations actions skip 'publishcontent' defined permissions": "https://www.drupal.org/files/issues/2020-07-22/2820867-7-permissions-for-bulk-operations.patch"
},
diff --git a/config/core.extension.yml b/config/core.extension.yml
index 3e6194900..3e137722c 100644
--- a/config/core.extension.yml
+++ b/config/core.extension.yml
@@ -39,6 +39,7 @@ module:
ghi_base_objects: 0
ghi_blocks: 0
ghi_content: 0
+ ghi_embargoed_access: 0
ghi_form_elements: 0
ghi_gin: 0
ghi_hero_image: 0
@@ -100,6 +101,7 @@ module:
path: 0
path_alias: 0
phpexcel: 0
+ protected_pages: 0
publishcontent: 0
queue_ui: 0
rabbit_hole: 0
diff --git a/config/ghi_embargoed_access.settings.yml b/config/ghi_embargoed_access.settings.yml
new file mode 100644
index 000000000..b9f64a101
--- /dev/null
+++ b/config/ghi_embargoed_access.settings.yml
@@ -0,0 +1,3 @@
+_core:
+ default_config_hash: KhBLA3nouSdIVDBWen9UHN71v2RCEWFem9zwn7C9XC4
+enabled: true
diff --git a/config/protected_pages.settings.yml b/config/protected_pages.settings.yml
new file mode 100644
index 000000000..c60814592
--- /dev/null
+++ b/config/protected_pages.settings.yml
@@ -0,0 +1,19 @@
+_core:
+ default_config_hash: fcx2bfv-TfdQ_hGuvq4GkK3SAeANYibuVJMcEJBGG38
+langcode: en
+password:
+ per_page_or_global: only_global
+ protected_pages_session_expire_time: '0'
+ enter_password_once: '1'
+ validate_per_section: true
+ protected_pages_global_password: $2y$10$xP0doQlJn.LFMdJO49YJ4uR53yJrRkjKn364MZyzUHlcZN4NeBOUW
+email:
+ subject: 'Please visit this new page'
+ body: "Dear friend,\r\n\r\nI just created a new page on my website and wanted to invite you to visit. The page is protected by password. Please find the details below:-\r\n\r\nPage Url = [protected-page-url]\r\n\r\nPage Password = password here\r\n\r\nThank you.\r\n[site-name]"
+others:
+ protected_pages_title: 'GHO embargoed access'
+ protected_pages_description: "
\r\nThe page you are trying to view is password protected.
\r\nPlease enter the password you have received by email to access the embargoed content.\r\n
"
+ protected_pages_password_fieldset_legend: ''
+ protected_pages_password_label: Password
+ protected_pages_submit_button_text: Submit
+ protected_pages_incorrect_password_msg: 'An incorrect password was submitted. Please check your password and try again.'
diff --git a/config/system.action.protect_content.yml b/config/system.action.protect_content.yml
new file mode 100644
index 000000000..9742cbd6b
--- /dev/null
+++ b/config/system.action.protect_content.yml
@@ -0,0 +1,13 @@
+uuid: b6324a7b-f553-44e2-9ed4-382df0ef5cac
+langcode: en
+status: true
+dependencies:
+ module:
+ - ghi_embargoed_access
+_core:
+ default_config_hash: SVo71HduKFbRs1uPA_qEluJ_mFJSz6vXrQ19ZSObuU8
+id: protect_content
+label: 'Protect Content'
+type: node
+plugin: protect_content
+configuration: { }
diff --git a/config/system.action.unprotect_content.yml b/config/system.action.unprotect_content.yml
new file mode 100644
index 000000000..11b75c785
--- /dev/null
+++ b/config/system.action.unprotect_content.yml
@@ -0,0 +1,13 @@
+uuid: d64129aa-a465-4438-92c7-0f5970603b69
+langcode: en
+status: true
+dependencies:
+ module:
+ - ghi_embargoed_access
+_core:
+ default_config_hash: 03CbUBTrNYTt7-XQZn1cwc4fMixXExZVVwVPjs5TQOM
+id: unprotect_content
+label: 'Unprotect Content'
+type: node
+plugin: unprotect_content
+configuration: { }
diff --git a/config/user.role.anonymous.yml b/config/user.role.anonymous.yml
index eeb7e4e7a..78865f2e5 100644
--- a/config/user.role.anonymous.yml
+++ b/config/user.role.anonymous.yml
@@ -3,6 +3,7 @@ langcode: en
status: true
dependencies:
module:
+ - protected_pages
- system
_core:
default_config_hash: j5zLMOdJBqC0bMvSdth5UebkprJB8g_2FXHqhfpJzow
@@ -12,3 +13,4 @@ weight: -10
is_admin: false
permissions:
- 'access content'
+ - 'access protected page password screen'
diff --git a/config/user.role.authenticated.yml b/config/user.role.authenticated.yml
index 7d1e34014..a2a1324ea 100644
--- a/config/user.role.authenticated.yml
+++ b/config/user.role.authenticated.yml
@@ -3,6 +3,7 @@ langcode: en
status: true
dependencies:
module:
+ - protected_pages
- system
_core:
default_config_hash: dJ0L2DNSj5q6XVZAGsuVDpJTh5UeYkIPwKrUOOpr8YI
@@ -12,3 +13,4 @@ weight: -9
is_admin: false
permissions:
- 'access content'
+ - 'access protected page password screen'
diff --git a/config/views.view.content.yml b/config/views.view.content.yml
index 1b04824dd..933d8ab5e 100644
--- a/config/views.view.content.yml
+++ b/config/views.view.content.yml
@@ -15,20 +15,22 @@ dependencies:
- node.type.custom_subpage
- node.type.document
- node.type.financials
- - node.type.logframe
- node.type.global_section
- node.type.homepage
+ - node.type.logframe
- node.type.news_story
- node.type.page
- node.type.plan_cluster
- node.type.population
- node.type.presence
+ - node.type.progress
- node.type.section
- taxonomy.vocabulary.tags
- taxonomy.vocabulary.team
module:
- ghi_base_objects
- ghi_content
+ - ghi_embargoed_access
- node
- taxonomy
- user
@@ -1366,6 +1368,8 @@ display:
selected_actions:
- node_publish_action
- node_unpublish_action
+ - protect_content
+ - unprotect_content
title:
id: title
table: node_field_data
@@ -1536,6 +1540,60 @@ display:
format: custom
format_custom_false: Unpublished
format_custom_true: Published
+ protected_status:
+ id: protected_status
+ table: node
+ field: protected_status
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: node
+ plugin_id: protected_status
+ label: Protected
+ exclude: false
+ alter:
+ alter_text: false
+ text: ''
+ make_link: false
+ path: ''
+ absolute: false
+ external: false
+ replace_spaces: false
+ path_case: none
+ trim_whitespace: false
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: false
+ max_length: 0
+ word_boundary: true
+ ellipsis: true
+ more_link: false
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: false
+ trim: false
+ preserve_tags: ''
+ html: false
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: true
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: true
+ empty: ''
+ hide_empty: false
+ empty_zero: false
+ hide_alter_empty: true
+ type: yes-no
+ type_custom_true: ''
+ type_custom_false: ''
+ not: 0
changed:
id: changed
table: node_field_data
@@ -2618,6 +2676,8 @@ display:
selected_actions:
- node_publish_action
- node_unpublish_action
+ - protect_content
+ - unprotect_content
title:
id: title
table: node_field_data
@@ -2788,6 +2848,60 @@ display:
format: custom
format_custom_false: Unpublished
format_custom_true: Published
+ protected_status:
+ id: protected_status
+ table: node
+ field: protected_status
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: node
+ plugin_id: protected_status
+ label: Protected
+ exclude: false
+ alter:
+ alter_text: false
+ text: ''
+ make_link: false
+ path: ''
+ absolute: false
+ external: false
+ replace_spaces: false
+ path_case: none
+ trim_whitespace: false
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: false
+ max_length: 0
+ word_boundary: true
+ ellipsis: true
+ more_link: false
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: false
+ trim: false
+ preserve_tags: ''
+ html: false
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: true
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: true
+ empty: ''
+ hide_empty: false
+ empty_zero: false
+ hide_alter_empty: true
+ type: yes-no
+ type_custom_true: ''
+ type_custom_false: ''
+ not: 0
changed:
id: changed
table: node_field_data
diff --git a/config_dev/language/fr/views.view.watchdog.yml b/config_dev/language/fr/views.view.watchdog.yml
index 8831e02b3..9b5e06f3c 100644
--- a/config_dev/language/fr/views.view.watchdog.yml
+++ b/config_dev/language/fr/views.view.watchdog.yml
@@ -7,6 +7,8 @@ display:
label: Type
timestamp:
label: Date
+ message:
+ label: Message
name:
label: Utilisateur
link:
@@ -22,11 +24,7 @@ display:
submit_button: Filtrer
reset_button_label: RĂ©initialiser
exposed_sorts_label: 'Trier par'
- sort_asc_label: Asc
- sort_desc_label: Desc
filters:
type:
expose:
label: Type
- page:
- display_title: Page
diff --git a/html/modules/custom/ghi_embargoed_access/config/install/ghi_embargoed_access.settings.yml b/html/modules/custom/ghi_embargoed_access/config/install/ghi_embargoed_access.settings.yml
new file mode 100644
index 000000000..bc114417c
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/config/install/ghi_embargoed_access.settings.yml
@@ -0,0 +1 @@
+enabled: false
diff --git a/html/modules/custom/ghi_embargoed_access/config/install/system.action.protect_content.yml b/html/modules/custom/ghi_embargoed_access/config/install/system.action.protect_content.yml
new file mode 100644
index 000000000..28ec1cf92
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/config/install/system.action.protect_content.yml
@@ -0,0 +1,10 @@
+langcode: en
+status: true
+dependencies:
+ module:
+ - node
+id: protect_content
+label: 'Protect Content'
+type: node
+plugin: protect_content
+configuration: { }
\ No newline at end of file
diff --git a/html/modules/custom/ghi_embargoed_access/config/install/system.action.unprotect_content.yml b/html/modules/custom/ghi_embargoed_access/config/install/system.action.unprotect_content.yml
new file mode 100644
index 000000000..2fa29c5b9
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/config/install/system.action.unprotect_content.yml
@@ -0,0 +1,10 @@
+langcode: en
+status: true
+dependencies:
+ module:
+ - node
+id: unprotect_content
+label: 'Unprotect Content'
+type: node
+plugin: unprotect_content
+configuration: { }
\ No newline at end of file
diff --git a/html/modules/custom/ghi_embargoed_access/config/schema/ghi_embargoed_access.schema.yml b/html/modules/custom/ghi_embargoed_access/config/schema/ghi_embargoed_access.schema.yml
new file mode 100644
index 000000000..024ff03de
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/config/schema/ghi_embargoed_access.schema.yml
@@ -0,0 +1,8 @@
+ghi_embargoed_access.settings:
+ type: config_object
+ translatable: true
+ label: 'Settings'
+ mapping:
+ enabled:
+ type: 'boolean'
+ label: 'Whether the embargoed access is enabled or not'
\ No newline at end of file
diff --git a/html/modules/custom/ghi_embargoed_access/css/protect_pages_login_form.css b/html/modules/custom/ghi_embargoed_access/css/protect_pages_login_form.css
new file mode 100644
index 000000000..1ed821ef7
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/css/protect_pages_login_form.css
@@ -0,0 +1,6 @@
+.path-protected-page .protected_pages_description strong {
+ font-weight: normal;
+}
+.path-protected-page .protected-pages-enter-password .form-item-password {
+ margin-bottom: 2rem;
+}
\ No newline at end of file
diff --git a/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.info.yml b/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.info.yml
new file mode 100644
index 000000000..68f224977
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.info.yml
@@ -0,0 +1,9 @@
+name: GHI Embargoed Access
+description: Provides support for embargoed access to specific pages.
+package: GHI
+
+type: module
+core_version_requirement: ^9 || ^10
+
+dependencies:
+ - protected_pages:protected_pages
\ No newline at end of file
diff --git a/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.libraries.yml b/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.libraries.yml
new file mode 100644
index 000000000..42d2b74b2
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.libraries.yml
@@ -0,0 +1,5 @@
+protect_pages_login_form:
+ version: VERSION
+ css:
+ component:
+ css/protect_pages_login_form.css: {}
diff --git a/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.links.menu.yml b/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.links.menu.yml
new file mode 100644
index 000000000..7fd15cbfc
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.links.menu.yml
@@ -0,0 +1,5 @@
+ghi_embargoed_access.config:
+ title: 'Embargoed access'
+ route_name: ghi_embargoed_access.settings
+ description: 'Configure the embargoed access'
+ parent: system.admin_config_ghi
\ No newline at end of file
diff --git a/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.module b/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.module
new file mode 100644
index 000000000..f294f8eaf
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.module
@@ -0,0 +1,27 @@
+getPath() == '/protected-page') {
+ $vars['attributes']['class'][] = 'path-node';
+ }
+}
+
+/**
+ * Implements hook_form_FORM_ID_alter().
+ */
+function ghi_embargoed_access_form_protected_pages_enter_password_alter(array &$form, FormStateInterface $form_state) {
+ $form['#attributes']['class'][] = 'content-width';
+ $form['#attached']['library'][] = 'ghi_embargoed_access/protect_pages_login_form';
+}
diff --git a/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.routing.yml b/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.routing.yml
new file mode 100644
index 000000000..3d6cca541
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.routing.yml
@@ -0,0 +1,9 @@
+ghi_embargoed_access.settings:
+ path: 'admin/config/ghi/embargoed-access'
+ defaults:
+ _title: 'Embargoed access'
+ _form: '\Drupal\ghi_embargoed_access\Form\GhiEmbargoedAccessSettingForm'
+ options:
+ _admin_route: TRUE
+ requirements:
+ _permission: 'administer site configuration'
\ No newline at end of file
diff --git a/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.views.inc b/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.views.inc
new file mode 100644
index 000000000..086f958f0
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/ghi_embargoed_access.views.inc
@@ -0,0 +1,21 @@
+ [
+ 'title' => t('Protected status'),
+ 'help' => t('Get the protected status of a node.'),
+ 'id' => 'protected_status',
+ ],
+ ];
+ return $data;
+}
diff --git a/html/modules/custom/ghi_embargoed_access/src/EventSubscriber/GhiEmbargoedAccessEventSubscriber.php b/html/modules/custom/ghi_embargoed_access/src/EventSubscriber/GhiEmbargoedAccessEventSubscriber.php
new file mode 100644
index 000000000..a414464b7
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/src/EventSubscriber/GhiEmbargoedAccessEventSubscriber.php
@@ -0,0 +1,77 @@
+configFactory = $config_factory;
+ }
+
+ /**
+ * Redirects user to protected page login screen.
+ *
+ * @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event
+ * The event to process.
+ */
+ public function checkProtectedPage(ResponseEvent $event) {
+ if (!$this->configFactory->get('ghi_embargoed_access.settings')->get('enabled')) {
+ return NULL;
+ }
+ return parent::checkProtectedPage($event);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getSubscribedEvents() {
+ $events[KernelEvents::RESPONSE][] = ['checkProtectedPage'];
+ return $events;
+ }
+
+}
diff --git a/html/modules/custom/ghi_embargoed_access/src/Form/GhiEmbargoedAccessSettingForm.php b/html/modules/custom/ghi_embargoed_access/src/Form/GhiEmbargoedAccessSettingForm.php
new file mode 100644
index 000000000..b90325d5f
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/src/Form/GhiEmbargoedAccessSettingForm.php
@@ -0,0 +1,53 @@
+config('ghi_embargoed_access.settings');
+ $form['enabled'] = [
+ '#type' => 'checkbox',
+ '#title' => $this->t('Global protection enabled'),
+ '#description' => $this->t('Check to use the global protection for embargoed access.'),
+ '#default_value' => $config->get('enabled'),
+ ];
+ return $form;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function submitForm(array &$form, FormStateInterface $form_state) {
+ $config = $this->config('ghi_embargoed_access.settings');
+ $config->set('enabled', $form_state->getValue('enabled'));
+ $config->save();
+ drupal_flush_all_caches();
+ return parent::submitForm($form, $form_state);
+ }
+
+}
diff --git a/html/modules/custom/ghi_embargoed_access/src/GhiEmbargoedAccessServiceProvider.php b/html/modules/custom/ghi_embargoed_access/src/GhiEmbargoedAccessServiceProvider.php
new file mode 100644
index 000000000..359accb05
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/src/GhiEmbargoedAccessServiceProvider.php
@@ -0,0 +1,24 @@
+getDefinition('protected_pages.check_protected_page');
+ $definition->setClass('Drupal\ghi_embargoed_access\EventSubscriber\GhiEmbargoedAccessEventSubscriber')
+ ->addArgument(new Reference('config.factory'));
+ }
+
+}
diff --git a/html/modules/custom/ghi_embargoed_access/src/Plugin/Action/ProtectContent.php b/html/modules/custom/ghi_embargoed_access/src/Plugin/Action/ProtectContent.php
new file mode 100644
index 000000000..c454cfef6
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/src/Plugin/Action/ProtectContent.php
@@ -0,0 +1,91 @@
+protectedPagesStorage = $container->get('protected_pages.storage');
+ $instance->password = $container->get('password');
+ return $instance;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function execute($node = NULL) {
+ if (!$node || !$node instanceof NodeInterface) {
+ return;
+ }
+ $path = '/node/' . $node->id();
+ $fields = ['pid'];
+ $conditions = [
+ 'general' => [],
+ ];
+ $conditions['general'][] = [
+ 'field' => 'path',
+ 'value' => $path,
+ 'operator' => '=',
+ ];
+ $pid = $this->protectedPagesStorage->loadProtectedPage($fields, $conditions, TRUE);
+ if ($pid) {
+ // Already done.
+ return;
+ }
+ $random = new Random();
+ $page_data = [
+ 'password' => $this->password->hash(Html::escape($random->string(32))),
+ 'path' => $path,
+ ];
+ $pid = $this->protectedPagesStorage->insertProtectedPage($page_data);
+ Cache::invalidateTags($node->getCacheTags());
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
+ /** @var \Drupal\Core\Access\AccessResultInterface $result */
+ $result = $object->access('update', $account, TRUE);
+ $result->andIf(AccessResult::allowedIf($account->hasPermission('administer protected pages configuration')));
+ return $return_as_object ? $result : $result->isAllowed();
+ }
+
+}
diff --git a/html/modules/custom/ghi_embargoed_access/src/Plugin/Action/UnprotectContent.php b/html/modules/custom/ghi_embargoed_access/src/Plugin/Action/UnprotectContent.php
new file mode 100644
index 000000000..aaa55f5e1
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/src/Plugin/Action/UnprotectContent.php
@@ -0,0 +1,76 @@
+protectedPagesStorage = $container->get('protected_pages.storage');
+ return $instance;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function execute($node = NULL) {
+ if (!$node || !$node instanceof NodeInterface) {
+ return;
+ }
+ $path = '/node/' . $node->id();
+ $fields = ['pid'];
+ $conditions = [
+ 'general' => [],
+ ];
+ $conditions['general'][] = [
+ 'field' => 'path',
+ 'value' => $path,
+ 'operator' => '=',
+ ];
+ $pid = $this->protectedPagesStorage->loadProtectedPage($fields, $conditions, TRUE);
+ if (!$pid) {
+ // Already done.
+ return;
+ }
+ $pid = $this->protectedPagesStorage->deleteProtectedPage($pid);
+ Cache::invalidateTags($node->getCacheTags());
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
+ /** @var \Drupal\Core\Access\AccessResultInterface $result */
+ $result = $object->access('update', $account, TRUE);
+ $result->andIf(AccessResult::allowedIf($account->hasPermission('administer protected pages configuration')));
+ return $return_as_object ? $result : $result->isAllowed();
+ }
+
+}
diff --git a/html/modules/custom/ghi_embargoed_access/src/Plugin/views/field/ProtectedStatus.php b/html/modules/custom/ghi_embargoed_access/src/Plugin/views/field/ProtectedStatus.php
new file mode 100644
index 000000000..b9a90b43b
--- /dev/null
+++ b/html/modules/custom/ghi_embargoed_access/src/Plugin/views/field/ProtectedStatus.php
@@ -0,0 +1,57 @@
+protectedPagesStorage = $container->get('protected_pages.storage');
+ return $instance;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function query() {
+ // Overridden to prevent additional query.
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getValue(ResultRow $values, $field = NULL) {
+ $path = '/node/' . $values->_entity->id();
+ $fields = ['pid'];
+ $conditions = [
+ 'general' => [],
+ ];
+ $conditions['general'][] = [
+ 'field' => 'path',
+ 'value' => $path,
+ 'operator' => '=',
+ ];
+ $pid = $this->protectedPagesStorage->loadProtectedPage($fields, $conditions, TRUE);
+ return !empty($pid);
+ }
+
+}