Hi,
I have written two access plugins: page_403 and page_404. These plugins have been helpful to me while creating 403 and 404 pages with Panels Everywhere module.

Sorry for my English.

Comments

zestagio’s picture

StatusFileSize
new2.96 KB

Status: Needs review » Needs work

The last submitted patch, access_plugins_403_404_pages-1968802.patch, failed testing.

zestagio’s picture

Status: Needs work » Needs review
StatusFileSize
new4.27 KB

Status: Needs review » Needs work

The last submitted patch, 1968802-access_plugins_403_404.patch, failed testing.

zestagio’s picture

Status: Needs work » Needs review
StatusFileSize
new2.63 KB
andypost’s picture

Status: Needs review » Needs work

Awesome idea! I think this should be implemented as 1 plugin to allow choose a response type a-la page_manager has

function page_manager_http_response_codes() {
  return array(
    403 => t('403 Access denied'),
    404 => t('404 Page not found'),
    410 => t('410 Gone'),
    301 => t('301 Redirect'),
  );
}

And use this setting in summary and access check

+++ b/plugins/access/page_403.incundefined
@@ -0,0 +1,45 @@
+  'settings form' => 'ctools_page_403_ctools_access_settings',
...
+  return $form;

+++ b/plugins/access/page_404.incundefined
@@ -0,0 +1,45 @@
+  'settings form' => 'ctools_page_404_ctools_access_settings',
...
+  return $form;

You need to implement settings_form()

zestagio’s picture

andypost, thanks for review. In the near future I will put a new version

Sorry for my English.

zestagio’s picture

Status: Needs work » Needs review
StatusFileSize
new1.89 KB
andypost’s picture

Status: Needs review » Needs work

Just small nitpicks

+++ b/plugins/access/response_code.incundefined
@@ -0,0 +1,64 @@
+    '403 Forbidden' => t('403 Access denied'),
+    '404 Not Found' => t('404 Page not found'),

403 => t(),
404 => t(),
is enough here, no reason to use string for key

+++ b/plugins/access/response_code.incundefined
@@ -0,0 +1,64 @@
+  $response_code = drupal_get_http_header('status');
+  if ($response_code == $conf['code']) {
+    return TRUE;
+  }
+
+  return FALSE;

return $conf['code'] == drupal_get_http_header('status');
Seems cleaner

zestagio’s picture

Status: Needs work » Needs review
StatusFileSize
new1.81 KB
+++ b/plugins/access/response_code.incundefined
@@ -0,0 +1,64 @@
+    '403 Forbidden' => t('403 Access denied'),
+    '404 Not Found' => t('404 Page not found'),

I used string for keys, because keys are http headers for easily compare. In the new patch, I added a description of why to use a string keys.

Sorry for my English.

zestagio’s picture

StatusFileSize
new1.81 KB
andypost’s picture

Status: Needs review » Reviewed & tested by the community

Awesome!

japerry’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review

Hmm needs more review... If I remember correctly, I think D8 has a plugin like this, we'd probably want to backport.