You are here

logouttab.module in Logout Tab 6

Same filename and directory in other branches
  1. 8 logouttab.module
  2. 5 logouttab.module
  3. 7 logouttab.module

Adds a logout tab to the profile area.

File

logouttab.module
View source
<?php

/**
 * @file
 * Adds a logout tab to the profile area.
 */

/**
 * Implementation of 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' => 8,
    'type' => MENU_LOCAL_TASK,
  );
  $items['admin/user/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', 'logout'));
}

/**
 * Defines the settings form.
 */
function logouttab_admin_settings() {
  $form['logouttab_url'] = array(
    '#type' => 'textfield',
    '#title' => t('URL for the account help page'),
    '#description' => t('Enter the relative path for the user account logout page.'),
    '#default_value' => variable_get('logouttab_url', 'logout'),
    '#title' => t('URL'),
  );
  return system_settings_form($form);
}

Functions

Namesort descending Description
logouttab_admin_settings Defines the settings form.
logouttab_menu Implementation of hook_menu().
_logouttab_redirect_url Redirects user to defined page.