Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Image Model
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Gallery
|
||||
* @since 04 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\gallery;
|
||||
@@ -25,7 +24,6 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
class _Image extends \IPS\Content\Item implements
|
||||
\IPS\Content\Permissions,
|
||||
\IPS\Content\Tags,
|
||||
\IPS\Content\Reputation,
|
||||
\IPS\Content\Followable,
|
||||
\IPS\Content\ReportCenter,
|
||||
\IPS\Content\ReadMarkers,
|
||||
@@ -34,8 +32,11 @@ class _Image extends \IPS\Content\Item implements
|
||||
\IPS\Content\Shareable,
|
||||
\IPS\Content\Ratings,
|
||||
\IPS\Content\Searchable,
|
||||
\IPS\Content\Embeddable
|
||||
\IPS\Content\Embeddable,
|
||||
\IPS\Content\MetaData
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
@@ -110,6 +111,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
'num_reviews' => 'reviews',
|
||||
'unapproved_reviews' => 'unapproved_reviews',
|
||||
'hidden_reviews' => 'hidden_reviews',
|
||||
'meta_data' => 'meta_data'
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -127,11 +129,6 @@ class _Image extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static $formLangPrefix = 'image_';
|
||||
|
||||
/**
|
||||
* @brief Reputation Type
|
||||
*/
|
||||
public static $reputationType = 'image_id';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
@@ -383,7 +380,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
$unread = FALSE;
|
||||
|
||||
/* Some generic moderator permissions */
|
||||
if ( $this->canSeeMultiModTools() )
|
||||
if ( $this->canSeeMultiModTools() OR ( $this->container()->club() AND $this->container()->club()->isModerator() ) )
|
||||
{
|
||||
if( $this->canMove() )
|
||||
{
|
||||
@@ -542,12 +539,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static function contentTableTemplate()
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'gallery.css', 'gallery', 'front' ) );
|
||||
|
||||
if ( \IPS\Theme::i()->settings['responsive'] )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'gallery_responsive.css', 'gallery', 'front' ) );
|
||||
}
|
||||
\IPS\gallery\Application::outputCss();
|
||||
|
||||
return array( \IPS\Theme::i()->getTemplate( 'browse', 'gallery' ), 'tableRowsRows' );
|
||||
}
|
||||
@@ -573,11 +565,11 @@ class _Image extends \IPS\Content\Item implements
|
||||
|
||||
if ( $this->container()->allow_reviews AND $this->directContainer()->allow_reviews )
|
||||
{
|
||||
$tabs['reviews'] = \IPS\Member::loggedIn()->language()->pluralize( \IPS\Member::loggedIn()->language()->get( 'image_review_count' ), array( $this->mapped('num_reviews') ) );
|
||||
$tabs['reviews'] = \IPS\Member::loggedIn()->language()->addToStack( 'image_review_count', TRUE, array( 'pluralize' => array( $this->mapped('num_reviews') ) ) );
|
||||
}
|
||||
if ( $this->container()->allow_comments AND $this->directContainer()->allow_comments )
|
||||
{
|
||||
$tabs['comments'] = \IPS\Member::loggedIn()->language()->pluralize( \IPS\Member::loggedIn()->language()->get( 'image_comment_count' ), array( $this->mapped('num_comments') ) );
|
||||
$tabs['comments'] = \IPS\Member::loggedIn()->language()->addToStack( 'image_comment_count', TRUE, array( 'pluralize' => array( $this->mapped('num_comments') ) ) );
|
||||
}
|
||||
|
||||
return $tabs;
|
||||
@@ -620,6 +612,65 @@ class _Image extends \IPS\Content\Item implements
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the container class to store in the search index
|
||||
*
|
||||
* @return \IPS\Node\Model|NULL
|
||||
*/
|
||||
public function searchIndexContainerClass()
|
||||
{
|
||||
return $this->directContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Give class a chance to inspect and manipulate search engine filters for streams
|
||||
*
|
||||
* @param array $filters Filters to be used for activity stream
|
||||
* @param \IPS\Content\Search\Query $query Search query object
|
||||
* @return void
|
||||
*/
|
||||
public static function searchEngineFiltering( &$filters, &$query )
|
||||
{
|
||||
/* Make sure our CSS is output */
|
||||
\IPS\gallery\Application::outputCss();
|
||||
|
||||
/* Loop through and see if we are also including albums */
|
||||
$includingAlbums = FALSE;
|
||||
|
||||
if( !count( $filters ) )
|
||||
{
|
||||
$includingAlbums = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach( $filters as $filter )
|
||||
{
|
||||
if( $filter->itemClass == 'IPS\\gallery\\Album\\Item' )
|
||||
{
|
||||
$includingAlbums = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $includingAlbums === TRUE )
|
||||
{
|
||||
if( count( $filters ) )
|
||||
{
|
||||
foreach( $filters as $k => $filter )
|
||||
{
|
||||
if( $filter->itemClass == 'IPS\\gallery\\Image' )
|
||||
{
|
||||
$filter->containerClasses = array( 'IPS\\gallery\\Category' );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->filterByContainerClasses( array( 'IPS\\gallery\\Album' ), array( 'IPS\\gallery\\Image\\Comment', 'IPS\\gallery\\Image\\Review' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Users to receive immediate notifications
|
||||
*
|
||||
@@ -1584,23 +1635,39 @@ class _Image extends \IPS\Content\Item implements
|
||||
/**
|
||||
* Are comments supported by this class?
|
||||
*
|
||||
* @param \IPS\Member\NULL $member The member to check for or NULL fto not check permission
|
||||
* @return int
|
||||
* @param \IPS\Member|NULL $member The member to check for or NULL to not check permission
|
||||
* @param \IPS\Node\Model|NULL $container The container to check in, or NULL for any container
|
||||
* @return bool
|
||||
*/
|
||||
public static function supportsComments( \IPS\Member $member = NULL )
|
||||
{
|
||||
return parent::supportsComments() and ( !$member or \IPS\gallery\Category::countWhere( 'read', $member, array( 'category_allow_comments=1' ) ) );
|
||||
public static function supportsComments( \IPS\Member $member = NULL, \IPS\Node\Model $container = NULL )
|
||||
{
|
||||
if( $container !== NULL )
|
||||
{
|
||||
return parent::supportsComments() and $container->allow_comments AND ( !$member or $container->can( 'read', $member ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::supportsComments() and ( !$member or \IPS\gallery\Category::countWhere( 'read', $member, array( 'category_allow_comments=1' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Are reviews supported by this class?
|
||||
*
|
||||
* @param \IPS\Member\NULL $member The member to check for or NULL to not check permission
|
||||
* @return int
|
||||
* @param \IPS\Member|NULL $member The member to check for or NULL to not check permission
|
||||
* @param \IPS\Node\Model|NULL $container The container to check in, or NULL for any container
|
||||
* @return bool
|
||||
*/
|
||||
public static function supportsReviews( \IPS\Member $member = NULL )
|
||||
public static function supportsReviews( \IPS\Member $member = NULL, \IPS\Node\Model $container = NULL )
|
||||
{
|
||||
return parent::supportsReviews() and ( !$member or \IPS\gallery\Category::countWhere( 'read', $member, array( 'category_allow_reviews=1' ) ) );
|
||||
if( $container !== NULL )
|
||||
{
|
||||
return parent::supportsReviews() and $container->allow_reviews AND ( !$member or $container->can( 'read', $member ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::supportsReviews() and ( !$member or \IPS\gallery\Category::countWhere( 'read', $member, array( 'category_allow_reviews=1' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1798,16 +1865,19 @@ class _Image extends \IPS\Content\Item implements
|
||||
}
|
||||
|
||||
/* Check if the image is in a private or restricted access album */
|
||||
if( !\IPS\gallery\Image::modPermission( 'edit', NULL, $this->container() ) AND $this->directcontainer() instanceof \IPS\gallery\Album )
|
||||
if( !\IPS\gallery\Image::modPermission( 'edit', NULL, $this->container() ) AND $this->directContainer() instanceof \IPS\gallery\Album )
|
||||
{
|
||||
/* Make sure we have a member */
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
/* Is this a private album we can't access? */
|
||||
if( $this->directcontainer()->type == 2 AND $this->directcontainer()->owner() != $member )
|
||||
if( $this->directContainer()->type == 2 AND $this->directContainer()->owner() != $member )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Is this a restricted album we can't access? */
|
||||
if( $this->directcontainer()->type == 3 AND $this->directcontainer()->owner() != $member )
|
||||
if( $this->directContainer()->type == 3 AND $this->directContainer()->owner() != $member )
|
||||
{
|
||||
/* This will throw an exception of the row does not exist */
|
||||
try
|
||||
@@ -1817,7 +1887,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
$member = \IPS\Db::i()->select( '*', 'core_sys_social_group_members', array( 'group_id=? AND member_id=?', $this->directcontainer()->allowed_access, $member->member_id ) )->first();
|
||||
$member = \IPS\Db::i()->select( '*', 'core_sys_social_group_members', array( 'group_id=? AND member_id=?', $this->directContainer()->allowed_access, $member->member_id ) )->first();
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
@@ -1831,6 +1901,15 @@ class _Image extends \IPS\Content\Item implements
|
||||
}
|
||||
}
|
||||
|
||||
/* And make sure we're not in a hidden album, unless we can view hidden albums */
|
||||
if( $this->directContainer() instanceof \IPS\gallery\Album )
|
||||
{
|
||||
if( !$this->directContainer()->asItem()->canView( $member ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1876,12 +1955,29 @@ class _Image extends \IPS\Content\Item implements
|
||||
/* 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 ) )
|
||||
{
|
||||
return array( "( gallery_albums.album_id IS NULL OR gallery_albums.album_type IN(1,2) OR ( gallery_albums.album_type=3 AND ( gallery_albums.album_owner_id=? OR gallery_albums.album_allowed_access IN (" . implode( ',', $restricted ) . ") ) ) )", $member->member_id );
|
||||
$result = array( "( gallery_albums.album_id IS NULL OR gallery_albums.album_type IN(1,2) OR ( gallery_albums.album_type=3 AND ( gallery_albums.album_owner_id=? OR gallery_albums.album_allowed_access IN (" . implode( ',', $restricted ) . ") ) ) )", $member->member_id );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 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 );
|
||||
$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 );
|
||||
}
|
||||
|
||||
/* 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 ) )
|
||||
{
|
||||
$result[0] .= " AND ( gallery_albums.album_id IS NULL OR gallery_albums.album_hidden=0 OR gallery_albums.album_category_id IN(" . implode( ',', $hiddenContainers ) . ") )";
|
||||
}
|
||||
else
|
||||
{
|
||||
$result[0] .= " AND ( gallery_albums.album_id IS NULL OR gallery_albums.album_hidden=0 )";
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1989,6 +2085,18 @@ class _Image extends \IPS\Content\Item implements
|
||||
return \IPS\File::get( 'gallery_Images', $this->thumb_file_name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content for embed
|
||||
*
|
||||
* @param array $params Additional parameters to add to URL
|
||||
* @return string
|
||||
*/
|
||||
public function embedContent( $params )
|
||||
{
|
||||
\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' )->embedImage( $this, $this->url()->setQueryString( $params ), $this->embedImage() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Index Permissions
|
||||
*
|
||||
@@ -2077,4 +2185,38 @@ class _Image extends \IPS\Content\Item implements
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
return parent::canReview( $member ) and $this->container()->allow_reviews and $this->directContainer()->allow_reviews;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reaction Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function reactionType()
|
||||
{
|
||||
return 'image_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Supported Meta Data Types
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function supportedMetaDataTypes()
|
||||
{
|
||||
return array( 'core_FeaturedComments', 'core_ContentMessages' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get widget sort options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getWidgetSortOptions()
|
||||
{
|
||||
$sortOptions = parent::getWidgetSortOptions();
|
||||
|
||||
$sortOptions['_rand'] = 'sort_rand';
|
||||
|
||||
return $sortOptions;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user