various bugfixes on the collaboration system
This commit is contained in:
parent
850404ad3b
commit
d361711600
5 changed files with 366 additions and 76 deletions
|
|
@ -532,7 +532,6 @@ while (my ($id, $template, $namespace) = $sth->array) {
|
|||
my $newNamespace;
|
||||
if ($namespace eq "Forum") {
|
||||
$newNamespace = "Collaboration";
|
||||
$template = '<a name="<tmpl_var assetId>"></a><tmpl_if session.var.adminOn><p><tmpl_var controls></p></tmpl_if>'.$template;
|
||||
} elsif ($namespace eq "Forum/PostForm") {
|
||||
$newNamespace = "Collaboration/PostForm";
|
||||
} elsif ($namespace eq "Forum/Search") {
|
||||
|
|
@ -546,6 +545,8 @@ while (my ($id, $template, $namespace) = $sth->array) {
|
|||
$template =~ s/\<tmpl_var\s+callback\.label\>//ixsg;
|
||||
$template =~ s/\<tmpl_var\s+forum\.description\>//ixsg;
|
||||
$template =~ s/\<tmpl_var\s+forum\.title\>//ixsg;
|
||||
$template =~ s/forum\.title/collaboration.title/ixsg;
|
||||
$template =~ s/forum\.description/collaboration.description/ixsg;
|
||||
$template =~ s/forum\.//ixsg;
|
||||
$template =~ s/thread\.list\.url/collaboration.url/ixsg;
|
||||
$template =~ s/thread\.new\.url/add.url/ixsg;
|
||||
|
|
@ -608,8 +609,324 @@ while (my ($id, $template, $namespace) = $sth->array) {
|
|||
WebGUI::SQL->write("update template set template=".quote($template).", namespace=".quote($newNamespace)." where templateId=".quote($id)." and namespace=".quote($namespace));
|
||||
}
|
||||
$sth->finish;
|
||||
my $defaultThread = '
|
||||
<a name="<tmpl_var assetId>"></a>
|
||||
<tmpl_if session.var.adminOn>
|
||||
<p><tmpl_var controls></p>
|
||||
</tmpl_if>
|
||||
|
||||
|
||||
<style>
|
||||
.postBorder {
|
||||
border: 1px solid #cccccc;
|
||||
width: 100%;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.postBorderCurrent {
|
||||
border: 3px dotted black;
|
||||
width: 100%;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.postSubject {
|
||||
border-bottom: 1px solid #cccccc;
|
||||
font-weight: bold;
|
||||
padding: 3px;
|
||||
}
|
||||
.postData {
|
||||
border-bottom: 1px solid #cccccc;
|
||||
font-size: 11px;
|
||||
background-color: #eeeeee;
|
||||
color: black;
|
||||
padding: 3px;
|
||||
}
|
||||
.postControls {
|
||||
border-top: 1px solid #cccccc;
|
||||
background-color: #eeeeee;
|
||||
color: black;
|
||||
padding: 3px;
|
||||
}
|
||||
.postMessage {
|
||||
padding: 3px;
|
||||
}
|
||||
.currentThread {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
.threadHead {
|
||||
font-weight: bold;
|
||||
border-bottom: 1px solid #cccccc;
|
||||
font-size: 11px;
|
||||
background-color: #eeeeee;
|
||||
color: black;
|
||||
padding: 3px;
|
||||
}
|
||||
.threadData {
|
||||
font-size: 11px;
|
||||
padding: 3px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<div style="float: left; width: 70%">
|
||||
<h1><a href="<tmpl_var collaboration.url>"><tmpl_var collaboration.title></a></h1>
|
||||
</div>
|
||||
<div style="width: 30%; float: left; text-align: right;">
|
||||
<script language="JavaScript" type="text/javascript"> <!--
|
||||
function goLayout(){
|
||||
location = document.layout.layoutSelect.options[document.layout.layoutSelect.selectedIndex].value
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
<form name="layout">
|
||||
<select name="layoutSelect" size="1" onChange="goLayout()">
|
||||
<option value="<tmpl_var layout.flat.url>" <tmpl_if layout.isFlat>selected="1"</tmpl_if>><tmpl_var layout.flat.label></option>
|
||||
<option value="<tmpl_var layout.nested.url>" <tmpl_if layout.isNested>selected="1"</tmpl_if>><tmpl_var layout.nested.label></option>
|
||||
<option value="<tmpl_var layout.threaded.url>" <tmpl_if layout.isThreaded>selected="1"</tmpl_if>><tmpl_var layout.threaded.label></option>
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<tmpl_if layout.isThreaded>
|
||||
<!-- begin threaded layout -->
|
||||
<tmpl_loop post_loop>
|
||||
<tmpl_if isCurrent>
|
||||
<div class="postBorder">
|
||||
<a name="<tmpl_var assetId>"></a>
|
||||
<div class="postSubject">
|
||||
<tmpl_var title>
|
||||
</div>
|
||||
<div class="postData">
|
||||
<div style="float: left; width: 50%;">
|
||||
<b><tmpl_var user.label>:</b>
|
||||
<tmpl_if user.isVisitor>
|
||||
<tmpl_var username>
|
||||
<tmpl_else>
|
||||
<a href="<tmpl_var userProfile.url>"><tmpl_var username></a>
|
||||
</tmpl_if>
|
||||
<br />
|
||||
<b><tmpl_var date.label>:</b> <tmpl_var dateSubmitted.human><br />
|
||||
</div>
|
||||
<div>
|
||||
<b><tmpl_var views.label>:</b> <tmpl_var views><br />
|
||||
<b><tmpl_var rating.label>:</b> <tmpl_var rating>
|
||||
<tmpl_unless hasRated>
|
||||
<tmpl_var rate.label> [ <a href="<tmpl_var rate.url.1>">1</a>, <a href="<tmpl_var rate.url.2>">2</a>, <a href="<tmpl_var rate.url.3>">3</a>, <a href="<tmpl_var rate.url.4>">4</a>, <a href="<tmpl_var rate.url.5>">5</a> ]
|
||||
</tmpl_unless>
|
||||
<br />
|
||||
<tmpl_if user.isModerator>
|
||||
<b><tmpl_var status.label>:</b> <tmpl_var status> [ <a href="<tmpl_var approve.url>"><tmpl_var approve.label></a> | <a href="<tmpl_var deny.url>"><tmpl_var deny.label></a> ]<br />
|
||||
<tmpl_else>
|
||||
<tmpl_if user.isPoster>
|
||||
<b><tmpl_var status.label>:</b> <tmpl_var status><br />
|
||||
</tmpl_if>
|
||||
</tmpl_if>
|
||||
</div>
|
||||
</div>
|
||||
<div class="postMessage">
|
||||
<tmpl_var content>
|
||||
</div>
|
||||
<tmpl_unless isLocked>
|
||||
<div class="postControls">
|
||||
<tmpl_if user.canReply>
|
||||
<a href="<tmpl_var reply.url>">[<tmpl_var reply.label>]</a>
|
||||
</tmpl_if>
|
||||
<tmpl_if user.canEdit>
|
||||
<a href="<tmpl_var edit.url>">[<tmpl_var edit.label>]</a>
|
||||
<a href="<tmpl_var delete.url>">[<tmpl_var delete.label>]</a>
|
||||
</tmpl_if>
|
||||
</div>
|
||||
</tmpl_unless>
|
||||
</div>
|
||||
</tmpl_if>
|
||||
</tmpl_loop>
|
||||
<table style="width: 100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="threadHead"><tmpl_var subject.label></td>
|
||||
<td class="threadHead"><tmpl_var user.label></td>
|
||||
<td class="threadHead"><tmpl_var date.label></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tmpl_loop post_loop>
|
||||
<tr <tmpl_if isCurrent>class="currentThread"</tmpl_if>>
|
||||
<td class="threadData"><tmpl_loop indent_loop> </tmpl_loop><a href="<tmpl_var url>"><tmpl_var title.short></a></td>
|
||||
<td class="threadData"><tmpl_var username></td>
|
||||
<td class="threadData"><tmpl_var dateSubmitted.human></td>
|
||||
</tr>
|
||||
</tmpl_loop>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- end threaded layout -->
|
||||
</tmpl_if>
|
||||
|
||||
|
||||
|
||||
<tmpl_if layout.isFlat>
|
||||
<!-- begin flat layout -->
|
||||
<tmpl_loop post_loop>
|
||||
<div class="postBorder<tmpl_if isCurrent>Current</tmpl_if>">
|
||||
<a name="<tmpl_var assetId>"></a>
|
||||
<div class="postSubject">
|
||||
<tmpl_var title>
|
||||
</div>
|
||||
<div class="postData">
|
||||
<div style="float: left; width: 50%">
|
||||
<b><tmpl_var user.label>:</b>
|
||||
<tmpl_if user.isVisitor>
|
||||
<tmpl_var username>
|
||||
<tmpl_else>
|
||||
<a href="<tmpl_var userProfile.url>"><tmpl_var username></a>
|
||||
</tmpl_if>
|
||||
<br />
|
||||
<b><tmpl_var date.label>:</b> <tmpl_var dateSubmitted.human><br />
|
||||
</div>
|
||||
<div>
|
||||
<b><tmpl_var views.label>:</b> <tmpl_var views><br />
|
||||
<b><tmpl_var rating.label>:</b> <tmpl_var rating>
|
||||
<tmpl_unless hasRated>
|
||||
<tmpl_var rate.label> [ <a href="<tmpl_var rate.url.1>">1</a>, <a href="<tmpl_var rate.url.2>">2</a>, <a href="<tmpl_var rate.url.3>">3</a>, <a href="<tmpl_var rate.url.4>">4</a>, <a href="<tmpl_var rate.url.5>">5</a> ]
|
||||
</tmpl_unless>
|
||||
<br />
|
||||
<tmpl_if user.isModerator>
|
||||
<b><tmpl_var status.label>:</b> <tmpl_var status> [ <a href="<tmpl_var approve.url>"><tmpl_var approve.label></a> | <a href="<tmpl_var deny.url>"><tmpl_var deny.label></a> ]<br />
|
||||
<tmpl_else>
|
||||
<tmpl_if user.isPoster>
|
||||
<b><tmpl_var status.label>:</b> <tmpl_var status><br />
|
||||
</tmpl_if>
|
||||
</tmpl_if>
|
||||
</div>
|
||||
</div>
|
||||
<div class="postMessage">
|
||||
<tmpl_var content>
|
||||
</div>
|
||||
<tmpl_unless isLocked>
|
||||
<div class="postControls">
|
||||
<tmpl_if user.canReply>
|
||||
<a href="<tmpl_var reply.url>">[<tmpl_var reply.label>]</a>
|
||||
</tmpl_if>
|
||||
<tmpl_if user.canEdit>
|
||||
<a href="<tmpl_var edit.url>">[<tmpl_var edit.label>]</a>
|
||||
<a href="<tmpl_var delete.url>">[<tmpl_var delete.label>]</a>
|
||||
</tmpl_if>
|
||||
</div>
|
||||
</tmpl_unless>
|
||||
</div>
|
||||
</tmpl_loop>
|
||||
<!-- end flat layout -->
|
||||
</tmpl_if>
|
||||
|
||||
|
||||
|
||||
<tmpl_if layout.isNested>
|
||||
<!-- begin nested layout -->
|
||||
<tmpl_loop post_loop>
|
||||
<div style="margin-left: <tmpl_var depthX10>px;">
|
||||
<div class="postBorder<tmpl_if isCurrent>Current</tmpl_if>">
|
||||
<a name="<tmpl_var assetId>"></a>
|
||||
<div class="postSubject">
|
||||
<tmpl_var title>
|
||||
</div>
|
||||
<div class="postData">
|
||||
<div style="float: left; width: 50%">
|
||||
<b><tmpl_var user.label>:</b>
|
||||
<tmpl_if user.isVisitor>
|
||||
<tmpl_var username>
|
||||
<tmpl_else>
|
||||
<a href="<tmpl_var userProfile.url>"><tmpl_var username></a>
|
||||
</tmpl_if>
|
||||
<br />
|
||||
<b><tmpl_var date.label>:</b> <tmpl_var dateSubmitted.human><br />
|
||||
</div>
|
||||
<div>
|
||||
<b><tmpl_var views.label>:</b> <tmpl_var views><br />
|
||||
<b><tmpl_var rating.label>:</b> <tmpl_var rating>
|
||||
<tmpl_unless hasRated>
|
||||
<tmpl_var rate.label> [ <a href="<tmpl_var rate.url.1>">1</a>, <a href="<tmpl_var rate.url.2>">2</a>, <a href="<tmpl_var rate.url.3>">3</a>, <a href="<tmpl_var rate.url.4>">4</a>, <a href="<tmpl_var rate.url.5>">5</a> ]
|
||||
</tmpl_unless>
|
||||
<br />
|
||||
<tmpl_if user.isModerator>
|
||||
<b><tmpl_var status.label>:</b> <tmpl_var status> [ <a href="<tmpl_var approve.url>"><tmpl_var approve.label></a> | <a href="<tmpl_var deny.url>"><tmpl_var deny.label></a> ]<br />
|
||||
<tmpl_else>
|
||||
<tmpl_if user.isPoster>
|
||||
<b><tmpl_var status.label>:</b> <tmpl_var status><br />
|
||||
</tmpl_if>
|
||||
</tmpl_if>
|
||||
</div>
|
||||
</div>
|
||||
<div class="postMessage">
|
||||
<tmpl_var content>
|
||||
</div>
|
||||
<tmpl_unless isLocked>
|
||||
<div class="postControls">
|
||||
<tmpl_if user.canReply>
|
||||
<a href="<tmpl_var reply.url>">[<tmpl_var reply.label>]</a>
|
||||
</tmpl_if>
|
||||
<tmpl_if user.canEdit>
|
||||
<a href="<tmpl_var edit.url>">[<tmpl_var edit.label>]</a>
|
||||
<a href="<tmpl_var delete.url>">[<tmpl_var delete.label>]</a>
|
||||
</tmpl_if>
|
||||
</div>
|
||||
</tmpl_unless>
|
||||
</div>
|
||||
</div>
|
||||
</tmpl_loop>
|
||||
<!-- end nested layout -->
|
||||
</tmpl_if>
|
||||
|
||||
|
||||
|
||||
<tmpl_if pagination.pageCount.isMultiple>
|
||||
<div class="pagination" style="margin-top: 20px;">
|
||||
[ <tmpl_var pagination.previousPage> | <tmpl_var pagination.pageList.upTo10> | <tmpl_var pagination.nextPage> ]
|
||||
</div>
|
||||
</tmpl_if>
|
||||
|
||||
|
||||
<div style="margin-top: 20px;">
|
||||
<tmpl_if previous.url>
|
||||
<a href="<tmpl_var previous.url>">[<tmpl_var previous.label>]</a>
|
||||
</tmpl_if>
|
||||
<tmpl_if next.url>
|
||||
<a href="<tmpl_var next.url>">[<tmpl_var next.label>]</a>
|
||||
</tmpl_if>
|
||||
<tmpl_if user.canPost>
|
||||
<a href="<tmpl_var add.url>">[<tmpl_var add.label>]</a>
|
||||
</tmpl_if>
|
||||
<tmpl_if user.isModerator>
|
||||
<tmpl_if isSticky>
|
||||
<a href="<tmpl_var unstick.url>">[<tmpl_var unstick.label>]</a>
|
||||
<tmpl_else>
|
||||
<a href="<tmpl_var stick.url>">[<tmpl_var stick.label>]</a>
|
||||
</tmpl_if>
|
||||
<tmpl_if isLocked>
|
||||
<a href="<tmpl_var unlock.url>">[<tmpl_var unlock.label>]</a>
|
||||
<tmpl_else>
|
||||
<a href="<tmpl_var lock.url>">[<tmpl_var lock.label>]</a>
|
||||
</tmpl_if>
|
||||
</tmpl_if>
|
||||
<tmpl_unless user.isVisitor>
|
||||
<tmpl_if user.isSubscribed>
|
||||
<a href="<tmpl_var unsubscribe.url>">[<tmpl_var unsubscribe.label>]</a>
|
||||
<tmpl_else>
|
||||
<a href="<tmpl_var subscribe.url>">[<tmpl_var subscribe.label>]</a>
|
||||
</tmpl_if>
|
||||
</tmpl_unless>
|
||||
</div>
|
||||
|
||||
';
|
||||
WebGUI::SQL->write("update template set template=".quote($defaultThread)." where templateId='25' and namespace='Collaboration/Thread'");
|
||||
|
||||
|
||||
print "\tMigrating USS templates to collaboration templates\n" unless ($quiet);
|
||||
my $sth = WebGUI::SQL->read("select templateId,template,namespace from template where namespace in ('USS','USS/Submission','USS/SubmissionForm')");
|
||||
|
|
|
|||
|
|
@ -1197,9 +1197,7 @@ sub getLineage {
|
|||
my $cmd = "use ".$className;
|
||||
eval ($cmd);
|
||||
WebGUI::ErrorHandler::fatalError("Couldn't compile asset package: ".$className.". Root cause: ".$@) if ($@);
|
||||
my $assetObject = eval{$className->new("new")};
|
||||
WebGUI::ErrorHandler::fatalError("Couldn't create new asset for ".$className.". Root cause: ".$@) if ($@);
|
||||
foreach my $definition (@{$assetObject->definition}) {
|
||||
foreach my $definition (@{$className->definition}) {
|
||||
unless ($definition->{tableName} eq "asset") {
|
||||
my $tableName = $definition->{tableName};
|
||||
$tables .= ", $tableName ";
|
||||
|
|
@ -1480,7 +1478,8 @@ Name value pairs to add to the URL in the form of:
|
|||
sub getUrl {
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
my $url = WebGUI::URL::gateway($self->get("url"),$params);
|
||||
my $url = $self->get("url");
|
||||
$url = WebGUI::URL::gateway($url,$params);
|
||||
if ($self->get("encryptPage")) {
|
||||
$url = WebGUI::URL::getSiteURL().$url;
|
||||
$url =~ s/http:/https:/;
|
||||
|
|
|
|||
|
|
@ -68,13 +68,13 @@ sub canView {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 chopSubject ( )
|
||||
=head2 chopTitle ( )
|
||||
|
||||
Cuts a subject string off at 30 characters.
|
||||
Cuts a title string off at 30 characters.
|
||||
|
||||
=cut
|
||||
|
||||
sub chopSubject {
|
||||
sub chopTitle {
|
||||
my $self = shift;
|
||||
return substr($self->get("title"),0,30);
|
||||
}
|
||||
|
|
@ -363,16 +363,17 @@ sub getSynopsisAndContentFromFormPost {
|
|||
#-------------------------------------------------------------------
|
||||
sub getTemplateVars {
|
||||
my $self = shift;
|
||||
my %var = (%{$self->get});
|
||||
my %var = %{$self->get};
|
||||
$var{"userId"} = $self->get("ownerUserId");
|
||||
$var{"user.isPoster"} = $self->isPoster;
|
||||
|
||||
$var{"dateSubmitted.human"} = epochToHuman($self->get("dateSubmitted"));
|
||||
$var{"dateUpdated.human"} = epochToHuman($self->get("dateUpdated"));
|
||||
|
||||
$var{'title.short'} = $self->chopTitle;
|
||||
$var{content} = $self->formatContent if ($self->getThread);
|
||||
|
||||
$var{canEdit} = $self->canEdit if ($self->getThread);
|
||||
$var{'user.canEdit'} = $self->canEdit if ($self->getThread);
|
||||
$var{"delete.url"} = $self->getDeleteUrl;
|
||||
$var{"edit.url"} = $self->getEditUrl;
|
||||
|
||||
|
|
@ -383,7 +384,7 @@ sub getTemplateVars {
|
|||
$var{"reply.url"} = $self->getReplyUrl;
|
||||
$var{'reply.withquote.url'} = $self->getReplyUrl(1);
|
||||
|
||||
$var{'url'} = WebGUI::URL::getSiteURL().$self->getUrl;
|
||||
$var{'url'} = $self->getUrl.'#'.$self->getId;
|
||||
|
||||
$var{'rating.value'} = $self->get("rating")+0;
|
||||
$var{'rate.url.1'} = $self->getRateUrl(1);
|
||||
|
|
@ -593,6 +594,7 @@ sub notifySubscribers {
|
|||
'notify.subscription.message' => WebGUI::International::get(875,"WebGUI",$u->profileField("language"))
|
||||
};
|
||||
$lang{$u->profileField("language")}{var} = $self->getTemplateVars($lang{$u->profileField("language")}{var});
|
||||
$lang{$u->profileField("language")}{var}{url} = WebGUI::URL::getSiteURL().$self->getUrl;
|
||||
$lang{$u->profileField("language")}{subject} = WebGUI::International::get(523,"WebGUI",$u->profileField("language"));
|
||||
$lang{$u->profileField("language")}{message} = $self->processTemplate($lang{$u->profileField("language")}{var}, $self->getThread->getParent->get("notificationTemplateId"));
|
||||
}
|
||||
|
|
@ -670,10 +672,10 @@ sub rate {
|
|||
WebGUI::SQL->write("insert into Post_rating (assetId,userId,ipAddress,dateOfRating,rating) values ("
|
||||
.quote($self->getId).", ".quote($session{user}{userId}).", ".quote($session{env}{REMOTE_ADDR}).",
|
||||
".WebGUI::DateTime::time().", $rating)");
|
||||
my ($count) = WebGUI::SQL->quickArray("select count(*) from Post_rating where postId=".quote($self->getId));
|
||||
my ($count) = WebGUI::SQL->quickArray("select count(*) from Post_rating where assetId=".quote($self->getId));
|
||||
$count = $count || 1;
|
||||
my ($sum) = WebGUI::SQL->quickArray("select sum(rating) from Post_rating where postId=".quote($self->getId));
|
||||
my $average = round($sum/$count);
|
||||
my ($sum) = WebGUI::SQL->quickArray("select sum(rating) from Post_rating where assetId=".quote($self->getId));
|
||||
my $average = WebGUI::Utility::round($sum/$count);
|
||||
$self->update({rating=>$average});
|
||||
$self->getThread->rate;
|
||||
}
|
||||
|
|
@ -954,7 +956,7 @@ This is here to stop people from duplicating posts by hitting refresh in their b
|
|||
|
||||
sub www_redirectToParent {
|
||||
my $self = shift;
|
||||
WebGUI::HTTP::setRedirect($self->getThread->getParent->getUrl);
|
||||
WebGUI::HTTP::setRedirect($self->getParent->getUrl);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use WebGUI::Paginator;
|
|||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(WebGUI::Asset::Post);
|
||||
|
||||
|
|
@ -127,7 +128,7 @@ sub getName {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getLayoutUrl ( layout [, postId] )
|
||||
=head2 getLayoutUrl ( layout )
|
||||
|
||||
Formats the url to change the layout of a thread.
|
||||
|
||||
|
|
@ -135,35 +136,26 @@ Formats the url to change the layout of a thread.
|
|||
|
||||
A string indicating the type of layout to use. Can be flat, nested, or threaded.
|
||||
|
||||
=head3 postId
|
||||
|
||||
The asset id of the post to position on. Defaults to the root post of the thread.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLayoutUrl {
|
||||
my $self = shift;
|
||||
my $layout = shift;
|
||||
my $postId = shift || $self->get("rootPostId");
|
||||
return $self->getUrl("layout=".$layout."#".$postId);
|
||||
return $session{asset}->getUrl("layout=".$layout.'#'.$session{asset}->getId) if (exists $session{asset});
|
||||
return $self->getUrl("layout=".$layout);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getLockUrl ( [ postId ] )
|
||||
=head2 getLockUrl ( )
|
||||
|
||||
Formats the url to lock a thread.
|
||||
|
||||
=head3 postId
|
||||
|
||||
The asset id of the post to position on. Defaults to the root post of the thread.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLockUrl {
|
||||
my $self = shift;
|
||||
my $postId = shift || $self->get("rootPostId");
|
||||
$self->getUrl("fucn=lock#">$postId);
|
||||
$self->getUrl("func=lock");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -233,38 +225,28 @@ sub getPreviousThread {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStickUrl ( [ postId ] )
|
||||
=head2 getStickUrl ( )
|
||||
|
||||
Formats the url to make a thread sticky.
|
||||
|
||||
=head3 postId
|
||||
|
||||
The asset id of the post to position on. Defaults to the root post of the thread.
|
||||
|
||||
=cut
|
||||
|
||||
sub getStickUrl {
|
||||
my $self = shift;
|
||||
my $postId = shift || $self->get("rootPostId");
|
||||
return $self->getUrl("func=stick#".$postId);
|
||||
return $self->getUrl("func=stick");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getSubscribeUrl ( [ postId ] )
|
||||
=head2 getSubscribeUrl ( )
|
||||
|
||||
Formats the url to subscribe to the thread
|
||||
|
||||
=head3 postId
|
||||
|
||||
The asset id of the post to position on. Defaults to the root post of the thread.
|
||||
|
||||
=cut
|
||||
|
||||
sub getSubscribeUrl {
|
||||
my $self = shift;
|
||||
my $postId = shift || $self->get("rootPostId");
|
||||
return $self->getUrl("func=subscribe#".$postId);
|
||||
return $self->getUrl("func=subscribe");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -275,57 +257,42 @@ sub getThread {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getUnlockUrl ( [ postId ] )
|
||||
=head2 getUnlockUrl ( )
|
||||
|
||||
Formats the url to unlock the thread
|
||||
|
||||
=head3 postId
|
||||
|
||||
The asset id of the post to position on. Defaults to the root post of the thread.
|
||||
|
||||
=cut
|
||||
|
||||
sub getUnlockUrl {
|
||||
my $self = shift;
|
||||
my $postId = shift || $self->get("rootPostId");
|
||||
return $self->getUrl("func=unlock#".$postId);
|
||||
return $self->getUrl("func=unlock");
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getUnstickUrl ( [ postId ] )
|
||||
=head2 getUnstickUrl ( )
|
||||
|
||||
Formats the url to unstick the thread
|
||||
|
||||
=head3 postId
|
||||
|
||||
The asset id of the post to position on. Defaults to the root post of the thread.
|
||||
|
||||
=cut
|
||||
|
||||
sub getUnstickUrl {
|
||||
my $self = shift;
|
||||
my $postId = shift || $self->get("rootPostId");
|
||||
return $self->getUrl("func=unstick#".$postId);
|
||||
return $self->getUrl("func=unstick");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getUnsubscribeUrl ( [ postId ] )
|
||||
=head2 getUnsubscribeUrl ( )
|
||||
|
||||
Formats the url to unsubscribe from the thread
|
||||
|
||||
=head3 postId
|
||||
|
||||
The asset id of the post to position on. Defaults to the root post of the thread.
|
||||
|
||||
=cut
|
||||
|
||||
sub getUnsubscribeUrl {
|
||||
my $self = shift;
|
||||
my $postId = shift || $self->get("rootPostId");
|
||||
return $self->getUrl("func=unsubscribe#".$postId);
|
||||
return $self->getUrl("func=unsubscribe");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -583,7 +550,7 @@ sub view {
|
|||
my $layout = $session{scratch}{discussionLayout} || $session{user}{discussionLayout};
|
||||
$var->{'layout.isFlat'} = ($layout eq "flat");
|
||||
$var->{'layout.isNested'} = ($layout eq "nested");
|
||||
$var->{'layout.isThreaded'} = ($layout eq "threaded" || !($var->{'thread.layout.isNested'} || $var->{'thread.layout.isFlat'}));
|
||||
$var->{'layout.isThreaded'} = ($layout eq "threaded" || !($var->{'layout.isNested'} || $var->{'layout.isFlat'}));
|
||||
|
||||
$var->{'user.isSubscribed'} = $self->isSubscribed;
|
||||
$var->{'subscribe.url'} = $self->getSubscribeUrl;
|
||||
|
|
@ -599,11 +566,10 @@ sub view {
|
|||
|
||||
my $p = WebGUI::Paginator->new($self->getUrl,$self->getParent->get("postsPerPage"));
|
||||
my $sql = "select * from asset
|
||||
left join Post on Post.assetId=asset.assetId
|
||||
left join Thread on Thread.assetId=asset.assetId
|
||||
where asset.lineage like ".quote($self->get("lineage").'%')."
|
||||
and asset.assetId<>".quote($self->getId)."
|
||||
and (
|
||||
left join Post on Post.assetId=asset.assetId
|
||||
where asset.lineage like ".quote($self->get("lineage").'%')
|
||||
." and (
|
||||
Post.status in ('approved','archived')";
|
||||
$sql .= " or Post.status='pending'" if ($self->getParent->canModerate);
|
||||
$sql .= " or (asset.ownerUserId=".quote($session{user}{userId})." and asset.ownerUserId<>'1')
|
||||
|
|
@ -618,14 +584,17 @@ sub view {
|
|||
foreach my $dataSet (@{$p->getPageData()}) {
|
||||
my $reply = WebGUI::Asset::Post->newByPropertyHashRef($dataSet);
|
||||
$reply->{_thread} = $self; # caching thread for better performance
|
||||
my $replyVars = $reply->getTemplateVars;
|
||||
$replyVars->{isCurrent} = $session{asset}->getId eq $reply->getId;
|
||||
$replyVars->{depth} = $reply->getLineageLength - $self->getLineageLength - 1;
|
||||
my %replyVars = %{$reply->getTemplateVars};
|
||||
$replyVars{isCurrent} = ('/'.$reply->get("url") eq $session{env}{PATH_INFO});
|
||||
$replyVars{isThreadRoot} = $self->getId eq $reply->getId;
|
||||
$replyVars{depth} = $reply->getLineageLength - $self->getLineageLength;
|
||||
$replyVars{depthX10} = $replyVars{depth}*10;
|
||||
my @depth_loop;
|
||||
for (my $i=0; $i<$replyVars->{depth}; $i++) {
|
||||
push(@{$replyVars->{indent_loop}},{depth=>$i});
|
||||
#@{$replyVars{indent_loop}} = {};
|
||||
for (my $i=0; $i<$replyVars{depth}; $i++) {
|
||||
push(@{$replyVars{indent_loop}},{depth=>$i});
|
||||
}
|
||||
push (@{$var->{post_loop}}, $replyVars);
|
||||
push (@{$var->{post_loop}}, \%replyVars);
|
||||
}
|
||||
$p->appendTemplateVars($var);
|
||||
$var->{'add.url'} = $self->getParent->getNewThreadUrl;
|
||||
|
|
@ -637,6 +606,9 @@ sub view {
|
|||
|
||||
$var->{"search.url"} = $self->getParent->getSearchUrl;
|
||||
$var->{"collaboration.url"} = $self->getThread->getParent->getUrl;
|
||||
$var->{'collaboration.title'} = $self->getParent->get("title");
|
||||
$var->{'collaboration.description'} = $self->getParent->get("description");
|
||||
|
||||
return $self->processTemplate($var,$self->getParent->get("threadTemplateId"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -929,8 +929,8 @@ sub www_search {
|
|||
# this is for trained professionals only and should not be attempted at home
|
||||
my $sql = "select *
|
||||
from asset
|
||||
left join Post on Post.assetId=asset.assetId
|
||||
left join Thread on Thread.assetId=asset.assetId
|
||||
left join Post on Post.assetId=asset.assetId
|
||||
where (asset.className='WebGUI::Asset::Post' or asset.className='WebGUI::Asset::Post::Thread')
|
||||
and asset.lineage like ".quote($self->get("lineage").'%')."
|
||||
and asset.assetId<>".quote($self->getId)."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue