pollsettings.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Form to set your personal poll settings
  4. *
  5. * StatusNet, the distributed open-source microblogging tool
  6. *
  7. * PHP version 5
  8. *
  9. * LICENCE: This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * @category Plugins
  23. * @package StatusNet
  24. * @author Brion Vibber <brion@status.net>
  25. * @copyright 2012 StatusNet, Inc.
  26. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  27. * @link http://status.net/
  28. */
  29. if (!defined('GNUSOCIAL')) { exit(1); }
  30. class PollSettingsAction extends SettingsAction
  31. {
  32. /**
  33. * Title of the page
  34. *
  35. * @return string Page title
  36. */
  37. function title()
  38. {
  39. // TRANS: Page title.
  40. return _m('Poll settings');
  41. }
  42. /**
  43. * Instructions for use
  44. *
  45. * @return string Instructions for use
  46. */
  47. function getInstructions()
  48. {
  49. // TRANS: Page instructions.
  50. return _m('Set your poll preferences');
  51. }
  52. protected function getForm()
  53. {
  54. $prefs = User_poll_prefs::getKV('user_id', $this->scoped->getID());
  55. $form = new PollPrefsForm($this, $prefs);
  56. return $form;
  57. }
  58. protected function doPost()
  59. {
  60. $upp = User_poll_prefs::getKV('user_id', $this->scoped->getID());
  61. $orig = null;
  62. if ($upp instanceof User_poll_prefs) {
  63. $orig = clone($upp);
  64. } else {
  65. $upp = new User_poll_prefs();
  66. $upp->user_id = $this->scoped->getID();
  67. $upp->created = common_sql_now();
  68. }
  69. $upp->hide_responses = $this->boolean('hide_responses');
  70. $upp->modified = common_sql_now();
  71. if ($orig instanceof User_poll_prefs) {
  72. $upp->update($orig);
  73. } else {
  74. $upp->insert();
  75. }
  76. // TRANS: Confirmation shown when user profile settings are saved.
  77. return _('Settings saved.');
  78. }
  79. }