Elgg  Version 1.11
remove.php
Go to the documentation of this file.
1 <?php
6 $user_guid = get_input('guid');
8 
9 if (!$user || !$user->canEdit()) {
10  register_error(elgg_echo('avatar:remove:fail'));
12 }
13 
14 // Delete all icons from diskspace
15 $icon_sizes = elgg_get_config('icon_sizes');
16 foreach ($icon_sizes as $name => $size_info) {
17  $file = new ElggFile();
18  $file->owner_guid = $user_guid;
19  $file->setFilename("profile/{$user_guid}{$name}.jpg");
20  $filepath = $file->getFilenameOnFilestore();
21  if (!$file->delete()) {
22  elgg_log("Avatar file remove failed. Remove $filepath manually, please.", 'WARNING');
23  }
24 }
25 
26 // Remove crop coords
27 unset($user->x1);
28 unset($user->x2);
29 unset($user->y1);
30 unset($user->y2);
31 
32 // Remove icon
33 unset($user->icontime);
34 
35 system_message(elgg_echo('avatar:remove:success'));
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
if(!$user||!$user->canEdit()) $icon_sizes
Definition: remove.php:15
elgg forward
Meant to mimic the php forward() function by simply redirecting the user to another page...
Definition: elgglib.js:419
$user
Definition: remove.php:7
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
get_user($guid)
Get a user object from a GUID.
Definition: users.php:87
const REFERER
Definition: elgglib.php:1995
elgg system_message
Wrapper function for system_messages.
Definition: elgglib.js:374
elgg_log($message, $level= 'NOTICE')
Display or log a message.
Definition: elgglib.php:933
elgg register_error
Wrapper function for system_messages.
Definition: elgglib.js:383
$user_guid
Avatar remove action.
Definition: remove.php:6