Download & Extend

Torrent module disables all uploads

Project:BitTorrent
Version:5.x-2.0-beta2
Component:Code
Category:bug report
Priority:minor
Assigned:bradfordcp
Status:closed (won't fix)

Issue Summary

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

Comments

#1

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:

<?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

Priority:critical» minor
Assigned to:Anonymous» bradfordcp
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.

#3

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...

#4

Status:postponed» closed (won't fix)

5.x version is longer not supported.