b2evolution PHP Cross Reference Blogging Systems

Source: /inc/users/views/_user_avatar.form.php - 216 lines - 7642 bytes - Text - Print

   1  <?php
   2  
   3  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
   4  
   5  /**
   6   * @var user permission, if user is only allowed to edit his profile
   7   */
   8  global $user_profile_only;
   9  /**
  10   * @var User
  11   */
  12  global $edited_User;
  13  /**
  14   * @var User
  15   */
  16  global $current_User;
  17  /**
  18   * @var current action
  19   */
  20  global $action;
  21  /**
  22   * @var the action destination of the form (NULL for pagenow)
  23   */
  24  global $form_action;
  25  
  26  
  27  // Default params:
  28  $default_params = array(
  29          'skin_form_params' => array(),
  30      );
  31  
  32  if( isset( $params ) )
  33  {    // Merge with default params
  34      $params = array_merge( $default_params, $params );
  35  }
  36  else
  37  {    // Use a default params
  38      $params = $default_params;
  39  }
  40  
  41  
  42  // ------------------- PREV/NEXT USER LINKS -------------------
  43  user_prevnext_links( array(
  44          'block_start'  => '<table class="prevnext_user"><tr>',
  45          'prev_start'   => '<td width="33%">',
  46          'prev_end'     => '</td>',
  47          'prev_no_user' => '<td width="33%">&nbsp;</td>',
  48          'back_start'   => '<td width="33%" class="back_users_list">',
  49          'back_end'     => '</td>',
  50          'next_start'   => '<td width="33%" class="right">',
  51          'next_end'     => '</td>',
  52          'next_no_user' => '<td width="33%">&nbsp;</td>',
  53          'block_end'    => '</tr></table>',
  54          'user_tab'     => 'avatar'
  55      ) );
  56  // ------------- END OF PREV/NEXT USER LINKS -------------------
  57  
  58  
  59  $Form = new Form( $form_action, 'user_checkchanges', 'post', NULL, 'multipart/form-data' );
  60  
  61  $Form->switch_template_parts( $params['skin_form_params'] );
  62  
  63  if( !$user_profile_only )
  64  {
  65      echo_user_actions( $Form, $edited_User, $action );
  66  }
  67  
  68  $is_admin = is_admin_page();
  69  if( $is_admin )
  70  {
  71      $form_title = get_usertab_header( $edited_User, 'avatar', T_( 'Edit profile picture' ) );
  72      $form_class = 'fform';
  73      $Form->title_fmt = '<span style="float:right">$global_icons$</span><div>$title$</div>'."\n";
  74      $ctrl_param = '?ctrl=user&amp;user_tab=avatar&amp;user_ID='.$edited_User->ID;
  75  }
  76  else
  77  {
  78      global $Blog;
  79      $form_title = '';
  80      $form_class = 'bComment';
  81      $ctrl_param = url_add_param( $Blog->gen_blogurl(), 'disp='.$disp );
  82  }
  83  
  84  $Form->begin_form( $form_class, $form_title );
  85  
  86      $Form->add_crumb( 'user' );
  87      if( $is_admin )
  88      {
  89          $Form->hidden_ctrl();
  90      }
  91      else
  92      {
  93          $Form->hidden( 'disp', $disp );
  94      }
  95      $Form->hidden( 'user_tab', 'avatar' );
  96      $Form->hidden( 'avatar_form', '1' );
  97  
  98      $Form->hidden( 'user_ID', $edited_User->ID );
  99      if( isset( $Blog ) )
 100      {
 101          $Form->hidden( 'blog', $Blog->ID );
 102      }
 103  
 104      /***************  Avatar  **************/
 105  
 106  $Form->begin_fieldset( $is_admin ? T_('Profile picture') : '', array( 'class'=>'fieldset clear' ) );
 107  
 108  global $admin_url;
 109  $avatar_tag = $edited_User->get_avatar_imgtag( 'fit-160x160', 'avatar', '', true, '', 'user_pictures' );
 110  if( empty( $avatar_tag ) )
 111  {
 112      if( ( $current_User->ID == $edited_User->ID ) )
 113      {
 114          $avatar_tag = T_( 'You currently have no profile picture.' );
 115      }
 116      else
 117      {
 118          $avatar_tag = T_( 'This user currently has no profile picture.' );
 119      }
 120  }
 121  
 122  if( $edited_User->has_avatar() )
 123  {
 124      if( is_admin_page() )
 125      {
 126          $remove_picture_url = $ctrl_param.'&amp;action=remove_avatar&amp;'.url_crumb('user');
 127          $delete_picture_url = $ctrl_param.'&amp;action=delete_avatar&amp;file_ID='.$edited_User->avatar_file_ID.'&amp;'.url_crumb('user');
 128      }
 129      else
 130      {
 131          $remove_picture_url = get_secure_htsrv_url().'profile_update.php?user_tab=avatar&amp;blog='.$Blog->ID.'&amp;action=remove_avatar&amp;'.url_crumb('user');
 132          $delete_picture_url = get_secure_htsrv_url().'profile_update.php?user_tab=avatar&amp;blog='.$Blog->ID.'&amp;action=delete_avatar&amp;file_ID='.$edited_User->avatar_file_ID.'&amp;'.url_crumb('user');
 133      }
 134  
 135      $rotate_icons = $edited_User->get_rotate_avatar_icons( $edited_User->avatar_file_ID, array(
 136              'before' => '<p class="center">',
 137              'after'  => '</p>'
 138          ) );
 139  
 140      $remove_picture_text = T_( 'No longer use this as main profile picture' );
 141      $delete_picture_text = T_( 'Delete this profile picture' );
 142  
 143      $action_picture_links = '<div>'.
 144              '<p class="center">'.action_icon( $remove_picture_text, 'move_down', $remove_picture_url, $remove_picture_text, 3, 4, array( 'style' => 'display:block;text-indent:-16px;padding-left:16px' ), array( 'style' => 'margin-right:4px' ) ).'</p>'.
 145              '<p class="center">'.action_icon( $delete_picture_text, 'xross', $delete_picture_url, $delete_picture_text, 3, 4, array( 'style' => 'display:block;text-indent:-16px;padding-left:16px', 'onclick' => 'return confirm(\''.TS_('Are you sure want to delete this picture?').'\');' ), array( 'style' => 'margin-right:4px' ) ).'</p>'.
 146              $rotate_icons.
 147          '</div>';
 148  
 149      $avatar_tag = '<div class="avatar_main_frame">'.$avatar_tag.$action_picture_links.'<div class="clear"></div></div>';
 150  }
 151  
 152  $Form->info( T_( 'Current profile picture' ), $avatar_tag );
 153  
 154  // fp> TODO: a javascript REFRAME feature would ne neat here: selecting a square area of the img and saving it as a new avatar image
 155  
 156  if( ( $current_User->ID == $edited_User->ID ) || ( $current_User->check_perm( 'users', 'edit' ) ) )
 157  {
 158      // Upload or select:
 159      global $Settings;
 160      if( $Settings->get('upload_enabled') && ( $Settings->get( 'fm_enable_roots_user' ) ) )
 161      {    // Upload is enabled and we have permission to use it...
 162          $user_avatars = $edited_User->get_avatar_Files();
 163          if( count( $user_avatars ) > 0 )
 164          {
 165              $info_content = '';
 166              foreach( $user_avatars as $uFile )
 167              {
 168                  if( is_admin_page() )
 169                  {
 170                      $url_update = regenerate_url( '', 'user_tab=avatar&user_ID='.$edited_User->ID.'&action=update_avatar&file_ID='.$uFile->ID.'&'.url_crumb('user'), '', '&');
 171                      $url_delete = regenerate_url( '', 'user_tab=avatar&user_ID='.$edited_User->ID.'&action=delete_avatar&file_ID='.$uFile->ID.'&'.url_crumb('user'), '', '&');
 172                  }
 173                  else
 174                  {
 175                      $url_update = get_secure_htsrv_url().'profile_update.php?user_tab=avatar&blog='.$Blog->ID.'&user_ID='.$edited_User->ID.'&action=update_avatar&file_ID='.$uFile->ID.'&'.url_crumb('user');
 176                      $url_delete = get_secure_htsrv_url().'profile_update.php?user_tab=avatar&blog='.$Blog->ID.'&user_ID='.$edited_User->ID.'&action=delete_avatar&file_ID='.$uFile->ID.'&'.url_crumb('user');
 177                  }
 178                  $info_content .= '<div class="avatartag avatar_rounded">';
 179                  $info_content .= $uFile->get_tag( '', '', '', '', 'crop-top-80x80', 'original', $edited_User->login, 'lightbox[user_pictures]' );
 180                  $info_content .= '<br />'.action_icon( T_('Use as main picture'), 'move_up', $url_update, T_('Main'), 3, 4, array(), array( 'style' => 'margin-right:4px' ) );
 181                  $info_content .= '<br />'.action_icon( T_('Delete this picture'), 'xross', $url_delete, T_('Delete'), 3, 4, array( 'onclick' => 'return confirm(\''.TS_('Are you sure want to delete this picture?').'\');' ), array( 'style' => 'margin-right:4px' ) );
 182                  $info_content .= $edited_User->get_rotate_avatar_icons( $uFile->ID );
 183                  $info_content .= '</div>';
 184              }
 185              $Form->info( T_('Other pictures'), $info_content );
 186          }
 187  
 188          $Form->hidden( 'action', 'upload_avatar' );
 189          // The following is mainly a hint to the browser.
 190          $Form->hidden( 'MAX_FILE_SIZE', $Settings->get( 'upload_maxkb' )*1024 );
 191  
 192          // Upload
 193          $info_content = '<input name="uploadfile[]" type="file" size="10" />';
 194          $info_content .= '<input class="ActionButton" type="submit" value="&gt; './* TRANS: action */ T_('Upload!').'" />';
 195          $Form->info( T_('Upload a new picture'), $info_content );
 196      }
 197  
 198      $more_content = '';
 199  
 200      if( $current_User->check_perm( 'files', 'view' ) )
 201      {
 202          $more_content .= '<div><a href="'.$admin_url.'?ctrl=files&amp;user_ID='.$edited_User->ID.'">';
 203          $more_content .= T_( 'Use the file manager to assign a new profile picture' ).'</a></div>';
 204      }
 205  
 206      if( ! empty( $more_content ) )
 207      {
 208          $Form->info( T_('More functions'), $more_content );
 209      }
 210  }
 211  
 212  $Form->end_fieldset();
 213  
 214  $Form->end_form();
 215  
 216  ?>

title

Description

title

Description

title

Description

title

title

Body