squellete2
[aidenligne_francais_universite.git] / ecrire / action / documenter.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2007 *
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")) return;
14
15 include_spip('action/supprimer');
16
17 // http://doc.spip.org/@action_documenter_dist
18 function action_documenter_dist()
19 {
20 $securiser_action = charger_fonction('securiser_action', 'inc');
21 $arg = $securiser_action();
22
23 if (!preg_match(",^(-?)(\d+)\W(\w+)\W?(\d*)$,", $arg, $r))
24 spip_log("action_documenter $arg pas compris");
25 else action_documenter_post($r);
26 }
27
28 // http://doc.spip.org/@action_documenter_post
29 function action_documenter_post($r)
30 {
31 list($x, $sign, $id, $type, $vignette) = $r;
32 if ($vignette)
33 supprimer_document_et_vignette($vignette);
34 else {
35 if ($sign)
36 $x = spip_query("SELECT docs.id_document FROM spip_documents AS docs, spip_documents_".$type."s AS l, spip_types_documents AS lestypes WHERE l.id_$type=$id AND l.id_document=docs.id_document AND docs.mode='document' AND docs.id_type=lestypes.id_type AND lestypes.extension IN ('gif', 'jpg', 'png')");
37 else $x = spip_query("SELECT docs.* FROM spip_documents AS docs, spip_documents_".$type."s AS l, spip_types_documents AS lestypes WHERE l.id_$type=$id AND l.id_document=docs.id_document AND docs.mode='document' AND docs.id_type=lestypes.id_type AND lestypes.extension NOT IN ('gif', 'jpg', 'png')");
38 while($r = spip_fetch_array($x)) {
39 supprimer_document_et_vignette($r['id_document']);
40 }
41 }
42 if ($type == 'rubrique') {
43 include_spip('inc/rubriques');
44 calculer_rubriques();
45 }
46 }
47 ?>