| 1 |
<?php |
| 2 |
// Exit if accessed directly |
| 3 |
if( !defined( 'ABSPATH' ) ) exit; |
| 4 |
?> |
| 5 |
<?php |
| 6 |
/** |
| 7 |
* Template Name: WpForo Index (Forums List) |
| 8 |
*/ |
| 9 |
?> |
| 10 |
<?php if( $wpforo->use_home_url ) get_header() ?> |
| 11 |
<?php extract($wpforo->current_object, EXTR_OVERWRITE); ?> |
| 12 |
<?php include("header.php"); ?> |
| 13 |
<div class="wpforo-main"> |
| 14 |
<div class="wpforo-content"<?php echo is_active_sidebar('forum-sidebar') ? '' : 'style="width:100%"' ?>> |
| 15 |
<?php if( $wpforo->current_user_status == 'banned' || $wpforo->current_user_status == 'trashed' ) : ?> |
| 16 |
<p class="wpf-p-error"><?php wpforo_phrase('You have been banned. Please contact to forum administrators for more information.') ?></p> |
| 17 |
<?php else : ?> |
| 18 |
<?php |
| 19 |
if($template == 'search'){ |
| 20 |
include( wpftpl('search.php') ); |
| 21 |
}elseif($template == 'register'){ |
| 22 |
include( wpftpl('register.php') ); |
| 23 |
}elseif($template == 'login'){ |
| 24 |
include( wpftpl('login.php') ); |
| 25 |
}elseif($template == 'members'){ |
| 26 |
$wpfms = (isset($_GET['wpfms'])) ? sanitize_text_field($_GET['wpfms']) : ''; |
| 27 |
if($wpfms){ |
| 28 |
$users_include = $wpforo->member->search($wpfms, array('user_nicename', 'user_email', 'display_name', 'title')); |
| 29 |
} |
| 30 |
$args = array( |
| 31 |
'offset' => ($paged - 1) * $wpforo->post_options['posts_per_page'], |
| 32 |
'row_count' => $wpforo->post_options['posts_per_page'], |
| 33 |
'orderby' => 'posts DESC, display_name' |
| 34 |
); |
| 35 |
if(!empty($users_include)) $args['include'] = $users_include; |
| 36 |
$items_count = 0; |
| 37 |
$members = $wpforo->member->get_members($args, $items_count); |
| 38 |
if(isset($users_include) && empty($users_include)){ $members = array(); $items_count = 0; } |
| 39 |
|
| 40 |
include( wpftpl('members.php') ); |
| 41 |
}elseif( isset($wpforo->member_tpls[$template]) && $wpforo->member_tpls[$template] ){ |
| 42 |
include( wpftpl('profile.php') ); |
| 43 |
}else{ |
| 44 |
if( $template == 'forum' || $template == 'topic' ) : ?> |
| 45 |
<?php if(!isset($forum_slug)) : ?><h2 id="wpforo-title"><?php echo esc_html($wpforo->general_options['title']) ?></h2><?php endif; ?> |
| 46 |
<?php $cats = $wpforo->forum->get_forums( (isset($forum_slug) && $forum_slug != '' ? array( "parent_slug" => $forum_slug ) : array( "type" => 'category' ) ) ); ?> |
| 47 |
|
| 48 |
<?php if(is_array($cats) && !empty($cats)) : ?> |
| 49 |
|
| 50 |
<?php foreach($cats as $key => $cat) : ?> |
| 51 |
<?php if( $wpforo->perm->forum_can( 'vf', $cat['forumid'] ) ): ?> |
| 52 |
<?php $forums = $wpforo->forum->get_forums( array( "parentid" => $cat['forumid'], "type" => 'forum' ) ); ?> |
| 53 |
<?php if(is_array($forums) && !empty($forums)) : ?> |
| 54 |
<?php do_action( 'wpforo_category_loop_start', $cat, $key ) ?> |
| 55 |
<?php include( wpftpl('layouts/'.($cat['cat_layout'] ? $cat['cat_layout'] : 1).'/forum.php') ); ?> |
| 56 |
<?php do_action( 'wpforo_category_loop_end', $cat, $key ) ?> |
| 57 |
<?php endif; ?> |
| 58 |
<?php endif; //checking forum permissions (can view forum) ?> |
| 59 |
<?php endforeach; //$cats as $cat ?> |
| 60 |
|
| 61 |
<?php else : ?> |
| 62 |
<p class="wpf-p-error"><?php wpforo_phrase('No forums were found here.') ?></p> |
| 63 |
<?php endif; //is_array($cats) && !empty($cats) ?> |
| 64 |
|
| 65 |
<?php endif; //Forum template ?> |
| 66 |
|
| 67 |
<?php if( $template == 'topic' ) : ?> |
| 68 |
<?php if( is_array($cats) && !empty($cats) && $cat['is_cat'] == 0 ) : ?> |
| 69 |
|
| 70 |
<?php if( isset($forum_slug) && $forum_slug ) : ?> |
| 71 |
|
| 72 |
<?php $forum = $wpforo->forum->get_forum( array( 'slug' => $forum_slug ) ); ?> |
| 73 |
|
| 74 |
<?php if(is_array($forum) && !empty($forum)) : ?> |
| 75 |
|
| 76 |
<?php if( $wpforo->perm->forum_can( 'vf', $forum['forumid'] ) ): ?> |
| 77 |
|
| 78 |
<div class="wpf-head-bar"> |
| 79 |
<div class="wpf-head-bar-left"> |
| 80 |
<h2 id="wpforo-title"><?php echo esc_html($forum['title']) ?></h2> |
| 81 |
<div class="wpf-action-link"> |
| 82 |
<?php if ( is_user_logged_in() ): ?> |
| 83 |
<?php |
| 84 |
$args = array( "userid" => $wpforo->current_userid , "itemid" => $forum['forumid'], "type" => "forum" ); |
| 85 |
$subscribe = $wpforo->sbscrb->get_subscribe( $args ); |
| 86 |
if( isset( $subscribe['subid'] ) ): ?> |
| 87 |
<span class="wpf-unsubscribe-forum wpf-action" id="wpfsubscribe-<?php echo intval($forum['forumid']) ?>"><?php wpforo_phrase('Unsubscribe') ?></span> |
| 88 |
<?php else: ?> |
| 89 |
<span class="wpf-subscribe-forum wpf-action" id="wpfsubscribe-<?php echo intval($forum['forumid']) ?>"><?php wpforo_phrase('Subscribe for new topics') ?></span> |
| 90 |
<?php endif; ?> |
| 91 |
<?php endif; ?> |
| 92 |
<span class="wpf-feed">| <a href="<?php $wpforo->feed->rss2_url(); ?>" title="<?php wpforo_phrase('Forum RSS Feed') ?>" target="_blank"><span><?php wpforo_phrase('RSS') ?></span> <i class="fa fa-rss fa-0x"></i></a></span> |
| 93 |
</div> |
| 94 |
</div> |
| 95 |
<?php if( $wpforo->perm->forum_can( 'ct', $cat['forumid']) ): ?> |
| 96 |
<div class="wpf-head-bar-right"><button class="wpf-button" id="add_wpftopic"><?php wpforo_phrase('Add topic') ?></button></div> |
| 97 |
<?php elseif( $wpforo->current_user_groupid == 4 ) : ?> |
| 98 |
<div class="wpf-head-bar-right"><button class="wpf-button not_reg_user" id="add_wpftopic"><?php wpforo_phrase('Add topic') ?></button></div> |
| 99 |
<?php endif; ?> |
| 100 |
<div class="wpf-clear"></div> |
| 101 |
</div> |
| 102 |
|
| 103 |
<?php if( is_user_logged_in() && $wpforo->perm->forum_can( 'ct', $cat['forumid'] ) ) $wpforo->tpl->topic_form($forum['forumid']); ?> |
| 104 |
|
| 105 |
<?php |
| 106 |
$args = array( |
| 107 |
'offset' => ($paged - 1) * $wpforo->post_options['topics_per_page'], |
| 108 |
'row_count' => $wpforo->post_options['topics_per_page'], |
| 109 |
'forumid' => $cat['forumid'], |
| 110 |
'orderby' => 'type, modified', |
| 111 |
'order' => 'DESC' |
| 112 |
); |
| 113 |
$items_count = 0; |
| 114 |
$topics = $wpforo->topic->get_topics( $args, $items_count ); |
| 115 |
?> |
| 116 |
|
| 117 |
<?php if( is_array($topics) && !empty($topics) ) : ?> |
| 118 |
|
| 119 |
<?php $wpforo->tpl->pagenavi($paged, $items_count); ?> |
| 120 |
|
| 121 |
<?php include( wpftpl('layouts/'.($cat['cat_layout'] ? $cat['cat_layout'] : 1).'/topic.php') ); ?> |
| 122 |
|
| 123 |
<?php $wpforo->tpl->pagenavi($paged, $items_count); ?> |
| 124 |
|
| 125 |
<?php else : ?> |
| 126 |
<p class="wpf-p-error"><?php wpforo_phrase('No topics were found here') ?> </p> |
| 127 |
<?php endif; ?> |
| 128 |
|
| 129 |
<?php endif; //chekcing permissions (can view forum) ?> |
| 130 |
|
| 131 |
<?php else : ?> |
| 132 |
<?php include( wpftpl('404.php') ) ?> |
| 133 |
<?php endif; ?> |
| 134 |
|
| 135 |
<?php else : ?> |
| 136 |
<?php include( wpftpl('404.php') ) ?> |
| 137 |
<?php endif; ?> |
| 138 |
|
| 139 |
<?php endif; ?> |
| 140 |
<?php endif; ?> |
| 141 |
|
| 142 |
<?php if( $template == 'post' ) : ?> |
| 143 |
<?php |
| 144 |
if( is_array($forum) && !empty($forum) ) : |
| 145 |
|
| 146 |
if( $wpforo->perm->forum_can( 'vt', $forum['forumid'] ) ): |
| 147 |
|
| 148 |
if( is_array($topic) && !empty($topic) ) : ?> |
| 149 |
|
| 150 |
<?php if( isset($topic['private']) && $topic['private'] && !wpforo_is_owner($topic['userid']) && !$wpforo->perm->forum_can( 'vp', $forum['forumid'] ) ): ?> |
| 151 |
<p class="wpf-p-error"><?php wpforo_phrase('Permission denied') ?></p> |
| 152 |
<?php else: ?> |
| 153 |
|
| 154 |
<?php |
| 155 |
$cat_layout = $wpforo->forum->get_layout( array( 'topicid' => $topic['topicid'] ) ); |
| 156 |
$args = array( |
| 157 |
'offset' => ($paged - 1) * $wpforo->post_options['posts_per_page'], |
| 158 |
'row_count' => $wpforo->post_options['posts_per_page'], |
| 159 |
'topicid' => $topic['topicid'], |
| 160 |
'forumid' => $forum['forumid'] |
| 161 |
); |
| 162 |
$items_count = 0; |
| 163 |
$posts = $wpforo->post->get_posts( $args, $items_count); |
| 164 |
?> |
| 165 |
|
| 166 |
<?php if( is_array($posts) && !empty($posts) ) : ?> |
| 167 |
<div class="wpf-head-bar"> |
| 168 |
<h2 id="wpforo-title"><?php $icon_title = $wpforo->tpl->icon('topic', $topic, false, 'title'); if( $icon_title ) echo '<span class="wpf-status-title">[' . esc_html($icon_title) . ']</span> ' ?><?php echo esc_html($topic['title']) ?> </h2> |
| 169 |
<?php if ( is_user_logged_in() ): ?> |
| 170 |
<div class="wpf-action-link"> |
| 171 |
<?php |
| 172 |
$args = array( "userid" => $wpforo->current_userid , "itemid" => $topic['topicid'], "type" => "topic" ); |
| 173 |
$subscribe = $wpforo->sbscrb->get_subscribe( $args ); |
| 174 |
if( isset( $subscribe['subid'] ) ): ?> |
| 175 |
<span class="wpf-unsubscribe-topic wpf-action" id="wpfsubscribe-<?php echo intval($topic['topicid']) ?>" ><?php wpforo_phrase('Unsubscribe') ?></span> |
| 176 |
<?php else: ?> |
| 177 |
<span class="wpf-subscribe-topic wpf-action" id="wpfsubscribe-<?php echo intval($topic['topicid']) ?>" ><?php wpforo_phrase('Subscribe for new replies') ?></span> |
| 178 |
<?php endif; ?> |
| 179 |
</div> |
| 180 |
<?php endif; ?> |
| 181 |
</div> |
| 182 |
|
| 183 |
<?php $wpforo->tpl->pagenavi( $paged, $items_count ); ?> |
| 184 |
|
| 185 |
<?php include( wpftpl('layouts/'.($cat_layout ? $cat_layout : 1).'/post.php') ); ?> |
| 186 |
|
| 187 |
<?php $wpforo->tpl->pagenavi($paged, $items_count); ?> |
| 188 |
|
| 189 |
<?php |
| 190 |
if(is_user_logged_in()){ |
| 191 |
$default = array( |
| 192 |
"topic_closed" => $topic['closed'], |
| 193 |
"topicid" => $topic['topicid'], |
| 194 |
"forumid" => $forum['forumid'], |
| 195 |
"layout" => ($cat_layout ? $cat_layout : 1), |
| 196 |
"topic_title" => $topic['title'] |
| 197 |
); |
| 198 |
$wpforo->tpl->reply_form( $default ); |
| 199 |
} |
| 200 |
?> |
| 201 |
<?php else : ?> |
| 202 |
<?php include( wpftpl('404.php') ) ?> |
| 203 |
<?php endif; ?> |
| 204 |
|
| 205 |
<?php endif; ?> |
| 206 |
|
| 207 |
<?php else : ?> |
| 208 |
<?php include( wpftpl('404.php') ) ?> |
| 209 |
<?php endif; ?> |
| 210 |
|
| 211 |
<?php endif; //checking permission can view topic ?> |
| 212 |
|
| 213 |
<?php else : ?> |
| 214 |
<?php include( wpftpl('404.php') ) ?> |
| 215 |
<?php endif ?> |
| 216 |
|
| 217 |
<?php endif; ?> |
| 218 |
<?php } ?> |
| 219 |
</div> |
| 220 |
<?php if (is_active_sidebar('forum-sidebar')) : ?> |
| 221 |
<div class="wpforo-right-sidebar"> |
| 222 |
<?php dynamic_sidebar('forum-sidebar') ?> |
| 223 |
</div> |
| 224 |
<?php endif; ?> |
| 225 |
<?php endif; ?> |
| 226 |
<div class="wpf-clear"></div> |
| 227 |
</div> |
| 228 |
<?php include("footer.php") ?> |
| 229 |
|
| 230 |
<?php if( $wpforo->use_home_url ) get_footer() ?> |