diff --git a/formulaires/exporter_blocktypes.php b/formulaires/exporter_blocktypes.php index da5284e7c81fbbd87b0e8f93039c7e3b8245c039..ae23c92fddf0ef0663b2045194e05443748aebf8 100644 --- a/formulaires/exporter_blocktypes.php +++ b/formulaires/exporter_blocktypes.php @@ -44,7 +44,7 @@ function formulaires_exporter_blocktypes_traiter() { $blocks = sql_allfetsel('*', 'spip_blocktypes'); foreach ($blocks as $block) { - $block['enfants'] = array_column(sql_allfetsel( + $block['enfant'] = array_column(sql_allfetsel( 'b.identifiant', 'spip_blocktypes_liens bl join spip_blocktypes b on(b.id_blocktype = bl.id_objet)', [ @@ -54,7 +54,7 @@ function formulaires_exporter_blocktypes_traiter() { ] ), 'identifiant'); - $block['parents'] = array_column(sql_allfetsel( + $block['parent'] = array_column(sql_allfetsel( 'b.identifiant', 'spip_blocktypes_liens bl join spip_blocktypes b on(b.id_blocktype = bl.id_objet)', [ @@ -71,11 +71,11 @@ function formulaires_exporter_blocktypes_traiter() { if ($block['objets']) { $data['objets'] = $block['objets']; } - if ($block['enfants']) { - $data['enfants'] = $block['enfants']; + if ($block['enfant']) { + $data['roles']['enfant'] = $block['enfant']; } - if ($block['parents']) { - $data['parents'] = $block['parents']; + if ($block['parent']) { + $data['roles']['parent'] = $block['parent']; } if ($saisies = blocks_deserialize($block['saisies'])) { diff --git a/inc/blocks.php b/inc/blocks.php index 081804b2dc38e2844e8dc0dbbb38a9b7070664ed..05680d2ff46911c7dff7e3d5d5cd17802b6fdde2 100644 --- a/inc/blocks.php +++ b/inc/blocks.php @@ -32,7 +32,6 @@ function blocks_deserialize($data): ?array { return is_array($retour) ? $retour : null; } - /** * Chercher tous les types de blocs existant * On cherche des fichiers blocks/*.yaml dans le PATH @@ -308,18 +307,15 @@ function bloctypes_trouver_parents($blocktype): array { * @return array */ function _bloctypes_trouver_role(string $blocktype, string $role): array { - // TODO : à réécrire !!! - - // include_spip('action/editer_liens'); - // if ( - // $id_blocktype - // && $role - // && ($blocktypes_parents = objet_trouver_liens(['blocktype' => $id_blocktype], ['blocktype' => '*'], ['role' => $role])) - // ) { - // return array_column($blocktypes_parents, 'id_objet'); - // } - - return []; + $blocktypes_roles = []; + if ( + $blocktype + && ($blocktypes = blocktypes_lister_types()) + ) { + $blocktypes_roles = $blocktypes[$blocktype]['roles'][$role] ?? []; + } + + return $blocktypes_roles; } /**