aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-12-24 07:45:22 -0500
committerCash Costello <cash.costello@gmail.com>2011-12-24 07:45:22 -0500
commite357d172fa71f9b940ed35df0dd5ee6eb6777d5a (patch)
tree89d302d4e2778ed1b831fccb4da9e05454fd7414
parent1c2735807961ce916c27832327a07ef0bc9d5a40 (diff)
downloadelgg-e357d172fa71f9b940ed35df0dd5ee6eb6777d5a.tar.gz
elgg-e357d172fa71f9b940ed35df0dd5ee6eb6777d5a.tar.bz2
Fixes #3272 added button to revert avatar
-rw-r--r--actions/avatar/revert.php15
-rw-r--r--engine/lib/users.php1
-rw-r--r--languages/en.php4
-rw-r--r--views/default/core/avatar/upload.php12
4 files changed, 32 insertions, 0 deletions
diff --git a/actions/avatar/revert.php b/actions/avatar/revert.php
new file mode 100644
index 000000000..8cff40a68
--- /dev/null
+++ b/actions/avatar/revert.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Avatar revert action
+ */
+
+$guid = get_input('guid');
+$user = get_entity($guid);
+if ($user) {
+ unset($user->icontime);
+ system_message(elgg_echo('avatar:revert:success'));
+} else {
+ register_error(elgg_echo('avatar:revert:fail'));
+}
+
+forward(REFERER);
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 4404f42e0..3a3756923 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -1550,6 +1550,7 @@ function users_init() {
elgg_register_action('friends/remove');
elgg_register_action('avatar/upload');
elgg_register_action('avatar/crop');
+ elgg_register_action('avatar/revert');
elgg_register_action('profile/edit');
elgg_register_action('friends/collections/add');
diff --git a/languages/en.php b/languages/en.php
index 93099c98f..2f8ab41c9 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -363,6 +363,7 @@ $english = array(
'avatar:preview' => 'Preview',
'avatar:upload' => 'Upload a new avatar',
'avatar:current' => 'Current avatar',
+ 'avatar:revert' => 'Revert your avatar to the default icon',
'avatar:crop:title' => 'Avatar cropping tool',
'avatar:upload:instructions' => "Your avatar is displayed throughout the site. You can change it as often as you'd like. (File formats accepted: GIF, JPG or PNG)",
'avatar:create:instructions' => 'Click and drag a square below to match how you want your avatar cropped. A preview will appear in the box on the right. When you are happy with the preview, click \'Create your avatar\'. This cropped version will be used throughout the site as your avatar.',
@@ -371,6 +372,8 @@ $english = array(
'avatar:resize:fail' => 'Resize of the avatar failed',
'avatar:crop:success' => 'Cropping the avatar succeeded',
'avatar:crop:fail' => 'Avatar cropping failed',
+ 'avatar:revert:success' => 'Reverting the avatar succeeded',
+ 'avatar:revert:fail' => 'Avatar revert failed',
'profile:edit' => 'Edit profile',
'profile:aboutme' => "About me",
@@ -840,6 +843,7 @@ $english = array(
'new' => 'New',
'add' => 'Add',
'create' => 'Create',
+ 'revert' => 'Revert',
'site' => 'Site',
'activity' => 'Activity',
diff --git a/views/default/core/avatar/upload.php b/views/default/core/avatar/upload.php
index 4aa86373a..29aa59c9c 100644
--- a/views/default/core/avatar/upload.php
+++ b/views/default/core/avatar/upload.php
@@ -12,6 +12,17 @@ $user_avatar = elgg_view('output/img', array(
$current_label = elgg_echo('avatar:current');
+$revert_button = '';
+if ($vars['entity']->icontime) {
+ $revert_button = elgg_view('output/url', array(
+ 'text' => elgg_echo('revert'),
+ 'title' => elgg_echo('avatar:revert'),
+ 'href' => 'action/avatar/revert?guid=' . elgg_get_page_owner_guid(),
+ 'is_action' => true,
+ 'class' => 'elgg-button elgg-button-cancel mll',
+ ));
+}
+
$form_params = array('enctype' => 'multipart/form-data');
$upload_form = elgg_view_form('avatar/upload', $form_params, $vars);
@@ -28,6 +39,7 @@ $image = <<<HTML
<label>$current_label</label><br />
$user_avatar
</div>
+$revert_button
HTML;
$body = <<<HTML