private function editMsgCategoryDataSubmit() { $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['site'] = isset($_POST['site']) ? trim($_POST['site']) : ''; $data['gmail'] = isset($_POST['gmail']) ? trim($_POST['gmail']) : ''; $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 = array_map('mysql_real_escape_string', $data); $msgcat_obj = new amazonmessagecategoryModel(); $lpower_obj = new LocalPowerAmazonModel(); $global_obj = new GetLoacalUserModel(); //print_r($_SESSION); $creater = $global_obj->getRealNameByGlobalId($_SESSION['globaluserid']); $data['creater'] = $creater['global_user_name']; $data['createtime'] = time(); if ($data['account'] == -1) { //未分配账号 $promptdata = array('data' => array('请分配账号!'), 'link' => $gobackurl); goErrMsgPage($promptdata); } $cid = isset($_POST['cid']) ? trim($_POST['cid']) : 0; //这下面是判断是新增分类还是编辑分类,然后执行相应操作 if ($cid === 0) { //新增加分类 try { $result = $msgcat_obj->addNewCategory($data); } catch (Exception $e) { $promptdata = array('data' => array('新增分类失败!'), 'link' => $gobackurl); goErrMsgPage($promptdata); exit; } if (empty($result)) { //不存在的id $promptdata = array('data' => array('不合法的id!'), 'link' => $gobackurl); goErrMsgPage($promptdata); exit; } else { /*----- 将新增的分类的权限给创建者 -----*/ try { $new_cid = $msgcat_obj->getCategoryInfoByCatname($data['name']); $lpower_obj->updatePowerByAddClass($_SESSION['userId'], $new_cid['id']); } catch (Exception $e) { print_r($new_cid); /* $promptdata = array('data'=>array('权限更新失败!'), 'link'=>$gobackurl); goErrMsgPage($promptdata); */ exit; } } } else { //更新分类 /*----- 如果是更新 则需确保数据分类是否和操作的向对应 -----*/ $catinfo = $msgcat_obj->getCategoryInfoById($cid); if (empty($catinfo)) { //不存在的id $promptdata = array('data' => array('不合法的id!'), 'link' => $gobackurl); goErrMsgPage($promptdata); exit; } $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; } }
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; } }