123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class PollSettingsAction extends SettingsAction
- {
-
- function title()
- {
-
- return _m('Poll settings');
- }
-
- function getInstructions()
- {
-
- return _m('Set your poll preferences');
- }
-
- function showContent()
- {
- $user = common_current_user();
- $prefs = User_poll_prefs::getKV('user_id', $user->id);
- $form = new PollPrefsForm($this, $prefs);
- $form->show();
- }
-
- function handlePost()
- {
- $user = common_current_user();
- $upp = User_poll_prefs::getKV('user_id', $user->id);
- $orig = null;
- if (!empty($upp)) {
- $orig = clone($upp);
- } else {
- $upp = new User_poll_prefs();
- $upp->user_id = $user->id;
- $upp->created = common_sql_now();
- }
- $upp->hide_responses = $this->boolean('hide_responses');
- $upp->modified = common_sql_now();
- if (!empty($orig)) {
- $upp->update($orig);
- } else {
- $upp->insert();
- }
-
- $this->showForm(_('Settings saved.'), true);
- return;
- }
- }
- class PollPrefsForm extends Form
- {
- var $prefs;
- function __construct($out, $prefs)
- {
- parent::__construct($out);
- $this->prefs = $prefs;
- }
-
- function formData()
- {
- $this->elementStart('fieldset');
- $this->elementStart('ul', 'form_data');
- $this->elementStart('li');
- $this->checkbox('hide_responses',
- _('Do not deliver poll responses to my home timeline'),
- (!empty($this->prefs) && $this->prefs->hide_responses));
- $this->elementEnd('li');
- $this->elementEnd('ul');
- $this->elementEnd('fieldset');
- }
-
- function formActions()
- {
- $this->submit('submit', _('Save'));
- }
-
- function id()
- {
- return 'form_poll_prefs';
- }
-
- function action()
- {
- return common_local_url('pollsettings');
- }
-
- function formClass()
- {
- return 'form_settings';
- }
- }
|