code:
/*Default Sheet for Forum*/

@font-face {
    font-family: roboto;
     src: url("fonts/Roboto-Regular.ttf");
}

@font-face {
    font-family: roboto-black;
     src: url("fonts/Roboto-Bold.ttf");
}

html {
    position: relative;
    min-height: 100%;
}

body {
    /* Margin bottom by footer height */
    margin-bottom: 60px;
    margin-right: 0;
    margin-left: 0;
    margin-top: 0;
    padding:0;

    background:#e6e6e6;
}

body, .wrap
{
    /*background-image:url('images/bg.png');*/
    font-family:roboto;
	font-size: 15px;
}

#submenu
{
     background:#666666;
}
/*In phones workaround to remove spaces*/
@media(max-width: 767px) {
    body
    {
        background:#fae6d2;
        margin-bottom: 60px;
    }

    #breadcrumbs
    {
      padding:0;
      margin:0;
    }

    #submenu
    {
        margin-bottom:1px;
    }

    #footer p
    {
        padding:0;
    }

    #footer
    {
        position: absolute;
        bottom: 0;
        height:60px;
        width: 100%;
        /* Set the fixed height of the footer here */
    }
}

#footer
{
    position: absolute;
    bottom: 0;
    width: 100%;
    /* Set the fixed height of the footer here */
    height: 60px;

    background:#666666;
    color:#e6e6e6;
    vertical-align:middle;
}

#yboard-wrapper
{
	background-color: #e6e6e6;
}

#footer a,
#footer a:visited
{
    color:#66cccc;
}

#yboard-wrapper .form-group
{
    padding:5px;
}

/*Headers*/
.header2 {
	font-size: 18px;
	font-weight: bold;
    font-family:roboto-black;
}

.header3 {
	font-size: 16px;
	font-weight: bold;
}
.header4 {
	font-size: 14px;
	font-weight: bold;
}

/* Page Header: */
#yboard-header {
	border-top: 2px solid #b23939;
	border-bottom: 1px solid grey;
	background-color: #ff6b6b;
	color: #e6e6e6;

}

/* Page Header menu: */
.yboard-menu {
	padding:0;
	margin: 0;
	color: #e6e6e6;
}

.yboard-menu ul {
	display:table;
	margin: 0;
	padding: 0;
	float: left;
	width:100%
}

.yboard-menu a {
	margin: 0;
	padding: 5px 5px;
	text-decoration: none;
	line-height:24px;
    color:#66cccc;
}

.yboard-menu li {
	display: table-cell;
	display: table-cell;
	position: relative;
	padding: 0;
	line-height:24px;
}

.yboard-menu ul li {
	display: table-cell;
	float: left;
}

.yboard-menu ul li>a:hover{
    color:#66cccc;
}

.menu-link
{
	margin: 0;
	text-decoration: none;
	line-height:24px;
    color:#66cccc;
}

.menu-link a, a:active
{
    color:#66cccc;
}

.menu-link a img
{
    text-decoration:none;
    border:none;
    height:18px;
    height:18px;

}

.yboard-menu ul li.active>a  {
	color: #66cccc;
}

/*Search Box*/

#yboard-header .welcome {
	background-color: transparent;
    padding-top:3px;
    vertical-align:middle;
}

/*Profile Info*/
#yboard-header .yboard-profile-box {
	padding: 5px;
}

#yboard-header .yboard-profile-box a {
	color: #000000;
}

#yboard-header .yboard-profile-box a:hover {
	color: #e6e6e6;
}

/* Page Forum list */
#yboardForum {
     margin:0;
}

#yboardForum .forum-container {
    background:#66cccc;
}

#yboard-wrapper #sidebar{
    padding:0;
    padding-right:15px;
}

#yboard-wrapper #sidebar .portlet{
    background:#66cccc;
    margin-bottom:10px;
}

#yboard-wrapper #sidebar .portlet a{
    color:#666666;
}

#yboard-wrapper #sidebar .portlet .header{
    background:#666666;
    color:#e6e6e6;
    padding:5px;
}

#yboard-wrapper #sidebar .portlet .contents{
}

#yboard-wrapper #sidebar .portlet .contents .even{
    padding:5px;
    background:rgba(230, 230, 230, 0.5);
}

#yboard-wrapper #sidebar .portlet .contents .odd{
    padding:5px;
    background:rgba(230, 230, 230, 0.7);
}

#yboardForum .forum-container .single-foro-item {
    margin-top:0;
    background:#66cccc;
    border-bottom: solid #666666 1px;
}

#yboardForum .forum{
	display: block;
    border-top: solid grey 1px;
}

#yboardForum a {
	color: #666666 ;
}

#yboardForum a:hover {
	color: #666666;
}

/* Forum/Category/Topic header */
#yboard-wrapper .forum-category span{
    padding-left:5px;
}

#yboard-wrapper .forum-category {
	color: #e6e6e6;
	background: #666666;
}

#yboard-wrapper .forum-cell {
	padding: 2px 5px;
	vertical-align: top;
}

/* Unread */
#yboard-wrapper .forum-cell.forum1 {
	width: 48px;
	min-width: 48px;
	height: 48px;
	background-image: url('images/forum_unread.png');
	background-repeat: no-repeat;
	padding: 0;
}

/* Read */
#yboard-wrapper .forum-cell.forum2 {
	width: 48px;
	min-width: 48px;
	height: 48px;
	background-image: url('images/forum.png');
	background-repeat: no-repeat;
	padding: 0;
}

/* Unread hidden */
#yboard-wrapper .forum-cell.forum1h
{
    width: 48px;
	min-width: 48px;
	height: 48px;
	background-image: url('images/forum_unread_hidden.png');
	background-repeat: no-repeat;
	padding: 0;
}

/* read hidden*/
#yboard-wrapper .forum-cell.forum2h
{
    width: 48px;
	min-width: 48px;
	height: 48px;
	background-image: url('images/forum_read_hidden.png');
	background-repeat: no-repeat;
	padding: 0;
}

/* unread locked*/
#yboard-wrapper .forum-cell.forum1l
{
    width: 48px;
	min-width: 48px;
	height: 48px;
	background-image: url('images/forum_unread_locked.png');
	background-repeat: no-repeat;
	padding: 0;
}

/* read locked*/
#yboard-wrapper .forum-cell.forum2l
{
	width: 48px;
	min-width: 48px;
	height: 48px;
	background-image: url('images/forum_read_locked.png');
	background-repeat: no-repeat;
	padding: 0;
}

#yboard-wrapper .forum-cell.forum1m
{
    width: 48px;
	min-width: 48px;
	height: 48px;
	background-image: url('images/forum_unread_moderated.png');
	background-repeat: no-repeat;
	padding: 0;
}

#yboard-wrapper .forum-cell.forum2m
{
    width: 48px;
	min-width: 48px;
	height: 48px;
	background-image: url('images/forum_read_moderated.png');
	background-repeat: no-repeat;
	padding: 0;
}

#yboard-wrapper .forum-cell.forum1lm
{

}

#yboard-wrapper .forum-cell.forum2lm
{
    width: 48px;
	min-width: 48px;
	height: 48px;
	background-image: url('images/forum_read_moderated_locked.png');
	background-repeat: no-repeat;
	padding: 0;
}

.forum-descr-title
{
    font-size:14px;
	vertical-align: middle;
}

#yboard-wrapper .main {
}

/* Page Footer */
#yboard-footer {
	background-color: #fae6d2;
	border-bottom: 2px solid #f03c3c;
	border-top: 6px solid #f03c3c;
    padding:5px;
    opacity:0.8;
	color: #666666;
}

#yboard-footer a {
    color:#f03c3c;
    opacity:0.8;
    text-decoration:none;
}

#yboard-footer a:hover {
    color:#f03c3c;
    text-decoration:underline;
    opacity:1.0;
}

#yboard-footer caption {
	background-color: transparent;
	font-size: 17px;
	font-weight: bold;
}

#yboard-footer .legend {
	vertical-align: middle;
}

#yboard-footer .statistics {
	vertical-align: top;
}

#yboard-footer a.spider {
	color: #ff8c00;
}
/* Topic list */
#yboardTopic {
}

#yboardTopic a {
	color: #666666 ;
}

#yboardTopic .topic {
	background-color: #66cccc;
	display: block;
    border-top: dotted grey 1px;
    padding:5px;
}

#yboardTopic li.selected  a {
	background-color: #aaaaaa;
}

#yboardTopic li.selected  a:hover {
	color: #e6e6e6;
}

#yboardTopic a.posted:after {
	color: silver;
	content: " \272f";
}

/*Topic*/
#yboard-wrapper .forum-cell.topic1l,
#yboard-wrapper .forum-cell.topic2l
{
	width: 24px;
	min-width: 24px;
	height: 24px;
	background-image: url('images/topic_locked.png');
	background-repeat: no-repeat
}

#yboard-wrapper .forum-cell.topic1
{
	width: 24px;
	min-width: 24px;
	height: 24px;
	background-image: url('images/topic_new.png');
	background-repeat: no-repeat
}

#yboard-wrapper .forum-cell.topic2 {
	width: 24px;
	min-width: 24px;
	height: 22px;
	background-image: url('images/topic.png');
	background-repeat: no-repeat;
}

#yboard-wrapper .forum-cell.topic1l
{
	width: 36px;
	min-width: 36px;
	height: 36px;
	background-image: url('images/topic_locked.png');
	background-repeat: no-repeat;
	padding: 0;
}

#yboard-wrapper .forum-cell.topic1s ,
#yboard-wrapper .forum-cell.topic2s
{
	width: 36px;
	min-width: 36px;
	height: 36px;
	background-image: url('images/topic_sticky.png');
	background-repeat: no-repeat;
	padding: 0;
}

#yboard-wrapper .forum-cell.topic1p,
#yboard-wrapper .forum-cell.topic2p
{
	width: 36px;
	min-width: 36px;
	height: 36px;
	background-image: url('images/topic_poll.png');
	background-repeat: no-repeat;
	padding: 0;
}

#yboard-wrapper .forum-cell.topic1g,
#yboard-wrapper .forum-cell.topic2g
{
	width: 36px;
	min-width: 36px;
	height: 36px;
	background-image: url('images/topic_global.png');
	background-repeat: no-repeat;
	padding: 0;
}

/* Post list */
#yboardPost {
	background-color: #fae6d2;
}

#yboardPost .avatar {
    padding:5px 0 10px 10px;
	max-width: 180px;
}

#yboardPost .avatar img{
    border:solid grey 1px;
    padding:0;
}

#yboardPost .avatar-mobile {
	max-width: 90px;
	max-height: 90px;
}

#yboardPost .avatar-mobile img{
    border:solid grey 1px;
    padding:0;
    width:50px;
}

#yboardPost .member-mobile .header2{
    color:#666666;
    padding-left:5px;
    font-weight:normal;
}

#yboardPost .user-info-box.user-info {
    padding:5px;
}

#yboardPost #posted-time{
    border-bottom: solid #ff6b6b 1px;
    padding:5px;
}

#yboardPost .member-cell {
	text-align: center;
    color:#ff6b6b;
    font-weight:bold;
}

#yboardPost .member-cell .membername {
	text-align: center;
}

#yboardPost .member-cell .group {
	text-align: center;
}

#yboardPost a {
    color:#b23939;
}

#yboardPost a:hover {
    color:#4196cc;
}

#yboardPost li.selected  a {
	background-color: #aaaaaa;
}

#yboardPost li.selected  a:hover {
	color: #e6e6e6;
}

#yboardPost .post-content {
	padding: 10px;
    font-size:15px;
}

#yboardPost .post-content blockquote {
	border: solid 1px #cccccc;
	margin: 15px;
	padding: 5px 10px;
    display: inline-block;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    font-size:15px;
}

#yboardPost .quotation-content p {
    padding-top:10px;
}

#yboardPost .quotation-username {
    color:#ff6b6b;
    font-weight:bold;
}

#yboardPost .quotation-date {
    font-style:italic;
}

#yboardPost .quotation-header {
    border-bottom: solid #000000 1px;
	background-image: url('images/quote-icon-left.png');
	background-repeat: no-repeat;
	padding-left:25px;
	padding-bottom:5px;
	margin-bottom:10px;
}

#yboardPost .signature {
    border-top: dotted #c9c7c7 1px;
    padding:10px 15px 15px 15px;
    color:#666666;
    opacity:0.8;
}

#yboardPost .action-buttons {
    /*border-bottom: solid  #666666 1px; */

}

#yboardPost .post-bottom {
    height:5px;
    border-bottom: solid #666666 1px;
    padding:0;
    margin-bottom:10px;

}

#yboardPost .post-time {
    background:#66cccc;
    color:#666666;
    padding:5px;

}

#yboardPost .post-time a{
    background:#66cccc;
    color:#e6e6e6;

}

#yboardPost .toolbar {
	padding: 5px 0 10px 10px;
}

#yboardPost .toolbar form{
    padding:3px;
    float:left;
}

/*Poll stuffs*/
.yboard-poll-button {
	padding-top:5px;
	padding-bottom:5px;
}

.yboard-poll
{
    padding:5px;
    margin-left:5px;
}

#yboardPoll
{
    padding:5px;
}

#yboardPoll .ui-progressbar
{
    background:#aaaaaa;
    height:20px;
    max-width:300px;;
}

#yboardPoll .ui-progressbar-value
{
    background:#ff6b6b;
    height:20px;
    max-width:300px;;
}

.yboard-panel
{
    padding:5px;
    margin-top:5px;
}

/*bread crumbs*/
#breadcrumbs
{
    margin-bottom:30px;
	border-bottom: 1px solid #666666;
    background:#fae6d2;
}

#breadcrumbs .breadcrumb
{
    -webkit-border-radius: 0;
    -moz-border-radius: 0;
    border-radius: 0;

    margin:0;
    background:#fae6d2;
}

#breadcrumbs .breadcrumb a,
#breadcrumbs .breadcrumb a:visited
{
    color:#f03c3c;
    opacity:0.5;
}

/*User info*/
.yboard-member-view
{
    background:#e6e6e6;
    color:#666666;
}

.yboard-member-view li>a
{
    color:#66cccc;
    font-weight:bold;
}

.yboard-member-view .header2
{
    color:#ff6b6b;
}

.yboard-member-view .active
{
    background:#fae6d2;
}

/*Forum settings/Layout*/
#yboard-wrapper #sortcategory
{
    background:#666666;
    color:#fae6d2;
    padding:0 0 10px 0;
    margin:0;

}

#yboard-wrapper .forum-item
{
    background:#e6e6e6;
    color:#b23939;
    border-top: solid black 1px;
}

#yboard-wrapper .sortable
{
    background:#b23939;
    color:#fae6d2;
    padding:0;
    border-left:solid #666666 1px;
    border-right:solid #666666 1px;
}

/*Forum members*/
#yboard-member-index
{

}

.single-member
{
    border: solid #666666 1px;
    padding:5px 0 0 0;
    margin-bottom:10px;
    background:#fae6d2;
    color:#666666;
}
.single-member a
{
    color:#66cccc;
}

.yboard-member-search
{
}

#user-avatar
{
    padding:2px;
    border:solid grey 1px;
}

/*Helpers*/
.header2-style
{
    background:#666666;
    color:#66cccc;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    display: block;
    margin-bottom: -1px;
    padding: 10px 15px;
    position: relative;
}

.unread
{
    font-weight:bold;
    color:#f03c3c;
    opacity:0.8;
}

.list-group-item a
{
    color:#f03c3c;
    opacity:0.8;
}

.center-element
{
    margin-left: auto;
    margin-right: auto;
    width: 70%;
}
.vertical-center-element
{
    margin-top: auto;
    margin-bottom: auto;
    height: 70%;
}

.center {
	text-align: center;
}
.pad5 {
	padding: 5px;
}
.pad5-bottom {
	padding-bottom: 5px;
}

.pad5-top{
	padding-top: 5px;
}

.pad5-left{
	padding-left: 5px;
}

.pad5-right{
	padding-right: 5px;
}

.pad15{
	padding: 15px;
}

.pad15-left{
	padding-left: 15px;
}

.pad15-right{
	padding-right: 15px;
}

.pad15-top{
	padding-top: 15px;
}

.pad15-bottom{
	padding-bottom: 15px;
}

.no-padding
{
    padding:0;
}

.margin5 {
	margin: 5px;
}

.margin5-top {
	margin-top: 5px;
}

.spacer {
    margin-bottom: 40px;
}

/*paging*/

.pagination
{
    padding:0;
    margin:15px;
}

.pagination li>a
{
    background:#fae6d2;
}

li.pager-active
{
    background:#66cccc;
}

li.pager-active>a
{
    background:#66cccc;
}
li.pager-active a:hover
{
    color:#e6e6e6;
    background:#666666;
}

li.pager-disabled span
{
    background:#fae6d2;
    color:#666666;
}

li.pager-disabled span:hover
{
    background:#fae6d2;
}

li.pager-prev a
{
    background:#fae6d2;
    color:#f03c3c;
}

li.pager-prev a:hover
{
    background:#fae6d2;
    color:#66cccc;
}

li.pager-next a
{
    background:#fae6d2;
    color:#f03c3c;
}

li.pager-next a:hover
{
    background:#fae6d2;
    color:#66cccc;
}

/*buttons*/
.btn-info
{
    background:#4196cc;
}
.form
{
    padding-left :5px;
    padding-right :5px;
}

.note
{
    padding:5px;
}

/*Bootstrap custom navbar code*/
.navbar-custom {
  background-color: #f03c3c;
  border-color: #ee1d1d;
  margin-bottom:0;
  opacity:0.8;
}
.navbar-custom .navbar-brand {
  color: #fae6d2;
}
.navbar-custom .navbar-brand:hover,
.navbar-custom .navbar-brand:focus {
  color: #f5cda4;
  background-color: transparent;
}
.navbar-custom .navbar-text {
  color: #fae6d2;
}
.navbar-custom .navbar-nav > li > a {
  color: #fae6d2;
}
.navbar-custom .navbar-nav > li > a:hover,
.navbar-custom .navbar-nav > li > a:focus {
  color: #e6e6e6;
  background-color: transparent;
}
.navbar-custom .navbar-nav > .active > a,
.navbar-custom .navbar-nav > .active > a:hover,
.navbar-custom .navbar-nav > .active > a:focus {
  color: #e6e6e6;
  background-color: #ee1d1d;
}
.navbar-custom .navbar-nav > .disabled > a,
.navbar-custom .navbar-nav > .disabled > a:hover,
.navbar-custom .navbar-nav > .disabled > a:focus {
  color: #cccccc;
  background-color: transparent;
}
.navbar-custom .navbar-toggle {
  border-color: #dddddd;
}
.navbar-custom .navbar-toggle:hover,
.navbar-custom .navbar-toggle:focus {
  background-color: #dddddd;
}
.navbar-custom .navbar-toggle .icon-bar {
  background-color: #cccccc;
}
.navbar-custom .navbar-collapse,
.navbar-custom .navbar-form {
  border-color: #ed1b1b;
}
.navbar-custom .navbar-nav > .dropdown > a:hover .caret,
.navbar-custom .navbar-nav > .dropdown > a:focus .caret {
  border-top-color: #e6e6e6;
  border-bottom-color: #e6e6e6;
}
.navbar-custom .navbar-nav > .open > a,
.navbar-custom .navbar-nav > .open > a:hover,
.navbar-custom .navbar-nav > .open > a:focus {
  background-color: #ee1d1d;
  color: #e6e6e6;
}
.navbar-custom .navbar-nav > .open > a .caret,
.navbar-custom .navbar-nav > .open > a:hover .caret,
.navbar-custom .navbar-nav > .open > a:focus .caret {
  border-top-color: #e6e6e6;
  border-bottom-color: #e6e6e6;
}
.navbar-custom .navbar-nav > .dropdown > a .caret {
  border-top-color: #fae6d2;
  border-bottom-color: #fae6d2;
}
@media (max-width: 767) {
  .navbar-custom .navbar-nav .open .dropdown-menu > li > a {
    color: #fae6d2;
  }
  .navbar-custom .navbar-nav .open .dropdown-menu > li > a:hover,
  .navbar-custom .navbar-nav .open .dropdown-menu > li > a:focus {
    color: #e6e6e6;
    background-color: transparent;
  }
  .navbar-custom .navbar-nav .open .dropdown-menu > .active > a,
  .navbar-custom .navbar-nav .open .dropdown-menu > .active > a:hover,
  .navbar-custom .navbar-nav .open .dropdown-menu > .active > a:focus {
    color: #e6e6e6;
    background-color: #ee1d1d;
  }
  .navbar-custom .navbar-nav .open .dropdown-menu > .disabled > a,
  .navbar-custom .navbar-nav .open .dropdown-menu > .disabled > a:hover,
  .navbar-custom .navbar-nav .open .dropdown-menu > .disabled > a:focus {
    color: #cccccc;
    background-color: transparent;
  }
}
.navbar-custom .navbar-link {
  color: #fae6d2;
}
.navbar-custom .navbar-link:hover {
  color: #e6e6e6;
}

.navbar a.navbar-brand
{
    padding: 0;
}

@media (max-width: 767px) {
    .navbar-brand {
        padding: 0;
    }

    .navbar-brand img {
        margin-top: 5px;
        margin-left: 5px;
    }
}


code:
function showAppreciation(members)
{
    $("#appreciated-content").html(unescape(members));
    $("#dlg-appreciated").dialog('open');
}

function viewMessage(id, url) {
	request = {'id':id};
	$('#yboard-message').addClass('spinner');
	$('#yboard-message').html('');
	$.post(url, request, function(data) {
		if(data.success == 'yes') {
			$('#yboard-message').removeClass('spinner');
            //clear unread status
            $('#msg_id_'+id).removeClass(); //remove all classes
			$("#yboard-message").html(data.html);
		} else {
			$('#yboard-message').removeClass('spinner');
			alert(data.message);
		}
	}, 'json');
}

function replyMessage(to) {
	$('#field-yboardmessage-subject').hide();
	$('#YBoardMessage_send_to').val(to);
    $("#dlgPrivateMsg" ).dialog('open');
}

function viewPost(id, url) {
	request = {'id':id};
	$('#yboard-message').toggleClass('spinner');
	$('#yboard-message').html('');
	$.post(url, request, function(data) {
		if(data.success == 'yes') {
			$("#yboard-message").html(data.html);
			$('#yboard-message').toggleClass('spinner');
		} else {
			alert(data.message);
			$('#yboard-message').toggleClass('spinner');
		}
	}, 'json');
}

function deletePost(url) {
	request = {'ajax': '1'};
	$.ajax({
		url: url,
		type: "GET",
		dataType: "json",
		data: request
	}).done(function(data){
        location.reload();
    });
}

function sendPm(uid) {
	$('#YBoardMessage_send_to').val(uid);
    $("#dlgPrivateMsg" ).dialog('open');
}

function sendPMForm() {
	formdata = $('#pm-form').serialize();
	url = $('#pm-url').val();
	$.post(url, formdata, function(data) {
		if(data.success == 'yes') {
			alert(data.message);
			$("#dlgPrivateMsg").dialog('close');
            location.reload();
		} else {
			alert(data.message);
		}
	}, 'json');
}

function reportPost(id) {
	$('#YBoardMessage_post_id').val(id);
	$('#dlgReportForm').dialog('open');
}

function sendReport() {
	formdata = $('#report-form').serialize();
	url = $('#url').val();
	$.post(url, formdata, function(data) {
		if(data.success == 'yes') {
			alert(data.message);
			$("#dlgReportForm").dialog('close');
		} else {
			alert(data.message);
			$("#dlgReportForm").dialog('close');
		}
	}, 'json');
}

function banIp(id, url) {
	url = url + /id/ + id;
	$.get(url);
}

/** Ban User with ID in URL
 * @param url string
 */
function banUser(bannedBy, url) {
	if(bannedBy != undefined) {
        $("#dlg-ban").dialog("option", "buttons", [
            {
                text: "Close", click: function() {
                    $( this ).dialog( "close" );
                }
            },
            {
                text: "Ban", click: function() {

                    request = {
                        'banned_by':bannedBy,
                        'message':$('#ban-message').val(),
                        'expires':$('#ban-expires').val(),
                    };

                    $.post(url, request, function(data) {
                        if(data.success == 'yes') {
                            location.reload();
                        } else {
                            alert(data.message);
                        }
                    }, 'json');
                }
            }
        ]).dialog('open');
	}
}

/** Lift Ban */
function banLift(url) {
	$.post(url, function(data) {
		if(data.success == 'yes') {
            location.reload();
		} else {
            alert(data.error);
		}
	}, 'json');
}

/** Show Ban reason */
function banMessage(msg) {
    $('#dlgBanMsgText').text(msg);
	$('#dlgBanMsg').dialog('open');
}

function refreshTopics(obj, url) {
	$.post(url, {'id': obj.value}, function(data) {
		if(data.success == 'yes') {
			$('#YBoardTopic_merge').html(data.option);
		} else {
			alert(data.message);
		}
	}, 'json');
	return false;
}

function upvotePost(id, author, url) {
	$.post(url, {'author': author, 'id': id}, function(data) {
		if(data.success == 'yes') {
			//$('#upvote_'+id).replaceWith(data.html);
            location.reload();
		}
	}, 'json');
	return false;
}

// Poll functions
function showPoll() {
	togglePoll();
	$('#addPoll').val('yes');
}

function hidePoll() {
	togglePoll();
	$('#addPoll').val('no');
}

function togglePoll() {
	$('#poll-button').toggle();
	$('.poll-form-showhide').toggle();
}

function pollChange(obj) {
	id = obj.id;
	text = obj.value;
	if(text.length > 0) {
		addChoice();
	} else {
        alert(id);
		removeChoice(id);
	}
}

function addChoice() {
	allfilled = true;
	$('#poll-choices>div').children('input').each(function(){
		if(this.value.length == 0) {
			allfilled = false;
		}
	});
	if(allfilled) {
		last_id = $('#poll-choices input:last').attr('id');
		id = last_id.split('_')[1];
		id++;
		html = '
<input id="choice_'+id+'" type="text" name="choice['+id+']" value="" onchange="pollChange(this)" class="form-control">
';
		$('#poll-choices').append(html);
		$('#poll-choices input:last').focus();
	}
}

function removeChoice(id) {
	n = $('#poll-choices').children('input').size();
	if(n > 2) {
		$('#'+id).remove();
		addChoice();
	}
}

function vote(url) {
	formdata = $('#yboard-poll-form').serialize();
	$.post(url, formdata, function(data) {
		if(data.success == 'yes') {
			$("#poll").html(data.html);
		}
	}, 'json');
}

function changeVote(poll_id, url) {
	formdata = {'poll_id':poll_id};
	$.post(url, formdata, function(data) {
		if(data.success == 'yes') {
			$("#poll").html(data.html);
		}
	}, 'json');
}

function editPoll(poll_id, url) {
	formdata = {'poll_id':poll_id};
	$.post(url, formdata, function(data) {
		if(data.success == 'yes') {
			$("#poll").html(data.html);
			/*$('#expiredate').datepicker($.extend({showMonthAfterYear:false},$.datepicker.regional[language],
				{'altField':'#YBoardPoll_expire_date','altFormat':'yy-mm-dd','showAnim':'fold','defaultDate':7,'minDate':1}
			));*/
		}
	}, 'json');
}

YBoard = {
	topicApprove: function(id, url) {
		$.post(url, function(data) {
			if(data.success == 'yes') {
                $('#'+id).remove();
			} else {
                alert(data.error);
			}
		}, 'json');
	},
	changeTopic: function(url) {
		formdata = $('#update-topic-form').serialize();
		$.post(url, formdata, function(data) {
			if(data.success == 'yes') {
				$("#dlgTopicForm").dialog('close');
                location.reload();
			} else {
				settings = $('#update-topic-form').data('settings');
                //TODO: Update to yii2
				$.each(settings.attributes, function () {
					$.fn.yiiactiveform.updateInput(this, data.error, $('#update-topic-form'));
				});
			}
		}, 'json');
	},
	toggleForumGroup: function(id, url) {
		if($('#category_'+id).css('display') == 'none') {
			action = 'unset';
		} else {
			action = 'set';
		}
		$('#category_'+id).toggle('fold',{size:1},'fast');
		data = {id:id,action:action};
		$.post(url, data, function(data) {}, 'json');

	},
	updateTopic: function(id, url) {
        $("#yboard-post-update-id").attr('value', id);
		$.post(url, {'id': id}, function(data) {
			if(data.success == 'yes') {
				$('#YBoardTopic_id').val(id);
                //from post
				$('#YBoardTopic_forum_id').val(data.forum_id);
				$('#YBoardTopic_title').val(data.title);
				$('#YBoardTopic_locked').val(data.locked);
				$('#YBoardTopic_sticky').val(data.sticky);
				$('#YBoardTopic_global').val(data.global);
				$('#YBoardTopic_approved').val(data.approved);
				$('#YBoardTopic_merge').html(data.option);
				$("#dlgTopicForm").dialog('open');
			} else {
				alert(data.message);
				$("#dlgTopicForm").dialog('close');
			}
		}, 'json');
	},

	postUpdateDialog: function(url) {
		$.post(url, function(data) {
			if(data.success == 'yes') {
				$('#dlgUpdatePostFormHolder').html(data.html);
				$("#dlgUpdatePostForm").dialog('open');
			}
            else {
				alert(data.error);
                $('#dlgUpdatePostFormHolder').html('');
				$("#dlgUpdatePostForm").dialog('close');
			}
		}, 'json');
	},

	updateModPost: function(url) {
        for(iname in CKEDITOR.instances)
            CKEDITOR.instances[iname].updateElement();

        formdata = $('#create-topic-form').serialize();
		$.post(url, formdata, function(data) {
			if(data.success == 'yes') {
				$("#dlgUpdatePostForm").dialog('close');
                location.reload();
			}
            else {
				alert(data.error);
                $('#dlgUpdatePostFormHolder').html('');
				$("#dlgUpdatePostForm").dialog('close');
			}
		}, 'json');
	},

    postApprove: function(id, url) {
		$.post(url, function(data) {
			if(data.success == 'yes') {
                $('#'+id).remove();
			} else {
                alert(data.error);
			}
		}, 'json');
	},

    viewPost: function(html) {
        html = $("
").html(html).text();
        $('#dlgapproveMsgText').html(html);
        $('#dlgapproveMsg').dialog('open');
	},
}

license: mit


code:
/** Sorting function
 * @param obj HtmlElement Object
 * @param url string
*/
function Sort(obj, url) {
	var sort = $('#'+obj.id).sortable('serialize');
	$.ajax({
		url: url,
		type: "POST",
		dataType: "json",
		data: sort,
		success: function(data){
		},
		error: function(error){
			 console.log("Error:");
			 console.log(error);
		}
	});
}

//Settings
function newSetting(url)
{
    $("#dlgNewSetting").dialog();
    $("#dlgNewSetting").dialog('open');
}

function updateSetting(url, key, value)
{
    $("#yboard-setting-key").val(key);
    $("#yboard-setting-value").val(value);

    $("#dlgNewSetting").dialog({
        buttons: [
            {
                text: "Cancel", click: function(){
                    $(this).dialog( "close" );
                    location.reload();
                }
            } ,
            {
                text: "Save", click: function() {
                    var formdata = $('#yboard-setting-form').serialize();
                    $.post(url, formdata, function(data) {
                        if(data.success == 'yes') {
                            location.reload();
                        } else {
                            alert(data.error);
                        }
                    }, 'json');
                }
            }
        ]
    });

    $("#dlgNewSetting").dialog('open');

}

function saveSetting(url)
{
    $("#dlgNewSetting").dialog();
    var formdata = $('#yboard-setting-form').serialize();
	$.post(url, formdata, function(data) {
		if(data.success == 'yes') {
			$("#dlgNewSetting").dialog('close');
			location.reload();
		} else {
            alert(data.error);
			//settings = $('#edit-forum-form').data('settings');
			//$.each(settings.attributes, function () {
				//$.fn.yiiactiveform.updateInput(this, data.error, $('#edit-forum-form'));
			//});
		}
	}, 'json');
}

/** Open dlgEditForum for editing Forum
 * @param id integer
 * @param val string
 */
function editForum(id, val, url) {
	var request = {'id':id};
	$("#dlgEditForum").dialog('option', 'title', val);
	$('.YBoardForum_type').show();
	$('.YBoardForum_category').show();
	$('.YBoardForum_public').show();
	$('.YBoardForum_locked').show();
	$('.YBoardForum_moderated').show();
	$('.YBoardForum_polls').show();

	$.getJSON(url, request, function(data){
		$('#YBoardForum_id').val(data.id);
		$('#YBoardForum_name').val(data.name);
		$('#YBoardForum_subtitle').val(data.subtitle);
		$('#YBoardForum_sort').val(data.sort);
        $('#YBoardForum_category').val(data.cat_id);
		$('#YBoardForum_public').val(data.public);
		$('#YBoardForum_locked').val(data.locked);
		$('#YBoardForum_moderated').val(data.moderated);
		$('#YBoardForum_type').val(data.type);
		$('#YBoardForum_membergroup_id').val(data.membergroup_id);
		$('#YBoardForum_polls').val(data.poll);
	});
	$("#dlgEditForum").dialog('open');
}

/** Delete Forum or Category */
function deleteForum(url) {
	var val = confirmation[$('#YBoardForum_type').val()];
	var id = $('#YBoardForum_id').val();
	var request = {'id':id};
	if(confirm(val)) {
		$.post(url, request, function(data) {
			if(data.success == 'yes') {
				$("#dlgEditForum").dialog('close');
				location.reload();
			} else {
				alert(data.message);
			}
		}, 'json');
	}
}

/** Save Forum or Category */
function saveForum(url) {
	var formdata = $('#edit-forum-form').serialize();
	$.post(url, formdata, function(data) {
		if(data.success == 'yes') {
			$("#dlgEditForum").dialog('close');
			location.reload();
		} else {
            console.log(data.error);
            alert(data.error);
		}
	}, 'json');
}

/** Open dlgEditForum for editing Category
 * @param id integer
 * @param val string
 */
function editCategory(id, val, url) {
	var request = {'id':id};
	$("#dlgEditForum").dialog('option', 'title', val);
	//$('.YBoardForum_category').hide();
	$('.YBoardForum_public').hide();
	$('.YBoardForum_locked').hide();
	$('.YBoardForum_moderated').hide();
	$('.YBoardForum_polls').hide();

	$.getJSON(url, request, function(data){
		$('#YBoardForum_id').val(data.id);
		$('#YBoardForum_name').val(data.name);
		$('#YBoardForum_category').val(data.category);
		$('#YBoardForum_category').val(data.category);
		$('#YBoardForum_sort').val(data.sort);
		$('#YBoardForum_type').val(data.type); //the ID of parent Forum?
 	});
	$("#dlgEditForum").dialog('open');
}

/** Open dlgEditMembergroup for creating or editing Membergroup
 * @param id integer
 * @param url string
 */
function editMembergroup(id, url) {
	var request = {'id':id};
	if(id == undefined) {
			$('#YBoardMembergroup_name').val('');
			$('#YBoardMembergroup_description').val('');
			$('#YBoardMembergroup_image').val('');
			$('#YBoardMembergroup_group_role').val('');
			$("#dlgEditMembergroup").dialog('open');
	} else {
		$.getJSON(url, request, function(data){
			$('#YBoardMembergroup_id').val(data.id);
			$('#YBoardMembergroup_name').val(data.name);
			$('#YBoardMembergroup_description').val(data.description);
			$('#YBoardMembergroup_image').val(data.image);
			$('#YBoardMembergroup_group_role').val(data.group_role);
            $("#YBoardMembergroup_color").spectrum("set", data.color);
		});
		$("#dlgEditMembergroup").dialog('open');
	}
}

/** Delete Membergroup */
function deleteMembergroup(url) {
	var id = $('#YBoardMembergroup_id').val();
	var request = {'id':id};
	if(confirm(confirmation)) {
		$.post(url, request, function(data) {
			if(data.success == 'yes') {
				$("#dlgEditMembergroup").dialog('close');
				location.reload();
			} else {
				alert(data.message);
			}
		}, 'json');
	}
}

/** Save Membergroup */
function saveMembergroup(url) {
	var formdata = $('#edit-membergroup-form').serialize();
	$.post(url, formdata, function(data) {
		if(data.success == 'yes') {
			$("#dlgEditMembergroup").dialog('close');
            location.reload();
		} else {
            alert(data.error);
			/*settings = $('#edit-membergroup-form').data('settings');
			$.each(settings.attributes, function () {
				$.fn.yiiactiveform.updateInput(this, data.error, $('#edit-membergroup-form'));
			});*/
		}
	}, 'json');
}

/** Delete Member*/
function deleteMember(url) {
    $.post(url, function(data) {
        if(data.success == 'yes') {
            alert('Done!');
            location.reload();
        } else {
            alert(data.error);
        }
    }, 'json');
}

/** Open dlgEditRank for creating or editing Ranks
 * @param id integer
 * @param url string
 */
function editRank(id, url) {
	var request = {'id':id};
	if(id == undefined) {
			$('#YBoardRank_title').val('');
			$('#YBoardRank_min_posts').val('');
			$('#YBoardRank_stars').val('');
			$("#dlgEditRank").dialog('open');
	} else {
		$.getJSON(url, request, function(data){
			$('#YBoardRank_id').val(data.id);
			$('#YBoardRank_title').val(data.title);
			$('#YBoardRank_min_posts').val(data.min_posts);
			$('#YBoardRank_stars').val(data.stars);
		});
		$("#dlgEditRank").dialog('open');
	}
}

/** Delete Rank */
function deleteRank(url) {
	var id = $('#YBoardRank_id').val();
	var request = {'id':id};
	if(confirm(confirmation)) {
		$.post(url, request, function(data) {
			if(data.success == 'yes') {
				$("#dlgEditRank").dialog('close');
				location.reload();
			} else {
				alert(data.message);
			}
		}, 'json');
	}
}

/** Save Rank */
function saveRank(url) {
	var formdata = $('#edit-rank-form').serialize();
	$.post(url, formdata, function(data) {
		if(data.success == 'yes') {
			$("#dlgEditRank").dialog('close');
            location.reload();
		} else {
            alert(data.error);
			/*settings = $('#edit-membergroup-form').data('settings');
			$.each(settings.attributes, function () {
				$.fn.yiiactiveform.updateInput(this, data.error, $('#edit-membergroup-form'));
			});*/
		}
	}, 'json');
}

var YBoardSetting = {
	EditSpider: function(id,url) {
		var request = {'id':id};
		if(id == undefined) {
				$('#YBoardSpider_name').val('');
				$('#YBoardSpider_user_agent').val('');
				$("#dlgEditSpider").dialog('open');
		} else {
			$.getJSON(url, request, function(data){
				$('#YBoardSpider_id').val(data.id);
				$('#YBoardSpider_name').val(data.name);
				$('#YBoardSpider_user_agent').val(data.user_agent);
			});
			$("#dlgEditSpider").dialog('open');
		}
	},
	DeleteSpider: function(url) {
		var id = $('#YBoardSpider_id').val();
		var request = {'id':id};
		if(confirm(confirmation)) {
			$.post(url, request, function(data) {
				if(data.success == 'yes') {
					$("#dlgEditSpider").dialog('close');
                    location.reload();
				} else {
					alert(data.message);
				}
			}, 'json');
		}
	},
	SaveSpider: function(url) {
		var formdata = $('#edit-spider-form').serialize();
		$.post(url, formdata, function(data) {
			if(data.success == 'yes') {
				$("#dlgEditSpider").dialog('close');
                location.reload();
			} else {
                alert(data.message);
			}
		}, 'json');
	}
}


code:
<?php
namespace app\modules\yboard\components;

use app\modules\yboard\models\YBoardMember;
use DateTime;
use DateTimeZone;

class DateTimeCalculation {
	static public function shortDate($timestamp) {
		$df = \Yii::$app->formatter;
		return $df->asDate(self::userTimestamp($timestamp), 'short');
	}

	static public function longDate($timestamp) {
		$df = \Yii::$app->formatter;
		return $df->asDate(self::userTimestamp($timestamp), 'long');
	}

	static public function medium($timestamp) {
		$df = \Yii::$app->formatter;
		return $df->asDatetime(self::userTimestamp($timestamp), 'medium');
	}

	static public function short($timestamp) {
		$df = \Yii::$app->formatter;
		return $df->asDatetime(self::userTimestamp($timestamp), 'short');
	}

	static public function long($timestamp) {
		$df = \Yii::$app->formatter;
		return $df->asDatetime(self::userTimestamp($timestamp), 'long');
	}

	static public function full($timestamp) {
		$df = \Yii::$app->formatter;
		return $df->asDatetime(self::userTimestamp($timestamp), 'full') . ' ' . self::userTimezoneNotation();
	}

	/**
	 * Precursor function to convert timestamp for user
	 * @param string $timestamp timestamp format 'yyyy-MM-dd hh:mm:ss'
	 * @return string timestamp format 'yyyy-MM-dd hh:mm:ss'
	 */
	static public function userTimestamp($timestamp) {
        if(!is_numeric($timestamp))  //skip for unix timestamps
        {
            $dt = new DateTime($timestamp);
            $timestamp = $dt->getTimestamp();
        }

		if(\Yii::$app->user->isGuest) {
			return $timestamp;
		}
		$timezone = YBoardMember::findOne(\Yii::$app->user->id);

        if($timezone==null||!isset($timezone->profile->timezone)) {
			return $timestamp;
		}
        else if(empty($timezone->profile->timezone))
        {
			return $timestamp;
        }else {
			return self::convertTimestamp($timestamp, $timezone->profile->timezone);
		}
	}

	/**
	 * Convert timestamp from server time to time in target timezone
	 * @param string $timestamp timestamp format 'yyyy-MM-dd hh:mm:ss'
	 * @param string $timezone e.g. 'Europe/Paris'
	 * @return string timestamp format 'yyyy-MM-dd hh:mm:ss'
	 */
	static public function convertTimestamp($timestamp, $timezone) {
        $datetime = new DateTime('', new DateTimeZone($timezone));
        $datetime->setTimeStamp($timestamp);
        return $datetime->format('Y-m-d H:i:s');
	}

	/**
	 * Return the timezone notation for the user
	 * @return string
	 */
	static public function userTimezoneNotation() {
		if(\Yii::$app->user->isGuest) {
			$timezone = date_default_timezone_get();
		} else {
			$timezone = YBoardMember::findOne(\Yii::$app->user->id);
            if(isset($timezone->profile->timezone))
                $timezone = $timezone->profile->timezone;

			if(empty($timezone)) {
				$timezone = date_default_timezone_get();
			}
		}
		$dateTime = new DateTime();
		$dateTime->setTimeZone(new DateTimeZone($timezone));
		return $dateTime->format('T');
	}

    /**
	 * Return the difference btn dates formatted
     * inputs are unix timestamps
	 * @return string
	 */
	static public function getDiff($past, $future)
    {
        $days = floor(abs(($future-$past)/(60*60*24)));
        $secs = abs(($future-$past)%(60*60*24));
        $hrs = ceil($secs/(60*60));

        return ['days'=>$days, 'hours'=>$hrs];
    }
}


code:
<?php
namespace app\modules\yboard\components;

use yii\base\Widget;
use yii\helpers\Html;

class SimpleSearchForm extends Widget
{
    public $options = [];
    public $model = null;

    public function init()
    {
        parent::init();
        if(!isset($this->options['action']))
        {
            $this->options['action'] = 'search/index';
        }
    }

    public function run()
    {
        $form = \yii\widgets\ActiveForm::begin([
            'id'=>'simple-search-form',
			'action'=> [$this->options['action']],
			'enableAjaxValidation'=>false,
        ]);

        echo Html::textInput('search', null, ['class'=>'form-control', 'hint'=>YBoard::t('yboard', 'Search')]);
        echo Html::hiddenInput('type', '0');
        echo Html::hiddenInput('choice', '0');
        Html::submitButton('Submit', ['class' => 'small-search-button'])  ;

        \yii\widgets\ActiveForm::end();
    }
}


code:
<?php

namespace app\modules\yboard\components;

use yii\helpers\HtmlPurifier;

class Utils {
	static public function cleanHtml($html) {

        return HtmlPurifier::process($html, [
            'Attr.EnableID' => false,
        ]);
	}
}


code:
<?php

namespace app\modules\yboard\components\rbac;

use yii\rbac\Rule;

/**
 * Checks if blog owner matches user passed via params
 */
class PollRule extends Rule
{
    public $name = 'isYourPoll';

    /**
     * @param string|integer $user the user ID.
     * @param Item $item the role or permission that this rule is associated with
     * @param array $params parameters passed to ManagerInterface::checkAccess().
     * @return boolean a value indicating whether the rule permits the role or permission it is associated with.
     */
    public function execute($user, $item, $params)
    {
        return isset($params['poll']) ? $params['poll']->user_id == $user || $params['isModerator'] : false;
    }
}


code:
<?php

namespace app\modules\yboard\components\rbac;

use yii\rbac\Rule;

/**
 * Checks if blog owner matches user passed via params
 */
class PostRule extends Rule
{
    public $name = 'isYourPost';

    /**
     * @param string|integer $user the user ID.
     * @param Item $item the role or permission that this rule is associated with
     * @param array $params parameters passed to ManagerInterface::checkAccess().
     * @return boolean a value indicating whether the rule permits the role or permission it is associated with.
     */
    public function execute($user, $item, $params)
    {
        return isset($params['post']) ? ($params['post']->user_id == $user && $params['post']->topic->locked==0) || $params['isModerator'] : false;
    }
}


code:
<?php

namespace app\modules\yboard\components\rbac;

use yii\rbac\Rule;

/**
 * Checks if blog owner matches user passed via params
 */
class PrivateMessageRule extends Rule
{
    public $name = 'isMessageYours';

    /**
     * @param string|integer $user the user ID.
     * @param Item $item the role or permission that this rule is associated with
     * @param array $params parameters passed to ManagerInterface::checkAccess().
     * @return boolean a value indicating whether the rule permits the role or permission it is associated with.
     */
    public function execute($user, $item, $params)
    {
        return isset($params['message']) ? $params['message']->sendfrom == $user || $params['message']->sendto == $user : false;
    }
}


code:
<?php

namespace app\modules\yboard\components\rbac;

use yii\rbac\Rule;

/**
 * Checks if blog owner matches user passed via params
 */
class ProfileRule extends Rule
{
    public $name = 'isYourprofile';

    /**
     * @param string|integer $user the user ID.
     * @param Item $item the role or permission that this rule is associated with
     * @param array $params parameters passed to ManagerInterface::checkAccess().
     * @return boolean a value indicating whether the rule permits the role or permission it is associated with.
     */
    public function execute($user, $item, $params)
    {
        return isset($params['profile']) ? $params['profile']->id == $user  : false;
    }
}


description: Forum module for Yii 2.0

minimum-stability: dev

keywords:
forum
bulletin board


code:
<?php

return [
    'userClass'=>'hosanna\profile\models\User',
    'userIdColumn'=>'id',
    'userNameColumn'=>'username',
    'genderColumn'=>'gender',
    'birthdateColumn'=>'birthdate',
    'regdateColumn'=>'regtime',
    'profile'=>[
        'view'=>'/profile/account/view',
        'edit'=>'/profile/account/view',
    ],
    'css'=>['css/forum.css'],
];


code:
<?php

namespace app\modules\yboard\controllers;

use Yii;
use app\modules\yboard\YBoard;
use app\modules\yboard\models\YBoardSetting;
use app\modules\yboard\models\YBoardBan;
use app\modules\yboard\models\YBoardForum;
use app\modules\yboard\models\YBoardMember;
use app\modules\yboard\models\YBoardMessage;
use app\modules\yboard\models\YBoardMembergroup;
use app\modules\yboard\models\YBoardPost;
use app\modules\yboard\models\YBoardTopic;
use app\modules\yboard\models\YBoardForumSearch;
use app\modules\yboard\models\YBoardVote;
use app\modules\yboard\models\YBoardPoll;
use app\modules\yboard\models\YBoardChoice;
use app\modules\yboard\models\YBoardLogTopic;
use app\modules\yboard\models\YBoardUpvoted;
use app\modules\yboard\components\DateTimeCalculation;

use app\modules\yboard\components;

use yii\web\NotFoundHttpException;
use yii\web\ForbiddenHttpException;

use yii\filters\VerbFilter;
use yii\data\ActiveDataProvider;
use yii\helpers\Html;

/**
 * ForumController implements the CRUD actions for YBoardForum model.
 */
class ForumController extends \yii\web\Controller
{

    public $poll;
	public $choiceProvider;
	public $voted;

    public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['post'],
                ],
            ],
        ];
    }

    /**
     * Lists all YBoardForum models.
     * @return mixed
     */
    public function actionIndex()
    {
        $NumberOfTopics = YBoardSetting::find()->where(['key'=>'latest_topic'])->one();
        $NumberOfReplies = YBoardSetting::find()->where(['key'=>'latest_reply'])->one();

        $query = YBoardForum::find()
            ->sortedScope()
            ->andWhere('cat_id IS NULL') ;

        if(Yii::$app->user->isGuest) {
            $query->categoriesScope()
                ->publicScope()
                ->memberGroupScope()  ;
        }
        else if(Yii::$app->user->can('admin'))
        {
            $query->categoriesScope() ;
        } else
        {
            $query->memberGroupScope(Yii::$app->user->id) ;
        }

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pageSize' => 20,
            ],
        ]);

        //get forum IDs allowed
        $fids = [];
        foreach($dataProvider->models as $cat)
        {
            foreach($cat->forums as $fmodel)
                $fids[] = $fmodel->id;
        }

        $recentTopics = YBoardTopic::find()
            ->where(['forum_id'=>$fids])
            ->orderBy('id DESC')
            ->limit($NumberOfTopics==null ? 10 : $NumberOfTopics->value)
            ->all();

        $recentReplies = YBoardPost::find()
            ->where(['forum_id'=>$fids])
            ->andWhere('original_post=0')
            ->orderBy('create_time DESC')
            ->limit($NumberOfReplies==null ? 10 : $NumberOfReplies->value)
            ->all();

        return $this->render('index', [
            'dataProvider' => $dataProvider,
            'recentTopics' => $recentTopics,
            'recentReplies' => $recentReplies,
        ]);
    }

/**
	 * Show forum with topics
	 */
	public function actionForum($id) {
        $forum = $this->findModel($id);

		if(Yii::$app->user->isGuest && $forum->public == 0) {
			throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no permission to view requested forum.'));
		}

		if($forum->membergroup_id != 0) {
			if(Yii::$app->user->isGuest) {
				throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no permission to view requested forum.'));
			} elseif(!Yii::$app->user->can('moderator')) {
				$groupId = YBoardMember::findOne(Yii::$app->user->id)->group_id;
				if($forum->membergroup_id != $groupId) {
					throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no permission to view requested forum.'));
				}
			}
		}

		if(isset($_GET['YBoardTopic_page']) && isset($_GET['ajax'])) {
            $topicPage = (int) $_GET['YBoardTopic_page'] - 1;
            Yii::$app->session->set('YBoardTopic_page', $topicPage);
			Yii::$app->session->set('YBoardForum_id', $id);
            unset($_GET['YBoardTopic_page']);
        } elseif(isset($_GET['ajax'])) {
            Yii::$app->session->set('YBoardTopic_page', 0);
		} elseif(Yii::$app->session->get('YBoardForum_id', null)!=null && Yii::$app->user->YBoardForum_id != $id) {
			unset(Yii::$app->user->YBoardForum_id);
			Yii::$app->session->set('YBoardTopic_page', 0);
		}

        $query = YBoardTopic::find()
                ->with('starter');

                if(!Yii::$app->user->can('moderator'))
                    $query->where(['approved'=>1]);

                $query->andWhere(['forum_id'=>$forum->id])
                ->orWhere(['global'=>1])
                ->orderBy('global DESC, sticky DESC, last_post_id DESC');

		$dataProvider = new ActiveDataProvider([
			'query'=>$query,
			'pagination'=>[
				'pageSize'=>$this->module->topicsPerPage,
				'page' => Yii::$app->session->get('YBoardTopic_page', 0),
			],
		]);

		return $this->render('forum', [
            'forum' => $forum,
			'dataProvider' => $dataProvider
		]);
	}

    public function actionTopic($id, $nav = null, $postId = null) {
		$topic = YBoardTopic::findOne($id);
		if($topic === null) {
			throw new NotFoundHttpException(YBoard::t('yboard', 'The requested topic does not exist.'));
		}

        $replyModel = new YBoardPost;
        $replyModel->topic_id = $topic->id;
        $replyModel->subject = YBoard::t('yboard', 're:').$topic->title;

		$forum = YBoardForum::findOne($topic->forum_id);
		if(Yii::$app->user->isGuest && $forum->public == 0) {
			throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no permission to read requested topic.'));
		}

		if($topic->approved == 0 && !Yii::$app->user->can('moderator')) {
			throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no permission to read requested topic.'));
		}

		if($forum->membergroup_id != 0) {
			if(Yii::$app->user->isGuest) {
				throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no permission to read requested topic.'));
			} elseif(!Yii::$app->user->can('moderator')) {
				$groupId = YBoardMember::findOne(Yii::$app->user->id)->group_id;
				if($forum->membergroup_id != $groupId) {
					throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no permission to read requested topic.'));
				}
			}
		}
		$dataProvider = new ActiveDataProvider([
            'query'=>YBoardPost::find()
                    ->where(['approved'=>1])
                    ->andWhere(['topic_id'=>$topic->id])
                    ->orderBy('id')
                    ->with('poster'),
			'pagination'=>array(
				'pageSize'=>$this->module->postsPerPage,
			),
		]);
		// Determine poll
 		$this->poll = YBoardPoll::find()->where(['post_id'=>$topic->first_post_id])->one();
		if($this->poll !== null) {
			$this->choiceProvider = new ActiveDataProvider([
                'query'=>YBoardChoice::find()
                        ->where(['poll_id'=>$this->poll->id])
                        ->orderBy('sort') ,
				'pagination'=>false,
			]);
			// Determine whether user has voted
			if(Yii::$app->user->isGuest) {
				$this->voted = true; // A guest may not vote and sees the result immediately
			} else {
 				$this->voted = YBoardVote::find()
                        ->where(['poll_id'=>$this->poll->id])
                        ->andWhere(['user_id'=> Yii::$app->user->id])
                        ->exists();
			}
			// Determine wheter the poll has expired
			if(!$this->voted && isset($this->poll->expire_date) && $this->poll->expire_date < date('Y-m-d')) {
				$this->voted = true;
			}
		}
		// Navigate to a post in a topic
		if(isset($nav)) {
			$cPage = $dataProvider->getPagination();
			if(is_numeric($nav)) {
                $count = YBoardPost::find()
                    ->where('topic_id = ' . $topic->id . ' and id <= ' . $nav . ' and approved = 1')
                    ->count();
				$page = ceil($count/$cPage->pageSize);
				$post = $nav;
			} else {
				$page = ceil($dataProvider->totalCount/$cPage->pageSize);
				$post = $topic->last_post_id;
			}
			if(Yii::$app->session->hasFlash('moderation')) {
				Yii::$app->session->setFlash('moderation', Yii::$app->session->getFlash('moderation'));
			}
            //set current page to calculated if we are having last page
            if(!isset($_GET['per-page']))
                $dataProvider->pagination->page = $page-1; //pages are 0 indexed
		}
		// Increase topic views
		$topic->updateCounters(['num_views'=>1]);
		// Register the last visit of a topic
		if(!Yii::$app->user->isGuest) {
			$topicLog = YBoardLogTopic::findOne(['member_id'=>Yii::$app->user->id, 'topic_id'=>$topic->id]);
			if($topicLog === null) {
				$topicLog = new YBoardLogTopic;
				$topicLog->member_id = Yii::$app->user->id;
				$topicLog->topic_id = $topic->id;
				$topicLog->forum_id = $topic->forum_id;
			}
			$topicLog->last_post_id = $topic->last_post_id;
			$topicLog->save();
		}

        return $this->render('topic', array(
			'forum' => $forum,
			'reply' => $replyModel,
			'topic' => $topic,
			'dataProvider' => $dataProvider,
			'choiceProvider' => $this->choiceProvider,
			'postId' => $postId,
		));
	}

    /**
     * Creates a new YBoardForum model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
    public function actionCreateTopic()
    {
        if(!Yii::$app->user->can('app.forum.forum.create-topic'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

        $post = new YBoardPost;
        //top post aka OP
        $post->original_post = 1;

		$poll = new YBoardPoll;

		if(isset($_POST['YBoardForum'])) {
			$post->forum_id = $_POST['YBoardForum']['id'];
			$forum = YBoardForum::findOne($post->forum_id);
		}
		if(isset($_POST['choice'])) {
			$choiceArr = $_POST['choice'];
			while(count($choiceArr) < 3) {
				$choiceArr[] = '';
			}
		} else {
			$choiceArr = array('', '', '');
		}
        //print_r(Yii::$app->request->post());die();
		if($post->load(Yii::$app->request->post())) {
			//$post->attributes = $_POST['YBoardPost'];
			$forum = YBoardForum::findOne($post->forum_id);
            $post->setAttributes([
                'approved'=>$forum->moderated? 0 : 1,
                'user_id'=>Yii::$app->user->identity->id,
            ]);

			if($post->save()) {
				// Topic
				$topic = new YBoardTopic;
				$topic->forum_id 		= $forum->id;
				$topic->title 			= $post->subject;
				$topic->first_post_id 	= $post->id;
				$topic->last_post_id 	= $post->id;
				$topic->approved 		= $post->approved;

                if(isset($_POST['sticky'])) { $topic->sticky = 1; }
				if(isset($_POST['global'])) { $topic->global = 1; }
				if(isset($_POST['locked'])) { $topic->locked = 1; }

                // Poll
				if(isset($_POST['YBoardPoll']) && isset($_POST['addPoll']) && $_POST['addPoll'] == 'yes') {
					$poll->attributes = $_POST['YBoardPoll'];
					$poll->post_id = $post->id;
					$poll->user_id = Yii::$app->user->identity->id;
					if(empty($poll->expire_date)) {
						unset($poll->expire_date);
					}
					$count = 0;
					$choices = $_POST['choice'];
					foreach($choices as $choice) {
						if(!empty($choice)) { $count++; }
					}
					if($poll->validate() && $count > 1) {
						$correct = true;
					} else {
						$correct = false;
						if($correct < 2) {
							$poll->addError('question', YBoard::t('yboard','A poll should have at least 2 choices.'));
						}
					}
				} else {
					$correct = true;
				}

				if($correct && $topic->save()) {
					$post->topic_id = $topic->id;
					$post->save();

					if(!$forum->moderated) {
						$forum->updateCounters(['num_posts'=>1,'num_topics'=>1]);
						$forum->last_post_id = $post->id;
						$forum->save();
					} else {
						Yii::$app->session->setFlash('moderation',YBoard::t('yboard', 'Your post has been saved. It has been placed in a queue and is now waiting for approval by a moderator before it will appear on the forum. Thank you for your contribution to the forum.'));
					}
					if(isset($_POST['YBoardPoll'])) {
						$poll->save();
						$choices = $_POST['choice'];
						$i = 1;
						foreach($choices as $choice) {
							if(!empty($choice)) {
								$ch = new YBoardChoice;
								$ch->choice = $choice;
								$ch->poll_id = $poll->id;
								$ch->sort = $i++;
								$ch->save();
							}
						}
					}
					return $this->redirect(['topic', 'id'=>$topic->id]);
				} else {
					$post->delete();
				}
			}
		}

        return $this->render('create', [
			'forum' => $forum,
			'post' => $post,
			'poll' => $poll,
			'choices' => $choiceArr,
		]);
    }

    /**
     * Updates an existing YBoardForum model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param string $id
     * @return mixed
     */
    public function actionUpdate($id) {
		$post = YBoardPost::findOne($id);
		if($post === null) {
			throw new NotFoundException(404, YBoard::t('yboard', 'The requested post does not exist.'));
		}

        if(!Yii::$app->user->can('app.forum.forum.update', ['post'=>$post, 'isModerator'=>Yii::$app->user->can('moderator')]))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

		$topic = YBoardTopic::findOne($post->topic_id);
		$forum = YBoardForum::findOne($topic->forum_id);

		if(isset($_POST['YBoardPost'])) {
			$post->attributes = $_POST['YBoardPost'];
			$post->change_id = Yii::$app->user->id;
			if($forum->moderated) {
				$post->approved = 0;
			} else {
				$post->approved = 1;
			}
			if($post->save()) {
				if(!$post->approved) {
					$forum->updateCounters(['num_posts'=>-1]);
					if($topic->num_replies > 0) {
						$topic->updateCounters(['num_replies'=>-1]);
					} else {
						$topic->approved = 0;
						$topic->update();
						$forum->updateCounters(['num_topics'=>-1]);
					}
					$post->poster->updateAllCounters(['posts'=>-1]);
				}
				$this->redirect(['topic', 'id'=>$post->topic_id]);
			}
		}

        return $this->render('update', array(
			'forum' =>$forum,
			'topic' => $topic,
			'post' => $post
		));
	}

    /**
	 * Reply to a topic
	 * @param $id integer topic_id
	 */
	public function actionReply($id) {

        if(!Yii::$app->user->can('app.forum.forum.reply'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

		$topic = YBoardTopic::findOne($id);
		if($topic === null) {
			throw new NotFoundHttpException(YBoard::t('yboard', 'The requested topic does not exist.'), 404);
		}

		if($topic->approved==0) {
			throw new ForbiddenHttpException(YBoard::t('yboard', 'The requested topic cannot be replied to.'), 403);
		}

		$forum = YBoardForum::findOne($topic->forum_id);
		$post = new YBoardPost;

		if(isset($_POST['YBoardPost'])) {
			$post->attributes = $_POST['YBoardPost'];
			$post->user_id = Yii::$app->user->id;
			if($forum->moderated) {
				$post->approved = 0;
			} else {
				$post->approved = 1;
			}

            $post->forum_id = $topic->forum_id;

			if($post->save()) {
				if($post->approved) {
					$forum->updateCounters(['num_posts'=>1]);

					$topic->updateCounters(['num_replies'=>1]);

					$topic->updateAttributes(['last_post_id'=>$post->id]);
					$forum->updateAttributes(['last_post_id'=>$post->id]);

				} else {
					Yii::$app->session->setFlash('moderation',YBoard::t('yboard', 'Your post has been saved. It has been placed in a queue and is now waiting for approval by a moderator before it will appear on the forum. Thank you for your contribution to the forum.'));
				}

                //send notifications
                $this->sendNotifications($post);

				$this->redirect(['topic', 'id'=>$post->topic_id, 'nav'=>'last', '#'=>$post->id]);
			}
		} else {
			$post->subject = $topic->title;
			$post->forum_id = $forum->id;
			$post->topic_id = $topic->id;
		}

		return $this->render('reply', array(
			'forum' => $forum,
			'topic' => $topic,
			'post' => $post
		));
	}

    /**
	 * Handle Ajax call for upvote/downvote of post
	 */
	public function actionUpvote() {
        if(!Yii::$app->user->can('app.forum.forum.upvote'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

		$json = [];
		if(isset($_POST['id'])) {
            $criteria =  [
                'member_id'=>Yii::$app->user->identity->id,
                'post_id'=>$_POST['id']
            ];

            if( YBoardUpvoted::find()->where($criteria)->count()>0) {	// remove upvote
				YBoardUpvoted::deleteAll($criteria);

                $post = YBoardPost::findOne($_POST['id']);
				$topic = YBoardTopic::findOne($post->topic_id);
				$member = YBoardMember::findOne($post->user_id);

                $post->updateCounters(array('upvoted'=>-1));
				$topic->updateCounters(array('upvoted'=>-1));
			} else {										// add upvote
				$upvote = new YBoardUpvoted;
				$upvote->member_id = Yii::$app->user->id;
				$upvote->post_id = $_POST['id'];
				$upvote->author = $_POST['author'];
				$upvote->save();

                $post = YBoardPost::findOne($_POST['id']);
				$topic = YBoardTopic::findOne($post->topic_id);
				$member = YBoardMember::findOne($post->user_id);

                $post->updateCounters(array('upvoted'=>1));
				$topic->updateCounters(array('upvoted'=>1));
			}
			$json['success'] = 'yes';
			$json['html'] = $this->showUpvote($_POST['id']);
		} else {
			$json['success'] = 'no';
		}
		echo json_encode($json);
		Yii::$app->end();
	}

    /**
	 * Handle Ajax call for voting
	 */
	public function actionVote() {
        if(!Yii::$app->user->can('app.forum.forum.vote'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

		$json = [];
		if(isset($_POST['poll_id'])) {
			$this->poll = YBoardPoll::findOne($_POST['poll_id']);
			if(isset($_POST['choice'])) {
				// In case of a revote: remove previous votes
				$votes = YBoardVote::find()->where(['poll_id'=>$_POST['poll_id'], 'user_id'=>Yii::$app->user->id])->all();
				foreach($votes as $vote) {
					$this->poll->updateCounters(['votes'=>-1]);
					$model = YBoardChoice::findOne($vote->choice_id);
					$model->updateCounters(['votes'=>-1]);
					$vote->delete();
				}
				foreach($_POST['choice'] as $choice) {
					$model = new YBoardVote;
					$model->poll_id = $_POST['poll_id'];
					$model->choice_id = $choice;
					$model->user_id = Yii::$app->user->id;
					$model->save();
					$model = YBoardChoice::findOne($choice);
					$model->updateCounters(array('votes'=>1));
					$this->poll->updateCounters(array('votes'=>1));
				}

                $provider = new ActiveDataProvider([
                    'query' => YBoardChoice::find()
                        ->where(['poll_id'=>$_POST['poll_id']])
                        ->orderBy('sort'),
					'pagination'=>false,
                ]);

				$json['html'] = $this->renderAjax('poll', array('choiceProvider'=>$provider), true);
				$json['success'] = 'yes';
			} else {
				$json['success'] = 'no';
			}
		} else {
			$json['success'] = 'no';
		}
		echo json_encode($json);
		Yii::$app->end();
	}

    /**
	 * Handle Ajax call for display of vote form
	 */
	public function actionDisplayVote() {
		$json = [];
		if(isset($_POST['poll_id'])) {
			$this->poll = YBoardPoll::findOne($_POST['poll_id']);
			$choiceProvider=new ActiveDataProvider([
                'query' => YBoardChoice::find()
                    ->where(['poll_id'=>$_POST['poll_id']])
                    ->orderBy('sort'),
                'pagination'=>false,
            ]);

			$json['html'] = $this->renderPartial('vote', ['choiceProvider'=>$choiceProvider], true);
			$json['success'] = 'yes';
		} else {
			$json['success'] = 'no';
		}
		echo json_encode($json);
		Yii::$app->end();
	}

	/**
	 * Handle Ajax call for display of poll edit form
	 */
	public function actionEditPoll() {

        if(!Yii::$app->user->can('app.forum.forum.edit-poll'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

		$json = array();
		if(isset($_POST['poll_id'])) {
			$poll = YBoardPoll::findOne($_POST['poll_id']);
			$choices = [];
			$models = YBoardChoice::find()->where(['poll_id' => $poll->id])->all();
			foreach($models as $model) {
				$choices[$model->id] = $model->choice;
			}
			$json['html'] = $this->renderAjax('editPoll',['poll'=>$poll, 'choices'=>$choices], true);
			$json['success'] = 'yes';
		} else {
			$json['success'] = 'no';
		}
		echo json_encode($json);
		Yii::$app->end();
	}

	public function actionUpdatePoll($id) {
		$poll = YBoardPoll::findOne($id);
		if($poll === null) {
			throw new NotFoundHttpException(YBoard::t('yboard', 'The requested poll does not exist.'));
		}

        if(!Yii::$app->user->can('app.forum.forum.update-poll', ['poll'=>$poll, 'isModerator'=>Yii::$app->user->can('moderator')]))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

		$post = YBoardPost::findOne($poll->post_id);

        if($poll->user_id != Yii::$app->user->id && !Yii::$app->user->can('moderator')) {
			throw new ForbiddenHttpException(Yii::t('yii', 'You are not authorized to perform this action.'));
		}

		if(isset($_POST['YBoardPoll'])) {
			$poll->attributes = $_POST['YBoardPoll'];
			if(empty($poll->expire_date)) {
				unset($poll->expire_date);
			}
			if($poll->save()) {
				$choices = $_POST['choice'];
				foreach($choices as $key => $choice) {
					$ch = YBoardChoice::findOne($key);
					if($ch !== null) {
						$ch->choice = $choice;
						$ch->save();
					}
				}
			}
		}
		$this->redirect(array('topic', 'id'=>$post->topic_id));
	}

    /**
	 * Quote the original post in the reply (reply to a post)
	 * @param $id integer post_id
	 */
	public function actionQuote($id) {
        if(!Yii::$app->user->can('app.forum.forum.quote'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

		$quoted = YBoardPost::findOne($id);
		if($quoted === null) {
			throw new NotFoundHttpException(404, YBoard::t('yboard', 'The requested post does not exist.'));
		}

        if($quoted->topic->approved==0) {
			throw new ForbiddenHttpException(YBoard::t('yboard', 'The requested topic cannot be replied to.'), 403);
		}

		$topic = YBoardTopic::findOne($quoted->topic_id);
		$forum = YBoardForum::findOne($topic->forum_id);

		if(isset($_POST['YBoardPost'])) {
			$post = new YBoardPost;
			$post->attributes = $_POST['YBoardPost'];
			$post->user_id = Yii::$app->user->id;

			if($forum->moderated) {
				$post->approved = 0;
			} else {
				$post->approved = 1;
			}

            $post->forum_id = $topic->forum_id;

            if($post->save()) {
				if($post->approved) {
					$forum->updateCounters(['num_posts'=>1]);
					$topic->updateCounters(['num_replies'=>1]);

					$topic->updateAttributes(['last_post_id'=>$post->id]);
					$forum->updateAttributes(['last_post_id'=>$post->id]);
				} else {
					Yii::$app->session->setFlash('moderation',YBoard::t('yboard', 'Your post has been saved. It has been placed in a queue and is now waiting for approval by a moderator before it will appear on the forum. Thank you for your contribution to the forum.'));
				}

                //send notifications
                $this->sendNotifications($post);

				$this->redirect(['topic', 'id'=>$post->topic_id, 'nav'=>'last']);
			}
		} else {
			$post = new YBoardPost;
			$quote = '<div class="quotation-header"><cite class="quotation-username">'.$quoted->poster->profile->username .' '. YBoard::t('yboard', 'Wrote:') .' </cite><cite class="quotation-date">'. DateTimeCalculation::medium($quoted->create_time).'</cite></div>';
			$quote = '<div class="quotation-header"><cite class="quotation-username">'.$quoted->poster->profile->username .' '. YBoard::t('yboard', 'wrote') .' </cite><cite class="quotation-date">'. DateTimeCalculation::medium($quoted->create_time).'</cite></div>';
			$post->content = '<blockquote class="quotation-content">'. $quote .' ' . $quoted->content . '</blockquote>  <p></p>';
			$post->subject  = $quoted->subject;
			$post->forum_id = $quoted->forum_id;
			$post->topic_id = $quoted->topic_id;
		}

        return $this->render('reply', array(
			'forum' => $forum,
			'topic' => $topic,
			'post' => $post
		));
	}

    /**
     * Finds the YBoardForum model based on its primary key value.
     * If the model is not found, a 404 HTTP exception will be thrown.
     * @param string $id
     * @return YBoardForum the loaded model
     * @throws NotFoundHttpException if the model cannot be found
     */
    protected function findModel($id)
    {
        if (($model = YBoardForum::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }

    /**
	 * Function to send mails to Reply
	 */
	public function sendNotifications($postModel)
    {
        $query = new \yii\db\Query;
        $rows = $query->select('user_id')
            ->from('YBoardPost')
            ->where(['topic_id'=>$postModel->topic_id])
            ->distinct()
            ->all();

        $users = [];
        foreach($rows as $row)
        {
            if($row['user_id'] == $postModel->poster->id)
            {
                continue; //don't send to author
            }

            $users[] = $row['user_id'];
        }

        $query = new \yii\db\Query;
        $userDetails = $query->select('id,fname, lname, email')
            ->from('Users')
            ->where(['in', 'id', $users])
            ->all();

        $subject = YBoard::t('yboard','{user} replied to {topic}', ['user'=>$postModel->poster->profile->username, 'topic'=>$postModel->topic->title]);

        foreach($userDetails as $user)
        {
            $message = YBoard::t('yboard', '{user}, {replier} has just posted a reply to a topic that you have subscribed to titled "{title}".
            ----------------------------------------------------------------------
            {summary}
            ----------------------------------------------------------------------
            The topic with currrent replies can be found {url}', [
                'user'=>$user['fname'].' '.$user['lname'],
                'replier'=>$postModel->poster->profile->username,
                'title'=>$postModel->topic->title,
                'summary'=>$postModel->content,
                'url'=>Html::a(YBoard::t('yboard', 'here'), Yii::$app->urlManager->createAbsoluteUrl([$this->module->id.'/forum/topic', 'id'=>$postModel->topic_id])),
            ]);
            //strip new line
            $message = str_replace(array("\r\r", "\n\n"), '', $message);
            $message =  nl2br($message);

            try
           {
                $sent = Yii::$app->mailer->compose()
                    ->setTo($user['email'])
                    ->setFrom(Yii::$app->params['supportEmail'])
                    ->setSubject($subject)
                    ->setHtmlBody($message)
                    ->send();

                if(!$sent)
                {
                    die("FAILED TO SEND MAIL");
                }
           }
           catch(\Exception $e)
           {
                echo $e->getMessage();
                die();
           }
        }
    }

    /**
	 * Function to determine whether a forum group should be hidden
	 */
	public function collapsed($id)
    {
		if(isset(Yii::$app->request->cookies['yboardCollapsed'])) {
			$catString = Yii::$app->request->cookies['yboardCollapsed']->value;
			$catArray = explode('_', $catString);
			if(in_array($id, $catArray)) {
				return true;
			}
		}
		return false;
	}

    /**
	 * Determine whether a forum is completely read by a user
	 * @param integer forum id
	 * @return boolean
	 */
	public function forumIsRead($forum_id) {
		if(Yii::$app->user->isGuest) {
			return false;
		} else {
			$models = YBoardTopic::find()
                ->where(['forum_id'=>$forum_id])
                ->orderBy('last_post_id DESC')
                ->limit(100)
                ->all();
			$result = true;

            foreach($models as $topic) {
				$topicLog = YBoardLogTopic::findOne(array('member_id'=>Yii::$app->user->id, 'topic_id'=>$topic->id));
				if($topicLog === null) {
					$result = false;
					break;
				} else {
					if($topic->last_post_id > $topicLog->last_post_id) {
						$result = false;
						break;
					}
				}
			}
			return $result;
		}
	}

    /**
	 * Determine the icon for a topic
	 */
	public function topicIcon($topic) {
		$img = 'topic';
		if($this->topicIsRead($topic->id)) {
			$img .= '2';
		} else {
			$img .= '1';
		}
		if($topic->global) {
			$img .= 'g';
		}
		if($topic->sticky) {
			$img .= 's';
		}
		if(YBoardPoll::find()->where(['post_id'=>$topic->first_post_id])->one()) {
			$img .= 'p';
		}
		if($topic->locked) {
			$img .= 'l';
		}
		return $img;
	}

    /**
	 * Determine whether a topic is completely read by a user
	 * @param integer forum id
	 * @return boolean
	 */
	public function topicIsRead($topic_id) {
		if(Yii::$app->user->isGuest) {
			return false;
		} else {
			$topicLog = YBoardLogTopic::findOne(['member_id'=>Yii::$app->user->id, 'topic_id'=>$topic_id]);
			if($topicLog === null) {
				return false;
			} else {

				$topic = Yii::$app->db->cache(function ($db) use($topic_id) {
                    return YBoardTopic::findOne($topic_id);
                }, 300);

				if($topic->last_post_id > $topicLog->last_post_id) {
					return false;
				} else {
					return true;
				}
			}
		}
	}

    public function showUpvote($post_id) {
		$url = Yii::$app->urlManager->createAbsoluteUrl($this->module->id.'/forum/upvote');
		$post = YBoardPost::findOne($post_id);
		if($post === null || $post->user_id == Yii::$app->user->id) {
			return '';
		}

        $upvoted = YBoardUpvoted::find()
            ->where(['member_id'=>Yii::$app->user->identity->id])
            ->andWhere(['post_id'=>$post_id])
            ->count();

		if($upvoted>0) {
			$html = Html::button(YBoard::t('yboard', 'Downvote').' <span class="glyphicon glyphicon-chevron-down"></span>', ['class'=>'btn btn-sm btn-default', 'title'=>YBoard::t('yboard', 'Remove your appreciation'), 'id'=>'upvote_'.$post_id, 'style'=>'cursor:pointer;', 'onclick'=>'upvotePost(' . $post_id . ','  . $post->user_id .  ',"' . $url . '")']);
		} else {
			$html = Html::button(YBoard::t('yboard', 'Upvote').' <span class="glyphicon glyphicon-chevron-up"></span>', ['class'=>'btn btn-sm btn-default', 'title'=>YBoard::t('yboard', 'Appreciate this post'), 'id'=>'upvote_'.$post_id, 'style'=>'cursor:pointer;', 'onclick'=>'upvotePost(' . $post_id . ','  . $post->user_id . ',"' . $url . '")']);
		}
		return $html;
	}

    public function actionMarkAllRead() {
        if(!Yii::$app->user->can('app.forum.forum.mark-all-read'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

		$topics = YBoardTopic::find()->all();
		foreach($topics as $topic) {
			$topicLog = YBoardLogTopic::findOne(['member_id'=>Yii::$app->user->id, 'topic_id'=>$topic->id]);
			if($topicLog === null) {
				$topicLog = new YBoardLogTopic;
				$topicLog->member_id = Yii::$app->user->id;
				$topicLog->topic_id = $topic->id;
				$topicLog->forum_id = $topic->forum_id;
			}
			$topicLog->last_post_id = $topic->last_post_id;
			$topicLog->save();
		}

		$this->redirect(['index']);
	}

    /**
	 * Banned users Lands Here!
	 */
	/**
     * Displays a single YBoardBan model.
     * @param integer $id
     * @return mixed
     */
    public function actionBanned($id)
    {
        $model = YBoardBan::findOne($id);
        $user = YBoardMember::findOne($model->user_id);
        $isIP = true;

        if($user!==null)
            $isIP = false;

        if ($model == null) {
            throw new NotFoundHttpException(YBoard::t('yboard','The requested Banned User does not exist.'));
        }

        $settings = YBoardSetting::find()->where(['key'=>'email'])->one();

        return $this->render('banned', [
            'model' => $model,
            'member' => $user,
            'isIp' => $isIP,
            'email' => $settings== null ? YBoard::t('board', 'no email') : $settings->value,
        ]);
    }

    /**
	 * This is the action to handle external exceptions.
	 */
	public function actionError()
	{
		if($error=Yii::$app->errorHandler->exception)
		{
			if(Yii::$app->request->isAjax)
				echo $error->getMessage() ;
			else
				return $this->render('error', ['exception'=>$error]);
		}
	}
}


code:
<?php

namespace app\modules\yboard\controllers;

use Yii;
use app\modules\yboard\models\YBoardMember;
use app\modules\yboard\models\YBoardMemberSearch;
use app\modules\yboard\models\YBoardSession;
use app\modules\yboard\YBoard;
use yii\web\NotFoundHttpException;
use yii\web\ForbiddenHttpException;
use yii\filters\VerbFilter;
use hosanna\profile\models\User;
use yii\data\ActiveDataProvider;

/**
 * MemberController implements the CRUD actions for YBoardMember model.
 */
class MemberController extends \yii\web\Controller
{
    public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['post'],
                ],
            ],
        ];
    }

    /**
     * Lists all YBoardMember models.
     * @return mixed
     */
    public function actionIndex()
    {
        if(!Yii::$app->user->can('app.forum.member.index'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

        $user = new User;

        $qstring = Yii::$app->request->get($user->formName())['username'];

        $user->username = $qstring;

        $userIds =  User::find()
            ->select('id')
            ->asArray()
            ->filterWhere(['like','username',$qstring])->all();

        $query = YBoardMember::find();

        foreach($userIds as $id)
        {
            $query->orWhere(['id'=>$id['id']]);
        }

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        //if ($searchModel->load(Yii::$app->request->getQueryParams())) {
        //    $query->andFilterWhere(['like','id', $searchModel->id]);
        //}

        return $this->render('index', [
            'dataProvider' => $dataProvider,
            'searchModel' => $user,
        ]);
    }

    /**
     * Displays a single YBoardMember model.
     * @param string $id
     * @return mixed
     */
    public function actionView($id)
    {
        if(!Yii::$app->user->can('app.forum.member.view'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

        return $this->render('view', [
            'model' => $this->findModel($id),
        ]);
    }

    /**
     * Displays a single YBoardMember model for Editing and other bells.
     * @param string $id
     * @return mixed
     */
    public function actionProfile($id)
    {
        $model = $this->findModel($id);
        if(!Yii::$app->user->can('app.forum.member.profile', ['profile'=>$model]))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

        return $this->render('profile', [
            'model' => $model,
        ]);
    }

    /**
     * Displays a single YBoardMember model allowing Limited.
     * @param string $id
     * @return mixed
     */
    public function actionUsercp($id)
    {
        $model = $this->findModel($id);

        if(!Yii::$app->user->can('app.forum.member.usercp', ['profile'=>$model]))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

        if (isset($_POST['hasEditable'])) {
            // read your posted model attributes
            if (!$model->load($_POST)  || !$model->save()) {
                // validation error
                echo \yii\helpers\Json::encode(['output'=>'', 'message'=>'Could Not Update Field']);
            }
            // else if nothing to do always return an empty JSON encoded output
            else {
                $attrName = key($_POST[$model->formName()]);
                // read or convert your posted information
                $value = $model->{$attrName};
                echo \yii\helpers\Json::encode(['output'=>$value, 'message'=>'']);
            }
        }
        else
        {
            throw new ForbiddenHttpException(YBoard::t('yboard','This Action is forbidden!'));
        }
    }

    /**
     * Creates a new YBoardMember model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
    public function actionAssociate($id)
    {
        if(!Yii::$app->user->can('app.forum.member.associate'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

        $model = YBoardMember::findOne($id);
        if($model==null)
            $model = new YBoardMember;
        $model->setAttribute('id',$id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }

    /**
     * Updates an existing YBoardMember model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param string $id
     * @return mixed
     */
    public function actionUpdate($id)
    {
        $model = $this->findModel($id);
        if(!Yii::$app->user->can('app.forum.member.update', ['profile'=>$model]))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }

    /**
     * Deletes an existing YBoardMember model.
     * If deletion is successful, the browser will be redirected to the 'index' page.
     * @param string $id
     * @return mixed
     */
    public function actionDelete($id)
    {
        if(!Yii::$app->user->can('app.forum.member.delete'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

        $this->findModel($id)->delete();

        return $this->redirect(['index']);
    }

    //set user active
	public function actionUpdateOnlineStatus($id, $uid=null)
    {
        $time = time() - $this->module->onlineLimit;
        // delete older session entries
        YBoardSession::deleteAll("last_visit <".$time);

        $session = YBoardSession::findOne($id) ;

        //print_r($session); die();
        if($session==null)
        {
            $session = new YBoardSession;
            $session->setAttributes(['last_visit'=>time(), 'id'=>$id, 'user_id'=>$uid]);
        }
        else
            $session->setAttribute('last_visit', time());

        $success = $session->save();

        $guests =  YBoardSession::find()->where('user_id IS NULL')->count();
        $members =  YBoardSession::find()->where('user_id IS NOT NULL')->count();

        //echo  json_encode(['success'=>$success, 'errors'=>$session->errors, 'users'=>['guests'=>$guests, 'members'=>$members]]);
        echo  json_encode(['time'=>$time, 'success'=>$success, 'errors'=>$session->errors, 'message'=>YBoard::t('yboard','{{guests}} guest(s) and {{members}} active member(s)', ['{guests}'=>($guests), '{members}'=>$members])]);
    }

    /**
     * Finds the YBoardMember model based on its primary key value.
     * If the model is not found, a 404 HTTP exception will be thrown.
     * @param string $id
     * @return YBoardMember the loaded model
     * @throws NotFoundHttpException if the model cannot be found
     */
    protected function findModel($id)
    {
        if (($model = YBoardMember::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
}


code:
<?php

namespace app\modules\yboard\controllers;

use app\modules\yboard\YBoard;
use yii\helpers\Html;

use Yii;
use hosanna\profile\models\User;
use app\modules\yboard\models\YBoardMessage;
use app\modules\yboard\models\YBoardMessageSearch;
use app\modules\yboard\models\YBoardPost;
use app\modules\yboard\models\YBoardMember;

use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\data\ActiveDataProvider;

/**
 * MessageController implements the CRUD actions for YBoardMessage model.
 */
class MessageController extends \yii\web\Controller
{
    public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['post'],
                ],
            ],
        ];
    }

    /**
     * Lists all YBoardMessage models.
     * @return mixed
     */
    public function actionIndex()
    {
        if(!Yii::$app->user->can('app.forum.message.index'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

        $searchModel = new YBoardMessageSearch;
        $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());

        return $this->render('index', [
            'dataProvider' => $dataProvider,
            'searchModel' => $searchModel,
        ]);
    }

    /**
     * Displays a single YBoardMessage model.
     * @param string $id
     * @return mixed
     *
     * handle Ajax call for viewing message
	 */
	public function actionView() {
        if(!Yii::$app->user->can('app.forum.message.view'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

		$json = [];
		if(isset($_POST['id'])) {
			$model = YBoardMessage::findOne($_POST['id']);
			if($model !== null /*&& (Yii::$app->user->can('moderator')|| $model->sendto == Yii::$app->user->id || $model->sendfrom == Yii::$app->user->id)*/) {
				$json['success'] = 'yes';
				$json['html'] = $this->renderPartial('_view', ['model' => $model]);
                $model->read_indicator = 1;
                $model->update();
			} else {
				$json['success'] = 'no';
				$json['message'] = YBoard::t('yboard', 'Message not found.');
			}
		} else {
			$json['success'] = 'no';
			$json['message'] = YBoard::t('yboard', 'Message not found.');
		}
		echo json_encode($json);
		Yii::$app->end();
	}

    //Handle Ajax replies
    public function actionReply()
    {
        if(!Yii::$app->user->can('app.forum.message.reply'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

        $json = [];

        $model = new YBoardMessage;
        $model->load(Yii::$app->request->post());
        $model->setAttributes([
            'ip'=>Yii::$app->request->getUserIP(),
            'create_time'=>new \yii\db\Expression('NOW()')
        ]);

        if($model->save())
        {
            $json['success'] = 'yes';
            $json['message'] = YBoard::t('yboard', 'PM Sent Successfully');
        } else
        {
            $json['success'] = 'no';
            $json['message'] = YBoard::t('yboard', 'Could not send your private message. Try again').json_encode($_POST)." ===== ".json_encode($model->errors);
        }

        echo json_encode($json);
        Yii::$app->end();

    }

    /**
     * Creates a new YBoardMessage model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
    public function actionCreate()
    {
        if(!Yii::$app->user->can('app.forum.message.create'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

        $model = new YBoardMessage;
        $model->load(Yii::$app->request->post());
        $model->setAttributes([
            'ip'=>Yii::$app->request->getUserIP(),
            'create_time'=>new \yii\db\Expression('NOW()')
        ]);

        $json = [];
        //are we sending single or multiple messages?
        if($model->usernames!=null)
        {
            $usernames = explode(',', $model->usernames);
            $json['success'] = 'no';
            $str = '';
            foreach($usernames as $usr)
            {
                $userModel = User::find()->where(['username'=>$usr])->one();
                if($userModel!=null)
                {
                    $model->setAttribute('sendto', $userModel->id);
                    $model->id=null;
                    $model->isNewRecord = true;

                    if($model->save())
                    {
                        $str.=YBoard::t('yboard', 'Message sent to {usr}', ['usr'=>$usr]);
                        $str.= "\n";
                    }
                    else
                    {
                        $str.=YBoard::t('yboard', 'Message not sent to {usr}', ['usr'=>$usr]);
                        $str.= "\n";
                    }

                }
            }
            $json['message'] = $str;
        }
        else
        {
            if($model->save()) {
                $json['success'] = 'yes';
                $json['message'] = YBoard::t('yboard', 'PM Sent Successfully');
            } else {
                $json['success'] = 'no';
                $json['message'] = YBoard::t('yboard', 'Could not send your private message. Try again').json_encode($_POST)." ===== ".json_encode($model->errors);
            }
        }
        echo json_encode($json);
        Yii::$app->end();
    }

    /**
     * Deletes an existing YBoardMessage model.
     * If deletion is successful, the browser will be redirected to the 'index' page.
     * @param string $id
     * @return mixed
     */
    public function actionDelete($id)
    {
        $model = $this->findModel($id);

        if(!Yii::$app->user->can('app.forum.message.delete', ['message'=> $model]))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

        if(!\Yii::$app->request->isAjax)
            Yii::$app->end();

        if($model->delete())
            echo json_encode(['success'=>true, 'msg'=>YBoard::t('yboard', 'Message Successfully Deleted')]);
        else
            echo json_encode(['success'=>false, 'msg'=>YBoard::t('yboard', 'Message Deletion Failed')]);

        Yii::$app->end();
    }

    /**
	 * handle Ajax call for sending a report on a post
	 */
	public function actionSendReport() {
        if(!Yii::$app->user->can('app.forum.message.send-report'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

		$json = [];
		if(isset($_POST['YBoardMessage'])) {
			$model = new YBoardMessage;
			$model->attributes = $_POST['YBoardMessage'];

            $post = YBoardPost::findOne($model->post_id);

			$model->subject = YBoard::t('yboard', 'Post reported:').' '.$post->subject;
			$model->sendto = 0; //reported post No recipient
			$model->sendfrom = Yii::$app->user->id;
			$model->outbox = 0;// not put to outbox
			$model->type = 2; //notifications
			$model->ip = Yii::$app->request->userIP;

            $user = YBoardMember::findOne(Yii::$app->user->id);

            $content = YBoard::t('yboard', 'Reporter: {user}
            Reason:{reason} . The link to the post is attached below"', [
                'reason'=>$model->content,
                'user'=>$user->profile->username,
            ])
            .'
'
            .Html::a( YBoard::t('yboard', 'click to view post'),['/'.$this->module->id.'/forum/topic',  'id' => $post->topic_id, '#' => $post->id], ['target'=>'_blank'])
            .'

'
            .Html::a( YBoard::t('yboard', 'click to view reporter [{username}]', ['username'=>$user->profile->username]), ['/'.$this->module->id.'/member/view', 'id'=>$user->id], ['target'=>'_blank']).'
'
             .'
'
            .YBoard::t('yboard', ' Reporter IP: {ip}]', ['ip'=>Yii::$app->request->userIP])
            .'
';

            $model->content = $content;

            if($model->save()) {
				$json['success'] = 'yes';
				$json['message'] = YBoard::t('yboard', 'Thank you for your report.');
			} else {
				$json['success'] = 'no';
				$json['message'] = YBoard::t('yboard', 'Could not register your report.').json_encode($_POST)." ===== ".json_encode($model->errors);
			}
		}
		echo json_encode($json);
		Yii::$app->end();
	}

    //PM Inbox
    public function actionInbox($id=null) {

        if(!Yii::$app->user->can('app.forum.message.inbox'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

        if($id==null)
			$id = Yii::$app->user->id;

        $query = null;
        $count = [];

        $query = YBoardMessage::find()
            ->inboxScope()
            ->andWhere(['sendto'=>Yii::$app->user->id]);

        $count['inbox'] = $query->count();
        $count['outbox'] = YBoardMessage::find()
            ->outboxScope()
            ->andWhere(['sendfrom'=>Yii::$app->user->id])
            ->count();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        return $this->render('inbox', [
            //'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
			'count'=>$count
        ]);
	}

	public function actionOutbox($id = null) {
        if(!Yii::$app->user->can('app.forum.message.outbox'))
            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));

		if($id==null)
			$id = Yii::$app->user->id;

        $count['inbox'] = YBoardMessage::find()
            ->inboxScope()
            ->andWhere(['sendto'=>Yii::$app->user->id])
            ->count();
        $query = YBoardMessage::find()
                ->outboxScope()
                ->andWhere(['sendfrom'=>Yii::$app->user->id]);

        $count['outbox'] = $query->count();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        //print_r(Yii::$app->request->queryParams); die();
        //$dataProvider = $searchModel->search(Yii::$app->request->queryParams);

        return $this->render('outbox', [
            //'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
			'count'=>$count
        ]);
	}

    /**
     * Finds the YBoardMessage model based on its primary key value.
     * If the model is not found, a 404 HTTP exception will be thrown.
     * @param string $id
     * @return YBoardMessage the loaded model
     * @throws NotFoundHttpException if the model cannot be found
     */
    protected function findModel($id)
    {
        if (($model = YBoardMessage::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
}