pages_restriction.module in Pages Restriction Access 7
Same filename and directory in other branches
Contains the administrative features for the Pages Restriction.
File
pages_restriction.moduleView source
<?php
/**
* @file
* Contains the administrative features for the Pages Restriction.
*/
/**
* Implements hook_menu().
*/
function pages_restriction_menu() {
$items = array();
$items['admin/config/pages_restriction'] = array(
'title' => 'Pages Restriction Access',
'description' => 'Validation settings.',
'position' => 'right',
'weight' => -20,
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array(
'administer site configuration',
),
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
);
$items['admin/config/pages_restriction/restrict_access'] = array(
'title' => 'Restrict Access',
'description' => 'Configuration to block access for Pre Defined Pages.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'pages_restriction_admin_form',
),
'access arguments' => array(
'administer site configuration',
),
'type' => MENU_NORMAL_ITEM,
'file' => 'pages_restriction.admin.inc',
);
return $items;
}
/**
* Implements hook_page_alter().
*/
function pages_restriction_page_alter(&$page) {
global $language;
$lang_name = $language->language;
module_load_include('inc', 'pages_restriction', 'includes/pages_restriction.helpers');
module_load_include('inc', 'pages_restriction', 'includes/pages_restriction.cache');
$path = current_path();
$path_alias = drupal_lookup_path('alias', $path);
if ($path_alias == FALSE) {
$path_alias = $path;
}
$translated_path = _pages_restriction_get_translated_path($path_alias);
if ($translated_path != $path_alias) {
$path_alias = $translated_path;
}
if (strpos($path_alias, $lang_name . "/") !== FALSE) {
$path_alias = str_replace($lang_name . "/", "", $path_alias);
}
$rules = _pages_restriction_get_rules_by_path($path_alias);
if (_pages_restriction_restrict_access($path_alias)) {
foreach ($rules as $rule) {
if (!preg_match('@^' . str_replace('%', '\\w*', trim($rule[1])) . '$@', $path_alias)) {
drupal_goto($path_alias);
}
}
}
foreach ($rules as $rule) {
if (preg_match('@^' . str_replace('%', '\\w*', trim($rule[1])) . '$@', $path_alias)) {
$data = _pages_restriction_get_cached_data();
_pages_restriction_unset_sections_with_path($path_alias);
if (empty($data)) {
drupal_goto($rule[0]);
}
}
}
}
/**
* Implements hook_flush_caches().
*/
function pages_restriction_flush_caches() {
// Workaround just to trigger this function during Clear Cache button.
module_load_include('inc', 'pages_restriction', 'includes/pages_restriction.cache');
_pages_restriction_flush_cache();
return array();
}
Functions
Name | Description |
---|---|
pages_restriction_flush_caches | Implements hook_flush_caches(). |
pages_restriction_menu | Implements hook_menu(). |
pages_restriction_page_alter | Implements hook_page_alter(). |