function pof_importer_tasksdriveimport_importRow($row, $row_index, $saveToDataBase = false)
{
    $agegroups_and_taskgroups = pof_importer_get_agegroups_and_taskgroups();
    if (empty($row['A']) || substr($row['A'], 0, 2) != 'KY' || empty($row['D'])) {
        if (!empty($row['D'])) {
            echo "Not importing, because row not setted to be imported: " . $row['D'];
        } else {
            if (empty($row['A'])) {
                return;
            }
            echo "Not importing, because row not setted to be imported, empty title. Row " . $row_index;
        }
        echo '<br />';
        return;
    }
    echo "<br />";
    echo "to be imported: " . $row['D'];
    /*
    	echo "<pre>";
    	print_r($row);
    	echo "</pre>";
    */
    $taskgroup_obj = new stdClass();
    $agegroup_title = pof_importer_normalize_title($row['B']);
    $taskgroup_title = pof_importer_normalize_title($row['C']);
    if (!empty($agegroups_and_taskgroups[$agegroup_title]) && !empty($agegroups_and_taskgroups[$agegroup_title]->taskgroups[$taskgroup_title])) {
        $taskgroup_obj = $agegroups_and_taskgroups[$agegroup_title]->taskgroups[$taskgroup_title];
    }
    if (empty($taskgroup_obj->id)) {
        echo "<h2>Couldn't find taskgroup '" . $row['C'] . "' for task '" . $row['D'] . "'</h2>";
        return;
    }
    $wp_error = false;
    $post = null;
    $args = array('numberposts' => -1, 'posts_per_page' => -1, 'post_type' => array('pof_post_task'), 'meta_key' => 'suoritepaketti', 'meta_value' => $taskgroup_obj->id, 'search_post_title' => trim($row['D']));
    add_filter('posts_where', 'pof_importer_title_filter', 10, 2);
    $the_query_task = new WP_Query($args);
    remove_filter('posts_where', 'pof_importer_title_filter', 10, 2);
    if ($the_query_task->have_posts()) {
        while ($the_query_task->have_posts()) {
            $item = new stdClass();
            $the_query_task->the_post();
            $post = $the_query_task->post;
        }
    }
    if (empty($post)) {
        echo "  POST NOT FOUND; TO BE CREATED";
        if ($saveToDataBase) {
            $post = array('post_title' => trim($row['D']), 'post_content' => $row['F'], 'post_type' => 'pof_post_task', 'post_status' => 'publish', 'post_author' => get_current_user_id());
            $post_id = wp_insert_post($post, $wp_error);
            echo "imported, post_id: " . $post_id;
            $post = get_post($post_id);
        }
    } else {
        echo "  POST FOUND; TO BE UPDATED";
        $post_id = $post->ID;
    }
    if ($saveToDataBase) {
        update_post_meta($post_id, "suoritepaketti", $taskgroup_obj->id);
        update_field("ingress", $row['E'], $post_id);
        update_field("leader_tasks_fi", $row['G'], $post_id);
        $post->post_title = trim($row['D']);
        $post->post_content = $row['F'];
        $post->post_author = get_current_user_id();
        update_post_meta($post_id, "task_duration", trim(str_replace(" min", "", $row['M'])));
        if (substr(strtolower($row['K']), 0, 2) == 'ky') {
            update_field("task_mandatory", 1, $post_id);
        } else {
            update_field("task_mandatory", 0, $post_id);
        }
        $places = pof_importer_get_places($row['L']);
        update_field("task_place_of_performance", $places, $post_id);
        update_field("task_level", pof_importer_get_level($row['N']), $post_id);
        echo " updated places, " . count($places) . " items,";
        $skillareas = pof_importer_get_skillareas(trim($row['I']));
        wp_set_post_terms($post_id, $skillareas, "pof_tax_skillarea", false);
        $growth_targets = pof_importer_get_growth_targets(trim($row['H']));
        wp_set_post_terms($post_id, $growth_targets, "pof_tax_growth_target", false);
        update_post_meta($post_id, "content_imported_fi", pof_settigs_getDatetimeNow());
        wp_update_post($post, $wp_error);
    }
    echo "<br />";
}
function pof_importer_get_agegroups_and_tasks_get_tasks($taskgroup_ids)
{
    $items = array();
    $args = array('numberposts' => -1, 'posts_per_page' => -1, 'post_type' => array('pof_post_task'), 'orderby' => 'title', 'order' => 'ASC', 'meta_query' => array(array('key' => 'suoritepaketti', 'value' => $taskgroup_ids, 'compare' => 'IN')));
    $the_query4 = new WP_Query($args);
    if ($the_query4->have_posts()) {
        while ($the_query4->have_posts()) {
            $item = new stdClass();
            $the_query4->the_post();
            $item->id = $the_query4->post->ID;
            $item->title = $the_query4->post->post_title;
            $item->guid = get_post_meta($the_query4->post->ID, "post_guid", true);
            $items[pof_importer_normalize_title($the_query4->post->post_title)] = $item;
        }
    }
    return $items;
}
function pof_importer_suggestionssdriveimport_importRow($row, $row_index, $saveToDataBase = false)
{
    $agegroups_and_taskgroups = pof_importer_get_agegroups_and_taskgroups();
    if (empty($row['A']) || substr($row['A'], 0, 2) != 'KY' || empty($row['D'])) {
        if (empty($row['A'])) {
            return;
        }
        if (!empty($row['D'])) {
            echo "Not importing, because row not setted to be imported: " . $row['D'];
        } else {
            echo "Not importing, because row not setted to be imported, empty title. Row " . $row_index;
        }
        echo '<br />';
        return;
    }
    echo "<br />";
    echo "to be imported:" . $row['F'];
    echo "<br />";
    /*
    	echo "<pre>";
    	print_r($row);
    	echo "</pre>";
    */
    $taskgroup_obj = new stdClass();
    $agegroup_title = pof_importer_normalize_title($row['B']);
    $taskgroup_title = pof_importer_normalize_title($row['C']);
    if (!empty($agegroups_and_taskgroups[$agegroup_title]) && !empty($agegroups_and_taskgroups[$agegroup_title]->taskgroups[$taskgroup_title])) {
        $taskgroup_obj = $agegroups_and_taskgroups[$agegroup_title]->taskgroups[$taskgroup_title];
    }
    if (empty($taskgroup_obj->id)) {
        echo "<h2>Couldn't find taskgroup '" . $row['C'] . "' for suggestion '" . $row['F'] . "'</h2>";
        return;
    }
    $wp_error = false;
    $post = null;
    $args = array('numberposts' => -1, 'posts_per_page' => -1, 'post_type' => array('pof_post_task'), 'meta_key' => 'suoritepaketti', 'meta_value' => $taskgroup_obj->id, 'search_post_title' => $row['D']);
    add_filter('posts_where', 'pof_importer_title_filter', 10, 2);
    $the_query_task = new WP_Query($args);
    remove_filter('posts_where', 'pof_importer_title_filter', 10, 2);
    if ($the_query_task->have_posts()) {
        while ($the_query_task->have_posts()) {
            $the_query_task->the_post();
            $task = $the_query_task->post;
        }
    }
    if (empty($task)) {
        echo "<h2>Couldn't find task '" . $row['D'] . "' for suggestion '" . $row['F'] . "'</h2>";
        return;
    }
    $args = array('numberposts' => -1, 'posts_per_page' => -1, 'post_type' => array('pof_post_suggestion'), 'meta_key' => 'pof_suggestion_task', 'meta_value' => $task->ID, 'search_post_title' => $row['F']);
    add_filter('posts_where', 'pof_importer_title_filter', 10, 2);
    $the_query_suggestion = new WP_Query($args);
    remove_filter('posts_where', 'pof_importer_title_filter', 10, 2);
    if ($the_query_suggestion->have_posts()) {
        while ($the_query_suggestion->have_posts()) {
            $the_query_suggestion->the_post();
            $post = $the_query_suggestion->post;
        }
    }
    if (empty($post)) {
        echo "POST NOT FOUND; TO BE CREATED<br />";
        if ($saveToDataBase) {
            $post = array('post_title' => trim($row['B']), 'post_content' => $row['F'], 'post_type' => 'pof_post_suggestion', 'post_status' => 'publish', 'post_author' => get_current_user_id());
            $post_id = wp_insert_post($post, $wp_error);
            echo "imported, post: <a href=\"/wp-admin/post.php?post=" . $post_id . "&action=edit\" target=\"_blank\">" . $post_id . "</a>";
            echo "<br />";
            $post = get_post($post_id);
        }
    } else {
        echo "POST FOUND; TO BE UPDATED: <a href=\"/wp-admin/post.php?post=" . $post_id . "&action=edit\" target=\"_blank\">" . $post_id . "</a><br />";
        $post_id = $post->ID;
    }
    if ($saveToDataBase) {
        update_post_meta($post_id, "pof_suggestion_task", $task->ID);
        update_post_meta($post_id, "pof_suggestion_lang", pof_importer_suggestions_get_language($row['C']));
        update_post_meta($post_id, "pof_suggestion_writer", $row['D']);
        $post->post_title = trim($row['F']);
        $post->post_content = $row['I'];
        $post->post_author = get_current_user_id();
        // TODO: read publish time
        wp_update_post($post, $wp_error);
    }
}
function pof_importer_suggestionssdriveimport_importRow2($row, $row_index, $agegroup_id, $lang, $saveToDataBase = false)
{
    $wp_error = false;
    $post = null;
    $agegroups_and_tasks = pof_importer_get_agegroups_and_tasks($agegroup_id);
    $tasks = $agegroups_and_tasks[$agegroup_id];
    $task_title = pof_importer_normalize_title($row['A']);
    if (array_key_exists($task_title, $tasks)) {
        $task = $tasks[$task_title];
        echo "<br />Task found <a href=\"/wp-admin/post.php?post=" . $task->id . "&action=edit\" target=\"_blank\">'" . $row['A'] . "'</a></br>";
        $title_counter = 0;
        foreach ($row as $row_key => $row_value) {
            if ($row_key == 'A') {
                continue;
            }
            if ($row_key == 'H') {
                break;
            }
            $title_counter++;
            $title = "Toteutusvinkki " . strval($title_counter);
            if ($lang == 'sv') {
                $title = "Tips " . strval($title_counter);
            } elseif ($lang == 'en') {
                $title = "Example " . strval($title_counter);
            }
            if (strlen(trim($row_value)) < 5) {
                continue;
            }
            $args = array('numberposts' => -1, 'posts_per_page' => -1, 'post_type' => array('pof_post_suggestion'), 'meta_key' => 'pof_suggestion_task', 'meta_value' => $task->id, 'search_post_title' => $title);
            add_filter('posts_where', 'pof_importer_title_filter', 10, 2);
            $the_query_suggestion = new WP_Query($args);
            remove_filter('posts_where', 'pof_importer_title_filter', 10, 2);
            if ($the_query_suggestion->have_posts()) {
                while ($the_query_suggestion->have_posts()) {
                    $the_query_suggestion->the_post();
                    $tmp_lang = get_post_meta($the_query_suggestion->post->ID, "pof_suggestion_lang", true);
                    if ($tmp_lang == $lang) {
                        $post = $the_query_suggestion->post;
                    }
                }
            }
            if (empty($post)) {
                echo "POST NOT FOUND; TO BE CREATED, " . $title . "<br />";
                if ($saveToDataBase) {
                    $post = array('post_title' => $title, 'post_content' => $row_value, 'post_type' => 'pof_post_suggestion', 'post_status' => 'publish', 'post_author' => get_current_user_id());
                    $post_id = wp_insert_post($post, $wp_error);
                    echo "imported, post: <a href=\"/wp-admin/post.php?post=" . $post_id . "&action=edit\" target=\"_blank\">" . $post_id . "</a>";
                    echo "<br />";
                    $post = get_post($post_id);
                    update_post_meta($post_id, "pof_suggestion_task", $task->id);
                    update_post_meta($post_id, "pof_suggestion_lang", $lang);
                    update_post_meta($post_id, "pof_suggestion_writer", "Suomen partiolaiset");
                }
            } else {
                echo "SUGGESTION <a href=\"/wp-admin/post.php?post=" . $post->ID . "&action=edit\" target=\"_blank\">" . $title . "</a> FOUND; SKIPPING<br />";
            }
            $post = null;
        }
    } else {
        echo "<h2>Couldn't find task '" . $row['A'] . "'</h2>";
    }
}