1 <?php
2 /**
3 * @package Joomla.Platform
4 * @subpackage Facebook
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 */
9
10 defined('JPATH_PLATFORM') or die();
11
12 /**
13 * Facebook API Group class for the Joomla Platform.
14 *
15 * @link http://developers.facebook.com/docs/reference/api/group/
16 * @since 13.1
17 * @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
18 */
19 class JFacebookGroup extends JFacebookObject
20 {
21 /**
22 * Method to read a group. Requires authentication and user_groups or friends_groups permission for non-public groups.
23 *
24 * @param string $group The group id.
25 *
26 * @return mixed The decoded JSON response or false if the client is not authenticated.
27 *
28 * @since 13.1
29 */
30 public function getGroup($group)
31 {
32 return $this->get($group);
33 }
34
35 /**
36 * Method to get the group's wall. Requires authentication and user_groups or friends_groups permission for non-public groups.
37 *
38 * @param string $group The group id.
39 * @param integer $limit The number of objects per page.
40 * @param integer $offset The object's number on the page.
41 * @param string $until A unix timestamp or any date accepted by strtotime.
42 * @param string $since A unix timestamp or any date accepted by strtotime.
43 *
44 * @return mixed The decoded JSON response or false if the client is not authenticated.
45 *
46 * @since 13.1
47 */
48 public function getFeed($group, $limit = 0, $offset = 0, $until = null, $since = null)
49 {
50 return $this->getConnection($group, 'feed', '', $limit, $offset, $until, $since);
51 }
52
53 /**
54 * Method to get the group's members. Requires authentication and user_groups or friends_groups permission for non-public groups.
55 *
56 * @param string $group The group id.
57 * @param integer $limit The number of objects per page.
58 * @param integer $offset The object's number on the page.
59 *
60 * @return mixed The decoded JSON response or false if the client is not authenticated.
61 *
62 * @since 13.1
63 */
64 public function getMembers($group, $limit = 0, $offset = 0)
65 {
66 return $this->getConnection($group, 'members', '', $limit, $offset);
67 }
68
69 /**
70 * Method to get the group's docs. Requires authentication and user_groups or friends_groups permission for non-public groups.
71 *
72 * @param string $group The group id.
73 * @param integer $limit The number of objects per page.
74 * @param integer $offset The object's number on the page.
75 * @param string $until A unix timestamp or any date accepted by strtotime.
76 * @param string $since A unix timestamp or any date accepted by strtotime.
77 *
78 * @return mixed The decoded JSON response or false if the client is not authenticated.
79 *
80 * @since 13.1
81 */
82 public function getDocs($group, $limit = 0, $offset = 0, $until = null, $since = null)
83 {
84 return $this->getConnection($group, 'docs', '', $limit, $offset, $until, $since);
85 }
86
87 /**
88 * Method to get the groups's picture. Requires authentication and user_groups or friends_groups permission.
89 *
90 * @param string $group The group id.
91 * @param string $type To request a different photo use square | small | normal | large.
92 *
93 * @return string The URL to the group's picture.
94 *
95 * @since 13.1
96 */
97 public function getPicture($group, $type = null)
98 {
99 if ($type)
100 {
101 $type = '?type=' . $type;
102 }
103
104 return $this->getConnection($group, 'picture', $type);
105 }
106
107 /**
108 * Method to post a link on group's wall. Requires authentication and publish_stream permission.
109 *
110 * @param string $group The group id.
111 * @param string $link Link URL.
112 * @param strin $message Link message.
113 *
114 * @return mixed The decoded JSON response or false if the client is not authenticated.
115 *
116 * @since 13.1
117 */
118 public function createLink($group, $link, $message = null)
119 {
120 // Set POST request parameters.
121 $data = array();
122 $data['link'] = $link;
123
124 if ($message)
125 {
126 $data['message'] = $message;
127 }
128
129 return $this->createConnection($group, 'feed', $data);
130 }
131
132 /**
133 * Method to delete a link. Requires authentication.
134 *
135 * @param mixed $link The Link ID.
136 *
137 * @return boolean Returns true if successful, and false otherwise.
138 *
139 * @since 13.1
140 */
141 public function deleteLink($link)
142 {
143 return $this->deleteConnection($link);
144 }
145
146 /**
147 * Method to post on group's wall. Message or link parameter is required. Requires authentication and publish_stream permission.
148 *
149 * @param string $group The group id.
150 * @param string $message Post message.
151 * @param string $link Post URL.
152 * @param string $picture Post thumbnail image (can only be used if link is specified)
153 * @param string $name Post name (can only be used if link is specified).
154 * @param string $caption Post caption (can only be used if link is specified).
155 * @param string $description Post description (can only be used if link is specified).
156 * @param array $actions Post actions array of objects containing name and link.
157 *
158 * @return mixed The decoded JSON response or false if the client is not authenticated.
159 *
160 * @since 13.1
161 */
162 public function createPost($group, $message = null, $link = null, $picture = null, $name = null, $caption = null,
163 $description = null, $actions = null)
164 {
165 // Set POST request parameters.
166 if ($message)
167 {
168 $data['message'] = $message;
169 }
170
171 if ($link)
172 {
173 $data['link'] = $link;
174 }
175
176 if ($name)
177 {
178 $data['name'] = $name;
179 }
180
181 if ($caption)
182 {
183 $data['caption'] = $caption;
184 }
185
186 if ($description)
187 {
188 $data['description'] = $description;
189 }
190
191 if ($actions)
192 {
193 $data['actions'] = $actions;
194 }
195
196 if ($picture)
197 {
198 $data['picture'] = $picture;
199 }
200
201 return $this->createConnection($group, 'feed', $data);
202 }
203
204 /**
205 * Method to delete a post. Note: you can only delete the post if it was created by the current user. Requires authentication.
206 *
207 * @param string $post The Post ID.
208 *
209 * @return boolean Returns true if successful, and false otherwise.
210 *
211 * @since 13.1
212 */
213 public function deletePost($post)
214 {
215 return $this->deleteConnection($post);
216 }
217
218 /**
219 * Method to post a status message on behalf of the user on the group's wall. Requires authentication and publish_stream permission.
220 *
221 * @param string $group The group id.
222 * @param string $message Status message content.
223 *
224 * @return mixed The decoded JSON response or false if the client is not authenticated.
225 *
226 * @since 13.1
227 */
228 public function createStatus($group, $message)
229 {
230 // Set POST request parameters.
231 $data = array();
232 $data['message'] = $message;
233
234 return $this->createConnection($group, 'feed', $data);
235 }
236
237 /**
238 * Method to delete a status. Note: you can only delete the status if it was created by the current user. Requires authentication.
239 *
240 * @param string $status The Status ID.
241 *
242 * @return boolean Returns true if successful, and false otherwise.
243 *
244 * @since 13.1
245 */
246 public function deleteStatus($status)
247 {
248 return $this->deleteConnection($status);
249 }
250 }
251