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 {
41 * @param array $args misc. arguments
43 * @return boolean true
45 function prepare($args) {
46 parent::prepare($args);
47 $this->start = $this->arg('start');
48 $this->duration = $this->boolean('duration', false);
53 * Handle input and ouput something
55 * @param array $args $_REQUEST arguments
59 function handle($args)
61 parent::handle($args);
63 if (!common_logged_in()) {
64 // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
65 $this->clientError(_m('Not logged in.'));
68 if (!empty($this->start)) {
69 $times = EventTimeList::getTimes($this->start, $this->duration);
71 // TRANS: Client error when submitting a form with unexpected information.
72 $this->clientError(_m('Unexpected form submission.'));
75 if ($this->boolean('ajax')) {
76 header('Content-Type: application/json; charset=utf-8');
77 print json_encode($times);
79 // TRANS: Client error displayed when using an action in a non-AJAX way.
80 $this->clientError(_m('This action is AJAX only.'));
85 * Override the regular error handler to show something more
88 * @param string $msg error message
89 * @param int $code error code
91 function clientError($msg, $code = 400) {
92 if ($this->boolean('ajax')) {
93 header('Content-Type: application/json; charset=utf-8');
102 parent::clientError($msg, $code);