Completed
Push — master ( e39588...dc8aec )
by Steve
12:08
created

views/default/resources/avatar/edit.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Upload and crop an avatar page
4
 */
5
6
// Only logged in users
7
elgg_gatekeeper();
8
9
elgg_push_context('settings');
10
elgg_push_context('profile_edit');
11
12
$title = elgg_echo('avatar:edit');
13
14
$entity = elgg_get_page_owner_entity();
15 View Code Duplication
if (!elgg_instanceof($entity, 'user') || !$entity->canEdit()) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
	register_error(elgg_echo('avatar:noaccess'));
17
	forward(REFERER);
18
}
19
20
$content = elgg_view('core/avatar/upload', ['entity' => $entity]);
21
22
// only offer the crop view if an avatar has been uploaded
23
if ($entity->hasIcon('master')) {
24
	$content .= elgg_view('core/avatar/crop', ['entity' => $entity]);
25
}
26
27
$params = [
28
	'content' => $content,
29
	'title' => $title,
30
];
31
$body = elgg_view_layout('one_sidebar', $params);
32
33
echo elgg_view_page($title, $body);
34