@all Can you look at this answer? Does it just allows any cap that passed to user_has_cap filter? For example if we do a check for current_user_can( 'manage_options') ?
Based on @Marco answer I think I manage to write it simpler:
function allow_attachment_actions( $user_caps, $req_cap, $args ) {
// if no post is connected with capabilities check just return original array
if ( empty($args[2]) )
return $user_caps;
$post = get_post( $args[2] );
if (...
Sorry, I meant attachment related caps.. manage option won't pass for the post type check.