Browse Source

getDefaults now returns a bns instance

...instead of an associative array.

To be consistent with everything else.
master
Chimo 4 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

public static function getDefaults()
{
return array(
'enabled' => true,
'mentions_only' => false
);
$bns = new BrowserNotificationSettings();
$bns->enabled = true;
$bns->mentions_only = false;

return $bns;
}

public function toJSON()

+ 6
- 6
forms/browsernotificationssettings.php View File

@@ -37,9 +37,8 @@ class BrowserNotificationsSettingsForm extends Form
// Overwrite defaults with user settings if available
$bns = BrowserNotificationSettings::getByUserId($this->out->user->id);

if(!empty($bns)) {
$user_settings['enabled'] = $bns->enabled;
$user_settings['mentions_only'] = $bns->mentions_only;
if (!empty($bns)) {
$user_settings = $bns;
}

// Enabled?
@@ -47,7 +46,7 @@ class BrowserNotificationsSettingsForm extends Form
$this->out->checkbox(
'enabled', // id
'Enabled', // label
$user_settings['enabled'] // checked
$user_settings->enabled // checked
);
$this->unli();

@@ -57,7 +56,7 @@ class BrowserNotificationsSettingsForm extends Form
$this->out->checkbox(
'mentions_only',
'Only show notifications for notices that mention me',
$user_settings['mentions_only']
$user_settings->mentions_only;
);
$this->unli(); */

@@ -69,4 +68,5 @@ class BrowserNotificationsSettingsForm extends Form
{
$this->out->submit('browser-notifications-settings-submit', _m('BUTTON', 'Save'), 'submit', 'submit');
}
}
}


Loading…
Cancel
Save