'UserloginBar Settings', 'page callback' => 'drupal_get_form', 'page arguments' => array('userloginbar_admin'), 'access arguments' => array('administrator content'), ); return $items; } /** implementing the new user login block */ function userloginbar_block($op = 'list', $delta = 0) { if ($op == 'list') { $blocks[0]['info'] = t("User Login Bar Block"); return $blocks; } elseif ($op == 'view') { $block['content'] = theme('userloginbar'); return $block; } } /** * Implementation of hook_theme()... */ function userloginbar_theme() { return array( 'userloginbar' => array('arguments' => array()), ); } /** * Theming function for messages. */ function theme_userloginbar() { drupal_add_css(drupal_get_path('module', 'userloginbar') .'/userloginbar.css'); global $user; $output = ''; if (arg(0) == "user" && !is_numeric(arg(1))) { return; } if (!$user->uid) { $output .= drupal_get_form('user_login_block'); } else if (!variable_get('disable_welcome_box', FALSE)) { $output .= t('

Hi !user, welcome back.

', array('!user' => theme('username', $user))); $output .= theme('item_list', array( l(t('Your account'), 'user/'. $user->uid, array('title' => t('Edit your account'))), l(t('Sign out'), 'logout'), )); } $output = '
'. $output .'
'; return $output; } function userloginbar_form_alter(&$form, $form_state, $form_id) { global $form_values; switch ($form_id) { case 'user_login_block': $form['#action'] = '?q=user&'. drupal_get_destination(); $form['#method'] = 'post'; $form['form_id'] = array( '#type' => 'hidden', '#default_value' => 'user_login', ); $items = array(); if (variable_get('user_register', 1)) { $items[] = l(t('Register'), 'user/register', array('title' => t('Create a new user account.'))) .' |  '; } $items[] = l(t('Forgot Password?'), 'user/password', array('title' => t('Request new password via e-mail.'))); $form['links'] = array('#value' => theme('item_list', $items)); break; } } function userloginbar_admin() { $form['text'] = array( '#type' => 'fieldset', '#title' => t('Userloginbar Settings'), ); $form['text']['disable_welcome_box'] = array( '#type' => 'checkbox', '#title' => t('Check this box, if you want to disable welcome box when the user logs in!'), '#default_value' => variable_get('disable_welcome_box', FALSE), ); return system_settings_form($form); }