Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -31,10 +31,9 @@ class _Item extends \IPS\Content\Item implements
|
||||
\IPS\Content\Hideable,
|
||||
\IPS\Content\Featurable,
|
||||
\IPS\Content\Lockable,
|
||||
\IPS\Content\ReportCenter,
|
||||
\IPS\Content\MetaData
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
/**
|
||||
* @brief Application
|
||||
@@ -230,7 +229,7 @@ class _Item extends \IPS\Content\Item implements
|
||||
{
|
||||
if( $this->cover_img_id OR $this->last_img_id )
|
||||
{
|
||||
return \IPS\File::get( 'gallery_Images', \IPS\gallery\Image::load( $this->cover_img_id ?: $this->last_img_id )->thumb_file_name );
|
||||
return \IPS\File::get( 'gallery_Images', \IPS\gallery\Image::load( $this->cover_img_id ?: $this->last_img_id )->small_file_name );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -279,10 +278,48 @@ class _Item extends \IPS\Content\Item implements
|
||||
*/
|
||||
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, $skipPermission=FALSE, $joinTags=TRUE, $joinAuthor=TRUE, $joinLastCommenter=TRUE, $showMovedLinks=FALSE )
|
||||
{
|
||||
if( $permissionKey == 'add' )
|
||||
{
|
||||
$where[] = static::submitRestrictionWhere( $member, \IPS\gallery\Category::load( $where[0][1] ) );
|
||||
}
|
||||
|
||||
$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 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional WHERE clauses for finding albums the user can submit to
|
||||
*
|
||||
* @param \IPS\Member|NULL $member Member to check
|
||||
* @param \IPS\gallery\Category $category Category we are submitted in
|
||||
* @return string
|
||||
*/
|
||||
public static function submitRestrictionWhere( $member, $category )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
/* For starters, allow us to submit to public albums and our own albums */
|
||||
$wheres = array(
|
||||
'(album_submit_type=' . \IPS\gallery\Album::AUTH_SUBMIT_OWNER . ' and album_owner_id=' . $member->member_id . ')',
|
||||
'(album_submit_type=' . \IPS\gallery\Album::AUTH_SUBMIT_PUBLIC . ')'
|
||||
);
|
||||
|
||||
/* Now allow us to submit to albums that allow group submissions */
|
||||
$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() ) . ')';
|
||||
|
||||
/* 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() ) )
|
||||
{
|
||||
$wheres[] = '(album_submit_type=' . \IPS\gallery\Album::AUTH_SUBMIT_CLUB . ')';
|
||||
}
|
||||
|
||||
return '(album_owner_id=' . $member->member_id . ' OR ' . implode( ' OR ', $wheres ) . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cached groups the member can access
|
||||
*/
|
||||
@@ -368,24 +405,6 @@ class _Item extends \IPS\Content\Item implements
|
||||
return $this->asNode()->searchIndexPermissions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can edit?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public function canEdit( $member=NULL )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
if( $member->member_id == $this->mapped('author') )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return parent::canEdit( $member );
|
||||
}
|
||||
|
||||
/**
|
||||
* Columns needed to query for search result / stream view
|
||||
*
|
||||
@@ -433,8 +452,13 @@ class _Item extends \IPS\Content\Item implements
|
||||
|
||||
$return = array();
|
||||
|
||||
foreach ( \IPS\gallery\Image::getItemsWithPermission( array( array( 'image_id IN(' . implode( ',', $imageIds ) . ')' ) ), NULL, 20 ) as $image )
|
||||
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 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$return[ $image->album_id ][] = $image;
|
||||
}
|
||||
|
||||
@@ -464,6 +488,29 @@ class _Item extends \IPS\Content\Item implements
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'gallery', 'front' )->searchResultAlbumSnippet( $indexData, $itemData, $images, $url, $view == 'condensed' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the language string key to use in search results
|
||||
*
|
||||
* @note Normally we show "(user) posted a (thing) in (area)" but sometimes this may not be accurate, so this is abstracted to allow
|
||||
* content classes the ability to override
|
||||
* @param array $authorData Author data
|
||||
* @param array $articles Articles language strings
|
||||
* @param array $indexData Search index data
|
||||
* @param array $itemData Data about the item
|
||||
* @return string
|
||||
*/
|
||||
public static function searchResultSummaryLanguage( $authorData, $articles, $indexData, $itemData )
|
||||
{
|
||||
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'] ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::searchResultSummaryLanguage( $authorData, $articles, $indexData, $itemData );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A classname applied to the search result block
|
||||
*/
|
||||
@@ -516,7 +563,7 @@ class _Item extends \IPS\Content\Item implements
|
||||
{
|
||||
\IPS\gallery\Application::outputCss();
|
||||
|
||||
return array( \IPS\Theme::i()->getTemplate( 'browse', 'gallery' ), 'albums' );
|
||||
return array( \IPS\Theme::i()->getTemplate( 'browse', 'gallery', 'front' ), 'albums' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -581,4 +628,36 @@ class _Item extends \IPS\Content\Item implements
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'embed.css', 'gallery', 'front' ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'gallery' )->embedAlbums( $this, $this->asNode(), $this->url()->setQueryString( $params ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the container item class to use for mod permission checks
|
||||
*
|
||||
* @return string|NULL
|
||||
* @note By default we will return NULL and the container check will execute against Node::$contentItemClass, however
|
||||
* in some situations we may need to override this (i.e. for Gallery Albums)
|
||||
*/
|
||||
protected static function getContainerModPermissionClass()
|
||||
{
|
||||
return 'IPS\gallery\Album\Item';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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', ... );
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function contentImages( $limit = NULL )
|
||||
{
|
||||
$images = array();
|
||||
|
||||
foreach( \IPS\gallery\Image::getItemsWithPermission( array( array( 'image_album_id=?', $this->id ) ), NULL, $limit ? $limit : 10 ) as $image )
|
||||
{
|
||||
$images[] = array( 'gallery_Images' => $image->masked_file_name );
|
||||
}
|
||||
|
||||
return count( $images ) ? $images : NULL;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user