b2evolution PHP Cross Reference Blogging Systems

Source: /inc/widgets/widgets/_user_login.widget.php - 274 lines - 8041 bytes - Summary - Text - Print

Description: This file implements the user_login_Widget class. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**

   3   * This file implements the user_login_Widget class.

   4   *

   5   * This file is part of the evoCore framework - {@link http://evocore.net/}

   6   * See also {@link http://sourceforge.net/projects/evocms/}.

   7   *

   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}

   9   *

  10   * {@internal License choice

  11   * - If you have received this file as part of a package, please find the license.txt file in

  12   *   the same folder or the closest folder above for complete license terms.

  13   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)

  14   *   then you must choose one of the following licenses before using the file:

  15   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php

  16   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php

  17   * }}

  18   *

  19   * @package evocore

  20   *

  21   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}

  22   * @author fplanque: Francois PLANQUE.

  23   *

  24   * @version $Id: _coll_search_form.widget.php 9 2011-10-24 22:32:00Z fplanque $

  25   */
  26  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  27  
  28  load_class( 'widgets/model/_widget.class.php', 'ComponentWidget' );
  29  load_class( '_core/model/dataobjects/_dataobjectlist2.class.php', 'DataObjectList2' );
  30  
  31  /**

  32   * ComponentWidget Class

  33   *

  34   * A ComponentWidget is a displayable entity that can be placed into a Container on a web page.

  35   *

  36   * @package evocore

  37   */
  38  class user_login_Widget extends ComponentWidget
  39  {
  40      /**

  41       * Constructor

  42       */
  43  	function user_login_Widget( $db_row = NULL )
  44      {
  45          // Call parent constructor:

  46          parent::ComponentWidget( $db_row, 'core', 'user_login' );
  47      }
  48  
  49  
  50      /**

  51       * Get name of widget

  52       */
  53  	function get_name()
  54      {
  55          return T_('User log in');
  56      }
  57  
  58  
  59      /**

  60       * Get a very short desc. Used in the widget list.

  61       */
  62  	function get_short_desc()
  63      {
  64          return format_to_output($this->disp_params['title']);
  65      }
  66  
  67  
  68      /**

  69       * Get short description

  70       */
  71  	function get_desc()
  72      {
  73          return T_('Display user login form & greeting.');
  74      }
  75  
  76  
  77      /**

  78       * Get definitions for editable params

  79       *

  80       * @see Plugin::GetDefaultSettings()

  81       * @param local params like 'for_editing' => true

  82       */
  83  	function get_param_definitions( $params )
  84      {
  85          load_funcs( 'files/model/_image.funcs.php' );
  86  
  87          $r = array_merge( array(
  88                  'title' => array(
  89                      'label' => T_('Block title'),
  90                      'note' => T_('Title to display in your skin.'),
  91                      'size' => 40,
  92                      'defaultvalue' => T_('User log in'),
  93                  ),
  94                  // Password

  95                  'password_link_show' => array(
  96                      'label' => T_( 'Password recovery link'),
  97                      'note' => T_( 'Show link' ),
  98                      'type' => 'checkbox',
  99                      'defaultvalue' => 1,
 100                  ),
 101                  'password_link' => array(
 102                      'size' => 30,
 103                      'note' => T_( 'Link text to display' ),
 104                      'type' => 'text',
 105                      'defaultvalue' => T_( 'Lost password?' ),
 106                  ),
 107                  // Register

 108                  'register_link_show' => array(
 109                      'label' => T_( 'Register link'),
 110                      'note' => T_( 'Show link' ),
 111                      'type' => 'checkbox',
 112                      'defaultvalue' => 1,
 113                  ),
 114                  'register_link' => array(
 115                      'size' => 30,
 116                      'note' => T_( 'Link text to display' ),
 117                      'type' => 'text',
 118                      'defaultvalue' => T_( 'No account yet? Register here &raquo;' ),
 119                  ),
 120                  // Picture

 121                  'profile_picture_size' => array(
 122                      'label' => T_( 'Profile picture'),
 123                      'note' => '',
 124                      'type' => 'select',
 125                      'options' => get_available_thumb_sizes( T_('none') ),
 126                      'defaultvalue' => 'crop-top-32x32',
 127                  ),
 128                  // Group

 129                  'group_show' => array(
 130                      'label' => T_( 'User group'),
 131                      'note' => T_( 'Show user group' ),
 132                      'type' => 'checkbox',
 133                      'defaultvalue' => 1,
 134                  ),
 135                  'group_text' => array(
 136                      'size' => 30,
 137                      'note' => T_( 'Group text to display' ),
 138                      'type' => 'text',
 139                      'defaultvalue' => T_( 'Your group: $group$' ),
 140                  ),
 141                  // Level

 142                  'level_show' => array(
 143                      'label' => T_( 'User level'),
 144                      'note' => T_( 'Show user level' ),
 145                      'type' => 'checkbox',
 146                      'defaultvalue' => 1,
 147                  ),
 148                  'level_text' => array(
 149                      'size' => 30,
 150                      'note' => T_( 'Level text to display' ),
 151                      'type' => 'text',
 152                      'defaultvalue' => T_( 'Your level: $level$' ),
 153                  ),
 154                  // Greeting

 155                  'greeting_show' => array(
 156                      'label' => T_( 'Greeting'),
 157                      'note' => T_( 'Show greeting' ),
 158                      'type' => 'checkbox',
 159                      'defaultvalue' => 1,
 160                  ),
 161                  'greeting_text' => array(
 162                      'size' => 30,
 163                      'note' => T_( 'Greeting text to display' ),
 164                      'type' => 'text',
 165                      'defaultvalue' => T_( 'Hello $login$ !' ),
 166                  ),
 167              ), parent::get_param_definitions( $params ) );
 168  
 169          if( isset( $r['allow_blockcache'] ) )
 170          { // Set default blockcache to false and disable this setting because caching is never allowed for this widget
 171              $r['allow_blockcache']['defaultvalue'] = false;
 172              $r['allow_blockcache']['disabled'] = 'disabled';
 173              if( ! empty( $this->params ) && ( ! isset( $params['infinite_loop'] ) ) )
 174              { // Force allow_blockache to false! It is never allowed to be on, no matter what was set in the database.
 175                  $this->set( 'allow_blockcache', false );
 176              }
 177          }
 178  
 179          return $r;
 180      }
 181  
 182  
 183      /**

 184       * Request all required css and js files for this widget

 185       */
 186  	function request_required_files()
 187      {
 188          global $Settings, $Plugins;
 189  
 190          //get required js files for _widget_login.form

 191          $transmit_hashed_password = (bool)$Settings->get('js_passwd_hashing') && !(bool)$Plugins->trigger_event_first_true('LoginAttemptNeedsRawPassword');
 192          if( $transmit_hashed_password )
 193          { // Include JS for client-side password hashing:
 194              require_js( 'sha1_md5.js', 'blog' );
 195          }
 196      }
 197  
 198  
 199      /**

 200       * Display the widget!

 201       *

 202       * @param array MUST contain at least the basic display params

 203       */
 204  	function display( $params )
 205      {
 206          global $Blog, $redirect_to, $skins_path;
 207  
 208          if( get_param( 'disp' ) == 'login' )
 209          {    // No display a duplicate form for inskin login mode
 210              return false;
 211          }
 212  
 213          $this->init_display( $params );
 214  
 215          if( isset( $this->BlockCache ) )
 216          {    // Do NOT cache some of these links are using a redirect_to param, which makes it page dependent.
 217              // Note: also beware of the source param.

 218              // so this will be cached by the PageCache; there is no added benefit to cache it in the BlockCache

 219              // (which could have been shared between several pages):

 220              $this->BlockCache->abort_collect();
 221          }
 222  
 223          echo $this->disp_params['block_start'];
 224  
 225          if( ! is_logged_in() )
 226          {    // Login form:
 227              $source = 'user_login_widget';
 228              if( empty( $redirect_to ) )
 229              {
 230                  $redirect_to = regenerate_url( '', '', '', '&' );
 231              }
 232  
 233              $this->disp_title();
 234              // display widget login form

 235              require $skins_path.'_widget_login.form.php';
 236          }
 237          else
 238          {    // Display a greeting text
 239              global $current_User;
 240  
 241              if( $this->get_param('profile_picture_size') != '' )
 242              {    // Display profile picture
 243                  echo $current_User->get_avatar_imgtag( $this->disp_params['profile_picture_size'], 'avatar', 'middle' );
 244              }
 245  
 246              if( $this->get_param('greeting_show') )
 247              {    // Display greeting text
 248                  $user_login = $current_User->get_identity_link( array( 'link_text' => 'login', 'display_bubbletip' => false ) );
 249                  echo ' <strong class="greeting">'.str_replace( '$login$', $user_login, $this->get_param('greeting_text') ).'</strong>';
 250              }
 251  
 252              if( $this->get_param('group_show') )
 253              {    // Display user group
 254                  $user_Group = $current_User->get_Group();
 255                  echo '<p class="user_group">'
 256                      .str_replace( '$group$', $user_Group->get( 'name' ), $this->get_param('group_text') )
 257                      .'</p>';
 258              }
 259  
 260              if( $this->get_param('level_show') )
 261              {    // Display user group
 262                  echo '<p class="user_level">'
 263                      .str_replace( '$level$', $current_User->get( 'level' ), $this->get_param('level_text') )
 264                      .'</p>';
 265              }
 266          }
 267  
 268          echo $this->disp_params['block_end'];
 269  
 270          return true;
 271      }
 272  }
 273  
 274  ?>

title

Description

title

Description

title

Description

title

title

Body