You are here

function upload_link in Drupal 6

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

Implementation of hook_link().

File

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

Code

function upload_link($type, $node = NULL, $teaser = FALSE) {
  $links = array();

  // Display a link with the number of attachments
  if ($teaser && $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['upload_attachments'] = array(
        'title' => format_plural($num_files, '1 attachment', '@count attachments'),
        'href' => "node/{$node->nid}",
        'attributes' => array(
          'title' => t('Read full article to view attachments.'),
        ),
        'fragment' => 'attachments',
      );
    }
  }
  return $links;
}