$thread_buttons['reply']['name'] = _MD_REPLY; } if (!$isadmin && $xoopsModuleConfig['reportmod_enabled']) { $thread_buttons['report']['image'] = forum_displayImage($xforumImage['p_report'], _MD_REPORT); $thread_buttons['report']['link'] = "report.php?forum=" . $post->getVar('forum_id') . "&topic_id=" . $post->getVar('topic_id'); $thread_buttons['report']['name'] = _MD_REPORT; } $thread_action = array(); $xoopsTpl->append('posts', array( 'post_id' => $post->getVar('post_id'), 'topic_id' => $post->getVar('topic_id'), 'forum_id' => $post->getVar('forum_id'), 'post_date' => forum_formatTimestamp($post->getVar('post_time')), 'post_image' => $post_image, 'post_title' => $post_title, 'post_text' => $post_text, 'post_attachment' => $post_attachment, 'post_edit' => $post->displayPostEdit(), 'post_no' => $start+$pn, 'post_signature' => ($post->getVar('attachsig'))?@$poster["signature"]:"", 'poster_ip' => ($isadmin && $xoopsModuleConfig['show_ip'])?long2ip($post->getVar('poster_ip')):"", 'thread_action' => $thread_action, 'thread_buttons' => $thread_buttons, 'poster' => $poster ) ); unset($thread_buttons);
function &display(&$xforums_obj) { global $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $xforumImage, $myts; include_once XOOPS_ROOT_PATH.'/modules/xforum/include/functions.php'; $posts = array(); $posts_obj = array(); foreach (array_keys($xforums_obj) as $id) { $posts[] = $xforums_obj[$id]->getVar("forum_last_post_id"); } if(!empty($posts)){ $post_handler =& xoops_getmodulehandler('post', 'xforum'); $posts_obj =& $post_handler->getAll(new Criteria("post_id", "(".implode(", ", $posts).")", "IN"), array("uid", "topic_id", "post_time", "subject", "poster_name", "icon")); } $users = array(); $reads = array(); foreach (array_keys($xforums_obj) as $id) { $forum_obj =& $xforums_obj[$id]; if(!$forum_obj->getVar("forum_last_post_id")) continue; if(!$post_obj =& $posts_obj[$forum_obj->getVar("forum_last_post_id")]) { $forum_obj->assignVar("forum_last_post_id", 0); continue; } $users[] = $post_obj->getVar("uid"); if($moderators = $forum_obj->getModerators()){ $users = array_merge($users, $moderators); } // reads if(!empty($xoopsModuleConfig["read_mode"])){ $reads[$id] = ($xoopsModuleConfig["read_mode"] == 1)?$post_obj->getVar('post_time'):$post_obj->getVar('post_id'); } } $forum_isread = forum_isRead("forum", $reads); $users_linked = forum_getUnameFromIds(array_unique($users), !empty($xoopsModuleConfig['show_realname']), true); $xforums_array = array(); foreach (array_keys($xforums_obj) as $id) { $forum_obj =& $xforums_obj[$id]; if(!$this->getPermission($forum_obj, "access", false)) continue; $_forum_data = array(); $_forum_data["forum_order"] = $forum_obj->getVar('forum_order'); $_forum_data["forum_id"] = $id; $_forum_data["forum_cid"] = $forum_obj->getVar('cat_id'); $_forum_data["forum_name"] = $forum_obj->getVar('forum_name'); $_forum_data["forum_desc"] = $forum_obj->getVar('forum_desc'); $_forum_data["forum_posts"] = $forum_obj->getVar("forum_posts"); $_forum_data["forum_topics"] = $forum_obj->getVar("forum_topics"); $_forum_data["forum_type"] = $forum_obj->getVar('forum_type'); $_forum_data["forum_permission"]= $this->getPermission($forum_obj, "view"); $forum_moderators = array(); $moderators = $forum_obj->getModerators(); foreach($moderators as $moderator){ $forum_moderators[] = @$users_linked[$moderator]; } $_forum_data["forum_moderators"] = implode(", ", array_filter($forum_moderators)); if($forum_obj->getVar("forum_last_post_id")): $post_obj =& $posts_obj[$forum_obj->getVar("forum_last_post_id")]; if(!empty($users_linked[$post_obj->getVar("uid")])){ $_forum_data["forum_lastpost_user"] = $users_linked[$post_obj->getVar("uid")]; }elseif($post_obj->getVar("poster_name")){ $_forum_data["forum_lastpost_user"] = $post_obj->getVar("poster_name"); }else{ $_forum_data["forum_lastpost_user"] = $myts->htmlSpecialChars($GLOBALS["xoopsConfig"]["anonymous"]); } $_forum_data['forum_lastpost_time'] = forum_formatTimestamp($post_obj->getVar('post_time')); $_forum_data['forum_lastpost_icon'] = '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar("dirname") . '/viewtopic.php?post_id=' . $post_obj->getVar('post_id') . '&topic_id=' . $post_obj->getVar('topic_id') . '#forumpost' . $post_obj->getVar('post_id') . '">'. '<img src="' . XOOPS_URL . '/images/subject/' . ($post_obj->getVar('icon')?$post_obj->getVar('icon'): 'icon1.gif') . '" alt="" />'. '</a>'; endif; if (empty($forum_isread[$id])) { $forum_folder = ($forum_obj->getVar('forum_type') == 1) ? $xforumImage['locked_forum_newposts'] : $xforumImage['newposts_forum']; } else { $forum_folder = ($forum_obj->getVar('forum_type') == 1) ? $xforumImage['locked_forum'] : $xforumImage['folder_forum']; } $_forum_data['forum_folder'] = forum_displayImage($forum_folder); $xforums_array[$forum_obj->getVar('parent_forum')][] = $_forum_data; } return $xforums_array; }
function getInfo() { global $xoopsModuleConfig, $myts; $userinfo=array(); $user =& $this->user; if ( !(is_object($user)) || !($user->isActive()) ) return array("name"=>$myts->HtmlSpecialChars($GLOBALS["xoopsConfig"]['anonymous']), "link"=>$myts->HtmlSpecialChars($GLOBALS["xoopsConfig"]['anonymous'])); $userinfo["uid"] = $user->getVar("uid"); $name = $user->getVar('name'); $name = (empty($xoopsModuleConfig['show_realname'])||empty($name))?$user->getVar('uname'):$name; $userinfo["name"] = $name; $userinfo["link"] = "<a href=\"".XOOPS_URL . "/userinfo.php?uid=" . $user->getVar("uid") ."\">".$name."</a>"; $userinfo["avatar"] = $user->getVar('user_avatar'); $userinfo["from"] = $user->getVar('user_from'); $userinfo["regdate"] = forum_formatTimestamp($user->getVar('user_regdate'), 'reg'); $userinfo["posts"] = $user->getVar('posts'); $userinfo["groups_id"] = $user -> getGroups(); if(!empty($xoopsModuleConfig['user_level'])){ $userinfo["level"] = $this->getLevel(); } if(!empty($xoopsModuleConfig['userbar_enabled'])){ $userinfo["userbar"] = $this->getUserbar(); } $rank = forum_getrank($user->getVar("rank"), $user->getVar("posts")); $userinfo['rank']["title"] = $rank['title']; if (!empty($rank['image'])) { $userinfo['rank']['image'] = "<img src='" . XOOPS_UPLOAD_URL . "/" . htmlspecialchars($rank['image'], ENT_QUOTES) . "' alt='' />"; } $userinfo["signature"] = $user->user_sig(); return $userinfo; }
function showTreeItem(&$topic, &$postArray) { global $xoopsConfig, $xoopsModuleConfig, $viewtopic_users, $myts; $postArray['post_time'] = forum_formatTimestamp($postArray['post_time']); if (!empty($postArray['icon'])){ $postArray['icon'] = '<img src="' . XOOPS_URL . "/images/subject/" . htmlspecialchars($postArray['icon']) . '" alt="" />'; }else{ $postArray['icon'] = '<a name="' . $postArray['post_id'] . '"><img src="' . XOOPS_URL . '/images/icons/no_posticon.gif" alt="" /></a>'; } if (isset($viewtopic_users[$postArray['uid']]['is_forumadmin'])){ $postArray['subject'] = $myts->undoHtmlSpecialChars($postArray['subject']); } $postArray['subject'] = '<a href="'.XOOPS_URL.'/modules/xforum/'.'viewtopic.php?viewmode=thread&topic_id=' . $topic->getVar('topic_id') . '&forum=' . $postArray['forum_id'] . '&post_id=' . $postArray['post_id'] . '">' . $postArray['subject'] . '</a>'; $isActiveUser = false; if (isset($viewtopic_users[$postArray['uid']]['name'])) { $postArray['poster'] = $viewtopic_users[$postArray['uid']]['name']; if($postArray['uid']>0) $postArray['poster'] = "<a href=\"".XOOPS_URL . "/userinfo.php?uid=" . $postArray['uid'] ."\">".$viewtopic_users[$postArray['uid']]['name']."</a>"; }else{ $postArray['poster'] = (empty($postArray['poster_name']))?$myts->HtmlSpecialChars($xoopsConfig['anonymous']):$postArray['poster_name']; } return $postArray; }
function showPost($isadmin) { global $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsUser, $myts, $xoopsTpl; global $xforumUrl, $xforumImage; global $viewtopic_users, $viewtopic_posters, $viewtopic_forum, $xforumtopic, $online, $user_karma, $viewmode, $order, $start, $total_posts, $topic_status; static $post_NO = 0; static $user_ip; $post_id = $this->getVar('post_id'); $topic_id = $this->getVar('topic_id'); $forum_id = $this->getVar('forum_id'); $topic_status = $xforumtopic->getVar('topic_status'); $uid = is_object($xoopsUser)? $xoopsUser->getVar('uid'):0; $post_NO ++; if (strtolower($order) == "desc") $post_no = $total_posts - ($start + $post_NO) + 1; else $post_no = $start + $post_NO; if ($isadmin or $this->checkIdentity()) { $post_text = $this->getVar('post_text'); $post_attachment = $this->displayAttachment(); } elseif ($xoopsModuleConfig['enable_karma'] && $this->getVar('post_karma') > $user_karma) { $post_text = "<div class='karma'>" . sprintf(_MD_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')) . "</div>"; $post_attachment = ''; } elseif ( $xoopsModuleConfig['allow_require_reply'] && $this->getVar('require_reply') && ( !$uid || !in_array($uid, $viewtopic_posters) ) ) { $post_text = "<div class='karma'>" . _MD_REPLY_REQUIREMENT . "</div>"; $post_attachment = ''; } else { $post_text = $this->getVar('post_text'); $post_attachment = $this->displayAttachment(); } $poster = (($this->getVar('uid') > 0) && isset($viewtopic_users[$this->getVar('uid')]))? $viewtopic_users[$this->getVar('uid')]: array( 'poster_uid' => 0, 'name' => $this->getVar('poster_name')?$this->getVar('poster_name'):$myts->HtmlSpecialChars($xoopsConfig['anonymous']), 'link' => $this->getVar('poster_name')?$this->getVar('poster_name'):$myts->HtmlSpecialChars($xoopsConfig['anonymous']) ); $posticon = $this->getVar('icon'); if (!empty($posticon)){ $post_image = '<a name="' . $post_id . '"><img src="' . XOOPS_URL . '/images/subject/' . $posticon . '" alt="" /></a>'; }else{ $post_image = '<a name="' . $post_id . '"><img src="' . XOOPS_URL . '/images/icons/posticon.gif" alt="" /></a>'; } $post_title = $this->getVar('subject'); $thread_buttons = array(); if($GLOBALS["xoopsModuleConfig"]['enable_permcheck']){ $topic_handler = &xoops_getmodulehandler('topic', 'xforum'); if ($topic_handler->getPermission($forum_id, $topic_status, "edit")) { $edit_ok = false; if ($isadmin) { $edit_ok = true; } elseif ($this->checkIdentity() && $this->checkTimelimit('edit_timelimit')) { $edit_ok = true; } if ($edit_ok) { $thread_buttons['edit']['image'] = forum_displayImage($xforumImage['p_edit'], _EDIT); $thread_buttons['edit']['link'] = "edit.php?forum=" . $forum_id . "&topic_id=" . $topic_id . "&viewmode=$viewmode&order=$order"; $thread_buttons['edit']['name'] = _EDIT; } } if ($topic_handler->getPermission($forum_id, $topic_status, "delete")) { $delete_ok = false; if ($isadmin) { $delete_ok = true; } elseif ($this->checkIdentity() && $this->checkTimelimit('delete_timelimit')) { $delete_ok = true; } if ($delete_ok) { $thread_buttons['delete']['image'] = forum_displayImage($xforumImage['p_delete'], _DELETE); $thread_buttons['delete']['link'] = "delete.php?forum=" . $forum_id . "&topic_id=" . $topic_id . "&viewmode=$viewmode&order=$order"; $thread_buttons['delete']['name'] = _DELETE; } } if ($topic_handler->getPermission($forum_id, $topic_status, "reply")) { $thread_buttons['reply']['image'] = forum_displayImage($xforumImage['p_reply'], _MD_REPLY); $thread_buttons['reply']['link'] = "reply.php?forum=" . $forum_id . "&topic_id=" . $topic_id . "&viewmode=$viewmode&order=$order&start=$start"; $thread_buttons['reply']['name'] = _MD_REPLY; /* $thread_buttons['quote']['image'] = forum_displayImage($xforumImage['p_quote'], _MD_QUOTE); $thread_buttons['quote']['link'] = "reply.php?forum=" . $forum_id . "&topic_id=" . $topic_id . "&viewmode=$viewmode&order=$order&start=$start&quotedac=1"; $thread_buttons['quote']['name'] = _MD_QUOTE; */ } }else{ $thread_buttons['edit']['image'] = forum_displayImage($xforumImage['p_edit'], _EDIT); $thread_buttons['edit']['link'] = "edit.php?forum=" . $forum_id . "&topic_id=" . $topic_id . "&viewmode=$viewmode&order=$order"; $thread_buttons['edit']['name'] = _EDIT; $thread_buttons['delete']['image'] = forum_displayImage($xforumImage['p_delete'], _DELETE); $thread_buttons['delete']['link'] = "delete.php?forum=" . $forum_id . "&topic_id=" . $topic_id . "&viewmode=$viewmode&order=$order"; $thread_buttons['delete']['name'] = _DELETE; $thread_buttons['reply']['image'] = forum_displayImage($xforumImage['p_reply'], _MD_REPLY); $thread_buttons['reply']['link'] = "reply.php?forum=" . $forum_id . "&topic_id=" . $topic_id . "&viewmode=$viewmode&order=$order&start=$start"; $thread_buttons['reply']['name'] = _MD_REPLY; } if (!$isadmin && $xoopsModuleConfig['reportmod_enabled']) { $thread_buttons['report']['image'] = forum_displayImage($xforumImage['p_report'], _MD_REPORT); $thread_buttons['report']['link'] = "report.php?forum=" . $forum_id . "&topic_id=" . $topic_id . "&viewmode=$viewmode&order=$order"; $thread_buttons['report']['name'] = _MD_REPORT; } $thread_action = array(); /* if ($isadmin) { $thread_action['news']['image'] = forum_displayImage($xforumImage['news'], _MD_POSTTONEWS); $thread_action['news']['link'] = "posttonews.php?topic_id=" . $topic_id; $thread_action['news']['name'] = _MD_POSTTONEWS; } $thread_action['pdf']['image'] = forum_displayImage($xforumImage['pdf'], _MD_PDF); $thread_action['pdf']['link'] = "makepdf.php?type=post&pageid=0&scale=0.66"; $thread_action['pdf']['name'] = _MD_PDF; $thread_action['print']['image'] = forum_displayImage($xforumImage['printer'], _MD_PRINT); $thread_action['print']['link'] = "print.php?form=2&forum=". $forum_id."&topic_id=" . $topic_id; $thread_action['print']['name'] = _MD_PRINT; if(is_object($xoopsUser) && $this->getVar('uid') > 0 && isset($viewtopic_users[$this->getVar('uid')])){ $thread_action['pm']['image'] = $image_url = "<img src=\"".$xforumImage['pm']."\" alt=\""._MD_PM."\" align=\"middle\" />"; $thread_action['pm']['link'] = "posttopm.php?"; $thread_action['pm']['name'] = _MD_PM; } */ if (file_exists(XOOPS_ROOT_PATH."/modules/tag/include/tagbar.php")) { include_once XOOPS_ROOT_PATH."/modules/tag/include/tagbar.php"; $tagbar = tagBar($post_id, $catid = 0); $hastags = true; } else { $tagbar = ''; $hastags = false; } $post = array( 'post_id' => $post_id, 'post_parent_id' => $this->getVar('pid'), 'post_date' => forum_formatTimestamp($this->getVar('post_time')), 'post_image' => $post_image, 'post_title' => $post_title, 'post_text' => $post_text, 'post_attachment' => $post_attachment, 'post_edit' => $this->displayPostEdit(), 'post_no' => $post_no, 'post_signature' => ($this->getVar('attachsig'))?@$poster["signature"]:"", 'poster_ip' => ($isadmin && $xoopsModuleConfig['show_ip'])?long2ip($this->getVar('poster_ip')):"", 'thread_action' => $thread_action, 'thread_buttons' => $thread_buttons, 'poster' => $poster, 'hastags' => $hastags, 'tagbar' => $tagbar ); unset($thread_buttons); unset($eachposter); return $post; }
function b_forum_post_show($options) { global $xoopsConfig; global $access_forums; $db = &Database::getInstance(); $myts = &MyTextSanitizer::getInstance(); $block = array(); $i = 0; $order = ""; $extra_criteria = ""; $time_criteria = null; if(!empty($options[2])) { $time_criteria = time() - forum_getSinceTime($options[2]); $extra_criteria = " AND p.post_time>".$time_criteria; } switch ($options[0]) { case "text": if(!empty($xforumConfig['enable_karma'])) $extra_criteria .= " AND p.post_karma = 0"; if(!empty($xforumConfig['allow_require_reply'])) $extra_criteria .= " AND p.require_reply = 0"; default: $order = 'p.post_time'; break; } $xforumConfig = getConfigForBlock(); if(!isset($access_forums)){ $forum_handler = &xoops_getmodulehandler('forum', 'xforum'); if(!$access_obj =& $forum_handler->getForums(0, 'access', array('forum_id', 'cat_id', 'forum_type')) ){ return null; } $access_forums = array_keys( $access_obj ); // get all accessible forums unset($access_obj ); } if (!empty($options[6])) { $allowedforums = array_filter(array_slice($options, 6), "b_forum_array_filter"); // get allowed forums $allowed_forums = array_intersect($allowedforums, $access_forums); }else{ $allowed_forums = $access_forums; } $forum_criteria = ' AND p.forum_id IN (' . implode(',', $allowed_forums) . ')'; $approve_criteria = ' AND p.approved = 1'; $query = 'SELECT'; $query .= ' p.post_id, p.subject, p.post_time, p.icon, p.uid, p.poster_name,'; if($options[0]=="text"){ $query .= ' p.dohtml, p.dosmiley, p.doxcode, p.dobr, pt.post_text,'; } $query .= ' f.forum_id, f.forum_name, f.allow_subject_prefix'. ' FROM ' . $db->prefix('xf_posts') . ' AS p '. ' LEFT JOIN ' . $db->prefix('xf_forums') . ' AS f ON f.forum_id=p.forum_id'; if($options[0]=="text"){ $query .= ' LEFT JOIN ' . $db->prefix('xf_posts_text') . ' AS pt ON pt.post_id=p.post_id'; } $query .= ' WHERE 1=1 ' . $forum_criteria . $approve_criteria . $extra_criteria . ' ORDER BY ' . $order . ' DESC'; $result = $db->query($query, $options[1], 0); if (!$result) { forum_message("xforum block query error: ".$query); return false; } $block['disp_mode'] = ($options[0]=="text")?3:$options[3]; // 0 - full view; 1 - compact view; 2 - lite view; $rows = array(); $author = array(); while ($row = $db->fetchArray($result)) { $rows[] = $row; $author[$row["uid"]] = 1; } if (count($rows) < 1) return false; $author_name = forum_getUnameFromIds(array_keys($author), $xforumConfig['show_realname'], true); foreach ($rows as $arr) { //if ($arr['icon'] && is_file(XOOPS_ROOT_PATH . "/images/subject/" . $arr['icon'])) { if (!empty($arr['icon'])) { $last_post_icon = '<img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars($arr['icon']) . '" alt="" />'; } else { $last_post_icon = '<img src="' . XOOPS_URL . '/images/subject/icon1.gif" alt="" />'; } //$topic['jump_post'] = "<a href='" . XOOPS_URL . "/modules/xforum/viewtopic.php?post_id=" . $arr['post_id'] ."#forumpost" . $arr['post_id'] . "'>" . $last_post_icon . "</a>"; $topic['forum_id'] = $arr['forum_id']; $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); //$topic['id'] = $arr['topic_id']; $title = $myts->htmlSpecialChars($arr['subject']); if($options[0]!="text" && !empty($options[5])) { $title = xoops_substr($title, 0, $options[5]); } $topic['title'] = $title; $topic['post_id'] = $arr['post_id']; $topic['time'] = forum_formatTimestamp($arr['post_time']); if (!empty($author_name[$arr['uid']])) { $topic_poster = $author_name[$arr['uid']]; } else { $topic_poster = $myts->htmlSpecialChars( ($arr['poster_name'])?$arr['poster_name']:$GLOBALS["xoopsConfig"]["anonymous"] ); } $topic['topic_poster'] = $topic_poster; if($options[0]=="text"){ $post_text = $myts->displayTarea($arr['post_text'],$arr['dohtml'],$arr['dosmiley'],$arr['doxcode'],1,$arr['dobr']); if(!empty($options[5])){ $post_text = xoops_substr(forum_html2text($post_text), 0, $options[5]); } $topic['post_text'] = $post_text; } $block['topics'][] = $topic; unset($topic); } $block['indexNav'] = intval($options[4]); return $block; }
}else{ $topic['uname'] = ($topic['poster_name'])?$myts->htmlSpecialChars($topic['poster_name']):$myts->htmlSpecialChars($GLOBALS["xoopsConfig"]["anonymous"]); } $description = $topic["forum_name"]."::"; if ($topic['allow_subject_prefix']) { $subjectpres = explode(',', $xoopsModuleConfig['subject_prefix']); if (count($subjectpres) > 1) { foreach($subjectpres as $subjectpre) { $subject_array[] = $subjectpre; } $subject_array[0] = null; } $topic['topic_subject'] = $subject_array[$topic['topic_subject']]; } else { $topic['topic_subject'] = ""; } $description .= $topic['topic_subject']." ".$topic['topic_title']."<br />\n"; $description .= $myts->displayTarea($topic['post_text'], $topic['dohtml'], $topic['dosmiley'], $topic['doxcode']); $label = _MD_BY." ".$topic['uname']; $time = forum_formatTimestamp($topic['post_time'], "rss"); $link = XOOPS_URL . "/modules/" . $xoopsModule->dirname() . '/viewtopic.php?topic_id=' . $topic['topic_id'] . '&forum=' . $topic['forum_id']; $title = $topic['subject']; if(!$rss->addItem($title, $link, $description, $label, $time)) break; } $rss_feed = &$xmlrss_handler->get($rss); $tpl->assign('rss', $rss_feed); unset($rss); } $tpl->display('db:xforum_rss.html', $xoopsCachedTemplateId, $compile_id); ?>