Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\calendar\api;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -38,19 +38,76 @@ class _events extends \IPS\Content\Api\ItemController
|
||||
* @apiparam int locked If 1, only events which are locked are returned, if 0 only unlocked
|
||||
* @apiparam int hidden If 1, only events which are hidden are returned, if 0 only not hidden
|
||||
* @apiparam int featured If 1, only events which are featured are returned, if 0 only not featured
|
||||
* @apiparam string sortBy What to sort by. Can be 'date' for creation date, 'title' or leave unspecified for ID
|
||||
* @apiparam string rangeStart YYYY-MM-DD. Only events occurring on or after this date will be returned.
|
||||
* @apiparam string rangeEnd YYYY-MM-DD. Only events occurring on or before this date will be returned.
|
||||
* @apiparam string sortBy What to sort by. Can be 'date' for creation date, 'start' for event start date, 'end' for event end date, 'title' or leave unspecified for ID
|
||||
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
|
||||
* @apiparam int page Page number
|
||||
* @apiparam int perPage Number of results per page - defaults to 25
|
||||
* @return \IPS\Api\PaginatedResponse<IPS\calendar\Event>
|
||||
* @throws 1L296/M INVALID_DATE The rangeStart and/or rangeEnd value was not a valid date in YYYY-MM-DD format
|
||||
*/
|
||||
public function GETindex()
|
||||
{
|
||||
/* Where clause */
|
||||
$where = array();
|
||||
|
||||
/* Are we limiting to a date range? */
|
||||
if( isset( \IPS\Request::i()->rangeStart ) OR isset( \IPS\Request::i()->rangeEnd ) )
|
||||
{
|
||||
$startDate = $endDate = NULL;
|
||||
|
||||
foreach( array( 'start', 'end' ) as $limiter )
|
||||
{
|
||||
$inputKey = 'range' . mb_ucfirst( $limiter );
|
||||
|
||||
if( \IPS\Request::i()->$inputKey )
|
||||
{
|
||||
$datePieces = explode( '-', \IPS\Request::i()->$inputKey );
|
||||
|
||||
/* Let's make sure the date is valid... */
|
||||
if( @checkdate( $datePieces[1], $datePieces[2], $datePieces[0] ) )
|
||||
{
|
||||
if( $limiter === 'start' )
|
||||
{
|
||||
$startDate = \IPS\calendar\Date::getDate( $datePieces[0], $datePieces[1], $datePieces[2] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$endDate = \IPS\calendar\Date::getDate( $datePieces[0], $datePieces[1], $datePieces[2], 23, 59, 59 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_DATE', '1L296/M', 403 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the events within this range */
|
||||
$events = \IPS\calendar\Event::retrieveEvents( $startDate, $endDate, NULL, NULL, FALSE, new \IPS\Member, NULL, TRUE );
|
||||
|
||||
if( !\count( $events ) )
|
||||
{
|
||||
/* Force no results */
|
||||
$where[] = array( '0=1' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( 'event_id IN(' . implode( ',', array_map( function( $event ) { return $event->id; }, $events ) ) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
/* Sort by */
|
||||
$sortBy = NULL;
|
||||
|
||||
if ( isset( \IPS\Request::i()->sortBy ) and \in_array( \IPS\Request::i()->sortBy, array( 'start', 'end' ) ) )
|
||||
{
|
||||
$sortBy = 'event_' . \IPS\Request::i()->sortBy . '_date';
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return $this->_list( $where, 'calendars' );
|
||||
return $this->_list( $where, 'calendars', FALSE, $sortBy );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +134,7 @@ class _events extends \IPS\Content\Api\ItemController
|
||||
* POST /calendar/events
|
||||
* Create an event
|
||||
*
|
||||
* @note For requests using an OAuth Access Token for a particular member, any parameters the user doesn't have permission to use are ignored (for example, locked will only be honoured if the authentictaed user has permission to lock events).
|
||||
* @note For requests using an OAuth Access Token for a particular member, any parameters the user doesn't have permission to use are ignored (for example, locked will only be honoured if the authenticated user has permission to lock events).
|
||||
* @reqapiparam int calendar The ID number of the calendar the event should be created in
|
||||
* @apiparam int author The ID number of the member creating the event (0 for guest). Required for requests made using an API Key or the Client Credentials Grant Type. For requests using an OAuth Access Token for a particular member, that member will always be the author
|
||||
* @reqapiparam string title The event title
|
||||
@@ -180,7 +237,7 @@ class _events extends \IPS\Content\Api\ItemController
|
||||
* POST /calendar/events/{id}
|
||||
* Edit an event
|
||||
*
|
||||
* @note For requests using an OAuth Access Token for a particular member, any parameters the user doesn't have permission to use are ignored (for example, locked will only be honoured if the authentictaed user has permission to lock topics).
|
||||
* @note For requests using an OAuth Access Token for a particular member, any parameters the user doesn't have permission to use are ignored (for example, locked will only be honoured if the authenticated user has permission to lock topics).
|
||||
* @reqapiparam int calendar The ID number of the calendar the event should be created in
|
||||
* @reqapiparam int author The ID number of the member creating the event (0 for guest). Ignored for requests using an OAuth Access Token for a particular member.
|
||||
* @reqapiparam string title The event title
|
||||
@@ -193,11 +250,11 @@ class _events extends \IPS\Content\Api\ItemController
|
||||
* @apiparam \IPS\GeoLocation location The location where the event is taking place
|
||||
* @apiparam string prefix Prefix tag
|
||||
* @apiparam string tags Comma-separated list of tags (do not include prefix)
|
||||
* @apiparam datetime date The date/time that should be used for the event/post post date. If not provided, will use the current date/time. Ignored for requests using an OAuth Access Token for a particular member.
|
||||
* @apiparam string ip_address The IP address that should be stored for the event/post. If not provided, will use the IP address from the API request. Ignored for requests using an OAuth Access Token for a particular member.
|
||||
* @apiparam int locked 1/0 indicating if the event should be locked
|
||||
* @apiparam int hidden 0 = unhidden; 1 = hidden, pending moderator approval; -1 = hidden (as if hidden by a moderator)
|
||||
* @apiparam int featured 1/0 indicating if the event should be featured
|
||||
* @param int $id ID Number
|
||||
* @throws 1L296/I INVALID_ID The event ID is invalid or the authorized user does not have permission to view it
|
||||
* @throws 1L296/D NO_CALENDAR The calendar ID does not exist or the authorized user does not have permission to post in it
|
||||
* @throws 1L296/E NO_AUTHOR The author ID does not exist
|
||||
@@ -397,7 +454,7 @@ class _events extends \IPS\Content\Api\ItemController
|
||||
*/
|
||||
public function PUTitem_rsvps( $id, $memberId )
|
||||
{
|
||||
if ( !isset( \IPS\Request::i()->response ) or !in_array( (int) \IPS\Request::i()->response, range( 0, 2 ) ) )
|
||||
if ( !isset( \IPS\Request::i()->response ) or !\in_array( (int) \IPS\Request::i()->response, range( 0, 2 ) ) )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_RESPONSE', '1L296/L', 400 );
|
||||
}
|
||||
@@ -458,7 +515,7 @@ class _events extends \IPS\Content\Api\ItemController
|
||||
throw new \IPS\Api\Exception( 'INVALID_MEMBER', '2L296/K', 404 );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->delete( 'calendar_event_rsvp', array( 'rsvp_event_id=? AND rsvp_member_id=?', intval( $id ), intval( $memberId ) ) );
|
||||
\IPS\Db::i()->delete( 'calendar_event_rsvp', array( 'rsvp_event_id=? AND rsvp_member_id=?', \intval( $id ), \intval( $memberId ) ) );
|
||||
return new \IPS\Api\Response( 200, NULL );
|
||||
}
|
||||
|
||||
@@ -502,7 +559,7 @@ class _events extends \IPS\Content\Api\ItemController
|
||||
/* RSVP */
|
||||
if ( isset( \IPS\Request::i()->rsvp ) and ( !$this->member or $item->container()->can( 'askrsvp', $this->member ) ) )
|
||||
{
|
||||
$item->rsvp = intval( \IPS\Request::i()->rsvp );
|
||||
$item->rsvp = \intval( \IPS\Request::i()->rsvp );
|
||||
if ( $item->rsvp and isset( \IPS\Request::i()->rsvpLimit ) and \IPS\Request::i()->rsvpLimit )
|
||||
{
|
||||
$item->rsvp_limit = \IPS\Request::i()->rsvpLimit;
|
||||
|
||||
Reference in new issue
Block a user