| 1 | <?php |
| 2 | function smarty_function_get_k_filtred_nodes($params,&$smarty) { |
| 3 | |
| 4 | global $db,$node; |
| 5 | |
| 6 | $user_id = $_SESSION['user_id']; |
| 7 | $node_id = 2472165; |
| 8 | $q="select src from neurons where synapse_creator='$user_id' and dst='$node_id'"; |
| 9 | |
| 10 | $set=$db->query($q); |
| 11 | while ($set->next()) { |
| 12 | $k_filtred_nodes_array[0][]=$set->getRecord(); |
| 13 | } |
| 14 | |
| 15 | // get k |
| 16 | |
| 17 | if (is_numeric($params['offset'])) $offset=$params['offset']; |
| 18 | else $offset=0; |
| 19 | if (is_numeric($params['listing_amount'])) $listing_amount=$params['listing_amount']; |
| 20 | else $listing_amount=DEFAULT_LISTING_AMOUNT; |
| 21 | if (!is_numeric($_POST['interval'])) $interval=1; |
| 22 | else $interval = $_POST['interval']; |
| 23 | if ($params['vector']) { |
| 24 | $vector=$params['vector']; |
| 25 | $interval=365; |
| 26 | } |
| 27 | else $vector="00"; |
| 28 | |
| 29 | $q="select node_content.node_content,nodes.*,parent.node_name as parent_name,users.login as creator |
| 30 | from nodes left join node_content on node_content.node_id=nodes.node_id left join nodes as parent on nodes.node_parent=parent.node_id |
| 31 | left join users on users.user_id=nodes.node_creator where nodes.node_created>now()-interval $interval day |
| 32 | and nodes.node_vector like '$vector%' and nodes.k>0 and nodes.node_system_access!='private' order by nodes.k desc limit $offset,$listing_amount"; |
| 33 | |
| 34 | $set=$db->query($q); |
| 35 | while ($set->next()) { |
| 36 | $k_filtred_nodes_array[1][]=$set->getRecord(); |
| 37 | } |
| 38 | |
| 39 | $smarty->assign('get_k_filtred_nodes',$k_filtred_nodes_array); |
| 40 | |
| 41 | } |
| 42 | ?> |