function do_del($id) { global $db; $db->query('delete from dataclass where id = ' . $id); $db->query('delete from data where dataclass_id = ' . $id); $list = $db->get_results('select * from dataclass where parent_id = ' . $id . ' order by sort desc, id desc', ARRAY_A); foreach ($list as $item) { do_del($item["id"]); } }
function do_post() { global $pdf_file; global $icons; get_pdf_file_post(); $action = get_post('action', 'none'); //IE, posila obsah butonu, wtfff? if (false !== strpos($action, $icons['done'])) { $action = 'done'; } if (false !== strpos($action, $icons['undo'])) { $action = 'undone'; } if (false !== strpos($action, $icons['dele'])) { $action = 'del'; } switch ($action) { case 'delall': do_delall(); break; case 'lock': do_lock(); break; case 'unlock': do_unlock(); break; case 'del': do_del(); break; case 'del-comment': do_delete_comment(); break; case 'done': do_done(true); break; case 'undone': do_done(false); break; case 'regen': regen_pdf_img(); break; case 'regen2': regen2_pdf_img(); break; case 'update': do_update_correction(); break; case 'update-comment': do_update_comment(); break; case 'comment': do_insert_comment(); break; default: do_insert_correction(); } }
if ($id) { $sql = "select * from dataclass where id = " . $id; $row = $db->get_row($sql, ARRAY_A); } else { $row = array("id" => 0, "name" => "", "type" => $type, "parent_id" => 0, "sort" => 0); } $smarty->assign("row", $row); $smarty->display('admin/admin_dataclass_add.html'); } elseif ($act == "addsubmit") { $list = array("name" => str_filter($_REQUEST["name"]), "sort" => intval($_REQUEST["sort"]), "parent_id" => intval($_REQUEST["parent_id"]), "type" => intval($_REQUEST['type'])); $id = isset($_REQUEST["id"]) ? intval($_REQUEST["id"]) : 0; if ($id) { $sql = SqlText::update("dataclass", $list, "id = " . $id); $db->query($sql); output_json(0, "更新成功"); } else { $sql = SqlText::insert("dataclass", $list); $db->query($sql); output_json(0, "添加成功"); } } elseif ($act == "get_tree_selector") { //获取 $type = isset($_REQUEST["type"]) ? intval($_REQUEST["type"]) : 0; $data = get_tree_selector($type); output_json(0, "请求成功", $data); } elseif ($act == "del") { do_del(intval($_REQUEST['id'])); output_json(0, "删除成功"); } else { exit("错误请求"); }