Index: upload.module =================================================================== RCS file: /cvs/drupal/drupal/modules/upload.module,v retrieving revision 1.15 diff -U3 -r1.15 upload.module --- upload.module 23 Nov 2004 22:20:41 -0000 1.15 +++ upload.module 3 Dec 2004 03:50:51 -0000 @@ -6,6 +6,9 @@ * File-handling and attaching files to nodes. */ +/** + * Implementation of hook_help(). + */ function upload_help($section) { switch ($section) { case 'admin/modules#description': @@ -26,10 +29,38 @@ } } +/** + * Implementation of hook_perm(). + */ function upload_perm() { return array('upload files', 'view uploaded files'); } +/** + * Implementation of hook_link(). + */ +function upload_link($type, $node = 0, $main = 0) { + $links = array(); + + // Main page: display a link with the number of attachments + if ($main && $type == 'node' && $node->files) { + $num_files = 0; + foreach ($node->files as $file) { + if ($file->list) { + $num_files++; + } + } + if ($num_files) { + $links[] = l(format_plural($num_files, '1 attachment', '%count attachments'), "node/$node->nid", array('title' => t('Read full article to view attachments.')), NULL, NULL); + } + } + + return $links; +} + +/** + * Implementation of hook_menu(). + */ function upload_menu($may_cache) { $items = array(); @@ -102,6 +133,9 @@ } } +/** + * Implementation of hook_nodeapi(). + */ function upload_nodeapi(&$node, $op, $arg) { switch ($op) { case 'settings':