@@ -16,17 +16,17 @@ discard block |
||
16 | 16 | $ok = Request::getInt('ok', 0, 'POST'); |
17 | 17 | |
18 | 18 | foreach (['forum', 'topic_id', 'post_id', 'order', 'pid', 'act'] as $getint) { |
19 | - ${$getint} = Request::getInt($getint, 0, 'POST'); |
|
19 | + ${$getint} = Request::getInt($getint, 0, 'POST'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | foreach (['forum', 'topic_id', 'post_id', 'order', 'pid', 'act'] as $getint) { |
23 | - ${$getint} = !empty(${$getint}) ? ${$getint} : Request::getInt($getint, 0, 'GET'); |
|
23 | + ${$getint} = !empty(${$getint}) ? ${$getint} : Request::getInt($getint, 0, 'GET'); |
|
24 | 24 | } |
25 | 25 | //$viewmode = (isset($_GET['viewmode']) && $_GET['viewmode'] !== 'flat') ? 'thread' : 'flat'; |
26 | 26 | //$viewmode = ($viewmode) ? $viewmode: (isset($_POST['viewmode'])?$_POST['viewmode'] : 'flat'); |
27 | 27 | |
28 | 28 | $viewmode = (Request::getString('viewmode', '', 'GET') |
29 | - && 'flat' !== Request::getString('viewmode', '', 'GET')) ? 'thread' : 'flat'; |
|
29 | + && 'flat' !== Request::getString('viewmode', '', 'GET')) ? 'thread' : 'flat'; |
|
30 | 30 | $viewmode = $viewmode ?: (Request::getString('viewmode', '', 'POST') ?: 'flat'); |
31 | 31 | |
32 | 32 | ///** @var Newbb\ForumHandler $forumHandler */ |
@@ -37,21 +37,21 @@ discard block |
||
37 | 37 | //$postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
38 | 38 | |
39 | 39 | if (!empty($post_id)) { |
40 | - $topic = $topicHandler->getByPost($post_id); |
|
40 | + $topic = $topicHandler->getByPost($post_id); |
|
41 | 41 | } else { |
42 | - $topic = $topicHandler->get($topic_id); |
|
42 | + $topic = $topicHandler->get($topic_id); |
|
43 | 43 | } |
44 | 44 | $topic_id = $topic->getVar('topic_id'); |
45 | 45 | if (!$topic_id) { |
46 | - $redirect = empty($forum) ? 'index.php' : 'viewforum.php?forum=' . $forum; |
|
47 | - $redirect = XOOPS_URL . '/modules/newbb/' . $redirect; |
|
48 | - redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
|
46 | + $redirect = empty($forum) ? 'index.php' : 'viewforum.php?forum=' . $forum; |
|
47 | + $redirect = XOOPS_URL . '/modules/newbb/' . $redirect; |
|
48 | + redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | $forum = $topic->getVar('forum_id'); |
52 | 52 | $forumObject = $forumHandler->get($forum); |
53 | 53 | if (!$forumHandler->getPermission($forumObject)) { |
54 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
54 | + redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $isAdmin = newbbIsAdmin($forumObject); |
@@ -62,95 +62,95 @@ discard block |
||
62 | 62 | $topic_status = $topic->getVar('topic_status'); |
63 | 63 | if (($postObject->checkIdentity() || $isAdmin) && $topicHandler->getPermission($topic->getVar('forum_id'), $topic_status, 'delete')) { |
64 | 64 | } else { |
65 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_DELNOTALLOWED); |
|
65 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_DELNOTALLOWED); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | if (!$isAdmin && !$postObject->checkTimelimit('delete_timelimit')) { |
69 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id&post_id=$post_id&pid=$pid", 2, _MD_NEWBB_TIMEISUPDEL); |
|
69 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id&post_id=$post_id&pid=$pid", 2, _MD_NEWBB_TIMEISUPDEL); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
73 | - // /** @var Newbb\OnlineHandler $onlineHandler */ |
|
74 | - // $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
75 | - $onlineHandler->init($forumObject); |
|
73 | + // /** @var Newbb\OnlineHandler $onlineHandler */ |
|
74 | + // $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
75 | + $onlineHandler->init($forumObject); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | if ($ok) { |
79 | - $isDeleteOne = (1 === $ok); |
|
80 | - if ($postObject->isTopic() && 0 == $topic->getVar('topic_replies')) { |
|
81 | - $isDeleteOne = false; |
|
82 | - } |
|
83 | - if ($isDeleteOne && $postObject->isTopic() && $topic->getVar('topic_replies') > 0) { |
|
84 | - //$postHandler->emptyTopic($postObject); |
|
85 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTFIRSTWITHREPLYNODELETED); |
|
86 | - } else { |
|
87 | - if (Request::getString('post_text', '', 'POST')) { |
|
88 | - //send a message |
|
89 | - /** @var \XoopsMemberHandler $memberHandler */ |
|
90 | - $memberHandler = xoops_getHandler('member'); |
|
91 | - $senduser = $memberHandler->getUser($postObject->getVar('uid')); |
|
92 | - if ($senduser->getVar('notify_method') > 0) { |
|
93 | - $xoopsMailer = xoops_getMailer(); |
|
94 | - $xoopsMailer->reset(); |
|
95 | - if (1 == $senduser->getVar('notify_method')) { |
|
96 | - $xoopsMailer->usePM(); |
|
97 | - } else { |
|
98 | - $xoopsMailer->useMail(); |
|
99 | - } |
|
100 | - $xoopsMailer->setHTML(true); |
|
101 | - $xoopsMailer->setToUsers($senduser); |
|
102 | - $xoopsMailer->setFromName($GLOBALS['xoopsUser']->getVar('uname')); |
|
103 | - $xoopsMailer->setSubject(_MD_NEWBB_DELEDEDMSG_SUBJECT); |
|
104 | - $forenurl = '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $postObject->getVar('topic_id') . '">' . $postObject->getVar('subject') . '</a>'; |
|
105 | - if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
|
106 | - $forenurl = seo_urls($forenurl); |
|
107 | - } |
|
108 | - $body = sprintf(_MD_NEWBB_DELEDEDMSG_BODY, $senduser->getVar('uname'), $forenurl, Request::getString('post_text', '', 'POST'), $GLOBALS['xoopsUser']->getVar('uname'), $GLOBALS['xoopsConfig']['sitename'], XOOPS_URL . '/'); |
|
109 | - $body = $myts->nl2Br($body); |
|
110 | - $xoopsMailer->setBody($body); |
|
111 | - $xoopsMailer->send(); |
|
112 | - } |
|
113 | - } |
|
114 | - $postHandler->delete($postObject, $isDeleteOne); |
|
115 | - $forumHandler->synchronization($forum); |
|
116 | - $topicHandler->synchronization($topic_id); |
|
117 | - // /** @var Newbb\StatsHandler $statsHandler */ |
|
118 | - // $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
119 | - $statsHandler->reset(); |
|
120 | - } |
|
79 | + $isDeleteOne = (1 === $ok); |
|
80 | + if ($postObject->isTopic() && 0 == $topic->getVar('topic_replies')) { |
|
81 | + $isDeleteOne = false; |
|
82 | + } |
|
83 | + if ($isDeleteOne && $postObject->isTopic() && $topic->getVar('topic_replies') > 0) { |
|
84 | + //$postHandler->emptyTopic($postObject); |
|
85 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTFIRSTWITHREPLYNODELETED); |
|
86 | + } else { |
|
87 | + if (Request::getString('post_text', '', 'POST')) { |
|
88 | + //send a message |
|
89 | + /** @var \XoopsMemberHandler $memberHandler */ |
|
90 | + $memberHandler = xoops_getHandler('member'); |
|
91 | + $senduser = $memberHandler->getUser($postObject->getVar('uid')); |
|
92 | + if ($senduser->getVar('notify_method') > 0) { |
|
93 | + $xoopsMailer = xoops_getMailer(); |
|
94 | + $xoopsMailer->reset(); |
|
95 | + if (1 == $senduser->getVar('notify_method')) { |
|
96 | + $xoopsMailer->usePM(); |
|
97 | + } else { |
|
98 | + $xoopsMailer->useMail(); |
|
99 | + } |
|
100 | + $xoopsMailer->setHTML(true); |
|
101 | + $xoopsMailer->setToUsers($senduser); |
|
102 | + $xoopsMailer->setFromName($GLOBALS['xoopsUser']->getVar('uname')); |
|
103 | + $xoopsMailer->setSubject(_MD_NEWBB_DELEDEDMSG_SUBJECT); |
|
104 | + $forenurl = '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $postObject->getVar('topic_id') . '">' . $postObject->getVar('subject') . '</a>'; |
|
105 | + if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
|
106 | + $forenurl = seo_urls($forenurl); |
|
107 | + } |
|
108 | + $body = sprintf(_MD_NEWBB_DELEDEDMSG_BODY, $senduser->getVar('uname'), $forenurl, Request::getString('post_text', '', 'POST'), $GLOBALS['xoopsUser']->getVar('uname'), $GLOBALS['xoopsConfig']['sitename'], XOOPS_URL . '/'); |
|
109 | + $body = $myts->nl2Br($body); |
|
110 | + $xoopsMailer->setBody($body); |
|
111 | + $xoopsMailer->send(); |
|
112 | + } |
|
113 | + } |
|
114 | + $postHandler->delete($postObject, $isDeleteOne); |
|
115 | + $forumHandler->synchronization($forum); |
|
116 | + $topicHandler->synchronization($topic_id); |
|
117 | + // /** @var Newbb\StatsHandler $statsHandler */ |
|
118 | + // $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
119 | + $statsHandler->reset(); |
|
120 | + } |
|
121 | 121 | |
122 | - //$postObject->loadFilters('delete'); |
|
123 | - if ($isDeleteOne) { |
|
124 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTDELETED); |
|
125 | - } else { |
|
126 | - redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?forum=$forum", 2, _MD_NEWBB_POSTSDELETED); |
|
127 | - } |
|
122 | + //$postObject->loadFilters('delete'); |
|
123 | + if ($isDeleteOne) { |
|
124 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTDELETED); |
|
125 | + } else { |
|
126 | + redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?forum=$forum", 2, _MD_NEWBB_POSTSDELETED); |
|
127 | + } |
|
128 | 128 | } else { |
129 | - require_once $GLOBALS['xoops']->path('header.php'); |
|
130 | - //xoops_confirm(array('post_id' => $post_id, 'viewmode' => $viewmode, 'order' => $order, 'forum' => $forum, 'topic_id' => $topic_id, 'ok' => 1), 'delete.php', _MD_NEWBB_DEL_ONE); |
|
131 | - echo '<div class="confirmMsg">' . _MD_NEWBB_DEL_ONE . '<br> |
|
129 | + require_once $GLOBALS['xoops']->path('header.php'); |
|
130 | + //xoops_confirm(array('post_id' => $post_id, 'viewmode' => $viewmode, 'order' => $order, 'forum' => $forum, 'topic_id' => $topic_id, 'ok' => 1), 'delete.php', _MD_NEWBB_DEL_ONE); |
|
131 | + echo '<div class="confirmMsg">' . _MD_NEWBB_DEL_ONE . '<br> |
|
132 | 132 | <form method="post" action="' . XOOPS_URL . '/modules/newbb/delete.php">'; |
133 | - echo _MD_NEWBB_DELEDEDMSG . '<br>'; |
|
134 | - echo '<textarea name="post_text" cols="50" rows="5"></textarea><br>'; |
|
135 | - echo '<input type="hidden" name="post_id" value="' . htmlspecialchars($post_id, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
136 | - echo '<input type="hidden" name="order" value="' . htmlspecialchars($order, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
137 | - echo '<input type="hidden" name="forum" value="' . htmlspecialchars($forum, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
138 | - echo '<input type="hidden" name="topic_id" value="' . htmlspecialchars($topic_id, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
139 | - echo '<input type="hidden" name="ok" value="1" />'; |
|
140 | - echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
|
141 | - echo '<input type="submit" name="confirm_submit" value="' . _SUBMIT . '" title="' . _SUBMIT . '"/> |
|
133 | + echo _MD_NEWBB_DELEDEDMSG . '<br>'; |
|
134 | + echo '<textarea name="post_text" cols="50" rows="5"></textarea><br>'; |
|
135 | + echo '<input type="hidden" name="post_id" value="' . htmlspecialchars($post_id, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
136 | + echo '<input type="hidden" name="order" value="' . htmlspecialchars($order, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
137 | + echo '<input type="hidden" name="forum" value="' . htmlspecialchars($forum, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
138 | + echo '<input type="hidden" name="topic_id" value="' . htmlspecialchars($topic_id, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
139 | + echo '<input type="hidden" name="ok" value="1" />'; |
|
140 | + echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
|
141 | + echo '<input type="submit" name="confirm_submit" value="' . _SUBMIT . '" title="' . _SUBMIT . '"/> |
|
142 | 142 | <input type="button" name="confirm_back" value="' . _CANCEL . '" onclick="history.go(-1);" title="' . _CANCEL . '" /> |
143 | 143 | </form> |
144 | 144 | </div>'; |
145 | - if ($isAdmin) { |
|
146 | - xoops_confirm([ |
|
147 | - 'post_id' => $post_id, |
|
148 | - 'viewmode' => $viewmode, |
|
149 | - 'order' => $order, |
|
150 | - 'forum' => $forum, |
|
151 | - 'topic_id' => $topic_id, |
|
152 | - 'ok' => 99 |
|
153 | - ], 'delete.php', _MD_NEWBB_DEL_RELATED); |
|
154 | - } |
|
155 | - require_once $GLOBALS['xoops']->path('footer.php'); |
|
145 | + if ($isAdmin) { |
|
146 | + xoops_confirm([ |
|
147 | + 'post_id' => $post_id, |
|
148 | + 'viewmode' => $viewmode, |
|
149 | + 'order' => $order, |
|
150 | + 'forum' => $forum, |
|
151 | + 'topic_id' => $topic_id, |
|
152 | + 'ok' => 99 |
|
153 | + ], 'delete.php', _MD_NEWBB_DEL_RELATED); |
|
154 | + } |
|
155 | + require_once $GLOBALS['xoops']->path('footer.php'); |
|
156 | 156 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | use Xmf\Request; |
13 | 13 | |
14 | -require_once __DIR__ . '/header.php'; |
|
14 | +require_once __DIR__.'/header.php'; |
|
15 | 15 | |
16 | 16 | $ok = Request::getInt('ok', 0, 'POST'); |
17 | 17 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | } |
44 | 44 | $topic_id = $topic->getVar('topic_id'); |
45 | 45 | if (!$topic_id) { |
46 | - $redirect = empty($forum) ? 'index.php' : 'viewforum.php?forum=' . $forum; |
|
47 | - $redirect = XOOPS_URL . '/modules/newbb/' . $redirect; |
|
46 | + $redirect = empty($forum) ? 'index.php' : 'viewforum.php?forum='.$forum; |
|
47 | + $redirect = XOOPS_URL.'/modules/newbb/'.$redirect; |
|
48 | 48 | redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
49 | 49 | } |
50 | 50 | |
51 | 51 | $forum = $topic->getVar('forum_id'); |
52 | 52 | $forumObject = $forumHandler->get($forum); |
53 | 53 | if (!$forumHandler->getPermission($forumObject)) { |
54 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
54 | + redirect_header(XOOPS_URL.'/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $isAdmin = newbbIsAdmin($forumObject); |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | $topic_status = $topic->getVar('topic_status'); |
63 | 63 | if (($postObject->checkIdentity() || $isAdmin) && $topicHandler->getPermission($topic->getVar('forum_id'), $topic_status, 'delete')) { |
64 | 64 | } else { |
65 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_DELNOTALLOWED); |
|
65 | + redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_DELNOTALLOWED); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | if (!$isAdmin && !$postObject->checkTimelimit('delete_timelimit')) { |
69 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id&post_id=$post_id&pid=$pid", 2, _MD_NEWBB_TIMEISUPDEL); |
|
69 | + redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id&post_id=$post_id&pid=$pid", 2, _MD_NEWBB_TIMEISUPDEL); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | if ($isDeleteOne && $postObject->isTopic() && $topic->getVar('topic_replies') > 0) { |
84 | 84 | //$postHandler->emptyTopic($postObject); |
85 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTFIRSTWITHREPLYNODELETED); |
|
85 | + redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id=$topic_id&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTFIRSTWITHREPLYNODELETED); |
|
86 | 86 | } else { |
87 | 87 | if (Request::getString('post_text', '', 'POST')) { |
88 | 88 | //send a message |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | $xoopsMailer->setToUsers($senduser); |
102 | 102 | $xoopsMailer->setFromName($GLOBALS['xoopsUser']->getVar('uname')); |
103 | 103 | $xoopsMailer->setSubject(_MD_NEWBB_DELEDEDMSG_SUBJECT); |
104 | - $forenurl = '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $postObject->getVar('topic_id') . '">' . $postObject->getVar('subject') . '</a>'; |
|
104 | + $forenurl = '<a href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/viewtopic.php?topic_id='.$postObject->getVar('topic_id').'">'.$postObject->getVar('subject').'</a>'; |
|
105 | 105 | if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
106 | 106 | $forenurl = seo_urls($forenurl); |
107 | 107 | } |
108 | - $body = sprintf(_MD_NEWBB_DELEDEDMSG_BODY, $senduser->getVar('uname'), $forenurl, Request::getString('post_text', '', 'POST'), $GLOBALS['xoopsUser']->getVar('uname'), $GLOBALS['xoopsConfig']['sitename'], XOOPS_URL . '/'); |
|
108 | + $body = sprintf(_MD_NEWBB_DELEDEDMSG_BODY, $senduser->getVar('uname'), $forenurl, Request::getString('post_text', '', 'POST'), $GLOBALS['xoopsUser']->getVar('uname'), $GLOBALS['xoopsConfig']['sitename'], XOOPS_URL.'/'); |
|
109 | 109 | $body = $myts->nl2Br($body); |
110 | 110 | $xoopsMailer->setBody($body); |
111 | 111 | $xoopsMailer->send(); |
@@ -121,25 +121,25 @@ discard block |
||
121 | 121 | |
122 | 122 | //$postObject->loadFilters('delete'); |
123 | 123 | if ($isDeleteOne) { |
124 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTDELETED); |
|
124 | + redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id=$topic_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum", 2, _MD_NEWBB_POSTDELETED); |
|
125 | 125 | } else { |
126 | - redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?forum=$forum", 2, _MD_NEWBB_POSTSDELETED); |
|
126 | + redirect_header(XOOPS_URL."/modules/newbb/viewforum.php?forum=$forum", 2, _MD_NEWBB_POSTSDELETED); |
|
127 | 127 | } |
128 | 128 | } else { |
129 | 129 | require_once $GLOBALS['xoops']->path('header.php'); |
130 | 130 | //xoops_confirm(array('post_id' => $post_id, 'viewmode' => $viewmode, 'order' => $order, 'forum' => $forum, 'topic_id' => $topic_id, 'ok' => 1), 'delete.php', _MD_NEWBB_DEL_ONE); |
131 | - echo '<div class="confirmMsg">' . _MD_NEWBB_DEL_ONE . '<br> |
|
132 | - <form method="post" action="' . XOOPS_URL . '/modules/newbb/delete.php">'; |
|
133 | - echo _MD_NEWBB_DELEDEDMSG . '<br>'; |
|
131 | + echo '<div class="confirmMsg">'._MD_NEWBB_DEL_ONE.'<br> |
|
132 | + <form method="post" action="' . XOOPS_URL.'/modules/newbb/delete.php">'; |
|
133 | + echo _MD_NEWBB_DELEDEDMSG.'<br>'; |
|
134 | 134 | echo '<textarea name="post_text" cols="50" rows="5"></textarea><br>'; |
135 | - echo '<input type="hidden" name="post_id" value="' . htmlspecialchars($post_id, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
136 | - echo '<input type="hidden" name="order" value="' . htmlspecialchars($order, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
137 | - echo '<input type="hidden" name="forum" value="' . htmlspecialchars($forum, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
138 | - echo '<input type="hidden" name="topic_id" value="' . htmlspecialchars($topic_id, ENT_QUOTES | ENT_HTML5) . '" />'; |
|
135 | + echo '<input type="hidden" name="post_id" value="'.htmlspecialchars($post_id, ENT_QUOTES | ENT_HTML5).'" />'; |
|
136 | + echo '<input type="hidden" name="order" value="'.htmlspecialchars($order, ENT_QUOTES | ENT_HTML5).'" />'; |
|
137 | + echo '<input type="hidden" name="forum" value="'.htmlspecialchars($forum, ENT_QUOTES | ENT_HTML5).'" />'; |
|
138 | + echo '<input type="hidden" name="topic_id" value="'.htmlspecialchars($topic_id, ENT_QUOTES | ENT_HTML5).'" />'; |
|
139 | 139 | echo '<input type="hidden" name="ok" value="1" />'; |
140 | 140 | echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
141 | - echo '<input type="submit" name="confirm_submit" value="' . _SUBMIT . '" title="' . _SUBMIT . '"/> |
|
142 | - <input type="button" name="confirm_back" value="' . _CANCEL . '" onclick="history.go(-1);" title="' . _CANCEL . '" /> |
|
141 | + echo '<input type="submit" name="confirm_submit" value="'._SUBMIT.'" title="'._SUBMIT.'"/> |
|
142 | + <input type="button" name="confirm_back" value="' . _CANCEL.'" onclick="history.go(-1);" title="'._CANCEL.'" /> |
|
143 | 143 | </form> |
144 | 144 | </div>'; |
145 | 145 | if ($isAdmin) { |
@@ -30,17 +30,17 @@ discard block |
||
30 | 30 | xoops_load('XoopsLocal'); |
31 | 31 | $op = 'add'; |
32 | 32 | $goodOps = [ |
33 | - 'add', |
|
34 | - 'save', |
|
35 | - 'edit', |
|
36 | - 'update', |
|
37 | - 'addmore', |
|
38 | - 'savemore', |
|
39 | - 'delete', |
|
40 | - 'delete_ok', |
|
41 | - 'restart', |
|
42 | - 'restart_ok', |
|
43 | - 'log' |
|
33 | + 'add', |
|
34 | + 'save', |
|
35 | + 'edit', |
|
36 | + 'update', |
|
37 | + 'addmore', |
|
38 | + 'savemore', |
|
39 | + 'delete', |
|
40 | + 'delete_ok', |
|
41 | + 'restart', |
|
42 | + 'restart_ok', |
|
43 | + 'log' |
|
44 | 44 | ]; |
45 | 45 | $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : 'add'; |
46 | 46 | $op = (!in_array($op, $goodOps)) ? 'add' : $op; |
@@ -54,705 +54,705 @@ discard block |
||
54 | 54 | $topicObject = $topicHandler->get($topic_id); |
55 | 55 | // topic exist |
56 | 56 | if (is_object($topicObject)) { |
57 | - $forum_id = $topicObject->getVar('forum_id'); |
|
57 | + $forum_id = $topicObject->getVar('forum_id'); |
|
58 | 58 | } else { |
59 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_POLLMODULE_ERROR . ': ' . _MD_NEWBB_FORUMNOEXIST); |
|
59 | + redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_POLLMODULE_ERROR . ': ' . _MD_NEWBB_FORUMNOEXIST); |
|
60 | 60 | } |
61 | 61 | // forum access permission |
62 | 62 | /** @var Newbb\ForumHandler $forumHandler */ |
63 | 63 | $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
64 | 64 | $forumObject = $forumHandler->get($forum_id); |
65 | 65 | if (!$forumHandler->getPermission($forumObject)) { |
66 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
66 | + redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
67 | 67 | } |
68 | 68 | // topic view permission |
69 | 69 | if (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view')) { |
70 | - redirect_header('viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW); |
|
70 | + redirect_header('viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW); |
|
71 | 71 | } |
72 | 72 | // poll module |
73 | 73 | $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']); |
74 | 74 | if (is_object($pollModuleHandler) && $pollModuleHandler->getVar('isactive')) { |
75 | - // new xoopspoll module |
|
76 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
77 | - xoops_load('constants', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
78 | - xoops_load('pollUtility', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
79 | - xoops_load('request', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
80 | - xoops_loadLanguage('admin', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
81 | - /** @var Xoopspoll\PollHandler $xpPollHandler */ |
|
82 | - $xpPollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
|
83 | - /** @var \XoopsPoll $pollObject */ |
|
84 | - $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist |
|
85 | - // old xoopspoll or umfrage or any clone from them |
|
86 | - } else { |
|
87 | - require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php'); |
|
88 | - $classPoll = $topicObject->loadOldPoll(); |
|
89 | - $pollObject = new $classPoll($poll_id); // will create poll if poll_id = 0 exist |
|
90 | - } |
|
75 | + // new xoopspoll module |
|
76 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
77 | + xoops_load('constants', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
78 | + xoops_load('pollUtility', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
79 | + xoops_load('request', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
80 | + xoops_loadLanguage('admin', $GLOBALS['xoopsModuleConfig']['poll_module']); |
|
81 | + /** @var Xoopspoll\PollHandler $xpPollHandler */ |
|
82 | + $xpPollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
|
83 | + /** @var \XoopsPoll $pollObject */ |
|
84 | + $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist |
|
85 | + // old xoopspoll or umfrage or any clone from them |
|
86 | + } else { |
|
87 | + require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php'); |
|
88 | + $classPoll = $topicObject->loadOldPoll(); |
|
89 | + $pollObject = new $classPoll($poll_id); // will create poll if poll_id = 0 exist |
|
90 | + } |
|
91 | 91 | } else { |
92 | - // irmtfan - issue with javascript:history.go(-1) |
|
93 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_POLLMODULE_ERROR); |
|
92 | + // irmtfan - issue with javascript:history.go(-1) |
|
93 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_POLLMODULE_ERROR); |
|
94 | 94 | } |
95 | 95 | // include header |
96 | 96 | require_once $GLOBALS['xoops']->path('header.php'); |
97 | 97 | |
98 | 98 | // no admin user permission |
99 | 99 | if (is_object($GLOBALS['xoopsUser']) && !newbbIsAdmin($forumObject)) { |
100 | - $perm = false; |
|
101 | - if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'addpoll')) { |
|
102 | - if (('add' === $op || 'save' === $op || 'update' === $op) && !$topicObject->getVar('topic_haspoll') |
|
103 | - && ($GLOBALS['xoopsUser']->getVar('uid') == $topicObject->getVar('topic_poster'))) { |
|
104 | - $perm = true; |
|
105 | - } elseif (!empty($poll_id) && ($GLOBALS['xoopsUser']->getVar('uid') == $pollObject->getVar('user_id'))) { |
|
106 | - $perm = true; |
|
107 | - } |
|
108 | - } |
|
109 | - if (!$perm) { |
|
110 | - redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _NOPERM); |
|
111 | - } |
|
100 | + $perm = false; |
|
101 | + if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'addpoll')) { |
|
102 | + if (('add' === $op || 'save' === $op || 'update' === $op) && !$topicObject->getVar('topic_haspoll') |
|
103 | + && ($GLOBALS['xoopsUser']->getVar('uid') == $topicObject->getVar('topic_poster'))) { |
|
104 | + $perm = true; |
|
105 | + } elseif (!empty($poll_id) && ($GLOBALS['xoopsUser']->getVar('uid') == $pollObject->getVar('user_id'))) { |
|
106 | + $perm = true; |
|
107 | + } |
|
108 | + } |
|
109 | + if (!$perm) { |
|
110 | + redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _NOPERM); |
|
111 | + } |
|
112 | 112 | } |
113 | 113 | switch ($op) { |
114 | - case 'add': |
|
115 | - // new xoopspoll module |
|
116 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
117 | - echo '<h4>' . _MD_NEWBB_POLL_CREATNEWPOLL . "</h4>\n"; |
|
118 | - $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
|
119 | - // old xoopspoll or umfrage or any clone from them |
|
120 | - } else { |
|
121 | - $classOption = $classPoll . 'Option'; |
|
122 | - $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true); |
|
123 | - $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("<a href='" |
|
124 | - . XOOPS_URL |
|
125 | - . '/userinfo.php?uid=' |
|
126 | - . $GLOBALS['xoopsUser']->getVar('uid') |
|
127 | - . "'>" |
|
128 | - . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']) |
|
129 | - . '</a>') : $GLOBALS['xoopsConfig']['anonymous']); |
|
130 | - $poll_form->addElement($author_label); |
|
131 | - $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255); |
|
132 | - $poll_form->addElement($question_text); |
|
133 | - $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description'); |
|
134 | - $poll_form->addElement($desc_tarea); |
|
135 | - $currenttime = formatTimestamp(time(), 'Y-m-d H:i:s'); |
|
136 | - $endtime = formatTimestamp(time() + 604800, 'Y-m-d H:i:s'); |
|
137 | - $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, $currenttime) . '</small>', 'end_time', 30, 19, $endtime); |
|
138 | - $poll_form->addElement($expire_text); |
|
139 | - |
|
140 | - $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, 0); |
|
141 | - $poll_form->addElement($weight_text); |
|
142 | - |
|
143 | - $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', 0); |
|
144 | - $poll_form->addElement($multi_yn); |
|
145 | - |
|
146 | - $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1); |
|
147 | - $poll_form->addElement($notify_yn); |
|
148 | - |
|
149 | - $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
150 | - $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
151 | - for ($i = 0; $i < 10; ++$i) { |
|
152 | - $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
|
153 | - $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
|
154 | - $option_tray->addElement($option_text); |
|
155 | - $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
|
156 | - $color_select->addOptionArray($barcolor_array); |
|
157 | - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'"); |
|
158 | - $color_label = new \XoopsFormLabel('', "<img src='" |
|
159 | - . XOOPS_URL |
|
160 | - . '/modules/' |
|
161 | - . $GLOBALS['xoopsModuleConfig']['poll_module'] |
|
162 | - . '/assets/images/colorbars/' |
|
163 | - . $current_bar |
|
164 | - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' width='30' align='bottom' height='15' alt='' /><br>"); |
|
165 | - $option_tray->addElement($color_select); |
|
166 | - $option_tray->addElement($color_label); |
|
167 | - if (!next($barcolor_array)) { |
|
168 | - reset($barcolor_array); |
|
169 | - } |
|
170 | - unset($color_select, $color_label); |
|
171 | - } |
|
172 | - $poll_form->addElement($option_tray); |
|
173 | - |
|
174 | - $poll_form->addElement(new \XoopsFormHidden('op', 'save')); |
|
175 | - $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
176 | - $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
177 | - $poll_form->addElement(new \XoopsFormHidden('user_id', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0)); |
|
178 | - $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
179 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . '</h4>'; |
|
180 | - $poll_form->display(); |
|
181 | - } |
|
182 | - break; // op: add |
|
183 | - |
|
184 | - case 'edit': |
|
185 | - // new xoopspoll module |
|
186 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
187 | - echo '<h4>' . _MD_NEWBB_POLL_EDITPOLL . "</h4>\n"; |
|
188 | - $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
|
189 | - // old xoopspoll or umfrage or any clone from them |
|
190 | - } else { |
|
191 | - $classOption = $classPoll . 'Option'; |
|
192 | - $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_EDITPOLL, 'poll_form', 'polls.php', 'post', true); |
|
193 | - $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $pollObject->getVar('user_id') . "'>" . newbbGetUnameFromId($pollObject->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']) . '</a>'); |
|
194 | - $poll_form->addElement($author_label); |
|
195 | - $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255, $pollObject->getVar('question', 'E')); |
|
196 | - $poll_form->addElement($question_text); |
|
197 | - $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description', $pollObject->getVar('description', 'E')); |
|
198 | - $poll_form->addElement($desc_tarea); |
|
199 | - $date = formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s'); // important "Y-m-d H:i:s" use in jdf function |
|
200 | - if (!$pollObject->hasExpired()) { |
|
201 | - $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '</small>', 'end_time', 20, 19, $date); |
|
202 | - $poll_form->addElement($expire_text); |
|
203 | - } else { |
|
204 | - // irmtfan full URL - add topic_id |
|
205 | - $restart_label = new \XoopsFormLabel( |
|
206 | - _MD_NEWBB_POLL_EXPIRATION, |
|
207 | - sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=restart&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . '</a>' |
|
208 | - ); |
|
209 | - $poll_form->addElement($restart_label); |
|
210 | - } |
|
211 | - $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, $pollObject->getVar('weight')); |
|
212 | - $poll_form->addElement($weight_text); |
|
213 | - $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', $pollObject->getVar('multiple')); |
|
214 | - $poll_form->addElement($multi_yn); |
|
215 | - $options_arr =& $classOption::getAllByPollId($poll_id); |
|
216 | - $notify_value = 1; |
|
217 | - if (0 !== $pollObject->getVar('mail_status')) { |
|
218 | - $notify_value = 0; |
|
219 | - } |
|
220 | - $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', $notify_value); |
|
221 | - $poll_form->addElement($notify_yn); |
|
222 | - $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
223 | - $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/")); |
|
224 | - $i = 0; |
|
225 | - foreach ($options_arr as $option) { |
|
226 | - /** @var \XoopsPoll $option */ |
|
227 | - $option_tray->addElement(new \XoopsFormText('', 'option_text[]', 50, 255, $option->getVar('option_text'))); |
|
228 | - $option_tray->addElement(new \XoopsFormHidden('option_id[]', $option->getVar('option_id'))); |
|
229 | - $color_select = new \XoopsFormSelect('', 'option_color[{$i}]', $option->getVar('option_color')); |
|
230 | - $color_select->addOptionArray($barcolor_array); |
|
231 | - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
232 | - $color_label = new \XoopsFormLabel('', "<img src='" |
|
233 | - . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) |
|
234 | - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
235 | - $option_tray->addElement($color_select); |
|
236 | - $option_tray->addElement($color_label); |
|
237 | - unset($color_select, $color_label); |
|
238 | - ++$i; |
|
239 | - } |
|
240 | - // irmtfan full URL |
|
241 | - $more_label = new \XoopsFormLabel('', "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=addmore&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_ADDMORE . '</a>'); |
|
242 | - $option_tray->addElement($more_label); |
|
243 | - $poll_form->addElement($option_tray); |
|
244 | - $poll_form->addElement(new \XoopsFormHidden('op', 'update')); |
|
245 | - $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
246 | - $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
247 | - $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
248 | - |
|
249 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
250 | - $poll_form->display(); |
|
251 | - } |
|
252 | - break; // op: edit |
|
253 | - |
|
254 | - case 'save': |
|
255 | - // old xoopspoll or umfrage or any clone from them |
|
256 | - if ($pollModuleHandler->getVar('version') < 140) { |
|
257 | - // check security token |
|
258 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
259 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
260 | - } |
|
261 | - /* |
|
114 | + case 'add': |
|
115 | + // new xoopspoll module |
|
116 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
117 | + echo '<h4>' . _MD_NEWBB_POLL_CREATNEWPOLL . "</h4>\n"; |
|
118 | + $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
|
119 | + // old xoopspoll or umfrage or any clone from them |
|
120 | + } else { |
|
121 | + $classOption = $classPoll . 'Option'; |
|
122 | + $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true); |
|
123 | + $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("<a href='" |
|
124 | + . XOOPS_URL |
|
125 | + . '/userinfo.php?uid=' |
|
126 | + . $GLOBALS['xoopsUser']->getVar('uid') |
|
127 | + . "'>" |
|
128 | + . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']) |
|
129 | + . '</a>') : $GLOBALS['xoopsConfig']['anonymous']); |
|
130 | + $poll_form->addElement($author_label); |
|
131 | + $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255); |
|
132 | + $poll_form->addElement($question_text); |
|
133 | + $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description'); |
|
134 | + $poll_form->addElement($desc_tarea); |
|
135 | + $currenttime = formatTimestamp(time(), 'Y-m-d H:i:s'); |
|
136 | + $endtime = formatTimestamp(time() + 604800, 'Y-m-d H:i:s'); |
|
137 | + $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, $currenttime) . '</small>', 'end_time', 30, 19, $endtime); |
|
138 | + $poll_form->addElement($expire_text); |
|
139 | + |
|
140 | + $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, 0); |
|
141 | + $poll_form->addElement($weight_text); |
|
142 | + |
|
143 | + $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', 0); |
|
144 | + $poll_form->addElement($multi_yn); |
|
145 | + |
|
146 | + $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1); |
|
147 | + $poll_form->addElement($notify_yn); |
|
148 | + |
|
149 | + $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
150 | + $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
151 | + for ($i = 0; $i < 10; ++$i) { |
|
152 | + $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
|
153 | + $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
|
154 | + $option_tray->addElement($option_text); |
|
155 | + $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
|
156 | + $color_select->addOptionArray($barcolor_array); |
|
157 | + $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'"); |
|
158 | + $color_label = new \XoopsFormLabel('', "<img src='" |
|
159 | + . XOOPS_URL |
|
160 | + . '/modules/' |
|
161 | + . $GLOBALS['xoopsModuleConfig']['poll_module'] |
|
162 | + . '/assets/images/colorbars/' |
|
163 | + . $current_bar |
|
164 | + . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' width='30' align='bottom' height='15' alt='' /><br>"); |
|
165 | + $option_tray->addElement($color_select); |
|
166 | + $option_tray->addElement($color_label); |
|
167 | + if (!next($barcolor_array)) { |
|
168 | + reset($barcolor_array); |
|
169 | + } |
|
170 | + unset($color_select, $color_label); |
|
171 | + } |
|
172 | + $poll_form->addElement($option_tray); |
|
173 | + |
|
174 | + $poll_form->addElement(new \XoopsFormHidden('op', 'save')); |
|
175 | + $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
176 | + $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
177 | + $poll_form->addElement(new \XoopsFormHidden('user_id', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0)); |
|
178 | + $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
179 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . '</h4>'; |
|
180 | + $poll_form->display(); |
|
181 | + } |
|
182 | + break; // op: add |
|
183 | + |
|
184 | + case 'edit': |
|
185 | + // new xoopspoll module |
|
186 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
187 | + echo '<h4>' . _MD_NEWBB_POLL_EDITPOLL . "</h4>\n"; |
|
188 | + $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
|
189 | + // old xoopspoll or umfrage or any clone from them |
|
190 | + } else { |
|
191 | + $classOption = $classPoll . 'Option'; |
|
192 | + $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_EDITPOLL, 'poll_form', 'polls.php', 'post', true); |
|
193 | + $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $pollObject->getVar('user_id') . "'>" . newbbGetUnameFromId($pollObject->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']) . '</a>'); |
|
194 | + $poll_form->addElement($author_label); |
|
195 | + $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255, $pollObject->getVar('question', 'E')); |
|
196 | + $poll_form->addElement($question_text); |
|
197 | + $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description', $pollObject->getVar('description', 'E')); |
|
198 | + $poll_form->addElement($desc_tarea); |
|
199 | + $date = formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s'); // important "Y-m-d H:i:s" use in jdf function |
|
200 | + if (!$pollObject->hasExpired()) { |
|
201 | + $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '</small>', 'end_time', 20, 19, $date); |
|
202 | + $poll_form->addElement($expire_text); |
|
203 | + } else { |
|
204 | + // irmtfan full URL - add topic_id |
|
205 | + $restart_label = new \XoopsFormLabel( |
|
206 | + _MD_NEWBB_POLL_EXPIRATION, |
|
207 | + sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=restart&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . '</a>' |
|
208 | + ); |
|
209 | + $poll_form->addElement($restart_label); |
|
210 | + } |
|
211 | + $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, $pollObject->getVar('weight')); |
|
212 | + $poll_form->addElement($weight_text); |
|
213 | + $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', $pollObject->getVar('multiple')); |
|
214 | + $poll_form->addElement($multi_yn); |
|
215 | + $options_arr =& $classOption::getAllByPollId($poll_id); |
|
216 | + $notify_value = 1; |
|
217 | + if (0 !== $pollObject->getVar('mail_status')) { |
|
218 | + $notify_value = 0; |
|
219 | + } |
|
220 | + $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', $notify_value); |
|
221 | + $poll_form->addElement($notify_yn); |
|
222 | + $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
223 | + $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/")); |
|
224 | + $i = 0; |
|
225 | + foreach ($options_arr as $option) { |
|
226 | + /** @var \XoopsPoll $option */ |
|
227 | + $option_tray->addElement(new \XoopsFormText('', 'option_text[]', 50, 255, $option->getVar('option_text'))); |
|
228 | + $option_tray->addElement(new \XoopsFormHidden('option_id[]', $option->getVar('option_id'))); |
|
229 | + $color_select = new \XoopsFormSelect('', 'option_color[{$i}]', $option->getVar('option_color')); |
|
230 | + $color_select->addOptionArray($barcolor_array); |
|
231 | + $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
232 | + $color_label = new \XoopsFormLabel('', "<img src='" |
|
233 | + . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) |
|
234 | + . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
235 | + $option_tray->addElement($color_select); |
|
236 | + $option_tray->addElement($color_label); |
|
237 | + unset($color_select, $color_label); |
|
238 | + ++$i; |
|
239 | + } |
|
240 | + // irmtfan full URL |
|
241 | + $more_label = new \XoopsFormLabel('', "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=addmore&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_ADDMORE . '</a>'); |
|
242 | + $option_tray->addElement($more_label); |
|
243 | + $poll_form->addElement($option_tray); |
|
244 | + $poll_form->addElement(new \XoopsFormHidden('op', 'update')); |
|
245 | + $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
246 | + $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
247 | + $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
248 | + |
|
249 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
250 | + $poll_form->display(); |
|
251 | + } |
|
252 | + break; // op: edit |
|
253 | + |
|
254 | + case 'save': |
|
255 | + // old xoopspoll or umfrage or any clone from them |
|
256 | + if ($pollModuleHandler->getVar('version') < 140) { |
|
257 | + // check security token |
|
258 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
259 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
260 | + } |
|
261 | + /* |
|
262 | 262 | * The option check should be done before submitting |
263 | 263 | */ |
264 | - $option_empty = true; |
|
265 | - if (!Request::getString('option_text', '', 'POST')) { |
|
266 | - // irmtfan - issue with javascript:history.go(-1) |
|
267 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
268 | - } |
|
269 | - $option_text = Request::getArray('option_text', '', 'POST'); |
|
270 | - foreach ($option_text as $optxt) { |
|
271 | - if ('' !== trim($optxt)) { |
|
272 | - $option_empty = false; |
|
273 | - break; |
|
274 | - } |
|
275 | - } |
|
276 | - if ($option_empty) { |
|
277 | - // irmtfan - issue with javascript:history.go(-1) |
|
278 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
279 | - } |
|
280 | - $pollObject->setVar('question', Request::getString('question', '', 'POST')); |
|
281 | - $pollObject->setVar('description', Request::getString('description', '', 'POST')); |
|
282 | - $end_time = Request::getString('end_time', '', 'POST'); // (empty($_POST['end_time'])) ? "" : $_POST['end_time']; |
|
283 | - if ('' !== $end_time) { |
|
284 | - $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
285 | - $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
286 | - } else { |
|
287 | - // if expiration date is not set, set it to 10 days from now |
|
288 | - $pollObject->setVar('end_time', time() + (86400 * 10)); |
|
289 | - } |
|
290 | - |
|
291 | - $pollObject->setVar('display', 0); |
|
292 | - $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST')); |
|
293 | - $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST')); |
|
294 | - $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST')); |
|
295 | - if (Request::getInt('notify', 0, 'POST') && $end_time > time()) { |
|
296 | - // if notify, set mail status to "not mailed" |
|
297 | - $pollObject->setVar('mail_status', Xoopspoll\Constants::POLL_NOT_MAILED); |
|
298 | - } else { |
|
299 | - // if not notify, set mail status to already "mailed" |
|
300 | - $pollObject->setVar('mail_status', Xoopspoll\Constants::POLL_MAILED); |
|
301 | - } |
|
302 | - $new_poll_id = $pollObject->store(); |
|
303 | - if (empty($new_poll_id)) { |
|
304 | - xoops_error($pollObject->getHtmlErrors); |
|
305 | - break; |
|
306 | - } |
|
307 | - $i = 0; |
|
308 | - $option_color = Request::getArray('option_color', null, 'POST'); |
|
309 | - $classOption = $classPoll . 'Option'; |
|
310 | - foreach ($option_text as $optxt) { |
|
311 | - $optxt = trim($optxt); |
|
312 | - /** @var Xoopspoll\Option $optionObject */ |
|
313 | - $optionObject = new $classOption(); |
|
314 | - if ('' !== $optxt) { |
|
315 | - $optionObject->setVar('option_text', $optxt); |
|
316 | - $optionObject->setVar('option_color', $option_color[$i]); |
|
317 | - $optionObject->setVar('poll_id', $new_poll_id); |
|
318 | - $optionObject->store(); |
|
319 | - } |
|
320 | - ++$i; |
|
321 | - } |
|
322 | - // clear the template cache so changes take effect immediately |
|
323 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
324 | - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
325 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
326 | - |
|
327 | - // update topic to indicate it has a poll |
|
328 | - $topicObject->setVar('topic_haspoll', 1); |
|
329 | - $topicObject->setVar('poll_id', $new_poll_id); |
|
330 | - $success = $topicHandler->insert($topicObject); |
|
331 | - if (!$success) { |
|
332 | - xoops_error($topicHandler->getHtmlErrors()); |
|
333 | - } else { |
|
334 | - redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
335 | - } |
|
336 | - break;// op: save |
|
337 | - } |
|
338 | - // no break |
|
339 | - case 'update': |
|
340 | - // check security token |
|
341 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
342 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
343 | - } |
|
344 | - /* make sure there's at least one option */ |
|
345 | - $option_text = Request::getString('option_text', '', 'POST'); |
|
346 | - $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; |
|
347 | - $option_string = trim($option_string); |
|
348 | - if ('' === $option_string) { |
|
349 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
350 | - } |
|
351 | - |
|
352 | - // new xoopspoll module |
|
353 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
354 | - /** @var Xoopspoll\OptionHandler $xpOptHandler */ |
|
355 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
356 | - /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
357 | - $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
358 | - // $classRequest = ucfirst($GLOBALS['xoopsModuleConfig']["poll_module"]) . "Request"; |
|
359 | - $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
360 | - $notify = Request::getInt('notify', $classConstants::NOTIFICATION_ENABLED, 'POST'); |
|
361 | - $currentTimestamp = time(); |
|
362 | - //$xuEndTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_end_time', null, 'POST')) |
|
363 | - // : strtotime(Request::getString('xu_end_time', null, 'POST')); |
|
364 | - $xuEndTimestamp = strtotime(Request::getString('xu_end_time', null, 'POST')); |
|
365 | - $endTimestamp = (!Request::getString('xu_end_time', null, 'POST')) ? ($currentTimestamp + $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp); |
|
366 | - //$xuStartTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_start_time', null, 'POST')) |
|
367 | - // : strtotime(Request::getString('xu_start_time', null, 'POST')); |
|
368 | - $xuStartTimestamp = strtotime(Request::getString('xu_start_time', null, 'POST')); |
|
369 | - $startTimestamp = (!Request::getString('xu_start_time', null, 'POST')) ? ($endTimestamp - $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp); |
|
370 | - |
|
371 | - // don't allow changing start time if there are votes in the log |
|
372 | - if (($startTimestamp < $pollObject->getVar('start_time')) |
|
373 | - && ($xpLogHandler->getTotalVotesByPollId($poll_id) > 0)) { |
|
374 | - $startTimestamp = $pollObject->getVar('start_time'); //don't change start time |
|
375 | - } |
|
376 | - |
|
377 | - $poll_vars = [ |
|
378 | - 'user_id' => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'), |
|
379 | - 'question' => Request::getString('question', null, 'POST'), |
|
380 | - 'description' => Request::getText('description', null, 'POST'), |
|
381 | - 'mail_status' => ($classConstants::NOTIFICATION_ENABLED == $notify) ? $classConstants::POLL_NOT_MAILED : $classConstants::POLL_MAILED, |
|
382 | - 'mail_voter' => Request::getInt('mail_voter', $classConstants::NOT_MAIL_POLL_TO_VOTER, 'POST'), |
|
383 | - 'start_time' => $startTimestamp, |
|
384 | - 'end_time' => $endTimestamp, |
|
385 | - 'display' => Request::getInt('display', $classConstants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'), |
|
386 | - 'visibility' => Request::getInt('visibility', $classConstants::HIDE_NEVER, 'POST'), |
|
387 | - 'weight' => Request::getInt('weight', $classConstants::DEFAULT_WEIGHT, 'POST'), |
|
388 | - 'multiple' => Request::getInt('multiple', $classConstants::NOT_MULTIPLE_SELECT_POLL, 'POST'), |
|
389 | - 'multilimit' => Request::getInt('multilimit', $classConstants::MULTIPLE_SELECT_LIMITLESS, 'POST'), |
|
390 | - 'anonymous' => Request::getInt('anonymous', $classConstants::ANONYMOUS_VOTING_DISALLOWED, 'POST') |
|
391 | - ]; |
|
392 | - $pollObject->setVars($poll_vars); |
|
393 | - $poll_id = $xpPollHandler->insert($pollObject); |
|
394 | - if (!$poll_id) { |
|
395 | - $err = $pollObject->getHtmlErrors(); |
|
396 | - exit($err); |
|
397 | - } |
|
398 | - |
|
399 | - // now get the options |
|
400 | - $optionIdArray = Request::getArray('option_id', [], 'POST'); |
|
401 | - $optionIdArray = array_map('intval', $optionIdArray); |
|
402 | - $optionTextArray = Request::getArray('option_text', [], 'POST'); |
|
403 | - $optionColorArray = Request::getArray('option_color', [], 'POST'); |
|
404 | - |
|
405 | - foreach ($optionIdArray as $key => $oId) { |
|
406 | - if (!empty($oId) && ($optionObject = $xpOptHandler->get($oId))) { |
|
407 | - // existing option object so need to update it |
|
408 | - $optionTextArray[$key] = trim($optionTextArray[$key]); |
|
409 | - if ('' === $optionTextArray[$key]) { |
|
410 | - // want to delete this option |
|
411 | - if (false !== $xpOptHandler->delete($optionObject)) { |
|
412 | - // now remove it from the log |
|
413 | - $xpLogHandler->deleteByOptionId($optionObject->getVar('option_id')); |
|
414 | - //update vote count in poll |
|
415 | - $xpPollHandler->updateCount($pollObject); |
|
416 | - } else { |
|
417 | - xoops_error($xpLogHandler->getHtmlErrors()); |
|
418 | - break; |
|
419 | - } |
|
420 | - } else { |
|
421 | - $optionObject->setVar('option_text', $optionTextArray[$key]); |
|
422 | - $optionObject->setVar('option_color', $optionColorArray[$key]); |
|
423 | - $optionObject->setVar('poll_id', $poll_id); |
|
424 | - $xpOptHandler->insert($optionObject); |
|
425 | - } |
|
426 | - } else { |
|
427 | - // new option object |
|
428 | - $optionObject = $xpOptHandler->create(); |
|
429 | - $optionTextArray[$key] = trim($optionTextArray[$key]); |
|
430 | - if ('' !== $optionTextArray[$key]) { // ignore if text is empty |
|
431 | - $optionObject->setVar('option_text', $optionTextArray[$key]); |
|
432 | - $optionObject->setVar('option_color', $optionColorArray[$key]); |
|
433 | - $optionObject->setVar('poll_id', $poll_id); |
|
434 | - $xpOptHandler->insert($optionObject); |
|
435 | - } |
|
436 | - unset($optionObject); |
|
437 | - } |
|
438 | - } |
|
439 | - // old xoopspoll or umfrage or any clone from them |
|
440 | - } else { |
|
441 | - $pollObject->setVar('question', Request::getString('question', '', 'POST')); |
|
442 | - $pollObject->setVar('description', Request::getString('description', '', 'POST')); |
|
443 | - |
|
444 | - $end_time = Request::getString('end_time', '', 'POST'); |
|
445 | - if ('' !== $end_time) { |
|
446 | - $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
447 | - $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
448 | - } |
|
449 | - $pollObject->setVar('display', 0); |
|
450 | - $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST')); |
|
451 | - $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST')); |
|
452 | - $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST')); |
|
453 | - if (Request::getInt('notify', 0, 'POST') && $end_time > time()) { |
|
454 | - // if notify, set mail status to "not mailed" |
|
455 | - $pollObject->setVar('mail_status', $classConstants::POLL_NOT_MAILED); |
|
456 | - } else { |
|
457 | - // if not notify, set mail status to already "mailed" |
|
458 | - $pollObject->setVar('mail_status', $classConstants::POLL_MAILED); |
|
459 | - } |
|
460 | - |
|
461 | - if (!$pollObject->store()) { |
|
462 | - xoops_error($pollObject->getHtmlErrors); |
|
463 | - break; |
|
464 | - } |
|
465 | - $i = 0; |
|
466 | - $option_id = Request::getArray('option_id', null, 'POST'); |
|
467 | - $option_color = Request::getArray('option_color', null, 'POST'); |
|
468 | - $classOption = $classPoll . 'Option'; |
|
469 | - $classLog = $classPoll . 'Log'; |
|
470 | - foreach ($option_id as $opid) { |
|
471 | - $optionObject = new $classOption($opid); |
|
472 | - $option_text[$i] = trim($option_text[$i]); |
|
473 | - if ('' !== $option_text[$i]) { |
|
474 | - $optionObject->setVar('option_text', $option_text[$i]); |
|
475 | - $optionObject->setVar('option_color', $option_color[$i]); |
|
476 | - $optionObject->store(); |
|
477 | - } else { |
|
478 | - if (false !== $optionObject->delete()) { |
|
479 | - $classLog::deleteByOptionId($option->getVar('option_id')); |
|
480 | - } |
|
481 | - } |
|
482 | - ++$i; |
|
483 | - } |
|
484 | - $pollObject->updateCount(); |
|
485 | - } |
|
486 | - // clear the template cache so changes take effect immediately |
|
487 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
488 | - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
489 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
490 | - |
|
491 | - // update topic to indicate it has a poll |
|
492 | - $topicObject->setVar('topic_haspoll', 1); |
|
493 | - $topicObject->setVar('poll_id', $pollObject->getVar('poll_id')); |
|
494 | - $success = $topicHandler->insert($topicObject); |
|
495 | - if (!$success) { |
|
496 | - xoops_error($topicHandler->getHtmlErrors()); |
|
497 | - } else { |
|
498 | - redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
499 | - } |
|
500 | - break;// op: save | update |
|
501 | - |
|
502 | - case 'addmore': |
|
503 | - $question = $pollObject->getVar('question'); |
|
504 | - unset($pollObject); |
|
505 | - $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_ADDMORE, 'poll_form', 'polls.php', 'post', true); |
|
506 | - $poll_form->addElement(new \XoopsFormLabel(_MD_NEWBB_POLL_POLLQUESTION, $question)); |
|
507 | - // new xoopspoll module |
|
508 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
509 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
510 | - $option_tray = $xpOptHandler->renderOptionFormTray($poll_id); |
|
511 | - // old xoopspoll or umfrage or any clone from them |
|
512 | - } else { |
|
513 | - $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
514 | - $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
515 | - for ($i = 0; $i < 10; ++$i) { |
|
516 | - $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
|
517 | - $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
|
518 | - $option_tray->addElement($option_text); |
|
519 | - $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
|
520 | - $color_select->addOptionArray($barcolor_array); |
|
521 | - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
522 | - $color_label = new \XoopsFormLabel('', "<img src='" |
|
523 | - . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}") |
|
524 | - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
525 | - $option_tray->addElement($color_select); |
|
526 | - $option_tray->addElement($color_label); |
|
527 | - unset($color_select, $color_label, $option_text); |
|
528 | - if (!next($barcolor_array)) { |
|
529 | - reset($barcolor_array); |
|
530 | - } |
|
531 | - } |
|
532 | - } |
|
533 | - $poll_form->addElement($option_tray); |
|
534 | - $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
535 | - $poll_form->addElement(new \XoopsFormHidden('op', 'savemore')); |
|
536 | - $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
537 | - $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
538 | - |
|
539 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
540 | - $poll_form->display(); |
|
541 | - break; |
|
542 | - |
|
543 | - case 'savemore': |
|
544 | - // check security token |
|
545 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
546 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
547 | - } |
|
548 | - |
|
549 | - $option_text = Request::getString('option_text', '', 'POST'); |
|
550 | - $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; |
|
551 | - $option_string = trim($option_string); |
|
552 | - if ('' === $option_string) { |
|
553 | - // irmtfan - issue with javascript:history.go(-1) |
|
554 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
555 | - } |
|
556 | - $i = 0; |
|
557 | - $option_color = Request::getArray('option_color', null, 'POST'); |
|
558 | - foreach ($option_text as $optxt) { |
|
559 | - $optxt = trim($optxt); |
|
560 | - if ('' !== $optxt) { |
|
561 | - // new xoopspoll module |
|
562 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
563 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
564 | - $optionObject = $xpOptHandler->create(); |
|
565 | - $optionObject->setVar('option_text', $optxt); |
|
566 | - $optionObject->setVar('poll_id', $poll_id); |
|
567 | - $optionObject->setVar('option_color', $option_color[$i]); |
|
568 | - $xpOptHandler->insert($optionObject); |
|
569 | - // old xoopspoll or umfrage or any clone from them |
|
570 | - } else { |
|
571 | - $classOption = $classPoll . 'Option'; |
|
572 | - $optionObject = new $classOption(); |
|
573 | - $optionObject->setVar('option_text', $optxt); |
|
574 | - $optionObject->setVar('poll_id', $poll_id); |
|
575 | - $optionObject->setVar('option_color', $option_color[$i]); |
|
576 | - $optionObject->store(); |
|
577 | - } |
|
578 | - unset($optionObject); |
|
579 | - } |
|
580 | - ++$i; |
|
581 | - } |
|
582 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
583 | - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
584 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
585 | - redirect_header("polls.php?op=edit&poll_id={$poll_id}&topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
586 | - break; |
|
587 | - |
|
588 | - case 'delete': |
|
589 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
590 | - xoops_confirm(['op' => 'delete_ok', 'topic_id' => $topic_id, 'poll_id' => $poll_id], 'polls.php', sprintf(_MD_NEWBB_POLL_RUSUREDEL, $pollObject->getVar('question'))); |
|
591 | - break; |
|
592 | - |
|
593 | - case 'delete_ok': |
|
594 | - // check security token |
|
595 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
596 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
597 | - } |
|
598 | - //try and delete the poll |
|
599 | - // new xoopspoll module |
|
600 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
601 | - $status = $xpPollHandler->delete($pollObject); |
|
602 | - if (false !== $status) { |
|
603 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
604 | - $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
605 | - $xpOptHandler->deleteByPollId($poll_id); |
|
606 | - $xpLogHandler->deleteByPollId($poll_id); |
|
607 | - } else { |
|
608 | - $msg = $xpPollHandler->getHtmlErrors(); |
|
609 | - } |
|
610 | - // old xoopspoll or umfrage or any clone from them |
|
611 | - } else { |
|
612 | - $status = $pollObject->delete(); |
|
613 | - $classOption = $classPoll . 'Option'; |
|
614 | - $classLog = $classPoll . 'Log'; |
|
615 | - if (false !== $status) { |
|
616 | - $classOption::deleteByPollId($poll_id); |
|
617 | - $classLog::deleteByPollId($poll_id); |
|
618 | - } else { |
|
619 | - $msg = $pollObject->getHtmlErrors(); |
|
620 | - } |
|
621 | - } |
|
622 | - if (false !== $status) { |
|
623 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
624 | - xoops_template_clear_module_cache($xoopsModule->getVar('mid')); |
|
625 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
626 | - // delete comments for this poll |
|
627 | - xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id); |
|
628 | - |
|
629 | - $topicObject->setVar('votes', 0); // not sure why we want to clear votes too... but I left it alone |
|
630 | - $topicObject->setVar('topic_haspoll', 0); |
|
631 | - $topicObject->setVar('poll_id', 0); |
|
632 | - $success = $topicHandler->insert($topicObject); |
|
633 | - if (!$success) { |
|
634 | - xoops_error($topicHandler->getHtmlErrors()); |
|
635 | - break; |
|
636 | - } |
|
637 | - } else { |
|
638 | - xoops_error($msg); |
|
639 | - break; |
|
640 | - } |
|
641 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
642 | - break; |
|
643 | - |
|
644 | - case 'restart': |
|
645 | - // new xoopspoll module |
|
646 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
647 | - $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
648 | - $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
|
649 | - // old xoopspoll or umfrage or any clone from them |
|
650 | - } else { |
|
651 | - $default_poll_duration = (86400 * 10); |
|
652 | - } |
|
653 | - $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true); |
|
654 | - $expire_text = new \XoopsFormText( |
|
655 | - _MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '<br>' . sprintf( |
|
656 | - _MD_NEWBB_POLL_EXPIREDAT, |
|
657 | - formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s') |
|
658 | - ) . '</small>', |
|
659 | - 'end_time', |
|
660 | - 20, |
|
661 | - 19, |
|
662 | - formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s') |
|
663 | - ); |
|
664 | - $poll_form->addElement($expire_text); |
|
665 | - $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1)); |
|
666 | - $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_RESET, 'reset', 0)); |
|
667 | - $poll_form->addElement(new \XoopsFormHidden('op', 'restart_ok')); |
|
668 | - $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
669 | - $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
670 | - $poll_form->addElement(new \XoopsFormButton('', 'poll_submit', _MD_NEWBB_POLL_RESTART, 'submit')); |
|
671 | - |
|
672 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
673 | - $poll_form->display(); |
|
674 | - break; |
|
675 | - |
|
676 | - case 'restart_ok': |
|
677 | - // check security token |
|
678 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
679 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
680 | - } |
|
681 | - |
|
682 | - // new xoopspoll module |
|
683 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
684 | - $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
685 | - $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
|
686 | - $poll_not_mailed = $classConstants::POLL_NOT_MAILED; |
|
687 | - $poll_mailed = $classConstants::POLL_MAILED; |
|
688 | - // old xoopspoll or umfrage or any clone from them |
|
689 | - } else { |
|
690 | - $default_poll_duration = (86400 * 10); |
|
691 | - $poll_not_mailed = Xoopspoll\Constants::POLL_NOT_MAILED; |
|
692 | - $poll_mailed = Xoopspoll\Constants::POLL_MAILED; |
|
693 | - } |
|
694 | - |
|
695 | - $end_time = !Request::getInt('end_time', 0, 'POST'); |
|
696 | - if (0 !== $end_time) { |
|
697 | - $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
698 | - $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
699 | - } else { |
|
700 | - $pollObject->setVar('end_time', time() + $default_poll_duration); |
|
701 | - } |
|
702 | - |
|
703 | - $isNotify = Request::getInt('notify', 0, 'POST'); |
|
704 | - if (!empty($isNotify) && ($end_time > time())) { |
|
705 | - // if notify, set mail status to "not mailed" |
|
706 | - $pollObject->setVar('mail_status', $poll_not_mailed); |
|
707 | - } else { |
|
708 | - // if not notify, set mail status to already "mailed" |
|
709 | - $pollObject->setVar('mail_status', $poll_mailed); |
|
710 | - } |
|
711 | - |
|
712 | - // new xoopspoll module |
|
713 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
714 | - if (!$xpPollHandler->insert($pollObject)) { // update the poll |
|
715 | - xoops_error($pollObject->getHtmlErrors()); |
|
716 | - exit(); |
|
717 | - } |
|
718 | - if (Request::getInt('reset', 0, 'POST')) { // reset all vote/voter counters |
|
719 | - /** @var Xoopspoll\OptionHandler $xpOptHandler */ |
|
720 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
721 | - /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
722 | - $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
723 | - $xpLogHandler->deleteByPollId($poll_id); |
|
724 | - $xpOptHandler->resetCountByPollId($poll_id); |
|
725 | - $xpPollHandler->updateCount($pollObject); |
|
726 | - } |
|
727 | - // old xoopspoll or umfrage or any clone from them |
|
728 | - } else { |
|
729 | - if (!$pollObject->store()) { // update the poll |
|
730 | - xoops_error($pollObject->getHtmlErrors()); |
|
731 | - exit(); |
|
732 | - } |
|
733 | - if (Request::getInt('reset', 0, 'POST')) { // reset all logs |
|
734 | - $classOption = $classPoll . 'Option'; |
|
735 | - $classLog = $classPoll . 'Log'; |
|
736 | - $classLog::deleteByPollId($poll_id); |
|
737 | - $classOption::resetCountByPollId($poll_id); |
|
738 | - $pollObject->updateCount(); |
|
739 | - } |
|
740 | - } |
|
741 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
742 | - xoops_template_clear_module_cache($xoopsModule->getVar('mid')); |
|
743 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
744 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
745 | - break; |
|
746 | - |
|
747 | - case 'log': |
|
748 | - // new xoopspoll module |
|
749 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
750 | - redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/main.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); |
|
751 | - // old xoopspoll or umfrage or any clone from them |
|
752 | - } else { |
|
753 | - redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/index.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); |
|
754 | - } |
|
755 | - break; |
|
264 | + $option_empty = true; |
|
265 | + if (!Request::getString('option_text', '', 'POST')) { |
|
266 | + // irmtfan - issue with javascript:history.go(-1) |
|
267 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
268 | + } |
|
269 | + $option_text = Request::getArray('option_text', '', 'POST'); |
|
270 | + foreach ($option_text as $optxt) { |
|
271 | + if ('' !== trim($optxt)) { |
|
272 | + $option_empty = false; |
|
273 | + break; |
|
274 | + } |
|
275 | + } |
|
276 | + if ($option_empty) { |
|
277 | + // irmtfan - issue with javascript:history.go(-1) |
|
278 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
279 | + } |
|
280 | + $pollObject->setVar('question', Request::getString('question', '', 'POST')); |
|
281 | + $pollObject->setVar('description', Request::getString('description', '', 'POST')); |
|
282 | + $end_time = Request::getString('end_time', '', 'POST'); // (empty($_POST['end_time'])) ? "" : $_POST['end_time']; |
|
283 | + if ('' !== $end_time) { |
|
284 | + $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
285 | + $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
286 | + } else { |
|
287 | + // if expiration date is not set, set it to 10 days from now |
|
288 | + $pollObject->setVar('end_time', time() + (86400 * 10)); |
|
289 | + } |
|
290 | + |
|
291 | + $pollObject->setVar('display', 0); |
|
292 | + $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST')); |
|
293 | + $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST')); |
|
294 | + $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST')); |
|
295 | + if (Request::getInt('notify', 0, 'POST') && $end_time > time()) { |
|
296 | + // if notify, set mail status to "not mailed" |
|
297 | + $pollObject->setVar('mail_status', Xoopspoll\Constants::POLL_NOT_MAILED); |
|
298 | + } else { |
|
299 | + // if not notify, set mail status to already "mailed" |
|
300 | + $pollObject->setVar('mail_status', Xoopspoll\Constants::POLL_MAILED); |
|
301 | + } |
|
302 | + $new_poll_id = $pollObject->store(); |
|
303 | + if (empty($new_poll_id)) { |
|
304 | + xoops_error($pollObject->getHtmlErrors); |
|
305 | + break; |
|
306 | + } |
|
307 | + $i = 0; |
|
308 | + $option_color = Request::getArray('option_color', null, 'POST'); |
|
309 | + $classOption = $classPoll . 'Option'; |
|
310 | + foreach ($option_text as $optxt) { |
|
311 | + $optxt = trim($optxt); |
|
312 | + /** @var Xoopspoll\Option $optionObject */ |
|
313 | + $optionObject = new $classOption(); |
|
314 | + if ('' !== $optxt) { |
|
315 | + $optionObject->setVar('option_text', $optxt); |
|
316 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
317 | + $optionObject->setVar('poll_id', $new_poll_id); |
|
318 | + $optionObject->store(); |
|
319 | + } |
|
320 | + ++$i; |
|
321 | + } |
|
322 | + // clear the template cache so changes take effect immediately |
|
323 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
324 | + xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
325 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
326 | + |
|
327 | + // update topic to indicate it has a poll |
|
328 | + $topicObject->setVar('topic_haspoll', 1); |
|
329 | + $topicObject->setVar('poll_id', $new_poll_id); |
|
330 | + $success = $topicHandler->insert($topicObject); |
|
331 | + if (!$success) { |
|
332 | + xoops_error($topicHandler->getHtmlErrors()); |
|
333 | + } else { |
|
334 | + redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
335 | + } |
|
336 | + break;// op: save |
|
337 | + } |
|
338 | + // no break |
|
339 | + case 'update': |
|
340 | + // check security token |
|
341 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
342 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
343 | + } |
|
344 | + /* make sure there's at least one option */ |
|
345 | + $option_text = Request::getString('option_text', '', 'POST'); |
|
346 | + $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; |
|
347 | + $option_string = trim($option_string); |
|
348 | + if ('' === $option_string) { |
|
349 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
350 | + } |
|
351 | + |
|
352 | + // new xoopspoll module |
|
353 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
354 | + /** @var Xoopspoll\OptionHandler $xpOptHandler */ |
|
355 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
356 | + /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
357 | + $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
358 | + // $classRequest = ucfirst($GLOBALS['xoopsModuleConfig']["poll_module"]) . "Request"; |
|
359 | + $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
360 | + $notify = Request::getInt('notify', $classConstants::NOTIFICATION_ENABLED, 'POST'); |
|
361 | + $currentTimestamp = time(); |
|
362 | + //$xuEndTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_end_time', null, 'POST')) |
|
363 | + // : strtotime(Request::getString('xu_end_time', null, 'POST')); |
|
364 | + $xuEndTimestamp = strtotime(Request::getString('xu_end_time', null, 'POST')); |
|
365 | + $endTimestamp = (!Request::getString('xu_end_time', null, 'POST')) ? ($currentTimestamp + $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp); |
|
366 | + //$xuStartTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_start_time', null, 'POST')) |
|
367 | + // : strtotime(Request::getString('xu_start_time', null, 'POST')); |
|
368 | + $xuStartTimestamp = strtotime(Request::getString('xu_start_time', null, 'POST')); |
|
369 | + $startTimestamp = (!Request::getString('xu_start_time', null, 'POST')) ? ($endTimestamp - $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp); |
|
370 | + |
|
371 | + // don't allow changing start time if there are votes in the log |
|
372 | + if (($startTimestamp < $pollObject->getVar('start_time')) |
|
373 | + && ($xpLogHandler->getTotalVotesByPollId($poll_id) > 0)) { |
|
374 | + $startTimestamp = $pollObject->getVar('start_time'); //don't change start time |
|
375 | + } |
|
376 | + |
|
377 | + $poll_vars = [ |
|
378 | + 'user_id' => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'), |
|
379 | + 'question' => Request::getString('question', null, 'POST'), |
|
380 | + 'description' => Request::getText('description', null, 'POST'), |
|
381 | + 'mail_status' => ($classConstants::NOTIFICATION_ENABLED == $notify) ? $classConstants::POLL_NOT_MAILED : $classConstants::POLL_MAILED, |
|
382 | + 'mail_voter' => Request::getInt('mail_voter', $classConstants::NOT_MAIL_POLL_TO_VOTER, 'POST'), |
|
383 | + 'start_time' => $startTimestamp, |
|
384 | + 'end_time' => $endTimestamp, |
|
385 | + 'display' => Request::getInt('display', $classConstants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'), |
|
386 | + 'visibility' => Request::getInt('visibility', $classConstants::HIDE_NEVER, 'POST'), |
|
387 | + 'weight' => Request::getInt('weight', $classConstants::DEFAULT_WEIGHT, 'POST'), |
|
388 | + 'multiple' => Request::getInt('multiple', $classConstants::NOT_MULTIPLE_SELECT_POLL, 'POST'), |
|
389 | + 'multilimit' => Request::getInt('multilimit', $classConstants::MULTIPLE_SELECT_LIMITLESS, 'POST'), |
|
390 | + 'anonymous' => Request::getInt('anonymous', $classConstants::ANONYMOUS_VOTING_DISALLOWED, 'POST') |
|
391 | + ]; |
|
392 | + $pollObject->setVars($poll_vars); |
|
393 | + $poll_id = $xpPollHandler->insert($pollObject); |
|
394 | + if (!$poll_id) { |
|
395 | + $err = $pollObject->getHtmlErrors(); |
|
396 | + exit($err); |
|
397 | + } |
|
398 | + |
|
399 | + // now get the options |
|
400 | + $optionIdArray = Request::getArray('option_id', [], 'POST'); |
|
401 | + $optionIdArray = array_map('intval', $optionIdArray); |
|
402 | + $optionTextArray = Request::getArray('option_text', [], 'POST'); |
|
403 | + $optionColorArray = Request::getArray('option_color', [], 'POST'); |
|
404 | + |
|
405 | + foreach ($optionIdArray as $key => $oId) { |
|
406 | + if (!empty($oId) && ($optionObject = $xpOptHandler->get($oId))) { |
|
407 | + // existing option object so need to update it |
|
408 | + $optionTextArray[$key] = trim($optionTextArray[$key]); |
|
409 | + if ('' === $optionTextArray[$key]) { |
|
410 | + // want to delete this option |
|
411 | + if (false !== $xpOptHandler->delete($optionObject)) { |
|
412 | + // now remove it from the log |
|
413 | + $xpLogHandler->deleteByOptionId($optionObject->getVar('option_id')); |
|
414 | + //update vote count in poll |
|
415 | + $xpPollHandler->updateCount($pollObject); |
|
416 | + } else { |
|
417 | + xoops_error($xpLogHandler->getHtmlErrors()); |
|
418 | + break; |
|
419 | + } |
|
420 | + } else { |
|
421 | + $optionObject->setVar('option_text', $optionTextArray[$key]); |
|
422 | + $optionObject->setVar('option_color', $optionColorArray[$key]); |
|
423 | + $optionObject->setVar('poll_id', $poll_id); |
|
424 | + $xpOptHandler->insert($optionObject); |
|
425 | + } |
|
426 | + } else { |
|
427 | + // new option object |
|
428 | + $optionObject = $xpOptHandler->create(); |
|
429 | + $optionTextArray[$key] = trim($optionTextArray[$key]); |
|
430 | + if ('' !== $optionTextArray[$key]) { // ignore if text is empty |
|
431 | + $optionObject->setVar('option_text', $optionTextArray[$key]); |
|
432 | + $optionObject->setVar('option_color', $optionColorArray[$key]); |
|
433 | + $optionObject->setVar('poll_id', $poll_id); |
|
434 | + $xpOptHandler->insert($optionObject); |
|
435 | + } |
|
436 | + unset($optionObject); |
|
437 | + } |
|
438 | + } |
|
439 | + // old xoopspoll or umfrage or any clone from them |
|
440 | + } else { |
|
441 | + $pollObject->setVar('question', Request::getString('question', '', 'POST')); |
|
442 | + $pollObject->setVar('description', Request::getString('description', '', 'POST')); |
|
443 | + |
|
444 | + $end_time = Request::getString('end_time', '', 'POST'); |
|
445 | + if ('' !== $end_time) { |
|
446 | + $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
447 | + $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
448 | + } |
|
449 | + $pollObject->setVar('display', 0); |
|
450 | + $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST')); |
|
451 | + $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST')); |
|
452 | + $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST')); |
|
453 | + if (Request::getInt('notify', 0, 'POST') && $end_time > time()) { |
|
454 | + // if notify, set mail status to "not mailed" |
|
455 | + $pollObject->setVar('mail_status', $classConstants::POLL_NOT_MAILED); |
|
456 | + } else { |
|
457 | + // if not notify, set mail status to already "mailed" |
|
458 | + $pollObject->setVar('mail_status', $classConstants::POLL_MAILED); |
|
459 | + } |
|
460 | + |
|
461 | + if (!$pollObject->store()) { |
|
462 | + xoops_error($pollObject->getHtmlErrors); |
|
463 | + break; |
|
464 | + } |
|
465 | + $i = 0; |
|
466 | + $option_id = Request::getArray('option_id', null, 'POST'); |
|
467 | + $option_color = Request::getArray('option_color', null, 'POST'); |
|
468 | + $classOption = $classPoll . 'Option'; |
|
469 | + $classLog = $classPoll . 'Log'; |
|
470 | + foreach ($option_id as $opid) { |
|
471 | + $optionObject = new $classOption($opid); |
|
472 | + $option_text[$i] = trim($option_text[$i]); |
|
473 | + if ('' !== $option_text[$i]) { |
|
474 | + $optionObject->setVar('option_text', $option_text[$i]); |
|
475 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
476 | + $optionObject->store(); |
|
477 | + } else { |
|
478 | + if (false !== $optionObject->delete()) { |
|
479 | + $classLog::deleteByOptionId($option->getVar('option_id')); |
|
480 | + } |
|
481 | + } |
|
482 | + ++$i; |
|
483 | + } |
|
484 | + $pollObject->updateCount(); |
|
485 | + } |
|
486 | + // clear the template cache so changes take effect immediately |
|
487 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
488 | + xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
489 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
490 | + |
|
491 | + // update topic to indicate it has a poll |
|
492 | + $topicObject->setVar('topic_haspoll', 1); |
|
493 | + $topicObject->setVar('poll_id', $pollObject->getVar('poll_id')); |
|
494 | + $success = $topicHandler->insert($topicObject); |
|
495 | + if (!$success) { |
|
496 | + xoops_error($topicHandler->getHtmlErrors()); |
|
497 | + } else { |
|
498 | + redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
499 | + } |
|
500 | + break;// op: save | update |
|
501 | + |
|
502 | + case 'addmore': |
|
503 | + $question = $pollObject->getVar('question'); |
|
504 | + unset($pollObject); |
|
505 | + $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_ADDMORE, 'poll_form', 'polls.php', 'post', true); |
|
506 | + $poll_form->addElement(new \XoopsFormLabel(_MD_NEWBB_POLL_POLLQUESTION, $question)); |
|
507 | + // new xoopspoll module |
|
508 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
509 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
510 | + $option_tray = $xpOptHandler->renderOptionFormTray($poll_id); |
|
511 | + // old xoopspoll or umfrage or any clone from them |
|
512 | + } else { |
|
513 | + $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
514 | + $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
515 | + for ($i = 0; $i < 10; ++$i) { |
|
516 | + $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
|
517 | + $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
|
518 | + $option_tray->addElement($option_text); |
|
519 | + $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
|
520 | + $color_select->addOptionArray($barcolor_array); |
|
521 | + $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
522 | + $color_label = new \XoopsFormLabel('', "<img src='" |
|
523 | + . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}") |
|
524 | + . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
525 | + $option_tray->addElement($color_select); |
|
526 | + $option_tray->addElement($color_label); |
|
527 | + unset($color_select, $color_label, $option_text); |
|
528 | + if (!next($barcolor_array)) { |
|
529 | + reset($barcolor_array); |
|
530 | + } |
|
531 | + } |
|
532 | + } |
|
533 | + $poll_form->addElement($option_tray); |
|
534 | + $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
535 | + $poll_form->addElement(new \XoopsFormHidden('op', 'savemore')); |
|
536 | + $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
537 | + $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
538 | + |
|
539 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
540 | + $poll_form->display(); |
|
541 | + break; |
|
542 | + |
|
543 | + case 'savemore': |
|
544 | + // check security token |
|
545 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
546 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
547 | + } |
|
548 | + |
|
549 | + $option_text = Request::getString('option_text', '', 'POST'); |
|
550 | + $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; |
|
551 | + $option_string = trim($option_string); |
|
552 | + if ('' === $option_string) { |
|
553 | + // irmtfan - issue with javascript:history.go(-1) |
|
554 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
555 | + } |
|
556 | + $i = 0; |
|
557 | + $option_color = Request::getArray('option_color', null, 'POST'); |
|
558 | + foreach ($option_text as $optxt) { |
|
559 | + $optxt = trim($optxt); |
|
560 | + if ('' !== $optxt) { |
|
561 | + // new xoopspoll module |
|
562 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
563 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
564 | + $optionObject = $xpOptHandler->create(); |
|
565 | + $optionObject->setVar('option_text', $optxt); |
|
566 | + $optionObject->setVar('poll_id', $poll_id); |
|
567 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
568 | + $xpOptHandler->insert($optionObject); |
|
569 | + // old xoopspoll or umfrage or any clone from them |
|
570 | + } else { |
|
571 | + $classOption = $classPoll . 'Option'; |
|
572 | + $optionObject = new $classOption(); |
|
573 | + $optionObject->setVar('option_text', $optxt); |
|
574 | + $optionObject->setVar('poll_id', $poll_id); |
|
575 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
576 | + $optionObject->store(); |
|
577 | + } |
|
578 | + unset($optionObject); |
|
579 | + } |
|
580 | + ++$i; |
|
581 | + } |
|
582 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
583 | + xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
584 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
585 | + redirect_header("polls.php?op=edit&poll_id={$poll_id}&topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
586 | + break; |
|
587 | + |
|
588 | + case 'delete': |
|
589 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
590 | + xoops_confirm(['op' => 'delete_ok', 'topic_id' => $topic_id, 'poll_id' => $poll_id], 'polls.php', sprintf(_MD_NEWBB_POLL_RUSUREDEL, $pollObject->getVar('question'))); |
|
591 | + break; |
|
592 | + |
|
593 | + case 'delete_ok': |
|
594 | + // check security token |
|
595 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
596 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
597 | + } |
|
598 | + //try and delete the poll |
|
599 | + // new xoopspoll module |
|
600 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
601 | + $status = $xpPollHandler->delete($pollObject); |
|
602 | + if (false !== $status) { |
|
603 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
604 | + $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
605 | + $xpOptHandler->deleteByPollId($poll_id); |
|
606 | + $xpLogHandler->deleteByPollId($poll_id); |
|
607 | + } else { |
|
608 | + $msg = $xpPollHandler->getHtmlErrors(); |
|
609 | + } |
|
610 | + // old xoopspoll or umfrage or any clone from them |
|
611 | + } else { |
|
612 | + $status = $pollObject->delete(); |
|
613 | + $classOption = $classPoll . 'Option'; |
|
614 | + $classLog = $classPoll . 'Log'; |
|
615 | + if (false !== $status) { |
|
616 | + $classOption::deleteByPollId($poll_id); |
|
617 | + $classLog::deleteByPollId($poll_id); |
|
618 | + } else { |
|
619 | + $msg = $pollObject->getHtmlErrors(); |
|
620 | + } |
|
621 | + } |
|
622 | + if (false !== $status) { |
|
623 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
624 | + xoops_template_clear_module_cache($xoopsModule->getVar('mid')); |
|
625 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
626 | + // delete comments for this poll |
|
627 | + xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id); |
|
628 | + |
|
629 | + $topicObject->setVar('votes', 0); // not sure why we want to clear votes too... but I left it alone |
|
630 | + $topicObject->setVar('topic_haspoll', 0); |
|
631 | + $topicObject->setVar('poll_id', 0); |
|
632 | + $success = $topicHandler->insert($topicObject); |
|
633 | + if (!$success) { |
|
634 | + xoops_error($topicHandler->getHtmlErrors()); |
|
635 | + break; |
|
636 | + } |
|
637 | + } else { |
|
638 | + xoops_error($msg); |
|
639 | + break; |
|
640 | + } |
|
641 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
642 | + break; |
|
643 | + |
|
644 | + case 'restart': |
|
645 | + // new xoopspoll module |
|
646 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
647 | + $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
648 | + $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
|
649 | + // old xoopspoll or umfrage or any clone from them |
|
650 | + } else { |
|
651 | + $default_poll_duration = (86400 * 10); |
|
652 | + } |
|
653 | + $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true); |
|
654 | + $expire_text = new \XoopsFormText( |
|
655 | + _MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '<br>' . sprintf( |
|
656 | + _MD_NEWBB_POLL_EXPIREDAT, |
|
657 | + formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s') |
|
658 | + ) . '</small>', |
|
659 | + 'end_time', |
|
660 | + 20, |
|
661 | + 19, |
|
662 | + formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s') |
|
663 | + ); |
|
664 | + $poll_form->addElement($expire_text); |
|
665 | + $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1)); |
|
666 | + $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_RESET, 'reset', 0)); |
|
667 | + $poll_form->addElement(new \XoopsFormHidden('op', 'restart_ok')); |
|
668 | + $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
669 | + $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
670 | + $poll_form->addElement(new \XoopsFormButton('', 'poll_submit', _MD_NEWBB_POLL_RESTART, 'submit')); |
|
671 | + |
|
672 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
673 | + $poll_form->display(); |
|
674 | + break; |
|
675 | + |
|
676 | + case 'restart_ok': |
|
677 | + // check security token |
|
678 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
679 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
680 | + } |
|
681 | + |
|
682 | + // new xoopspoll module |
|
683 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
684 | + $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
685 | + $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
|
686 | + $poll_not_mailed = $classConstants::POLL_NOT_MAILED; |
|
687 | + $poll_mailed = $classConstants::POLL_MAILED; |
|
688 | + // old xoopspoll or umfrage or any clone from them |
|
689 | + } else { |
|
690 | + $default_poll_duration = (86400 * 10); |
|
691 | + $poll_not_mailed = Xoopspoll\Constants::POLL_NOT_MAILED; |
|
692 | + $poll_mailed = Xoopspoll\Constants::POLL_MAILED; |
|
693 | + } |
|
694 | + |
|
695 | + $end_time = !Request::getInt('end_time', 0, 'POST'); |
|
696 | + if (0 !== $end_time) { |
|
697 | + $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
698 | + $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
699 | + } else { |
|
700 | + $pollObject->setVar('end_time', time() + $default_poll_duration); |
|
701 | + } |
|
702 | + |
|
703 | + $isNotify = Request::getInt('notify', 0, 'POST'); |
|
704 | + if (!empty($isNotify) && ($end_time > time())) { |
|
705 | + // if notify, set mail status to "not mailed" |
|
706 | + $pollObject->setVar('mail_status', $poll_not_mailed); |
|
707 | + } else { |
|
708 | + // if not notify, set mail status to already "mailed" |
|
709 | + $pollObject->setVar('mail_status', $poll_mailed); |
|
710 | + } |
|
711 | + |
|
712 | + // new xoopspoll module |
|
713 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
714 | + if (!$xpPollHandler->insert($pollObject)) { // update the poll |
|
715 | + xoops_error($pollObject->getHtmlErrors()); |
|
716 | + exit(); |
|
717 | + } |
|
718 | + if (Request::getInt('reset', 0, 'POST')) { // reset all vote/voter counters |
|
719 | + /** @var Xoopspoll\OptionHandler $xpOptHandler */ |
|
720 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
721 | + /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
722 | + $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
723 | + $xpLogHandler->deleteByPollId($poll_id); |
|
724 | + $xpOptHandler->resetCountByPollId($poll_id); |
|
725 | + $xpPollHandler->updateCount($pollObject); |
|
726 | + } |
|
727 | + // old xoopspoll or umfrage or any clone from them |
|
728 | + } else { |
|
729 | + if (!$pollObject->store()) { // update the poll |
|
730 | + xoops_error($pollObject->getHtmlErrors()); |
|
731 | + exit(); |
|
732 | + } |
|
733 | + if (Request::getInt('reset', 0, 'POST')) { // reset all logs |
|
734 | + $classOption = $classPoll . 'Option'; |
|
735 | + $classLog = $classPoll . 'Log'; |
|
736 | + $classLog::deleteByPollId($poll_id); |
|
737 | + $classOption::resetCountByPollId($poll_id); |
|
738 | + $pollObject->updateCount(); |
|
739 | + } |
|
740 | + } |
|
741 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
742 | + xoops_template_clear_module_cache($xoopsModule->getVar('mid')); |
|
743 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
744 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
745 | + break; |
|
746 | + |
|
747 | + case 'log': |
|
748 | + // new xoopspoll module |
|
749 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
750 | + redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/main.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); |
|
751 | + // old xoopspoll or umfrage or any clone from them |
|
752 | + } else { |
|
753 | + redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/index.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); |
|
754 | + } |
|
755 | + break; |
|
756 | 756 | } // switch |
757 | 757 | |
758 | 758 | // irmtfan move to footer.php |
@@ -111,648 +111,648 @@ |
||
111 | 111 | } |
112 | 112 | } |
113 | 113 | switch ($op) { |
114 | - case 'add': |
|
115 | - // new xoopspoll module |
|
116 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
117 | - echo '<h4>' . _MD_NEWBB_POLL_CREATNEWPOLL . "</h4>\n"; |
|
118 | - $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
|
119 | - // old xoopspoll or umfrage or any clone from them |
|
120 | - } else { |
|
121 | - $classOption = $classPoll . 'Option'; |
|
122 | - $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true); |
|
123 | - $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("<a href='" |
|
124 | - . XOOPS_URL |
|
125 | - . '/userinfo.php?uid=' |
|
126 | - . $GLOBALS['xoopsUser']->getVar('uid') |
|
127 | - . "'>" |
|
128 | - . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']) |
|
129 | - . '</a>') : $GLOBALS['xoopsConfig']['anonymous']); |
|
130 | - $poll_form->addElement($author_label); |
|
131 | - $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255); |
|
132 | - $poll_form->addElement($question_text); |
|
133 | - $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description'); |
|
134 | - $poll_form->addElement($desc_tarea); |
|
135 | - $currenttime = formatTimestamp(time(), 'Y-m-d H:i:s'); |
|
136 | - $endtime = formatTimestamp(time() + 604800, 'Y-m-d H:i:s'); |
|
137 | - $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, $currenttime) . '</small>', 'end_time', 30, 19, $endtime); |
|
138 | - $poll_form->addElement($expire_text); |
|
139 | - |
|
140 | - $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, 0); |
|
141 | - $poll_form->addElement($weight_text); |
|
142 | - |
|
143 | - $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', 0); |
|
144 | - $poll_form->addElement($multi_yn); |
|
145 | - |
|
146 | - $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1); |
|
147 | - $poll_form->addElement($notify_yn); |
|
148 | - |
|
149 | - $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
150 | - $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
151 | - for ($i = 0; $i < 10; ++$i) { |
|
152 | - $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
|
153 | - $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
|
154 | - $option_tray->addElement($option_text); |
|
155 | - $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
|
156 | - $color_select->addOptionArray($barcolor_array); |
|
157 | - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'"); |
|
158 | - $color_label = new \XoopsFormLabel('', "<img src='" |
|
159 | - . XOOPS_URL |
|
160 | - . '/modules/' |
|
161 | - . $GLOBALS['xoopsModuleConfig']['poll_module'] |
|
162 | - . '/assets/images/colorbars/' |
|
163 | - . $current_bar |
|
164 | - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' width='30' align='bottom' height='15' alt='' /><br>"); |
|
165 | - $option_tray->addElement($color_select); |
|
166 | - $option_tray->addElement($color_label); |
|
167 | - if (!next($barcolor_array)) { |
|
168 | - reset($barcolor_array); |
|
169 | - } |
|
170 | - unset($color_select, $color_label); |
|
171 | - } |
|
172 | - $poll_form->addElement($option_tray); |
|
173 | - |
|
174 | - $poll_form->addElement(new \XoopsFormHidden('op', 'save')); |
|
175 | - $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
176 | - $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
177 | - $poll_form->addElement(new \XoopsFormHidden('user_id', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0)); |
|
178 | - $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
179 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . '</h4>'; |
|
180 | - $poll_form->display(); |
|
181 | - } |
|
182 | - break; // op: add |
|
183 | - |
|
184 | - case 'edit': |
|
185 | - // new xoopspoll module |
|
186 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
187 | - echo '<h4>' . _MD_NEWBB_POLL_EDITPOLL . "</h4>\n"; |
|
188 | - $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
|
189 | - // old xoopspoll or umfrage or any clone from them |
|
190 | - } else { |
|
191 | - $classOption = $classPoll . 'Option'; |
|
192 | - $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_EDITPOLL, 'poll_form', 'polls.php', 'post', true); |
|
193 | - $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $pollObject->getVar('user_id') . "'>" . newbbGetUnameFromId($pollObject->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']) . '</a>'); |
|
194 | - $poll_form->addElement($author_label); |
|
195 | - $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255, $pollObject->getVar('question', 'E')); |
|
196 | - $poll_form->addElement($question_text); |
|
197 | - $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description', $pollObject->getVar('description', 'E')); |
|
198 | - $poll_form->addElement($desc_tarea); |
|
199 | - $date = formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s'); // important "Y-m-d H:i:s" use in jdf function |
|
200 | - if (!$pollObject->hasExpired()) { |
|
201 | - $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '</small>', 'end_time', 20, 19, $date); |
|
202 | - $poll_form->addElement($expire_text); |
|
203 | - } else { |
|
204 | - // irmtfan full URL - add topic_id |
|
205 | - $restart_label = new \XoopsFormLabel( |
|
206 | - _MD_NEWBB_POLL_EXPIRATION, |
|
207 | - sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=restart&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . '</a>' |
|
208 | - ); |
|
209 | - $poll_form->addElement($restart_label); |
|
210 | - } |
|
211 | - $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, $pollObject->getVar('weight')); |
|
212 | - $poll_form->addElement($weight_text); |
|
213 | - $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', $pollObject->getVar('multiple')); |
|
214 | - $poll_form->addElement($multi_yn); |
|
215 | - $options_arr =& $classOption::getAllByPollId($poll_id); |
|
216 | - $notify_value = 1; |
|
217 | - if (0 !== $pollObject->getVar('mail_status')) { |
|
218 | - $notify_value = 0; |
|
219 | - } |
|
220 | - $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', $notify_value); |
|
221 | - $poll_form->addElement($notify_yn); |
|
222 | - $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
223 | - $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/")); |
|
224 | - $i = 0; |
|
225 | - foreach ($options_arr as $option) { |
|
226 | - /** @var \XoopsPoll $option */ |
|
227 | - $option_tray->addElement(new \XoopsFormText('', 'option_text[]', 50, 255, $option->getVar('option_text'))); |
|
228 | - $option_tray->addElement(new \XoopsFormHidden('option_id[]', $option->getVar('option_id'))); |
|
229 | - $color_select = new \XoopsFormSelect('', 'option_color[{$i}]', $option->getVar('option_color')); |
|
230 | - $color_select->addOptionArray($barcolor_array); |
|
231 | - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
232 | - $color_label = new \XoopsFormLabel('', "<img src='" |
|
233 | - . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) |
|
234 | - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
235 | - $option_tray->addElement($color_select); |
|
236 | - $option_tray->addElement($color_label); |
|
237 | - unset($color_select, $color_label); |
|
238 | - ++$i; |
|
239 | - } |
|
240 | - // irmtfan full URL |
|
241 | - $more_label = new \XoopsFormLabel('', "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=addmore&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_ADDMORE . '</a>'); |
|
242 | - $option_tray->addElement($more_label); |
|
243 | - $poll_form->addElement($option_tray); |
|
244 | - $poll_form->addElement(new \XoopsFormHidden('op', 'update')); |
|
245 | - $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
246 | - $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
247 | - $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
248 | - |
|
249 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
250 | - $poll_form->display(); |
|
251 | - } |
|
252 | - break; // op: edit |
|
253 | - |
|
254 | - case 'save': |
|
255 | - // old xoopspoll or umfrage or any clone from them |
|
256 | - if ($pollModuleHandler->getVar('version') < 140) { |
|
257 | - // check security token |
|
258 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
259 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
260 | - } |
|
261 | - /* |
|
114 | + case 'add': |
|
115 | + // new xoopspoll module |
|
116 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
117 | + echo '<h4>' . _MD_NEWBB_POLL_CREATNEWPOLL . "</h4>\n"; |
|
118 | + $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
|
119 | + // old xoopspoll or umfrage or any clone from them |
|
120 | + } else { |
|
121 | + $classOption = $classPoll . 'Option'; |
|
122 | + $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true); |
|
123 | + $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("<a href='" |
|
124 | + . XOOPS_URL |
|
125 | + . '/userinfo.php?uid=' |
|
126 | + . $GLOBALS['xoopsUser']->getVar('uid') |
|
127 | + . "'>" |
|
128 | + . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']) |
|
129 | + . '</a>') : $GLOBALS['xoopsConfig']['anonymous']); |
|
130 | + $poll_form->addElement($author_label); |
|
131 | + $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255); |
|
132 | + $poll_form->addElement($question_text); |
|
133 | + $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description'); |
|
134 | + $poll_form->addElement($desc_tarea); |
|
135 | + $currenttime = formatTimestamp(time(), 'Y-m-d H:i:s'); |
|
136 | + $endtime = formatTimestamp(time() + 604800, 'Y-m-d H:i:s'); |
|
137 | + $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, $currenttime) . '</small>', 'end_time', 30, 19, $endtime); |
|
138 | + $poll_form->addElement($expire_text); |
|
139 | + |
|
140 | + $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, 0); |
|
141 | + $poll_form->addElement($weight_text); |
|
142 | + |
|
143 | + $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', 0); |
|
144 | + $poll_form->addElement($multi_yn); |
|
145 | + |
|
146 | + $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1); |
|
147 | + $poll_form->addElement($notify_yn); |
|
148 | + |
|
149 | + $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
150 | + $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
151 | + for ($i = 0; $i < 10; ++$i) { |
|
152 | + $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
|
153 | + $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
|
154 | + $option_tray->addElement($option_text); |
|
155 | + $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
|
156 | + $color_select->addOptionArray($barcolor_array); |
|
157 | + $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'"); |
|
158 | + $color_label = new \XoopsFormLabel('', "<img src='" |
|
159 | + . XOOPS_URL |
|
160 | + . '/modules/' |
|
161 | + . $GLOBALS['xoopsModuleConfig']['poll_module'] |
|
162 | + . '/assets/images/colorbars/' |
|
163 | + . $current_bar |
|
164 | + . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' width='30' align='bottom' height='15' alt='' /><br>"); |
|
165 | + $option_tray->addElement($color_select); |
|
166 | + $option_tray->addElement($color_label); |
|
167 | + if (!next($barcolor_array)) { |
|
168 | + reset($barcolor_array); |
|
169 | + } |
|
170 | + unset($color_select, $color_label); |
|
171 | + } |
|
172 | + $poll_form->addElement($option_tray); |
|
173 | + |
|
174 | + $poll_form->addElement(new \XoopsFormHidden('op', 'save')); |
|
175 | + $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
176 | + $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
177 | + $poll_form->addElement(new \XoopsFormHidden('user_id', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0)); |
|
178 | + $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
179 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . '</h4>'; |
|
180 | + $poll_form->display(); |
|
181 | + } |
|
182 | + break; // op: add |
|
183 | + |
|
184 | + case 'edit': |
|
185 | + // new xoopspoll module |
|
186 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
187 | + echo '<h4>' . _MD_NEWBB_POLL_EDITPOLL . "</h4>\n"; |
|
188 | + $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
|
189 | + // old xoopspoll or umfrage or any clone from them |
|
190 | + } else { |
|
191 | + $classOption = $classPoll . 'Option'; |
|
192 | + $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_EDITPOLL, 'poll_form', 'polls.php', 'post', true); |
|
193 | + $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $pollObject->getVar('user_id') . "'>" . newbbGetUnameFromId($pollObject->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']) . '</a>'); |
|
194 | + $poll_form->addElement($author_label); |
|
195 | + $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255, $pollObject->getVar('question', 'E')); |
|
196 | + $poll_form->addElement($question_text); |
|
197 | + $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description', $pollObject->getVar('description', 'E')); |
|
198 | + $poll_form->addElement($desc_tarea); |
|
199 | + $date = formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s'); // important "Y-m-d H:i:s" use in jdf function |
|
200 | + if (!$pollObject->hasExpired()) { |
|
201 | + $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '</small>', 'end_time', 20, 19, $date); |
|
202 | + $poll_form->addElement($expire_text); |
|
203 | + } else { |
|
204 | + // irmtfan full URL - add topic_id |
|
205 | + $restart_label = new \XoopsFormLabel( |
|
206 | + _MD_NEWBB_POLL_EXPIRATION, |
|
207 | + sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=restart&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . '</a>' |
|
208 | + ); |
|
209 | + $poll_form->addElement($restart_label); |
|
210 | + } |
|
211 | + $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, $pollObject->getVar('weight')); |
|
212 | + $poll_form->addElement($weight_text); |
|
213 | + $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', $pollObject->getVar('multiple')); |
|
214 | + $poll_form->addElement($multi_yn); |
|
215 | + $options_arr =& $classOption::getAllByPollId($poll_id); |
|
216 | + $notify_value = 1; |
|
217 | + if (0 !== $pollObject->getVar('mail_status')) { |
|
218 | + $notify_value = 0; |
|
219 | + } |
|
220 | + $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', $notify_value); |
|
221 | + $poll_form->addElement($notify_yn); |
|
222 | + $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
223 | + $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/")); |
|
224 | + $i = 0; |
|
225 | + foreach ($options_arr as $option) { |
|
226 | + /** @var \XoopsPoll $option */ |
|
227 | + $option_tray->addElement(new \XoopsFormText('', 'option_text[]', 50, 255, $option->getVar('option_text'))); |
|
228 | + $option_tray->addElement(new \XoopsFormHidden('option_id[]', $option->getVar('option_id'))); |
|
229 | + $color_select = new \XoopsFormSelect('', 'option_color[{$i}]', $option->getVar('option_color')); |
|
230 | + $color_select->addOptionArray($barcolor_array); |
|
231 | + $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
232 | + $color_label = new \XoopsFormLabel('', "<img src='" |
|
233 | + . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) |
|
234 | + . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
235 | + $option_tray->addElement($color_select); |
|
236 | + $option_tray->addElement($color_label); |
|
237 | + unset($color_select, $color_label); |
|
238 | + ++$i; |
|
239 | + } |
|
240 | + // irmtfan full URL |
|
241 | + $more_label = new \XoopsFormLabel('', "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=addmore&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_ADDMORE . '</a>'); |
|
242 | + $option_tray->addElement($more_label); |
|
243 | + $poll_form->addElement($option_tray); |
|
244 | + $poll_form->addElement(new \XoopsFormHidden('op', 'update')); |
|
245 | + $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
246 | + $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
247 | + $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
248 | + |
|
249 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
250 | + $poll_form->display(); |
|
251 | + } |
|
252 | + break; // op: edit |
|
253 | + |
|
254 | + case 'save': |
|
255 | + // old xoopspoll or umfrage or any clone from them |
|
256 | + if ($pollModuleHandler->getVar('version') < 140) { |
|
257 | + // check security token |
|
258 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
259 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
260 | + } |
|
261 | + /* |
|
262 | 262 | * The option check should be done before submitting |
263 | 263 | */ |
264 | - $option_empty = true; |
|
265 | - if (!Request::getString('option_text', '', 'POST')) { |
|
266 | - // irmtfan - issue with javascript:history.go(-1) |
|
267 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
268 | - } |
|
269 | - $option_text = Request::getArray('option_text', '', 'POST'); |
|
270 | - foreach ($option_text as $optxt) { |
|
271 | - if ('' !== trim($optxt)) { |
|
272 | - $option_empty = false; |
|
273 | - break; |
|
274 | - } |
|
275 | - } |
|
276 | - if ($option_empty) { |
|
277 | - // irmtfan - issue with javascript:history.go(-1) |
|
278 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
279 | - } |
|
280 | - $pollObject->setVar('question', Request::getString('question', '', 'POST')); |
|
281 | - $pollObject->setVar('description', Request::getString('description', '', 'POST')); |
|
282 | - $end_time = Request::getString('end_time', '', 'POST'); // (empty($_POST['end_time'])) ? "" : $_POST['end_time']; |
|
283 | - if ('' !== $end_time) { |
|
284 | - $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
285 | - $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
286 | - } else { |
|
287 | - // if expiration date is not set, set it to 10 days from now |
|
288 | - $pollObject->setVar('end_time', time() + (86400 * 10)); |
|
289 | - } |
|
290 | - |
|
291 | - $pollObject->setVar('display', 0); |
|
292 | - $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST')); |
|
293 | - $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST')); |
|
294 | - $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST')); |
|
295 | - if (Request::getInt('notify', 0, 'POST') && $end_time > time()) { |
|
296 | - // if notify, set mail status to "not mailed" |
|
297 | - $pollObject->setVar('mail_status', Xoopspoll\Constants::POLL_NOT_MAILED); |
|
298 | - } else { |
|
299 | - // if not notify, set mail status to already "mailed" |
|
300 | - $pollObject->setVar('mail_status', Xoopspoll\Constants::POLL_MAILED); |
|
301 | - } |
|
302 | - $new_poll_id = $pollObject->store(); |
|
303 | - if (empty($new_poll_id)) { |
|
304 | - xoops_error($pollObject->getHtmlErrors); |
|
305 | - break; |
|
306 | - } |
|
307 | - $i = 0; |
|
308 | - $option_color = Request::getArray('option_color', null, 'POST'); |
|
309 | - $classOption = $classPoll . 'Option'; |
|
310 | - foreach ($option_text as $optxt) { |
|
311 | - $optxt = trim($optxt); |
|
312 | - /** @var Xoopspoll\Option $optionObject */ |
|
313 | - $optionObject = new $classOption(); |
|
314 | - if ('' !== $optxt) { |
|
315 | - $optionObject->setVar('option_text', $optxt); |
|
316 | - $optionObject->setVar('option_color', $option_color[$i]); |
|
317 | - $optionObject->setVar('poll_id', $new_poll_id); |
|
318 | - $optionObject->store(); |
|
319 | - } |
|
320 | - ++$i; |
|
321 | - } |
|
322 | - // clear the template cache so changes take effect immediately |
|
323 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
324 | - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
325 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
326 | - |
|
327 | - // update topic to indicate it has a poll |
|
328 | - $topicObject->setVar('topic_haspoll', 1); |
|
329 | - $topicObject->setVar('poll_id', $new_poll_id); |
|
330 | - $success = $topicHandler->insert($topicObject); |
|
331 | - if (!$success) { |
|
332 | - xoops_error($topicHandler->getHtmlErrors()); |
|
333 | - } else { |
|
334 | - redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
335 | - } |
|
336 | - break;// op: save |
|
337 | - } |
|
338 | - // no break |
|
339 | - case 'update': |
|
340 | - // check security token |
|
341 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
342 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
343 | - } |
|
344 | - /* make sure there's at least one option */ |
|
345 | - $option_text = Request::getString('option_text', '', 'POST'); |
|
346 | - $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; |
|
347 | - $option_string = trim($option_string); |
|
348 | - if ('' === $option_string) { |
|
349 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
350 | - } |
|
351 | - |
|
352 | - // new xoopspoll module |
|
353 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
354 | - /** @var Xoopspoll\OptionHandler $xpOptHandler */ |
|
355 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
356 | - /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
357 | - $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
358 | - // $classRequest = ucfirst($GLOBALS['xoopsModuleConfig']["poll_module"]) . "Request"; |
|
359 | - $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
360 | - $notify = Request::getInt('notify', $classConstants::NOTIFICATION_ENABLED, 'POST'); |
|
361 | - $currentTimestamp = time(); |
|
362 | - //$xuEndTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_end_time', null, 'POST')) |
|
363 | - // : strtotime(Request::getString('xu_end_time', null, 'POST')); |
|
364 | - $xuEndTimestamp = strtotime(Request::getString('xu_end_time', null, 'POST')); |
|
365 | - $endTimestamp = (!Request::getString('xu_end_time', null, 'POST')) ? ($currentTimestamp + $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp); |
|
366 | - //$xuStartTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_start_time', null, 'POST')) |
|
367 | - // : strtotime(Request::getString('xu_start_time', null, 'POST')); |
|
368 | - $xuStartTimestamp = strtotime(Request::getString('xu_start_time', null, 'POST')); |
|
369 | - $startTimestamp = (!Request::getString('xu_start_time', null, 'POST')) ? ($endTimestamp - $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp); |
|
370 | - |
|
371 | - // don't allow changing start time if there are votes in the log |
|
372 | - if (($startTimestamp < $pollObject->getVar('start_time')) |
|
373 | - && ($xpLogHandler->getTotalVotesByPollId($poll_id) > 0)) { |
|
374 | - $startTimestamp = $pollObject->getVar('start_time'); //don't change start time |
|
375 | - } |
|
376 | - |
|
377 | - $poll_vars = [ |
|
378 | - 'user_id' => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'), |
|
379 | - 'question' => Request::getString('question', null, 'POST'), |
|
380 | - 'description' => Request::getText('description', null, 'POST'), |
|
381 | - 'mail_status' => ($classConstants::NOTIFICATION_ENABLED == $notify) ? $classConstants::POLL_NOT_MAILED : $classConstants::POLL_MAILED, |
|
382 | - 'mail_voter' => Request::getInt('mail_voter', $classConstants::NOT_MAIL_POLL_TO_VOTER, 'POST'), |
|
383 | - 'start_time' => $startTimestamp, |
|
384 | - 'end_time' => $endTimestamp, |
|
385 | - 'display' => Request::getInt('display', $classConstants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'), |
|
386 | - 'visibility' => Request::getInt('visibility', $classConstants::HIDE_NEVER, 'POST'), |
|
387 | - 'weight' => Request::getInt('weight', $classConstants::DEFAULT_WEIGHT, 'POST'), |
|
388 | - 'multiple' => Request::getInt('multiple', $classConstants::NOT_MULTIPLE_SELECT_POLL, 'POST'), |
|
389 | - 'multilimit' => Request::getInt('multilimit', $classConstants::MULTIPLE_SELECT_LIMITLESS, 'POST'), |
|
390 | - 'anonymous' => Request::getInt('anonymous', $classConstants::ANONYMOUS_VOTING_DISALLOWED, 'POST') |
|
391 | - ]; |
|
392 | - $pollObject->setVars($poll_vars); |
|
393 | - $poll_id = $xpPollHandler->insert($pollObject); |
|
394 | - if (!$poll_id) { |
|
395 | - $err = $pollObject->getHtmlErrors(); |
|
396 | - exit($err); |
|
397 | - } |
|
398 | - |
|
399 | - // now get the options |
|
400 | - $optionIdArray = Request::getArray('option_id', [], 'POST'); |
|
401 | - $optionIdArray = array_map('intval', $optionIdArray); |
|
402 | - $optionTextArray = Request::getArray('option_text', [], 'POST'); |
|
403 | - $optionColorArray = Request::getArray('option_color', [], 'POST'); |
|
404 | - |
|
405 | - foreach ($optionIdArray as $key => $oId) { |
|
406 | - if (!empty($oId) && ($optionObject = $xpOptHandler->get($oId))) { |
|
407 | - // existing option object so need to update it |
|
408 | - $optionTextArray[$key] = trim($optionTextArray[$key]); |
|
409 | - if ('' === $optionTextArray[$key]) { |
|
410 | - // want to delete this option |
|
411 | - if (false !== $xpOptHandler->delete($optionObject)) { |
|
412 | - // now remove it from the log |
|
413 | - $xpLogHandler->deleteByOptionId($optionObject->getVar('option_id')); |
|
414 | - //update vote count in poll |
|
415 | - $xpPollHandler->updateCount($pollObject); |
|
416 | - } else { |
|
417 | - xoops_error($xpLogHandler->getHtmlErrors()); |
|
418 | - break; |
|
419 | - } |
|
420 | - } else { |
|
421 | - $optionObject->setVar('option_text', $optionTextArray[$key]); |
|
422 | - $optionObject->setVar('option_color', $optionColorArray[$key]); |
|
423 | - $optionObject->setVar('poll_id', $poll_id); |
|
424 | - $xpOptHandler->insert($optionObject); |
|
425 | - } |
|
426 | - } else { |
|
427 | - // new option object |
|
428 | - $optionObject = $xpOptHandler->create(); |
|
429 | - $optionTextArray[$key] = trim($optionTextArray[$key]); |
|
430 | - if ('' !== $optionTextArray[$key]) { // ignore if text is empty |
|
431 | - $optionObject->setVar('option_text', $optionTextArray[$key]); |
|
432 | - $optionObject->setVar('option_color', $optionColorArray[$key]); |
|
433 | - $optionObject->setVar('poll_id', $poll_id); |
|
434 | - $xpOptHandler->insert($optionObject); |
|
435 | - } |
|
436 | - unset($optionObject); |
|
437 | - } |
|
438 | - } |
|
439 | - // old xoopspoll or umfrage or any clone from them |
|
440 | - } else { |
|
441 | - $pollObject->setVar('question', Request::getString('question', '', 'POST')); |
|
442 | - $pollObject->setVar('description', Request::getString('description', '', 'POST')); |
|
443 | - |
|
444 | - $end_time = Request::getString('end_time', '', 'POST'); |
|
445 | - if ('' !== $end_time) { |
|
446 | - $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
447 | - $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
448 | - } |
|
449 | - $pollObject->setVar('display', 0); |
|
450 | - $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST')); |
|
451 | - $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST')); |
|
452 | - $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST')); |
|
453 | - if (Request::getInt('notify', 0, 'POST') && $end_time > time()) { |
|
454 | - // if notify, set mail status to "not mailed" |
|
455 | - $pollObject->setVar('mail_status', $classConstants::POLL_NOT_MAILED); |
|
456 | - } else { |
|
457 | - // if not notify, set mail status to already "mailed" |
|
458 | - $pollObject->setVar('mail_status', $classConstants::POLL_MAILED); |
|
459 | - } |
|
460 | - |
|
461 | - if (!$pollObject->store()) { |
|
462 | - xoops_error($pollObject->getHtmlErrors); |
|
463 | - break; |
|
464 | - } |
|
465 | - $i = 0; |
|
466 | - $option_id = Request::getArray('option_id', null, 'POST'); |
|
467 | - $option_color = Request::getArray('option_color', null, 'POST'); |
|
468 | - $classOption = $classPoll . 'Option'; |
|
469 | - $classLog = $classPoll . 'Log'; |
|
470 | - foreach ($option_id as $opid) { |
|
471 | - $optionObject = new $classOption($opid); |
|
472 | - $option_text[$i] = trim($option_text[$i]); |
|
473 | - if ('' !== $option_text[$i]) { |
|
474 | - $optionObject->setVar('option_text', $option_text[$i]); |
|
475 | - $optionObject->setVar('option_color', $option_color[$i]); |
|
476 | - $optionObject->store(); |
|
477 | - } else { |
|
478 | - if (false !== $optionObject->delete()) { |
|
479 | - $classLog::deleteByOptionId($option->getVar('option_id')); |
|
480 | - } |
|
481 | - } |
|
482 | - ++$i; |
|
483 | - } |
|
484 | - $pollObject->updateCount(); |
|
485 | - } |
|
486 | - // clear the template cache so changes take effect immediately |
|
487 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
488 | - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
489 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
490 | - |
|
491 | - // update topic to indicate it has a poll |
|
492 | - $topicObject->setVar('topic_haspoll', 1); |
|
493 | - $topicObject->setVar('poll_id', $pollObject->getVar('poll_id')); |
|
494 | - $success = $topicHandler->insert($topicObject); |
|
495 | - if (!$success) { |
|
496 | - xoops_error($topicHandler->getHtmlErrors()); |
|
497 | - } else { |
|
498 | - redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
499 | - } |
|
500 | - break;// op: save | update |
|
501 | - |
|
502 | - case 'addmore': |
|
503 | - $question = $pollObject->getVar('question'); |
|
504 | - unset($pollObject); |
|
505 | - $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_ADDMORE, 'poll_form', 'polls.php', 'post', true); |
|
506 | - $poll_form->addElement(new \XoopsFormLabel(_MD_NEWBB_POLL_POLLQUESTION, $question)); |
|
507 | - // new xoopspoll module |
|
508 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
509 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
510 | - $option_tray = $xpOptHandler->renderOptionFormTray($poll_id); |
|
511 | - // old xoopspoll or umfrage or any clone from them |
|
512 | - } else { |
|
513 | - $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
514 | - $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
515 | - for ($i = 0; $i < 10; ++$i) { |
|
516 | - $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
|
517 | - $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
|
518 | - $option_tray->addElement($option_text); |
|
519 | - $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
|
520 | - $color_select->addOptionArray($barcolor_array); |
|
521 | - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
522 | - $color_label = new \XoopsFormLabel('', "<img src='" |
|
523 | - . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}") |
|
524 | - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
525 | - $option_tray->addElement($color_select); |
|
526 | - $option_tray->addElement($color_label); |
|
527 | - unset($color_select, $color_label, $option_text); |
|
528 | - if (!next($barcolor_array)) { |
|
529 | - reset($barcolor_array); |
|
530 | - } |
|
531 | - } |
|
532 | - } |
|
533 | - $poll_form->addElement($option_tray); |
|
534 | - $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
535 | - $poll_form->addElement(new \XoopsFormHidden('op', 'savemore')); |
|
536 | - $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
537 | - $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
538 | - |
|
539 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
540 | - $poll_form->display(); |
|
541 | - break; |
|
542 | - |
|
543 | - case 'savemore': |
|
544 | - // check security token |
|
545 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
546 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
547 | - } |
|
548 | - |
|
549 | - $option_text = Request::getString('option_text', '', 'POST'); |
|
550 | - $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; |
|
551 | - $option_string = trim($option_string); |
|
552 | - if ('' === $option_string) { |
|
553 | - // irmtfan - issue with javascript:history.go(-1) |
|
554 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
555 | - } |
|
556 | - $i = 0; |
|
557 | - $option_color = Request::getArray('option_color', null, 'POST'); |
|
558 | - foreach ($option_text as $optxt) { |
|
559 | - $optxt = trim($optxt); |
|
560 | - if ('' !== $optxt) { |
|
561 | - // new xoopspoll module |
|
562 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
563 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
564 | - $optionObject = $xpOptHandler->create(); |
|
565 | - $optionObject->setVar('option_text', $optxt); |
|
566 | - $optionObject->setVar('poll_id', $poll_id); |
|
567 | - $optionObject->setVar('option_color', $option_color[$i]); |
|
568 | - $xpOptHandler->insert($optionObject); |
|
569 | - // old xoopspoll or umfrage or any clone from them |
|
570 | - } else { |
|
571 | - $classOption = $classPoll . 'Option'; |
|
572 | - $optionObject = new $classOption(); |
|
573 | - $optionObject->setVar('option_text', $optxt); |
|
574 | - $optionObject->setVar('poll_id', $poll_id); |
|
575 | - $optionObject->setVar('option_color', $option_color[$i]); |
|
576 | - $optionObject->store(); |
|
577 | - } |
|
578 | - unset($optionObject); |
|
579 | - } |
|
580 | - ++$i; |
|
581 | - } |
|
582 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
583 | - xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
584 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
585 | - redirect_header("polls.php?op=edit&poll_id={$poll_id}&topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
586 | - break; |
|
587 | - |
|
588 | - case 'delete': |
|
589 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
590 | - xoops_confirm(['op' => 'delete_ok', 'topic_id' => $topic_id, 'poll_id' => $poll_id], 'polls.php', sprintf(_MD_NEWBB_POLL_RUSUREDEL, $pollObject->getVar('question'))); |
|
591 | - break; |
|
592 | - |
|
593 | - case 'delete_ok': |
|
594 | - // check security token |
|
595 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
596 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
597 | - } |
|
598 | - //try and delete the poll |
|
599 | - // new xoopspoll module |
|
600 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
601 | - $status = $xpPollHandler->delete($pollObject); |
|
602 | - if (false !== $status) { |
|
603 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
604 | - $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
605 | - $xpOptHandler->deleteByPollId($poll_id); |
|
606 | - $xpLogHandler->deleteByPollId($poll_id); |
|
607 | - } else { |
|
608 | - $msg = $xpPollHandler->getHtmlErrors(); |
|
609 | - } |
|
610 | - // old xoopspoll or umfrage or any clone from them |
|
611 | - } else { |
|
612 | - $status = $pollObject->delete(); |
|
613 | - $classOption = $classPoll . 'Option'; |
|
614 | - $classLog = $classPoll . 'Log'; |
|
615 | - if (false !== $status) { |
|
616 | - $classOption::deleteByPollId($poll_id); |
|
617 | - $classLog::deleteByPollId($poll_id); |
|
618 | - } else { |
|
619 | - $msg = $pollObject->getHtmlErrors(); |
|
620 | - } |
|
621 | - } |
|
622 | - if (false !== $status) { |
|
623 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
624 | - xoops_template_clear_module_cache($xoopsModule->getVar('mid')); |
|
625 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
626 | - // delete comments for this poll |
|
627 | - xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id); |
|
628 | - |
|
629 | - $topicObject->setVar('votes', 0); // not sure why we want to clear votes too... but I left it alone |
|
630 | - $topicObject->setVar('topic_haspoll', 0); |
|
631 | - $topicObject->setVar('poll_id', 0); |
|
632 | - $success = $topicHandler->insert($topicObject); |
|
633 | - if (!$success) { |
|
634 | - xoops_error($topicHandler->getHtmlErrors()); |
|
635 | - break; |
|
636 | - } |
|
637 | - } else { |
|
638 | - xoops_error($msg); |
|
639 | - break; |
|
640 | - } |
|
641 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
642 | - break; |
|
643 | - |
|
644 | - case 'restart': |
|
645 | - // new xoopspoll module |
|
646 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
647 | - $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
648 | - $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
|
649 | - // old xoopspoll or umfrage or any clone from them |
|
650 | - } else { |
|
651 | - $default_poll_duration = (86400 * 10); |
|
652 | - } |
|
653 | - $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true); |
|
654 | - $expire_text = new \XoopsFormText( |
|
655 | - _MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '<br>' . sprintf( |
|
656 | - _MD_NEWBB_POLL_EXPIREDAT, |
|
657 | - formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s') |
|
658 | - ) . '</small>', |
|
659 | - 'end_time', |
|
660 | - 20, |
|
661 | - 19, |
|
662 | - formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s') |
|
663 | - ); |
|
664 | - $poll_form->addElement($expire_text); |
|
665 | - $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1)); |
|
666 | - $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_RESET, 'reset', 0)); |
|
667 | - $poll_form->addElement(new \XoopsFormHidden('op', 'restart_ok')); |
|
668 | - $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
669 | - $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
670 | - $poll_form->addElement(new \XoopsFormButton('', 'poll_submit', _MD_NEWBB_POLL_RESTART, 'submit')); |
|
671 | - |
|
672 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
673 | - $poll_form->display(); |
|
674 | - break; |
|
675 | - |
|
676 | - case 'restart_ok': |
|
677 | - // check security token |
|
678 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
679 | - redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
680 | - } |
|
681 | - |
|
682 | - // new xoopspoll module |
|
683 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
684 | - $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
685 | - $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
|
686 | - $poll_not_mailed = $classConstants::POLL_NOT_MAILED; |
|
687 | - $poll_mailed = $classConstants::POLL_MAILED; |
|
688 | - // old xoopspoll or umfrage or any clone from them |
|
689 | - } else { |
|
690 | - $default_poll_duration = (86400 * 10); |
|
691 | - $poll_not_mailed = Xoopspoll\Constants::POLL_NOT_MAILED; |
|
692 | - $poll_mailed = Xoopspoll\Constants::POLL_MAILED; |
|
693 | - } |
|
694 | - |
|
695 | - $end_time = !Request::getInt('end_time', 0, 'POST'); |
|
696 | - if (0 !== $end_time) { |
|
697 | - $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
698 | - $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
699 | - } else { |
|
700 | - $pollObject->setVar('end_time', time() + $default_poll_duration); |
|
701 | - } |
|
702 | - |
|
703 | - $isNotify = Request::getInt('notify', 0, 'POST'); |
|
704 | - if (!empty($isNotify) && ($end_time > time())) { |
|
705 | - // if notify, set mail status to "not mailed" |
|
706 | - $pollObject->setVar('mail_status', $poll_not_mailed); |
|
707 | - } else { |
|
708 | - // if not notify, set mail status to already "mailed" |
|
709 | - $pollObject->setVar('mail_status', $poll_mailed); |
|
710 | - } |
|
711 | - |
|
712 | - // new xoopspoll module |
|
713 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
714 | - if (!$xpPollHandler->insert($pollObject)) { // update the poll |
|
715 | - xoops_error($pollObject->getHtmlErrors()); |
|
716 | - exit(); |
|
717 | - } |
|
718 | - if (Request::getInt('reset', 0, 'POST')) { // reset all vote/voter counters |
|
719 | - /** @var Xoopspoll\OptionHandler $xpOptHandler */ |
|
720 | - $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
721 | - /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
722 | - $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
723 | - $xpLogHandler->deleteByPollId($poll_id); |
|
724 | - $xpOptHandler->resetCountByPollId($poll_id); |
|
725 | - $xpPollHandler->updateCount($pollObject); |
|
726 | - } |
|
727 | - // old xoopspoll or umfrage or any clone from them |
|
728 | - } else { |
|
729 | - if (!$pollObject->store()) { // update the poll |
|
730 | - xoops_error($pollObject->getHtmlErrors()); |
|
731 | - exit(); |
|
732 | - } |
|
733 | - if (Request::getInt('reset', 0, 'POST')) { // reset all logs |
|
734 | - $classOption = $classPoll . 'Option'; |
|
735 | - $classLog = $classPoll . 'Log'; |
|
736 | - $classLog::deleteByPollId($poll_id); |
|
737 | - $classOption::resetCountByPollId($poll_id); |
|
738 | - $pollObject->updateCount(); |
|
739 | - } |
|
740 | - } |
|
741 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
742 | - xoops_template_clear_module_cache($xoopsModule->getVar('mid')); |
|
743 | - xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
744 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
745 | - break; |
|
746 | - |
|
747 | - case 'log': |
|
748 | - // new xoopspoll module |
|
749 | - if ($pollModuleHandler->getVar('version') >= 140) { |
|
750 | - redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/main.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); |
|
751 | - // old xoopspoll or umfrage or any clone from them |
|
752 | - } else { |
|
753 | - redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/index.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); |
|
754 | - } |
|
755 | - break; |
|
264 | + $option_empty = true; |
|
265 | + if (!Request::getString('option_text', '', 'POST')) { |
|
266 | + // irmtfan - issue with javascript:history.go(-1) |
|
267 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
268 | + } |
|
269 | + $option_text = Request::getArray('option_text', '', 'POST'); |
|
270 | + foreach ($option_text as $optxt) { |
|
271 | + if ('' !== trim($optxt)) { |
|
272 | + $option_empty = false; |
|
273 | + break; |
|
274 | + } |
|
275 | + } |
|
276 | + if ($option_empty) { |
|
277 | + // irmtfan - issue with javascript:history.go(-1) |
|
278 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
279 | + } |
|
280 | + $pollObject->setVar('question', Request::getString('question', '', 'POST')); |
|
281 | + $pollObject->setVar('description', Request::getString('description', '', 'POST')); |
|
282 | + $end_time = Request::getString('end_time', '', 'POST'); // (empty($_POST['end_time'])) ? "" : $_POST['end_time']; |
|
283 | + if ('' !== $end_time) { |
|
284 | + $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
285 | + $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
286 | + } else { |
|
287 | + // if expiration date is not set, set it to 10 days from now |
|
288 | + $pollObject->setVar('end_time', time() + (86400 * 10)); |
|
289 | + } |
|
290 | + |
|
291 | + $pollObject->setVar('display', 0); |
|
292 | + $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST')); |
|
293 | + $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST')); |
|
294 | + $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST')); |
|
295 | + if (Request::getInt('notify', 0, 'POST') && $end_time > time()) { |
|
296 | + // if notify, set mail status to "not mailed" |
|
297 | + $pollObject->setVar('mail_status', Xoopspoll\Constants::POLL_NOT_MAILED); |
|
298 | + } else { |
|
299 | + // if not notify, set mail status to already "mailed" |
|
300 | + $pollObject->setVar('mail_status', Xoopspoll\Constants::POLL_MAILED); |
|
301 | + } |
|
302 | + $new_poll_id = $pollObject->store(); |
|
303 | + if (empty($new_poll_id)) { |
|
304 | + xoops_error($pollObject->getHtmlErrors); |
|
305 | + break; |
|
306 | + } |
|
307 | + $i = 0; |
|
308 | + $option_color = Request::getArray('option_color', null, 'POST'); |
|
309 | + $classOption = $classPoll . 'Option'; |
|
310 | + foreach ($option_text as $optxt) { |
|
311 | + $optxt = trim($optxt); |
|
312 | + /** @var Xoopspoll\Option $optionObject */ |
|
313 | + $optionObject = new $classOption(); |
|
314 | + if ('' !== $optxt) { |
|
315 | + $optionObject->setVar('option_text', $optxt); |
|
316 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
317 | + $optionObject->setVar('poll_id', $new_poll_id); |
|
318 | + $optionObject->store(); |
|
319 | + } |
|
320 | + ++$i; |
|
321 | + } |
|
322 | + // clear the template cache so changes take effect immediately |
|
323 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
324 | + xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
325 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
326 | + |
|
327 | + // update topic to indicate it has a poll |
|
328 | + $topicObject->setVar('topic_haspoll', 1); |
|
329 | + $topicObject->setVar('poll_id', $new_poll_id); |
|
330 | + $success = $topicHandler->insert($topicObject); |
|
331 | + if (!$success) { |
|
332 | + xoops_error($topicHandler->getHtmlErrors()); |
|
333 | + } else { |
|
334 | + redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
335 | + } |
|
336 | + break;// op: save |
|
337 | + } |
|
338 | + // no break |
|
339 | + case 'update': |
|
340 | + // check security token |
|
341 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
342 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
343 | + } |
|
344 | + /* make sure there's at least one option */ |
|
345 | + $option_text = Request::getString('option_text', '', 'POST'); |
|
346 | + $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; |
|
347 | + $option_string = trim($option_string); |
|
348 | + if ('' === $option_string) { |
|
349 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
350 | + } |
|
351 | + |
|
352 | + // new xoopspoll module |
|
353 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
354 | + /** @var Xoopspoll\OptionHandler $xpOptHandler */ |
|
355 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
356 | + /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
357 | + $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
358 | + // $classRequest = ucfirst($GLOBALS['xoopsModuleConfig']["poll_module"]) . "Request"; |
|
359 | + $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
360 | + $notify = Request::getInt('notify', $classConstants::NOTIFICATION_ENABLED, 'POST'); |
|
361 | + $currentTimestamp = time(); |
|
362 | + //$xuEndTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_end_time', null, 'POST')) |
|
363 | + // : strtotime(Request::getString('xu_end_time', null, 'POST')); |
|
364 | + $xuEndTimestamp = strtotime(Request::getString('xu_end_time', null, 'POST')); |
|
365 | + $endTimestamp = (!Request::getString('xu_end_time', null, 'POST')) ? ($currentTimestamp + $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp); |
|
366 | + //$xuStartTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_start_time', null, 'POST')) |
|
367 | + // : strtotime(Request::getString('xu_start_time', null, 'POST')); |
|
368 | + $xuStartTimestamp = strtotime(Request::getString('xu_start_time', null, 'POST')); |
|
369 | + $startTimestamp = (!Request::getString('xu_start_time', null, 'POST')) ? ($endTimestamp - $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp); |
|
370 | + |
|
371 | + // don't allow changing start time if there are votes in the log |
|
372 | + if (($startTimestamp < $pollObject->getVar('start_time')) |
|
373 | + && ($xpLogHandler->getTotalVotesByPollId($poll_id) > 0)) { |
|
374 | + $startTimestamp = $pollObject->getVar('start_time'); //don't change start time |
|
375 | + } |
|
376 | + |
|
377 | + $poll_vars = [ |
|
378 | + 'user_id' => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'), |
|
379 | + 'question' => Request::getString('question', null, 'POST'), |
|
380 | + 'description' => Request::getText('description', null, 'POST'), |
|
381 | + 'mail_status' => ($classConstants::NOTIFICATION_ENABLED == $notify) ? $classConstants::POLL_NOT_MAILED : $classConstants::POLL_MAILED, |
|
382 | + 'mail_voter' => Request::getInt('mail_voter', $classConstants::NOT_MAIL_POLL_TO_VOTER, 'POST'), |
|
383 | + 'start_time' => $startTimestamp, |
|
384 | + 'end_time' => $endTimestamp, |
|
385 | + 'display' => Request::getInt('display', $classConstants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'), |
|
386 | + 'visibility' => Request::getInt('visibility', $classConstants::HIDE_NEVER, 'POST'), |
|
387 | + 'weight' => Request::getInt('weight', $classConstants::DEFAULT_WEIGHT, 'POST'), |
|
388 | + 'multiple' => Request::getInt('multiple', $classConstants::NOT_MULTIPLE_SELECT_POLL, 'POST'), |
|
389 | + 'multilimit' => Request::getInt('multilimit', $classConstants::MULTIPLE_SELECT_LIMITLESS, 'POST'), |
|
390 | + 'anonymous' => Request::getInt('anonymous', $classConstants::ANONYMOUS_VOTING_DISALLOWED, 'POST') |
|
391 | + ]; |
|
392 | + $pollObject->setVars($poll_vars); |
|
393 | + $poll_id = $xpPollHandler->insert($pollObject); |
|
394 | + if (!$poll_id) { |
|
395 | + $err = $pollObject->getHtmlErrors(); |
|
396 | + exit($err); |
|
397 | + } |
|
398 | + |
|
399 | + // now get the options |
|
400 | + $optionIdArray = Request::getArray('option_id', [], 'POST'); |
|
401 | + $optionIdArray = array_map('intval', $optionIdArray); |
|
402 | + $optionTextArray = Request::getArray('option_text', [], 'POST'); |
|
403 | + $optionColorArray = Request::getArray('option_color', [], 'POST'); |
|
404 | + |
|
405 | + foreach ($optionIdArray as $key => $oId) { |
|
406 | + if (!empty($oId) && ($optionObject = $xpOptHandler->get($oId))) { |
|
407 | + // existing option object so need to update it |
|
408 | + $optionTextArray[$key] = trim($optionTextArray[$key]); |
|
409 | + if ('' === $optionTextArray[$key]) { |
|
410 | + // want to delete this option |
|
411 | + if (false !== $xpOptHandler->delete($optionObject)) { |
|
412 | + // now remove it from the log |
|
413 | + $xpLogHandler->deleteByOptionId($optionObject->getVar('option_id')); |
|
414 | + //update vote count in poll |
|
415 | + $xpPollHandler->updateCount($pollObject); |
|
416 | + } else { |
|
417 | + xoops_error($xpLogHandler->getHtmlErrors()); |
|
418 | + break; |
|
419 | + } |
|
420 | + } else { |
|
421 | + $optionObject->setVar('option_text', $optionTextArray[$key]); |
|
422 | + $optionObject->setVar('option_color', $optionColorArray[$key]); |
|
423 | + $optionObject->setVar('poll_id', $poll_id); |
|
424 | + $xpOptHandler->insert($optionObject); |
|
425 | + } |
|
426 | + } else { |
|
427 | + // new option object |
|
428 | + $optionObject = $xpOptHandler->create(); |
|
429 | + $optionTextArray[$key] = trim($optionTextArray[$key]); |
|
430 | + if ('' !== $optionTextArray[$key]) { // ignore if text is empty |
|
431 | + $optionObject->setVar('option_text', $optionTextArray[$key]); |
|
432 | + $optionObject->setVar('option_color', $optionColorArray[$key]); |
|
433 | + $optionObject->setVar('poll_id', $poll_id); |
|
434 | + $xpOptHandler->insert($optionObject); |
|
435 | + } |
|
436 | + unset($optionObject); |
|
437 | + } |
|
438 | + } |
|
439 | + // old xoopspoll or umfrage or any clone from them |
|
440 | + } else { |
|
441 | + $pollObject->setVar('question', Request::getString('question', '', 'POST')); |
|
442 | + $pollObject->setVar('description', Request::getString('description', '', 'POST')); |
|
443 | + |
|
444 | + $end_time = Request::getString('end_time', '', 'POST'); |
|
445 | + if ('' !== $end_time) { |
|
446 | + $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
447 | + $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
448 | + } |
|
449 | + $pollObject->setVar('display', 0); |
|
450 | + $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST')); |
|
451 | + $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST')); |
|
452 | + $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST')); |
|
453 | + if (Request::getInt('notify', 0, 'POST') && $end_time > time()) { |
|
454 | + // if notify, set mail status to "not mailed" |
|
455 | + $pollObject->setVar('mail_status', $classConstants::POLL_NOT_MAILED); |
|
456 | + } else { |
|
457 | + // if not notify, set mail status to already "mailed" |
|
458 | + $pollObject->setVar('mail_status', $classConstants::POLL_MAILED); |
|
459 | + } |
|
460 | + |
|
461 | + if (!$pollObject->store()) { |
|
462 | + xoops_error($pollObject->getHtmlErrors); |
|
463 | + break; |
|
464 | + } |
|
465 | + $i = 0; |
|
466 | + $option_id = Request::getArray('option_id', null, 'POST'); |
|
467 | + $option_color = Request::getArray('option_color', null, 'POST'); |
|
468 | + $classOption = $classPoll . 'Option'; |
|
469 | + $classLog = $classPoll . 'Log'; |
|
470 | + foreach ($option_id as $opid) { |
|
471 | + $optionObject = new $classOption($opid); |
|
472 | + $option_text[$i] = trim($option_text[$i]); |
|
473 | + if ('' !== $option_text[$i]) { |
|
474 | + $optionObject->setVar('option_text', $option_text[$i]); |
|
475 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
476 | + $optionObject->store(); |
|
477 | + } else { |
|
478 | + if (false !== $optionObject->delete()) { |
|
479 | + $classLog::deleteByOptionId($option->getVar('option_id')); |
|
480 | + } |
|
481 | + } |
|
482 | + ++$i; |
|
483 | + } |
|
484 | + $pollObject->updateCount(); |
|
485 | + } |
|
486 | + // clear the template cache so changes take effect immediately |
|
487 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
488 | + xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
489 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
490 | + |
|
491 | + // update topic to indicate it has a poll |
|
492 | + $topicObject->setVar('topic_haspoll', 1); |
|
493 | + $topicObject->setVar('poll_id', $pollObject->getVar('poll_id')); |
|
494 | + $success = $topicHandler->insert($topicObject); |
|
495 | + if (!$success) { |
|
496 | + xoops_error($topicHandler->getHtmlErrors()); |
|
497 | + } else { |
|
498 | + redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
499 | + } |
|
500 | + break;// op: save | update |
|
501 | + |
|
502 | + case 'addmore': |
|
503 | + $question = $pollObject->getVar('question'); |
|
504 | + unset($pollObject); |
|
505 | + $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_ADDMORE, 'poll_form', 'polls.php', 'post', true); |
|
506 | + $poll_form->addElement(new \XoopsFormLabel(_MD_NEWBB_POLL_POLLQUESTION, $question)); |
|
507 | + // new xoopspoll module |
|
508 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
509 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
510 | + $option_tray = $xpOptHandler->renderOptionFormTray($poll_id); |
|
511 | + // old xoopspoll or umfrage or any clone from them |
|
512 | + } else { |
|
513 | + $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
|
514 | + $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
515 | + for ($i = 0; $i < 10; ++$i) { |
|
516 | + $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
|
517 | + $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
|
518 | + $option_tray->addElement($option_text); |
|
519 | + $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
|
520 | + $color_select->addOptionArray($barcolor_array); |
|
521 | + $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
522 | + $color_label = new \XoopsFormLabel('', "<img src='" |
|
523 | + . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}") |
|
524 | + . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
525 | + $option_tray->addElement($color_select); |
|
526 | + $option_tray->addElement($color_label); |
|
527 | + unset($color_select, $color_label, $option_text); |
|
528 | + if (!next($barcolor_array)) { |
|
529 | + reset($barcolor_array); |
|
530 | + } |
|
531 | + } |
|
532 | + } |
|
533 | + $poll_form->addElement($option_tray); |
|
534 | + $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
|
535 | + $poll_form->addElement(new \XoopsFormHidden('op', 'savemore')); |
|
536 | + $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
537 | + $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
538 | + |
|
539 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
540 | + $poll_form->display(); |
|
541 | + break; |
|
542 | + |
|
543 | + case 'savemore': |
|
544 | + // check security token |
|
545 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
546 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
547 | + } |
|
548 | + |
|
549 | + $option_text = Request::getString('option_text', '', 'POST'); |
|
550 | + $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; |
|
551 | + $option_string = trim($option_string); |
|
552 | + if ('' === $option_string) { |
|
553 | + // irmtfan - issue with javascript:history.go(-1) |
|
554 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
555 | + } |
|
556 | + $i = 0; |
|
557 | + $option_color = Request::getArray('option_color', null, 'POST'); |
|
558 | + foreach ($option_text as $optxt) { |
|
559 | + $optxt = trim($optxt); |
|
560 | + if ('' !== $optxt) { |
|
561 | + // new xoopspoll module |
|
562 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
563 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
564 | + $optionObject = $xpOptHandler->create(); |
|
565 | + $optionObject->setVar('option_text', $optxt); |
|
566 | + $optionObject->setVar('poll_id', $poll_id); |
|
567 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
568 | + $xpOptHandler->insert($optionObject); |
|
569 | + // old xoopspoll or umfrage or any clone from them |
|
570 | + } else { |
|
571 | + $classOption = $classPoll . 'Option'; |
|
572 | + $optionObject = new $classOption(); |
|
573 | + $optionObject->setVar('option_text', $optxt); |
|
574 | + $optionObject->setVar('poll_id', $poll_id); |
|
575 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
576 | + $optionObject->store(); |
|
577 | + } |
|
578 | + unset($optionObject); |
|
579 | + } |
|
580 | + ++$i; |
|
581 | + } |
|
582 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
583 | + xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid')); |
|
584 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
585 | + redirect_header("polls.php?op=edit&poll_id={$poll_id}&topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
|
586 | + break; |
|
587 | + |
|
588 | + case 'delete': |
|
589 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
590 | + xoops_confirm(['op' => 'delete_ok', 'topic_id' => $topic_id, 'poll_id' => $poll_id], 'polls.php', sprintf(_MD_NEWBB_POLL_RUSUREDEL, $pollObject->getVar('question'))); |
|
591 | + break; |
|
592 | + |
|
593 | + case 'delete_ok': |
|
594 | + // check security token |
|
595 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
596 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
597 | + } |
|
598 | + //try and delete the poll |
|
599 | + // new xoopspoll module |
|
600 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
601 | + $status = $xpPollHandler->delete($pollObject); |
|
602 | + if (false !== $status) { |
|
603 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
604 | + $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
605 | + $xpOptHandler->deleteByPollId($poll_id); |
|
606 | + $xpLogHandler->deleteByPollId($poll_id); |
|
607 | + } else { |
|
608 | + $msg = $xpPollHandler->getHtmlErrors(); |
|
609 | + } |
|
610 | + // old xoopspoll or umfrage or any clone from them |
|
611 | + } else { |
|
612 | + $status = $pollObject->delete(); |
|
613 | + $classOption = $classPoll . 'Option'; |
|
614 | + $classLog = $classPoll . 'Log'; |
|
615 | + if (false !== $status) { |
|
616 | + $classOption::deleteByPollId($poll_id); |
|
617 | + $classLog::deleteByPollId($poll_id); |
|
618 | + } else { |
|
619 | + $msg = $pollObject->getHtmlErrors(); |
|
620 | + } |
|
621 | + } |
|
622 | + if (false !== $status) { |
|
623 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
624 | + xoops_template_clear_module_cache($xoopsModule->getVar('mid')); |
|
625 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
626 | + // delete comments for this poll |
|
627 | + xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id); |
|
628 | + |
|
629 | + $topicObject->setVar('votes', 0); // not sure why we want to clear votes too... but I left it alone |
|
630 | + $topicObject->setVar('topic_haspoll', 0); |
|
631 | + $topicObject->setVar('poll_id', 0); |
|
632 | + $success = $topicHandler->insert($topicObject); |
|
633 | + if (!$success) { |
|
634 | + xoops_error($topicHandler->getHtmlErrors()); |
|
635 | + break; |
|
636 | + } |
|
637 | + } else { |
|
638 | + xoops_error($msg); |
|
639 | + break; |
|
640 | + } |
|
641 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
642 | + break; |
|
643 | + |
|
644 | + case 'restart': |
|
645 | + // new xoopspoll module |
|
646 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
647 | + $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
648 | + $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
|
649 | + // old xoopspoll or umfrage or any clone from them |
|
650 | + } else { |
|
651 | + $default_poll_duration = (86400 * 10); |
|
652 | + } |
|
653 | + $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true); |
|
654 | + $expire_text = new \XoopsFormText( |
|
655 | + _MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '<br>' . sprintf( |
|
656 | + _MD_NEWBB_POLL_EXPIREDAT, |
|
657 | + formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s') |
|
658 | + ) . '</small>', |
|
659 | + 'end_time', |
|
660 | + 20, |
|
661 | + 19, |
|
662 | + formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s') |
|
663 | + ); |
|
664 | + $poll_form->addElement($expire_text); |
|
665 | + $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1)); |
|
666 | + $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_RESET, 'reset', 0)); |
|
667 | + $poll_form->addElement(new \XoopsFormHidden('op', 'restart_ok')); |
|
668 | + $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
|
669 | + $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
|
670 | + $poll_form->addElement(new \XoopsFormButton('', 'poll_submit', _MD_NEWBB_POLL_RESTART, 'submit')); |
|
671 | + |
|
672 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
673 | + $poll_form->display(); |
|
674 | + break; |
|
675 | + |
|
676 | + case 'restart_ok': |
|
677 | + // check security token |
|
678 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
679 | + redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
|
680 | + } |
|
681 | + |
|
682 | + // new xoopspoll module |
|
683 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
684 | + $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
685 | + $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
|
686 | + $poll_not_mailed = $classConstants::POLL_NOT_MAILED; |
|
687 | + $poll_mailed = $classConstants::POLL_MAILED; |
|
688 | + // old xoopspoll or umfrage or any clone from them |
|
689 | + } else { |
|
690 | + $default_poll_duration = (86400 * 10); |
|
691 | + $poll_not_mailed = Xoopspoll\Constants::POLL_NOT_MAILED; |
|
692 | + $poll_mailed = Xoopspoll\Constants::POLL_MAILED; |
|
693 | + } |
|
694 | + |
|
695 | + $end_time = !Request::getInt('end_time', 0, 'POST'); |
|
696 | + if (0 !== $end_time) { |
|
697 | + $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null; |
|
698 | + $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone)); |
|
699 | + } else { |
|
700 | + $pollObject->setVar('end_time', time() + $default_poll_duration); |
|
701 | + } |
|
702 | + |
|
703 | + $isNotify = Request::getInt('notify', 0, 'POST'); |
|
704 | + if (!empty($isNotify) && ($end_time > time())) { |
|
705 | + // if notify, set mail status to "not mailed" |
|
706 | + $pollObject->setVar('mail_status', $poll_not_mailed); |
|
707 | + } else { |
|
708 | + // if not notify, set mail status to already "mailed" |
|
709 | + $pollObject->setVar('mail_status', $poll_mailed); |
|
710 | + } |
|
711 | + |
|
712 | + // new xoopspoll module |
|
713 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
714 | + if (!$xpPollHandler->insert($pollObject)) { // update the poll |
|
715 | + xoops_error($pollObject->getHtmlErrors()); |
|
716 | + exit(); |
|
717 | + } |
|
718 | + if (Request::getInt('reset', 0, 'POST')) { // reset all vote/voter counters |
|
719 | + /** @var Xoopspoll\OptionHandler $xpOptHandler */ |
|
720 | + $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option'); |
|
721 | + /** @var Xoopspoll\LogHandler $xpLogHandler */ |
|
722 | + $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
723 | + $xpLogHandler->deleteByPollId($poll_id); |
|
724 | + $xpOptHandler->resetCountByPollId($poll_id); |
|
725 | + $xpPollHandler->updateCount($pollObject); |
|
726 | + } |
|
727 | + // old xoopspoll or umfrage or any clone from them |
|
728 | + } else { |
|
729 | + if (!$pollObject->store()) { // update the poll |
|
730 | + xoops_error($pollObject->getHtmlErrors()); |
|
731 | + exit(); |
|
732 | + } |
|
733 | + if (Request::getInt('reset', 0, 'POST')) { // reset all logs |
|
734 | + $classOption = $classPoll . 'Option'; |
|
735 | + $classLog = $classPoll . 'Log'; |
|
736 | + $classLog::deleteByPollId($poll_id); |
|
737 | + $classOption::resetCountByPollId($poll_id); |
|
738 | + $pollObject->updateCount(); |
|
739 | + } |
|
740 | + } |
|
741 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
742 | + xoops_template_clear_module_cache($xoopsModule->getVar('mid')); |
|
743 | + xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
|
744 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
745 | + break; |
|
746 | + |
|
747 | + case 'log': |
|
748 | + // new xoopspoll module |
|
749 | + if ($pollModuleHandler->getVar('version') >= 140) { |
|
750 | + redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/main.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); |
|
751 | + // old xoopspoll or umfrage or any clone from them |
|
752 | + } else { |
|
753 | + redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/index.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG); |
|
754 | + } |
|
755 | + break; |
|
756 | 756 | } // switch |
757 | 757 | |
758 | 758 | // irmtfan move to footer.php |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | // rewrite by irmtfan and zyspec to accept xoopspoll 1.4 and all old xoopspoll and umfrage versions and all clones |
25 | 25 | |
26 | -require_once __DIR__ . '/header.php'; |
|
26 | +require_once __DIR__.'/header.php'; |
|
27 | 27 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
28 | 28 | require_once $GLOBALS['xoops']->path('class/xoopslists.php'); |
29 | 29 | require_once $GLOBALS['xoops']->path('class/xoopsblock.php'); |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | if (is_object($topicObject)) { |
57 | 57 | $forum_id = $topicObject->getVar('forum_id'); |
58 | 58 | } else { |
59 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_POLLMODULE_ERROR . ': ' . _MD_NEWBB_FORUMNOEXIST); |
|
59 | + redirect_header(XOOPS_URL.'/index.php', 2, _MD_NEWBB_POLLMODULE_ERROR.': '._MD_NEWBB_FORUMNOEXIST); |
|
60 | 60 | } |
61 | 61 | // forum access permission |
62 | 62 | /** @var Newbb\ForumHandler $forumHandler */ |
63 | 63 | $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
64 | 64 | $forumObject = $forumHandler->get($forum_id); |
65 | 65 | if (!$forumHandler->getPermission($forumObject)) { |
66 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
66 | + redirect_header(XOOPS_URL.'/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
67 | 67 | } |
68 | 68 | // topic view permission |
69 | 69 | if (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view')) { |
70 | - redirect_header('viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW); |
|
70 | + redirect_header('viewforum.php?forum='.$forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW); |
|
71 | 71 | } |
72 | 72 | // poll module |
73 | 73 | $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist |
85 | 85 | // old xoopspoll or umfrage or any clone from them |
86 | 86 | } else { |
87 | - require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php'); |
|
87 | + require_once $GLOBALS['xoops']->path('modules/'.$GLOBALS['xoopsModuleConfig']['poll_module'].'/include/constants.php'); |
|
88 | 88 | $classPoll = $topicObject->loadOldPoll(); |
89 | 89 | $pollObject = new $classPoll($poll_id); // will create poll if poll_id = 0 exist |
90 | 90 | } |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | case 'add': |
115 | 115 | // new xoopspoll module |
116 | 116 | if ($pollModuleHandler->getVar('version') >= 140) { |
117 | - echo '<h4>' . _MD_NEWBB_POLL_CREATNEWPOLL . "</h4>\n"; |
|
117 | + echo '<h4>'._MD_NEWBB_POLL_CREATNEWPOLL."</h4>\n"; |
|
118 | 118 | $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
119 | 119 | // old xoopspoll or umfrage or any clone from them |
120 | 120 | } else { |
121 | - $classOption = $classPoll . 'Option'; |
|
121 | + $classOption = $classPoll.'Option'; |
|
122 | 122 | $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true); |
123 | 123 | $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("<a href='" |
124 | 124 | . XOOPS_URL |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $poll_form->addElement($desc_tarea); |
135 | 135 | $currenttime = formatTimestamp(time(), 'Y-m-d H:i:s'); |
136 | 136 | $endtime = formatTimestamp(time() + 604800, 'Y-m-d H:i:s'); |
137 | - $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, $currenttime) . '</small>', 'end_time', 30, 19, $endtime); |
|
137 | + $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION.'<br><small>'._MD_NEWBB_POLL_FORMAT.'<br>'.sprintf(_MD_NEWBB_POLL_CURRENTTIME, $currenttime).'</small>', 'end_time', 30, 19, $endtime); |
|
138 | 138 | $poll_form->addElement($expire_text); |
139 | 139 | |
140 | 140 | $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, 0); |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | $poll_form->addElement($notify_yn); |
148 | 148 | |
149 | 149 | $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
150 | - $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
150 | + $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/'.$GLOBALS['xoopsModuleConfig']['poll_module'].'/assets/images/colorbars/')); |
|
151 | 151 | for ($i = 0; $i < 10; ++$i) { |
152 | 152 | $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
153 | 153 | $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
154 | 154 | $option_tray->addElement($option_text); |
155 | 155 | $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
156 | 156 | $color_select->addOptionArray($barcolor_array); |
157 | - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'"); |
|
157 | + $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/".$GLOBALS['xoopsModuleConfig']['poll_module'].'/assets/images/colorbars", "", "'.XOOPS_URL."\")'"); |
|
158 | 158 | $color_label = new \XoopsFormLabel('', "<img src='" |
159 | 159 | . XOOPS_URL |
160 | 160 | . '/modules/' |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
177 | 177 | $poll_form->addElement(new \XoopsFormHidden('user_id', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0)); |
178 | 178 | $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
179 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . '</h4>'; |
|
179 | + echo '<h4>'._MD_NEWBB_POLL_POLLCONF.'</h4>'; |
|
180 | 180 | $poll_form->display(); |
181 | 181 | } |
182 | 182 | break; // op: add |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | case 'edit': |
185 | 185 | // new xoopspoll module |
186 | 186 | if ($pollModuleHandler->getVar('version') >= 140) { |
187 | - echo '<h4>' . _MD_NEWBB_POLL_EDITPOLL . "</h4>\n"; |
|
187 | + echo '<h4>'._MD_NEWBB_POLL_EDITPOLL."</h4>\n"; |
|
188 | 188 | $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]); |
189 | 189 | // old xoopspoll or umfrage or any clone from them |
190 | 190 | } else { |
191 | - $classOption = $classPoll . 'Option'; |
|
191 | + $classOption = $classPoll.'Option'; |
|
192 | 192 | $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_EDITPOLL, 'poll_form', 'polls.php', 'post', true); |
193 | - $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $pollObject->getVar('user_id') . "'>" . newbbGetUnameFromId($pollObject->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']) . '</a>'); |
|
193 | + $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, "<a href='".XOOPS_URL.'/userinfo.php?uid='.$pollObject->getVar('user_id')."'>".newbbGetUnameFromId($pollObject->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']).'</a>'); |
|
194 | 194 | $poll_form->addElement($author_label); |
195 | 195 | $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255, $pollObject->getVar('question', 'E')); |
196 | 196 | $poll_form->addElement($question_text); |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | $poll_form->addElement($desc_tarea); |
199 | 199 | $date = formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s'); // important "Y-m-d H:i:s" use in jdf function |
200 | 200 | if (!$pollObject->hasExpired()) { |
201 | - $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '</small>', 'end_time', 20, 19, $date); |
|
201 | + $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION.'<br><small>'._MD_NEWBB_POLL_FORMAT.'<br>'.sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')).'</small>', 'end_time', 20, 19, $date); |
|
202 | 202 | $poll_form->addElement($expire_text); |
203 | 203 | } else { |
204 | 204 | // irmtfan full URL - add topic_id |
205 | 205 | $restart_label = new \XoopsFormLabel( |
206 | 206 | _MD_NEWBB_POLL_EXPIRATION, |
207 | - sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=restart&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . '</a>' |
|
207 | + sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date)."<br><a href='".XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/polls.php?op=restart&poll_id={$poll_id}&topic_id={$topic_id}'>"._MD_NEWBB_POLL_RESTART.'</a>' |
|
208 | 208 | ); |
209 | 209 | $poll_form->addElement($restart_label); |
210 | 210 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $poll_form->addElement($weight_text); |
213 | 213 | $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', $pollObject->getVar('multiple')); |
214 | 214 | $poll_form->addElement($multi_yn); |
215 | - $options_arr =& $classOption::getAllByPollId($poll_id); |
|
215 | + $options_arr = & $classOption::getAllByPollId($poll_id); |
|
216 | 216 | $notify_value = 1; |
217 | 217 | if (0 !== $pollObject->getVar('mail_status')) { |
218 | 218 | $notify_value = 0; |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | $option_tray->addElement(new \XoopsFormHidden('option_id[]', $option->getVar('option_id'))); |
229 | 229 | $color_select = new \XoopsFormSelect('', 'option_color[{$i}]', $option->getVar('option_color')); |
230 | 230 | $color_select->addOptionArray($barcolor_array); |
231 | - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
231 | + $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[".$i."]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"".XOOPS_URL."\")'"); |
|
232 | 232 | $color_label = new \XoopsFormLabel('', "<img src='" |
233 | - . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) |
|
233 | + . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/".$option->getVar('option_color', 'E')) |
|
234 | 234 | . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
235 | 235 | $option_tray->addElement($color_select); |
236 | 236 | $option_tray->addElement($color_label); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | ++$i; |
239 | 239 | } |
240 | 240 | // irmtfan full URL |
241 | - $more_label = new \XoopsFormLabel('', "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=addmore&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_ADDMORE . '</a>'); |
|
241 | + $more_label = new \XoopsFormLabel('', "<br><a href='".XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/polls.php?op=addmore&poll_id={$poll_id}&topic_id={$topic_id}'>"._MD_NEWBB_POLL_ADDMORE.'</a>'); |
|
242 | 242 | $option_tray->addElement($more_label); |
243 | 243 | $poll_form->addElement($option_tray); |
244 | 244 | $poll_form->addElement(new \XoopsFormHidden('op', 'update')); |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
247 | 247 | $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit')); |
248 | 248 | |
249 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
249 | + echo '<h4>'._MD_NEWBB_POLL_POLLCONF."</h4>\n"; |
|
250 | 250 | $poll_form->display(); |
251 | 251 | } |
252 | 252 | break; // op: edit |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $option_empty = true; |
265 | 265 | if (!Request::getString('option_text', '', 'POST')) { |
266 | 266 | // irmtfan - issue with javascript:history.go(-1) |
267 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
267 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED.': '._MD_NEWBB_POLL_POLLOPTIONS.' !'); |
|
268 | 268 | } |
269 | 269 | $option_text = Request::getArray('option_text', '', 'POST'); |
270 | 270 | foreach ($option_text as $optxt) { |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | } |
276 | 276 | if ($option_empty) { |
277 | 277 | // irmtfan - issue with javascript:history.go(-1) |
278 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
278 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED.': '._MD_NEWBB_POLL_POLLOPTIONS.' !'); |
|
279 | 279 | } |
280 | 280 | $pollObject->setVar('question', Request::getString('question', '', 'POST')); |
281 | 281 | $pollObject->setVar('description', Request::getString('description', '', 'POST')); |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | } |
307 | 307 | $i = 0; |
308 | 308 | $option_color = Request::getArray('option_color', null, 'POST'); |
309 | - $classOption = $classPoll . 'Option'; |
|
309 | + $classOption = $classPoll.'Option'; |
|
310 | 310 | foreach ($option_text as $optxt) { |
311 | 311 | $optxt = trim($optxt); |
312 | 312 | /** @var Xoopspoll\Option $optionObject */ |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | } else { |
334 | 334 | redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
335 | 335 | } |
336 | - break;// op: save |
|
336 | + break; // op: save |
|
337 | 337 | } |
338 | 338 | // no break |
339 | 339 | case 'update': |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | $option_string = is_array($option_text) ? implode('', $option_text) : $option_text; |
347 | 347 | $option_string = trim($option_string); |
348 | 348 | if ('' === $option_string) { |
349 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
349 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED.': '._MD_NEWBB_POLL_POLLOPTIONS.' !'); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | // new xoopspoll module |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | $i = 0; |
466 | 466 | $option_id = Request::getArray('option_id', null, 'POST'); |
467 | 467 | $option_color = Request::getArray('option_color', null, 'POST'); |
468 | - $classOption = $classPoll . 'Option'; |
|
469 | - $classLog = $classPoll . 'Log'; |
|
468 | + $classOption = $classPoll.'Option'; |
|
469 | + $classLog = $classPoll.'Log'; |
|
470 | 470 | foreach ($option_id as $opid) { |
471 | 471 | $optionObject = new $classOption($opid); |
472 | 472 | $option_text[$i] = trim($option_text[$i]); |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | } else { |
498 | 498 | redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
499 | 499 | } |
500 | - break;// op: save | update |
|
500 | + break; // op: save | update |
|
501 | 501 | |
502 | 502 | case 'addmore': |
503 | 503 | $question = $pollObject->getVar('question'); |
@@ -511,14 +511,14 @@ discard block |
||
511 | 511 | // old xoopspoll or umfrage or any clone from them |
512 | 512 | } else { |
513 | 513 | $option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, ''); |
514 | - $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/')); |
|
514 | + $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/'.$GLOBALS['xoopsModuleConfig']['poll_module'].'/assets/images/colorbars/')); |
|
515 | 515 | for ($i = 0; $i < 10; ++$i) { |
516 | 516 | $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array); |
517 | 517 | $option_text = new \XoopsFormText('', 'option_text[]', 50, 255); |
518 | 518 | $option_tray->addElement($option_text); |
519 | 519 | $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar); |
520 | 520 | $color_select->addOptionArray($barcolor_array); |
521 | - $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
|
521 | + $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"".XOOPS_URL."\")'"); |
|
522 | 522 | $color_label = new \XoopsFormLabel('', "<img src='" |
523 | 523 | . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}") |
524 | 524 | . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
537 | 537 | $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
538 | 538 | |
539 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
539 | + echo '<h4>'._MD_NEWBB_POLL_POLLCONF."</h4>\n"; |
|
540 | 540 | $poll_form->display(); |
541 | 541 | break; |
542 | 542 | |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | $option_string = trim($option_string); |
552 | 552 | if ('' === $option_string) { |
553 | 553 | // irmtfan - issue with javascript:history.go(-1) |
554 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
|
554 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED.': '._MD_NEWBB_POLL_POLLOPTIONS.' !'); |
|
555 | 555 | } |
556 | 556 | $i = 0; |
557 | 557 | $option_color = Request::getArray('option_color', null, 'POST'); |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | $xpOptHandler->insert($optionObject); |
569 | 569 | // old xoopspoll or umfrage or any clone from them |
570 | 570 | } else { |
571 | - $classOption = $classPoll . 'Option'; |
|
571 | + $classOption = $classPoll.'Option'; |
|
572 | 572 | $optionObject = new $classOption(); |
573 | 573 | $optionObject->setVar('option_text', $optxt); |
574 | 574 | $optionObject->setVar('poll_id', $poll_id); |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | break; |
587 | 587 | |
588 | 588 | case 'delete': |
589 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
589 | + echo '<h4>'._MD_NEWBB_POLL_POLLCONF."</h4>\n"; |
|
590 | 590 | xoops_confirm(['op' => 'delete_ok', 'topic_id' => $topic_id, 'poll_id' => $poll_id], 'polls.php', sprintf(_MD_NEWBB_POLL_RUSUREDEL, $pollObject->getVar('question'))); |
591 | 591 | break; |
592 | 592 | |
@@ -610,8 +610,8 @@ discard block |
||
610 | 610 | // old xoopspoll or umfrage or any clone from them |
611 | 611 | } else { |
612 | 612 | $status = $pollObject->delete(); |
613 | - $classOption = $classPoll . 'Option'; |
|
614 | - $classLog = $classPoll . 'Log'; |
|
613 | + $classOption = $classPoll.'Option'; |
|
614 | + $classLog = $classPoll.'Log'; |
|
615 | 615 | if (false !== $status) { |
616 | 616 | $classOption::deleteByPollId($poll_id); |
617 | 617 | $classLog::deleteByPollId($poll_id); |
@@ -638,13 +638,13 @@ discard block |
||
638 | 638 | xoops_error($msg); |
639 | 639 | break; |
640 | 640 | } |
641 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
641 | + redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
642 | 642 | break; |
643 | 643 | |
644 | 644 | case 'restart': |
645 | 645 | // new xoopspoll module |
646 | 646 | if ($pollModuleHandler->getVar('version') >= 140) { |
647 | - $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
647 | + $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
648 | 648 | $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
649 | 649 | // old xoopspoll or umfrage or any clone from them |
650 | 650 | } else { |
@@ -652,10 +652,10 @@ discard block |
||
652 | 652 | } |
653 | 653 | $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true); |
654 | 654 | $expire_text = new \XoopsFormText( |
655 | - _MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '<br>' . sprintf( |
|
655 | + _MD_NEWBB_POLL_EXPIRATION.'<br><small>'._MD_NEWBB_POLL_FORMAT.'<br>'.sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')).'<br>'.sprintf( |
|
656 | 656 | _MD_NEWBB_POLL_EXPIREDAT, |
657 | 657 | formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s') |
658 | - ) . '</small>', |
|
658 | + ).'</small>', |
|
659 | 659 | 'end_time', |
660 | 660 | 20, |
661 | 661 | 19, |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id)); |
670 | 670 | $poll_form->addElement(new \XoopsFormButton('', 'poll_submit', _MD_NEWBB_POLL_RESTART, 'submit')); |
671 | 671 | |
672 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
672 | + echo '<h4>'._MD_NEWBB_POLL_POLLCONF."</h4>\n"; |
|
673 | 673 | $poll_form->display(); |
674 | 674 | break; |
675 | 675 | |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | |
682 | 682 | // new xoopspoll module |
683 | 683 | if ($pollModuleHandler->getVar('version') >= 140) { |
684 | - $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
684 | + $classConstants = new XoopsModules\Xoopspoll\Constants(); |
|
685 | 685 | $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION; |
686 | 686 | $poll_not_mailed = $classConstants::POLL_NOT_MAILED; |
687 | 687 | $poll_mailed = $classConstants::POLL_MAILED; |
@@ -731,8 +731,8 @@ discard block |
||
731 | 731 | exit(); |
732 | 732 | } |
733 | 733 | if (Request::getInt('reset', 0, 'POST')) { // reset all logs |
734 | - $classOption = $classPoll . 'Option'; |
|
735 | - $classLog = $classPoll . 'Log'; |
|
734 | + $classOption = $classPoll.'Option'; |
|
735 | + $classLog = $classPoll.'Log'; |
|
736 | 736 | $classLog::deleteByPollId($poll_id); |
737 | 737 | $classOption::resetCountByPollId($poll_id); |
738 | 738 | $pollObject->updateCount(); |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | require_once $GLOBALS['xoops']->path('class/template.php'); |
742 | 742 | xoops_template_clear_module_cache($xoopsModule->getVar('mid')); |
743 | 743 | xoops_template_clear_module_cache($pollModuleHandler->getVar('mid')); |
744 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
744 | + redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED); |
|
745 | 745 | break; |
746 | 746 | |
747 | 747 | case 'log': |
@@ -756,5 +756,5 @@ discard block |
||
756 | 756 | } // switch |
757 | 757 | |
758 | 758 | // irmtfan move to footer.php |
759 | -require_once __DIR__ . '/footer.php'; |
|
759 | +require_once __DIR__.'/footer.php'; |
|
760 | 760 | require_once $GLOBALS['xoops']->path('footer.php'); |
@@ -36,9 +36,9 @@ |
||
36 | 36 | xoops_load('XoopsLists'); |
37 | 37 | $allfiles = \XoopsLists::getFileListAsArray($GLOBALS['xoops']->path($js_rel_path)); |
38 | 38 | foreach ($allfiles as $jsfile) { |
39 | - if ('js' === strtolower(pathinfo($jsfile, PATHINFO_EXTENSION))) { |
|
40 | - $xoTheme->addScript($js_rel_path . '/' . $jsfile); |
|
41 | - } |
|
39 | + if ('js' === strtolower(pathinfo($jsfile, PATHINFO_EXTENSION))) { |
|
40 | + $xoTheme->addScript($js_rel_path . '/' . $jsfile); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | global $forumCookie; // for $forumCookie["prefix"] revert last change - use global instead of include |
44 | 44 | // add toggle script |
@@ -25,23 +25,23 @@ |
||
25 | 25 | require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.render.php'); |
26 | 26 | $iconHandler = newbbGetIconHandler(); |
27 | 27 | // get css rel path from setted language |
28 | -$css_rel_path = $iconHandler->getPath('language/' . $GLOBALS['xoopsConfig']['language'], 'newbb', 'language/english', 'css'); |
|
28 | +$css_rel_path = $iconHandler->getPath('language/'.$GLOBALS['xoopsConfig']['language'], 'newbb', 'language/english', 'css'); |
|
29 | 29 | // add local stylesheet |
30 | 30 | /** @var xos_opal_Theme $xoTheme */ |
31 | -$xoTheme->addStylesheet($css_rel_path . '/style.css'); |
|
31 | +$xoTheme->addStylesheet($css_rel_path.'/style.css'); |
|
32 | 32 | |
33 | 33 | // get js rel path from setted language |
34 | -$js_rel_path = $iconHandler->getPath('language/' . $GLOBALS['xoopsConfig']['language'], 'newbb', 'language/english', 'js'); |
|
34 | +$js_rel_path = $iconHandler->getPath('language/'.$GLOBALS['xoopsConfig']['language'], 'newbb', 'language/english', 'js'); |
|
35 | 35 | // add all local js files inside js directory |
36 | 36 | xoops_load('XoopsLists'); |
37 | 37 | $allfiles = \XoopsLists::getFileListAsArray($GLOBALS['xoops']->path($js_rel_path)); |
38 | 38 | foreach ($allfiles as $jsfile) { |
39 | 39 | if ('js' === strtolower(pathinfo($jsfile, PATHINFO_EXTENSION))) { |
40 | - $xoTheme->addScript($js_rel_path . '/' . $jsfile); |
|
40 | + $xoTheme->addScript($js_rel_path.'/'.$jsfile); |
|
41 | 41 | } |
42 | 42 | } |
43 | -global $forumCookie; // for $forumCookie["prefix"] revert last change - use global instead of include |
|
43 | +global $forumCookie; // for $forumCookie["prefix"] revert last change - use global instead of include |
|
44 | 44 | // add toggle script |
45 | 45 | //$toggle_script = "var toggle_cookie=\"" . $forumCookie['prefix'] . 'G' . '\';'; |
46 | -$toggle_script = 'var toggle_cookie="' . $forumCookie['prefix'] . 'G";'; |
|
46 | +$toggle_script = 'var toggle_cookie="'.$forumCookie['prefix'].'G";'; |
|
47 | 47 | $xoTheme->addScript(null, ['type' => 'text/javascript'], $toggle_script); |
@@ -21,75 +21,75 @@ discard block |
||
21 | 21 | $forum_id = Request::getInt('forum', 0); |
22 | 22 | $isAdmin = newbbIsAdmin($forum_id); |
23 | 23 | if (!$isAdmin) { |
24 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
24 | + redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
25 | 25 | } |
26 | 26 | $is_administrator = $GLOBALS['xoopsUserIsAdmin']; |
27 | 27 | ///** @var Newbb\ModerateHandler $moderateHandler */ |
28 | 28 | //$moderateHandler = Newbb\Helper::getInstance()->getHandler('Moderate'); |
29 | 29 | |
30 | 30 | if (Request::hasVar('submit', 'POST') && Request::getInt('expire', 0, 'POST')) { |
31 | - $ipWithMask = ''; |
|
32 | - if (0 == $forum_userid) { |
|
33 | - $ipWithMask = Request::getString('ip', null, 'POST'); |
|
34 | - $mask = ''; |
|
35 | - $ipParts = explode('/', $ipWithMask); |
|
36 | - $ip = new \Xmf\IPAddress($ipParts[0]); |
|
37 | - if (false === $ip->asReadable()) { |
|
38 | - $ipWithMask = ''; |
|
39 | - } else { |
|
40 | - $ipWithMask = $ip->asReadable(); |
|
41 | - $mask = empty($ipParts[1]) ? 0 : (int)$ipParts[1]; |
|
42 | - $mask = ($mask > ((4 === $ip->ipVersion()) ? 32 : 128) || $mask < 8) ? '' : $mask; |
|
43 | - $ipWithMask .= empty($mask) ? '' : '/' . $mask; |
|
44 | - } |
|
45 | - } |
|
46 | - |
|
47 | - $mod_end = time() + Request::getInt('expire', 0, 'POST') * 3600 * 24; |
|
48 | - $mod_desc = Request::getString('desc', '', 'POST'); |
|
49 | - |
|
50 | - $moderateObject = $moderateHandler->create(); |
|
51 | - $moderateObject->setVar('uid', $forum_userid); |
|
52 | - $moderateObject->setVar('ip', $ipWithMask); |
|
53 | - $moderateObject->setVar('forum_id', $forum_id); |
|
54 | - $moderateObject->setVar('mod_start', time()); |
|
55 | - $moderateObject->setVar('mod_end', $mod_end); |
|
56 | - $moderateObject->setVar('mod_desc', $mod_desc); |
|
57 | - $res = $moderateHandler->insert($moderateObject); |
|
58 | - |
|
59 | - redirect_header("moderate.php?forum={$forum_id}", 2, _MD_NEWBB_DBUPDATED); |
|
31 | + $ipWithMask = ''; |
|
32 | + if (0 == $forum_userid) { |
|
33 | + $ipWithMask = Request::getString('ip', null, 'POST'); |
|
34 | + $mask = ''; |
|
35 | + $ipParts = explode('/', $ipWithMask); |
|
36 | + $ip = new \Xmf\IPAddress($ipParts[0]); |
|
37 | + if (false === $ip->asReadable()) { |
|
38 | + $ipWithMask = ''; |
|
39 | + } else { |
|
40 | + $ipWithMask = $ip->asReadable(); |
|
41 | + $mask = empty($ipParts[1]) ? 0 : (int)$ipParts[1]; |
|
42 | + $mask = ($mask > ((4 === $ip->ipVersion()) ? 32 : 128) || $mask < 8) ? '' : $mask; |
|
43 | + $ipWithMask .= empty($mask) ? '' : '/' . $mask; |
|
44 | + } |
|
45 | + } |
|
46 | + |
|
47 | + $mod_end = time() + Request::getInt('expire', 0, 'POST') * 3600 * 24; |
|
48 | + $mod_desc = Request::getString('desc', '', 'POST'); |
|
49 | + |
|
50 | + $moderateObject = $moderateHandler->create(); |
|
51 | + $moderateObject->setVar('uid', $forum_userid); |
|
52 | + $moderateObject->setVar('ip', $ipWithMask); |
|
53 | + $moderateObject->setVar('forum_id', $forum_id); |
|
54 | + $moderateObject->setVar('mod_start', time()); |
|
55 | + $moderateObject->setVar('mod_end', $mod_end); |
|
56 | + $moderateObject->setVar('mod_desc', $mod_desc); |
|
57 | + $res = $moderateHandler->insert($moderateObject); |
|
58 | + |
|
59 | + redirect_header("moderate.php?forum={$forum_id}", 2, _MD_NEWBB_DBUPDATED); |
|
60 | 60 | } elseif (Request::hasVar('del')) { |
61 | - $moderateObject = $moderateHandler->get(Request::getInt('del', 0, 'GET')); |
|
62 | - if ($is_administrator || $moderateObject->getVar('forum_id') == $forum_id) { |
|
63 | - $moderateHandler->delete($moderateObject, true); |
|
64 | - redirect_header("moderate.php?forum={$forum_id}", 2, _MD_NEWBB_DBUPDATED); |
|
65 | - } |
|
61 | + $moderateObject = $moderateHandler->get(Request::getInt('del', 0, 'GET')); |
|
62 | + if ($is_administrator || $moderateObject->getVar('forum_id') == $forum_id) { |
|
63 | + $moderateHandler->delete($moderateObject, true); |
|
64 | + redirect_header("moderate.php?forum={$forum_id}", 2, _MD_NEWBB_DBUPDATED); |
|
65 | + } |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $start = Request::getInt('start', 0, 'GET'); |
69 | 69 | $sortname = Request::getString('sort', '', 'GET'); |
70 | 70 | |
71 | 71 | switch ($sortname) { |
72 | - case 'uid': |
|
73 | - $sort = 'uid ASC, ip'; |
|
74 | - $order = 'ASC'; |
|
75 | - break; |
|
76 | - case 'start': |
|
77 | - $sort = 'mod_start'; |
|
78 | - $order = 'ASC'; |
|
79 | - break; |
|
80 | - case 'expire': |
|
81 | - $sort = 'mod_end'; |
|
82 | - $order = 'DESC'; |
|
83 | - break; |
|
84 | - default: |
|
85 | - $sort = 'forum_id ASC, uid ASC, ip'; |
|
86 | - $order = 'ASC'; |
|
87 | - break; |
|
72 | + case 'uid': |
|
73 | + $sort = 'uid ASC, ip'; |
|
74 | + $order = 'ASC'; |
|
75 | + break; |
|
76 | + case 'start': |
|
77 | + $sort = 'mod_start'; |
|
78 | + $order = 'ASC'; |
|
79 | + break; |
|
80 | + case 'expire': |
|
81 | + $sort = 'mod_end'; |
|
82 | + $order = 'DESC'; |
|
83 | + break; |
|
84 | + default: |
|
85 | + $sort = 'forum_id ASC, uid ASC, ip'; |
|
86 | + $order = 'ASC'; |
|
87 | + break; |
|
88 | 88 | } |
89 | 89 | // show all bans for module admin - for moderator just show its forum_id bans |
90 | 90 | $criteria = new \CriteriaCompo(); |
91 | 91 | if (!$is_administrator) { |
92 | - $criteria->add(new \Criteria('forum_id', $forum_id, '=')); |
|
92 | + $criteria->add(new \Criteria('forum_id', $forum_id, '=')); |
|
93 | 93 | } |
94 | 94 | $criteria->setLimit($GLOBALS['xoopsModuleConfig']['topics_per_page']); |
95 | 95 | $criteria->setStart($start); |
@@ -100,75 +100,75 @@ discard block |
||
100 | 100 | |
101 | 101 | $url = 'moderate.php'; |
102 | 102 | if ($forum_id) { |
103 | - $url .= '?forum=' . $forum_id; |
|
103 | + $url .= '?forum=' . $forum_id; |
|
104 | 104 | } |
105 | 105 | $xoopsTpl->assign('moderate_url', $url); |
106 | 106 | |
107 | 107 | if (!empty($moderate_count)) { |
108 | - $_users = []; |
|
109 | - foreach (array_keys($moderateObjects) as $id) { |
|
110 | - $_users[$moderateObjects[$id]->getVar('uid')] = 1; |
|
111 | - } |
|
112 | - $users = newbbGetUnameFromIds(array_keys($_users), $GLOBALS['xoopsModuleConfig']['show_realname'], true); |
|
113 | - |
|
114 | - $columnHeaders ['uid'] = [ |
|
115 | - 'url' => 'moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=uid', |
|
116 | - 'header' => _MD_NEWBB_SUSPEND_UID, |
|
117 | - 'title' => _MD_NEWBB_SUSPEND_UID, |
|
118 | - ]; |
|
119 | - $columnHeaders ['start'] = [ |
|
120 | - 'url' => 'moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=start', |
|
121 | - 'header' => _MD_NEWBB_SUSPEND_START, |
|
122 | - 'title' => _MD_NEWBB_SUSPEND_START, |
|
123 | - ]; |
|
124 | - $columnHeaders['expire'] = [ |
|
125 | - 'url' => 'moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=expire', |
|
126 | - 'header' => _MD_NEWBB_SUSPEND_EXPIRE, |
|
127 | - 'title' => _MD_NEWBB_SUSPEND_EXPIRE, |
|
128 | - ]; |
|
129 | - $columnHeaders['forum'] = [ |
|
130 | - 'url' => 'moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=forum', |
|
131 | - 'header' => _MD_NEWBB_SUSPEND_SCOPE, |
|
132 | - 'title' => _MD_NEWBB_SUSPEND_SCOPE, |
|
133 | - ]; |
|
134 | - $columnHeaders['desc'] = [ |
|
135 | - 'url' => false, |
|
136 | - 'header' => _MD_NEWBB_SUSPEND_DESC, |
|
137 | - 'title' => _MD_NEWBB_SUSPEND_DESC, |
|
138 | - ]; |
|
139 | - $columnHeaders['options'] = [ |
|
140 | - 'url' => false, |
|
141 | - 'header' => _DELETE, |
|
142 | - 'title' => _DELETE, |
|
143 | - ]; |
|
144 | - $xoopsTpl->assign('columnHeaders', $columnHeaders); |
|
145 | - |
|
146 | - // /** @var Newbb\ForumHandler $forumHandler */ |
|
147 | - // $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
148 | - $forum_list = $forumHandler->getAll(null, ['forum_name'], false); |
|
149 | - |
|
150 | - $columnRows = []; |
|
151 | - foreach (array_keys($moderateObjects) as $id) { |
|
152 | - // for anon, show ip instead |
|
153 | - $row['uid'] = ($moderateObjects[$id]->getVar('uid') ? (isset($users[$moderateObjects[$id]->getVar('uid')]) ? $users[$moderateObjects[$id]->getVar('uid')] : $moderateObjects[$id]->getVar('uid')) : $moderateObjects[$id]->getVar('ip')); |
|
154 | - $row['start'] = formatTimestamp($moderateObjects[$id]->getVar('mod_start')); |
|
155 | - $row['expire'] = formatTimestamp($moderateObjects[$id]->getVar('mod_end')); |
|
156 | - $row['forum'] = ($moderateObjects[$id]->getVar('forum_id') ? $forum_list[$moderateObjects[$id]->getVar('forum_id')]['forum_name'] : _ALL); |
|
157 | - $row['desc'] = ($moderateObjects[$id]->getVar('mod_desc') ?: _NONE); |
|
158 | - $row['options'] = (($is_administrator |
|
159 | - || $moderateObjects[$id]->getVar('forum_id') == $forum_id) ? '<a href="moderate.php?forum=' . $forum_id . '&del=' . $moderateObjects[$id]->getVar('mod_id') . '">' . _DELETE . '</a>' : ''); |
|
160 | - $columnRows[] = $row; |
|
161 | - } |
|
162 | - $xoopsTpl->assign('columnRows', $columnRows); |
|
163 | - |
|
164 | - if ($moderate_count > $GLOBALS['xoopsModuleConfig']['topics_per_page']) { |
|
165 | - require_once $GLOBALS['xoops']->path('class/pagenav.php'); |
|
166 | - $nav = new \XoopsPageNav($moderate_count, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start, 'start', 'forum=' . $forum_id . '&sort=' . $sortname); |
|
167 | - //if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
|
168 | - // $nav->url = formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . ' /' . $nav->url; |
|
169 | - //} |
|
170 | - $xoopsTpl->assign('moderate_page_nav', $nav->renderNav()); |
|
171 | - } |
|
108 | + $_users = []; |
|
109 | + foreach (array_keys($moderateObjects) as $id) { |
|
110 | + $_users[$moderateObjects[$id]->getVar('uid')] = 1; |
|
111 | + } |
|
112 | + $users = newbbGetUnameFromIds(array_keys($_users), $GLOBALS['xoopsModuleConfig']['show_realname'], true); |
|
113 | + |
|
114 | + $columnHeaders ['uid'] = [ |
|
115 | + 'url' => 'moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=uid', |
|
116 | + 'header' => _MD_NEWBB_SUSPEND_UID, |
|
117 | + 'title' => _MD_NEWBB_SUSPEND_UID, |
|
118 | + ]; |
|
119 | + $columnHeaders ['start'] = [ |
|
120 | + 'url' => 'moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=start', |
|
121 | + 'header' => _MD_NEWBB_SUSPEND_START, |
|
122 | + 'title' => _MD_NEWBB_SUSPEND_START, |
|
123 | + ]; |
|
124 | + $columnHeaders['expire'] = [ |
|
125 | + 'url' => 'moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=expire', |
|
126 | + 'header' => _MD_NEWBB_SUSPEND_EXPIRE, |
|
127 | + 'title' => _MD_NEWBB_SUSPEND_EXPIRE, |
|
128 | + ]; |
|
129 | + $columnHeaders['forum'] = [ |
|
130 | + 'url' => 'moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=forum', |
|
131 | + 'header' => _MD_NEWBB_SUSPEND_SCOPE, |
|
132 | + 'title' => _MD_NEWBB_SUSPEND_SCOPE, |
|
133 | + ]; |
|
134 | + $columnHeaders['desc'] = [ |
|
135 | + 'url' => false, |
|
136 | + 'header' => _MD_NEWBB_SUSPEND_DESC, |
|
137 | + 'title' => _MD_NEWBB_SUSPEND_DESC, |
|
138 | + ]; |
|
139 | + $columnHeaders['options'] = [ |
|
140 | + 'url' => false, |
|
141 | + 'header' => _DELETE, |
|
142 | + 'title' => _DELETE, |
|
143 | + ]; |
|
144 | + $xoopsTpl->assign('columnHeaders', $columnHeaders); |
|
145 | + |
|
146 | + // /** @var Newbb\ForumHandler $forumHandler */ |
|
147 | + // $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
148 | + $forum_list = $forumHandler->getAll(null, ['forum_name'], false); |
|
149 | + |
|
150 | + $columnRows = []; |
|
151 | + foreach (array_keys($moderateObjects) as $id) { |
|
152 | + // for anon, show ip instead |
|
153 | + $row['uid'] = ($moderateObjects[$id]->getVar('uid') ? (isset($users[$moderateObjects[$id]->getVar('uid')]) ? $users[$moderateObjects[$id]->getVar('uid')] : $moderateObjects[$id]->getVar('uid')) : $moderateObjects[$id]->getVar('ip')); |
|
154 | + $row['start'] = formatTimestamp($moderateObjects[$id]->getVar('mod_start')); |
|
155 | + $row['expire'] = formatTimestamp($moderateObjects[$id]->getVar('mod_end')); |
|
156 | + $row['forum'] = ($moderateObjects[$id]->getVar('forum_id') ? $forum_list[$moderateObjects[$id]->getVar('forum_id')]['forum_name'] : _ALL); |
|
157 | + $row['desc'] = ($moderateObjects[$id]->getVar('mod_desc') ?: _NONE); |
|
158 | + $row['options'] = (($is_administrator |
|
159 | + || $moderateObjects[$id]->getVar('forum_id') == $forum_id) ? '<a href="moderate.php?forum=' . $forum_id . '&del=' . $moderateObjects[$id]->getVar('mod_id') . '">' . _DELETE . '</a>' : ''); |
|
160 | + $columnRows[] = $row; |
|
161 | + } |
|
162 | + $xoopsTpl->assign('columnRows', $columnRows); |
|
163 | + |
|
164 | + if ($moderate_count > $GLOBALS['xoopsModuleConfig']['topics_per_page']) { |
|
165 | + require_once $GLOBALS['xoops']->path('class/pagenav.php'); |
|
166 | + $nav = new \XoopsPageNav($moderate_count, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start, 'start', 'forum=' . $forum_id . '&sort=' . $sortname); |
|
167 | + //if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
|
168 | + // $nav->url = formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . ' /' . $nav->url; |
|
169 | + //} |
|
170 | + $xoopsTpl->assign('moderate_page_nav', $nav->renderNav()); |
|
171 | + } |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
@@ -179,19 +179,19 @@ discard block |
||
179 | 179 | $forum_form->addElement(new \XoopsFormText(_MD_NEWBB_SUSPEND_DESC, 'desc', 50, 255)); |
180 | 180 | require_once __DIR__ . '/include/functions.forum.php'; |
181 | 181 | if (newbbIsAdmin()) { |
182 | - $forumSel = '<select name="forum">';// if user doesn't select, default is "0" all forums |
|
183 | - $forumSel .= '<option value="0"'; |
|
184 | - if (0 == $forum_id) { |
|
185 | - $forumSel .= ' selected'; |
|
186 | - } |
|
187 | - $forumSel .= '>' . _ALL . '</option>'; |
|
188 | - $forumSel .= newbbForumSelectBox($forum_id, 'access', false); //$accessForums, $permission = "access", $delimitorCategory = true |
|
189 | - $forumSel .= '</select>'; |
|
190 | - $forumEle = new \XoopsFormLabel(_MD_NEWBB_SELFORUM, $forumSel); |
|
191 | - $forumEle->customValidationCode[] = 'if (document.suspend.forum.value < 0) {return false;} '; |
|
192 | - $forum_form->addElement($forumEle); |
|
182 | + $forumSel = '<select name="forum">';// if user doesn't select, default is "0" all forums |
|
183 | + $forumSel .= '<option value="0"'; |
|
184 | + if (0 == $forum_id) { |
|
185 | + $forumSel .= ' selected'; |
|
186 | + } |
|
187 | + $forumSel .= '>' . _ALL . '</option>'; |
|
188 | + $forumSel .= newbbForumSelectBox($forum_id, 'access', false); //$accessForums, $permission = "access", $delimitorCategory = true |
|
189 | + $forumSel .= '</select>'; |
|
190 | + $forumEle = new \XoopsFormLabel(_MD_NEWBB_SELFORUM, $forumSel); |
|
191 | + $forumEle->customValidationCode[] = 'if (document.suspend.forum.value < 0) {return false;} '; |
|
192 | + $forum_form->addElement($forumEle); |
|
193 | 193 | } else { |
194 | - $forum_form->addElement(new \XoopsFormHidden('forum', $forum_id)); |
|
194 | + $forum_form->addElement(new \XoopsFormHidden('forum', $forum_id)); |
|
195 | 195 | } |
196 | 196 | $forum_form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
197 | 197 | $forum_form->assign($xoopsTpl); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | use Xmf\Request; |
13 | 13 | |
14 | -require_once __DIR__ . '/header.php'; |
|
14 | +require_once __DIR__.'/header.php'; |
|
15 | 15 | |
16 | 16 | global $xoTheme, $xoopsTpl; |
17 | 17 | $GLOBALS['xoopsOption']['template_main'] = 'newbb_moderate.tpl'; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $forum_id = Request::getInt('forum', 0); |
22 | 22 | $isAdmin = newbbIsAdmin($forum_id); |
23 | 23 | if (!$isAdmin) { |
24 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
24 | + redirect_header(XOOPS_URL.'/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
25 | 25 | } |
26 | 26 | $is_administrator = $GLOBALS['xoopsUserIsAdmin']; |
27 | 27 | ///** @var Newbb\ModerateHandler $moderateHandler */ |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | $ipWithMask = ''; |
39 | 39 | } else { |
40 | 40 | $ipWithMask = $ip->asReadable(); |
41 | - $mask = empty($ipParts[1]) ? 0 : (int)$ipParts[1]; |
|
41 | + $mask = empty($ipParts[1]) ? 0 : (int) $ipParts[1]; |
|
42 | 42 | $mask = ($mask > ((4 === $ip->ipVersion()) ? 32 : 128) || $mask < 8) ? '' : $mask; |
43 | - $ipWithMask .= empty($mask) ? '' : '/' . $mask; |
|
43 | + $ipWithMask .= empty($mask) ? '' : '/'.$mask; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | $url = 'moderate.php'; |
102 | 102 | if ($forum_id) { |
103 | - $url .= '?forum=' . $forum_id; |
|
103 | + $url .= '?forum='.$forum_id; |
|
104 | 104 | } |
105 | 105 | $xoopsTpl->assign('moderate_url', $url); |
106 | 106 | |
@@ -111,27 +111,27 @@ discard block |
||
111 | 111 | } |
112 | 112 | $users = newbbGetUnameFromIds(array_keys($_users), $GLOBALS['xoopsModuleConfig']['show_realname'], true); |
113 | 113 | |
114 | - $columnHeaders ['uid'] = [ |
|
115 | - 'url' => 'moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=uid', |
|
114 | + $columnHeaders ['uid'] = [ |
|
115 | + 'url' => 'moderate.php?forum='.$forum_id.'&start='.$start.'&sort=uid', |
|
116 | 116 | 'header' => _MD_NEWBB_SUSPEND_UID, |
117 | 117 | 'title' => _MD_NEWBB_SUSPEND_UID, |
118 | 118 | ]; |
119 | - $columnHeaders ['start'] = [ |
|
120 | - 'url' => 'moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=start', |
|
119 | + $columnHeaders ['start'] = [ |
|
120 | + 'url' => 'moderate.php?forum='.$forum_id.'&start='.$start.'&sort=start', |
|
121 | 121 | 'header' => _MD_NEWBB_SUSPEND_START, |
122 | 122 | 'title' => _MD_NEWBB_SUSPEND_START, |
123 | 123 | ]; |
124 | - $columnHeaders['expire'] = [ |
|
125 | - 'url' => 'moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=expire', |
|
124 | + $columnHeaders['expire'] = [ |
|
125 | + 'url' => 'moderate.php?forum='.$forum_id.'&start='.$start.'&sort=expire', |
|
126 | 126 | 'header' => _MD_NEWBB_SUSPEND_EXPIRE, |
127 | 127 | 'title' => _MD_NEWBB_SUSPEND_EXPIRE, |
128 | 128 | ]; |
129 | - $columnHeaders['forum'] = [ |
|
130 | - 'url' => 'moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=forum', |
|
129 | + $columnHeaders['forum'] = [ |
|
130 | + 'url' => 'moderate.php?forum='.$forum_id.'&start='.$start.'&sort=forum', |
|
131 | 131 | 'header' => _MD_NEWBB_SUSPEND_SCOPE, |
132 | 132 | 'title' => _MD_NEWBB_SUSPEND_SCOPE, |
133 | 133 | ]; |
134 | - $columnHeaders['desc'] = [ |
|
134 | + $columnHeaders['desc'] = [ |
|
135 | 135 | 'url' => false, |
136 | 136 | 'header' => _MD_NEWBB_SUSPEND_DESC, |
137 | 137 | 'title' => _MD_NEWBB_SUSPEND_DESC, |
@@ -156,14 +156,14 @@ discard block |
||
156 | 156 | $row['forum'] = ($moderateObjects[$id]->getVar('forum_id') ? $forum_list[$moderateObjects[$id]->getVar('forum_id')]['forum_name'] : _ALL); |
157 | 157 | $row['desc'] = ($moderateObjects[$id]->getVar('mod_desc') ?: _NONE); |
158 | 158 | $row['options'] = (($is_administrator |
159 | - || $moderateObjects[$id]->getVar('forum_id') == $forum_id) ? '<a href="moderate.php?forum=' . $forum_id . '&del=' . $moderateObjects[$id]->getVar('mod_id') . '">' . _DELETE . '</a>' : ''); |
|
159 | + || $moderateObjects[$id]->getVar('forum_id') == $forum_id) ? '<a href="moderate.php?forum='.$forum_id.'&del='.$moderateObjects[$id]->getVar('mod_id').'">'._DELETE.'</a>' : ''); |
|
160 | 160 | $columnRows[] = $row; |
161 | 161 | } |
162 | 162 | $xoopsTpl->assign('columnRows', $columnRows); |
163 | 163 | |
164 | 164 | if ($moderate_count > $GLOBALS['xoopsModuleConfig']['topics_per_page']) { |
165 | 165 | require_once $GLOBALS['xoops']->path('class/pagenav.php'); |
166 | - $nav = new \XoopsPageNav($moderate_count, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start, 'start', 'forum=' . $forum_id . '&sort=' . $sortname); |
|
166 | + $nav = new \XoopsPageNav($moderate_count, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start, 'start', 'forum='.$forum_id.'&sort='.$sortname); |
|
167 | 167 | //if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
168 | 168 | // $nav->url = formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . ' /' . $nav->url; |
169 | 169 | //} |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | $forum_form->addElement(new \XoopsFormText(_MD_NEWBB_SUSPEND_IP, 'ip', 50, 50)); |
178 | 178 | $forum_form->addElement(new \XoopsFormText(_MD_NEWBB_SUSPEND_DURATION, 'expire', 20, 25, '5'), true); |
179 | 179 | $forum_form->addElement(new \XoopsFormText(_MD_NEWBB_SUSPEND_DESC, 'desc', 50, 255)); |
180 | -require_once __DIR__ . '/include/functions.forum.php'; |
|
180 | +require_once __DIR__.'/include/functions.forum.php'; |
|
181 | 181 | if (newbbIsAdmin()) { |
182 | - $forumSel = '<select name="forum">';// if user doesn't select, default is "0" all forums |
|
182 | + $forumSel = '<select name="forum">'; // if user doesn't select, default is "0" all forums |
|
183 | 183 | $forumSel .= '<option value="0"'; |
184 | 184 | if (0 == $forum_id) { |
185 | 185 | $forumSel .= ' selected'; |
186 | 186 | } |
187 | - $forumSel .= '>' . _ALL . '</option>'; |
|
187 | + $forumSel .= '>'._ALL.'</option>'; |
|
188 | 188 | $forumSel .= newbbForumSelectBox($forum_id, 'access', false); //$accessForums, $permission = "access", $delimitorCategory = true |
189 | 189 | $forumSel .= '</select>'; |
190 | 190 | $forumEle = new \XoopsFormLabel(_MD_NEWBB_SELFORUM, $forumSel); |
@@ -196,5 +196,5 @@ discard block |
||
196 | 196 | $forum_form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
197 | 197 | $forum_form->assign($xoopsTpl); |
198 | 198 | |
199 | -require_once __DIR__ . '/footer.php'; |
|
199 | +require_once __DIR__.'/footer.php'; |
|
200 | 200 | require_once $GLOBALS['xoops']->path('footer.php'); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
16 | 16 | |
17 | 17 | if (defined('LIST_TOPIC_DEFINED')) { |
18 | - return; |
|
18 | + return; |
|
19 | 19 | } |
20 | 20 | define('LIST_TOPIC_DEFINED', true); |
21 | 21 | |
@@ -51,47 +51,47 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function newbb_list_topic_show($options) |
53 | 53 | { |
54 | - $newbbConfig = newbbLoadConfig(); // load all newbb configs |
|
55 | - |
|
56 | - $topicRenderer = new Newbb\TopicRenderer(); |
|
57 | - $topicRenderer->userlevel = $GLOBALS['xoopsUserIsAdmin'] ? 2 : is_object($GLOBALS['xoopsUser']); // Vistitor's level: 0 - anonymous; 1 - user; 2 - moderator or admin |
|
58 | - |
|
59 | - $topicRenderer->force = true; // force against static vars for parse |
|
60 | - |
|
61 | - $topicRenderer->is_multiple = true; // is it for multiple forums |
|
62 | - $topicRenderer->config =& $newbbConfig; // get all configs |
|
63 | - if (!empty($options[6])) { |
|
64 | - $topicRenderer->config['topics_per_page'] = (int)$options[6]; // number of topics (items) to display |
|
65 | - } |
|
66 | - $topicRenderer->config['topic_title_excerpt'] = (int)$options[10]; // topic title length 0 = dont excerpt |
|
67 | - $topicRenderer->config['post_excerpt'] = (int)$options[11]; // post text excerpt 0 = no post text |
|
68 | - |
|
69 | - $optionsStatus = explode(',', $options[0]); // status in where claus |
|
70 | - $optionsForum = explode(',', $options[12]); |
|
71 | - |
|
72 | - // set and parse values: |
|
73 | - // forum: parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums |
|
74 | - $topicRenderer->setVars([ |
|
75 | - 'status' => $optionsStatus, |
|
76 | - 'uid' => $options[1], |
|
77 | - 'lastposter' => $options[2], |
|
78 | - 'type' => $options[3], |
|
79 | - 'sort' => $options[4], |
|
80 | - 'order' => $options[5], |
|
81 | - 'since' => $options[7], |
|
82 | - 'forum' => $optionsForum |
|
83 | - ]); |
|
84 | - $block = []; |
|
85 | - // headers to display in block |
|
86 | - $block['headers'] = $topicRenderer->getHeader($options[8]); |
|
87 | - |
|
88 | - // render a list of topics using all above criterias |
|
89 | - list($block['topics'], $block['sticky']) = $topicRenderer->renderTopics(); |
|
90 | - |
|
91 | - // show index navigation |
|
92 | - $block['indexNav'] = !empty($options[9]); |
|
93 | - |
|
94 | - return $block; |
|
54 | + $newbbConfig = newbbLoadConfig(); // load all newbb configs |
|
55 | + |
|
56 | + $topicRenderer = new Newbb\TopicRenderer(); |
|
57 | + $topicRenderer->userlevel = $GLOBALS['xoopsUserIsAdmin'] ? 2 : is_object($GLOBALS['xoopsUser']); // Vistitor's level: 0 - anonymous; 1 - user; 2 - moderator or admin |
|
58 | + |
|
59 | + $topicRenderer->force = true; // force against static vars for parse |
|
60 | + |
|
61 | + $topicRenderer->is_multiple = true; // is it for multiple forums |
|
62 | + $topicRenderer->config =& $newbbConfig; // get all configs |
|
63 | + if (!empty($options[6])) { |
|
64 | + $topicRenderer->config['topics_per_page'] = (int)$options[6]; // number of topics (items) to display |
|
65 | + } |
|
66 | + $topicRenderer->config['topic_title_excerpt'] = (int)$options[10]; // topic title length 0 = dont excerpt |
|
67 | + $topicRenderer->config['post_excerpt'] = (int)$options[11]; // post text excerpt 0 = no post text |
|
68 | + |
|
69 | + $optionsStatus = explode(',', $options[0]); // status in where claus |
|
70 | + $optionsForum = explode(',', $options[12]); |
|
71 | + |
|
72 | + // set and parse values: |
|
73 | + // forum: parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums |
|
74 | + $topicRenderer->setVars([ |
|
75 | + 'status' => $optionsStatus, |
|
76 | + 'uid' => $options[1], |
|
77 | + 'lastposter' => $options[2], |
|
78 | + 'type' => $options[3], |
|
79 | + 'sort' => $options[4], |
|
80 | + 'order' => $options[5], |
|
81 | + 'since' => $options[7], |
|
82 | + 'forum' => $optionsForum |
|
83 | + ]); |
|
84 | + $block = []; |
|
85 | + // headers to display in block |
|
86 | + $block['headers'] = $topicRenderer->getHeader($options[8]); |
|
87 | + |
|
88 | + // render a list of topics using all above criterias |
|
89 | + list($block['topics'], $block['sticky']) = $topicRenderer->renderTopics(); |
|
90 | + |
|
91 | + // show index navigation |
|
92 | + $block['indexNav'] = !empty($options[9]); |
|
93 | + |
|
94 | + return $block; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -100,118 +100,118 @@ discard block |
||
100 | 100 | */ |
101 | 101 | function newbb_list_topic_edit($options) |
102 | 102 | { |
103 | - // require_once $GLOBALS['xoops']->path('class/blockform.php'); //reserve for 2.6 |
|
104 | - xoops_load('XoopsFormLoader'); |
|
105 | - // $form = new \XoopsBlockForm(); //reserve for 2.6 |
|
106 | - $form = new \XoopsThemeForm(_MB_NEWBB_DISPLAYMODE_DESC, 'list_topic', ''); |
|
107 | - |
|
108 | - $topicRenderer = new Newbb\TopicRenderer(); |
|
109 | - $topicRenderer->userlevel = 2; // 2 - moderator or admin |
|
110 | - |
|
111 | - // status element |
|
112 | - $optionsStatus = explode(',', $options[0]); |
|
113 | - $statusEle = new \XoopsFormSelect(_MB_NEWBB_CRITERIA, 'options[0]', $optionsStatus, 5, true); |
|
114 | - $status = $topicRenderer->getStatus($topicRenderer->userlevel); // get all public status + admin status (admin mode, pending deleted) |
|
115 | - $statusEle->addOptionArray($status); |
|
116 | - $statusEle->setExtra("onchange = \"validate('options[0][]','select', true)\""); // if user dont select any option it select "all" |
|
117 | - $statusEle->setDescription(_MB_NEWBB_CRITERIA_DESC); |
|
118 | - |
|
119 | - // topic_poster element |
|
120 | - $topicPosterRadioEle = new \XoopsFormRadio(_MB_NEWBB_AUTHOR, 'options[1]', $options[1]); |
|
121 | - $topicPosterRadioEle->addOption(-1, _MD_NEWBB_TOTALUSER); |
|
122 | - $topicPosterRadioEle->addOption((-1 !== $options[1]) ? $options[1] : 0, _SELECT); // if no user in selection box it select uid=0 anon users |
|
123 | - $topicPosterRadioEle->setExtra("onchange=\"var el=document.getElementById('options[1]'); el.disabled=(this.id == 'options[1]1'); if (!el.value) {el.value= this.value}\""); // if user dont select any option it select "all" |
|
124 | - $topicPosterSelectEle = new \XoopsFormSelectUser(_MB_NEWBB_AUTHOR, 'options[1]', true, explode(',', $options[1]), 5, true);// show $limit = 200 users when no user is selected; |
|
125 | - $topicPosterEle = new \XoopsFormLabel(_MB_NEWBB_AUTHOR, $topicPosterRadioEle->render() . $topicPosterSelectEle->render()); |
|
126 | - |
|
127 | - // lastposter element |
|
128 | - $lastPosterRadioEle = new \XoopsFormRadio(_MD_NEWBB_POSTER, 'options[2]', $options[2]); |
|
129 | - $lastPosterRadioEle->addOption(-1, _MD_NEWBB_TOTALUSER); |
|
130 | - $lastPosterRadioEle->addOption((-1 !== $options[2]) ? $options[2] : 0, _SELECT); // if no user in selection box it select uid=1 |
|
131 | - $lastPosterRadioEle->setExtra("onchange=\"var el=document.getElementById('options[2]'); el.disabled=(this.id == 'options[2]1'); if (!el.value) {el.value= this.value}\""); // if user dont select any option it select "all" |
|
132 | - $lastPosterSelectEle = new \XoopsFormSelectUser(_MD_NEWBB_POSTER, 'options[2]', true, explode(',', $options[2]), 5, true);// show $limit = 200 users when no user is selected; |
|
133 | - $lastPosterEle = new \XoopsFormLabel(_MD_NEWBB_POSTER, $lastPosterRadioEle->render() . $lastPosterSelectEle->render()); |
|
134 | - |
|
135 | - // type element |
|
136 | - $types = $topicRenderer->getTypes(); // get all available types in all forums |
|
137 | - $typeEle = new \XoopsFormSelect(_MD_NEWBB_TYPE, 'options[3]', $options[3]); |
|
138 | - $typeEle->addOption(0, _NONE); |
|
139 | - if (!empty($types)) { |
|
140 | - foreach ($types as $type_id => $type) { |
|
141 | - $typeEle->addOption($type_id, $type['type_name']); |
|
142 | - } |
|
143 | - } |
|
144 | - |
|
145 | - // sort element |
|
146 | - $sortEle = new \XoopsFormSelect(_MD_NEWBB_SORTBY, 'options[4]', $options[4]); |
|
147 | - $sortEle->setDescription(_MB_NEWBB_CRITERIA_SORT_DESC); |
|
148 | - $sorts = $topicRenderer->getSort('', 'title'); |
|
149 | - $sortEle->addOptionArray($sorts); |
|
150 | - |
|
151 | - // order element |
|
152 | - $orderEle = new \XoopsFormSelect(_MB_NEWBB_CRITERIA_ORDER, 'options[5]', $options[5]); |
|
153 | - $orderEle->addOption(0, _DESCENDING); |
|
154 | - $orderEle->addOption(1, _ASCENDING); |
|
155 | - |
|
156 | - // number of topics to display element |
|
157 | - $numdispEle = new \XoopsFormText(_MB_NEWBB_DISPLAY, 'options[6]', 10, 255, (int)$options[6]); |
|
158 | - |
|
159 | - $timeEle = new \XoopsFormText(_MB_NEWBB_TIME, 'options[7]', 10, 255, $options[7]); |
|
160 | - $timeEle->setDescription(_MB_NEWBB_TIME_DESC); |
|
161 | - |
|
162 | - // mode disp element |
|
163 | - $options_headers = explode(',', $options[8]); |
|
164 | - $modeEle = new \XoopsFormCheckBox(_MB_NEWBB_DISPLAYMODE, 'options[8][]', $options_headers); |
|
165 | - $modeEle->setDescription(_MB_NEWBB_DISPLAYMODE_DESC); |
|
166 | - $modeEle->columns = 4; |
|
167 | - $disps = $topicRenderer->getHeader(); |
|
168 | - $modeEle->addOptionArray($disps); |
|
169 | - $modeEle->setExtra("onchange = \"validate('options[8][]','checkbox', true)\""); // prevent user select no option |
|
170 | - // Index navigation element |
|
171 | - $navEle = new \XoopsFormRadioYN(_MB_NEWBB_INDEXNAV, 'options[9]', !empty($options[9])); |
|
172 | - |
|
173 | - // Topic title element |
|
174 | - $lengthEle = new \XoopsFormText(_MB_NEWBB_TITLE_LENGTH, 'options[10]', 10, 255, (int)$options[10]); |
|
175 | - $lengthEle->setDescription(_MB_NEWBB_TITLE_LENGTH_DESC); |
|
176 | - |
|
177 | - // Post text element |
|
178 | - $postExcerptEle = new \XoopsFormText(_MB_NEWBB_POST_EXCERPT, 'options[11]', 10, 255, (int)$options[11]); |
|
179 | - $postExcerptEle->setDescription(_MB_NEWBB_POST_EXCERPT_DESC); |
|
180 | - |
|
181 | - // forum element |
|
182 | - $optionsForum = explode(',', $options[12]); |
|
183 | - require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
184 | - /** @var Newbb\ForumHandler $forumHandler */ |
|
185 | - $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
186 | - //get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums |
|
187 | - // Get accessible forums |
|
188 | - $accessForums = $forumHandler->getIdsByValues(array_map('intval', $optionsForum)); |
|
189 | - $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
190 | - $forumSel = "<select name=\"options[12][]\" multiple=\"multiple\" onchange = \"validate('options[12][]','select', true)\">";// if user dont select any it select "0" |
|
191 | - $forumSel .= '<option value="0" '; |
|
192 | - if ($isAll) { |
|
193 | - $forumSel .= ' selected'; |
|
194 | - $accessForums = null; // just select _ALL option |
|
195 | - } |
|
196 | - $forumSel .= '>' . _ALL . '</option>'; |
|
197 | - $forumSel .= newbbForumSelectBox($accessForums, 'access', false); //$accessForums, $permission = "access", $delimitorCategory = false |
|
198 | - $forumSel .= '</select>'; |
|
199 | - $forumEle = new \XoopsFormLabel(_MB_NEWBB_FORUMLIST, $forumSel); |
|
200 | - |
|
201 | - // add all elements to form |
|
202 | - $form->addElement($statusEle); |
|
203 | - $form->addElement($topicPosterEle); |
|
204 | - $form->addElement($lastPosterEle); |
|
205 | - $form->addElement($typeEle); |
|
206 | - $form->addElement($sortEle); |
|
207 | - $form->addElement($orderEle); |
|
208 | - $form->addElement($numdispEle); |
|
209 | - $form->addElement($timeEle); |
|
210 | - $form->addElement($modeEle, true); // required: user should select at least one otherwise it will select the first one |
|
211 | - $form->addElement($navEle); |
|
212 | - $form->addElement($lengthEle); |
|
213 | - $form->addElement($postExcerptEle); |
|
214 | - $form->addElement($forumEle); |
|
215 | - |
|
216 | - return $form->render(); |
|
103 | + // require_once $GLOBALS['xoops']->path('class/blockform.php'); //reserve for 2.6 |
|
104 | + xoops_load('XoopsFormLoader'); |
|
105 | + // $form = new \XoopsBlockForm(); //reserve for 2.6 |
|
106 | + $form = new \XoopsThemeForm(_MB_NEWBB_DISPLAYMODE_DESC, 'list_topic', ''); |
|
107 | + |
|
108 | + $topicRenderer = new Newbb\TopicRenderer(); |
|
109 | + $topicRenderer->userlevel = 2; // 2 - moderator or admin |
|
110 | + |
|
111 | + // status element |
|
112 | + $optionsStatus = explode(',', $options[0]); |
|
113 | + $statusEle = new \XoopsFormSelect(_MB_NEWBB_CRITERIA, 'options[0]', $optionsStatus, 5, true); |
|
114 | + $status = $topicRenderer->getStatus($topicRenderer->userlevel); // get all public status + admin status (admin mode, pending deleted) |
|
115 | + $statusEle->addOptionArray($status); |
|
116 | + $statusEle->setExtra("onchange = \"validate('options[0][]','select', true)\""); // if user dont select any option it select "all" |
|
117 | + $statusEle->setDescription(_MB_NEWBB_CRITERIA_DESC); |
|
118 | + |
|
119 | + // topic_poster element |
|
120 | + $topicPosterRadioEle = new \XoopsFormRadio(_MB_NEWBB_AUTHOR, 'options[1]', $options[1]); |
|
121 | + $topicPosterRadioEle->addOption(-1, _MD_NEWBB_TOTALUSER); |
|
122 | + $topicPosterRadioEle->addOption((-1 !== $options[1]) ? $options[1] : 0, _SELECT); // if no user in selection box it select uid=0 anon users |
|
123 | + $topicPosterRadioEle->setExtra("onchange=\"var el=document.getElementById('options[1]'); el.disabled=(this.id == 'options[1]1'); if (!el.value) {el.value= this.value}\""); // if user dont select any option it select "all" |
|
124 | + $topicPosterSelectEle = new \XoopsFormSelectUser(_MB_NEWBB_AUTHOR, 'options[1]', true, explode(',', $options[1]), 5, true);// show $limit = 200 users when no user is selected; |
|
125 | + $topicPosterEle = new \XoopsFormLabel(_MB_NEWBB_AUTHOR, $topicPosterRadioEle->render() . $topicPosterSelectEle->render()); |
|
126 | + |
|
127 | + // lastposter element |
|
128 | + $lastPosterRadioEle = new \XoopsFormRadio(_MD_NEWBB_POSTER, 'options[2]', $options[2]); |
|
129 | + $lastPosterRadioEle->addOption(-1, _MD_NEWBB_TOTALUSER); |
|
130 | + $lastPosterRadioEle->addOption((-1 !== $options[2]) ? $options[2] : 0, _SELECT); // if no user in selection box it select uid=1 |
|
131 | + $lastPosterRadioEle->setExtra("onchange=\"var el=document.getElementById('options[2]'); el.disabled=(this.id == 'options[2]1'); if (!el.value) {el.value= this.value}\""); // if user dont select any option it select "all" |
|
132 | + $lastPosterSelectEle = new \XoopsFormSelectUser(_MD_NEWBB_POSTER, 'options[2]', true, explode(',', $options[2]), 5, true);// show $limit = 200 users when no user is selected; |
|
133 | + $lastPosterEle = new \XoopsFormLabel(_MD_NEWBB_POSTER, $lastPosterRadioEle->render() . $lastPosterSelectEle->render()); |
|
134 | + |
|
135 | + // type element |
|
136 | + $types = $topicRenderer->getTypes(); // get all available types in all forums |
|
137 | + $typeEle = new \XoopsFormSelect(_MD_NEWBB_TYPE, 'options[3]', $options[3]); |
|
138 | + $typeEle->addOption(0, _NONE); |
|
139 | + if (!empty($types)) { |
|
140 | + foreach ($types as $type_id => $type) { |
|
141 | + $typeEle->addOption($type_id, $type['type_name']); |
|
142 | + } |
|
143 | + } |
|
144 | + |
|
145 | + // sort element |
|
146 | + $sortEle = new \XoopsFormSelect(_MD_NEWBB_SORTBY, 'options[4]', $options[4]); |
|
147 | + $sortEle->setDescription(_MB_NEWBB_CRITERIA_SORT_DESC); |
|
148 | + $sorts = $topicRenderer->getSort('', 'title'); |
|
149 | + $sortEle->addOptionArray($sorts); |
|
150 | + |
|
151 | + // order element |
|
152 | + $orderEle = new \XoopsFormSelect(_MB_NEWBB_CRITERIA_ORDER, 'options[5]', $options[5]); |
|
153 | + $orderEle->addOption(0, _DESCENDING); |
|
154 | + $orderEle->addOption(1, _ASCENDING); |
|
155 | + |
|
156 | + // number of topics to display element |
|
157 | + $numdispEle = new \XoopsFormText(_MB_NEWBB_DISPLAY, 'options[6]', 10, 255, (int)$options[6]); |
|
158 | + |
|
159 | + $timeEle = new \XoopsFormText(_MB_NEWBB_TIME, 'options[7]', 10, 255, $options[7]); |
|
160 | + $timeEle->setDescription(_MB_NEWBB_TIME_DESC); |
|
161 | + |
|
162 | + // mode disp element |
|
163 | + $options_headers = explode(',', $options[8]); |
|
164 | + $modeEle = new \XoopsFormCheckBox(_MB_NEWBB_DISPLAYMODE, 'options[8][]', $options_headers); |
|
165 | + $modeEle->setDescription(_MB_NEWBB_DISPLAYMODE_DESC); |
|
166 | + $modeEle->columns = 4; |
|
167 | + $disps = $topicRenderer->getHeader(); |
|
168 | + $modeEle->addOptionArray($disps); |
|
169 | + $modeEle->setExtra("onchange = \"validate('options[8][]','checkbox', true)\""); // prevent user select no option |
|
170 | + // Index navigation element |
|
171 | + $navEle = new \XoopsFormRadioYN(_MB_NEWBB_INDEXNAV, 'options[9]', !empty($options[9])); |
|
172 | + |
|
173 | + // Topic title element |
|
174 | + $lengthEle = new \XoopsFormText(_MB_NEWBB_TITLE_LENGTH, 'options[10]', 10, 255, (int)$options[10]); |
|
175 | + $lengthEle->setDescription(_MB_NEWBB_TITLE_LENGTH_DESC); |
|
176 | + |
|
177 | + // Post text element |
|
178 | + $postExcerptEle = new \XoopsFormText(_MB_NEWBB_POST_EXCERPT, 'options[11]', 10, 255, (int)$options[11]); |
|
179 | + $postExcerptEle->setDescription(_MB_NEWBB_POST_EXCERPT_DESC); |
|
180 | + |
|
181 | + // forum element |
|
182 | + $optionsForum = explode(',', $options[12]); |
|
183 | + require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
184 | + /** @var Newbb\ForumHandler $forumHandler */ |
|
185 | + $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
186 | + //get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums |
|
187 | + // Get accessible forums |
|
188 | + $accessForums = $forumHandler->getIdsByValues(array_map('intval', $optionsForum)); |
|
189 | + $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
190 | + $forumSel = "<select name=\"options[12][]\" multiple=\"multiple\" onchange = \"validate('options[12][]','select', true)\">";// if user dont select any it select "0" |
|
191 | + $forumSel .= '<option value="0" '; |
|
192 | + if ($isAll) { |
|
193 | + $forumSel .= ' selected'; |
|
194 | + $accessForums = null; // just select _ALL option |
|
195 | + } |
|
196 | + $forumSel .= '>' . _ALL . '</option>'; |
|
197 | + $forumSel .= newbbForumSelectBox($accessForums, 'access', false); //$accessForums, $permission = "access", $delimitorCategory = false |
|
198 | + $forumSel .= '</select>'; |
|
199 | + $forumEle = new \XoopsFormLabel(_MB_NEWBB_FORUMLIST, $forumSel); |
|
200 | + |
|
201 | + // add all elements to form |
|
202 | + $form->addElement($statusEle); |
|
203 | + $form->addElement($topicPosterEle); |
|
204 | + $form->addElement($lastPosterEle); |
|
205 | + $form->addElement($typeEle); |
|
206 | + $form->addElement($sortEle); |
|
207 | + $form->addElement($orderEle); |
|
208 | + $form->addElement($numdispEle); |
|
209 | + $form->addElement($timeEle); |
|
210 | + $form->addElement($modeEle, true); // required: user should select at least one otherwise it will select the first one |
|
211 | + $form->addElement($navEle); |
|
212 | + $form->addElement($lengthEle); |
|
213 | + $form->addElement($postExcerptEle); |
|
214 | + $form->addElement($forumEle); |
|
215 | + |
|
216 | + return $form->render(); |
|
217 | 217 | } |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | |
22 | 22 | //require_once dirname(__DIR__) . '/include/functions.ini.php'; |
23 | 23 | //require_once dirname(__DIR__) . '/class/TopicRenderer.php'; |
24 | -require_once dirname(__DIR__) . '/footer.php'; // to include js/style files like validate function |
|
24 | +require_once dirname(__DIR__).'/footer.php'; // to include js/style files like validate function |
|
25 | 25 | |
26 | 26 | xoops_loadLanguage('main', 'newbb'); |
27 | 27 | |
28 | -require_once dirname(__DIR__) . '/include/functions.config.php'; |
|
29 | -require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
30 | -require_once dirname(__DIR__) . '/include/functions.session.php'; |
|
31 | -require_once dirname(__DIR__) . '/include/functions.render.php'; |
|
32 | -require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
28 | +require_once dirname(__DIR__).'/include/functions.config.php'; |
|
29 | +require_once dirname(__DIR__).'/include/functions.time.php'; |
|
30 | +require_once dirname(__DIR__).'/include/functions.session.php'; |
|
31 | +require_once dirname(__DIR__).'/include/functions.render.php'; |
|
32 | +require_once dirname(__DIR__).'/include/functions.user.php'; |
|
33 | 33 | |
34 | 34 | // options[0] - Status in WHERE claus: all(by default), sticky, digest,lock, poll, voted, viewed, replied, read, (UN_) , active, pending, deleted (admin) (It is multi-select) |
35 | 35 | // options[1] - Uid in WHERE claus: uid of the topic poster : -1 - all users (by default) |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | $topicRenderer->force = true; // force against static vars for parse |
60 | 60 | |
61 | 61 | $topicRenderer->is_multiple = true; // is it for multiple forums |
62 | - $topicRenderer->config =& $newbbConfig; // get all configs |
|
62 | + $topicRenderer->config = & $newbbConfig; // get all configs |
|
63 | 63 | if (!empty($options[6])) { |
64 | - $topicRenderer->config['topics_per_page'] = (int)$options[6]; // number of topics (items) to display |
|
64 | + $topicRenderer->config['topics_per_page'] = (int) $options[6]; // number of topics (items) to display |
|
65 | 65 | } |
66 | - $topicRenderer->config['topic_title_excerpt'] = (int)$options[10]; // topic title length 0 = dont excerpt |
|
67 | - $topicRenderer->config['post_excerpt'] = (int)$options[11]; // post text excerpt 0 = no post text |
|
66 | + $topicRenderer->config['topic_title_excerpt'] = (int) $options[10]; // topic title length 0 = dont excerpt |
|
67 | + $topicRenderer->config['post_excerpt'] = (int) $options[11]; // post text excerpt 0 = no post text |
|
68 | 68 | |
69 | 69 | $optionsStatus = explode(',', $options[0]); // status in where claus |
70 | 70 | $optionsForum = explode(',', $options[12]); |
@@ -121,16 +121,16 @@ discard block |
||
121 | 121 | $topicPosterRadioEle->addOption(-1, _MD_NEWBB_TOTALUSER); |
122 | 122 | $topicPosterRadioEle->addOption((-1 !== $options[1]) ? $options[1] : 0, _SELECT); // if no user in selection box it select uid=0 anon users |
123 | 123 | $topicPosterRadioEle->setExtra("onchange=\"var el=document.getElementById('options[1]'); el.disabled=(this.id == 'options[1]1'); if (!el.value) {el.value= this.value}\""); // if user dont select any option it select "all" |
124 | - $topicPosterSelectEle = new \XoopsFormSelectUser(_MB_NEWBB_AUTHOR, 'options[1]', true, explode(',', $options[1]), 5, true);// show $limit = 200 users when no user is selected; |
|
125 | - $topicPosterEle = new \XoopsFormLabel(_MB_NEWBB_AUTHOR, $topicPosterRadioEle->render() . $topicPosterSelectEle->render()); |
|
124 | + $topicPosterSelectEle = new \XoopsFormSelectUser(_MB_NEWBB_AUTHOR, 'options[1]', true, explode(',', $options[1]), 5, true); // show $limit = 200 users when no user is selected; |
|
125 | + $topicPosterEle = new \XoopsFormLabel(_MB_NEWBB_AUTHOR, $topicPosterRadioEle->render().$topicPosterSelectEle->render()); |
|
126 | 126 | |
127 | 127 | // lastposter element |
128 | 128 | $lastPosterRadioEle = new \XoopsFormRadio(_MD_NEWBB_POSTER, 'options[2]', $options[2]); |
129 | 129 | $lastPosterRadioEle->addOption(-1, _MD_NEWBB_TOTALUSER); |
130 | 130 | $lastPosterRadioEle->addOption((-1 !== $options[2]) ? $options[2] : 0, _SELECT); // if no user in selection box it select uid=1 |
131 | 131 | $lastPosterRadioEle->setExtra("onchange=\"var el=document.getElementById('options[2]'); el.disabled=(this.id == 'options[2]1'); if (!el.value) {el.value= this.value}\""); // if user dont select any option it select "all" |
132 | - $lastPosterSelectEle = new \XoopsFormSelectUser(_MD_NEWBB_POSTER, 'options[2]', true, explode(',', $options[2]), 5, true);// show $limit = 200 users when no user is selected; |
|
133 | - $lastPosterEle = new \XoopsFormLabel(_MD_NEWBB_POSTER, $lastPosterRadioEle->render() . $lastPosterSelectEle->render()); |
|
132 | + $lastPosterSelectEle = new \XoopsFormSelectUser(_MD_NEWBB_POSTER, 'options[2]', true, explode(',', $options[2]), 5, true); // show $limit = 200 users when no user is selected; |
|
133 | + $lastPosterEle = new \XoopsFormLabel(_MD_NEWBB_POSTER, $lastPosterRadioEle->render().$lastPosterSelectEle->render()); |
|
134 | 134 | |
135 | 135 | // type element |
136 | 136 | $types = $topicRenderer->getTypes(); // get all available types in all forums |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $orderEle->addOption(1, _ASCENDING); |
155 | 155 | |
156 | 156 | // number of topics to display element |
157 | - $numdispEle = new \XoopsFormText(_MB_NEWBB_DISPLAY, 'options[6]', 10, 255, (int)$options[6]); |
|
157 | + $numdispEle = new \XoopsFormText(_MB_NEWBB_DISPLAY, 'options[6]', 10, 255, (int) $options[6]); |
|
158 | 158 | |
159 | 159 | $timeEle = new \XoopsFormText(_MB_NEWBB_TIME, 'options[7]', 10, 255, $options[7]); |
160 | 160 | $timeEle->setDescription(_MB_NEWBB_TIME_DESC); |
@@ -171,29 +171,29 @@ discard block |
||
171 | 171 | $navEle = new \XoopsFormRadioYN(_MB_NEWBB_INDEXNAV, 'options[9]', !empty($options[9])); |
172 | 172 | |
173 | 173 | // Topic title element |
174 | - $lengthEle = new \XoopsFormText(_MB_NEWBB_TITLE_LENGTH, 'options[10]', 10, 255, (int)$options[10]); |
|
174 | + $lengthEle = new \XoopsFormText(_MB_NEWBB_TITLE_LENGTH, 'options[10]', 10, 255, (int) $options[10]); |
|
175 | 175 | $lengthEle->setDescription(_MB_NEWBB_TITLE_LENGTH_DESC); |
176 | 176 | |
177 | 177 | // Post text element |
178 | - $postExcerptEle = new \XoopsFormText(_MB_NEWBB_POST_EXCERPT, 'options[11]', 10, 255, (int)$options[11]); |
|
178 | + $postExcerptEle = new \XoopsFormText(_MB_NEWBB_POST_EXCERPT, 'options[11]', 10, 255, (int) $options[11]); |
|
179 | 179 | $postExcerptEle->setDescription(_MB_NEWBB_POST_EXCERPT_DESC); |
180 | 180 | |
181 | 181 | // forum element |
182 | 182 | $optionsForum = explode(',', $options[12]); |
183 | - require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
183 | + require_once dirname(__DIR__).'/include/functions.forum.php'; |
|
184 | 184 | /** @var Newbb\ForumHandler $forumHandler */ |
185 | 185 | $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
186 | 186 | //get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums |
187 | 187 | // Get accessible forums |
188 | 188 | $accessForums = $forumHandler->getIdsByValues(array_map('intval', $optionsForum)); |
189 | 189 | $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
190 | - $forumSel = "<select name=\"options[12][]\" multiple=\"multiple\" onchange = \"validate('options[12][]','select', true)\">";// if user dont select any it select "0" |
|
191 | - $forumSel .= '<option value="0" '; |
|
190 | + $forumSel = "<select name=\"options[12][]\" multiple=\"multiple\" onchange = \"validate('options[12][]','select', true)\">"; // if user dont select any it select "0" |
|
191 | + $forumSel .= '<option value="0" '; |
|
192 | 192 | if ($isAll) { |
193 | - $forumSel .= ' selected'; |
|
193 | + $forumSel .= ' selected'; |
|
194 | 194 | $accessForums = null; // just select _ALL option |
195 | 195 | } |
196 | - $forumSel .= '>' . _ALL . '</option>'; |
|
196 | + $forumSel .= '>'._ALL.'</option>'; |
|
197 | 197 | $forumSel .= newbbForumSelectBox($accessForums, 'access', false); //$accessForums, $permission = "access", $delimitorCategory = false |
198 | 198 | $forumSel .= '</select>'; |
199 | 199 | $forumEle = new \XoopsFormLabel(_MB_NEWBB_FORUMLIST, $forumSel); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); |
27 | 27 | |
28 | 28 | if (defined('NEWBB_BLOCK_DEFINED')) { |
29 | - return; |
|
29 | + return; |
|
30 | 30 | } |
31 | 31 | define('NEWBB_BLOCK_DEFINED', true); |
32 | 32 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | function b_newbb_array_filter($var) |
38 | 38 | { |
39 | - return $var > 0; |
|
39 | + return $var > 0; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | // options[0] - Citeria valid: time(by default) |
@@ -53,166 +53,166 @@ discard block |
||
53 | 53 | */ |
54 | 54 | function b_newbb_show($options) |
55 | 55 | { |
56 | - global $accessForums; |
|
57 | - global $xoopsLogger; |
|
58 | - |
|
59 | - require_once dirname(__DIR__) . '/include/functions.config.php'; |
|
60 | - require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
61 | - |
|
62 | - $myts = \MyTextSanitizer::getInstance(); |
|
63 | - $block = []; |
|
64 | - $i = 0; |
|
65 | - $order = ''; |
|
66 | - $extraCriteria = ''; |
|
67 | - if (!empty($options[2])) { |
|
68 | - //require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
69 | - $extraCriteria .= ' AND p.post_time>' . (time() - newbbGetSinceTime($options[2])); |
|
70 | - } |
|
71 | - switch ($options[0]) { |
|
72 | - case 'time': |
|
73 | - default: |
|
74 | - $order = 't.topic_last_post_id'; |
|
75 | - break; |
|
76 | - } |
|
77 | - |
|
78 | - if (!isset($accessForums)) { |
|
79 | - /** var Newbb\PermissionHandler $permHandler */ |
|
80 | - $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
81 | - if (!$accessForums = $permHandler->getForums()) { |
|
82 | - return $block; |
|
83 | - } |
|
84 | - } |
|
85 | - if (!empty($options[6])) { |
|
86 | - $myallowedForums = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
|
87 | - $allowedForums = array_intersect($myallowedForums, $accessForums); |
|
88 | - } else { |
|
89 | - $allowedForums = $accessForums; |
|
90 | - } |
|
91 | - if (empty($allowedForums)) { |
|
92 | - return $block; |
|
93 | - } |
|
94 | - |
|
95 | - $forumCriteria = ' AND t.forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
96 | - $approveCriteria = ' AND t.approved = 1'; |
|
97 | - |
|
98 | - $newbbConfig = newbbLoadConfig(); |
|
99 | - if (!empty($newbbConfig['do_rewrite'])) { |
|
100 | - require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php'); |
|
101 | - } else { |
|
102 | - if (!defined('SEO_MODULE_NAME')) { |
|
103 | - define('SEO_MODULE_NAME', 'modules/newbb'); |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - $query = 'SELECT' |
|
108 | - . ' t.topic_id, t.topic_replies, t.forum_id, t.topic_title, t.topic_views, t.type_id,' |
|
109 | - . ' f.forum_name,t.topic_status,' |
|
110 | - . ' p.post_id, p.post_time, p.icon, p.uid, p.poster_name' |
|
111 | - . ' FROM ' |
|
112 | - . $GLOBALS['xoopsDB']->prefix('newbb_topics') |
|
113 | - . ' AS t ' |
|
114 | - . ' LEFT JOIN ' |
|
115 | - . $GLOBALS['xoopsDB']->prefix('newbb_posts') |
|
116 | - . ' AS p ON t.topic_last_post_id=p.post_id' |
|
117 | - . ' LEFT JOIN ' |
|
118 | - . $GLOBALS['xoopsDB']->prefix('newbb_forums') |
|
119 | - . ' AS f ON f.forum_id=t.forum_id' |
|
120 | - . ' WHERE 1=1 ' |
|
121 | - . $forumCriteria |
|
122 | - . $approveCriteria |
|
123 | - . $extraCriteria |
|
124 | - . ' ORDER BY ' |
|
125 | - . $order |
|
126 | - . ' DESC'; |
|
127 | - |
|
128 | - $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
|
129 | - |
|
130 | - if (!$result) { |
|
131 | - //xoops_error($GLOBALS['xoopsDB']->error()); |
|
132 | - return false; |
|
133 | - } |
|
134 | - $block['disp_mode'] = $options[3]; // 0 - full view; 1 - compact view; 2 - lite view; |
|
135 | - $rows = []; |
|
136 | - $author = []; |
|
137 | - $types = []; |
|
138 | - |
|
139 | - while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
140 | - $rows[] = $row; |
|
141 | - $author[$row['uid']] = 1; |
|
142 | - if ($row['type_id'] > 0) { |
|
143 | - $types[$row['type_id']] = 1; |
|
144 | - } |
|
145 | - } |
|
146 | - |
|
147 | - if (count($rows) < 1) { |
|
148 | - return $block; |
|
149 | - } |
|
150 | - |
|
151 | - require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
152 | - $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true); |
|
153 | - |
|
154 | - if (count($types) > 0) { |
|
155 | - /** @var Newbb\TypeHandler $typeHandler */ |
|
156 | - $typeHandler = Newbb\Helper::getInstance()->getHandler('Type'); |
|
157 | - $type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN')); |
|
158 | - } |
|
159 | - |
|
160 | - foreach ($rows as $arr) { |
|
161 | - // irmtfan add lastposticon - load main lang |
|
162 | - xoops_loadLanguage('main', 'newbb'); |
|
163 | - $topic = []; |
|
164 | - $topic_page_jump = newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST); |
|
165 | - $topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '[' . $type_list[$arr['type_id']] . ']'; |
|
166 | - |
|
167 | - $topic['post_id'] = $arr['post_id']; |
|
168 | - $topic['topic_status'] = $arr['topic_status']; |
|
169 | - $topic['forum_id'] = $arr['forum_id']; |
|
170 | - $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); |
|
171 | - $topic['id'] = $arr['topic_id']; |
|
172 | - |
|
173 | - $title = $myts->htmlSpecialChars($arr['topic_title']); |
|
174 | - if (!empty($options[5])) { |
|
175 | - $title = xoops_substr($title, 0, $options[5]); |
|
176 | - } |
|
177 | - $topic['title'] = $topic['topic_subject'] . ' ' . $title; |
|
178 | - $topic['replies'] = $arr['topic_replies']; |
|
179 | - $topic['views'] = $arr['topic_views']; |
|
180 | - $topic['time'] = newbbFormatTimestamp($arr['post_time']); |
|
181 | - if (!empty($author_name[$arr['uid']])) { |
|
182 | - $topic_poster = $author_name[$arr['uid']]; |
|
183 | - } else { |
|
184 | - $topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); |
|
185 | - } |
|
186 | - $topic['topic_poster'] = $topic_poster; |
|
187 | - $topic['topic_page_jump'] = $topic_page_jump; |
|
188 | - // START irmtfan remove hardcoded html in URLs - add $seo_topic_url |
|
189 | - $seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id']; |
|
190 | - $seo_topic_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id']; |
|
191 | - $seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id']; |
|
192 | - if (!empty($newbbConfig['do_rewrite'])) { |
|
193 | - $topic['seo_url'] = seo_urls($seo_url); |
|
194 | - $topic['seo_topic_url'] = seo_urls($seo_topic_url); |
|
195 | - $topic['seo_forum_url'] = seo_urls($seo_forum_url); |
|
196 | - } else { |
|
197 | - $topic['seo_url'] = $seo_url; |
|
198 | - $topic['seo_topic_url'] = $seo_topic_url; |
|
199 | - $topic['seo_forum_url'] = $seo_forum_url; |
|
200 | - } |
|
201 | - // END irmtfan remove hardcoded html in URLs - add $seo_topic_url |
|
202 | - $block['topics'][] = $topic; |
|
203 | - unset($topic); |
|
204 | - } |
|
205 | - // START irmtfan remove hardcoded html in URLs |
|
206 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME; |
|
207 | - $block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
208 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php'; |
|
209 | - $block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
210 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php'; |
|
211 | - $block['seo_top_allposts'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
212 | - // END irmtfan remove hardcoded html in URLs |
|
213 | - $block['indexNav'] = (int)$options[4]; |
|
214 | - |
|
215 | - return $block; |
|
56 | + global $accessForums; |
|
57 | + global $xoopsLogger; |
|
58 | + |
|
59 | + require_once dirname(__DIR__) . '/include/functions.config.php'; |
|
60 | + require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
61 | + |
|
62 | + $myts = \MyTextSanitizer::getInstance(); |
|
63 | + $block = []; |
|
64 | + $i = 0; |
|
65 | + $order = ''; |
|
66 | + $extraCriteria = ''; |
|
67 | + if (!empty($options[2])) { |
|
68 | + //require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
69 | + $extraCriteria .= ' AND p.post_time>' . (time() - newbbGetSinceTime($options[2])); |
|
70 | + } |
|
71 | + switch ($options[0]) { |
|
72 | + case 'time': |
|
73 | + default: |
|
74 | + $order = 't.topic_last_post_id'; |
|
75 | + break; |
|
76 | + } |
|
77 | + |
|
78 | + if (!isset($accessForums)) { |
|
79 | + /** var Newbb\PermissionHandler $permHandler */ |
|
80 | + $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
81 | + if (!$accessForums = $permHandler->getForums()) { |
|
82 | + return $block; |
|
83 | + } |
|
84 | + } |
|
85 | + if (!empty($options[6])) { |
|
86 | + $myallowedForums = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
|
87 | + $allowedForums = array_intersect($myallowedForums, $accessForums); |
|
88 | + } else { |
|
89 | + $allowedForums = $accessForums; |
|
90 | + } |
|
91 | + if (empty($allowedForums)) { |
|
92 | + return $block; |
|
93 | + } |
|
94 | + |
|
95 | + $forumCriteria = ' AND t.forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
96 | + $approveCriteria = ' AND t.approved = 1'; |
|
97 | + |
|
98 | + $newbbConfig = newbbLoadConfig(); |
|
99 | + if (!empty($newbbConfig['do_rewrite'])) { |
|
100 | + require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php'); |
|
101 | + } else { |
|
102 | + if (!defined('SEO_MODULE_NAME')) { |
|
103 | + define('SEO_MODULE_NAME', 'modules/newbb'); |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + $query = 'SELECT' |
|
108 | + . ' t.topic_id, t.topic_replies, t.forum_id, t.topic_title, t.topic_views, t.type_id,' |
|
109 | + . ' f.forum_name,t.topic_status,' |
|
110 | + . ' p.post_id, p.post_time, p.icon, p.uid, p.poster_name' |
|
111 | + . ' FROM ' |
|
112 | + . $GLOBALS['xoopsDB']->prefix('newbb_topics') |
|
113 | + . ' AS t ' |
|
114 | + . ' LEFT JOIN ' |
|
115 | + . $GLOBALS['xoopsDB']->prefix('newbb_posts') |
|
116 | + . ' AS p ON t.topic_last_post_id=p.post_id' |
|
117 | + . ' LEFT JOIN ' |
|
118 | + . $GLOBALS['xoopsDB']->prefix('newbb_forums') |
|
119 | + . ' AS f ON f.forum_id=t.forum_id' |
|
120 | + . ' WHERE 1=1 ' |
|
121 | + . $forumCriteria |
|
122 | + . $approveCriteria |
|
123 | + . $extraCriteria |
|
124 | + . ' ORDER BY ' |
|
125 | + . $order |
|
126 | + . ' DESC'; |
|
127 | + |
|
128 | + $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
|
129 | + |
|
130 | + if (!$result) { |
|
131 | + //xoops_error($GLOBALS['xoopsDB']->error()); |
|
132 | + return false; |
|
133 | + } |
|
134 | + $block['disp_mode'] = $options[3]; // 0 - full view; 1 - compact view; 2 - lite view; |
|
135 | + $rows = []; |
|
136 | + $author = []; |
|
137 | + $types = []; |
|
138 | + |
|
139 | + while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
140 | + $rows[] = $row; |
|
141 | + $author[$row['uid']] = 1; |
|
142 | + if ($row['type_id'] > 0) { |
|
143 | + $types[$row['type_id']] = 1; |
|
144 | + } |
|
145 | + } |
|
146 | + |
|
147 | + if (count($rows) < 1) { |
|
148 | + return $block; |
|
149 | + } |
|
150 | + |
|
151 | + require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
152 | + $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true); |
|
153 | + |
|
154 | + if (count($types) > 0) { |
|
155 | + /** @var Newbb\TypeHandler $typeHandler */ |
|
156 | + $typeHandler = Newbb\Helper::getInstance()->getHandler('Type'); |
|
157 | + $type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN')); |
|
158 | + } |
|
159 | + |
|
160 | + foreach ($rows as $arr) { |
|
161 | + // irmtfan add lastposticon - load main lang |
|
162 | + xoops_loadLanguage('main', 'newbb'); |
|
163 | + $topic = []; |
|
164 | + $topic_page_jump = newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST); |
|
165 | + $topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '[' . $type_list[$arr['type_id']] . ']'; |
|
166 | + |
|
167 | + $topic['post_id'] = $arr['post_id']; |
|
168 | + $topic['topic_status'] = $arr['topic_status']; |
|
169 | + $topic['forum_id'] = $arr['forum_id']; |
|
170 | + $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); |
|
171 | + $topic['id'] = $arr['topic_id']; |
|
172 | + |
|
173 | + $title = $myts->htmlSpecialChars($arr['topic_title']); |
|
174 | + if (!empty($options[5])) { |
|
175 | + $title = xoops_substr($title, 0, $options[5]); |
|
176 | + } |
|
177 | + $topic['title'] = $topic['topic_subject'] . ' ' . $title; |
|
178 | + $topic['replies'] = $arr['topic_replies']; |
|
179 | + $topic['views'] = $arr['topic_views']; |
|
180 | + $topic['time'] = newbbFormatTimestamp($arr['post_time']); |
|
181 | + if (!empty($author_name[$arr['uid']])) { |
|
182 | + $topic_poster = $author_name[$arr['uid']]; |
|
183 | + } else { |
|
184 | + $topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); |
|
185 | + } |
|
186 | + $topic['topic_poster'] = $topic_poster; |
|
187 | + $topic['topic_page_jump'] = $topic_page_jump; |
|
188 | + // START irmtfan remove hardcoded html in URLs - add $seo_topic_url |
|
189 | + $seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id']; |
|
190 | + $seo_topic_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id']; |
|
191 | + $seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id']; |
|
192 | + if (!empty($newbbConfig['do_rewrite'])) { |
|
193 | + $topic['seo_url'] = seo_urls($seo_url); |
|
194 | + $topic['seo_topic_url'] = seo_urls($seo_topic_url); |
|
195 | + $topic['seo_forum_url'] = seo_urls($seo_forum_url); |
|
196 | + } else { |
|
197 | + $topic['seo_url'] = $seo_url; |
|
198 | + $topic['seo_topic_url'] = $seo_topic_url; |
|
199 | + $topic['seo_forum_url'] = $seo_forum_url; |
|
200 | + } |
|
201 | + // END irmtfan remove hardcoded html in URLs - add $seo_topic_url |
|
202 | + $block['topics'][] = $topic; |
|
203 | + unset($topic); |
|
204 | + } |
|
205 | + // START irmtfan remove hardcoded html in URLs |
|
206 | + $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME; |
|
207 | + $block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
208 | + $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php'; |
|
209 | + $block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
210 | + $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php'; |
|
211 | + $block['seo_top_allposts'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
212 | + // END irmtfan remove hardcoded html in URLs |
|
213 | + $block['indexNav'] = (int)$options[4]; |
|
214 | + |
|
215 | + return $block; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | // options[0] - Citeria valid: time(by default), views, replies, digest, sticky |
@@ -229,168 +229,168 @@ discard block |
||
229 | 229 | */ |
230 | 230 | function b_newbb_topic_show($options) |
231 | 231 | { |
232 | - global $accessForums; |
|
233 | - require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
234 | - $myts = \MyTextSanitizer::getInstance(); |
|
235 | - $block = []; |
|
236 | - $i = 0; |
|
237 | - $order = ''; |
|
238 | - $extraCriteria = ''; |
|
239 | - $time_criteria = null; |
|
240 | - if (!empty($options[2])) { |
|
241 | - $time_criteria = time() - newbbGetSinceTime($options[2]); |
|
242 | - $extraCriteria = ' AND t.topic_time>' . $time_criteria; |
|
243 | - } |
|
244 | - switch ($options[0]) { |
|
245 | - case 'views': |
|
246 | - $order = 't.topic_views'; |
|
247 | - break; |
|
248 | - case 'replies': |
|
249 | - $order = 't.topic_replies'; |
|
250 | - break; |
|
251 | - case 'digest': |
|
252 | - $order = 't.digest_time'; |
|
253 | - $extraCriteria = ' AND t.topic_digest=1'; |
|
254 | - if (null !== $time_criteria) { |
|
255 | - $extraCriteria .= ' AND t.digest_time>' . $time_criteria; |
|
256 | - } |
|
257 | - break; |
|
258 | - case 'sticky': |
|
259 | - $order = 't.topic_id'; |
|
260 | - $extraCriteria .= ' AND t.topic_sticky=1'; |
|
261 | - break; |
|
262 | - case 'time': |
|
263 | - default: |
|
264 | - $order = 't.topic_id'; |
|
265 | - break; |
|
266 | - } |
|
267 | - |
|
268 | - $newbbConfig = newbbLoadConfig(); |
|
269 | - if (!empty($newbbConfig['do_rewrite'])) { |
|
270 | - require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php'); |
|
271 | - } else { |
|
272 | - if (!defined('SEO_MODULE_NAME')) { |
|
273 | - define('SEO_MODULE_NAME', 'modules/newbb'); |
|
274 | - } |
|
275 | - } |
|
276 | - |
|
277 | - if (!isset($accessForums)) { |
|
278 | - /** var Newbb\PermissionHandler $permHandler */ |
|
279 | - $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
280 | - if (!$accessForums = $permHandler->getForums()) { |
|
281 | - return $block; |
|
282 | - } |
|
283 | - } |
|
284 | - |
|
285 | - if (!empty($options[6])) { |
|
286 | - $myallowedForums = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
|
287 | - $allowedForums = array_intersect($myallowedForums, $accessForums); |
|
288 | - } else { |
|
289 | - $allowedForums = $accessForums; |
|
290 | - } |
|
291 | - if (empty($allowedForums)) { |
|
292 | - return false; |
|
293 | - } |
|
294 | - |
|
295 | - $forumCriteria = ' AND t.forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
296 | - $approveCriteria = ' AND t.approved = 1'; |
|
297 | - |
|
298 | - $query = 'SELECT' |
|
299 | - . ' t.topic_id, t.topic_replies, t.forum_id, t.topic_title, t.topic_views, t.type_id, t.topic_time, t.topic_poster, t.poster_name,' |
|
300 | - . ' f.forum_name' |
|
301 | - . ' FROM ' |
|
302 | - . $GLOBALS['xoopsDB']->prefix('newbb_topics') |
|
303 | - . ' AS t ' |
|
304 | - . ' LEFT JOIN ' |
|
305 | - . $GLOBALS['xoopsDB']->prefix('newbb_forums') |
|
306 | - . ' AS f ON f.forum_id=t.forum_id' |
|
307 | - . ' WHERE 1=1 ' |
|
308 | - . $forumCriteria |
|
309 | - . $approveCriteria |
|
310 | - . $extraCriteria |
|
311 | - . ' ORDER BY ' |
|
312 | - . $order |
|
313 | - . ' DESC'; |
|
314 | - |
|
315 | - $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
|
316 | - |
|
317 | - if (!$result) { |
|
318 | - //xoops_error($GLOBALS['xoopsDB']->error()); |
|
319 | - return $block; |
|
320 | - } |
|
321 | - $block['disp_mode'] = $options[3]; // 0 - full view; 1 - compact view; 2 - lite view; |
|
322 | - $rows = []; |
|
323 | - $author = []; |
|
324 | - $types = []; |
|
325 | - while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
326 | - $rows[] = $row; |
|
327 | - $author[$row['topic_poster']] = 1; |
|
328 | - if ($row['type_id'] > 0) { |
|
329 | - $types[$row['type_id']] = 1; |
|
330 | - } |
|
331 | - } |
|
332 | - if (count($rows) < 1) { |
|
333 | - return $block; |
|
334 | - } |
|
335 | - require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
336 | - $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true); |
|
337 | - if (count($types) > 0) { |
|
338 | - /** @var Newbb\TypeHandler $typeHandler */ |
|
339 | - $typeHandler = Newbb\Helper::getInstance()->getHandler('Type'); |
|
340 | - $type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN')); |
|
341 | - } |
|
342 | - |
|
343 | - foreach ($rows as $arr) { |
|
344 | - // irmtfan remove $topic_page_jump because there is no last post |
|
345 | - //$topic_page_jump = ''; |
|
346 | - $topic = []; |
|
347 | - $topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '[' . $type_list[$arr['type_id']] . '] '; |
|
348 | - $topic['forum_id'] = $arr['forum_id']; |
|
349 | - $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); |
|
350 | - $topic['id'] = $arr['topic_id']; |
|
351 | - |
|
352 | - $title = $myts->htmlSpecialChars($arr['topic_title']); |
|
353 | - if (!empty($options[5])) { |
|
354 | - $title = xoops_substr($title, 0, $options[5]); |
|
355 | - } |
|
356 | - $topic['title'] = $topic['topic_subject'] . $title; |
|
357 | - $topic['replies'] = $arr['topic_replies']; |
|
358 | - $topic['views'] = $arr['topic_views']; |
|
359 | - $topic['time'] = newbbFormatTimestamp($arr['topic_time']); |
|
360 | - if (!empty($author_name[$arr['topic_poster']])) { |
|
361 | - $topic_poster = $author_name[$arr['topic_poster']]; |
|
362 | - } else { |
|
363 | - $topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); |
|
364 | - } |
|
365 | - $topic['topic_poster'] = $topic_poster; |
|
366 | - // irmtfan remove $topic_page_jump because there is no last post |
|
367 | - //$topic['topic_page_jump'] = $topic_page_jump; |
|
368 | - // START irmtfan remove hardcoded html in URLs - add $seo_topic_url |
|
369 | - $seo_topic_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id']; |
|
370 | - $seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id']; |
|
371 | - |
|
372 | - if (!empty($newbbConfig['do_rewrite'])) { |
|
373 | - $topic['seo_topic_url'] = seo_urls($seo_topic_url); |
|
374 | - $topic['seo_forum_url'] = seo_urls($seo_forum_url); |
|
375 | - } else { |
|
376 | - $topic['seo_topic_url'] = $seo_topic_url; |
|
377 | - $topic['seo_forum_url'] = $seo_forum_url; |
|
378 | - } |
|
379 | - // END irmtfan remove hardcoded html in URLs - add $seo_topic_url |
|
380 | - $block['topics'][] = $topic; |
|
381 | - unset($topic); |
|
382 | - } |
|
383 | - // START irmtfan remove hardcoded html in URLs |
|
384 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME; |
|
385 | - $block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
386 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php'; |
|
387 | - $block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
388 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php'; |
|
389 | - $block['seo_top_allposts'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
390 | - // END irmtfan remove hardcoded html in URLs |
|
391 | - $block['indexNav'] = (int)$options[4]; |
|
392 | - |
|
393 | - return $block; |
|
232 | + global $accessForums; |
|
233 | + require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
234 | + $myts = \MyTextSanitizer::getInstance(); |
|
235 | + $block = []; |
|
236 | + $i = 0; |
|
237 | + $order = ''; |
|
238 | + $extraCriteria = ''; |
|
239 | + $time_criteria = null; |
|
240 | + if (!empty($options[2])) { |
|
241 | + $time_criteria = time() - newbbGetSinceTime($options[2]); |
|
242 | + $extraCriteria = ' AND t.topic_time>' . $time_criteria; |
|
243 | + } |
|
244 | + switch ($options[0]) { |
|
245 | + case 'views': |
|
246 | + $order = 't.topic_views'; |
|
247 | + break; |
|
248 | + case 'replies': |
|
249 | + $order = 't.topic_replies'; |
|
250 | + break; |
|
251 | + case 'digest': |
|
252 | + $order = 't.digest_time'; |
|
253 | + $extraCriteria = ' AND t.topic_digest=1'; |
|
254 | + if (null !== $time_criteria) { |
|
255 | + $extraCriteria .= ' AND t.digest_time>' . $time_criteria; |
|
256 | + } |
|
257 | + break; |
|
258 | + case 'sticky': |
|
259 | + $order = 't.topic_id'; |
|
260 | + $extraCriteria .= ' AND t.topic_sticky=1'; |
|
261 | + break; |
|
262 | + case 'time': |
|
263 | + default: |
|
264 | + $order = 't.topic_id'; |
|
265 | + break; |
|
266 | + } |
|
267 | + |
|
268 | + $newbbConfig = newbbLoadConfig(); |
|
269 | + if (!empty($newbbConfig['do_rewrite'])) { |
|
270 | + require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php'); |
|
271 | + } else { |
|
272 | + if (!defined('SEO_MODULE_NAME')) { |
|
273 | + define('SEO_MODULE_NAME', 'modules/newbb'); |
|
274 | + } |
|
275 | + } |
|
276 | + |
|
277 | + if (!isset($accessForums)) { |
|
278 | + /** var Newbb\PermissionHandler $permHandler */ |
|
279 | + $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
280 | + if (!$accessForums = $permHandler->getForums()) { |
|
281 | + return $block; |
|
282 | + } |
|
283 | + } |
|
284 | + |
|
285 | + if (!empty($options[6])) { |
|
286 | + $myallowedForums = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
|
287 | + $allowedForums = array_intersect($myallowedForums, $accessForums); |
|
288 | + } else { |
|
289 | + $allowedForums = $accessForums; |
|
290 | + } |
|
291 | + if (empty($allowedForums)) { |
|
292 | + return false; |
|
293 | + } |
|
294 | + |
|
295 | + $forumCriteria = ' AND t.forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
296 | + $approveCriteria = ' AND t.approved = 1'; |
|
297 | + |
|
298 | + $query = 'SELECT' |
|
299 | + . ' t.topic_id, t.topic_replies, t.forum_id, t.topic_title, t.topic_views, t.type_id, t.topic_time, t.topic_poster, t.poster_name,' |
|
300 | + . ' f.forum_name' |
|
301 | + . ' FROM ' |
|
302 | + . $GLOBALS['xoopsDB']->prefix('newbb_topics') |
|
303 | + . ' AS t ' |
|
304 | + . ' LEFT JOIN ' |
|
305 | + . $GLOBALS['xoopsDB']->prefix('newbb_forums') |
|
306 | + . ' AS f ON f.forum_id=t.forum_id' |
|
307 | + . ' WHERE 1=1 ' |
|
308 | + . $forumCriteria |
|
309 | + . $approveCriteria |
|
310 | + . $extraCriteria |
|
311 | + . ' ORDER BY ' |
|
312 | + . $order |
|
313 | + . ' DESC'; |
|
314 | + |
|
315 | + $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
|
316 | + |
|
317 | + if (!$result) { |
|
318 | + //xoops_error($GLOBALS['xoopsDB']->error()); |
|
319 | + return $block; |
|
320 | + } |
|
321 | + $block['disp_mode'] = $options[3]; // 0 - full view; 1 - compact view; 2 - lite view; |
|
322 | + $rows = []; |
|
323 | + $author = []; |
|
324 | + $types = []; |
|
325 | + while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
326 | + $rows[] = $row; |
|
327 | + $author[$row['topic_poster']] = 1; |
|
328 | + if ($row['type_id'] > 0) { |
|
329 | + $types[$row['type_id']] = 1; |
|
330 | + } |
|
331 | + } |
|
332 | + if (count($rows) < 1) { |
|
333 | + return $block; |
|
334 | + } |
|
335 | + require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
336 | + $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true); |
|
337 | + if (count($types) > 0) { |
|
338 | + /** @var Newbb\TypeHandler $typeHandler */ |
|
339 | + $typeHandler = Newbb\Helper::getInstance()->getHandler('Type'); |
|
340 | + $type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN')); |
|
341 | + } |
|
342 | + |
|
343 | + foreach ($rows as $arr) { |
|
344 | + // irmtfan remove $topic_page_jump because there is no last post |
|
345 | + //$topic_page_jump = ''; |
|
346 | + $topic = []; |
|
347 | + $topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '[' . $type_list[$arr['type_id']] . '] '; |
|
348 | + $topic['forum_id'] = $arr['forum_id']; |
|
349 | + $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); |
|
350 | + $topic['id'] = $arr['topic_id']; |
|
351 | + |
|
352 | + $title = $myts->htmlSpecialChars($arr['topic_title']); |
|
353 | + if (!empty($options[5])) { |
|
354 | + $title = xoops_substr($title, 0, $options[5]); |
|
355 | + } |
|
356 | + $topic['title'] = $topic['topic_subject'] . $title; |
|
357 | + $topic['replies'] = $arr['topic_replies']; |
|
358 | + $topic['views'] = $arr['topic_views']; |
|
359 | + $topic['time'] = newbbFormatTimestamp($arr['topic_time']); |
|
360 | + if (!empty($author_name[$arr['topic_poster']])) { |
|
361 | + $topic_poster = $author_name[$arr['topic_poster']]; |
|
362 | + } else { |
|
363 | + $topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); |
|
364 | + } |
|
365 | + $topic['topic_poster'] = $topic_poster; |
|
366 | + // irmtfan remove $topic_page_jump because there is no last post |
|
367 | + //$topic['topic_page_jump'] = $topic_page_jump; |
|
368 | + // START irmtfan remove hardcoded html in URLs - add $seo_topic_url |
|
369 | + $seo_topic_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id']; |
|
370 | + $seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id']; |
|
371 | + |
|
372 | + if (!empty($newbbConfig['do_rewrite'])) { |
|
373 | + $topic['seo_topic_url'] = seo_urls($seo_topic_url); |
|
374 | + $topic['seo_forum_url'] = seo_urls($seo_forum_url); |
|
375 | + } else { |
|
376 | + $topic['seo_topic_url'] = $seo_topic_url; |
|
377 | + $topic['seo_forum_url'] = $seo_forum_url; |
|
378 | + } |
|
379 | + // END irmtfan remove hardcoded html in URLs - add $seo_topic_url |
|
380 | + $block['topics'][] = $topic; |
|
381 | + unset($topic); |
|
382 | + } |
|
383 | + // START irmtfan remove hardcoded html in URLs |
|
384 | + $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME; |
|
385 | + $block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
386 | + $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php'; |
|
387 | + $block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
388 | + $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php'; |
|
389 | + $block['seo_top_allposts'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
390 | + // END irmtfan remove hardcoded html in URLs |
|
391 | + $block['indexNav'] = (int)$options[4]; |
|
392 | + |
|
393 | + return $block; |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | // options[0] - Citeria valid: title(by default), text |
@@ -407,155 +407,155 @@ discard block |
||
407 | 407 | */ |
408 | 408 | function b_newbb_post_show($options) |
409 | 409 | { |
410 | - global $accessForums; |
|
411 | - global $newbbConfig; |
|
412 | - |
|
413 | - require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
414 | - $myts = \MyTextSanitizer::getInstance(); |
|
415 | - $block = []; |
|
416 | - $i = 0; |
|
417 | - $order = ''; |
|
418 | - $extraCriteria = ''; |
|
419 | - $time_criteria = null; |
|
420 | - if (!empty($options[2])) { |
|
421 | - $time_criteria = time() - newbbGetSinceTime($options[2]); |
|
422 | - $extraCriteria = ' AND p.post_time>' . $time_criteria; |
|
423 | - } |
|
424 | - |
|
425 | - switch ($options[0]) { |
|
426 | - case 'text': |
|
427 | - if (!empty($newbbConfig['enable_karma'])) { |
|
428 | - $extraCriteria .= ' AND p.post_karma = 0'; |
|
429 | - } |
|
430 | - if (!empty($newbbConfig['allow_require_reply'])) { |
|
431 | - $extraCriteria .= ' AND p.require_reply = 0'; |
|
432 | - } |
|
433 | - // no break |
|
434 | - default: |
|
435 | - $order = 'p.post_id'; |
|
436 | - break; |
|
437 | - } |
|
438 | - |
|
439 | - if (!isset($accessForums)) { |
|
440 | - /** var Newbb\PermissionHandler $permHandler */ |
|
441 | - $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
442 | - if (!$accessForums = $permHandler->getForums()) { |
|
443 | - return $block; |
|
444 | - } |
|
445 | - } |
|
446 | - |
|
447 | - $newbbConfig = newbbLoadConfig(); |
|
448 | - if (!empty($newbbConfig['do_rewrite'])) { |
|
449 | - require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php'); |
|
450 | - } else { |
|
451 | - if (!defined('SEO_MODULE_NAME')) { |
|
452 | - define('SEO_MODULE_NAME', 'modules/newbb'); |
|
453 | - } |
|
454 | - } |
|
455 | - |
|
456 | - if (!empty($options[6])) { |
|
457 | - $myallowedForums = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
|
458 | - $allowedForums = array_intersect($myallowedForums, $accessForums); |
|
459 | - } else { |
|
460 | - $allowedForums = $accessForums; |
|
461 | - } |
|
462 | - if (empty($allowedForums)) { |
|
463 | - return $block; |
|
464 | - } |
|
465 | - |
|
466 | - $forumCriteria = ' AND p.forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
467 | - $approveCriteria = ' AND p.approved = 1'; |
|
468 | - |
|
469 | - $query = 'SELECT'; |
|
470 | - $query .= ' p.post_id, p.subject, p.post_time, p.icon, p.uid, p.poster_name,'; |
|
471 | - if ('text' === $options[0]) { |
|
472 | - $query .= ' pt.dohtml, pt.dosmiley, pt.doxcode, pt.dobr, pt.post_text,'; |
|
473 | - } |
|
474 | - $query .= ' f.forum_id, f.forum_name' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' AS p ' . ' LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('newbb_forums') . ' AS f ON f.forum_id=p.forum_id'; |
|
475 | - if ('text' === $options[0]) { |
|
476 | - $query .= ' LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('newbb_posts_text') . ' AS pt ON pt.post_id=p.post_id'; |
|
477 | - } |
|
478 | - $query .= ' WHERE 1=1 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' ORDER BY ' . $order . ' DESC'; |
|
479 | - |
|
480 | - $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
|
481 | - if (!$result) { |
|
482 | - //xoops_error($GLOBALS['xoopsDB']->error()); |
|
483 | - return $block; |
|
484 | - } |
|
485 | - $block['disp_mode'] = ('text' === $options[0]) ? 3 : $options[3]; // 0 - full view; 1 - compact view; 2 - lite view; |
|
486 | - $rows = []; |
|
487 | - $author = []; |
|
488 | - while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
489 | - $rows[] = $row; |
|
490 | - $author[$row['uid']] = 1; |
|
491 | - } |
|
492 | - if (count($rows) < 1) { |
|
493 | - return $block; |
|
494 | - } |
|
495 | - require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
496 | - $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true); |
|
497 | - |
|
498 | - foreach ($rows as $arr) { |
|
499 | - //if ($arr['icon'] && is_file($GLOBALS['xoops']->path('images/subject/' . $arr['icon']))) { |
|
500 | - if (!empty($arr['icon'])) { |
|
501 | - $last_post_icon = '<img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars($arr['icon'], ENT_QUOTES | ENT_HTML5) . '" alt="" />'; |
|
502 | - } else { |
|
503 | - $last_post_icon = '<img src="' . XOOPS_URL . '/images/subject/icon1.gif" alt="" />'; |
|
504 | - } |
|
505 | - //$topic['jump_post'] = "<a href='" . XOOPS_URL . "/modules/newbb/viewtopic.php?post_id=" . $arr['post_id'] ."#forumpost" . $arr['post_id'] . "'>" . $last_post_icon . '</a>'; |
|
506 | - $topic = []; |
|
507 | - $topic['forum_id'] = $arr['forum_id']; |
|
508 | - $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); |
|
509 | - //$topic['id'] = $arr['topic_id']; |
|
510 | - |
|
511 | - $title = $myts->htmlSpecialChars($arr['subject']); |
|
512 | - if ('text' !== $options[0] && !empty($options[5])) { |
|
513 | - $title = xoops_substr($title, 0, $options[5]); |
|
514 | - } |
|
515 | - $topic['title'] = $title; |
|
516 | - $topic['post_id'] = $arr['post_id']; |
|
517 | - $topic['time'] = newbbFormatTimestamp($arr['post_time']); |
|
518 | - if (!empty($author_name[$arr['uid']])) { |
|
519 | - $topic_poster = $author_name[$arr['uid']]; |
|
520 | - } else { |
|
521 | - $topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); |
|
522 | - } |
|
523 | - $topic['topic_poster'] = $topic_poster; |
|
524 | - |
|
525 | - if ('text' === $options[0]) { |
|
526 | - $post_text = $myts->displayTarea($arr['post_text'], $arr['dohtml'], $arr['dosmiley'], $arr['doxcode'], 1, $arr['dobr']); |
|
527 | - if (!empty($options[5])) { |
|
528 | - $post_text = xoops_substr(strip_tags($post_text), 0, $options[5]); |
|
529 | - } |
|
530 | - $topic['post_text'] = $post_text; |
|
531 | - } |
|
532 | - // START irmtfan remove hardcoded html in URLs |
|
533 | - $seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id']; |
|
534 | - $seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id']; |
|
535 | - // END irmtfan remove hardcoded html in URLs |
|
536 | - if (!empty($newbbConfig['do_rewrite'])) { |
|
537 | - $topic['seo_url'] = seo_urls($seo_url); |
|
538 | - $topic['seo_forum_url'] = seo_urls($seo_forum_url); |
|
539 | - } else { |
|
540 | - $topic['seo_url'] = $seo_url; |
|
541 | - $topic['seo_forum_url'] = $seo_forum_url; |
|
542 | - } |
|
543 | - |
|
544 | - $block['topics'][] = $topic; |
|
545 | - unset($topic); |
|
546 | - } |
|
547 | - // START irmtfan remove hardcoded html in URLs |
|
548 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME; |
|
549 | - $block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
550 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php'; |
|
551 | - $block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
552 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php'; |
|
553 | - $block['seo_top_allposts'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
554 | - // END irmtfan remove hardcoded html in URLs |
|
555 | - |
|
556 | - $block['indexNav'] = (int)$options[4]; |
|
557 | - |
|
558 | - return $block; |
|
410 | + global $accessForums; |
|
411 | + global $newbbConfig; |
|
412 | + |
|
413 | + require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
414 | + $myts = \MyTextSanitizer::getInstance(); |
|
415 | + $block = []; |
|
416 | + $i = 0; |
|
417 | + $order = ''; |
|
418 | + $extraCriteria = ''; |
|
419 | + $time_criteria = null; |
|
420 | + if (!empty($options[2])) { |
|
421 | + $time_criteria = time() - newbbGetSinceTime($options[2]); |
|
422 | + $extraCriteria = ' AND p.post_time>' . $time_criteria; |
|
423 | + } |
|
424 | + |
|
425 | + switch ($options[0]) { |
|
426 | + case 'text': |
|
427 | + if (!empty($newbbConfig['enable_karma'])) { |
|
428 | + $extraCriteria .= ' AND p.post_karma = 0'; |
|
429 | + } |
|
430 | + if (!empty($newbbConfig['allow_require_reply'])) { |
|
431 | + $extraCriteria .= ' AND p.require_reply = 0'; |
|
432 | + } |
|
433 | + // no break |
|
434 | + default: |
|
435 | + $order = 'p.post_id'; |
|
436 | + break; |
|
437 | + } |
|
438 | + |
|
439 | + if (!isset($accessForums)) { |
|
440 | + /** var Newbb\PermissionHandler $permHandler */ |
|
441 | + $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
442 | + if (!$accessForums = $permHandler->getForums()) { |
|
443 | + return $block; |
|
444 | + } |
|
445 | + } |
|
446 | + |
|
447 | + $newbbConfig = newbbLoadConfig(); |
|
448 | + if (!empty($newbbConfig['do_rewrite'])) { |
|
449 | + require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php'); |
|
450 | + } else { |
|
451 | + if (!defined('SEO_MODULE_NAME')) { |
|
452 | + define('SEO_MODULE_NAME', 'modules/newbb'); |
|
453 | + } |
|
454 | + } |
|
455 | + |
|
456 | + if (!empty($options[6])) { |
|
457 | + $myallowedForums = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
|
458 | + $allowedForums = array_intersect($myallowedForums, $accessForums); |
|
459 | + } else { |
|
460 | + $allowedForums = $accessForums; |
|
461 | + } |
|
462 | + if (empty($allowedForums)) { |
|
463 | + return $block; |
|
464 | + } |
|
465 | + |
|
466 | + $forumCriteria = ' AND p.forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
467 | + $approveCriteria = ' AND p.approved = 1'; |
|
468 | + |
|
469 | + $query = 'SELECT'; |
|
470 | + $query .= ' p.post_id, p.subject, p.post_time, p.icon, p.uid, p.poster_name,'; |
|
471 | + if ('text' === $options[0]) { |
|
472 | + $query .= ' pt.dohtml, pt.dosmiley, pt.doxcode, pt.dobr, pt.post_text,'; |
|
473 | + } |
|
474 | + $query .= ' f.forum_id, f.forum_name' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' AS p ' . ' LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('newbb_forums') . ' AS f ON f.forum_id=p.forum_id'; |
|
475 | + if ('text' === $options[0]) { |
|
476 | + $query .= ' LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('newbb_posts_text') . ' AS pt ON pt.post_id=p.post_id'; |
|
477 | + } |
|
478 | + $query .= ' WHERE 1=1 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' ORDER BY ' . $order . ' DESC'; |
|
479 | + |
|
480 | + $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
|
481 | + if (!$result) { |
|
482 | + //xoops_error($GLOBALS['xoopsDB']->error()); |
|
483 | + return $block; |
|
484 | + } |
|
485 | + $block['disp_mode'] = ('text' === $options[0]) ? 3 : $options[3]; // 0 - full view; 1 - compact view; 2 - lite view; |
|
486 | + $rows = []; |
|
487 | + $author = []; |
|
488 | + while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
489 | + $rows[] = $row; |
|
490 | + $author[$row['uid']] = 1; |
|
491 | + } |
|
492 | + if (count($rows) < 1) { |
|
493 | + return $block; |
|
494 | + } |
|
495 | + require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
496 | + $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true); |
|
497 | + |
|
498 | + foreach ($rows as $arr) { |
|
499 | + //if ($arr['icon'] && is_file($GLOBALS['xoops']->path('images/subject/' . $arr['icon']))) { |
|
500 | + if (!empty($arr['icon'])) { |
|
501 | + $last_post_icon = '<img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars($arr['icon'], ENT_QUOTES | ENT_HTML5) . '" alt="" />'; |
|
502 | + } else { |
|
503 | + $last_post_icon = '<img src="' . XOOPS_URL . '/images/subject/icon1.gif" alt="" />'; |
|
504 | + } |
|
505 | + //$topic['jump_post'] = "<a href='" . XOOPS_URL . "/modules/newbb/viewtopic.php?post_id=" . $arr['post_id'] ."#forumpost" . $arr['post_id'] . "'>" . $last_post_icon . '</a>'; |
|
506 | + $topic = []; |
|
507 | + $topic['forum_id'] = $arr['forum_id']; |
|
508 | + $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); |
|
509 | + //$topic['id'] = $arr['topic_id']; |
|
510 | + |
|
511 | + $title = $myts->htmlSpecialChars($arr['subject']); |
|
512 | + if ('text' !== $options[0] && !empty($options[5])) { |
|
513 | + $title = xoops_substr($title, 0, $options[5]); |
|
514 | + } |
|
515 | + $topic['title'] = $title; |
|
516 | + $topic['post_id'] = $arr['post_id']; |
|
517 | + $topic['time'] = newbbFormatTimestamp($arr['post_time']); |
|
518 | + if (!empty($author_name[$arr['uid']])) { |
|
519 | + $topic_poster = $author_name[$arr['uid']]; |
|
520 | + } else { |
|
521 | + $topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); |
|
522 | + } |
|
523 | + $topic['topic_poster'] = $topic_poster; |
|
524 | + |
|
525 | + if ('text' === $options[0]) { |
|
526 | + $post_text = $myts->displayTarea($arr['post_text'], $arr['dohtml'], $arr['dosmiley'], $arr['doxcode'], 1, $arr['dobr']); |
|
527 | + if (!empty($options[5])) { |
|
528 | + $post_text = xoops_substr(strip_tags($post_text), 0, $options[5]); |
|
529 | + } |
|
530 | + $topic['post_text'] = $post_text; |
|
531 | + } |
|
532 | + // START irmtfan remove hardcoded html in URLs |
|
533 | + $seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id']; |
|
534 | + $seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id']; |
|
535 | + // END irmtfan remove hardcoded html in URLs |
|
536 | + if (!empty($newbbConfig['do_rewrite'])) { |
|
537 | + $topic['seo_url'] = seo_urls($seo_url); |
|
538 | + $topic['seo_forum_url'] = seo_urls($seo_forum_url); |
|
539 | + } else { |
|
540 | + $topic['seo_url'] = $seo_url; |
|
541 | + $topic['seo_forum_url'] = $seo_forum_url; |
|
542 | + } |
|
543 | + |
|
544 | + $block['topics'][] = $topic; |
|
545 | + unset($topic); |
|
546 | + } |
|
547 | + // START irmtfan remove hardcoded html in URLs |
|
548 | + $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME; |
|
549 | + $block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
550 | + $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php'; |
|
551 | + $block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
552 | + $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php'; |
|
553 | + $block['seo_top_allposts'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
554 | + // END irmtfan remove hardcoded html in URLs |
|
555 | + |
|
556 | + $block['indexNav'] = (int)$options[4]; |
|
557 | + |
|
558 | + return $block; |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | // options[0] - Citeria valid: post(by default), topic, digest, sticky |
@@ -572,95 +572,95 @@ discard block |
||
572 | 572 | */ |
573 | 573 | function b_newbb_author_show($options) |
574 | 574 | { |
575 | - global $accessForums; |
|
576 | - global $newbbConfig; |
|
577 | - $myts = \MyTextSanitizer::getInstance(); |
|
578 | - $block = []; |
|
579 | - // $i = 0; |
|
580 | - $type = 'topic'; |
|
581 | - $order = 'count'; |
|
582 | - $extraCriteria = ''; |
|
583 | - $time_criteria = null; |
|
584 | - if (!empty($options[2])) { |
|
585 | - require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
586 | - $time_criteria = time() - newbbGetSinceTime($options[2]); |
|
587 | - $extraCriteria = ' AND topic_time > ' . $time_criteria; |
|
588 | - } |
|
589 | - switch ($options[0]) { |
|
590 | - case 'topic': |
|
591 | - break; |
|
592 | - case 'digest': |
|
593 | - $extraCriteria = ' AND topic_digest = 1'; |
|
594 | - if (null !== $time_criteria) { |
|
595 | - $extraCriteria .= ' AND digest_time > ' . $time_criteria; |
|
596 | - } |
|
597 | - break; |
|
598 | - case 'sticky': |
|
599 | - $extraCriteria .= ' AND topic_sticky = 1'; |
|
600 | - break; |
|
601 | - case 'post': |
|
602 | - default: |
|
603 | - $type = 'post'; |
|
604 | - if (null !== $time_criteria) { |
|
605 | - $extraCriteria = ' AND post_time > ' . $time_criteria; |
|
606 | - } |
|
607 | - break; |
|
608 | - } |
|
609 | - |
|
610 | - if (!isset($accessForums)) { |
|
611 | - /** var Newbb\PermissionHandler $permHandler */ |
|
612 | - $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
613 | - if (!$accessForums = $permHandler->getForums()) { |
|
614 | - return $block; |
|
615 | - } |
|
616 | - } |
|
617 | - |
|
618 | - if (!empty($options[5])) { |
|
619 | - $myallowedForums = array_filter(array_slice($options, 5), 'b_newbb_array_filter'); // get allowed forums |
|
620 | - $allowedForums = array_intersect($myallowedForums, $accessForums); |
|
621 | - } else { |
|
622 | - $allowedForums = $accessForums; |
|
623 | - } |
|
624 | - if (empty($allowedForums)) { |
|
625 | - return false; |
|
626 | - } |
|
627 | - |
|
628 | - if ('topic' === $type) { |
|
629 | - $forumCriteria = ' AND forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
630 | - $approveCriteria = ' AND approved = 1'; |
|
631 | - $query = 'SELECT DISTINCT topic_poster AS author, COUNT(*) AS count |
|
575 | + global $accessForums; |
|
576 | + global $newbbConfig; |
|
577 | + $myts = \MyTextSanitizer::getInstance(); |
|
578 | + $block = []; |
|
579 | + // $i = 0; |
|
580 | + $type = 'topic'; |
|
581 | + $order = 'count'; |
|
582 | + $extraCriteria = ''; |
|
583 | + $time_criteria = null; |
|
584 | + if (!empty($options[2])) { |
|
585 | + require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
586 | + $time_criteria = time() - newbbGetSinceTime($options[2]); |
|
587 | + $extraCriteria = ' AND topic_time > ' . $time_criteria; |
|
588 | + } |
|
589 | + switch ($options[0]) { |
|
590 | + case 'topic': |
|
591 | + break; |
|
592 | + case 'digest': |
|
593 | + $extraCriteria = ' AND topic_digest = 1'; |
|
594 | + if (null !== $time_criteria) { |
|
595 | + $extraCriteria .= ' AND digest_time > ' . $time_criteria; |
|
596 | + } |
|
597 | + break; |
|
598 | + case 'sticky': |
|
599 | + $extraCriteria .= ' AND topic_sticky = 1'; |
|
600 | + break; |
|
601 | + case 'post': |
|
602 | + default: |
|
603 | + $type = 'post'; |
|
604 | + if (null !== $time_criteria) { |
|
605 | + $extraCriteria = ' AND post_time > ' . $time_criteria; |
|
606 | + } |
|
607 | + break; |
|
608 | + } |
|
609 | + |
|
610 | + if (!isset($accessForums)) { |
|
611 | + /** var Newbb\PermissionHandler $permHandler */ |
|
612 | + $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
613 | + if (!$accessForums = $permHandler->getForums()) { |
|
614 | + return $block; |
|
615 | + } |
|
616 | + } |
|
617 | + |
|
618 | + if (!empty($options[5])) { |
|
619 | + $myallowedForums = array_filter(array_slice($options, 5), 'b_newbb_array_filter'); // get allowed forums |
|
620 | + $allowedForums = array_intersect($myallowedForums, $accessForums); |
|
621 | + } else { |
|
622 | + $allowedForums = $accessForums; |
|
623 | + } |
|
624 | + if (empty($allowedForums)) { |
|
625 | + return false; |
|
626 | + } |
|
627 | + |
|
628 | + if ('topic' === $type) { |
|
629 | + $forumCriteria = ' AND forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
630 | + $approveCriteria = ' AND approved = 1'; |
|
631 | + $query = 'SELECT DISTINCT topic_poster AS author, COUNT(*) AS count |
|
632 | 632 | FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' |
633 | 633 | WHERE topic_poster>0 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' GROUP BY topic_poster ORDER BY ' . $order . ' DESC'; |
634 | - } else { |
|
635 | - $forumCriteria = ' AND forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
636 | - $approveCriteria = ' AND approved = 1'; |
|
637 | - $query = 'SELECT DISTINCT uid AS author, COUNT(*) AS count |
|
634 | + } else { |
|
635 | + $forumCriteria = ' AND forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
636 | + $approveCriteria = ' AND approved = 1'; |
|
637 | + $query = 'SELECT DISTINCT uid AS author, COUNT(*) AS count |
|
638 | 638 | FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' |
639 | 639 | WHERE uid > 0 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' GROUP BY uid ORDER BY ' . $order . ' DESC'; |
640 | - } |
|
641 | - |
|
642 | - $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
|
643 | - if (!$result) { |
|
644 | - //xoops_error($GLOBALS['xoopsDB']->error()); |
|
645 | - return $block; |
|
646 | - } |
|
647 | - $author = []; |
|
648 | - while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
649 | - $author[$row['author']]['count'] = $row['count']; |
|
650 | - } |
|
651 | - if (count($author) < 1) { |
|
652 | - return $block; |
|
653 | - } |
|
654 | - require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
655 | - $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname']); |
|
656 | - foreach (array_keys($author) as $uid) { |
|
657 | - $author[$uid]['name'] = $myts->htmlSpecialChars($author_name[$uid]); |
|
658 | - } |
|
659 | - $block['authors'] =& $author; |
|
660 | - $block['disp_mode'] = $options[3]; // 0 - full view; 1 - lite view; |
|
661 | - $block['indexNav'] = (int)$options[4]; |
|
662 | - |
|
663 | - return $block; |
|
640 | + } |
|
641 | + |
|
642 | + $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
|
643 | + if (!$result) { |
|
644 | + //xoops_error($GLOBALS['xoopsDB']->error()); |
|
645 | + return $block; |
|
646 | + } |
|
647 | + $author = []; |
|
648 | + while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
649 | + $author[$row['author']]['count'] = $row['count']; |
|
650 | + } |
|
651 | + if (count($author) < 1) { |
|
652 | + return $block; |
|
653 | + } |
|
654 | + require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
655 | + $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname']); |
|
656 | + foreach (array_keys($author) as $uid) { |
|
657 | + $author[$uid]['name'] = $myts->htmlSpecialChars($author_name[$uid]); |
|
658 | + } |
|
659 | + $block['authors'] =& $author; |
|
660 | + $block['disp_mode'] = $options[3]; // 0 - full view; 1 - lite view; |
|
661 | + $block['indexNav'] = (int)$options[4]; |
|
662 | + |
|
663 | + return $block; |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -669,58 +669,58 @@ discard block |
||
669 | 669 | */ |
670 | 670 | function b_newbb_edit($options) |
671 | 671 | { |
672 | - require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
673 | - |
|
674 | - $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
675 | - $form .= "<option value='time'"; |
|
676 | - if ('time' === $options[0]) { |
|
677 | - $form .= " selected='selected' "; |
|
678 | - } |
|
679 | - $form .= '>' . _MB_NEWBB_CRITERIA_TIME . '</option>'; |
|
680 | - $form .= '</select>'; |
|
681 | - $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' />"; |
|
682 | - $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' />"; |
|
683 | - $form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
684 | - $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
685 | - if (0 == $options[3]) { |
|
686 | - $form .= ' checked'; |
|
687 | - } |
|
688 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'"; |
|
689 | - if (1 == $options[3]) { |
|
690 | - $form .= ' checked'; |
|
691 | - } |
|
692 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'"; |
|
693 | - if (2 == $options[3]) { |
|
694 | - $form .= ' checked'; |
|
695 | - } |
|
696 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
697 | - |
|
698 | - $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
699 | - if (1 == $options[4]) { |
|
700 | - $form .= ' checked'; |
|
701 | - } |
|
702 | - $form .= ' />' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
703 | - if (0 == $options[4]) { |
|
704 | - $form .= ' checked'; |
|
705 | - } |
|
706 | - $form .= ' />' . _NO; |
|
707 | - |
|
708 | - $form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' />"; |
|
709 | - |
|
710 | - $form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
711 | - |
|
712 | - $optionsForum = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
|
713 | - $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
714 | - $form .= '<br> <select name="options[]" multiple="multiple">'; |
|
715 | - $form .= '<option value="0" '; |
|
716 | - if ($isAll) { |
|
717 | - $form .= ' selected'; |
|
718 | - } |
|
719 | - $form .= '>' . _ALL . '</option>'; |
|
720 | - $form .= newbbForumSelectBox($optionsForum); |
|
721 | - $form .= '</select><br>'; |
|
722 | - |
|
723 | - return $form; |
|
672 | + require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
673 | + |
|
674 | + $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
675 | + $form .= "<option value='time'"; |
|
676 | + if ('time' === $options[0]) { |
|
677 | + $form .= " selected='selected' "; |
|
678 | + } |
|
679 | + $form .= '>' . _MB_NEWBB_CRITERIA_TIME . '</option>'; |
|
680 | + $form .= '</select>'; |
|
681 | + $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' />"; |
|
682 | + $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' />"; |
|
683 | + $form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
684 | + $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
685 | + if (0 == $options[3]) { |
|
686 | + $form .= ' checked'; |
|
687 | + } |
|
688 | + $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'"; |
|
689 | + if (1 == $options[3]) { |
|
690 | + $form .= ' checked'; |
|
691 | + } |
|
692 | + $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'"; |
|
693 | + if (2 == $options[3]) { |
|
694 | + $form .= ' checked'; |
|
695 | + } |
|
696 | + $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
697 | + |
|
698 | + $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
699 | + if (1 == $options[4]) { |
|
700 | + $form .= ' checked'; |
|
701 | + } |
|
702 | + $form .= ' />' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
703 | + if (0 == $options[4]) { |
|
704 | + $form .= ' checked'; |
|
705 | + } |
|
706 | + $form .= ' />' . _NO; |
|
707 | + |
|
708 | + $form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' />"; |
|
709 | + |
|
710 | + $form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
711 | + |
|
712 | + $optionsForum = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
|
713 | + $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
714 | + $form .= '<br> <select name="options[]" multiple="multiple">'; |
|
715 | + $form .= '<option value="0" '; |
|
716 | + if ($isAll) { |
|
717 | + $form .= ' selected'; |
|
718 | + } |
|
719 | + $form .= '>' . _ALL . '</option>'; |
|
720 | + $form .= newbbForumSelectBox($optionsForum); |
|
721 | + $form .= '</select><br>'; |
|
722 | + |
|
723 | + return $form; |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | /** |
@@ -729,78 +729,78 @@ discard block |
||
729 | 729 | */ |
730 | 730 | function b_newbb_topic_edit($options) |
731 | 731 | { |
732 | - require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
733 | - $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
734 | - $form .= "<option value='time'"; |
|
735 | - if ('time' === $options[0]) { |
|
736 | - $form .= " selected='selected' "; |
|
737 | - } |
|
738 | - $form .= '>' . _MB_NEWBB_CRITERIA_TIME . '</option>'; |
|
739 | - $form .= "<option value='views'"; |
|
740 | - if ('views' === $options[0]) { |
|
741 | - $form .= " selected='selected' "; |
|
742 | - } |
|
743 | - $form .= '>' . _MB_NEWBB_CRITERIA_VIEWS . '</option>'; |
|
744 | - $form .= "<option value='replies'"; |
|
745 | - if ('replies' === $options[0]) { |
|
746 | - $form .= " selected='selected' "; |
|
747 | - } |
|
748 | - $form .= '>' . _MB_NEWBB_CRITERIA_REPLIES . '</option>'; |
|
749 | - $form .= "<option value='digest'"; |
|
750 | - if ('digest' === $options[0]) { |
|
751 | - $form .= " selected='selected' "; |
|
752 | - } |
|
753 | - $form .= '>' . _MB_NEWBB_CRITERIA_DIGEST . '</option>'; |
|
754 | - $form .= "<option value='sticky'"; |
|
755 | - if ('sticky' === $options[0]) { |
|
756 | - $form .= " selected='selected' "; |
|
757 | - } |
|
758 | - $form .= '>' . _MB_NEWBB_CRITERIA_STICKY . '</option>'; |
|
759 | - $form .= '</select>'; |
|
760 | - $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' />"; |
|
761 | - $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' />"; |
|
762 | - $form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
763 | - $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
764 | - if (0 == $options[3]) { |
|
765 | - $form .= ' checked'; |
|
766 | - } |
|
767 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'"; |
|
768 | - if (1 == $options[3]) { |
|
769 | - $form .= ' checked'; |
|
770 | - } |
|
771 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'"; |
|
772 | - if (2 == $options[3]) { |
|
773 | - $form .= ' checked'; |
|
774 | - } |
|
775 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
776 | - |
|
777 | - $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
778 | - if (1 == $options[4]) { |
|
779 | - $form .= ' checked'; |
|
780 | - } |
|
781 | - $form .= ' />' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
782 | - if (0 == $options[4]) { |
|
783 | - $form .= ' checked'; |
|
784 | - } |
|
785 | - $form .= ' />' . _NO; |
|
786 | - |
|
787 | - $form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' />"; |
|
788 | - |
|
789 | - $form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
790 | - |
|
791 | - $optionsForum = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
|
792 | - |
|
793 | - $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
794 | - $form .= '<br> <select name="options[]" multiple="multiple">'; |
|
795 | - $form .= '<option value="0" '; |
|
796 | - if ($isAll) { |
|
797 | - $form .= ' selected="selected"'; |
|
798 | - } |
|
799 | - $form .= '>' . _ALL . '</option>'; |
|
800 | - $form .= newbbForumSelectBox($optionsForum); |
|
801 | - $form .= '</select><br>'; |
|
802 | - |
|
803 | - return $form; |
|
732 | + require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
733 | + $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
734 | + $form .= "<option value='time'"; |
|
735 | + if ('time' === $options[0]) { |
|
736 | + $form .= " selected='selected' "; |
|
737 | + } |
|
738 | + $form .= '>' . _MB_NEWBB_CRITERIA_TIME . '</option>'; |
|
739 | + $form .= "<option value='views'"; |
|
740 | + if ('views' === $options[0]) { |
|
741 | + $form .= " selected='selected' "; |
|
742 | + } |
|
743 | + $form .= '>' . _MB_NEWBB_CRITERIA_VIEWS . '</option>'; |
|
744 | + $form .= "<option value='replies'"; |
|
745 | + if ('replies' === $options[0]) { |
|
746 | + $form .= " selected='selected' "; |
|
747 | + } |
|
748 | + $form .= '>' . _MB_NEWBB_CRITERIA_REPLIES . '</option>'; |
|
749 | + $form .= "<option value='digest'"; |
|
750 | + if ('digest' === $options[0]) { |
|
751 | + $form .= " selected='selected' "; |
|
752 | + } |
|
753 | + $form .= '>' . _MB_NEWBB_CRITERIA_DIGEST . '</option>'; |
|
754 | + $form .= "<option value='sticky'"; |
|
755 | + if ('sticky' === $options[0]) { |
|
756 | + $form .= " selected='selected' "; |
|
757 | + } |
|
758 | + $form .= '>' . _MB_NEWBB_CRITERIA_STICKY . '</option>'; |
|
759 | + $form .= '</select>'; |
|
760 | + $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' />"; |
|
761 | + $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' />"; |
|
762 | + $form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
763 | + $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
764 | + if (0 == $options[3]) { |
|
765 | + $form .= ' checked'; |
|
766 | + } |
|
767 | + $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'"; |
|
768 | + if (1 == $options[3]) { |
|
769 | + $form .= ' checked'; |
|
770 | + } |
|
771 | + $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'"; |
|
772 | + if (2 == $options[3]) { |
|
773 | + $form .= ' checked'; |
|
774 | + } |
|
775 | + $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
776 | + |
|
777 | + $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
778 | + if (1 == $options[4]) { |
|
779 | + $form .= ' checked'; |
|
780 | + } |
|
781 | + $form .= ' />' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
782 | + if (0 == $options[4]) { |
|
783 | + $form .= ' checked'; |
|
784 | + } |
|
785 | + $form .= ' />' . _NO; |
|
786 | + |
|
787 | + $form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' />"; |
|
788 | + |
|
789 | + $form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
790 | + |
|
791 | + $optionsForum = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
|
792 | + |
|
793 | + $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
794 | + $form .= '<br> <select name="options[]" multiple="multiple">'; |
|
795 | + $form .= '<option value="0" '; |
|
796 | + if ($isAll) { |
|
797 | + $form .= ' selected="selected"'; |
|
798 | + } |
|
799 | + $form .= '>' . _ALL . '</option>'; |
|
800 | + $form .= newbbForumSelectBox($optionsForum); |
|
801 | + $form .= '</select><br>'; |
|
802 | + |
|
803 | + return $form; |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | /** |
@@ -809,62 +809,62 @@ discard block |
||
809 | 809 | */ |
810 | 810 | function b_newbb_post_edit($options) |
811 | 811 | { |
812 | - require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
813 | - $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
814 | - $form .= "<option value='title'"; |
|
815 | - if ('title' === $options[0]) { |
|
816 | - $form .= " selected='selected' "; |
|
817 | - } |
|
818 | - $form .= '>' . _MB_NEWBB_CRITERIA_TITLE . '</option>'; |
|
819 | - $form .= "<option value='text'"; |
|
820 | - if ('text' === $options[0]) { |
|
821 | - $form .= " selected='selected' "; |
|
822 | - } |
|
823 | - $form .= '>' . _MB_NEWBB_CRITERIA_TEXT . '</option>'; |
|
824 | - $form .= '</select>'; |
|
825 | - $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' />"; |
|
826 | - $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' />"; |
|
827 | - $form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
828 | - $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
829 | - if (0 == $options[3]) { |
|
830 | - $form .= ' checked'; |
|
831 | - } |
|
832 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'"; |
|
833 | - if (1 == $options[3]) { |
|
834 | - $form .= ' checked'; |
|
835 | - } |
|
836 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'"; |
|
837 | - if (2 == $options[3]) { |
|
838 | - $form .= ' checked'; |
|
839 | - } |
|
840 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
841 | - |
|
842 | - $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
843 | - if (1 == $options[4]) { |
|
844 | - $form .= ' checked'; |
|
845 | - } |
|
846 | - $form .= ' />' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
847 | - if (0 == $options[4]) { |
|
848 | - $form .= ' checked'; |
|
849 | - } |
|
850 | - $form .= ' />' . _NO; |
|
851 | - |
|
852 | - $form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' />"; |
|
853 | - |
|
854 | - $form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
855 | - |
|
856 | - $optionsForum = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
|
857 | - $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
858 | - $form .= '<br> <select name="options[]" multiple="multiple">'; |
|
859 | - $form .= '<option value="0" '; |
|
860 | - if ($isAll) { |
|
861 | - $form .= ' selected="selected"'; |
|
862 | - } |
|
863 | - $form .= '>' . _ALL . '</option>'; |
|
864 | - $form .= newbbForumSelectBox($optionsForum); |
|
865 | - $form .= '</select><br>'; |
|
866 | - |
|
867 | - return $form; |
|
812 | + require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
813 | + $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
814 | + $form .= "<option value='title'"; |
|
815 | + if ('title' === $options[0]) { |
|
816 | + $form .= " selected='selected' "; |
|
817 | + } |
|
818 | + $form .= '>' . _MB_NEWBB_CRITERIA_TITLE . '</option>'; |
|
819 | + $form .= "<option value='text'"; |
|
820 | + if ('text' === $options[0]) { |
|
821 | + $form .= " selected='selected' "; |
|
822 | + } |
|
823 | + $form .= '>' . _MB_NEWBB_CRITERIA_TEXT . '</option>'; |
|
824 | + $form .= '</select>'; |
|
825 | + $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' />"; |
|
826 | + $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' />"; |
|
827 | + $form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
828 | + $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
829 | + if (0 == $options[3]) { |
|
830 | + $form .= ' checked'; |
|
831 | + } |
|
832 | + $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'"; |
|
833 | + if (1 == $options[3]) { |
|
834 | + $form .= ' checked'; |
|
835 | + } |
|
836 | + $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'"; |
|
837 | + if (2 == $options[3]) { |
|
838 | + $form .= ' checked'; |
|
839 | + } |
|
840 | + $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
841 | + |
|
842 | + $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
843 | + if (1 == $options[4]) { |
|
844 | + $form .= ' checked'; |
|
845 | + } |
|
846 | + $form .= ' />' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
847 | + if (0 == $options[4]) { |
|
848 | + $form .= ' checked'; |
|
849 | + } |
|
850 | + $form .= ' />' . _NO; |
|
851 | + |
|
852 | + $form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' />"; |
|
853 | + |
|
854 | + $form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
855 | + |
|
856 | + $optionsForum = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
|
857 | + $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
858 | + $form .= '<br> <select name="options[]" multiple="multiple">'; |
|
859 | + $form .= '<option value="0" '; |
|
860 | + if ($isAll) { |
|
861 | + $form .= ' selected="selected"'; |
|
862 | + } |
|
863 | + $form .= '>' . _ALL . '</option>'; |
|
864 | + $form .= newbbForumSelectBox($optionsForum); |
|
865 | + $form .= '</select><br>'; |
|
866 | + |
|
867 | + return $form; |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | /** |
@@ -873,66 +873,66 @@ discard block |
||
873 | 873 | */ |
874 | 874 | function b_newbb_author_edit($options) |
875 | 875 | { |
876 | - require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
877 | - $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
878 | - $form .= "<option value='post'"; |
|
879 | - if ('post' === $options[0]) { |
|
880 | - $form .= " selected='selected' "; |
|
881 | - } |
|
882 | - $form .= '>' . _MB_NEWBB_CRITERIA_POST . '</option>'; |
|
883 | - $form .= "<option value='topic'"; |
|
884 | - if ('topic' === $options[0]) { |
|
885 | - $form .= " selected='selected' "; |
|
886 | - } |
|
887 | - $form .= '>' . _MB_NEWBB_CRITERIA_TOPIC . '</option>'; |
|
888 | - $form .= "<option value='digest'"; |
|
889 | - if ('digest' === $options[0]) { |
|
890 | - $form .= " selected='selected' "; |
|
891 | - } |
|
892 | - $form .= '>' . _MB_NEWBB_CRITERIA_DIGESTS . '</option>'; |
|
893 | - $form .= "<option value='sticky'"; |
|
894 | - if ('sticky' === $options[0]) { |
|
895 | - $form .= " selected='selected' "; |
|
896 | - } |
|
897 | - $form .= '>' . _MB_NEWBB_CRITERIA_STICKYS . '</option>'; |
|
898 | - $form .= '</select>'; |
|
899 | - $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' />"; |
|
900 | - $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' />"; |
|
901 | - $form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
902 | - $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
903 | - if (0 == $options[3]) { |
|
904 | - $form .= ' checked'; |
|
905 | - } |
|
906 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='1'"; |
|
907 | - if (1 == $options[3]) { |
|
908 | - $form .= ' checked'; |
|
909 | - } |
|
910 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
911 | - |
|
912 | - $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
913 | - if (1 == $options[4]) { |
|
914 | - $form .= ' checked'; |
|
915 | - } |
|
916 | - $form .= ' />' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
917 | - if (0 == $options[4]) { |
|
918 | - $form .= ' checked'; |
|
919 | - } |
|
920 | - $form .= ' />' . _NO; |
|
921 | - |
|
922 | - $form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
923 | - |
|
924 | - $optionsForum = array_filter(array_slice($options, 5), 'b_newbb_array_filter'); // get allowed forums |
|
925 | - $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
926 | - $form .= '<br> <select name="options[]" multiple="multiple">'; |
|
927 | - $form .= '<option value="0" '; |
|
928 | - if ($isAll) { |
|
929 | - $form .= ' selected="selected"'; |
|
930 | - } |
|
931 | - $form .= '>' . _ALL . '</option>'; |
|
932 | - $form .= newbbForumSelectBox($optionsForum); |
|
933 | - $form .= '</select><br>'; |
|
934 | - |
|
935 | - return $form; |
|
876 | + require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
877 | + $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
878 | + $form .= "<option value='post'"; |
|
879 | + if ('post' === $options[0]) { |
|
880 | + $form .= " selected='selected' "; |
|
881 | + } |
|
882 | + $form .= '>' . _MB_NEWBB_CRITERIA_POST . '</option>'; |
|
883 | + $form .= "<option value='topic'"; |
|
884 | + if ('topic' === $options[0]) { |
|
885 | + $form .= " selected='selected' "; |
|
886 | + } |
|
887 | + $form .= '>' . _MB_NEWBB_CRITERIA_TOPIC . '</option>'; |
|
888 | + $form .= "<option value='digest'"; |
|
889 | + if ('digest' === $options[0]) { |
|
890 | + $form .= " selected='selected' "; |
|
891 | + } |
|
892 | + $form .= '>' . _MB_NEWBB_CRITERIA_DIGESTS . '</option>'; |
|
893 | + $form .= "<option value='sticky'"; |
|
894 | + if ('sticky' === $options[0]) { |
|
895 | + $form .= " selected='selected' "; |
|
896 | + } |
|
897 | + $form .= '>' . _MB_NEWBB_CRITERIA_STICKYS . '</option>'; |
|
898 | + $form .= '</select>'; |
|
899 | + $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' />"; |
|
900 | + $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' />"; |
|
901 | + $form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
902 | + $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
903 | + if (0 == $options[3]) { |
|
904 | + $form .= ' checked'; |
|
905 | + } |
|
906 | + $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='1'"; |
|
907 | + if (1 == $options[3]) { |
|
908 | + $form .= ' checked'; |
|
909 | + } |
|
910 | + $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
911 | + |
|
912 | + $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
913 | + if (1 == $options[4]) { |
|
914 | + $form .= ' checked'; |
|
915 | + } |
|
916 | + $form .= ' />' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
917 | + if (0 == $options[4]) { |
|
918 | + $form .= ' checked'; |
|
919 | + } |
|
920 | + $form .= ' />' . _NO; |
|
921 | + |
|
922 | + $form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
923 | + |
|
924 | + $optionsForum = array_filter(array_slice($options, 5), 'b_newbb_array_filter'); // get allowed forums |
|
925 | + $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
926 | + $form .= '<br> <select name="options[]" multiple="multiple">'; |
|
927 | + $form .= '<option value="0" '; |
|
928 | + if ($isAll) { |
|
929 | + $form .= ' selected="selected"'; |
|
930 | + } |
|
931 | + $form .= '>' . _ALL . '</option>'; |
|
932 | + $form .= newbbForumSelectBox($optionsForum); |
|
933 | + $form .= '</select><br>'; |
|
934 | + |
|
935 | + return $form; |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | /** |
@@ -941,22 +941,22 @@ discard block |
||
941 | 941 | */ |
942 | 942 | function b_newbb_custom($options) |
943 | 943 | { |
944 | - // if no newbb module block set, we have to include the language file |
|
945 | - if (is_readable($GLOBALS['xoops']->path('modules/newbb/language/' . $GLOBALS['xoopsConfig']['language'] . '/blocks.php'))) { |
|
946 | - require_once $GLOBALS['xoops']->path('modules/newbb/language/' . $GLOBALS['xoopsConfig']['language'] . '/blocks.php'); |
|
947 | - } else { |
|
948 | - require_once $GLOBALS['xoops']->path('modules/newbb/language/english/blocks.php'); |
|
949 | - } |
|
950 | - |
|
951 | - $options = explode('|', $options); |
|
952 | - $block = b_newbb_show($options); |
|
953 | - if (count($block['topics']) < 1) { |
|
954 | - return false; |
|
955 | - } |
|
956 | - |
|
957 | - $tpl = new \XoopsTpl(); |
|
958 | - $tpl->assign('block', $block); |
|
959 | - $tpl->display('db:newbb_block.tpl'); |
|
944 | + // if no newbb module block set, we have to include the language file |
|
945 | + if (is_readable($GLOBALS['xoops']->path('modules/newbb/language/' . $GLOBALS['xoopsConfig']['language'] . '/blocks.php'))) { |
|
946 | + require_once $GLOBALS['xoops']->path('modules/newbb/language/' . $GLOBALS['xoopsConfig']['language'] . '/blocks.php'); |
|
947 | + } else { |
|
948 | + require_once $GLOBALS['xoops']->path('modules/newbb/language/english/blocks.php'); |
|
949 | + } |
|
950 | + |
|
951 | + $options = explode('|', $options); |
|
952 | + $block = b_newbb_show($options); |
|
953 | + if (count($block['topics']) < 1) { |
|
954 | + return false; |
|
955 | + } |
|
956 | + |
|
957 | + $tpl = new \XoopsTpl(); |
|
958 | + $tpl->assign('block', $block); |
|
959 | + $tpl->display('db:newbb_block.tpl'); |
|
960 | 960 | } |
961 | 961 | |
962 | 962 | /** |
@@ -965,20 +965,20 @@ discard block |
||
965 | 965 | */ |
966 | 966 | function b_newbb_custom_topic($options) |
967 | 967 | { |
968 | - /** @var \XoopsModules\Newbb\Helper $helper */ |
|
969 | - $helper = \XoopsModules\Newbb\Helper::getInstance(); |
|
970 | - // if no newbb module block set, we have to include the language file |
|
971 | - $helper->loadLanguage('blocks'); |
|
972 | - |
|
973 | - $options = explode('|', $options); |
|
974 | - $block = b_newbb_topic_show($options); |
|
975 | - if (count($block['topics']) < 1) { |
|
976 | - return false; |
|
977 | - } |
|
978 | - |
|
979 | - $tpl = new \XoopsTpl(); |
|
980 | - $tpl->assign('block', $block); |
|
981 | - $tpl->display('db:newbb_block_topic.tpl'); |
|
968 | + /** @var \XoopsModules\Newbb\Helper $helper */ |
|
969 | + $helper = \XoopsModules\Newbb\Helper::getInstance(); |
|
970 | + // if no newbb module block set, we have to include the language file |
|
971 | + $helper->loadLanguage('blocks'); |
|
972 | + |
|
973 | + $options = explode('|', $options); |
|
974 | + $block = b_newbb_topic_show($options); |
|
975 | + if (count($block['topics']) < 1) { |
|
976 | + return false; |
|
977 | + } |
|
978 | + |
|
979 | + $tpl = new \XoopsTpl(); |
|
980 | + $tpl->assign('block', $block); |
|
981 | + $tpl->display('db:newbb_block_topic.tpl'); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | /** |
@@ -987,20 +987,20 @@ discard block |
||
987 | 987 | */ |
988 | 988 | function b_newbb_custom_post($options) |
989 | 989 | { |
990 | - /** @var \XoopsModules\Newbb\Helper $helper */ |
|
991 | - $helper = \XoopsModules\Newbb\Helper::getInstance(); |
|
992 | - // if no newbb module block set, we have to include the language file |
|
993 | - $helper->loadLanguage('blocks'); |
|
994 | - |
|
995 | - $options = explode('|', $options); |
|
996 | - $block = b_newbb_post_show($options); |
|
997 | - if (count($block['topics']) < 1) { |
|
998 | - return false; |
|
999 | - } |
|
1000 | - |
|
1001 | - $tpl = new \XoopsTpl(); |
|
1002 | - $tpl->assign('block', $block); |
|
1003 | - $tpl->display('db:newbb_block_post.tpl'); |
|
990 | + /** @var \XoopsModules\Newbb\Helper $helper */ |
|
991 | + $helper = \XoopsModules\Newbb\Helper::getInstance(); |
|
992 | + // if no newbb module block set, we have to include the language file |
|
993 | + $helper->loadLanguage('blocks'); |
|
994 | + |
|
995 | + $options = explode('|', $options); |
|
996 | + $block = b_newbb_post_show($options); |
|
997 | + if (count($block['topics']) < 1) { |
|
998 | + return false; |
|
999 | + } |
|
1000 | + |
|
1001 | + $tpl = new \XoopsTpl(); |
|
1002 | + $tpl->assign('block', $block); |
|
1003 | + $tpl->display('db:newbb_block_post.tpl'); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | /** |
@@ -1009,20 +1009,20 @@ discard block |
||
1009 | 1009 | */ |
1010 | 1010 | function b_newbb_custom_author($options) |
1011 | 1011 | { |
1012 | - /** @var \XoopsModules\Newbb\Helper $helper */ |
|
1013 | - $helper = \XoopsModules\Newbb\Helper::getInstance(); |
|
1014 | - // if no newbb module block set, we have to include the language file |
|
1015 | - $helper->loadLanguage('blocks'); |
|
1016 | - |
|
1017 | - $options = explode('|', $options); |
|
1018 | - $block = b_newbb_author_show($options); |
|
1019 | - if (count($block['authors']) < 1) { |
|
1020 | - return false; |
|
1021 | - } |
|
1022 | - |
|
1023 | - $tpl = new \XoopsTpl(); |
|
1024 | - $tpl->assign('block', $block); |
|
1025 | - $tpl->display('db:newbb_block_author.tpl'); |
|
1012 | + /** @var \XoopsModules\Newbb\Helper $helper */ |
|
1013 | + $helper = \XoopsModules\Newbb\Helper::getInstance(); |
|
1014 | + // if no newbb module block set, we have to include the language file |
|
1015 | + $helper->loadLanguage('blocks'); |
|
1016 | + |
|
1017 | + $options = explode('|', $options); |
|
1018 | + $block = b_newbb_author_show($options); |
|
1019 | + if (count($block['authors']) < 1) { |
|
1020 | + return false; |
|
1021 | + } |
|
1022 | + |
|
1023 | + $tpl = new \XoopsTpl(); |
|
1024 | + $tpl->assign('block', $block); |
|
1025 | + $tpl->display('db:newbb_block_author.tpl'); |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | // irmtfan add local stylesheet and js footer.php |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | global $accessForums; |
57 | 57 | global $xoopsLogger; |
58 | 58 | |
59 | - require_once dirname(__DIR__) . '/include/functions.config.php'; |
|
60 | - require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
59 | + require_once dirname(__DIR__).'/include/functions.config.php'; |
|
60 | + require_once dirname(__DIR__).'/include/functions.time.php'; |
|
61 | 61 | |
62 | 62 | $myts = \MyTextSanitizer::getInstance(); |
63 | 63 | $block = []; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $extraCriteria = ''; |
67 | 67 | if (!empty($options[2])) { |
68 | 68 | //require_once dirname(__DIR__) . '/include/functions.time.php'; |
69 | - $extraCriteria .= ' AND p.post_time>' . (time() - newbbGetSinceTime($options[2])); |
|
69 | + $extraCriteria .= ' AND p.post_time>'.(time() - newbbGetSinceTime($options[2])); |
|
70 | 70 | } |
71 | 71 | switch ($options[0]) { |
72 | 72 | case 'time': |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | return $block; |
93 | 93 | } |
94 | 94 | |
95 | - $forumCriteria = ' AND t.forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
95 | + $forumCriteria = ' AND t.forum_id IN ('.implode(',', $allowedForums).')'; |
|
96 | 96 | $approveCriteria = ' AND t.approved = 1'; |
97 | 97 | |
98 | 98 | $newbbConfig = newbbLoadConfig(); |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | return $block; |
149 | 149 | } |
150 | 150 | |
151 | - require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
151 | + require_once dirname(__DIR__).'/include/functions.user.php'; |
|
152 | 152 | $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true); |
153 | 153 | |
154 | 154 | if (count($types) > 0) { |
155 | 155 | /** @var Newbb\TypeHandler $typeHandler */ |
156 | 156 | $typeHandler = Newbb\Helper::getInstance()->getHandler('Type'); |
157 | - $type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN')); |
|
157 | + $type_list = $typeHandler->getList(new \Criteria('type_id', '('.implode(', ', array_keys($types)).')', 'IN')); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | foreach ($rows as $arr) { |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | xoops_loadLanguage('main', 'newbb'); |
163 | 163 | $topic = []; |
164 | 164 | $topic_page_jump = newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST); |
165 | - $topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '[' . $type_list[$arr['type_id']] . ']'; |
|
165 | + $topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '['.$type_list[$arr['type_id']].']'; |
|
166 | 166 | |
167 | 167 | $topic['post_id'] = $arr['post_id']; |
168 | 168 | $topic['topic_status'] = $arr['topic_status']; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | if (!empty($options[5])) { |
175 | 175 | $title = xoops_substr($title, 0, $options[5]); |
176 | 176 | } |
177 | - $topic['title'] = $topic['topic_subject'] . ' ' . $title; |
|
177 | + $topic['title'] = $topic['topic_subject'].' '.$title; |
|
178 | 178 | $topic['replies'] = $arr['topic_replies']; |
179 | 179 | $topic['views'] = $arr['topic_views']; |
180 | 180 | $topic['time'] = newbbFormatTimestamp($arr['post_time']); |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | $topic['topic_poster'] = $topic_poster; |
187 | 187 | $topic['topic_page_jump'] = $topic_page_jump; |
188 | 188 | // START irmtfan remove hardcoded html in URLs - add $seo_topic_url |
189 | - $seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id']; |
|
190 | - $seo_topic_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id']; |
|
191 | - $seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id']; |
|
189 | + $seo_url = XOOPS_URL.'/'.SEO_MODULE_NAME.'/viewtopic.php?post_id='.$topic['post_id']; |
|
190 | + $seo_topic_url = XOOPS_URL.'/'.SEO_MODULE_NAME.'/viewtopic.php?topic_id='.$topic['id']; |
|
191 | + $seo_forum_url = XOOPS_URL.'/'.SEO_MODULE_NAME.'/viewforum.php?forum='.$topic['forum_id']; |
|
192 | 192 | if (!empty($newbbConfig['do_rewrite'])) { |
193 | 193 | $topic['seo_url'] = seo_urls($seo_url); |
194 | 194 | $topic['seo_topic_url'] = seo_urls($seo_topic_url); |
@@ -203,14 +203,14 @@ discard block |
||
203 | 203 | unset($topic); |
204 | 204 | } |
205 | 205 | // START irmtfan remove hardcoded html in URLs |
206 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME; |
|
206 | + $seo_top_allforums = XOOPS_URL.'/'.SEO_MODULE_NAME; |
|
207 | 207 | $block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
208 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php'; |
|
208 | + $seo_top_allforums = XOOPS_URL.'/'.SEO_MODULE_NAME.'/list.topic.php'; |
|
209 | 209 | $block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
210 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php'; |
|
210 | + $seo_top_allforums = XOOPS_URL.'/'.SEO_MODULE_NAME.'/viewpost.php'; |
|
211 | 211 | $block['seo_top_allposts'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
212 | 212 | // END irmtfan remove hardcoded html in URLs |
213 | - $block['indexNav'] = (int)$options[4]; |
|
213 | + $block['indexNav'] = (int) $options[4]; |
|
214 | 214 | |
215 | 215 | return $block; |
216 | 216 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | function b_newbb_topic_show($options) |
231 | 231 | { |
232 | 232 | global $accessForums; |
233 | - require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
233 | + require_once dirname(__DIR__).'/include/functions.time.php'; |
|
234 | 234 | $myts = \MyTextSanitizer::getInstance(); |
235 | 235 | $block = []; |
236 | 236 | $i = 0; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $time_criteria = null; |
240 | 240 | if (!empty($options[2])) { |
241 | 241 | $time_criteria = time() - newbbGetSinceTime($options[2]); |
242 | - $extraCriteria = ' AND t.topic_time>' . $time_criteria; |
|
242 | + $extraCriteria = ' AND t.topic_time>'.$time_criteria; |
|
243 | 243 | } |
244 | 244 | switch ($options[0]) { |
245 | 245 | case 'views': |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | $order = 't.digest_time'; |
253 | 253 | $extraCriteria = ' AND t.topic_digest=1'; |
254 | 254 | if (null !== $time_criteria) { |
255 | - $extraCriteria .= ' AND t.digest_time>' . $time_criteria; |
|
255 | + $extraCriteria .= ' AND t.digest_time>'.$time_criteria; |
|
256 | 256 | } |
257 | 257 | break; |
258 | 258 | case 'sticky': |
259 | - $order = 't.topic_id'; |
|
259 | + $order = 't.topic_id'; |
|
260 | 260 | $extraCriteria .= ' AND t.topic_sticky=1'; |
261 | 261 | break; |
262 | 262 | case 'time': |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | return false; |
293 | 293 | } |
294 | 294 | |
295 | - $forumCriteria = ' AND t.forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
295 | + $forumCriteria = ' AND t.forum_id IN ('.implode(',', $allowedForums).')'; |
|
296 | 296 | $approveCriteria = ' AND t.approved = 1'; |
297 | 297 | |
298 | 298 | $query = 'SELECT' |
@@ -332,19 +332,19 @@ discard block |
||
332 | 332 | if (count($rows) < 1) { |
333 | 333 | return $block; |
334 | 334 | } |
335 | - require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
335 | + require_once dirname(__DIR__).'/include/functions.user.php'; |
|
336 | 336 | $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true); |
337 | 337 | if (count($types) > 0) { |
338 | 338 | /** @var Newbb\TypeHandler $typeHandler */ |
339 | 339 | $typeHandler = Newbb\Helper::getInstance()->getHandler('Type'); |
340 | - $type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN')); |
|
340 | + $type_list = $typeHandler->getList(new \Criteria('type_id', '('.implode(', ', array_keys($types)).')', 'IN')); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | foreach ($rows as $arr) { |
344 | 344 | // irmtfan remove $topic_page_jump because there is no last post |
345 | 345 | //$topic_page_jump = ''; |
346 | 346 | $topic = []; |
347 | - $topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '[' . $type_list[$arr['type_id']] . '] '; |
|
347 | + $topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '['.$type_list[$arr['type_id']].'] '; |
|
348 | 348 | $topic['forum_id'] = $arr['forum_id']; |
349 | 349 | $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); |
350 | 350 | $topic['id'] = $arr['topic_id']; |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | if (!empty($options[5])) { |
354 | 354 | $title = xoops_substr($title, 0, $options[5]); |
355 | 355 | } |
356 | - $topic['title'] = $topic['topic_subject'] . $title; |
|
356 | + $topic['title'] = $topic['topic_subject'].$title; |
|
357 | 357 | $topic['replies'] = $arr['topic_replies']; |
358 | 358 | $topic['views'] = $arr['topic_views']; |
359 | 359 | $topic['time'] = newbbFormatTimestamp($arr['topic_time']); |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | // irmtfan remove $topic_page_jump because there is no last post |
367 | 367 | //$topic['topic_page_jump'] = $topic_page_jump; |
368 | 368 | // START irmtfan remove hardcoded html in URLs - add $seo_topic_url |
369 | - $seo_topic_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id']; |
|
370 | - $seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id']; |
|
369 | + $seo_topic_url = XOOPS_URL.'/'.SEO_MODULE_NAME.'/viewtopic.php?topic_id='.$topic['id']; |
|
370 | + $seo_forum_url = XOOPS_URL.'/'.SEO_MODULE_NAME.'/viewforum.php?forum='.$topic['forum_id']; |
|
371 | 371 | |
372 | 372 | if (!empty($newbbConfig['do_rewrite'])) { |
373 | 373 | $topic['seo_topic_url'] = seo_urls($seo_topic_url); |
@@ -381,14 +381,14 @@ discard block |
||
381 | 381 | unset($topic); |
382 | 382 | } |
383 | 383 | // START irmtfan remove hardcoded html in URLs |
384 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME; |
|
384 | + $seo_top_allforums = XOOPS_URL.'/'.SEO_MODULE_NAME; |
|
385 | 385 | $block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
386 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php'; |
|
386 | + $seo_top_allforums = XOOPS_URL.'/'.SEO_MODULE_NAME.'/list.topic.php'; |
|
387 | 387 | $block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
388 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php'; |
|
388 | + $seo_top_allforums = XOOPS_URL.'/'.SEO_MODULE_NAME.'/viewpost.php'; |
|
389 | 389 | $block['seo_top_allposts'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
390 | 390 | // END irmtfan remove hardcoded html in URLs |
391 | - $block['indexNav'] = (int)$options[4]; |
|
391 | + $block['indexNav'] = (int) $options[4]; |
|
392 | 392 | |
393 | 393 | return $block; |
394 | 394 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | global $accessForums; |
411 | 411 | global $newbbConfig; |
412 | 412 | |
413 | - require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
413 | + require_once dirname(__DIR__).'/include/functions.time.php'; |
|
414 | 414 | $myts = \MyTextSanitizer::getInstance(); |
415 | 415 | $block = []; |
416 | 416 | $i = 0; |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | $time_criteria = null; |
420 | 420 | if (!empty($options[2])) { |
421 | 421 | $time_criteria = time() - newbbGetSinceTime($options[2]); |
422 | - $extraCriteria = ' AND p.post_time>' . $time_criteria; |
|
422 | + $extraCriteria = ' AND p.post_time>'.$time_criteria; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | switch ($options[0]) { |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | return $block; |
464 | 464 | } |
465 | 465 | |
466 | - $forumCriteria = ' AND p.forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
466 | + $forumCriteria = ' AND p.forum_id IN ('.implode(',', $allowedForums).')'; |
|
467 | 467 | $approveCriteria = ' AND p.approved = 1'; |
468 | 468 | |
469 | 469 | $query = 'SELECT'; |
@@ -471,11 +471,11 @@ discard block |
||
471 | 471 | if ('text' === $options[0]) { |
472 | 472 | $query .= ' pt.dohtml, pt.dosmiley, pt.doxcode, pt.dobr, pt.post_text,'; |
473 | 473 | } |
474 | - $query .= ' f.forum_id, f.forum_name' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' AS p ' . ' LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('newbb_forums') . ' AS f ON f.forum_id=p.forum_id'; |
|
474 | + $query .= ' f.forum_id, f.forum_name'.' FROM '.$GLOBALS['xoopsDB']->prefix('newbb_posts').' AS p '.' LEFT JOIN '.$GLOBALS['xoopsDB']->prefix('newbb_forums').' AS f ON f.forum_id=p.forum_id'; |
|
475 | 475 | if ('text' === $options[0]) { |
476 | - $query .= ' LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('newbb_posts_text') . ' AS pt ON pt.post_id=p.post_id'; |
|
476 | + $query .= ' LEFT JOIN '.$GLOBALS['xoopsDB']->prefix('newbb_posts_text').' AS pt ON pt.post_id=p.post_id'; |
|
477 | 477 | } |
478 | - $query .= ' WHERE 1=1 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' ORDER BY ' . $order . ' DESC'; |
|
478 | + $query .= ' WHERE 1=1 '.$forumCriteria.$approveCriteria.$extraCriteria.' ORDER BY '.$order.' DESC'; |
|
479 | 479 | |
480 | 480 | $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
481 | 481 | if (!$result) { |
@@ -492,15 +492,15 @@ discard block |
||
492 | 492 | if (count($rows) < 1) { |
493 | 493 | return $block; |
494 | 494 | } |
495 | - require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
495 | + require_once dirname(__DIR__).'/include/functions.user.php'; |
|
496 | 496 | $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true); |
497 | 497 | |
498 | 498 | foreach ($rows as $arr) { |
499 | 499 | //if ($arr['icon'] && is_file($GLOBALS['xoops']->path('images/subject/' . $arr['icon']))) { |
500 | 500 | if (!empty($arr['icon'])) { |
501 | - $last_post_icon = '<img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars($arr['icon'], ENT_QUOTES | ENT_HTML5) . '" alt="" />'; |
|
501 | + $last_post_icon = '<img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($arr['icon'], ENT_QUOTES | ENT_HTML5).'" alt="" />'; |
|
502 | 502 | } else { |
503 | - $last_post_icon = '<img src="' . XOOPS_URL . '/images/subject/icon1.gif" alt="" />'; |
|
503 | + $last_post_icon = '<img src="'.XOOPS_URL.'/images/subject/icon1.gif" alt="" />'; |
|
504 | 504 | } |
505 | 505 | //$topic['jump_post'] = "<a href='" . XOOPS_URL . "/modules/newbb/viewtopic.php?post_id=" . $arr['post_id'] ."#forumpost" . $arr['post_id'] . "'>" . $last_post_icon . '</a>'; |
506 | 506 | $topic = []; |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | $topic['post_text'] = $post_text; |
531 | 531 | } |
532 | 532 | // START irmtfan remove hardcoded html in URLs |
533 | - $seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id']; |
|
534 | - $seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id']; |
|
533 | + $seo_url = XOOPS_URL.'/'.SEO_MODULE_NAME.'/viewtopic.php?post_id='.$topic['post_id']; |
|
534 | + $seo_forum_url = XOOPS_URL.'/'.SEO_MODULE_NAME.'/viewforum.php?forum='.$topic['forum_id']; |
|
535 | 535 | // END irmtfan remove hardcoded html in URLs |
536 | 536 | if (!empty($newbbConfig['do_rewrite'])) { |
537 | 537 | $topic['seo_url'] = seo_urls($seo_url); |
@@ -545,15 +545,15 @@ discard block |
||
545 | 545 | unset($topic); |
546 | 546 | } |
547 | 547 | // START irmtfan remove hardcoded html in URLs |
548 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME; |
|
548 | + $seo_top_allforums = XOOPS_URL.'/'.SEO_MODULE_NAME; |
|
549 | 549 | $block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
550 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php'; |
|
550 | + $seo_top_allforums = XOOPS_URL.'/'.SEO_MODULE_NAME.'/list.topic.php'; |
|
551 | 551 | $block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
552 | - $seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php'; |
|
552 | + $seo_top_allforums = XOOPS_URL.'/'.SEO_MODULE_NAME.'/viewpost.php'; |
|
553 | 553 | $block['seo_top_allposts'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
554 | 554 | // END irmtfan remove hardcoded html in URLs |
555 | 555 | |
556 | - $block['indexNav'] = (int)$options[4]; |
|
556 | + $block['indexNav'] = (int) $options[4]; |
|
557 | 557 | |
558 | 558 | return $block; |
559 | 559 | } |
@@ -582,9 +582,9 @@ discard block |
||
582 | 582 | $extraCriteria = ''; |
583 | 583 | $time_criteria = null; |
584 | 584 | if (!empty($options[2])) { |
585 | - require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
585 | + require_once dirname(__DIR__).'/include/functions.time.php'; |
|
586 | 586 | $time_criteria = time() - newbbGetSinceTime($options[2]); |
587 | - $extraCriteria = ' AND topic_time > ' . $time_criteria; |
|
587 | + $extraCriteria = ' AND topic_time > '.$time_criteria; |
|
588 | 588 | } |
589 | 589 | switch ($options[0]) { |
590 | 590 | case 'topic': |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | case 'digest': |
593 | 593 | $extraCriteria = ' AND topic_digest = 1'; |
594 | 594 | if (null !== $time_criteria) { |
595 | - $extraCriteria .= ' AND digest_time > ' . $time_criteria; |
|
595 | + $extraCriteria .= ' AND digest_time > '.$time_criteria; |
|
596 | 596 | } |
597 | 597 | break; |
598 | 598 | case 'sticky': |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | default: |
603 | 603 | $type = 'post'; |
604 | 604 | if (null !== $time_criteria) { |
605 | - $extraCriteria = ' AND post_time > ' . $time_criteria; |
|
605 | + $extraCriteria = ' AND post_time > '.$time_criteria; |
|
606 | 606 | } |
607 | 607 | break; |
608 | 608 | } |
@@ -626,17 +626,17 @@ discard block |
||
626 | 626 | } |
627 | 627 | |
628 | 628 | if ('topic' === $type) { |
629 | - $forumCriteria = ' AND forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
629 | + $forumCriteria = ' AND forum_id IN ('.implode(',', $allowedForums).')'; |
|
630 | 630 | $approveCriteria = ' AND approved = 1'; |
631 | 631 | $query = 'SELECT DISTINCT topic_poster AS author, COUNT(*) AS count |
632 | - FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' |
|
633 | - WHERE topic_poster>0 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' GROUP BY topic_poster ORDER BY ' . $order . ' DESC'; |
|
632 | + FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics').' |
|
633 | + WHERE topic_poster>0 ' . $forumCriteria.$approveCriteria.$extraCriteria.' GROUP BY topic_poster ORDER BY '.$order.' DESC'; |
|
634 | 634 | } else { |
635 | - $forumCriteria = ' AND forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
635 | + $forumCriteria = ' AND forum_id IN ('.implode(',', $allowedForums).')'; |
|
636 | 636 | $approveCriteria = ' AND approved = 1'; |
637 | 637 | $query = 'SELECT DISTINCT uid AS author, COUNT(*) AS count |
638 | - FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' |
|
639 | - WHERE uid > 0 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' GROUP BY uid ORDER BY ' . $order . ' DESC'; |
|
638 | + FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts').' |
|
639 | + WHERE uid > 0 ' . $forumCriteria.$approveCriteria.$extraCriteria.' GROUP BY uid ORDER BY '.$order.' DESC'; |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | $result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
@@ -651,14 +651,14 @@ discard block |
||
651 | 651 | if (count($author) < 1) { |
652 | 652 | return $block; |
653 | 653 | } |
654 | - require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
654 | + require_once dirname(__DIR__).'/include/functions.user.php'; |
|
655 | 655 | $author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname']); |
656 | 656 | foreach (array_keys($author) as $uid) { |
657 | 657 | $author[$uid]['name'] = $myts->htmlSpecialChars($author_name[$uid]); |
658 | 658 | } |
659 | - $block['authors'] =& $author; |
|
659 | + $block['authors'] = & $author; |
|
660 | 660 | $block['disp_mode'] = $options[3]; // 0 - full view; 1 - lite view; |
661 | - $block['indexNav'] = (int)$options[4]; |
|
661 | + $block['indexNav'] = (int) $options[4]; |
|
662 | 662 | |
663 | 663 | return $block; |
664 | 664 | } |
@@ -669,45 +669,45 @@ discard block |
||
669 | 669 | */ |
670 | 670 | function b_newbb_edit($options) |
671 | 671 | { |
672 | - require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
672 | + require_once dirname(__DIR__).'/include/functions.forum.php'; |
|
673 | 673 | |
674 | - $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
674 | + $form = _MB_NEWBB_CRITERIA."<select name='options[0]'>"; |
|
675 | 675 | $form .= "<option value='time'"; |
676 | 676 | if ('time' === $options[0]) { |
677 | 677 | $form .= " selected='selected' "; |
678 | 678 | } |
679 | - $form .= '>' . _MB_NEWBB_CRITERIA_TIME . '</option>'; |
|
679 | + $form .= '>'._MB_NEWBB_CRITERIA_TIME.'</option>'; |
|
680 | 680 | $form .= '</select>'; |
681 | - $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' />"; |
|
682 | - $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' />"; |
|
683 | - $form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
684 | - $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
681 | + $form .= '<br>'._MB_NEWBB_DISPLAY."<input type='text' name='options[1]' value='".$options[1]."' />"; |
|
682 | + $form .= '<br>'._MB_NEWBB_TIME."<input type='text' name='options[2]' value='".$options[2]."' />"; |
|
683 | + $form .= '<br> <small>'._MB_NEWBB_TIME_DESC.'</small>'; |
|
684 | + $form .= '<br>'._MB_NEWBB_DISPLAYMODE."<input type='radio' name='options[3]' value='0'"; |
|
685 | 685 | if (0 == $options[3]) { |
686 | 686 | $form .= ' checked'; |
687 | 687 | } |
688 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'"; |
|
688 | + $form .= ' /> '._MB_NEWBB_DISPLAYMODE_FULL."<input type='radio' name='options[3]' value='1'"; |
|
689 | 689 | if (1 == $options[3]) { |
690 | 690 | $form .= ' checked'; |
691 | 691 | } |
692 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'"; |
|
692 | + $form .= ' /> '._MB_NEWBB_DISPLAYMODE_COMPACT."<input type='radio' name='options[3]' value='2'"; |
|
693 | 693 | if (2 == $options[3]) { |
694 | 694 | $form .= ' checked'; |
695 | 695 | } |
696 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
696 | + $form .= ' /> '._MB_NEWBB_DISPLAYMODE_LITE; |
|
697 | 697 | |
698 | - $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
698 | + $form .= '<br>'._MB_NEWBB_INDEXNAV.'<input type="radio" name="options[4]" value="1"'; |
|
699 | 699 | if (1 == $options[4]) { |
700 | 700 | $form .= ' checked'; |
701 | 701 | } |
702 | - $form .= ' />' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
702 | + $form .= ' />'._YES.'<input type="radio" name="options[4]" value="0"'; |
|
703 | 703 | if (0 == $options[4]) { |
704 | 704 | $form .= ' checked'; |
705 | 705 | } |
706 | - $form .= ' />' . _NO; |
|
706 | + $form .= ' />'._NO; |
|
707 | 707 | |
708 | - $form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' />"; |
|
708 | + $form .= '<br>'._MB_NEWBB_TITLE_LENGTH."<input type='text' name='options[5]' value='".$options[5]."' />"; |
|
709 | 709 | |
710 | - $form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
710 | + $form .= '<br><br>'._MB_NEWBB_FORUMLIST; |
|
711 | 711 | |
712 | 712 | $optionsForum = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
713 | 713 | $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | if ($isAll) { |
717 | 717 | $form .= ' selected'; |
718 | 718 | } |
719 | - $form .= '>' . _ALL . '</option>'; |
|
719 | + $form .= '>'._ALL.'</option>'; |
|
720 | 720 | $form .= newbbForumSelectBox($optionsForum); |
721 | 721 | $form .= '</select><br>'; |
722 | 722 | |
@@ -729,64 +729,64 @@ discard block |
||
729 | 729 | */ |
730 | 730 | function b_newbb_topic_edit($options) |
731 | 731 | { |
732 | - require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
733 | - $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
732 | + require_once dirname(__DIR__).'/include/functions.forum.php'; |
|
733 | + $form = _MB_NEWBB_CRITERIA."<select name='options[0]'>"; |
|
734 | 734 | $form .= "<option value='time'"; |
735 | 735 | if ('time' === $options[0]) { |
736 | 736 | $form .= " selected='selected' "; |
737 | 737 | } |
738 | - $form .= '>' . _MB_NEWBB_CRITERIA_TIME . '</option>'; |
|
738 | + $form .= '>'._MB_NEWBB_CRITERIA_TIME.'</option>'; |
|
739 | 739 | $form .= "<option value='views'"; |
740 | 740 | if ('views' === $options[0]) { |
741 | 741 | $form .= " selected='selected' "; |
742 | 742 | } |
743 | - $form .= '>' . _MB_NEWBB_CRITERIA_VIEWS . '</option>'; |
|
743 | + $form .= '>'._MB_NEWBB_CRITERIA_VIEWS.'</option>'; |
|
744 | 744 | $form .= "<option value='replies'"; |
745 | 745 | if ('replies' === $options[0]) { |
746 | 746 | $form .= " selected='selected' "; |
747 | 747 | } |
748 | - $form .= '>' . _MB_NEWBB_CRITERIA_REPLIES . '</option>'; |
|
748 | + $form .= '>'._MB_NEWBB_CRITERIA_REPLIES.'</option>'; |
|
749 | 749 | $form .= "<option value='digest'"; |
750 | 750 | if ('digest' === $options[0]) { |
751 | 751 | $form .= " selected='selected' "; |
752 | 752 | } |
753 | - $form .= '>' . _MB_NEWBB_CRITERIA_DIGEST . '</option>'; |
|
753 | + $form .= '>'._MB_NEWBB_CRITERIA_DIGEST.'</option>'; |
|
754 | 754 | $form .= "<option value='sticky'"; |
755 | 755 | if ('sticky' === $options[0]) { |
756 | 756 | $form .= " selected='selected' "; |
757 | 757 | } |
758 | - $form .= '>' . _MB_NEWBB_CRITERIA_STICKY . '</option>'; |
|
758 | + $form .= '>'._MB_NEWBB_CRITERIA_STICKY.'</option>'; |
|
759 | 759 | $form .= '</select>'; |
760 | - $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' />"; |
|
761 | - $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' />"; |
|
762 | - $form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
763 | - $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
760 | + $form .= '<br>'._MB_NEWBB_DISPLAY."<input type='text' name='options[1]' value='".$options[1]."' />"; |
|
761 | + $form .= '<br>'._MB_NEWBB_TIME."<input type='text' name='options[2]' value='".$options[2]."' />"; |
|
762 | + $form .= '<br> <small>'._MB_NEWBB_TIME_DESC.'</small>'; |
|
763 | + $form .= '<br>'._MB_NEWBB_DISPLAYMODE."<input type='radio' name='options[3]' value='0'"; |
|
764 | 764 | if (0 == $options[3]) { |
765 | 765 | $form .= ' checked'; |
766 | 766 | } |
767 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'"; |
|
767 | + $form .= ' /> '._MB_NEWBB_DISPLAYMODE_FULL."<input type='radio' name='options[3]' value='1'"; |
|
768 | 768 | if (1 == $options[3]) { |
769 | 769 | $form .= ' checked'; |
770 | 770 | } |
771 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'"; |
|
771 | + $form .= ' /> '._MB_NEWBB_DISPLAYMODE_COMPACT."<input type='radio' name='options[3]' value='2'"; |
|
772 | 772 | if (2 == $options[3]) { |
773 | 773 | $form .= ' checked'; |
774 | 774 | } |
775 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
775 | + $form .= ' /> '._MB_NEWBB_DISPLAYMODE_LITE; |
|
776 | 776 | |
777 | - $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
777 | + $form .= '<br>'._MB_NEWBB_INDEXNAV.'<input type="radio" name="options[4]" value="1"'; |
|
778 | 778 | if (1 == $options[4]) { |
779 | 779 | $form .= ' checked'; |
780 | 780 | } |
781 | - $form .= ' />' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
781 | + $form .= ' />'._YES.'<input type="radio" name="options[4]" value="0"'; |
|
782 | 782 | if (0 == $options[4]) { |
783 | 783 | $form .= ' checked'; |
784 | 784 | } |
785 | - $form .= ' />' . _NO; |
|
785 | + $form .= ' />'._NO; |
|
786 | 786 | |
787 | - $form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' />"; |
|
787 | + $form .= '<br>'._MB_NEWBB_TITLE_LENGTH."<input type='text' name='options[5]' value='".$options[5]."' />"; |
|
788 | 788 | |
789 | - $form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
789 | + $form .= '<br><br>'._MB_NEWBB_FORUMLIST; |
|
790 | 790 | |
791 | 791 | $optionsForum = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
792 | 792 | |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | if ($isAll) { |
797 | 797 | $form .= ' selected="selected"'; |
798 | 798 | } |
799 | - $form .= '>' . _ALL . '</option>'; |
|
799 | + $form .= '>'._ALL.'</option>'; |
|
800 | 800 | $form .= newbbForumSelectBox($optionsForum); |
801 | 801 | $form .= '</select><br>'; |
802 | 802 | |
@@ -809,49 +809,49 @@ discard block |
||
809 | 809 | */ |
810 | 810 | function b_newbb_post_edit($options) |
811 | 811 | { |
812 | - require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
813 | - $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
812 | + require_once dirname(__DIR__).'/include/functions.forum.php'; |
|
813 | + $form = _MB_NEWBB_CRITERIA."<select name='options[0]'>"; |
|
814 | 814 | $form .= "<option value='title'"; |
815 | 815 | if ('title' === $options[0]) { |
816 | 816 | $form .= " selected='selected' "; |
817 | 817 | } |
818 | - $form .= '>' . _MB_NEWBB_CRITERIA_TITLE . '</option>'; |
|
818 | + $form .= '>'._MB_NEWBB_CRITERIA_TITLE.'</option>'; |
|
819 | 819 | $form .= "<option value='text'"; |
820 | 820 | if ('text' === $options[0]) { |
821 | 821 | $form .= " selected='selected' "; |
822 | 822 | } |
823 | - $form .= '>' . _MB_NEWBB_CRITERIA_TEXT . '</option>'; |
|
823 | + $form .= '>'._MB_NEWBB_CRITERIA_TEXT.'</option>'; |
|
824 | 824 | $form .= '</select>'; |
825 | - $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' />"; |
|
826 | - $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' />"; |
|
827 | - $form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
828 | - $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
825 | + $form .= '<br>'._MB_NEWBB_DISPLAY."<input type='text' name='options[1]' value='".$options[1]."' />"; |
|
826 | + $form .= '<br>'._MB_NEWBB_TIME."<input type='text' name='options[2]' value='".$options[2]."' />"; |
|
827 | + $form .= '<br> <small>'._MB_NEWBB_TIME_DESC.'</small>'; |
|
828 | + $form .= '<br>'._MB_NEWBB_DISPLAYMODE."<input type='radio' name='options[3]' value='0'"; |
|
829 | 829 | if (0 == $options[3]) { |
830 | 830 | $form .= ' checked'; |
831 | 831 | } |
832 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'"; |
|
832 | + $form .= ' /> '._MB_NEWBB_DISPLAYMODE_FULL."<input type='radio' name='options[3]' value='1'"; |
|
833 | 833 | if (1 == $options[3]) { |
834 | 834 | $form .= ' checked'; |
835 | 835 | } |
836 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'"; |
|
836 | + $form .= ' /> '._MB_NEWBB_DISPLAYMODE_COMPACT."<input type='radio' name='options[3]' value='2'"; |
|
837 | 837 | if (2 == $options[3]) { |
838 | 838 | $form .= ' checked'; |
839 | 839 | } |
840 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
840 | + $form .= ' /> '._MB_NEWBB_DISPLAYMODE_LITE; |
|
841 | 841 | |
842 | - $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
842 | + $form .= '<br>'._MB_NEWBB_INDEXNAV.'<input type="radio" name="options[4]" value="1"'; |
|
843 | 843 | if (1 == $options[4]) { |
844 | 844 | $form .= ' checked'; |
845 | 845 | } |
846 | - $form .= ' />' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
846 | + $form .= ' />'._YES.'<input type="radio" name="options[4]" value="0"'; |
|
847 | 847 | if (0 == $options[4]) { |
848 | 848 | $form .= ' checked'; |
849 | 849 | } |
850 | - $form .= ' />' . _NO; |
|
850 | + $form .= ' />'._NO; |
|
851 | 851 | |
852 | - $form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' />"; |
|
852 | + $form .= '<br>'._MB_NEWBB_TITLE_LENGTH."<input type='text' name='options[5]' value='".$options[5]."' />"; |
|
853 | 853 | |
854 | - $form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
854 | + $form .= '<br><br>'._MB_NEWBB_FORUMLIST; |
|
855 | 855 | |
856 | 856 | $optionsForum = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums |
857 | 857 | $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | if ($isAll) { |
861 | 861 | $form .= ' selected="selected"'; |
862 | 862 | } |
863 | - $form .= '>' . _ALL . '</option>'; |
|
863 | + $form .= '>'._ALL.'</option>'; |
|
864 | 864 | $form .= newbbForumSelectBox($optionsForum); |
865 | 865 | $form .= '</select><br>'; |
866 | 866 | |
@@ -873,53 +873,53 @@ discard block |
||
873 | 873 | */ |
874 | 874 | function b_newbb_author_edit($options) |
875 | 875 | { |
876 | - require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
877 | - $form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
876 | + require_once dirname(__DIR__).'/include/functions.forum.php'; |
|
877 | + $form = _MB_NEWBB_CRITERIA."<select name='options[0]'>"; |
|
878 | 878 | $form .= "<option value='post'"; |
879 | 879 | if ('post' === $options[0]) { |
880 | 880 | $form .= " selected='selected' "; |
881 | 881 | } |
882 | - $form .= '>' . _MB_NEWBB_CRITERIA_POST . '</option>'; |
|
882 | + $form .= '>'._MB_NEWBB_CRITERIA_POST.'</option>'; |
|
883 | 883 | $form .= "<option value='topic'"; |
884 | 884 | if ('topic' === $options[0]) { |
885 | 885 | $form .= " selected='selected' "; |
886 | 886 | } |
887 | - $form .= '>' . _MB_NEWBB_CRITERIA_TOPIC . '</option>'; |
|
887 | + $form .= '>'._MB_NEWBB_CRITERIA_TOPIC.'</option>'; |
|
888 | 888 | $form .= "<option value='digest'"; |
889 | 889 | if ('digest' === $options[0]) { |
890 | 890 | $form .= " selected='selected' "; |
891 | 891 | } |
892 | - $form .= '>' . _MB_NEWBB_CRITERIA_DIGESTS . '</option>'; |
|
892 | + $form .= '>'._MB_NEWBB_CRITERIA_DIGESTS.'</option>'; |
|
893 | 893 | $form .= "<option value='sticky'"; |
894 | 894 | if ('sticky' === $options[0]) { |
895 | 895 | $form .= " selected='selected' "; |
896 | 896 | } |
897 | - $form .= '>' . _MB_NEWBB_CRITERIA_STICKYS . '</option>'; |
|
897 | + $form .= '>'._MB_NEWBB_CRITERIA_STICKYS.'</option>'; |
|
898 | 898 | $form .= '</select>'; |
899 | - $form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' />"; |
|
900 | - $form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' />"; |
|
901 | - $form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
902 | - $form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
899 | + $form .= '<br>'._MB_NEWBB_DISPLAY."<input type='text' name='options[1]' value='".$options[1]."' />"; |
|
900 | + $form .= '<br>'._MB_NEWBB_TIME."<input type='text' name='options[2]' value='".$options[2]."' />"; |
|
901 | + $form .= '<br> <small>'._MB_NEWBB_TIME_DESC.'</small>'; |
|
902 | + $form .= '<br>'._MB_NEWBB_DISPLAYMODE."<input type='radio' name='options[3]' value='0'"; |
|
903 | 903 | if (0 == $options[3]) { |
904 | 904 | $form .= ' checked'; |
905 | 905 | } |
906 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='1'"; |
|
906 | + $form .= ' /> '._MB_NEWBB_DISPLAYMODE_COMPACT."<input type='radio' name='options[3]' value='1'"; |
|
907 | 907 | if (1 == $options[3]) { |
908 | 908 | $form .= ' checked'; |
909 | 909 | } |
910 | - $form .= ' /> ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
910 | + $form .= ' /> '._MB_NEWBB_DISPLAYMODE_LITE; |
|
911 | 911 | |
912 | - $form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
912 | + $form .= '<br>'._MB_NEWBB_INDEXNAV.'<input type="radio" name="options[4]" value="1"'; |
|
913 | 913 | if (1 == $options[4]) { |
914 | 914 | $form .= ' checked'; |
915 | 915 | } |
916 | - $form .= ' />' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
916 | + $form .= ' />'._YES.'<input type="radio" name="options[4]" value="0"'; |
|
917 | 917 | if (0 == $options[4]) { |
918 | 918 | $form .= ' checked'; |
919 | 919 | } |
920 | - $form .= ' />' . _NO; |
|
920 | + $form .= ' />'._NO; |
|
921 | 921 | |
922 | - $form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
922 | + $form .= '<br><br>'._MB_NEWBB_FORUMLIST; |
|
923 | 923 | |
924 | 924 | $optionsForum = array_filter(array_slice($options, 5), 'b_newbb_array_filter'); // get allowed forums |
925 | 925 | $isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | if ($isAll) { |
929 | 929 | $form .= ' selected="selected"'; |
930 | 930 | } |
931 | - $form .= '>' . _ALL . '</option>'; |
|
931 | + $form .= '>'._ALL.'</option>'; |
|
932 | 932 | $form .= newbbForumSelectBox($optionsForum); |
933 | 933 | $form .= '</select><br>'; |
934 | 934 | |
@@ -942,8 +942,8 @@ discard block |
||
942 | 942 | function b_newbb_custom($options) |
943 | 943 | { |
944 | 944 | // if no newbb module block set, we have to include the language file |
945 | - if (is_readable($GLOBALS['xoops']->path('modules/newbb/language/' . $GLOBALS['xoopsConfig']['language'] . '/blocks.php'))) { |
|
946 | - require_once $GLOBALS['xoops']->path('modules/newbb/language/' . $GLOBALS['xoopsConfig']['language'] . '/blocks.php'); |
|
945 | + if (is_readable($GLOBALS['xoops']->path('modules/newbb/language/'.$GLOBALS['xoopsConfig']['language'].'/blocks.php'))) { |
|
946 | + require_once $GLOBALS['xoops']->path('modules/newbb/language/'.$GLOBALS['xoopsConfig']['language'].'/blocks.php'); |
|
947 | 947 | } else { |
948 | 948 | require_once $GLOBALS['xoops']->path('modules/newbb/language/english/blocks.php'); |
949 | 949 | } |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function newbb_tag_block_cloud_show($options) |
22 | 22 | { |
23 | - if (!@require_once $GLOBALS['xoops']->path('modules/tag/blocks/block.php')) { |
|
24 | - return null; |
|
25 | - } |
|
26 | - $block_content = tag_block_cloud_show($options, 'newbb'); |
|
23 | + if (!@require_once $GLOBALS['xoops']->path('modules/tag/blocks/block.php')) { |
|
24 | + return null; |
|
25 | + } |
|
26 | + $block_content = tag_block_cloud_show($options, 'newbb'); |
|
27 | 27 | |
28 | - return $block_content; |
|
28 | + return $block_content; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function newbb_tag_block_cloud_edit($options) |
36 | 36 | { |
37 | - if (!@require_once $GLOBALS['xoops']->path('modules/tag/blocks/block.php')) { |
|
38 | - return null; |
|
39 | - } |
|
40 | - $form = tag_block_cloud_edit($options); |
|
37 | + if (!@require_once $GLOBALS['xoops']->path('modules/tag/blocks/block.php')) { |
|
38 | + return null; |
|
39 | + } |
|
40 | + $form = tag_block_cloud_edit($options); |
|
41 | 41 | |
42 | - return $form; |
|
42 | + return $form; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /**#@+ |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function newbb_tag_block_top_show($options) |
51 | 51 | { |
52 | - if (!@require_once $GLOBALS['xoops']->path('modules/tag/blocks/block.php')) { |
|
53 | - return null; |
|
54 | - } |
|
55 | - $block_content = tag_block_top_show($options, 'newbb'); |
|
52 | + if (!@require_once $GLOBALS['xoops']->path('modules/tag/blocks/block.php')) { |
|
53 | + return null; |
|
54 | + } |
|
55 | + $block_content = tag_block_top_show($options, 'newbb'); |
|
56 | 56 | |
57 | - return $block_content; |
|
57 | + return $block_content; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | */ |
64 | 64 | function newbb_tag_block_top_edit($options) |
65 | 65 | { |
66 | - if (!@require_once $GLOBALS['xoops']->path('modules/tag/blocks/block.php')) { |
|
67 | - return null; |
|
68 | - } |
|
69 | - $form = tag_block_top_edit($options); |
|
66 | + if (!@require_once $GLOBALS['xoops']->path('modules/tag/blocks/block.php')) { |
|
67 | + return null; |
|
68 | + } |
|
69 | + $form = tag_block_top_edit($options); |
|
70 | 70 | |
71 | - return $form; |
|
71 | + return $form; |
|
72 | 72 | } |
@@ -35,22 +35,22 @@ discard block |
||
35 | 35 | |
36 | 36 | $GPC = '_GET'; |
37 | 37 | if (Request::getString('submit', '', 'POST')) { |
38 | - $GPC = '_POST'; |
|
38 | + $GPC = '_POST'; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | foreach (['post_id', 'order', 'forum', 'topic_id'] as $getint) { |
42 | - ${$getint} = (int)(@${$GPC}[$getint]); |
|
42 | + ${$getint} = (int)(@${$GPC}[$getint]); |
|
43 | 43 | } |
44 | 44 | $viewmode = (isset(${$GPC}['viewmode']) && 'flat' !== ${$GPC}['viewmode']) ? 'thread' : 'flat'; |
45 | 45 | |
46 | 46 | if (empty($post_id)) { |
47 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_ERRORPOST); |
|
47 | + redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_ERRORPOST); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
51 | - // /** @var Newbb\OnlineHandler $onlineHandler */ |
|
52 | - // $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
53 | - $onlineHandler->init($forum); |
|
51 | + // /** @var Newbb\OnlineHandler $onlineHandler */ |
|
52 | + // $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
53 | + $onlineHandler->init($forum); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | $myts = \MyTextSanitizer::getInstance(); |
@@ -60,68 +60,68 @@ discard block |
||
60 | 60 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
61 | 61 | |
62 | 62 | if (Request::hasVar('submit', 'POST')) { |
63 | - $error_message = ''; |
|
64 | - if (!is_object($GLOBALS['xoopsUser'])) { |
|
65 | - xoops_load('xoopscaptcha'); |
|
66 | - $xoopsCaptcha = \XoopsCaptcha::getInstance(); |
|
67 | - if (!$xoopsCaptcha->verify()) { |
|
68 | - $captcha_invalid = true; |
|
69 | - $error_message = $xoopsCaptcha->getMessage(); |
|
70 | - } |
|
71 | - } |
|
72 | - if ('' !== $error_message) { |
|
73 | - xoops_error($error_message); |
|
74 | - } else { |
|
75 | - // $reportHandler = Newbb\Helper::getInstance()->getHandler('Report'); |
|
76 | - $report = $reportHandler->create(); |
|
77 | - $report->setVar('report_text', Request::getString('report_text', '', 'POST')); |
|
78 | - $report->setVar('post_id', Request::getInt('post_id', 0, 'POST')); |
|
79 | - $report->setVar('report_time', time()); |
|
80 | - $report->setVar('reporter_uid', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0); |
|
81 | - $report->setVar('reporter_ip', \Xmf\IPAddress::fromRequest()->asReadable()); |
|
82 | - $report->setVar('report_result', 0); |
|
83 | - $report->setVar('report_memo', ''); |
|
84 | - |
|
85 | - if ($report_id = $reportHandler->insert($report)) { |
|
86 | - // $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
87 | - if (empty($forum)) { |
|
88 | - } |
|
89 | - $forumObject = $forumHandler->get($forum); |
|
90 | - |
|
91 | - if (is_object($forumObject)) { |
|
92 | - $mods = $forumObject->getVar('forum_moderator'); |
|
93 | - $emails = []; |
|
94 | - /** @var \XoopsMemberHandler $memberHandler */ |
|
95 | - $memberHandler = xoops_getHandler('member'); |
|
96 | - foreach ($mods as $mod) { |
|
97 | - $thisUser = $memberHandler->getUser($mod); |
|
98 | - if (is_object($thisUser)) { |
|
99 | - $emails[] = $thisUser->getVar('email'); |
|
100 | - unset($thisUser); |
|
101 | - } |
|
102 | - } |
|
103 | - $xoopsMailer = xoops_getMailer(); |
|
104 | - $xoopsMailer->reset(); |
|
105 | - $xoopsMailer->setTemplateDir(); |
|
106 | - $xoopsMailer->useMail(); |
|
107 | - $xoopsMailer->setTemplate('forum_report.tpl'); |
|
108 | - $xoopsMailer->setToEmails($emails); |
|
109 | - $xoopsMailer->assign('MESSAGE', Request::getString('report_text', '', 'POST')); |
|
110 | - $xoopsMailer->setSubject(_MD_NEWBB_REPORTSUBJECT); |
|
111 | - $xoopsMailer->send(); |
|
112 | - } |
|
113 | - $message = _MD_NEWBB_REPORTED; |
|
114 | - } else { |
|
115 | - $message = _MD_NEWBB_REPORT_ERROR; |
|
116 | - } |
|
117 | - redirect_header("viewtopic.php?forum=$forum&topic_id=$topic_id&post_id=$post_id&order=$order&viewmode=$viewmode", 2, $message); |
|
118 | - } |
|
63 | + $error_message = ''; |
|
64 | + if (!is_object($GLOBALS['xoopsUser'])) { |
|
65 | + xoops_load('xoopscaptcha'); |
|
66 | + $xoopsCaptcha = \XoopsCaptcha::getInstance(); |
|
67 | + if (!$xoopsCaptcha->verify()) { |
|
68 | + $captcha_invalid = true; |
|
69 | + $error_message = $xoopsCaptcha->getMessage(); |
|
70 | + } |
|
71 | + } |
|
72 | + if ('' !== $error_message) { |
|
73 | + xoops_error($error_message); |
|
74 | + } else { |
|
75 | + // $reportHandler = Newbb\Helper::getInstance()->getHandler('Report'); |
|
76 | + $report = $reportHandler->create(); |
|
77 | + $report->setVar('report_text', Request::getString('report_text', '', 'POST')); |
|
78 | + $report->setVar('post_id', Request::getInt('post_id', 0, 'POST')); |
|
79 | + $report->setVar('report_time', time()); |
|
80 | + $report->setVar('reporter_uid', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0); |
|
81 | + $report->setVar('reporter_ip', \Xmf\IPAddress::fromRequest()->asReadable()); |
|
82 | + $report->setVar('report_result', 0); |
|
83 | + $report->setVar('report_memo', ''); |
|
84 | + |
|
85 | + if ($report_id = $reportHandler->insert($report)) { |
|
86 | + // $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
87 | + if (empty($forum)) { |
|
88 | + } |
|
89 | + $forumObject = $forumHandler->get($forum); |
|
90 | + |
|
91 | + if (is_object($forumObject)) { |
|
92 | + $mods = $forumObject->getVar('forum_moderator'); |
|
93 | + $emails = []; |
|
94 | + /** @var \XoopsMemberHandler $memberHandler */ |
|
95 | + $memberHandler = xoops_getHandler('member'); |
|
96 | + foreach ($mods as $mod) { |
|
97 | + $thisUser = $memberHandler->getUser($mod); |
|
98 | + if (is_object($thisUser)) { |
|
99 | + $emails[] = $thisUser->getVar('email'); |
|
100 | + unset($thisUser); |
|
101 | + } |
|
102 | + } |
|
103 | + $xoopsMailer = xoops_getMailer(); |
|
104 | + $xoopsMailer->reset(); |
|
105 | + $xoopsMailer->setTemplateDir(); |
|
106 | + $xoopsMailer->useMail(); |
|
107 | + $xoopsMailer->setTemplate('forum_report.tpl'); |
|
108 | + $xoopsMailer->setToEmails($emails); |
|
109 | + $xoopsMailer->assign('MESSAGE', Request::getString('report_text', '', 'POST')); |
|
110 | + $xoopsMailer->setSubject(_MD_NEWBB_REPORTSUBJECT); |
|
111 | + $xoopsMailer->send(); |
|
112 | + } |
|
113 | + $message = _MD_NEWBB_REPORTED; |
|
114 | + } else { |
|
115 | + $message = _MD_NEWBB_REPORT_ERROR; |
|
116 | + } |
|
117 | + redirect_header("viewtopic.php?forum=$forum&topic_id=$topic_id&post_id=$post_id&order=$order&viewmode=$viewmode", 2, $message); |
|
118 | + } |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $report_form = new \XoopsThemeForm('', 'reportform', 'report.php'); |
122 | 122 | $report_form->addElement(new \XoopsFormText(_MD_NEWBB_REPORT_TEXT, 'report_text', 80, 255, Request::getString('report_text', '', 'POST')), true); |
123 | 123 | if (!is_object($GLOBALS['xoopsUser'])) { |
124 | - $report_form->addElement(new \XoopsFormCaptcha()); |
|
124 | + $report_form->addElement(new \XoopsFormCaptcha()); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | //$postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
@@ -147,19 +147,19 @@ discard block |
||
147 | 147 | |
148 | 148 | $r_subject = $postObject->getVar('subject', 'E'); |
149 | 149 | if ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $postObject->getVar('post_karma') > 0) { |
150 | - $r_message = sprintf(_MD_NEWBB_KARMA_REQUIREMENT, '***', $postObject->getVar('post_karma')) . '</div>'; |
|
150 | + $r_message = sprintf(_MD_NEWBB_KARMA_REQUIREMENT, '***', $postObject->getVar('post_karma')) . '</div>'; |
|
151 | 151 | } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $postObject->getVar('require_reply')) { |
152 | - $r_message = _MD_NEWBB_REPLY_REQUIREMENT; |
|
152 | + $r_message = _MD_NEWBB_REPLY_REQUIREMENT; |
|
153 | 153 | } else { |
154 | - $r_message = $postObject->getVar('post_text'); |
|
154 | + $r_message = $postObject->getVar('post_text'); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | $r_date = formatTimestamp($postObject->getVar('post_time')); |
158 | 158 | if ($postObject->getVar('uid')) { |
159 | - $r_name = newbbGetUnameFromId($postObject->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']); |
|
159 | + $r_name = newbbGetUnameFromId($postObject->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']); |
|
160 | 160 | } else { |
161 | - $poster_name = $postObject->getVar('poster_name'); |
|
162 | - $r_name = empty($poster_name) ? $GLOBALS['xoopsConfig']['anonymous'] : $myts->htmlSpecialChars($poster_name); |
|
161 | + $poster_name = $postObject->getVar('poster_name'); |
|
162 | + $r_name = empty($poster_name) ? $GLOBALS['xoopsConfig']['anonymous'] : $myts->htmlSpecialChars($poster_name); |
|
163 | 163 | } |
164 | 164 | $r_content = _MD_NEWBB_SUBJECTC . ' ' . $r_subject . '<br>'; |
165 | 165 | $r_content .= _MD_NEWBB_BY . ' ' . $r_name . ' ' . _MD_NEWBB_ON . ' ' . $r_date . '<br><br>'; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | use Xmf\Request; |
33 | 33 | |
34 | -require_once __DIR__ . '/header.php'; |
|
34 | +require_once __DIR__.'/header.php'; |
|
35 | 35 | |
36 | 36 | $GPC = '_GET'; |
37 | 37 | if (Request::getString('submit', '', 'POST')) { |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | foreach (['post_id', 'order', 'forum', 'topic_id'] as $getint) { |
42 | - ${$getint} = (int)(@${$GPC}[$getint]); |
|
42 | + ${$getint} = (int) (@${$GPC}[$getint]); |
|
43 | 43 | } |
44 | 44 | $viewmode = (isset(${$GPC}['viewmode']) && 'flat' !== ${$GPC}['viewmode']) ? 'thread' : 'flat'; |
45 | 45 | |
46 | 46 | if (empty($post_id)) { |
47 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_ERRORPOST); |
|
47 | + redirect_header(XOOPS_URL.'/index.php', 2, _MD_NEWBB_ERRORPOST); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $submit_button = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
140 | 140 | $cancel_button = new \XoopsFormButton('', 'cancel', _MD_NEWBB_CANCELPOST, 'button'); |
141 | 141 | $extra = "viewtopic.php?forum=$forum&topic_id=$topic_id&post_id=$post_id&order=$order&viewmode=$viewmode"; |
142 | -$cancel_button->setExtra("onclick='location=\"" . $extra . "\"'"); |
|
142 | +$cancel_button->setExtra("onclick='location=\"".$extra."\"'"); |
|
143 | 143 | $button_tray->addElement($submit_button); |
144 | 144 | $button_tray->addElement($cancel_button); |
145 | 145 | $report_form->addElement($button_tray); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | $r_subject = $postObject->getVar('subject', 'E'); |
149 | 149 | if ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $postObject->getVar('post_karma') > 0) { |
150 | - $r_message = sprintf(_MD_NEWBB_KARMA_REQUIREMENT, '***', $postObject->getVar('post_karma')) . '</div>'; |
|
150 | + $r_message = sprintf(_MD_NEWBB_KARMA_REQUIREMENT, '***', $postObject->getVar('post_karma')).'</div>'; |
|
151 | 151 | } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $postObject->getVar('require_reply')) { |
152 | 152 | $r_message = _MD_NEWBB_REPLY_REQUIREMENT; |
153 | 153 | } else { |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | $poster_name = $postObject->getVar('poster_name'); |
162 | 162 | $r_name = empty($poster_name) ? $GLOBALS['xoopsConfig']['anonymous'] : $myts->htmlSpecialChars($poster_name); |
163 | 163 | } |
164 | -$r_content = _MD_NEWBB_SUBJECTC . ' ' . $r_subject . '<br>'; |
|
165 | -$r_content .= _MD_NEWBB_BY . ' ' . $r_name . ' ' . _MD_NEWBB_ON . ' ' . $r_date . '<br><br>'; |
|
164 | +$r_content = _MD_NEWBB_SUBJECTC.' '.$r_subject.'<br>'; |
|
165 | +$r_content .= _MD_NEWBB_BY.' '.$r_name.' '._MD_NEWBB_ON.' '.$r_date.'<br><br>'; |
|
166 | 166 | $r_content .= $r_message; |
167 | 167 | |
168 | -echo "<br><table cellpadding='4' cellspacing='1' width='98%' class='outer'><tr><td class='head'>" . $r_subject . '</td></tr>'; |
|
169 | -echo '<tr><td><br>' . $r_content . '<br></td></tr></table>'; |
|
168 | +echo "<br><table cellpadding='4' cellspacing='1' width='98%' class='outer'><tr><td class='head'>".$r_subject.'</td></tr>'; |
|
169 | +echo '<tr><td><br>'.$r_content.'<br></td></tr></table>'; |
|
170 | 170 | |
171 | 171 | require_once $GLOBALS['xoops']->path('footer.php'); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | require_once $GLOBALS['xoops']->path('header.php'); |
21 | 21 | // irmtfan new method |
22 | 22 | if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) { |
23 | - $xoopsTpl->assign('xoops_module_header', ' |
|
23 | + $xoopsTpl->assign('xoops_module_header', ' |
|
24 | 24 | <link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/rss.php" /> |
25 | 25 | ' . @$xoopsTpl->get_template_vars('xoops_module_header')); |
26 | 26 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $topic_renderer->userlevel = $GLOBALS['xoopsUserIsAdmin'] ? 2 : is_object($GLOBALS['xoopsUser']); |
36 | 36 | // irmtfan if list topic block is in the page then force to parse |
37 | 37 | if (defined('LIST_TOPIC_DEFINED')) { |
38 | - $topic_renderer->force = true; // force against static vars |
|
38 | + $topic_renderer->force = true; // force against static vars |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $topic_renderer->is_multiple = true; |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | //$isAdmin = $GLOBALS["xoopsUserIsAdmin"]; |
53 | 53 | /* Only admin has access to admin mode */ |
54 | 54 | if ($topic_renderer->userlevel < 2) { // irmtfan use userlevel |
55 | - $mode = 0; |
|
55 | + $mode = 0; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
59 | - // /** @var Newbb\OnlineHandler $onlineHandler */ |
|
60 | - // $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
61 | - $onlineHandler->init(); |
|
62 | - $onlineHandler->render($xoopsTpl); |
|
59 | + // /** @var Newbb\OnlineHandler $onlineHandler */ |
|
60 | + // $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
61 | + $onlineHandler->init(); |
|
62 | + $onlineHandler->render($xoopsTpl); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | $topic_renderer->buildHeaders($xoopsTpl); |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | $xoopsTpl->assign('newpost_link', 'viewpost.php?status=new'); |
88 | 88 | |
89 | 89 | if (!empty($GLOBALS['xoopsModuleConfig']['show_jump'])) { |
90 | - require_once __DIR__ . '/include/functions.forum.php'; |
|
91 | - $xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox()); |
|
90 | + require_once __DIR__ . '/include/functions.forum.php'; |
|
91 | + $xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox()); |
|
92 | 92 | } |
93 | 93 | $xoopsTpl->assign('menumode', $menumode); |
94 | 94 | $xoopsTpl->assign('menumode_other', $menumode_other); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | use Xmf\Request; |
13 | 13 | use XoopsModules\Newbb; |
14 | 14 | |
15 | -require_once __DIR__ . '/header.php'; |
|
15 | +require_once __DIR__.'/header.php'; |
|
16 | 16 | |
17 | 17 | //$xoopsOption['xoops_module_header']= $xoops_module_header; |
18 | 18 | $GLOBALS['xoopsOption']['template_main'] = 'newbb_viewall.tpl'; |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | // irmtfan new method |
22 | 22 | if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) { |
23 | 23 | $xoopsTpl->assign('xoops_module_header', ' |
24 | - <link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/rss.php" /> |
|
24 | + <link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name').'" href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/rss.php" /> |
|
25 | 25 | ' . @$xoopsTpl->get_template_vars('xoops_module_header')); |
26 | 26 | } |
27 | 27 | //$xoopsTpl->assign('xoops_module_header', $xoops_module_header); |
28 | 28 | |
29 | -require_once __DIR__ . '/include/functions.time.php'; |
|
30 | -require_once __DIR__ . '/include/functions.render.php'; |
|
29 | +require_once __DIR__.'/include/functions.time.php'; |
|
30 | +require_once __DIR__.'/include/functions.render.php'; |
|
31 | 31 | |
32 | 32 | // irmtfan use require_once because it will redeclared in newbb/blocks/list_topic.php |
33 | 33 | //require_once __DIR__ . '/./class/TopicRenderer.php'; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $xoopsTpl->assign('newpost_link', 'viewpost.php?status=new'); |
88 | 88 | |
89 | 89 | if (!empty($GLOBALS['xoopsModuleConfig']['show_jump'])) { |
90 | - require_once __DIR__ . '/include/functions.forum.php'; |
|
90 | + require_once __DIR__.'/include/functions.forum.php'; |
|
91 | 91 | $xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox()); |
92 | 92 | } |
93 | 93 | $xoopsTpl->assign('menumode', $menumode); |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | |
96 | 96 | $xoopsTpl->assign('mode', $mode); |
97 | 97 | $xoopsTpl->assign('status', $status); |
98 | -$xoopsTpl->assign('viewer_level', $topic_renderer->userlevel);// irmtfan use userlevel |
|
98 | +$xoopsTpl->assign('viewer_level', $topic_renderer->userlevel); // irmtfan use userlevel |
|
99 | 99 | |
100 | 100 | $pagetitle = sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)); |
101 | 101 | $xoopsTpl->assign('forum_index_title', $pagetitle); |
102 | 102 | $xoopsTpl->assign('xoops_pagetitle', $pagetitle); |
103 | 103 | |
104 | 104 | // irmtfan move to footer.php |
105 | -require_once __DIR__ . '/footer.php'; |
|
105 | +require_once __DIR__.'/footer.php'; |
|
106 | 106 | require_once $GLOBALS['xoops']->path('footer.php'); |