Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -12,7 +12,7 @@
namespace IPS\gallery;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -281,7 +281,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
)
) ) );
$class = get_called_class();
$class = \get_called_class();
$form->add( new \IPS\Helpers\Form\Node( 'gcategory_parent_id', $this->id ? $this->parent_id : ( \IPS\Request::i()->parent ?: 0 ), FALSE, array(
'class' => '\IPS\gallery\Category',
@@ -332,11 +332,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
$form->addHeader( 'category_tags' );
$form->add( new \IPS\Helpers\Form\YesNo( 'category_can_tag', $this->id ? $this->can_tag : TRUE, FALSE, array( 'togglesOn' => array( 'category_tag_prefixes', 'category_preset_tags' ) ), NULL, NULL, NULL, 'category_can_tag' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'category_tag_prefixes', $this->id ? $this->tag_prefixes : TRUE, FALSE, array(), NULL, NULL, NULL, 'category_tag_prefixes' ) );
if ( !\IPS\Settings::i()->tags_open_system )
{
$form->add( new \IPS\Helpers\Form\Text( 'category_preset_tags', $this->preset_tags, FALSE, array( 'autocomplete' => array( 'unique' => 'true' ), 'nullLang' => 'ctags_predefined_unlimited' ), NULL, NULL, NULL, 'category_preset_tags' ) );
}
$form->add( new \IPS\Helpers\Form\Text( 'category_preset_tags', $this->preset_tags, FALSE, array( 'autocomplete' => array( 'unique' => 'true' ), 'nullLang' => 'ctags_predefined_unlimited' ), NULL, NULL, NULL, 'category_preset_tags' ) );
}
$form->addTab( 'category_rules' );
@@ -435,7 +431,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
/* Parent ID */
if ( isset( $values['category_parent_id'] ) )
{
$values['category_parent_id'] = $values['category_parent_id'] ? intval( $values['category_parent_id']->id ) : 0;
$values['category_parent_id'] = $values['category_parent_id'] ? \intval( $values['category_parent_id']->id ) : 0;
}
/* Cannot be null */
@@ -482,7 +478,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
$message = trim( \IPS\Member::loggedIn()->language()->get( "gallery_category_{$this->id}_permerror" ) );
if ( !empty( $message ) AND ( $message != '<p></p>' ) )
{
return $message;
return \IPS\Theme::i()->getTemplate('global', 'core', 'global')->richText( $message );
}
}
catch ( \Exception $e ) {}
@@ -575,6 +571,10 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
public function setLastImage( \IPS\gallery\Image $image=NULL )
{
/* Reset counts */
$this->resetCommentCounts();
/* Reset last image */
if( $image === NULL )
{
try
@@ -592,10 +592,8 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
}
}
$this->last_img_id = $image->id;
$this->last_img_date = $image->date;
$this->resetCommentCounts();
$this->last_img_id = $image->id;
$this->last_img_date = $image->date;
if( $image->album_id )
{
@@ -659,7 +657,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
}
/* Make sure it's a valid size */
if( !in_array( $size, array( 'masked', 'small' ) ) )
if( !\in_array( $size, array( 'masked', 'small' ) ) )
{
throw new \InvalidArgumentException;
}
@@ -711,14 +709,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
if ( isset( $qs['category'] ) )
{
if ( method_exists( get_called_class(), 'loadAndCheckPerms' ) )
{
return static::loadAndCheckPerms( $qs['category'] );
}
else
{
return static::load( $qs['category'] );
}
return static::load( $qs['category'] );
}
throw new \InvalidArgumentException;
@@ -792,9 +783,9 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
{
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'gallery_albums', array( 'album_category_id=?', $this->id ) ), 'IPS\gallery\Album' ) as $album )
{
if ( $values['node_move_children'] )
if ( isset( $values['node_move_children'] ) AND $values['node_move_children'] )
{
$album->moveTo( $values['node_move_children'] );
$album->moveTo( \IPS\gallery\Category::load( ( isset( $values['node_destination'] ) ) ? $values['node_destination'] : \IPS\Request::i()->node_move_children ) );
}
else
{
@@ -834,26 +825,57 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
* permission to create content in any node to determine
* if there should be a "Submit" button
*
* @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
* @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
* @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 static function canOnAny( $permission, $member=NULL, $where = array() )
public static function canOnAny( $permission, $member=NULL, $where = array(), $considerPostBeforeRegistering = TRUE )
{
/* Load member */
if ( $member === NULL )
{
$member = \IPS\Member::loggedIn();
}
$member = $member ?: \IPS\Member::loggedIn();
if ( $member->members_bitoptions['remove_gallery_access'] )
{
return FALSE;
}
return parent::canOnAny( $permission, $member, $where );
/* 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;
}
/**
@@ -918,7 +940,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
$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_albums_club', $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 ) );
@@ -945,7 +967,7 @@ class _Category extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
public function _saveClubForm( \IPS\Member\Club $club, $values )
{
$this->allow_albums = $values['category_allow_albums'];
$this->allow_albums = $values['category_allow_albums_club'];
$this->allow_comments = $values['category_allow_comments'];
$this->allow_reviews = $values['category_allow_reviews'];
$this->sort_options = $values['category_sort_options'];