<?php

if (empty($mpv[3]))
    yun_error(mlang('权限不足'));
/**
 * 批量删除
 */
$js = '';
$type = $_POST['type'];
is_array($_POST['pids']) or yun_error(mlang('至少选择一项'));
$pids = $_POST['pids'];
if ($type == 'del')
{
    foreach ($pids as $pid)
    {
        $pid = abs(intval($pid));
        if ($row = $db->fetch_first('select * from (' . PF .
            'article as article left join ' . PF . 'posts as post on article.menu_id=' . MID .
            ' && article.post_id=post.id) left join ' . PF .
            'user as user on post.authorid=user.id where article.post_id=' . $pid))
        {
            del_topic($pid, $row, MID);
            $js .= 'parent.document.getElementById("pid_' . $pid .
                '").style.display="none";';
        }
    }
    yun_succeed(mlang('删除成功'), $js);
} else
    if ($type == 'fdel')
    {
        foreach ($pids as $pid)
        {
            $pid = abs(intval($pid));
            if ($row = $db->fetch_first('select * from (' . PF .
                'article as article left join ' . PF . 'posts as post on article.menu_id=' . MID .
                ' && article.post_id=post.id) left join ' . PF .
                'user as user on post.authorid=user.id where article.post_id=' . $pid))
            {
                del_topic($pid, $row);
                $js .= 'parent.document.getElementById("pid_' . $pid .
                    '").style.display="none";';
            }
        }
        yun_succeed(mlang('删除成功'), $js);
    } else
        if ($type == 'move')
        {
            $tomid = intval($_POST['tomid']);
            $tomod = $conf['sys_menus'][$tomid]['mod'];
            empty($tomod) && yun_error(mlang('移动目标不明确'));
            $conf['sys_modules'][$tomod]['tixi'] == 'yuns' or yun_error(mlang('移动目标不明确'));
            foreach ($pids as $pid)
            {
                $pid = abs(intval($pid));
                if ($row = $db->fetch_first('select * from (' . PF .
                    'article as article left join ' . PF . 'posts as post on article.menu_id=' . MID .
                    ' && article.post_id=post.id) left join ' . PF .
                    'user as user on post.authorid=user.id where article.post_id=' . $pid))
                {
                    move_topic($pid, $row, MID, $tomid);
                    $js .= 'parent.document.getElementById("pid_' . $pid .
                        '").style.display="none";';
                }
            }
            yun_succeed(mlang('移动成功'), $js);
        } else
        {
            yun_error(mlang('error'));
        }

?>