| 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 == 'lostpassword'){ |
| 26 |
do_shortcode('[wpforo-lostpassword]'); |
| 27 |
}elseif($template == 'resetpassword'){ |
| 28 |
do_shortcode('[wpforo-resetpassword]'); |
| 29 |
}elseif($template == 'members'){ |
| 30 |
if( !empty($_GET['_wpfms']) ){ |
| 31 |
$users_include = array(); |
| 32 |
$search_fields_names = $wpforo->member->get_search_fields_names(true); |
| 33 |
|
| 34 |
$wpfms = (isset($_GET['wpfms'])) ? sanitize_text_field($_GET['wpfms']) : ''; |
| 35 |
if($wpfms){ |
| 36 |
$users_include = $wpforo->member->search($wpfms, $search_fields_names); |
| 37 |
}else{ |
| 38 |
if( $filters = array_filter($_GET) ){ |
| 39 |
$args = array(); |
| 40 |
foreach ($filters as $filter_key => $filter){ |
| 41 |
if( in_array($filter_key, (array) $search_fields_names) && !is_array($filter) ){ |
| 42 |
$args[$filter_key] = $filter; |
| 43 |
} |
| 44 |
} |
| 45 |
$users_include = $wpforo->member->filter($args); |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
$users_include = apply_filters('wpforo_member_search_users_include', $users_include); |
| 50 |
} |
| 51 |
$args = array( |
| 52 |
'offset' => ($paged - 1) * $wpforo->post->options['posts_per_page'], |
| 53 |
'row_count' => $wpforo->post->options['posts_per_page'], |
| 54 |
'orderby' => 'posts', |
| 55 |
'order' => 'DESC' |
| 56 |
); |
| 57 |
if(!empty($users_include)) $args['include'] = $users_include; |
| 58 |
$items_count = 0; |
| 59 |
$members = $wpforo->member->get_members($args, $items_count); |
| 60 |
if(isset($users_include) && empty($users_include)){ $members = array(); $items_count = 0; } |
| 61 |
|
| 62 |
include( wpftpl('members.php') ); |
| 63 |
}elseif( isset($wpforo->member_tpls[$template]) && $wpforo->member_tpls[$template] ){ |
| 64 |
include( wpftpl('profile.php') ); |
| 65 |
}else{ |
| 66 |
if( $template == 'forum' || $template == 'topic' ) : ?> |
| 67 |
<?php if(!isset($forum_slug)) : ?> |
| 68 |
<h1 id="wpforo-title"> |
| 69 |
<?php echo esc_html($wpforo->general_options['title']) ?> |
| 70 |
<?php if( wpforo_feature('rss-feed', $wpforo) ): ?> |
| 71 |
<div class="wpforo-feed"> |
| 72 |
<span class="wpf-feed-forums"> |
| 73 |
<a href="<?php $wpforo->feed->rss2_url( true, 'forum' ); ?>" title="<?php wpforo_phrase('Forums RSS Feed') ?>" target="_blank"> |
| 74 |
<span><?php wpforo_phrase('Forums') ?></span> <i class="fa fa-rss fa-0x"></i> |
| 75 |
</a> |
| 76 |
</span><sep> | </sep> |
| 77 |
<span class="wpf-feed-topics"> |
| 78 |
<a href="<?php $wpforo->feed->rss2_url( true, 'topic' ); ?>" title="<?php wpforo_phrase('Topics RSS Feed') ?>" target="_blank"> |
| 79 |
<span><?php wpforo_phrase('Topics') ?></span> <i class="fa fa-rss fa-0x"></i> |
| 80 |
</a> |
| 81 |
</span> |
| 82 |
</div> |
| 83 |
<?php endif; ?> |
| 84 |
</h1> |
| 85 |
<?php endif; ?> |
| 86 |
<?php $cats = $wpforo->forum->get_forums( (isset($forum_slug) && $forum_slug != '' ? array( "parent_slug" => $forum_slug ) : array( "type" => 'category' ) ) ); ?> |
| 87 |
|
| 88 |
<?php if(is_array($cats) && !empty($cats)) : ?> |
| 89 |
|
| 90 |
<?php foreach($cats as $key => $cat) : ?> |
| 91 |
<?php if( $wpforo->perm->forum_can( 'vf', $cat['forumid'] ) ): ?> |
| 92 |
<?php $forums = $wpforo->forum->get_forums( array( "parentid" => $cat['forumid'], "type" => 'forum' ) ); ?> |
| 93 |
<?php if(is_array($forums) && !empty($forums)) : ?> |
| 94 |
<?php do_action( 'wpforo_category_loop_start', $cat, $key ) ?> |
| 95 |
<?php include( wpftpl('layouts/'.($cat['cat_layout'] ? $cat['cat_layout'] : 1).'/forum.php') ); ?> |
| 96 |
<?php do_action( 'wpforo_category_loop_end', $cat, $key ) ?> |
| 97 |
<?php endif; ?> |
| 98 |
<?php endif; //checking forum permissions (can view forum) ?> |
| 99 |
<?php endforeach; //$cats as $cat ?> |
| 100 |
|
| 101 |
<?php else : ?> |
| 102 |
<p class="wpf-p-error"><?php wpforo_phrase('No forums were found here.') ?></p> |
| 103 |
<?php endif; //is_array($cats) && !empty($cats) ?> |
| 104 |
<?php if( $template == 'topic' ) : ?><div class="wpf-subforum-sep" style="height:20px;"></div><?php endif; ?> |
| 105 |
|
| 106 |
<?php endif; //Forum template ?> |
| 107 |
|
| 108 |
<?php if( $template == 'topic' ) : ?> |
| 109 |
<?php if( is_array($cats) && !empty($cats) && $cat['is_cat'] == 0 ) : ?> |
| 110 |
|
| 111 |
<?php if( isset($forum_slug) && $forum_slug ) : ?> |
| 112 |
|
| 113 |
<?php $forum = $wpforo->forum->get_forum( array( 'slug' => $forum_slug ) ); ?> |
| 114 |
|
| 115 |
<?php if(is_array($forum) && !empty($forum)) : ?> |
| 116 |
|
| 117 |
<?php if( $wpforo->perm->forum_can( 'vf', $forum['forumid'] ) ): ?> |
| 118 |
|
| 119 |
<div class="wpf-head-bar"> |
| 120 |
<div class="wpf-head-bar-left"> |
| 121 |
<h1 id="wpforo-title"><?php echo esc_html($forum['title']) ?></h1> |
| 122 |
<?php if( $forum['description'] ): ?> |
| 123 |
<div id="wpforo-description"><?php echo $forum['description'] ?></div> |
| 124 |
<?php endif; ?> |
| 125 |
<div class="wpf-action-link"> |
| 126 |
<?php if ( is_user_logged_in() ): ?> |
| 127 |
<?php |
| 128 |
$args = array( "userid" => $wpforo->current_userid , "itemid" => $forum['forumid'], "type" => "forum" ); |
| 129 |
$subscribe = $wpforo->sbscrb->get_subscribe( $args ); |
| 130 |
if( isset( $subscribe['subid'] ) ): ?> |
| 131 |
<span class="wpf-unsubscribe-forum wpf-action" id="wpfsubscribe-<?php echo intval($forum['forumid']) ?>"><?php wpforo_phrase('Unsubscribe') ?></span> |
| 132 |
<?php else: ?> |
| 133 |
<span class="wpf-subscribe-forum wpf-action" id="wpfsubscribe-<?php echo intval($forum['forumid']) ?>"><?php wpforo_phrase('Subscribe for new topics') ?></span> |
| 134 |
<?php endif; ?> |
| 135 |
<?php endif; ?> |
| 136 |
<?php if( wpforo_feature('rss-feed', $wpforo) ): ?> |
| 137 |
<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> |
| 138 |
<?php endif; ?> |
| 139 |
</div> |
| 140 |
</div> |
| 141 |
<?php if( $wpforo->perm->forum_can( 'ct', $cat['forumid']) ): ?> |
| 142 |
<div class="wpf-head-bar-right"><button class="wpf-button" id="add_wpftopic"><?php wpforo_phrase('Add topic') ?></button></div> |
| 143 |
<?php elseif( $wpforo->current_user_groupid == 4 ) : ?> |
| 144 |
<div class="wpf-head-bar-right"><button class="wpf-button not_reg_user" id="add_wpftopic"><?php wpforo_phrase('Add topic') ?></button></div> |
| 145 |
<?php endif; ?> |
| 146 |
<div class="wpf-clear"></div> |
| 147 |
</div> |
| 148 |
|
| 149 |
<?php if( is_user_logged_in() && $wpforo->perm->forum_can( 'ct', $cat['forumid'] ) ) $wpforo->tpl->topic_form($forum['forumid']); ?> |
| 150 |
|
| 151 |
<?php |
| 152 |
$args = array( |
| 153 |
'offset' => ($paged - 1) * $wpforo->post->options['topics_per_page'], |
| 154 |
'row_count' => $wpforo->post->options['topics_per_page'], |
| 155 |
'forumid' => $cat['forumid'], |
| 156 |
'orderby' => 'type, modified', |
| 157 |
'order' => 'DESC' |
| 158 |
); |
| 159 |
$items_count = 0; |
| 160 |
$topics = $wpforo->topic->get_topics( $args, $items_count ); |
| 161 |
?> |
| 162 |
|
| 163 |
<?php if( is_array($topics) && !empty($topics) ) : ?> |
| 164 |
|
| 165 |
<?php $wpforo->tpl->pagenavi($paged, $items_count, true, 'wpf-navi-topic-top'); ?> |
| 166 |
|
| 167 |
<?php include( wpftpl('layouts/'.($cat['cat_layout'] ? $cat['cat_layout'] : 1).'/topic.php') ); ?> |
| 168 |
|
| 169 |
<?php $wpforo->tpl->pagenavi($paged, $items_count, true, 'wpf-navi-topic-bottom'); ?> |
| 170 |
|
| 171 |
<?php else : ?> |
| 172 |
<p class="wpf-p-error"><?php wpforo_phrase('No topics were found here') ?> </p> |
| 173 |
<?php endif; ?> |
| 174 |
|
| 175 |
<?php endif; //chekcing permissions (can view forum) ?> |
| 176 |
|
| 177 |
<?php else : ?> |
| 178 |
<?php include( wpftpl('404.php') ) ?> |
| 179 |
<?php endif; ?> |
| 180 |
|
| 181 |
<?php else : ?> |
| 182 |
<?php include( wpftpl('404.php') ) ?> |
| 183 |
<?php endif; ?> |
| 184 |
|
| 185 |
<?php endif; ?> |
| 186 |
<?php endif; ?> |
| 187 |
|
| 188 |
<?php if( $template == 'post' ) : ?> |
| 189 |
<?php |
| 190 |
if( is_array($forum) && !empty($forum) ) : |
| 191 |
|
| 192 |
if( $wpforo->perm->forum_can( 'vt', $forum['forumid'] ) ): |
| 193 |
|
| 194 |
if( is_array($topic) && !empty($topic) ) : ?> |
| 195 |
|
| 196 |
<?php if( isset($topic['private']) && $topic['private'] && !wpforo_is_owner($topic['userid']) && !$wpforo->perm->forum_can( 'vp', $forum['forumid'] ) ): ?> |
| 197 |
<p class="wpf-p-error"><?php wpforo_phrase('Permission denied') ?></p> |
| 198 |
<?php else: ?> |
| 199 |
|
| 200 |
<?php |
| 201 |
$cat_layout = $wpforo->forum->get_layout( array( 'topicid' => $topic['topicid'] ) ); |
| 202 |
$args = array( |
| 203 |
'offset' => ($paged - 1) * $wpforo->post->options['posts_per_page'], |
| 204 |
'row_count' => $wpforo->post->options['posts_per_page'], |
| 205 |
'topicid' => $topic['topicid'], |
| 206 |
'forumid' => $forum['forumid'] |
| 207 |
); |
| 208 |
$items_count = 0; |
| 209 |
$posts = $wpforo->post->get_posts( $args, $items_count); |
| 210 |
?> |
| 211 |
|
| 212 |
<?php if( is_array($posts) && !empty($posts) ) : ?> |
| 213 |
<div class="wpf-head-bar"> |
| 214 |
<h1 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']) ?> </h1> |
| 215 |
<?php if ( is_user_logged_in() ): ?> |
| 216 |
<div class="wpf-action-link"> |
| 217 |
<?php |
| 218 |
$args = array( "userid" => $wpforo->current_userid , "itemid" => $topic['topicid'], "type" => "topic" ); |
| 219 |
$subscribe = $wpforo->sbscrb->get_subscribe( $args ); |
| 220 |
if( isset( $subscribe['subid'] ) ): ?> |
| 221 |
<span class="wpf-unsubscribe-topic wpf-action" id="wpfsubscribe-<?php echo intval($topic['topicid']) ?>" ><?php wpforo_phrase('Unsubscribe') ?></span> |
| 222 |
<?php else: ?> |
| 223 |
<span class="wpf-subscribe-topic wpf-action" id="wpfsubscribe-<?php echo intval($topic['topicid']) ?>" ><?php wpforo_phrase('Subscribe for new replies') ?></span> |
| 224 |
<?php endif; ?> |
| 225 |
</div> |
| 226 |
<?php endif; ?> |
| 227 |
</div> |
| 228 |
|
| 229 |
<?php $wpforo->tpl->pagenavi( $paged, $items_count, true, 'wpf-navi-post-top' ); ?> |
| 230 |
|
| 231 |
<?php include( wpftpl('layouts/'.($cat_layout ? $cat_layout : 1).'/post.php') ); ?> |
| 232 |
|
| 233 |
<?php $wpforo->tpl->pagenavi($paged, $items_count, true, 'wpf-navi-post-bottom'); ?> |
| 234 |
|
| 235 |
<?php |
| 236 |
if(is_user_logged_in()){ |
| 237 |
$default = array( |
| 238 |
"topic_closed" => $topic['closed'], |
| 239 |
"topicid" => $topic['topicid'], |
| 240 |
"forumid" => $forum['forumid'], |
| 241 |
"layout" => ($cat_layout ? $cat_layout : 1), |
| 242 |
"topic_title" => $topic['title'] |
| 243 |
); |
| 244 |
$wpforo->tpl->reply_form( $default ); |
| 245 |
} |
| 246 |
?> |
| 247 |
<?php else : ?> |
| 248 |
<?php include( wpftpl('404.php') ) ?> |
| 249 |
<?php endif; ?> |
| 250 |
|
| 251 |
<?php endif; ?> |
| 252 |
|
| 253 |
<?php else : ?> |
| 254 |
<?php include( wpftpl('404.php') ) ?> |
| 255 |
<?php endif; ?> |
| 256 |
|
| 257 |
<?php endif; //checking permission can view topic ?> |
| 258 |
|
| 259 |
<?php else : ?> |
| 260 |
<?php include( wpftpl('404.php') ) ?> |
| 261 |
<?php endif ?> |
| 262 |
|
| 263 |
<?php endif; ?> |
| 264 |
<?php } ?> |
| 265 |
</div> |
| 266 |
<?php if (is_active_sidebar('forum-sidebar')) : ?> |
| 267 |
<div class="wpforo-right-sidebar"> |
| 268 |
<?php dynamic_sidebar('forum-sidebar') ?> |
| 269 |
</div> |
| 270 |
<?php endif; ?> |
| 271 |
<?php endif; ?> |
| 272 |
<div class="wpf-clear"></div> |
| 273 |
</div> |
| 274 |
<?php include("footer.php") ?> |
| 275 |
|
| 276 |
<?php if( $wpforo->use_home_url ) get_footer() ?> |