Version 4.3.6
This commit is contained in:
1 parent
fe1acf984a
commit
1a0c7fd3c2
609 files changed
+14707
-5726
No files matched your search
@@ -144,44 +144,15 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
{
|
||||
$obj = parent::loadAndCheckPerms( $id );
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
if ( !$obj->can( $perm ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
if ( $obj->type == static::AUTH_TYPE_DELETED )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
/* If we don't have edit permission in the category, check album restrictions */
|
||||
if( !\IPS\gallery\Image::modPermission( 'edit', NULL, $obj->category() ) )
|
||||
if ( !$obj->can( $perm ) )
|
||||
{
|
||||
/* Throw exception if this is a private album we can't access */
|
||||
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() != $member )
|
||||
{
|
||||
/* This will throw an exception if the row does not exist... but we need it to throw an OutOfRangeException */
|
||||
try
|
||||
{
|
||||
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, $member->member_id ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
return $obj;
|
||||
@@ -342,6 +313,16 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
return $this->count_comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of content comments (for display)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get__commentsForDisplay()
|
||||
{
|
||||
return $this->_comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of content reviews
|
||||
*
|
||||
@@ -539,7 +520,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
|
||||
if( \IPS\Member::loggedIn()->group['g_create_albums_fo'] )
|
||||
{
|
||||
$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' );
|
||||
$return[] = new \IPS\Helpers\Form\SocialGroup( 'album_allowed_access', $album ? (int) $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(
|
||||
@@ -567,7 +548,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
|
||||
$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' );
|
||||
$return[] = new \IPS\Helpers\Form\SocialGroup( 'album_submit_access_members', ( $album AND $album->submit_type == static::AUTH_SUBMIT_MEMBERS ) ? (int) $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' );
|
||||
|
||||
@@ -922,7 +903,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
$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 ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->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 AND gallery_images.image_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 ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->join( 'gallery_images', 'image_id=review_image_id' )->first();
|
||||
@@ -1218,11 +1199,6 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if( $this->owner_id == \IPS\Member::loggedIn()->member_id AND \IPS\Member::loggedIn()->group['g_delete_own_albums'] )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return $this->asItem()->canDelete();
|
||||
}
|
||||
|
||||
@@ -1243,68 +1219,129 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
/* Figure out member */
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
/* If we are checking 'add' permission, verify if we can add */
|
||||
if( $permission == 'add' )
|
||||
/* Are we looking at a member? */
|
||||
if( $member instanceof \IPS\Member )
|
||||
{
|
||||
/* First check we can submit to this album based on the "Submissions" setting */
|
||||
switch ( $this->submit_type )
|
||||
/* If we don't have edit permission in the category, check album restrictions */
|
||||
if( !\IPS\gallery\Image::modPermission( 'edit', $member, $this->category() ) )
|
||||
{
|
||||
/* Owner */
|
||||
case static::AUTH_SUBMIT_OWNER:
|
||||
if ( $this->owner_id != $member->member_id )
|
||||
/* Deny access if the album is private and we aren't the owner */
|
||||
if( $this->type == static::AUTH_TYPE_PRIVATE AND $this->owner() != $member )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If this is a restricted album, check that we're "on the list" */
|
||||
if( $this->type == static::AUTH_TYPE_RESTRICTED AND $this->owner() != $member )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( !$member->member_id )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
\IPS\Db::i()->select( '*', 'core_sys_social_group_members', array( 'group_id=? AND member_id=?', $this->allowed_access, $member->member_id ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
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 )
|
||||
|
||||
/* If we are checking 'add' permission, verify if we can add */
|
||||
if( $permission == 'add' )
|
||||
{
|
||||
return FALSE;
|
||||
/* 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() ) AND $this->owner_id != $member->member_id )
|
||||
{
|
||||
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( $member->group['g_img_album_limit'] AND $member->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() )
|
||||
{
|
||||
if( !$asItem->canView( $member ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$methodToCheck = "can" . \ucwords( $permission );
|
||||
|
||||
if( method_exists( $asItem, $methodToCheck ) )
|
||||
{
|
||||
return $asItem->$methodToCheck( $member );
|
||||
}
|
||||
else
|
||||
{
|
||||
return $asItem->can( $permission, $member );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Albums can be hidden, so make sure to test permissions */
|
||||
if( $asItem->hidden() )
|
||||
/* Or are we looking at a group? */
|
||||
else
|
||||
{
|
||||
if( !$asItem->canView( $member ) )
|
||||
if( $permission == 'add' )
|
||||
{
|
||||
return FALSE;
|
||||
/* Verify if the group is in the submit list */
|
||||
if( $this->submit_type == static::AUTH_SUBMIT_GROUPS AND !in_array( $member->g_id, explode( ',', $this->submit_access ) ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Verify if we can add any more files to this album */
|
||||
if( $member->g_img_album_limit AND $member->g_img_album_limit - ( $this->count_imgs + $this->count_imgs_hidden ) < 1 )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
$methodToCheck = "can" . \ucwords( $permission );
|
||||
/* Albums can be hidden, so make sure to test permissions */
|
||||
if( $asItem->hidden() )
|
||||
{
|
||||
if( !$asItem->can( 'view', $member ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( method_exists( $asItem, $methodToCheck ) )
|
||||
{
|
||||
return $asItem->$methodToCheck( $member );
|
||||
}
|
||||
else
|
||||
{
|
||||
return $asItem->can( $permission, $member );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ class _Item extends \IPS\Content\Item implements
|
||||
$wheres[] = '(album_submit_type=' . \IPS\gallery\Album::AUTH_SUBMIT_GROUPS . ' AND ' . \IPS\Db::i()->findInSet( 'album_submit_access', $member->groups ) . ')';
|
||||
|
||||
/* And where we as an individual member are allowed to submit */
|
||||
$wheres[] = '(album_submit_type=' . \IPS\gallery\Album::AUTH_SUBMIT_MEMBERS . ' AND ' . \IPS\Db::i()->findInSet( 'album_submit_access', $member->socialGroups() ) . ')';
|
||||
$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() ) )
|
||||
@@ -660,4 +660,18 @@ class _Item extends \IPS\Content\Item implements
|
||||
|
||||
return count( $images ) ? $images : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
parent::delete();
|
||||
|
||||
/* Recount category info */
|
||||
$this->container()->resetCommentCounts();
|
||||
$this->container()->save();
|
||||
}
|
||||
}
|
||||
@@ -174,11 +174,21 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
*/
|
||||
protected function get__comments()
|
||||
{
|
||||
$comments = $this->count_comments;
|
||||
return (int) $this->count_comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get number of content comments (including children)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get__commentsForDisplay()
|
||||
{
|
||||
$comments = $this->_comments;
|
||||
|
||||
foreach( $this->children() as $child )
|
||||
{
|
||||
$comments += $child->count_comments;
|
||||
$comments += $child->_comments;
|
||||
}
|
||||
|
||||
return $comments;
|
||||
@@ -796,6 +806,17 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
return parent::deleteOrMoveFormSubmit( $values );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Default Values
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultValues()
|
||||
{
|
||||
$this->sort_options = 'album_last_img_date';
|
||||
$this->sort_options_img = 'updated';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template for node tables
|
||||
*
|
||||
@@ -900,6 +921,19 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_allow_albums', $this->id ? $this->allow_albums : TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_allow_comments', $this->id ? $this->allow_comments : TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_allow_reviews', $this->id ? $this->allow_reviews : FALSE ) );
|
||||
|
||||
$sortoptions = array(
|
||||
'album_last_img_date' => 'sort_updated',
|
||||
'album_last_comment' => 'sort_last_comment',
|
||||
'album_rating_aggregate' => 'sort_rating',
|
||||
'album_comments' => 'sort_num_comments',
|
||||
'album_reviews' => 'sort_num_reviews',
|
||||
'album_name' => 'sort_album_name',
|
||||
'album_count_comments' => 'sort_album_count_comments',
|
||||
'album_count_imgs' => 'sort_album_count_imgs'
|
||||
);
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'category_sort_options', $this->sort_options ?: 'updated', FALSE, array( 'options' => $sortoptions ), NULL, NULL, NULL, 'category_sort_options' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'category_sort_options_img', $this->sort_options_img ?: '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, 'category_sort_options_img' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -914,6 +948,8 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$this->allow_albums = $values['category_allow_albums'];
|
||||
$this->allow_comments = $values['category_allow_comments'];
|
||||
$this->allow_reviews = $values['category_allow_reviews'];
|
||||
$this->sort_options = $values['category_sort_options'];
|
||||
$this->sort_options_img = $values['category_sort_options_img'];
|
||||
$this->can_tag = TRUE;
|
||||
$this->tag_prefixes = TRUE;
|
||||
|
||||
|
||||
@@ -646,7 +646,8 @@ class _Image extends \IPS\Content\Item implements
|
||||
{
|
||||
if( $filter->itemClass == 'IPS\\gallery\\Image' )
|
||||
{
|
||||
$filter->containerClasses = array( 'IPS\\gallery\\Category' );
|
||||
/* container class can be category or album */
|
||||
$filter->containerClasses = array( 'IPS\\gallery\\Category', 'IPS\\gallery\\Album' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -855,9 +856,9 @@ class _Image extends \IPS\Content\Item implements
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Images on same date
|
||||
* @brief Images that match the current one based on the current sort
|
||||
*/
|
||||
protected $imagesSameDate = NULL;
|
||||
protected $imagesSameSort = NULL;
|
||||
|
||||
/**
|
||||
* Get the next or previous 5 images in the container
|
||||
@@ -874,37 +875,42 @@ 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 ];
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( 'image_category_id=?', $this->category_id );
|
||||
$where[] = array( 'image_album_id=?', 0 );
|
||||
$sortBy = static::$databaseColumnMap[ $this->directContainer()->sort_options_img ?: 'updated' ];
|
||||
}
|
||||
|
||||
$where['id'] = array( 'image_id<>?', $this->id );
|
||||
|
||||
$column = $this->getDateColumn();
|
||||
|
||||
if( $this->imagesSameDate === NULL )
|
||||
if( $sortBy == 'caption' )
|
||||
{
|
||||
$where['date'] = array( static::$databasePrefix . $column . '= ?', $this->$column );
|
||||
$this->imagesSameDate = \IPS\Db::i()->select( 'COUNT(*)', 'gallery_images', $where )->first();
|
||||
$direction = ( $direction == 'ASC' ) ? 'DESC' : 'ASC';
|
||||
$dir = ( $dir == '>' ) ? '<' : '>';
|
||||
}
|
||||
|
||||
if( !$this->imagesSameDate )
|
||||
if( $this->imagesSameSort === NULL )
|
||||
{
|
||||
$where['date'] = array( static::$databasePrefix . $column . " {$dir}= ?", $this->$column );
|
||||
return iterator_to_array( \IPS\gallery\Image::getItemsWithPermission( $where, static::$databasePrefix . $column . ' ' . $direction, $count ) );
|
||||
$where['date'] = array( static::$databasePrefix . $sortBy . '= ?', $this->$sortBy );
|
||||
$this->imagesSameSort = \IPS\Db::i()->select( 'COUNT(*)', 'gallery_images', $where )->first();
|
||||
}
|
||||
|
||||
if( !$this->imagesSameSort )
|
||||
{
|
||||
$where['date'] = array( static::$databasePrefix . $sortBy . " {$dir}= ?", $this->$sortBy );
|
||||
return iterator_to_array( \IPS\gallery\Image::getItemsWithPermission( $where, static::$databasePrefix . $sortBy . ' ' . $direction . ', image_id ' . $direction, $count ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where['date'] = array( static::$databasePrefix . $column . '= ?', $this->$column );
|
||||
unset( $where['id'] );
|
||||
|
||||
$results = array();
|
||||
$seen = FALSE;
|
||||
|
||||
foreach( \IPS\gallery\Image::getItemsWithPermission( $where, static::$databasePrefix . $column . ' ' . $direction, NULL ) as $image )
|
||||
foreach( \IPS\gallery\Image::getItemsWithPermission( $where, static::$databasePrefix . $sortBy . ' ' . $direction . ', image_id ' . $direction, NULL ) as $image )
|
||||
{
|
||||
if( !$seen )
|
||||
{
|
||||
@@ -926,8 +932,8 @@ class _Image extends \IPS\Content\Item implements
|
||||
|
||||
if( count( $results ) < $count )
|
||||
{
|
||||
$where['date'] = array( static::$databasePrefix . $column . " {$dir} ?", $this->$column );
|
||||
$results = array_merge( $results, iterator_to_array( \IPS\gallery\Image::getItemsWithPermission( $where, static::$databasePrefix . $column . ' ' . $direction, $count - count( $results ) ) ) );
|
||||
$where['date'] = array( static::$databasePrefix . $sortBy . " {$dir} ?", $this->$sortBy );
|
||||
$results = array_merge( $results, iterator_to_array( \IPS\gallery\Image::getItemsWithPermission( $where, static::$databasePrefix . $sortBy . ' ' . $direction, $count - count( $results ) ) ) );
|
||||
}
|
||||
|
||||
return $results;
|
||||
@@ -1371,6 +1377,12 @@ class _Image extends \IPS\Content\Item implements
|
||||
*/
|
||||
public function deleteThumbnails()
|
||||
{
|
||||
/* We don't delete thumbnails for videos */
|
||||
if( $this->media )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach( array( 'masked_file_name', 'small_file_name' ) as $size )
|
||||
{
|
||||
if( isset( $this->_data[ $size ] ) AND $this->$size AND $this->$size != $this->original_file_name )
|
||||
|
||||
@@ -50,6 +50,19 @@ class _Table extends \IPS\Helpers\Table\Content
|
||||
return parent::__construct( $class, $baseUrl, $where, $container, $includeHidden, $permCheck, $honorPinned );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows
|
||||
*
|
||||
* @param array $advancedSearchValues Values from the advanced search form
|
||||
* @return array
|
||||
*/
|
||||
public function getRows( $advancedSearchValues )
|
||||
{
|
||||
$this->sortOptions['title'] = $this->sortOptions['title'] . ' ASC, image_id ';
|
||||
|
||||
return parent::getRows( $advancedSearchValues );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form to move images
|
||||
*
|
||||
@@ -225,21 +238,4 @@ class _Table extends \IPS\Helpers\Table\Content
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the sort direction to use for links
|
||||
*
|
||||
* @note Abstracted so other table helper instances can adjust as needed
|
||||
* @param string $column Sort by string
|
||||
* @return string [asc|desc]
|
||||
*/
|
||||
public function getSortDirection( $column )
|
||||
{
|
||||
if( $column == 'image_caption' )
|
||||
{
|
||||
return 'asc';
|
||||
}
|
||||
|
||||
return 'desc';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user