Source

lorea_production / elgg / mod / threaded_forums / views / default / groups / forum_latest.php

<?php
    if($vars['entity']->threaded_forums_enable != 'no'){
	$vars['title'] = elgg_echo("groups:latestdiscussion");
	$vars['more_link'] = "{$vars['url']}pg/threaded_forums/{$vars['entity']->guid}/";
	$vars['class'] = "contentWrapper group_widget";

	$add_link = $vars['url']."mod/threaded_forums/addtopic.php?group_guid=".$vars['entity']->guid;
	$link_text = elgg_echo('groups:addtopic');
	$vars['buttons'] = array($add_link => $link_text);

    // get the topic information
	$query = array('name'=>'status','value'=>array('open','sticky'));
	$limit = get_plugin_setting('num_topics', 'threaded_forums');
	$options = array('type'=>'object',
			'metadata_name_value_pairs'=>$query,
			'container_guid'=>get_input('group_guid'),
			'order_by'=>'e.time_updated desc',
			'limit'=> $limit ? $limit : 4,
			'count' => false,
			'subtype'=>'groupforumtopic'
			);
	$forum = elgg_get_entities_from_metadata($options);

	if($forum){
		$vars['content'] = "";
		foreach($forum as $f){

			// query to check how many posts their are for each topic, replacement for countAnnotations
			$post_count_check = get_data("SELECT * from {$CONFIG->dbprefix}entity_relationships WHERE guid_one=".$f->guid);
			$counter = count($post_count_check);

			$vars['content'] .= "<div class=\"forum_latest\">";
			$vars['content'] .= "<div class=\"topic_owner_icon\">" . elgg_view('profile/icon',array('entity' => $f->getOwnerEntity(), 'size' => 'tiny', 'override' => true)) . "</div>";
			$vars['content'] .= "<div class=\"topic_title\"><p><b><a href=\"{$vars['url']}mod/threaded_forums/topicposts.php?topic={$f->guid}&group_guid={$vars['entity']->guid}\">" . $f->title . "</a>".elgg_view('tools/object', array('entity'=>$f))."</b></p> <p class=\"topic_replies\"><small>".elgg_echo('groups:posts').": " . $counter . "</small></p></div>";

			$vars['content'] .= "</div>";
		}
	} else {
		$vars['content'] = "<div class=\"forum_latest\">".elgg_echo("grouptopic:notcreated")."</div>";
	}
	echo elgg_view('groups/group_widget',$vars);
}
?>