still removing warnings
[mirrors/Kyberia-bloodline.git] / wwwroot / inc / smarty / node_methodz / function.get_bookmarks.php
CommitLineData
51ff3226 1<?php
2
3function smarty_function_get_bookmarks($brawco,&$smarty) {
4
202c37b7 5if ((!empty($brawco['node_id'])) && is_numeric($brawco['node_id'])) $bookcat=$brawco['node_id'];
6if ((!empty($brawco['user_id'])) && is_numeric($brawco['user_id'])) $user_id=$brawco['user_id'];
51ff3226 7global $db;
8
9//returning user specific bookmarks
202c37b7 10if ((!empty($user_id)) && $user_id) {
51ff3226 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);
13while ($set->next()) {
14$array[]=$set->getRecord();
15}
16$smarty->assign('get_bookmarks',$array);
17return 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);
23while ($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 ";
202c37b7 28if ((!empty($bookcat)) && $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; ble
51ff3226 30
31else $q.="order by node_name";
32$result=$db->query($q);
5bd150af 33if (empty($bookcat) || !$bookcat) {
202c37b7 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 }
51ff3226 44
202c37b7 45 $smarty->assign('get_bookmarks',$categories);
51ff3226 46}
47
48else {
202c37b7 49 while ($result->next()) {
50 $bookmarks[]=$result->getRecord();
51 }
52 $smarty->assign('get_bookmarks',$bookmarks);
51ff3226 53}
54}
55?>
This page took 0.278962 seconds and 4 git commands to generate.