You are here

function upload_link in Drupal 4

Same name and namespace in other branches
  1. 5 modules/upload/upload.module \upload_link()
  2. 6 modules/upload/upload.module \upload_link()

Implementation of hook_link().

File

modules/upload.module, line 43
File-handling and attaching files to nodes.

Code

function upload_link($type, $node = 0, $main = 0) {
  $links = array();

  // Display a link with the number of attachments
  if ($main && $type == 'node' && isset($node->files) && user_access('view uploaded 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, 'attachments');
    }
  }
  return $links;
}