From d062a0e7e7e2aaf61574fa61f4976c9b41465b41 Mon Sep 17 00:00:00 2001
From: nicod_ <nicod@lerebooteux.fr>
Date: Wed, 15 Jan 2025 00:48:13 +0100
Subject: [PATCH] =?UTF-8?q?change:=20statut=20des=20blocks=20mis=20=C3=A0?=
 =?UTF-8?q?=20jour?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On supprime le statut prop, doublon de prepa fonctionnellement
On ajoute le statut poubelle, et on branche la corbeille
---
 base/blocks.php                    | 28 +++++++-------
 blocks_administrations.php         |  2 +
 blocks_pipelines.php               | 15 ++++++++
 lang/block_fr.php                  |  4 ++
 paquet.xml                         | 60 +++++++++++++++---------------
 prive/listes/corbeille_blocks.html | 18 +++++++++
 prive/objets/liste/blocks.html     |  6 ++-
 7 files changed, 88 insertions(+), 45 deletions(-)
 create mode 100644 prive/listes/corbeille_blocks.html

diff --git a/base/blocks.php b/base/blocks.php
index ac1da53..19fa595 100644
--- a/base/blocks.php
+++ b/base/blocks.php
@@ -44,16 +44,16 @@ function blocks_declarer_tables_objets_sql($tables) {
 		'type'                    => 'block',
 		'principale'              => 'oui',
 		'field'                   => [
-			'id_block'     => 'bigint(21) NOT NULL',
-			'blocktype'    => 'varchar(255) DEFAULT "" NOT NULL',
-			'objet'        => 'varchar(25) DEFAULT "" NOT NULL',
-			'id_objet'     => 'bigint(21) DEFAULT "0" NOT NULL',
-			'rang_lien'    => 'int(4) DEFAULT "0" NOT NULL',
-			'ancre'        => 'varchar(20) NOT NULL DEFAULT ""',
-			'valeurs'      => 'text NOT NULL DEFAULT ""',
-			'date'         => 'datetime NOT NULL DEFAULT "0000-00-00 00:00:00"',
-			'statut'       => 'varchar(20)  DEFAULT "0" NOT NULL',
-			'maj'          => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
+			'id_block'  => 'bigint(21) NOT NULL',
+			'blocktype' => 'varchar(255) DEFAULT "" NOT NULL',
+			'objet'     => 'varchar(25) DEFAULT "" NOT NULL',
+			'id_objet'  => 'bigint(21) DEFAULT "0" NOT NULL',
+			'rang_lien' => 'int(4) DEFAULT "0" NOT NULL',
+			'ancre'     => 'varchar(20) NOT NULL DEFAULT ""',
+			'valeurs'   => 'text NOT NULL DEFAULT ""',
+			'date'      => 'datetime NOT NULL DEFAULT "0000-00-00 00:00:00"',
+			'statut'    => 'varchar(20)  DEFAULT "0" NOT NULL',
+			'maj'       => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
 		],
 		'key'                     => [
 			'PRIMARY KEY'   => 'id_block',
@@ -67,11 +67,9 @@ function blocks_declarer_tables_objets_sql($tables) {
 		'champs_editables'        => ['blocktype', 'id_objet', 'objet', 'ancre'],
 		'champs_versionnes'       => ['blocktype', 'id_objet', 'objet', 'ancre', 'valeurs'],
 		'statut_textes_instituer' => [
-			'prepa'  => 'texte_statut_en_cours_redaction',
-			'prop'   => 'texte_statut_propose_evaluation',
-			'publie' => 'texte_statut_publie',
-			//			'refuse'   => 'texte_statut_refuse',
-			//			'poubelle' => 'texte_statut_poubelle',
+			'prepa'    => 'block:texte_statut_masque',
+			'publie'   => 'block:texte_statut_affiche',
+			'poubelle' => 'texte_statut_poubelle',
 		],
 		'statut'                  => [
 			[
diff --git a/blocks_administrations.php b/blocks_administrations.php
index 385095d..773bab8 100644
--- a/blocks_administrations.php
+++ b/blocks_administrations.php
@@ -115,6 +115,8 @@ function blocks_update_1_3_0() {
 			'id_block = ' . $blocks_lien['id_block']
 		);
 	}
+	// Le statut prop disparait au profit de prepa
+	sql_updateq('spip_blocks',['statut' => 'prepa'],'statut = "prop"');
 }
 
 function blocks_update_2_0_0() {
diff --git a/blocks_pipelines.php b/blocks_pipelines.php
index 374a1d1..b76f944 100644
--- a/blocks_pipelines.php
+++ b/blocks_pipelines.php
@@ -68,3 +68,18 @@ function blocks_optimiser_base_disparus($flux) {
 	sql_delete('spip_blocks', "statut='poubelle' AND maj < " . $flux['args']['date']);
 	return $flux;
 }
+
+/**
+ * Pipeline de la corbeille, permet de définir les objets à supprimer
+ *
+ * @param array $param Tableau d'objets
+ * @return array Tableau d'objets complété
+ */
+function blocks_corbeille_table_infos($param) {
+	$param['blocks'] = [
+		'statut' => 'poubelle',
+		'table'  => 'spip_blocks',
+	];
+
+	return $param;
+}
diff --git a/lang/block_fr.php b/lang/block_fr.php
index 0f48437..f226321 100644
--- a/lang/block_fr.php
+++ b/lang/block_fr.php
@@ -23,6 +23,8 @@ return [
 	'champ_blocktype_label'                => 'Type de bloc',
 	'champ_valeurs_label'                  => 'Valeurs',
 	'confirmer_supprimer_block'            => 'Confirmez-vous la suppression de ce bloc ?',
+	'corbeille_blocks_un'                  => 'Un block dans la corbeille',
+	'corbeille_blocks_tous'                => '@nb@ blocks dans la corbeille',
 
 	// I
 	'icone_creer_block'                    => 'Créer un bloc',
@@ -57,4 +59,6 @@ return [
 	'titre_logo_block'                     => 'Logo de ce bloc',
 	'titre_objets_lies_block'              => 'Liés à ce bloc',
 	'titre_page_blocks'                    => 'Les blocs',
+	'texte_statut_masque'                  => 'Masqué',
+	'texte_statut_affiche'                 => 'Affiché',
 ];
diff --git a/paquet.xml b/paquet.xml
index 5e58aae..5ee0dcc 100644
--- a/paquet.xml
+++ b/paquet.xml
@@ -1,41 +1,43 @@
 <paquet
-    prefix="blocks"
-    version="2.0.0"
-    etat="dev"
-    compatibilite="[4.2.0;4.*]"
-    logo="prive/themes/spip/images/blocks-xx.svg"
-    documentation=""
-    schema="2.0.0"
+	prefix="blocks"
+	version="2.0.0"
+	etat="dev"
+	compatibilite="[4.2.0;4.*]"
+	logo="prive/themes/spip/images/blocks-xx.svg"
+	documentation=""
+	schema="2.0.0"
 >
 
-    <nom>Blocks</nom>
-    <!-- Composer des pages avec des blocs -->
+	<nom>Blocks</nom>
+	<!-- Composer des pages avec des blocs -->
 
-    <auteur lien='https://contrib.spip.net/nicod_'>nicod_</auteur>
+	<auteur lien='https://contrib.spip.net/nicod_'>nicod_</auteur>
 
-    <licence>GNU/GPL</licence>
-    <necessite nom="ajaxfiltre" compatibilite="[1.0.10;]"/>
-    <necessite nom="saisies" compatibilite="[3.50.1;]"/>
-    <necessite nom="select2" compatibilite="[2.0.0;]"/>
-    <necessite nom="spip_bonux" compatibilite="[4.1.2;]"/>
-    <necessite nom="verifier" compatibilite="[3.1.0;]"/>
-    <necessite nom="yaml" compatibilite="[3.0.3;]"/>
+	<licence>GNU/GPL</licence>
+	<necessite nom="ajaxfiltre" compatibilite="[1.0.10;]"/>
+	<necessite nom="saisies" compatibilite="[3.50.1;]"/>
+	<necessite nom="select2" compatibilite="[2.0.0;]"/>
+	<necessite nom="spip_bonux" compatibilite="[4.1.2;]"/>
+	<necessite nom="verifier" compatibilite="[3.1.0;]"/>
+	<necessite nom="yaml" compatibilite="[3.0.3;]"/>
+	<utilise nom="corbeille"/>
 
-    <pipeline nom="autoriser" inclure="blocks_autorisations.php"/>
+	<pipeline nom="autoriser" inclure="blocks_autorisations.php"/>
 
-    <pipeline nom="declarer_tables_objets_sql" inclure="base/blocks.php"/>
-    <pipeline nom="declarer_tables_interfaces" inclure="base/blocks.php"/>
-	<pipeline nom="declarer_tables_auxiliaires" inclure="base/blocks.php" />
+	<pipeline nom="declarer_tables_objets_sql" inclure="base/blocks.php"/>
+	<pipeline nom="declarer_tables_interfaces" inclure="base/blocks.php"/>
+	<pipeline nom="declarer_tables_auxiliaires" inclure="base/blocks.php"/>
 
-    <pipeline nom="header_prive" inclure="blocks_pipelines.php"/>
-    <pipeline nom="affiche_enfants" inclure="blocks_pipelines.php"/>
-    <pipeline nom="afficher_contenu_objet" inclure="blocks_pipelines.php"/>
-    <pipeline nom="optimiser_base_disparus" inclure="blocks_pipelines.php"/>
+	<pipeline nom="header_prive" inclure="blocks_pipelines.php"/>
+	<pipeline nom="affiche_enfants" inclure="blocks_pipelines.php"/>
+	<pipeline nom="afficher_contenu_objet" inclure="blocks_pipelines.php"/>
+	<pipeline nom="optimiser_base_disparus" inclure="blocks_pipelines.php"/>
+	<pipeline nom="corbeille_table_infos" inclure="blocks_pipelines.php"/>
 
-    <menu nom="blocks" titre="block:titre_blocks" parent="menu_squelette" icone="images/block-16.png" action="blocks"/>
-    <menu nom="blocktypes" titre="blocktype:titre_blocktypes" parent="menu_squelette" icone="images/blocktype-16.png" action="blocktypes"/>
+	<menu nom="blocks" titre="block:titre_blocks" parent="menu_squelette" icone="images/block-16.png" action="blocks"/>
+	<menu nom="blocktypes" titre="blocktype:titre_blocktypes" parent="menu_squelette" icone="images/blocktype-16.png" action="blocktypes"/>
 
-    <chemin path="squelettes"/>
-    <chemin path=""/>
+	<chemin path="squelettes"/>
+	<chemin path=""/>
 
 </paquet>
diff --git a/prive/listes/corbeille_blocks.html b/prive/listes/corbeille_blocks.html
new file mode 100644
index 0000000..a8cb114
--- /dev/null
+++ b/prive/listes/corbeille_blocks.html
@@ -0,0 +1,18 @@
+<B_corbeille>
+  <div class="liste">
+	  [<h3 class="titrem">(#GRAND_TOTAL|singulier_ou_pluriel{block:corbeille_blocks_un,block:corbeille_blocks_tous})</h3>]
+	  [<nav class='pagination'>(#PAGINATION)</nav>]
+	  <ul class='liste-items checkables'>
+		  <BOUCLE_corbeille(BLOCKS){statut='poubelle'}{pagination 5}{!par date}{recherche ?}>
+		  <li class='item'>
+			  <label for='block-#ID_BLOCK'><:corbeille:selectionner:></label>
+			  <input type='checkbox' name='elements[]' id="block-#ID_BLOCK" value='#ID_BLOCK'[ (#ID_BLOCK|in_any{#ENV{elements}}|oui)checked='checked']/>
+			  <h4>[(#INFO_TITRE{block,#ID_BLOCK}|concat{' (',#OBJET,' n° ',#ID_OBJET,')'}|sinon{<:info_sans_titre:>})]</h4>
+			  <small>[(#DATE|affdate)][ (#DATE|heures)]:[(#DATE|minutes)]</small>
+			  <p class='actions'><a href='#URL_ECRIRE{block,id_block=#ID_BLOCK}'><:corbeille:voir_detail:></a></p>
+		  </li>
+		  </BOUCLE_corbeille>
+	  </ul>
+	  [<p class='pagination'>(#PAGINATION{prive})</p>]
+  </div>
+</B_corbeille>
diff --git a/prive/objets/liste/blocks.html b/prive/objets/liste/blocks.html
index 48d023e..c4efd9d 100644
--- a/prive/objets/liste/blocks.html
+++ b/prive/objets/liste/blocks.html
@@ -1,3 +1,6 @@
+[(#ENV{statut}|=={poubelle}|non)
+	#SET{where,'statut <> "poubelle"'}
+]
 [(#SET{defaut_tri,#ARRAY{
 	date,-1,
 	id_block,1,
@@ -20,7 +23,8 @@
 		</tr>
 	</thead>
 	<tbody>
-	<BOUCLE_liste_blocks(BLOCKS) {id_?} {objet?}{ where?} {statut?} {blocktype?} {recherche?}
+	<BOUCLE_liste_blocks(BLOCKS) {id_?} {objet?} {statut?} {blocktype?} {recherche?}
+		{where #GET{where}}
 		{tri #ENV{par,date},#GET{defaut_tri}} {!par date} {pagination #ENV{nb,10}}>
 		<tr class="[(#COMPTEUR_BOUCLE|alterner{row_odd,row_even})]">
 			<td class="picto">[(#CHEMIN_IMAGE{block-16.png}|balise_img)]</td>
-- 
GitLab