/** * 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 user avatar * * @param integer user ID * @return string */ function user_avatar($user_ID) { global $Blog; $UserCache =& get_UserCache(); $User =& $UserCache->get_by_ID($user_ID, false, false); if ($User) { if (empty($Blog)) { $avatar_size = 'crop-top-32x32'; } else { $avatar_size = $Blog->get_setting('image_size_messaging'); } $avatar_tag = $User->get_avatar_imgtag($avatar_size); $identity_url = get_user_identity_url($user_ID); if (!empty($avatar_tag)) { if (empty($identity_url)) { // current_User has no permission to view user settings, and Blog is empty return $avatar_tag; } return '<a href="' . $identity_url . '">' . $avatar_tag . '</a>'; } } return ''; }
function user_status($user_status, $user_ID) { global $current_User; $user_status_icons = get_user_status_icons(true); $status_content = $user_status_icons[$user_status]; if (is_admin_page() && $current_User->check_perm('users', 'edit')) { // current User is an administrator and view is displayed on admin interface, return link to user admin tab return '<a href="' . get_user_identity_url($user_ID, 'admin') . '">' . $status_content . '</a>'; } return $status_content; }
/** * Get link to previous/next user * * @return string Link to previous/next user */ function prevnext_user_link($direction, $before = '', $after = '', $text = '« $login$', $no_user = '', $user_tab = 'profile', $display = true) { /** * @var User */ $prev_User =& $this->get_prevnext_User($direction); if (has_cross_country_restriction('users', 'list')) { // If current user has cross country restriction, make sure we display only users from the same country // Note: This may happen only if the user list filter was saved and the cross country restriction was changed after that global $current_User; while (!empty($prev_User) && $current_User->ctry_ID !== $prev_User->ctry_ID) { $prev_User =& $this->get_prevnext_User($direction, $prev_User->ID); } } if (!empty($prev_User)) { // User exists in DB $output = $before; $identity_url = get_user_identity_url($prev_User->ID, $user_tab); $login = str_replace('$login$', $prev_User->get_colored_login(array('login_text' => 'name')), $text); if (!empty($identity_url)) { // User link is available // Note: we don't want a bubble tip on navigation links $output .= '<a href="' . $identity_url . '">' . $login . '</a>'; } else { // No identity link $output .= $login; } $output .= $after; } else { // No user $output = $no_user; } if ($display) { echo $output; } return $output; }
/** * Get styled avatar * * @param array params * @return string */ function get_avatar_styled($params = array()) { global $thumbnail_sizes; $params = array_merge(array('block_class' => 'avatar_rounded', 'size' => 'crop-top-64x64', 'avatar_class' => 'avatar', 'zoomable' => false, 'overlay_text' => '', 'show_login' => true, 'bubbletip' => true), $params); $bubbletip_param = ''; if ($params['bubbletip']) { // Init bubbletip param $bubbletip_param = 'rel="bubbletip_user_' . $this->ID . '"'; } $style_width = ''; if (isset($thumbnail_sizes[$params['size']])) { $style_width = ' style="width:' . $thumbnail_sizes[$params['size']][1] . 'px"'; } $identity_url = get_user_identity_url($this->ID); if (!empty($identity_url)) { $r = '<a href="' . $identity_url . '" class="' . $params['block_class'] . '"' . $bubbletip_param . $style_width . '>'; } else { $r = '<div class="' . $params['block_class'] . '"' . $bubbletip_param . $style_width . '>'; } $r .= $this->get_avatar_imgtag($params['size'], $params['avatar_class'], '', $params['zoomable'], $params['overlay_text']); if ($params['show_login']) { // Display user name $r .= $this->get_colored_login(array('login_text' => 'name')); } $r .= !empty($identity_url) ? '</a>' : '</div>'; return $r; }
/** * Get avatar <img> tag by user login * * @param user login * @param if true show user login after avatar * @param if true link to user profile * @param avatar size * @param style class of image * @param image align * @param avatar overlay text * @param style class of link * @param if true show user avatar * @return login <img> tag */ function get_avatar_imgtag($user_login, $show_login = true, $link = true, $size = 'crop-top-15x15', $img_class = 'avatar_before_login', $align = '', $avatar_overlay_text = '', $link_class = '', $show_avatar = true) { global $current_User; $UserCache =& get_UserCache(); $User =& $UserCache->get_by_login($user_login); if ($User === false) { return ''; } $img_tag = ''; if ($show_avatar) { // Get user avatar $img_tag = $User->get_avatar_imgtag($size, $img_class, $align, false, $avatar_overlay_text); } if ($show_login) { $img_tag = '<span class="nowrap">' . $img_tag . '<b>' . $user_login . '</b></span>'; } $identity_url = get_user_identity_url($User->ID); if (empty($identity_url)) { // Current user has not permissions to view other user profile $img_tag = '<span class="' . $User->get_gender_class() . '" rel="bubbletip_user_' . $User->ID . '">' . $img_tag . '</span>'; } else { if (!empty($img_tag)) { // Show avatar & user login as link to the profile page $link_class = $link_class != '' ? ' ' . $link_class : ''; $img_tag = '<a href="' . $identity_url . '" class="' . $User->get_gender_class() . $link_class . '" rel="bubbletip_user_' . $User->ID . '">' . $img_tag . '</a>'; } } return $img_tag; }
/** * Get link to previous/next user * * @return string Link to previous/next user */ function prevnext_user_link($direction, $before = '', $after = '', $text = '« $login$', $no_user = '', $user_tab = 'profile', $display = true) { /** * @var User */ $prev_User =& $this->get_prevnext_User($direction); if (!empty($prev_User)) { // User exists in DB $output = $before; $identity_url = get_user_identity_url($prev_User->ID, $user_tab); $login = str_replace('$login$', $prev_User->get_colored_login(), $text); if (!empty($identity_url)) { // User link is available // Note: we don't want a bubble tip on navigation links $output .= '<a href="' . $identity_url . '">' . $login . '</a>'; } else { // No identity link $output .= $login; } $output .= $after; } else { // No user $output = $no_user; } if ($display) { echo $output; } return $output; }
/** * Display the widget! * * @param array MUST contain at least the basic display params */ function display($params) { $this->init_display($params); $UserCache =& get_UserCache(); $UserList = new DataObjectList2($UserCache); switch ($this->disp_params['order_by']) { case 'regdate': $sql_order = 'user_created_datetime DESC'; break; case 'moddate': $sql_order = 'user_profileupdate_date DESC'; break; case 'random': default: $sql_order = 'RAND()'; break; } // Query list of files: $SQL = new SQL(); $SQL->SELECT('*'); $SQL->FROM('T_users'); $SQL->WHERE('user_avatar_file_ID IS NOT NULL'); $SQL->ORDER_BY($sql_order); $SQL->LIMIT($this->disp_params['limit']); $UserList->sql = $SQL->get(); $UserList->query(false, false, false, 'User avatars widget'); $layout = $this->disp_params['thumb_layout']; $nb_cols = $this->disp_params['grid_nb_cols']; $count = 0; $r = ''; /** * @var User */ while ($User =& $UserList->get_next()) { if ($layout == 'grid') { if ($count % $nb_cols == 0) { $r .= $this->disp_params['grid_colstart']; } $r .= $this->disp_params['grid_cellstart']; } else { $r .= $this->disp_params['item_start']; } $identity_url = get_user_identity_url($User->ID); $avatar_tag = $User->get_avatar_imgtag($this->disp_params['thumb_size']); if ($this->disp_params['bubbletip'] == '1') { // Bubbletip is enabled $bubbletip_param = ' rel="bubbletip_user_' . $User->ID . '"'; $avatar_tag = str_replace('<img ', '<img ' . $bubbletip_param . ' ', $avatar_tag); } if (!empty($identity_url)) { $r .= '<a href="' . $identity_url . '">' . $avatar_tag . '</a>'; } else { $r .= $avatar_tag; } ++$count; if ($layout == 'grid') { $r .= $this->disp_params['grid_cellend']; if ($count % $nb_cols == 0) { $r .= $this->disp_params['grid_colend']; } } else { $r .= $this->disp_params['item_end']; } } // Exit if no files found if (empty($r)) { return; } echo $this->disp_params['block_start']; // Display title if requested $this->disp_title(); if ($layout == 'grid') { echo $this->disp_params['grid_start']; } else { echo $this->disp_params['list_start']; } echo $r; if ($layout == 'grid') { if ($count && $count % $nb_cols != 0) { echo $this->disp_params['grid_colend']; } echo $this->disp_params['grid_end']; } else { echo $this->disp_params['list_end']; } echo $this->disp_params['block_end']; return true; }
/** * Display the widget! * * @param array MUST contain at least the basic display params */ function display($params) { $this->init_display($params); $UserCache =& get_UserCache(); $UserList = new DataObjectList2($UserCache); switch ($this->disp_params['order_by']) { case 'regdate': $sql_order = 'user_created_datetime DESC'; break; case 'moddate': $sql_order = 'user_profileupdate_date DESC'; break; case 'random': default: $sql_order = 'RAND()'; break; } // Query list of users with picture and not closed: $SQL = new SQL(); $SQL->SELECT('*'); $SQL->FROM('T_users'); $SQL->WHERE('user_avatar_file_ID IS NOT NULL'); $SQL->WHERE_and('user_status <> "closed"'); if (is_logged_in()) { // Add filters global $current_User, $DB; switch ($this->disp_params['gender']) { // Filter by gender case 'same': $SQL->WHERE_and('user_gender = "' . $current_User->gender . '"'); break; case 'opposite': $SQL->WHERE_and('user_gender != "' . $current_User->gender . '"'); break; } switch ($this->disp_params['location']) { // Filter by location case 'city': $SQL->WHERE_and('user_city_ID ' . (empty($current_User->city_ID) ? 'IS NULL' : '= "' . $current_User->city_ID . '"')); case 'subregion': $SQL->WHERE_and('user_subrg_ID ' . (empty($current_User->subrg_ID) ? 'IS NULL' : '= "' . $current_User->subrg_ID . '"')); case 'region': $SQL->WHERE_and('user_rgn_ID ' . (empty($current_User->rgn_ID) ? 'IS NULL' : '= "' . $current_User->rgn_ID . '"')); case 'country': $SQL->WHERE_and('user_ctry_ID ' . (empty($current_User->ctry_ID) ? 'IS NULL' : '= "' . $current_User->ctry_ID . '"')); break; case 'closest': if (!empty($current_User->city_ID)) { // Check if users exist with same city $user_exists = $DB->get_var('SELECT user_ID FROM T_users WHERE user_city_ID ="' . $current_User->city_ID . '" AND user_ID != "' . $current_User->ID . '" LIMIT 1'); if (!empty($user_exists)) { $SQL->WHERE_and('user_city_ID = "' . $current_User->city_ID . '"'); $SQL->WHERE_and('user_subrg_ID = "' . $current_User->subrg_ID . '"'); $SQL->WHERE_and('user_rgn_ID = "' . $current_User->rgn_ID . '"'); $SQL->WHERE_and('user_ctry_ID = "' . $current_User->ctry_ID . '"'); break; } } if (!empty($current_User->subrg_ID) && empty($user_exists)) { // Check if users exist with same sub-region $user_exists = $DB->get_var('SELECT user_ID FROM T_users WHERE user_subrg_ID ="' . $current_User->subrg_ID . '" AND user_ID != "' . $current_User->ID . '" LIMIT 1'); if (!empty($user_exists)) { $SQL->WHERE_and('user_subrg_ID = "' . $current_User->subrg_ID . '"'); $SQL->WHERE_and('user_rgn_ID = "' . $current_User->rgn_ID . '"'); $SQL->WHERE_and('user_ctry_ID = "' . $current_User->ctry_ID . '"'); break; } } if (!empty($current_User->rgn_ID) && empty($user_exists)) { // Check if users exist with same region $user_exists = $DB->get_var('SELECT user_ID FROM T_users WHERE user_rgn_ID ="' . $current_User->rgn_ID . '" AND user_ID != "' . $current_User->ID . '" LIMIT 1'); if (!empty($user_exists)) { $SQL->WHERE_and('user_rgn_ID = "' . $current_User->rgn_ID . '"'); $SQL->WHERE_and('user_ctry_ID = "' . $current_User->ctry_ID . '"'); break; } } if (!empty($current_User->ctry_ID) && empty($user_exists)) { // Check if users exist with same country $user_exists = $DB->get_var('SELECT user_ID FROM T_users WHERE user_ctry_ID ="' . $current_User->ctry_ID . '" AND user_ID != "' . $current_User->ID . '" LIMIT 1'); if (!empty($user_exists)) { $SQL->WHERE_and('user_ctry_ID = "' . $current_User->ctry_ID . '"'); } } break; } } $SQL->ORDER_BY($sql_order); $SQL->LIMIT(intval($this->disp_params['limit'])); $UserList->sql = $SQL->get(); $UserList->query(false, false, false, 'User avatars widget'); $avatar_link_attrs = ''; if ($this->disp_params['style'] == 'badges') { // Remove borders of <td> elements $this->disp_params['grid_cellstart'] = str_replace('>', ' style="border:none">', $this->disp_params['grid_cellstart']); $avatar_link_attrs = ' class="avatar_rounded"'; } $layout = $this->disp_params['thumb_layout']; $nb_cols = intval($this->disp_params['grid_nb_cols']); $count = 0; $r = ''; /** * @var User */ while ($User =& $UserList->get_next()) { if ($layout == 'grid') { // Grid layout if ($count % $nb_cols == 0) { $r .= $this->disp_params['grid_colstart']; } $r .= $this->disp_params['grid_cellstart']; } elseif ($layout == 'flow') { // Flow block layout $r .= $this->disp_params['flow_block_start']; } else { // List layout $r .= $this->disp_params['item_start']; } $identity_url = get_user_identity_url($User->ID); $avatar_tag = $User->get_avatar_imgtag($this->disp_params['thumb_size']); if ($this->disp_params['bubbletip'] == '1') { // Bubbletip is enabled $bubbletip_param = ' rel="bubbletip_user_' . $User->ID . '"'; $avatar_tag = str_replace('<img ', '<img ' . $bubbletip_param . ' ', $avatar_tag); } if (!empty($identity_url)) { $r .= '<a href="' . $identity_url . '"' . $avatar_link_attrs . '>'; $r .= $avatar_tag; if ($this->disp_params['style'] == 'badges') { // Add user login after picture $r .= '<br >' . $User->get_colored_login(); } $r .= '</a>'; } else { $r .= $avatar_tag; } ++$count; if ($layout == 'grid') { // Grid layout $r .= $this->disp_params['grid_cellend']; if ($count % $nb_cols == 0) { $r .= $this->disp_params['grid_colend']; } } elseif ($layout == 'flow') { // Flow block layout $r .= $this->disp_params['flow_block_end']; } else { // List layout $r .= $this->disp_params['item_end']; } } // Exit if no files found if (empty($r)) { return; } echo $this->disp_params['block_start']; // Display title if requested $this->disp_title(); echo $this->disp_params['block_body_start']; if ($layout == 'grid') { echo $this->disp_params['grid_start']; } elseif ($layout == 'flow') { // Flow block layout echo $this->disp_params['flow_start']; } else { echo $this->disp_params['list_start']; } echo $r; if ($layout == 'grid') { if ($count && $count % $nb_cols != 0) { echo $this->disp_params['grid_colend']; } echo $this->disp_params['grid_end']; } elseif ($layout == 'flow') { // Flow block layout echo $this->disp_params['flow_end']; } else { echo $this->disp_params['list_end']; } echo $this->disp_params['block_body_end']; echo $this->disp_params['block_end']; return true; }