function protected_pages_init in Protected Pages 7
Same name and namespace in other branches
- 7.2 protected_pages.module \protected_pages_init()
Implements hook_init().
File
- ./
protected_pages.module, line 114 - This module allows you to protect any page of your website by secure password. You can enter urls of pages to protect and set password per page. Admin (uid = 1) or user with bypass protection permission can view page.
Code
function protected_pages_init() {
if (user_access('bypass pages password protection')) {
return;
}
$current_path = current_path();
$normal_path = drupal_get_normal_path($current_path);
$pid = protected_pages_is_page_locked($current_path, $normal_path);
if ($pid) {
$query = drupal_get_destination();
if (!empty($_SERVER['HTTP_REFERER'])) {
$query['back'] = urlencode($current_path);
}
$query['protected_page'] = $pid;
drupal_goto('protected-page', array(
'query' => $query,
));
}
}