function sf_add_new_topic_tag($forumid, $linktext = "Add new topic in the %FORUMNAME% forum", $beforelink = '', $afterlink = '', $beforetext = '', $aftertext = '') { global $current_user; sf_initialise_globals($forumid); if (sf_can_view_forum($forum_id)) { $forum = sf_get_forum_record($forumid); $linktext = str_replace("%FORUMNAME%", $forum->forum_name, $linktext); $url = trailingslashit(sf_build_url($forum->forum_slug, '', 0, 0)); $url = sf_get_sfqurl($url) . 'new=topic'; $out = '<p>' . $beforelink . '<a href="' . $url . '">' . $beforetext . $linktext . $aftertext . '</a>' . $afterlink . '</p>'; echo $out; } return; }
function sf_blog_linked_tag($postid, $show_img = true) { sf_initialise_globals(); include_once SF_PLUGIN_DIR . '/linking/sf-links-forum.php'; $checkrow = sf_blog_links_postmeta('read', $postid, ''); if ($checkrow) { $keys = explode('@', $checkrow->meta_value); $sfpostlinking = array(); $sfpostlinking = get_option('sfpostlinking'); $text = stripslashes($sfpostlinking['sflinkblogtext']); $icon = '<img src="' . SFRESOURCES . 'bloglink.png" alt="" />'; if ($show_img) { $text = str_replace('%ICON%', $icon, $text); } else { $text = str_replace('%ICON%', '', $text); } $postcount = sf_get_posts_count_in_topic($keys[1]); $counttext = ' - (' . $postcount . ') ' . __("Posts", "sforum"); echo '<span class="sfforumlink"><a href="' . sf_build_url(sf_get_forum_slug($keys[0]), sf_get_topic_slug($keys[1]), 1, 0) . '">' . $text . '</a>' . $counttext . '</span>'; } }
function sf_most_rated_posts($limit = 10, $forum = true, $user = true, $postdate = true, $listtags = true, $forumids = 0) { global $wpdb, $current_user, $sfvars; sf_initialise_globals($sfvars['forumid']); $out = ''; $postratings = get_option('sfpostratings'); if (!$postratings['sfpostratings']) { if ($listtags) { $out .= "<li class='sftagli'>\n"; } $out .= __("Post Rating is not Enabled!", "sforum") . "\n"; if ($listtags) { $out .= "</li>\n"; } return; } # are we passing forum ID's? if ($forumids == 0) { $where = ''; } else { $flist = explode(",", $forumids); $where = ' WHERE '; $x = 0; for ($x; $x < count($flist); $x++) { $where .= SFPOSTS . ".forum_id = " . $flist[$x]; if ($x != count($flist) - 1) { $where .= " OR "; } } } # limit to viewable forums based on permissions if (!$current_user->forumadmin) { $allforums = sf_get_forum_memberships($current_user->ID); if ($allforums) { $forum_ids = ''; foreach ($allforums as $thisforum) { if (sf_can_view_forum($thisforum->forum_id)) { $forum_ids[] = $thisforum->forum_id; } } } else { return ''; } # create where clause based on forums that current user can view if ($forum_ids != '') { if ($where == '') { $where = ' WHERE '; } else { $where .= ' AND '; } $where .= SFPOSTS . ".forum_id IN (" . implode(",", $forum_ids) . ") "; } } $sfposts = $wpdb->get_results("SELECT " . SFPOSTRATINGS . ".post_id, ratings_sum, vote_count, " . SFPOSTS . ".topic_id, " . SFPOSTS . ".forum_id, " . SFPOSTS . ".user_id, post_date, post_index, topic_slug, topic_name, forum_slug, forum_name, display_name, guest_name\n\t\t\tFROM " . SFPOSTRATINGS . "\n\t\t\tJOIN " . SFPOSTS . " ON " . SFPOSTRATINGS . ".post_id = " . SFPOSTS . ".post_id\n\t\t\tJOIN " . SFTOPICS . " ON " . SFPOSTS . ".topic_id = " . SFTOPICS . ".topic_id\n\t\t\tJOIN " . SFFORUMS . " ON " . SFPOSTS . ".forum_id = " . SFFORUMS . ".forum_id\n\t\t\tLEFT JOIN " . SFMEMBERS . " ON " . SFPOSTS . ".user_id = " . SFMEMBERS . ".user_id\n\t\t\t" . $where . "\n\t\t\tORDER BY vote_count DESC\n\t\t\tLIMIT " . $limit); if ($sfposts) { foreach ($sfposts as $sfpost) { if (sf_can_view_forum($sfpost->forum_id)) { # Start contruction if ($listtags) { $out .= "<li class='sftagli'>\n"; } $out .= '<a href="' . sf_build_url($sfpost->forum_slug, $sfpost->topic_slug, 1, $sfpost->post_id, $sfpost->post_index) . '">'; $out .= $sfpost->topic_name; if ($forum) { $out .= ' ' . __("posted in", "sforum") . ' ' . stripslashes($sfpost->forum_name); $p = true; } if ($user) { $out .= ' ' . __("by", "sforum") . ' '; $poster = sf_build_name_display($sfpost->user_id, stripslashes($sfpost->display_name)); if (empty($poster)) { $poster = apply_filters('sf_show_post_name', stripslashes($sfpost->guest_name)); } $out .= $poster; $p = true; } if ($postdate) { $out .= ' ' . __("on", "sforum") . ' ' . mysql2date(SFDATES, $sfpost->post_date); $p = true; } $out .= '</a>'; if ($listtags) { $out .= "</li>\n"; } } } } else { if ($listtags) { $out .= "<li class='sftagli'>\n"; } $out .= __("No Rated Posts to Display", "sforum") . "\n"; if ($listtags) { $out .= "</li>\n"; } } echo $out; return; }