<?php
/**
- * imp.php - performs the AJAX-requested action.
+ * Performs the AJAX-requested action.
*
* Copyright 2005-2009 The Horde Project (http://www.horde.org/)
*
}
// Send the final result.
-IMP::sendHTTPResponse(DIMP::prepareResponse($result, $notify), 'json');
+Horde::sendHTTPResponse(Horde::prepareResponse($result, $notify ? $GLOBALS['imp_notify'] : null), 'json');
$result->info = end($info);
$result->imp_compose = $imp_compose->getCacheId();
}
- IMP::sendHTTPResponse(DIMP::prepareResponse($result, true, false), 'js-json');
+ Horde::sendHTTPResponse(Horde::prepareResponse($result, $GLOBALS['imp_notify'], false), 'js-json');
exit;
}
}
}
- IMP::sendHTTPResponse(DIMP::prepareResponse($result, !$result->success || !Util::getFormData('nonotify'), false), 'json');
+ Horde::sendHTTPResponse(Horde::prepareResponse($result, !$result->success || !Util::getFormData('nonotify') ? $GLOBALS['imp_notify'] : null, false), 'json');
exit;
}
if (!($path = Util::getFormData('imple'))) {
if ($viewmode == 'dimp') {
- IMP::sendHTTPResponse(new stdClass(), 'json');
+ Horde::sendHTTPResponse(new stdClass(), 'json');
}
exit;
}
if (!($imple = IMP_Imple::factory($impleName))) {
if ($viewmode == 'dimp') {
- IMP::sendHTTPResponse(new stdClass(), 'json');
+ Horde::sendHTTPResponse(new stdClass(), 'json');
}
exit;
}
? (is_string($result) ? 'plain' : 'json')
: $_SERVER['Content-Type'];
-IMP::sendHTTPResponse($result, $ct);
+Horde::sendHTTPResponse($result, $ct);
}
/**
- * Returns a stdClass response object with added notification information.
- *
- * @param string $data The 'response' data.
- * @param boolean $notify If true, adds notification information to
- * object.
- * @param boolean $auto If true, DimpCore will automatically display the
- * notification. If false, the callback handler
- * is responsible for displaying the notification.
- */
- public function prepareResponse($data = null, $notify = true, $auto = true)
- {
- $response = new stdClass();
- $response->response = $data;
- if ($notify) {
- $GLOBALS['notification']->notify(array('listeners' => 'status'));
- $stack = $GLOBALS['imp_notify']->getStack();
- if (!empty($stack)) {
- $response->msgs = $GLOBALS['imp_notify']->getStack();
- if (!(bool)$auto) {
- $response->msgs_noauto = true;
- }
- }
- }
- return $response;
- }
-
- /**
* Return information about the current attachments for a message
*
* @param IMP_Compose $imp_compose An IMP_Compose object.
}
/**
- * Send response data to browser.
- *
- * @param mixed $data The data to serialize and send to the browser.
- * @param string $ct The content-type to send the data with. Either
- * 'json', 'js-json', 'html', 'plain', and 'xml'.
- */
- static public function sendHTTPResponse($data, $ct)
- {
- $charset = NLS::getCharset();
-
- // Output headers and encoded response.
- switch ($ct) {
- case 'json':
- case 'js-json':
- /* JSON responses are a structured object which always
- * includes the response in a member named 'response', and an
- * additional array of messages in 'msgs' which may be updates
- * for the server or notification messages.
- *
- * Make sure no null bytes sneak into the JSON output stream.
- * Null bytes cause IE to stop reading from the input stream,
- * causing malformed JSON data and a failed request. These
- * bytes don't seem to break any other browser, but might as
- * well remove them anyway.
- *
- * Finally, add prototypejs security delimiters to returned
- * JSON. */
- $s_data = '/*-secure-' .
- String::convertCharset(str_replace("\00", '', Horde_Serialize::serialize($data, SERIALIZE_JSON, $charset)), 'UTF-8') .
- '*/';
-
- if ($ct == 'json') {
- header('Content-Type: application/json');
- echo $s_data;
- } else {
- header('Content-Type: text/html; charset=' . $charset);
- echo htmlspecialchars($s_data);
- }
- break;
-
- case 'html':
- case 'plain':
- case 'xml':
- header('Content-Type: text/' . $ct . '; charset=' . $charset);
- echo $data;
- break;
-
- default:
- echo $data;
- }
-
- exit;
- }
-
- /**
* Outputs the necessary script tags, honoring local configuration
* choices as to script caching.
*/
switch (Util::nonInputVar('session_timeout')) {
case 'json':
$notification->push(null, 'dimp.timeout');
- IMP::sendHTTPResponse(DIMP::prepareResponse(), 'json');
+ Horde::sendHTTPResponse(Horde::prepareResponse(), 'json');
case 'none':
exit;