Elgg  Version 3.0
crop.php
Go to the documentation of this file.
1 <?php
6 $guid = (int) get_input('guid');
8 
9 if (!$owner || !$owner->canEdit()) {
10  return elgg_error_response(elgg_echo('avatar:crop:fail'));
11 }
12 
13 // ensuring the avatar image exists in the first place
14 if (!$owner->hasIcon('master')) {
15  return elgg_error_response(elgg_echo('avatar:crop:fail'));
16 }
17 
19  'x1' => (int) get_input('x1', 0),
20  'y1' => (int) get_input('y1', 0),
21  'x2' => (int) get_input('x2', 0),
22  'y2' => (int) get_input('y2', 0),
23 ];
24 
25 if (!$owner->saveIconFromElggFile($owner->getIcon('master'), 'icon', $coords)) {
26  return elgg_error_response(elgg_echo('avatar:crop:fail'));
27 }
28 
29 // River
30 $view = 'river/user/default/profileiconupdate';
31 
32 // remove old river items
34  'subject_guid' => $owner->guid,
35  'view' => $view,
36  'limit' => false,
37 ]);
38 // create new river entry
40  'view' => $view,
41  'action_type' => 'update',
42  'subject_guid' => $owner->guid,
43  'object_guid' => $owner->guid,
44 ]);
45 
46 return elgg_ok_response('', elgg_echo('avatar:crop:success'));
get_user($guid)
Get a user object from a GUID.
Definition: users.php:40
elgg_delete_river(array $options=[])
Delete river items based on $options.
Definition: river.php:220
elgg_create_river_item(array $options=[])
Adds an item to the river.
Definition: river.php:33
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
if(!$owner||!$owner->canEdit()) if(!$owner->hasIcon('master')) if(!$owner->saveIconFromElggFile($owner->getIcon('master'), 'icon', $coords)) $view
Definition: crop.php:30
$owner
Definition: crop.php:7
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
$guid
Avatar crop action.
Definition: crop.php:6
elgg_error_response($error= '', $forward_url=REFERRER, $status_code=ELGG_HTTP_OK)
Prepare an error response to be returned by a page or an action handler.
elgg_ok_response($content= '', $message= '', $forward_url=null, $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
if(!$owner||!$owner->canEdit()) if(!$owner->hasIcon('master')) $coords
Definition: crop.php:18