logouttab.module in Logout Tab 7
Same filename and directory in other branches
Adds a logout tab to the profile area.
File
logouttab.moduleView source
<?php
/**
* @file
* Adds a logout tab to the profile area.
*/
/**
* Implements hook_menu().
*/
function logouttab_menu() {
$items['user/%user/logouttab'] = array(
'title' => 'Log out',
'page callback' => '_logouttab_redirect_url',
'access callback' => 'user_is_logged_in',
'weight' => variable_get('logouttab_weight', 8),
'type' => MENU_LOCAL_TASK,
);
$items['admin/config/people/logouttab'] = array(
'title' => 'Logout settings',
'description' => 'Choose the page that the user account logout tab link goes to.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'logouttab_admin_settings',
),
'access arguments' => array(
'administer users',
),
);
return $items;
}
/**
* Redirects user to defined page.
*/
function _logouttab_redirect_url() {
drupal_goto(variable_get('logouttab_url', 'user/logout'));
}
/**
* Defines the settings form.
*/
function logouttab_admin_settings() {
$form['logouttab_url'] = array(
'#type' => 'textfield',
'#title' => t('URL for the account logout page'),
'#description' => t('Enter the relative path for the user account logout page.'),
'#default_value' => variable_get('logouttab_url', 'user/logout'),
);
$form['logouttab_weight'] = array(
'#type' => 'weight',
'#title' => t('Weight of the logout tab'),
'#default_value' => variable_get('logouttab_weight', 8),
'#delta' => 30,
);
// Add own submit handler to request menu rebuild if weight changed.
$form['#submit'][] = 'logouttab_admin_settings_submit';
return system_settings_form($form);
}
/**
* Form submission handler for logouttab_admin_settings().
*/
function logouttab_admin_settings_submit($form, &$form_state) {
if (variable_get('logouttab_weight', 8) != $form_state['values']['logouttab_weight']) {
// Rebuild menu.
variable_set('menu_rebuild_needed', TRUE);
}
}
Functions
Name | Description |
---|---|
logouttab_admin_settings | Defines the settings form. |
logouttab_admin_settings_submit | Form submission handler for logouttab_admin_settings(). |
logouttab_menu | Implements hook_menu(). |
_logouttab_redirect_url | Redirects user to defined page. |