-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update forum module add last post box
- Loading branch information
kveldscholten
committed
Feb 6, 2016
1 parent
18a76f3
commit 99aa855
Showing
5 changed files
with
110 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* @copyright Ilch 2.0 | ||
* @package ilch | ||
*/ | ||
|
||
namespace Modules\Forum\Boxes; | ||
|
||
use Modules\Forum\Mappers\Forum as ForumMapper; | ||
use Modules\Forum\Mappers\Topic as TopicMapper; | ||
use Modules\User\Mappers\User as UserMapper; | ||
|
||
class Forum extends \Ilch\Box | ||
{ | ||
public function render() | ||
{ | ||
$forumMapper = new ForumMapper(); | ||
$topicMapper = new TopicMapper(); | ||
$userMapper = new UserMapper(); | ||
|
||
$groupIds = array(0); | ||
|
||
if ($this->getUser()) { | ||
$userId = $this->getUser()->getId(); | ||
$user = $userMapper->getUserById($userId); | ||
|
||
$groupIds = array(); | ||
foreach ($user->getGroups() as $groups) { | ||
$groupIds[] = $groups->getId(); | ||
} | ||
} | ||
|
||
$groupIdsArray = explode(',',implode(',', $groupIds)); | ||
|
||
$this->getView()->set('forumMapper', $forumMapper); | ||
$this->getView()->set('topicMapper', $topicMapper); | ||
$this->getView()->set('topics', $topicMapper->getTopics('', 5)); | ||
$this->getView()->set('groupIdsArray', $groupIdsArray); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
$forumMapper = $this->get('forumMapper'); | ||
$topicMapper = $this->get('topicMapper'); | ||
$groupIdsArray = $this->get('groupIdsArray'); | ||
$adminAccess = null; | ||
if ($this->getUser()) { | ||
$adminAccess = $this->getUser()->isAdmin(); | ||
} | ||
?> | ||
|
||
<?php if (!empty($this->get('topics'))): ?> | ||
<ul class="list-unstyled"> | ||
<?php foreach ($this->get('topics') as $topic): ?> | ||
<?php $forum = $forumMapper->getForumById($topic->getForumId()); ?> | ||
<?php if (is_in_array($groupIdsArray, explode(',', $forum->getReadAccess())) || $adminAccess == true): ?> | ||
<?php $lastPost = $topicMapper->getLastPostByTopicId($topic->getId()) ?> | ||
<?php $date = new \Ilch\Date($lastPost->getDateCreated()); ?> | ||
<li style="line-height: 25px;"> | ||
<?php if ($this->getUser()): ?> | ||
<?php if (in_array($this->getUser()->getId(), explode(',', $lastPost->getRead()))): ?> | ||
<img src="<?=$this->getStaticUrl('../application/modules/forum/static/img/forum_read.png') ?>" style="float: left; margin-top: 8px;"> | ||
<?php else: ?> | ||
<img src="<?=$this->getStaticUrl('../application/modules/forum/static/img/topic_unread.png') ?>" style="float: left; margin-top: 8px;"> | ||
<?php endif; ?> | ||
<?php else: ?> | ||
<img src="<?=$this->getStaticUrl('../application/modules/forum/static/img/forum_read.png') ?>" style="float: left; margin-top: 8px;"> | ||
<?php endif; ?> | ||
<a href="<?=$this->getUrl(array('module' => 'forum', 'controller' => 'showposts', 'action' => 'index', 'topicid' => $lastPost->getTopicId())) ?>"> | ||
<?=$topic->getTopicTitle() ?> | ||
</a> | ||
<br /> | ||
<small><?=$date->format("d.m.y - H:i", true) ?> <?=$this->getTrans('clock') ?></small> | ||
</li> | ||
<?php endif; ?> | ||
<?php endforeach; ?> | ||
</ul> | ||
<?php else: ?> | ||
<?=$this->getTrans('noPosts') ?> | ||
<?php endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,5 +40,5 @@ | |
'no' => 'No', | ||
'joined' => 'Joined', | ||
'showNewPosts' => 'New posts', | ||
|
||
'noPosts' => 'No posts available', | ||
); |