]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Added validation to fields in user admin panel
authorZach Copley <zach@status.net>
Thu, 19 Nov 2009 23:17:24 +0000 (15:17 -0800)
committerZach Copley <zach@status.net>
Thu, 19 Nov 2009 23:17:24 +0000 (15:17 -0800)
actions/useradminpanel.php
lib/router.php

index 968f2a24752c61e9c8d043907b9ef94fc7b39c95..e657692125d22f2633dff3dd62ecba9212692825 100644 (file)
@@ -143,6 +143,31 @@ class UseradminpanelAction extends AdminPanelAction
 
     function validate(&$values)
     {
+        // Validate biolimit
+
+        if (!Validate::number($values['profile']['biolimit'])) {
+            $this->clientError(_("Invalid bio limit. Must be numeric."));
+        }
+
+        // Validate welcome text
+
+        if (mb_strlen($values['newuser']['welcome']) > 255) {
+            $this->clientError(_("Invalid welcome text. Max length is 255 characters."));
+        }
+
+        // Validate default subscription
+
+        if (!empty($values['newuser']['default'])) {
+            $defuser = User::staticGet('nickname', trim($values['newuser']['default']));
+            if (empty($defuser)) {
+                $this->clientError(
+                    sprintf(
+                        _('Invalid default subscripton: \'%1$s\' is not user.'),
+                        $values['newuser']['default']
+                    )
+                );
+            }
+        }
     }
 }
 
@@ -208,7 +233,7 @@ class UserAdminPanelForm extends AdminForm
 
         $this->li();
         $this->input('welcome', _('New user welcome'),
-                     _('Welcome text for new users.'),
+                     _('Welcome text for new users (Max 255 chars).'),
                      'newuser');
         $this->unli();
 
index d5101826f1d744d6cef5a33e735bd26571fc1be5..b2218512676e9e7776fb799875105804b28a9805 100644 (file)
@@ -593,8 +593,6 @@ class Router
             $m->connect('admin/user', array('action' => 'useradminpanel'));
             $m->connect('admin/paths', array('action' => 'pathsadminpanel'));
 
-
-
             $m->connect('getfile/:filename',
                         array('action' => 'getfile'),
                         array('filename' => '[A-Za-z0-9._-]+'));