function getLevels($id) { global $db; $result = array($id); $qString = "select parent_id from topics where id=".(int)$id; $qResult = pg_query($db, $qString); $checkId = pg_fetch_assoc($qResult); pg_free_result($qResult); $checkId = (int)$checkId['id']; if($checkId) { $result = array_merge($result,getLevels($checkId)); } return $result; } function getGroups($parent_id = 0, $lvl = 0,$currentGroup = 0, $currentTopic = 0, $currentComment = 0, $limitLvl = 0) { global $db; $params = array( 'comment', 'topic', 'group' ); $qString = "select id, name, description from topics where parent_id='.$parent_id.' order by pos asc"; $qResult = pg_query($db,$qString); $switch($lvl) { case 0: $currentValue = $currentGroup; break; case 1: $currentValue = $currentTopic; break; case 2: $currentValue = $currentComment; break; } while($row = pg_fetch_assoc($qResult)) { if($currentValue == $row['id']) { $cssStl = 'text-decorations: underline;'; } else { $cssStl = 'text-decorations: none;'; } $idChain = getLevels($row['id']); if(count($idChain)<4) { for($i = 0; $i < (4-count($idChain)); $i++) { $idChain = array_merge(array(0),$idChain); } } $url = ''; foreach($idChain as $cnt => $id) { if($id) { $url .= '&'.$params[$cnt].='='.$id; } } $aLink1 = ''; $aLink2 = ''; $topicsList .= '
'.$row['description'].'