Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

@@ -287,6 +287,7 @@ 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_last_comment' => 'sort_last_comment',
@@ -298,7 +299,10 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
'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\Select( 'category_sort_options_img', $this->sort_options_img ?: 'updated', FALSE, array( 'options' => array( 'updated' => 'sort_updated', 'last_comment' => 'sort_last_comment', 'title' => 'album_sort_caption', 'rating' => 'sort_rating', 'date' => 'sort_date', 'num_comments' => 'sort_num_comments', 'num_reviews' => 'sort_num_reviews', 'views' => 'sort_views' ) ), NULL, NULL, NULL, 'category_sort_options_img' ) );
$form->add( new \IPS\Helpers\Form\Radio( 'category_allow_albums', $this->id ? $this->allow_albums : 1, TRUE, array( 'options' => array( 0 => 'cat_no_allow_albums', 1 => 'cat_allow_albums', 2 => 'cat_require_albums' ) ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'category_approve_img', $this->approve_img, FALSE ) );
if( \IPS\Settings::i()->gallery_watermark_path )
@@ -374,7 +378,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
/* 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;
$values['category_watermark'] = 1;
}
/* Claim attachments */
@@ -565,7 +569,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
{
try
{
$image = \IPS\gallery\Image::constructFromData( \IPS\Db::i()->select( '*', 'gallery_images', array( 'image_category_id=? AND image_approved=1 AND ( image_album_id = 0 OR album_type NOT IN ( 2, 3 ) )', $this->id ), 'image_date DESC', 1 )->join(
$image = \IPS\gallery\Image::constructFromData( \IPS\Db::i()->select( '*', 'gallery_images', array( 'image_category_id=? AND image_approved=1 AND ( image_album_id = 0 OR album_type NOT IN ( 2, 3 ) )', $this->id ), 'image_date DESC', 1, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->join(
'gallery_albums',
"image_album_id=album_id"
)->first() );
@@ -590,6 +594,29 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
$album->save();
}
}
/**
* Set the comment/approved/hidden counts
*
* @return void
*/
public function resetCommentCounts()
{
parent::resetCommentCounts();
/* If we allow albums, add album comment/review counts too */
if( $this->allow_albums )
{
try
{
$consolidated = \IPS\Db::i()->select( 'SUM(album_comments) as comments, SUM(album_comments_unapproved) as unapproved_comments', 'gallery_albums', array( 'album_category_id=?', $this->_id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
$this->_comments = $this->count_comments + $consolidated['comments'];
$this->_unapprovedComments = $this->count_comments_hidden + $consolidated['unapproved_comments'];
}
catch( \UnderflowException $e ){}
}
}
/**
* Get last comment time
@@ -610,44 +637,54 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
/**
* Retrieve a cover photo
*
* @param string $size One of full, medium, small or thumb
* @param string $size Masked or small
* @return string|null
* @throws \InvalidArgumentException
*/
public function coverPhoto( $size='thumb' )
public function coverPhoto( $size='small' )
{
if ( !$this->can( 'read' ) )
{
return NULL;
}
if( $size == 'full' )
/* Make sure it's a valid size */
if( !in_array( $size, array( 'masked', 'small' ) ) )
{
$size = 'masked';
throw new \InvalidArgumentException;
}
$property = $size . "_file_name";
if( !$this->cover_img_id )
/* If we have an explicit cover photo set, make sure it's valid and load/cache it */
if( $this->cover_img_id )
{
if( $lastImage = $this->lastImage() )
if( $this->coverPhoto === NULL )
{
return (string) \IPS\File::get( 'gallery_Images', $lastImage->$property )->url;
try
{
$this->coverPhoto = \IPS\gallery\Image::load( $this->cover_img_id );
}
catch( \OutOfRangeException $e )
{
/* Cover photo isn't valid, reset category automatically */
$this->cover_img_id = 0;
$this->save();
}
}
return NULL;
if( $this->coverPhoto !== NULL )
{
return (string) \IPS\File::get( 'gallery_Images', $this->coverPhoto->$property )->url;
}
}
if( !in_array( $size, array( 'masked', 'medium', 'small', 'thumb' ) ) )
if( $lastImage = $this->lastImage() )
{
throw new \InvalidArgumentException;
return (string) \IPS\File::get( 'gallery_Images', $lastImage->$property )->url;
}
if( $this->coverPhoto === NULL )
{
$this->coverPhoto = \IPS\gallery\Image::load( $this->cover_img_id );
}
return (string) \IPS\File::get( 'gallery_Images', $this->coverPhoto->$property )->url;
return NULL;
}
/**
@@ -778,10 +815,11 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
*
* @param mixed $permission A key which has a value in static::$permissionMap['view'] matching a column ID in core_permission_index
* @param \IPS\Member|\IPS\Member\Group|NULL $member The member or group to check (NULL for currently logged in member)
* @param array $where Additional WHERE clause
* @return bool
* @throws \OutOfBoundsException If $permission does not exist in static::$permissionMap
*/
public static function canOnAny( $permission, $member = NULL )
public static function canOnAny( $permission, $member=NULL, $where = array() )
{
/* Load member */
if ( $member === NULL )
@@ -794,7 +832,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
return FALSE;
}
return parent::canOnAny( $permission, $member );
return parent::canOnAny( $permission, $member, $where );
}
/**
@@ -835,7 +873,6 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
return 'x';
}
/* !Clubs */
/**
@@ -884,5 +921,11 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
{
$this->name_seo = \IPS\Http\Url\Friendly::seoTitle( $values['club_node_name'] );
}
if ( !$this->_id )
{
$this->save();
\IPS\File::claimAttachments( 'gallery-new-cat', $this->id, NULL, 'description' );
}
}
}