PageRenderTime 31ms CodeModel.GetById 19ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/libraries/joomla/facebook/group.php

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