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

+45 -38
View File
@@ -12,7 +12,7 @@
namespace IPS\gallery\Album;
/* 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;
@@ -160,54 +160,38 @@ class _Item extends \IPS\Content\Item implements
*/
public static $seoTitleColumn = 'name_seo';
/**
* Get URL
*
* @param string|NULL $action Action
* @return \IPS\Http\Url
*/
public function url( $action=NULL )
{
$url = $this->asNode()->url();
if( $action !== NULL )
{
$url = $url->setQueryString( 'do', $action );
}
return $url;
}
/**
* Can review?
*
* @param \IPS\Member\NULL $member The member (NULL for currently logged in member)
* @param \IPS\Member\NULL $member The member (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
*/
public function canReview( $member=NULL )
public function canReview( $member=NULL, $considerPostBeforeRegistering = TRUE )
{
if ( !$this->use_reviews )
{
return FALSE;
}
return parent::canReview( $member );
return parent::canReview( $member, $considerPostBeforeRegistering );
}
/**
* Can comment?
*
* @param \IPS\Member\NULL $member The member (NULL for currently logged in member)
* @param \IPS\Member\NULL $member The member (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
*/
public function canComment( $member=NULL )
public function canComment( $member=NULL, $considerPostBeforeRegistering = TRUE )
{
if ( !$this->use_comments )
{
return FALSE;
}
return parent::canComment( $member );
return parent::canComment( $member, $considerPostBeforeRegistering );
}
/**
@@ -312,7 +296,7 @@ class _Item extends \IPS\Content\Item implements
$wheres[] = '(album_submit_type=' . \IPS\gallery\Album::AUTH_SUBMIT_MEMBERS . ' AND (' . \IPS\Db::i()->findInSet( 'album_submit_access', $member->socialGroups() ) . ' OR album_owner_id=' . $member->member_id . ' ) )';
/* And finally, if we're in a club and we allow anyone in the club to submit, handle that */
if( $category->club() AND in_array( $category->club()->id, $member->clubs() ) )
if( $category->club() AND \in_array( $category->club()->id, $member->clubs() ) )
{
$wheres[] = '(album_submit_type=' . \IPS\gallery\Album::AUTH_SUBMIT_CLUB . ')';
}
@@ -324,7 +308,12 @@ class _Item extends \IPS\Content\Item implements
* @brief Cached groups the member can access
*/
protected static $_availableGroups = array();
/**
* @brief Cached URLs
*/
protected $_url = array();
/**
* WHERE clause for getItemsWithPermission
*
@@ -446,7 +435,7 @@ class _Item extends \IPS\Content\Item implements
}
}
if ( count( $imageIds ) )
if ( \count( $imageIds ) )
{
\IPS\gallery\Application::outputCss();
@@ -454,7 +443,7 @@ class _Item extends \IPS\Content\Item implements
foreach ( \IPS\gallery\Image::getItemsWithPermission( array( array( 'image_id IN(' . implode( ',', $imageIds ) . ')' ) ), NULL, NULL ) as $image )
{
if( isset( $return[ $image->album_id] ) AND count( $return[ $image->album_id ] ) > 19 )
if( isset( $return[ $image->album_id] ) AND \count( $return[ $image->album_id ] ) > 19 )
{
continue;
}
@@ -483,7 +472,7 @@ class _Item extends \IPS\Content\Item implements
public static function searchResultSnippet( array $indexData, array $authorData, array $itemData, array $containerData = NULL, array $reputationData, $reviewRating, $view )
{
$url = \IPS\Http\Url::internal( static::$urlBase . $indexData['index_item_id'], 'front', static::$urlTemplate, \IPS\Http\Url\Friendly::seoTitle( $indexData['index_title'] ?: $itemData[ static::$databasePrefix . static::$databaseColumnMap['title'] ] ) );
$images = ( isset( $itemData['extra'] ) AND count( $itemData['extra'] ) ) ? $itemData['extra'] : array();
$images = ( isset( $itemData['extra'] ) AND \count( $itemData['extra'] ) ) ? $itemData['extra'] : array();
return \IPS\Theme::i()->getTemplate( 'global', 'gallery', 'front' )->searchResultAlbumSnippet( $indexData, $itemData, $images, $url, $view == 'condensed' );
}
@@ -501,9 +490,9 @@ class _Item extends \IPS\Content\Item implements
*/
public static function searchResultSummaryLanguage( $authorData, $articles, $indexData, $itemData )
{
if( !in_array( 'IPS\Content\Comment', class_parents( $indexData['index_class'] ) ) )
if( !\in_array( 'IPS\Content\Comment', class_parents( $indexData['index_class'] ) ) )
{
return \IPS\Member::loggedIn()->language()->addToStack( "album_user_own_activity_item", FALSE, array( 'sprintf' => array( $authorData['name'], $articles['indefinite'] ) ) );
return \IPS\Member::loggedIn()->language()->addToStack( "album_user_own_activity_item", FALSE, array( 'sprintf' => array( $articles['indefinite'] ), 'htmlsprintf' => array( \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLinkFromData( $authorData['member_id'], $authorData['name'], $authorData['members_seo_name'], $authorData['member_group_id'] ?? \IPS\Settings::i()->guest_group ) ) ) );
}
else
{
@@ -644,21 +633,21 @@ class _Item extends \IPS\Content\Item implements
/**
* 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 )
{
$images = array();
foreach( \IPS\gallery\Image::getItemsWithPermission( array( array( 'image_album_id=?', $this->id ) ), NULL, $limit ? $limit : 10 ) as $image )
foreach( \IPS\gallery\Image::getItemsWithPermission( array( array( 'image_album_id=?', $this->id ) ), NULL, $limit ? $limit : 10, $ignorePermissions ? NULL : 'read' ) as $image )
{
$images[] = array( 'gallery_Images' => $image->masked_file_name );
}
return count( $images ) ? $images : NULL;
return \count( $images ) ? $images : NULL;
}
/**
@@ -674,4 +663,22 @@ class _Item extends \IPS\Content\Item implements
$this->container()->resetCommentCounts();
$this->container()->save();
}
/**
* Get the last modification date for the sitemap
*
* @return \IPS\DateTime|null Timestamp of the last modification time for the sitemap
*/
public function lastModificationDate()
{
/* Returns the last last comment date */
$lastMod = parent::lastModificationDate();
if( !$lastMod AND $this->last_img_date OR ( $lastMod AND $this->last_img_date AND $this->last_img_date > $lastMod->getTimestamp() ) )
{
$lastMod = \IPS\DateTime::ts( $this->last_img_date );
}
return $lastMod;
}
}