3 * Form to set your personal poll settings
5 * StatusNet, the distributed open-source microblogging tool
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.
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.
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/>.
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/
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
34 class PollSettingsAction extends SettingsAction
39 * @return string Page title
44 return _m('Poll settings');
48 * Instructions for use
50 * @return string Instructions for use
53 function getInstructions()
55 // TRANS: Page instructions.
56 return _m('Set your poll preferences');
60 * Show the form for Poll
64 function showContent()
66 $user = common_current_user();
68 $prefs = User_poll_prefs::getKV('user_id', $user->id);
70 $form = new PollPrefsForm($this, $prefs);
78 * @param array $argarray is ignored since it's now passed in in prepare()
85 $user = common_current_user();
87 $upp = User_poll_prefs::getKV('user_id', $user->id);
93 $upp = new User_poll_prefs();
94 $upp->user_id = $user->id;
95 $upp->created = common_sql_now();
98 $upp->hide_responses = $this->boolean('hide_responses');
99 $upp->modified = common_sql_now();
107 // TRANS: Confirmation shown when user profile settings are saved.
108 $this->showForm(_('Settings saved.'), true);
114 class PollPrefsForm extends Form
118 function __construct($out, $prefs)
120 parent::__construct($out);
121 $this->prefs = $prefs;
125 * Visible or invisible data elements
127 * Display the form fields that make up the data of the form.
128 * Sub-classes should overload this to show their data.
135 $this->elementStart('fieldset');
136 $this->elementStart('ul', 'form_data');
137 $this->elementStart('li');
138 $this->checkbox('hide_responses',
139 _('Do not deliver poll responses to my home timeline'),
140 (!empty($this->prefs) && $this->prefs->hide_responses));
141 $this->elementEnd('li');
142 $this->elementEnd('ul');
143 $this->elementEnd('fieldset');
147 * Buttons for form actions
149 * Submit and cancel buttons (or whatever)
150 * Sub-classes should overload this to show their own buttons.
155 function formActions()
157 $this->submit('submit', _('Save'));
163 * Should be unique on the page. Sub-classes should overload this
164 * to show their own IDs.
166 * @return int ID of the form
171 return 'form_poll_prefs';
175 * Action of the form.
177 * URL to post to. Should be overloaded by subclasses to give
178 * somewhere to post to.
180 * @return string URL to post to
185 return common_local_url('pollsettings');
189 * Class of the form. May include space-separated list of multiple classes.
191 * @return string the form's class
196 return 'form_settings';