/** * Get the avatar of the comment's author. * * @param string Avatar thumb size * @param string Class name of avatar img tag * @param array Params * @return string */ function get_avatar($size = 'crop-top-64x64', $class = 'bCommentAvatar', $params = array()) { // Make sure we are not missing any param: $params = array_merge(array('thumb_zoomable' => false), $params); global $Settings, $Plugins; if (!$Settings->get('allow_avatars')) { // Avatars are not allowed generally, Exit here return; } $comment_Item = $this->get_Item(); $comment_Item->load_Blog(); if (!$this->Item->Blog->get_setting('comments_avatars')) { // Avatars are not allowe for this Blog, Exit here return; } $author_link = get_user_identity_url($this->author_user_ID); if ($comment_author_User =& $this->get_author_User()) { // Author is a user if ($comment_author_User->has_avatar()) { // Get an image $r = $comment_author_User->get_avatar_imgtag($size, $class, '', $params['thumb_zoomable']); if ($author_link != '' && !$params['thumb_zoomable']) { // Add author link $r = '<a href="' . $author_link . '">' . $r . '</a>'; } return $r; } } // TODO> add new event // See if plugin supplies an image // $img_url = $Plugins->trigger_event( 'GetCommentAvatar', array( 'Comment' => & $this, 'size' => $size ) ); // Get gravatar for anonymous users and for users without uploaded avatar return get_avatar_imgtag_default($size, $class, '', array('email' => $this->get_author_email(), 'username' => $this->get_author_name())); }
/** * Get styled avatar * * @param integer user ID * @param array params * @return string */ function get_user_avatar_styled($user_ID, $params) { global $thumbnail_sizes; $params = array_merge(array('block_class' => 'avatar_rounded', 'size' => 'crop-top-64x64', 'avatar_class' => 'avatar', 'bubbletip' => true), $params); $UserCache =& get_UserCache(); $User =& $UserCache->get_by_ID($user_ID, false, false); if ($User) { // requested user exists return $User->get_avatar_styled($params); } // user doesn't exists because it was deleted $bubbletip_param = ''; if ($params['bubbletip']) { // Init bubbletip param $bubbletip_param = 'rel="bubbletip_user_' . $user_ID . '"'; } $style_width = ''; if (isset($thumbnail_sizes[$params['size']])) { $style_width = ' style="width:' . $thumbnail_sizes[$params['size']][1] . 'px"'; } $result = '<div class="' . $params['block_class'] . '" ' . $bubbletip_param . $style_width . '>' . get_avatar_imgtag_default($params['size'], $params['avatar_class']) . '<span class="user deleted">' . T_('Deleted user') . '</span>' . '</div>'; return $result; }
/** * Get avatar IMG tag. * * @param string size * @param string class * @param string align * @param boolean true if the avatar image should be zoomed on click, false otherwise * @param string avatar overlay text * @param string group name for lightbox plugin * @param string Change size of the attributes "width" & "height". * Example: ( $tag_size = '160' ) => width="160" height="160" * ( $tag_size = '160x320' ) => width="160" height="320" * NULL - use real size * @return string */ function get_avatar_imgtag($size = 'crop-top-64x64', $class = 'avatar', $align = '', $zoomable = false, $avatar_overlay_text = '', $lightbox_group = '', $tag_size = NULL) { global $current_User; /** * @var Link */ $Link =& $this->get_avatar_Link(); /** * @var File */ if (!$Link || !($File =& $Link->get_File())) { // User doesn't have an avatar return get_avatar_imgtag_default($size, $class, $align, array('email' => $this->get('email'), 'gender' => $this->get('gender'), 'tag_size' => $tag_size)); } if (!$this->check_status('can_display_avatar') && !(is_admin_page() && is_logged_in(false) && $current_User->check_perm('users', 'edit'))) { // if the user status doesn't allow to display avatar and current User is not an admin in admin interface, then show default avatar return get_avatar_imgtag_default($size, $class, $align, array('email' => $this->get('email'), 'gender' => $this->get('gender'), 'tag_size' => $tag_size)); } if ($zoomable) { // return clickable avatar tag, zoom on click if (is_logged_in()) { // Only logged in users can see a big picture of the avatar // set random value to link_rel, this way the pictures on the page won't be grouped // this is usefull because the same avatar picture may appear more times in the same page if (empty($lightbox_group)) { $link_rel = 'lightbox[l' . $Link->ID . rand(0, 100000) . ']'; } else { $link_rel = 'lightbox[' . $lightbox_group . ']'; } $r = $Link->get_tag(array('before_image' => '', 'before_image_legend' => '', 'after_image_legend' => '', 'after_image' => '', 'image_size' => $size, 'image_link_title' => $this->login, 'image_link_rel' => $link_rel, 'image_class' => $class, 'image_align' => $align, 'tag_size' => $tag_size)); } else { // Anonymous user get an avatar picture with link to login page global $Blog; $redirect_to = ''; if (isset($Blog)) { // Redirect user after login $redirect_to = $Blog->get('userurl', array('glue' => '&', 'url_suffix' => 'user_ID=' . $this->ID)); } $r = '<a href="' . get_login_url('cannot see avatar', $redirect_to) . '">' . $File->get_thumb_imgtag($size, $class, $align, '', $tag_size) . '</a>'; } } else { $r = $File->get_thumb_imgtag($size, $class, $align, '', $tag_size); } if ($r != '' && $avatar_overlay_text != '') { // Add overlay text if it is enabled $r = $this->get_avatar_overlay_text($r, $size, $avatar_overlay_text, $class, $File); } return $r; }
/** * Get thread's recipients * * @param integer Thread ID * @param boolean TRUE for abuse management mode * @return string Recipients (avatar + login) */ function col_thread_recipients($thread_ID, $abuse_management) { global $DB, $Blog; $SQL = new SQL(); $SQL->SELECT('user_login'); $SQL->FROM('T_messaging__threadstatus mts'); $SQL->FROM_add('LEFT JOIN T_users u ON user_ID = tsta_user_ID'); $SQL->WHERE('tsta_thread_ID = ' . $thread_ID); if (!$abuse_management) { // Show current user only in abuse management global $current_User; $SQL->WHERE_and('tsta_user_ID != ' . $current_User->ID); } $recipients = $DB->get_col($SQL->get()); $image_size = isset($Blog) ? $Blog->get_setting('image_size_messaging') : 'crop-top-32x32'; if (empty($recipients)) { // There are no recipients in this list. This is only possible if the recipients were deleted as spammer return '<span class="nowrap">' . get_avatar_imgtag_default($image_size, 'avatar_before_login_middle mb1') . '<span class="user deleted">' . T_('Deleted user(s)') . '</span>' . '</span>'; } return get_avatar_imgtags($recipients, true, true, $image_size, 'avatar_before_login_middle mb1', '', NULL, true, '<br />', true); }