/**
  * Check user permissions and topic status is valid for solving or
  * unsolving the post and topic given.
  *
  * @param string $solve Either "solved" or "unsolved".
  * @param array $topic_data Topic to be solved or unsolved.
  *
  * @throws \phpbb\exception\http_exception
  *         if post and topic can not be marked as solved or unsolved.
  *
  * @return void
  */
 protected function check_solve_conditions($solve, $topic_data)
 {
     if (!$this->topicsolved->user_can_solve_post($solve, $topic_data)) {
         throw new http_exception(403, 'FORBIDDEN_MARK_SOLVED');
     }
     if ($solve == 'solved' && !empty($topic_data['topic_solved'])) {
         throw new http_exception(403, 'TOPIC_ALREADY_SOLVED');
     } else {
         if ($solve == 'unsolved' && empty($topic_data['topic_solved'])) {
             throw new http_exception(403, 'TOPIC_ALREADY_UNSOLVED');
         }
     }
 }
 /**
  * Returns URL to action for setting a post as solved/unsolved.
  *
  * @param array $topic_data Forum topic data.
  * @param string $post_id Post ID
  *
  * @return string URL to action for solving/unsolving post.
  */
 protected function get_url_set_solved($topic_data, $post_id)
 {
     if ($this->topicsolved->user_can_solve_post('solved', $topic_data) && !$topic_data['topic_solved']) {
         return $this->helper->route('tierra_topicsolved_controller_mark', array('solve' => 'solved', 'post_id' => (int) $post_id));
     } else {
         if ($this->topicsolved->user_can_solve_post('unsolved', $topic_data) && $topic_data['topic_solved']) {
             return $this->helper->route('tierra_topicsolved_controller_mark', array('solve' => 'unsolved', 'post_id' => (int) $post_id));
         }
     }
     return '';
 }