/** * show edit forum page * @param $forum_id forum id * @param $cat_id category id * @param return forum edit window xml */ function editForum($forum_id, $cat_id) { $db = new DbAdmin(); $fdb = new DbForum(); if ($forum_id) { $a = $db->getForum((int) $forum_id); } else { $a['cat_id'] = $cat_id; } $c = $fdb->getCat($a['cat_id']); $a['cat_uri'] = $c['cat_uri']; $cu = $this->getUrlsXml(); encode_post_text($a['forum_title'], 0); encode_post_text($a['forum_desc'], 0); return <<<OES <root> {$cu} <forum forum_id="{$forum_id}"> <cat_id>{$a['cat_id']}</cat_id>\t <cat_uri>{$a['cat_uri']}</cat_uri> \t<title>{$a['forum_title']}</title>\t \t<desc>{$a['forum_desc']}</desc>\t \t<type>{$a['forum_type']}</type>\t <order>{$a['forum_order']}</order>\t </forum> </root> OES; }
/** * returns forum topics XML * @param $forum_id forum id * @param $wp return whole page XML * @param $start record to start with */ function getTopicsXML($forum_uri, $wp, $start = 0) { global $gConf; $fdb = new DbForum(); $f = $fdb->getForumByUri($forum_uri); $forum_id = $f['forum_id']; $user = $this->getLoginUser(); if (!$this->_checkUserPerm($user, $f['forum_type'], 'read', $forum_id)) { return $this->_no_access($wp); } $canPost = (string) (int) $this->_checkUserPerm($user, $f['forum_type'], 'post', $forum_id); $perm = "<perm><can_post>{$canPost}</can_post></perm>"; encode_post_text($f['forum_title'], $wp); encode_post_text($f['forum_desc'], $wp); $x1 = <<<EOF <forum> <id>{$f['forum_id']}</id> \t<uri>{$f['forum_uri']}</uri> \t<title>{$f['forum_title']}</title> \t<desc>{$f['forum_desc']}</desc> \t<type>{$f['forum_type']}</type> </forum> EOF; $cat = $fdb->getCat($f['cat_id']); encode_post_text($cat['cat_name'], $wp); $x2 = <<<EOF <cat> <id>{$cat['cat_id']}</id> <uri>{$cat['cat_uri']}</uri> \t<title>{$cat['cat_name']}</title> </cat> EOF; $user_last_act = (int) $fdb->getUserLastActivity($user); $a = $fdb->getTopics($forum_id, $start); reset($a); $t = ''; while (list(, $r) = each($a)) { $td = $fdb->getTopicDesc($r['topic_id']); $this->_buld_topic_desc($td); if (!$user) { $new_topic = 0; } else { $new_topic = $this->isNewTopic($r['topic_id'], $r['last_post_when'], $user_last_act) ? 1 : 0; } encode_post_text($r['topic_title'], $wp, 1); $t .= <<<EOF <topic id="{$r['topic_id']}" new="{$new_topic}" lpt="{$r['last_post_when']}" lut="{$user_last_act}" sticky="{$r['topic_sticky']}" locked="{$r['topic_locked']}"> \t<uri>{$r['topic_uri']}</uri> \t<title>{$r['topic_title']}</title> \t<desc>{$td}</desc> \t<count>{$r['count_posts']}</count> \t<last_u>{$r['last_post_user']}</last_u> \t<last_d>{$r['last_when']}</last_d> \t<first_u>{$r['first_post_user']}</first_u> \t<first_d>{$r['first_when']}</first_d> </topic> EOF; } $p = ''; $num = $fdb->getTopicsNum($forum_id); for ($i = 0; $i < $num; $i += $gConf['topics_per_page']) { $p .= '<p c="' . ($start >= $i && $start < $i + $gConf['topics_per_page'] ? 1 : 0) . '" start="' . $i . '">' . ($i / $gConf['topics_per_page'] + 1) . '</p>'; } if ($wp) { $li = $this->_getLoginInfo($user); return $this->addHeaderFooter($li, "<topics><pages>{$p}</pages>{$perm}{$x2}{$x1}{$t}</topics>"); } else { $cu = $this->getUrlsXml(); return "<root>{$cu}<topics><pages>{$p}</pages>{$perm}{$x2}{$x1}{$t}</topics></root>"; } }