]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/pathsadminpanel.php
Merge commit 'refs/merge-requests/122' of git://gitorious.org/statusnet/mainline...
[quix0rs-gnu-social.git] / actions / pathsadminpanel.php
index c4ab18c00cbc96cd5cc089e17b5a372f4c16e4a7..9155a7e42856ae19b61b405973c5de83aa3b3d5e 100644 (file)
@@ -24,7 +24,7 @@
  * @author    Evan Prodromou <evan@status.net>
  * @author    Zach Copley <zach@status.net>
  * @author    Sarven Capadisli <csarven@status.net>
- * @copyright 2008-2009 StatusNet, Inc.
+ * @copyright 2008-2010 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link      http://status.net/
  */
@@ -92,12 +92,17 @@ class PathsadminpanelAction extends AdminPanelAction
     function saveSettings()
     {
         static $settings = array(
-            'site' => array('path', 'locale_path'),
+            'site' => array('path', 'locale_path', 'ssl', 'sslserver'),
             'theme' => array('server', 'dir', 'path'),
             'avatar' => array('server', 'dir', 'path'),
             'background' => array('server', 'dir', 'path')
         );
 
+       // XXX: If we're only going to have one boolean on thi page we
+       // can remove some of the boolean processing code --Z
+
+       static $booleans = array('site' => array('fancy'));
+
         $values = array();
 
         foreach ($settings as $section => $parts) {
@@ -106,6 +111,12 @@ class PathsadminpanelAction extends AdminPanelAction
             }
         }
 
+        foreach ($booleans as $section => $parts) {
+            foreach ($parts as $setting) {
+                $values[$section][$setting] = ($this->boolean($setting)) ? 1 : 0;
+            }
+        }
+
         $this->validate($values);
 
         // assert(all values are valid);
@@ -120,7 +131,13 @@ class PathsadminpanelAction extends AdminPanelAction
             }
         }
 
-        $config->query('COMMIT');
+       foreach ($booleans as $section => $parts) {
+           foreach ($parts as $setting) {
+                Config::save($section, $setting, $values[$section][$setting]);
+            }
+       }
+
+       $config->query('COMMIT');
 
         return;
     }
@@ -160,6 +177,11 @@ class PathsadminpanelAction extends AdminPanelAction
             $this->clientError(sprintf(_("Locales directory not readable: %s"), $values['site']['locale_path']));
         }
 
+        // Validate SSL setup
+
+        if (mb_strlen($values['site']['sslserver']) > 255) {
+            $this->clientError(_("Invalid SSL server. The maximum length is 255 characters."));
+        }
     }
 
 }
@@ -208,10 +230,14 @@ class PathsAdminPanelForm extends AdminForm
 
     function formData()
     {
-        $this->out->elementStart('fieldset', array('id' => 'settings_paths_locale'));
+       $this->out->elementStart('fieldset', array('id' => 'settings_paths_locale'));
         $this->out->element('legend', null, _('Site'), 'site');
         $this->out->elementStart('ul', 'form_data');
 
+       $this->li();
+        $this->input('server', _('Server'), _('Site\'s server hostname.'));
+        $this->unli();
+
         $this->li();
         $this->input('path', _('Path'), _('Site path'));
         $this->unli();
@@ -220,6 +246,12 @@ class PathsAdminPanelForm extends AdminForm
         $this->input('locale_path', _('Path to locales'), _('Directory path to locales'), 'site');
         $this->unli();
 
+       $this->li();
+        $this->out->checkbox('fancy', _('Fancy URLs'),
+                             (bool) $this->value('fancy'),
+                             _('Use fancy (more readable and memorable) URLs?'));
+       $this->unli();
+
         $this->out->elementEnd('ul');
         $this->out->elementEnd('fieldset');
 
@@ -283,6 +315,29 @@ class PathsAdminPanelForm extends AdminForm
 
         $this->out->elementEnd('ul');
         $this->out->elementEnd('fieldset');
+
+        $this->out->elementStart('fieldset', array('id' => 'settings_admin_ssl'));
+        $this->out->element('legend', null, _('SSL'));
+        $this->out->elementStart('ul', 'form_data');
+        $this->li();
+        $ssl = array('never' => _('Never'),
+                     'sometimes' => _('Sometimes'),
+                     'always' => _('Always'));
+
+        common_debug("site ssl = " . $this->value('site', 'ssl'));
+
+        $this->out->dropdown('site-ssl', _('Use SSL'),
+                             $ssl, _('When to use SSL'),
+                             false, $this->value('ssl', 'site'));
+        $this->unli();
+
+        $this->li();
+        $this->input('sslserver', _('SSL server'),
+                     _('Server to direct SSL requests to'), 'site');
+        $this->unli();
+        $this->out->elementEnd('ul');
+        $this->out->elementEnd('fieldset');
+
     }
 
     /**
@@ -293,11 +348,10 @@ class PathsAdminPanelForm extends AdminForm
 
     function formActions()
     {
-        $this->out->submit('save', _('Save'), 'submit form_action-secondary',
+        $this->out->submit('save', _('Save'), 'submit',
                 'save', _('Save paths'));
     }
 
-
     /**
      * Utility to simplify some of the duplicated code around
      * params and settings. Overriding the input() in the base class