function BP_Forums_Template_Forum($forum_id, $per_page, $max) { global $bp, $current_user; $this->pag_page = isset($_REQUEST['forum_page']) ? intval($_REQUEST['forum_page']) : 1; $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page; $this->topics = bp_forums_get_topics($forum_id, $this->pag_num, $this->pag_page); if (!$this->topics) { $this->topic_count = 0; $this->total_topic_count = 0; } else { if (!$max) { $this->total_topic_count = count(bp_forums_get_topics($forum_id)); } else { $this->total_topic_count = (int) $max; } if ($max) { if ($max >= count($this->topics)) { $this->topic_count = count($this->topics); } else { $this->topic_count = (int) $max; } } else { $this->topic_count = count($this->topics); } } $this->pag_links = paginate_links(array('base' => add_query_arg(array('forum_page' => '%#%', 'num' => $this->pag_num)), 'format' => '', 'total' => ceil($this->total_topic_count / $this->pag_num), 'current' => $this->pag_page, 'prev_text' => '«', 'next_text' => '»', 'mid_size' => 1)); }
function bp_group_active_forum_topics($total_topics = 3, $group = false) { global $groups_template, $forum_template; if (!$group) { $group =& $groups_template->group; } $forum_id = groups_get_groupmeta($group->id, 'forum_id'); if ($forum_id && $forum_id != '') { if (function_exists('bp_forums_setup')) { $latest_topics = bp_forums_get_topics($forum_id, $total_topics, 1); if ($latest_topics) { ?> <ul class="item-list" id="recent-forum-topics"><?php $counter = 0; foreach ($latest_topics as $topic) { $alt = $counter % 2 == 1 ? ' class="alt"' : ''; $forum_template->topic = (object) $topic; ?> <li<?php echo $alt; ?> > <div class="avatar"> <?php bp_the_topic_poster_avatar(); ?> </div> <a href="<?php bp_the_topic_permalink(); ?> " title="<?php bp_the_topic_title(); ?> - <?php _e('Permalink', 'buddypress'); ?> "><?php bp_the_topic_title(); ?> </a> <span class="small">- <?php bp_the_topic_total_post_count(); ?> </span> <p><span class="activity"><?php echo sprintf(__('updated %s ago', 'buddypress'), bp_the_topic_time_since_last_post(false)); ?> </span></p> <div class="latest-post"> <?php _e('Latest by', 'buddypress'); ?> <?php bp_the_topic_last_poster_name(); ?> : <?php bp_the_topic_latest_post_excerpt(); ?> </div> </li> <?php $counter++; ?> <?php } ?> </ul> <?php } else { ?> <div id="message" class="info"> <p><?php _e('There are no active forum topics for this group', 'buddypress'); ?> </p> </div> <?php } } } }