Skip to content

Commit

Permalink
#201 Changed table name
Browse files Browse the repository at this point in the history
  • Loading branch information
simba77 committed Mar 30, 2022
1 parent 439b31b commit 8834d5c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions modules/johncms/forum/src/ForumCounters.php
Expand Up @@ -35,8 +35,8 @@ public function unreadMessages(): int
if ($this->user) {
$total = DB::selectOne(
"SELECT COUNT(*) as cnt FROM `forum_topic`
LEFT JOIN `cms_forum_rdm` ON `forum_topic`.`id` = `cms_forum_rdm`.`topic_id` AND `cms_forum_rdm`.`user_id` = '" . $this->user->id . "'
WHERE (`cms_forum_rdm`.`topic_id` IS NULL OR `forum_topic`.`last_post_date` > `cms_forum_rdm`.`time`)
LEFT JOIN `forum_read` ON `forum_topic`.`id` = `forum_read`.`topic_id` AND `forum_read`.`user_id` = '" . $this->user->id . "'
WHERE (`forum_read`.`topic_id` IS NULL OR `forum_topic`.`last_post_date` > `forum_read`.`time`)
" . ($this->user->hasAnyRole() >= 7 ? '' : ' AND (`forum_topic`.`deleted` != 1 OR `forum_topic`.`deleted` IS NULL)')
);
return $total->cnt;
Expand Down
2 changes: 1 addition & 1 deletion modules/johncms/forum/src/Models/ForumUnread.php
Expand Up @@ -46,7 +46,7 @@ class ForumUnread extends Model
*
* @var string
*/
protected $table = 'cms_forum_rdm';
protected $table = 'forum_read';

public $timestamps = false;

Expand Down
2 changes: 1 addition & 1 deletion modules/johncms/forum/src/Topics/ForumTopicRepository.php
Expand Up @@ -26,7 +26,7 @@ public function getUnread(): ?Builder

return ForumTopic::query()
->select(['*', 'sect.name as section_name', 'forum.name as forum_name'])
->leftJoin('cms_forum_rdm as rdm', function (JoinClause $joinClause) {
->leftJoin('forum_read as rdm', function (JoinClause $joinClause) {
return $joinClause->on('id', '=', 'rdm.topic_id')
->where('rdm.user_id', $this->user->id);
})
Expand Down
8 changes: 4 additions & 4 deletions system/src/Counters.php
Expand Up @@ -124,8 +124,8 @@ public function forumNew($mod = 0)
if ($this->user) {
$total = $this->db->query(
"SELECT COUNT(*) FROM `forum_topic`
LEFT JOIN `cms_forum_rdm` ON `forum_topic`.`id` = `cms_forum_rdm`.`topic_id` AND `cms_forum_rdm`.`user_id` = '" . $this->user->id . "'
WHERE (`cms_forum_rdm`.`topic_id` IS NULL OR `forum_topic`.`last_post_date` > `cms_forum_rdm`.`time`)
LEFT JOIN `forum_read` ON `forum_topic`.`id` = `forum_read`.`topic_id` AND `forum_read`.`user_id` = '" . $this->user->id . "'
WHERE (`forum_read`.`topic_id` IS NULL OR `forum_topic`.`last_post_date` > `forum_read`.`time`)
" . ($this->user->rights >= 7 ? '' : ' AND (`forum_topic`.`deleted` != 1 OR `forum_topic`.`deleted` IS NULL)') . '
'
)->fetchColumn();
Expand All @@ -152,8 +152,8 @@ public function forumUnreadCount()
if ($this->user) {
$total = $this->db->query(
"SELECT COUNT(*) FROM `forum_topic`
LEFT JOIN `cms_forum_rdm` ON `forum_topic`.`id` = `cms_forum_rdm`.`topic_id` AND `cms_forum_rdm`.`user_id` = '" . $this->user->id . "'
WHERE (`cms_forum_rdm`.`topic_id` IS NULL OR `forum_topic`.`last_post_date` > `cms_forum_rdm`.`time`)
LEFT JOIN `forum_read` ON `forum_topic`.`id` = `forum_read`.`topic_id` AND `forum_read`.`user_id` = '" . $this->user->id . "'
WHERE (`forum_read`.`topic_id` IS NULL OR `forum_topic`.`last_post_date` > `forum_read`.`time`)
" . ($this->user->rights >= 7 ? '' : ' AND (`forum_topic`.`deleted` != 1 OR `forum_topic`.`deleted` IS NULL)') . '
'
)->fetchColumn();
Expand Down

0 comments on commit 8834d5c

Please sign in to comment.