Torrent module disables all uploads

Jonas Kvarnstrom - January 30, 2008 - 09:49
Project:BitTorrent
Version:5.x-2.0-beta2
Component:Code
Category:bug report
Priority:minor
Assigned:bradfordcp
Status:postponed
Description

The torrent module unconditionally sets #attachments to true in bt_torrent_form_alter, which is called for all forms in the system. This disables uploads for all node types.

A partly tested solution: Test whether the form ID is bt_torrent_form.

<?php
function bt_torrent_form_alter($form_id, &$form) {
   ...
   if (
$form_id == 'bt_torrent_form') {
     unset(
$form['attachments']);
   }
}
?>

I'm attaching a patch (hopefully in the correct format), but as I said it's partly tested and I don't know if this is the correct solution.

AttachmentSize
attachment-patch-01.patch463 bytes

#1

bradfordcp - February 4, 2008 - 18:25
Status:patch (code needs review)» patch (code needs work)

This will work, but it will allow a user to upload more than one torrent per node, which I am trying to avoid. I am thinking of switching to:

<?php
function bt_torrent_form_alter($form_id, &$form) {
  if (
$form_id == 'torrent_node_form') {
    unset(
$form['attachments']);
  }
  else if(
$form_id == 'upload_js') {
    if (
variable_get("upload_$node->type", TRUE) && isset($form['files']['upload_0']) && preg_match('/\.torrent/', $form['files']['upload_0']['filename']['#value'])) {
      unset(
$form['new']);
    }
  }
}
?>

but this will not allow users to upload more than one torrent on any node type.

#2

bradfordcp - February 4, 2008 - 22:16
Priority:critical» minor
Assigned to:Anonymous» bradfordcp
Status:patch (code needs work)» postponed

I have rolled the above code in, this will allow uploads across all forms unless your first upload is a .torrent file, then it disables a second file from being added.

 
 

Drupal is a registered trademark of Dries Buytaert.