Example #1
0
    die('Access denied');
}
use Tygh\Registry;
use Twigmo\Core\Functions\Order\TwigmoOrder;
use Twigmo\Core\Api;
use Twigmo\Core\TwigmoConnector;
use Tygh\Session;
use Tygh\Navigation\LastView;
use Twigmo\Core\Functions\Lang;
use Twigmo\Api\ApiData;
use Twigmo\Core\TwigmoSettings;
$format = !empty($_REQUEST['format']) ? $_REQUEST['format'] : TWG_DEFAULT_DATA_FORMAT;
$api_version = !empty($_REQUEST['api_version']) ? $_REQUEST['api_version'] : TWG_DEFAULT_API_VERSION;
$response = new ApiData($api_version, $format);
if (!empty($_REQUEST['callback'])) {
    $response->setCallback($_REQUEST['callback']);
}
$object = !empty($_REQUEST['object']) ? $_REQUEST['object'] : '';
$lang_code = DESCR_SL;
$action = $_REQUEST['action'];
if (empty($action) || !fn_twg_check_permissions($object, $action, $auth)) {
    fn_twg_throw_error_denied($response);
}
$data = '';
if (!empty($_REQUEST['data'])) {
    $data = ApiData::parseDocument(base64_decode(rawurldecode($_REQUEST['data'])), $format);
}
$update_actions = array('update', 'update_status', 'update_info', 'delete');
if (($_SERVER['REQUEST_METHOD'] == 'POST' || $format == 'jsonp') && in_array($action, $update_actions)) {
    if (empty($data)) {
        $response->addError('ERROR_WRONG_DATA', __('twgadmin_wrong_api_data'));