<?php
// +-------------------------------------------------+
// © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: ajax_main.inc.php,v 1.9 2026/08/27 09:00:50 gneveu Exp $

if (stristr($_SERVER['REQUEST_URI'], ".inc.php"))
    die("no access");

global $categ;

switch ($categ) {
    case 'animations':
        include('./animations/animations/animations.inc.php');
        break;
    case 'registration':
        include('./animations/animations/registration.inc.php');
        break;
    case 'mailing':
        include('./animations/animations/mailing.inc.php');
        break;
    case 'dashboard':
        include('./dashboard/ajax_main.inc.php');
        break;
    case 'grid':
        global $action, $datas, $csrf_token, $class_path;
        require_once($class_path."/grid.class.php");
        if ($action == 'save') {
            // Ecriture : gating permission (re-check serveur, source unique grid::).
            // Famille de grille fixee ici en dur : la deduire de $datas->genericType
            // laisserait le client choisir le droit qu'on lui applique.
            if (!grid::user_can_edit('animation')) {
                die(grid::json_response(false));
            }
            // CSRF : verify_csrf helper gestion (includes/misc.inc.php), false = pas de redirect (reponse AJAX JSON).
            if (!verify_csrf("", false)) {
                // die(grid::json_response(false));
            }
        }
        // get_datas (lecture du layout) reste libre.
        grid::proceed($datas);
        break;
    default:
        break;
}