sensitivecontentsettings.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. defined('GNUSOCIAL') || die();
  17. class SensitiveContentSettingsAction extends SettingsAction
  18. {
  19. public function title()
  20. {
  21. return _m('Sensitive content settings');
  22. }
  23. public function getInstructions()
  24. {
  25. return _m('Set preferences for display of "sensitive" content');
  26. }
  27. public function showContent()
  28. {
  29. $user = $this->scoped->getUser();
  30. $this->elementStart(
  31. 'form',
  32. [
  33. 'method' => 'post',
  34. 'id' => 'sensitivecontent',
  35. 'class' => 'form_settings',
  36. 'action' => common_local_url('sensitivecontentsettings'),
  37. ]
  38. );
  39. $this->elementStart('fieldset');
  40. $this->hidden('token', common_session_token());
  41. $this->elementStart('ul', 'form_data');
  42. $this->elementStart('li');
  43. $this->checkbox(
  44. 'hidesensitive',
  45. _('Hide attachments in posts hashtagged #NSFW'),
  46. ($this->arg('hidesensitive') ?
  47. $this->boolean('hidesensitive') : $this->scoped->getPref('MoonMan', 'hide_sensitive', 0))
  48. );
  49. $this->elementEnd('li');
  50. $this->elementEnd('ul');
  51. $this->submit('save', _m('BUTTON', 'Save'));
  52. $this->elementEnd('fieldset');
  53. $this->elementEnd('form');
  54. }
  55. public function doPost()
  56. {
  57. $hidesensitive = $this->boolean('hidesensitive') ? '1' : '0';
  58. $this->scoped->setPref('MoonMan', 'hide_sensitive', $hidesensitive);
  59. return _('Settings saved.');
  60. }
  61. }