Skip to content
Extraits de code Groupes Projets
Valider 208cf9a3 rédigé par nicod's avatar nicod
Parcourir les fichiers

fix: Gestion des rôles dans un tableau de la config des types de blocks

parent 7aaf68a1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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'])) {
......
......@@ -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;
}
/**
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter