]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/oldschoolsettings.php
Merge branch 'master' into nightly
[quix0rs-gnu-social.git] / actions / oldschoolsettings.php
index 74c6c05cda365b95c6d028bc797335691aab19b0..5c071954788e8690ad669a944838b6e8ec77bb67 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
-    // This check helps protect against security problems;
-    // your code file can't be executed directly from the web.
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Old-school settings
@@ -77,71 +73,49 @@ class OldschoolsettingsAction extends SettingsAction
      * @return boolean true
      */
 
-    function prepare($argarray)
+    protected function doPreparation()
     {
         if (!common_config('oldschool', 'enabled')) {
             throw new ClientException("Old-school settings not enabled.");
         }
-        parent::prepare($argarray);
-        return true;
     }
 
-    /**
-     * Handler method
-     *
-     * @param array $argarray is ignored since it's now passed in in prepare()
-     *
-     * @return void
-     */
-
-    function handlePost()
+    function doPost()
     {
-        $user = common_current_user();
-
-        $osp = Old_school_prefs::staticGet('user_id', $user->id);
+        $osp = Old_school_prefs::getKV('user_id', $this->scoped->getID());
         $orig = null;
 
         if (!empty($osp)) {
             $orig = clone($osp);
         } else {
             $osp = new Old_school_prefs();
-            $osp->user_id = $user->id;
+            $osp->user_id = $this->scoped->getID();
             $osp->created = common_sql_now();
         }
 
         $osp->stream_mode_only  = $this->boolean('stream_mode_only');
-        $osp->conversation_tree = $this->boolean('conversation_tree');
         $osp->stream_nicknames  = $this->boolean('stream_nicknames');
         $osp->modified          = common_sql_now();
 
-        if (!empty($orig)) {
+        if ($orig instanceof Old_school_prefs) {
             $osp->update($orig);
         } else {
             $osp->insert();
         }
 
         // TRANS: Confirmation shown when user profile settings are saved.
-        $this->showForm(_('Settings saved.'), true);
-
-        return;
-    }
-
-    function showContent()
-    {
-        $user = common_current_user();
-        $form = new OldSchoolForm($this, $user);
-        $form->show();
+        return _('Settings saved.');
     }
 }
 
-class OldSchoolForm extends Form
+class OldSchoolSettingsForm extends Form
 {
     var $user;
 
-    function __construct($out, $user)
+    function __construct(Action $out)
     {
         parent::__construct($out);
-        $this->user = $user;
+        $this->user = $out->getScoped()->getUser();
     }
 
     /**
@@ -162,10 +136,6 @@ class OldSchoolForm extends Form
                         $this->user->streamModeOnly());
         $this->elementEnd('li');
         $this->elementStart('li');
-        $this->checkbox('conversation_tree', _('Show conversation page as hierarchical trees'),
-                        $this->user->conversationTree());
-        $this->elementEnd('li');
-        $this->elementStart('li');
         $this->checkbox('stream_nicknames', _('Show nicknames (not full names) in timelines'),
                         $this->user->streamNicknames());
         $this->elementEnd('li');