]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/apigroupshow.php
Merge commit 'mainline/0.9.x' into 0.9.x
[quix0rs-gnu-social.git] / actions / apigroupshow.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Show information about a group
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  API
23  * @package   StatusNet
24  * @author    Craig Andrews <candrews@integralblue.com>
25  * @author    Evan Prodromou <evan@status.net>
26  * @author    Jeffery To <jeffery.to@gmail.com>
27  * @author    Zach Copley <zach@status.net>
28  * @copyright 2009 StatusNet, Inc.
29  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
30  * @link      http://status.net/
31  */
32
33 if (!defined('STATUSNET')) {
34     exit(1);
35 }
36
37 require_once INSTALLDIR . '/lib/apiprivateauth.php';
38
39 /**
40  * Outputs detailed information about the group specified by ID
41  *
42  * @category API
43  * @package  StatusNet
44  * @author   Craig Andrews <candrews@integralblue.com>
45  * @author   Evan Prodromou <evan@status.net>
46  * @author   Jeffery To <jeffery.to@gmail.com>
47  * @author   Zach Copley <zach@status.net>
48  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
49  * @link     http://status.net/
50  */
51
52 class ApiGroupShowAction extends ApiPrivateAuthAction
53 {
54     var $group = null;
55
56     /**
57      * Take arguments for running
58      *
59      * @param array $args $_REQUEST args
60      *
61      * @return boolean success flag
62      *
63      */
64
65     function prepare($args)
66     {
67         parent::prepare($args);
68
69         $this->group = $this->getTargetGroup($this->arg('id'));
70
71         return true;
72     }
73
74     /**
75      * Handle the request
76      *
77      * Check the format and show the user info
78      *
79      * @param array $args $_REQUEST data (unused)
80      *
81      * @return void
82      */
83
84     function handle($args)
85     {
86         parent::handle($args);
87
88         if (empty($this->group)) {
89             $this->clientError(
90                 _('Group not found!'),
91                 404,
92                 $this->format
93             );
94             return;
95         }
96
97         switch($this->format) {
98         case 'xml':
99             $this->showSingleXmlGroup($this->group);
100             break;
101         case 'json':
102             $this->showSingleJsonGroup($this->group);
103             break;
104         default:
105             $this->clientError(_('API method not found!'), 404, $this->format);
106             break;
107         }
108
109     }
110
111     /**
112      * When was this group last modified?
113      *
114      * @return string datestamp of the latest notice in the stream
115      */
116
117     function lastModified()
118     {
119         if (!empty($this->group)) {
120             return strtotime($this->group->modified);
121         }
122
123         return null;
124     }
125
126     /**
127      * An entity tag for this group
128      *
129      * Returns an Etag based on the action name, language, and
130      * timestamps of the notice
131      *
132      * @return string etag
133      */
134
135     function etag()
136     {
137         if (!empty($this->group)) {
138
139             return '"' . implode(
140                 ':',
141                 array($this->arg('action'),
142                       common_language(),
143                       $this->group->id,
144                       strtotime($this->group->modified))
145             )
146             . '"';
147         }
148
149         return null;
150     }
151
152 }