<?php /* Template Name: Badges & Points */
get_header();
	if ( have_posts() ) : while ( have_posts() ) : the_post();
		$badges_style = askme_options("badges_style");
		if ($badges_style == "by_groups_points") {
			$badges = askme_options("badges_groups_points");
		}else {
			$badges = askme_options("badges");
		}
		$points_badges = array_column($badges,'badge_points');
    	array_multisort($points_badges,SORT_ASC,$badges);
		if ($badges_style != "by_groups" && isset($badges) && is_array($badges)) {?>
			<div class="page-content page-content-user-profile">
				<div class="user-profile-widget">
					<div class="boxedtitle page-title"><h2><?php _e("Badges","vbegy")?></h2></div>
					<div class="ul_list ul_list-icon-ok">
						<ul>
							<?php foreach ($badges as $badges_k => $badges_v) {?>
								<li style="background-color: <?php echo esc_html($badges_v["badge_color"])?>;color: #FFF;"><?php echo strip_tags(stripslashes($badges_v["badge_name"]),"<i>")?><span> ( <span><?php echo esc_html($badges_v["badge_points"])?></span> ) <?php _e("Points","vbegy")?></span></li>
							<?php }?>
						</ul>
					</div>
				</div><!-- End user-profile-widget -->
			</div><!-- End page-content -->
		<?php }
		$active_points = askme_options("active_points");
		if ($active_points == 1) {
			$point_add_question = askme_options("point_add_question");
			$point_best_answer = askme_options("point_best_answer");
			$point_rating_question = askme_options("point_rating_question");
			$point_add_comment = askme_options("point_add_comment");
			$point_rating_answer = askme_options("point_rating_answer");
			$point_following_me = askme_options("point_following_me");
			$point_new_user = askme_options("point_new_user");
			$point_add_post = askme_options("point_add_post");
			$points_array = askme_get_points();
			if (is_array($points_array) && !empty($points_array)) {?>
				<div class="page-content page-content-user-profile">
					<div class="user-profile-widget">
						<div class="boxedtitle page-title"><h2><?php _e("Points","vbegy")?></h2></div>
						<div class="ul_list ul_list-icon-ok">
							<ul>
								<?php foreach ($points_array as $key => $value) {
									if (isset($value["points"]) && $value["points"] > 0) {?>
										<li><?php echo askme_get_points_name($key)?><span> ( <span><?php echo ($value["points"])?></span> ) </span></li>
									<?php }
								}?>
							</ul>
						</div>
					</div><!-- End user-profile-widget -->
				</div><!-- End page-content -->
			<?php }
		}
	endwhile; endif;
get_footer();?>