]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OpenID/openidsettings.php
Squashed commit of the following:
[quix0rs-gnu-social.git] / plugins / OpenID / openidsettings.php
index f1a62384b4d2c4f5e86359b13fabbd449b8cd70a..0dc4930ce1b8931841207c5d0b94806f4ca5313c 100644 (file)
@@ -222,6 +222,22 @@ class OpenidsettingsAction extends SettingsAction
                                       // TRANS: Button text to remove an OpenID trustroot.
                                       'value' => _m('BUTTON','Remove')));
         $this->elementEnd('fieldset');
+        
+        $prefs = User_openid_prefs::staticGet('user_id', $user->id);
+
+        $this->elementStart('fieldset');
+        $this->element('legend', null, _m('LEGEND','Preferences'));
+        $this->elementStart('ul', 'form_data');
+        $this->checkBox('hide_profile_link', "Hide OpenID links from my profile", !empty($prefs) && $prefs->hide_profile_link);
+        $this->element('input', array('type' => 'submit',
+                                      'id' => 'settings_openid_prefs_save',
+                                      'name' => 'save_prefs',
+                                      'class' => 'submit',
+                                      // TRANS: Button text to save OpenID prefs
+                                      'value' => _m('BUTTON','Save')));
+        $this->elementEnd('ul');
+        $this->elementEnd('fieldset');
+
         $this->elementEnd('form');
     }
 
@@ -258,6 +274,8 @@ class OpenidsettingsAction extends SettingsAction
             $this->removeOpenid();
         } else if($this->arg('remove_trustroots')) {
             $this->removeTrustroots();
+        } else if($this->arg('save_prefs')) {
+            $this->savePrefs();
         } else {
             // TRANS: Unexpected form validation error.
             $this->showForm(_m('Something weird happened.'));
@@ -326,4 +344,43 @@ class OpenidsettingsAction extends SettingsAction
         $this->showForm(_m('OpenID removed.'), true);
         return;
     }
+
+    /**
+     * Handles a request to save preferences
+     *
+     * Validates input and, if everything is OK, deletes the OpenID.
+     * Reloads the form with a success or error notification.
+     *
+     * @return void
+     */
+    function savePrefs()
+    {
+        $cur = common_current_user();
+
+        if (empty($cur)) {
+            throw new ClientException(_("Not logged in."));
+        }
+
+        $orig  = null;
+        $prefs = User_openid_prefs::staticGet('user_id', $cur->id);
+
+        if (empty($prefs)) {
+            $prefs          = new User_openid_prefs();
+            $prefs->user_id = $cur->id;
+            $prefs->created = common_sql_now();
+        } else {
+            $orig = clone($prefs);
+        }
+
+        $prefs->hide_profile_link = $this->boolean('hide_profile_link');
+
+        if (empty($orig)) {
+            $prefs->insert();
+        } else {
+            $prefs->update($orig);
+        }
+
+        $this->showForm(_m('OpenID preferences saved.'), true);
+        return;
+    }
 }