Commit | Line | Data |
---|---|---|
e586807d | 1 | <?php |
b42b2bf9 | 2 | //returns array of linked nodes, possible args listing_amount,offset,node_id,orderby=synapse |
e586807d H |
3 | |
4 | function smarty_function_get_linked_nodes($params,&$smarty) { | |
b42b2bf9 H |
5 | global $db, $error, $node; |
6 | ||
7 | if ($params['listing_amount']=='all') $listing_amount='23232323232323323'; | |
8 | elseif (is_numeric($params['listing_amount'])) $listing_amount=$params['listing_amount']; | |
9 | else $listing_amount=DEFAULT_LISTING_AMOUNT; | |
10 | ||
11 | if (is_numeric($params['offset'])) $offset=$params['offset']; | |
12 | elseif (is_numeric($_POST['offset'])) $offset=$_POST['offset']; | |
13 | else $offset=0; | |
14 | ||
15 | ||
16 | ||
17 | if ($params['node_id']) { | |
18 | $node_id=$params['node_id']; | |
e586807d | 19 | } |
b42b2bf9 H |
20 | |
21 | else { | |
22 | $node_id=$node['node_id']; | |
23 | } | |
24 | ||
25 | if ($params['orderby']='synapse') { | |
26 | $orderby='synapse_created'; | |
27 | } | |
28 | ||
e586807d | 29 | else { |
b42b2bf9 | 30 | $orderby='node_id'; |
e586807d H |
31 | } |
32 | ||
b42b2bf9 H |
33 | |
34 | ||
35 | $q="select neurons.synapse_created,node_content,author.login,linker.login as linker,nodes.* from neurons left join nodes on neurons.src=nodes.node_id left join users as linker on neurons.synapse_creator=linker.user_id left join users as author on nodes.node_creator=author.user_id where dst='$node_id' and link in ('hard','bookmark') order by $orderby desc limit $offset , $listing_amount"; | |
e586807d H |
36 | $result=$db->query($q); |
37 | while ($result->next()) { | |
38 | $array=$result->getRecord(); | |
39 | $array['node_status']="linked"; | |
e586807d H |
40 | $array['node_created']=$array['synapse_created']; |
41 | $get_linked_nodes[]=$array; | |
42 | } | |
43 | $smarty->assign('get_linked_nodes',$get_linked_nodes); | |
44 | ||
b42b2bf9 H |
45 | } |
46 | ||
47 | ?> | |
48 |