]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/mailbox.php
Merge branch '1.0.x' into profile-fixups
[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
46 class MailboxAction extends CurrentUserDesignAction
47 {
48     var $page = null;
49
50     function prepare($args)
51     {
52         parent::prepare($args);
53
54         $nickname   = common_canonical_nickname($this->arg('nickname'));
55         $this->user = User::staticGet('nickname', $nickname);
56         $this->page = $this->trimmed('page');
57
58         if (!$this->page) {
59             $this->page = 1;
60         }
61
62         common_set_returnto($this->selfUrl());
63
64         return true;
65     }
66
67     /**
68      * output page based on arguments
69      *
70      * @param array $args HTTP arguments (from $_REQUEST)
71      *
72      * @return void
73      */
74
75     function handle($args)
76     {
77         parent::handle($args);
78
79         if (!$this->user) {
80             $this->clientError(_('No such user.'), 404);
81             return;
82         }
83
84         $cur = common_current_user();
85
86         if (!$cur || $cur->id != $this->user->id) {
87             $this->clientError(_('Only the user can read their own mailboxes.'),
88                 403);
89             return;
90         }
91
92         $this->showPage();
93     }
94
95     function showNoticeForm()
96     {
97         $message_form = new MessageForm($this);
98         $message_form->show();
99     }
100
101     function showContent()
102     {
103         $message = $this->getMessages();
104
105         if ($message) {
106
107             $ml = $this->getMessageList($message);
108
109             $cnt = $ml->show();
110
111             $this->pagination($this->page > 1,
112                               $cnt > MESSAGES_PER_PAGE,
113                               $this->page,
114                               $this->trimmed('action'),
115                               array('nickname' => $this->user->nickname));
116         } else {
117             $this->element('p', 
118                            'guide', 
119                            _('You have no private messages. '.
120                              'You can send private message to engage other users in conversation. '.
121                              'People can send you messages for your eyes only.'));
122         }
123     }
124
125     function getMessages()
126     {
127         return null;
128     }
129
130     function getMessageList($message)
131     {
132         return null;
133     }
134
135     /**
136      * Show the page notice
137      *
138      * Shows instructions for the page
139      *
140      * @return void
141      */
142
143     function showPageNotice()
144     {
145         $instr  = $this->getInstructions();
146         $output = common_markup_to_html($instr);
147
148         $this->elementStart('div', 'instructions');
149         $this->raw($output);
150         $this->elementEnd('div');
151     }
152
153     /**
154      * Mailbox actions are read only
155      *
156      * @param array $args other arguments
157      *
158      * @return boolean
159      */
160
161     function isReadOnly($args)
162     {
163          return true;
164     }
165
166     function showObjectNav()
167     {
168         $mm = new MailboxMenu($this);
169         $mm->show();
170     }
171 }