diff options
author | Sem <sembrestels@riseup.net> | 2012-05-17 13:43:27 +0200 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2012-05-17 13:43:27 +0200 |
commit | 3643efd144c3a9190018100665d02ec798989bfd (patch) | |
tree | f0ce4004edc0d141902beea2da5aea49345428d5 /actions/avatar/revert.php | |
parent | dfc5cf46a841a144f868ebdd99262c0479a4b59d (diff) | |
download | elgg-3643efd144c3a9190018100665d02ec798989bfd.tar.gz elgg-3643efd144c3a9190018100665d02ec798989bfd.tar.bz2 |
Fixes #4396. Revert avatar also deletes avatar's files and crop coords now.
Diffstat (limited to 'actions/avatar/revert.php')
-rw-r--r-- | actions/avatar/revert.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/actions/avatar/revert.php b/actions/avatar/revert.php index 8cff40a68..bc84e9298 100644 --- a/actions/avatar/revert.php +++ b/actions/avatar/revert.php @@ -6,6 +6,25 @@ $guid = get_input('guid'); $user = get_entity($guid); if ($user) { + // Delete all icons from diskspace + $icon_sizes = elgg_get_config('icon_sizes'); + foreach ($icon_sizes as $name => $size_info) { + $file = new ElggFile(); + $file->owner_guid = $guid; + $file->setFilename("profile/{$guid}{$name}.jpg"); + $filepath = $file->getFilenameOnFilestore(); + if (!$file->delete()) { + elgg_log("Avatar file revert failed. Remove $filepath manually, please.", 'WARNING'); + } + } + + // Revert crop coords + unset($user->x1); + unset($user->x2); + unset($user->y1); + unset($user->y2); + + // Revert icon unset($user->icontime); system_message(elgg_echo('avatar:revert:success')); } else { |