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.

61 lines
1.5KB

  1. <?php
  2. if (!defined('GNUSOCIAL')) {
  3. exit(1);
  4. }
  5. class BrowserNotificationsSettingsAction extends Action
  6. {
  7. function prepare($args)
  8. {
  9. parent::prepare($args);
  10. if (!common_logged_in()) { // Make sure we're logged in
  11. $this->clientError(_('Not logged in.'));
  12. return;
  13. } else if (!common_is_real_login()) { // Make _really_ sure we're logged in...
  14. common_set_returnto($this->selfUrl());
  15. $user = common_current_user();
  16. if (Event::handle('RedirectToLogin', array($this, $user))) {
  17. common_redirect(common_local_url('login'), 303);
  18. }
  19. } else { // k, I think by now we're logged in. For realz.
  20. $this->user = common_current_user();
  21. }
  22. if ($this->isPost()) {
  23. $this->checkSessionToken();
  24. }
  25. return true;
  26. }
  27. function handle($args)
  28. {
  29. parent::handle($args);
  30. if ($this->isPost()) {
  31. $settings = array(
  32. 'enabled' => $this->boolean('enabled', false),
  33. 'mentions_only' => $this->boolean('mentions_only', false)
  34. );
  35. BrowserNotificationSettings::save($this->user, $settings);
  36. }
  37. $this->showPage();
  38. }
  39. function title()
  40. {
  41. return _m('Browser Notifications Settings');
  42. }
  43. function showContent()
  44. {
  45. // TODO: Show 'success'/'error' msg after a form submit
  46. $form = new BrowserNotificationsSettingsForm($this);
  47. $form->show();
  48. }
  49. }