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

Ajout d'une table de liens entre les blocs et les objets

parent 8c3cbf50
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -63,7 +63,7 @@ function blocks_declarer_tables_objets_sql($tables) { ...@@ -63,7 +63,7 @@ function blocks_declarer_tables_objets_sql($tables) {
'champs_editables' => ['titre', 'id_blocs_type'], 'champs_editables' => ['titre', 'id_blocs_type'],
'champs_versionnes' => ['titre', 'valeurs', 'id_blocs_type'], 'champs_versionnes' => ['titre', 'valeurs', 'id_blocs_type'],
'rechercher_champs' => ["titre" => 10], 'rechercher_champs' => ["titre" => 10],
'tables_jointures' => [], 'tables_jointures' => ['spip_blocs_liens'],
'statut_textes_instituer' => [ 'statut_textes_instituer' => [
'prepa' => 'texte_statut_en_cours_redaction', 'prepa' => 'texte_statut_en_cours_redaction',
'prop' => 'texte_statut_propose_evaluation', 'prop' => 'texte_statut_propose_evaluation',
...@@ -108,3 +108,30 @@ function blocks_declarer_tables_objets_sql($tables) { ...@@ -108,3 +108,30 @@ function blocks_declarer_tables_objets_sql($tables) {
return $tables; return $tables;
} }
/**
* Déclaration des tables secondaires (liaisons)
*
* @pipeline declarer_tables_auxiliaires
* @param array $tables
* Description des tables
* @return array
* Description complétée des tables
*/
function blocks_declarer_tables_auxiliaires($tables) {
$tables['spip_blocs_liens'] = [
'field' => [
'id_bloc' => 'bigint(21) DEFAULT "0" NOT NULL',
'id_objet' => 'bigint(21) DEFAULT "0" NOT NULL',
'objet' => 'varchar(25) DEFAULT "" NOT NULL',
'vu' => 'varchar(6) DEFAULT "non" NOT NULL',
],
'key' => [
'PRIMARY KEY' => 'id_bloc,id_objet,objet',
'KEY id_bloc' => 'id_bloc',
],
];
return $tables;
}
...@@ -26,7 +26,7 @@ function blocks_upgrade($nom_meta_base_version, $version_cible) { ...@@ -26,7 +26,7 @@ function blocks_upgrade($nom_meta_base_version, $version_cible) {
$maj = []; $maj = [];
$maj['create'] = [ $maj['create'] = [
['maj_tables', ['spip_blocs', 'spip_blocs_types']], ['maj_tables', ['spip_blocs', 'spip_blocs_liens', 'spip_blocs_types']],
['blocks_installe_config'], ['blocks_installe_config'],
]; ];
...@@ -44,6 +44,7 @@ function blocks_upgrade($nom_meta_base_version, $version_cible) { ...@@ -44,6 +44,7 @@ function blocks_upgrade($nom_meta_base_version, $version_cible) {
function blocks_vider_tables($nom_meta_base_version) { function blocks_vider_tables($nom_meta_base_version) {
sql_drop_table('spip_blocs'); sql_drop_table('spip_blocs');
sql_drop_table('spip_blocs_liens');
sql_drop_table('spip_blocs_types'); sql_drop_table('spip_blocs_types');
# Nettoyer les liens courants (le génie optimiser_base_disparus se chargera de nettoyer toutes les tables de liens) # Nettoyer les liens courants (le génie optimiser_base_disparus se chargera de nettoyer toutes les tables de liens)
......
...@@ -123,6 +123,22 @@ function autoriser_blocstype_creerblocdans_dist($faire, $type, $id, $qui, $opt) ...@@ -123,6 +123,22 @@ function autoriser_blocstype_creerblocdans_dist($faire, $type, $id, $qui, $opt)
return ($id and autoriser('voir', 'blocs_types', $id) and autoriser('creer', 'bloc')); return ($id and autoriser('voir', 'blocs_types', $id) and autoriser('creer', 'bloc'));
} }
/**
* Autorisation de lier/délier l'élément (blocs)
*
* @param string $faire Action demandée
* @param string $type Type d'objet sur lequel appliquer l'action
* @param int $id Identifiant de l'objet
* @param array $qui Description de l'auteur demandant l'autorisation
* @param array $opt Options de cette autorisation
* @return bool true s'il a le droit, false sinon
**/
function autoriser_associerblocs_dist($faire, $type, $id, $qui, $opt) {
return ($qui['statut'] == '0minirezo' and !$qui['restreint'])
or (blocks_autoriser_statuts('bloc', $id, $qui, $opt)
and $auteurs = blocks_auteurs_objet('bloc', $id) and in_array($qui['id_auteur'], $auteurs));
}
// ----------------- // -----------------
// Objet blocs_types // Objet blocs_types
......
...@@ -93,6 +93,7 @@ function blocks_objet_compte_enfants($flux) { ...@@ -93,6 +93,7 @@ function blocks_objet_compte_enfants($flux) {
/** /**
* Optimiser la base de données * Optimiser la base de données
* *
* Supprime les liens orphelins de l'objet vers quelqu'un et de quelqu'un vers l'objet.
* Supprime les objets à la poubelle. * Supprime les objets à la poubelle.
* *
* @pipeline optimiser_base_disparus * @pipeline optimiser_base_disparus
...@@ -100,6 +101,10 @@ function blocks_objet_compte_enfants($flux) { ...@@ -100,6 +101,10 @@ function blocks_objet_compte_enfants($flux) {
* @return array Données du pipeline * @return array Données du pipeline
*/ */
function blocks_optimiser_base_disparus($flux) { function blocks_optimiser_base_disparus($flux) {
include_spip('action/editer_liens');
$flux['data'] += objet_optimiser_liens(['bloc' => '*'], '*');
sql_delete('spip_blocs', "statut='poubelle' AND maj < " . $flux['args']['date']); sql_delete('spip_blocs', "statut='poubelle' AND maj < " . $flux['args']['date']);
return $flux; return $flux;
} }
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
<pipeline nom="declarer_tables_objets_sql" 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_interfaces" inclure="base/blocks.php"/>
<pipeline nom="declarer_tables_auxiliaires" inclure="base/blocks.php" />
<pipeline nom="affiche_enfants" inclure="blocks_pipelines.php"/> <pipeline nom="affiche_enfants" inclure="blocks_pipelines.php"/>
<pipeline nom="boite_infos" inclure="blocks_pipelines.php"/> <pipeline nom="boite_infos" inclure="blocks_pipelines.php"/>
......
...@@ -37,6 +37,18 @@ ...@@ -37,6 +37,18 @@
] ]
] ]
<div class="nettoyeur"></div>
<div class="liste">
<BOUCLE_objetslies(spip_blocs_liens){id_bloc}{0,1}><h3><:bloc:titre_objets_lies_bloc:/></h3></BOUCLE_objetslies>
<BOUCLE_listeobjets(spip_blocs_liens){id_bloc}{fusion objet}{par objet}>
#SET{table,#OBJET|table_objet}
[(#SET{titre,[#OBJET:info_(#GET{table})_liees_bloc]})]
[(#SET{liste,#VAL{prive/objets/liste/#GET{table}}|trouver_fond|?{#GET{table},objets_lies_bloc}})]
<INCLURE{fond=prive/objets/liste/#GET{liste},objet,id_bloc,ajax,env} />
</BOUCLE_listeobjets>
</div>
#PIPELINE{afficher_complement_objet,#ARRAY{args,#ARRAY{type,bloc,id,#ID_BLOC},data,'<div class="nettoyeur"></div>'}} #PIPELINE{afficher_complement_objet,#ARRAY{args,#ARRAY{type,bloc,id,#ID_BLOC},data,'<div class="nettoyeur"></div>'}}
#BOITE_FERMER #BOITE_FERMER
......
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