diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm
index b62c997af..d152973ea 100644
--- a/lib/WebGUI.pm
+++ b/lib/WebGUI.pm
@@ -37,16 +37,24 @@ sub _generateDebug {
$debug .= '
'.$session{debug}{audit}.'
';
$debug .= '';
while (my ($section, $hash) = each %session) {
- while (my ($key, $value) = each %$hash) {
- if (ref $value eq 'ARRAY') {
- $value = '['.join(', ',@$value).']';
- } elsif (ref $value eq 'HASH') {
- $value = '{'.join(', ',map {"$_ => $value->{$_}"} keys %$value).'}';
+ if (ref $hash eq 'HASH') {
+ while (my ($key, $value) = each %$hash) {
+ if (ref $value eq 'ARRAY') {
+ $value = '['.join(', ',@$value).']';
+ } elsif (ref $value eq 'HASH') {
+ $value = '{'.join(', ',map {"$_ => $value->{$_}"} keys %$value).'}';
+ }
+ unless (lc($key) eq "password" || lc($key) eq "identifier") {
+ $debug .= '| '.$section.'.'.$key.': | '.$value.' | ';
+ }
+ }
+ } elsif (ref $hash eq 'ARRAY') {
+ my $i = 1;
+ foreach (@$hash) {
+ $debug .= '
| '.$section.'.'.$i.': | '.$_.' | ';
+ $i++;
}
- unless (lc($key) eq "password" || lc($key) eq "identifier") {
- $debug .= '
| '.$section.'.'.$key.': | '.$value.' | ';
- }
- }
+ }
$debug .= '
| |
';
}
$debug .='
';
diff --git a/lib/WebGUI/Discussion.pm b/lib/WebGUI/Discussion.pm
index 71d9be771..ea63f362d 100644
--- a/lib/WebGUI/Discussion.pm
+++ b/lib/WebGUI/Discussion.pm
@@ -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 .= '>'.substr($data[1],0,30).'';
if ($data[4] == $session{user}{userId}) {
- $html .= ' ('.$status{$data[5]}.')';
+ $html .= ' ('.status($data[5]).')';
}
$html .= ' | '.$data[2].
@@ -533,7 +529,7 @@ sub showThreads {
$data{messageId}.'&wid='.$session{form}{wid}.'&sid='.$session{form}{sid}).'">'.substr($data{subject},0,30).
'';
if ($data{userId} == $session{user}{userId}) {
- $html .= ' ('.$status{$data{status}}.')';
+ $html .= ' ('.status($data{status}).')';
}
$html .= ' | '.$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 .= '> | '.$depth.''.substr($data[1],0,30).'';
if ($data[4] == $session{user}{userId}) {
- $html .= ' ('.$status{$data[5]}.')';
+ $html .= ' ('.status($data[5]).')';
}
$html .= ' | '
.$data[2].' | '.epochToHuman($data[3],"%z %Z").' | ';
diff --git a/lib/WebGUI/Macro/AdminBar.pm b/lib/WebGUI/Macro/AdminBar.pm
index 46c6bf78c..374fa446c 100644
--- a/lib/WebGUI/Macro/AdminBar.pm
+++ b/lib/WebGUI/Macro/AdminBar.pm
@@ -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);
diff --git a/lib/WebGUI/Macro/H_homeLink.pm b/lib/WebGUI/Macro/H_homeLink.pm
index 46a5f9b6c..0a90e9bd3 100644
--- a/lib/WebGUI/Macro/H_homeLink.pm
+++ b/lib/WebGUI/Macro/H_homeLink.pm
@@ -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 = '';
@@ -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;
diff --git a/lib/WebGUI/Macro/Question_search.pm b/lib/WebGUI/Macro/Question_search.pm
index efae2eeeb..290ea0836 100644
--- a/lib/WebGUI/Macro/Question_search.pm
+++ b/lib/WebGUI/Macro/Question_search.pm
@@ -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;
diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm
index 21524e8e0..16379d380 100644
--- a/lib/WebGUI/SQL.pm
+++ b/lib/WebGUI/SQL.pm
@@ -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);
diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm
index dc6ee5ef2..19e746e1e 100644
--- a/lib/WebGUI/Session.pm
+++ b/lib/WebGUI/Session.pm
@@ -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";
diff --git a/lib/WebGUI/Template.pm b/lib/WebGUI/Template.pm
index 6eaad00b8..7671ed185 100644
--- a/lib/WebGUI/Template.pm
+++ b/lib/WebGUI/Template.pm
@@ -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;
diff --git a/lib/WebGUI/Wobject.pm b/lib/WebGUI/Wobject.pm
index 96fb8913a..a17a40c09 100644
--- a/lib/WebGUI/Wobject.pm
+++ b/lib/WebGUI/Wobject.pm
@@ -32,6 +32,7 @@ use WebGUI::URL;
use WebGUI::Utility;
+
=head1 NAME
Package WebGUI::Wobject
diff --git a/lib/WebGUI/Wobject/Article.pm b/lib/WebGUI/Wobject/Article.pm
index ed470f1de..5b1ef34d4 100644
--- a/lib/WebGUI/Wobject/Article.pm
+++ b/lib/WebGUI/Wobject/Article.pm
@@ -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;
diff --git a/lib/WebGUI/Wobject/MessageBoard.pm b/lib/WebGUI/Wobject/MessageBoard.pm
index 4b3ff330b..37081d467 100644
--- a/lib/WebGUI/Wobject/MessageBoard.pm
+++ b/lib/WebGUI/Wobject/MessageBoard.pm
@@ -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}),
diff --git a/lib/WebGUI/Wobject/USS.pm b/lib/WebGUI/Wobject/USS.pm
index 58e0d1dcb..c674731e9 100644
--- a/lib/WebGUI/Wobject/USS.pm
+++ b/lib/WebGUI/Wobject/USS.pm
@@ -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"));