/* ===================================================================================== sf_latest_posts_truncate($limit=5, $trunhars=300, $pad="...") displays the quicklinks dropdowns for forum list and recent topics list and trims content length if needed. parameters: $limit How many items to show in the list number 5 $trunchars How many charectors to find truncate point (will leave complete words) number 300 $pad If content needs trimming, this will be added to the end of it. string "..." ===================================================================================*/ function sf_latest_posts_truncate($limit=5, $trunchars=300, $pad="...") { global $wpdb, $current_user, $sfvars; $limit = sf_esc_int($limit); if (empty($limit)) return; 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) . ") = 1"; } else { return ''; } } $posts = $wpdb->get_results( "SELECT post_id, topic_id, forum_id, post_content, post_index, ".sf_zone_datetime('post_date').", ".SFPOSTS.".user_id, guest_name, ".SFMEMBERS.".display_name FROM ".SFPOSTS." LEFT JOIN ".SFMEMBERS." ON ".SFPOSTS.".user_id = ".SFMEMBERS.".user_id ".$where." ORDER BY post_date DESC LIMIT ".$limit); $out.='
'.__("No Topics to Display", "sforum").'
'."\n"; $out.='