Commit | Line | Data |
---|---|---|
e586807d H |
1 | <?php |
2 | /* This program is free software. It comes without any warranty, to | |
3 | * the extent permitted by applicable law. You can redistribute it | |
4 | * and/or modify it under the terms of the Do What The Fuck You Want | |
5 | * To Public License, Version 2, as published by Sam Hocevar. See | |
6 | * http://sam.zoy.org/wtfpl/COPYING for more details. */ | |
7 | ||
8 | function delete() { | |
9 | // die(); | |
10 | ||
11 | /* najprv insertne do tiamat vsetky data nody tykajuce sa dotycnej nody | |
12 | potom ju zmaze | |
13 | potom urobi to iste s descendantami | |
14 | what about node_access and neurons ? | |
15 | */ | |
16 | error_reporting(E_ALL); | |
17 | global $node,$db,$error; | |
18 | $nodes=$_POST['node_chosen']; | |
19 | $user_id=$_SESSION['user_id']; | |
20 | ||
21 | if (empty($nodes)) { | |
22 | $nodes[]=$node['node_id']; | |
23 | } | |
24 | ||
25 | foreach ($nodes as $chosen) { | |
26 | if (empty($chosen)) { | |
27 | $error="just a little bug"; | |
28 | return false; | |
29 | } | |
30 | ||
31 | $delete_node=nodes::getNodeById($chosen); | |
32 | $vector=$delete_node['node_vector']; | |
33 | $node_parent=$delete_node['node_parent']; | |
34 | $created=$delete_node['node_created']; | |
35 | ||
36 | if ($delete_node['node_creator']==$_SESSION['user_id'] || permissions::isHierarch($delete_node)) { | |
37 | $q="insert into tiamat (node_id,node_name,node_parent,node_vector, | |
38 | node_external_access,node_system_access,node_children_count,node_creator,node_created,lastchild_created,k, | |
39 | node_views,node_destructor,node_content,node_descendant_count,lastdescendant_created,template_id,external_link) | |
40 | select nodes.node_id,node_name,node_parent,node_vector,node_external_access,node_system_access, | |
41 | node_children_count,node_creator,node_created,lastchild_created,k,node_views,'$user_id',node_content, | |
42 | node_descendant_count,lastdescendant_created,template_id,external_link from nodes left join node_content on nodes.node_id=node_content.node_id where nodes.node_id='$chosen'"; | |
43 | ||
44 | $q="delete from nodes where node_id='$chosen'"; | |
45 | $db->query($q); | |
46 | echo $q; | |
47 | if (!empty($vector)) { | |
48 | $q="select node_id from nodes where node_vector like '$vector%'"; | |
49 | echo $q; | |
50 | $cset=$db->query($q); | |
51 | while ($cset->next()) { | |
52 | $chosen_child=$cset->getString('node_id'); | |
53 | $q="insert into tiamat (node_id,node_name,node_parent,node_vector, | |
54 | node_external_access,node_system_access,node_children_count,node_creator,node_created,lastchild_created,k, | |
55 | node_views,node_destructor,node_content,node_descendant_count,lastdescendant_created,template_id,external_link) | |
56 | select nodes.node_id,node_name,node_parent,node_vector,node_external_access,node_system_access, | |
57 | node_children_count,node_creator,node_created,lastchild_created,k,node_views,'$user_id',node_content, | |
58 | node_descendant_count,lastdescendant_created,template_id,external_link from nodes left join node_content on nodes.node_id=node_content.node_id where nodes.node_id='$chosen_child'"; | |
59 | echo $q; | |
60 | $db->query($q); | |
61 | ||
62 | } | |
63 | } | |
64 | log::log('delete',$chosen,'ok',$_SESSION['user_id']); | |
65 | } | |
66 | else { | |
67 | global $error_messages; | |
68 | $error=$error_messages['EVENT_PERMISSION_ERROR']; | |
69 | log::log('delete',$chosen,'EVENT_PERMISSION_ERROR',$_SESSION['user_id']); | |
70 | return false; | |
71 | } | |
72 | ||
73 | ||
74 | ||
75 | } | |
76 | ||
77 | } | |
78 | ?> |