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