function add_or_edit_cat() { global $global, $smarty, $lang; $cat_id = post('cat_id'); $cat_parent_id = post('cat_parent_id'); $cat_name = post('cat_name'); $obj = new cat_art(); $obj->set_value('cat_parent_id', $cat_parent_id); $obj->set_value('cat_name', $cat_name); if ($cat_id != '') { $obj->set_where("cat_id = {$cat_id}"); $obj->edit(); $info_text = $lang['edit_cat_success']; } else { $obj->set_value('cat_channel_id', $global['channel_id']); $obj->set_value('cat_lang', S_LANG); $obj->add(); $info_text = $lang['add_cat_success']; } $smarty->assign('info_text', $info_text); $smarty->assign('link_text', $lang['return_list']); $smarty->assign('link_href', url(array('channel' => $global['channel'], 'mod' => 'cat_list'))); }