<?php 

global $gp_settings, $post;

// Post Type
$gp_settings['post_type'] = get_post_meta($post->ID, 'ghostpool_post_type', true);

// Image Dimensions
if(get_post_meta($post->ID, 'ghostpool_thumbnail_width', true) && get_post_meta($post->ID, 'ghostpool_thumbnail_width', true)) {
	$gp_settings['image_width'] = get_post_meta($post->ID, 'ghostpool_thumbnail_width', true);
} else {
	$gp_settings['image_width'] = $gp_settings['thumbnail_width'];
}
if(get_post_meta($post->ID, 'ghostpool_thumbnail_height', true) && get_post_meta($post->ID, 'ghostpool_thumbnail_height', true)) {
	$gp_settings['image_height'] = get_post_meta($post->ID, 'ghostpool_thumbnail_height', true);
} else {
	$gp_settings['image_height'] = $gp_settings['thumbnail_height'];
}

$gp_settings['enc_link'] = add_query_arg('refid', bp_dedication_encode(get_permalink()), get_option('siteurl') . '/index.php');

// Song data
$gp_settings['video'] = get_post_meta($post->ID, 'ghostpool_dedication_url', true);
$gp_settings['artist'] = get_post_meta($post->ID, 'ghostpool_dedication_artist', true);
$gp_settings['artist_short'] = cutstr($gp_settings['artist'], 47, '...');
$gp_settings['song'] = get_post_meta($post->ID, 'ghostpool_dedication_song', true);
$gp_settings['song_short'] = cutstr($gp_settings['song'], 47, '...');
$gp_settings['artist_song'] = $gp_settings['artist'] . '. ' . $gp_settings['song'];
$gp_settings['artist_song_span'] = '<span>' . $gp_settings['artist'] . '</span>. ' . $gp_settings['song'];
$gp_settings['artist_song_span_short'] = cutstr($gp_settings['artist_song_span'], 38, '');
if ($gp_settings['artist_song_span_short'] != $gp_settings['artist_song_span']) {
    $gp_settings['artist_song_span_short'] .= '...';
}



// from user
$gp_settings['from_user_id'] = get_the_author_meta('ID');
$gp_settings['from_user_link'] = '<a href="'.bp_core_get_userlink($gp_settings['from_user_id'], false, true).'" title="'.bp_core_get_username($gp_settings['from_user_id']).'">'.bp_core_get_username($gp_settings['from_user_id']).'</a>';
                                    //bp_core_get_userlink($gp_settings['from_user_id']);
$gp_settings['from_flag'] = gp_get_the_flag($gp_settings['from_user_id']);

if ($gp_settings['from_user_id'] == mar_get_user_id()) :
    $mark_as_read = mar_add_to_usermeta($post->ID);
    $update_count = mar_increase_count($post->ID);    
endif;
$read_posts = mar_get_user_read_posts( mar_get_user_id() );

$gp_settings['unreaded'] = (!in_array($post->ID, $read_posts));

// to user
$gp_settings['to_user_id'] = get_post_meta($post->ID, 'ghostpool_destination_user_id', true);
$gp_settings['to_user_email'] = get_post_meta($post->ID, 'ghostpool_destination_user_email', true);
$gp_settings['to_user_name'] = get_post_meta($post->ID, 'ghostpool_destination_user_name', true);
$gp_settings['to_user_country'] = get_post_meta($post->ID, 'ghostpool_destination_user_country', true);
$gp_settings['to_user'] = get_userdata($gp_settings['to_user_id']);


if ($gp_settings['to_user']) {
    $gp_settings['to_flag'] = gp_get_the_flag($gp_settings['to_user']->ID, 32);   
    $gp_settings['to_user_name'] = bp_core_get_username($gp_settings['to_user']->ID);
    $gp_settings['to_user_link'] = '<a href="'.bp_core_get_userlink($gp_settings['to_user']->ID, false, true).'" title="'.$gp_settings['to_user_name'].'">'.$gp_settings['to_user_name'].'</a>';
                                    //bp_core_get_userlink($gp_settings['to_user']->ID);
} else {
    $gp_settings['to_flag'] = gp_get_flag_img_country($gp_settings['to_user_country'], 32);    
    $gp_settings['to_user_link'] = $gp_settings['to_user_name'];
}

// Post Text Width
if(!has_post_thumbnail() OR $gp_settings['image_wrap'] == "Disable") {
	$gp_settings['post_text_width'] = $gp_settings['content_width'];	
} else {
	$gp_settings['post_text_width'] = $gp_settings['content_width'] - $gp_settings['image_width'] - 17;
}	

// Post Left Width
if($gp_settings['post_type'] == "Review" && $gp_settings['review_date_column'] == "0" && (($gp_settings['score_type'] == "Site Score" && $gp_settings['gp_gdsr']->review > 0) OR ($gp_settings['score_type'] == "User Score" && $gp_settings['user_voting'] != "Users cannot vote") OR ($gp_settings['score_type'] == "Site & User Score" && ($gp_settings['gp_gdsr']->review > 0 OR $gp_settings['user_voting'] != "Users cannot vote")))) {
	$gp_settings['post_left_width'] = $gp_settings['post_text_width'] - 190;
} elseif($gp_settings['post_type'] == "Review" && $gp_settings['review_date_column'] == "1" && (($gp_settings['score_type'] == "Site Score" && $gp_settings['gp_gdsr']->review > 0) OR ($gp_settings['score_type'] == "User Score" && $gp_settings['user_voting'] != "Users cannot vote") OR ($gp_settings['score_type'] == "Site & User Score" && ($gp_settings['gp_gdsr']->review > 0 OR $gp_settings['user_voting'] != "Users cannot vote")))) {
	$gp_settings['post_left_width'] = $gp_settings['post_text_width'] - 95;
} else {
	$gp_settings['post_left_width'] = $gp_settings['post_text_width'];
}	

?>
