Commit | Line | Data |
---|---|---|
e586807d H |
1 | <?php |
2 | ||
3 | function smarty_function_get_threaded_children($params,&$smarty) { | |
4 | global $db, $error, $node; | |
5 | ||
6 | $offset=$params['offset']; | |
7 | $limit=$params['listing_amount']; | |
8 | ||
9 | if (!empty($params['search'])) { | |
10 | if ($params['search_type']=='content') $sql_type.=" and node_content like '%".addslashes($params['search'])."%' "; | |
11 | else { | |
12 | $q2="select user_id from users where login='".$params['search']."'"; | |
13 | $userset=$db->query($q2); | |
14 | $userset->next(); | |
15 | $id=$userset->getString('user_id'); | |
16 | $sql_type=" and nodes.node_creator='$id'"; | |
17 | } | |
18 | $q.=$sql_type; | |
19 | } | |
20 | if (!empty($params['time'])) $sql_type.=" and node_created >'".$params['time']."'"; | |
21 | if (empty($params['orderby']) OR $params['orderby']=='desc') { | |
22 | //$orderby="node_vector desc"; | |
23 | $orderby="concat(node_vector,'z') desc,depth"; | |
24 | } | |
25 | else { | |
26 | $orderby="node_vector asc"; | |
27 | } | |
28 | if ($params['link']=='yes') $q.="("; | |
29 | $q.="select nodes.node_id,node_name,node_external_access,node_system_access,node_children_count,node_creator,node_created,lastchild_created,k,node_views,node_descendant_count,lastdescendant_created,template_id,node_updated,length(node_vector) as depth,users.login,node_vector, node_content from nodes left join node_content on node_content.node_id=nodes.node_id left join users on users.user_id=nodes.node_creator where node_vector like '".$node['node_vector']."%' $sql_type and node_vector NOT LIKE '".$node['node_vector']."' order by $orderby LIMIT $offset,$limit"; | |
30 | ||
31 | if ($params['link']=='yes') { | |
32 | $q.=" ) UNION (select nodes.node_id,node_name,node_external_access,node_system_access,node_children_count,node_creator,node_created,lastchild_created,k,node_views,node_descendant_count,lastdescendant_created,template_id,node_updated,length(node_vector) as depth, | |
33 | users.login,dst_vector as node_vector,node_content from neurons left join nodes on neurons.src=nodes.node_id left join node_content on (node_content.node_id=nodes.node_id) left join users on users.user_id=nodes.node_creator where dst_vector like '".$node['node_vector']."%' $sql_type and dst_vector NOT LIKE '".$node['node_vector']."' order by $orderby LIMIT $offset,$limit)"; | |
34 | } | |
35 | ||
36 | if ($params['link']=='yes') $q.=" order by $orderby LIMIT $offset,$limit"; | |
37 | ||
38 | $result=$db->query($q); | |
39 | ||
40 | while ($result->next()) { | |
41 | $get_children_array[]=$result->getRecord(); | |
42 | } | |
43 | global $time_1, $time_2; | |
44 | $time_2=$result->getString('node_created'); | |
45 | $time_1=$get_children_array[0]['node_created']; | |
46 | ||
47 | $smarty->assign('get_threaded_children',$get_children_array); | |
48 | ||
49 | } | |
50 | ?> |