$cal->images_url = "{$mod_url}/images/{$skin_folder}";
$cal->images_path = "{$mod_path}/images/{$skin_folder}";
// XOOPS関連の初期化
$myts =& MyTextSanitizer::getInstance();
$cattree = new XoopsTree($cal->cat_table, "cid", "pid");
$gperm_handler =& xoops_gethandler('groupperm');
// データベース更新などがからむ処理
if ($action == "insert") {
    // Ticket Check
    if (!$xoopsGTicket->check()) {
        redirect_header(XOOPS_URL . '/', 3, $xoopsGTicket->getErrors());
    }
    // 新規登録
    $sql = "INSERT INTO {$cal->cat_table} SET ";
    $cols = array("weight" => "I:N:0", "ismenuitem" => "I:N:0", "cat_title" => "255:J:1", "cat_desc" => "A:J:0", "pid" => "I:N:0");
    $sql .= $cal->get_sql_set($cols);
    if (!mysql_query($sql, $conn)) {
        die(mysql_error());
    }
    rebuild_cat_tree($cal->cat_table);
    $mes = urlencode(_AM_MB_CAT_INSERTED);
    $cal->redirect("done=inserted&mes={$mes}");
    exit;
} else {
    if ($action == "update" && $_POST['cid'] > 0) {
        // Ticket Check
        if (!$xoopsGTicket->check()) {
            redirect_header(XOOPS_URL . '/', 3, $xoopsGTicket->getErrors());
        }
        // 更新
        $cid = intval($_POST['cid']);