aboutsummaryrefslogtreecommitdiff
path: root/mod/groups/all.php
blob: 51030adc901229964b8ec519b0e974bcb26b1700 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
 * Elgg groups plugin
 *
 * @package ElggGroups
 */
require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");

$limit = get_input("limit", 10);
$offset = get_input("offset", 0);
$filter = get_input("filter");
if (!$filter) {
	// active discussions is the default
	$filter = "newest";
}

$context = elgg_get_context();

switch ($filter) {
	case "newest":
		$objects = elgg_list_entities(array(
			'type' => 'group',
			'limit' => $limit,
			'full_view' => false,
		));
		break;

	case "pop":
		$objects = list_entities_by_relationship_count('member', true, "", "", 0, $limit, false);
		break;

	case "active":
	case 'default':
		$options = array(
			'type' => 'object',
			'subtype' => 'groupforumtopic',
			'annotation_name' => 'generic_comment',
			'order_by' => 'e.last_action desc',
			'limit' => 40,
			'fullview' => TRUE
		);
		$objects = elgg_list_entities($options);
		break;
}

//get a group count
$group_count = elgg_get_entities(array('types' => 'group', 'limit' => 10, 'count' => TRUE));

//find groups
$area2 .= elgg_view("groups/sidebar/find");

//featured groups
$area2 .= elgg_view("groups/sidebar/featured");

elgg_set_context($context);

$objects = "<div class='group_listings'>" . $objects . "</div>";

$title = elgg_echo("groups:all", array(elgg_get_page_owner()->name));
if (isloggedin ()) {
	$area1 .= elgg_view('page/elements/content_header', array('context' => "everyone", 'type' => 'groups', 'new_link' => "pg/groups/new"));
}
$area1 .= elgg_view("groups/group_sort_menu", array("count" => $group_count, "filter" => $filter)) . $objects;

$params = array(
	'content' => $area1,
	'sidebar' => $area2
);
$body = elgg_view_layout('one_sidebar', $params);

// Finally draw the page
echo elgg_view_page($title, $body);