[SPIP] v3.2.1-->v3.2.2
[lhc/web/www.git] / www / ecrire / action / instituer_langue_rubrique.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2019 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13 /**
14 * Action des changements de langue des rubriques
15 *
16 * @package SPIP\Core\Edition
17 **/
18
19 if (!defined('_ECRIRE_INC_VERSION')) {
20 return;
21 }
22
23 /**
24 * Modifie la langue d'une rubrique
25 **/
26 function action_instituer_langue_rubrique_dist() {
27
28 $securiser_action = charger_fonction('securiser_action', 'inc');
29 $arg = $securiser_action();
30 $changer_lang = _request('changer_lang');
31
32 list($id_rubrique, $id_parent) = preg_split('/\W/', $arg);
33
34 if ($changer_lang
35 and $id_rubrique > 0
36 and $GLOBALS['meta']['multi_rubriques'] == 'oui'
37 and ($GLOBALS['meta']['multi_secteurs'] == 'non' or $id_parent == 0)
38 ) {
39 if ($changer_lang != "herit") {
40 sql_updateq('spip_rubriques', array('lang' => $changer_lang, 'langue_choisie' => 'oui'),
41 "id_rubrique=$id_rubrique");
42 } else {
43 if ($id_parent == 0) {
44 $langue_parent = $GLOBALS['meta']['langue_site'];
45 } else {
46 $langue_parent = sql_getfetsel("lang", "spip_rubriques", "id_rubrique=$id_parent");
47 }
48 sql_updateq('spip_rubriques', array('lang' => $langue_parent, 'langue_choisie' => 'non'),
49 "id_rubrique=$id_rubrique");
50 }
51 include_spip('inc/rubriques');
52 calculer_langues_rubriques();
53
54 // invalider les caches marques de cette rubrique
55 include_spip('inc/invalideur');
56 suivre_invalideur("id='rubrique/$id_rubrique'");
57 }
58 }