| 1 | <?php |
| 2 | |
| 3 | function smarty_function_get_nodes_by_type($params,&$smarty) { |
| 4 | global $node; |
| 5 | $type=$params['type']; |
| 6 | if ($params['listing_amount']=='all') $listing_amount='2323232323232323'; |
| 7 | else $listing_amount=$params['listing_amount']; |
| 8 | if (empty($params['offset'])) $offset=0; |
| 9 | else $offset=$params['offset']; |
| 10 | if ($params['vector']) { |
| 11 | $vector=addslashes($params['vector']); |
| 12 | } |
| 13 | if ($params['orderby']) { |
| 14 | $orderby=addslashes($params['orderby']); |
| 15 | } |
| 16 | |
| 17 | global $db,$node; |
| 18 | $node_id=$node['node_id']; |
| 19 | $user_id=$_SESSION['user_id']; |
| 20 | $q="select parent.node_name as parent_name,users.*,nodes.*,node_access.node_user_subchild_count from nodes left join nodes as parent on parent.node_id=nodes.node_parent left join node_access on node_access.node_id=nodes.node_id and node_access.user_id='$user_id' left join users on users.user_id=nodes.node_creator where "; |
| 21 | if ($vector) $q.="nodes.node_vector like '$vector%' and"; |
| 22 | $q.=" nodes.template_id='$type' and nodes.node_system_access!='private'"; |
| 23 | if ($orderby) $q.=" order by $orderby "; |
| 24 | else $q.=" order by nodes.node_id desc "; |
| 25 | $q.= " LIMIT $offset,$listing_amount "; |
| 26 | $set=$db->query($q); |
| 27 | |
| 28 | while ($set->next()) $pole[]=$set->getRecord(); |
| 29 | $smarty->assign('get_nodes_by_type',$pole); |
| 30 | |
| 31 | } |
| 32 | ?> |