diff options
| -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; |
