/** * Delete a link * * @param int $cat_id The category ID * @param int $link_id The link ID * @return null|\Symfony\Component\HttpFoundation\Response A Symfony Response object */ public function delete_link($cat_id, $link_id) { if ($this->request->is_set_post('cancel')) { $redirect = $this->helper->route('ernadoo_phpbbdirectory_page_controller', array('cat_id' => (int) $cat_id)); redirect($redirect); } $sql = 'SELECT link_user_id FROM ' . DIR_LINK_TABLE . ' WHERE link_id = ' . (int) $link_id; $result = $this->db->sql_query($sql); $link_data = $this->db->sql_fetchrow($result); if (empty($link_data)) { throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_LINKS'); } $delete_allowed = $this->user->data['is_registered'] && ($this->auth->acl_get('m_delete_dir') || $this->user->data['user_id'] == $link_data['link_user_id'] && $this->auth->acl_get('u_delete_dir')); if (!$delete_allowed) { throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); } if (confirm_box(true)) { $this->link->del($cat_id, $link_id); $meta_info = $this->helper->route('ernadoo_phpbbdirectory_page_controller', array('cat_id' => (int) $cat_id)); meta_refresh(3, $meta_info); $message = $this->user->lang['DIR_DELETE_OK'] . '<br /><br />' . $this->user->lang('DIR_CLICK_RETURN_DIR', '<a href="' . $this->helper->route('ernadoo_phpbbdirectory_base_controller') . '">', '</a>') . '<br /><br />' . $this->user->lang('DIR_CLICK_RETURN_CAT', '<a href="' . $this->helper->route('ernadoo_phpbbdirectory_page_controller', array('cat_id' => (int) $cat_id)) . '">', '</a>'); return $this->helper->message($message); } else { confirm_box(false, 'DIR_DELETE_SITE'); } }