[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/userloginbar/ -> userloginbar.module (source)

   1  <?php
   2  // $Id: userloginbar.module,v 1.1.2.1 2009/01/17 17:58:12 ebizondrupalservices Exp $
   3  
   4  
   5  /*
   6   * Userloginbar is a module written by developers at Ebizon Technologies (www.ebizontek.com). It is the implementation of http://drupal.org/node/92657#comment-792952. This module creates a new user login bar block.
   7   */
   8  
   9  /**
  10   * Implementation of hook_menu().
  11   */
  12  function userloginbar_menu() {
  13  
  14    $items = array();
  15  
  16    $items['admin/settings/userloginbar'] = array(
  17      'title' => 'UserloginBar Settings',
  18      'page callback' => 'drupal_get_form',
  19      'page arguments' => array('userloginbar_admin'),
  20      'access arguments' => array('administrator content'),
  21    );
  22  
  23    return $items;
  24  }
  25  
  26  /** implementing the new user login block */
  27  function userloginbar_block($op = 'list', $delta = 0) {
  28    if ($op == 'list') {
  29      $blocks[0]['info'] = t("User Login Bar Block");
  30      return $blocks;
  31    }
  32    elseif ($op == 'view') {
  33  
  34      $block['content'] = theme('userloginbar');
  35      return $block;
  36    }
  37  }
  38  
  39  /**
  40   * Implementation of hook_theme()...
  41   */
  42  function userloginbar_theme() {
  43    return array(
  44      'userloginbar' => array('arguments' => array()),
  45    );
  46  }
  47  
  48  /**
  49   * Theming function for messages.
  50   */
  51  function theme_userloginbar() {
  52    drupal_add_css(drupal_get_path('module', 'userloginbar') .'/userloginbar.css');
  53    global $user;
  54    $output = '';
  55  
  56    if (arg(0) == "user" && !is_numeric(arg(1))) {
  57  
  58      return;
  59  
  60    }
  61    if (!$user->uid) {
  62      $output .= drupal_get_form('user_login_block');
  63    }
  64    else if (!variable_get('disable_welcome_box', FALSE)) {
  65      $output .= t('<p class="user-info">Hi !user, welcome back.</p>', array('!user' => theme('username', $user)));
  66  
  67      $output .= theme('item_list', array(
  68          l(t('Your account'), 'user/'. $user->uid, array('title' => t('Edit your account'))),
  69          l(t('Sign out'), 'logout'),
  70        ));
  71    }
  72  
  73    $output = '<div id="user-login-form">'. $output .'</div>';
  74  
  75    return $output;
  76  }
  77  
  78  function userloginbar_form_alter(&$form, $form_state, $form_id) {
  79    global $form_values;
  80    switch ($form_id) {
  81      case 'user_login_block':
  82        $form['#action'] = '?q=user&'. drupal_get_destination();
  83        $form['#method'] = 'post';
  84        $form['form_id'] = array(
  85          '#type' => 'hidden',
  86          '#default_value' => 'user_login',
  87        );
  88        $items = array();
  89        if (variable_get('user_register', 1)) {
  90          $items[] = l(t('Register'), 'user/register', array('title' => t('Create a new user account.'))) .' | &nbsp;';
  91        }
  92        $items[] = l(t('Forgot Password?'), 'user/password', array('title' => t('Request new password via e-mail.')));
  93  
  94        $form['links'] = array('#value' => theme('item_list', $items));
  95        break;
  96    }
  97  }
  98  
  99  function userloginbar_admin() {
 100    $form['text'] = array(
 101      '#type' => 'fieldset',
 102      '#title' => t('Userloginbar Settings'),
 103    );
 104  
 105    $form['text']['disable_welcome_box'] = array(
 106      '#type' => 'checkbox',
 107      '#title' => t('Check this box, if you want to disable welcome box when the user logs in!'),
 108      '#default_value' => variable_get('disable_welcome_box', FALSE),
 109    );
 110  
 111    return system_settings_form($form);
 112  }
 113  


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7