git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

microsummary.php 2.39 KB
Newer Older
Evan Prodromou's avatar
Evan Prodromou committed
1
<?php
Robin Millette's avatar
Robin Millette committed
2 3 4 5 6 7
/**
 * Microsummary action, see https://wiki.mozilla.org/Microsummaries
 *
 * PHP version 5
 *
 * @category Action
8
 * @package  StatusNet
9 10
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
Robin Millette's avatar
Robin Millette committed
11
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12
 * @link     http://status.net/
Robin Millette's avatar
Robin Millette committed
13
 *
14
 * StatusNet - the distributed open-source microblogging tool
15
 * Copyright (C) 2008, 2009, StatusNet, Inc.
Evan Prodromou's avatar
Evan Prodromou committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

31
if (!defined('STATUSNET') && !defined('LACONICA')) {
Robin Millette's avatar
Robin Millette committed
32 33
    exit(1);
}
Evan Prodromou's avatar
Evan Prodromou committed
34

Robin Millette's avatar
Robin Millette committed
35 36 37 38
/**
 * Microsummary action class.
 *
 * @category Action
39
 * @package  StatusNet
40 41
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
Robin Millette's avatar
Robin Millette committed
42
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43
 * @link     http://status.net/
Robin Millette's avatar
Robin Millette committed
44
 */
45 46
class MicrosummaryAction extends Action
{
Robin Millette's avatar
Robin Millette committed
47 48
    /**
     * Class handler.
49
     *
Robin Millette's avatar
Robin Millette committed
50 51 52 53
     * @param array $args array of arguments
     *
     * @return nothing
     */
54 55
    function handle($args)
    {
56
        parent::handle($args);
Evan Prodromou's avatar
Evan Prodromou committed
57

58
        $nickname = common_canonical_nickname($this->arg('nickname'));
59
        $user     = User::getKV('nickname', $nickname);
Evan Prodromou's avatar
Evan Prodromou committed
60

61
        if (!$user) {
62
            // TRANS: Client error displayed trying to make a micro summary without providing a valid user.
63
            $this->clientError(_('No such user.'), 404);
64
        }
65

66
        $notice = $user->getCurrentNotice();
67

68
        if (!$notice) {
69
            // TRANS: Client error displayed trying to make a micro summary without providing a status.
70
            $this->clientError(_('No current status.'), 404);
71
        }
72

73
        header('Content-Type: text/plain');
74

75 76
        print $user->nickname . ': ' . $notice->content;
    }
77

78
    function isReadOnly($args)
79 80 81
    {
        return true;
    }
Evan Prodromou's avatar
Evan Prodromou committed
82
}