Commit | Line | Data |
---|---|---|
e586807d | 1 | <?php |
e586807d H |
2 | |
3 | ||
4 | function set_bookmark_category() { | |
e586807d H |
5 | global $node,$db,$error; |
6 | $bookmarks=$_POST['bookmarks_chosen']; | |
7 | $category_id=$_POST['bookmark_category_id']; | |
8 | $new_parent=nodes::getNodeById($category_id,$_SESSION['user_id']); | |
9 | $new_parent_permissions=permissions::checkPermissions($new_parent); | |
10 | ||
11 | ||
12 | if (!$new_parent_permissions['w']) { | |
13 | global $error_messages; | |
14 | $error=$error_messages['WRITE_PERMISSION_ERROR']; | |
15 | return false; | |
16 | } | |
17 | ||
18 | ||
19 | ||
20 | foreach ($bookmarks as $chosen_id) { | |
21 | ||
22 | unset($chosen); | |
23 | ||
24 | $db->query("start transaction"); | |
e586807d H |
25 | |
26 | $q="update node_access set bookmark_category='$category_id' where node_id='$chosen_id' and user_id='".$_SESSION['user_id']."'"; | |
27 | $db->query($q); | |
28 | ||
b42b2bf9 H |
29 | $q="update neurons set dst='$category_id' where src='$chosen_id' and synapse_creator='".$_SESSION['user_id']."' and link='bookmark'"; |
30 | $result=$db->update($q); | |
31 | if (!$result) $db->query("insert into neurons set synapse_creator='".$_SESSION['user_id']."',src='$chosen_id',dst='$category_id',link='bookmark'"); | |
32 | $db->query("update nodes set lastdescendant_created=NOW() where node_id='$category_id'"); | |
33 | $db->query("commit"); | |
e586807d H |
34 | } |
35 | ||
36 | return true; | |
37 | } | |
b42b2bf9 H |
38 | ?> |
39 | ||
40 |