diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-21 20:12:42 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-21 20:12:42 +0100 |
| commit | d673d42771ba298851ad58dcf109946b0d983087 (patch) | |
| tree | 5da92969c6ecee513049ef2dafb01842d2de71d1 | |
| parent | d70999eb3b6bec121d199293650ab6661db44942 (diff) | |
| download | fisheye-d673d42771ba298851ad58dcf109946b0d983087.tar.gz fisheye-d673d42771ba298851ad58dcf109946b0d983087.tar.bz2 fisheye-d673d42771ba298851ad58dcf109946b0d983087.zip | |
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 <noreply@anthropic.com>
| -rwxr-xr-x | edit.php | 9 | ||||
| -rwxr-xr-x | includes/upload_inc.php | 9 |
2 files changed, 18 insertions, 0 deletions
@@ -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 ); diff --git a/includes/upload_inc.php b/includes/upload_inc.php index cab8b30..c694117 100755 --- a/includes/upload_inc.php +++ b/includes/upload_inc.php @@ -122,6 +122,15 @@ function fisheye_store_upload( &$pFileHash, $pImageData = [], $pAutoRotate=true if( !empty( $pFileHash ) && ( $pFileHash['size'] > 0 ) && is_file( $pFileHash['tmp_name'] ) && fisheye_verify_upload_item( $pFileHash ) ) { // make a copy for each image we need to store $image = new FisheyeImage(); + // Inherit protector role from the target gallery if not explicitly set + if( !isset( $pImageData['protector']['role_id'] ) && !empty( $pImageData['gallery_additions'] ) ) { + $parentGalleryId = reset( $pImageData['gallery_additions'] ); + if( $parentContentId = $image->mDb->GetOne( "SELECT `content_id` FROM `".BIT_DB_PREFIX."fisheye_gallery` WHERE `gallery_id`=?", [ $parentGalleryId ] ) ) { + if( ( $parentRole = $image->mDb->GetOne( "SELECT `role_id` FROM `".BIT_DB_PREFIX."liberty_content_role_map` WHERE `content_id`=?", [ $parentContentId ] ) ) !== false ) { + $pImageData['protector']['role_id'] = $parentRole; + } + } + } // Store/Update the image $pImageData['_files_override'] = [ $pFileHash ]; $pImageData['process_storage'] = STORAGE_IMAGE; |
