The snippet below can be a nice addition to the upload module. It gives
a table with all nodes uploaded on the system via the core API. It would
nice to have the possibility of managing (remove/edit) images from this
page via the upload module API. What do you think ?


global $base_url;

$result = db_query('SELECT DISTINCT n.uid, f .* FROM {files} f INNER JOIN {node} n ON f.nid = n.nid INNER JOIN {file_revisions} r ON f.fid = r.fid');

$header = array('Node', 'User', 'File', 'Type', 'Size');
$files = array();

while ($file = db_fetch_object($result)) {
     $node = l('n','node/' . $file->nid);
     $user = l('u','user/' . $file->uid);
     $path = l($file->filename, $file->filepath);
     $files[] = array($node,$user,$path,$file->filemime,$file->filesize);
}

print theme('table',$header,$files);

Comments

bradlis7’s picture

I don't like "n" and "u", maybe instead you could use the username, and the node title?

This may not be the most optimized, but I've come up with something...

<?php
global $base_url;

$result = db_query('SELECT DISTINCT n.uid, n.title, f.* FROM {files} f INNER JOIN {node} n ON f.nid = n.nid INNER JOIN {file_revisions} r ON f.fid = r.fid');

$header = array('Node', 'User', 'File', 'Type', 'Size');
$files = array();

while ($file = db_fetch_object($result)) {
    $node = l($file->title,'node/' . $file->nid);
    $user_ = user_load(array("uid"=>$file->uid));
    $user = l($user_->name,'user/' . $file->uid);
    $path = l($file->filename, $file->filepath);
    $files[] = array($node,$user,$path,$file->filemime,$file->filesize);
}

print theme('table',$header,$files);
?>
abir16’s picture

It's very nice code. I think I will use it in file upload service. Thanks.