public function edit($node_id, $topic_id, $id) { if (empty($node_id) || empty($topic_id) || empty($id)) { show_message('缺少参数哟', site_url('topic/show/' . $topic_id)); } $this->load->model('comment_m'); $data['comment'] = $this->comment_m->get_comment_by_id($id); if ($this->auth->is_admin() || $this->auth->is_master($node_id) || $this->auth->is_user($data['comment']['uid'])) { //无编辑器时的处理 //if($this->config->item('show_editor')=='off'){ // $data['comment']['content'] = filter_check($data['comment']['content']); // $this->load->helper('format_content'); // $data['comment']['content'] = format_content($data['comment']['content']); // $data['comment']['content'] =br2nl($data['comment']['content'] ); //} $data['comment']['content'] = br2nl($data['comment']['content']); $data['comment']['content'] = $this->input->post('content') ? $this->input->post('content') : $data['comment']['content']; $data['comment']['content'] = decode_format($data['comment']['content']); $data['comment']['node_id'] = $node_id; //加载form类,为调用错误函数,需view前加载 $this->load->helper('form'); if ($this->form_validation->run('comment/edit') === TRUE) { //数据处理 $comment = array('content' => $this->input->post('content', true), 'replytime' => time()); $this->load->helper('format_content'); $comment['content'] = format_content($comment['content']); if ($this->db->where('id', $id)->update('comments', $comment)) { //更新贴子回复时间 $this->load->model('topic_m'); $this->db->set('lastreply', time(), FALSE)->where('topic_id', $topic_id)->update('topics'); redirect('topic/show/' . $topic_id); exit; } } $data['title'] = '编辑回贴'; $data['csrf_name'] = $this->security->get_csrf_token_name(); $data['csrf_token'] = $this->security->get_csrf_hash(); $this->load->view('comment_edit', $data); } else { show_message('非本人或管理员或本版块版主不能操作', site_url('topic/show/' . $topic_id)); } }
public function edit($topic_id) { //加载form类,为调用错误函数,需view前加载 $this->load->helper('form'); $data['title'] = '编辑话题'; $data['item'] = $this->topic_m->get_topic_by_topic_id($topic_id); //权限修改判断 if (!$this->auth->is_login()) { show_message('请登录后再编辑', site_url('user/login')); } if ($this->auth->is_user($data['item']['uid']) || $this->auth->is_admin() || $this->auth->is_master($data['item']['node_id'])) { //对内容进行br转换 $this->load->helper('br2nl'); $data['item']['content'] = br2nl($data['item']['content']); //反转义 $data['item']['content'] = stripslashes($data['item']['content']); //反format $data['item']['content'] = decode_format($data['item']['content']); //获取所有分类 $data['cates'] = $this->cate_m->get_all_cates(); //获取当前分类(包括已选择) $node_id = $this->input->post('node_id') ? $this->input->post('node_id') : $data['item']['node_id']; $data['cate'] = $this->db->get_where('nodes', array('node_id' => $node_id))->row_array(); //标题编辑(包括已输入) $data['item']['title'] = $this->input->post('title') ? $this->input->post('title') : $data['item']['title']; //内容编辑(包括已输入) $data['item']['content'] = $this->input->post('content') ? $this->input->post('content') : $data['item']['content']; if ($this->form_validation->run('topic/add') === TRUE) { $str = array('title' => $this->input->post('title'), 'content' => $this->input->post('content'), 'node_id' => $this->input->post('node_id'), 'updatetime' => time()); $this->load->helper('format_content'); $str['content'] = format_content($str['content']); if ($this->topic_m->update_topic($topic_id, $str)) { show_message('修改成功', site_url('topic/show/' . $topic_id), 1); } } //开启storage config $this->load->config('qiniu'); $data['csrf_name'] = $this->security->get_csrf_token_name(); $data['csrf_token'] = $this->security->get_csrf_hash(); $this->load->view('topic_edit', $data); } else { show_message('你无权修改此贴子'); } }