Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -157,7 +157,12 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
|
||||
if ( !$obj->can( $perm ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
/* If we are adding and the member has mod permissions to edit in the category, they can create an album for another user. In that case
|
||||
we need to allow the add permissions or they won't be able to add images to the new album */
|
||||
if( $perm != 'add' OR !\IPS\gallery\Album\Item::modPermission( 'edit', $member, $obj->category() ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
|
||||
return $obj;
|
||||
@@ -555,7 +560,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
|
||||
$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' );
|
||||
$return[] = new \IPS\Helpers\Form\CheckboxSet( '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' );
|
||||
|
||||
$return[] = new \IPS\Helpers\Form\Select( 'album_sort_options', ( $album and $album->sort_options ) ? $album->sort_options : '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, 'album_sort_options' );
|
||||
|
||||
@@ -1494,4 +1499,17 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
|
||||
return array( \IPS\Theme::i()->getTemplate( 'global', 'gallery' ), 'manageFollowNodeRow' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title for a node using the specified language object
|
||||
* This is commonly used where we cannot use the logged in member's language, such as sending emails
|
||||
*
|
||||
* @param \IPS\Lang $language Language object to fetch the title with
|
||||
* @param array $options What options to use for language parsing
|
||||
* @return string
|
||||
*/
|
||||
public function getTitleForLanguage( $language, $options=array() )
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* Album Comment Model
|
||||
*/
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable, \IPS\Content\Anonymous
|
||||
{
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
@@ -58,7 +58,8 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
'edit_time' => 'edit_time',
|
||||
'edit_member_name' => 'edit_name',
|
||||
'edit_show' => 'append_edit',
|
||||
'approved' => 'approved'
|
||||
'approved' => 'approved',
|
||||
'is_anon' => 'is_anon'
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -141,7 +142,7 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
* @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( \IPS\gallery\Album\Item::$urlBase . $indexData['index_item_id'], 'front', \IPS\gallery\Album\Item::$urlTemplate, \IPS\Http\Url\Friendly::seoTitle( $indexData['index_title'] ?: $itemData[ \IPS\gallery\Album\Item::$databasePrefix . \IPS\gallery\Album\Item::$databaseColumnMap['title'] ] ) );
|
||||
$images = ( isset( $itemData['extra'] ) AND \count( $itemData['extra'] ) ) ? $itemData['extra'] : array();
|
||||
|
||||
@@ -469,7 +469,7 @@ class _Item 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'] ] ) );
|
||||
$images = ( isset( $itemData['extra'] ) AND \count( $itemData['extra'] ) ) ? $itemData['extra'] : array();
|
||||
|
||||
@@ -124,7 +124,7 @@ class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \
|
||||
* @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 )
|
||||
{
|
||||
return \IPS\gallery\Album\Comment::searchResultSnippet( $indexData, $authorData, $itemData, $containerData, $reputationData, $reviewRating, $view );
|
||||
}
|
||||
|
||||
@@ -319,6 +319,8 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_watermark', $this->id ? $this->watermark : TRUE, FALSE ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'allow_anonymous_comments', $this->id ? $this->allow_anonymous : FALSE, FALSE, array() ) );
|
||||
|
||||
$form->addHeader( 'category_comments_and_ratings' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_allow_comments', $this->id ? $this->allow_comments : TRUE, FALSE, array( 'togglesOn' => array( 'category_approve_com' ) ), NULL, NULL, NULL, 'category_allow_comments' ) );
|
||||
@@ -380,7 +382,13 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$values['category_parent_id'] = $values['gcategory_parent_id'];
|
||||
unset( $values['gcategory_parent_id'] );
|
||||
}
|
||||
|
||||
|
||||
if( isset( $values['allow_anonymous_comments'] ) )
|
||||
{
|
||||
$values['allow_anonymous'] = ( $values['allow_anonymous_comments'] ? 2 : 0 );
|
||||
unset( $values['allow_anonymous_comments'] );
|
||||
}
|
||||
|
||||
/* If watermarks are disabled, enable them at the category level so that if you later enable watermarks they work in your existing categories */
|
||||
if( !\IPS\Settings::i()->gallery_watermark_path )
|
||||
{
|
||||
@@ -573,16 +581,19 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
/* Reset counts */
|
||||
$this->resetCommentCounts();
|
||||
$this->commentCountsReset = TRUE;
|
||||
|
||||
/* Reset last image */
|
||||
if( $image === NULL )
|
||||
{
|
||||
try
|
||||
{
|
||||
$image = \IPS\gallery\Image::constructFromData( \IPS\Db::i()->select( '*', 'gallery_images', array( 'image_category_id=? AND image_approved=1 AND ( image_album_id = 0 OR album_type NOT IN ( 2, 3 ) )', $this->id ), 'image_date DESC', 1, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->join(
|
||||
$result = \IPS\Db::i()->select( '*', 'gallery_images', array( 'image_category_id=? AND image_approved=1 AND ( image_album_id = 0 OR album_type NOT IN ( 2, 3 ) )', $this->id ), 'image_date DESC', 1, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->join(
|
||||
'gallery_albums',
|
||||
"image_album_id=album_id"
|
||||
)->first() );
|
||||
)->first();
|
||||
|
||||
$image = \IPS\gallery\Image::constructFromData( $result );
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
@@ -597,12 +608,17 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
|
||||
if( $image->album_id )
|
||||
{
|
||||
$album = \IPS\gallery\Album::load( $image->album_id );
|
||||
$album->setLastImage( $image );
|
||||
$album = \IPS\gallery\Album::constructFromData( $result );
|
||||
$album->setLastImage();
|
||||
$album->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Track if we've already reset comment counts so we don't do it more than once between saves
|
||||
*/
|
||||
protected $commentCountsReset = FALSE;
|
||||
|
||||
/**
|
||||
* Set the comment/approved/hidden counts
|
||||
*
|
||||
@@ -610,6 +626,11 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
*/
|
||||
public function resetCommentCounts()
|
||||
{
|
||||
if( $this->commentCountsReset )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
parent::resetCommentCounts();
|
||||
|
||||
/* If we allow albums, add album comment/review counts too */
|
||||
@@ -625,14 +646,27 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
catch( \UnderflowException $e ){}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Save Changed Columns
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
parent::save();
|
||||
|
||||
$this->commentCountsReset = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get last comment time
|
||||
*
|
||||
* @note This should return the last comment time for this node only, not for children nodes
|
||||
* @param \IPS\Member|NULL $member MemberObject
|
||||
* @return \IPS\DateTime|NULL
|
||||
*/
|
||||
public function getLastCommentTime()
|
||||
public function getLastCommentTime( \IPS\Member $member = NULL )
|
||||
{
|
||||
return $this->last_img_date ? \IPS\DateTime::ts( $this->last_img_date ) : NULL;
|
||||
}
|
||||
@@ -842,42 +876,9 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If we cannot create albums, make sure at least one category does not require them */
|
||||
if( $permission == 'add' AND !$member->group['g_create_albums'] )
|
||||
{
|
||||
$where[] = array( 'gallery_categories.category_allow_albums != ?', 2 );
|
||||
}
|
||||
|
||||
return parent::canOnAny( $permission, $member, $where, $considerPostBeforeRegistering );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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
|
||||
*/
|
||||
public function can( $permission, $member=NULL, $considerPostBeforeRegistering = TRUE )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$result = parent::can( $permission, $member, $considerPostBeforeRegistering );
|
||||
|
||||
if( $result === FALSE )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( $permission == 'add' AND $this->allow_albums == 2 AND !$member->group['g_create_albums'] )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Duplicate
|
||||
*
|
||||
@@ -916,6 +917,16 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
return 'x';
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get the fully qualified node type (mostly for Pages because Pages is Pages)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function fullyQualifiedType()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('__app_gallery') . ' ' . \IPS\Member::loggedIn()->language()->addToStack( static::$nodeTitle . '_sg');
|
||||
}
|
||||
|
||||
/* !Clubs */
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* Image Comment Model
|
||||
*/
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable, \IPS\Content\Anonymous
|
||||
{
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
@@ -68,7 +68,8 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
'edit_time' => 'edit_time',
|
||||
'edit_member_name' => 'edit_name',
|
||||
'edit_show' => 'append_edit',
|
||||
'approved' => 'approved'
|
||||
'approved' => 'approved',
|
||||
'is_anon' => 'is_anon'
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -110,7 +111,11 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
*/
|
||||
public static function getItemsWithPermission( $where=array(), $order=NULL, $limit=10, $permissionKey='read', $includeHiddenItems=\IPS\Content\Hideable::FILTER_AUTOMATIC, $queryFlags=0, \IPS\Member $member=NULL, $joinContainer=FALSE, $joinComments=FALSE, $joinReviews=FALSE, $countOnly=FALSE, $joins=NULL )
|
||||
{
|
||||
$where[] = \IPS\gallery\Image::getItemsWithPermissionWhere( $where, $member, $joins );
|
||||
if( $itemsWhere = \IPS\gallery\Image::getItemsWithPermissionWhere( $where, $member, $joins ) AND \count( $itemsWhere ) )
|
||||
{
|
||||
$where[] = $itemsWhere;
|
||||
}
|
||||
|
||||
return parent::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHiddenItems, $queryFlags, $member, $joinContainer, $joinComments, $joinReviews, $countOnly, $joins );
|
||||
}
|
||||
|
||||
@@ -155,7 +160,7 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
* @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( \IPS\gallery\Image::$urlBase . $indexData['index_item_id'], 'front', \IPS\gallery\Image::$urlTemplate, \IPS\Http\Url\Friendly::seoTitle( $indexData['index_title'] ?: $itemData[ \IPS\gallery\Image::$databasePrefix . \IPS\gallery\Image::$databaseColumnMap['title'] ] ) );
|
||||
|
||||
|
||||
@@ -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' ) )
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \
|
||||
* @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 )
|
||||
{
|
||||
return \IPS\gallery\Image\Comment::searchResultSnippet( $indexData, $authorData, $itemData, $containerData, $reputationData, $reviewRating, $view );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user