quote($_); } keys %cataccess); $and_cat_in = "AND tl.tpcatid IN ($in)"; } $sth = $dbh->prepare("SELECT tm.tpmapid, tm.tptopid, tm.itemid FROM topic_map tm, topic_list tl WHERE tm.tptopid=tl.tptopid AND tm.status='new' $and_cat_in LIMIT 50"); $sth->execute; if ($dbh->err) { return $dbh->errstr; } my %topic; while (my $map = $sth->fetchrow_hashref) { push @maps, $map; $topic{$map->{'tptopid'}} = undef; } unless (@maps) { return "Empty! ... no items are awaiting approval"; } my $top_in = join(",", keys %topic); $sth = $dbh->prepare("SELECT tptopid, tpcatid, topname FROM topic_list WHERE tptopid IN ($top_in)"); $sth->execute; if ($dbh->err) { return $dbh->errstr; } my %cat; while (my $top = $sth->fetchrow_hashref) { $topic{$top->{'tptopid'}} = $top; $cat{$top->{'tpcatid'}} = undef; } my $cat_in = join(",", keys %cat); $sth = $dbh->prepare("SELECT tpcatid, parent, catname FROM topic_cats WHERE tpcatid IN ($cat_in)"); $sth->execute; if ($dbh->err) { return $dbh->errstr; } while (my $cat = $sth->fetchrow_hashref) { $cat{$cat->{'tpcatid'}} = $cat; } $ret .= "
"; foreach my $map (@maps) { my $catid = $topic{$map->{'tptopid'}}->{'tpcatid'}; next unless ($cataccess{'all'} || $cataccess{$catid}); &load_cats_up($catid, \%cat); $ret .= "

"; my $fullcat; my $catup = $catid; while ($catup) { $fullcat = "$cat{$catup}->{'catname'} : $fullcat"; $catup = $cat{$catup}->{'parent'}; } $fullcat .= $topic{$map->{'tptopid'}}->{'topname'}; $ret .= "[$fullcat]"; $ret .= "
{'itemid'}\" TARGET=\"main\">$map->{'itemid'}"; my %opts = ("L" => "Leave", "A" => "Approve", "D" => "Deny"); foreach (qw(L A D)) { $ret .= "
{'tptopid'}:$map->{'itemid'}\" VALUE=\"$_\">$opts{$_}\n"; } } $ret .= "

"; return $ret; sub load_cats_up { my $catid = shift; my $hashref = shift; $catid += 0; while ($catid) { unless ($hashref->{$catid}) { $sth = $dbh->prepare("SELECT parent, catname FROM topic_cats WHERE tpcatid=$catid"); $sth->execute; my $cat = $sth->fetchrow_hashref; if ($cat) { $hashref->{$catid} = $cat; $catid = $cat->{'parent'} } } else { $catid = $hashref->{$catid}->{'parent'}; } } } _code?> link: htdocs/talkpost.bml post: htdocs/admin/topics/screen_links.bml _c?>