mailbox.php 4.47 KB
Newer Older
1
<?php
2
/**
3
 * StatusNet, the distributed open-source microblogging tool
4
 *
5 6 7 8 9
 * common superclass for direct messages inbox and outbox
 *
 * PHP version 5
 *
 * LICENCE: This program is free software: you can redistribute it and/or modify
10 11 12 13 14 15 16 17 18 19 20
 * 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/>.
21
 *
22
 * @category  Message
23
 * @package   StatusNet
24
 * @author    Evan Prodromou <evan@status.net>
25
 * @copyright 2008 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/
28 29
 */

30
if (!defined('STATUSNET') && !defined('LACONICA')) {
31 32
    exit(1);
}
33

34 35 36
/**
 * common superclass for direct messages inbox and outbox
 *
37
 * @category Message
38
 * @package  StatusNet
39
 * @author   Evan Prodromou <evan@status.net>
40
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41
 * @link     http://status.net/
42 43 44
 * @see      InboxAction
 * @see      OutboxAction
 */
45
class MailboxAction extends Action
46
{
47 48
    var $page = null;

49
    function prepare($args)
50 51 52 53
    {
        parent::prepare($args);

        $nickname   = common_canonical_nickname($this->arg('nickname'));
54
        $this->user = User::getKV('nickname', $nickname);
55 56 57 58 59 60
        $this->page = $this->trimmed('page');

        if (!$this->page) {
            $this->page = 1;
        }

61 62
        common_set_returnto($this->selfUrl());

63 64 65
        return true;
    }

66 67 68 69 70 71 72 73 74 75 76
    /**
     * output page based on arguments
     *
     * @param array $args HTTP arguments (from $_REQUEST)
     *
     * @return void
     */
    function handle($args)
    {
        parent::handle($args);

77
        if (!$this->user) {
78
            // TRANS: Client error displayed when trying to access a mailbox without providing a user.
79
            $this->clientError(_('No such user.'), 404);
80 81 82 83
        }

        $cur = common_current_user();

84
        if (!$cur || $cur->id != $this->user->id) {
85
            // TRANS: Client error displayed when trying to access a mailbox that is not of the logged in user.
86
            $this->clientError(_('Only the user can read their own mailboxes.'), 403);
87 88
        }

89
        $this->showPage();
90 91
    }

92
    function showNoticeForm()
93
    {
94 95
        $message_form = new MessageForm($this);
        $message_form->show();
96 97
    }

98
    function showContent()
99
    {
100
        $message = $this->getMessages();
101 102 103

        if ($message) {

104
            $ml = $this->getMessageList($message);
105

106
            $cnt = $ml->show();
107

108 109 110 111
            $this->pagination($this->page > 1,
                              $cnt > MESSAGES_PER_PAGE,
                              $this->page,
                              $this->trimmed('action'),
112
                              array('nickname' => $this->user->nickname));
113
        } else {
114 115 116
            $this->element('p',
                           'guide',
                           // TRANS: Message displayed when there are no private messages in the inbox of a user.
117 118 119
                           _('You have no private messages. '.
                             'You can send private message to engage other users in conversation. '.
                             'People can send you messages for your eyes only.'));
120
        }
121 122
    }

123 124 125 126 127
    function getMessages()
    {
        return null;
    }

128
    function getMessageList($message)
129 130 131 132
    {
        return null;
    }

133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
    /**
     * Show the page notice
     *
     * Shows instructions for the page
     *
     * @return void
     */
    function showPageNotice()
    {
        $instr  = $this->getInstructions();
        $output = common_markup_to_html($instr);

        $this->elementStart('div', 'instructions');
        $this->raw($output);
        $this->elementEnd('div');
    }

150 151 152 153 154 155 156 157 158 159 160
    /**
     * Mailbox actions are read only
     *
     * @param array $args other arguments
     *
     * @return boolean
     */
    function isReadOnly($args)
    {
         return true;
    }
161 162 163 164 165 166

    function showObjectNav()
    {
        $mm = new MailboxMenu($this);
        $mm->show();
    }
167
}