Commit | Line | Data |
---|---|---|
e586807d H |
1 | <?php |
2 | ||
b42b2bf9 | 3 | function smarty_function_get_children($params,&$smarty) { |
e586807d | 4 | |
b42b2bf9 | 5 | global $db,$node; |
e586807d | 6 | |
b42b2bf9 | 7 | $node_id=$node['node_id']; |
e586807d | 8 | |
b42b2bf9 H |
9 | $listing_amount=$params['listing_amount']; |
10 | if (!is_numeric($listing_amount)) { | |
11 | $listing_amount=23; | |
12 | } | |
13 | $offset=$params['offset']; | |
14 | if (!is_numeric($offset)) { | |
15 | $offset=0; | |
16 | } | |
e586807d | 17 | |
b42b2bf9 H |
18 | if ($_POST['get_children_orderby']=="asc" || $params['orderby']=='asc') $orderby='asc'; |
19 | else $orderby='desc'; | |
e586807d | 20 | |
b42b2bf9 | 21 | $q="select node_access.last_visit,creator.node_name as creator,users.*,nodes.*,nodes.node_id as node_id from nodes |
e586807d | 22 | left join node_access on (nodes.node_id=node_access.node_id |
b42b2bf9 | 23 | and node_access.user_id='".$_SESSION['user_id']."') left join users on users.user_id=nodes.node_creator left join nodes as creator on nodes.node_creator=creator.node_id where nodes.node_parent='$node_id'"; |
e586807d H |
24 | |
25 | if (!empty($params['search'])) { | |
b42b2bf9 H |
26 | if ($params['search_type']=='content') $sql_type.=" and node_content like '%".addslashes($params['sea |
27 | rch'])."%' "; | |
28 | else { | |
29 | $id=nodes::getNodeByLogin($params['search']); | |
30 | $sql_type=" and nodes.node_creator='$id'"; | |
31 | } | |
32 | $q.=$sql_type; | |
33 | } | |
34 | if ($children_type=='4' || $params['orderby_type']=='time') $q.=" order by nodes.node_created $orderby limit $offset,$listing_amount"; | |
35 | else $q.=" order by nodes.template_id,nodes.node_name LIMIT $offset,$listing_amount"; | |
36 | $set=$db->query($q); | |
37 | ||
38 | while ($set->next()) { | |
39 | $get_children_array[]=$set->getRecord(); | |
40 | } | |
41 | ||
42 | $smarty->assign('get_children',$get_children_array); | |
43 | } | |
e586807d | 44 | ?> |