# ================================================================== # Gossamer Forum - Advanced web community # # Website : http://gossamer-threads.com/ # Support : http://gossamer-threads.com/scripts/support/ # Revision : $Id: Admin.pm,v 1.15 2002/03/04 07:40:26 jagerman Exp $ # # Copyright (c) 2001 Gossamer Threads Inc. All Rights Reserved. # Redistribution in part or in whole strictly prohibited. Please # see LICENSE file for full details. # ================================================================== package GForum::Admin; # ================================================================== use strict; use GForum qw/$DB $CFG/; use GT::SQL::Admin; use vars qw/@ISA $ERROR_MESSAGE $VERSION $DEBUG $FONT $ROW_COLOR1 $ROW_COLOR2/; # This line is annoying constants GT::SQL::Admin uses. @ISA = qw/GT::SQL::Admin/; $VERSION = sprintf "%d.%03d", q$Revision: 1.15 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0; $ERROR_MESSAGE = 'GT::SQL'; $ROW_COLOR1 = $GT::SQL::Admin::ROW_COLOR1; $ROW_COLOR2 = $GT::SQL::Admin::ROW_COLOR2; $FONT = $GT::SQL::Admin::FONT; sub _check_opts { # ------------------------------------------------------------------- # This is overriden to allow searching by moderators, subscribers, or system group permissions # for the Forum table. # my $self = shift; my $sel = 0; my $cols = $self->{table}->cols; for (keys %{$self->{cgi}}) { if ($self->{cgi}->{$_} =~ /\S/ and exists $cols->{$_}) { $sel = 1; last; } } if (exists $self->{cgi}->{query} and $self->{cgi}->{query} =~ /\S/ or exists $self->{cgi}->{keyword} and $self->{cgi}->{keyword} =~ /\S/) { $sel = 1; } my $prefix = $DB->prefix; if (!$sel and $self->{table}->name eq $prefix . 'Forum' and $self->{cgi}->{'ForumModerator.user_id_fk'} || $self->{cgi}->{'ForumSubscriber.user_id_fk'}) { $sel = 1; } if (!$sel and $self->{table}->name eq $prefix . 'User' and exists $self->{cgi}->{'UserGroup.group_id_fk'}) { $sel = 1; } return $sel; } sub _buttons { # ------------------------------------------------------------------- # Adds a warning message to delete Users, Posts, and Categories. # my $self = shift; my $name = shift; my $table = $self->{record}; my $msg = ''; if ($self->{record} eq 'Forum' and $name eq 'Delete') { $msg = qq~

Warning: deleting a forum will also delete all posts contained within that forum!

~; } elsif ($self->{record} eq 'Category' and $name eq 'Delete') { $msg = qq~

Warning: deleting a category will also delete all forums in that category and any posts in those forums!

~; } elsif ($self->{record} eq 'Post' and $name eq 'Delete') { $msg = qq~

Warning: deleting a post will also delete any direct or indirect replies to that post!

~; } elsif ($self->{record} eq 'Forum' and $name eq 'Add' and not $DB->table('Category')->count) { return ''; } my $ret = ''; $table = 'Group' if $table eq 'Grouping'; return qq~\n$ret
$msg
\n~; } sub search_results { my $self = shift; return $self->SUPER::search_results(@_) unless $self->{cgi}->{db} and $self->{cgi}->{db} eq 'User' and not ($self->{cgi}->{display} and $self->{cgi}->{display} eq 'details'); print $self->{in}->header; # Make sure the user passed in some values to search on $self->_check_opts or return $self->search_form ("You must specify at least one search term."); # Format the cgi for searching $self->format_search_cgi; # Do the search and count the results. my $sth = $self->{table}->query_sth($self->{cgi}); my $hits = $self->{table}->hits(); if ($hits == 0) { return $self->search_form ("Your search did not match any records."); } #elsif ($hits == 1) { # return $self->SUPER::search_results(); #} print $self->_start_html({ title => "Search Results" }); print $self->_header("Search Results", "Your search returned $hits " . ($hits == 1 ? 'result.' : 'results.')); my $speedbar = ''; my $name = GT::CGI->url(remove_empty => 1); if ($hits > ($self->{cgi}->{mh} || 25)) { $speedbar = "

Pages: "; $speedbar .= $self->{html}->toolbar($self->{cgi}->{nh} || 1, $self->{cgi}->{mh} || 25, $hits, $name); $speedbar .= "

\n"; print $speedbar; } if ( $self->{in}->param('dr') and $self->{in}->param('dr') eq 'rows' ) { print qq!

!; print "", $self->{html}->display_row_cols({ mode => 'search_results' }), ""; my $i = 0; while (my $result = $sth->fetchrow_hashref) { print "", $self->{html}->display_row({ mode => 'search_results', values => $result }), ""; } print "
"; } else { my $font = ""; print qq|
|; print qq||; while (my $result = $sth->fetchrow_hashref) { my ($username, $email, $status) = map $self->{html}->display_text({ name => $_, def => $self->{table}->{schema}->{cols}->{$_}, value => $result->{$_} }), qw/user_username user_email user_status/; my $enabled = $result->{user_enabled} ? 'Yes' : 'No'; my $validated = (not $result->{user_val_code} and $result->{user_admin_validated}) ? 'Yes' : 'No'; $username = "$username"; $email = "$email"; print qq' '; } print qq|
${font}Username${font}Status${font}Enabled${font}Validated${font}E-mail 
$font$username $font$status $font$enabled $font$validated $font$email $fontDetails | Modify | Delete
|; } print $speedbar if $speedbar; print "

", $self->_footer; print $self->_end_html; } 1;