Commit | Line | Data |
---|---|---|
e586807d | 1 | <?php |
e586807d | 2 | function put() { |
b42b2bf9 H |
3 | global $error_messages,$db,$node,$error; |
4 | $user_id = $_SESSION['user_id']; | |
5 | ||
6 | if (!empty($_POST['nodeshell_id'])) $nodeshell_id = mysql_real_escape_string($_POST['nodeshell_id']); | |
7 | else $nodeshell_id = mysql_real_escape_string($_POST['nodeshell_id_select']); | |
e586807d | 8 | |
b42b2bf9 H |
9 | $nodeshell = nodes::getNodeById($nodeshell_id,$_SESSION['user_id']); |
10 | $nodeshell_permissions = permissions::checkPermissions($nodeshell); | |
11 | $nodeshell_vector = $nodeshell['node_vector']; | |
e586807d | 12 | |
b42b2bf9 H |
13 | if (!$nodeshell_permissions['w']) { |
14 | $error = $error_messages['WRITE_PERMISSION_ERROR']; | |
15 | return false; | |
16 | } | |
e586807d | 17 | |
b42b2bf9 H |
18 | if (is_array($_POST['node_chosen'])) $put_array = $_POST['node_chosen']; |
19 | else $put_array[] = $node['node_id']; | |
e586807d H |
20 | |
21 | foreach ($put_array as $chosen) { | |
b42b2bf9 H |
22 | $dst_vector = $nodeshell_vector.str_pad($chosen,VECTOR_CHARS,0,STR_PAD_LEFT); |
23 | $q = "update neurons set synapse_created=NOW(),link='hard',synapse=synapse+1, | |
24 | dst_vector='$dst_vector' where src='$chosen' and dst='$nodeshell_id'"; | |
25 | $result=$db->update($q); | |
26 | ||
27 | if (!$result) $db->query("insert into neurons set synapse_creator='$user_id',synapse_created=NOW(), | |
28 | src='$chosen',dst='$nodeshell_id',dst_vector='$dst_vector',link='hard',synapse=1"); | |
29 | ||
e586807d H |
30 | $db->query("update nodes set lastdescendant_created=NOW() where node_id='$nodeshell_id'"); |
31 | } | |
32 | } | |
b42b2bf9 | 33 | ?> |