function cw_review_avail_by_settings($product_id, $customer_id, $extended_review_customer_id)
{
    global $config;
    $avail_by_settings = $config['estore_products_review']['writing_reviews'] == 'A' || $config['estore_products_review']['writing_reviews'] == 'R' && !empty($customer_id) || $config['estore_products_review']['writing_reviews'] == 'P' && cw_review_check_is_purchasers($product_id, $customer_id) || $extended_review_customer_id && $config['estore_products_review']['writing_reviews'] != 'N';
    return $avail_by_settings;
}
        } elseif ($review['vote'] >= 1) {
            $vote_reviews[1][0]++;
        } else {
            $vote_reviews[0][0]++;
        }
    }
    for ($i = 0; $i <= 5; $i++) {
        $vote_reviews[$i][1] = intval($vote_reviews[$i][0] / count($reviews) * 100);
    }
    $smarty->assign('vote_reviews', $vote_reviews);
}
$reviews = array_slice($reviews, ($page - 1) * $reviews_per_page, $reviews_per_page);
foreach ($reviews as $k => $review) {
    $reviews[$k]['customer_vote'] = cw_query_first_cell("SELECT rate FROM {$tables['products_reviews_ratings']} WHERE customer_id = '{$customer_id}' AND review_id = {$review['review_id']}");
    $reviews[$k]['attribute_votes'] = cw_review_get_attribute_vote_values($reviews[$k]);
}
// Restore review data to fill form if error occured
if (!empty($review_store_place)) {
    $smarty->assign("review", $review_store_place);
    $review_store_place = false;
}
$stoplist_where = "remote_ip='{$user_ip}'";
if (!empty($_customer_id)) {
    $stoplist_where .= " OR customer_id='{$_customer_id}'";
}
$block_by_stop_list = cw_query_first_cell("\n    SELECT review_id FROM {$tables['products_reviews']}\n    WHERE ({$stoplist_where}) AND stoplist = 1\n");
$smarty->assign("block_by_stop_list", $block_by_stop_list);
$smarty->assign("user_is_purchasers", cw_review_check_is_purchasers($product_id, $_customer_id));
$smarty->assign("reviews", $reviews);
$smarty->assign("extended_review_customer_id", $extended_review_customer_id);
$smarty->assign("avail_by_settings", $avail_by_settings);