b2evolution PHP Cross Reference Blogging Systems

Source: /skins/_user.disp.php - 340 lines - 12863 bytes - Text - Print

Description: This is the template that displays the user profile page. This file is not meant to be called directly. It is meant to be called by an include in the main.page.php template.

   1  <?php
   2  /**
   3   * This is the template that displays the user profile page.
   4   *
   5   * This file is not meant to be called directly.
   6   * It is meant to be called by an include in the main.page.php template.
   7   *
   8   * This file is part of the b2evolution/evocms project - {@link http://b2evolution.net/}.
   9   * See also {@link http://sourceforge.net/projects/evocms/}.
  10   *
  11   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}.
  12   *
  13   * @license http://b2evolution.net/about/license.html GNU General Public License (GPL)
  14   *
  15   * @package evoskins
  16   *
  17   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  18   * @author fplanque: Francois PLANQUE.
  19   *
  20   * @version $Id: _user.disp.php 6136 2014-03-08 07:59:48Z manuel $
  21   */
  22  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  23  
  24  /**
  25  * @var Blog
  26  */
  27  global $Blog;
  28  /**
  29   * @var GeneralSettings
  30   */
  31  global $Settings;
  32  /**
  33   * @var Current User
  34   */
  35  global $current_User;
  36  
  37  // init is logged in status
  38  $is_logged_in = is_logged_in();
  39  
  40  // Default params:
  41  $params = array_merge( array(
  42          'profile_avatar_before'            => '<span style="position:absolute;right:1em">',
  43          'profile_avatar_after'             => '</span>',
  44          'avatar_image_size'                => 'fit-160x160',
  45          'avatar_image_size_if_anonymous'   => 'fit-160x160-blur-18',
  46          'avatar_overlay_text_if_anonymous' => '#default#',
  47          'edit_my_profile_link_text'        => T_('Edit my profile').' &raquo;',
  48          'edit_user_admin_link_text'        => T_('Edit this user in backoffice'),
  49          'skin_form_params'                 => array(),
  50      ), $params );
  51  
  52  
  53  // ------------------- PREV/NEXT USER LINKS (SINGLE USER MODE) -------------------
  54  user_prevnext_links( array(
  55          'block_start'  => '<table class="prevnext_user"><tr>',
  56          'prev_start'   => '<td width="33%">',
  57          'prev_end'     => '</td>',
  58          'prev_no_user' => '<td width="33%">&nbsp;</td>',
  59          'back_start'   => '<td width="33%" class="back_users_list">',
  60          'back_end'     => '</td>',
  61          'next_start'   => '<td width="33%" class="right">',
  62          'next_end'     => '</td>',
  63          'next_no_user' => '<td width="33%">&nbsp;</td>',
  64          'block_end'    => '</tr></table>',
  65      ) );
  66  // ------------------------- END OF PREV/NEXT USER LINKS -------------------------
  67  
  68  
  69  $user_ID = param( 'user_ID', 'integer', '' );
  70  if( empty($user_ID) )
  71  {    // Grab the current User
  72      $user_ID = $current_User->ID;
  73  }
  74  
  75  $UserCache = & get_UserCache();
  76  /**
  77   * @var User
  78   */
  79  $User = & $UserCache->get_by_ID( $user_ID );
  80  
  81  /**
  82   * form to update the profile
  83   * @var Form
  84   */
  85  $ProfileForm = new Form( get_dispctrl_url( 'contacts' ), 'ProfileForm' );
  86  
  87  $ProfileForm->switch_template_parts( $params['skin_form_params'] );
  88  
  89  if( $is_logged_in )
  90  { // user is logged in
  91      if( $current_User->check_perm( 'users', 'edit' ) && $current_User->check_status( 'can_access_admin' ) )
  92      { // Current user can edit other user's profiles
  93          global $admin_url;
  94          echo '<div class="edit_user_admin_link">';
  95          echo '<a href="'.url_add_param( $admin_url, 'ctrl=user&amp;user_ID='.$User->ID ).'">'.$params['edit_user_admin_link_text'].'</a>';
  96          echo '</div>';
  97      }
  98  
  99      if( $User->ID == $current_User->ID && !empty($params['edit_my_profile_link_text']) )
 100      {    // Display edit link profile for owner:
 101          echo '<div class="floatright">';
 102          echo '<a href="'.url_add_param( $Blog->get('url'), 'disp=profile' ).'">'.$params['edit_my_profile_link_text'].'</a>';
 103          echo '</div>';
 104      }
 105  }
 106  
 107  echo '<div class="clear"></div>';
 108  
 109  $ProfileForm->begin_form( 'bComment' );
 110  
 111  $avatar_overlay_text = '';
 112  if( $is_logged_in )
 113  {    // Avatar size for logged in user
 114      $avatar_image_size = $params['avatar_image_size'];
 115  }
 116  else
 117  {    // Avatar settings for anonymous user
 118      $avatar_image_size = $params['avatar_image_size_if_anonymous'];
 119      if( $params['avatar_overlay_text_if_anonymous'] != '#default#' )
 120      {    // Get overlay text from params
 121          $avatar_overlay_text = $params['avatar_overlay_text_if_anonymous'];
 122      }
 123      else
 124      {    // Get default overlay text from Back-office settings
 125          $avatar_overlay_text = $Settings->get('bubbletip_overlay');
 126      }
 127  }
 128  
 129  $avatar_imgtag = $params['profile_avatar_before'].$User->get_avatar_imgtag( $avatar_image_size, '', '', true, $avatar_overlay_text, 'user' ).$params['profile_avatar_after'];
 130  
 131  if( $is_logged_in )
 132  {
 133      if( $User->ID == $current_User->ID && ! $User->has_avatar() )
 134      {    // If user hasn't an avatar, add a link to go for uploading of avatar
 135          $avatar_imgtag = '<a href="'.get_user_avatar_url().'">'.$avatar_imgtag.'</a>';
 136      }
 137  }
 138  
 139  echo $avatar_imgtag;
 140  
 141  $ProfileForm->begin_fieldset( T_('Identity') );
 142  
 143      echo '<div class="profile_pictured_fieldsets">';
 144  
 145      $login_note = '';
 146      if( $is_logged_in && ( $User->ID == $current_User->ID ) && ( $User->check_status( 'can_be_validated' ) ) )
 147      { // Remind the current user that he has not activated his account yet:
 148          $login_note = '<span style="color:red; font-weight:bold">[<a style="color:red" href="'.get_activate_info_url().'">'.T_('Not activated').'</a>]</span>';
 149      }
 150  
 151      $ProfileForm->info( T_('Login'), $User->get_colored_login(), $login_note );
 152  
 153      if( $Settings->get( 'firstname_editing' ) != 'hidden' && $User->get( 'firstname' ) != '' )
 154      {
 155          $ProfileForm->info( T_('First Name'), $User->get( 'firstname' ) );
 156      }
 157  
 158      if( $Settings->get( 'lastname_editing' ) != 'hidden' && $User->get( 'lastname' ) != '' )
 159      {
 160          $ProfileForm->info( T_('Last Name'), $User->get( 'lastname' ) );
 161      }
 162  
 163      $ProfileForm->info( T_( 'I am' ), $User->get_gender() );
 164  
 165      if( ! empty( $User->ctry_ID ) && user_country_visible() )
 166      {    // Display country
 167          load_class( 'regional/model/_country.class.php', 'Country' );
 168          $ProfileForm->info( T_( 'Country' ), $User->get_country_name() );
 169      }
 170  
 171      if( ! empty( $User->rgn_ID ) && user_region_visible() )
 172      {    // Display region
 173          load_class( 'regional/model/_region.class.php', 'Region' );
 174          $ProfileForm->info( T_( 'Region' ), $User->get_region_name() );
 175      }
 176  
 177      if( ! empty( $User->subrg_ID ) && user_subregion_visible() )
 178      {    // Display sub-region
 179          load_class( 'regional/model/_subregion.class.php', 'Subregion' );
 180          $ProfileForm->info( T_( 'Sub-region' ), $User->get_subregion_name() );
 181      }
 182  
 183      if( ! empty( $User->city_ID ) && user_city_visible() )
 184      {    // Display city
 185          load_class( 'regional/model/_city.class.php', 'City' );
 186          $ProfileForm->info( T_( 'City' ), $User->get_city_name() );
 187      }
 188  
 189      if( ! empty( $User->age_min ) || ! empty( $User->age_max ) )
 190      {
 191          $ProfileForm->info( T_( 'My age group' ), sprintf( T_('from %d to %d years old'), $User->get('age_min'), $User->get('age_max') ) );
 192      }
 193  
 194      echo '</div>';
 195  
 196      if( $is_logged_in && $current_User->check_status( 'can_view_user', $user_ID ) )
 197      { // Display other pictures, but only for logged in and activated users:
 198          $user_avatars = $User->get_avatar_Files();
 199          if( count( $user_avatars ) > 0 )
 200          {
 201              $info_content = '';
 202              foreach( $user_avatars as $uFile )
 203              {
 204                  $info_content .= $uFile->get_tag( '<div class="avatartag">', '', '', '</div>', 'crop-top-80x80', 'original', $User->login, 'lightbox[user]' );
 205              }
 206              $info_content .= '<div class="clear"></div>';
 207              $ProfileForm->info( T_('Other pictures'), $info_content );
 208          }
 209      }
 210  
 211  $ProfileForm->end_fieldset();
 212  
 213  $ProfileForm->begin_fieldset( sprintf( T_('You and %s...'), $User->login ) );
 214  
 215      $contacts = array();
 216      if( $is_logged_in && ( $current_User->ID != $User->ID ) && ( $current_User->check_perm( 'perm_messaging', 'reply' ) ) )
 217      { // User is logged in, has messaging access permission and is not the same user as displayed user
 218          $is_contact = check_contact( $User->ID );
 219          if( $is_contact )
 220          { // displayed user is on current User contact list
 221              $contacts[] = action_icon( T_('On my contacts list'), 'allowback', url_add_param( $Blog->gen_blogurl(), 'disp=contacts' ), T_('On my contacts list'), 3, 4, array(), array( 'style' => 'margin: 0 2px' ) );
 222              $contacts_groups = get_contacts_groups_list( $User->ID );
 223          }
 224          elseif( $is_contact !== NULL )
 225          { // displayed user is on current User contact list but it's blocked by current User
 226              $contacts[] = get_icon( 'file_not_allowed', 'imgtag', array( 'style' => 'margin-left: 4px' ) ).T_('You have blocked this user').' - <a href="'.url_add_param( $Blog->gen_blogurl(), 'disp=contacts&amp;action=unblock&amp;user_ID='.$User->ID.'&amp;'.url_crumb( 'messaging_contacts' ) ).'">'.T_('Unblock').'</a>';
 227          }
 228          elseif( $current_User->check_status( 'can_edit_contacts' ) )
 229          { // user is not in current User contact list, so allow "Add to my contacts" action, but only if current User is activated
 230              $contacts[] = action_icon( T_('Add to my contacts'), 'add', url_add_param( $Blog->gen_blogurl(), 'disp=contacts&amp;action=add_user&amp;user_ID='.$User->ID.'&amp;'.url_crumb( 'messaging_contacts' ) ), T_('Add to my contacts'), 3, 4, array(), array( 'style' => 'margin: 0 2px 0 0' ) );
 231          }
 232      }
 233  
 234      $msgform_url = $User->get_msgform_url( $Blog->get('msgformurl') );
 235      if( !empty($msgform_url) )
 236      {
 237          $msgform_url = url_add_param( $msgform_url, 'msg_type=PM' );
 238          $contacts[] = action_icon( T_('Send a message'), 'email', $msgform_url, T_('Send a message'), 3, 4, array(), array( 'style' => 'margin: 2px' ) );
 239      }
 240      else
 241      { // No message form possibility to contact with User, get the reason why
 242          $contacts[] = $User->get_no_msgform_reason();
 243      }
 244  
 245      $ProfileForm->info( T_('Contact'), implode( '<div style="height:6px"> </div>', $contacts ) );
 246  
 247      if( $is_logged_in && $current_User->check_status( 'can_edit_contacts' ) && $current_User->check_perm( 'perm_messaging', 'reply' ) )
 248      { // user is logged in, the account was activated and has the minimal messaging permission
 249          $ProfileForm->add_crumb( 'messaging_contacts' );
 250          $ProfileForm->hidden( 'user_ID', $User->ID );
 251  
 252          $ProfileForm->output = false;
 253          $button_add_group = $ProfileForm->submit_input( array(
 254                  'name' => 'actionArray[add_user]',
 255                  'value' => T_('Add'),
 256                  'class' => 'SaveButton'
 257              ) );
 258          $ProfileForm->output = true;
 259  
 260          if( !empty( $contacts_groups ) )
 261          {    // Display contacts groups for current User
 262              $ProfileForm->custom_content( '<p><strong>'.T_( 'You can organize your contacts into groups. You can decide in which groups to put this user here:' ).'</strong></p>' );
 263              $ProfileForm->info( sprintf( T_('%s is'), $User->login ), $contacts_groups );
 264  
 265              // Form to create a new group
 266              $ProfileForm->hidden( 'group_ID', 'new' );
 267              $ProfileForm->text_input( 'group_ID_combo', param( 'group_ID_combo', 'string', '' ), 18, T_('Create a new group'), '', array( 'field_suffix' => $button_add_group, 'maxlength' => 50 ) );
 268          }
 269          else if( $User->ID != $current_User->ID )
 270          {    // Form to add this user into the group
 271              $ProfileForm->combo_box( 'group_ID', param( 'group_ID_combo', 'string', '' ), get_contacts_groups_options( param( 'group', 'string', '-1' ), false ), T_('Add this user to a group'), array( 'new_field_size' => '8', 'field_suffix' => $button_add_group ) );
 272          }
 273      }
 274  
 275      // Display Report User part
 276      user_report_form( array(
 277              'Form'       => $ProfileForm,
 278              'user_ID'    => $User->ID,
 279              'crumb_name' => 'messaging_contacts',
 280              'cancel_url' => url_add_param( $Blog->get('url'), 'disp=contacts&amp;user_ID='.$User->ID.'&amp;action=remove_report&amp;'.url_crumb( 'messaging_contacts' ) ),
 281          ) );
 282  
 283  $ProfileForm->end_fieldset();
 284  
 285  
 286  // Load the user fields:
 287  $User->userfields_load();
 288  
 289  // fp> TODO: have some clean iteration support
 290  $group_ID = 0;
 291  foreach( $User->userfields as $userfield )
 292  {
 293      if( $group_ID != $userfield->ufgp_ID )
 294      {    // Start new group
 295          if( $group_ID > 0 )
 296          {    // End previous group
 297              $ProfileForm->end_fieldset();
 298          }
 299          $ProfileForm->begin_fieldset( T_( $userfield->ufgp_name ) );
 300      }
 301  
 302      if( $userfield->ufdf_type == 'text' )
 303      {    // convert textarea values
 304          $userfield->uf_varchar = nl2br( $userfield->uf_varchar );
 305      }
 306      $ProfileForm->info( $userfield->ufdf_name, $userfield->uf_varchar );
 307  
 308      $group_ID = $userfield->ufgp_ID;
 309  }
 310  if( $group_ID > 0 )
 311  {    // End fieldset if userfields are exist
 312      $ProfileForm->end_fieldset();
 313  }
 314  
 315  $ProfileForm->begin_fieldset( T_( 'Reputation' ) );
 316  
 317      $ProfileForm->info( T_('Number of posts'), $User->get_reputation_posts() );
 318  
 319      $ProfileForm->info( T_('Number of comments'), $User->get_reputation_comments() );
 320  
 321      $ProfileForm->info( T_('Number of helpful votes'), $User->get_reputation_helpful() );
 322  
 323      $ProfileForm->info( T_('Spam fighter score'), $User->get_reputation_spam() );
 324  
 325  $ProfileForm->end_fieldset();
 326  
 327  $Plugins->trigger_event( 'DisplayProfileFormFieldset', array( 'Form' => & $ProfileForm, 'User' => & $User, 'edit_layout' => 'public' ) );
 328  
 329  // Make sure we're below the floating user avatar on the right
 330  echo '<div class="clear"></div>';
 331  
 332  $ProfileForm->end_form();
 333  
 334  if( $is_logged_in && ( $User->ID == $current_User->ID ) && ( !empty( $params['edit_my_profile_link_text'] ) ) )
 335  { // Display edit link profile for owner:
 336      echo '<div class="center" style="font-size:150%">';
 337      echo '<a href="'.url_add_param( $Blog->get('url'), 'disp=profile' ).'">'.$params['edit_my_profile_link_text'].'</a>';
 338      echo '</div>';
 339  }
 340  ?>

title

Description

title

Description

title

Description

title

title

Body