function sf_topic_link($forumid, $topicid, $linktext = '', $listtags = true) { global $current_user; sf_initialise_globals($forumid); if (empty($forumid)) { return ''; } if (empty($topicid)) { return ''; } $out = ''; if (sf_topic_exists($topicid)) { if (sf_can_view_forum($forum_id)) { $forumslug = sf_get_forum_slug($forumid); $topicrec = sf_get_topic_record($topicid); $topicslug = $topicrec->topic_slug; if (empty($linktext)) { $linktext = stripslashes($topicrec->topic_name); } if ($listtags) { $out .= "<li>\n"; } $out .= '<a href="' . sf_build_url($forumslug, $topicslug, 1, 0) . '">' . $linktext . '</a>' . "\n"; if ($listtags) { $out .= "</li>\n"; } } } else { $out = printf(__('Topic %s Not Found', 'sforum'), $topicid) . "\n"; } echo $out; return; }
function sf_latest_posts($limit = 5) { global $wpdb, $current_user, $sfvars; sf_initialise_globals($sfvars['forumid']); $out = ''; $where = " WHERE " . SFPOSTS . ".post_status = 0"; # 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 != '') { $where .= " AND forum_id IN (" . implode(",", $forum_ids) . ") "; } } $posts = $wpdb->get_results("SELECT post_id, topic_id, forum_id, post_content, post_index, " . sf_zone_datetime('post_date') . ",\n\t\t\t " . SFPOSTS . ".user_id, guest_name, " . SFMEMBERS . ".display_name FROM " . SFPOSTS . "\n\t\t\t LEFT JOIN " . SFMEMBERS . " ON " . SFPOSTS . ".user_id = " . SFMEMBERS . ".user_id\n\t\t\t " . $where . "\n\t\t\t ORDER BY post_date DESC\n\t\t\t LIMIT " . $limit); $out .= '<div class="sf-latest">'; if ($posts) { foreach ($posts as $post) { $thisforum = sf_get_forum_record($post->forum_id); $poster = sf_build_name_display($post->user_id, stripslashes($post->display_name)); if (empty($poster)) { $poster = apply_filters('sf_show_post_name', stripslashes($post->guest_name)); } $topic = sf_get_topic_record($post->topic_id); $out .= '<div class="sf-latest-header">'; $out .= $poster . __(' posted ', "sforum"); $out .= '<a href="' . sf_build_url($thisforum->forum_slug, $topic->topic_slug, 1, $post->post_id, $post->post_index) . '">'; $out .= stripslashes($topic->topic_name) . '</a>'; $out .= __(' in ', "sforum"); $out .= '<a href="' . sf_build_url($thisforum->forum_slug, '', 1, 0) . '">' . sf_get_forum_name($thisforum->forum_slug) . '</a>'; $out .= '<br />' . mysql2date(SFDATES, $post->post_date); $out .= '</div>'; $out .= '<div class="sf-latest-content">'; $text = sf_filter_content(stripslashes($post->post_content), ''); $text = sf_rss_excerpt($text); $out .= $text; $out .= '</div>'; $out .= '<br />'; } } else { $out .= '<div class="sf-latest-header">'; $out .= '<p>' . __("No Topics to Display", "sforum") . '</p>' . "\n"; $out .= '</div>'; } $out .= '</div>'; echo $out; return; }