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

index de475a27bf34d1e61c2beeca3fd0b9f70ab1a080..968f2a24752c61e9c8d043907b9ef94fc7b39c95 100644 (file)
@@ -90,13 +90,28 @@ class UseradminpanelAction extends AdminPanelAction
 
     function saveSettings()
     {
-        static $settings = array('theme');
-        static $booleans = array('closed', 'inviteonly', 'private');
+        static $settings = array(
+                'profile' => array('biolimit'),
+                'newuser' => array('welcome', 'default')
+        );
+
+        static $booleans = array(
+            'sessions' => array('handle', 'debug'),
+            'invite' => array('enabled')
+        );
 
         $values = array();
 
-        foreach ($settings as $setting) {
-            $values[$setting] = $this->trimmed($setting);
+        foreach ($settings as $section => $parts) {
+            foreach ($parts as $setting) {
+                $values[$section][$setting] = $this->trimmed("$section-$setting");
+            }
+        }
+
+        foreach ($booleans as $section => $parts) {
+            foreach ($parts as $setting) {
+                $values[$section][$setting] = ($this->boolean("$section-$setting")) ? 1 : 0;
+            }
         }
 
         // This throws an exception on validation errors
@@ -109,8 +124,16 @@ class UseradminpanelAction extends AdminPanelAction
 
         $config->query('BEGIN');
 
-        foreach ($settings as $setting) {
-            Config::save('site', $setting, $values[$setting]);
+        foreach ($settings as $section => $parts) {
+            foreach ($parts as $setting) {
+                Config::save($section, $setting, $values[$section][$setting]);
+            }
+        }
+
+        foreach ($booleans as $section => $parts) {
+            foreach ($parts as $setting) {
+                Config::save($section, $setting, $values[$section][$setting]);
+            }
         }
 
         $config->query('COMMIT');
@@ -123,7 +146,7 @@ class UseradminpanelAction extends AdminPanelAction
     }
 }
 
-class UserAdminPanelForm extends Form
+class UserAdminPanelForm extends AdminForm
 {
     /**
      * ID of the form
@@ -144,7 +167,7 @@ class UserAdminPanelForm extends Form
 
     function formClass()
     {
-        return 'form_user_admin_panel';
+        return 'form_settings';
     }
 
     /**
@@ -166,53 +189,92 @@ class UserAdminPanelForm extends Form
 
     function formData()
     {
+        $this->out->elementStart('fieldset', array('id' => 'settings_user-profile'));
+        $this->out->element('legend', null, _('Profile'));
+        $this->out->elementStart('ul', 'form_data');
+
         $this->li();
+        $this->input('biolimit', _('Bio Limit'),
+                     _('Maximum length of a profile bio in characters.'),
+                     'profile');
+        $this->unli();
+
+        $this->out->elementEnd('ul');
+        $this->out->elementEnd('fieldset');
+
+        $this->out->elementStart('fieldset', array('id' => 'settings_user-newusers'));
+        $this->out->element('legend', null, _('New users'));
+        $this->out->elementStart('ul', 'form_data');
 
-        $this->out->checkbox('closed', _('Closed'),
-                             (bool) $this->value('closed'),
-                             _('Is registration on this site prohibited?'));
+        $this->li();
+        $this->input('welcome', _('New user welcome'),
+                     _('Welcome text for new users.'),
+                     'newuser');
+        $this->unli();
 
+        $this->li();
+        $this->input('default', _('Default subscription'),
+                     _('Automatically subscribe new users to this user.'),
+                     'newuser');
         $this->unli();
+
+        $this->out->elementEnd('ul');
+
+        $this->out->elementEnd('fieldset');
+
+        $this->out->elementStart('fieldset', array('id' => 'settings_user-invitations'));
+        $this->out->element('legend', null, _('Invitations'));
+        $this->out->elementStart('ul', 'form_data');
+
         $this->li();
 
-        $this->out->checkbox('inviteonly', _('Invite-only'),
-                             (bool) $this->value('inviteonly'),
-                             _('Is registration on this site only open to invited users?'));
+        $this->out->checkbox('invite-enabled', _('Invitations enabled'),
+                              (bool) $this->value('enabled', 'invite'),
+                              _('Whether to allow users to invite new users.'));
+        $this->unli();
+
+        $this->out->elementEnd('ul');
+        $this->out->elementEnd('fieldset');
 
+        $this->out->elementStart('fieldset', array('id' => 'settings_user_sessions'));
+        $this->out->element('legend', null, _('Sessions'));
+
+        $this->out->elementStart('ul');
+
+        $this->li();
+        $this->out->checkbox('sessions-handle', _('Handle sessions'),
+                              (bool) $this->value('handle', 'sessions'),
+                              _('Whether to handle sessions ourselves.'));
         $this->unli();
+
+        $this->li();
+        $this->out->checkbox('sessions-debug', _('Session debugging'),
+                              (bool) $this->value('debug', 'sessions'),
+                              _('Turn on debugging output for sessions.'));
+        $this->unli();
+
+        $this->out->elementEnd('ul');
+
+        $this->out->elementEnd('fieldset');
+
     }
 
     /**
      * Utility to simplify some of the duplicated code around
-     * params and settings.
+     * params and settings.  Overrided from base class to be
+     * more specific about input ids.
      *
      * @param string $setting      Name of the setting
      * @param string $title        Title to use for the input
      * @param string $instructions Instructions for this field
+     * @param string $section      config section, default = 'site'
      *
      * @return void
      */
 
-    function input($setting, $title, $instructions)
+    function input($setting, $title, $instructions, $section='site')
     {
-        $this->out->input($setting, $title, $this->value($setting), $instructions);
-    }
-
-    /**
-     * Utility to simplify getting the posted-or-stored setting value
-     *
-     * @param string $setting Name of the setting
-     *
-     * @return string param value if posted, or current config value
-     */
-
-    function value($cat, $setting)
-    {
-        $value = $this->out->trimmed($setting);
-        if (empty($value)) {
-            $value = common_config($cat, $setting);
-        }
-        return $value;
+        $this->out->input("$section-$setting", $title, $this->value($setting, $section), $instructions);
     }
 
     /**
index 89a129db1fed9351decc06cc344cf9c4bee93334..7997eb2b1f4b13a7db84f7c78fd3af07d0c44527 100644 (file)
@@ -302,6 +302,9 @@ class AdminPanelNav extends Widget
             $this->out->menuItem(common_local_url('designadminpanel'), _('Design'),
                 _('Design configuration'), $action_name == 'designadminpanel', 'nav_design_admin_panel');
 
+            $this->out->menuItem(common_local_url('useradminpanel'), _('User'),
+                _('Paths configuration'), $action_name == 'useradminpanel', 'nav_design_admin_panel');
+
             $this->out->menuItem(common_local_url('pathsadminpanel'), _('Paths'),
                 _('Paths configuration'), $action_name == 'pathsadminpanel', 'nav_design_admin_panel');
 
index afe36f712c9968aabfc5feceb0fe76d159173c8e..d5101826f1d744d6cef5a33e735bd26571fc1be5 100644 (file)
@@ -590,9 +590,11 @@ class Router
 
             $m->connect('admin/site', array('action' => 'siteadminpanel'));
             $m->connect('admin/design', array('action' => 'designadminpanel'));
+            $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._-]+'));