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 /edit.php | |
| 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>
Diffstat (limited to 'edit.php')
| -rwxr-xr-x | edit.php | 9 |
1 files changed, 9 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 ); |
