/** * returns single post XML * @param $post_id post id * @param $force_show force show hidden post */ function getHiddenPostXML($post_id, $force_show) { global $gConf; $post_id = (int) $post_id; if (!$post_id) { return false; } $ui = array(); $fdb = new DbForum(); $t = $fdb->getTopicByPostId($post_id); $topic_id = $t['topic_id']; $f = $fdb->getForum($t['forum_id']); $forum_id = $f['forum_id']; // check user permission to read this topic posts $forum_type = $f['forum_type']; if (!$this->_checkUserPerm('', $forum_type, 'read', $forum_id)) { return $this->_no_access(); } // check user permissions to delete or edit posts $gl_allow_edit = 0; $gl_allow_del = 0; if ($this->_checkUserPerm('', $forum_type, 'edit', $forum_id)) { $gl_allow_edit = 1; } if ($this->_checkUserPerm('', $forum_type, 'del', $forum_id)) { $gl_allow_del = 1; } $u = $this->_getLoginUser(); $r = $fdb->getPost($post_id, $u); // acquire user info if (!$ui[$r['user']]) { $aa = $this->_getUserInfo($r['user']); $ui[$r['user']] = array('posts' => (int) $fdb->getUserPosts($r['user']), 'avatar' => $aa['avatar'], 'url' => $aa['profile_url'], 'onclick' => $aa['profile_onclick']); } $allow_edit = $gl_allow_edit; $allow_del = $gl_allow_del; if (!$allow_edit && $r['user'] == $this->_getLoginUserName()) { if ($this->_checkUserPerm($r['user'], 'own', 'edit', $forum_id)) { $allow_edit = 1; } } if (!$allow_del && $r['user'] == $this->_getLoginUserName()) { if ($this->_checkUserPerm($r['user'], 'own', 'del', $forum_id)) { $allow_del = 1; } } $cu = $this->getUrlsXml(); encode_post_text($r['post_text']); return <<<EOF <root> {$cu} <forum> <id>{$f['forum_id']}</id> <uri>{$f['forum_uri']}</uri> </forum> <topic> <id>{$topic_id}</id> <uri>{$t['topic_uri']}</uri> </topic> <post id="{$r['post_id']}" force_show="{$force_show}"> \t<text>{$r['post_text']}</text> \t<when>{$r['when']}</when> \t<allow_edit>{$allow_edit}</allow_edit> \t<allow_del>{$allow_del}</allow_del> \t<points>{$r['votes']}</points> \t<vote_user_point>{$r['vote_user_point']}</vote_user_point>\t \t<user posts="{$ui[$r['user']]['posts']}" name="{$r['user']}"> \t\t<avatar>{$ui[$r['user']]['avatar']}</avatar> \t\t<url>{$ui[$r['user']]['url']}</url> \t\t<onclick>{$ui[$r['user']]['onclick']}</onclick> \t</user> \t<min_point>{$gConf['min_point']}</min_point> </post> </root> EOF; }
/** * xml for edit post * @param $post_id post id * @param $topic_id topic id */ function editPostXml($post_id, $topic_id) { $cu = $this->getUrlsXml(); if ($post_id) { $db = new DbForum(); $a = $db->getTopicByPostId($post_id); $t = $db->getTopic($a['topic_id']); $topic_id = $t['topic_uri']; } return <<<EOS <root> \t{$cu} \t<edit_post> \t\t<post_id>{$post_id}</post_id> \t\t<topic_id>{$topic_id}</topic_id> \t</edit_post> </root> EOS; }