Browse Source

getDefaults now returns a bns instance

...instead of an associative array.

To be consistent with everything else.
master
Chimo 3 years ago
parent
commit
2539426e62
2 changed files with 11 additions and 10 deletions
  1. 5
    4
      classes/BrowserNotificationSettings.php
  2. 6
    6
      forms/browsernotificationssettings.php

+ 5
- 4
classes/BrowserNotificationSettings.php View File

@@ -31,10 +31,11 @@ class BrowserNotificationSettings extends Managed_DataObject
31 31
 
32 32
     public static function getDefaults()
33 33
     {
34
-        return array(
35
-            'enabled' => true,
36
-            'mentions_only' => false
37
-        );
34
+        $bns = new BrowserNotificationSettings();
35
+        $bns->enabled = true;
36
+        $bns->mentions_only = false;
37
+
38
+        return $bns;
38 39
     }
39 40
 
40 41
     public function toJSON()

+ 6
- 6
forms/browsernotificationssettings.php View File

@@ -37,9 +37,8 @@ class BrowserNotificationsSettingsForm extends Form
37 37
         // Overwrite defaults with user settings if available
38 38
         $bns = BrowserNotificationSettings::getByUserId($this->out->user->id);
39 39
 
40
-        if(!empty($bns)) {
41
-            $user_settings['enabled'] = $bns->enabled;
42
-            $user_settings['mentions_only'] = $bns->mentions_only;
40
+        if (!empty($bns)) {
41
+            $user_settings = $bns;
43 42
         }
44 43
 
45 44
         // Enabled?
@@ -47,7 +46,7 @@ class BrowserNotificationsSettingsForm extends Form
47 46
         $this->out->checkbox(
48 47
             'enabled',  // id
49 48
             'Enabled',  // label
50
-            $user_settings['enabled'] // checked
49
+            $user_settings->enabled // checked
51 50
         );
52 51
         $this->unli();
53 52
 
@@ -57,7 +56,7 @@ class BrowserNotificationsSettingsForm extends Form
57 56
         $this->out->checkbox(
58 57
             'mentions_only',
59 58
             'Only show notifications for notices that mention me',
60
-            $user_settings['mentions_only']
59
+            $user_settings->mentions_only;
61 60
         );
62 61
         $this->unli(); */
63 62
 
@@ -69,4 +68,5 @@ class BrowserNotificationsSettingsForm extends Form
69 68
     {
70 69
         $this->out->submit('browser-notifications-settings-submit', _m('BUTTON', 'Save'), 'submit', 'submit');
71 70
     }
72
-}
71
+}
72
+

Loading…
Cancel
Save