Skip to content

Commit d63a5d4

Browse files
committed
Removing forum details from user model
1 parent 6e05cd7 commit d63a5d4

File tree

1 file changed

+0
-65
lines changed

1 file changed

+0
-65
lines changed

src/models/User.php

-65
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ public function scopeVisible($query)
123123
'otherKey' => 'preference_id',
124124
'pivotKeys' => array('value'),
125125
'orderBy' => array('id', 'asc')),
126-
'posts' => array('hasMany', 'Forum_Post', 'foreignKey' => 'user_id'),
127-
'replies' => array('hasMany', 'Forum_Reply', 'foreignKey' => 'user_id'),
128126
'media' => array('hasMany', 'Media', 'foreignKey' => 'user_id'),
129127
'folders' => array('hasMany', 'Message_Folder', 'foreignKey' => 'user_id', 'orderBy' => array('name', 'asc')),
130128
);
@@ -417,69 +415,6 @@ public function updateLastActive()
417415
$this->save();
418416
}
419417

420-
/**
421-
* See if there are unread posts in a certain forum board
422-
*
423-
* @param int $boardId A forum board Id
424-
*
425-
* @return boolean
426-
*/
427-
public function checkUnreadBoard($boardId)
428-
{
429-
// Future version
430-
// return Forum_Board::where('id', '=', $boardId)->or_where('parent_id', '=', $boardId)->get()->unreadFlagForUser($this->id);
431-
432-
// Get all parent and child boards matching the id
433-
$boardIds = Forum_Board::where('uniqueId', $boardId)->orWhere('parent_id', '=', $boardId)->get()->id->toArray();
434-
435-
// Get any posts within those boards
436-
$posts = Forum_Post::whereIn('forum_board_id', $boardIds)->get();
437-
$postIds = $posts->id->toArray();
438-
439-
// Make sure there are posts
440-
if (count($postIds) > 0) {
441-
442-
// See which of these posts the user has already viewed
443-
$viewedPosts = Forum_Post_View::where('user_id', '=', $this->id)->whereIn('forum_post_id', $postIds)->get();
444-
445-
// If the posts are greater than the viewed, there are new posts
446-
if (count($posts) > count($viewedPosts)) {
447-
return true;
448-
}
449-
}
450-
return false;
451-
}
452-
453-
/**
454-
* Get the number of unread posts
455-
*
456-
* @return int
457-
*/
458-
public function unreadPostCount()
459-
{
460-
// Get the id of all posts
461-
$posts = Forum_Post::all();
462-
$postsCount = $posts->count();
463-
464-
if ($postsCount > 0) {
465-
foreach ($posts as $key => $post) {
466-
if ($post->board->forum_board_type_id == Forum_Board::TYPE_GM && !$this->checkPermission('GAME_MASTER')) {
467-
unset($posts[$key]);
468-
}
469-
}
470-
$postIds = $posts->id->toArray();
471-
472-
// See which of these the user has viewed
473-
$viewedPostCount = Forum_Post_View::where('user_id', $this->id)->whereIn('forum_post_id', $postIds)->count();
474-
475-
// If there are more posts than viewed posts, return the remainder
476-
if ($postsCount > $viewedPostCount) {
477-
return $postsCount - $viewedPostCount;
478-
}
479-
}
480-
return 0;
481-
}
482-
483418
/**
484419
* Get the number of unread private messages
485420
*

0 commit comments

Comments
 (0)