still removing warnings
[mirrors/Kyberia-bloodline.git] / wwwroot / inc / smarty / node_methodz / function.get_bookmarks.php
... / ...
CommitLineData
1<?php
2
3function smarty_function_get_bookmarks($brawco,&$smarty) {
4
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'];
7global $db;
8
9//returning user specific bookmarks
10if ((!empty($user_id)) && $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);
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 ";
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
30
31else $q.="order by node_name";
32$result=$db->query($q);
33if (empty($bookcat) || !$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
48else {
49 while ($result->next()) {
50 $bookmarks[]=$result->getRecord();
51 }
52 $smarty->assign('get_bookmarks',$bookmarks);
53}
54}
55?>
This page took 0.101948 seconds and 4 git commands to generate.