]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
New Events for avatar settings
authorEric Helgeson <erichelgeson@gmail.com>
Thu, 10 Dec 2009 03:31:07 +0000 (22:31 -0500)
committerEric Helgeson <erichelgeson@gmail.com>
Thu, 10 Dec 2009 03:31:07 +0000 (22:31 -0500)
EVENTS.txt
actions/avatarsettings.php

index e0516f8f45ebe94a9354ffc542003adeb2b94069..96250f64c784dc665d78d1a0fdadf8653c9fe556 100644 (file)
@@ -290,6 +290,18 @@ StartRegistrationTry: before validating and saving a new user
 EndRegistrationTry: after saving a new user (note: no profile or user object!)
 - $action: action object being shown
 
+StartAvatarFormData: before displaying avatar form
+- $action: action object being shown
+
+EndAvatarFormData: after displaying avatar form
+- $action: action object being shown
+
+StartAvatarSaveForm: before saving the avatar
+- $action: action object being shown
+
+EndAvatarSaveForm: after saving the avatar
+- $action: action object being shown
+
 StartNewQueueManager: before trying to start a new queue manager; good for plugins implementing new queue manager classes
 - $qm: empty queue manager to set
 
index 879e44842f40a03961b20241f7186ef4eefc71d0..cf4525552029f1fde641d6311235991cca3732a5 100644 (file)
@@ -118,53 +118,56 @@ class AvatarsettingsAction extends AccountSettingsAction
         $this->elementStart('fieldset');
         $this->element('legend', null, _('Avatar settings'));
         $this->hidden('token', common_session_token());
-
-        $this->elementStart('ul', 'form_data');
-        if ($original) {
-            $this->elementStart('li', array('id' => 'avatar_original',
-                                            'class' => 'avatar_view'));
-            $this->element('h2', null, _("Original"));
-            $this->elementStart('div', array('id'=>'avatar_original_view'));
-            $this->element('img', array('src' => $original->url,
-                                        'width' => $original->width,
-                                        'height' => $original->height,
-                                        'alt' => $user->nickname));
-            $this->elementEnd('div');
+        
+        if (Event::handle('StartAvatarFormData', array($this))) {
+            $this->elementStart('ul', 'form_data');
+            if ($original) {
+                $this->elementStart('li', array('id' => 'avatar_original',
+                                                'class' => 'avatar_view'));
+                $this->element('h2', null, _("Original"));
+                $this->elementStart('div', array('id'=>'avatar_original_view'));
+                $this->element('img', array('src' => $original->url,
+                                            'width' => $original->width,
+                                            'height' => $original->height,
+                                            'alt' => $user->nickname));
+                $this->elementEnd('div');
+                $this->elementEnd('li');
+            }
+
+            $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+
+            if ($avatar) {
+                $this->elementStart('li', array('id' => 'avatar_preview',
+                                                'class' => 'avatar_view'));
+                $this->element('h2', null, _("Preview"));
+                $this->elementStart('div', array('id'=>'avatar_preview_view'));
+                $this->element('img', array('src' => $original->url,
+                                            'width' => AVATAR_PROFILE_SIZE,
+                                            'height' => AVATAR_PROFILE_SIZE,
+                                            'alt' => $user->nickname));
+                $this->elementEnd('div');
+                $this->submit('delete', _('Delete'));
+                $this->elementEnd('li');
+            }
+
+            $this->elementStart('li', array ('id' => 'settings_attach'));
+            $this->element('input', array('name' => 'avatarfile',
+                                          'type' => 'file',
+                                          'id' => 'avatarfile'));
+            $this->element('input', array('name' => 'MAX_FILE_SIZE',
+                                          'type' => 'hidden',
+                                          'id' => 'MAX_FILE_SIZE',
+                                          'value' => ImageFile::maxFileSizeInt()));
             $this->elementEnd('li');
-        }
-
-        $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+            $this->elementEnd('ul');
 
-        if ($avatar) {
-            $this->elementStart('li', array('id' => 'avatar_preview',
-                                            'class' => 'avatar_view'));
-            $this->element('h2', null, _("Preview"));
-            $this->elementStart('div', array('id'=>'avatar_preview_view'));
-            $this->element('img', array('src' => $original->url,
-                                        'width' => AVATAR_PROFILE_SIZE,
-                                        'height' => AVATAR_PROFILE_SIZE,
-                                        'alt' => $user->nickname));
-            $this->elementEnd('div');
-            $this->submit('delete', _('Delete'));
+            $this->elementStart('ul', 'form_actions');
+            $this->elementStart('li');
+            $this->submit('upload', _('Upload'));
             $this->elementEnd('li');
+            $this->elementEnd('ul');
         }
-
-        $this->elementStart('li', array ('id' => 'settings_attach'));
-        $this->element('input', array('name' => 'avatarfile',
-                                      'type' => 'file',
-                                      'id' => 'avatarfile'));
-        $this->element('input', array('name' => 'MAX_FILE_SIZE',
-                                      'type' => 'hidden',
-                                      'id' => 'MAX_FILE_SIZE',
-                                      'value' => ImageFile::maxFileSizeInt()));
-        $this->elementEnd('li');
-        $this->elementEnd('ul');
-
-        $this->elementStart('ul', 'form_actions');
-        $this->elementStart('li');
-        $this->submit('upload', _('Upload'));
-        $this->elementEnd('li');
-        $this->elementEnd('ul');
+        Event::handle('EndAvatarFormData', array($this));
 
         $this->elementEnd('fieldset');
         $this->elementEnd('form');
@@ -266,15 +269,18 @@ class AvatarsettingsAction extends AccountSettingsAction
                                'Try again, please.'));
             return;
         }
-
-        if ($this->arg('upload')) {
-            $this->uploadAvatar();
-        } else if ($this->arg('crop')) {
-            $this->cropAvatar();
-        } else if ($this->arg('delete')) {
-            $this->deleteAvatar();
-        } else {
-            $this->showForm(_('Unexpected form submission.'));
+        
+        if (Event::handle('StartAvatarSaveForm', array($this))) {
+            if ($this->arg('upload')) {
+                $this->uploadAvatar();
+                } else if ($this->arg('crop')) {
+                    $this->cropAvatar();
+                } else if ($this->arg('delete')) {
+                    $this->deleteAvatar();
+                } else {
+                    $this->showForm(_('Unexpected form submission.'));
+                }
+            Event::handle('EndAvatarSaveForm', array($this));
         }
     }