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 Album Node
|
||||
* @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;
|
||||
@@ -30,7 +29,8 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
const AUTH_TYPE_PUBLIC = 1;
|
||||
const AUTH_TYPE_PRIVATE = 2;
|
||||
const AUTH_TYPE_RESTRICTED = 3;
|
||||
|
||||
const AUTH_TYPE_DELETED = 4;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
@@ -56,6 +56,11 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
*/
|
||||
public static $nodeTitle = 'albums';
|
||||
|
||||
/**
|
||||
* @brief [Node] Node Database Order Column
|
||||
*/
|
||||
public static $databaseColumnOrder = 'name';
|
||||
|
||||
/**
|
||||
* @brief [Node] Sortable?
|
||||
*/
|
||||
@@ -80,6 +85,23 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
'rating_hits' => 'rating_count',
|
||||
);
|
||||
|
||||
/**
|
||||
* Return this album as a content item instead of a node
|
||||
*
|
||||
* @return \IPS\gallery\Album\Item
|
||||
*/
|
||||
public function asItem()
|
||||
{
|
||||
$data = $this->_data;
|
||||
|
||||
foreach( $this->_data as $k => $v )
|
||||
{
|
||||
$data['album_' . $k ] = $v;
|
||||
}
|
||||
|
||||
return \IPS\gallery\Album\Item::constructFromData( $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Return the owner if this node can be owned
|
||||
*
|
||||
@@ -109,13 +131,18 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
*/
|
||||
public static function loadAndCheckPerms( $id, $perm='view' )
|
||||
{
|
||||
$obj = static::load( $id );
|
||||
$obj = parent::loadAndCheckPerms( $id );
|
||||
|
||||
if ( !$obj->category()->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() ) )
|
||||
{
|
||||
@@ -147,6 +174,21 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all nodes owned by a given user
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member whose nodes to load
|
||||
* @param array $where Initial where clause
|
||||
* @return array
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public static function loadByOwner( $member=NULL, $where=array() )
|
||||
{
|
||||
$where[] = array( 'album_type !=?', static::AUTH_TYPE_DELETED );
|
||||
|
||||
return parent::loadByOwner( $member, $where );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cached approved members
|
||||
@@ -458,15 +500,25 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
|
||||
$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' => 'sort_title', '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' );
|
||||
|
||||
$return[] = new \IPS\Helpers\Form\YesNo( 'album_allow_rating', $album ? $album->allow_rating : TRUE, FALSE );
|
||||
|
||||
if( ( ( $album and $album->category_id ) and ( \IPS\gallery\Category::load( $album->category_id )->allow_comments ) ) or ( ( isset( \IPS\Request::i()->chosenCategory ) or isset( \IPS\Request::i()->category ) ) and \IPS\gallery\Category::load( (int) \IPS\Request::i()->chosenCategory ?: \IPS\Request::i()->category )->allow_comments ) )
|
||||
{
|
||||
$return[] = new \IPS\Helpers\Form\YesNo('album_allow_comments', $album ? $album->allow_comments : TRUE, FALSE);
|
||||
}
|
||||
$return[] = new \IPS\Helpers\Form\YesNo( 'album_allow_rating', $album ? $album->allow_rating : TRUE, FALSE );
|
||||
if( ( ( $album and $album->category_id ) and ( \IPS\gallery\Category::load( $album->category_id )->allow_reviews ) ) or ( ( isset( \IPS\Request::i()->chosenCategory ) or isset( \IPS\Request::i()->category ) ) and \IPS\gallery\Category::load( (int) \IPS\Request::i()->chosenCategory ?: \IPS\Request::i()->category )->allow_reviews ) )
|
||||
{
|
||||
$return[] = new \IPS\Helpers\Form\YesNo('album_allow_reviews', $album ? $album->allow_reviews : TRUE, FALSE);
|
||||
}
|
||||
|
||||
if( ( ( $album and $album->category_id ) and ( \IPS\gallery\Category::load( $album->category_id )->allow_comments ) ) or ( ( isset( \IPS\Request::i()->chosenCategory ) or isset( \IPS\Request::i()->category ) ) and \IPS\gallery\Category::load( (int) \IPS\Request::i()->chosenCategory ?: \IPS\Request::i()->category )->allow_comments ) )
|
||||
{
|
||||
$return[] = new \IPS\Helpers\Form\YesNo('album_use_comments', $album ? $album->use_comments : TRUE, FALSE );
|
||||
}
|
||||
if( ( ( $album and $album->category_id ) and ( \IPS\gallery\Category::load( $album->category_id )->allow_reviews ) ) or ( ( isset( \IPS\Request::i()->chosenCategory ) or isset( \IPS\Request::i()->category ) ) and \IPS\gallery\Category::load( (int) \IPS\Request::i()->chosenCategory ?: \IPS\Request::i()->category )->allow_reviews ) )
|
||||
{
|
||||
$return[] = new \IPS\Helpers\Form\YesNo('album_use_reviews', $album ? $album->use_reviews : TRUE, FALSE );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -631,7 +683,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
* Move to a different category
|
||||
*
|
||||
* @param \IPS\gallery\Category $newCategory New category
|
||||
* @pram \IPS\gallery\Category|NULL $existingCategory Old category
|
||||
* @param \IPS\gallery\Category|NULL $existingCategory Old category
|
||||
* @return void
|
||||
*/
|
||||
public function moveTo( \IPS\gallery\Category $newCategory, \IPS\gallery\Category $existingCategory = NULL )
|
||||
@@ -665,6 +717,21 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
'tag_perm_aap_lookup' => md5( 'gallery;category;' . $newCategory->_id ),
|
||||
'tag_perm_text' => \IPS\Db::i()->select( 'perm_2', 'core_permission_index', array( 'app=? AND perm_type=? AND perm_type_id=?', 'gallery', 'category', $newCategory->_id ) )->first()
|
||||
), array( 'tag_perm_aap_lookup=?', md5( 'gallery;category;' . $existingCategory->_id ) ) );
|
||||
|
||||
/* Load the item */
|
||||
$asItem = $this->asItem();
|
||||
|
||||
/* Add to search index */
|
||||
\IPS\Content\Search\Index::i()->index( $asItem );
|
||||
|
||||
foreach ( array( 'commentClass', 'reviewClass' ) as $class )
|
||||
{
|
||||
$className = \IPS\gallery\Album\Item::$$class;
|
||||
\IPS\Content\Search\Index::i()->massUpdate( $className, NULL, $this->id, $this->searchIndexPermissions(), NULL, $newCategory->_id );
|
||||
}
|
||||
|
||||
/* Update caches */
|
||||
$asItem->expireWidgetCaches();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -761,7 +828,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
|
||||
$this->last_x_images = json_encode( $_latestImages );
|
||||
|
||||
/* Now get the counts and set them */
|
||||
/* Now get the counts and set them for our images */
|
||||
$this->_items = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_images', array( 'image_album_id=? AND image_approved=1', $this->id ) )->first();
|
||||
$this->_unapprovedItems = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_images', array( 'image_album_id=? AND image_approved=0', $this->id ) )->first();
|
||||
|
||||
@@ -770,8 +837,40 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
|
||||
$this->_reviews = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_reviews', array( 'gallery_images.image_album_id=? AND review_approved=1', $this->id ) )->join( 'gallery_images', 'image_id=review_image_id' )->first();
|
||||
$this->_unapprovedReviews = \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_reviews', array( 'gallery_images.image_album_id=? AND review_approved=0', $this->id ) )->join( 'gallery_images', 'image_id=review_image_id' )->first();
|
||||
}
|
||||
|
||||
/* And then get counts/latest data for the direct comments/reviews */
|
||||
$this->comments = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_comments', array( 'comment_album_id=? AND comment_approved=1', $this->id ) )->first();
|
||||
$this->comments_unapproved = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_comments', array( 'comment_album_id=? AND comment_approved=0', $this->id ) )->first();
|
||||
$this->comments_hidden = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_comments', array( 'comment_album_id=? AND comment_approved=-1', $this->id ) )->first();
|
||||
|
||||
$this->reviews = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_reviews', array( 'review_album_id=? AND review_approved=1', $this->id ) )->first();
|
||||
$this->reviews_unapproved = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_reviews', array( 'review_album_id=? AND review_approved=0', $this->id ) )->first();
|
||||
$this->reviews_hidden = (int) \IPS\Db::i()->select( 'COUNT(*) as total', 'gallery_album_reviews', array( 'review_album_id=? AND review_approved=-1', $this->id ) )->first();
|
||||
|
||||
/* Save and then make sure search index is updated */
|
||||
\IPS\Content\Search\Index::i()->index( $this->asItem() );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->medium_file_name );
|
||||
}
|
||||
|
||||
return count( $images ) ? $images : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the latest images
|
||||
*
|
||||
@@ -857,6 +956,9 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
\IPS\Db::i()->update( 'calendar_events', array( 'event_album' => 0 ), array( 'event_album=?', $this->id ) );
|
||||
}
|
||||
|
||||
/* Delete as an item to remove comments, meta data, search index, reviews, etc. */
|
||||
$this->asItem()->delete();
|
||||
|
||||
/* Update category information */
|
||||
if( $this->type == static::AUTH_TYPE_PUBLIC )
|
||||
{
|
||||
@@ -884,22 +986,42 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
/**
|
||||
* Retrieve content items (if applicable) for a node.
|
||||
*
|
||||
* @param int $limit The limit
|
||||
* @param int $offset The offset
|
||||
* @param array $additionalWhere Additional where clauses
|
||||
* @return \IPS\Patterns\ActiveRecordIterator
|
||||
* @param int $limit The limit
|
||||
* @param int $offset The offset
|
||||
* @param array $additional Where Additional where clauses
|
||||
* @param int $countOnly If TRUE, will get the number of results
|
||||
* @return \IPS\Patterns\ActiveRecordIterator|int
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function getContentItems( $limit, $offset, $additionalWhere = array() )
|
||||
public function getContentItems( $limit, $offset, $additionalWhere = array(), $countOnly=FALSE )
|
||||
{
|
||||
if ( !isset( static::$contentItemClass ) )
|
||||
{
|
||||
throw new \BadMethodCallException;
|
||||
}
|
||||
|
||||
|
||||
$contentItemClass = static::$contentItemClass;
|
||||
$limit = ( $offset !== NULL ) ? array( $offset, $limit ) : NULL;
|
||||
return new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', $contentItemClass::$databaseTable, array( $contentItemClass::$databasePrefix . 'album_id=?', $this->_id ), $contentItemClass::$databasePrefix . $contentItemClass::$databaseColumnId, $limit ), $contentItemClass );
|
||||
|
||||
$where = array();
|
||||
$where[] = array( $contentItemClass::$databasePrefix . 'album_id=?', $this->_id );
|
||||
|
||||
if ( count( $additionalWhere ) )
|
||||
{
|
||||
foreach( $additionalWhere AS $clause )
|
||||
{
|
||||
$where[] = $clause;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $countOnly )
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', $contentItemClass::$databaseTable, $where )->first();
|
||||
}
|
||||
else
|
||||
{
|
||||
$limit = ( $offset !== NULL ) ? array( $offset, $limit ) : NULL;
|
||||
return new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', $contentItemClass::$databaseTable, $where, $contentItemClass::$databasePrefix . $contentItemClass::$databaseColumnId, $limit ), $contentItemClass );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -938,7 +1060,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
|
||||
if( $size == 'full' )
|
||||
{
|
||||
$size = 'masked';
|
||||
$size = 'masked';
|
||||
}
|
||||
|
||||
$property = $size . "_file_name";
|
||||
@@ -953,7 +1075,7 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( !in_array( $size, array( 'full', 'medium', 'small', 'thumb' ) ) )
|
||||
if( !in_array( $size, array( 'masked', 'medium', 'small', 'thumb' ) ) )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
@@ -1024,6 +1146,30 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
*/
|
||||
public function can( $permission, $member=NULL )
|
||||
{
|
||||
/* Load the item */
|
||||
$asItem = $this->asItem();
|
||||
|
||||
/* 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 );
|
||||
}
|
||||
}
|
||||
|
||||
/* We'll just rely on category permissions if the album isn't hidden */
|
||||
try
|
||||
{
|
||||
return $this->category()->can( $permission, $member );
|
||||
@@ -1096,27 +1242,11 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
*/
|
||||
public static function nodeTableTemplate()
|
||||
{
|
||||
\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' ), 'albums' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content for embed
|
||||
*
|
||||
* @param array $params Additional parameters to add to URL
|
||||
* @return string
|
||||
*/
|
||||
public function embedContent( $params )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'gallery' )->embedAlbums( $this, $this->url()->setQueryString( $params ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
@@ -1143,8 +1273,20 @@ class _Album extends \IPS\Node\Model implements \IPS\Node\Ratings, \IPS\Content\
|
||||
'approvedMembers' => $this->approvedMembers ? array_map( function( $val ) {
|
||||
return $val->apiOutput();
|
||||
}, $this->approvedMembers ) : null,
|
||||
'images' => $this->count_images,
|
||||
'images' => $this->count_imgs,
|
||||
'url' => (string) $this->url()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template for managing this nodes follows
|
||||
*
|
||||
* @return callable
|
||||
*/
|
||||
public static function manageFollowNodeRow()
|
||||
{
|
||||
\IPS\gallery\Application::outputCss();
|
||||
|
||||
return array( \IPS\Theme::i()->getTemplate( 'global', 'gallery' ), 'manageFollowNodeRow' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Album Comment Model
|
||||
* @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 17 Mar 2017
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\Album;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Album Comment Model
|
||||
*/
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\ReportCenter, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
|
||||
/**
|
||||
* @brief [Content\Comment] Item Class
|
||||
*/
|
||||
public static $itemClass = 'IPS\gallery\Album\Item';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'gallery_album_comments';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'comment_';
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
'item' => 'album_id',
|
||||
'author' => 'author_id',
|
||||
'author_name' => 'author_name',
|
||||
'content' => 'text',
|
||||
'date' => 'post_date',
|
||||
'ip_address' => 'ip_address',
|
||||
'edit_time' => 'edit_time',
|
||||
'edit_member_name' => 'edit_name',
|
||||
'edit_show' => 'append_edit',
|
||||
'approved' => 'approved'
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = 'gallery';
|
||||
|
||||
/**
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = 'gallery_album_comment';
|
||||
|
||||
/**
|
||||
* @brief Icon
|
||||
*/
|
||||
public static $icon = 'camera';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
public static $hideLogKey = 'gallery-albums';
|
||||
|
||||
/**
|
||||
* Get items with permisison check
|
||||
*
|
||||
* @note We override in order to provide checking against album restrictions
|
||||
* @param array $where Where clause
|
||||
* @param string $order MySQL ORDER BY clause (NULL to order by date)
|
||||
* @param int|array $limit Limit clause
|
||||
* @param string $permissionKey A key which has a value in the permission map (either of the container or of this class) matching a column ID in core_permission_index
|
||||
* @param mixed $includeHiddenItems Include hidden comments? NULL to detect if currently logged in member has permission, -1 to return public content only, TRUE to return unapproved content and FALSE to only return unapproved content the viewing member submitted
|
||||
* @param int $queryFlags Select bitwise flags
|
||||
* @param \IPS\Member $member The member (NULL to use currently logged in member)
|
||||
* @param bool $joinContainer If true, will join container data (set to TRUE if your $where clause depends on this data)
|
||||
* @param bool $joinComments If true, will join comment data (set to TRUE if your $where clause depends on this data)
|
||||
* @param bool $joinReviews If true, will join review data (set to TRUE if your $where clause depends on this data)
|
||||
* @return \IPS\Patterns\ActiveRecordIterator|int
|
||||
*/
|
||||
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\Album\Item::getItemsWithPermissionWhere( $where, $member, $joins );
|
||||
return parent::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHiddenItems, $queryFlags, $member, $joinContainer, $joinComments, $joinReviews, $countOnly, $joins );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL for doing stuff
|
||||
*
|
||||
* @param string|NULL $action Action
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function url( $action='find' )
|
||||
{
|
||||
return parent::url( $action )->setQueryString( 'tab', 'comments' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Do stuff after creating (abstracted as comments and reviews need to do different things)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
parent::postCreate();
|
||||
|
||||
$this->item()->asNode()->setLastComment();
|
||||
$this->item()->asNode()->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get snippet HTML for search result display
|
||||
*
|
||||
* @param array $indexData Data from the search index
|
||||
* @param array $authorData Basic data about the author. Only includes columns returned by \IPS\Member::columnsForPhoto()
|
||||
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
|
||||
* @param array|NULL $containerData Basic data about the container. Only includes columns returned by container::basicDataColumns()
|
||||
* @param array $reputationData Array of people who have given reputation and the reputation they gave
|
||||
* @param int|NULL $reviewRating If this is a review, the rating
|
||||
* @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 )
|
||||
{
|
||||
$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();
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'gallery', 'front' )->searchResultAlbumCommentSnippet( $indexData, $itemData, $images, $url, $reviewRating, $view == 'condensed' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A classname applied to the search result block
|
||||
*/
|
||||
public static $searchResultClassName = 'cGalleryAlbumSearchResult';
|
||||
|
||||
/**
|
||||
* Reaction Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function reactionType()
|
||||
{
|
||||
return 'comment_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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' )->embedAlbumComment( $this, $this->item(), $this->url()->setQueryString( $params ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,584 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Gallery Album Content Item Model
|
||||
* @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 13 Mar 2017
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\Album;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Model
|
||||
*/
|
||||
class _Item extends \IPS\Content\Item implements
|
||||
\IPS\Content\Permissions,
|
||||
\IPS\Content\ReadMarkers,
|
||||
\IPS\Content\Ratings,
|
||||
\IPS\Content\Searchable,
|
||||
\IPS\Content\Shareable,
|
||||
\IPS\Content\Embeddable,
|
||||
\IPS\Content\Hideable,
|
||||
\IPS\Content\Featurable,
|
||||
\IPS\Content\Lockable,
|
||||
\IPS\Content\ReportCenter,
|
||||
\IPS\Content\MetaData
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = 'gallery';
|
||||
|
||||
/**
|
||||
* @brief Module
|
||||
*/
|
||||
public static $module = 'gallery';
|
||||
|
||||
/**
|
||||
* @brief Database Table
|
||||
*/
|
||||
public static $databaseTable = 'gallery_albums';
|
||||
|
||||
/**
|
||||
* @brief Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'album_';
|
||||
|
||||
/**
|
||||
* @brief Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
|
||||
/**
|
||||
* @brief Node Class
|
||||
*/
|
||||
public static $containerNodeClass = 'IPS\gallery\Category';
|
||||
|
||||
/**
|
||||
* @brief Review Class
|
||||
*/
|
||||
public static $reviewClass = 'IPS\gallery\Album\Review';
|
||||
|
||||
/**
|
||||
* @brief Comment Class
|
||||
*/
|
||||
public static $commentClass = 'IPS\gallery\Album\Comment';
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
'title' => 'name',
|
||||
'content' => 'description',
|
||||
'container' => 'category_id',
|
||||
'num_reviews' => 'reviews',
|
||||
'unapproved_reviews' => 'reviews_unapproved',
|
||||
'hidden_reviews' => 'reviews_hidden',
|
||||
'num_comments' => 'comments',
|
||||
'unapproved_comments' => 'comments_unapproved',
|
||||
'hidden_comments' => 'comments_hidden',
|
||||
'rating_total' => 'rating_total',
|
||||
'rating_hits' => 'rating_count',
|
||||
'rating_average' => 'rating_aggregate',
|
||||
'rating' => 'rating_aggregate',
|
||||
'meta_data' => 'meta_data',
|
||||
'updated' => 'last_img_date',
|
||||
'date' => 'last_img_date',
|
||||
'author' => 'owner_id',
|
||||
'last_comment' => 'last_comment',
|
||||
'last_review' => 'last_review',
|
||||
'featured' => 'featured',
|
||||
'locked' => 'locked',
|
||||
'hidden' => 'hidden',
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = 'gallery_album';
|
||||
|
||||
/**
|
||||
* @brief Icon
|
||||
*/
|
||||
public static $icon = 'file-photo-o';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
public static $hideLogKey = 'gallery-album';
|
||||
|
||||
/**
|
||||
* Get title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get album as node
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function asNode()
|
||||
{
|
||||
$data = $this->_data;
|
||||
|
||||
foreach( $this->_data as $k => $v )
|
||||
{
|
||||
$data['album_' . $k ] = $v;
|
||||
}
|
||||
|
||||
return \IPS\gallery\Album::constructFromData( $data, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief URL Base
|
||||
*/
|
||||
public static $urlBase = 'app=gallery&module=gallery&controller=browse&album=';
|
||||
|
||||
/**
|
||||
* @brief URL Base
|
||||
*/
|
||||
public static $urlTemplate = 'gallery_album';
|
||||
|
||||
/**
|
||||
* @brief SEO Title Column
|
||||
*/
|
||||
public static $seoTitleColumn = 'name_seo';
|
||||
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @param string|NULL $action Action
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function url( $action=NULL )
|
||||
{
|
||||
$url = $this->asNode()->url();
|
||||
|
||||
if( $action !== NULL )
|
||||
{
|
||||
$url = $url->setQueryString( 'do', $action );
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can review?
|
||||
*
|
||||
* @param \IPS\Member\NULL $member The member (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public function canReview( $member=NULL )
|
||||
{
|
||||
if ( !$this->use_reviews )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return parent::canReview( $member );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can comment?
|
||||
*
|
||||
* @param \IPS\Member\NULL $member The member (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public function canComment( $member=NULL )
|
||||
{
|
||||
if ( !$this->use_comments )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return parent::canComment( $member );
|
||||
}
|
||||
|
||||
/**
|
||||
* Supported Meta Data Types
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function supportedMetaDataTypes()
|
||||
{
|
||||
return array( 'core_ContentMessages' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image for embed
|
||||
*
|
||||
* @return \IPS\File|NULL
|
||||
*/
|
||||
public function embedImage()
|
||||
{
|
||||
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 );
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get preview image for share services
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function shareImage()
|
||||
{
|
||||
if( $this->cover_img_id OR $this->last_img_id )
|
||||
{
|
||||
return (string) \IPS\File::get( 'gallery_Images', \IPS\gallery\Image::load( $this->cover_img_id ?: $this->last_img_id )->masked_file_name )->url;
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get items with permission check
|
||||
*
|
||||
* @param array $where Where clause
|
||||
* @param string $order MySQL ORDER BY clause (NULL to order by date)
|
||||
* @param int|array $limit Limit clause
|
||||
* @param string|NULL $permissionKey A key which has a value in the permission map (either of the container or of this class) matching a column ID in core_permission_index or NULL to ignore permissions
|
||||
* @param mixed $includeHiddenItems Include hidden items? NULL to detect if currently logged in member has permission, -1 to return public content only, TRUE to return unapproved content and FALSE to only return unapproved content the viewing member submitted
|
||||
* @param int $queryFlags Select bitwise flags
|
||||
* @param \IPS\Member $member The member (NULL to use currently logged in member)
|
||||
* @param bool $joinContainer If true, will join container data (set to TRUE if your $where clause depends on this data)
|
||||
* @param bool $joinComments If true, will join comment data (set to TRUE if your $where clause depends on this data)
|
||||
* @param bool $joinReviews If true, will join review data (set to TRUE if your $where clause depends on this data)
|
||||
* @param bool $countOnly If true will return the count
|
||||
* @param array|null $joins Additional arbitrary joins for the query
|
||||
* @param mixed $skipPermission If you are getting records from a specific container, pass the container to reduce the number of permission checks necessary or pass TRUE to skip conatiner-based permission. You must still specify this in the $where clause
|
||||
* @param bool $joinTags If true, will join the tags table
|
||||
* @param bool $joinAuthor If true, will join the members table for the author
|
||||
* @param bool $joinLastCommenter If true, will join the members table for the last commenter
|
||||
* @param bool $showMovedLinks If true, moved item links are included in the results
|
||||
* @return \IPS\Patterns\ActiveRecordIterator|int
|
||||
*/
|
||||
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 )
|
||||
{
|
||||
$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 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cached groups the member can access
|
||||
*/
|
||||
protected static $_availableGroups = array();
|
||||
|
||||
/**
|
||||
* WHERE clause for getItemsWithPermission
|
||||
*
|
||||
* @param array $where Current WHERE clause
|
||||
* @param \IPS\Member $member The member (NULL to use currently logged in member)
|
||||
* @param bool $joins Additional joins
|
||||
* @return array
|
||||
*/
|
||||
public static function getItemsWithPermissionWhere( $where, $member, &$joins )
|
||||
{
|
||||
/* We need to make sure we can access the album */
|
||||
$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;
|
||||
}
|
||||
|
||||
/* If you can edit images in a category you can see 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_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_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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional WHERE clauses for Follow view
|
||||
*
|
||||
* @param bool $joinContainer If true, will join container data (set to TRUE if your $where clause depends on this data)
|
||||
* @param array $joins Other joins
|
||||
* @return array
|
||||
*/
|
||||
public static function followWhere( &$joinContainer, &$joins )
|
||||
{
|
||||
return array_merge( parent::followWhere( $joinContainer, $joins ), array( static::getItemsWithPermissionWhere( array(), \IPS\Member::loggedIn(), $joins ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Move
|
||||
*
|
||||
* @param \IPS\Node\Model $container Container to move to
|
||||
* @param bool $keepLink If TRUE, will keep a link in the source
|
||||
* @return void
|
||||
* @note We need to update the image category references too
|
||||
*/
|
||||
public function move( \IPS\Node\Model $container, $keepLink=FALSE )
|
||||
{
|
||||
return $this->asNode()->moveTo( $container, $this->container() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Index Permissions
|
||||
*
|
||||
* @return string Comma-delimited values or '*'
|
||||
* @li Number indicates a group
|
||||
* @li Number prepended by "m" indicates a member
|
||||
* @li Number prepended by "s" indicates a social group
|
||||
*/
|
||||
public function searchIndexPermissions()
|
||||
{
|
||||
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
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function basicDataColumns()
|
||||
{
|
||||
$return = parent::basicDataColumns();
|
||||
$return[] = 'album_last_x_images';
|
||||
$return[] = 'album_cover_img_id';
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query to get additional data for search result / stream view
|
||||
*
|
||||
* @param array $items Item data (will be an array containing values from basicDataColumns())
|
||||
* @return array
|
||||
*/
|
||||
public static function searchResultExtraData( $items )
|
||||
{
|
||||
$imageIds = array();
|
||||
foreach ( $items as $itemData )
|
||||
{
|
||||
if ( $itemData['album_cover_img_id'] )
|
||||
{
|
||||
$imageIds[] = $itemData['album_cover_img_id'];
|
||||
}
|
||||
|
||||
if ( $itemData['album_last_x_images'] )
|
||||
{
|
||||
$latestImages = json_decode( $itemData['album_last_x_images'], true );
|
||||
|
||||
foreach( $latestImages as $imageId )
|
||||
{
|
||||
$imageIds[] = $imageId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $imageIds ) )
|
||||
{
|
||||
\IPS\gallery\Application::outputCss();
|
||||
|
||||
$return = array();
|
||||
|
||||
foreach ( \IPS\gallery\Image::getItemsWithPermission( array( array( 'image_id IN(' . implode( ',', $imageIds ) . ')' ) ), NULL, 20 ) as $image )
|
||||
{
|
||||
$return[ $image->album_id ][] = $image;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get snippet HTML for search result display
|
||||
*
|
||||
* @param array $indexData Data from the search index
|
||||
* @param array $authorData Basic data about the author. Only includes columns returned by \IPS\Member::columnsForPhoto()
|
||||
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
|
||||
* @param array|NULL $containerData Basic data about the container. Only includes columns returned by container::basicDataColumns()
|
||||
* @param array $reputationData Array of people who have given reputation and the reputation they gave
|
||||
* @param int|NULL $reviewRating If this is a review, the rating
|
||||
* @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 )
|
||||
{
|
||||
$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();
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'gallery', 'front' )->searchResultAlbumSnippet( $indexData, $itemData, $images, $url, $view == 'condensed' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A classname applied to the search result block
|
||||
*/
|
||||
public static $searchResultClassName = 'cGalleryAlbumSearchResult';
|
||||
|
||||
/**
|
||||
* Are comments supported by this class?
|
||||
*
|
||||
* @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, \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
|
||||
* @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, \IPS\Node\Model $container = NULL )
|
||||
{
|
||||
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' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template for content tables
|
||||
*
|
||||
* @return callable
|
||||
*/
|
||||
public static function contentTableTemplate()
|
||||
{
|
||||
\IPS\gallery\Application::outputCss();
|
||||
|
||||
return array( \IPS\Theme::i()->getTemplate( 'browse', 'gallery' ), 'albums' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available comment/review tabs
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function commentReviewTabs()
|
||||
{
|
||||
$tabs = array();
|
||||
|
||||
if ( $this->container()->allow_reviews AND $this->use_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->use_comments )
|
||||
{
|
||||
$tabs['comments'] = \IPS\Member::loggedIn()->language()->addToStack( 'image_comment_count', TRUE, array( 'pluralize' => array( $this->mapped('num_comments') ) ) );
|
||||
}
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment/review output
|
||||
*
|
||||
* @param string $tab Active tab
|
||||
* @return string
|
||||
*/
|
||||
public function commentReviews( $tab )
|
||||
{
|
||||
if ( $tab === 'reviews' AND $this->container()->allow_reviews AND $this->use_reviews )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('browse')->albumReviews( $this );
|
||||
}
|
||||
elseif( $tab === 'comments' AND $this->container()->allow_comments AND $this->use_comments )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('browse')->albumComments( $this );
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Reaction Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function reactionType()
|
||||
{
|
||||
return 'album_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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' )->embedAlbums( $this, $this->asNode(), $this->url()->setQueryString( $params ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Album Review Model
|
||||
* @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 17 Mar 2017
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\Album;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Album Review Model
|
||||
*/
|
||||
class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \IPS\Content\ReportCenter, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
|
||||
/**
|
||||
* @brief [Content\Comment] Item Class
|
||||
*/
|
||||
public static $itemClass = 'IPS\gallery\Album\Item';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'gallery_album_reviews';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'review_';
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
'item' => 'album_id',
|
||||
'author' => 'author',
|
||||
'author_name' => 'author_name',
|
||||
'content' => 'content',
|
||||
'date' => 'date',
|
||||
'ip_address' => 'ip_address',
|
||||
'edit_time' => 'edit_time',
|
||||
'edit_member_name' => 'edit_member_name',
|
||||
'edit_show' => 'edit_show',
|
||||
'rating' => 'rating',
|
||||
'votes_total' => 'votes_total',
|
||||
'votes_helpful' => 'votes_helpful',
|
||||
'votes_data' => 'votes_data',
|
||||
'approved' => 'approved',
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = 'gallery';
|
||||
|
||||
/**
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = 'gallery_album_review';
|
||||
|
||||
/**
|
||||
* @brief Icon
|
||||
*/
|
||||
public static $icon = 'camera';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
public static $hideLogKey = 'gallery-album-review';
|
||||
|
||||
/**
|
||||
* Get URL for doing stuff
|
||||
*
|
||||
* @param string|NULL $action Action
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function url( $action=NULL )
|
||||
{
|
||||
return parent::url( $action )->setQueryString( 'tab', 'reviews' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Do stuff after creating (abstracted as comments and reviews need to do different things)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
parent::postCreate();
|
||||
|
||||
$this->item()->asNode()->setLastComment();
|
||||
$this->item()->asNode()->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get snippet HTML for search result display
|
||||
*
|
||||
* @param array $indexData Data from the search index
|
||||
* @param array $authorData Basic data about the author. Only includes columns returned by \IPS\Member::columnsForPhoto()
|
||||
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
|
||||
* @param array|NULL $containerData Basic data about the container. Only includes columns returned by container::basicDataColumns()
|
||||
* @param array $reputationData Array of people who have given reputation and the reputation they gave
|
||||
* @param int|NULL $reviewRating If this is a review, the rating
|
||||
* @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 )
|
||||
{
|
||||
return \IPS\gallery\Album\Comment::searchResultSnippet( $indexData, $authorData, $itemData, $containerData, $reputationData, $reviewRating, $view );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A classname applied to the search result block
|
||||
*/
|
||||
public static $searchResultClassName = 'cGalleryAlbumSearchResult';
|
||||
|
||||
/**
|
||||
* Reaction Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function reactionType()
|
||||
{
|
||||
return 'review_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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' )->embedAlbumReview( $this, $this->item(), $this->url()->setQueryString( $params ) );
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Table Builder for Gallery albums
|
||||
* @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 17 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\Album;
|
||||
@@ -22,7 +21,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* Table Builder for Gallery albums
|
||||
*/
|
||||
class _Table extends \IPS\Helpers\Table\Table
|
||||
class _Table extends \IPS\Helpers\Table\Content
|
||||
{
|
||||
/**
|
||||
* @brief Container
|
||||
@@ -43,6 +42,11 @@ class _Table extends \IPS\Helpers\Table\Table
|
||||
* @brief Table resort parameter
|
||||
*/
|
||||
public $resortKey = 'albumResort';
|
||||
|
||||
/**
|
||||
* @brief No Moderate
|
||||
*/
|
||||
public $noModerate = TRUE;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -53,35 +57,31 @@ class _Table extends \IPS\Helpers\Table\Table
|
||||
*/
|
||||
public function __construct( \IPS\Http\Url $url=NULL, \IPS\Node\Model $container=NULL )
|
||||
{
|
||||
/* Init */
|
||||
$this->container = $container;
|
||||
|
||||
/* Init */
|
||||
parent::__construct( ( $url !== NULL ) ? $url : $container->url() );
|
||||
|
||||
$this->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'browse', 'gallery' ), 'albums' );
|
||||
|
||||
/* Set container */
|
||||
if ( $container !== NULL )
|
||||
{
|
||||
$this->where[] = array( 'album_category_id=?', $container->_id );
|
||||
|
||||
if ( $this->sortBy === 'album_name' )
|
||||
if ( !$this->sortBy and $container->_sortBy )
|
||||
{
|
||||
$this->sortDirection = 'asc';
|
||||
}
|
||||
|
||||
if ( !$this->sortBy and $container->_sortBy !== NULL )
|
||||
{
|
||||
$this->sortBy = $container->_sortBy;
|
||||
$this->sortBy = '`' . \IPS\gallery\Album::$databaseTable . '`.`' . \IPS\gallery\Album::$databasePrefix . $container->_sortBy . '`';
|
||||
$this->sortDirection = $container->_sortOrder;
|
||||
}
|
||||
|
||||
if ( !$this->filter )
|
||||
{
|
||||
$this->filter = $container->_filter;
|
||||
}
|
||||
|
||||
if ( $this->sortBy === 'name' )
|
||||
{
|
||||
$this->sortDirection = 'asc';
|
||||
}
|
||||
}
|
||||
|
||||
/* Init */
|
||||
parent::__construct( '\\IPS\\gallery\\Album\\Item', ( $url !== NULL ) ? $url : $container->url(), NULL, $container );
|
||||
|
||||
$this->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'browse', 'gallery' ), 'albums' );
|
||||
|
||||
/* If we can't moderate in this category, restrict results */
|
||||
if( $container === NULL OR !\IPS\gallery\Image::modPermission( 'edit', NULL, $container ) )
|
||||
{
|
||||
@@ -99,23 +99,20 @@ class _Table extends \IPS\Helpers\Table\Table
|
||||
$this->where[] = array( 'album_type<>4' );
|
||||
}
|
||||
|
||||
|
||||
/* Set available sort options */
|
||||
foreach ( array( 'last_img_date', 'count_comments', 'rating_aggregate', 'name', 'count_imgs' ) as $k )
|
||||
foreach ( array( 'name', 'count_comments', 'count_imgs' ) as $k )
|
||||
{
|
||||
if( $k == 'count_comments' AND ( $container === NULL OR !$this->container->allow_comments ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( $k == 'rating_aggregate' AND ( $container === NULL OR !$this->container->allow_rating ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->sortOptions[ $k ] = 'album_' . $k;
|
||||
$this->sortOptions[ 'album_' . $k ] = $k;
|
||||
}
|
||||
|
||||
unset( $this->sortOptions['date'] );
|
||||
unset( $this->sortOptions['title'] );
|
||||
|
||||
if ( !$this->sortBy )
|
||||
{
|
||||
$this->sortBy = 'album_last_img_date';
|
||||
@@ -133,51 +130,6 @@ class _Table extends \IPS\Helpers\Table\Table
|
||||
$this->where[] = array( 'album_owner_id=?', $member->member_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rows
|
||||
*
|
||||
* @param array $advancedSearchValues Values from the advanced search form
|
||||
* @return array
|
||||
*/
|
||||
public function getRows( $advancedSearchValues )
|
||||
{
|
||||
/* Init */
|
||||
$class = "IPS\\gallery\\Album";
|
||||
$subquery = NULL;
|
||||
|
||||
/* Check sortBy */
|
||||
$this->sortBy = in_array( $this->sortBy, $this->sortOptions ) ? $this->sortBy : 'album_last_img_date';
|
||||
|
||||
/* What are we sorting by? */
|
||||
$sortBy = $this->sortBy . ' ' . ( mb_strtolower( $this->sortDirection ) == 'asc' ? 'asc' : 'desc' );
|
||||
|
||||
/* Specify filter in where clause */
|
||||
$where = $this->where ? is_array( $this->where ) ? $this->where : array( $this->where ) : array();
|
||||
if ( $this->filter and isset( $this->filters[ $this->filter ] ) )
|
||||
{
|
||||
$where[] = is_array( $this->filters[ $this->filter ] ) ? $this->filters[ $this->filter ] : array( $this->filters[ $this->filter ] );
|
||||
}
|
||||
|
||||
$where[] = array( '(' . \IPS\Db::i()->findInSet( 'core_permission_index.perm_view', \IPS\Member::loggedIn()->groups ) . ' OR ' . 'core_permission_index.perm_view=? )', '*' );
|
||||
|
||||
/* Get results */
|
||||
$it = \IPS\Db::i()->select( '*', 'gallery_albums', $where, $sortBy, array( ( $this->limit * ( $this->page - 1 ) ), $this->limit ), NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS );
|
||||
$it->join( 'gallery_categories', array( "gallery_categories.category_id=gallery_albums.album_category_id" ) );
|
||||
$it->join( 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND core_permission_index.perm_type_id=gallery_categories.category_id", 'gallery', 'category' ) );
|
||||
|
||||
$this->pages = ceil( $it->count( TRUE ) / $this->limit );
|
||||
|
||||
$rows = iterator_to_array( $it );
|
||||
|
||||
foreach( $rows as $index => $row )
|
||||
{
|
||||
$rows[ $index ] = \IPS\gallery\Album::constructFromData( $row );
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the table headers
|
||||
*
|
||||
@@ -188,4 +140,15 @@ class _Table extends \IPS\Helpers\Table\Table
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the user have permission to use the multi-mod checkboxes?
|
||||
*
|
||||
* @param string|null $action Specific action to check (hide/unhide, etc.) or NULL for a generic check
|
||||
* @return bool
|
||||
*/
|
||||
public function canModerate( $action=NULL )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Category Node
|
||||
* @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;
|
||||
@@ -24,6 +23,8 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
use \IPS\Content\ClubContainer;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
@@ -152,7 +153,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
*/
|
||||
public function get__sortBy()
|
||||
{
|
||||
return $this->sort_options;
|
||||
return str_replace( 'album_', '', $this->sort_options );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,7 +287,16 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
return !isset( \IPS\Request::i()->id ) or ( $node->id != \IPS\Request::i()->id and !$node->isChildOf( $node::load( \IPS\Request::i()->id ) ) );
|
||||
}
|
||||
) ) );
|
||||
$sortoptions = array( 'album_last_img_date' => 'sort_updated', 'album_name' => 'sort_title', 'album_rating_aggregate' => 'sort_rating', 'album_count_comments' => 'sort_num_comments', 'album_count_images' => 'sort_count_imgs' );
|
||||
$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\YesNo( 'category_allow_albums', $this->id ? $this->allow_albums : TRUE, FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_approve_img', $this->approve_img, FALSE ) );
|
||||
@@ -361,6 +371,12 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
unset( $values['gcategory_parent_id'] );
|
||||
}
|
||||
|
||||
/* 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 )
|
||||
{
|
||||
$values['category_watermark']= 1;
|
||||
}
|
||||
|
||||
/* Claim attachments */
|
||||
if ( !$this->id )
|
||||
{
|
||||
@@ -603,6 +619,11 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( $size == 'full' )
|
||||
{
|
||||
$size = 'masked';
|
||||
}
|
||||
|
||||
$property = $size . "_file_name";
|
||||
|
||||
@@ -616,16 +637,11 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( !in_array( $size, array( 'full', 'medium', 'small', 'thumb' ) ) )
|
||||
if( !in_array( $size, array( 'masked', 'medium', 'small', 'thumb' ) ) )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
|
||||
if( $size == 'full' )
|
||||
{
|
||||
$size = 'masked';
|
||||
}
|
||||
|
||||
if( $this->coverPhoto === NULL )
|
||||
{
|
||||
$this->coverPhoto = \IPS\gallery\Image::load( $this->cover_img_id );
|
||||
@@ -721,10 +737,9 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
* Handle submissions of form to delete or move content
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @param bool $deleteWhenDone Delete the node when done?
|
||||
* @return void
|
||||
*/
|
||||
public function deleteOrMoveFormSubmit( $values, $deleteWhenDone=TRUE )
|
||||
public function deleteOrMoveFormSubmit( $values )
|
||||
{
|
||||
if ( $this->hasAlbums() )
|
||||
{
|
||||
@@ -736,7 +751,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'DeleteOrMoveContent', array( 'class' => 'IPS\gallery\Album', 'id' => $album->_id, 'deleteWhenDone' => $deleteWhenDone ) );
|
||||
\IPS\Task::queue( 'core', 'DeleteOrMoveContent', array( 'class' => 'IPS\gallery\Album', 'id' => $album->_id, 'deleteWhenDone' => TRUE ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -819,4 +834,55 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
return 'x';
|
||||
}
|
||||
|
||||
|
||||
/* !Clubs */
|
||||
|
||||
/**
|
||||
* Get acp language string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function clubAcpTitle()
|
||||
{
|
||||
return 'editor__gallery_Categories';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set form for creating a node of this type in a club
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form Form object
|
||||
* @return void
|
||||
*/
|
||||
public function clubForm( \IPS\Helpers\Form $form )
|
||||
{
|
||||
$itemClass = static::$contentItemClass;
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'club_node_name', $this->_id ? $this->_title : \IPS\Member::loggedIn()->language()->addToStack( $itemClass::$title . '_pl' ), TRUE, array( 'maxLength' => 255 ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'club_node_description', $this->_id ? \IPS\Member::loggedIn()->language()->get( static::$titleLangPrefix . $this->_id . '_desc' ) : NULL, FALSE, array( 'app' => 'gallery', 'key' => 'Categories', 'autoSaveKey' => ( $this->id ? "gallery-cat-{$this->id}" : "gallery-new-cat" ), 'attachIds' => $this->id ? array( $this->id, NULL, 'description' ) : NULL, 'minimize' => 'cdesc_placeholder' ) ) );
|
||||
|
||||
$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 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Class-specific routine when saving club form
|
||||
*
|
||||
* @param \IPS\Member\Club $club The club
|
||||
* @param array $values Values
|
||||
* @return void
|
||||
*/
|
||||
public function _saveClubForm( \IPS\Member\Club $club, $values )
|
||||
{
|
||||
$this->allow_albums = $values['category_allow_albums'];
|
||||
$this->allow_comments = $values['category_allow_comments'];
|
||||
$this->allow_reviews = $values['category_allow_reviews'];
|
||||
$this->can_tag = TRUE;
|
||||
$this->tag_prefixes = TRUE;
|
||||
|
||||
if ( $values['club_node_name'] )
|
||||
{
|
||||
$this->name_seo = \IPS\Http\Url\Friendly::seoTitle( $values['club_node_name'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Image Comment 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\Image;
|
||||
@@ -22,8 +21,10 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* Image Comment Model
|
||||
*/
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\ReportCenter, \IPS\Content\Hideable, \IPS\Content\Reputation, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\ReportCenter, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
@@ -75,11 +76,6 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
*/
|
||||
public static $icon = 'camera';
|
||||
|
||||
/**
|
||||
* @brief Reputation Type
|
||||
*/
|
||||
public static $reputationType = 'comment_id';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
@@ -155,4 +151,26 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'gallery', 'front' )->searchResultCommentSnippet( $indexData, $itemData, $image, $url, $reviewRating, $view == 'condensed' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reaction Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function reactionType()
|
||||
{
|
||||
return 'comment_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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' )->embedImageComment( $this, $this->item(), $this->url()->setQueryString( $params ) );
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Image Review 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 18 Aug 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\Image;
|
||||
@@ -22,8 +21,10 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* Image Review Model
|
||||
*/
|
||||
class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \IPS\Content\ReportCenter, \IPS\Content\Hideable, \IPS\Content\Reputation, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \IPS\Content\ReportCenter, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
{
|
||||
use \IPS\Content\Reactable;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
@@ -79,11 +80,6 @@ class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \
|
||||
*/
|
||||
public static $icon = 'camera';
|
||||
|
||||
/**
|
||||
* @brief Reputation Type
|
||||
*/
|
||||
public static $reputationType = 'review_id';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
@@ -116,4 +112,26 @@ class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \
|
||||
{
|
||||
return \IPS\gallery\Image\Comment::searchResultSnippet( $indexData, $authorData, $itemData, $containerData, $reputationData, $reviewRating, $view );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reaction Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function reactionType()
|
||||
{
|
||||
return 'review_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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' )->embedImageReview( $this, $this->item(), $this->url()->setQueryString( $params ) );
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Custom table helper for gallery images to override move menu
|
||||
* @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 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\Image;
|
||||
@@ -72,7 +71,7 @@ class _Table extends \IPS\Helpers\Table\Content
|
||||
if ( \IPS\Request::i()->modaction == 'move' )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'form', 'move' );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'move_to_category', NULL, FALSE, array( 'class' => 'IPS\\gallery\\Category', 'url' => \IPS\Request::i()->url()->setQueryString( 'modaction', 'move' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'move_to_category', NULL, FALSE, array( 'clubs' => true, 'class' => 'IPS\\gallery\\Category', 'url' => \IPS\Request::i()->url()->setQueryString( 'modaction', 'move' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'move_to_album', NULL, FALSE, array(
|
||||
'class' => 'IPS\\gallery\\Album',
|
||||
'forceOwner' => FALSE,
|
||||
|
||||
Reference in new issue
Block a user