--- comment_upload.module	23 Jun 2006 00:06:31 -0000	1.4
+++ comment_upload.module	10 Sep 2006 06:42:40 -0000
@@ -20,41 +20,33 @@
       $cobj->files = _comment_upload_load_files($cid);
       _upload_prepare($cobj);
       $form = array('#attributes' => array('enctype' => 'multipart/form-data'));
-      if (variable_get('comment_upload_single', 0)) {
-        $form['upload'] = array(
-        '#type' => 'file',
-          '#title' => t('Attachment'),
-          '#size' => 50,
-          '#description' => !empty($cobj->files) ? t('You already have a file uploaded, if you upload another it will overwrite the current one.') :''
-          );
-      }
-      else {
-        drupal_add_js('misc/progress.js');
-        drupal_add_js('misc/upload.js');
 
-        // Attachments fieldset
-        $form['attachments'] = array(
-          '#type' => 'fieldset',
-          '#title' => t('File attachments'),
-          '#collapsible' => TRUE,
-          '#collapsed' => empty($cobj->files),
-          '#description' => t('Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.'),
-          '#prefix' => '<div class="attachments">',
-          '#suffix' => '</div>',
-          '#weight' => 10,
-        );
-
-        // Wrapper for fieldset contents (used by upload JS).
-        $form['attachments']['wrapper'] = array(
-          '#prefix' => '<div id="attach-wrapper">',
-          '#suffix' => '</div>',
-        );
-        $form['attachments']['wrapper'] += _upload_form($cobj);
-
-        $form['attachments']['wrapper']['attach']['#value'] = url('comment_upload/js', NULL, NULL, TRUE);
-        $form['current']['cid'] = array('#type' => 'hidden', '#value' => $cid);
-        unset($form['attachments']['wrapper']['current']['vid']);
-      }
+      drupal_add_js('misc/progress.js');
+      drupal_add_js('misc/upload.js');
+
+      // Attachments fieldset
+      $form['attachments'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('File attachments'),
+        '#collapsible' => TRUE,
+        '#collapsed' => empty($cobj->files),
+        '#description' => t('Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.'),
+        '#prefix' => '<div class="attachments">',
+        '#suffix' => '</div>',
+        '#weight' => 10,
+      );
+
+      // Wrapper for fieldset contents (used by upload JS).
+      $form['attachments']['wrapper'] = array(
+        '#prefix' => '<div id="attach-wrapper">',
+        '#suffix' => '</div>',
+      );
+      $form['attachments']['wrapper'] += _upload_form($cobj);
+
+      $form['attachments']['wrapper']['attach']['#value'] = url('comment_upload/js', NULL, NULL, TRUE);
+      $form['current']['cid'] = array('#type' => 'hidden', '#value' => $cid);
+      unset($form['attachments']['wrapper']['current']['vid']);
+
       return $form;
     case 'validate':
       _upload_validate($comment);
@@ -76,22 +68,9 @@
       if (!isset($comment->files)) {
         $comment->files = _comment_upload_load_files($cid, $comment->nid);
       }
-      elseif (is_array($comment->files) && variable_get('comment_upload_single', 0)) {
-        // Simulate overwrite for preview
-        foreach ($comment->files as $file) {
-          if (strpos($file['fid'], 'upload') !== false) {
-            unset($comment->files[0]);
-            break;
-          }
-        }
-      }
       if ($comment->files) {
-        if (count($comment->files) == 1 && variable_get('comment_upload_single', 0)) {
-          $files = $comment->files;
-          $comment->comment .= theme('comment_attachment', (object)array_pop($files), $comment);
-        }
-        else {
-          $comment->comment .= theme('upload_attachments', $comment->files);
+        while (count($comment->files) > 0) {
+          $comment->comment .= theme('comment_attachment', (object)array_pop($comment->files), $comment);
         }
       }
       break;
@@ -106,13 +85,9 @@
     );
   }
   else if ($form_id == 'upload_settings_form') {
-    $form['settings_general']['comment_upload_single'] = array(
-      '#type' => 'select', '#title' => t('Attachments on comments'), '#default_value' => variable_get('comment_upload_single', 0),
-      '#options' => array(t('Multiple'), t('Single')), '#description' => t('Set whether to allow only one attachment per comment'),
-    );
     $form['settings_general']['comment_upload_inline_image'] = array(
       '#type' => 'select', '#title' => t('Images on comments'), '#default_value' => variable_get('comment_upload_inline_image', 0),
-      '#options' => array(t('Normal attachment'), t('Inline display')), '#description' => t('Show uploaded image with comment or use a normal attachment link (single attachment mode only)'),
+      '#options' => array(t('Normal attachment'), t('Inline display')), '#description' => t('Show uploaded image with comment or use a normal attachment link'),
     );
   }
 }
@@ -206,15 +181,10 @@
     elseif (strpos($file->fid, 'upload') !== false) {
       if ($file = file_save_upload($file, $file->filename)) {
         // Overwrite existing in single-attachment mode
-        if (variable_get('comment_upload_single', 0) && isset($comment['files'][0])) {
-          db_query("UPDATE {files} SET filename = '%s', filepath = '%s', filemime = '%s', filesize = %d WHERE fid = %d", $file->filename, $file->filepath, $file->filemime, $file->filesize, $comment['files'][0]['fid']);
-        }
-        else {
-          $file->fid = db_next_id('{files}_fid');
-          db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', %d)", $file->fid, 0, $file->filename, $file->filepath, $file->filemime, $file->filesize);
-          db_query("INSERT INTO {file_revisions} (fid, vid, list, description) VALUES (%d, %d, %d, '%s')", $file->fid, 0, $file->list, $file->description);
-          db_query("INSERT INTO {comment_files} (fid, nid, cid) VALUES (%d, %d, %d)", $file->fid, $comment['nid'], $comment['cid']);
-        }
+        $file->fid = db_next_id('{files}_fid');
+        db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', %d)", $file->fid, 0, $file->filename, $file->filepath, $file->filemime, $file->filesize);
+        db_query("INSERT INTO {file_revisions} (fid, vid, list, description) VALUES (%d, %d, %d, '%s')", $file->fid, 0, $file->list, $file->description);
+        db_query("INSERT INTO {comment_files} (fid, nid, cid) VALUES (%d, %d, %d)", $file->fid, $comment['nid'], $comment['cid']);
       }
       unset($_SESSION['file_previews'][$fid]);
     }
@@ -243,10 +213,11 @@
   $href = check_url(strpos($file->fid, 'upload') === false ? file_create_url($file->filepath) : url(file_create_filename($file->filename, file_create_path())));
   $regex = '/\.('. ereg_replace(' +', '|', preg_quote('jpg jpeg gif png')) .')$/i';
   if (variable_get('comment_upload_inline_image', 0) && preg_match($regex, $file->filename)) {
-    $html = '<img src="'. $href .'"/>';
+    $html = '<h4>' . $file->description . '</h4>'
+      . '<div><img src="' . $href . '" alt="' . $file->description . '" /></div>';
   }
   else {
-    $html = '<a href="'. $href .'">'. check_plain($file->filename) .' ('. format_size($file->filesize) .')</a>';
+    $html = '<a href="'. $href .'">'. check_plain($file->filename) .' ('. format_size($file->filesize) .')</a><br />';
   }
   return $html;
 }
