You are here

function img_assist_upload in Image Assist 6.2

Same name and namespace in other branches
  1. 5.3 img_assist.module \img_assist_upload()
  2. 5 img_assist.module \img_assist_upload()
  3. 5.2 img_assist.module \img_assist_upload()
  4. 6 img_assist.module \img_assist_upload()

Interface for adding images. Uses the regular image node form.

Related topics

1 string reference to 'img_assist_upload'
img_assist_menu in ./img_assist.module
Implementation of hook_menu().

File

./img_assist.module, line 743
Image Assist module

Code

function img_assist_upload() {
  global $user;
  module_load_include('inc', 'node', 'node.pages');
  if (module_exists('image') && user_access('create images')) {

    // On other img_assist_pages I've added the javascript using the body onload
    // attribute, but for this page will also need the collapse functions and
    // setting the body onload interferes with this. To solve this, I'm forced
    // use the $(document).ready call. I should probably switch all the pages to
    // this format to be more Drupal friendly, but at the same time I don't know
    // if it really matters. If a user doesn't have Javascript, she can't use
    // img_assist at all.
    $output = "<script type=\"text/javascript\"><!-- \n";
    $output .= "  if (Drupal.jsEnabled) { \n";
    $output .= "    \$(document).ready(parent.initUpload);\n";
    $output .= "  } \n";
    $output .= "--></script>\n";

    // Define an empty node and fetch an image node form
    $node = array(
      'uid' => $user->uid,
      'name' => $user->name,
      'type' => 'image',
    );
    $output .= drupal_get_form('image_node_form', $node);
  }
  else {
    if (!module_exists('image')) {
      $output = t('The image module must be enabled to use Image assist.');
    }
    else {
      $output = t('Your account does not have image uploading privileges.');
    }
  }
  echo theme('img_assist_page', $output, array(
    'id' => 'img_assist_upload',
    'class' => 'img_assist',
  ));
  exit;
}