Hello Andy
Just got to try your plug in.. pretty nice..
Several small globals that I use, they may be worth assing..
All user list
sub {
# Displays all Users.
my $tags=shift;
my $search_db= $DB->table('Users');
my $nh = (ref $tags->{nh} ? ${$tags->{nh}} : $tags->{nh});
my $mh = (ref $tags->{maxhits} ? ${$tags->{maxhits}} : $tags->{maxhits});
my $offset = ($nh-1) * $mh;
$search_db->select_options ('ORDER BY Username ASC',"LIMIT $offset, $mh");
my $sth = $search_db->select;
my $output;
while (my $user = $sth->fetchrow_hashref) {
$output .= qq~<li><a href="$CFG->{db_cgi_url}/page.cgi?page=user&user=$user->{Username}">$user->{Username}</a></li> ~;
}
return $output;
}
All links in a given category
sub {
# all links in a given category.
require Links::SiteHTML;
my $catID = $_[0];
my $catname = $DB->table('Category')->select( ['Full_Name'], { ID => $catID } )->fetchrow;
my $cond = GT::SQL::Condition->new(
Full_Name => '=' => "$catname",
Full_Name => 'LIKE' => "$catname/%"
);
$cond->bool('OR');
my $cat_tbl = $DB->table('Category');
$cat_tbl->select_options('ORDER BY Full_Name DESC');
my $sth = $cat_tbl->select( $cond ) || die $GT::SQL::error;
my $output;
while (my $hit = $sth->fetchrow_hashref) {
my $links_sth = $DB->table('CatLinks')->select( { CategoryID =>$hit->{ID} } ) || die $GT::SQL::error;
while (my $hit2 = $links_sth->fetchrow_hashref) {
my $hit3 = $DB->table('Links')->get($hit2->{LinkID});
$output .= Links::SiteHTML::display('link', $hit3);
}
}
return $output;
}
Random link from a given category
sub {
my ($output,$sth,$hash,$cond);
my $catid = $_[0];
my $limit = $_[1] || 4;
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ("ORDER BY rand()", "LIMIT $limit");
my $all_ids = $DB->table('Category')->children($catid);
push @$all_ids, $catid;
$cond = GT::SQL::Condition->new('isValidated','=','Yes', 'CategoryID', 'IN', $all_ids);
$sth = $search_db->select ($cond);
while ($hash = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link', $hash);
}
return $output;
}
Directory map: a simple map of top few levels of directory
sub {
# will build a map for the directory.
my $tags = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Full_Name');
my $sth = $cat_db->select ( { FatherID => 0}, ['Full_Name','ID','Name'] );
my $output=qq~<table>~;
my $i=0;
while (my ($root_cat,$ID,$heading) = $sth->fetchrow_array) {
$i++;
my $url1 = $cat_db->as_url($root_cat);
$output.= qq~<tr valign=top><td width="100%" colspan="2"><h3><b><a href="$CFG->{build_root_url}/$url1">$heading</a></b></h3></td></tr>~;
$cat_db->select_options ('ORDER BY Full_Name');
my $sth2 = $cat_db->select ( { FatherID => $ID}, ['Full_Name','ID','Name'] );
while (my ($cat,$id,$heading1) = $sth2->fetchrow_array) {
# my $link_count = $DB->table('CatLinks')->count ( {CategoryID => $id});
my $url = $cat_db->as_url($cat);
$output .= qq~<tr valign=top><td width="25%"> </td><td width="75%"><a href="$CFG->{build_root_url}/$url">$heading1</a></td></tr>~; }
}
$output.="</table>";
return $output;
}
grand_total_cat
sub { return $DB->table('Category')->count; }
grand_total_newlinks
sub { $DB->table('Links')->count( { isNew => 'Yes' } ) }
grand_total_users
sub { return $DB->table('Users')->count; }
Regards
KaTaBd
Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory