function cw_faq_create_rubrik($title, $parent_id, $ars_id = 0, $ars_type = '') { global $tables; $to_insert = array(); $to_insert['title'] = $title; $to_insert['date'] = cw_core_get_time(); $to_insert['parent_id'] = $parent_id; $to_insert['ars_id'] = $ars_id; $to_insert['ars_type'] = $ars_type; $rubrik_id = cw_array2insert('faq_rubrik', $to_insert); cw_faq_update_path($rubrik_id); cw_faq_recalc_counters($rubrik_id); return $rubrik_id; }
<?php cw_load('faq'); if ($action == 'add' && $data['title']) { $rubrik_id = cw_faq_create_rubrik($data['title'], $cat); cw_faq_recalc_counters($cat); cw_header_location('index.php?target=' . $target . '&mode=category&rubrik_id=' . $rubrik_id); } if ($action == 'edit') { db_query("update {$tables['faq_rubrik']} set title='{$data['title']}' where rubrik_id='{$rubrik_id}'"); cw_faq_recalc_counters($rubrik_id); if ($data['parent_id'] >= 0) { db_query("update {$tables['faq_rubrik']} set parent_id='{$data['parent_id']}' where rubrik_id='{$rubrik_id}'"); cw_faq_update_path($rubrik_id); cw_faq_recalc_counters($current_parent); if ($new_parent != $current_parent) { cw_faq_recalc_counters($new_parent); } } cw_header_location('index.php?target=' . $target . '&mode=category&rubrik_id=' . $rubrik_id); } $location[] = array(cw_get_langvar_by_name('lbl_faq_categories'), 'index.php?target=faq_categories'); if (!$rubrik_id) { if ($cat && !cw_faq_is_category($cat)) { cw_header_location('index.php?target=faq_categories'); } $smarty->assign('cat', $cat); $smarty->assign('mode', 'add'); } else { $smarty->assign('all_rubriks', cw_faq_get_all_rubriks($rubrik_id)); $smarty->assign('current_rubrik', cw_faq_get_rubrik($rubrik_id));