[SPIP] ~v3.0.20-->v3.0.25
[lhc/web/clavette_www.git] / www / plugins-dist / medias / action / changer_mode_document.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2016 *
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
16 /**
17 * Cette action permet de basculer du mode image au mode document et vice versa
18 *
19 * http://code.spip.net/@action_changer_mode_document_dist
20 *
21 * @param int $id_document
22 * @param string $mode
23 * @return void
24 */
25 function action_changer_mode_document_dist($id_document=null, $mode=null){
26 if (is_null($id_document) OR is_null($mode)){
27 $securiser_action = charger_fonction('securiser_action', 'inc');
28 $arg = $securiser_action();
29
30 if (!preg_match(",^(\d+)\W(\w+)$,", $arg, $r))
31 spip_log("action_changer_mode_document $arg pas compris");
32 else {
33 array_shift($r);
34 list($id_document, $mode) = $r;
35 }
36 }
37
38 if ($id_document
39 AND include_spip('inc/autoriser')
40 AND autoriser('modifier','document',$id_document))
41 action_changer_mode_document_post($id_document, $mode);
42 }
43
44 // http://code.spip.net/@action_changer_mode_document_post
45 function action_changer_mode_document_post($id_document, $mode){
46 // - id_document le doc a modifier
47 // - mode le mode a lui donner
48 if ($id_document = intval($id_document)
49 AND in_array($mode, array('vignette', 'image', 'document'))) {
50 include_spip('action/editer_document');
51 document_modifier($id_document,array('mode'=>$mode));
52 }
53 }
54 ?>