You are here

userloginbar.module in UserLoginBar 8

Same filename and directory in other branches
  1. 5 userloginbar.module
  2. 7 userloginbar.module

File

userloginbar.module
View source
<?php

/*
 * 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.
 */
use Drupal\user\Form\UserLoginForm;
use Drupal\user\Plugin\Block\UserLoginBlock;

/**
 * Implementation of hook_menu().
 */
function userloginbar_menu() {
  $items = array();
  $items['admin/config/people/userloginbar'] = array(
    'title' => t('UserloginBar Settings'),
    'description' => t('Configure userloginbar welcome box.'),
    'access arguments' => array(
      'userloginbar_access',
    ),
    'route_name' => 'userloginbar_settings',
  );
  return $items;
}
function userloginbar_access() {
  return TRUE;
}

/**
 * Implementation of hook_theme().
 */
function userloginbar_theme() {
  return array(
    'userloginbar' => array(
      'variables' => array(),
    ),
  );
}

/**
 * Theming function for messages.
 */
function theme_userloginbar() {
  $config = \Drupal::config('userloginbar.settings');
  drupal_add_css(drupal_get_path('module', 'userloginbar') . '/userloginbar.css');
  global $user;
  $output = '';
  if ($user
    ->id() and !$config
    ->get('disable_welcome_box')) {
    $output .= t('<p class="user-info">Hi !user, welcome back.</p>', array(
      '!user' => theme('username', array(
        'account' => $user,
      )),
    )) . '&nbsp';
    l(t('your account'), 'user/' . $user
      ->id(), array(
      'attributes' => array(
        'title' => t('Edit your account.'),
      ),
    )) . ' | &nbsp;';
    $output .= theme('item_list', array(
      'attributes' => array(
        'class' => 'welcome-box',
      ),
      'items' => array(
        l(t('Your account'), 'user/' . $user
          ->id(), array(
          'attributes' => array(
            'title' => t('Edit your account'),
          ),
        )) . '&nbsp|&nbsp',
        l(t('Sign out'), 'user/logout', array(
          'attributes' => array(
            'title' => t('Logout'),
          ),
        )),
      ),
    ));
  }
  return $output;
}

Functions

Namesort descending Description
theme_userloginbar Theming function for messages.
userloginbar_access
userloginbar_menu Implementation of hook_menu().
userloginbar_theme Implementation of hook_theme().