boonebgorges / buddypress-docs

GNU General Public License v3.0
106 stars 44 forks source link

Upload document from Media Library #699

Closed ParkLai closed 3 years ago

ParkLai commented 3 years ago

When uploading a file, Admin is unable to select an existing (uploaded) file from the media library. Is there a way to enable this (just for Admin)?

Use case:

  1. There are multiple groups (A, B, C).
  2. There is a document which can be accessed by group A & B.
  3. Admin need to upload the same file on A, and again on B, as currently a document can only be assigned to a single group.
  4. The same documents will have 2 copies in the backend as it was uploaded twice to be assigned to group A & B.

This issue can be solved if there's a way for the Admin to select the same file for a different group.

boonebgorges commented 3 years ago

Hi @ParkLai - Thanks for the ticket.

The plugin's protections against direct file downloads make it difficult for this to work. Specifically, buddypress-docs filters the return path of wp_upload_dir() so that it's specific to the current Doc ID. Thus, when you upload a file via the Docs attachment interface, it's going into a directory that looks like uploads/bp-attachments/[doc_id]/. The autogenerated .htaccess files on Apache then depend on this Doc-specific directory when creating rewrite rules.

In contrast, if you uploaded a file to group 123, and it were stored in the 123 directory, but then you tried to use it in group 456, the system - as currently built - would check to see whether you have permissions to view 123.

As such, this change is not possible without extensive modifications to the underlying system of how files are uploaded and served. Files must be uploaded separately to each group.