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 User class for the Joomla Platform.
14 *
15 * @link http://developers.facebook.com/docs/reference/api/event/
16 * @since 13.1
17 * @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
18 */
19 class JFacebookEvent extends JFacebookObject
20 {
21 /**
22 * Method to get information about an event visible to the current user. Requires authentication.
23 *
24 * @param string $event The event 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 getEvent($event)
31 {
32 return $this->get($event);
33 }
34
35 /**
36 * Method to get the event's wall. Requires authentication.
37 *
38 * @param string $event The event 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($event, $limit = 0, $offset = 0, $until = null, $since = null)
49 {
50 return $this->getConnection($event, 'feed', '', $limit, $offset, $until, $since);
51 }
52
53 /**
54 * Method to post a link on event's feed which the current_user is or maybe attending. Requires authentication and publish_stream permission.
55 *
56 * @param string $event The event id.
57 * @param string $link Link URL.
58 * @param string $message Link message.
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 createLink($event, $link, $message = null)
65 {
66 // Set POST request parameters.
67 $data = array();
68 $data['link'] = $link;
69 $data['message'] = $message;
70
71 return $this->createConnection($event, 'feed', $data);
72 }
73
74 /**
75 * Method to delete a link. Requires authentication and publish_stream permission.
76 *
77 * @param mixed $link The Link ID.
78 *
79 * @return boolean Returns true if successful, and false otherwise.
80 *
81 * @since 13.1
82 */
83 public function deleteLink($link)
84 {
85 return $this->deleteConnection($link);
86 }
87
88 /**
89 * Method to post on event's wall. Message or link parameter is required. Requires authentication and publish_stream permission.
90 *
91 * @param string $event The event id.
92 * @param string $message Post message.
93 * @param string $link Post URL.
94 * @param string $picture Post thumbnail image (can only be used if link is specified)
95 * @param string $name Post name (can only be used if link is specified).
96 * @param string $caption Post caption (can only be used if link is specified).
97 * @param string $description Post description (can only be used if link is specified).
98 * @param array $actions Post actions array of objects containing name and link.
99 *
100 * @return mixed The decoded JSON response or false if the client is not authenticated.
101 *
102 * @since 13.1
103 */
104 public function createPost($event, $message = null, $link = null, $picture = null, $name = null, $caption = null,
105 $description = null, $actions = null)
106 {
107 // Set POST request parameters.
108 $data = array();
109 $data['message'] = $message;
110 $data['link'] = $link;
111 $data['name'] = $name;
112 $data['caption'] = $caption;
113 $data['description'] = $description;
114 $data['actions'] = $actions;
115 $data['picture'] = $picture;
116
117 return $this->createConnection($event, 'feed', $data);
118 }
119
120 /**
121 * Method to delete a post. Note: you can only delete the post if it was created by the current user.
122 * Requires authentication and publish_stream permission.
123 *
124 * @param string $post The Post ID.
125 *
126 * @return boolean Returns true if successful, and false otherwise.
127 *
128 * @since 13.1
129 */
130 public function deletePost($post)
131 {
132 return $this->deleteConnection($post);
133 }
134
135 /**
136 * Method to post a status message on behalf of the user on the event's wall. Requires authentication and publish_stream permission.
137 *
138 * @param string $event The event id.
139 * @param string $message Status message content.
140 *
141 * @return mixed The decoded JSON response or false if the client is not authenticated.
142 *
143 * @since 13.1
144 */
145 public function createStatus($event, $message)
146 {
147 // Set POST request parameters.
148 $data = array();
149 $data['message'] = $message;
150
151 return $this->createConnection($event, 'feed', $data);
152 }
153
154 /**
155 * Method to delete a status. Note: you can only delete the post if it was created by the current user.
156 * Requires authentication and publish_stream permission.
157 *
158 * @param string $status The Status ID.
159 *
160 * @return boolean Returns true if successful, and false otherwise.
161 *
162 * @since 13.1
163 */
164 public function deleteStatus($status)
165 {
166 return $this->deleteConnection($status);
167 }
168
169 /**
170 * Method to get the list of invitees for the event. Requires authentication and user_events or friends_events permission.
171 *
172 * @param string $event The event id.
173 * @param integer $limit The number of objects per page.
174 * @param integer $offset The object's number on the page.
175 *
176 * @return mixed The decoded JSON response or false if the client is not authenticated.
177 *
178 * @since 13.1
179 */
180 public function getInvited($event, $limit = 0, $offset = 0)
181 {
182 return $this->getConnection($event, 'invited', '', $limit, $offset);
183 }
184
185 /**
186 * Method to check if a user is invited to the event. Requires authentication and user_events or friends_events permission.
187 *
188 * @param string $event The event id.
189 * @param mixed $user Either an integer containing the user ID or a string containing the username.
190 *
191 * @return array The decoded JSON response or an empty array if the user is not invited.
192 *
193 * @since 13.1
194 */
195 public function isInvited($event, $user)
196 {
197 return $this->getConnection($event, 'invited/' . $user);
198 }
199
200 /**
201 * Method to invite users to the event. Requires authentication and create_event permission.
202 *
203 * @param string $event The event id.
204 * @param string $users Comma separated list of user ids.
205 *
206 * @return boolean Returns true if successful, and false otherwise.
207 *
208 * @since 13.1
209 */
210 public function createInvite($event, $users)
211 {
212 // Set POST request parameters.
213 $data = array();
214 $data['users'] = $users;
215
216 return $this->createConnection($event, 'invited', $data);
217 }
218
219 /**
220 * Method to delete an invitation. Note: you can only delete the invite if the current user is the event admin.
221 * Requires authentication and rsvp_event permission.
222 *
223 * @param string $event The event id.
224 * @param string $user The user id.
225 *
226 * @return boolean Returns true if successful, and false otherwise.
227 *
228 * @since 13.1
229 */
230 public function deleteInvite($event, $user)
231 {
232 return $this->deleteConnection($event, 'invited/' . $user);
233 }
234
235 /**
236 * Method to get the list of attending users. Requires authentication and user_events or friends_events permission.
237 *
238 * @param string $event The event id.
239 * @param integer $limit The number of objects per page.
240 * @param integer $offset The object's number on the page.
241 *
242 * @return mixed The decoded JSON response or false if the client is not authenticated.
243 *
244 * @since 13.1
245 */
246 public function getAttending($event, $limit = 0, $offset = 0)
247 {
248 return $this->getConnection($event, 'attending', '', $limit, $offset);
249 }
250
251 /**
252 * Method to check if a user is attending an event. Requires authentication and user_events or friends_events permission.
253 *
254 * @param string $event The event id.
255 * @param mixed $user Either an integer containing the user ID or a string containing the username.
256 *
257 * @return array The decoded JSON response or an empty array if the user is not invited.
258 *
259 * @since 13.1
260 */
261 public function isAttending($event, $user)
262 {
263 return $this->getConnection($event, 'attending/' . $user);
264 }
265
266 /**
267 * Method to set the current user as attending. Requires authentication and rsvp_event permission.
268 *
269 * @param string $event The event id.
270 *
271 * @return boolean Returns true if successful, and false otherwise.
272 *
273 * @since 13.1
274 */
275 public function createAttending($event)
276 {
277 return $this->createConnection($event, 'attending');
278 }
279
280 /**
281 * Method to get the list of maybe attending users. Requires authentication and user_events or friends_events permission.
282 *
283 * @param string $event The event id.
284 * @param integer $limit The number of objects per page.
285 * @param integer $offset The object's number on the page.
286 *
287 * @return mixed The decoded JSON response or false if the client is not authenticated.
288 *
289 * @since 13.1
290 */
291 public function getMaybe($event, $limit = 0, $offset = 0)
292 {
293 return $this->getConnection($event, 'maybe', '', $limit, $offset);
294 }
295
296 /**
297 * Method to check if a user is maybe attending an event. Requires authentication and user_events or friends_events permission.
298 *
299 * @param string $event The event id.
300 * @param mixed $user Either an integer containing the user ID or a string containing the username.
301 *
302 * @return array The decoded JSON response or an empty array if the user is not invited.
303 *
304 * @since 13.1
305 */
306 public function isMaybe($event, $user)
307 {
308 return $this->getConnection($event, 'maybe/' . $user);
309 }
310
311 /**
312 * Method to set the current user as maybe attending. Requires authentication and rscp_event permission.
313 *
314 * @param string $event The event id.
315 *
316 * @return boolean Returns true if successful, and false otherwise.
317 *
318 * @since 13.1
319 */
320 public function createMaybe($event)
321 {
322 return $this->createConnection($event, 'maybe');
323 }
324
325 /**
326 * Method to get the list of users which declined the event. Requires authentication and user_events or friends_events permission.
327 *
328 * @param string $event The event id.
329 * @param integer $limit The number of objects per page.
330 * @param integer $offset The object's number on the page.
331 *
332 * @return mixed The decoded JSON response or false if the client is not authenticated.
333 *
334 * @since 13.1
335 */
336 public function getDeclined($event, $limit = 0, $offset = 0)
337 {
338 return $this->getConnection($event, 'declined', '', $limit, $offset);
339 }
340
341 /**
342 * Method to check if a user responded 'no' to the event. Requires authentication and user_events or friends_events permission.
343 *
344 * @param string $event The event id.
345 * @param mixed $user Either an integer containing the user ID or a string containing the username.
346 *
347 * @return array The decoded JSON response or an empty array if the user is not invited.
348 *
349 * @since 13.1
350 */
351 public function isDeclined($event, $user)
352 {
353 return $this->getConnection($event, 'declined/' . $user);
354 }
355
356 /**
357 * Method to set the current user as declined. Requires authentication and rscp_event permission.
358 *
359 * @param string $event The event id.
360 *
361 * @return boolean Returns true if successful, and false otherwise.
362 *
363 * @since 13.1
364 */
365 public function createDeclined($event)
366 {
367 return $this->createConnection($event, 'declined');
368 }
369
370 /**
371 * Method to get the list of users which have not replied to the event. Requires authentication and user_events or friends_events permission.
372 *
373 * @param string $event The event id.
374 * @param integer $limit The number of objects per page.
375 * @param integer $offset The object's number on the page.
376 *
377 * @return mixed The decoded JSON response or false if the client is not authenticated.
378 *
379 * @since 13.1
380 */
381 public function getNoreply($event, $limit = 0, $offset = 0)
382 {
383 return $this->getConnection($event, 'noreply', '', $limit, $offset);
384 }
385
386 /**
387 * Method to check if a user has not replied to the event. Requires authentication and user_events or friends_events permission.
388 *
389 * @param string $event The event id.
390 * @param mixed $user Either an integer containing the user ID or a string containing the username.
391 *
392 * @return array The decoded JSON response or an empty array if the user is not invited.
393 *
394 * @since 13.1
395 */
396 public function isNoreply($event, $user)
397 {
398 return $this->getConnection($event, 'noreply/' . $user);
399 }
400
401 /**
402 * Method to get the event's profile picture. Requires authentication and user_events or friends_events permission.
403 *
404 * @param string $event The event id.
405 * @param boolean $redirect If false this will return the URL of the picture without a 302 redirect.
406 * @param string $type To request a different photo use square | small | normal | large.
407 *
408 * @return string The URL to the event's profile picture.
409 *
410 * @since 13.1
411 */
412 public function getPicture($event, $redirect = true, $type = null)
413 {
414 $extra_fields = '';
415
416 if ($redirect == false)
417 {
418 $extra_fields = '?redirect=false';
419 }
420
421 if ($type)
422 {
423 $extra_fields .= (strpos($extra_fields, '?') === false) ? '?type=' . $type : '&type=' . $type;
424 }
425
426 return $this->getConnection($event, 'picture', $extra_fields);
427 }
428
429 /**
430 * Method to get photos published on event's wall. Requires authentication.
431 *
432 * @param string $event The event id.
433 * @param integer $limit The number of objects per page.
434 * @param integer $offset The object's number on the page.
435 * @param string $until A unix timestamp or any date accepted by strtotime.
436 * @param string $since A unix timestamp or any date accepted by strtotime.
437 *
438 * @return mixed The decoded JSON response or false if the client is not authenticated.
439 *
440 * @since 13.1
441 */
442 public function getPhotos($event, $limit = 0, $offset = 0, $until = null, $since = null)
443 {
444 return $this->getConnection($event, 'photos', '', $limit, $offset, $until, $since);
445 }
446
447 /**
448 * Method to post a photo on event's wall. Requires authentication and publish_stream permission.
449 *
450 * @param string $event The event id.
451 * @param string $source Path to photo.
452 * @param string $message Photo description.
453 *
454 * @return mixed The decoded JSON response or false if the client is not authenticated.
455 *
456 * @since 13.1
457 */
458 public function createPhoto($event, $source, $message = null)
459 {
460 // Set POST request parameters.
461 $data = array();
462 $data[basename($source)] = '@' . realpath($source);
463
464 if ($message)
465 {
466 $data['message'] = $message;
467 }
468
469 return $this->createConnection($event, 'photos', $data, array('Content-Type' => 'multipart/form-data'));
470 }
471
472 /**
473 * Method to get videos published on event's wall. Requires authentication.
474 *
475 * @param string $event The event id.
476 * @param integer $limit The number of objects per page.
477 * @param integer $offset The object's number on the page.
478 * @param string $until A unix timestamp or any date accepted by strtotime.
479 * @param string $since A unix timestamp or any date accepted by strtotime.
480 *
481 * @return mixed The decoded JSON response or false if the client is not authenticated.
482 *
483 * @since 13.1
484 */
485 public function getVideos($event, $limit = 0, $offset = 0, $until = null, $since = null)
486 {
487 return $this->getConnection($event, 'videos', '', $limit, $offset, $until, $since);
488 }
489
490 /**
491 * Method to post a video on event's wall. Requires authentication and publish_stream permission.
492 *
493 * @param string $event The event id.
494 * @param string $source Path to photo.
495 * @param string $title Video title.
496 * @param string $description Video description.
497 *
498 * @return mixed The decoded JSON response or false if the client is not authenticated.
499 *
500 * @since 13.1
501 */
502 public function createVideo($event, $source, $title = null, $description = null)
503 {
504 // Set POST request parameters.
505 $data = array();
506 $data[basename($source)] = '@' . realpath($source);
507
508 if ($title)
509 {
510 $data['title'] = $title;
511 }
512
513 if ($description)
514 {
515 $data['description'] = $description;
516 }
517
518 return $this->createConnection($event, 'videos', $data, array('Content-Type' => 'multipart/form-data'));
519 }
520 }
521