logouttab.module in Logout Tab 5
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.
*/
/**
* Implementation of hook_menu().
*/
function logouttab_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/settings/useraccounthelp',
'title' => t('User Account helppage settings'),
'description' => t('Choose the page that the user account help tab link goes to.'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'logouttab_admin_settings',
),
'access' => user_access('administer site configuration'),
);
}
//testing to make sure we're in a user profile...
if (arg(0) == 'user' && is_numeric(arg(1))) {
global $user;
$view_access = user_access('access user profiles') && $user->uid == arg(1);
if ($user !== FALSE && $view_access) {
$helpurl = variable_get('logouttab_url', 'logout');
// User help page
$items[] = array(
'path' => "user/" . arg(1) . "/" . $helpurl,
'title' => t('Logout'),
'weight' => 8,
'callback' => 'send_to_help_page',
'callback arguments' => $helpurl,
//'access' => user_access('maintain own subscriptions'),
'type' => MENU_LOCAL_TASK,
);
}
}
return $items;
}
function send_to_help_page($helpurl) {
drupal_goto($path = $helpurl);
}
/**
* 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 help page.'),
'#default_value' => variable_get('logouttab_url', 'logout'),
'#title' => t('URL'),
);
return system_settings_form($form);
}
Functions
Name | Description |
---|---|
logouttab_admin_settings | Defines the settings form. |
logouttab_menu | Implementation of hook_menu(). |
send_to_help_page |