Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -0,0 +1,77 @@
<?php
/**
* @brief GraphQL: Image query
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @since 23 Feb 2019
* @version SVN_VERSION_NUMBER
*/
namespace IPS\gallery\api\GraphQL\Queries;
use GraphQL\Type\Definition\ObjectType;
use IPS\Api\GraphQL\TypeRegistry;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Image query for GraphQL API
*/
class _Image
{
/*
* @brief Query description
*/
public static $description = "Returns a gallery image";
/*
* Query arguments
*/
public function args()
{
return array(
'id' => TypeRegistry::nonNull( TypeRegistry::id() )
);
}
/**
* Return the query return type
*/
public function type()
{
return \IPS\gallery\api\GraphQL\TypeRegistry::image();
}
/**
* Resolves this query
*
* @param mixed Value passed into this resolver
* @param array Arguments
* @param array Context values
* @return \IPS\gallery\Image
*/
public function resolve($val, $args, $context, $info)
{
try
{
$topic = \IPS\gallery\Image::loadAndCheckPerms( $args['id'] );
}
catch ( \OutOfRangeException $e )
{
throw new \IPS\Api\GraphQL\SafeException( 'NO_IMAGE', '1F294/2', 400 );
}
if( !$topic->can('read') )
{
throw new \IPS\Api\GraphQL\SafeException( 'INVALID_ID', '2F294/9', 403 );
}
return $topic;
}
}
@@ -0,0 +1,39 @@
<?php
/**
* @brief GraphQL: Gallery queries
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @since 23 Feb 2019
* @version SVN_VERSION_NUMBER
*/
namespace IPS\gallery\api\GraphQL;
use GraphQL\Type\Definition\ObjectType;
use IPS\Api\GraphQL\Types;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Forums queries for GraphQL API
*/
abstract class _Query
{
/**
* Get the supported query types in this app
*
* @return array
*/
public static function queries()
{
return [
'image' => new \IPS\gallery\api\GraphQL\Queries\Image(),
];
}
}
@@ -0,0 +1,83 @@
<?php
/**
* @brief GraphQL: Types registry
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @since 23 Feb 2019
* @version SVN_VERSION_NUMBER
*/
namespace IPS\gallery\api\GraphQL;
use GraphQL\Type\Definition\ObjectType;
use IPS\Api\GraphQL\Types;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Gallery type registry. GraphQL requires exactly one instance of each type,
* so we'll generate singletons here.
* @todo automate this somehow?
*/
class _TypeRegistry
{
protected static $album;
protected static $albumComment;
protected static $albumItem;
protected static $image;
protected static $imageComment;
/**
* Constructor
*/
public function __construct()
{
// Defined to suppress static warnings
}
/**
* @return ImageType
*/
public static function album()
{
return self::$album ?: (self::$album = new \IPS\gallery\api\GraphQL\Types\AlbumType());
}
/**
* @return AlbumCommentType
*/
public static function albumComment()
{
return self::$albumComment ?: (self::$albumComment = new \IPS\gallery\api\GraphQL\Types\AlbumCommentType());
}
/**
* @return AlbumCommentType
*/
public static function albumItem()
{
return self::$albumItem ?: (self::$albumItem = new \IPS\gallery\api\GraphQL\Types\AlbumItemType());
}
/**
* @return ImageType
*/
public static function image()
{
return self::$image ?: (self::$image = new \IPS\gallery\api\GraphQL\Types\ImageType());
}
/**
* @return ImageCommentType
*/
public static function imageComment()
{
return self::$imageComment ?: (self::$imageComment = new \IPS\gallery\api\GraphQL\Types\ImageCommentType());
}
}
@@ -0,0 +1,63 @@
<?php
/**
* @brief GraphQL: AlbumComment Type
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @since 23 Feb 2019
* @version SVN_VERSION_NUMBER
*/
namespace IPS\gallery\api\GraphQL\Types;
use GraphQL\Type\Definition\ObjectType;
use IPS\Api\GraphQL\TypeRegistry;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* AlbumCommentType for GraphQL API
*/
class _AlbumCommentType extends \IPS\Content\Api\GraphQL\CommentType
{
/*
* @brief The item classname we use for this type
*/
protected static $commentClass = '\IPS\gallery\Album\Comment';
/*
* @brief GraphQL type name
*/
protected static $typeName = 'gallery_AlbumComment';
/*
* @brief GraphQL type description
*/
protected static $typeDescription = 'An album comment';
/**
* Get the item type that goes with this item type
*
* @return ObjectType
*/
public static function getItemType()
{
return \IPS\gallery\api\GraphQL\TypeRegistry::album();
}
/**
* Return the fields available in this type
*
* @return array
*/
public function fields()
{
$defaultFields = parent::fields();
return $defaultFields;
}
}
@@ -0,0 +1,75 @@
<?php
/**
* @brief GraphQL: Album Item Type
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @since 24 Feb 2019
* @version SVN_VERSION_NUMBER
*/
namespace IPS\gallery\api\GraphQL\Types;
use GraphQL\Type\Definition\ObjectType;
use IPS\Api\GraphQL\TypeRegistry;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* AlbumItemType for GraphQL API
*/
class _AlbumItemType extends \IPS\Content\Api\GraphQL\ItemType
{
/*
* @brief The item classname we use for this type
*/
protected static $itemClass = '\IPS\gallery\Album\Item';
/*
* @brief GraphQL type name
*/
protected static $typeName = 'gallery_AlbumItem';
/*
* @brief GraphQL type description
*/
protected static $typeDescription = 'An album';
/*
* @brief Follow data passed in to FollowType resolver
*/
protected static $followData = array('app' => 'gallery', 'area' => 'album');
/**
* Return the fields available in this type
*
* @return array
*/
public function fields()
{
// Extend our fields with image-specific stuff
$defaultFields = parent::fields();
// Remove duplicated fields
unset( $defaultFields['views'] );
unset( $defaultFields['poll'] );
unset( $defaultFields['hasPoll'] );
return $defaultFields;
}
/**
* Get the comment type that goes with this item type
*
* @return ObjectType
*/
protected static function getCommentType()
{
return \IPS\gallery\api\GraphQL\TypeRegistry::albumComment();
}
}
@@ -0,0 +1,98 @@
<?php
/**
* @brief GraphQL: Album Type
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @since 24 Feb 2019
* @version SVN_VERSION_NUMBER
*/
namespace IPS\gallery\api\GraphQL\Types;
use GraphQL\Type\Definition\ObjectType;
use IPS\Api\GraphQL\TypeRegistry;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* AlbumType for GraphQL API
*/
class _AlbumType extends \IPS\Node\Api\GraphQL\NodeType
{
/*
* @brief The item classname we use for this type
*/
protected static $nodeClass = '\IPS\gallery\Album';
/*
* @brief GraphQL type name
*/
protected static $typeName = 'gallery_Album';
/*
* @brief GraphQL type description
*/
protected static $typeDescription = 'An album';
/*
* @brief Follow data passed in to FollowType resolver
*/
protected static $followData = array('app' => 'gallery', 'area' => 'album');
/**
* Return the fields available in this type
*
* @return array
*/
public function fields()
{
$defaultFields = parent::fields();
$albumFields = array(
'owner' => [
'type' => \IPS\core\api\GraphQL\TypeRegistry::member(),
'resolve' => function ($album) {
return $album->owner();
}
],
'lastImage' => [
'type' => \IPS\gallery\api\GraphQL\TypeRegistry::image(),
'resolve' => function ($album) {
return $album->lastImage();
}
],
'latestImages' => [
'type' => TypeRegistry::listOf( \IPS\gallery\api\GraphQL\TypeRegistry::image() ),
'resolve' => function ($album) {
return $album->_latestImages;
}
],
'item' => [
'type' => \IPS\gallery\api\GraphQL\TypeRegistry::albumItem(),
'resolve' => function ($album) {
return $album->asItem();
}
]
);
// Remove unnecessary fields
unset( $defaultFields['children'] );
return array_merge( $defaultFields, $albumFields );
}
/**
* Get the item type that goes with this node type
*
* @return ObjectType
*/
public static function getItemType()
{
return \IPS\gallery\api\GraphQL\TypeRegistry::image();
}
}
@@ -0,0 +1,63 @@
<?php
/**
* @brief GraphQL: ImageComment Type
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @since 23 Feb 2019
* @version SVN_VERSION_NUMBER
*/
namespace IPS\gallery\api\GraphQL\Types;
use GraphQL\Type\Definition\ObjectType;
use IPS\Api\GraphQL\TypeRegistry;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* ImageCommentType for GraphQL API
*/
class _ImageCommentType extends \IPS\Content\Api\GraphQL\CommentType
{
/*
* @brief The item classname we use for this type
*/
protected static $commentClass = '\IPS\gallery\Image\Comment';
/*
* @brief GraphQL type name
*/
protected static $typeName = 'gallery_ImageComment';
/*
* @brief GraphQL type description
*/
protected static $typeDescription = 'An image comment';
/**
* Get the item type that goes with this item type
*
* @return ObjectType
*/
public static function getItemType()
{
return \IPS\gallery\api\GraphQL\TypeRegistry::image();
}
/**
* Return the fields available in this type
*
* @return array
*/
public function fields()
{
$defaultFields = parent::fields();
return $defaultFields;
}
}
@@ -0,0 +1,211 @@
<?php
/**
* @brief GraphQL: Image Type
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @since 23 Feb 2019
* @version SVN_VERSION_NUMBER
*/
namespace IPS\gallery\api\GraphQL\Types;
use GraphQL\Type\Definition\ObjectType;
use IPS\Api\GraphQL\TypeRegistry;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* ImageType for GraphQL API
*/
class _ImageType extends \IPS\Content\Api\GraphQL\ItemType
{
/*
* @brief The item classname we use for this type
*/
protected static $itemClass = '\IPS\gallery\Image';
/*
* @brief GraphQL type name
*/
protected static $typeName = 'gallery_Image';
/*
* @brief GraphQL type description
*/
protected static $typeDescription = 'An image';
/*
* @brief Follow data passed in to FollowType resolver
*/
protected static $followData = array('app' => 'gallery', 'area' => 'image');
/**
* Return the fields available in this type
*
* @return array
*/
public function fields()
{
// Extend our fields with image-specific stuff
$defaultFields = parent::fields();
$imageFields = array(
'caption' => [
'type' => TypeRegistry::string(),
'resolve' => function ($image) {
return $image->caption;
}
],
'hasAlbum' => [
'type' => TypeRegistry::boolean(),
'resolve' => function ($image) {
return (bool) $image->album_id;
}
],
'album' => [
'type' => \IPS\gallery\api\GraphQL\TypeRegistry::album(),
'resolve' => function ($image) {
if( $image->album_id )
{
return \IPS\gallery\Album::load( $image->album_id );
}
return NULL;
}
],
'nextImage' => [
'type' => \IPS\gallery\api\GraphQL\TypeRegistry::image(),
'resolve' => function ($image) {
return $image->nextItem();
}
],
'prevImage' => [
'type' => \IPS\gallery\api\GraphQL\TypeRegistry::image(),
'resolve' => function ($image) {
return $image->prevItem();
}
],
'credit' => [
'type' => TypeRegistry::string(),
'resolve' => function ($image) {
return $image->credit_info;
}
],
'copyright' => [
'type' => TypeRegistry::string(),
'resolve' => function ($image) {
return $image->copyright;
}
],
'isMedia' => [
'type' => TypeRegistry::boolean(),
'resolve' => function ($image) {
return (bool) $image->media;
}
],
'maskedFileName' => [
'type' => TypeRegistry::string(),
'resolve' => function ($image) {
return (string) \IPS\File::get( 'gallery_Images', $image->masked_file_name )->url;
}
],
'originalFileName' => [
'type' => TypeRegistry::string(),
'resolve' => function ($image) {
return (string) \IPS\File::get( 'gallery_Images', $image->original_file_name )->url;
}
],
'smallFileName' => [
'type' => TypeRegistry::string(),
'resolve' => function ($image) {
return (string) \IPS\File::get( 'gallery_Images', $image->small_file_name )->url;
}
],
'fileSize' => [
'type' => TypeRegistry::int(),
'resolve' => function ($image) {
return $image->file_size;
}
],
'location' => [
'type' => \IPS\GeoLocation\Api\GraphQL\TypeRegistry::geolocation(),
'resolve' => function ($image) {
if( $image->gps_raw )
{
return \IPS\GeoLocation::buildFromJson( $image->gps_raw );
}
return NULL;
}
],
'dims' => [
'type' => new ObjectType([
'name' => 'gallery_ImageSize',
'fields' => [
'width' => [
'type' => TypeRegistry::int(),
'resolve' => function ($size) {
return $size[0];
}
],
'height' => [
'type' => TypeRegistry::int(),
'resolve' => function ($size) {
return $size[1];
}
]
]
]),
'args' => [
'size' => TypeRegistry::string()
],
'resolve' => function ($image, $args) {
$imageSizes = json_decode( $image->data, true );
if( isset( $imageSizes[ $args['size'] ] ) ){
return $imageSizes[ $args['size'] ];
}
return null;
}
]
);
// Duplicate fields that have different names in topics
/*$topicFields['forum'] = $defaultFields['container'];
$topicFields['posts'] = $defaultFields['comments'];
$topicFields['postCount'] = $defaultFields['commentCount'];
$topicFields['lastPostAuthor'] = $defaultFields['lastCommentAuthor'];
$topicFields['lastPostDate'] = $defaultFields['lastCommentDate'];*/
// Remove duplicated fields
unset( $defaultFields['poll'] );
unset( $defaultFields['hasPoll'] );
return array_merge( $defaultFields, $imageFields );
}
/*public static function args()
{
return array_merge( parent::args(), array(
'password' => [
'type' => TypeRegistry::string()
]
));
}*/
/**
* Get the comment type that goes with this item type
*
* @return ObjectType
*/
protected static function getCommentType()
{
return \IPS\gallery\api\GraphQL\TypeRegistry::imageComment();
}
}
+3 -3
View File
@@ -12,7 +12,7 @@
namespace IPS\gallery\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;
@@ -77,7 +77,7 @@ class _albums extends \IPS\Api\Controller
}
/* Sort */
if ( isset( \IPS\Request::i()->sortBy ) and in_array( \IPS\Request::i()->sortBy, array( 'name', 'count_images' ) ) )
if ( isset( \IPS\Request::i()->sortBy ) and \in_array( \IPS\Request::i()->sortBy, array( 'name', 'count_images' ) ) )
{
$sortBy = 'album_' . \IPS\Request::i()->sortBy;
}
@@ -85,7 +85,7 @@ class _albums extends \IPS\Api\Controller
{
$sortBy = 'album_id';
}
$sortDir = ( isset( \IPS\Request::i()->sortDir ) and in_array( mb_strtolower( \IPS\Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? \IPS\Request::i()->sortDir : 'asc';
$sortDir = ( isset( \IPS\Request::i()->sortDir ) and \in_array( mb_strtolower( \IPS\Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? \IPS\Request::i()->sortDir : 'asc';
/* Get results */
if ( $this->member )
+81
View File
@@ -0,0 +1,81 @@
<?php
/**
* @brief Gallery Categories API
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Gallery
* @since 20 Feb 2020
*/
namespace IPS\gallery\api;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* @brief Gallery Categories API
*/
class _categories extends \IPS\Node\Api\NodeController
{
/**
* Class
*/
protected $class = 'IPS\gallery\Category';
/**
* GET /gallery/categories
* Get list of gallery categories
*
* @apiparam string sortBy What to sort by. Can be 'count_imgs' for number of entries, 'last_img_date' for last image date or do not specify 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\blog\Entry>
*/
public function GETindex()
{
/* Where clause */
$where = array();
/* Sort */
if ( isset( \IPS\Request::i()->sortBy ) and \in_array( \IPS\Request::i()->sortBy, array( 'count_imgs', 'last_img_date' ) ) )
{
$sortBy = 'category_' . \IPS\Request::i()->sortBy;
}
else
{
$sortBy = 'category_id';
}
$sortDir = ( isset( \IPS\Request::i()->sortDir ) and \in_array( mb_strtolower( \IPS\Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? \IPS\Request::i()->sortDir : 'asc';
/* Return */
return new \IPS\Api\PaginatedResponse(
200,
\IPS\Db::i()->select( '*', 'gallery_categories', $where, "{$sortBy} {$sortDir}" ),
isset( \IPS\Request::i()->page ) ? \IPS\Request::i()->page : 1,
'IPS\gallery\Category',
\IPS\Db::i()->select( 'COUNT(*)', 'gallery_categories', $where )->first(),
$this->member,
isset( \IPS\Request::i()->perPage ) ? \IPS\Request::i()->perPage : NULL
);
}
/**
* GET /gallery/categories/{id}
* Get information about a specific gallery category
*
* @param int $id ID Number
* @return \IPS\blog\Blog
*/
public function GETitem( $id )
{
return $this->_view( $id );
}
}
+3 -3
View File
@@ -12,7 +12,7 @@
namespace IPS\gallery\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;
@@ -93,7 +93,7 @@ class _comments extends \IPS\Content\Api\CommentController
* POST /gallery/comments
* Create a comment
*
* @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, hidden will only be honoured if the authentictaed user has permission to hide content).
* @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, hidden will only be honoured if the authenticated user has permission to hide content).
* @reqapiparam int image The ID number of the image the comment is for
* @reqapiparam int author The ID number of the member making the comment (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
* @apiparam string author_name If author is 0, the guest name that should be used
@@ -159,7 +159,7 @@ class _comments extends \IPS\Content\Api\CommentController
* POST /gallery/comments/{id}
* Edit a comment
*
* @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, hidden will only be honoured if the authentictaed user has permission to hide content).
* @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, hidden will only be honoured if the authenticated user has permission to hide content).
* @param int $id ID Number
* @apiparam int author The ID number of the member making the comment (0 for guest). Ignored for requests using an OAuth Access Token for a particular member.
* @apiparam string author_name If author is 0, the guest name that should be used
+7 -7
View File
@@ -12,7 +12,7 @@
namespace IPS\gallery\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;
@@ -39,7 +39,7 @@ class _images extends \IPS\Content\Api\ItemController
* @apiparam int locked If 1, only images which are locked are returned, if 0 only unlocked
* @apiparam int hidden If 1, only images which are hidden are returned, if 0 only not hidden
* @apiparam int featured If 1, only images 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 sortBy What to sort by. Can be 'date' for creation date, 'title', 'updated' 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
@@ -84,7 +84,7 @@ class _images extends \IPS\Content\Api\ItemController
* POST /gallery/images
* Upload an image
*
* @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 images).
* @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 images).
* @reqapiparam int album The ID number of the album the image should be created in - not required if category is provided (only provide one or the other)
* @reqapiparam int category The ID number of the category the image should be created in - not required if album is provided (only provide one or the other)
* @reqapiparam int author The ID number of the member uploading the image (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
@@ -113,7 +113,7 @@ class _images extends \IPS\Content\Api\ItemController
* @return \IPS\gallery\Image
*/
public function POSTindex()
{
{
/* Get category or album */
if ( isset( \IPS\Request::i()->album ) )
{
@@ -210,7 +210,7 @@ class _images extends \IPS\Content\Api\ItemController
if( \IPS\Image::exifSupported() )
{
$image->metadata = $imageObject->parseExif();
if( count( $image->metadata ) )
if( \count( $image->metadata ) )
{
$image->parseGeolocation();
$image->gps_show = isset( \IPS\Request::i()->gpsShow ) ? \IPS\Request::i()->gpsShow : 1;
@@ -233,7 +233,7 @@ class _images extends \IPS\Content\Api\ItemController
* POST /gallery/images/{id}
* Edit an image
*
* @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).
* @apiparam int album The ID number of the album (only provide this or category to move image)
* @apiparam int category The ID number of the category (only provide this or category to move image)
* @apiparam int author The ID number of the member uploading the image (0 for guest). Ignored for requests using an OAuth Access Token for a particular member.
@@ -244,12 +244,12 @@ class _images extends \IPS\Content\Api\ItemController
* @apiparam int gpsShow If the image contains the location in it's EXIF data, 1/0 indicating if a map should be shown (defaults to 1)
* @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 image 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 image. 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 image should be locked
* @apiparam int hidden 0 = unhidden; 1 = hidden, pending moderator approval; -1 = hidden (as if hidden by a moderator)
* @apiparam int pinned 1/0 indicating if the image should be locked
* @apiparam int featured 1/0 indicating if the image should be featured
* @param int $id ID Number
* @throws 2G316/7 INVALID_ID The image ID is invalid or the authorized user does not have permission to view it
* @throws 1G316/8 NO_CATEGORY_OR_ALBUM The category or album does not exist or the authorized user does not have permission to post in it
* @throws 1G316/9 NO_AUTHOR The author ID does not exist
View File
Whitespace-only changes.
+5 -5
View File
@@ -12,7 +12,7 @@
namespace IPS\gallery\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;
@@ -93,7 +93,7 @@ class _reviews extends \IPS\Content\Api\CommentController
* POST /gallery/reviews
* Create a review
*
* @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, hidden will only be honoured if the authentictaed user has permission to hide content).
* @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, hidden will only be honoured if the authenticated user has permission to hide content).
* @reqapiparam int image The ID number of the image the review is for
* @reqapiparam int author The ID number of the member making the review (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
* @apiparam string author_name If author is 0, the guest name that should be used
@@ -154,7 +154,7 @@ class _reviews extends \IPS\Content\Api\CommentController
}
/* Check we have a rating */
if ( !\IPS\Request::i()->rating or !in_array( (int) \IPS\Request::i()->rating, range( 1, \IPS\Settings::i()->reviews_rating_out_of ) ) )
if ( !\IPS\Request::i()->rating or !\in_array( (int) \IPS\Request::i()->rating, range( 1, \IPS\Settings::i()->reviews_rating_out_of ) ) )
{
throw new \IPS\Api\Exception( 'INVALID_RATING', '2G318/8', 403 );
}
@@ -167,7 +167,7 @@ class _reviews extends \IPS\Content\Api\CommentController
* POST /gallery/reviews/{id}
* Edit a review
*
* @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, hidden will only be honoured if the authentictaed user has permission to hide content).
* @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, hidden will only be honoured if the authenticated user has permission to hide content).
* @param int $id ID Number
* @apiparam int author The ID number of the member making the review (0 for guest). Ignored for requests using an OAuth Access Token for a particular member.
* @apiparam string author_name If author is 0, the guest name that should be used
@@ -196,7 +196,7 @@ class _reviews extends \IPS\Content\Api\CommentController
}
/* Check */
if ( isset( \IPS\Request::i()->rating ) and !in_array( (int) \IPS\Request::i()->rating, range( 1, \IPS\Settings::i()->reviews_rating_out_of ) ) )
if ( isset( \IPS\Request::i()->rating ) and !\in_array( (int) \IPS\Request::i()->rating, range( 1, \IPS\Settings::i()->reviews_rating_out_of ) ) )
{
throw new \IPS\Api\Exception( 'INVALID_RATING', '1G318/A', 403 );
}