Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -32,7 +32,8 @@ class _Image extends \IPS\Content\Item implements
|
||||
\IPS\Content\Ratings,
|
||||
\IPS\Content\Searchable,
|
||||
\IPS\Content\Embeddable,
|
||||
\IPS\Content\MetaData
|
||||
\IPS\Content\MetaData,
|
||||
\IPS\Content\Anonymous
|
||||
{
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
@@ -110,7 +111,9 @@ class _Image extends \IPS\Content\Item implements
|
||||
'num_reviews' => 'reviews',
|
||||
'unapproved_reviews' => 'unapproved_reviews',
|
||||
'hidden_reviews' => 'hidden_reviews',
|
||||
'meta_data' => 'meta_data'
|
||||
'meta_data' => 'meta_data',
|
||||
'is_anon' => 'is_anon',
|
||||
'last_comment_anon' => 'last_poster_anon',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -913,7 +916,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
if( $this->album_id )
|
||||
{
|
||||
$where[] = array( 'image_album_id=?', $this->album_id );
|
||||
$sortBy = static::$databaseColumnMap[ $this->directContainer()->_sortBy ];
|
||||
$sortBy = static::$databaseColumnMap[ $this->directContainer()->_sortBy ?: 'updated' ];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -996,7 +999,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
break;
|
||||
|
||||
case 'new':
|
||||
$results = iterator_to_array( static::getItemsWithPermission( ( \IPS\Settings::i()->club_nodes_in_apps ? array() : array( array( 'category_club_id IS NULL' ) ) ), NULL, 30, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, !\IPS\Settings::i()->club_nodes_in_apps ) );
|
||||
$results = iterator_to_array( static::getItemsWithPermission( static::clubImageExclusion(), NULL, 30, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, !\IPS\Settings::i()->club_nodes_in_apps ) );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1046,7 +1049,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
break;
|
||||
|
||||
case 'new':
|
||||
$results = iterator_to_array( static::getItemsWithPermission( ( \IPS\Settings::i()->club_nodes_in_apps ? array() : array( array( 'category_club_id IS NULL' ) ) ), NULL, 30, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, !\IPS\Settings::i()->club_nodes_in_apps ) );
|
||||
$results = iterator_to_array( static::getItemsWithPermission( static::clubImageExclusion(), NULL, 30, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, !\IPS\Settings::i()->club_nodes_in_apps ) );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1122,7 +1125,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
*
|
||||
* @return callable
|
||||
*/
|
||||
public function approvalQueueHtml( $ref=NULL, $container, $title )
|
||||
public function approvalQueueHtml( $ref, $container, $title )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'gallery', 'front' )->approvalQueueItem( $this, $ref, $container, $title );
|
||||
}
|
||||
@@ -1339,29 +1342,6 @@ class _Image extends \IPS\Content\Item implements
|
||||
parent::processBeforeCreate( $values );
|
||||
}
|
||||
|
||||
/**
|
||||
* Process created object AFTER the object has been created
|
||||
*
|
||||
* @param \IPS\Content\Comment|NULL $comment The first comment
|
||||
* @param array $values Values from form
|
||||
* @return void
|
||||
*/
|
||||
protected function processAfterCreate( $comment, $values )
|
||||
{
|
||||
parent::processAfterCreate( $comment, $values );
|
||||
|
||||
/* Update last image info */
|
||||
$this->container()->setLastImage();
|
||||
$this->container()->save();
|
||||
|
||||
if( $this->album_id )
|
||||
{
|
||||
$album = \IPS\gallery\Album::load( $this->album_id );
|
||||
$album->setLastImage();
|
||||
$album->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to parse geolocation data from EXIF data
|
||||
*
|
||||
@@ -1651,10 +1631,6 @@ class _Image extends \IPS\Content\Item implements
|
||||
$album->setLastImage();
|
||||
$album->save();
|
||||
}
|
||||
|
||||
$category = \IPS\gallery\Category::load( $this->category_id );
|
||||
$category->setLastImage();
|
||||
$category->save();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1669,7 +1645,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
* @param string $view 'expanded' or 'condensed'
|
||||
* @return callable
|
||||
*/
|
||||
public static function searchResultSnippet( array $indexData, array $authorData, array $itemData, array $containerData = NULL, array $reputationData, $reviewRating, $view )
|
||||
public static function searchResultSnippet( array $indexData, array $authorData, array $itemData, ?array $containerData, 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'] ] ) );
|
||||
|
||||
@@ -1752,7 +1728,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
'caption' => $this->caption,
|
||||
'description' => \IPS\Text\Parser::removeLazyLoad( $this->description ),
|
||||
'filename' => $this->file_name,
|
||||
'filesize' => $this->file_size,
|
||||
'filesize' => \intval( $this->file_size ),
|
||||
'images' => array(
|
||||
'original' => (string) \IPS\File::get( 'gallery_Images', $this->original_file_name )->url,
|
||||
'large' => (string) \IPS\File::get( 'gallery_Images', $this->masked_file_name )->url,
|
||||
@@ -2019,11 +1995,6 @@ class _Image extends \IPS\Content\Item implements
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cached groups the member can access
|
||||
*/
|
||||
protected static $_availableGroups = array();
|
||||
|
||||
/**
|
||||
* WHERE clause for getItemsWithPermission
|
||||
*
|
||||
@@ -2034,38 +2005,23 @@ class _Image extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static function getItemsWithPermissionWhere( $where, $member, &$joins )
|
||||
{
|
||||
/* We need to add a join for the album, which may or may not exist */
|
||||
$joins[] = array( 'from' => 'gallery_albums', 'where' => 'gallery_albums.album_id=gallery_images.image_album_id' );
|
||||
|
||||
/* Then we need to make sure we can access the album the image is in, if applicable */
|
||||
$restricted = array( 0 );
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
if( isset( static::$_availableGroups[ $member->member_id ] ) )
|
||||
{
|
||||
$restricted = static::$_availableGroups[ $member->member_id ];
|
||||
}
|
||||
else
|
||||
{
|
||||
if( $member->member_id )
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_sys_social_group_members', array( 'member_id=?', $member->member_id ) ) as $group )
|
||||
{
|
||||
$restricted[] = $group['group_id'];
|
||||
}
|
||||
}
|
||||
|
||||
static::$_availableGroups[ $member->member_id ] = $restricted;
|
||||
}
|
||||
$restricted = $member->socialGroups();
|
||||
|
||||
/* If you can edit images in a category you can see images in private albums in that category. We can only really check globally at this stage, however. */
|
||||
if( \IPS\gallery\Image::modPermission( 'edit', $member ) )
|
||||
{
|
||||
$result = array( "( gallery_albums.album_id IS NULL OR gallery_albums.album_type IN(1,2,3) )" );
|
||||
return array();
|
||||
}
|
||||
|
||||
if( \count( $restricted ) )
|
||||
{
|
||||
$subQuery = array( "( album_type=1 OR ( album_type=2 AND album_owner_id=? ) OR ( album_type=3 AND ( album_owner_id=? OR album_allowed_access IN (" . implode( ',', $restricted ) . ") ) ) )", $member->member_id, $member->member_id );
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = array( "( gallery_albums.album_id IS NULL OR gallery_albums.album_type=1 OR ( gallery_albums.album_type=2 AND gallery_albums.album_owner_id=? ) OR ( gallery_albums.album_type=3 AND ( gallery_albums.album_owner_id=? OR gallery_albums.album_allowed_access IN (" . implode( ',', $restricted ) . ") ) ) )", $member->member_id, $member->member_id );
|
||||
$subQuery = array( "( album_type=1 OR ( album_type=2 AND album_owner_id=? ) )", $member->member_id );
|
||||
}
|
||||
|
||||
/* Make sure the images aren't in hidden albums, unless we can view hidden albums */
|
||||
@@ -2075,15 +2031,15 @@ class _Image extends \IPS\Content\Item implements
|
||||
{
|
||||
if( \is_array( $hiddenContainers ) AND \count( $hiddenContainers ) )
|
||||
{
|
||||
$result[0] .= " AND ( gallery_albums.album_id IS NULL OR gallery_albums.album_hidden=0 OR gallery_albums.album_category_id IN(" . implode( ',', $hiddenContainers ) . ") )";
|
||||
$subQuery[0] .= " AND ( album_hidden=0 OR album_category_id IN(" . implode( ',', $hiddenContainers ) . ") )";
|
||||
}
|
||||
else
|
||||
{
|
||||
$result[0] .= " AND ( gallery_albums.album_id IS NULL OR gallery_albums.album_hidden=0 )";
|
||||
$subQuery[0] .= " AND album_hidden=0";
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
return array( '( gallery_images.image_album_id IS NULL OR gallery_images.image_album_id IN(?) )', \IPS\Db::i()->select( 'album_id', 'gallery_albums', $subQuery ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2136,8 +2092,36 @@ class _Image extends \IPS\Content\Item implements
|
||||
|
||||
$order = implode( ', ', $newOrders );
|
||||
|
||||
$where[] = static::getItemsWithPermissionWhere( $where, $member, $joins );
|
||||
return parent::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHiddenItems, $queryFlags, $member, $joinContainer, $joinComments, $joinReviews, $countOnly, $joins, $skipPermission, $joinTags, $joinAuthor, $joinLastCommenter, $showMovedLinks );
|
||||
if( $additionalWhere = static::getItemsWithPermissionWhere( $where, $member, $joins ) )
|
||||
{
|
||||
$where[] = $additionalWhere;
|
||||
}
|
||||
|
||||
$parentResult = parent::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHiddenItems, $queryFlags, $member, $joinContainer, $joinComments, $joinReviews, $countOnly, $joins, $skipPermission, $joinTags, $joinAuthor, $joinLastCommenter, $showMovedLinks );
|
||||
|
||||
/* Pre-prime album AR objects by loading them in one query now */
|
||||
if( !$countOnly )
|
||||
{
|
||||
$albumIds = array();
|
||||
|
||||
foreach ( $parentResult as $result )
|
||||
{
|
||||
if ( $result->album_id )
|
||||
{
|
||||
$albumIds[ $result->album_id ] = $result->album_id;
|
||||
}
|
||||
}
|
||||
|
||||
if ( \count( $albumIds ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'gallery_albums', array( \IPS\Db::i()->in( 'album_id', $albumIds ) ) ) as $album )
|
||||
{
|
||||
\IPS\gallery\Album::constructFromData( $album );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $parentResult;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2246,8 +2230,11 @@ class _Image extends \IPS\Content\Item implements
|
||||
{
|
||||
parent::hide( $member, $reason );
|
||||
|
||||
$this->directContainer()->setLastImage();
|
||||
$this->directContainer()->save();
|
||||
if( $this->directContainer() instanceof \IPS\gallery\Album )
|
||||
{
|
||||
$this->directContainer()->setLastImage();
|
||||
$this->directContainer()->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2260,8 +2247,11 @@ class _Image extends \IPS\Content\Item implements
|
||||
{
|
||||
parent::unhide( $member );
|
||||
|
||||
$this->directContainer()->setLastImage();
|
||||
$this->directContainer()->save();
|
||||
if( $this->directContainer() instanceof \IPS\gallery\Album )
|
||||
{
|
||||
$this->directContainer()->setLastImage();
|
||||
$this->directContainer()->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2399,4 +2389,24 @@ class _Image extends \IPS\Content\Item implements
|
||||
|
||||
return $member->group['g_download_original'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return query WHERE clause to use for getItemsWithPermission when excluding club content
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function clubImageExclusion()
|
||||
{
|
||||
if( \IPS\Settings::i()->club_nodes_in_apps )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
else
|
||||
{
|
||||
return array( array(
|
||||
'gallery_images.image_category_id NOT IN(?)',
|
||||
\IPS\Db::i()->select( 'node_id', 'core_clubs_node_map', array( 'node_class=?', 'IPS\gallery\Category' ) )
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user