예제 #1
0
/**
 * Forhåndsvisning av forumtråd
 * 
 * Inndata:
 * - topic_id [optional]
 * - text
 */
require "../../../app/ajax.php";
ajax::require_user();
// kontroller lås
ajax::validate_lock(true);
global $_base, $_game;
// sett opp tekst
$text = postval("text");
if (empty($text)) {
    $text = "Mangler innhold.";
}
// forhåndsviser vi en redigert forumtråd?
if (isset($_POST['topic_id'])) {
    // hent forumtråden
    $topic = new \Kofradia\Forum\TopicAjax($_POST['topic_id']);
    // sett opp data
    $data = $topic->extended_info();
    $data['ft_text'] = $text;
    $data['ft_last_edit'] = time();
    $data['ft_last_edit_up_id'] = login::$user->player->id;
} else {
    // sett opp data
    $data = array("ft_text" => $text);
}
ajax::html(parse_html(\Kofradia\Forum\Category::template_topic_preview($data)));
예제 #2
0
        $new_last_edit[$row['fr_id']] = $data['fr_last_edit'];
    }
    // oppdatere sist sett?
    if ($time_last && login::$logged_in) {
        // oppdater
        \Kofradia\DB::get()->exec("UPDATE forum_seen SET fs_time = GREATEST(fs_time, {$time_last}) WHERE fs_ft_id = {$id} AND fs_u_id = " . login::$user->id);
    }
}
// generer XML
$xml = '
<topic id="' . $id . '" time="' . time() . '">';
// forumtråden oppdatert?
if ((int) $topic['ft_last_edit'] != $topic_last_edit) {
    $topic_obj = new \Kofradia\Forum\TopicAjax($id, $forum);
    $xml .= '
	<tupdated last_edit="' . $topic_obj->info['ft_last_edit'] . '">' . htmlspecialchars(parse_html($forum->template_topic($topic_obj->extended_info()))) . '</tupdated>';
}
$xml .= '
	<new>';
// noen nye?
if (count($new) > 0) {
    $new = parse_html_array($new);
    foreach ($new as $id => $html) {
        $xml .= '
		<post id="' . $id . '" last_edit="' . intval($new_last_edit[$id]) . '">' . htmlspecialchars($html) . '</post>';
    }
    $xml .= '
';
}
$xml .= '</new>
	<updated>';