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