| 1 | <?php |
| 2 | |
| 3 | # XXX remove constants and move to backend |
| 4 | function smarty_function_get_last($params,&$smarty) { |
| 5 | |
| 6 | if ($params['listing_amount']=='all') $listing_amount='-1'; |
| 7 | else $listing_amount=addslashes($params['listing_amount']); |
| 8 | if (empty($params['offset'])) $offset=0; |
| 9 | else $offset=addslashes($params['offset']); |
| 10 | |
| 11 | global $db,$node; |
| 12 | |
| 13 | if ($node['node_id']==23) { |
| 14 | $interval=" nodes.node_created>NOW()-INTERVAL 65 HOUR and"; |
| 15 | $params['vector']="00"; |
| 16 | } |
| 17 | |
| 18 | else { |
| 19 | $vector=$node['node_vector']; |
| 20 | $interval=" nodes.node_created>NOW()-INTERVAL 42 DAY and"; |
| 21 | } |
| 22 | |
| 23 | $node_id=$node['node_id']; |
| 24 | $user_id=$_SESSION['user_id']; |
| 25 | $q="select parent.node_name as parent_name,users.*,nodes.* from nodes |
| 26 | left join nodes as parent on parent.node_id=nodes.node_parent |
| 27 | left join users on users.user_id=nodes.node_creator where $interval |
| 28 | nodes.node_vector like '$vector%' and |
| 29 | nodes.node_system_access!='private' order by nodes.node_id desc LIMIT $offset,$listing_amount "; |
| 30 | |
| 31 | $set=$db->query($q); |
| 32 | while ($set->next()) $pole[]=$set->getRecord(); |
| 33 | $smarty->assign('get_last',$pole); |
| 34 | |
| 35 | } |
| 36 | ?> |