-
-
Save barraponto/53f79f6e3f00a19817bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// $Id$ | |
/** | |
* @file | |
* Outputs block with simple links to login / logout. | |
*/ | |
/** | |
* Implementation of hook_block_info() | |
*/ | |
function simple_login_block_info() { | |
$blocks['simple_login'] = array ( | |
'info' => t('User logout / login links'), | |
'status' => true, | |
'region' => 'header', | |
'weight' => 0, | |
'visibility' => 1, | |
'cache' => DRUPAL_CACHE_PER_USER, | |
); | |
return $blocks; | |
} | |
/** | |
* Implementation of hook_block_view() | |
*/ | |
function simple_login_block_view($delta = '') { | |
switch($delta) { | |
case 'simple_login': | |
$block['subject'] = ''; | |
$block['content'] = simple_login_contents(); | |
return $block; | |
break; | |
} | |
} | |
function simple_login_contents() { | |
if (user_is_logged_in()){ | |
global $user; | |
$output = theme('username', array('account'=> $user)) . ' | ' . l('Log out', 'user/logout'); | |
} else { | |
$output = l('Login', 'user') . ' | '. l('Create Account','user/register'); | |
} | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment