Database efficiency improvements.
This commit is contained in:
parent
547e10affd
commit
f0ebc98582
12 changed files with 100 additions and 52 deletions
|
|
@ -25,10 +25,6 @@ use WebGUI::SQL;
|
|||
use WebGUI::URL;
|
||||
use WebGUI::User;
|
||||
|
||||
our %status =("Approved"=>WebGUI::International::get(560),
|
||||
"Denied"=>WebGUI::International::get(561),
|
||||
"Pending"=>WebGUI::International::get(562));
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _deleteReplyTree {
|
||||
my ($sth, %data, $messageId);
|
||||
|
|
@ -474,7 +470,7 @@ sub showReplyTree {
|
|||
$html .= '><td class="tableData"><a href="'.WebGUI::URL::page('func=showMessage&mid='.$data[0].'&wid='.
|
||||
$message{wobjectId}).'">'.substr($data[1],0,30).'</a>';
|
||||
if ($data[4] == $session{user}{userId}) {
|
||||
$html .= ' ('.$status{$data[5]}.')';
|
||||
$html .= ' ('.status($data[5]).')';
|
||||
}
|
||||
$html .= '</td><td class="tableData"><a href="'.
|
||||
WebGUI::URL::page('op=viewProfile&uid='.$data[4]).'">'.$data[2].
|
||||
|
|
@ -533,7 +529,7 @@ sub showThreads {
|
|||
$data{messageId}.'&wid='.$session{form}{wid}.'&sid='.$session{form}{sid}).'">'.substr($data{subject},0,30).
|
||||
'</a>';
|
||||
if ($data{userId} == $session{user}{userId}) {
|
||||
$html .= ' ('.$status{$data{status}}.')';
|
||||
$html .= ' ('.status($data{status}).')';
|
||||
}
|
||||
$html .= '</td><td class="tableData"><a href="'.
|
||||
WebGUI::URL::page('op=viewProfile&uid='.$data{userId}).'">'.$data{username}.
|
||||
|
|
@ -561,6 +557,17 @@ sub showThreads {
|
|||
return $html;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub status {
|
||||
if ($_[0] eq "Approved") {
|
||||
return WebGUI::International::get(560);
|
||||
} elsif ($_[0] eq "Denied") {
|
||||
return WebGUI::International::get(561);
|
||||
} elsif ($_[0] eq "Pending") {
|
||||
return WebGUI::International::get(562);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub traverseReplyTree {
|
||||
my ($sth, @data, $html, $depth, $i);
|
||||
|
|
@ -578,7 +585,7 @@ sub traverseReplyTree {
|
|||
$html .= '><td class="tableData">'.$depth.'<a href="'.WebGUI::URL::page('func=showMessage&mid='.$data[0]
|
||||
.'&wid='.$session{form}{wid}.'&sid='.$session{form}{sid}).'">'.substr($data[1],0,30).'</a>';
|
||||
if ($data[4] == $session{user}{userId}) {
|
||||
$html .= ' ('.$status{$data[5]}.')';
|
||||
$html .= ' ('.status($data[5]).')';
|
||||
}
|
||||
$html .= '</td><td class="tableData"><a href="'.WebGUI::URL::page('op=viewProfile&uid='.$data[4]).'">'
|
||||
.$data[2].'</a></td><td class="tableData">'.epochToHuman($data[3],"%z %Z").'</td></tr>';
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ package WebGUI::Macro::AdminBar;
|
|||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use strict qw(refs vars);
|
||||
use Tie::IxHash;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::International;
|
||||
|
|
@ -31,7 +31,10 @@ sub _replacement {
|
|||
$hash{WebGUI::URL::page('op=selectPackageToDeploy')} = WebGUI::International::get(376);
|
||||
}
|
||||
foreach $key (keys %{$session{wobject}}) {
|
||||
$hash{WebGUI::URL::page('func=edit&wid=new&namespace='.$key)} = $session{wobject}{$key};
|
||||
my $cmd = "\$WebGUI::Wobject::".$key."::name";
|
||||
#$hash{WebGUI::URL::page('func=edit&wid=new&namespace='.$key)} = $session{wobject}{$key};
|
||||
$hash{WebGUI::URL::page('func=edit&wid=new&namespace='.$key)} = eval($cmd);
|
||||
WebGUI::ErrorHandler::warn("Could use wobject $key because: ".$@) if ($@);
|
||||
}
|
||||
%hash = sortHash(%hash);
|
||||
%hash = (%{{WebGUI::URL::page()=>WebGUI::International::get(1)}},%hash);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,11 @@ use WebGUI::SQL;
|
|||
sub _replacement {
|
||||
my (@param, $temp);
|
||||
@param = WebGUI::Macro::getParams($1);
|
||||
($temp) = WebGUI::SQL->quickArray("select urlizedTitle from page where pageId=$session{setting}{defaultPage}");
|
||||
if ($session{setting}{defaultPage} == $session{page}{pageId}) {
|
||||
$temp = $session{page}{urlizedTitle};
|
||||
} else {
|
||||
($temp) = WebGUI::SQL->quickArray("select urlizedTitle from page where pageId=$session{setting}{defaultPage}");
|
||||
}
|
||||
$temp = WebGUI::URL::gateway($temp);
|
||||
if ($param[0] ne "linkonly") {
|
||||
$temp = '<a class="homeLink" href="'.$temp.'">';
|
||||
|
|
@ -36,7 +40,7 @@ sub _replacement {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my ($output, $temp, @param);
|
||||
my ($output);
|
||||
$output = $_[0];
|
||||
$output =~ s/\^H\((.*?)\)\;/_replacement($1)/ge;
|
||||
$output =~ s/\^H\;/_replacement()/ge;
|
||||
|
|
|
|||
|
|
@ -17,18 +17,21 @@ use WebGUI::Session;
|
|||
use WebGUI::URL;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my ($output, $temp, $f);
|
||||
$output = $_[0];
|
||||
sub _replacement {
|
||||
my ($f);
|
||||
$f = WebGUI::HTMLForm->new(1);
|
||||
$f->hidden("op","search");
|
||||
$f->text("atLeastOne",'',$session{form}{atLeastOne});
|
||||
$f->submit(WebGUI::International::get(364));
|
||||
$temp = $f->print;
|
||||
$output =~ s/\^\?\;/$temp/g;
|
||||
return $output;
|
||||
return $f->print;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my ($output);
|
||||
$output = $_[0];
|
||||
$output =~ s/\^\?\;/_replacement()/ge;
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -307,6 +307,9 @@ sub new {
|
|||
$class = shift;
|
||||
$sql = shift;
|
||||
$dbh = shift || $WebGUI::Session::session{dbh};
|
||||
if ($WebGUI::Session::session{setting}{showDebug}) {
|
||||
push(@{$WebGUI::Session::session{SQLquery}},$sql);
|
||||
}
|
||||
$sth = $dbh->prepare($sql) or WebGUI::ErrorHandler::fatalError("Couldn't prepare statement: ".$sql." : ". DBI->errstr);
|
||||
$sth->execute or WebGUI::ErrorHandler::fatalError("Couldn't execute statement: ".$sql." : ". DBI->errstr);
|
||||
bless ({_sth => $sth}, $class);
|
||||
|
|
|
|||
|
|
@ -185,12 +185,13 @@ sub _loadWobjects {
|
|||
next if (isIn($namespace, split(/,/,$exclude)));
|
||||
$cmd = "WebGUI::Wobject::".$namespace."::uiLevel";
|
||||
next if (eval($cmd) > $session{user}{uiLevel});
|
||||
$cmd = "\$WebGUI::Wobject::".$namespace."::name";
|
||||
$session{wobject}{$namespace} = eval($cmd);
|
||||
if ($@) {
|
||||
WebGUI::ErrorHandler::warn("No name method in wobject: $namespace. ".$@);
|
||||
$session{wobject}{$namespace} = "ERROR: ".$namespace;
|
||||
}
|
||||
# $cmd = "\$WebGUI::Wobject::".$namespace."::name";
|
||||
# $session{wobject}{$namespace} = eval($cmd);
|
||||
$session{wobject}{$namespace} = $namespace;
|
||||
# if ($@) {
|
||||
# WebGUI::ErrorHandler::warn("No name method in wobject: $namespace. ".$@);
|
||||
# $session{wobject}{$namespace} = "ERROR: ".$namespace;
|
||||
# }
|
||||
} else {
|
||||
WebGUI::ErrorHandler::warn("Wobject failed to compile: $namespace. ".$@);
|
||||
$session{wobject}{$namespace} = "ERROR: ".$namespace;
|
||||
|
|
@ -226,8 +227,7 @@ sub end {
|
|||
#-------------------------------------------------------------------
|
||||
sub httpHeader {
|
||||
unless ($session{header}{charset}) {
|
||||
my ($charset) = WebGUI::SQL->quickArray("select characterSet from language where languageId=".$session{user}{language});
|
||||
$session{header}{charset} = $charset || "ISO-8859-1";
|
||||
$session{header}{charset} = $session{language}{characterSet} || "ISO-8859-1";
|
||||
}
|
||||
if ($session{header}{filename} && $session{header}{mimetype} eq "text/html") {
|
||||
$session{header}{mimetype} = "application/octet-stream";
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ sub process {
|
|||
strict=>0
|
||||
);
|
||||
while (my ($section, $hash) = each %session) {
|
||||
next unless (ref $hash eq 'HASH');
|
||||
while (my ($key, $value) = each %$hash) {
|
||||
if (ref $value eq 'ARRAY') {
|
||||
next;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ use WebGUI::URL;
|
|||
use WebGUI::Utility;
|
||||
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Wobject
|
||||
|
|
|
|||
|
|
@ -158,13 +158,17 @@ sub www_view {
|
|||
$var{"attachment.url"} = $file->getURL;
|
||||
$var{"attachment.name"} = $file->getFilename;
|
||||
}
|
||||
($var{"replies.count"}) = WebGUI::SQL->quickArray("select count(*) from discussion where wobjectId=".$_[0]->get("wobjectId"));
|
||||
$var{"replies.URL"} = WebGUI::URL::page('func=showMessage&wid='.$_[0]->get("wobjectId"));
|
||||
$var{"replies.label"} = WebGUI::International::get(28,$namespace);
|
||||
$var{"post.URL"} = WebGUI::URL::page('func=post&mid=new&wid='.$_[0]->get("wobjectId"));
|
||||
$var{"post.label"} = WebGUI::International::get(24,$namespace);
|
||||
if ($_[0]->get("allowDiscussion")) {
|
||||
($var{"replies.count"}) = WebGUI::SQL->quickArray("select count(*) from discussion
|
||||
where wobjectId=".$_[0]->get("wobjectId"));
|
||||
$var{"replies.URL"} = WebGUI::URL::page('func=showMessage&wid='.$_[0]->get("wobjectId"));
|
||||
$var{"replies.label"} = WebGUI::International::get(28,$namespace);
|
||||
$var{"post.URL"} = WebGUI::URL::page('func=post&mid=new&wid='.$_[0]->get("wobjectId"));
|
||||
$var{"post.label"} = WebGUI::International::get(24,$namespace);
|
||||
}
|
||||
return $_[0]->processMacros($_[0]->processTemplate($_[0]->get("templateId"),\%var));
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,11 +29,6 @@ our @ISA = qw(WebGUI::Wobject);
|
|||
our $namespace = "MessageBoard";
|
||||
our $name = WebGUI::International::get(2,$namespace);
|
||||
|
||||
our %status =("Approved"=>WebGUI::International::get(560),
|
||||
"Denied"=>WebGUI::International::get(561),
|
||||
"Pending"=>WebGUI::International::get(562));
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub duplicate {
|
||||
my ($w);
|
||||
|
|
@ -50,6 +45,17 @@ sub set {
|
|||
$_[0]->SUPER::set($_[1],[qw(templateId messagesPerPage)]);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub status {
|
||||
if ($_[0] eq "Approved") {
|
||||
return WebGUI::International::get(560);
|
||||
} elsif ($_[0] eq "Denied") {
|
||||
return WebGUI::International::get(561);
|
||||
} elsif ($_[0] eq "Pending") {
|
||||
return WebGUI::International::get(562);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
|
||||
|
|
@ -124,7 +130,7 @@ sub www_view {
|
|||
"message.url" => WebGUI::URL::page('func=showMessage&mid='.$data->{messageId}.'&wid='.$_[0]->get("wobjectId")),
|
||||
"message.subject" => substr($data->{subject},0,30),
|
||||
"message.currentUser" => ($data->{userId} == $session{user}{userId}),
|
||||
"message.status" => $status{$data->{status}},
|
||||
"message.status" => status($data->{status}),
|
||||
"message.userProfile" => WebGUI::URL::page('op=viewProfile&uid='.$data->{userId}),
|
||||
"message.username" => $data->{username},
|
||||
"message.date" => epochToHuman($data->{dateOfPost}),
|
||||
|
|
|
|||
|
|
@ -34,10 +34,6 @@ our @ISA = qw(WebGUI::Wobject);
|
|||
our $namespace = "USS";
|
||||
our $name = WebGUI::International::get(29,$namespace);
|
||||
|
||||
our %submissionStatus =("Approved"=>WebGUI::International::get(560),
|
||||
"Denied"=>WebGUI::International::get(561),
|
||||
"Pending"=>WebGUI::International::get(562));
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub duplicate {
|
||||
my ($sth, $file, %row, $newSubmissionId, $w);
|
||||
|
|
@ -82,6 +78,17 @@ sub set {
|
|||
submissionTemplateId templateId karmaPerSubmission allowDiscussion)]);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub status {
|
||||
if ($_[0] eq "Approved") {
|
||||
return WebGUI::International::get(560);
|
||||
} elsif ($_[0] eq "Denied") {
|
||||
return WebGUI::International::get(561);
|
||||
} elsif ($_[0] eq "Pending") {
|
||||
return WebGUI::International::get(562);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_approveSubmission {
|
||||
my (%submission);
|
||||
|
|
@ -181,7 +188,8 @@ sub www_edit {
|
|||
$f->group("groupToApprove",WebGUI::International::get(1,$namespace),[$groupToApprove]);
|
||||
$f->group("groupToContribute",WebGUI::International::get(2,$namespace),[$_[0]->get("groupToContribute")]);
|
||||
$f->integer("submissionsPerPage",WebGUI::International::get(6,$namespace),$submissionsPerPage);
|
||||
$f->select("defaultStatus",\%submissionStatus,WebGUI::International::get(563),[$defaultStatus]);
|
||||
$f->select("defaultStatus",{Approved=>status('Approved'),Denied=>status('Denied'),Pending=>status('Pending')}
|
||||
,WebGUI::International::get(563),[$defaultStatus]);
|
||||
if ($session{setting}{useKarma}) {
|
||||
$f->integer("karmaPerSubmission",WebGUI::International::get(30,$namespace),$_[0]->get("karmaPerSubmission"));
|
||||
} else {
|
||||
|
|
@ -395,7 +403,7 @@ sub www_viewSubmission {
|
|||
$var{"date.epoch"} = $submission->{dateSubmitted};
|
||||
$var{"date.human"} = epochToHuman($submission->{dateSubmitted});
|
||||
$var{"status.label"} = WebGUI::International::get(14,$namespace);
|
||||
$var{"status.status"} = $submissionStatus{$submission->{status}};
|
||||
$var{"status.status"} = status($submission->{status});
|
||||
$var{"views.label"} = WebGUI::International::get(514);
|
||||
$var{"views.count"} = $submission->{views};
|
||||
$var{canPost} = WebGUI::Privilege::isInGroup($_[0]->get("groupToContribute"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue