You are here

function imce_js in IMCE 6.2

Same name and namespace in other branches
  1. 6 inc/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/imce.page.inc
Returns the content of the file browser.

File

inc/imce.page.inc, line 90
Implements the file browser.

Code

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

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

      // Allow alteration of response.
      foreach (variable_get('imce_custom_response', array()) as $func => $state) {
        if ($state && function_exists($func)) {
          $func($jsop, $response, $imce, $user);
        }
      }
    }
  }

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

  //disable devel log.
  $GLOBALS['devel_shutdown'] = FALSE;

  //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;
}