Commit | Line | Data |
---|---|---|
e586807d | 1 | <?php |
b42b2bf9 | 2 | |
e586807d H |
3 | function smarty_function_get_bookmarks($brawco,&$smarty) { |
4 | ||
b42b2bf9 H |
5 | if (is_numeric($brawco['node_id'])) $bookcat=$brawco['node_id']; |
6 | if (is_numeric($brawco['user_id'])) $user_id=$brawco['user_id']; | |
7 | global $db; | |
8 | ||
9 | //returning user specific bookmarks | |
10 | if ($user_id) { | |
11 | $q="select * from node_access left join nodes on node_access.node_id=nodes.node_id where user_id='$user_id' and node_bookmark='yes' and nodes.node_system_access='public'"; | |
12 | $set=$db->query($q); | |
13 | while ($set->next()) { | |
14 | $array[]=$set->getRecord(); | |
15 | } | |
16 | $smarty->assign('get_bookmarks',$array); | |
17 | return false; | |
18 | } | |
19 | ||
20 | //returning my own bookmarks divided in categories | |
21 | $q="select distinct bookmark_category,nodes.* from node_access left join nodes on node_access.bookmark_category=nodes.node_id where user_id='".$_SESSION['user_id']."' and node_bookmark='yes' order by node_name"; | |
22 | $result=$db->query($q); | |
23 | while ($result->next()) { | |
24 | $categories[$result->getString('node_id')]=$result->getRecord(); | |
25 | } | |
26 | ||
27 | $q="select * from node_access left join nodes on node_access.node_id=nodes.node_id where user_id='".$_SESSION['user_id']."' and node_bookmark='yes' and node_name is not NULL "; | |
28 | if ($bookcat) $q.=" and (bookmark_category='$bookcat' or bookmark_category=0 or bookmark_category IS NULL) order by node_name desc"; | |
29 | if ($bookcat && $_SESSION['user_id']==548) echo $q; | |
30 | ||
31 | else $q.="order by node_name"; | |
32 | $result=$db->query($q); | |
33 | if (!$bookcat) { | |
34 | while ($result->next()) { | |
35 | if (!$result->getString('bookmark_category')) { | |
36 | $categories['unsorted']['children'][]=$result->getRecord(); | |
37 | $categories['unsorted']['sum']+=$result->getString('node_user_subchild_count'); | |
38 | } | |
39 | else { | |
40 | $categories[$result->getString('bookmark_category')]['children'][]=$result->getRecord(); | |
41 | $categories[$result->getString('bookmark_category')]['sum']+=$result->getString('node_user_subchild_count'); | |
42 | } | |
43 | } | |
44 | ||
45 | $smarty->assign('get_bookmarks',$categories); | |
46 | } | |
47 | ||
48 | else { | |
49 | while ($result->next()) { | |
50 | $bookmarks[]=$result->getRecord(); | |
51 | } | |
52 | $smarty->assign('get_bookmarks',$bookmarks); | |
53 | } | |
e586807d H |
54 | } |
55 | ?> |