package WebGUI::Macro::Shared; #------------------------------------------------------------------- # WebGUI is Copyright 2001 Plain Black Software. #------------------------------------------------------------------- # Please read the legal notices (docs/legal.txt) and the license # (docs/license.txt) that came with this distribution before using # this software. #------------------------------------------------------------------- # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- use Exporter; use Tie::CPHash; use WebGUI::Privilege; use WebGUI::Session; use WebGUI::SQL; our @ISA = qw(Exporter); our @EXPORT = qw(&traversePageTree); #------------------------------------------------------------------- sub process { return $_[0]; } #------------------------------------------------------------------- sub traversePageTree { my ($sth, @data, $output, $depth, $i, $toLevel); if ($_[2] > 0) { $toLevel = $_[2]; } else { $toLevel = 99; } for ($i=1;$i<=$_[1];$i++) { $depth .= "   "; } if ($_[1] < $toLevel) { $sth = WebGUI::SQL->read("select urlizedTitle, title, pageId from page where parentId='$_[0]' order by sequenceNumber",$session{dbh}); while (@data = $sth->array) { if (WebGUI::Privilege::canViewPage($data[2])) { $output .= $depth.''.$data[1].'
'; $output .= traversePageTree($data[2],$_[1]+1,$_[2]); } } $sth->finish; } return $output; } 1;