mambax7 /
newbb
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php declare(strict_types=1); |
||||
| 2 | |||||
| 3 | /** |
||||
| 4 | * Newbb module |
||||
| 5 | * |
||||
| 6 | * You may not change or alter any portion of this comment or credits |
||||
| 7 | * of supporting developers from this source code or any supporting source code |
||||
| 8 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||||
| 9 | * This program is distributed in the hope that it will be useful, |
||||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
| 12 | * |
||||
| 13 | * @copyright XOOPS Project (https://xoops.org) |
||||
| 14 | * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||||
| 15 | * @since 4.0 |
||||
| 16 | * @author Taiwen Jiang <[email protected]> |
||||
| 17 | */ |
||||
| 18 | |||||
| 19 | use Xmf\Request; |
||||
| 20 | use XoopsModules\Newbb\{ |
||||
| 21 | Forum, |
||||
| 22 | Helper, |
||||
| 23 | ModerateHandler, |
||||
| 24 | Post, |
||||
| 25 | PostHandler, |
||||
| 26 | Topic, |
||||
| 27 | TopicHandler, |
||||
| 28 | TypeHandler |
||||
| 29 | }; |
||||
| 30 | use XoopsModules\Tag\FormTag; |
||||
| 31 | |||||
| 32 | /** @var Forum $forumObject */ |
||||
| 33 | /** @var Helper $helper */ |
||||
| 34 | /** @var ModerateHandler $moderateHandler */ |
||||
| 35 | /** @var TopicHandler $topicHandler */ |
||||
| 36 | /** @var Topic $topicObject */ |
||||
| 37 | /** @var TypeHandler $typeHandler */ |
||||
| 38 | /** @var Post $postObject */ |
||||
| 39 | /** @var PostHandler $postHandler */ |
||||
| 40 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
||||
| 41 | |||||
| 42 | $xoopsTpl->assign('lang_forum_index', sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars((string)$GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES))); |
||||
| 43 | |||||
| 44 | $categoryHandler = Helper::getInstance()->getHandler('Category'); |
||||
| 45 | $categoryObject = $categoryHandler->get($forumObject->getVar('cat_id'), ['cat_title']); |
||||
| 46 | |||||
| 47 | //check banning |
||||
| 48 | $moderated_id = (is_object($GLOBALS['xoopsUser']) |
||||
| 49 | && $GLOBALS['xoopsUser']->uid() > 0) ? $GLOBALS['xoopsUser']->uid() : 0; |
||||
| 50 | $moderated_ip = Request::getString('REMOTE_ADDR', '', 'SERVER'); |
||||
| 51 | $moderated_forum = $forumObject->getVar('forum_id'); |
||||
| 52 | $moderateHandler = Helper::getInstance()->getHandler('Moderate'); |
||||
| 53 | if (!$moderateHandler->verifyUser($moderated_id, '', $moderated_forum)) { |
||||
| 54 | $criteria = new \CriteriaCompo(); |
||||
| 55 | $criteria->add(new \Criteria('uid', $moderated_id, '=')); |
||||
| 56 | $criteria->setSort('mod_end'); |
||||
| 57 | $criteria->setOrder('DESC'); |
||||
| 58 | $mod = $moderateHandler->getObjects($criteria, false, false); |
||||
| 59 | $tage = ($mod[0]['mod_end'] - $mod[0]['mod_start']) / 60 / 60 / 24; |
||||
| 60 | $msg = $myts->displayTarea(sprintf(_MD_NEWBB_SUSPEND_TEXT, newbbGetUnameFromId($moderated_id), (int)$tage, $mod[0]['mod_desc'], formatTimestamp($mod[0]['mod_end'])), 1); |
||||
| 61 | xoops_error($msg, _MD_NEWBB_SUSPEND_NOACCESS); |
||||
| 62 | require_once $GLOBALS['xoops']->path('footer.php'); |
||||
| 63 | exit(); |
||||
| 64 | } |
||||
| 65 | |||||
| 66 | $xoopsTpl->assign('category', ['id' => $forumObject->getVar('cat_id'), 'title' => $categoryObject->getVar('cat_title')]); |
||||
| 67 | $xoopsTpl->assign('parentforum', $forumHandler->getParents($forumObject)); |
||||
| 68 | $xoopsTpl->assign( |
||||
| 69 | [ |
||||
| 70 | 'forum_id' => $forumObject->getVar('forum_id'), |
||||
| 71 | 'forum_name' => $forumObject->getVar('forum_name'), |
||||
| 72 | ] |
||||
| 73 | ); |
||||
| 74 | |||||
| 75 | if (!is_object($topicObject)) { |
||||
| 76 | $topicObject = $topicHandler->create(); |
||||
| 77 | } |
||||
| 78 | |||||
| 79 | $editby = false; |
||||
| 80 | if ($topicObject->isNew()) { |
||||
| 81 | $form_title = _MD_NEWBB_POSTNEW; |
||||
| 82 | } elseif ($postObject->isNew()) { |
||||
| 83 | /** @var Post $postParentObject */ |
||||
| 84 | if (empty($postParentObject)) { |
||||
| 85 | $postParentObject = $postHandler->get($pid); |
||||
| 86 | } |
||||
| 87 | $form_title = _MD_NEWBB_REPLY . ': <a href="' . XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}&post_id={$pid}\" rel=\"external\">" . $postParentObject->getVar('subject') . '</a>'; |
||||
| 88 | } else { |
||||
| 89 | $form_title = _EDIT . ': <a href="' . XOOPS_URL . "/modules/newbb/viewtopic.php?post_id={$post_id}\" rel=\"external\">" . $postObject->getVar('subject') . '</a>'; |
||||
| 90 | $editby = true; |
||||
| 91 | } |
||||
| 92 | $xoopsTpl->assign('form_title', $form_title); |
||||
| 93 | |||||
| 94 | foreach ( |
||||
| 95 | [ |
||||
| 96 | 'start', |
||||
| 97 | 'topic_id', |
||||
| 98 | 'post_id', |
||||
| 99 | 'pid', |
||||
| 100 | 'isreply', |
||||
| 101 | 'isedit', |
||||
| 102 | 'contents_preview', |
||||
| 103 | ] as $getint |
||||
| 104 | ) { |
||||
| 105 | ${$getint} = Request::getInt($getint, (!empty(${$getint}) ? ${$getint} : 0), 'GET'); // isset($_GET[$getint]) ? (int)($_GET[$getint]) : ((!empty(${$getint})) ? ${$getint} : 0); |
||||
| 106 | } |
||||
| 107 | foreach ( |
||||
| 108 | [ |
||||
| 109 | 'order', |
||||
| 110 | 'viewmode', |
||||
| 111 | 'hidden', |
||||
| 112 | 'newbb_form', |
||||
| 113 | 'icon', |
||||
| 114 | 'op', |
||||
| 115 | ] as $getstr |
||||
| 116 | ) { |
||||
| 117 | ${$getstr} = Request::getString($getstr, (!empty(${$getstr}) ? ${$getstr} : ''), 'GET'); //isset($_GET[$getstr]) ? $_GET[$getstr] : ((!empty(${$getstr})) ? ${$getstr} : ''); |
||||
| 118 | } |
||||
| 119 | |||||
| 120 | $topicHandler = Helper::getInstance()->getHandler('Topic'); |
||||
| 121 | $topic_status = $topicHandler->get(@$topic_id, 'topic_status'); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 122 | |||||
| 123 | //$filname = XOOPS_URL.$_SERVER['REQUEST_URI']; |
||||
| 124 | |||||
| 125 | /** @var \XoopsThemeForm $forum_form */ |
||||
| 126 | $forum_form = new \XoopsThemeForm(htmlspecialchars(@$form_title, ENT_QUOTES | ENT_HTML5), 'form_post', XOOPS_URL . '/modules/newbb/post.php', 'post', true); |
||||
| 127 | $forum_form->setExtra('enctype="multipart/form-data"'); |
||||
| 128 | |||||
| 129 | if ($editby) { |
||||
| 130 | $forum_form->addElement(new \XoopsFormText(_MD_NEWBB_EDITEDMSG, 'editwhy', 60, 100, '')); |
||||
| 131 | } |
||||
| 132 | |||||
| 133 | $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||||
| 134 | if (newbbIsAdmin($forumObject) |
||||
| 135 | || ($topicHandler->getPermission($forumObject, $topic_status, 'type') |
||||
| 136 | && (0 === $topic_id |
||||
| 137 | || $uid == $topicHandler->get(@$topic_id, 'topic_poster')))) { |
||||
| 138 | $type_id = $topicHandler->get(@$topic_id, 'type_id'); |
||||
| 139 | $typeHandler = Helper::getInstance()->getHandler('Type'); |
||||
| 140 | $types = $typeHandler->getByForum($forumObject->getVar('forum_id')); |
||||
| 141 | if (!empty($types)) { |
||||
| 142 | $type_element = new \XoopsFormSelect(_MD_NEWBB_TYPE, 'type_id', $type_id); |
||||
| 143 | //$type_element = new \XoopsFormRadio(_MD_NEWBB_TYPE, 'type_id', $type_id); |
||||
| 144 | $type_element->addOption(0, _NONE); |
||||
| 145 | foreach ($types as $key => $type) { |
||||
| 146 | //$value = empty($type["type_color"]) ? $type["type_name"] : "<em style=\"font-style: normal; color: " . $type["type_color"] . ";\">" . $type["type_name"] . "</em>"; |
||||
| 147 | $type_element->addOption($key, $type['type_name']); |
||||
| 148 | } |
||||
| 149 | $forum_form->addElement($type_element); |
||||
| 150 | } else { |
||||
| 151 | $forum_form->addElement(new \XoopsFormHidden('type_id', 0)); |
||||
| 152 | } |
||||
| 153 | } |
||||
| 154 | |||||
| 155 | $subject_form = new \XoopsFormText(_MD_NEWBB_SUBJECTC, 'subject', 60, 100, $subject); |
||||
| 156 | $subject_form->setExtra("tabindex='1'"); |
||||
| 157 | $forum_form->addElement($subject_form, true); |
||||
| 158 | |||||
| 159 | if (!is_object($GLOBALS['xoopsUser'])) { |
||||
| 160 | $required = !empty($GLOBALS['xoopsModuleConfig']['require_name']); |
||||
| 161 | $forum_form->addElement(new \XoopsFormText(_MD_NEWBB_NAMEMAIL, 'poster_name', 60, 255, ($isedit !== 0 && !empty($poster_name)) ? $poster_name : ''), $required); |
||||
| 162 | } |
||||
| 163 | |||||
| 164 | $icons_radio = new \XoopsFormRadio(_MD_NEWBB_MESSAGEICON, 'icon', $icon); |
||||
| 165 | $subject_icons = \XoopsLists::getSubjectsList(); |
||||
| 166 | foreach ($subject_icons as $iconfile) { |
||||
| 167 | $icons_radio->addOption($iconfile, '<img src="' . XOOPS_URL . '/images/subject/' . $iconfile . '" alt="" >'); |
||||
| 168 | } |
||||
| 169 | $forum_form->addElement($icons_radio); |
||||
| 170 | |||||
| 171 | $nohtml = !$topicHandler->getPermission($forumObject, $topic_status, 'html'); |
||||
| 172 | |||||
| 173 | if (Request::getString('editor', '', 'POST')) { |
||||
| 174 | $editor = trim((string) Request::getString('editor', '', 'POST')); |
||||
| 175 | newbbSetCookie('editor', $editor); |
||||
| 176 | } elseif (!$editor = newbbGetCookie('editor')) { |
||||
| 177 | if (empty($editor)) { |
||||
| 178 | $editor = @$GLOBALS['xoopsModuleConfig']['editor_default']; |
||||
| 179 | } |
||||
| 180 | } |
||||
| 181 | if ((is_countable(@$GLOBALS['xoopsModuleConfig']['editor_allowed']) ? count(@$GLOBALS['xoopsModuleConfig']['editor_allowed']) : 0) > 0) { |
||||
| 182 | if (!in_array($editor, $GLOBALS['xoopsModuleConfig']['editor_allowed'], true)) { |
||||
| 183 | $editor = $GLOBALS['xoopsModuleConfig']['editor_allowed'][0]; |
||||
| 184 | newbbSetCookie('editor', $editor); |
||||
| 185 | } |
||||
| 186 | } |
||||
| 187 | |||||
| 188 | $forum_form->addElement(new \XoopsFormSelectEditor($forum_form, 'editor', $editor, $nohtml, @$GLOBALS['xoopsModuleConfig']['editor_allowed'][0])); |
||||
|
0 ignored issues
–
show
$forum_form of type XoopsThemeForm is incompatible with the type string expected by parameter $form of XoopsFormSelectEditor::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 189 | |||||
| 190 | $editor_configs = []; |
||||
| 191 | $editor_configs['name'] = 'message'; |
||||
| 192 | $editor_configs['value'] = $message; |
||||
| 193 | $editor_configs['rows'] = empty($GLOBALS['xoopsModuleConfig']['editor_rows']) ? 10 : $GLOBALS['xoopsModuleConfig']['editor_rows']; |
||||
| 194 | $editor_configs['cols'] = empty($GLOBALS['xoopsModuleConfig']['editor_cols']) ? 30 : $GLOBALS['xoopsModuleConfig']['editor_cols']; |
||||
| 195 | $editor_configs['width'] = empty($GLOBALS['xoopsModuleConfig']['editor_width']) ? '100%' : $GLOBALS['xoopsModuleConfig']['editor_width']; |
||||
| 196 | $editor_configs['height'] = empty($GLOBALS['xoopsModuleConfig']['editor_height']) ? '400px' : $GLOBALS['xoopsModuleConfig']['editor_height']; |
||||
| 197 | |||||
| 198 | $_editor = new \XoopsFormEditor(_MD_NEWBB_MESSAGEC, $editor, $editor_configs, $nohtml, $onfailure = null); |
||||
| 199 | $forum_form->addElement($_editor, true); |
||||
| 200 | |||||
| 201 | if (!empty($GLOBALS['xoopsModuleConfig']['do_tag']) && (empty($postObject) || $postObject->isTopic())) { |
||||
| 202 | $topic_tags = ''; |
||||
| 203 | if (Request::getString('topic_tags', '', 'POST')) { |
||||
| 204 | $topic_tags = htmlspecialchars((string) Request::getString('topic_tags', '', 'POST'), ENT_QUOTES | ENT_HTML5); |
||||
| 205 | } elseif ($topic_id !== 0) { |
||||
| 206 | $topic_tags = $topicHandler->get($topic_id, 'topic_tags'); |
||||
| 207 | } |
||||
| 208 | if (!empty($newbbConfig['do_tag']) && \class_exists(\XoopsModules\Tag\FormTag::class)) { |
||||
| 209 | $forum_form->addElement(new \XoopsModules\Tag\FormTag('topic_tags', 60, 255, $topic_tags)); |
||||
| 210 | } |
||||
| 211 | } |
||||
| 212 | |||||
| 213 | $options_tray = new \XoopsFormElementTray(_MD_NEWBB_OPTIONS, '<br>'); |
||||
| 214 | if (is_object($GLOBALS['xoopsUser']) && 1 == $GLOBALS['xoopsModuleConfig']['allow_user_anonymous']) { |
||||
| 215 | $noname = ($isedit !== 0 && is_object($postObject) && 0 == $postObject->getVar('uid')) ? 1 : 0; |
||||
| 216 | $noname_checkbox = new \XoopsFormCheckBox('', 'noname', $noname); |
||||
| 217 | $noname_checkbox->addOption(1, _MD_NEWBB_POSTANONLY); |
||||
| 218 | $options_tray->addElement($noname_checkbox); |
||||
| 219 | } |
||||
| 220 | |||||
| 221 | if ($nohtml) { |
||||
| 222 | $forum_form->addElement(new \XoopsFormHidden('dohtml', 0)); |
||||
| 223 | } else { |
||||
| 224 | $html_checkbox = new \XoopsFormCheckBox('', 'dohtml', $dohtml); |
||||
| 225 | $html_checkbox->addOption(1, _MD_NEWBB_DOHTML); |
||||
| 226 | $options_tray->addElement($html_checkbox); |
||||
| 227 | } |
||||
| 228 | |||||
| 229 | $smiley_checkbox = new \XoopsFormCheckBox('', 'dosmiley', $dosmiley); |
||||
| 230 | $smiley_checkbox->addOption(1, _MD_NEWBB_DOSMILEY); |
||||
| 231 | $options_tray->addElement($smiley_checkbox); |
||||
| 232 | |||||
| 233 | $xcode_checkbox = new \XoopsFormCheckBox('', 'doxcode', $doxcode); |
||||
| 234 | $xcode_checkbox->addOption(1, _MD_NEWBB_DOXCODE); |
||||
| 235 | $options_tray->addElement($xcode_checkbox); |
||||
| 236 | |||||
| 237 | if ($nohtml) { |
||||
| 238 | $forum_form->addElement(new \XoopsFormHidden('dobr', 1)); |
||||
| 239 | } else { |
||||
| 240 | $br_checkbox = new \XoopsFormCheckBox('', 'dobr', $dobr); |
||||
| 241 | $br_checkbox->addOption(1, _MD_NEWBB_DOBR); |
||||
| 242 | $options_tray->addElement($br_checkbox); |
||||
| 243 | } |
||||
| 244 | |||||
| 245 | if (is_object($GLOBALS['xoopsUser']) && $topicHandler->getPermission($forumObject, $topic_status, 'signature')) { |
||||
| 246 | $attachsig_checkbox = new \XoopsFormCheckBox('', 'attachsig', $attachsig); |
||||
| 247 | $attachsig_checkbox->addOption(1, _MD_NEWBB_ATTACHSIG); |
||||
| 248 | $options_tray->addElement($attachsig_checkbox); |
||||
| 249 | } |
||||
| 250 | $notify = 0; |
||||
| 251 | if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsModuleConfig']['notification_enabled']) { |
||||
| 252 | if ($notify !== 0) { |
||||
|
0 ignored issues
–
show
|
|||||
| 253 | // If 'notify' set, use that value (e.g. preview or upload) |
||||
| 254 | //$notify = 1; |
||||
| 255 | } else { |
||||
| 256 | // Otherwise, check previous subscribed status... |
||||
| 257 | /** @var \XoopsNotificationHandler $notificationHandler */ |
||||
| 258 | $notificationHandler = xoops_getHandler('notification'); |
||||
| 259 | if ($topic_id !== 0 |
||||
| 260 | && $notificationHandler->isSubscribed('thread', $topic_id, 'new_post', $xoopsModule->getVar('mid'), $GLOBALS['xoopsUser']->getVar('uid'))) { |
||||
| 261 | $notify = 1; |
||||
| 262 | } |
||||
| 263 | } |
||||
| 264 | |||||
| 265 | $notify_checkbox = new \XoopsFormCheckBox('', 'notify', $notify); |
||||
| 266 | $notify_checkbox->addOption(1, _MD_NEWBB_NEWPOSTNOTIFY); |
||||
| 267 | $options_tray->addElement($notify_checkbox); |
||||
| 268 | } |
||||
| 269 | $forum_form->addElement($options_tray); |
||||
| 270 | |||||
| 271 | if ($topicHandler->getPermission($forumObject, $topic_status, 'attach')) { |
||||
| 272 | $upload_tray = new \XoopsFormElementTray(_MD_NEWBB_ATTACHMENT); |
||||
| 273 | $upload_tray->addElement(new \XoopsFormFile('', 'userfile', $forumObject->getVar('attach_maxkb') * 1024)); |
||||
| 274 | $upload_tray->addElement(new \XoopsFormButton('', 'contents_upload', _MD_NEWBB_UPLOAD, 'submit')); |
||||
| 275 | $upload_tray->addElement(new \XoopsFormLabel('<br><br>' . _MD_NEWBB_MAX_FILESIZE . ':', $forumObject->getVar('attach_maxkb') . 'Kb; ')); |
||||
| 276 | $extensions = trim(str_replace('|', ' ', (string) $forumObject->getVar('attach_ext'))); |
||||
| 277 | $extensions = (empty($extensions) || '*' === $extensions) ? _ALL : $extensions; |
||||
| 278 | $upload_tray->addElement(new \XoopsFormLabel(_MD_NEWBB_ALLOWED_EXTENSIONS . ':', $extensions)); |
||||
| 279 | $upload_tray->addElement(new \XoopsFormLabel('<br>' . sprintf(_MD_NEWBB_MAXPIC, $GLOBALS['xoopsModuleConfig']['max_img_height'], $GLOBALS['xoopsModuleConfig']['max_img_width']))); |
||||
| 280 | $forum_form->addElement($upload_tray); |
||||
| 281 | } |
||||
| 282 | |||||
| 283 | if (!empty($attachments) && is_array($attachments) && count($attachments)) { |
||||
| 284 | $delete_attach_checkbox = new \XoopsFormCheckBox(_MD_NEWBB_THIS_FILE_WAS_ATTACHED_TO_THIS_POST, 'delete_attach[]'); |
||||
| 285 | foreach ($attachments as $key => $attachment) { |
||||
| 286 | $attach = ' ' . _DELETE . ' <a href=' . XOOPS_URL . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attachment['name_saved'] . ' rel="external">' . $attachment['nameDisplay'] . '</a><br>'; |
||||
| 287 | $delete_attach_checkbox->addOption($key, $attach); |
||||
| 288 | } |
||||
| 289 | $forum_form->addElement($delete_attach_checkbox); |
||||
| 290 | unset($delete_attach_checkbox); |
||||
| 291 | } |
||||
| 292 | |||||
| 293 | if (!empty($attachments_tmp) && is_array($attachments_tmp) && count($attachments_tmp)) { |
||||
| 294 | $delete_attach_checkbox = new \XoopsFormCheckBox(_MD_NEWBB_REMOVE, 'delete_tmp[]'); |
||||
| 295 | $url_prefix = str_replace(XOOPS_ROOT_PATH, XOOPS_URL, (string) XOOPS_CACHE_PATH); |
||||
| 296 | foreach ($attachments_tmp as $key => $attachment) { |
||||
| 297 | $attach = ' <a href="' . $url_prefix . '/' . $attachment[0] . '" rel="external">' . $attachment[1] . '</a><br>'; |
||||
| 298 | $delete_attach_checkbox->addOption($key, $attach); |
||||
| 299 | } |
||||
| 300 | $forum_form->addElement($delete_attach_checkbox); |
||||
| 301 | unset($delete_attach_checkbox); |
||||
| 302 | $attachments_tmp = base64_encode(serialize($attachments_tmp)); |
||||
| 303 | $forum_form->addElement(new \XoopsFormHidden('attachments_tmp', $attachments_tmp)); |
||||
| 304 | } |
||||
| 305 | $radiobox = null; |
||||
| 306 | $karma_array = null; |
||||
| 307 | if ($GLOBALS['xoopsModuleConfig']['enable_karma'] || $GLOBALS['xoopsModuleConfig']['allow_require_reply']) { |
||||
| 308 | $view_require = $require_reply ? 'require_reply' : ($post_karma ? 'require_karma' : 'require_null'); |
||||
| 309 | $radiobox = new \XoopsFormRadio(_MD_NEWBB_VIEW_REQUIRE, 'view_require', $view_require); |
||||
| 310 | if ($GLOBALS['xoopsModuleConfig']['allow_require_reply']) { |
||||
| 311 | $radiobox->addOption('require_reply', _MD_NEWBB_REQUIRE_REPLY); |
||||
| 312 | } |
||||
| 313 | if ($GLOBALS['xoopsModuleConfig']['enable_karma']) { |
||||
| 314 | $karmas = array_map('\trim', explode(',', (string) $GLOBALS['xoopsModuleConfig']['karma_options'])); |
||||
| 315 | if (count($karmas) > 1) { |
||||
| 316 | foreach ($karmas as $karma) { |
||||
| 317 | $karma_array[(string)$karma] = (int)$karma; |
||||
| 318 | } |
||||
| 319 | $karma_select = new \XoopsFormSelect('', 'post_karma', $post_karma); |
||||
| 320 | $karma_select->addOptionArray($karma_array); |
||||
| 321 | $radiobox->addOption('require_karma', _MD_NEWBB_REQUIRE_KARMA . $karma_select->render()); |
||||
| 322 | } |
||||
| 323 | } |
||||
| 324 | $radiobox->addOption('require_null', _MD_NEWBB_REQUIRE_NULL); |
||||
| 325 | } |
||||
| 326 | if (null !== $radiobox) { |
||||
| 327 | $forum_form->addElement($radiobox); |
||||
| 328 | } |
||||
| 329 | |||||
| 330 | if (empty($uid)) { |
||||
| 331 | $forum_form->addElement(new \XoopsFormCaptcha()); |
||||
| 332 | } |
||||
| 333 | |||||
| 334 | $forum_form->addElement(new \XoopsFormHidden('pid', @$pid)); |
||||
| 335 | $forum_form->addElement(new \XoopsFormHidden('post_id', @$post_id)); |
||||
| 336 | $forum_form->addElement(new \XoopsFormHidden('topic_id', @$topic_id)); |
||||
| 337 | $forum_form->addElement(new \XoopsFormHidden('forum', $forumObject->getVar('forum_id'))); |
||||
| 338 | $forum_form->addElement(new \XoopsFormHidden('viewmode', @$viewmode)); |
||||
| 339 | $forum_form->addElement(new \XoopsFormHidden('order', @$order)); |
||||
| 340 | $forum_form->addElement(new \XoopsFormHidden('start', @$start)); |
||||
| 341 | $forum_form->addElement(new \XoopsFormHidden('isreply', @$isreply)); |
||||
| 342 | $forum_form->addElement(new \XoopsFormHidden('isedit', @$isedit)); |
||||
| 343 | $forum_form->addElement(new \XoopsFormHidden('op', @$op)); |
||||
| 344 | |||||
| 345 | $buttonTray = new \XoopsFormElementTray(''); |
||||
| 346 | |||||
| 347 | $submit_button = new \XoopsFormButton('', 'contents_submit', _SUBMIT, 'submit'); |
||||
| 348 | $submit_button->setExtra("tabindex='3'"); |
||||
| 349 | |||||
| 350 | $cancel_button = new \XoopsFormButton('', 'cancel', _CANCEL, 'button'); |
||||
| 351 | if ($topic_id !== 0) { |
||||
| 352 | $extra = XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . (int)$topic_id; |
||||
| 353 | } else { |
||||
| 354 | $extra = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $forumObject->getVar('forum_id'); |
||||
| 355 | } |
||||
| 356 | $cancel_button->setExtra("onclick='location=\"" . $extra . "\"'"); |
||||
| 357 | $cancel_button->setExtra("tabindex='6'"); |
||||
| 358 | |||||
| 359 | /** @var string $hidden */ |
||||
| 360 | if ($isreply !== 0 && null !== $hidden) { |
||||
| 361 | $forum_form->addElement(new \XoopsFormHidden('hidden', $hidden)); |
||||
| 362 | |||||
| 363 | $quote_button = new \XoopsFormButton('', 'quote', _MD_NEWBB_QUOTE, 'button'); |
||||
| 364 | $quote_button->setExtra("onclick='xoopsGetElementById(\"message\").value=xoopsGetElementById(\"message\").value+ xoopsGetElementById(\"hidden\").value;xoopsGetElementById(\"hidden\").value=\"\";'"); |
||||
| 365 | $quote_button->setExtra("tabindex='4'"); |
||||
| 366 | $buttonTray->addElement($quote_button); |
||||
| 367 | } |
||||
| 368 | |||||
| 369 | $preview_button = new \XoopsFormButton('', 'btn_preview', _PREVIEW, 'button'); |
||||
| 370 | $preview_button->setExtra("tabindex='5'"); |
||||
| 371 | $preview_button->setExtra('onclick="window.document.forms.' . $forum_form->getName() . '.contents_preview.value=1; window.document.forms.' . $forum_form->getName() . '.submit() ;"'); |
||||
| 372 | $forum_form->addElement(new \XoopsFormHidden('contents_preview', 0)); |
||||
| 373 | |||||
| 374 | $buttonTray->addElement($preview_button); |
||||
| 375 | $buttonTray->addElement($submit_button); |
||||
| 376 | $buttonTray->addElement($cancel_button); |
||||
| 377 | $forum_form->addElement($buttonTray); |
||||
| 378 | |||||
| 379 | //$forum_form->display(); |
||||
| 380 | $forum_form->assign($xoopsTpl); |
||||
| 381 | $karma_array = null; |
||||
| 382 |