3 * Laconica, the distributed open-source microblogging tool
5 * Miscellaneous settings
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 Robin Millette <millette@controlyourself.ca>
25 * @author Evan Prodromou <evan@controlyourself.ca>
26 * @copyright 2008-2009 Control Yourself, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28 * @link http://laconi.ca/
31 if (!defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/accountsettingsaction.php';
38 * Miscellaneous settings actions
40 * Currently this just manages URL shortening.
44 * @author Robin Millette <millette@controlyourself.ca>
45 * @author Zach Copley <zach@controlyourself.ca>
46 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
47 * @link http://laconi.ca/
50 class OthersettingsAction extends AccountSettingsAction
55 * @return string Title of the page
60 return _('Other Settings');
64 * Instructions for use
66 * @return instructions for use
69 function getInstructions()
71 return _('Manage various other options.');
75 * Content area of the page
77 * Shows a form for uploading an avatar.
82 function showContent()
84 $user = common_current_user();
87 $this->elementStart('form', array('method' => 'post',
88 'id' => 'form_settings_other',
89 'class' => 'form_settings',
91 common_local_url('othersettings')));
92 $this->elementStart('fieldset');
93 $this->element('legend', null, _('URL Auto-shortening'));
94 $this->hidden('token', common_session_token());
100 'ur1.ca' => 'ur1.ca (free service)',
101 '2tu.us' => '2tu.us (free service)',
102 'ptiturl.com' => 'ptiturl.com',
103 'bit.ly' => 'bit.ly',
104 'tinyurl.com' => 'tinyurl.com',
106 'snipr.com' => 'snipr.com',
107 'metamark.net' => 'metamark.net'
110 $this->elementStart('ul', 'form_data');
111 $this->elementStart('li');
112 $this->dropdown('urlshorteningservice', _('Service'),
113 $services, _('Automatic shortening service to use.'),
114 false, $user->urlshorteningservice);
115 $this->elementEnd('li');
116 $this->elementEnd('ul');
117 $this->submit('save', _('Save'));
118 $this->elementEnd('fieldset');
119 $this->elementEnd('form');
125 * Saves the changes to url-shortening prefs and shows a success or failure
131 function handlePost()
134 $token = $this->trimmed('token');
135 if (!$token || $token != common_session_token()) {
136 $this->showForm(_('There was a problem with your session token. '.
137 'Try again, please.'));
141 $urlshorteningservice = $this->trimmed('urlshorteningservice');
143 if (!is_null($urlshorteningservice) && strlen($urlshorteningservice) > 50) {
144 $this->showForm(_('URL shortening service is too long (max 50 chars).'));
148 $user = common_current_user();
150 assert(!is_null($user)); // should already be checked
152 $user->query('BEGIN');
154 $original = clone($user);
156 $user->urlshorteningservice = $urlshorteningservice;
158 $result = $user->update($original);
160 if ($result === false) {
161 common_log_db_error($user, 'UPDATE', __FILE__);
162 $this->serverError(_('Couldn\'t update user.'));
166 $user->query('COMMIT');
168 $this->showForm(_('Preferences saved.'), true);