/** * index页面操作筛选 */ public function indexHandle() { $PostsLogic = new PostsLogic(); if (I('post.keyword') != '') { $this->redirect('Admin/Posts/' . I('post.post_type', 'single'), array('keyword' => I('post.keyword'))); } if (I('post.delAll') == 1) { $post_ids = I('post.posts'); is_string($post_ids) == true ? $num = 0 : ($num = count($post_ids)); $res_info = ''; foreach ($post_ids as $post_id) { $res = $PostsLogic->preDel($post_id); if ($res == false) { $res_info = $res_info . ' 文章ID:' . $post_id . '删除到回收站失败'; } } $this->success($num . '篇文章批量删除到回收站成功' . $res_info); } if (I('post.emptyAll') == 1) { $post_ids = I('post.posts'); is_string($post_ids) == true ? $num = 0 : ($num = count($post_ids)); $res_info = ''; foreach ($post_ids as $post_id) { $res = $PostsLogic->del($post_id); if ($res == false) { $res_info = $res_info . ' 文章ID:' . $post_id . '批量彻底删除失败'; } } $this->success($num . '篇文章批量彻底删除成功' . $res_info); } if (I('post.verifyAll') == 1) { $post_ids = I('post.posts'); is_string($post_ids) == true ? $num = 0 : ($num = count($post_ids)); $res_info = ''; foreach ($post_ids as $post_id) { $res = $PostsLogic->verify($post_id); if ($res == false) { $res_info = $res_info . '文章ID:' . $post_id . '移至待审核列表失败'; } } $this->success($num . '篇文章批量移至待审核列表' . $res_info); } if (I('post.restoreAll') == 1) { $post_ids = I('post.posts'); is_string($post_ids) == true ? $num = 0 : ($num = count($post_ids)); $res_info = ''; foreach ($post_ids as $post_id) { $res = $PostsLogic->restore($post_id); if ($res == false) { $res_info = $res_info . '文章ID:' . $post_id . '移至所有文章列表失败'; } } $this->success($num . '篇文章批量移至所有文章列表' . $res_info); } if (I('post.postAdd') == 1) { $this->redirect('Admin/Posts/add'); } }
/** * 删除标签 * @param $id */ public function delTag($id = -1) { $TagsLogic = new TagsLogic(); $PostsLogic = new PostsLogic(); $process_method = I('post.process_method'); if ($process_method == 'totag' && I('post.newtag') == $id) { $this->error("移动后的标签不能和当前分类相同"); } if ($TagsLogic->delete($id)) { if (D('Post_tag')->where(array("tag_id" => $id))->find()) { $pt_list = D('Post_tag')->where(array("tag_id" => $id))->select(); foreach ($pt_list as $pt) { if ($process_method == 'del') { $PostsLogic->preDel($pt['post_id']); } if ($process_method == 'totag') { $data['tag_id'] = I('post.newtag'); D('Post_tag')->where(array("pt_id" => $pt['pt_id']))->data($data)->save(); } } } } else { $this->error('标签删除失败:没有找到指定标签,可能它已经被删除', U('Admin/Posts/tag')); } $this->success('标签删除成功', U('Admin/Posts/tag')); }