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.

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.

CommentFileSizeAuthor
attachment-patch-01.patch463 bytesJonas Kvarnstrom

Comments

bradfordcp’s picture

Status: Needs review » 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:

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.

bradfordcp’s picture

Assigned: Unassigned » bradfordcp
Priority: Critical » Minor
Status: 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.

gildedgod’s picture

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.

And that is the case when it does not work: http://drupal.org/node/317686

Because of using CCK module the first upload is not a .torrent file...

liquixis’s picture

Status: Postponed » Closed (won't fix)

5.x version is longer not supported.