Changeset 93617 in spip-zone
- Timestamp:
- Dec 13, 2015, 11:44:49 AM (4 years ago)
- Location:
- _core_/plugins/mots
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
_core_/plugins/mots/action/editer_groupe_mots.php
r93543 r93617 16 16 * @package SPIP\Mots\Actions 17 17 */ 18 if (!defined("_ECRIRE_INC_VERSION")) return; 18 if (!defined("_ECRIRE_INC_VERSION")) { 19 return; 20 } 19 21 20 22 include_spip('inc/filtres'); … … 27 29 * Si aucun identifiant n'est donné, on crée alors un nouveau groupe de 28 30 * mots clés. 29 * 31 * 30 32 * @param null|int $id_groupe 31 33 * Identifiant du groupe de mot-clé. En absence utilise l'argument … … 33 35 * @return array 34 36 * Liste (identifiant du groupe de mot clé, Texte d'erreur éventuel) 35 **/ 36 function action_editer_groupe_mots_dist($id_groupe = null) 37 { 38 if (is_null($id_groupe)){ 37 **/ 38 function action_editer_groupe_mots_dist($id_groupe = null) { 39 if (is_null($id_groupe)) { 39 40 $securiser_action = charger_fonction('securiser_action', 'inc'); 40 41 $id_groupe = $securiser_action(); … … 45 46 } 46 47 47 if ($id_groupe >0)48 if ($id_groupe > 0) { 48 49 $err = groupe_mots_modifier($id_groupe); 49 50 return array($id_groupe,$err); 50 } 51 52 return array($id_groupe, $err); 51 53 } 52 54 … … 57 59 * @pipeline_appel pre_insertion 58 60 * @pipeline_appel post_insertion 59 * 61 * 60 62 * @param int $id_parent 61 63 * inutilise, pour consistance de l'API … … 68 70 // support de la signature derogatoire pour compat 69 71 // groupe_mots_inserer($table='') 70 if (is_string($id_parent) AND strlen($id_parent)) {71 if (is_null($set)) {72 if (is_string($id_parent) AND strlen($id_parent)) { 73 if (is_null($set)) { 72 74 $set = array(); 73 75 } … … 81 83 'obligatoire' => 'non', 82 84 'tables_liees' => '', 83 'minirezo' => 84 'comite' => 85 'minirezo' => 'oui', 86 'comite' => 'non', 85 87 'forum' => 'non' 86 88 ); 87 89 88 if ($set) 90 if ($set) { 89 91 $champs = array_merge($champs, $set); 92 } 90 93 91 94 // Envoyer aux plugins … … 99 102 ); 100 103 101 $id_groupe = sql_insertq("spip_groupes_mots", $champs) 104 $id_groupe = sql_insertq("spip_groupes_mots", $champs); 102 105 103 106 pipeline('post_insertion', … … 117 120 /** 118 121 * Modifier un groupe de mot 119 * 122 * 120 123 * @param int $id_groupe 121 124 * Identifiant du grope de mots clés à modifier … … 134 137 include_spip('inc/modifier'); 135 138 $c = collecter_requests( 136 // white list 137 array( 138 'titre', 'descriptif', 'texte', 'tables_liees', 139 'obligatoire', 'unseul', 140 'comite', 'forum', 'minirezo', 139 // white list 140 array( 141 'titre', 142 'descriptif', 143 'texte', 144 'tables_liees', 145 'obligatoire', 146 'unseul', 147 'comite', 148 'forum', 149 'minirezo', 141 150 ), 142 151 // black list … … 147 156 // normaliser les champ oui/non 148 157 foreach (array( 149 'obligatoire', 'unseul', 150 'comite', 'forum', 'minirezo' 151 ) as $champ) 152 if (isset($c[$champ])) 153 $c[$champ] = ($c[$champ]=='oui'?'oui':'non'); 154 155 if (isset($c['tables_liees']) AND is_array($c['tables_liees'])) 156 $c['tables_liees'] = implode(',',array_diff($c['tables_liees'],array(''))); 158 'obligatoire', 159 'unseul', 160 'comite', 161 'forum', 162 'minirezo' 163 ) as $champ) { 164 if (isset($c[$champ])) { 165 $c[$champ] = ($c[$champ] == 'oui' ? 'oui' : 'non'); 166 } 167 } 168 169 if (isset($c['tables_liees']) AND is_array($c['tables_liees'])) { 170 $c['tables_liees'] = implode(',', array_diff($c['tables_liees'], array(''))); 171 } 157 172 158 173 $err = objet_modifier_champs('groupe_mot', $id_groupe, … … 174 189 * @deprecated Utiliser groupe_mots_modifier() 175 190 * @see groupe_mots_modifier() 176 * 191 * 177 192 * @param int $id_groupe 178 193 * Identifiant du grope de mots clés à modifier … … 187 202 */ 188 203 function revision_groupe_mot($id_groupe, $c = false) { 189 return groupe_mots_modifier($id_groupe, $c);204 return groupe_mots_modifier($id_groupe, $c); 190 205 } 191 206 … … 196 211 * @deprecated Utiliser groupe_mots_inserer() ou objet_inserer() 197 212 * @see groupe_mots_inserer() 198 * 213 * 199 214 * @param string $table 200 215 * Tables sur lesquels des mots de ce groupe pourront être liés … … 212 227 * @deprecated Utiliser groupe_mots_modifier() ou objet_modifier() 213 228 * @see groupe_mots_modifier() 214 * 229 * 215 230 * @param int $id_groupe 216 231 * Identifiant du grope de mots clés à modifier … … 227 242 return groupe_mots_modifier($id_groupe, $set); 228 243 } 244 229 245 ?> -
_core_/plugins/mots/action/editer_mot.php
r93543 r93617 16 16 * @package SPIP\Mots\Actions 17 17 */ 18 if (!defined("_ECRIRE_INC_VERSION")) return; 18 if (!defined("_ECRIRE_INC_VERSION")) { 19 return; 20 } 19 21 20 22 include_spip('inc/filtres'); … … 26 28 * 27 29 * Si aucun identifiant n'est donné, on crée alors un nouveau mot clé. 28 * 30 * 29 31 * @param null|int $arg 30 32 * Identifiant du mot-clé. En absence utilise l'argument … … 32 34 * @return array 33 35 * Liste (identifiant du mot clé, Texte d'erreur éventuel) 34 **/ 35 function action_editer_mot_dist($arg = null) 36 { 37 if (is_null($arg)){ 36 **/ 37 function action_editer_mot_dist($arg = null) { 38 if (is_null($arg)) { 38 39 $securiser_action = charger_fonction('securiser_action', 'inc'); 39 40 $arg = $securiser_action(); … … 47 48 48 49 // Enregistre l'envoi dans la BD 49 if ($id_mot > 0) $err = mot_modifier($id_mot); 50 51 return array($id_mot,$err); 50 if ($id_mot > 0) { 51 $err = mot_modifier($id_mot); 52 } 53 54 return array($id_mot, $err); 52 55 } 53 56 … … 57 60 * @pipeline_appel pre_insertion 58 61 * @pipeline_appel post_insertion 59 * 62 * 60 63 * @param int $id_groupe 61 64 * Identifiant du groupe de mot … … 67 70 68 71 $champs = array(); 69 $row = sql_fetsel("titre", "spip_groupes_mots", "id_groupe=" .intval($id_groupe));72 $row = sql_fetsel("titre", "spip_groupes_mots", "id_groupe=" . intval($id_groupe)); 70 73 if ($row) { 71 74 $champs['id_groupe'] = $id_groupe; 72 75 $champs['type'] = $row['titre']; 73 } 74 else 76 } else { 75 77 return false; 76 77 if ($set) 78 } 79 80 if ($set) { 78 81 $champs = array_merge($champs, $set); 82 } 79 83 80 84 // Envoyer aux plugins … … 105 109 /** 106 110 * Modifier un mot 107 * 111 * 108 112 * @param int $id_mot 109 113 * Identifiant du mot clé à modifier … … 120 124 include_spip('inc/modifier'); 121 125 $c = collecter_requests( 122 // white list 123 array( 124 'titre', 'descriptif', 'texte', 'id_groupe' 126 // white list 127 array( 128 'titre', 129 'descriptif', 130 'texte', 131 'id_groupe' 125 132 ), 126 133 // black list … … 129 136 $set 130 137 ); 131 138 132 139 if ($err = objet_modifier_champs('mot', $id_mot, 133 140 array( … … 135 142 'nonvide' => array('titre' => _T('info_sans_titre')) 136 143 ), 137 $c)) 144 $c) 145 ) { 138 146 return $err; 139 140 $c = collecter_requests(array('id_groupe', 'type'),array(),$set); 147 } 148 149 $c = collecter_requests(array('id_groupe', 'type'), array(), $set); 141 150 $err = mot_instituer($id_mot, $c); 151 142 152 return $err; 143 153 } … … 148 158 * @pipeline_appel pre_insertion 149 159 * @pipeline_appel post_insertion 150 * 160 * 151 161 * @param int $id_mot 152 162 * Identifiant du mot clé … … 156 166 * Null si aucun champ à modifier, chaîne vide sinon. 157 167 */ 158 function mot_instituer($id_mot, $c) {168 function mot_instituer($id_mot, $c) { 159 169 $champs = array(); 160 170 // regler le groupe 161 171 if (isset($c['id_groupe']) OR isset($c['type'])) { 162 $row = sql_fetsel("titre", "spip_groupes_mots", "id_groupe=" .intval($c['id_groupe']));172 $row = sql_fetsel("titre", "spip_groupes_mots", "id_groupe=" . intval($c['id_groupe'])); 163 173 if ($row) { 164 174 $champs['id_groupe'] = $c['id_groupe']; … … 173 183 'table' => 'spip_mots', 174 184 'id_objet' => $id_mot, 175 'action' =>'instituer',185 'action' => 'instituer', 176 186 ), 177 187 'data' => $champs … … 179 189 ); 180 190 181 if (!$champs) return; 182 183 sql_updateq('spip_mots', $champs, "id_mot=".intval($id_mot)); 191 if (!$champs) { 192 return; 193 } 194 195 sql_updateq('spip_mots', $champs, "id_mot=" . intval($id_mot)); 184 196 185 197 // … … 197 209 'table' => 'spip_mots', 198 210 'id_objet' => $id_mot, 199 'action' =>'instituer',211 'action' => 'instituer', 200 212 ), 201 213 'data' => $champs … … 217 229 * 218 230 * @pipeline_appel trig_supprimer_objets_lies 219 * 231 * 220 232 * @param int $id_mot 221 233 * Identifiant du mot clé à supprimer … … 223 235 */ 224 236 function mot_supprimer($id_mot) { 225 sql_delete("spip_mots", "id_mot=" .intval($id_mot));237 sql_delete("spip_mots", "id_mot=" . intval($id_mot)); 226 238 mot_dissocier($id_mot, '*'); 227 239 pipeline('trig_supprimer_objets_lies', 228 240 array( 229 array('type' =>'mot','id'=>$id_mot)241 array('type' => 'mot', 'id' => $id_mot) 230 242 ) 231 243 ); 232 244 } 233 234 245 235 246 … … 237 248 * Associer un mot à des objets listés sous forme 238 249 * `array($objet=>$id_objets,...)` 239 * 250 * 240 251 * $id_objets peut lui-même être un scalaire ou un tableau pour une 241 252 * liste d'objets du même type … … 249 260 * mot_associer(3, array('auteur'=>2)); 250 261 * // Ne fonctionnera pas ici car pas de champ 'vu' sur spip_mots_liens : 251 * mot_associer(3, array('auteur'=>2), array('vu'=>'oui)); 262 * mot_associer(3, array('auteur'=>2), array('vu'=>'oui)); 252 263 * ``` 253 * 264 * 254 265 * @param int $id_mot 255 266 * Identifiant du mot à faire associer … … 261 272 * Nombre de modifications, false si erreur 262 273 */ 263 function mot_associer($id_mot, $objets, $qualif = null) {274 function mot_associer($id_mot, $objets, $qualif = null) { 264 275 265 276 include_spip('action/editer_liens'); … … 267 278 // si il s'agit d'un groupe avec 'unseul', alors supprimer d'abord les autres 268 279 // mots de ce groupe associe a ces objets 269 $id_groupe = sql_getfetsel('id_groupe', 'spip_mots','id_mot='.intval($id_mot));280 $id_groupe = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($id_mot)); 270 281 if (un_seul_mot_dans_groupe($id_groupe)) { 271 $mots_groupe = sql_allfetsel("id_mot", "spip_mots", "id_groupe=".intval($id_groupe)); 272 $mots_groupe = array_map('reset',$mots_groupe); 273 objet_dissocier(array('mot'=>$mots_groupe), $objets); 274 } 275 276 return objet_associer(array('mot'=>$id_mot), $objets, $qualif); 277 } 278 282 $mots_groupe = sql_allfetsel("id_mot", "spip_mots", "id_groupe=" . intval($id_groupe)); 283 $mots_groupe = array_map('reset', $mots_groupe); 284 objet_dissocier(array('mot' => $mots_groupe), $objets); 285 } 286 287 return objet_associer(array('mot' => $id_mot), $objets, $qualif); 288 } 279 289 280 290 … … 282 292 * Dissocier un mot des objets listés sous forme 283 293 * `array($objet=>$id_objets,...)` 284 * 294 * 285 295 * $id_objets peut lui-même être un scalaire ou un tableau pour une 286 296 * liste d'objets du même type 287 * 297 * 288 298 * un * pour $id_mot,$objet,$id_objet permet de traiter par lot 289 299 * … … 295 305 * Nombre de modifications, false si erreur 296 306 */ 297 function mot_dissocier($id_mot, $objets) {307 function mot_dissocier($id_mot, $objets) { 298 308 include_spip('action/editer_liens'); 299 return objet_dissocier(array('mot'=>$id_mot), $objets); 309 310 return objet_dissocier(array('mot' => $id_mot), $objets); 300 311 } 301 312 … … 303 314 * Qualifier le lien d'un mot avec les objets listés 304 315 * `array($objet=>$id_objets,...)` 305 * 316 * 306 317 * $id_objets peut lui-même être un scalaire ou un tableau pour une 307 318 * liste d'objets du même type 308 * 319 * 309 320 * Une * pour $id_auteur,$objet,$id_objet permet de traiter par lot 310 * 321 * 311 322 * @example 312 323 * ``` … … 323 334 * Nombre de modifications, false si erreur 324 335 */ 325 function mot_qualifier($id_mot, $objets, $qualif) {336 function mot_qualifier($id_mot, $objets, $qualif) { 326 337 include_spip('action/editer_liens'); 327 return objet_qualifier(array('mot'=>$id_mot), $objets, $qualif); 328 } 329 338 339 return objet_qualifier(array('mot' => $id_mot), $objets, $qualif); 340 } 330 341 331 342 332 343 /** 333 344 * Teste si un groupe ne doit avoir qu'un seul mot clé associé 334 * 345 * 335 346 * Renvoyer TRUE si le groupe de mot ne doit être associé qu'une fois aux objet 336 347 * (maximum un seul mot de ce groupe associé à chaque objet) … … 341 352 * true si un seul mot doit être lié avec ce groupe, false sinon. 342 353 */ 343 function un_seul_mot_dans_groupe($id_groupe) 344 { 354 function un_seul_mot_dans_groupe($id_groupe) { 345 355 return sql_countsel('spip_groupes_mots', "id_groupe=$id_groupe AND unseul='oui'"); 346 356 } 347 348 357 349 358 … … 356 365 * @deprecated Utiliser mot_inserer() 357 366 * @see mot_inserer() 358 * 367 * 359 368 * @param int $id_groupe 360 369 * Identifiant du groupe de mot … … 371 380 * @deprecated Utiliser mot_modifier() 372 381 * @see mot_modifier() 373 * 382 * 374 383 * @param int $id_mot 375 384 * Identifiant du mot clé à modifier … … 392 401 * @deprecated Utiliser mot_modifier() 393 402 * @see mot_modifier() 394 * 403 * 395 404 * @param int $id_mot 396 405 * Identifiant du mot clé à modifier -
_core_/plugins/mots/action/supprimer_groupe_mots.php
r93092 r93617 16 16 * @package SPIP\Mots\Actions 17 17 */ 18 if (!defined("_ECRIRE_INC_VERSION")) return; 18 if (!defined("_ECRIRE_INC_VERSION")) { 19 return; 20 } 19 21 20 22 include_spip('inc/filtres'); … … 27 29 * Supprime le groupe uniquement si on en a l'autorisation. Cela implique 28 30 * qu'il n'y ait pas de mots clés dans le groupe. 29 * 31 * 30 32 * @param null|int $id_groupe 31 33 * Identifiant du groupe à supprimer. En absence utilise l'argument 32 34 * de l'action sécurisée. 33 35 */ 34 function action_supprimer_groupe_mots_dist($id_groupe = null) {36 function action_supprimer_groupe_mots_dist($id_groupe = null) { 35 37 36 if (is_null($id_groupe)) {38 if (is_null($id_groupe)) { 37 39 $securiser_action = charger_fonction('securiser_action', 'inc'); 38 40 $id_groupe = $securiser_action(); … … 40 42 41 43 include_spip('inc/autoriser'); 42 if (autoriser('supprimer','groupemots',$id_groupe)){ 43 sql_delete("spip_groupes_mots", "id_groupe=" .intval($id_groupe)); 44 if (autoriser('supprimer', 'groupemots', $id_groupe)) { 45 sql_delete("spip_groupes_mots", "id_groupe=" . intval($id_groupe)); 46 } else { 47 spip_log("action_supprimer_groupe_mots_dist $id_groupe interdit", _LOG_INFO_IMPORTANTE); 44 48 } 45 else46 spip_log("action_supprimer_groupe_mots_dist $id_groupe interdit",_LOG_INFO_IMPORTANTE);47 49 } 48 50 -
_core_/plugins/mots/action/supprimer_mot.php
r89285 r93617 16 16 * @package SPIP\Mots\Actions 17 17 */ 18 if (!defined("_ECRIRE_INC_VERSION")) return; 18 if (!defined("_ECRIRE_INC_VERSION")) { 19 return; 20 } 19 21 20 22 /** -
_core_/plugins/mots/base/mots.php
r89285 r93617 13 13 /** 14 14 * Déclarations relatives à la base de données 15 * 15 * 16 16 * @package SPIP\Mots\Pipelines 17 **/ 18 if (!defined('_ECRIRE_INC_VERSION')) return; 17 **/ 18 if (!defined('_ECRIRE_INC_VERSION')) { 19 return; 20 } 19 21 20 22 /** … … 27 29 * Déclarations d'interface pour le compilateur 28 30 */ 29 function mots_declarer_tables_interfaces($interfaces) {30 31 $interfaces['table_des_tables']['mots'] ='mots';32 $interfaces['table_des_tables']['groupes_mots'] ='groupes_mots';31 function mots_declarer_tables_interfaces($interfaces) { 32 33 $interfaces['table_des_tables']['mots'] = 'mots'; 34 $interfaces['table_des_tables']['groupes_mots'] = 'groupes_mots'; 33 35 34 36 $interfaces['exceptions_des_tables']['mots']['titre_mot'] = 'titre'; 35 $interfaces['table_des_traitements']['TYPE']['mots'] = _TRAITEMENT_TYPO_SANS_NUMERO;37 $interfaces['table_des_traitements']['TYPE']['mots'] = _TRAITEMENT_TYPO_SANS_NUMERO; 36 38 37 39 $interfaces['exceptions_des_jointures']['titre_mot'] = array('spip_mots', 'titre'); … … 48 50 49 51 50 51 52 /** 52 53 * Déclarer les tables auxiliaires des mots … … 58 59 * Description complétée des tables 59 60 */ 60 function mots_declarer_tables_auxiliaires($tables_auxiliaires) {61 function mots_declarer_tables_auxiliaires($tables_auxiliaires) { 61 62 62 63 $spip_mots_liens = array( 63 "id_mot" => "bigint(21) DEFAULT '0' NOT NULL", 64 "id_objet" => "bigint(21) DEFAULT '0' NOT NULL", 65 "objet" => "VARCHAR (25) DEFAULT '' NOT NULL"); 64 "id_mot" => "bigint(21) DEFAULT '0' NOT NULL", 65 "id_objet" => "bigint(21) DEFAULT '0' NOT NULL", 66 "objet" => "VARCHAR (25) DEFAULT '' NOT NULL" 67 ); 66 68 67 69 $spip_mots_liens_key = array( 68 "PRIMARY KEY"=> "id_mot,id_objet,objet",69 "KEY id_mot"=> "id_mot",70 "KEY id_objet"=> "id_objet",71 "KEY objet"=> "objet",70 "PRIMARY KEY" => "id_mot,id_objet,objet", 71 "KEY id_mot" => "id_mot", 72 "KEY id_objet" => "id_objet", 73 "KEY objet" => "objet", 72 74 ); 73 75 74 76 $tables_auxiliaires['spip_mots_liens'] = 75 77 array('field' => &$spip_mots_liens, 'key' => &$spip_mots_liens_key); 76 78 77 79 return $tables_auxiliaires; 78 80 } … … 88 90 * Description complétée des tables 89 91 */ 90 function mots_declarer_tables_objets_sql($tables) {92 function mots_declarer_tables_objets_sql($tables) { 91 93 $tables['spip_mots'] = array( 92 'type' =>'mot',94 'type' => 'mot', 93 95 'type_surnoms' => array('mot-cle'), // pour les icones... 94 96 'texte_retour' => 'icone_retour', … … 100 102 'texte_logo_objet' => 'mots:logo_mot_cle', 101 103 'texte_creer_associer' => 'mots:creer_et_associer_un_mot', 102 'info_aucun_objet' => 'mots:info_aucun_mot_cle',104 'info_aucun_objet' => 'mots:info_aucun_mot_cle', 103 105 'info_1_objet' => 'info_1_mot_cle', 104 106 'info_nb_objets' => 'info_nb_mots_cles', … … 106 108 'date' => 'date', 107 109 'principale' => 'oui', 108 'field' => array(109 "id_mot" 110 "titre" 111 "descriptif" 112 "texte" 113 "id_groupe" 114 "type" 115 "maj" 110 'field' => array( 111 "id_mot" => "bigint(21) NOT NULL", 112 "titre" => "text DEFAULT '' NOT NULL", 113 "descriptif" => "text DEFAULT '' NOT NULL", 114 "texte" => "longtext DEFAULT '' NOT NULL", 115 "id_groupe" => "bigint(21) DEFAULT 0 NOT NULL", 116 "type" => "text DEFAULT '' NOT NULL", 117 "maj" => "TIMESTAMP" 116 118 ), 117 119 'key' => array( 118 "PRIMARY KEY" 120 "PRIMARY KEY" => "id_mot", 119 121 "KEY id_groupe" => "id_groupe" 120 122 ), 121 123 'rechercher_champs' => array( 122 'titre' => 8, 'texte' => 1, 'descriptif' => 5 123 ), 124 'tables_jointures' => array( 125 #'mots_liens' // declare generiquement ci dessous 126 ), 127 'champs_versionnes' => array('titre', 'descriptif', 'texte','id_groupe'), 124 'titre' => 8, 125 'texte' => 1, 126 'descriptif' => 5 127 ), 128 'tables_jointures' => array(#'mots_liens' // declare generiquement ci dessous 129 ), 130 'champs_versionnes' => array('titre', 'descriptif', 'texte', 'id_groupe'), 128 131 ); 129 132 130 133 $tables['spip_groupes_mots'] = array( 131 'table_objet_surnoms' => array('groupemot','groupe_mots' /*hum*/,'groupe_mot' /* hum*/,'groupe' /*hum (EXPOSE)*/), 132 'type'=>'groupe_mots', 133 'type_surnoms' => array('groupes_mot','groupemot','groupe_mot'), 134 'table_objet_surnoms' => array( 135 'groupemot', 136 'groupe_mots' 137 /*hum*/, 138 'groupe_mot' 139 /* hum*/, 140 'groupe' 141 /*hum (EXPOSE)*/ 142 ), 143 'type' => 'groupe_mots', 144 'type_surnoms' => array('groupes_mot', 'groupemot', 'groupe_mot'), 134 145 'texte_retour' => 'icone_retour', 135 146 'texte_objets' => 'mots:titre_groupes_mots', … … 138 149 'texte_creer' => 'mots:icone_creation_groupe_mots', 139 150 'texte_logo_objet' => 'mots:logo_groupe', 140 'info_aucun_objet' => 'mots:info_aucun_groupemots',151 'info_aucun_objet' => 'mots:info_aucun_groupemots', 141 152 'info_1_objet' => 'mots:info_1_groupemots', 142 153 'info_nb_objets' => 'mots:info_nb_groupemots', … … 145 156 'principale' => 'oui', 146 157 'page' => '', // pas de page publique pour les groupes 147 'field' => array(148 "id_groupe" 149 "titre" 150 "descriptif" 151 "texte" 152 "unseul" 153 "obligatoire" 158 'field' => array( 159 "id_groupe" => "bigint(21) NOT NULL", 160 "titre" => "text DEFAULT '' NOT NULL", 161 "descriptif" => "text DEFAULT '' NOT NULL", 162 "texte" => "longtext DEFAULT '' NOT NULL", 163 "unseul" => "varchar(3) DEFAULT '' NOT NULL", 164 "obligatoire" => "varchar(3) DEFAULT '' NOT NULL", 154 165 "tables_liees" => "text DEFAULT '' NOT NULL", 155 "minirezo" 156 "comite" 157 "forum" 158 "maj" 166 "minirezo" => "varchar(3) DEFAULT '' NOT NULL", 167 "comite" => "varchar(3) DEFAULT '' NOT NULL", 168 "forum" => "varchar(3) DEFAULT '' NOT NULL", 169 "maj" => "TIMESTAMP" 159 170 ), 160 171 'key' => array( 161 "PRIMARY KEY" 172 "PRIMARY KEY" => "id_groupe" 162 173 ), 163 174 'rechercher_champs' => array( 164 'titre' => 8, 'texte' => 1, 'descriptif' => 5 175 'titre' => 8, 176 'texte' => 1, 177 'descriptif' => 5 165 178 ), 166 179 'tables_jointures' => array( 167 180 'mots' 168 181 ), 169 'champs_versionnes' => array('titre', 'descriptif', 'texte','un_seul','obligatoire','tables_liees','minirezo','forum','comite'), 182 'champs_versionnes' => array( 183 'titre', 184 'descriptif', 185 'texte', 186 'un_seul', 187 'obligatoire', 188 'tables_liees', 189 'minirezo', 190 'forum', 191 'comite' 192 ), 170 193 ); 171 194 172 195 // jointures sur les mots pour tous les objets 173 $tables[]['tables_jointures'][] = 'mots_liens';174 $tables[]['tables_jointures'][] = 'mots';196 $tables[]['tables_jointures'][] = 'mots_liens'; 197 $tables[]['tables_jointures'][] = 'mots'; 175 198 176 199 // cas particulier des auteurs et mots : declarer explicitement mots_liens comme jointure privilegiee 177 200 // cf https://core.spip.net/issues/2329 178 $tables['spip_auteurs']['tables_jointures'][] = 'mots_liens';179 $tables['spip_auteurs']['tables_jointures'][] = 'mots';180 $tables['spip_mots']['tables_jointures'][] = 'mots_liens';181 $tables['spip_mots']['tables_jointures'][] = 'mots';201 $tables['spip_auteurs']['tables_jointures'][] = 'mots_liens'; 202 $tables['spip_auteurs']['tables_jointures'][] = 'mots'; 203 $tables['spip_mots']['tables_jointures'][] = 'mots_liens'; 204 $tables['spip_mots']['tables_jointures'][] = 'mots'; 182 205 183 206 … … 189 212 return $tables; 190 213 } 214 191 215 ?> -
_core_/plugins/mots/formulaires/configurer_mots.php
r89285 r93617 12 12 13 13 /** 14 * Gestion du formulaire de configuration des groupes de mots 14 * Gestion du formulaire de configuration des groupes de mots 15 15 * 16 16 * @package SPIP\Mots\Formulaires 17 **/ 18 if (!defined("_ECRIRE_INC_VERSION")) return; 17 **/ 18 if (!defined("_ECRIRE_INC_VERSION")) { 19 return; 20 } 19 21 20 22 include_spip('inc/presentation'); … … 25 27 * @return array 26 28 * Environnement du formulaire 27 **/28 function formulaires_configurer_mots_charger_dist() {29 foreach (array(30 "articles_mots",31 "config_precise_groupes",32 "mots_cles_forums",33 ) as $m)29 **/ 30 function formulaires_configurer_mots_charger_dist() { 31 foreach (array( 32 "articles_mots", 33 "config_precise_groupes", 34 "mots_cles_forums", 35 ) as $m) { 34 36 $valeurs[$m] = $GLOBALS['meta'][$m]; 37 } 35 38 36 39 return $valeurs; … … 42 45 * @return array 43 46 * Retours du traitement 44 **/ 45 function formulaires_configurer_mots_traiter_dist(){ 46 $res = array('editable'=>true); 47 foreach(array( 48 "articles_mots", 49 "config_precise_groupes", 50 "mots_cles_forums", 51 ) as $m) 52 if (!is_null($v=_request($m))) 53 ecrire_meta($m, $v=='oui'?'oui':'non'); 47 **/ 48 function formulaires_configurer_mots_traiter_dist() { 49 $res = array('editable' => true); 50 foreach (array( 51 "articles_mots", 52 "config_precise_groupes", 53 "mots_cles_forums", 54 ) as $m) { 55 if (!is_null($v = _request($m))) { 56 ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); 57 } 58 } 54 59 55 60 $res['message_ok'] = _T('config_info_enregistree'); 61 56 62 return $res; 57 63 } -
_core_/plugins/mots/formulaires/editer_groupe_mot.php
r93092 r93617 12 12 13 13 /** 14 * Gestion du formulaire de d'édition d'un groupe de mots 14 * Gestion du formulaire de d'édition d'un groupe de mots 15 15 * 16 16 * @package SPIP\Mots\Formulaires 17 **/ 18 if (!defined("_ECRIRE_INC_VERSION")) return; 17 **/ 18 if (!defined("_ECRIRE_INC_VERSION")) { 19 return; 20 } 19 21 20 22 include_spip('inc/actions'); … … 22 24 23 25 /** 24 * Chargement du formulaire d'édition d'un groupe de mots 26 * Chargement du formulaire d'édition d'un groupe de mots 25 27 * 26 28 * @param int|string $id_groupe … … 36 38 * @return array 37 39 * Environnement du formulaire 38 **/ 39 function formulaires_editer_groupe_mot_charger_dist($id_groupe = 'new', $retour = '', $config_fonc = 'groupes_mots_edit_config', $row = array(), $hidden = ''){ 40 $valeurs = formulaires_editer_objet_charger('groupe_mots',$id_groupe,0,'',$retour,$config_fonc,$row,$hidden); 40 **/ 41 function formulaires_editer_groupe_mot_charger_dist( 42 $id_groupe = 'new', 43 $retour = '', 44 $config_fonc = 'groupes_mots_edit_config', 45 $row = array(), 46 $hidden = '' 47 ) { 48 $valeurs = formulaires_editer_objet_charger('groupe_mots', $id_groupe, 0, '', $retour, $config_fonc, $row, $hidden); 41 49 42 $valeurs['tables_liees'] = explode(',', $valeurs['tables_liees']);50 $valeurs['tables_liees'] = explode(',', $valeurs['tables_liees']); 43 51 44 52 // par defaut a la creation de groupe … … 69 77 * Hash du formulaire 70 78 */ 71 function formulaires_editer_groupe_mot_identifier_dist($id_groupe = 'new', $retour = '', $config_fonc = 'groupes_mots_edit_config', $row = array(), $hidden = ''){ 79 function formulaires_editer_groupe_mot_identifier_dist( 80 $id_groupe = 'new', 81 $retour = '', 82 $config_fonc = 'groupes_mots_edit_config', 83 $row = array(), 84 $hidden = '' 85 ) { 72 86 return serialize(array(intval($id_groupe))); 73 87 } … … 81 95 * Configuration pour le formulaire 82 96 */ 83 function groupes_mots_edit_config($row) 84 { 97 function groupes_mots_edit_config($row) { 85 98 global $spip_ecran, $spip_lang; 86 99 87 100 $config = $GLOBALS['meta']; 88 $config['lignes'] = ($spip_ecran == "large") ? 8 : 5;101 $config['lignes'] = ($spip_ecran == "large") ? 8 : 5; 89 102 $config['langue'] = $spip_lang; 103 90 104 return $config; 91 105 } 92 106 93 107 /** 94 * Vérification du formulaire d'édition d'un groupe de mots 108 * Vérification du formulaire d'édition d'un groupe de mots 95 109 * 96 110 * @param int|string $id_groupe … … 106 120 * @return array 107 121 * Tableau des erreurs 108 **/ 109 function formulaires_editer_groupe_mot_verifier_dist($id_groupe = 'new', $retour = '', $config_fonc = 'groupes_mots_edit_config', $row = array(), $hidden = ''){ 122 **/ 123 function formulaires_editer_groupe_mot_verifier_dist( 124 $id_groupe = 'new', 125 $retour = '', 126 $config_fonc = 'groupes_mots_edit_config', 127 $row = array(), 128 $hidden = '' 129 ) { 110 130 111 $erreurs = formulaires_editer_objet_verifier('groupe_mots',0,array('titre')); 131 $erreurs = formulaires_editer_objet_verifier('groupe_mots', 0, array('titre')); 132 112 133 return $erreurs; 113 134 } 114 135 115 136 /** 116 * Traitement du formulaire d'édition d'un groupe de mots 137 * Traitement du formulaire d'édition d'un groupe de mots 117 138 * 118 139 * @param int|string $id_groupe … … 128 149 * @return array 129 150 * Retour des traitements 130 **/ 131 function formulaires_editer_groupe_mot_traiter_dist($id_groupe = 'new', $retour = '', $config_fonc = 'groupes_mots_edit_config', $row = array(), $hidden = ''){ 132 set_request('redirect',''); 151 **/ 152 function formulaires_editer_groupe_mot_traiter_dist( 153 $id_groupe = 'new', 154 $retour = '', 155 $config_fonc = 'groupes_mots_edit_config', 156 $row = array(), 157 $hidden = '' 158 ) { 159 set_request('redirect', ''); 133 160 // cas des checkbox : injecter la valeur non si rien de coche 134 161 foreach (array( 135 'obligatoire', 'unseul', 136 'comite', 'forum', 'minirezo' 137 ) as $champ) 138 if (!_request($champ)) 139 set_request($champ,'non'); 162 'obligatoire', 163 'unseul', 164 'comite', 165 'forum', 166 'minirezo' 167 ) as $champ) { 168 if (!_request($champ)) { 169 set_request($champ, 'non'); 170 } 171 } 140 172 141 $res = formulaires_editer_objet_traiter('groupe_mots',$id_groupe,0,0,$retour,$config_fonc,$row,$hidden); 173 $res = formulaires_editer_objet_traiter('groupe_mots', $id_groupe, 0, 0, $retour, $config_fonc, $row, $hidden); 174 142 175 return $res; 143 176 } -
_core_/plugins/mots/formulaires/editer_mot.php
r93092 r93617 15 15 * 16 16 * @package SPIP\Mots\Formulaires 17 **/ 18 if (!defined("_ECRIRE_INC_VERSION")) return; 17 **/ 18 if (!defined("_ECRIRE_INC_VERSION")) { 19 return; 20 } 19 21 20 22 include_spip('inc/actions'); … … 25 27 * 26 28 * @see formulaires_editer_objet_charger() 27 * 29 * 28 30 * @param int|string $id_mot 29 31 * Identifiant du mot. 'new' pour un nouveau mot. … … 45 47 * @return array 46 48 * Environnement du formulaire 47 **/ 48 function formulaires_editer_mot_charger_dist($id_mot = 'new', $id_groupe = 0, $retour = '', $associer_objet = '', $dummy1 = '', $dummy2 = '', $config_fonc = 'mots_edit_config', $row = array(), $hidden = ''){ 49 $valeurs = formulaires_editer_objet_charger('mot',$id_mot,$id_groupe,'',$retour,$config_fonc,$row,$hidden); 50 if ($valeurs['id_parent'] && !$valeurs['id_groupe']) 49 **/ 50 function formulaires_editer_mot_charger_dist( 51 $id_mot = 'new', 52 $id_groupe = 0, 53 $retour = '', 54 $associer_objet = '', 55 $dummy1 = '', 56 $dummy2 = '', 57 $config_fonc = 'mots_edit_config', 58 $row = array(), 59 $hidden = '' 60 ) { 61 $valeurs = formulaires_editer_objet_charger('mot', $id_mot, $id_groupe, '', $retour, $config_fonc, $row, $hidden); 62 if ($valeurs['id_parent'] && !$valeurs['id_groupe']) { 51 63 $valeurs['id_groupe'] = $valeurs['id_parent']; 52 53 if ($associer_objet){ 54 if (intval($associer_objet)){ 64 } 65 66 if ($associer_objet) { 67 if (intval($associer_objet)) { 55 68 // compat avec l'appel de la forme ajouter_id_article 56 69 $objet = 'article'; 57 70 $id_objet = intval($associer_objet); 58 } 59 else { 60 list($objet,$id_objet) = explode('|',$associer_objet); 61 } 62 } 63 $valeurs['table'] = ($associer_objet?table_objet($objet):''); 71 } else { 72 list($objet, $id_objet) = explode('|', $associer_objet); 73 } 74 } 75 $valeurs['table'] = ($associer_objet ? table_objet($objet) : ''); 64 76 65 77 // Si nouveau et titre dans l'url : fixer le titre 66 78 if ($id_mot == 'oui' 67 AND strlen($titre = _request('titre'))) 79 AND strlen($titre = _request('titre')) 80 ) { 68 81 $valeurs['titre'] = $titre; 82 } 69 83 70 84 return $valeurs; … … 95 109 * @return string 96 110 * Hash du formulaire 97 **/ 98 function formulaires_editer_mot_identifier_dist($id_mot = 'new', $id_groupe = 0, $retour = '', $associer_objet = '', $dummy1 = '', $dummy2 = '', $config_fonc = 'mots_edit_config', $row = array(), $hidden = ''){ 99 return serialize(array(intval($id_mot),$associer_objet)); 111 **/ 112 function formulaires_editer_mot_identifier_dist( 113 $id_mot = 'new', 114 $id_groupe = 0, 115 $retour = '', 116 $associer_objet = '', 117 $dummy1 = '', 118 $dummy2 = '', 119 $config_fonc = 'mots_edit_config', 120 $row = array(), 121 $hidden = '' 122 ) { 123 return serialize(array(intval($id_mot), $associer_objet)); 100 124 } 101 125 … … 108 132 * Configuration pour le formulaire 109 133 */ 110 function mots_edit_config($row) 111 { 134 function mots_edit_config($row) { 112 135 global $spip_ecran, $spip_lang; 113 136 114 137 $config = $GLOBALS['meta']; 115 $config['lignes'] = ($spip_ecran == "large") ? 8 : 5;138 $config['lignes'] = ($spip_ecran == "large") ? 8 : 5; 116 139 $config['langue'] = $spip_lang; 117 140 $config['restreint'] = false; 141 118 142 return $config; 119 143 } … … 123 147 * 124 148 * @see formulaires_editer_objet_verifier() 125 * 149 * 126 150 * @param int|string $id_mot 127 151 * Identifiant du mot. 'new' pour un nouveau mot. … … 143 167 * @return array 144 168 * Tableau des erreurs 145 **/ 146 function formulaires_editer_mot_verifier_dist($id_mot = 'new', $id_groupe = 0, $retour = '', $associer_objet = '', $dummy1 = '', $dummy2 = '', $config_fonc = 'mots_edit_config', $row = array(), $hidden = ''){ 147 148 $erreurs = formulaires_editer_objet_verifier('mot',$id_mot,array('titre')); 169 **/ 170 function formulaires_editer_mot_verifier_dist( 171 $id_mot = 'new', 172 $id_groupe = 0, 173 $retour = '', 174 $associer_objet = '', 175 $dummy1 = '', 176 $dummy2 = '', 177 $config_fonc = 'mots_edit_config', 178 $row = array(), 179 $hidden = '' 180 ) { 181 182 $erreurs = formulaires_editer_objet_verifier('mot', $id_mot, array('titre')); 149 183 // verifier qu'un mot du meme groupe n'existe pas avec le meme titre 150 184 // la comparaison accepte un numero absent ou different … … 152 186 // on ne fait la verification que si c'est une creation de mot ou un retitrage 153 187 if (!intval($id_mot) 154 OR supprimer_numero(_request('titre'))!==supprimer_numero(sql_getfetsel('titre','spip_mots','id_mot='.intval($id_mot)))){ 155 if (!count($erreurs) AND !_request('confirm_titre_mot')){ 188 OR supprimer_numero(_request('titre')) !== supprimer_numero(sql_getfetsel('titre', 'spip_mots', 189 'id_mot=' . intval($id_mot))) 190 ) { 191 if (!count($erreurs) AND !_request('confirm_titre_mot')) { 156 192 if (sql_countsel("spip_mots", 157 "titre REGEXP ".sql_quote("^([0-9]+[.] )?".preg_quote(supprimer_numero(_request('titre')))."$")158 ." AND id_mot<>".intval($id_mot)))193 "titre REGEXP " . sql_quote("^([0-9]+[.] )?" . preg_quote(supprimer_numero(_request('titre'))) . "$") 194 . " AND id_mot<>" . intval($id_mot))) { 159 195 $erreurs['titre'] = 160 _T('mots:avis_doublon_mot_cle') 161 ." <input type='hidden' name='confirm_titre_mot' value='1' />"; 162 } 163 } 196 _T('mots:avis_doublon_mot_cle') 197 . " <input type='hidden' name='confirm_titre_mot' value='1' />"; 198 } 199 } 200 } 201 164 202 return $erreurs; 165 203 } … … 167 205 /** 168 206 * Traitements du formulaire d'édition d'un mot 169 * 207 * 170 208 * @param int|string $id_mot 171 209 * Identifiant du mot. 'new' pour un nouveau mot. … … 187 225 * @return array 188 226 * Retour des traitements 189 **/ 190 function formulaires_editer_mot_traiter_dist($id_mot = 'new', $id_groupe = 0, $retour = '', $associer_objet = '', $dummy1 = '', $dummy2 = '', $config_fonc = 'mots_edit_config', $row = array(), $hidden = ''){ 227 **/ 228 function formulaires_editer_mot_traiter_dist( 229 $id_mot = 'new', 230 $id_groupe = 0, 231 $retour = '', 232 $associer_objet = '', 233 $dummy1 = '', 234 $dummy2 = '', 235 $config_fonc = 'mots_edit_config', 236 $row = array(), 237 $hidden = '' 238 ) { 191 239 $res = array(); 192 set_request('redirect', '');193 $action_editer = charger_fonction("editer_mot", 'action');194 list($id_mot, $err) = $action_editer();195 if ($err) {240 set_request('redirect', ''); 241 $action_editer = charger_fonction("editer_mot", 'action'); 242 list($id_mot, $err) = $action_editer(); 243 if ($err) { 196 244 $res['message_erreur'] = $err; 197 } 198 else { 245 } else { 199 246 $res['message_ok'] = ""; 200 if ($retour) {201 if (strncmp($retour, 'javascript:',11)==0){202 $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' .substr($retour,11).'/*]]>*/</script>';247 if ($retour) { 248 if (strncmp($retour, 'javascript:', 11) == 0) { 249 $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>'; 203 250 $res['editable'] = true; 204 } 205 else { 251 } else { 206 252 $res['redirect'] = $retour; 207 if (strlen(parametre_url($retour,'id_mot'))) 208 $res['redirect'] = parametre_url($res['redirect'],'id_mot',$id_mot); 209 } 210 } 211 212 if ($associer_objet){ 213 if (intval($associer_objet)){ 253 if (strlen(parametre_url($retour, 'id_mot'))) { 254 $res['redirect'] = parametre_url($res['redirect'], 'id_mot', $id_mot); 255 } 256 } 257 } 258 259 if ($associer_objet) { 260 if (intval($associer_objet)) { 214 261 // compat avec l'appel de la forme ajouter_id_article 215 262 $objet = 'article'; 216 263 $id_objet = intval($associer_objet); 217 } 218 else { 219 list($objet,$id_objet) = explode('|',$associer_objet); 220 } 221 if ($objet AND $id_objet AND autoriser('modifier',$objet,$id_objet)){ 264 } else { 265 list($objet, $id_objet) = explode('|', $associer_objet); 266 } 267 if ($objet AND $id_objet AND autoriser('modifier', $objet, $id_objet)) { 222 268 include_spip('action/editer_mot'); 223 mot_associer($id_mot, array($objet=>$id_objet)); 224 if (isset($res['redirect'])) 225 $res['redirect'] = parametre_url ($res['redirect'], "id_lien_ajoute", $id_mot, '&'); 226 } 227 } 228 229 } 269 mot_associer($id_mot, array($objet => $id_objet)); 270 if (isset($res['redirect'])) { 271 $res['redirect'] = parametre_url($res['redirect'], "id_lien_ajoute", $id_mot, '&'); 272 } 273 } 274 } 275 276 } 277 230 278 return $res; 231 279 } -
_core_/plugins/mots/inc/mots.php
r93092 r93617 12 12 13 13 /** 14 * Déclaration de filtres pour les squelettes 14 * Déclaration de filtres pour les squelettes 15 15 * 16 16 * @package SPIP\Mots\Filtres 17 **/ 18 if (!defined("_ECRIRE_INC_VERSION")) return; 17 **/ 18 if (!defined("_ECRIRE_INC_VERSION")) { 19 return; 20 } 19 21 20 22 include_spip('inc/presentation'); … … 27 29 * 28 30 * @pipeline_appel afficher_nombre_objets_associes_a 29 * 31 * 30 32 * @param int $id_mot 31 33 * Identifiant du mot clé … … 34 36 * @return string[] 35 37 * Tableau de textes indiquant le nombre d'éléments tel que '3 articles' 36 **/38 **/ 37 39 function filtre_objets_associes_mot_dist($id_mot, $id_groupe) { 38 40 static $occurrences = array(); 39 41 40 42 // calculer tous les liens du groupe d'un coup 41 if (!isset ($occurrences[$id_groupe])) 43 if (!isset ($occurrences[$id_groupe])) { 42 44 $occurrences[$id_groupe] = calculer_utilisations_mots($id_groupe); 45 } 43 46 44 47 $associes = array(); 45 48 $tables = lister_tables_objets_sql(); 46 foreach ($tables as $table_objet_sql =>$infos) {49 foreach ($tables as $table_objet_sql => $infos) { 47 50 $nb = (isset($occurrences[$id_groupe][$table_objet_sql][$id_mot]) ? $occurrences[$id_groupe][$table_objet_sql][$id_mot] : 0); 48 if ($nb) 49 $associes[] = objet_afficher_nb($nb,$infos['type']); 51 if ($nb) { 52 $associes[] = objet_afficher_nb($nb, $infos['type']); 53 } 50 54 } 51 55 52 $associes = pipeline('afficher_nombre_objets_associes_a',array('args'=>array('objet'=>'mot','id_objet'=>$id_mot),'data'=>$associes)); 56 $associes = pipeline('afficher_nombre_objets_associes_a', 57 array('args' => array('objet' => 'mot', 'id_objet' => $id_mot), 'data' => $associes)); 58 53 59 return $associes; 54 60 … … 65 71 * Mots est un tableau de couples (id_mot => nombre d'utilisation) 66 72 */ 67 function calculer_utilisations_mots($id_groupe) 68 { 73 function calculer_utilisations_mots($id_groupe) { 69 74 $retour = array(); 70 $objets = sql_allfetsel('DISTINCT objet', array('spip_mots_liens AS L', 'spip_mots AS M'), array('L.id_mot=M.id_mot', 'M.id_groupe='.intval($id_groupe))); 75 $objets = sql_allfetsel('DISTINCT objet', array('spip_mots_liens AS L', 'spip_mots AS M'), 76 array('L.id_mot=M.id_mot', 'M.id_groupe=' . intval($id_groupe))); 71 77 72 foreach ($objets as $o) {73 $objet =$o['objet'];78 foreach ($objets as $o) { 79 $objet = $o['objet']; 74 80 $_id_objet = id_table_objet($objet); 75 81 $table_objet_sql = table_objet_sql($objet); 76 82 $infos = lister_tables_objets_sql($table_objet_sql); 77 if (isset($infos['field']) AND $infos['field']) {83 if (isset($infos['field']) AND $infos['field']) { 78 84 // uniquement certains statut d'objet, 79 85 // et uniquement si la table dispose du champ statut. … … 85 91 86 92 // bricoler les statuts d'apres la declaration de l'objet (champ previsu a defaut de mieux) 87 if (array_key_exists('previsu', $infos['statut'][0]) AND strlen($infos['statut'][0]['previsu']) >1) {93 if (array_key_exists('previsu', $infos['statut'][0]) AND strlen($infos['statut'][0]['previsu']) > 1) { 88 94 $str_statuts = $infos['statut'][0]['previsu']; 89 if ($GLOBALS['connect_statut'] !="0minirezo") 90 $str_statuts = str_replace('prepa','',$str_statuts); 91 $not = (substr($str_statuts, 0, 1) == '!'? 'NOT' : ''); 92 $str_statuts = str_replace('!','',$str_statuts); 95 if ($GLOBALS['connect_statut'] != "0minirezo") { 96 $str_statuts = str_replace('prepa', '', $str_statuts); 97 } 98 $not = (substr($str_statuts, 0, 1) == '!' ? 'NOT' : ''); 99 $str_statuts = str_replace('!', '', $str_statuts); 93 100 $Tstatuts = array_filter(explode(',', $str_statuts)); 94 $statuts = " AND " . sql_in("O.$c_statut", $Tstatuts, $not); 101 $statuts = " AND " . sql_in("O.$c_statut", $Tstatuts, $not); 102 } // objets sans champ previsu ou avec un previsu == '!' (par ex les rubriques) 103 else { 104 $statuts = " AND " . sql_in("O.$c_statut", 105 ($GLOBALS['connect_statut'] == "0minirezo") ? array('prepa', 'prop', 'publie') : array('prop', 'publie')); 95 106 } 96 // objets sans champ previsu ou avec un previsu == '!' (par ex les rubriques)97 else98 $statuts = " AND " . sql_in("O.$c_statut", ($GLOBALS['connect_statut'] =="0minirezo") ? array('prepa','prop','publie') : array('prop','publie'));99 107 } 100 108 $res = sql_allfetsel( … … 103 111 LEFT JOIN spip_mots AS M ON L.id_mot=M.id_mot 104 112 AND L.objet=" . sql_quote($objet) . " 105 LEFT JOIN " . $table_objet_sql . " AS O ON L.id_objet=O.$_id_objet" 113 LEFT JOIN " . $table_objet_sql . " AS O ON L.id_objet=O.$_id_objet", 106 114 "M.id_groupe=$id_groupe$statuts", 107 115 "L.id_mot"); 108 foreach ($res as $row) {116 foreach ($res as $row) { 109 117 $retour[$table_objet_sql][$row['id_mot']] = $row['cnt']; 110 118 } … … 114 122 return $retour; 115 123 } 124 116 125 ?> -
_core_/plugins/mots/mots_administrations.php
r93092 r93617 15 15 * 16 16 * @package SPIP\Mots\Installation 17 **/ 18 if (!defined('_ECRIRE_INC_VERSION')) return; 17 **/ 18 if (!defined('_ECRIRE_INC_VERSION')) { 19 return; 20 } 19 21 20 22 /** … … 27 29 * @return void 28 30 */ 29 function mots_upgrade($nom_meta_base_version, $version_cible) {31 function mots_upgrade($nom_meta_base_version, $version_cible) { 30 32 31 33 // cas particulier : … … 33 35 // considerer que c'est un upgrade depuis v 1.0.0 34 36 // pour gerer l'historique des installations SPIP <=2.1 35 if (!isset($GLOBALS['meta'][$nom_meta_base_version])) {36 $trouver_table = charger_fonction('trouver_table', 'base');37 if (!isset($GLOBALS['meta'][$nom_meta_base_version])) { 38 $trouver_table = charger_fonction('trouver_table', 'base'); 37 39 if ($desc = $trouver_table('spip_mots') 38 AND isset($desc['exist']) AND $desc['exist'] 39 AND $desc = $trouver_table('spip_mots_articles') 40 AND isset($desc['exist']) AND $desc['exist']){ 41 ecrire_meta($nom_meta_base_version,'1.0.0'); 40 AND isset($desc['exist']) AND $desc['exist'] 41 AND $desc = $trouver_table('spip_mots_articles') 42 AND isset($desc['exist']) AND $desc['exist'] 43 ) { 44 ecrire_meta($nom_meta_base_version, '1.0.0'); 42 45 } 43 46 // si pas de table en base, on fera une simple creation de base … … 46 49 $maj = array(); 47 50 $maj['create'] = array( 48 array('maj_tables', array('spip_groupes_mots','spip_mots','spip_mots_liens')),51 array('maj_tables', array('spip_groupes_mots', 'spip_mots', 'spip_mots_liens')), 49 52 ); 50 53 $maj['1.0.0'] = array( 51 array('maj_tables', array('spip_groupes_mots','spip_mots','spip_mots_liens')),54 array('maj_tables', array('spip_groupes_mots', 'spip_mots', 'spip_mots_liens')), 52 55 ); 53 56 include_spip('maj/svn10000'); 54 57 $maj['2.0.0'] = array( 55 array('maj_liens', 'mot'), // creer la table liens56 array('maj_liens', 'mot','breve'),57 array('sql_drop_table', "spip_mots_breves"),58 array('maj_liens', 'mot','rubrique'),59 array('sql_drop_table', "spip_mots_rubriques"),60 array('maj_liens', 'mot','syndic'),61 array('sql_drop_table', "spip_mots_syndic"),62 array('maj_liens', 'mot','forum'),63 array('sql_drop_table', "spip_mots_forum"),64 array('maj_liens', 'mot','auteur'),65 array('sql_drop_table', "spip_mots_auteurs"),66 array('maj_liens', 'mot','document'),67 array('sql_drop_table', "spip_mots_documents"),68 array('maj_liens', 'mot','article'),69 array('sql_drop_table', "spip_mots_articles"),58 array('maj_liens', 'mot'), // creer la table liens 59 array('maj_liens', 'mot', 'breve'), 60 array('sql_drop_table', "spip_mots_breves"), 61 array('maj_liens', 'mot', 'rubrique'), 62 array('sql_drop_table', "spip_mots_rubriques"), 63 array('maj_liens', 'mot', 'syndic'), 64 array('sql_drop_table', "spip_mots_syndic"), 65 array('maj_liens', 'mot', 'forum'), 66 array('sql_drop_table', "spip_mots_forum"), 67 array('maj_liens', 'mot', 'auteur'), 68 array('sql_drop_table', "spip_mots_auteurs"), 69 array('maj_liens', 'mot', 'document'), 70 array('sql_drop_table', "spip_mots_documents"), 71 array('maj_liens', 'mot', 'article'), 72 array('sql_drop_table', "spip_mots_articles"), 70 73 ); 71 74 $maj['2.0.1'] = array( 72 array('sql_updateq', "spip_mots_liens",array('objet'=>'site'),"objet='syndic'"),75 array('sql_updateq', "spip_mots_liens", array('objet' => 'site'), "objet='syndic'"), 73 76 ); 74 77 $maj['2.1.0'] = array( 75 array('sql_alter', "TABLE spip_mots_liens ADD INDEX id_objet (id_objet)"),76 array('sql_alter', "TABLE spip_mots_liens ADD INDEX objet (objet)"),78 array('sql_alter', "TABLE spip_mots_liens ADD INDEX id_objet (id_objet)"), 79 array('sql_alter', "TABLE spip_mots_liens ADD INDEX objet (objet)"), 77 80 ); 78 81 $maj['2.1.1'] = array( 79 array('sql_alter', "TABLE spip_mots ADD INDEX id_groupe (id_groupe)")82 array('sql_alter', "TABLE spip_mots ADD INDEX id_groupe (id_groupe)") 80 83 ); 81 84 82 85 include_spip('base/upgrade'); 83 86 maj_plugin($nom_meta_base_version, $version_cible, $maj); … … 96 99 sql_drop_table("spip_groupes_mots"); 97 100 sql_drop_table("spip_mots_liens"); 98 101 99 102 effacer_meta('articles_mots'); 100 103 effacer_meta('config_precise_groupes'); 101 104 102 105 effacer_meta($nom_meta_base_version); 103 106 } -
_core_/plugins/mots/mots_autoriser.php
r93092 r93617 12 12 13 13 /** 14 * Définit les autorisations du plugin mots 14 * Définit les autorisations du plugin mots 15 15 * 16 16 * @package SPIP\Mots\Autorisations 17 **/ 18 if (!defined('_ECRIRE_INC_VERSION')) return; 17 **/ 18 if (!defined('_ECRIRE_INC_VERSION')) { 19 return; 20 } 19 21 20 22 /** 21 23 * Fonction d'appel pour le pipeline 24 * 22 25 * @pipeline autoriser 23 26 */ 24 function mots_autoriser(){} 25 26 /** 27 * Autorisation de voir un élément de menu 28 * 29 * @param string $faire Action demandée 30 * @param string $type Type d'objet sur lequel appliquer l'action 31 * @param int $id Identifiant de l'objet 32 * @param array $qui Description de l'auteur demandant l'autorisation 33 * @param array $opt Options de cette autorisation 34 * @return bool true s'il a le droit, false sinon 35 **/ 36 function autoriser_mots_menu_dist($faire, $type, $id, $qui, $opt){ 37 if ($qui['statut'] == '0minirezo') 38 return ($GLOBALS['meta']['articles_mots'] != 'non' OR sql_countsel('spip_groupes_mots')); 27 function mots_autoriser() { } 28 29 /** 30 * Autorisation de voir un élément de menu 31 * 32 * @param string $faire Action demandée 33 * @param string $type Type d'objet sur lequel appliquer l'action 34 * @param int $id Identifiant de l'objet 35 * @param array $qui Description de l'auteur demandant l'autorisation 36 * @param array $opt Options de cette autorisation 37 * @return bool true s'il a le droit, false sinon 38 **/ 39 function autoriser_mots_menu_dist($faire, $type, $id, $qui, $opt) { 40 if ($qui['statut'] == '0minirezo') { 41 return ($GLOBALS['meta']['articles_mots'] != 'non' OR sql_countsel('spip_groupes_mots')); 42 } 39 43 $where = ""; 40 if ($qui['statut'] =='1comite')44 if ($qui['statut'] == '1comite') { 41 45 $where = "comite='oui' OR forum='oui'"; 42 if ($qui['statut']=='6forum') 46 } 47 if ($qui['statut'] == '6forum') { 43 48 $where = "forum='oui'"; 49 } 50 44 51 return ($where 45 52 AND $GLOBALS['meta']['articles_mots'] != 'non' 46 AND sql_countsel('spip_groupes_mots',$where));53 AND sql_countsel('spip_groupes_mots', $where)); 47 54 } 48 55 … … 51 58 * 52 59 * @param string $faire Action demandée 53 * @param string $type 54 * @param int $idIdentifiant de l'objet55 * @param array $quiDescription de l'auteur demandant l'autorisation56 * @param array $optOptions de cette autorisation57 * @return bool true s'il a le droit, false sinon 58 **/59 function autoriser_motcreer_menu_dist($faire, $type, $id, $qui, $opt) {60 * @param string $type Type d'objet sur lequel appliquer l'action 61 * @param int $id Identifiant de l'objet 62 * @param array $qui Description de l'auteur demandant l'autorisation 63 * @param array $opt Options de cette autorisation 64 * @return bool true s'il a le droit, false sinon 65 **/ 66 function autoriser_motcreer_menu_dist($faire, $type, $id, $qui, $opt) { 60 67 // [fixme] Meta 'article_mots' mal nommée maintenant 61 68 // car elle désigne l'activation ou non des mots clés, quelque soit l'objet. 62 69 return ($GLOBALS['meta']['articles_mots'] != 'non' 63 70 AND sql_countsel('spip_groupes_mots') 64 AND autoriser('creer', 'mot',null,$qui,$opt));71 AND autoriser('creer', 'mot', null, $qui, $opt)); 65 72 } 66 73 … … 73 80 * 74 81 * @param string $faire Action demandée 75 * @param string $type 76 * @param int $idIdentifiant de l'objet77 * @param array $quiDescription de l'auteur demandant l'autorisation78 * @param array $optOptions de cette autorisation79 * @return bool true s'il a le droit, false sinon 80 **/82 * @param string $type Type d'objet sur lequel appliquer l'action 83 * @param int $id Identifiant de l'objet 84 * @param array $qui Description de l'auteur demandant l'autorisation 85 * @param array $opt Options de cette autorisation 86 * @return bool true s'il a le droit, false sinon 87 **/ 81 88 function autoriser_groupemots_voir_dist($faire, $type, $id, $qui, $opt) { 82 if ($qui['statut'] == '0minirezo') return true; 83 $acces = sql_fetsel("comite,forum", "spip_groupes_mots", "id_groupe=".intval($id)); 84 if ($qui['statut']=='1comite' AND ($acces['comite'] == 'oui' OR $acces['forum'] == 'oui')) 89 if ($qui['statut'] == '0minirezo') { 85 90 return true; 86 if ($qui['statut']=='6forum' AND $acces['forum'] == 'oui') 91 } 92 $acces = sql_fetsel("comite,forum", "spip_groupes_mots", "id_groupe=" . intval($id)); 93 if ($qui['statut'] == '1comite' AND ($acces['comite'] == 'oui' OR $acces['forum'] == 'oui')) { 87 94 return true; 95 } 96 if ($qui['statut'] == '6forum' AND $acces['forum'] == 'oui') { 97 return true; 98 } 99 88 100 return false; 89 101 } … … 93 105 * 94 106 * @param string $faire Action demandée 95 * @param string $type 96 * @param int $idIdentifiant de l'objet97 * @param array $quiDescription de l'auteur demandant l'autorisation98 * @param array $optOptions de cette autorisation99 * @return bool true s'il a le droit, false sinon 100 **/107 * @param string $type Type d'objet sur lequel appliquer l'action 108 * @param int $id Identifiant de l'objet 109 * @param array $qui Description de l'auteur demandant l'autorisation 110 * @param array $opt Options de cette autorisation 111 * @return bool true s'il a le droit, false sinon 112 **/ 101 113 function autoriser_groupemots_creer_dist($faire, $type, $id, $qui, $opt) { 102 114 return … … 112 124 * 113 125 * @param string $faire Action demandée 114 * @param string $type 115 * @param int $idIdentifiant de l'objet116 * @param array $quiDescription de l'auteur demandant l'autorisation117 * @param array $optOptions de cette autorisation118 * @return bool true s'il a le droit, false sinon 119 **/126 * @param string $type Type d'objet sur lequel appliquer l'action 127 * @param int $id Identifiant de l'objet 128 * @param array $qui Description de l'auteur demandant l'autorisation 129 * @param array $opt Options de cette autorisation 130 * @return bool true s'il a le droit, false sinon 131 **/ 120 132 function autoriser_groupemots_modifier_dist($faire, $type, $id, $qui, $opt) { 121 133 return 122 134 $qui['statut'] == '0minirezo' AND !$qui['restreint'] 123 AND autoriser('voir', 'groupemots',$id,$qui,$opt);135 AND autoriser('voir', 'groupemots', $id, $qui, $opt); 124 136 } 125 137 … … 129 141 * 130 142 * @param string $faire Action demandée 131 * @param string $type 132 * @param int $idIdentifiant de l'objet133 * @param array $quiDescription de l'auteur demandant l'autorisation134 * @param array $optOptions de cette autorisation135 * @return bool true s'il a le droit, false sinon 136 **/143 * @param string $type Type d'objet sur lequel appliquer l'action 144 * @param int $id Identifiant de l'objet 145 * @param array $qui Description de l'auteur demandant l'autorisation 146 * @param array $opt Options de cette autorisation 147 * @return bool true s'il a le droit, false sinon 148 **/ 137 149 function autoriser_groupemots_supprimer_dist($faire, $type, $id, $qui, $opt) { 138 if (!autoriser('modifier','groupemots',$id)) 139 return false; 140 return sql_countsel('spip_mots','id_groupe='.intval($id))?false:true; 150 if (!autoriser('modifier', 'groupemots', $id)) { 151 return false; 152 } 153 154 return sql_countsel('spip_mots', 'id_groupe=' . intval($id)) ? false : true; 141 155 } 142 156 … … 145 159 * 146 160 * Il faut avoir le droit de modifier le groupe parent 147 * 161 * 148 162 * Note : passer l'id_groupe dans le tableau d'option 149 163 * permet de gagner du CPU et une requête SQL (c'est ce que fait l'espace privé) 150 * 151 * @param string $faire Action demandée 152 * @param string $type 153 * @param int $idIdentifiant de l'objet154 * @param array $quiDescription de l'auteur demandant l'autorisation155 * @param array $optOptions de cette autorisation156 * @return bool true s'il a le droit, false sinon 157 **/164 * 165 * @param string $faire Action demandée 166 * @param string $type Type d'objet sur lequel appliquer l'action 167 * @param int $id Identifiant de l'objet 168 * @param array $qui Description de l'auteur demandant l'autorisation 169 * @param array $opt Options de cette autorisation 170 * @return bool true s'il a le droit, false sinon 171 **/ 158 172 function autoriser_mot_modifier_dist($faire, $type, $id, $qui, $opt) { 159 173 return 160 isset($opt['id_groupe'])161 ? autoriser('modifier', 'groupemots', $opt['id_groupe'], $qui, $opt)162 : (163 $t = sql_getfetsel("id_groupe", "spip_mots", "id_mot=" .intval($id))174 isset($opt['id_groupe']) 175 ? autoriser('modifier', 'groupemots', $opt['id_groupe'], $qui, $opt) 176 : ( 177 $t = sql_getfetsel("id_groupe", "spip_mots", "id_mot=" . intval($id)) 164 178 AND autoriser('modifier', 'groupemots', $t, $qui, $opt) 165 179 ); … … 174 188 * Si l'id_groupe est passé en option, 175 189 * vérifie également que l'auteur a le droit de modifier ce groupe 176 * 177 * @param string $faire Action demandée 178 * @param string $type 179 * @param int $idIdentifiant de l'objet180 * @param array $quiDescription de l'auteur demandant l'autorisation181 * @param array $optOptions de cette autorisation182 * @return bool true s'il a le droit, false sinon 183 **/190 * 191 * @param string $faire Action demandée 192 * @param string $type Type d'objet sur lequel appliquer l'action 193 * @param int $id Identifiant de l'objet 194 * @param array $qui Description de l'auteur demandant l'autorisation 195 * @param array $opt Options de cette autorisation 196 * @return bool true s'il a le droit, false sinon 197 **/ 184 198 function autoriser_mot_creer_dist($faire, $type, $id, $qui, $opt) { 185 if ($qui['statut'] != '0minirezo' OR $qui['restreint']) 186 return false; 199 if ($qui['statut'] != '0minirezo' OR $qui['restreint']) { 200 return false; 201 } 187 202 188 203 $where = ''; … … 190 205 // a la table correspondante 191 206 if (isset($opt['associer_objet']) 192 AND $associer_objet = $opt['associer_objet']){ 193 if (!preg_match(',^(\w+)\|[0-9]+$,',$associer_objet,$match)) 207 AND $associer_objet = $opt['associer_objet'] 208 ) { 209 if (!preg_match(',^(\w+)\|[0-9]+$,', $associer_objet, $match)) { 194 210 return false; 195 $where = "tables_liees REGEXP '(^|,)".addslashes(table_objet($match[1]))."($|,)'"; 211 } 212 $where = "tables_liees REGEXP '(^|,)" . addslashes(table_objet($match[1])) . "($|,)'"; 196 213 } 197 214 // si pas de groupe de mot qui colle, pas le droit 198 if (!sql_countsel('spip_groupes_mots',$where)) 199 return false; 200 201 if (isset($opt['id_groupe'])) 202 return autoriser('modifier','groupemots',$opt['id_groupe']); 203 215 if (!sql_countsel('spip_groupes_mots', $where)) { 216 return false; 217 } 218 219 if (isset($opt['id_groupe'])) { 220 return autoriser('modifier', 'groupemots', $opt['id_groupe']); 221 } 222 204 223 return true; 205 224 } … … 211 230 * 212 231 * @param string $faire Action demandée 213 * @param string $type 214 * @param int $idIdentifiant de l'objet215 * @param array $quiDescription de l'auteur demandant l'autorisation216 * @param array $optOptions de cette autorisation217 * @return bool true s'il a le droit, false sinon 218 **/232 * @param string $type Type d'objet sur lequel appliquer l'action 233 * @param int $id Identifiant de l'objet 234 * @param array $qui Description de l'auteur demandant l'autorisation 235 * @param array $opt Options de cette autorisation 236 * @return bool true s'il a le droit, false sinon 237 **/ 219 238 function autoriser_mot_supprimer_dist($faire, $type, $id, $qui, $opt) { 220 239 // On cherche le groupe du mot 221 $id_groupe = $opt['id_groupe'] ? $opt['id_groupe'] : sql_getfetsel('id_groupe', 'spip_mots', 'id_mot = '.intval($id)); 222 223 return autoriser('creer', 'mot', $id, $qui, array('id_groupe'=>$id_groupe)); 240 $id_groupe = $opt['id_groupe'] ? $opt['id_groupe'] : sql_getfetsel('id_groupe', 'spip_mots', 241 'id_mot = ' . intval($id)); 242 243 return autoriser('creer', 'mot', $id, $qui, array('id_groupe' => $id_groupe)); 224 244 } 225 245 … … 234 254 * 235 255 * @param string $faire Action demandée 236 * @param string $type 237 * @param int $idIdentifiant de l'objet238 * @param array $quiDescription de l'auteur demandant l'autorisation239 * @param array $optOptions de cette autorisation240 * @return bool true s'il a le droit, false sinon 241 */ 242 function autoriser_associermots_dist($faire, $type, $id, $qui, $opt) {256 * @param string $type Type d'objet sur lequel appliquer l'action 257 * @param int $id Identifiant de l'objet 258 * @param array $qui Description de l'auteur demandant l'autorisation 259 * @param array $opt Options de cette autorisation 260 * @return bool true s'il a le droit, false sinon 261 */ 262 function autoriser_associermots_dist($faire, $type, $id, $qui, $opt) { 243 263 // jamais de mots sur des mots 244 if ($type=='mot') return false; 245 if ($type=='groupemots') return false; 246 $droit = substr($qui['statut'],1); 247 248 if (!isset($opt['groupe_champs']) AND !isset($opt['id_groupe'])){ 264 if ($type == 'mot') { 265 return false; 266 } 267 if ($type == 'groupemots') { 268 return false; 269 } 270 $droit = substr($qui['statut'], 1); 271 272 if (!isset($opt['groupe_champs']) AND !isset($opt['id_groupe'])) { 249 273 // chercher si un groupe est autorise pour mon statut 250 274 // et pour la table demandee 251 275 $table = addslashes(table_objet($type)); 252 if (sql_countsel('spip_groupes_mots',"tables_liees REGEXP '(^|,)$table($|,)' AND ".addslashes($droit)."='oui'")) 276 if (sql_countsel('spip_groupes_mots', 277 "tables_liees REGEXP '(^|,)$table($|,)' AND " . addslashes($droit) . "='oui'")) { 253 278 return true; 254 }255 // cas d'un groupe en particulier279 } 280 } // cas d'un groupe en particulier 256 281 else { 257 282 // on recupere les champs du groupe s'ils ne sont pas passes en opt 258 if (!isset($opt['groupe_champs'])) {259 if (!$id_groupe = $opt['id_groupe']) 283 if (!isset($opt['groupe_champs'])) { 284 if (!$id_groupe = $opt['id_groupe']) { 260 285 return false; 286 } 261 287 include_spip('base/abstract_sql'); 262 $opt['groupe_champs'] = sql_fetsel("*", "spip_groupes_mots", "id_groupe=" .intval($id_groupe));288 $opt['groupe_champs'] = sql_fetsel("*", "spip_groupes_mots", "id_groupe=" . intval($id_groupe)); 263 289 } 264 290 $droit = $opt['groupe_champs'][$droit]; … … 273 299 ); 274 300 } 301 275 302 return false; 276 303 } … … 279 306 /** 280 307 * Autorisation d'affichier le sélecteur de mots 281 * 308 * 282 309 * Vérifie le droit d'afficher le selecteur de mots 283 310 * pour un groupe de mot donné, dans un objet / id_objet donné … … 286 313 * 287 314 * @param string $faire Action demandée 288 * @param string $type 289 * @param int $idIdentifiant de l'objet290 * @param array $quiDescription de l'auteur demandant l'autorisation291 * @param array $optOptions de cette autorisation292 * @return bool true s'il a le droit, false sinon 293 */ 294 function autoriser_groupemots_afficherselecteurmots_dist($faire, $type, $id, $qui, $opt) {315 * @param string $type Type d'objet sur lequel appliquer l'action 316 * @param int $id Identifiant de l'objet 317 * @param array $qui Description de l'auteur demandant l'autorisation 318 * @param array $opt Options de cette autorisation 319 * @return bool true s'il a le droit, false sinon 320 */ 321 function autoriser_groupemots_afficherselecteurmots_dist($faire, $type, $id, $qui, $opt) { 295 322 if (!isset($opt['minirezo']) || !isset($opt['comite'])) { 296 323 $i = sql_fetsel( … … 298 325 'spip_groupes_mots', 299 326 'id_groupe=' . intval($id)); 300 if (!$i) return false; # le groupe n'existe pas 327 if (!$i) { 328 return false; 329 } # le groupe n'existe pas 301 330 $admin = $i['minirezo']; 302 331 $redac = $i['comite']; … … 306 335 } 307 336 $statuts = array(); 308 if ($admin == 'oui') $statuts[] = '0minirezo'; 309 if ($redac == 'oui') $statuts[] = '1comite'; 337 if ($admin == 'oui') { 338 $statuts[] = '0minirezo'; 339 } 340 if ($redac == 'oui') { 341 $statuts[] = '1comite'; 342 } 310 343 311 344 return in_array($qui['statut'], $statuts); … … 315 348 /** 316 349 * Autorisation d'affichier le formulaire de logo 317 * 318 * @param string $faire Action demandée 319 * @param string $type 320 * @param int $idIdentifiant de l'objet321 * @param array $quiDescription de l'auteur demandant l'autorisation322 * @param array $optOptions de cette autorisation323 * @return bool true s'il a le droit, false sinon 324 */ 325 function autoriser_mot_iconifier_dist($faire, $type, $id, $qui, $opt) {350 * 351 * @param string $faire Action demandée 352 * @param string $type Type d'objet sur lequel appliquer l'action 353 * @param int $id Identifiant de l'objet 354 * @param array $qui Description de l'auteur demandant l'autorisation 355 * @param array $opt Options de cette autorisation 356 * @return bool true s'il a le droit, false sinon 357 */ 358 function autoriser_mot_iconifier_dist($faire, $type, $id, $qui, $opt) { 326 359 return (($qui['statut'] == '0minirezo') AND !$qui['restreint']); 327 360 } … … 329 362 /** 330 363 * Autorisation d'affichier le formulaire de logo 331 * 332 * @param string $faire Action demandée 333 * @param string $type 334 * @param int $idIdentifiant de l'objet335 * @param array $quiDescription de l'auteur demandant l'autorisation336 * @param array $optOptions de cette autorisation337 * @return bool true s'il a le droit, false sinon 338 */ 339 function autoriser_groupemots_iconifier_dist($faire, $type, $id, $qui, $opt) {364 * 365 * @param string $faire Action demandée 366 * @param string $type Type d'objet sur lequel appliquer l'action 367 * @param int $id Identifiant de l'objet 368 * @param array $qui Description de l'auteur demandant l'autorisation 369 * @param array $opt Options de cette autorisation 370 * @return bool true s'il a le droit, false sinon 371 */ 372 function autoriser_groupemots_iconifier_dist($faire, $type, $id, $qui, $opt) { 340 373 return (($qui['statut'] == '0minirezo') AND !$qui['restreint']); 341 374 } -
_core_/plugins/mots/mots_ieconfig.php
r64995 r93617 3 3 /** 4 4 * Déclarations des configurations qui peuvent être sauvegardées 5 * 5 * 6 6 * @package SPIP\Mots\Pipelines 7 **/ 8 if (!defined("_ECRIRE_INC_VERSION")) return; 7 **/ 8 if (!defined("_ECRIRE_INC_VERSION")) { 9 return; 10 } 9 11 10 12 /** … … 15 17 * @param array $table 16 18 * Déclaration des sauvegardes 17 * @return array 19 * @return array 18 20 * Déclaration des sauvegardes complétées 19 **/20 function mots_ieconfig_metas($table) {21 **/ 22 function mots_ieconfig_metas($table) { 21 23 $table['mots']['titre'] = _T('mots:info_mots_cles'); 22 24 $table['mots']['icone'] = 'mot-16.png'; 23 25 $table['mots']['metas_brutes'] = 'articles_mots,config_precise_groupes,mots_cles_forums'; 24 26 25 27 return $table; 26 28 } -
_core_/plugins/mots/mots_pipelines.php
r89285 r93617 12 12 13 13 /** 14 * Utilisations de pipelines 14 * Utilisations de pipelines 15 15 * 16 16 * @package SPIP\Mots\Pipelines 17 **/ 18 if (!defined('_ECRIRE_INC_VERSION')) return; 17 **/ 18 if (!defined('_ECRIRE_INC_VERSION')) { 19 return; 20 } 19 21 20 22 /** … … 27 29 * Couples nom de la méta => valeur par défaut 28 30 */ 29 function mots_configurer_liste_metas($metas){ 30 $metas['articles_mots'] = 'non'; 31 $metas['config_precise_groupes'] = 'non'; 31 function mots_configurer_liste_metas($metas) { 32 $metas['articles_mots'] = 'non'; 33 $metas['config_precise_groupes'] = 'non'; 34 32 35 #$metas['mots_cles_forums'] = 'non'; 33 36 return $metas; … … 36 39 /** 37 40 * Utilisation du pipeline affiche milieu 38 * 41 * 39 42 * - Ajoute le formulaire de configuration des mots sur la configuration des contenus 40 43 * - Ajoute le formulaire d'édition de mots sur les objets qui le peuvent 41 44 * 42 45 * @pipeline affiche_milieu 43 * 46 * 44 47 * @param array $flux 45 48 * Données du pipeline … … 47 50 * Données du pipeline 48 51 */ 49 function mots_affiche_milieu($flux) {52 function mots_affiche_milieu($flux) { 50 53 if ($flux["args"]["exec"] == "configurer_contenu") { 51 $flux["data"] .= recuperer_fond('prive/squelettes/inclure/configurer',array('configurer'=>'configurer_mots'));54 $flux["data"] .= recuperer_fond('prive/squelettes/inclure/configurer', array('configurer' => 'configurer_mots')); 52 55 } 53 56 54 57 // si on est sur une page ou il faut inserer les mots cles... 55 58 if ($en_cours = trouver_objet_exec($flux['args']['exec']) 56 AND $en_cours['edition'] !==true // page visu59 AND $en_cours['edition'] !== true // page visu 57 60 AND $type = $en_cours['type'] 58 61 AND $id_table_objet = $en_cours['id_table_objet'] 59 62 AND isset($flux['args'][$id_table_objet]) 60 AND ($id = intval($flux['args'][$id_table_objet]))){ 63 AND ($id = intval($flux['args'][$id_table_objet])) 64 ) { 61 65 $texte = recuperer_fond( 62 63 64 'table_source'=>'mots',65 'objet'=>$type,66 'id_objet'=>$id,67 66 'prive/objets/editer/liens', 67 array( 68 'table_source' => 'mots', 69 'objet' => $type, 70 'id_objet' => $id, 71 ) 68 72 ); 69 if ($p =strpos($flux['data'],"<!--affiche_milieu-->"))70 $flux['data'] = substr_replace($flux['data'], $texte,$p,0);71 else73 if ($p = strpos($flux['data'], "<!--affiche_milieu-->")) { 74 $flux['data'] = substr_replace($flux['data'], $texte, $p, 0); 75 } else { 72 76 $flux['data'] .= $texte; 77 } 73 78 } 74 79 75 80 return $flux; 76 81 } … … 80 85 * 81 86 * @pipeline optimiser_base_disparus 82 * 87 * 83 88 * @param array $flux 84 89 * Données du pipeline … … 86 91 * Données du pipeline 87 92 */ 88 function mots_optimiser_base_disparus($flux) {93 function mots_optimiser_base_disparus($flux) { 89 94 $n = &$flux['data']; 90 95 $mydate = $flux['args']['date']; 91 92 $result = sql_delete("spip_mots", "length(titre)=0 AND maj < " .sql_quote($mydate));96 97 $result = sql_delete("spip_mots", "length(titre)=0 AND maj < " . sql_quote($mydate)); 93 98 94 99 include_spip('action/editer_liens'); … … 96 101 // entre mots vers des objets effaces 97 102 // depuis des mots effaces 98 $n += objet_optimiser_liens(array('mot'=>'*'),'*');103 $n += objet_optimiser_liens(array('mot' => '*'), '*'); 99 104 100 105 return $flux; … … 108 113 * 109 114 * @pipeline post_edition 110 * 115 * 111 116 * @param array $flux 112 117 * Données du pipeline … … 114 119 * Données du pipeline 115 120 */ 116 function mots_post_edition($flux) {121 function mots_post_edition($flux) { 117 122 if (isset($flux['args']['table']) 118 123 and ($flux['args']['table'] == 'spip_groupes_mots') 119 and isset($flux['data']['titre']) )120 {124 and isset($flux['data']['titre']) 125 ) { 121 126 sql_updateq('spip_mots', array('type' => $flux['data']['titre']), 122 127 'id_groupe=' . $flux['args']['id_objet']); -
_core_/plugins/mots/prive/objets/infos/mot_fonctions.php
r89285 r93617 15 15 * 16 16 * @package SPIP\Mots\Fonctions 17 **/ 18 if (!defined("_ECRIRE_INC_VERSION")) return; 19 17 **/ 18 if (!defined("_ECRIRE_INC_VERSION")) { 19 return; 20 } 20 21 21 22 -
_core_/plugins/mots/prive/objets/liste/mots-admin_fonctions.php
r89285 r93617 15 15 * 16 16 * @package SPIP\Mots\Fonctions 17 **/ 18 if (!defined("_ECRIRE_INC_VERSION")) return; 17 **/ 18 if (!defined("_ECRIRE_INC_VERSION")) { 19 return; 20 } 19 21 20 22 include_spip('inc/mots'); -
_core_/plugins/mots/puce_statut/mot.php
r93092 r93617 15 15 * 16 16 * @package SPIP\Mots\PucesStatut 17 **/17 **/ 18 18 19 if (!defined('_ECRIRE_INC_VERSION')) return; 19 if (!defined('_ECRIRE_INC_VERSION')) { 20 return; 21 } 20 22 21 23
Note: See TracChangeset
for help on using the changeset viewer.