From d673d42771ba298851ad58dcf109946b0d983087 Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Thu, 21 May 2026 20:12:42 +0100 Subject: Inherit parent gallery protector role when creating sub-galleries and uploading images New sub-galleries and uploaded images now inherit the protector role_id from their first parent gallery, matching the behaviour of comment inheritance in protector_comment_store(). Only applies when no explicit role is chosen (-1). Co-Authored-By: Claude Sonnet 4.6 --- edit.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'edit.php') diff --git a/edit.php b/edit.php index f269b9c..92a861b 100755 --- a/edit.php +++ b/edit.php @@ -31,6 +31,15 @@ if( $gBitUser->hasPermission( 'p_fisheye_change_thumb_size' ) ) { $gBitSmarty->assign( 'galleryPaginationTypes', $gContent::getAllLayouts() ); if( !empty( $_REQUEST['savegallery'] ) ) { + // When creating a sub-gallery, inherit protector role from the first parent if not explicitly set + if( !$gContent->isValid() && !empty( $_REQUEST['gallery_additions'] ) && ( !isset( $_REQUEST['protector']['role_id'] ) || $_REQUEST['protector']['role_id'] == -1 ) ) { + $parentGalleryId = reset( $_REQUEST['gallery_additions'] ); + if( $parentContentId = $gContent->mDb->GetOne( "SELECT `content_id` FROM `".BIT_DB_PREFIX."fisheye_gallery` WHERE `gallery_id`=?", [ $parentGalleryId ] ) ) { + if( ( $parentRole = $gContent->mDb->GetOne( "SELECT `role_id` FROM `".BIT_DB_PREFIX."liberty_content_role_map` WHERE `content_id`=?", [ $parentContentId ] ) ) !== false ) { + $_REQUEST['protector']['role_id'] = $parentRole; + } + } + } if( $gContent->store( $_REQUEST ) ) { $gContent->storePreference( 'is_public', !empty( $_REQUEST['is_public'] ) ? $_REQUEST['is_public'] : null ); $gContent->storePreference( 'allow_comments', !empty( $_REQUEST['allow_comments'] ) ? $_REQUEST['allow_comments'] : null ); -- cgit v1.3