Hello folks,

I ported Disknode to work with Drupal core 6 about 6 weeks ago. I started with the developer version of 4.7.x. This whole development was part of a larger upgrade of a corporate intranet. The module's structure changed at some points to simplify it a little bit and reduce the amount of code. Some of these changes are explained in this post.

This post is mainly to get an idea how many people would like to use this module in D6. It has been working fine for the last couple of weeks for us. Though, the problem is that I didn't come up with a script to do the necessary change to the database that are needed to run it (described in the next section). I did those steps by hand when I upgraded our intranet.
If there is a huge interest in my solution I would invest time on my weekends to make it easy for 'first time users' (fresh D6 installations) and for users coming from 4.6.x or 4.7.x to use Disknode under D6 and keep their old attachments.

Evolution of 'files' table
Attachments are now stored in a table 'disknode'. This simply links the 'nid' (node id) to the 'fid' (file id). In Drupal 4.7.x this information was kept in the files table itself (there simply was a 'nid' field). Because this field no longer exists in D6 we duplicated the 'files' table and called it 'disknode'. Then we set 'nid' and 'fid' as primary keys and deleted all other fields in the new table. This has to be done prior to the upgrade to the newer Drupal core.

The structure of the 'disknode' table (after doing the steps above) is:

CREATE TABLE `disknode` (
  `fid` int(10) unsigned NOT NULL default '0',
  `nid` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  USING BTREE (`fid`,`nid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

Having this table implies that all files you want to attached to a node have to have a record in the 'files' table. Files that just have been copied & pasted into the 'files' folder can't be attached to nodes.

ZIP file upload
I implemented a ZIP file upload. An own folder will be created with the name of the ZIP file. If this folder already exists the folder name will also contain date and time. The files are extracted into that folder automatically and are registered in the 'files' table. At the moment there is no subfolder support. Only files that are in the base folder of the ZIP are extracted and registered.
There is an extra checkbox in the upload form to enable this feature. Therefore you could upload a ZIP file without having it extracted.

Minor issues fixed
We experienced some minor issues in D4.7.x (i.e. useless folders created when a file was uploaded and always forwards to the base folder rather then the last folder). These and some other issues have been fixed.

Ownership of files
I implemented a check of ownership that kicks in when a user tries to change (overwrite or delete) a file. The user won't be able to do so if he wasn't the person who uploaded the file in the first place. When you have the permission 'administer all disknode files' you'll be able to get around this check. So if you don't want this check at all you can just grant this permission to all 'authenticated' users.
In the 'info' panel (click the 'info' link beside a filename) you'll now see who's owning the file.

The attached ZIP file contains the module as we're using it. The purpose of posting the code now is to give you a preview of the code. Don't hesitate to discuss the code or to recommend changes, but please note that the code is still a bit dirty.

CommentFileSizeAuthor
disknode.zip45.28 KBmotto

Comments

drein’s picture

I'm using disknode but with drupal5.
First of all thanks a lot for your efforts and to give me a chance to work with drupal6 and disknode!
The problem is how to upgrade from a d5 to a d6, I'm very interested on this, because I have about 350 nodes and about 750 files uploaded with disknode, so reinstalling the module in d6 without keeping the original data will result in a great work to re-associate the node to the file.

Unfortunately there aren't many people that use this module, so obtain information or feedback is hard.
Anyway, if you have an idea of how to modify the mysql database I can try by hand, but I underline that I don't know anything about mysql, I'm able only to use Phpadmin to make basic operations, anyway modify a table can be done.
Thanks again!

mossaab’s picture

This is the best news I have ever heard since a couple of months ago.

Yes, I am very interested in porting disknode module to Drupal 6. In fact, I'm using it to manage about 1000 files in one website and 200 in an other one.

However, Is there any chance to make it upgradeable from Version 5?

enboig’s picture

Also interested in this.

idcm’s picture

Me too! I love the counter and the nice way it displays the download files. I have been in D4.6.8 and just this week upgraded to D6. I was reworking my taxonomy and realized I can't even edit the disknode now that I am in D6. Please keep the disknode rolling.

Ectar’s picture

I put this like a development release, don't know how to show it on a front page.

sgomez’s picture

Thanks for doing this. Keep it up!

v8powerage’s picture

I tried the 6 version but when I'm trying attach existing files from server into node I'm getting such an error:

downloads/ABC.pdf has not been found in the database. It will not appear under your post. Please download the file and upload it again to solve this problem.

drein’s picture

Well, today I tried to upgrade from d5 to d6.
I manually created the table disknode using your query and it's ok.
The problem is that I don't see my old files attached to the nodes.
A part of create that query, install the module and run update.php, do you know if I should make other things in order to recover all my old associations?
thanks.

drein’s picture

Ok, I solved some problems.
I must give a look at the files table and copy it into the disknode table, but removing all fields except for "nid" and "fid".
So now disknode runs correctly but I have the same problems you mentioned.
I think is incredible that few people use this module, nobody have a file that wants to attach to more nodes?

Hazeltree’s picture

I have been looking for a solution for awhile now. It works great on v 5 so with this solution I am ready to try it on the new v6 site I am working on. Thank you

drein’s picture

Hazeltree, there are 2 3 important bugs in the d6 version, I don't know if you are a coder o or developer, anyway
any efforts and testa are welcome!
let us know...

Ectar’s picture

Hey guys, how is it going with D6 port?