Commit | Line | Data |
---|---|---|
c495c100 P |
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 | // http://doc.spip.org/@action_editer_mot_dist | |
16 | function action_editer_mot_dist() { | |
17 | ||
18 | $securiser_action = charger_fonction('securiser_action', 'inc'); | |
19 | $arg = $securiser_action(); | |
20 | // arg = l'eventuel mot a supprimer pour d'eventuelles Row SQL | |
21 | if (!preg_match(',^(\d*)\D(-?\d*)\W(\w*)\W(\w*)\W(\w*)\W?(\d*)$,', $arg, $r)) | |
22 | spip_log("action editer_mot: $arg pas compris"); | |
23 | else action_editer_mot_post($r); | |
24 | } | |
25 | ||
26 | // http://doc.spip.org/@action_editer_mot_post | |
27 | function action_editer_mot_post($r) | |
28 | { | |
29 | $redirect = _request('redirect'); | |
30 | $cherche_mot = _request('cherche_mot'); | |
31 | $select_groupe = _request('select_groupe'); | |
32 | ||
33 | list($x, $id_objet, $id_mot, $table, $table_id, $objet, $nouv_mot) = $r; | |
34 | if ($id_mot) { | |
35 | if ($objet) | |
36 | // desassocier un/des mot d'un objet precis | |
37 | spip_query("DELETE FROM spip_mots_$table WHERE $table_id=$id_objet" . (($id_mot <= 0) ? "" : " AND id_mot=$id_mot")); | |
38 | else { | |
39 | // disparition complete d'un mot | |
40 | spip_query("DELETE FROM spip_mots WHERE id_mot=$id_mot"); | |
41 | spip_query("DELETE FROM spip_mots_articles WHERE id_mot=$id_mot"); | |
42 | spip_query("DELETE FROM spip_mots_rubriques WHERE id_mot=$id_mot"); | |
43 | spip_query("DELETE FROM spip_mots_syndic WHERE id_mot=$id_mot"); | |
44 | spip_query("DELETE FROM spip_mots_forum WHERE id_mot=$id_mot"); | |
45 | } | |
46 | } | |
47 | if ($nouv_mot ? $nouv_mot : ($nouv_mot = _request('nouv_mot'))) { | |
48 | // recopie de: | |
49 | // inserer_mot("spip_mots_$table", $table_id, $id_objet, $nouv_mot); | |
50 | $result = spip_num_rows(spip_query("SELECT id_mot FROM spip_mots_$table WHERE id_mot=$nouv_mot AND $table_id=$id_objet")); | |
51 | if (!$result) | |
52 | spip_query("INSERT INTO spip_mots_$table (id_mot,$table_id) VALUES ($nouv_mot, $id_objet)"); | |
53 | } | |
54 | ||
55 | if ($table AND $GLOBALS['meta']['activer_moteur'] == 'oui') { | |
56 | include_spip("inc/indexation"); | |
57 | marquer_indexer("spip_$table", $id_objet); | |
58 | } | |
59 | ||
60 | $redirect = rawurldecode($redirect); | |
61 | ||
62 | // hack du retour croise editer/grouper | |
63 | ||
64 | if (preg_match('/^(.*exec=)editer_mot(&.*)script=(grouper_mots)(.*)$/', $redirect, $r)) | |
65 | $redirect = $r[1] . $r[3] . $r[2] . $r[4]; | |
66 | ||
67 | if ($cherche_mot) { | |
68 | if ($p = strpos($redirect, '#')) { | |
69 | $a = substr($redirect,$p); | |
70 | $redirect = substr($redirect,0,$p); | |
71 | } else $a=''; | |
72 | $redirect .= "&cherche_mot=$cherche_mot&select_groupe=$select_groupe$a"; | |
73 | } | |
74 | redirige_par_entete($redirect); | |
75 | } | |
76 | ?> |