Version 4.7.23
This commit is contained in:
1 parent
7124a02564
commit
25ddeb65d6
1791 files changed
+76990
-44452
No files matched your search
@@ -987,22 +987,24 @@ class _Image extends \IPS\Content\Item implements
|
||||
|
||||
/* We need to sort on a unique value */
|
||||
$sortValue = $this->$sortBy . $this->updated;
|
||||
$sortBy = 'CONCAT(image_' . $sortBy . ',image_updated)';
|
||||
$where['date'] = array( "CONCAT(image_{$sortBy},image_updated) {$dir}= ?", $sortValue );
|
||||
$sortBy = 'image_' . $sortBy . ' ' . $direction. ',image_updated';
|
||||
}
|
||||
elseif( in_array( $sortBy, array( 'date', 'updated' ) ) )
|
||||
{
|
||||
/* We need to sort on a unique value */
|
||||
$sortValue = $this->$sortBy . $this->id;
|
||||
$sortBy = 'CONCAT(image_' . $sortBy . ',image_id)';
|
||||
$where['date'] = array( "CONCAT(image_{$sortBy},image_id) {$dir}= ?", $sortValue );
|
||||
$sortBy = 'image_' . $sortBy . ' ' . $direction. ',image_id';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortValue = $this->$sortBy;
|
||||
$sortBy = static::$databasePrefix . $sortBy;
|
||||
$where['date'] = array( $sortBy . " {$dir}= ?", $sortValue );
|
||||
}
|
||||
|
||||
$where['date'] = array( $sortBy . " {$dir}= ?", $sortValue );
|
||||
return iterator_to_array( \IPS\gallery\Image::getItemsWithPermission( $where, $sortBy . ' ' . $direction . ', image_id ' . $direction, $count ) );
|
||||
return iterator_to_array( \IPS\gallery\Image::getItemsWithPermission( $where, $sortBy . ' ' . $direction, $count, 'read', null, 0, null, false, false, false, false, null, false, false, false, false ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1231,6 +1233,31 @@ class _Image extends \IPS\Content\Item implements
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
|
||||
if( $this->album_id and !$this->isFutureDate() )
|
||||
{
|
||||
if( $this->hidden() === 0 and !$this->isFutureDate() )
|
||||
{
|
||||
$this->directContainer()->_items = ( $this->directContainer()->_items + 1 );
|
||||
}
|
||||
elseif( $this->hidden() === 1 )
|
||||
{
|
||||
$this->directContainer()->_unapprovedItems = ( $this->directContainer()->_unapprovedItems + 1 );
|
||||
}
|
||||
$this->directContainer()->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process after the object has been edited on the front-end
|
||||
*
|
||||
@@ -1292,7 +1319,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
|
||||
/* Get the file... */
|
||||
$file = NULL;
|
||||
if( isset( $values['imageLocation'] ) AND $values['imageLocation'] )
|
||||
if( isset( $values['imageLocation'] ) AND $values['imageLocation'] and $values['imageLocation'] != $this->original_file_name)
|
||||
{
|
||||
$file = \IPS\File::get( 'gallery_Images', $values['imageLocation'] );
|
||||
if ( isset( $values['imageRequiresModeration'] ) )
|
||||
@@ -1907,6 +1934,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
if( $previousAlbum )
|
||||
{
|
||||
$album = \IPS\gallery\Album::load( $previousAlbum );
|
||||
$album->_items = $album->_items -1;
|
||||
$album->setLastImage();
|
||||
$album->save();
|
||||
}
|
||||
@@ -1915,6 +1943,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
if( $this->album_id )
|
||||
{
|
||||
$album = \IPS\gallery\Album::load( $this->album_id );
|
||||
$album->_items = $album->_items +1;
|
||||
$album->setLastImage();
|
||||
$album->save();
|
||||
}
|
||||
@@ -2084,37 +2113,51 @@ class _Image extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static function getItemsWithPermissionWhere( $where, $member, &$joins )
|
||||
{
|
||||
/* Then we need to make sure we can access the album the image is in, if applicable */
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$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 ) )
|
||||
/* If we already filtered by a specific album, we can stop right here */
|
||||
if( array_key_exists( 'album', $where ) )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
if( \count( $restricted ) )
|
||||
/* Then we need to make sure we can access the album the image is in, if applicable */
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
/* Skip permissions for guests */
|
||||
if( !$member->member_id )
|
||||
{
|
||||
$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 );
|
||||
$subQuery = array( "album_type=1 AND album_hidden=0" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$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 */
|
||||
$hiddenContainers = \IPS\gallery\Album\Item::canViewHiddenItemsContainers( $member );
|
||||
|
||||
if( $hiddenContainers !== TRUE )
|
||||
{
|
||||
if( \is_array( $hiddenContainers ) AND \count( $hiddenContainers ) )
|
||||
/* 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 ) )
|
||||
{
|
||||
$subQuery[0] .= " AND ( album_hidden=0 OR album_category_id IN(" . implode( ',', $hiddenContainers ) . ") )";
|
||||
return array();
|
||||
}
|
||||
|
||||
$restricted = $member->socialGroups();
|
||||
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
|
||||
{
|
||||
$subQuery[0] .= " AND album_hidden=0";
|
||||
$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 */
|
||||
$hiddenContainers = \IPS\gallery\Album\Item::canViewHiddenItemsContainers( $member );
|
||||
|
||||
if( $hiddenContainers !== TRUE )
|
||||
{
|
||||
if( \is_array( $hiddenContainers ) AND \count( $hiddenContainers ) )
|
||||
{
|
||||
$subQuery[0] .= " AND ( album_hidden=0 OR album_category_id IN(" . implode( ',', $hiddenContainers ) . ") )";
|
||||
}
|
||||
else
|
||||
{
|
||||
$subQuery[0] .= " AND album_hidden=0";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2470,6 +2513,12 @@ class _Image extends \IPS\Content\Item implements
|
||||
return $member->group['g_download_original'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Store club node IDs so we can save on queries
|
||||
* @var array|null
|
||||
*/
|
||||
protected static ?array $_clubNodeIds = null;
|
||||
|
||||
/**
|
||||
* Return query WHERE clause to use for getItemsWithPermission when excluding club content
|
||||
*
|
||||
@@ -2477,17 +2526,22 @@ class _Image extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static function clubImageExclusion(): array
|
||||
{
|
||||
if( \IPS\Settings::i()->club_nodes_in_apps )
|
||||
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' ) )
|
||||
) );
|
||||
if( static::$_clubNodeIds === null )
|
||||
{
|
||||
static::$_clubNodeIds = iterator_to_array( \IPS\Db::i()->select( 'node_id', 'core_clubs_node_map', array( 'node_class=?', 'IPS\gallery\Category' ) ) );
|
||||
}
|
||||
|
||||
if( \count( static::$_clubNodeIds ) )
|
||||
{
|
||||
return array(
|
||||
array( \IPS\Db::i()->in( 'gallery_images.image_category_id', static::$_clubNodeIds, true ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user