cw_array2update('faq_questions', $to_insert, "question_id='{$question_id}'");
        } else {
            $question_id = cw_array2insert('faq_questions', $to_insert, "question_id='{$question_id}'");
        }
        $lng_insert = array('question_id' => $question_id, 'thema' => $data['thema'], 'content' => $data['content'], 'code' => $current_language);
        cw_array2insert('faq_questions_lng', $lng_insert, true);
        if ($_FILES) {
            $data = array();
            $data['file_path'] = cw_move_uploaded_file('file', '');
            $data['filename'] = $_FILES['file']['name'];
            if ($data['file_path']) {
                cw_file_area_save('faq_files', $question_id, $data);
            }
        }
        //        cw_faq_recalc_counters(array_shift(cw_faq_rubrik_path($to_insert['rubrik_id'])));
        $parents = cw_faq_parent_rubriks($to_insert['rubrik_id']);
        cw_faq_recalc_counters($parents[0]['rubrik_id']);
        cw_header_location('index.php?target=faq&mode=question&question_id=' . $question_id);
    }
    $saved_question = $to_insert;
    cw_header_location('index.php?target=faq&mode=question&error=1&question_id=' . $question_id);
}
if ($error) {
    $smarty->assign('question', array_map('stripslashes', $saved_question));
    $smarty->assign('field_errors', $field_errors);
    $field_errors = array();
    $saved_question = array();
} else {
    $smarty->assign('question', cw_faq_get_article($question_id, $current_language, false, false));
}
$smarty->assign('all_rubriks', cw_faq_get_all_rubriks());
}
if (AREA_TYPE == 'B') {
    $main_cat_id = cw_faq_get_salesman_category();
} elseif ($is_product_faq) {
    $main_cat_id = cw_faq_get_product_category();
    $smarty->assign('is_product_faq', $is_product_faq);
} elseif ($is_membership_faq) {
    $main_cat_id = cw_faq_get_membership_category();
}
$faq_categories = cw_get_faq_categories($main_cat_id);
$smarty->assign('faq_categories', $faq_categories);
if (empty($cat_id)) {
    $cat_id = $main_cat_id;
}
$smarty->assign('cat_id', $cat_id);
$path = cw_faq_parent_rubriks($cat_id);
if (is_array($path)) {
    foreach ($path as $result) {
        $location[] = array($result['title'], "index.php?target={$target}&mode=category&cat_id=" . $result['rubrik']);
    }
}
if ($cat_id) {
    $__tmp = array();
    $__tmp['main_category'] = cw_faq_get_main($cat_id);
    $smarty->assign('faq', $__tmp);
}
if ($mode == 'membership') {
    $smarty->assign('faq', cw_faq_get_membership_faq($user_account['membership_id']));
    $smarty->assign('main', 'product');
} elseif ($mode == 'salesman') {
    $smarty->assign('faq', cw_faq_get_salesman_faq());