aboutsummaryrefslogtreecommitdiff
path: root/pages/avatar/edit.php
blob: 56aede88739b1b875665495016cfa73321396cd8 (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
<?php
/**
 * Upload and crop an avatar page
 */

// Only logged in users
gatekeeper();

elgg_set_context('profile_edit');

$title = elgg_echo('avatar:edit');

$entity = elgg_get_page_owner_entity();
if (!elgg_instanceof($entity, 'user') || !$entity->canEdit()) {
	register_error(elgg_echo('avatar:noaccess'));
	forward(REFERER);
}

$content = elgg_view('core/avatar/upload', array('entity' => $entity));

// only offer the crop view if an avatar has been uploaded
if (isset($entity->icontime)) {
	$content .= elgg_view('core/avatar/crop', array('entity' => $entity));
}

$params = array(
	'content' => $content,
	'title' => $title,
);
$body = elgg_view_layout('one_sidebar', $params);

echo elgg_view_page($title, $body);