Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -319,6 +319,8 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_watermark', $this->id ? $this->watermark : TRUE, FALSE ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'allow_anonymous_comments', $this->id ? $this->allow_anonymous : FALSE, FALSE, array() ) );
|
||||
|
||||
$form->addHeader( 'category_comments_and_ratings' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_allow_comments', $this->id ? $this->allow_comments : TRUE, FALSE, array( 'togglesOn' => array( 'category_approve_com' ) ), NULL, NULL, NULL, 'category_allow_comments' ) );
|
||||
@@ -380,7 +382,13 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$values['category_parent_id'] = $values['gcategory_parent_id'];
|
||||
unset( $values['gcategory_parent_id'] );
|
||||
}
|
||||
|
||||
|
||||
if( isset( $values['allow_anonymous_comments'] ) )
|
||||
{
|
||||
$values['allow_anonymous'] = ( $values['allow_anonymous_comments'] ? 2 : 0 );
|
||||
unset( $values['allow_anonymous_comments'] );
|
||||
}
|
||||
|
||||
/* If watermarks are disabled, enable them at the category level so that if you later enable watermarks they work in your existing categories */
|
||||
if( !\IPS\Settings::i()->gallery_watermark_path )
|
||||
{
|
||||
@@ -573,16 +581,19 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
/* Reset counts */
|
||||
$this->resetCommentCounts();
|
||||
$this->commentCountsReset = TRUE;
|
||||
|
||||
/* Reset last image */
|
||||
if( $image === NULL )
|
||||
{
|
||||
try
|
||||
{
|
||||
$image = \IPS\gallery\Image::constructFromData( \IPS\Db::i()->select( '*', 'gallery_images', array( 'image_category_id=? AND image_approved=1 AND ( image_album_id = 0 OR album_type NOT IN ( 2, 3 ) )', $this->id ), 'image_date DESC', 1, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->join(
|
||||
$result = \IPS\Db::i()->select( '*', 'gallery_images', array( 'image_category_id=? AND image_approved=1 AND ( image_album_id = 0 OR album_type NOT IN ( 2, 3 ) )', $this->id ), 'image_date DESC', 1, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->join(
|
||||
'gallery_albums',
|
||||
"image_album_id=album_id"
|
||||
)->first() );
|
||||
)->first();
|
||||
|
||||
$image = \IPS\gallery\Image::constructFromData( $result );
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
@@ -597,12 +608,17 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
|
||||
if( $image->album_id )
|
||||
{
|
||||
$album = \IPS\gallery\Album::load( $image->album_id );
|
||||
$album->setLastImage( $image );
|
||||
$album = \IPS\gallery\Album::constructFromData( $result );
|
||||
$album->setLastImage();
|
||||
$album->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Track if we've already reset comment counts so we don't do it more than once between saves
|
||||
*/
|
||||
protected $commentCountsReset = FALSE;
|
||||
|
||||
/**
|
||||
* Set the comment/approved/hidden counts
|
||||
*
|
||||
@@ -610,6 +626,11 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
*/
|
||||
public function resetCommentCounts()
|
||||
{
|
||||
if( $this->commentCountsReset )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
parent::resetCommentCounts();
|
||||
|
||||
/* If we allow albums, add album comment/review counts too */
|
||||
@@ -625,14 +646,27 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
catch( \UnderflowException $e ){}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Save Changed Columns
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
parent::save();
|
||||
|
||||
$this->commentCountsReset = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get last comment time
|
||||
*
|
||||
* @note This should return the last comment time for this node only, not for children nodes
|
||||
* @param \IPS\Member|NULL $member MemberObject
|
||||
* @return \IPS\DateTime|NULL
|
||||
*/
|
||||
public function getLastCommentTime()
|
||||
public function getLastCommentTime( \IPS\Member $member = NULL )
|
||||
{
|
||||
return $this->last_img_date ? \IPS\DateTime::ts( $this->last_img_date ) : NULL;
|
||||
}
|
||||
@@ -842,42 +876,9 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If we cannot create albums, make sure at least one category does not require them */
|
||||
if( $permission == 'add' AND !$member->group['g_create_albums'] )
|
||||
{
|
||||
$where[] = array( 'gallery_categories.category_allow_albums != ?', 2 );
|
||||
}
|
||||
|
||||
return parent::canOnAny( $permission, $member, $where, $considerPostBeforeRegistering );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check permissions
|
||||
*
|
||||
* @param mixed $permission A key which has a value in static::$permissionMap['view'] matching a column ID in core_permission_index
|
||||
* @param \IPS\Member|\IPS\Member\Group|NULL $member The member or group to check (NULL for currently logged in member)
|
||||
* @param bool $considerPostBeforeRegistering If TRUE, and $member is a guest, will return TRUE if "Post Before Registering" feature is enabled
|
||||
* @return bool
|
||||
* @throws \OutOfBoundsException If $permission does not exist in static::$permissionMap
|
||||
*/
|
||||
public function can( $permission, $member=NULL, $considerPostBeforeRegistering = TRUE )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$result = parent::can( $permission, $member, $considerPostBeforeRegistering );
|
||||
|
||||
if( $result === FALSE )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( $permission == 'add' AND $this->allow_albums == 2 AND !$member->group['g_create_albums'] )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Duplicate
|
||||
*
|
||||
@@ -916,6 +917,16 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
return 'x';
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get the fully qualified node type (mostly for Pages because Pages is Pages)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function fullyQualifiedType()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('__app_gallery') . ' ' . \IPS\Member::loggedIn()->language()->addToStack( static::$nodeTitle . '_sg');
|
||||
}
|
||||
|
||||
/* !Clubs */
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user