private function editMsgCategoryDataSubmit($type) { $data['name'] = isset($_POST['catname']) ? trim($_POST['catname']) : ''; //名称 $data['rules'] = isset($_POST['alphabet']) ? $_POST['alphabet'] : array(); $data['account'] = isset($_POST['account']) ? trim($_POST['account']) : ''; //账号 $data['notes'] = isset($_POST['notes']) ? trim($_POST['notes']) : ''; //备注 extract($this->platformRelate($type)); //特定平台相关信息 $data['rules'] = array_intersect($data['rules'], generate_alphabet()); //计算交集 以确保规则正确 $data['rules'] = implode(',', $data['rules']); $data['platform'] = $platformid; $data = array_map('mysql_real_escape_string', $data); $msgcat_obj = new messagecategoryModel(); if ($data['account'] == -1) { //未分配账号 $promptdata = array('data' => array('请分配账号!'), 'link' => $gobackurl); goErrMsgPage($promptdata); exit; } $cid = isset($_POST['cid']) ? trim($_POST['cid']) : 0; if ($cid === 0) { //新增加分类 $result = $msgcat_obj->addNewCategory($data); } else { //更新分类 /*----- 如果是更新 则需确保数据分类是否和操作的向对应 -----*/ $catinfo = $msgcat_obj->getCategoryInfoById($cid); if (empty($catinfo)) { //不存在的id $promptdata = array('data' => array('不合法的id!'), 'link' => $gobackurl); goErrMsgPage($promptdata); exit; } if ($catinfo['platform'] != $data['platform']) { //hack行为 $promptdata = array('data' => array('不合法的id!'), 'link' => $gobackurl); goErrMsgPage($promptdata); exit; } unset($data['platform']); //不运行更新所属平台 $result = $msgcat_obj->updateCategoryInfo($cid, $data); } if ($result) { $promptdata = array('data' => array('操作成功!'), 'link' => $gobackurl); goOkMsgPage($promptdata); exit; } else { $promptdata = array('data' => array('操作失败!'), 'link' => $gobackurl); goErrMsgPage($promptdata); exit; } }
public function view_ajaxChangeMessagesCategory_alisite() { $ids = isset($_GET['msgids']) ? trim($_GET['msgids']) : ''; if (empty($ids)) { //没指定messageid $msgdata = array('errCode' => 10001, 'errMsg' => '请指定id'); echo json_encode($msgdata); exit; } $idar = clearData($ids); if (empty($idar)) { $msgdata = array('errCode' => 10002, 'errMsg' => '请指定id'); echo json_encode($msgdata); exit; } $catid = isset($_GET['cid']) ? trim($_GET['cid']) : 0; if ($catid == 0) { $msgdata = array('errCode' => 10004, 'errMsg' => '请指定分类id'); echo json_encode($msgdata); exit; } if (!is_numeric($catid)) { $msgdata = array('errCode' => 10003, 'errMsg' => '分类id不正确'); echo json_encode($msgdata); exit; } $msgcat_obj = new messagecategoryModel(); $catinfo = $msgcat_obj->getCategoryInfoById($catid, ' and platform=2'); if (empty($catinfo)) { $msgdata = array('errCode' => 10007, 'errMsg' => '分类id不正确'); echo json_encode($msgdata); exit; } $msg_obj = new messageModel(); $result = $msg_obj->moveMessagesToSpecifiedCategory_alisite($idar, $catid); if ($result) { $msgdata = array('errCode' => 10006, 'errMsg' => '执行成功!'); echo json_encode($msgdata); exit; } else { $msgdata = array('errCode' => 10005, 'errMsg' => '执行失败!'); echo json_encode($msgdata); exit; } }