aboutsummaryrefslogtreecommitdiff
path: root/mod/file/index.php
blob: ad5f4378c5fb6cf3f1bfed58622aca36ee7f8e41 (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
<?php
/**
 * Individual's or group's files
 *
 * @package ElggFile
 */

elgg_set_page_owner_guid(get_input('guid'));

// access check for closed groups
group_gatekeeper();

$owner = elgg_get_page_owner_entity();

elgg_push_breadcrumb(elgg_echo('file'), "pg/file/all/");
elgg_push_breadcrumb($owner->name);

$params = array();

if ($owner->guid == elgg_get_logged_in_user_guid()) {
	// user looking at own files
	$title = elgg_echo('file:yours');
	$params['filter_context'] = 'mine';
} else if (elgg_instanceof($owner, 'user')) {
	// someone else's files
	$title = elgg_echo("file:user", array($owner()->name));
	// do not show button or select a tab when viewing someone else's posts
	$params['filter_context'] = 'none';
	$params['buttons'] = '';
} else {
	// group files
	$title = elgg_echo("file:user", array($owner->name));
	$params['filter'] = '';
	if ($owner->isMember(elgg_get_logged_in_user_entity())) {
		$url = "pg/file/add/$owner->guid";
		$vars = array(
			'href' => $url,
			'text' => elgg_echo("file:add"),
			'class' => 'elgg-button-action',
		);
		$button = elgg_view('output/url', $vars);
		$params['buttons'] = $button;
	} else {
		$params['buttons'] = '';
	}
}

// List files
$content = elgg_list_entities(array(
	'types' => 'object',
	'subtypes' => 'file',
	'container_guid' => $owner->guid,
	'limit' => 10,
	'full_view' => FALSE,
));
if (!$content) {
	$content = elgg_echo("file:none");
}

$sidebar = file_get_type_cloud(elgg_get_page_owner_guid());
if (elgg_instanceof($owner, 'user')) {
	$sidebar .= elgg_view_latest_comments(elgg_get_page_owner_guid(), 'object', 'file');
}

$params['content'] = $content;
$params['title'] = $title;
$params['sidebar'] = $sidebar;

$body = elgg_view_layout('content', $params);

echo elgg_view_page($title, $body);