You are here

function imce_js in IMCE 6

Same name and namespace in other branches
  1. 6.2 inc/imce.page.inc \imce_js()
  2. 7 inc/imce.page.inc \imce_js()

Ajax operations. q=imce&jsop={op}

1 call to imce_js()
imce_content in inc/page.inc
Content of the file browser.

File

inc/page.inc, line 76

Code

function imce_js($user, $jsop = '') {
  $response = array();

  //data
  if ($imce = imce_initiate_profile($user)) {
    imce_process_profile($imce);
    if (!$imce['error']) {
      include_once './' . drupal_get_path('module', 'imce') . '/inc/js.inc';
      if (function_exists($func = 'imce_js_' . $jsop)) {
        $response['data'] = $func($imce);
      }
    }
  }

  //messages
  $response['messages'] = drupal_get_messages();

  //for upload we must return plain text header.
  drupal_set_header('Content-Type: text/' . ($jsop == 'upload' ? 'html' : 'javascript') . '; charset=utf-8');
  print drupal_to_js($response);
  exit;
}