You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.7KB

  1. <?php
  2. if (!defined('GNUSOCIAL')) {
  3. exit(1);
  4. }
  5. class BrowserNotificationsSettingsForm extends Form
  6. {
  7. function __construct($out=null)
  8. {
  9. parent::__construct($out);
  10. }
  11. function id()
  12. {
  13. return 'browser_notifications_settings';
  14. }
  15. function formClass()
  16. {
  17. return 'form_settings';
  18. }
  19. function action()
  20. {
  21. return common_local_url('browsernotificationssettings');
  22. }
  23. function formData()
  24. {
  25. $this->out->elementStart('fieldset');
  26. $this->out->elementStart('ul', 'form_data');
  27. // Start with default settings
  28. $user_settings = BrowserNotificationSettings::getDefaults();
  29. // Overwrite defaults with user settings if available
  30. $bns = BrowserNotificationSettings::getByUserId($this->out->user->id);
  31. if(!empty($bns)) {
  32. $user_settings['enabled'] = $bns->enabled;
  33. $user_settings['mentions_only'] = $bns->mentions_only;
  34. }
  35. // Enabled?
  36. $this->li();
  37. $this->out->checkbox(
  38. 'enabled', // id
  39. 'Enabled', // label
  40. $user_settings['enabled'] // checked
  41. );
  42. $this->unli();
  43. // Mentions only?
  44. // TODO
  45. /* $this->li();
  46. $this->out->checkbox(
  47. 'mentions_only',
  48. 'Only show notifications for notices that mention me',
  49. $user_settings['mentions_only']
  50. );
  51. $this->unli(); */
  52. $this->elementEnd('ul');
  53. $this->elementEnd('fieldset');
  54. }
  55. function formActions()
  56. {
  57. $this->out->submit('browser-notifications-settings-submit', _m('BUTTON', 'Save'), 'submit', 'submit');
  58. }
  59. }