/libraries/joomla/facebook/group.php

https://bitbucket.org/pastor399/newcastleunifc · PHP · 254 lines · 90 code · 25 blank · 139 comment · 9 complexity · 5f4c8c9e28e1f0055df7da93c5aaf0e4 MD5 · raw file

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