You are here

function comment_upload_form_alter in Comment Upload 6

Same name and namespace in other branches
  1. 5 comment_upload.module \comment_upload_form_alter()

Add an Attachments for comments setting to the content type settings forms.

Implementation of hook_form_alter().

File

./comment_upload.module, line 62
Provides file attachment functionality for comments.

Code

function comment_upload_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
    $form['comment']['comment_upload'] = array(
      '#type' => 'radios',
      '#title' => t('Attachments on comments'),
      '#default_value' => variable_get('comment_upload_' . $form['#node_type']->type, 0),
      '#options' => array(
        t('Disabled'),
        t('Enabled'),
      ),
      '#weight' => 20,
    );
    $image_options = array(
      'none' => t('Display as attachment'),
      'inline' => t('Display as full image'),
    );
    if (module_exists('imagecache')) {
      $presets = imagecache_presets();
      foreach ($presets as $preset_id => $preset) {
        $image_options[$preset_id] = t('Display via imagecache preset !preset', array(
          '!preset' => $preset['presetname'],
        ));
      }
    }
    $form['comment']['comment_upload_images'] = array(
      '#type' => 'select',
      '#title' => t('Image attachments on comments'),
      '#default_value' => variable_get('comment_upload_images_' . $form['#node_type']->type, 'none'),
      '#options' => $image_options,
      '#weight' => 20,
    );
  }
  elseif ($form_id == 'comment_form') {
    comment_upload_alter_comment_form($form, $form_state);
  }
}