Added rudimentary transport support to get_threaded_children
[mirrors/Kyberia-bloodline.git] / wwwroot / inc / eventz / delete.inc
CommitLineData
51ff3226 1<?php
2function delete() {
3// vlastne len wrapper na set_parent
4global $node,$db,$error;
5$new_parent_id=123456;
6$nodes=$_POST['node_chosen'];
7$hierarch_id=$node['node_id'];
8
9$new_parent=nodes::getNodeById($new_parent_id,$_SESSION['user_id']);
10$new_parent_permissions=permissions::checkPermissions($new_parent);
11
12if (!$new_parent_permissions['w'] and !isHierarch($new_parent)) {
13global $error_messages;
14$error=$error_messages['WRITE_PERMISSION_ERROR'];
15return false;
16}
17
18$parent_vector=$new_parent['node_vector'];
19
20if (!is_array($nodes)) {
21$nodes[]=$node['node_id'];
22}
23
24if (($node['node_creator']!=$_SESSION['user_id']) and
25($node['node_permission']!='master') and !permissions::isHierarch($node)) {
26global $error_messages;
27$error=$error_messages['EVENT_PERMISSION_ERROR'];
28return false;
29}
30
31foreach ($nodes as $chosen_id) {
32unset($chosen);
33
34$new_vector=$parent_vector.str_pad($chosen_id,VECTOR_CHARS,"0",STR_PAD_LEFT);
35
36$kset=$db->query("select src from neurons where dst='$chosen_id' and link='hard'");
37$kset->next();$src=$kset->getString('src');
38
39
40// echo 'Debug:: Novy vektor putu';
41// echo $new_vector.$src;
42
43
44
45$chosen=nodes::getNodeById($chosen_id,$_SESSION['user_id']);
46
47if (($chosen['node_creator']!=$_SESSION['user_id']) and
48($chosen['node_permission']!='master') and !permissions::isHierarch($chosen)) {
49global $error_messages;
50$error=$error_messages['EVENT_PERMISSION_ERROR'];
51return false;
52}
53
54$set=$db->query("select * from neurons where dst='$chosen_id' and link='hard'");
55if ($set->getNumRows()>0){
56
57$q="update neurons set dst_vector='$new_vector.$src' where dst='$chosen_id' and link='hard'";
58$debug2=$db->update($q);
59}
60
61
62$db->query("start transaction");
63$q="update nodes set node_parent='$new_parent_id',node_vector='".$new_vector."' where
64node_id='$chosen_id'";
65$debug1=$db->query($q);
66$q="update nodes set
67node_vector=replace(node_vector,'".$chosen['node_vector']."','$new_vector') where
68node_vector like '".$chosen['node_vector']."%'";
69$changed=$db->update($q);
70$q="update nodes set node_children_count=node_children_count+1 where node_id='$new_parent_id'";
71$db->update($q);
72$db->query("commit");
73
74// echo '<br>debug:: pocet putov v node:: <br>';
75//
76// $set=$db->query("select * from neurons where dst='$chosen_id' and link='hard'");
77// echo $set->getNumRows();
78
79}
80//echo "debug1:: <br>";
81//echo $debug1;echo "<br>";
82//echo "changed:: <br>";
83//echo $changed;echo "<br>";
84//echo "debug2:: <br>";
85//echo $debug2;echo "<br>";
86
87
88return false;
89
90
91}
92?>
This page took 0.904635 seconds and 4 git commands to generate.