<?php

class ModEss_Model_ModeratorDiscussion extends XenForo_Model
{

    public function getDiscussionById($discussionid)
    {
        return $this->_getDb()->fetchRow("Select * from xf_moderator_discussion where discussion_id =?", $discussionid);
    }

    public function getDiscussionByThread($ThreadId, $forumId)
    {


        return $this->_getDb()->fetchRow("Select * from xf_moderator_discussion where thread_id = ? and forum_id=?", array($ThreadId, $forumId));
    }

    public function getCreatedDiscussion($Thread_discussion, $forumId)
    {


        return $this->_getDb()->fetchRow("Select * from xf_moderator_discussion where discussion_thread = ? and forum_id=?", array($Thread_discussion, $forumId));
    }

    public function getModEntryById($id, $doCheck = true)
    {
        if (!$id)
        {
            return '';
        }

        $entry = $this->_getDb()->fetchRow("
				SELECT xf_moderator_discussion.*, user.username, user.avatar_date, user.avatar_width, user.avatar_height, user.gravatar, xf_thread.title
				FROM xf_moderator_discussion
				 JOIN xf_user AS user ON (user.user_id = xf_moderator_discussion.user_id)
                                 JOIN xf_thread  ON (xf_thread.thread_id=xf_moderator_discussion.thread_id)
				WHERE xf_moderator_discussion.thread_id=?", array($id));

        return $entry;
    }

}
