/** * Mark a topic as solved or unsolved. * * Route: /topicsolved/mark/{solve}/{post_id} * * @param string $solve Either "solved" or "unsolved". * @param int $post_id Post to mark. * * @return \Symfony\Component\HttpFoundation\Response */ public function mark($solve, $post_id) { $topic_data = $this->topicsolved->get_topic_data($post_id); if (empty($topic_data)) { throw new http_exception(404, 'TOPIC_NOT_FOUND'); } $this->check_solve_conditions($solve, $topic_data); if ($solve == 'solved') { $this->topicsolved->mark_solved($topic_data, $post_id); } else { $this->topicsolved->mark_unsolved($topic_data); } $post_url = $this->topicsolved->get_link_to_post($topic_data['forum_id'], $topic_data['topic_id'], $post_id); return new RedirectResponse($post_url); }
/** * Assign topic solved view data for topic. * * @param \phpbb\event\data $event Topic data being rendered. * * @return void */ public function viewtopic_assign_template_vars_before($event) { $topic_data = $event['topic_data']; if ($topic_data['topic_solved'] && $topic_data['forum_allow_solve'] && $topic_data['topic_type'] != POST_GLOBAL) { $solved_url = $this->topicsolved->get_link_to_post($event['forum_id'], $event['topic_id'], $topic_data['topic_solved']); $this->template->assign_var('U_SOLVED_POST', $solved_url); if (!empty($topic_data['forum_solve_text'])) { $this->template->assign_var('TOPIC_SOLVED_TITLE', $topic_data['forum_solve_text']); } else { $this->template->assign_var('TOPIC_SOLVED_IMAGE', $this->topicsolved->image('head', 'TOPIC_SOLVED')); } if (!empty($topic_data['forum_solve_color'])) { $this->template->assign_var('TOPIC_SOLVED_STYLE', $topic_data['forum_solve_color']); } } }