]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/attachment.php
Merge commit 'jeff-themovie/invite-enabled' into 0.8.x
[quix0rs-gnu-social.git] / actions / attachment.php
1 <?php
2 /**
3  * Laconica, the distributed open-source microblogging tool
4  *
5  * Show notice attachments
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  Personal
23  * @package   Laconica
24  * @author    Evan Prodromou <evan@controlyourself.ca>
25  * @copyright 2008-2009 Control Yourself, Inc.
26  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27  * @link      http://laconi.ca/
28  */
29
30 if (!defined('LACONICA')) {
31     exit(1);
32 }
33
34 require_once INSTALLDIR.'/lib/attachmentlist.php';
35
36 /**
37  * Show notice attachments
38  *
39  * @category Personal
40  * @package  Laconica
41  * @author   Evan Prodromou <evan@controlyourself.ca>
42  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
43  * @link     http://laconi.ca/
44  */
45
46 class AttachmentAction extends Action
47 {
48     /**
49      * Attachment object to show
50      */
51
52     var $attachment = null;
53
54     /**
55      * Load attributes based on database arguments
56      *
57      * Loads all the DB stuff
58      *
59      * @param array $args $_REQUEST array
60      *
61      * @return success flag
62      */
63
64     function prepare($args)
65     {
66         parent::prepare($args);
67
68         if ($id = $this->trimmed('attachment')) {
69             $this->attachment = File::staticGet($id);
70         }
71
72         if (empty($this->attachment)) {
73             $this->clientError(_('No such attachment.'), 404);
74             return false;
75         }
76         return true;
77     }
78
79     /**
80      * Is this action read-only?
81      *
82      * @return boolean true
83      */
84
85     function isReadOnly($args)
86     {
87         return true;
88     }
89
90     /**
91      * Title of the page
92      *
93      * @return string title of the page
94      */
95     function title()
96     {
97         $a = new Attachment($this->attachment);
98         return $a->title();
99     }
100
101     /**
102      * Handle input
103      *
104      * Only handles get, so just show the page.
105      *
106      * @param array $args $_REQUEST data (unused)
107      *
108      * @return void
109      */
110
111     function handle($args)
112     {
113         parent::handle($args);
114
115         if (empty($this->attachment->filename)) {
116
117             // if it's not a local file, gtfo
118
119             common_redirect($this->attachment->url, 303);
120
121         } else {
122             $this->showPage();
123         }
124     }
125
126     /**
127      * Don't show local navigation
128      *
129      * @return void
130      */
131
132     function showLocalNavBlock()
133     {
134     }
135
136     /**
137      * Fill the content area of the page
138      *
139      * Shows a single notice list item.
140      *
141      * @return void
142      */
143
144     function showContent()
145     {
146         $ali = new Attachment($this->attachment, $this);
147         $cnt = $ali->show();
148     }
149
150     /**
151      * Don't show page notice
152      *
153      * @return void
154      */
155
156     function showPageNoticeBlock()
157     {
158     }
159
160     /**
161      * Show aside: this attachments appears in what notices
162      *
163      * @return void
164      */
165     function showSections() {
166         $ns = new AttachmentNoticeSection($this);
167         $ns->show();
168         $atcs = new AttachmentTagCloudSection($this);
169         $atcs->show();
170     }
171 }
172