Index: modules/filestore2/filestore2.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/filestore2/filestore2.module,v retrieving revision 1.19 diff -u -r1.19 filestore2.module --- modules/filestore2/filestore2.module 8 Oct 2004 13:04:15 -0000 1.19 +++ modules/filestore2/filestore2.module 13 Oct 2004 07:02:17 -0000 @@ -1,5 +1,6 @@ t("Browse files to download"))); } - if (user_access('access files') && $node->fsid) { - $links[] = l(t('download'), "filestore2/download/$node->nid/$node->filename", array("title" => t('download %filename', array('%filename' => $node->filename)))); - } if ($type == "node" && user_access("access content") && $node->fsid) { + $links[] = l(t('download'), "filestore2/download/$node->nid/$node->filename", array("title" => t('download %filename', array('%filename' => $node->filename)))); $links[] = format_size($node->size); if (module_exist("statistics") && user_access("access statistics") && variable_get("statistics_display_counter", 0)) { $links[] = format_plural(($node->downloads ? $node->downloads : 0), "1 download", "%count downloads"); @@ -63,7 +62,7 @@ $items = array(); $items[] = array('path' => 'node/add/filestore2', 'title' => t('upload file'), 'callback' => 'node_page', 'access' => user_access("upload files"), 'type' => MENU_NORMAL_ITEM); - $items[] = array('path' => 'filestore2', 'title' => t('Browse files to download'), 'callback' => 'filestore2_page', 'access' => user_access("access files"), 'type' => MENU_CALLBACK); + $items[] = array('path' => 'filestore2', 'title' => t('Browse files to download'), 'callback' => 'filestore2_page', 'access' => user_access("access content"), 'type' => MENU_CALLBACK); $items[] = array('path' => 'filestore2/download', 'title' => t('Browse files to download'), 'callback' => 'filestore2_page', 'access' => user_access("access content"), 'type' => MENU_CALLBACK); $items[] = array('path' => 'admin/settings/filestore/convert', 'title' => t('convert'), 'callback' => 'filestore2_convert', 'access' => module_exist("filestore") && user_access("access administration pages"), 'type' => MENU_LOCAL_TASK); return $items; @@ -92,20 +91,19 @@ switch (arg(1)) { case "download": - if (user_access("access files")) { - $node = node_load(array("nid" => arg(2))); - if (fscache_download(array("fsid" => $node->fsid), TRUE)) { - db_query("UPDATE {filestore2} SET downloads = downloads + 1 WHERE nid = $node->nid"); - watchdog("user", t("file %filename downloaded.", array("%filename" => $node->filename))); - } - else { - drupal_access_denied(); - } + $node = node_load(array("nid" => arg(2))); + if (fscache_download(array("fsid" => $node->fsid), TRUE)) { + db_query("UPDATE {filestore2} SET downloads = downloads + 1 WHERE nid = $node->nid"); + watchdog("user", t("file %filename downloaded.", array("%filename" => $node->filename))); } break; + case 'browse': + print theme("page",_filestore2_browse(arg(2))); + break; default: + $output .= theme('box','',theme('filestore2alpha', ' ')); + $result = pager_query("SELECT n.nid, n.type FROM {node} n JOIN {filestore2} f WHERE n.status = '1' AND n.nid = f.nid ORDER BY ". ($_GET["order"] ? $_GET["order"]. " ". $_GET["sort"] : "n.sticky DESC, n.created DESC"), variable_get("default_nodes_main", 10)); - while ($node = db_fetch_object($result)) { $output .= node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1); } @@ -486,4 +484,65 @@ } } } -?> + +function _filestore2_browse($letter) { + $breadcrumb[] = l(t("Home"), NULL); + $breadcrumb[] = l(t("Files"),"filestore2"); + $breadcrumb[] = $letter; + drupal_set_breadcrumb($breadcrumb); + + $output = theme('box','',theme('filestore2alpha', $letter)); + + $output .= theme('filestore2_page_browse',$letter); + + return $output; +} + +//Theme functions +/* +* artistalpha($letter) +* $letter is were we are now +* returns htmlstring +* +* TODO: it would make sense to cache this, since the alphabet will not change often :). +* this can be achieved in a couple of ways: +* * make it a string that can be t()-ed +* * use the drupal cache, and call db. +*/ +function theme_filestore2alpha($letter) { + $alphabet = array ("A","B","C","D","E","F","G","H","I","J","K","L","M", + "N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0"); + $num = count($alphabet) - 1; + $output = "