Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

+200 -59
View File
@@ -24,12 +24,21 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\Embeddable
{
/**
* @brief Define access levels
* @brief Define view access levels
*/
const AUTH_TYPE_PUBLIC = 1;
const AUTH_TYPE_PRIVATE = 2;
const AUTH_TYPE_RESTRICTED = 3;
const AUTH_TYPE_DELETED = 4;
/**
* @brief Define submit access levels
*/
const AUTH_SUBMIT_OWNER = 0;
const AUTH_SUBMIT_PUBLIC = 1;
const AUTH_SUBMIT_GROUPS = 2;
const AUTH_SUBMIT_MEMBERS = 3;
const AUTH_SUBMIT_CLUB = 4;
/**
* @brief [ActiveRecord] Multiton Store
@@ -124,16 +133,19 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
/**
* [Node] Load and check permissions
*
* @param mixed $id ID
* @param string $perm Permission Key
* @param mixed $id ID
* @param string $perm Permission Key
* @param \IPS\Member|NULL $member Member, or NULL for logged in member
* @return static
* @throws \OutOfRangeException
* @note Album 'add' permissions are properly checked via the can() method
*/
public static function loadAndCheckPerms( $id, $perm='view' )
public static function loadAndCheckPerms( $id, $perm='view', \IPS\Member $member = NULL )
{
$obj = parent::loadAndCheckPerms( $id );
$member = $member ?: \IPS\Member::loggedIn();
if ( !$obj->category()->can( $perm ) )
if ( !$obj->can( $perm ) )
{
throw new \OutOfRangeException;
}
@@ -147,23 +159,23 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
if( !\IPS\gallery\Image::modPermission( 'edit', NULL, $obj->category() ) )
{
/* Throw exception if this is a private album we can't access */
if( $obj->type == static::AUTH_TYPE_PRIVATE AND $obj->owner() != \IPS\Member::loggedIn() )
if( $obj->type == static::AUTH_TYPE_PRIVATE AND $obj->owner() != $member )
{
throw new \OutOfRangeException;
}
/* Throw exception if this is a restricted album we can't access */
if( $obj->type == static::AUTH_TYPE_RESTRICTED AND $obj->owner() != \IPS\Member::loggedIn() )
if( $obj->type == static::AUTH_TYPE_RESTRICTED AND $obj->owner() != $member )
{
/* This will throw an exception if the row does not exist... but we need it to throw an OutOfRangeException */
try
{
if( !\IPS\Member::loggedIn()->member_id )
if( !$member->member_id )
{
throw new \OutOfRangeException;
}
$member = \IPS\Db::i()->select( '*', 'core_sys_social_group_members', array( 'group_id=? AND member_id=?', $obj->allowed_access, \IPS\Member::loggedIn()->member_id ) )->first();
$member = \IPS\Db::i()->select( '*', 'core_sys_social_group_members', array( 'group_id=? AND member_id=?', $obj->allowed_access, $member->member_id ) )->first();
}
catch( \UnderflowException $e )
{
@@ -174,6 +186,27 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
return $obj;
}
/**
* Fetch all albums we can submit to
*
* @param \IPS\gallery\Category $category Category we are submitting in
* @return array
* @throws \RuntimeException
*/
public static function loadForSubmit( $category )
{
$ownedAlbums = static::loadByOwner( NULL, array( array( 'album_category_id=?', $category->id ) ) );
$permittedAlbums = \IPS\gallery\Album\Item::getItemsWithPermission( array( array( 'album_category_id=?', $category->id ) ), NULL, NULL, 'add' );
$finalAlbums = $ownedAlbums;
foreach( $permittedAlbums as $album )
{
$finalAlbums[ $album->id ] = $album->asNode();
}
return $finalAlbums;
}
/**
* Fetch all nodes owned by a given user
@@ -196,7 +229,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
protected $_approvedMembers = FALSE;
/**
* Get members with access to restricted album
* Get members with access to view restricted album
*
* @return array|null
* @note This list will NOT include the album owner, who also inherently has access
@@ -288,6 +321,17 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
return $this->count_imgs;
}
/**
* Get items count language string
*
* @return string
* @throws \BadMethodCallException
*/
public function get__countLanguageString()
{
return 'num_images';
}
/**
* [Node] Get number of content comments
*
@@ -442,7 +486,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
$return[] = new \IPS\Helpers\Form\Text( 'album_name', $album ? $album->name : '', $required ?: NULL );
$return[] = new \IPS\Helpers\Form\Editor( 'album_description', $album ? $album->description : '', FALSE, array( 'app' => 'gallery', 'key' => 'Albums', 'autoSaveKey' => ( $album ? "gallery_album_{$album->id}_desc" : "gallery-new-album" ), 'attachIds' => $album ? array( $album->id, NULL, 'description' ) : NULL, 'minimize' => 'cdesc_placeholder' ) );
$return[] = new \IPS\Helpers\Form\Editor( 'album_description', $album ? $album->description : '', FALSE, array( 'app' => 'gallery', 'key' => 'Albums', 'autoSaveKey' => ( $album ? "gallery_album_{$album->id}_desc" : "gallery-new-album" ), 'attachIds' => $album ? array( $album->id, NULL, 'description' ) : NULL ) );
$return[] = new \IPS\Helpers\Form\Node( 'album_category', ( $album and $album->category_id ) ? \IPS\gallery\Category::load( $album->category_id ) : NULL, $required ?: NULL, array(
'class' => 'IPS\gallery\Category',
@@ -463,7 +507,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
}
) );
if( $forOther or \IPS\gallery\Image::modPermission( 'edit', NULL, ( $album ? $album->category() : NULL ) ) )
if( $forOther or \IPS\gallery\Album\Item::modPermission( 'edit', NULL, ( $album ? $album->category() : NULL ) ) )
{
if ( !$forOther )
{
@@ -497,8 +541,37 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
{
$return[] = new \IPS\Helpers\Form\SocialGroup( 'album_allowed_access', $album ? $album->allowed_access : NULL, FALSE, array( 'owner' => $album ? \IPS\Member::load( $album->owner_id ) : ( \IPS\Request::i()->album_owner ? \IPS\Member::load( \IPS\Request::i()->album_owner, 'name' ) : \IPS\Member::loggedIn() ) ), NULL, NULL, NULL, 'album_allowed_access' );
}
$submitTypes = array(
static::AUTH_SUBMIT_OWNER => 'album_submittype_owner',
static::AUTH_SUBMIT_PUBLIC => 'album_submittype_public',
static::AUTH_SUBMIT_GROUPS => 'album_submittype_groups',
static::AUTH_SUBMIT_MEMBERS => 'album_submittype_members'
);
/* Is the category in a club */
if( $album AND $album->category_id )
{
if( $album->category()->club() )
{
$submitTypes[ static::AUTH_SUBMIT_CLUB ] = 'album_submittype_club';
}
}
elseif( !$album AND ( isset( \IPS\Request::i()->chosenCategory ) or isset( \IPS\Request::i()->category ) ) )
{
if( \IPS\gallery\Category::load( (int) \IPS\Request::i()->chosenCategory ?: \IPS\Request::i()->category )->club() )
{
$submitTypes[ static::AUTH_SUBMIT_CLUB ] = 'album_submittype_club';
}
}
$return[] = new \IPS\Helpers\Form\Radio( 'album_submit_type', ( $album and $album->submit_type ) ? $album->submit_type : static::AUTH_SUBMIT_OWNER, FALSE, array( 'options' => $submitTypes, 'toggles' => array( static::AUTH_SUBMIT_MEMBERS => array( 'album_submit_access_members' ), static::AUTH_SUBMIT_GROUPS => array( 'album_submit_access_groups' ) ) ), NULL, NULL, NULL, 'album_submit_type' );
$return[] = new \IPS\Helpers\Form\SocialGroup( 'album_submit_access_members', ( $album AND $album->submit_type == static::AUTH_SUBMIT_MEMBERS ) ? $album->submit_access : NULL, FALSE, array( 'owner' => $album ? \IPS\Member::load( $album->owner_id ) : ( \IPS\Request::i()->album_owner ? \IPS\Member::load( \IPS\Request::i()->album_owner, 'name' ) : \IPS\Member::loggedIn() ) ), NULL, NULL, NULL, 'album_submit_access_members' );
$groups = array_combine( array_keys( \IPS\Member\Group::groups( TRUE, FALSE ) ), array_map( function( $_group ) { return (string) $_group; }, \IPS\Member\Group::groups( TRUE, FALSE ) ) );
$return[] = new \IPS\Helpers\Form\Select( 'album_submit_access_groups', ( $album and $album->submit_type == static::AUTH_SUBMIT_GROUPS ) ? explode( ',', $album->submit_access ) : NULL, FALSE, array( 'options' => $groups, 'multiple' => true ), NULL, NULL, NULL, 'album_submit_access_groups' );
$return[] = new \IPS\Helpers\Form\Select( 'album_sort_options', ( $album and $album->sort_options ) ? $album->sort_options : 'updated', FALSE, array( 'options' => array( 'updated' => 'sort_updated', 'last_comment' => 'sort_last_comment', 'title' => 'sort_title', 'rating' => 'sort_rating', 'date' => 'sort_date', 'num_comments' => 'sort_num_comments', 'num_reviews' => 'sort_num_reviews', 'views' => 'sort_views' ) ), NULL, NULL, NULL, 'album_sort_options' );
$return[] = new \IPS\Helpers\Form\Select( 'album_sort_options', ( $album and $album->sort_options ) ? $album->sort_options : 'updated', FALSE, array( 'options' => array( 'updated' => 'sort_updated', 'last_comment' => 'sort_last_comment', 'title' => 'album_sort_caption', 'rating' => 'sort_rating', 'date' => 'sort_date', 'num_comments' => 'sort_num_comments', 'num_reviews' => 'sort_num_reviews', 'views' => 'sort_views' ) ), NULL, NULL, NULL, 'album_sort_options' );
$return[] = new \IPS\Helpers\Form\YesNo( 'album_allow_rating', $album ? $album->allow_rating : TRUE, FALSE );
@@ -624,11 +697,25 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
$values['owner_id'] = ( $values['album_owner'] instanceof \IPS\Member ) ? $values['album_owner']->member_id : $values['album_owner'];
unset( $values['album_owner'] );
}
else
else if ( !$this->postSaveIsEdit )
{
$values['owner_id'] = \IPS\Member::loggedIn()->member_id;
}
switch( $values['album_submit_type'] )
{
case static::AUTH_SUBMIT_GROUPS:
$values['submit_access'] = implode( ',', $values['album_submit_access_groups'] );
break;
case static::AUTH_SUBMIT_MEMBERS:
$values['submit_access'] = $values['album_submit_access_members'];
break;
}
unset( $values['album_submit_access_members'] );
unset( $values['album_submit_access_groups'] );
/* Send to parent */
return $values;
}
@@ -656,6 +743,8 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
*/
public function postSaveForm( $values )
{
\IPS\File::claimAttachments( 'gallery-new-album', $this->id );
/* Update counts in categories if we move the album */
if( $this->postSaveIsEdit and $this->postSaveCategory != $values['category_id'] )
{
@@ -732,6 +821,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
/* Update caches */
$asItem->expireWidgetCaches();
$asItem->adjustSessions();
}
/**
@@ -815,7 +905,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
$this->last_img_date = 0;
$this->last_img_id = 0;
foreach( \IPS\Db::i()->select( '*', 'gallery_images', array( 'image_album_id=? AND image_approved=1', $this->id ), $sortBy, array( 0, 20 ) ) as $image )
foreach( \IPS\Db::i()->select( '*', 'gallery_images', array( 'image_album_id=? AND image_approved=1', $this->id ), $sortBy, array( 0, 20 ), NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER ) as $image )
{
if( $image['image_date'] > $this->last_img_date )
{
@@ -829,23 +919,23 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
$this->last_x_images = json_encode( $_latestImages );
/* Now get the counts and set them for our images */
$this->_items = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_images', array( 'image_album_id=? AND image_approved=1', $this->id ) )->first();
$this->_unapprovedItems = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_images', array( 'image_album_id=? AND image_approved=0', $this->id ) )->first();
$this->_items = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_images', array( 'image_album_id=? AND image_approved=1', $this->id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
$this->_unapprovedItems = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_images', array( 'image_album_id=? AND image_approved=0', $this->id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
$this->_comments = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_comments', array( 'gallery_images.image_album_id=? AND comment_approved=1', $this->id ) )->join( 'gallery_images', 'image_id=comment_img_id' )->first();
$this->_unapprovedComments = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_comments', array( 'gallery_images.image_album_id=? AND comment_approved=0', $this->id ) )->join( 'gallery_images', 'image_id=comment_img_id' )->first();
$this->_comments = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_comments', array( 'gallery_images.image_album_id=? AND comment_approved=1', $this->id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->join( 'gallery_images', 'image_id=comment_img_id' )->first();
$this->_unapprovedComments = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_comments', array( 'gallery_images.image_album_id=? AND comment_approved=0', $this->id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->join( 'gallery_images', 'image_id=comment_img_id' )->first();
$this->_reviews = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_reviews', array( 'gallery_images.image_album_id=? AND review_approved=1', $this->id ) )->join( 'gallery_images', 'image_id=review_image_id' )->first();
$this->_unapprovedReviews = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_reviews', array( 'gallery_images.image_album_id=? AND review_approved=0', $this->id ) )->join( 'gallery_images', 'image_id=review_image_id' )->first();
$this->_reviews = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_reviews', array( 'gallery_images.image_album_id=? AND review_approved=1', $this->id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->join( 'gallery_images', 'image_id=review_image_id' )->first();
$this->_unapprovedReviews = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_reviews', array( 'gallery_images.image_album_id=? AND review_approved=0', $this->id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->join( 'gallery_images', 'image_id=review_image_id' )->first();
/* And then get counts/latest data for the direct comments/reviews */
$this->comments = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_comments', array( 'comment_album_id=? AND comment_approved=1', $this->id ) )->first();
$this->comments_unapproved = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_comments', array( 'comment_album_id=? AND comment_approved=0', $this->id ) )->first();
$this->comments_hidden = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_comments', array( 'comment_album_id=? AND comment_approved=-1', $this->id ) )->first();
$this->comments = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_comments', array( 'comment_album_id=? AND comment_approved=1', $this->id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
$this->comments_unapproved = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_comments', array( 'comment_album_id=? AND comment_approved=0', $this->id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
$this->comments_hidden = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_comments', array( 'comment_album_id=? AND comment_approved=-1', $this->id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
$this->reviews = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_reviews', array( 'review_album_id=? AND review_approved=1', $this->id ) )->first();
$this->reviews_unapproved = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_reviews', array( 'review_album_id=? AND review_approved=0', $this->id ) )->first();
$this->reviews_hidden = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_reviews', array( 'review_album_id=? AND review_approved=-1', $this->id ) )->first();
$this->reviews = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_reviews', array( 'review_album_id=? AND review_approved=1', $this->id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
$this->reviews_unapproved = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_reviews', array( 'review_album_id=? AND review_approved=0', $this->id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
$this->reviews_hidden = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_reviews', array( 'review_album_id=? AND review_approved=-1', $this->id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
/* Save and then make sure search index is updated */
\IPS\Content\Search\Index::i()->index( $this->asItem() );
@@ -861,14 +951,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
*/
public function contentImages( $limit = NULL )
{
$images = array();
foreach( \IPS\gallery\Image::getItemsWithPermission( array( array( 'image_album_id=?', $this->id ) ), NULL, $limit ? $limit : 10 ) as $image )
{
$images[] = array( 'gallery_Images' => $image->medium_file_name );
}
return count( $images ) ? $images : NULL;
$this->asItem()->contentImages( $limit );
}
/**
@@ -1047,45 +1130,53 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
/**
* Retrieve a cover photo
*
* @param string $size One of full, medium, small or thumb
* @param string $size Masked or small
* @return string|null
*/
public function coverPhoto( $size='thumb' )
public function coverPhoto( $size='small' )
{
/* Can we view the images in this album? */
if ( !$this->can( 'read' ) )
{
return NULL;
}
if( $size == 'full' )
/* Make sure it's a valid size */
if( !in_array( $size, array( 'masked', 'small' ) ) )
{
$size = 'masked';
throw new \InvalidArgumentException;
}
$property = $size . "_file_name";
if( !$this->cover_img_id )
/* If we have an explicit cover photo set, make sure it's valid and load/cache it */
if( $this->cover_img_id )
{
if( $lastImage = $this->lastImage() )
if( $this->coverPhoto === NULL )
{
return (string) \IPS\File::get( 'gallery_Images', $lastImage->$property )->url;
try
{
$this->coverPhoto = \IPS\gallery\Image::load( $this->cover_img_id );
}
catch( \OutOfRangeException $e )
{
/* Cover photo isn't valid, reset album automatically */
$this->cover_img_id = 0;
$this->save();
}
}
return NULL;
if( $this->coverPhoto !== NULL )
{
return (string) \IPS\File::get( 'gallery_Images', $this->coverPhoto->$property )->url;
}
}
if( !in_array( $size, array( 'masked', 'medium', 'small', 'thumb' ) ) )
if( $lastImage = $this->lastImage() AND !$lastImage->media )
{
throw new \InvalidArgumentException;
return (string) \IPS\File::get( 'gallery_Images', $lastImage->$property )->url;
}
if( $this->coverPhoto === NULL )
{
$this->coverPhoto = \IPS\gallery\Image::load( $this->cover_img_id );
}
return (string) \IPS\File::get( 'gallery_Images', $this->coverPhoto->$property )->url;
return NULL;
}
/**
@@ -1132,7 +1223,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
return TRUE;
}
return FALSE;
return $this->asItem()->canDelete();
}
/**
@@ -1149,6 +1240,55 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
/* Load the item */
$asItem = $this->asItem();
/* Figure out member */
$member = $member ?: \IPS\Member::loggedIn();
/* If we are checking 'add' permission, verify if we can add */
if( $permission == 'add' )
{
/* First check we can submit to this album based on the "Submissions" setting */
switch ( $this->submit_type )
{
/* Owner */
case static::AUTH_SUBMIT_OWNER:
if ( $this->owner_id != $member->member_id )
{
return FALSE;
}
break;
/* Chosen groups */
case static::AUTH_SUBMIT_GROUPS:
if ( !$member->inGroup( explode( ',', $this->submit_access ) ) )
{
return FALSE;
}
break;
/* Chosen members */
case static::AUTH_SUBMIT_MEMBERS:
if ( !in_array( $this->submit_access, $member->socialGroups() ) )
{
return FALSE;
}
break;
/* Club */
case static::AUTH_SUBMIT_CLUB:
if ( $club = $this->category()->club() and !in_array( $club->id, $member->clubs() ) )
{
return FALSE;
}
break;
}
/* Verify if we can add any more files to this album */
if( \IPS\Member::loggedIn()->group['g_img_album_limit'] AND \IPS\Member::loggedIn()->group['g_img_album_limit'] - ( $this->count_imgs + $this->count_imgs_hidden ) < 1 )
{
return FALSE;
}
}
/* Albums can be hidden, so make sure to test permissions */
if( $asItem->hidden() )
{
@@ -1190,7 +1330,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
*/
public function searchIndexPermissions()
{
$return = parent::searchIndexPermissions();
$return = $this->category()->searchIndexPermissions();
if ( $this->type != static::AUTH_TYPE_PUBLIC )
{
@@ -1250,6 +1390,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
/**
* Get output for API
*
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
* @return array
* @apiresponse int id ID number
* @apiresponse string name Name
@@ -1261,17 +1402,17 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
* @apiresponse int images Number of images
* @apiresponse string url URL
*/
public function apiOutput()
public function apiOutput( \IPS\Member $authorizedMember = NULL )
{
return array(
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
'category' => $this->category()->apiOutput(),
'owner' => $this->owner()->apiOutput(),
'category' => $this->category()->apiOutput( $authorizedMember ),
'owner' => $this->owner()->apiOutput( $authorizedMember ),
'privacy' => ( $this->type == static::AUTH_TYPE_PUBLIC ) ? 'public' : ( $this->type == static::AUTH_TYPE_PRIVATE ? 'private' : ( $this->type == static::AUTH_TYPE_RESTRICTED ? 'restricted' : null ) ),
'approvedMembers' => $this->approvedMembers ? array_map( function( $val ) {
return $val->apiOutput();
'approvedMembers' => $this->approvedMembers ? array_map( function( $val ) use ( $authorizedMember ) {
return $val->apiOutput( $authorizedMember );
}, $this->approvedMembers ) : null,
'images' => $this->count_imgs,
'url' => (string) $this->url()