diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt
index 891738927..cbad12a30 100644
--- a/docs/changelog/6.x.x.txt
+++ b/docs/changelog/6.x.x.txt
@@ -29,6 +29,13 @@
- fix: not set UTF-8 in setup page
- fix: 6.99 nothing write to assetData.groupIdView & assetData.groupIdEdit
- fix: Insert A Link page has no head & body tags has no style
+ - fix: Username blank when editing user Visitor
+ - fix: Thread Count is off in the Collaboration system
+ - Fixed an indexing problem with Product assets.
+ - fix: Reply count off when restoring from trash
+ - fix: Karma not spent properly
+ - fix: Avatar Message Board Template Not Working
+
6.99.2
- fix - demo.plainblack.com getting started
diff --git a/docs/upgrades/templates-6.99.3/wgtemplate_default_submission.tmpl b/docs/upgrades/templates-6.99.3/wgtemplate_default_submission.tmpl
index 248884be5..aad73ab26 100644
--- a/docs/upgrades/templates-6.99.3/wgtemplate_default_submission.tmpl
+++ b/docs/upgrades/templates-6.99.3/wgtemplate_default_submission.tmpl
@@ -8,6 +8,11 @@
+
+
+

+
+
:
@@ -91,7 +96,12 @@
-
+
+
+
+ |
+
+ |
:
@@ -101,11 +111,12 @@
:
|
-
+ |
:
[  |  ]
+
:
|
@@ -151,7 +162,12 @@
-
+
+
+
+ |
+
+ |
:
@@ -161,11 +177,12 @@
:
|
-
+ |
:
[  |  ]
+
:
|
diff --git a/docs/upgrades/templates-6.99.3/wgtemplate_default_thread.tmpl b/docs/upgrades/templates-6.99.3/wgtemplate_default_thread.tmpl
index 39b7e7e86..ce5c33adc 100644
--- a/docs/upgrades/templates-6.99.3/wgtemplate_default_thread.tmpl
+++ b/docs/upgrades/templates-6.99.3/wgtemplate_default_thread.tmpl
@@ -27,7 +27,12 @@
-
+
+
+

+
+
+
:
@@ -87,7 +92,12 @@
-
+
+
+

+
+
+
:
@@ -243,4 +253,4 @@
font-size: 11px;
padding: 3px;
}
-
\ No newline at end of file
+
diff --git a/docs/upgrades/templates-6.99.3/wgtemplate_request_tracker_post_template.tmpl b/docs/upgrades/templates-6.99.3/wgtemplate_request_tracker_post_template.tmpl
index 1e7a02752..f1daa1cd1 100644
--- a/docs/upgrades/templates-6.99.3/wgtemplate_request_tracker_post_template.tmpl
+++ b/docs/upgrades/templates-6.99.3/wgtemplate_request_tracker_post_template.tmpl
@@ -8,6 +8,11 @@
+
+
+

+
+
:
@@ -96,7 +101,12 @@
-
+
+
+
+ |
+
+ |
:
@@ -106,11 +116,12 @@
:
|
-
+ |
:
[  |  ]
-
+
+
|
@@ -155,7 +166,12 @@
-
+
+
+
+ |
+
+ |
:
@@ -165,11 +181,12 @@
:
|
-
+ |
:
[  |  ]
-
+
+
|
@@ -344,4 +361,4 @@ display:block;
font-family:arial;
font-size:9pt;
}
-
\ No newline at end of file
+
diff --git a/docs/upgrades/upgrade_6.99.2-6.99.3.pl b/docs/upgrades/upgrade_6.99.2-6.99.3.pl
index 521579f2f..586401ac7 100644
--- a/docs/upgrades/upgrade_6.99.2-6.99.3.pl
+++ b/docs/upgrades/upgrade_6.99.2-6.99.3.pl
@@ -20,12 +20,18 @@ my $quiet; # this line required
my $session = start(); # this line required
+addAssetIndex();
fixCs();
fixCss();
fixSpectre();
finish($session); # this line required
+#-------------------------------------------------
+sub addAssetIndex {
+ print "\tAdding a new asset index.\n" unless ($quiet);
+ $session->db->write("alter table asset add index state_lineage (state,lineage)");
+}
#-------------------------------------------------
sub fixSpectre {
diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm
index bd187e666..6807875eb 100644
--- a/lib/WebGUI/Asset/Post.pm
+++ b/lib/WebGUI/Asset/Post.pm
@@ -714,6 +714,13 @@ sub postProcess {
#-------------------------------------------------------------------
+sub publish {
+ my $self = shift;
+ $self->getThread->sumReplies;
+}
+
+#-------------------------------------------------------------------
+
sub purge {
my $self = shift;
my $sth = $self->session->db->read("select storageId from Post where assetId=".$self->session->db->quote($self->getId));
@@ -772,6 +779,11 @@ sub rate {
my ($sum) = $self->session->db->quickArray("select sum(rating) from Post_rating where assetId=".$self->session->db->quote($self->getId));
$self->update({rating=>$sum});
$self->getThread->rate($rating);
+ if ($self->session->setting->get("useKarma")) {
+ $self->session->user->karma(-$self->getThread->getParent->get("karmaSpentToRate"), "Rated Post ".$self->getId, "Rated a CS Post.");
+ my $u = WebGUI::User->new($self->session, $self->get("ownerUserId"));
+ $u->karma($self->getThread->getParent->get("karmaRatingMultiplier"), "Post ".$self->getId." Rated by ".$self->session->user->userId, "Had post rated.");
+ }
}
}
@@ -847,14 +859,14 @@ sub setStatusUnarchived {
=head2 trash
-Moves post to the trash and decrements reply counter on thread.
+Moves post to the trash and updates reply counter on thread.
=cut
sub trash {
my $self = shift;
$self->SUPER::trash;
- $self->getThread->decrementReplies if ($self->isReply);
+ $self->getThread->sumReplies if ($self->isReply);
if ($self->getThread->get("lastPostId") eq $self->getId) {
my $threadLineage = $self->getThread->get("lineage");
my ($id, $date) = $self->session->db->quickArray("select Post.assetId, Post.dateSubmitted from Post, asset where asset.lineage like ".$self->session->db->quote($threadLineage.'%')." and Post.assetId<>".$self->session->db->quote($self->getId)." and asset.assetId=Post.assetId and asset.state='published' order by Post.dateSubmitted desc");
diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm
index b53725488..45fc4565a 100644
--- a/lib/WebGUI/Asset/Post/Thread.pm
+++ b/lib/WebGUI/Asset/Post/Thread.pm
@@ -77,20 +77,6 @@ sub createSubscriptionGroup {
});
}
-#-------------------------------------------------------------------
-
-=head2 decrementReplies ( )
-
-Deccrements this reply counter.
-
-=cut
-
-sub decrementReplies {
- my $self = shift;
- $self->update({replies=>$self->get("replies")-1});
- $self->getParent->decrementReplies;
-}
-
#-------------------------------------------------------------------
sub definition {
my $class = shift;
@@ -426,7 +412,7 @@ The id of the reply that caused the replies counter to be incremented.
sub incrementReplies {
my ($self, $dateOfReply, $replyId) = @_;
- $self->update({replies=>$self->get("replies")+1, lastPostId=>$replyId, lastPostDate=>$dateOfReply});
+ $self->update({replies=>$self->getDescendantCount, lastPostId=>$replyId, lastPostDate=>$dateOfReply});
$self->getParent->incrementReplies($dateOfReply,$replyId);
}
@@ -659,16 +645,30 @@ sub subscribe {
#-------------------------------------------------------------------
+=head2 sumReplies ( )
+
+Calculates the number of replies to this thread and updates the counter to reflect that. Also triggers a count in the collaboration system.
+
+=cut
+
+sub sumReplies {
+ my $self = shift;
+ $self->update({replies=>$self->getDescendantCount});
+ $self->getParent->sumReplies;
+}
+
+#-------------------------------------------------------------------
+
=head2 trash
-Moves thread to the trash and decrements reply counter on thread.
+Moves thread to the trash and updates reply counter on thread.
=cut
sub trash {
my $self = shift;
$self->SUPER::trash;
- $self->getParent->decrementThreads;
+ $self->getParent->sumReplies;
if ($self->getParent->get("lastPostId") eq $self->getId) {
my $parentLineage = $self->getThread->get("lineage");
my ($id, $date) = $self->session->db->quickArray("select Post.assetId, Post.dateSubmitted from Post, asset where asset.lineage like ".$self->session->db->quote($parentLineage.'%')." and Post.assetId<>".$self->session->db->quote($self->getId)." and Post.assetId=asset.assetId and asset.state='published' order by Post.dateSubmitted desc");
diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm
index afcefcbdf..8364b7c42 100644
--- a/lib/WebGUI/Asset/Wobject/Collaboration.pm
+++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm
@@ -262,34 +262,6 @@ sub createSubscriptionGroup {
});
}
-#-------------------------------------------------------------------
-
-=head2 decrementReplies ( )
-
-Deccrements this reply counter.
-
-=cut
-
-sub decrementReplies {
- my $self = shift;
- $self->update({replies=>$self->get("replies")-1});
-}
-
-
-#-------------------------------------------------------------------
-
-=head2 decrementThreads ( )
-
-Deccrements this thread counter.
-
-=cut
-
-sub decrementThreads {
- my $self = shift;
- $self->update({threads=>$self->get("threads")-1});
-}
-
-
#-------------------------------------------------------------------
sub definition {
my $class = shift;
@@ -892,7 +864,9 @@ The unique identifier of the post being added.
sub incrementReplies {
my ($self, $lastPostDate, $lastPostId) = @_;
- $self->update({replies=>$self->get("replies")+1, lastPostId=>$lastPostId, lastPostDate=>$lastPostDate});
+ my $threads = $self->getChildCount;
+ my $replies = $self->getDescendantCount - $threads;
+ $self->update({replies=>$replies, threads=>$threads, lastPostId=>$lastPostId, lastPostDate=>$lastPostDate});
}
#-------------------------------------------------------------------
@@ -913,7 +887,7 @@ The unique identifier of the post that was just added.
sub incrementThreads {
my ($self, $lastPostDate, $lastPostId) = @_;
- $self->update({threads=>$self->get("threads")+1, lastPostId=>$lastPostId, lastPostDate=>$lastPostDate});
+ $self->update({threads=>$self->getChildCount, lastPostId=>$lastPostId, lastPostDate=>$lastPostDate});
}
#-------------------------------------------------------------------
@@ -1051,6 +1025,34 @@ sub setLastPost {
#-------------------------------------------------------------------
+=head2 sumReplies ( )
+
+Calculates the number of replies to this collaboration system and updates the counter to reflect that. Also updates thread count since it needs to know that to calculate reply count.
+
+=cut
+
+sub sumReplies {
+ my $self = shift;
+ my $threads = $self->getChildCount;
+ my $replies = $self->getDescendantCount - $threads;
+ $self->update({replies=>$replies, threads=>$threads});
+}
+
+#-------------------------------------------------------------------
+
+=head2 sumThreads ( )
+
+Calculates the number of threads in this collaboration system and updates the counter to reflect that.
+
+=cut
+
+sub sumThreads {
+ my $self = shift;
+ $self->update({threads=>$self->getChildCount});
+}
+
+#-------------------------------------------------------------------
+
=head2 subscribe ( )
Subscribes a user to this collaboration system.
diff --git a/lib/WebGUI/Asset/Wobject/Product.pm b/lib/WebGUI/Asset/Wobject/Product.pm
index 562f94eaa..e443be9bb 100644
--- a/lib/WebGUI/Asset/Wobject/Product.pm
+++ b/lib/WebGUI/Asset/Wobject/Product.pm
@@ -270,7 +270,7 @@ sub indexContent {
$indexer->addKeywords(join(" ", @data));
@data = $self->session->db->buildArray("select benefit from Product_benefit where assetId=".$self->session->db->quote($self->getId));
$indexer->addKeywords(join(" ", @data));
- @data = $self->session->db->buildArray("select concat(name,' ',value,' ', units') from Product_specification where assetId=".$self->session->db->quote($self->getId));
+ @data = $self->session->db->buildArray("select concat(name,' ',value,' ', units) from Product_specification where assetId=".$self->session->db->quote($self->getId));
$indexer->addKeywords(join(" ", @data));
}
diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm
index c63662005..f07a45e56 100644
--- a/lib/WebGUI/AssetLineage.pm
+++ b/lib/WebGUI/AssetLineage.pm
@@ -154,6 +154,35 @@ sub formatRank {
}
+#-------------------------------------------------------------------
+
+=head2 getChildCount ( )
+
+Returns the number of children this asset has. This excludes assets in the trash or clipbaord.
+
+=cut
+
+sub getChildCount {
+ my $self = shift;
+ my ($count) = $self->session->db->quickArray("select count(*) from asset where state in ('published','archived') and parentId=?", [$self->getId]);
+ return $count;
+}
+
+#-------------------------------------------------------------------
+
+=head2 getDescendantCount ( )
+
+Returns the number of descendants this asset has. This excludes assets in the trash or clipboard.
+
+=cut
+
+sub getDescendantCount {
+ my $self = shift;
+ my ($count) = $self->session->db->quickArray("select count(*) from asset where state in ('published', 'archived') and lineage like ?", [$self->get("lineage")."%"]);
+ $count--; # have to subtract self
+ return $count;
+}
+
#-------------------------------------------------------------------
=head2 getFirstChild ( )
@@ -498,7 +527,7 @@ sub getRank {
=head2 hasChildren ( )
-Returns 1 or the count of Assets with the same parentId as current Asset (Which may be zero).
+Returns 1 or the count of Assets with the same parentId as current Asset's assetId (Which may be zero).
=cut
@@ -510,8 +539,7 @@ sub hasChildren {
} elsif (exists $self->{_lastChild}) {
$self->{_hasChildren} = 1;
} else {
- my ($hasChildren) = $self->session->db->quickArray("select count(*) from asset where parentId=".$self->session->db->quote($self->getId));
- $self->{_hasChildren} = $hasChildren;
+ $self->{_hasChildren} = $self->getChildCount;
}
}
return $self->{_hasChildren};
diff --git a/lib/WebGUI/Operation/User.pm b/lib/WebGUI/Operation/User.pm
index b37370a58..24b2b7e43 100644
--- a/lib/WebGUI/Operation/User.pm
+++ b/lib/WebGUI/Operation/User.pm
@@ -311,7 +311,7 @@ sub www_editUser {
my $tabform = WebGUI::TabForm->new($session,\%tabs);
$tabform->formHeader({extras=>'autocomplete="off"'});
my $u = WebGUI::User->new($session,($uid eq 'new') ? '' : $uid); #Setting uid to '' when uid is 'new' so visitor defaults prefill field for new user
- my $username = $u->userId eq '1' ? '' : $u->username;
+ my $username = ($u->userId eq '1' && $uid ne "1") ? '' : $u->username;
$session->stow->set("editUser_UID", $uid);
$tabform->hidden({name=>"op",value=>"editUserSave"});
$tabform->hidden({name=>"uid",value=>$uid});
@@ -519,7 +519,7 @@ sub www_editUserKarmaSave {
my ($u);
$u = WebGUI::User->new($session,$session->form->process("uid"));
$u->karma($session->form->process("amount"),$session->user->username." (".$session->user->userId.")",$session->form->process("description"));
- return www_editUser();
+ return www_editUser($session);
}
#-------------------------------------------------------------------