Multiple upload alone (for Drupal 6.x) allows to upload a single archive (zip) file and save the contained files into Drupal as node attachments (standard Upload).
When I wrote the first draft of it I haven't found any module for drupal 6.x to do this task but using proprietary plugins where single files were uploaded one after another. This wasn't the solution I was looking for since I have to give this module to unprivileged users to upload many photos and documents (from 30 to 70+ attachments per node) at once without caring of plugins and browser issues.
This is the refactored version of the module I'm using:
http://drupal.org/sandbox/chirale/1192546
Happy coding.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | preview.jpg | 16.33 KB | chirale |
Comments
Comment #1
andyf commentedHi,
I've taken a look through your module. First of all I installed it, and it worked as advertised! I have a few comments below.
hook_form_alter()to modify the upload element), rather than as a new local task. Is there a particular difficulty in that approach?_multiuploadalone_writefile()referencesarg(1)as the nid so can only be called from a node page). Also instead of cfr. you can use@see.drupal_get_form()and pass the name of the form as an argument.'file'key of the menu item.$extensionsarray.$tmp_filepathon line 200 seems unnecessary, as do_multiuploadalone_upload_page_init()and_multiuploadalone_upload_content(but maybe they're for something you're planning on adding?).$(document).ready(function(); it's preferred to use Drupal behaviors.Comment #2
chirale commentedThanks for your comments, AndyF! In the last commit:
$file->listfrom default upload setting is usedI've tested both for node edit (update) and creation (insert) and seems to work fine.
Some unsolved/future issues:
Feel free to review the new version. Thanks!
Comment #3
chirale commentedComment #4
andyf commentedHi chirale,
Sorry for the delay. I've taken a look through the latest, and the code and functionality are much nicer to my mind at least! I've put some notes below, but most of these are really quite minor I think.
multiuploadalone.module
t(). I also wonder if it might not be an idea to record this usingwatchdog(). Oh wait, looking closer it seems that it's not possible for this to ever error currently!!t()._upload_file_limits().multiuploadalone.inc
drupal_install_mkdir(). (The name does make you think it's only for install time, but the code seems generic.)$mode, give it a default value, then overwrite it (l33), then do a switch on it as if it hadn't been overwritten (l34), then repeat the code from the switch (l50-51) because the switch didn't do what you'd first expect!function_exists('exec')and respond gracefully if not, asexec()can be disabled for security reasons. You can also check for this inhook_requirements(), but I don't think that should replace the inline check, as someone might enable the module on a host with support and then migrate it to a different one.General
_multiuploadalone_uploadI personally find it weird to returnTRUEon error, but maybe that's just me :)multiuploadalone_upload_zip_validate()could be renamed to something a bit more generic? Following on from that, and just as a suggestion, if you know now that you might be adding support for other archive types, you can code with that in mind: currently where you have the extensionzipand mime typeapplication/ziphardcoded, they could be replaced by a function call that returns an array. This might make it easier to modify later.HTH
Andy
Comment #5
chirale commentedmultiuploadalone.module
5) By defaults upload_element module has a fallback to default upload limits if
file_validate_sizeis not overridden. I comment it but limits displayed on description are ignored. Apparently it is an Upload Element issue. Anyway, file limits are still used for single files contained within the archive.multiupload.inc
6) I try to use that function, but I have to include install.inc and I cannot get to work smoothly like mkdir. Added a Todo on comments about this issue.
7) It was simply a variable name error. Corrected.
9) That logic is on
multiuploadalone_requirements()on multiuploadalone.install. There, both exec and unzip command are checked (I've added few new lines). I've added phase runtime along install phase to alert the administrator on error. I've also added a check on user level that use the same function to avoid control statements duplications. Now the form element is not rendered if requirements are not met, and a message for the administrator is returned on Status Report page.General
11) Now it returns TRUE on success, FALSE on error.
13) Comment added on upload description.
14) Renamed to
multiuploadalone_upload_archive_validate().Any other issue of this list has been fixed.
Comment #6
andyf commentedHi,
Sorry for the delay in getting back to you.
I've put some notes below, and indicated the issues I think are blockers by asterisks*.
Ah sorry I didn't realise that: I think you definitely don't want to use it - it's not worth including a 22KB file just for that imho.
multiuploadalone.module
So on line 63 I think you should have
'file_validate_extensions' => array(implode(' ', $settings['allowed_extensions'])),. Similarly,$allowed_extensionson line 124 should beimplode(', ', $settings['allowed_extensions'])(or something similar). Currently it only displays the first element of the array.That's great. However I don't think it's very nice to manually call hook_requirements() (line 39) on the node edit form:
exec()on every nodeform build, which is not good from a performance point of view (it wouldn't scale well) as I understand.Personally I think it's best to keep hook_requirements absolutely the same, and just use a simple
function_exists('exec')for the nodeform check.if (user_access('upload files'))as that way you don't unnecessarily load the include file for users who won't need it (lower memory usage).multiupload.inc
rmdir- to me that's necessary. Is there a particular problem you were having with it? As it is, I think you'll end up with loads of directories in the tmp dir.HTH
Comment #7
chirale commentedNo problem, I was abroad and offline so I read your suggestions in the last few days.
multiuploadalone.module
multiupload.inc
And more:
Thank you for your suggestions.
Your turn.
Comment #8
chirale commentedComment #9
andyf commentedLooks good to me.
Comment #10
klausi* Git release branch is missing, see http://drupal.org/node/1015226
* README.txt is missing
* Remove the translations folder, translations are done on localize.drupal.org
* Remove empty install/uninstall functions
* "// Insert files within archive in {upload} table after save (new node) or update (existing node)" comment lines should not exceed 80 characters and should end with a "."
* "// Load" load what? be more specific in a comment
Comment #11
chirale commentedThank you klausi, I've created the 6.x-1.x branch and fix the other issues you listed. I've checked the module with Coder and should be fine now.
Are any other action required to comply to project standards?
Comment #12
klausiComment #13
chirale commentedPHP Zip extension support is planned: look at the comments within code to check the issues I've had. Anyway, the command line alternative should remains as fallback where PHP Zip extension is not available.
Comments and string concatenation should be ok now.
Are any other action required? Thank you.
Comment #14
klausiThos things are quite minor, otherwise RTBC for me. Now while we are waiting for the access grants to create full projects would you be so kind to do a review of the other applications pending? Just pick one from this list: http://drupal.org/project/issues/projectapplications?status=8
Comment #15
chirale commented$info is used to store version information from $execoutput when it's not empty. Fixed other lines and added doxygen header for a parameter on _multiuploadalone_file2db().
Thank you for reviewing this module, AndyF and klausi.
Comment #16
gregglesTwo smaller issues:
Please take a moment to make your project page follow tips for a great project page.
This is not great for translatability because it requires the version to be on the end:
better is
The @ substitution includes a call to check_plain.
Thanks for your contribution, chirale! Welcome to the community of project contributors on drupal.org.
I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
As you continue to work on your module, keep in minde: Commit messages - providing history and credit and Release naming conventions.