3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2011, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * @author Zach Copley <zach@status.net>
22 * @copyright 2011 StatusNet, Inc.
23 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
24 * @link http://status.net/
27 if (!defined('STATUSNET')) {
32 * Callback handler to populate end time dropdown
34 class TimelistAction extends Action {
42 * @param array $args misc. arguments
44 * @return boolean true
46 function prepare($args) {
47 parent::prepare($args);
48 $this->start = $this->arg('start');
49 $this->duration = $this->boolean('duration', false);
54 * Handle input and ouput something
56 * @param array $args $_REQUEST arguments
60 function handle($args)
62 parent::handle($args);
64 if (!common_logged_in()) {
65 // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
66 $this->clientError(_('Not logged in.'));
70 if (!empty($this->start)) {
71 $times = EventTimeList::getTimes($this->start, $this->duration);
73 $this->clientError(_m('Unexpected form submission.'));
77 if ($this->boolean('ajax')) {
78 header('Content-Type: application/json; charset=utf-8');
79 print json_encode($times);
81 $this->clientError(_m('This action is AJAX only.'));
86 * Override the regular error handler to show something more
89 * @param string $msg error message
90 * @param int $code error code
92 function clientError($msg, $code = 400) {
93 if ($this->boolean('ajax')) {
94 header('Content-Type: application/json; charset=utf-8');
103 parent::clientError($msg, $code);