<?php /** * Legg til ny forumtråd * * Inndata: * - sid * - forum_id * - title * - text * - type [optional, forum mod] * - locked [optional, forum mod] */ require "../../../app/ajax.php"; ajax::validate_sid(); // kontroller lås ajax::validate_lock(true); global $_base, $_game; // kontroller forumkategori og tilgang $forum = new \Kofradia\Forum\CategoryAjax(postval("forum_id")); $forum->require_access(); // forsøk å legg til forumtråden $type = isset($_POST['type']) && $forum->fmod ? $_POST['type'] : NULL; $locked = isset($_POST['locked']) && $forum->fmod ? $_POST['locked'] : NULL; $forum->add_topic(postval("title"), postval("text"), $type, $locked);
$topic_last_edit = (int) $_POST['topic_last_edit']; // hent topic info $seen_q = login::$logged_in ? "fs_ft_id = ft_id AND fs_u_id = " . login::$user->id : "FALSE"; $result = \Kofradia\DB::get()->query("\nSELECT\n\tft_id, ft_fse_id, ft_title, ft_deleted, ft_last_reply, ft_last_edit,\n\tfs_time\nFROM\n\tforum_topics\n\tLEFT JOIN forum_seen ON {$seen_q}\nWHERE ft_id = {$id}"); // finnes ikke? if ($result->rowCount() == 0) { ajax::text("ERROR:404-TOPIC", ajax::TYPE_INVALID); } // les info $topic = $result->fetch(); // sjekk om det er slettet, har vi tilgang? if ($topic['ft_deleted'] != 0 && !access::has("forum_mod")) { ajax::text("ERROR:404-TOPIC", ajax::TYPE_INVALID); } // kontroller tilgang til forumet $forum = new \Kofradia\Forum\CategoryAjax($topic['ft_fse_id']); $forum->require_access(); // mangler svarliste? if (!isset($_POST['r_id_list'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } // hvilket tidspunkt vi skal hente endringer etter if (!isset($_POST['time'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } $time_last = (int) $_POST['time']; // mangler siste id? if (!isset($_POST['r_last_id'])) { ajax::text("ERROR:MISSING"); } // sett opp liste over svar-ID-ene vi har