function cw_faq_create_membership($mem_id)
{
    global $tables;
    if ($mem_id == 0) {
        $mem_info['area'] = 'C';
        $mem_info['membership'] = 'Retail customer';
    } else {
        $mem_info = cw_query_first("select area, membership from {$tables['memberships']} where membership_id='{$mem_id}'");
    }
    if ($mem_info['area'] != 'C') {
        return;
    }
    $category_id = cw_query_first("select rubrik_id from {$tables['faq_rubrik']} where ars_id='{$mem_id}' and ars_type = 'member'");
    if ($category_id) {
        db_query("update {$tables['faq_rubrik']} set title='" . addslashes($mem_info['membership']) . "' where ars_id='{$mem_id}' and ars_type = 'member'");
    } else {
        $main = cw_faq_get_membership_category();
        $rubrik_id = cw_array2insert('faq_rubrik', array('parent_id' => $main, 'title' => addslashes($mem_info['membership']), 'date' => date("YmdHis"), 'ars_id' => $mem_id, 'ars_type' => 'member'));
        cw_faq_update_path($rubrik_id);
        cw_faq_recalc_counters($main);
    }
}
<?php

cw_load('faq', 'mail', 'user', 'file_area');
$location[] = array(cw_get_langvar_by_name('lbl_faq_main_page'), 'index.php?target=' . $target);
if (empty($mode)) {
    $mode = "category";
}
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);