2010-06-01 16:20:55 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2010-06-01 20:54:31 +02:00
|
|
|
* eGroupWare - general JSON handler for EGroupware
|
2010-06-01 16:20:55 +02:00
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package api
|
|
|
|
* @subpackage ajax
|
2010-06-01 20:54:31 +02:00
|
|
|
* @author Andreas Stoeckel <as@stylite.de>
|
2010-06-01 16:20:55 +02:00
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
2010-06-01 20:54:31 +02:00
|
|
|
/**
|
|
|
|
* callback if the session-check fails, redirects via xajax to login.php
|
|
|
|
*
|
|
|
|
* @param array &$anon_account anon account_info with keys 'login', 'passwd' and optional 'passwd_type'
|
|
|
|
* @return boolean/string true if we allow anon access and anon_account is set, a sessionid or false otherwise
|
|
|
|
*/
|
|
|
|
function xajax_redirect(&$anon_account)
|
|
|
|
{
|
|
|
|
$response = new egw_json_response();
|
2010-06-11 13:41:12 +02:00
|
|
|
$response->redirect($GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=10', true);
|
2010-06-01 20:54:31 +02:00
|
|
|
$response->printOutput();
|
|
|
|
|
|
|
|
common::egw_exit();
|
|
|
|
}
|
2010-06-01 16:20:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Exception handler for xajax, return the message (and trace, if enabled) as alert() to the user
|
|
|
|
*
|
|
|
|
* Does NOT return!
|
|
|
|
*
|
|
|
|
* @param Exception $e
|
|
|
|
*/
|
|
|
|
function ajax_exception_handler(Exception $e)
|
|
|
|
{
|
2010-06-01 20:54:31 +02:00
|
|
|
// logging all exceptions to the error_log
|
|
|
|
if (function_exists('_egw_log_exception'))
|
|
|
|
{
|
|
|
|
_egw_log_exception($e,$message);
|
|
|
|
}
|
|
|
|
$response = new egw_json_response();
|
|
|
|
$message .= ($message ? "\n\n" : '').$e->getMessage();
|
2011-03-14 18:50:22 +01:00
|
|
|
|
2010-06-01 20:54:31 +02:00
|
|
|
// only show trace (incl. function arguments) if explicitly enabled, eg. on a development system
|
|
|
|
if ($GLOBALS['egw_info']['server']['exception_show_trace'])
|
|
|
|
{
|
|
|
|
$message .= "\n\n".$e->getTraceAsString();
|
|
|
|
}
|
2010-06-08 11:34:49 +02:00
|
|
|
$response->alert($message);
|
2010-06-01 20:54:31 +02:00
|
|
|
$response->printOutput();
|
|
|
|
|
|
|
|
if (is_object($GLOBALS['egw']))
|
|
|
|
{
|
|
|
|
common::egw_exit();
|
|
|
|
}
|
|
|
|
exit;
|
2010-06-01 16:20:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// set our own exception handler, to not get the html from eGW's default one
|
|
|
|
set_exception_handler('ajax_exception_handler');
|
|
|
|
|
|
|
|
if (isset($_GET['menuaction']))
|
|
|
|
{
|
|
|
|
if (strpos($_GET['menuaction'],'::') !== false && strpos($_GET['menuaction'],'.') === false) // static method name app_something::method
|
|
|
|
{
|
|
|
|
@list($className,$functionName,$handler) = explode('::',$_GET['menuaction']);
|
|
|
|
list($appName) = explode('_',$className);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
@list($appName, $className, $functionName, $handler) = explode('.',$_GET['menuaction']);
|
|
|
|
}
|
2011-03-14 18:50:22 +01:00
|
|
|
//error_log("json.php: appName=$appName, className=$className, functionName=$functionName, handler=$handler");
|
2010-06-01 16:20:55 +02:00
|
|
|
|
|
|
|
$GLOBALS['egw_info'] = array(
|
|
|
|
'flags' => array(
|
|
|
|
'currentapp' => $appName,
|
|
|
|
'noheader' => True,
|
|
|
|
'disable_Template_class' => True,
|
|
|
|
'autocreate_session_callback' => 'xajax_redirect',
|
|
|
|
'no_exception_handler' => true, // we already installed our own
|
|
|
|
'no_dla_update' => $appName == 'notifications', // otherwise session never time out
|
|
|
|
)
|
|
|
|
);
|
2011-04-13 15:31:09 +02:00
|
|
|
//if ($_GET['menuaction'] !='notifications.notifications_ajax.get_notifications') error_log(__METHOD__.__LINE__.' Appname:'.$appName.' Action:'.print_r($_GET['menuaction'],true));
|
|
|
|
if ($_GET['menuaction']=='felamimail.ajaxfelamimail.refreshMessageList' ||
|
2011-05-03 21:43:51 +02:00
|
|
|
$_GET['menuaction']=='felamimail.ajaxfelamimail.refreshFolderList')
|
2011-04-13 15:31:09 +02:00
|
|
|
{
|
|
|
|
$GLOBALS['egw_info']['flags']['no_dla_update']=true;
|
|
|
|
}
|
2010-06-01 16:20:55 +02:00
|
|
|
include('./header.inc.php');
|
|
|
|
|
|
|
|
|
|
|
|
//Create a new json handler
|
|
|
|
$json = new egw_json_request();
|
|
|
|
|
|
|
|
//Check whether the request data is set
|
2010-06-29 14:58:55 +02:00
|
|
|
if (isset($GLOBALS['egw_unset_vars']['_POST[json_data]']))
|
|
|
|
{
|
|
|
|
throw new egw_exception_assertion_failed("JSON Data contains script tags. Aborting...");
|
|
|
|
}
|
2011-09-13 19:27:02 +02:00
|
|
|
$json->parseRequest($_GET['menuaction'], $_POST['json_data']);
|
2011-05-03 21:43:51 +02:00
|
|
|
egw_json_response::get();
|
2010-06-01 20:54:31 +02:00
|
|
|
common::egw_exit();
|
2010-06-01 16:20:55 +02:00
|
|
|
}
|
|
|
|
|
2010-06-01 20:54:31 +02:00
|
|
|
throw new Exception($_SERVER['PHP_SELF'] . ' Invalid AJAX JSON Request');
|