mambax7 /
newbb
| 1 | <?php |
||
| 2 | /* |
||
| 3 | * You may not change or alter any portion of this comment or credits |
||
| 4 | * of supporting developers from this source code or any supporting source code |
||
| 5 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | * |
||
| 7 | * This program is distributed in the hope that it will be useful, |
||
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | // ------------------------------------------------------------------------ // |
||
| 12 | // Author: phppp (D.J., [email protected]) // |
||
| 13 | // URL: https://xoops.org // |
||
| 14 | // Project: Article Project // |
||
| 15 | // ------------------------------------------------------------------------ // |
||
| 16 | |||
| 17 | use Xmf\Request; |
||
| 18 | use XoopsModules\Newbb\{ |
||
| 19 | Helper, |
||
| 20 | ForumHandler, |
||
| 21 | Post, |
||
| 22 | PostHandler, |
||
| 23 | TopicHandler |
||
| 24 | }; |
||
| 25 | /** @var Post $post_contextObject */ |
||
| 26 | /** @var PostHandler $post_contextObject */ |
||
| 27 | /** @var ForumHandler $forumHandler */ |
||
| 28 | /** @var TopicHandler $topicHandler */ |
||
| 29 | /** @var PostHandler $postHandler */ |
||
| 30 | |||
| 31 | require_once __DIR__ . '/header.php'; |
||
| 32 | |||
| 33 | $forum = Request::getInt('forum', 0, 'GET'); |
||
| 34 | $topic_id = Request::getInt('topic_id', 0, 'GET'); |
||
| 35 | $post_id = Request::getInt('post_id', 0, 'GET'); |
||
| 36 | $order = Request::getInt('order', 0, 'GET'); |
||
| 37 | $start = Request::getInt('start', 0, 'GET'); |
||
| 38 | |||
| 39 | if (!$topic_id && !$post_id) { |
||
| 40 | $redirect = empty($forum) ? 'index.php' : "viewforum.php?forum={$forum}"; |
||
| 41 | redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
||
| 42 | } |
||
| 43 | |||
| 44 | |||
| 45 | $forumHandler = Helper::getInstance()->getHandler('Forum'); |
||
| 46 | $topicHandler = Helper::getInstance()->getHandler('Topic'); |
||
| 47 | $postHandler = Helper::getInstance()->getHandler('Post'); |
||
| 48 | |||
| 49 | if (!$pid = $post_id) { |
||
| 50 | $pid = $topicHandler->getTopPostId($topic_id); |
||
| 51 | } |
||
| 52 | $postParentObject = $postHandler->get($pid); |
||
| 53 | $topic_id = $postParentObject->getVar('topic_id'); |
||
| 54 | $forum = $postParentObject->getVar('forum_id'); |
||
| 55 | $postObject = $postHandler->create(); |
||
| 56 | $postObject->setVar('pid', $pid); |
||
| 57 | $postObject->setVar('topic_id', $topic_id); |
||
| 58 | $postObject->setVar('forum_id', $forum); |
||
| 59 | |||
| 60 | $forumObject = $forumHandler->get($forum); |
||
| 61 | if (!$forumHandler->getPermission($forumObject)) { |
||
| 62 | redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
||
| 63 | } |
||
| 64 | |||
| 65 | $topicObject = $topicHandler->get($topic_id); |
||
| 66 | $topic_status = $topicObject->getVar('topic_status'); |
||
| 67 | if (!$topicHandler->getPermission($forumObject, $topic_status, 'reply')) { |
||
| 68 | /* |
||
| 69 | * Build the page query |
||
| 70 | */ |
||
| 71 | $query_vars = ['topic_id', 'post_id', 'status', 'order', 'mode', 'viewmode']; |
||
| 72 | $query_array = []; |
||
| 73 | foreach ($query_vars as $var) { |
||
| 74 | if (Request::getString($var, '', 'GET')) { |
||
| 75 | $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET'); |
||
| 76 | } |
||
| 77 | } |
||
| 78 | $page_query = htmlspecialchars(implode('&', array_values($query_array)), ENT_QUOTES | ENT_HTML5); |
||
| 79 | unset($query_array); |
||
| 80 | |||
| 81 | redirect_header("viewtopic.php?{$page_query}", 2, _MD_NEWBB_NORIGHTTOREPLY); |
||
| 82 | } |
||
| 83 | |||
| 84 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
||
| 85 | // /** @var OnlineHandler $onlineHandler */ |
||
| 86 | // $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online'); |
||
| 87 | $onlineHandler->init($forumObject); |
||
| 88 | } |
||
| 89 | |||
| 90 | $xoopsOption['template_main'] = 'newbb_edit_post.tpl'; |
||
| 91 | $GLOBALS['xoopsConfig']['module_cache'][$xoopsModule->getVar('mid')] = 0; |
||
| 92 | // irmtfan remove and move to footer.php |
||
| 93 | //$xoopsOption['xoops_module_header']= $xoops_module_header; |
||
| 94 | // irmtfan include header.php after defining $xoopsOption['template_main'] |
||
| 95 | require_once $GLOBALS['xoops']->path('header.php'); |
||
| 96 | //$xoopsTpl->assign('xoops_module_header', $xoops_module_header); |
||
| 97 | |||
| 98 | /* |
||
| 99 | $xoopsTpl->assign('lang_forum_index', sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES))); |
||
| 100 | |||
| 101 | $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); |
||
| 102 | $categoryObject = $categoryHandler->get($forumObject->getVar("cat_id"), array("cat_title")); |
||
| 103 | $xoopsTpl->assign('category', array("id" => $forumObject->getVar("cat_id"), "title" => $categoryObject->getVar('cat_title'))); |
||
| 104 | |||
| 105 | $form_title = _MD_NEWBB_REPLY.": <a href=\"viewtopic.php?topic_id={$topic_id}\">".$topicObject->getVar("topic_title"); |
||
| 106 | $xoopsTpl->assign("form_title", $form_title); |
||
| 107 | */ |
||
| 108 | |||
| 109 | if ((2 == $GLOBALS['xoopsModuleConfig']['disc_show']) || (3 == $GLOBALS['xoopsModuleConfig']['disc_show'])) { |
||
| 110 | $xoopsTpl->assign('disclaimer', $GLOBALS['xoopsModuleConfig']['disclaimer']); |
||
| 111 | } |
||
| 112 | |||
| 113 | $xoopsTpl->assign('parentforum', $forumHandler->getParents($forumObject)); |
||
|
0 ignored issues
–
show
|
|||
| 114 | |||
| 115 | $xoopsTpl->assign( |
||
| 116 | [ |
||
| 117 | 'forum_id' => $forumObject->getVar('forum_id'), |
||
| 118 | 'forum_name' => $forumObject->getVar('forum_name'), |
||
| 119 | ] |
||
| 120 | ); |
||
| 121 | |||
| 122 | if ($postParentObject->getVar('uid')) { |
||
| 123 | $r_name = newbbGetUnameFromId($postParentObject->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']); |
||
| 124 | } else { |
||
| 125 | $poster_name = $postParentObject->getVar('poster_name'); |
||
| 126 | $r_name = empty($poster_name) ? htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5) : $poster_name; |
||
| 127 | } |
||
| 128 | |||
| 129 | $r_subject = $postParentObject->getVar('subject', 'E'); |
||
| 130 | |||
| 131 | $subject = $r_subject; |
||
| 132 | if (!preg_match('/^(Re|' . _MD_NEWBB_RE . '):/i', $r_subject)) { |
||
| 133 | $subject = _MD_NEWBB_RE . ': ' . $r_subject; |
||
| 134 | } |
||
| 135 | |||
| 136 | $q_message = $postParentObject->getVar('post_text', 'e'); |
||
| 137 | if ((!$GLOBALS['xoopsModuleConfig']['enable_karma'] || !$postParentObject->getVar('post_karma')) |
||
| 138 | && (!$GLOBALS['xoopsModuleConfig']['allow_require_reply'] || !$postParentObject->getVar('require_reply'))) { |
||
| 139 | if (1 === Request::getInt('quotedac', 0, 'GET')) { |
||
| 140 | $message = "[quote]\n"; |
||
| 141 | $message .= sprintf(_MD_NEWBB_USERWROTE, $r_name); |
||
| 142 | $message .= "\n" . $q_message . '[/quote]'; |
||
| 143 | $hidden = ''; |
||
| 144 | } else { |
||
| 145 | $hidden = "[quote]\n"; |
||
| 146 | $hidden .= sprintf(_MD_NEWBB_USERWROTE, $r_name); |
||
| 147 | $hidden .= "\n" . $q_message . '[/quote]'; |
||
| 148 | $message = ''; |
||
| 149 | } |
||
| 150 | } else { |
||
| 151 | $hidden = ''; |
||
| 152 | $message = ''; |
||
| 153 | } |
||
| 154 | |||
| 155 | $isreply = 1; |
||
| 156 | $istopic = 0; |
||
| 157 | $dohtml = 1; |
||
| 158 | $dosmiley = 1; |
||
| 159 | $doxcode = 1; |
||
| 160 | $dobr = 1; |
||
| 161 | $icon = ''; |
||
| 162 | $attachsig = (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->getVar('attachsig')) ? 1 : 0; |
||
| 163 | $post_karma = 0; |
||
| 164 | $require_reply = 0; |
||
| 165 | |||
| 166 | require_once __DIR__ . '/include/form.post.php'; |
||
| 167 | |||
| 168 | ///** @var Newbb\KarmaHandler $karmaHandler */ |
||
| 169 | //$karmaHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Karma'); |
||
| 170 | $user_karma = $karmaHandler->getUserKarma(); |
||
| 171 | |||
| 172 | $posts_context = []; |
||
| 173 | //$posts_contextObject = $postHandler->getByLimit($topic_id, 5); //mb |
||
| 174 | $posts_contextObject = $postHandler->getByLimit(5, 0, null, null, true, $topic_id, 1); |
||
| 175 | foreach ($posts_contextObject as $post_contextObject) { |
||
| 176 | // Sorry, in order to save queries, we have to hide the non-open post_text even if you have replied or have adequate karma, even an admin. |
||
| 177 | if ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $post_contextObject->getVar('post_karma') > 0) { |
||
| 178 | $p_message = sprintf(_MD_NEWBB_KARMA_REQUIREMENT, '***', $post_contextObject->getVar('post_karma')) . '</div>'; |
||
| 179 | } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $post_contextObject->getVar('require_reply')) { |
||
| 180 | $p_message = _MD_NEWBB_REPLY_REQUIREMENT; |
||
| 181 | } else { |
||
| 182 | $p_message = $post_contextObject->getVar('post_text'); |
||
| 183 | } |
||
| 184 | |||
| 185 | if ($post_contextObject->getVar('uid')) { |
||
| 186 | $p_name = newbbGetUnameFromId($post_contextObject->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']); |
||
| 187 | } else { |
||
| 188 | $poster_name = $post_contextObject->getVar('poster_name'); |
||
| 189 | $p_name = empty($poster_name) ? htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5) : $poster_name; |
||
| 190 | } |
||
| 191 | $p_date = formatTimestamp($post_contextObject->getVar('post_time')); |
||
| 192 | $p_subject = $post_contextObject->getVar('subject'); |
||
| 193 | |||
| 194 | $posts_context[] = [ |
||
| 195 | 'subject' => $p_subject, |
||
| 196 | 'meta' => _MD_NEWBB_BY . ' ' . $p_name . ' ' . _MD_NEWBB_ON . ' ' . $p_date, |
||
| 197 | 'content' => $p_message, |
||
| 198 | ]; |
||
| 199 | } |
||
| 200 | $xoopsTpl->assign_by_ref('posts_context', $posts_context); |
||
| 201 | // irmtfan move to footer.php |
||
| 202 | require_once __DIR__ . '/footer.php'; |
||
| 203 | require_once $GLOBALS['xoops']->path('footer.php'); |
||
| 204 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.