]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/profilesettings.php
Merge branch 'testing' of gitorious.org:statusnet/mainline into testing
[quix0rs-gnu-social.git] / actions / profilesettings.php
index 0c1efa90726a6364451e1b59044fcde86ac42890..303bb0ad9bbd76be81fa193fb1adec3de72df680 100644 (file)
@@ -225,7 +225,13 @@ class ProfilesettingsAction extends AccountSettingsAction
 
         if (Event::handle('StartProfileSaveForm', array($this))) {
 
-            $nickname = $this->trimmed('nickname');
+            try {
+                $nickname = Nickname::normalize($this->trimmed('nickname'));
+            } catch (NicknameException $e) {
+                $this->showForm($e->getMessage());
+                return;
+            }
+
             $fullname = $this->trimmed('fullname');
             $homepage = $this->trimmed('homepage');
             $bio = $this->trimmed('bio');
@@ -236,13 +242,7 @@ class ProfilesettingsAction extends AccountSettingsAction
             $tagstring = $this->trimmed('tags');
 
             // Some validation
-            if (!Validate::string($nickname, array('min_length' => 1,
-                                                   'max_length' => 64,
-                                                   'format' => NICKNAME_FMT))) {
-                // TRANS: Validation error in form for profile settings.
-                $this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.'));
-                return;
-            } else if (!User::allowed_nickname($nickname)) {
+            if (!User::allowed_nickname($nickname)) {
                 // TRANS: Validation error in form for profile settings.
                 $this->showForm(_('Not a valid nickname.'));
                 return;
@@ -253,20 +253,20 @@ class ProfilesettingsAction extends AccountSettingsAction
                 return;
             } else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
                 // TRANS: Validation error in form for profile settings.
-                $this->showForm(_('Full name is too long (max 255 characters).'));
+                $this->showForm(_('Full name is too long (maximum 255 characters).'));
                 return;
             } else if (Profile::bioTooLong($bio)) {
                 // TRANS: Validation error in form for profile settings.
                 // TRANS: Plural form is used based on the maximum number of allowed
                 // TRANS: characters for the biography (%d).
-                $this->showForm(sprintf(_m('Bio is too long (max %d character).',
-                                           'Bio is too long (max %d characters).',
+                $this->showForm(sprintf(_m('Bio is too long (maximum %d character).',
+                                           'Bio is too long (maximum %d characters).',
                                            Profile::maxBio()),
                                         Profile::maxBio()));
                 return;
             } else if (!is_null($location) && mb_strlen($location) > 255) {
                 // TRANS: Validation error in form for profile settings.
-                $this->showForm(_('Location is too long (max 255 characters).'));
+                $this->showForm(_('Location is too long (maximum 255 characters).'));
                 return;
             }  else if (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) {
                 // TRANS: Validation error in form for profile settings.
@@ -278,7 +278,7 @@ class ProfilesettingsAction extends AccountSettingsAction
                 return;
             } else if (!is_null($language) && strlen($language) > 50) {
                 // TRANS: Validation error in form for profile settings.
-                $this->showForm(_('Language is too long (max 50 characters).'));
+                $this->showForm(_('Language is too long (maximum 50 characters).'));
                 return;
             }
 
@@ -452,4 +452,42 @@ class ProfilesettingsAction extends AccountSettingsAction
             return $other->id != $user->id;
         }
     }
+
+    function showAside() {
+        $user = common_current_user();
+
+        $this->elementStart('div', array('id' => 'aside_primary',
+                                         'class' => 'aside'));
+
+        $this->elementStart('div', array('id' => 'account_actions',
+                                         'class' => 'section'));
+        $this->elementStart('ul');
+        if (Event::handle('StartProfileSettingsActions', array($this))) {
+            if ($user->hasRight(Right::BACKUPACCOUNT)) {
+                $this->elementStart('li');
+                $this->element('a',
+                               array('href' => common_local_url('backupaccount')),
+                               _('Backup account'));
+                $this->elementEnd('li');
+            }
+            if ($user->hasRight(Right::DELETEACCOUNT)) {
+                $this->elementStart('li');
+                $this->element('a',
+                               array('href' => common_local_url('deleteaccount')),
+                               _('Delete account'));
+                $this->elementEnd('li');
+            }
+            if ($user->hasRight(Right::RESTOREACCOUNT)) {
+                $this->elementStart('li');
+                $this->element('a',
+                               array('href' => common_local_url('restoreaccount')),
+                               _('Restore account'));
+                $this->elementEnd('li');
+            }
+            Event::handle('EndProfileSettingsActions', array($this));
+        }
+        $this->elementEnd('ul');
+        $this->elementEnd('div');
+        $this->elementEnd('div');
+    }
 }