function add_category($parent_id, $name, $form_id = 1)
 {
     $category_id = JB_add_cat($name, $parent_id, $form_id, 'Y');
     return $category_id;
 }
Beispiel #2
0
<?php 
if ($_REQUEST['cat'] == false) {
    $_REQUEST['cat'] = 0;
}
$new_cat = $_REQUEST['new_cat'];
if ($new_cat != '') {
    if (strlen($new_cat) > 0) {
        if ($_REQUEST['allow_records'] == 'ON') {
            $allow_records = 'Y';
        } else {
            $allow_records = 'N';
        }
        // split each category on line:
        $cats = preg_split('#\\n#', $new_cat);
        foreach ($cats as $cat_name) {
            JB_add_cat($cat_name, $_REQUEST['cat'], $_SESSION['form_id'], $allow_records);
        }
        JB_compute_cat_has_child();
        JB_init_category_tables(0);
        JB_cache_del_keys_for_all_cats(1);
        JB_cache_del_keys_for_all_cats(2);
        JB_cache_del_keys_for_all_cats(3);
        JB_cache_del_keys_for_all_cats(4);
        JB_cache_del_keys_for_all_cats(5);
        JB_cache_del_keys_for_cat_options();
        $JBMarkup->ok_msg('Category Saved.');
    } else {
        $JBMarkup->error_msg('category name was left blank. Please retry.');
    }
}
if ($action == 'edit') {