$this->addItem($result); $this->output(); } } /** * 编辑话题和回复 */ public function update() { $rid = isset($this->input['rid']) ? intval($this->input['rid']) : -1; if ($rid < 0) { $this->errorOutput(PARAM_WRONG); } //检测编辑的话题或回复是否存在 $reply_info = $this->topic->detail_reply($rid); if (!$reply_info) { $this->errorOutput(TEAM_NO_TOPIC); } //检测是否开启讨论 $topic_info = $this->topic->detail($reply_info['topic_id']); if ($topic_info['state'] == 2) { $this->errorOutput(TOPIC_CLOSE); } //判断用户权限 $user_type = $this->team->check_user_type($this->user['user_id'], $topic_info['source_id']); if ($user_type['level']) { if ($user_type['level'] == 4) { $this->errorOutput(NO_PERMISSION); } if ($this->user['user_id'] != $reply_info['poster_id']) { $this->errorOutput(NO_PERMISSION); } } $data = array(); $subject = isset($this->input['subject']) ? trim(urldecode($this->input['subject'])) : ''; $content = isset($this->input['content']) ? trim(urldecode($this->input['content'])) : ''; if ($reply_info['subject'] && empty($subject) || empty($content)) { $this->errorOutput(PARAM_WRONG); } if ($reply_info['subject'] != $subject) { $data['subject'] = $subject; } if ($reply_info['content'] != $content) { $data['content'] = $content; } $data['update_time'] = TIMENOW; $data['from_ip'] = hg_getip(); //保存编辑信息 if ($data['subject']) { $this->topic->update(array('subject' => $data['subject']), $reply_info['topic_id']); } $result = $this->topic->update_reply($data, $rid); //附件的操作 if (isset($this->input['material']) && !$reply_info['reply_user_id']) { $img_info = unserialize(urldecode($this->input['material'])); $materialData = array('user_id' => $reply_info['poster_id'], 'user_name' => $reply_info['poster_name'], 'topic_id' => $reply_info['topic_id'], 'team_id' => $topic_info['source_id'], 'reply_id' => 0); if (is_array($img_info) && !empty($img_info)) { $materialNum = $this->topic->add_material($img_info, $materialData); //插入附件 //更新话题下的附件个数 $this->topic->update(array('material_num' => $materialNum), $reply_info['topic_id'], true); } } //视频修改 if (isset($this->input['video_url']) && !$reply_info['reply_user_id']) { $video_url = trim(urldecode($this->input['video_url'])); $video_info = $this->teamApi->show_video($reply_info['topic_id'], 'topic'); if ($video_url != $video_info['url']) { $video->update_video($video_info['id'], $video_url, 'topic', $reply_info['topic_id']); } } //标签修改 if (isset($this->input['topic_mark']) && !$reply_info['reply_user_id']) { $topic_mark = trim(urldecode($this->input['topic_mark'])); $mark = new mark(); $data = array('source' => 'topic', 'source_id' => $reply_info['topic_id'], 'parent_id' => $topic_info['source_id'], 'action' => 'topic_tag', 'user_id' => $reply_info['poster_id']); if ($topic_mark) { $data['name'] = $topic_mark; } $result_mark = $mark->update_source_id_mark($data); if ($result_mark) { $result['topic_mark'] = $topic_mark; $this->topic->update(array('tags' => $topic_mark), $reply_info['topic_id']); } else { $this->errorOutput(FAIL_OP); } } if (!$reply_info['reply_user_id']) {
if (!$apply_id) { $this->errorOutput(PARAM_WRONG); } $data['id'] = $apply_id; return $data; } /** * 更新小组信息操作 */ public function update() { $team_id = intval($this->input['team_id']); //检测对应的小组是否存在 $team_info = $this->team->detail($team_id); if (!$team_info) { $this->errorOutput(TEAM_NO_EXISTS); } $data = $this->filter_data(); $verify_data = array(); if (isset($data['team_type']) && $data['team_type']) { $result_type = $this->team->check_team_type($data['team_type']); if (!$result_type) { $this->errorOutput(PARAM_WRONG); } $verify_data['team_type'] = $data['team_type']; } if ($team_info['team_category'] != $data['team_category']) { //检测小组分类是否存在 $result_category = $this->team->check_team_category($data['team_category']); if (!$result_category) { $this->errorOutput(PARAM_WRONG); } $verify_data['team_category'] = $data['team_category']; } if ($team_info['team_name'] != $data['team_name']) { //检测更新的小组名称是否存在 $result_name = $this->team->check_team_name($data['team_name'], $team_id); if ($result_name) { $this->errorOutput(TEAM_EXISTS); } $verify_data['team_name'] = $data['team_name']; } if ($team_info['introduction'] != $data['introduction']) { $verify_data['introduction'] = $data['introduction']; } if (isset($data['team_logo']) && $data['team_logo']) { $verify_data['team_logo'] = $data['team_logo']; } if (isset($data['notice'])) { if ($team_info['notice'] != $data['notice']) { $verify_data['notice'] = $data['notice']; } } $verify_data['update_time'] = TIMENOW; $result = $this->team->update($verify_data, $team_id); //标签更新 if ($team_info['tags'] != $data['tags']) { $team_mark = $data['tags']; } if (isset($team_mark) && $result) { $mark = new mark(); $data = array('source' => 'team', 'source_id' => $team_id, 'parent_id' => $team_id, 'action' => 'team_tag', 'user_id' => $team_info['creater_id']); if ($team_mark) { $data['name'] = $team_mark; } $result_mark = $mark->update_source_id_mark($data); if ($result_mark) { $this->team->update(array('tags' => $team_mark), $team_id); } else {
$this->output(); } /** * 设置小组信息操作 */ public function setting() { $team_id = intval($this->input['team_id']); //检测对应的小组是否存在 $team_info = $this->team->detail($team_id, 1); if (!$team_info) { $this->errorOutput(TEAM_NO_EXISTS); } if ($team_info['creater_id'] != $this->user['user_id']) { $this->errorOutput(NO_PERMISSION); } $data = $this->filter_data(); $verify_data = array(); //检测小组类型是否存在 if (isset($data['team_type']) && $data['team_type']) { $result_type = $this->team->check_team_type($data['team_type']); if (!$result_type) { $this->errorOutput(PARAM_WRONG); } $verify_data['team_type'] = $data['team_type']; } if ($team_info['team_category'] != $data['team_category']) { //检测小组分类是否存在 $result_category = $this->team->check_team_category($data['team_category']); if (!$result_category) { $this->errorOutput(PARAM_WRONG); } $verify_data['team_category'] = $data['team_category']; } if ($team_info['team_name'] != $data['team_name']) { //检测更新的小组名称是否存在 $result_name = $this->team->check_team_name($data['team_name'], $team_id); if ($result_name) { $this->errorOutput(TEAM_EXISTS); } $verify_data['team_name'] = $data['team_name']; } if ($team_info['introduction'] != $data['introduction']) { $verify_data['introduction'] = $data['introduction']; } if (isset($data['team_logo']) && $data['team_logo']) { $verify_data['team_logo'] = $data['team_logo']; } if (isset($data['notice'])) { if ($team_info['notice'] != $data['notice']) { $verify_data['notice'] = $data['notice']; } } $verify_data['update_time'] = TIMENOW; $result = $this->team->update($verify_data, $team_id); //标签更新 if ($team_info['tags'] != $data['tags']) { $team_mark = $data['tags']; } if (isset($team_mark) && $result) { $mark = new mark(); $data = array('source' => 'team', 'source_id' => $team_id, 'parent_id' => $team_id, 'action' => 'team_tag', 'user_id' => $team_info['creater_id']); if ($team_mark) { $data['name'] = $team_mark; } $result_mark = $mark->update_source_id_mark($data); if ($result_mark) { $this->team->update(array('tags' => $team_mark), $team_id); } else { $this->errorOutput(FAIL_OP); } } if ($verify_data['notice'] && $result) { //获取关注小组的用户信息 $option = new option(); $member = $option->members('team', $team_id, 'attention', 0, -1); //发送通知 $send_arr = array(); if ($member['data']['attention']) { $send_con = array(); foreach ($member['data']['attention']['infos'] as $v) { $send_con['from_id'] = 0; $send_con['to_id'] = $v['user_id']; $send_con['content'] = '您关注的"' . $team_info['team_name'] . '小组"有新公告!'; $send_con['page_link'] = 'team.php?team_id=' . $team_id; $send_con['link_text'] = '点击查看'; $send_arr[] = $send_con; } } if ($send_arr) { $this->notify->notify_send(json_encode($send_arr), 0); } } //更新搜索