Browse Source

Fix undefined User on GET requests

Chimo 3 years ago
parent
commit
5b037006f1

+ 1
- 3
actions/browsernotificationssettings.php View File

@@ -7,14 +7,12 @@ class BrowserNotificationsSettingsAction extends SettingsAction
7 7
 {
8 8
     protected function doPost()
9 9
     {
10
-        $this->user = common_current_user();
11
-
12 10
         $settings = array(
13 11
             'enabled' => $this->boolean('enabled', false),
14 12
             'mentions_only' => $this->boolean('mentions_only', false)
15 13
         );
16 14
 
17
-        BrowserNotificationSettings::save($this->user, $settings);
15
+        BrowserNotificationSettings::save(common_current_user(), $settings);
18 16
 
19 17
         return _('Settings saved.');
20 18
     }

+ 3
- 1
forms/browsernotificationssettings.php View File

@@ -27,6 +27,8 @@ class BrowserNotificationsSettingsForm extends Form
27 27
 
28 28
     function formData()
29 29
     {
30
+        $user = common_current_user();
31
+
30 32
         $this->out->elementStart('fieldset');
31 33
 
32 34
         $this->out->elementStart('ul', 'form_data');
@@ -35,7 +37,7 @@ class BrowserNotificationsSettingsForm extends Form
35 37
         $user_settings = BrowserNotificationSettings::getDefaults();
36 38
 
37 39
         // Overwrite defaults with user settings if available
38
-        $bns = BrowserNotificationSettings::getByUserId($this->out->user->id);
40
+        $bns = BrowserNotificationSettings::getByUserId($user->id);
39 41
 
40 42
         if (!empty($bns)) {
41 43
             $user_settings = $bns;

Loading…
Cancel
Save