Skip to content

Commit 5c4397d

Browse files
committed
Fixes from when anima went live.
1 parent b31f6ea commit 5c4397d

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

src/models/Forum/Board.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,28 @@ public function getRepliesCountAttribute()
102102
public function getLastPostAttribute()
103103
{
104104
$posts = $this->posts()->get();
105-
$childrenPosts = $this->children()->get()->posts;
106-
107-
$allPosts = null;
108-
if ($posts->count() > 0) {
109-
$allPosts = $posts;
110-
}
111-
if ($childrenPosts->count() > 0) {
112-
if (isset($allPosts)) {
113-
$allPosts->merge($childrenPosts);
105+
$childrenPosts = $this->children->posts;
106+
107+
$newestPost = $posts->sortBy(function ($post) {
108+
return $post->modified_at;
109+
})->reverse()->first();
110+
111+
$newestChildPost = $childrenPosts->sortBy(function ($post) {
112+
return $post->modified_at;
113+
})->reverse()->first();
114+
115+
if ($newestPost != null && $newestChildPost == null) {
116+
return $newestPost;
117+
} elseif ($newestChildPost != null && $newestPost == null) {
118+
return $newestChildPost;
119+
} elseif ($newestChildPost != null && $newestPost != null) {
120+
if ($newestPost->modified_at > $newestChildPost->modified_at) {
121+
return $newestPost;
114122
} else {
115-
$allPosts = $childrenPosts;
123+
return $newestChildPost;
116124
}
117125
}
118126

119-
if ($allPosts != null) {
120-
$allPosts = $allPosts->sortBy(function ($post) {
121-
return $post->modified_at;
122-
})->reverse();
123-
124-
return $allPosts[0];
125-
}
126-
127127
return false;
128128
}
129129

src/presenters/Forum/BoardPresenter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function lastPostBlock()
4747
<br />
4848
in '. \HTML::link('forum/post/view/'. $this->resource->lastPost->id .'#reply:'. $this->resource->lastUpdate->id, $this->resource->lastUpdate->name) .'
4949
<br />
50-
on '. $this->resource->lastUpdate->created_at .'
50+
on '. $this->resource->lastUpdate->created_at->format('F jS, Y \a\t h:ia') .'
5151
</small>';
5252
} else {
5353
return '<small>

src/presenters/Forum/PostPresenter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function classes()
2626
}
2727
}
2828

29-
if ($this->resource->checkUserViewed(\CoreView::getActiveUser()->id)) {
29+
if (!$this->resource->checkUserViewed(\CoreView::getActiveUser()->id)) {
3030
$classes[] = 'unread';
3131
}
3232

@@ -35,7 +35,7 @@ public function classes()
3535

3636
public function link()
3737
{
38-
if ($this->resource->checkUserViewed(\CoreView::getActiveUser()->id)) {
38+
if (!$this->resource->checkUserViewed(\CoreView::getActiveUser()->id)) {
3939
return '<strong>'. \HTML::link('/forum/post/view/'. $this->resource->id, $this->resource->name) .'</strong>';
4040
}
4141

src/services/Utility/Response/Post.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ public function redirect($path = null, $message = null)
245245
if ($this->errorCount() > 0) {
246246
if ($path == 'back') {
247247
$back = $this->redirectBack();
248-
return $back->with('errors', $this->getErrors())->withInput()->send();
248+
return $back->with('errors', $this->getErrors())->send();
249249
} else {
250-
return Redirect::to(Request::path())->with('errors', $this->getErrors())->withInput()->send();
250+
return Redirect::to(Request::path())->with('errors', $this->getErrors())->send();
251251
}
252252
} else {
253253
if ($this->successMessage == null) {
@@ -259,9 +259,9 @@ public function redirect($path = null, $message = null)
259259
} else {
260260
if ($this->successPath == 'back') {
261261
$back = $this->redirectBack();
262-
return $back->with('message', $this->successMessage)->withInput()->send();
262+
return $back->with('message', $this->successMessage)->send();
263263
}
264-
return Redirect::to($this->successPath)->with('message', $this->successMessage)->withInput()->send();
264+
return Redirect::to($this->successPath)->with('message', $this->successMessage)->send();
265265
}
266266
}
267267
}

src/views/forum/post/components/postcontents.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<div class="pull-right text-bottom text-right">
88
<small>
99
@if ($post->frontPageFlag == 1)
10-
<small class="label pull-right">Front Page Post</small>
10+
<small class="label label-primary pull-right">Front Page Post</small>
1111
<div class="clearfix"></div>
1212
@endif
1313
@if ($post->adminReviewFlag == 1 || $post->moderatorLockedFlag == 1)

src/views/forum/post/components/postdisplay.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<div class="well-btn well-btn-right">
1111
<a href="#replyField" onClick="$('#collapseReply').addClass('in');">Reply</a>&nbsp;|&nbsp;
1212
<a href="#replyField" onClick="addQuote(this);" data-quote-id="{{ $post->id }}" data-quote-name="{{ $post->name }}" data-quote-type="{{ str_replace('Core\\', '', get_class($post)) }}">Quote</a>
13-
@if ($post->forumType == 'post' && Config::get('app.forumNews'))
13+
@if ($post->forumType == 'post' && Config::get('core::forumNews'))
1414
@if ($activeUser->checkPermission('PROMOTE_FRONT_PAGE'))
1515
@if ($post->frontPageFlag == 0)
1616
&nbsp;|&nbsp;<a href="/forum/post/modify/{{ $post->id }}/frontPageFlag/1">Promote</a>

0 commit comments

Comments
 (0)