mailbox.php 4.53 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 54 55 56 57 58 59 60
    {
        parent::prepare($args);

        $nickname   = common_canonical_nickname($this->arg('nickname'));
        $this->user = User::staticGet('nickname', $nickname);
        $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 84
            return;
        }

        $cur = common_current_user();

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

92
        $this->showPage();
93 94
    }

95
    function showNoticeForm()
96
    {
97 98
        $message_form = new MessageForm($this);
        $message_form->show();
99 100
    }

101
    function showContent()
102
    {
103
        $message = $this->getMessages();
104 105 106

        if ($message) {

107
            $ml = $this->getMessageList($message);
108

109
            $cnt = $ml->show();
110

111 112 113 114
            $this->pagination($this->page > 1,
                              $cnt > MESSAGES_PER_PAGE,
                              $this->page,
                              $this->trimmed('action'),
115
                              array('nickname' => $this->user->nickname));
116
        } else {
117 118 119
            $this->element('p',
                           'guide',
                           // TRANS: Message displayed when there are no private messages in the inbox of a user.
120 121 122
                           _('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.'));
123
        }
124 125
    }

126 127 128 129 130
    function getMessages()
    {
        return null;
    }

131
    function getMessageList($message)
132 133 134 135
    {
        return null;
    }

136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
    /**
     * 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');
    }

Zach Copley's avatar
Zach Copley committed
153 154 155 156 157 158 159 160 161 162 163
    /**
     * Mailbox actions are read only
     *
     * @param array $args other arguments
     *
     * @return boolean
     */
    function isReadOnly($args)
    {
         return true;
    }
164 165 166 167 168 169

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