Modifying multi-upload
Permalink
Hello,
I'm wondering what would be the best method to modify multi-upload to make it work as in following example:
The site that has an admin (the company) and hundreds of basic users (customers). The admin is uploading new PDF-files to site monthly and each one of files should only be seen by one spesific user. Would it be best to solve this case like this:
1. The files should be named with a certain pattern, e.g. a user spesific ID in the beginning.
2. When uploading, the upload scripts checks file name and compares it to user ID's in database. Advanced file permissions are set that only certain user can view certain file.
What would be the best way to achieve this? Is it possible to modify the current upload page or should this be done by a separate functionality like single page?
Thanks.
I'm wondering what would be the best method to modify multi-upload to make it work as in following example:
The site that has an admin (the company) and hundreds of basic users (customers). The admin is uploading new PDF-files to site monthly and each one of files should only be seen by one spesific user. Would it be best to solve this case like this:
1. The files should be named with a certain pattern, e.g. a user spesific ID in the beginning.
2. When uploading, the upload scripts checks file name and compares it to user ID's in database. Advanced file permissions are set that only certain user can view certain file.
What would be the best way to achieve this? Is it possible to modify the current upload page or should this be done by a separate functionality like single page?
Thanks.
I'd build a custom form in the dashboard using a single page, which listed many input type=file elements. Next to each one I'd also put a username. Then upon submission, i'd loop through all the files, and import them into the file manager (check out concrete/tools/files/importers/single.php to see an example of how the single file uploader works - how it imports a file and creates a file object).
Then, for each file object created, I'd assign read permissions to that user. and remove read permissions for guest. Something like
$ui = UserInfo::getByUserName($username);
$fileObject->setPermissions($ui, 1, 0, 0, 0, 0);
(the 1 above is "canRead").
That should get you started, I think.