[SPIP] v3.2.1-->v3.2.3
[lhc/web/www.git] / www / plugins-dist / petitions / action / traiter_lot_signature.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 if (!defined("_ECRIRE_INC_VERSION")) {
14 return;
15 }
16
17 function action_traiter_lot_signature_dist($arg = null) {
18
19 if (is_null($arg)) {
20 $securiser_action = charger_fonction('securiser_action', 'inc');
21 $arg = $securiser_action();
22 }
23
24 /**
25 * $arg contient l'action relancer/supprimer/valider
26 * les id sont dans un tableau non signe ids[]
27 */
28 if (preg_match(",^(\w+)$,", $arg, $match)
29 and in_array($statut = $match[1], array('relancer', 'supprimer', 'valider'))
30 and autoriser('modererlot', 'petition')
31 ) {
32 $where = '';
33 if (intval($id_petition = _request('id_petition'))) {
34 $where = "id_petition=" . intval($id_petition);
35 // pour relancer ou valider on ne prend que celles en attente
36 if (in_array($statut, array('relancer', 'valider'))) {
37 $where .= " AND statut!='publie' AND statut!='poubelle'";
38 }
39 } else {
40 $ids = _request('ids');
41 if (is_array($ids)) {
42 $ids = array_map('intval', $ids);
43 $where = sql_in('id_signature', $ids);
44 }
45 }
46
47 if ($where) {
48 $rows = sql_allfetsel("id_signature", "spip_signatures", $where);
49 if (!count($rows)) {
50 return;
51 }
52 $rows = array_map('reset', $rows);
53 if ($action = charger_fonction($statut . "_signature", 'action', true)) {
54 foreach ($rows as $id_signature) {
55 $action($id_signature);
56 }
57 }
58 }
59 }
60 }