guardr_core.module in Guardr Core 7
Same filename and directory in other branches
Support module for the Guardr distribution.
File
guardr_core.moduleView source
<?php
/**
* @file
* Support module for the Guardr distribution.
*/
/**
* Implements hook_init().
*/
function guardr_core_init() {
// Change to the birthday of Classic Graphics.
drupal_add_http_header('Expires', 'Fri, 15 April 1983 05:00:00 GMT');
}
/**
* Implements hook_permission().
*/
function guardr_core_permission() {
return array(
'change guardr core settings' => array(
'title' => t('Change guardr core settings'),
),
);
}
/**
* Implements hook_menu().
*/
function guardr_core_menu() {
$items['admin/config/guardr-core'] = array(
'title' => 'Guardr core',
'description' => 'Guardr core settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'guardr_core_settings_form',
),
'access arguments' => array(
'change guardr core settings',
),
'type' => MENU_NORMAL_ITEM,
'file' => 'guardr_core.admin.inc',
);
return $items;
}
/**
* Implements hook_block_info().
*/
function guardr_core_block_info() {
// Attributes for our advisory message.
$blocks['guardr_login_advisory'] = array(
'info' => t('Login advisory message'),
'status' => 1,
'region' => 'help',
'visibility' => BLOCK_VISIBILITY_LISTED,
'pages' => "user\nuser/login\nuser/password",
);
return $blocks;
}
/**
* Implements hook_block_configure().
*/
function guardr_core_block_configure($delta = '') {
$form = array();
// Edit page for login advisory block.
if ($delta == 'guardr_login_advisory') {
$form['guardr_login_advisory'] = array(
'#type' => 'textarea',
'#title' => '',
'#default_value' => variable_get('guardr_login_advisory', t('This is a monitored, private computer system containing confidential information. Unauthorized attempts to access or use this computer system or any information on it may result in termination of employment, civil fines, and criminal penalties. This system must be used for authorized business purposes only. Exit now if you are not authorized to access this system.')),
);
}
return $form;
}
/**
* Implements hook_block_save().
*/
function guardr_core_block_save($delta = '', $edit = array()) {
if ($delta == 'guardr_login_advisory') {
variable_set('guardr_login_advisory', $edit['guardr_login_advisory']);
}
}
/**
* Implements hook_block_view().
*/
function guardr_core_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'guardr_login_advisory':
$block['subject'] = '<none>';
$block['content'] = variable_get('guardr_login_advisory', t('This is a monitored, private computer system containing confidential information. Unauthorized attempts to access or use this computer system or any information on it may result in termination of employment, civil fines, and criminal penalties. This system must be used for authorized business purposes only. Exit now if you are not authorized to access this system.'));
break;
}
return $block;
}
/**
* Implements hook_preprocess().
*/
function guardr_core_preprocess(&$vars, $hook) {
// Check to see if this guardr is an intranet
// style install. See admin/config/guardr_core.
$intranet = variable_get('guardr_intranet');
switch ($hook) {
case 'html':
if ($vars['logged_in'] == FALSE && $intranet == TRUE) {
unset($vars['head_title']);
}
break;
case 'page':
// Here we remove the site name and logo if the user is
// anonymous and the guardr_intranet is default (1/TRUE).
if ($vars['logged_in'] == FALSE && $intranet == TRUE) {
unset($vars['site_name']);
unset($vars['logo']);
}
break;
}
}
/**
* Implements hook_form_alter().
*/
function guardr_core_form_alter(&$form, &$form_state, $form_id) {
// Check to see if this guardr is an intranet
// style install. See admin/config/guardr_core.
$intranet = variable_get('guardr_intranet');
switch ($form_id) {
case 'user_login':
// Here we remove the user_login form descriptions
// if the guardr_intranet variable is default (1/TRUE).
if ($intranet == TRUE) {
unset($form['name']['#description']);
unset($form['pass']['#description']);
}
break;
}
}
Functions
Name![]() |
Description |
---|---|
guardr_core_block_configure | Implements hook_block_configure(). |
guardr_core_block_info | Implements hook_block_info(). |
guardr_core_block_save | Implements hook_block_save(). |
guardr_core_block_view | Implements hook_block_view(). |
guardr_core_form_alter | Implements hook_form_alter(). |
guardr_core_init | Implements hook_init(). |
guardr_core_menu | Implements hook_menu(). |
guardr_core_permission | Implements hook_permission(). |
guardr_core_preprocess | Implements hook_preprocess(). |