Commit | Line | Data |
---|---|---|
e586807d H |
1 | <?php |
2 | ||
3 | function smarty_function_get_nodes_by_parent($params,&$smarty) { | |
4 | global $node; | |
5 | ||
6 | $parent=$params['parent']; | |
7 | $permissions=permissions::checkPermissions($parent); | |
8 | if (!$permissions['r']) { | |
9 | $error=$error_messages['READ_PERMISSION_ERROR']; | |
10 | return false; | |
11 | } | |
12 | ||
13 | if ($params['listing_amount']=='all') $listing_amount='232323233'; | |
14 | else $listing_amount=$params['listing_amount']; | |
15 | if (empty($params['offset'])) $offset=0; | |
16 | else $offset=$params['offset']; | |
17 | ||
18 | if ($params['orderby']) { | |
19 | $orderby=addslashes($params['orderby']); | |
20 | } | |
21 | ||
22 | global $db,$node; | |
23 | $node_id=$node['node_id']; | |
24 | $user_id=$_SESSION['user_id']; | |
25 | $q="select node_content.*,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 node_content on (node_content.node_id=nodes.node_id) left join users on users.user_id=nodes.node_creator where "; | |
26 | $q.=" nodes.node_parent='$parent' and nodes.node_system_access!='private'"; | |
27 | ||
28 | ||
29 | if ($_POST['template_event']=='filter_by') { | |
30 | if ($_POST['search_type']=='content') | |
31 | $sql_type.=" and node_content like '%".addslashes($_POST['node_content'])."%' "; | |
32 | else { | |
33 | $q2="select user_id from users where login='".$_POST['node_content']."'"; | |
34 | $userset=$db->query($q2); | |
35 | $userset->next(); | |
36 | $id=$userset->getString('user_id'); | |
37 | $sql_type=" and nodes.node_creator='$id'"; | |
38 | } | |
39 | $q.=$sql_type; | |
40 | } | |
41 | ||
42 | if ($orderby) $q.=" order by $orderby "; | |
43 | else $q.=" order by nodes.node_id desc "; | |
44 | $q.= " LIMIT $offset,$listing_amount "; | |
45 | $set=$db->query($q); | |
46 | while ($set->next()) $pole[]=$set->getRecord(); | |
47 | $smarty->assign('get_nodes_by_parent',$pole); | |
48 | ||
49 | } | |
50 | ?> |