aboutsummaryrefslogtreecommitdiff
path: root/actions/avatar/remove.php
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2012-06-02 07:46:27 -0700
committerCash Costello <cash.costello@gmail.com>2012-06-02 07:46:27 -0700
commitedb6a30963e704a102ba0032af98b5ccbb6bdbe4 (patch)
treef2bfb439444aa8906b84f3fa480415a27e1df5c6 /actions/avatar/remove.php
parent912bcd65be8fb4b12aef4b78e8e9fa5ad68fc412 (diff)
parentf848e3ada3e29c17cc5028d7d9edad8035706334 (diff)
downloadelgg-edb6a30963e704a102ba0032af98b5ccbb6bdbe4.tar.gz
elgg-edb6a30963e704a102ba0032af98b5ccbb6bdbe4.tar.bz2
Merge pull request #230 from sembrestels/avatar-revert1.8
Fixes #4396. Revert avatar also deletes avatar's files and crop coords now.
Diffstat (limited to 'actions/avatar/remove.php')
-rw-r--r--actions/avatar/remove.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/actions/avatar/remove.php b/actions/avatar/remove.php
new file mode 100644
index 000000000..cd38e456a
--- /dev/null
+++ b/actions/avatar/remove.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Avatar remove action
+ */
+
+$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 remove failed. Remove $filepath manually, please.", 'WARNING');
+ }
+ }
+
+ // Remove crop coords
+ unset($user->x1);
+ unset($user->x2);
+ unset($user->y1);
+ unset($user->y2);
+
+ // Remove icon
+ unset($user->icontime);
+ system_message(elgg_echo('avatar:remove:success'));
+} else {
+ register_error(elgg_echo('avatar:remove:fail'));
+}
+
+forward(REFERER);