]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/mailbox.php
More Favorite pluginification (favecount, cache, menus(favecount, cache, menus))
[quix0rs-gnu-social.git] / lib / mailbox.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * common superclass for direct messages inbox and outbox
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * 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     exit(1);
32 }
33
34 /**
35  * common superclass for direct messages inbox and outbox
36  *
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  * @see      InboxAction
43  * @see      OutboxAction
44  */
45 class MailboxAction extends Action
46 {
47     var $page = null;
48
49     function prepare($args)
50     {
51         parent::prepare($args);
52
53         $nickname   = common_canonical_nickname($this->arg('nickname'));
54         $this->user = User::getKV('nickname', $nickname);
55         $this->page = $this->trimmed('page');
56
57         if (!$this->page) {
58             $this->page = 1;
59         }
60
61         common_set_returnto($this->selfUrl());
62
63         return true;
64     }
65
66     /**
67      * output page based on arguments
68      *
69      * @param array $args HTTP arguments (from $_REQUEST)
70      *
71      * @return void
72      */
73     function handle($args)
74     {
75         parent::handle($args);
76
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         $cur = common_current_user();
83
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         $message_form = new MessageForm($this);
95         $message_form->show();
96     }
97
98     function showContent()
99     {
100         $message = $this->getMessages();
101
102         if ($message) {
103
104             $ml = $this->getMessageList($message);
105
106             $cnt = $ml->show();
107
108             $this->pagination($this->page > 1,
109                               $cnt > MESSAGES_PER_PAGE,
110                               $this->page,
111                               $this->trimmed('action'),
112                               array('nickname' => $this->user->nickname));
113         } else {
114             $this->element('p',
115                            'guide',
116                            // TRANS: Message displayed when there are no private messages in the inbox of a user.
117                            _('You have no private messages. '.
118                              'You can send private message to engage other users in conversation. '.
119                              'People can send you messages for your eyes only.'));
120         }
121     }
122
123     function getMessages()
124     {
125         return null;
126     }
127
128     function getMessageList($message)
129     {
130         return null;
131     }
132
133     /**
134      * Show the page notice
135      *
136      * Shows instructions for the page
137      *
138      * @return void
139      */
140     function showPageNotice()
141     {
142         $instr  = $this->getInstructions();
143         $output = common_markup_to_html($instr);
144
145         $this->elementStart('div', 'instructions');
146         $this->raw($output);
147         $this->elementEnd('div');
148     }
149
150     /**
151      * Mailbox actions are read only
152      *
153      * @param array $args other arguments
154      *
155      * @return boolean
156      */
157     function isReadOnly($args)
158     {
159          return true;
160     }
161
162     function showObjectNav()
163     {
164         $mm = new MailboxMenu($this);
165         $mm->show();
166     }
167 }