1 | <?php |
---|
2 | |
---|
3 | if (!defined("_ECRIRE_INC_VERSION")) return; |
---|
4 | |
---|
5 | function action_ranger_dist($arg=null){ |
---|
6 | if (is_null($arg)){ |
---|
7 | $securiser_action = charger_fonction('securiser_action', 'inc'); |
---|
8 | $arg = $securiser_action(); |
---|
9 | } |
---|
10 | $verifier_ordre=charger_fonction('verifier_ordre','inc'); |
---|
11 | include_spip("inc/autoriser"); |
---|
12 | include_spip("inc/config"); |
---|
13 | |
---|
14 | list($action,$lang,$id_selection_objet,$ordre,$objet_dest,$id_objet_dest,$load)=explode('-',$arg); |
---|
15 | $load=_request('load'); |
---|
16 | |
---|
17 | switch($action){ |
---|
18 | case 'supprimer_ordre' : |
---|
19 | |
---|
20 | include_spip('formulaires/bouton_article'); |
---|
21 | |
---|
22 | spip_log('eliminer 1','selection'); |
---|
23 | $where=array( |
---|
24 | 'id_selection_objet='.$id_selection_objet, |
---|
25 | ); |
---|
26 | |
---|
27 | sql_delete("spip_selection_objets",$where); |
---|
28 | |
---|
29 | // on vérifie l'ordre des objets déjà enregistrés et on corrige si beselection_objetin |
---|
30 | |
---|
31 | $where = array( |
---|
32 | 'id_objet_dest='.$id_objet_dest, |
---|
33 | 'objet_dest='.sql_quote($objet_dest), |
---|
34 | 'lang='.sql_quote($lang) |
---|
35 | ); |
---|
36 | |
---|
37 | $ordre=$verifier_ordre($where); |
---|
38 | |
---|
39 | break; |
---|
40 | |
---|
41 | case 'remonter_ordre': |
---|
42 | $where = array( |
---|
43 | 'lang="'.$lang.'"', |
---|
44 | 'objet_dest="'.$objet_dest.'"', |
---|
45 | 'id_objet_dest="'.$id_objet_dest.'"', |
---|
46 | 'ordre<="'.$ordre.'"', |
---|
47 | ); |
---|
48 | |
---|
49 | $result = sql_select("*", "spip_selection_objets", $where,'', "ordre DESC",2); |
---|
50 | |
---|
51 | while ($row = sql_fetch($result)) { |
---|
52 | if($id_selection_objet==$row["id_selection_objet"]){ |
---|
53 | $o =$ordre-1; |
---|
54 | } |
---|
55 | else{ |
---|
56 | $o =$ordre; |
---|
57 | } |
---|
58 | sql_updateq("spip_selection_objets", array("ordre" =>$o),'id_selection_objet='.$row['id_selection_objet']); |
---|
59 | } |
---|
60 | $where = array( |
---|
61 | 'id_objet_dest='.$id_objet_dest, |
---|
62 | 'objet_dest='.sql_quote($objet_dest), |
---|
63 | 'lang='.sql_quote($lang) |
---|
64 | ); |
---|
65 | $ordre=$verifier_ordre($where); |
---|
66 | break; |
---|
67 | |
---|
68 | case 'descendre_ordre': |
---|
69 | $where = array( |
---|
70 | 'lang="'.$lang.'"', |
---|
71 | 'objet_dest="'.$objet_dest.'"', |
---|
72 | 'id_objet_dest="'.$id_objet_dest.'"', |
---|
73 | 'ordre>="'.$ordre.'"', |
---|
74 | ); |
---|
75 | |
---|
76 | $result = sql_select("*", "spip_selection_objets", $where,'', "ordre",2); |
---|
77 | |
---|
78 | |
---|
79 | while ($row = sql_fetch($result)) { |
---|
80 | if($id_selection_objet==$row["id_selection_objet"]){ |
---|
81 | $o =$ordre+1; |
---|
82 | } |
---|
83 | else{ |
---|
84 | $o =$ordre; |
---|
85 | } |
---|
86 | sql_updateq("spip_selection_objets", array("ordre" =>$o),'id_selection_objet='.$row['id_selection_objet']); |
---|
87 | } |
---|
88 | $where = array( |
---|
89 | 'id_objet_dest='.$id_objet_dest, |
---|
90 | 'objet_dest='.sql_quote($objet_dest), |
---|
91 | 'lang='.sql_quote($lang) |
---|
92 | ); |
---|
93 | $ordre=$verifier_ordre($where); |
---|
94 | break; |
---|
95 | //drag&drop |
---|
96 | case 'nouvel_ordre': |
---|
97 | $nouvel_ordre=explode(',',_request('nouvel_ordre')); |
---|
98 | $ordre=0; |
---|
99 | foreach($nouvel_ordre AS $id_selection_objet){ |
---|
100 | $ordre++; |
---|
101 | sql_updateq("spip_selection_objets", array("ordre" => $ordre),'id_selection_objet='.$id_selection_objet); |
---|
102 | include_spip('inc/invalideur'); |
---|
103 | suivre_invalideur("id='selection_objet/$id_selection_objet'"); |
---|
104 | } |
---|
105 | break; |
---|
106 | } |
---|
107 | |
---|
108 | if($load){ |
---|
109 | $contexte = array('id_objet_dest'=>$id_objet_dest,'objet_dest'=>$objet_dest,'l'=>$lang); |
---|
110 | echo recuperer_fond($load,$contexte); |
---|
111 | } |
---|
112 | return $return; |
---|
113 | } |
---|
114 | |
---|
115 | ?> |
---|