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

+59 -32
View File
@@ -12,7 +12,7 @@
namespace IPS\gallery;
/* 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;
@@ -94,6 +94,11 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
'rating_hits' => 'rating_count',
);
/**
* @brief [Node] Maximum results to display at a time in any node helper form elements. Useful for user-submitted node types when there may be a lot. NULL for no limit.
*/
public static $maxFormHelperResults = 2000;
/**
* Return this album as a content item instead of a node
*
@@ -642,7 +647,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
if( isset( $values['album_name'] ) )
{
\IPS\Lang::saveCustom( 'gallery', "gallery_album_{$this->id}", $values['album_name'] );
$values['name_seo'] = \IPS\Http\Url\Friendly::seoTitle( is_array( $values['album_name'] ) ? $values['album_name'][ \IPS\Lang::defaultLanguage() ] : $values['album_name'] );
$values['name_seo'] = \IPS\Http\Url\Friendly::seoTitle( \is_array( $values['album_name'] ) ? $values['album_name'][ \IPS\Lang::defaultLanguage() ] : $values['album_name'] );
}
if( isset( $values['album_description'] ) )
@@ -715,7 +720,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
* @brief Remember previous album status when editing
*/
protected $postSaveType = NULL;
/**
* [Node] Perform actions after saving the form
*
@@ -725,6 +730,13 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
public function postSaveForm( $values )
{
\IPS\File::claimAttachments( 'gallery-new-album', $this->id );
$sendFilterNotifications = $this->asItem()->checkProfanityFilters( FALSE, $this->postSaveIsEdit );
if ( $sendFilterNotifications )
{
/* Save it so it hides */
$this->asItem()->save();
}
/* Update counts in categories if we move the album */
if( $this->postSaveIsEdit and $this->postSaveCategory != $values['category_id'] )
@@ -925,14 +937,14 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
/**
* Returns the content images
*
* @param int|null $limit Number of attachments to fetch, or NULL for all
*
* @return array|NULL If array, then array( 'core_Attachment' => 'month_x/foo.gif', ... );
* @param int|null $limit Number of attachments to fetch, or NULL for all
* @param bool $ignorePermissions If set to TRUE, permission to view the images will not be checked
* @return array|NULL
* @throws \BadMethodCallException
*/
public function contentImages( $limit = NULL )
public function contentImages( $limit = NULL, $ignorePermissions = FALSE )
{
$this->asItem()->contentImages( $limit );
return $this->asItem()->contentImages( $limit, $ignorePermissions );
}
/**
@@ -942,9 +954,9 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
*/
public function get__latestImages()
{
$_latestImages = json_decode( $this->last_x_images, TRUE );
$_latestImages = json_decode( $this->last_x_images, TRUE ) ?? array();
if( !count( $_latestImages ) )
if( !\count( $_latestImages ) )
{
return array();
}
@@ -975,7 +987,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
{
$events = iterator_to_array( \IPS\calendar\Event::getItemsWithPermission( array( array( 'event_album=?', $this->id ) ) ) );
if( !count( $events ) )
if( !\count( $events ) )
{
$this->_events = array();
return $this->_events;
@@ -1039,12 +1051,21 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
/**
* Retrieve the content item count
*
* @param null|array $data Data array for mass move/delete
* @return null|int
*/
public function getContentItemCount()
public function getContentItemCount( $data=NULL )
{
$contentItemClass = static::$contentItemClass;
return (int) \IPS\Db::i()->select( 'COUNT(*)', $contentItemClass::$databaseTable, array( $contentItemClass::$databasePrefix . 'album_id=?', $this->id ) )->first();
$where = array( array( $contentItemClass::$databasePrefix . 'album_id=?', $this->id ) );
if( $data )
{
$where = array_merge_recursive( $where, $this->massMoveorDeleteWhere( $data ) );
}
return (int) \IPS\Db::i()->select( 'COUNT(*)', $contentItemClass::$databaseTable, $where )->first();
}
/**
@@ -1069,7 +1090,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
$where = array();
$where[] = array( $contentItemClass::$databasePrefix . 'album_id=?', $this->_id );
if ( count( $additionalWhere ) )
if ( \count( $additionalWhere ) )
{
foreach( $additionalWhere AS $clause )
{
@@ -1122,7 +1143,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
}
/* Make sure it's a valid size */
if( !in_array( $size, array( 'masked', 'small' ) ) )
if( !\in_array( $size, array( 'masked', 'small' ) ) )
{
throw new \InvalidArgumentException;
}
@@ -1174,14 +1195,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
if ( isset( $qs['album'] ) )
{
if ( method_exists( get_called_class(), 'loadAndCheckPerms' ) )
{
return static::loadAndCheckPerms( $qs['album'] );
}
else
{
return static::load( $qs['album'] );
}
return static::load( $qs['album'] );
}
throw new \InvalidArgumentException;
@@ -1206,12 +1220,13 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
* Check permissions
*
* @param mixed $permission A key which has a value in static::$permissionMap['view'] matching a column ID in core_permission_index
* @param \IPS\Member|\IPS\Member\Group|NULL $member The member or group to check (NULL for currently logged in member)
* @param \IPS\Member|\IPS\Member\Group|NULL $member The member or group to check (NULL for currently logged in member)
* @param bool $considerPostBeforeRegistering If TRUE, and $member is a guest, will return TRUE if "Post Before Registering" feature is enabled
* @return bool
* @throws \OutOfBoundsException If $permission does not exist in static::$permissionMap
* @note Albums don't have permissions, but instead check against the category they are in
*/
public function can( $permission, $member=NULL )
public function can( $permission, $member=NULL, $considerPostBeforeRegistering = TRUE )
{
/* Load the item */
$asItem = $this->asItem();
@@ -1274,7 +1289,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
/* Chosen members */
case static::AUTH_SUBMIT_MEMBERS:
if ( !in_array( $this->submit_access, $member->socialGroups() ) AND $this->owner_id != $member->member_id )
if ( !\in_array( $this->submit_access, $member->socialGroups() ) AND $this->owner_id != $member->member_id )
{
return FALSE;
}
@@ -1282,7 +1297,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
/* Club */
case static::AUTH_SUBMIT_CLUB:
if ( $club = $this->category()->club() and !in_array( $club->id, $member->clubs() ) )
if ( $club = $this->category()->club() and !\in_array( $club->id, $member->clubs() ) )
{
return FALSE;
}
@@ -1312,7 +1327,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
}
else
{
return $asItem->can( $permission, $member );
return $asItem->can( $permission, $member, $considerPostBeforeRegistering );
}
}
}
@@ -1337,19 +1352,19 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
/* Albums can be hidden, so make sure to test permissions */
if( $asItem->hidden() )
{
if( !$asItem->can( 'view', $member ) )
if( !$asItem->can( 'view', $member, $considerPostBeforeRegistering ) )
{
return FALSE;
}
return $asItem->can( $permission, $member );
return $asItem->can( $permission, $member, $considerPostBeforeRegistering );
}
}
/* We'll just rely on category permissions if the album isn't hidden */
try
{
return $this->category()->can( $permission, $member );
return $this->category()->can( $permission, $member, $considerPostBeforeRegistering );
}
catch( \OutOfRangeException $e )
{
@@ -1444,7 +1459,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
return array(
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
'description' => \IPS\Member::loggedIn()->language()->addToStack("gallery_album_{$this->id}_desc", NULL, array( 'removeLazyLoad' => true ) ),
'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 ) ),
@@ -1455,6 +1470,18 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
'url' => (string) $this->url()
);
}
/**
* Webhook filters
*
* @return array
*/
public function webhookFilters()
{
$filters = array();
$filters['privacy'] = ( $this->type == static::AUTH_TYPE_PUBLIC ) ? 'public' : ( $this->type == static::AUTH_TYPE_PRIVATE ? 'private' : ( $this->type == static::AUTH_TYPE_RESTRICTED ? 'restricted' : null ) );
return $filters;
}
/**
* Get template for managing this nodes follows