@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | // irmtfan add LAST_INSERT_ID to enhance the mysql performances |
54 | 54 | public function incrementCounter() |
55 | 55 | { |
56 | - $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' SET topic_views = LAST_INSERT_ID(topic_views + 1) WHERE topic_id =' . $this->getVar('topic_id'); |
|
56 | + $sql = 'UPDATE '.$GLOBALS['xoopsDB']->prefix('newbb_topics').' SET topic_views = LAST_INSERT_ID(topic_views + 1) WHERE topic_id ='.$this->getVar('topic_id'); |
|
57 | 57 | $GLOBALS['xoopsDB']->queryF($sql); |
58 | 58 | } |
59 | 59 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | return $topic_title; |
75 | 75 | } |
76 | 76 | |
77 | - require_once __DIR__ . '/../include/functions.topic.php'; |
|
77 | + require_once __DIR__.'/../include/functions.topic.php'; |
|
78 | 78 | |
79 | 79 | return getTopicTitle($topic_title, $typeObject->getVar('type_name'), $typeObject->getVar('type_color')); |
80 | 80 | } |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | /** @var \XoopsPoll $poll */ |
155 | 155 | $poll = new $classPoll($poll_id); |
156 | 156 | if (false !== $poll->delete()) { |
157 | - $classOption = $classPoll . 'Option'; |
|
157 | + $classOption = $classPoll.'Option'; |
|
158 | 158 | $classOption::deleteByPollId($poll->getVar('poll_id')); |
159 | - $classLog = $classPoll . 'Log'; |
|
159 | + $classLog = $classPoll.'Log'; |
|
160 | 160 | $classLog::deleteByPollId($poll->getVar('poll_id')); |
161 | 161 | xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll->getVar('poll_id')); |
162 | 162 | } |
@@ -252,18 +252,18 @@ |
||
252 | 252 | $xoopsOnlineTable = $xoops_onlineHandler->table; |
253 | 253 | |
254 | 254 | $sql = 'DELETE FROM ' |
255 | - . $this->db->prefix('newbb_online') |
|
256 | - . ' WHERE' |
|
257 | - . ' ( online_uid > 0 AND online_uid NOT IN ( SELECT online_uid FROM ' |
|
258 | - . $xoopsOnlineTable |
|
259 | - . ' WHERE online_module =' |
|
260 | - . $xoopsModule->getVar('mid') |
|
261 | - . ' ) )' |
|
262 | - . ' OR ( online_uid = 0 AND online_ip NOT IN ( SELECT online_ip FROM ' |
|
263 | - . $xoopsOnlineTable |
|
264 | - . ' WHERE online_module =' |
|
265 | - . $xoopsModule->getVar('mid') |
|
266 | - . ' AND online_uid = 0 ) )'; |
|
255 | + . $this->db->prefix('newbb_online') |
|
256 | + . ' WHERE' |
|
257 | + . ' ( online_uid > 0 AND online_uid NOT IN ( SELECT online_uid FROM ' |
|
258 | + . $xoopsOnlineTable |
|
259 | + . ' WHERE online_module =' |
|
260 | + . $xoopsModule->getVar('mid') |
|
261 | + . ' ) )' |
|
262 | + . ' OR ( online_uid = 0 AND online_ip NOT IN ( SELECT online_ip FROM ' |
|
263 | + . $xoopsOnlineTable |
|
264 | + . ' WHERE online_module =' |
|
265 | + . $xoopsModule->getVar('mid') |
|
266 | + . ' AND online_uid = 0 ) )'; |
|
267 | 267 | |
268 | 268 | if ($result = $this->db->queryF($sql)) { |
269 | 269 | return true; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
17 | 17 | |
18 | -require_once __DIR__ . '/../include/functions.config.php'; |
|
18 | +require_once __DIR__.'/../include/functions.config.php'; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Class OnlineHandler |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function render(\Smarty $xoopsTpl) |
98 | 98 | { |
99 | - require_once __DIR__ . '/../include/functions.render.php'; |
|
100 | - require_once __DIR__ . '/../include/functions.user.php'; |
|
99 | + require_once __DIR__.'/../include/functions.render.php'; |
|
100 | + require_once __DIR__.'/../include/functions.user.php'; |
|
101 | 101 | $criteria = null; |
102 | 102 | if ($this->topic_id) { |
103 | 103 | $criteria = new \Criteria('online_topic', $this->topic_id); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } |
117 | 117 | $users_id[] = $users[$i]['online_uid']; |
118 | 118 | $users_online[$users[$i]['online_uid']] = [ |
119 | - 'link' => XOOPS_URL . '/userinfo.php?uid=' . $users[$i]['online_uid'], |
|
119 | + 'link' => XOOPS_URL.'/userinfo.php?uid='.$users[$i]['online_uid'], |
|
120 | 120 | 'uname' => $users[$i]['online_uname'] |
121 | 121 | ]; |
122 | 122 | ++$num_user; |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function showOnline() |
157 | 157 | { |
158 | - require_once __DIR__ . '/../include/functions.render.php'; |
|
159 | - require_once __DIR__ . '/../include/functions.user.php'; |
|
158 | + require_once __DIR__.'/../include/functions.render.php'; |
|
159 | + require_once __DIR__.'/../include/functions.user.php'; |
|
160 | 160 | $criteria = null; |
161 | 161 | if ($this->topic_id) { |
162 | 162 | $criteria = new \Criteria('online_topic', $this->topic_id); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | $users_id[] = $users[$i]['online_uid']; |
177 | 177 | $users_online[$users[$i]['online_uid']] = [ |
178 | - 'link' => XOOPS_URL . '/userinfo.php?uid=' . $users[$i]['online_uid'], |
|
178 | + 'link' => XOOPS_URL.'/userinfo.php?uid='.$users[$i]['online_uid'], |
|
179 | 179 | 'uname' => $users[$i]['online_uname'] |
180 | 180 | ]; |
181 | 181 | ++$num_user; |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | |
230 | 230 | $uid = (int)$uid; |
231 | 231 | if ($uid > 0) { |
232 | - $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_uid=' . $uid; |
|
232 | + $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('newbb_online').' WHERE online_uid='.$uid; |
|
233 | 233 | } else { |
234 | - $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_uid=' . $uid . " AND online_ip='" . $ip . "'"; |
|
234 | + $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('newbb_online').' WHERE online_uid='.$uid." AND online_ip='".$ip."'"; |
|
235 | 235 | } |
236 | 236 | list($count) = $this->db->fetchRow($this->db->queryF($sql)); |
237 | 237 | if ($count > 0) { |
238 | - $sql = 'UPDATE ' . $this->db->prefix('newbb_online') . " SET online_updated= '" . $time . "', online_forum = '" . $forum_id . "', online_topic = '" . $topic_id . "' WHERE online_uid = " . $uid; |
|
238 | + $sql = 'UPDATE '.$this->db->prefix('newbb_online')." SET online_updated= '".$time."', online_forum = '".$forum_id."', online_topic = '".$topic_id."' WHERE online_uid = ".$uid; |
|
239 | 239 | if (0 == $uid) { |
240 | - $sql .= " AND online_ip='" . $ip . "'"; |
|
240 | + $sql .= " AND online_ip='".$ip."'"; |
|
241 | 241 | } |
242 | 242 | } else { |
243 | 243 | $sql = sprintf('INSERT INTO `%s` (online_uid, online_uname, online_updated, online_ip, online_forum, online_topic) VALUES (%u, %s, %u, %s, %u, %u)', $this->db->prefix('newbb_online'), $uid, $this->db->quote($uname), $time, $this->db->quote($ip), $forum_id, $topic_id); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | public function gc($expire) |
284 | 284 | { |
285 | 285 | global $xoopsModule; |
286 | - $sql = 'DELETE FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_updated < ' . (time() - (int)$expire); |
|
286 | + $sql = 'DELETE FROM '.$this->db->prefix('newbb_online').' WHERE online_updated < '.(time() - (int)$expire); |
|
287 | 287 | $this->db->queryF($sql); |
288 | 288 | |
289 | 289 | $xoops_onlineHandler = xoops_getHandler('online'); |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | { |
301 | 301 | $ret = []; |
302 | 302 | $limit = $start = 0; |
303 | - $sql = 'SELECT * FROM ' . $this->db->prefix('newbb_online'); |
|
303 | + $sql = 'SELECT * FROM '.$this->db->prefix('newbb_online'); |
|
304 | 304 | if (is_object($criteria) && is_subclass_of($criteria, 'CriteriaElement')) { |
305 | - $sql .= ' ' . $criteria->renderWhere(); |
|
305 | + $sql .= ' '.$criteria->renderWhere(); |
|
306 | 306 | $limit = $criteria->getLimit(); |
307 | 307 | $start = $criteria->getStart(); |
308 | 308 | } |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | if (!empty($this->user_ids)) { |
334 | 334 | $online_users = $this->user_ids; |
335 | 335 | } else { |
336 | - $sql = 'SELECT online_uid FROM ' . $this->db->prefix('newbb_online'); |
|
336 | + $sql = 'SELECT online_uid FROM '.$this->db->prefix('newbb_online'); |
|
337 | 337 | if (!empty($uids)) { |
338 | - $sql .= ' WHERE online_uid IN (' . implode(', ', array_map('intval', $uids)) . ')'; |
|
338 | + $sql .= ' WHERE online_uid IN ('.implode(', ', array_map('intval', $uids)).')'; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | $result = $this->db->query($sql); |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | */ |
364 | 364 | public function getCount(\CriteriaElement $criteria = null) |
365 | 365 | { |
366 | - $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online'); |
|
366 | + $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('newbb_online'); |
|
367 | 367 | if (is_object($criteria) && is_subclass_of($criteria, 'CriteriaElement')) { |
368 | - $sql .= ' ' . $criteria->renderWhere(); |
|
368 | + $sql .= ' '.$criteria->renderWhere(); |
|
369 | 369 | } |
370 | 370 | if (!$result = $this->db->query($sql)) { |
371 | 371 | return false; |
@@ -32,7 +32,7 @@ |
||
32 | 32 | |
33 | 33 | use XoopsModules\Newbb; |
34 | 34 | |
35 | -require_once __DIR__ . '/read.php'; |
|
35 | +require_once __DIR__.'/read.php'; |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * A handler for read/unread handling |
@@ -119,12 +119,12 @@ discard block |
||
119 | 119 | $classOption = $classPoll . 'Option'; |
120 | 120 | $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true); |
121 | 121 | $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("<a href='" |
122 | - . XOOPS_URL |
|
123 | - . '/userinfo.php?uid=' |
|
124 | - . $GLOBALS['xoopsUser']->getVar('uid') |
|
125 | - . "'>" |
|
126 | - . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']) |
|
127 | - . '</a>') : $GLOBALS['xoopsConfig']['anonymous']); |
|
122 | + . XOOPS_URL |
|
123 | + . '/userinfo.php?uid=' |
|
124 | + . $GLOBALS['xoopsUser']->getVar('uid') |
|
125 | + . "'>" |
|
126 | + . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']) |
|
127 | + . '</a>') : $GLOBALS['xoopsConfig']['anonymous']); |
|
128 | 128 | $poll_form->addElement($author_label); |
129 | 129 | $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255); |
130 | 130 | $poll_form->addElement($question_text); |
@@ -154,12 +154,12 @@ discard block |
||
154 | 154 | $color_select->addOptionArray($barcolor_array); |
155 | 155 | $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'"); |
156 | 156 | $color_label = new \XoopsFormLabel('', "<img src='" |
157 | - . XOOPS_URL |
|
158 | - . '/modules/' |
|
159 | - . $GLOBALS['xoopsModuleConfig']['poll_module'] |
|
160 | - . '/assets/images/colorbars/' |
|
161 | - . $current_bar |
|
162 | - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' width='30' align='bottom' height='15' alt='' /><br>"); |
|
157 | + . XOOPS_URL |
|
158 | + . '/modules/' |
|
159 | + . $GLOBALS['xoopsModuleConfig']['poll_module'] |
|
160 | + . '/assets/images/colorbars/' |
|
161 | + . $current_bar |
|
162 | + . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' width='30' align='bottom' height='15' alt='' /><br>"); |
|
163 | 163 | $option_tray->addElement($color_select); |
164 | 164 | $option_tray->addElement($color_label); |
165 | 165 | if (!next($barcolor_array)) { |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | $color_select->addOptionArray($barcolor_array); |
229 | 229 | $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
230 | 230 | $color_label = new \XoopsFormLabel('', "<img src='" |
231 | - . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) |
|
232 | - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
231 | + . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) |
|
232 | + . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
233 | 233 | $option_tray->addElement($color_select); |
234 | 234 | $option_tray->addElement($color_label); |
235 | 235 | unset($color_select, $color_label); |
@@ -518,8 +518,8 @@ discard block |
||
518 | 518 | $color_select->addOptionArray($barcolor_array); |
519 | 519 | $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'"); |
520 | 520 | $color_label = new \XoopsFormLabel('', "<img src='" |
521 | - . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}") |
|
522 | - . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
521 | + . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}") |
|
522 | + . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>"); |
|
523 | 523 | $option_tray->addElement($color_select); |
524 | 524 | $option_tray->addElement($color_label); |
525 | 525 | unset($color_select, $color_label, $option_text); |
@@ -652,9 +652,9 @@ discard block |
||
652 | 652 | $expire_text = new \XoopsFormText( |
653 | 653 | _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( |
654 | 654 | _MD_NEWBB_POLL_EXPIREDAT, |
655 | - formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s') |
|
655 | + formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s') |
|
656 | 656 | ) . '</small>', |
657 | - 'end_time', |
|
657 | + 'end_time', |
|
658 | 658 | 20, |
659 | 659 | 19, |
660 | 660 | formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s') |
@@ -111,213 +111,377 @@ discard block |
||
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); |
|
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 | 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); |
|
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); |
|
169 | 171 | } |
170 | - unset($color_select, $color_label); |
|
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(); |
|
171 | 181 | } |
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 |
|
182 | + break; // op: add |
|
183 | 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); |
|
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 |
|
203 | 190 | } 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; |
|
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(); |
|
239 | 251 | } |
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')); |
|
252 | + break; // op: edit |
|
248 | 253 | |
249 | - echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
250 | - $poll_form->display(); |
|
251 | - } |
|
252 | - break; // op: edit |
|
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 | + * The option check should be done before submitting |
|
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 | + } |
|
253 | 290 | |
254 | - case 'save': |
|
255 | - // old xoopspoll or umfrage or any clone from them |
|
256 | - if ($pollModuleHandler->getVar('version') < 140) { |
|
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': |
|
257 | 340 | // check security token |
258 | 341 | if (!$GLOBALS['xoopsSecurity']->check()) { |
259 | 342 | redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
260 | 343 | } |
261 | - /* |
|
262 | - * The option check should be done before submitting |
|
263 | - */ |
|
264 | - $option_empty = true; |
|
265 | - if (!Request::getString('option_text', '', 'POST')) { |
|
266 | - // irmtfan - issue with javascript:history.go(-1) |
|
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) { |
|
267 | 349 | redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !'); |
268 | 350 | } |
269 | - $option_text = Request::getArray('option_text', '', 'POST'); |
|
270 | - foreach ($option_text as $optxt) { |
|
271 | - if ('' !== trim($optxt)) { |
|
272 | - $option_empty = false; |
|
273 | - break; |
|
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 |
|
274 | 375 | } |
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 | 376 | |
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); |
|
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 |
|
298 | 440 | } 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(); |
|
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)); |
|
319 | 448 | } |
320 | - ++$i; |
|
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(); |
|
321 | 485 | } |
322 | 486 | // clear the template cache so changes take effect immediately |
323 | 487 | require_once $GLOBALS['xoops']->path('class/template.php'); |
@@ -326,433 +490,269 @@ discard block |
||
326 | 490 | |
327 | 491 | // update topic to indicate it has a poll |
328 | 492 | $topicObject->setVar('topic_haspoll', 1); |
329 | - $topicObject->setVar('poll_id', $new_poll_id); |
|
493 | + $topicObject->setVar('poll_id', $pollObject->getVar('poll_id')); |
|
330 | 494 | $success = $topicHandler->insert($topicObject); |
331 | 495 | if (!$success) { |
332 | 496 | xoops_error($topicHandler->getHtmlErrors()); |
333 | 497 | } else { |
334 | 498 | redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED); |
335 | 499 | } |
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 |
|
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 | + } |
|
375 | 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)); |
|
376 | 538 | |
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); |
|
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())); |
|
397 | 547 | } |
398 | 548 | |
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]); |
|
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); |
|
423 | 566 | $optionObject->setVar('poll_id', $poll_id); |
567 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
424 | 568 | $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]); |
|
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); |
|
433 | 574 | $optionObject->setVar('poll_id', $poll_id); |
434 | - $xpOptHandler->insert($optionObject); |
|
575 | + $optionObject->setVar('option_color', $option_color[$i]); |
|
576 | + $optionObject->store(); |
|
435 | 577 | } |
436 | 578 | unset($optionObject); |
437 | 579 | } |
580 | + ++$i; |
|
438 | 581 | } |
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')); |
|
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; |
|
443 | 587 | |
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 | - } |
|
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; |
|
460 | 592 | |
461 | - if (!$pollObject->store()) { |
|
462 | - xoops_error($pollObject->getHtmlErrors); |
|
463 | - break; |
|
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())); |
|
464 | 597 | } |
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(); |
|
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); |
|
477 | 607 | } 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); |
|
608 | + $msg = $xpPollHandler->getHtmlErrors(); |
|
530 | 609 | } |
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 | 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); |
|
570 | 618 | } 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(); |
|
619 | + $msg = $pollObject->getHtmlErrors(); |
|
577 | 620 | } |
578 | - unset($optionObject); |
|
579 | 621 | } |
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 | 622 | 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); |
|
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 | + } |
|
607 | 637 | } else { |
608 | - $msg = $xpPollHandler->getHtmlErrors(); |
|
638 | + xoops_error($msg); |
|
639 | + break; |
|
609 | 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; |
|
610 | 649 | // 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 | 650 | } else { |
619 | - $msg = $pollObject->getHtmlErrors(); |
|
651 | + $default_poll_duration = (86400 * 10); |
|
620 | 652 | } |
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); |
|
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')); |
|
628 | 671 | |
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); |
|
672 | + echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n"; |
|
673 | + $poll_form->display(); |
|
639 | 674 | 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 | 675 | |
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 | - } |
|
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 | + } |
|
694 | 681 | |
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 | - } |
|
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 | + } |
|
702 | 694 | |
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 | - } |
|
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 | + } |
|
711 | 702 | |
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(); |
|
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); |
|
717 | 710 | } |
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); |
|
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 | + } |
|
726 | 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); |
|
727 | 751 | // 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(); |
|
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); |
|
739 | 754 | } |
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; |
|
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 | - include $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php'); |
|
87 | + include $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 | include $GLOBALS['xoops']->path('footer.php'); |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | $xoopsTpl->assign('notifyicon', $category_icon); |
221 | 221 | |
222 | 222 | $xoopsTpl->assign([ |
223 | - 'index_title' => sprintf(_MD_NEWBB_WELCOME, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)), |
|
224 | - 'index_desc' => _MD_NEWBB_TOSTART |
|
225 | - ]); |
|
223 | + 'index_title' => sprintf(_MD_NEWBB_WELCOME, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)), |
|
224 | + 'index_desc' => _MD_NEWBB_TOSTART |
|
225 | + ]); |
|
226 | 226 | |
227 | 227 | /* display user stats */ |
228 | 228 | if (!empty($GLOBALS['xoopsModuleConfig']['statistik_enabled'])) { |
@@ -280,10 +280,10 @@ discard block |
||
280 | 280 | $xoopsTpl->assign('rss_button', newbbDisplayImage('rss', 'RSS feed')); |
281 | 281 | } |
282 | 282 | $xoopsTpl->assign([ |
283 | - 'img_forum_new' => newbbDisplayImage('forum_new', _MD_NEWBB_NEWPOSTS), |
|
284 | - 'img_forum' => newbbDisplayImage('forum', _MD_NEWBB_NONEWPOSTS), |
|
285 | - 'img_subforum' => newbbDisplayImage('subforum') |
|
286 | - ]); |
|
283 | + 'img_forum_new' => newbbDisplayImage('forum_new', _MD_NEWBB_NEWPOSTS), |
|
284 | + 'img_forum' => newbbDisplayImage('forum', _MD_NEWBB_NONEWPOSTS), |
|
285 | + 'img_subforum' => newbbDisplayImage('subforum') |
|
286 | + ]); |
|
287 | 287 | |
288 | 288 | // irmtfan move to footer.php |
289 | 289 | require_once __DIR__ . '/footer.php'; |
@@ -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 | /* deal with marks */ |
18 | 18 | if (Request::getInt('mark_read', 0)) { |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | $markvalue = 0; |
24 | 24 | $markresult = _MD_NEWBB_MARK_UNREAD; |
25 | 25 | } |
26 | - require_once __DIR__ . '/include/functions.read.php'; |
|
26 | + require_once __DIR__.'/include/functions.read.php'; |
|
27 | 27 | newbbSetReadForum($markvalue); |
28 | - $url = XOOPS_URL . '/modules/newbb/index.php'; |
|
29 | - redirect_header($url, 2, _MD_NEWBB_ALL_FORUM_MARKED . ' ' . $markresult); |
|
28 | + $url = XOOPS_URL.'/modules/newbb/index.php'; |
|
29 | + redirect_header($url, 2, _MD_NEWBB_ALL_FORUM_MARKED.' '.$markresult); |
|
30 | 30 | } |
31 | 31 | |
32 | -$viewcat = Request::getInt('cat', 0, 'GET');//TODO mb check if this is GET or POST? |
|
32 | +$viewcat = Request::getInt('cat', 0, 'GET'); //TODO mb check if this is GET or POST? |
|
33 | 33 | ///** @var Newbb\CategoryHandler $categoryHandler */ |
34 | 34 | //$categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
35 | 35 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $categories[$viewcat] = $categoryObject->getValues(); |
45 | 45 | } |
46 | 46 | $forum_index_title = sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)); |
47 | - $xoops_pagetitle = $categoryObject->getVar('cat_title') . ' [' . $xoopsModule->getVar('name') . ']'; |
|
47 | + $xoops_pagetitle = $categoryObject->getVar('cat_title').' ['.$xoopsModule->getVar('name').']'; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | if (0 === count($categories)) { |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | //$xoopsOption['xoops_module_header'] = $xoops_module_header; |
58 | 58 | // irmtfan include header.php after defining $xoopsOption['template_main'] |
59 | 59 | require_once $GLOBALS['xoops']->path('header.php'); |
60 | -require_once __DIR__ . '/include/functions.render.php'; |
|
60 | +require_once __DIR__.'/include/functions.render.php'; |
|
61 | 61 | /* rss feed */ |
62 | 62 | // irmtfan new method |
63 | 63 | if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) { |
64 | 64 | $xoopsTpl->assign('xoops_module_header', ' |
65 | - <link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/rss.php" /> |
|
65 | + <link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name').'" href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/rss.php" /> |
|
66 | 66 | ' . @$xoopsTpl->get_template_vars('xoops_module_header')); |
67 | 67 | } |
68 | 68 | $xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle); |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | |
90 | 90 | if (!empty($forums_allowed)) { |
91 | 91 | $crit_top = new \CriteriaCompo(new \Criteria('parent_forum', 0)); |
92 | - $crit_top->add(new \Criteria('cat_id', '(' . implode(', ', array_keys($categories)) . ')', 'IN')); |
|
93 | - $crit_top->add(new \Criteria('forum_id', '(' . implode(', ', $forums_allowed) . ')', 'IN')); |
|
92 | + $crit_top->add(new \Criteria('cat_id', '('.implode(', ', array_keys($categories)).')', 'IN')); |
|
93 | + $crit_top->add(new \Criteria('forum_id', '('.implode(', ', $forums_allowed).')', 'IN')); |
|
94 | 94 | $forums_top = $forumHandler->getIds($crit_top); |
95 | 95 | } |
96 | 96 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | if ('hidden' === $GLOBALS['xoopsModuleConfig']['subforum_display'] || 0 === count($forums_top)) { |
99 | 99 | $forums_sub = []; |
100 | 100 | } else { |
101 | - $crit_sub = new \CriteriaCompo(new \Criteria('parent_forum', '(' . implode(', ', $forums_top) . ')', 'IN')); |
|
102 | - $crit_sub->add(new \Criteria('forum_id', '(' . implode(', ', $forums_allowed) . ')', 'IN')); |
|
101 | + $crit_sub = new \CriteriaCompo(new \Criteria('parent_forum', '('.implode(', ', $forums_top).')', 'IN')); |
|
102 | + $crit_sub->add(new \Criteria('forum_id', '('.implode(', ', $forums_allowed).')', 'IN')); |
|
103 | 103 | $forums_sub = $forumHandler->getIds($crit_sub); |
104 | 104 | } |
105 | 105 | |
@@ -111,17 +111,17 @@ discard block |
||
111 | 111 | $newposts = 0; |
112 | 112 | $deleteposts = 0; |
113 | 113 | if (0 !== count($forums_available)) { |
114 | - $crit_forum = new \Criteria('forum_id', '(' . implode(', ', $forums_available) . ')', 'IN'); |
|
114 | + $crit_forum = new \Criteria('forum_id', '('.implode(', ', $forums_available).')', 'IN'); |
|
115 | 115 | $crit_forum->setSort('cat_id ASC, parent_forum ASC, forum_order'); |
116 | 116 | $crit_forum->setOrder('ASC'); |
117 | 117 | $forums = $forumHandler->getAll($crit_forum, null, false); |
118 | 118 | $newtopics = $forumHandler->getTopicCount($forums, 0, 'pending'); |
119 | 119 | $deletetopics = $forumHandler->getTopicCount($forums, 0, 'deleted'); |
120 | 120 | $forums_array = $forumHandler->display($forums, $GLOBALS['xoopsModuleConfig']['length_title_index'], $GLOBALS['xoopsModuleConfig']['count_subforum']); |
121 | - $crit = new \CriteriaCompo(new \Criteria('forum_id', '(' . implode(', ', $forums_available) . ')', 'IN')); |
|
121 | + $crit = new \CriteriaCompo(new \Criteria('forum_id', '('.implode(', ', $forums_available).')', 'IN')); |
|
122 | 122 | $crit->add(new \Criteria('approved', '-1')); |
123 | 123 | $deleteposts = $postHandler->getCount($crit); |
124 | - $crit = new \CriteriaCompo(new \Criteria('forum_id', '(' . implode(', ', $forums_available) . ')', 'IN')); |
|
124 | + $crit = new \CriteriaCompo(new \Criteria('forum_id', '('.implode(', ', $forums_available).')', 'IN')); |
|
125 | 125 | $crit->add(new \Criteria('approved', '0')); |
126 | 126 | $newposts = $postHandler->getCount($crit); |
127 | 127 | } |
@@ -168,15 +168,15 @@ discard block |
||
168 | 168 | $forums = []; |
169 | 169 | $onecat = $categories[$id]; |
170 | 170 | |
171 | - $cat_element_id = 'cat_' . $onecat['cat_id']; |
|
171 | + $cat_element_id = 'cat_'.$onecat['cat_id']; |
|
172 | 172 | $expand = (count($toggles) > 0) ? (in_array($cat_element_id, $toggles) ? false : true) : true; |
173 | 173 | // START irmtfan to improve newbbDisplayImage |
174 | 174 | if ($expand) { |
175 | - $cat_display = 'block'; //irmtfan move semicolon |
|
175 | + $cat_display = 'block'; //irmtfan move semicolon |
|
176 | 176 | $cat_icon_display = 'minus'; |
177 | 177 | $cat_alt = _MD_NEWBB_HIDE; |
178 | 178 | } else { |
179 | - $cat_display = 'none'; //irmtfan move semicolon |
|
179 | + $cat_display = 'none'; //irmtfan move semicolon |
|
180 | 180 | $cat_icon_display = 'plus'; |
181 | 181 | $cat_alt = _MD_NEWBB_SEE; |
182 | 182 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $cat_image = ''; |
200 | 200 | $cat_image = $onecat['cat_image']; |
201 | 201 | if ('' !== $cat_image && 'blank.gif' !== $cat_image && $cat_image) { |
202 | - $cat_image = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/assets/images/category/' . $cat_image; |
|
202 | + $cat_image = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/assets/images/category/'.$cat_image; |
|
203 | 203 | } |
204 | 204 | $category_array[] = [ |
205 | 205 | 'cat_id' => $onecat['cat_id'], |
@@ -250,15 +250,15 @@ discard block |
||
250 | 250 | $stats = $statsHandler->getStats(array_merge([0], $forums_available)); |
251 | 251 | $xoopsTpl->assign_by_ref('stats', $stats); |
252 | 252 | $xoopsTpl->assign('subforum_display', $GLOBALS['xoopsModuleConfig']['subforum_display']); |
253 | -$xoopsTpl->assign('mark_read', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/index.php?mark_read=1'); |
|
254 | -$xoopsTpl->assign('mark_unread', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/index.php?mark_read=2'); |
|
253 | +$xoopsTpl->assign('mark_read', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/index.php?mark_read=1'); |
|
254 | +$xoopsTpl->assign('mark_unread', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/index.php?mark_read=2'); |
|
255 | 255 | |
256 | -$xoopsTpl->assign('all_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/list.topic.php?status=all'); |
|
257 | -$xoopsTpl->assign('post_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewpost.php?status=all'); |
|
258 | -$xoopsTpl->assign('newpost_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewpost.php?status=new'); |
|
259 | -$xoopsTpl->assign('digest_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/list.topic.php?status=digest'); |
|
260 | -$xoopsTpl->assign('unreplied_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/list.topic.php?status=unreplied'); |
|
261 | -$xoopsTpl->assign('unread_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/list.topic.php?status=unread'); |
|
256 | +$xoopsTpl->assign('all_link', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/list.topic.php?status=all'); |
|
257 | +$xoopsTpl->assign('post_link', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/viewpost.php?status=all'); |
|
258 | +$xoopsTpl->assign('newpost_link', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/viewpost.php?status=new'); |
|
259 | +$xoopsTpl->assign('digest_link', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/list.topic.php?status=digest'); |
|
260 | +$xoopsTpl->assign('unreplied_link', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/list.topic.php?status=unreplied'); |
|
261 | +$xoopsTpl->assign('unread_link', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/list.topic.php?status=unread'); |
|
262 | 262 | $xoopsTpl->assign('menumode', $menumode); |
263 | 263 | $xoopsTpl->assign('menumode_other', $menumode_other); |
264 | 264 | |
@@ -286,5 +286,5 @@ discard block |
||
286 | 286 | ]); |
287 | 287 | |
288 | 288 | // irmtfan move to footer.php |
289 | -require_once __DIR__ . '/footer.php'; |
|
289 | +require_once __DIR__.'/footer.php'; |
|
290 | 290 | include $GLOBALS['xoops']->path('footer.php'); |
@@ -46,179 +46,179 @@ |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | switch ($op) { |
49 | - case 'restore': |
|
50 | - $post_id = array_values($post_id); |
|
51 | - sort($post_id); |
|
52 | - $topics = []; |
|
53 | - $forums = []; |
|
54 | - foreach ($post_id as $post) { |
|
55 | - $postObject = $postHandler->get($post); |
|
56 | - if ($postObject->getVar('topic_id') < 1) { |
|
57 | - continue; |
|
49 | + case 'restore': |
|
50 | + $post_id = array_values($post_id); |
|
51 | + sort($post_id); |
|
52 | + $topics = []; |
|
53 | + $forums = []; |
|
54 | + foreach ($post_id as $post) { |
|
55 | + $postObject = $postHandler->get($post); |
|
56 | + if ($postObject->getVar('topic_id') < 1) { |
|
57 | + continue; |
|
58 | + } |
|
59 | + |
|
60 | + $postHandler->approve($postObject, true); |
|
61 | + $topics[$postObject->getVar('topic_id')] = 1; |
|
62 | + $forums[$postObject->getVar('forum_id')] = 1; |
|
63 | + unset($postObject); |
|
64 | + } |
|
65 | + foreach (array_keys($topics) as $topic) { |
|
66 | + $topicHandler->synchronization($topic); |
|
67 | + } |
|
68 | + foreach (array_keys($forums) as $forum) { |
|
69 | + $forumHandler->synchronization($forum); |
|
70 | + } |
|
71 | + break; |
|
72 | + case 'approve': |
|
73 | + $post_id = array_values($post_id); |
|
74 | + sort($post_id); |
|
75 | + $topics = []; |
|
76 | + $forums = []; |
|
77 | + $criteria = new \Criteria('post_id', '(' . implode(',', $post_id) . ')', 'IN'); |
|
78 | + $postsObject = $postHandler->getObjects($criteria, true); |
|
79 | + foreach ($post_id as $post) { |
|
80 | + /** @var Newbb\Post $postObject */ |
|
81 | + $postObject = $postsObject[$post]; |
|
82 | + if (!empty($topic_id) && $topic_id !== $postObject->getVar('topic_id')) { |
|
83 | + continue; |
|
84 | + } |
|
85 | + $postHandler->approve($postObject); |
|
86 | + $topics[$postObject->getVar('topic_id')] = $post; |
|
87 | + $forums[$postObject->getVar('forum_id')] = 1; |
|
88 | + } |
|
89 | + foreach (array_keys($topics) as $topic) { |
|
90 | + $topicHandler->synchronization($topic); |
|
91 | + } |
|
92 | + foreach (array_keys($forums) as $forum) { |
|
93 | + $forumHandler->synchronization($forum); |
|
58 | 94 | } |
59 | 95 | |
60 | - $postHandler->approve($postObject, true); |
|
61 | - $topics[$postObject->getVar('topic_id')] = 1; |
|
62 | - $forums[$postObject->getVar('forum_id')] = 1; |
|
63 | - unset($postObject); |
|
64 | - } |
|
65 | - foreach (array_keys($topics) as $topic) { |
|
66 | - $topicHandler->synchronization($topic); |
|
67 | - } |
|
68 | - foreach (array_keys($forums) as $forum) { |
|
69 | - $forumHandler->synchronization($forum); |
|
70 | - } |
|
71 | - break; |
|
72 | - case 'approve': |
|
73 | - $post_id = array_values($post_id); |
|
74 | - sort($post_id); |
|
75 | - $topics = []; |
|
76 | - $forums = []; |
|
77 | - $criteria = new \Criteria('post_id', '(' . implode(',', $post_id) . ')', 'IN'); |
|
78 | - $postsObject = $postHandler->getObjects($criteria, true); |
|
79 | - foreach ($post_id as $post) { |
|
80 | - /** @var Newbb\Post $postObject */ |
|
81 | - $postObject = $postsObject[$post]; |
|
82 | - if (!empty($topic_id) && $topic_id !== $postObject->getVar('topic_id')) { |
|
83 | - continue; |
|
96 | + if (empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) { |
|
97 | + break; |
|
98 | + } |
|
99 | + |
|
100 | + $criteria_topic = new \Criteria('topic_id', '(' . implode(',', array_keys($topics)) . ')', 'IN'); |
|
101 | + $topic_list = $topicHandler->getList($criteria_topic, true); |
|
102 | + |
|
103 | + $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
104 | + $forum_list = $forumHandler->getList($criteria_forum); |
|
105 | + |
|
106 | + require_once __DIR__ . '/include/notification.inc.php'; |
|
107 | + /** @var \XoopsNotificationHandler $notificationHandler */ |
|
108 | + $notificationHandler = xoops_getHandler('notification'); |
|
109 | + foreach ($post_id as $post) { |
|
110 | + $tags = []; |
|
111 | + /** @var Newbb\Post[] $postsObject [$post] */ |
|
112 | + $tags['THREAD_NAME'] = $topic_list[$postsObject[$post]->getVar('topic_id')]; |
|
113 | + $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $postsObject[$post]->getVar('topic_id') . '&forum=' . $postsObject[$post]->getVar('forum_id'); |
|
114 | + $tags['FORUM_NAME'] = $forum_list[$postsObject[$post]->getVar('forum_id')]; |
|
115 | + $tags['FORUM_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $postsObject[$post]->getVar('forum_id'); |
|
116 | + $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $post; |
|
117 | + $notificationHandler->triggerEvent('thread', $postsObject[$post]->getVar('topic_id'), 'new_post', $tags); |
|
118 | + $notificationHandler->triggerEvent('forum', $postsObject[$post]->getVar('forum_id'), 'new_post', $tags); |
|
119 | + $notificationHandler->triggerEvent('global', 0, 'new_post', $tags); |
|
120 | + $tags['POST_CONTENT'] = $postsObject[$post]->getVar('post_text'); |
|
121 | + $tags['POST_NAME'] = $postsObject[$post]->getVar('subject'); |
|
122 | + $notificationHandler->triggerEvent('global', 0, 'new_fullpost', $tags); |
|
123 | + $notificationHandler->triggerEvent('forum', $postsObject[$post]->getVar('forum_id'), 'new_fullpost', $tags); |
|
84 | 124 | } |
85 | - $postHandler->approve($postObject); |
|
86 | - $topics[$postObject->getVar('topic_id')] = $post; |
|
87 | - $forums[$postObject->getVar('forum_id')] = 1; |
|
88 | - } |
|
89 | - foreach (array_keys($topics) as $topic) { |
|
90 | - $topicHandler->synchronization($topic); |
|
91 | - } |
|
92 | - foreach (array_keys($forums) as $forum) { |
|
93 | - $forumHandler->synchronization($forum); |
|
94 | - } |
|
95 | - |
|
96 | - if (empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) { |
|
97 | 125 | break; |
98 | - } |
|
99 | - |
|
100 | - $criteria_topic = new \Criteria('topic_id', '(' . implode(',', array_keys($topics)) . ')', 'IN'); |
|
101 | - $topic_list = $topicHandler->getList($criteria_topic, true); |
|
102 | - |
|
103 | - $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
104 | - $forum_list = $forumHandler->getList($criteria_forum); |
|
105 | - |
|
106 | - require_once __DIR__ . '/include/notification.inc.php'; |
|
107 | - /** @var \XoopsNotificationHandler $notificationHandler */ |
|
108 | - $notificationHandler = xoops_getHandler('notification'); |
|
109 | - foreach ($post_id as $post) { |
|
110 | - $tags = []; |
|
111 | - /** @var Newbb\Post[] $postsObject [$post] */ |
|
112 | - $tags['THREAD_NAME'] = $topic_list[$postsObject[$post]->getVar('topic_id')]; |
|
113 | - $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $postsObject[$post]->getVar('topic_id') . '&forum=' . $postsObject[$post]->getVar('forum_id'); |
|
114 | - $tags['FORUM_NAME'] = $forum_list[$postsObject[$post]->getVar('forum_id')]; |
|
115 | - $tags['FORUM_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $postsObject[$post]->getVar('forum_id'); |
|
116 | - $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $post; |
|
117 | - $notificationHandler->triggerEvent('thread', $postsObject[$post]->getVar('topic_id'), 'new_post', $tags); |
|
118 | - $notificationHandler->triggerEvent('forum', $postsObject[$post]->getVar('forum_id'), 'new_post', $tags); |
|
119 | - $notificationHandler->triggerEvent('global', 0, 'new_post', $tags); |
|
120 | - $tags['POST_CONTENT'] = $postsObject[$post]->getVar('post_text'); |
|
121 | - $tags['POST_NAME'] = $postsObject[$post]->getVar('subject'); |
|
122 | - $notificationHandler->triggerEvent('global', 0, 'new_fullpost', $tags); |
|
123 | - $notificationHandler->triggerEvent('forum', $postsObject[$post]->getVar('forum_id'), 'new_fullpost', $tags); |
|
124 | - } |
|
125 | - break; |
|
126 | - case 'delete': |
|
127 | - $post_id = array_values($post_id); |
|
128 | - rsort($post_id); |
|
129 | - $topics = []; |
|
130 | - $forums = []; |
|
131 | - foreach ($post_id as $post) { |
|
132 | - $postObject = $postHandler->get($post); |
|
133 | - if (!empty($topic_id) && $topic_id !== $postObject->getVar('topic_id')) { |
|
134 | - continue; |
|
126 | + case 'delete': |
|
127 | + $post_id = array_values($post_id); |
|
128 | + rsort($post_id); |
|
129 | + $topics = []; |
|
130 | + $forums = []; |
|
131 | + foreach ($post_id as $post) { |
|
132 | + $postObject = $postHandler->get($post); |
|
133 | + if (!empty($topic_id) && $topic_id !== $postObject->getVar('topic_id')) { |
|
134 | + continue; |
|
135 | + } |
|
136 | + $topics[$postObject->getVar('topic_id')] = 1; |
|
137 | + $forums[$postObject->getVar('forum_id')] = 1; |
|
138 | + $postHandler->delete($postObject, true); |
|
139 | + unset($postObject); |
|
140 | + } |
|
141 | + foreach (array_keys($topics) as $topic) { |
|
142 | + $topicHandler->synchronization($topic); |
|
143 | + } |
|
144 | + foreach (array_keys($forums) as $forum) { |
|
145 | + $forumHandler->synchronization($forum); |
|
135 | 146 | } |
136 | - $topics[$postObject->getVar('topic_id')] = 1; |
|
137 | - $forums[$postObject->getVar('forum_id')] = 1; |
|
138 | - $postHandler->delete($postObject, true); |
|
139 | - unset($postObject); |
|
140 | - } |
|
141 | - foreach (array_keys($topics) as $topic) { |
|
142 | - $topicHandler->synchronization($topic); |
|
143 | - } |
|
144 | - foreach (array_keys($forums) as $forum) { |
|
145 | - $forumHandler->synchronization($forum); |
|
146 | - } |
|
147 | - break; |
|
148 | - case 'split': |
|
149 | - /** @var Newbb\Post $postObject */ |
|
150 | - $postObject = $postHandler->get($post_id); |
|
151 | - if (0 === count($post_id) || $postObject->isTopic()) { |
|
152 | 147 | break; |
153 | - } |
|
154 | - $topic_id = $postObject->getVar('topic_id'); |
|
155 | - |
|
156 | - $newtopic = $topicHandler->create(); |
|
157 | - $newtopic->setVar('topic_title', $postObject->getVar('subject'), true); |
|
158 | - $newtopic->setVar('topic_poster', $postObject->getVar('uid'), true); |
|
159 | - $newtopic->setVar('forum_id', $postObject->getVar('forum_id'), true); |
|
160 | - $newtopic->setVar('topic_time', $postObject->getVar('post_time'), true); |
|
161 | - $newtopic->setVar('poster_name', $postObject->getVar('poster_name'), true); |
|
162 | - $newtopic->setVar('approved', 1, true); |
|
163 | - $topicHandler->insert($newtopic, true); |
|
164 | - $new_topic_id = $newtopic->getVar('topic_id'); |
|
165 | - |
|
166 | - $pid = $postObject->getVar('pid'); |
|
167 | - |
|
168 | - $postObject->setVar('topic_id', $new_topic_id, true); |
|
169 | - $postObject->setVar('pid', 0, true); |
|
170 | - $postHandler->insert($postObject); |
|
171 | - |
|
172 | - /* split a single post */ |
|
173 | - if (1 === $mode) { |
|
174 | - $criteria = new \CriteriaCompo(new \Criteria('topic_id', $topic_id)); |
|
175 | - $criteria->add(new \Criteria('pid', $post_id)); |
|
176 | - $postHandler->updateAll('pid', $pid, $criteria, true); |
|
177 | - /* split a post and its children posts */ |
|
178 | - } elseif (2 === $mode) { |
|
179 | - require_once $GLOBALS['xoops']->path('class/xoopstree.php'); |
|
180 | - $mytree = new \XoopsTree($GLOBALS['xoopsDB']->prefix('newbb_posts'), 'post_id', 'pid'); |
|
181 | - $posts = $mytree->getAllChildId($post_id); |
|
182 | - if (count($posts) > 0) { |
|
183 | - $criteria = new \Criteria('post_id', '(' . implode(',', $posts) . ')', 'IN'); |
|
184 | - $postHandler->updateAll('topic_id', $new_topic_id, $criteria, true); |
|
148 | + case 'split': |
|
149 | + /** @var Newbb\Post $postObject */ |
|
150 | + $postObject = $postHandler->get($post_id); |
|
151 | + if (0 === count($post_id) || $postObject->isTopic()) { |
|
152 | + break; |
|
185 | 153 | } |
186 | - /* split a post and all posts coming after */ |
|
187 | - } elseif (3 === $mode) { |
|
188 | - $criteria = new \CriteriaCompo(new \Criteria('topic_id', $topic_id)); |
|
189 | - $criteria->add(new \Criteria('post_id', $post_id, '>')); |
|
190 | - $postHandler->updateAll('topic_id', $new_topic_id, $criteria, true); |
|
191 | - |
|
192 | - unset($criteria); |
|
193 | - $criteria = new \CriteriaCompo(new \Criteria('topic_id', $new_topic_id)); |
|
194 | - $criteria->add(new \Criteria('post_id', $post_id, '>')); |
|
195 | - $postHandler->identifierName = 'pid'; |
|
196 | - $posts = $postHandler->getList($criteria); |
|
197 | - |
|
198 | - unset($criteria); |
|
199 | - $post_update = []; |
|
200 | - foreach ($posts as $postid => $pid) { |
|
201 | - // if (!in_array($pid, array_keys($posts))) { |
|
202 | - if (!array_key_exists($pid, $posts)) { |
|
203 | - $post_update[] = $pid; |
|
154 | + $topic_id = $postObject->getVar('topic_id'); |
|
155 | + |
|
156 | + $newtopic = $topicHandler->create(); |
|
157 | + $newtopic->setVar('topic_title', $postObject->getVar('subject'), true); |
|
158 | + $newtopic->setVar('topic_poster', $postObject->getVar('uid'), true); |
|
159 | + $newtopic->setVar('forum_id', $postObject->getVar('forum_id'), true); |
|
160 | + $newtopic->setVar('topic_time', $postObject->getVar('post_time'), true); |
|
161 | + $newtopic->setVar('poster_name', $postObject->getVar('poster_name'), true); |
|
162 | + $newtopic->setVar('approved', 1, true); |
|
163 | + $topicHandler->insert($newtopic, true); |
|
164 | + $new_topic_id = $newtopic->getVar('topic_id'); |
|
165 | + |
|
166 | + $pid = $postObject->getVar('pid'); |
|
167 | + |
|
168 | + $postObject->setVar('topic_id', $new_topic_id, true); |
|
169 | + $postObject->setVar('pid', 0, true); |
|
170 | + $postHandler->insert($postObject); |
|
171 | + |
|
172 | + /* split a single post */ |
|
173 | + if (1 === $mode) { |
|
174 | + $criteria = new \CriteriaCompo(new \Criteria('topic_id', $topic_id)); |
|
175 | + $criteria->add(new \Criteria('pid', $post_id)); |
|
176 | + $postHandler->updateAll('pid', $pid, $criteria, true); |
|
177 | + /* split a post and its children posts */ |
|
178 | + } elseif (2 === $mode) { |
|
179 | + require_once $GLOBALS['xoops']->path('class/xoopstree.php'); |
|
180 | + $mytree = new \XoopsTree($GLOBALS['xoopsDB']->prefix('newbb_posts'), 'post_id', 'pid'); |
|
181 | + $posts = $mytree->getAllChildId($post_id); |
|
182 | + if (count($posts) > 0) { |
|
183 | + $criteria = new \Criteria('post_id', '(' . implode(',', $posts) . ')', 'IN'); |
|
184 | + $postHandler->updateAll('topic_id', $new_topic_id, $criteria, true); |
|
204 | 185 | } |
205 | - if (!array_key_exists($pid, $posts)) { |
|
206 | - $post_update2[] = $pid; |
|
186 | + /* split a post and all posts coming after */ |
|
187 | + } elseif (3 === $mode) { |
|
188 | + $criteria = new \CriteriaCompo(new \Criteria('topic_id', $topic_id)); |
|
189 | + $criteria->add(new \Criteria('post_id', $post_id, '>')); |
|
190 | + $postHandler->updateAll('topic_id', $new_topic_id, $criteria, true); |
|
191 | + |
|
192 | + unset($criteria); |
|
193 | + $criteria = new \CriteriaCompo(new \Criteria('topic_id', $new_topic_id)); |
|
194 | + $criteria->add(new \Criteria('post_id', $post_id, '>')); |
|
195 | + $postHandler->identifierName = 'pid'; |
|
196 | + $posts = $postHandler->getList($criteria); |
|
197 | + |
|
198 | + unset($criteria); |
|
199 | + $post_update = []; |
|
200 | + foreach ($posts as $postid => $pid) { |
|
201 | + // if (!in_array($pid, array_keys($posts))) { |
|
202 | + if (!array_key_exists($pid, $posts)) { |
|
203 | + $post_update[] = $pid; |
|
204 | + } |
|
205 | + if (!array_key_exists($pid, $posts)) { |
|
206 | + $post_update2[] = $pid; |
|
207 | + } |
|
208 | + } |
|
209 | + if (count($post_update)) { |
|
210 | + $criteria = new \Criteria('post_id', '(' . implode(',', $post_update) . ')', 'IN'); |
|
211 | + $postHandler->updateAll('pid', $post_id, $criteria, true); |
|
207 | 212 | } |
208 | 213 | } |
209 | - if (count($post_update)) { |
|
210 | - $criteria = new \Criteria('post_id', '(' . implode(',', $post_update) . ')', 'IN'); |
|
211 | - $postHandler->updateAll('pid', $post_id, $criteria, true); |
|
212 | - } |
|
213 | - } |
|
214 | 214 | |
215 | - $forum_id = $postObject->getVar('forum_id'); |
|
216 | - $topicHandler->synchronization($topic_id); |
|
217 | - $topicHandler->synchronization($new_topic_id); |
|
218 | - $sql = sprintf('UPDATE "%s" SET forum_topics = forum_topics+1 WHERE forum_id = "%u"', $GLOBALS['xoopsDB']->prefix('newbb_forums'), $forum_id); |
|
219 | - $result = $GLOBALS['xoopsDB']->queryF($sql); |
|
215 | + $forum_id = $postObject->getVar('forum_id'); |
|
216 | + $topicHandler->synchronization($topic_id); |
|
217 | + $topicHandler->synchronization($new_topic_id); |
|
218 | + $sql = sprintf('UPDATE "%s" SET forum_topics = forum_topics+1 WHERE forum_id = "%u"', $GLOBALS['xoopsDB']->prefix('newbb_forums'), $forum_id); |
|
219 | + $result = $GLOBALS['xoopsDB']->queryF($sql); |
|
220 | 220 | |
221 | - break; |
|
221 | + break; |
|
222 | 222 | } |
223 | 223 | if (!empty($topic_id)) { |
224 | 224 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id", 2, _MD_NEWBB_DBUPDATED); |
@@ -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 | $topic_id = Request::getInt('topic_id', 0, 'POST'); |
18 | 18 | $post_id = Request::getArray('post_id', Request::getArray('post_id', [], 'POST'), 'GET'); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $isAdmin = newbbIsAdmin($forumObject); |
43 | 43 | |
44 | 44 | if (!$isAdmin) { |
45 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
45 | + redirect_header(XOOPS_URL.'/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | switch ($op) { |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | sort($post_id); |
75 | 75 | $topics = []; |
76 | 76 | $forums = []; |
77 | - $criteria = new \Criteria('post_id', '(' . implode(',', $post_id) . ')', 'IN'); |
|
77 | + $criteria = new \Criteria('post_id', '('.implode(',', $post_id).')', 'IN'); |
|
78 | 78 | $postsObject = $postHandler->getObjects($criteria, true); |
79 | 79 | foreach ($post_id as $post) { |
80 | 80 | /** @var Newbb\Post $postObject */ |
@@ -97,23 +97,23 @@ discard block |
||
97 | 97 | break; |
98 | 98 | } |
99 | 99 | |
100 | - $criteria_topic = new \Criteria('topic_id', '(' . implode(',', array_keys($topics)) . ')', 'IN'); |
|
100 | + $criteria_topic = new \Criteria('topic_id', '('.implode(',', array_keys($topics)).')', 'IN'); |
|
101 | 101 | $topic_list = $topicHandler->getList($criteria_topic, true); |
102 | 102 | |
103 | - $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
103 | + $criteria_forum = new \Criteria('forum_id', '('.implode(',', array_keys($forums)).')', 'IN'); |
|
104 | 104 | $forum_list = $forumHandler->getList($criteria_forum); |
105 | 105 | |
106 | - require_once __DIR__ . '/include/notification.inc.php'; |
|
106 | + require_once __DIR__.'/include/notification.inc.php'; |
|
107 | 107 | /** @var \XoopsNotificationHandler $notificationHandler */ |
108 | 108 | $notificationHandler = xoops_getHandler('notification'); |
109 | 109 | foreach ($post_id as $post) { |
110 | 110 | $tags = []; |
111 | 111 | /** @var Newbb\Post[] $postsObject [$post] */ |
112 | 112 | $tags['THREAD_NAME'] = $topic_list[$postsObject[$post]->getVar('topic_id')]; |
113 | - $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $postsObject[$post]->getVar('topic_id') . '&forum=' . $postsObject[$post]->getVar('forum_id'); |
|
113 | + $tags['THREAD_URL'] = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/viewtopic.php?topic_id='.$postsObject[$post]->getVar('topic_id').'&forum='.$postsObject[$post]->getVar('forum_id'); |
|
114 | 114 | $tags['FORUM_NAME'] = $forum_list[$postsObject[$post]->getVar('forum_id')]; |
115 | - $tags['FORUM_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $postsObject[$post]->getVar('forum_id'); |
|
116 | - $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $post; |
|
115 | + $tags['FORUM_URL'] = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/viewforum.php?forum='.$postsObject[$post]->getVar('forum_id'); |
|
116 | + $tags['POST_URL'] = $tags['THREAD_URL'].'#forumpost'.$post; |
|
117 | 117 | $notificationHandler->triggerEvent('thread', $postsObject[$post]->getVar('topic_id'), 'new_post', $tags); |
118 | 118 | $notificationHandler->triggerEvent('forum', $postsObject[$post]->getVar('forum_id'), 'new_post', $tags); |
119 | 119 | $notificationHandler->triggerEvent('global', 0, 'new_post', $tags); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $mytree = new \XoopsTree($GLOBALS['xoopsDB']->prefix('newbb_posts'), 'post_id', 'pid'); |
181 | 181 | $posts = $mytree->getAllChildId($post_id); |
182 | 182 | if (count($posts) > 0) { |
183 | - $criteria = new \Criteria('post_id', '(' . implode(',', $posts) . ')', 'IN'); |
|
183 | + $criteria = new \Criteria('post_id', '('.implode(',', $posts).')', 'IN'); |
|
184 | 184 | $postHandler->updateAll('topic_id', $new_topic_id, $criteria, true); |
185 | 185 | } |
186 | 186 | /* split a post and all posts coming after */ |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | } |
208 | 208 | } |
209 | 209 | if (count($post_update)) { |
210 | - $criteria = new \Criteria('post_id', '(' . implode(',', $post_update) . ')', 'IN'); |
|
210 | + $criteria = new \Criteria('post_id', '('.implode(',', $post_update).')', 'IN'); |
|
211 | 211 | $postHandler->updateAll('pid', $post_id, $criteria, true); |
212 | 212 | } |
213 | 213 | } |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | break; |
222 | 222 | } |
223 | 223 | if (!empty($topic_id)) { |
224 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id", 2, _MD_NEWBB_DBUPDATED); |
|
224 | + redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id=$topic_id", 2, _MD_NEWBB_DBUPDATED); |
|
225 | 225 | } elseif (!empty($forum_id)) { |
226 | - redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?forum=$forum_id", 2, _MD_NEWBB_DBUPDATED); |
|
226 | + redirect_header(XOOPS_URL."/modules/newbb/viewforum.php?forum=$forum_id", 2, _MD_NEWBB_DBUPDATED); |
|
227 | 227 | } else { |
228 | - redirect_header(XOOPS_URL . "/modules/newbb/viewpost.php?uid=$uid", 2, _MD_NEWBB_DBUPDATED); |
|
228 | + redirect_header(XOOPS_URL."/modules/newbb/viewpost.php?uid=$uid", 2, _MD_NEWBB_DBUPDATED); |
|
229 | 229 | } |
230 | 230 | // irmtfan move to footer.php |
231 | -require_once __DIR__ . '/footer.php'; |
|
231 | +require_once __DIR__.'/footer.php'; |
|
232 | 232 | include $GLOBALS['xoops']->path('footer.php'); |
@@ -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 | $ratinguser = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
37 | 37 | $anonwaitdays = 1; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | if (empty($rate)) { |
54 | - redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_NOVOTERATE); |
|
54 | + redirect_header('viewtopic.php?topic_id='.$topic_id.'&forum='.$forum.'', 4, _MD_NEWBB_NOVOTERATE); |
|
55 | 55 | } |
56 | 56 | ///** @var Newbb\RateHandler $rateHandler */ |
57 | 57 | //$rateHandler = Newbb\Helper::getInstance()->getHandler('Rate'); |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | // /** @var Newbb\PostHandler $postHandler */ |
63 | 63 | // $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
64 | 64 | if ($postHandler->getCount($crit_post)) { |
65 | - redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_CANTVOTEOWN); |
|
65 | + redirect_header('viewtopic.php?topic_id='.$topic_id.'&forum='.$forum.'', 4, _MD_NEWBB_CANTVOTEOWN); |
|
66 | 66 | } |
67 | 67 | // Check if REG user is trying to vote twice. |
68 | 68 | $crit_rate = new \CriteriaCompo(new \Criteria('topic_id', $topic_id)); |
69 | 69 | $crit_rate->add(new \Criteria('ratinguser', $ratinguser)); |
70 | 70 | if ($rateHandler->getCount($crit_rate)) { |
71 | - redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_VOTEONCE); |
|
71 | + redirect_header('viewtopic.php?topic_id='.$topic_id.'&forum='.$forum.'', 4, _MD_NEWBB_VOTEONCE); |
|
72 | 72 | } |
73 | 73 | } else { |
74 | 74 | // Check if ANONYMOUS user is trying to vote more than once per day. |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $crit_rate->add(new \Criteria('ratinghostname', $ip)); |
78 | 78 | $crit_rate->add(new \Criteria('ratingtimestamp', time() - (86400 * $anonwaitdays), '>')); |
79 | 79 | if ($rateHandler->getCount($crit_rate)) { |
80 | - redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_VOTEONCE); |
|
80 | + redirect_header('viewtopic.php?topic_id='.$topic_id.'&forum='.$forum.'', 4, _MD_NEWBB_VOTEONCE); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | $rateObject = $rateHandler->create(); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $ratingid = $rateHandler->insert($rateObject); |
91 | 91 | |
92 | -$query = 'SELECT rating FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_votedata') . ' WHERE topic_id = ' . $topic_id . ' '; |
|
92 | +$query = 'SELECT rating FROM '.$GLOBALS['xoopsDB']->prefix('newbb_votedata').' WHERE topic_id = '.$topic_id.' '; |
|
93 | 93 | $voteresult = $GLOBALS['xoopsDB']->query($query); |
94 | 94 | $votesDB = $GLOBALS['xoopsDB']->getRowsNum($voteresult); |
95 | 95 | $totalrating = 0; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $sql = sprintf('UPDATE "%s" SET rating = "%u", votes = "%u" WHERE topic_id = "%u"', $GLOBALS['xoopsDB']->prefix('newbb_topics'), $finalrating, $votesDB, $topic_id); |
102 | 102 | $GLOBALS['xoopsDB']->queryF($sql); |
103 | 103 | |
104 | -$ratemessage = _MD_NEWBB_VOTEAPPRE . '<br>' . sprintf(_MD_NEWBB_THANKYOU, $GLOBALS['xoopsConfig']['sitename']); |
|
105 | -redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 2, $ratemessage); |
|
104 | +$ratemessage = _MD_NEWBB_VOTEAPPRE.'<br>'.sprintf(_MD_NEWBB_THANKYOU, $GLOBALS['xoopsConfig']['sitename']); |
|
105 | +redirect_header('viewtopic.php?topic_id='.$topic_id.'&forum='.$forum.'', 2, $ratemessage); |
|
106 | 106 | // irmtfan enhance include footer.php |
107 | 107 | include $GLOBALS['xoops']->path('footer.php'); |
@@ -37,150 +37,150 @@ |
||
37 | 37 | redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
38 | 38 | } |
39 | 39 | switch ($op) { |
40 | - case 'restore': |
|
41 | - $forums = []; |
|
42 | - $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
|
43 | - foreach (array_keys($topicsObject) as $id) { |
|
44 | - /** @var Newbb\Topic $topicObject */ |
|
45 | - $topicObject = $topicsObject[$id]; |
|
46 | - $topicHandler->approve($topicObject); |
|
47 | - $topicHandler->synchronization($topicObject); |
|
48 | - $forums[$topicObject->getVar('forum_id')] = 1; |
|
49 | - } |
|
50 | - $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
51 | - $forumsObject = $forumHandler->getAll($criteria_forum); |
|
52 | - foreach (array_keys($forumsObject) as $id) { |
|
53 | - $forumHandler->synchronization($forumsObject[$id]); |
|
54 | - } |
|
55 | - unset($topicsObject, $forumsObject); |
|
56 | - break; |
|
57 | - case 'approve': |
|
58 | - $forums = []; |
|
59 | - $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
|
60 | - foreach (array_keys($topicsObject) as $id) { |
|
61 | - /** @var Newbb\Topic $topicObject */ |
|
62 | - $topicObject = $topicsObject[$id]; |
|
63 | - $topicHandler->approve($topicObject); |
|
64 | - $topicHandler->synchronization($topicObject); |
|
65 | - $forums[$topicObject->getVar('forum_id')] = 1; |
|
66 | - } |
|
40 | + case 'restore': |
|
41 | + $forums = []; |
|
42 | + $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
|
43 | + foreach (array_keys($topicsObject) as $id) { |
|
44 | + /** @var Newbb\Topic $topicObject */ |
|
45 | + $topicObject = $topicsObject[$id]; |
|
46 | + $topicHandler->approve($topicObject); |
|
47 | + $topicHandler->synchronization($topicObject); |
|
48 | + $forums[$topicObject->getVar('forum_id')] = 1; |
|
49 | + } |
|
50 | + $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
51 | + $forumsObject = $forumHandler->getAll($criteria_forum); |
|
52 | + foreach (array_keys($forumsObject) as $id) { |
|
53 | + $forumHandler->synchronization($forumsObject[$id]); |
|
54 | + } |
|
55 | + unset($topicsObject, $forumsObject); |
|
56 | + break; |
|
57 | + case 'approve': |
|
58 | + $forums = []; |
|
59 | + $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
|
60 | + foreach (array_keys($topicsObject) as $id) { |
|
61 | + /** @var Newbb\Topic $topicObject */ |
|
62 | + $topicObject = $topicsObject[$id]; |
|
63 | + $topicHandler->approve($topicObject); |
|
64 | + $topicHandler->synchronization($topicObject); |
|
65 | + $forums[$topicObject->getVar('forum_id')] = 1; |
|
66 | + } |
|
67 | 67 | |
68 | - $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
69 | - $forumsObject = $forumHandler->getAll($criteria_forum); |
|
70 | - foreach (array_keys($forumsObject) as $id) { |
|
71 | - $forumHandler->synchronization($forumsObject[$id]); |
|
72 | - } |
|
68 | + $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
69 | + $forumsObject = $forumHandler->getAll($criteria_forum); |
|
70 | + foreach (array_keys($forumsObject) as $id) { |
|
71 | + $forumHandler->synchronization($forumsObject[$id]); |
|
72 | + } |
|
73 | 73 | |
74 | - if (empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) { |
|
75 | - break; |
|
76 | - } |
|
74 | + if (empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) { |
|
75 | + break; |
|
76 | + } |
|
77 | 77 | |
78 | - require_once __DIR__ . '/include/notification.inc.php'; |
|
79 | - /** @var \XoopsNotificationHandler $notificationHandler */ |
|
80 | - $notificationHandler = xoops_getHandler('notification'); |
|
81 | - foreach (array_keys($topicsObject) as $id) { |
|
82 | - $topicObject = $topicsObject[$id]; |
|
83 | - $tags = []; |
|
84 | - $tags['THREAD_NAME'] = $topicObject->getVar('topic_title'); |
|
85 | - $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewtopic.php?topic_id=' . $id . '&forum=' . $topicObject->getVar('forum_id'); |
|
86 | - /** @var Newbb\Forum[] $forumsObject */ |
|
87 | - $tags['FORUM_NAME'] = $forumsObject[$topicObject->getVar('forum_id')]->getVar('forum_name'); |
|
88 | - $tags['FORUM_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewforum.php?forum=' . $topicObject->getVar('forum_id'); |
|
89 | - $notificationHandler->triggerEvent('global', 0, 'new_thread', $tags); |
|
90 | - $notificationHandler->triggerEvent('forum', $topicObject->getVar('forum_id'), 'new_thread', $tags); |
|
91 | - $postObject = $topicHandler->getTopPost($id); |
|
92 | - $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $postObject->getVar('post_id'); |
|
93 | - $notificationHandler->triggerEvent('thread', $id, 'new_post', $tags); |
|
94 | - $notificationHandler->triggerEvent('forum', $topicObject->getVar('forum_id'), 'new_post', $tags); |
|
95 | - $notificationHandler->triggerEvent('global', 0, 'new_post', $tags); |
|
96 | - $tags['POST_CONTENT'] = $postObject->getVar('post_text'); |
|
97 | - $tags['POST_NAME'] = $postObject->getVar('subject'); |
|
98 | - $notificationHandler->triggerEvent('global', 0, 'new_fullpost', $tags); |
|
99 | - $notificationHandler->triggerEvent('forum', $topicObject->getVar('forum_id'), 'new_fullpost', $tags); |
|
100 | - unset($postObject); |
|
101 | - } |
|
102 | - unset($topicsObject, $forumsObject); |
|
103 | - break; |
|
104 | - case 'delete': |
|
105 | - $forums = []; |
|
106 | - /** @var Newbb\TopicHandler|\XoopsPersistableObjectHandler $topicHandler */ |
|
107 | - $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
|
108 | - foreach (array_keys($topicsObject) as $id) { |
|
109 | - /** @var Newbb\Topic $topicObject */ |
|
110 | - $topicObject = $topicsObject[$id]; |
|
111 | - // irmtfan should be set to false to not delete topic from database |
|
112 | - $topicHandler->delete($topicObject, false); |
|
113 | - $topicHandler->synchronization($topicObject); |
|
114 | - $forums[$topicObject->getVar('forum_id')] = 1; |
|
115 | - } |
|
78 | + require_once __DIR__ . '/include/notification.inc.php'; |
|
79 | + /** @var \XoopsNotificationHandler $notificationHandler */ |
|
80 | + $notificationHandler = xoops_getHandler('notification'); |
|
81 | + foreach (array_keys($topicsObject) as $id) { |
|
82 | + $topicObject = $topicsObject[$id]; |
|
83 | + $tags = []; |
|
84 | + $tags['THREAD_NAME'] = $topicObject->getVar('topic_title'); |
|
85 | + $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewtopic.php?topic_id=' . $id . '&forum=' . $topicObject->getVar('forum_id'); |
|
86 | + /** @var Newbb\Forum[] $forumsObject */ |
|
87 | + $tags['FORUM_NAME'] = $forumsObject[$topicObject->getVar('forum_id')]->getVar('forum_name'); |
|
88 | + $tags['FORUM_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewforum.php?forum=' . $topicObject->getVar('forum_id'); |
|
89 | + $notificationHandler->triggerEvent('global', 0, 'new_thread', $tags); |
|
90 | + $notificationHandler->triggerEvent('forum', $topicObject->getVar('forum_id'), 'new_thread', $tags); |
|
91 | + $postObject = $topicHandler->getTopPost($id); |
|
92 | + $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $postObject->getVar('post_id'); |
|
93 | + $notificationHandler->triggerEvent('thread', $id, 'new_post', $tags); |
|
94 | + $notificationHandler->triggerEvent('forum', $topicObject->getVar('forum_id'), 'new_post', $tags); |
|
95 | + $notificationHandler->triggerEvent('global', 0, 'new_post', $tags); |
|
96 | + $tags['POST_CONTENT'] = $postObject->getVar('post_text'); |
|
97 | + $tags['POST_NAME'] = $postObject->getVar('subject'); |
|
98 | + $notificationHandler->triggerEvent('global', 0, 'new_fullpost', $tags); |
|
99 | + $notificationHandler->triggerEvent('forum', $topicObject->getVar('forum_id'), 'new_fullpost', $tags); |
|
100 | + unset($postObject); |
|
101 | + } |
|
102 | + unset($topicsObject, $forumsObject); |
|
103 | + break; |
|
104 | + case 'delete': |
|
105 | + $forums = []; |
|
106 | + /** @var Newbb\TopicHandler|\XoopsPersistableObjectHandler $topicHandler */ |
|
107 | + $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
|
108 | + foreach (array_keys($topicsObject) as $id) { |
|
109 | + /** @var Newbb\Topic $topicObject */ |
|
110 | + $topicObject = $topicsObject[$id]; |
|
111 | + // irmtfan should be set to false to not delete topic from database |
|
112 | + $topicHandler->delete($topicObject, false); |
|
113 | + $topicHandler->synchronization($topicObject); |
|
114 | + $forums[$topicObject->getVar('forum_id')] = 1; |
|
115 | + } |
|
116 | 116 | |
117 | - $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
118 | - $forumsObject = $forumHandler->getAll($criteria_forum); |
|
119 | - foreach (array_keys($forumsObject) as $id) { |
|
120 | - $forumHandler->synchronization($forumsObject[$id]); |
|
121 | - } |
|
122 | - unset($topicsObject, $forumsObject); |
|
123 | - break; |
|
124 | - case 'move': |
|
125 | - if (Request::getInt('newforum', 0, 'POST') |
|
126 | - && Request::getInt('newforum', 0, 'POST') !== $forum_id |
|
127 | - && $forumHandler->getPermission(Request::getInt('newforum', 0, 'POST'), 'post')) { |
|
128 | - $criteria = new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN'); |
|
129 | - // /** @var Newbb\PostHandler $postHandler */ |
|
130 | - // $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
131 | - $postHandler->updateAll('forum_id', Request::getInt('newforum', 0, 'POST'), $criteria, true); |
|
132 | - $topicHandler->updateAll('forum_id', Request::getInt('newforum', 0, 'POST'), $criteria, true); |
|
133 | - $forumHandler->synchronization(Request::getInt('newforum', 0, 'POST')); |
|
134 | - $forumHandler->synchronization($forum_id); |
|
135 | - } else { |
|
136 | - include $GLOBALS['xoops']->path('header.php'); |
|
137 | - // /** @var Newbb\CategoryHandler $categoryHandler */ |
|
138 | - // $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
|
139 | - $categories = $categoryHandler->getByPermission('access'); |
|
140 | - $forums = $forumHandler->getForumsByCategory(array_keys($categories), 'post', false); |
|
117 | + $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
118 | + $forumsObject = $forumHandler->getAll($criteria_forum); |
|
119 | + foreach (array_keys($forumsObject) as $id) { |
|
120 | + $forumHandler->synchronization($forumsObject[$id]); |
|
121 | + } |
|
122 | + unset($topicsObject, $forumsObject); |
|
123 | + break; |
|
124 | + case 'move': |
|
125 | + if (Request::getInt('newforum', 0, 'POST') |
|
126 | + && Request::getInt('newforum', 0, 'POST') !== $forum_id |
|
127 | + && $forumHandler->getPermission(Request::getInt('newforum', 0, 'POST'), 'post')) { |
|
128 | + $criteria = new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN'); |
|
129 | + // /** @var Newbb\PostHandler $postHandler */ |
|
130 | + // $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
131 | + $postHandler->updateAll('forum_id', Request::getInt('newforum', 0, 'POST'), $criteria, true); |
|
132 | + $topicHandler->updateAll('forum_id', Request::getInt('newforum', 0, 'POST'), $criteria, true); |
|
133 | + $forumHandler->synchronization(Request::getInt('newforum', 0, 'POST')); |
|
134 | + $forumHandler->synchronization($forum_id); |
|
135 | + } else { |
|
136 | + include $GLOBALS['xoops']->path('header.php'); |
|
137 | + // /** @var Newbb\CategoryHandler $categoryHandler */ |
|
138 | + // $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
|
139 | + $categories = $categoryHandler->getByPermission('access'); |
|
140 | + $forums = $forumHandler->getForumsByCategory(array_keys($categories), 'post', false); |
|
141 | 141 | |
142 | - $box = '<select name="newforum" size="1">'; |
|
143 | - if (count($categories) > 0 && count($forums) > 0) { |
|
144 | - foreach (array_keys($forums) as $key) { |
|
142 | + $box = '<select name="newforum" size="1">'; |
|
143 | + if (count($categories) > 0 && count($forums) > 0) { |
|
144 | + foreach (array_keys($forums) as $key) { |
|
145 | 145 | |
146 | - /** @var Newbb\Category[] $categories */ |
|
147 | - $box .= "<option value='-1'>[" . $categories[$key]->getVar('cat_title') . ']</option>'; |
|
148 | - foreach ($forums[$key] as $forumid => $_forum) { |
|
149 | - $box .= "<option value='" . $forumid . "'>-- " . $_forum['title'] . '</option>'; |
|
150 | - if (!isset($_forum['sub'])) { |
|
151 | - continue; |
|
152 | - } |
|
153 | - foreach (array_keys($_forum['sub']) as $fid) { |
|
154 | - $box .= "<option value='" . $fid . "'>---- " . $_forum['sub'][$fid]['title'] . '</option>'; |
|
146 | + /** @var Newbb\Category[] $categories */ |
|
147 | + $box .= "<option value='-1'>[" . $categories[$key]->getVar('cat_title') . ']</option>'; |
|
148 | + foreach ($forums[$key] as $forumid => $_forum) { |
|
149 | + $box .= "<option value='" . $forumid . "'>-- " . $_forum['title'] . '</option>'; |
|
150 | + if (!isset($_forum['sub'])) { |
|
151 | + continue; |
|
152 | + } |
|
153 | + foreach (array_keys($_forum['sub']) as $fid) { |
|
154 | + $box .= "<option value='" . $fid . "'>---- " . $_forum['sub'][$fid]['title'] . '</option>'; |
|
155 | + } |
|
155 | 156 | } |
156 | 157 | } |
158 | + } else { |
|
159 | + $box .= "<option value='-1'>" . _MD_NEWBB_NOFORUMINDB . '</option>'; |
|
157 | 160 | } |
158 | - } else { |
|
159 | - $box .= "<option value='-1'>" . _MD_NEWBB_NOFORUMINDB . '</option>'; |
|
160 | - } |
|
161 | - $box .= '</select>'; |
|
162 | - unset($forums, $categories); |
|
161 | + $box .= '</select>'; |
|
162 | + unset($forums, $categories); |
|
163 | 163 | |
164 | - echo "<form action='" . Request::getString('PHP_SELF', '', 'SERVER') . "' method='post'>"; |
|
165 | - echo "<table border='0' cellpadding='1' cellspacing='0' align='center' width='95%'>"; |
|
166 | - echo "<tr><td class='bg2'>"; |
|
167 | - echo "<table border='0' cellpadding='1' cellspacing='1' width='100%'>"; |
|
168 | - echo '<tr><td class="bg3">' . _MD_NEWBB_MOVETOPICTO . '</td><td class="bg1">'; |
|
169 | - echo $box; |
|
170 | - echo '</td></tr>'; |
|
171 | - echo '<tr class="bg3"><td colspan="2" align="center">'; |
|
172 | - echo "<input type='hidden' name='op' value='move' />"; |
|
173 | - echo "<input type='hidden' name='forum_id' value='{$forum_id}' />"; |
|
174 | - foreach ($topic_id as $id) { |
|
175 | - echo "<input type='hidden' name='topic_id[]' value='" . $id . "' />"; |
|
164 | + echo "<form action='" . Request::getString('PHP_SELF', '', 'SERVER') . "' method='post'>"; |
|
165 | + echo "<table border='0' cellpadding='1' cellspacing='0' align='center' width='95%'>"; |
|
166 | + echo "<tr><td class='bg2'>"; |
|
167 | + echo "<table border='0' cellpadding='1' cellspacing='1' width='100%'>"; |
|
168 | + echo '<tr><td class="bg3">' . _MD_NEWBB_MOVETOPICTO . '</td><td class="bg1">'; |
|
169 | + echo $box; |
|
170 | + echo '</td></tr>'; |
|
171 | + echo '<tr class="bg3"><td colspan="2" align="center">'; |
|
172 | + echo "<input type='hidden' name='op' value='move' />"; |
|
173 | + echo "<input type='hidden' name='forum_id' value='{$forum_id}' />"; |
|
174 | + foreach ($topic_id as $id) { |
|
175 | + echo "<input type='hidden' name='topic_id[]' value='" . $id . "' />"; |
|
176 | + } |
|
177 | + echo "<input type='submit' name='submit' value='" . _SUBMIT . "' />"; |
|
178 | + echo '</td></tr></table></td></tr></table>'; |
|
179 | + echo '</form>'; |
|
180 | + include $GLOBALS['xoops']->path('footer.php'); |
|
181 | + exit(); |
|
176 | 182 | } |
177 | - echo "<input type='submit' name='submit' value='" . _SUBMIT . "' />"; |
|
178 | - echo '</td></tr></table></td></tr></table>'; |
|
179 | - echo '</form>'; |
|
180 | - include $GLOBALS['xoops']->path('footer.php'); |
|
181 | - exit(); |
|
182 | - } |
|
183 | - break; |
|
183 | + break; |
|
184 | 184 | } |
185 | 185 | ///** @var Newbb\StatsHandler $statsHandler */ |
186 | 186 | //$statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
@@ -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 | $forum_id = Request::getInt('forum_id', 0, 'POST'); |
18 | 18 | $topic_id = Request::getArray('topic_id', null, 'POST'); |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | $isAdmin = newbbIsAdmin($forum_id); |
35 | 35 | |
36 | 36 | if (!$isAdmin) { |
37 | - redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
37 | + redirect_header(XOOPS_URL.'/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS); |
|
38 | 38 | } |
39 | 39 | switch ($op) { |
40 | 40 | case 'restore': |
41 | 41 | $forums = []; |
42 | - $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
|
42 | + $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '('.implode(',', $topic_id).')', 'IN')); |
|
43 | 43 | foreach (array_keys($topicsObject) as $id) { |
44 | 44 | /** @var Newbb\Topic $topicObject */ |
45 | 45 | $topicObject = $topicsObject[$id]; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $topicHandler->synchronization($topicObject); |
48 | 48 | $forums[$topicObject->getVar('forum_id')] = 1; |
49 | 49 | } |
50 | - $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
50 | + $criteria_forum = new \Criteria('forum_id', '('.implode(',', array_keys($forums)).')', 'IN'); |
|
51 | 51 | $forumsObject = $forumHandler->getAll($criteria_forum); |
52 | 52 | foreach (array_keys($forumsObject) as $id) { |
53 | 53 | $forumHandler->synchronization($forumsObject[$id]); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | break; |
57 | 57 | case 'approve': |
58 | 58 | $forums = []; |
59 | - $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
|
59 | + $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '('.implode(',', $topic_id).')', 'IN')); |
|
60 | 60 | foreach (array_keys($topicsObject) as $id) { |
61 | 61 | /** @var Newbb\Topic $topicObject */ |
62 | 62 | $topicObject = $topicsObject[$id]; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $forums[$topicObject->getVar('forum_id')] = 1; |
66 | 66 | } |
67 | 67 | |
68 | - $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
68 | + $criteria_forum = new \Criteria('forum_id', '('.implode(',', array_keys($forums)).')', 'IN'); |
|
69 | 69 | $forumsObject = $forumHandler->getAll($criteria_forum); |
70 | 70 | foreach (array_keys($forumsObject) as $id) { |
71 | 71 | $forumHandler->synchronization($forumsObject[$id]); |
@@ -75,21 +75,21 @@ discard block |
||
75 | 75 | break; |
76 | 76 | } |
77 | 77 | |
78 | - require_once __DIR__ . '/include/notification.inc.php'; |
|
78 | + require_once __DIR__.'/include/notification.inc.php'; |
|
79 | 79 | /** @var \XoopsNotificationHandler $notificationHandler */ |
80 | 80 | $notificationHandler = xoops_getHandler('notification'); |
81 | 81 | foreach (array_keys($topicsObject) as $id) { |
82 | 82 | $topicObject = $topicsObject[$id]; |
83 | 83 | $tags = []; |
84 | 84 | $tags['THREAD_NAME'] = $topicObject->getVar('topic_title'); |
85 | - $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewtopic.php?topic_id=' . $id . '&forum=' . $topicObject->getVar('forum_id'); |
|
85 | + $tags['THREAD_URL'] = XOOPS_URL.'/modules/'.$moduleDirName.'/viewtopic.php?topic_id='.$id.'&forum='.$topicObject->getVar('forum_id'); |
|
86 | 86 | /** @var Newbb\Forum[] $forumsObject */ |
87 | 87 | $tags['FORUM_NAME'] = $forumsObject[$topicObject->getVar('forum_id')]->getVar('forum_name'); |
88 | - $tags['FORUM_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewforum.php?forum=' . $topicObject->getVar('forum_id'); |
|
88 | + $tags['FORUM_URL'] = XOOPS_URL.'/modules/'.$moduleDirName.'/viewforum.php?forum='.$topicObject->getVar('forum_id'); |
|
89 | 89 | $notificationHandler->triggerEvent('global', 0, 'new_thread', $tags); |
90 | 90 | $notificationHandler->triggerEvent('forum', $topicObject->getVar('forum_id'), 'new_thread', $tags); |
91 | 91 | $postObject = $topicHandler->getTopPost($id); |
92 | - $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $postObject->getVar('post_id'); |
|
92 | + $tags['POST_URL'] = $tags['THREAD_URL'].'#forumpost'.$postObject->getVar('post_id'); |
|
93 | 93 | $notificationHandler->triggerEvent('thread', $id, 'new_post', $tags); |
94 | 94 | $notificationHandler->triggerEvent('forum', $topicObject->getVar('forum_id'), 'new_post', $tags); |
95 | 95 | $notificationHandler->triggerEvent('global', 0, 'new_post', $tags); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | case 'delete': |
105 | 105 | $forums = []; |
106 | 106 | /** @var Newbb\TopicHandler|\XoopsPersistableObjectHandler $topicHandler */ |
107 | - $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
|
107 | + $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '('.implode(',', $topic_id).')', 'IN')); |
|
108 | 108 | foreach (array_keys($topicsObject) as $id) { |
109 | 109 | /** @var Newbb\Topic $topicObject */ |
110 | 110 | $topicObject = $topicsObject[$id]; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $forums[$topicObject->getVar('forum_id')] = 1; |
115 | 115 | } |
116 | 116 | |
117 | - $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
117 | + $criteria_forum = new \Criteria('forum_id', '('.implode(',', array_keys($forums)).')', 'IN'); |
|
118 | 118 | $forumsObject = $forumHandler->getAll($criteria_forum); |
119 | 119 | foreach (array_keys($forumsObject) as $id) { |
120 | 120 | $forumHandler->synchronization($forumsObject[$id]); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | if (Request::getInt('newforum', 0, 'POST') |
126 | 126 | && Request::getInt('newforum', 0, 'POST') !== $forum_id |
127 | 127 | && $forumHandler->getPermission(Request::getInt('newforum', 0, 'POST'), 'post')) { |
128 | - $criteria = new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN'); |
|
128 | + $criteria = new \Criteria('topic_id', '('.implode(',', $topic_id).')', 'IN'); |
|
129 | 129 | // /** @var Newbb\PostHandler $postHandler */ |
130 | 130 | // $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
131 | 131 | $postHandler->updateAll('forum_id', Request::getInt('newforum', 0, 'POST'), $criteria, true); |
@@ -144,37 +144,37 @@ discard block |
||
144 | 144 | foreach (array_keys($forums) as $key) { |
145 | 145 | |
146 | 146 | /** @var Newbb\Category[] $categories */ |
147 | - $box .= "<option value='-1'>[" . $categories[$key]->getVar('cat_title') . ']</option>'; |
|
147 | + $box .= "<option value='-1'>[".$categories[$key]->getVar('cat_title').']</option>'; |
|
148 | 148 | foreach ($forums[$key] as $forumid => $_forum) { |
149 | - $box .= "<option value='" . $forumid . "'>-- " . $_forum['title'] . '</option>'; |
|
149 | + $box .= "<option value='".$forumid."'>-- ".$_forum['title'].'</option>'; |
|
150 | 150 | if (!isset($_forum['sub'])) { |
151 | 151 | continue; |
152 | 152 | } |
153 | 153 | foreach (array_keys($_forum['sub']) as $fid) { |
154 | - $box .= "<option value='" . $fid . "'>---- " . $_forum['sub'][$fid]['title'] . '</option>'; |
|
154 | + $box .= "<option value='".$fid."'>---- ".$_forum['sub'][$fid]['title'].'</option>'; |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | } |
158 | 158 | } else { |
159 | - $box .= "<option value='-1'>" . _MD_NEWBB_NOFORUMINDB . '</option>'; |
|
159 | + $box .= "<option value='-1'>"._MD_NEWBB_NOFORUMINDB.'</option>'; |
|
160 | 160 | } |
161 | 161 | $box .= '</select>'; |
162 | 162 | unset($forums, $categories); |
163 | 163 | |
164 | - echo "<form action='" . Request::getString('PHP_SELF', '', 'SERVER') . "' method='post'>"; |
|
164 | + echo "<form action='".Request::getString('PHP_SELF', '', 'SERVER')."' method='post'>"; |
|
165 | 165 | echo "<table border='0' cellpadding='1' cellspacing='0' align='center' width='95%'>"; |
166 | 166 | echo "<tr><td class='bg2'>"; |
167 | 167 | echo "<table border='0' cellpadding='1' cellspacing='1' width='100%'>"; |
168 | - echo '<tr><td class="bg3">' . _MD_NEWBB_MOVETOPICTO . '</td><td class="bg1">'; |
|
168 | + echo '<tr><td class="bg3">'._MD_NEWBB_MOVETOPICTO.'</td><td class="bg1">'; |
|
169 | 169 | echo $box; |
170 | 170 | echo '</td></tr>'; |
171 | 171 | echo '<tr class="bg3"><td colspan="2" align="center">'; |
172 | 172 | echo "<input type='hidden' name='op' value='move' />"; |
173 | 173 | echo "<input type='hidden' name='forum_id' value='{$forum_id}' />"; |
174 | 174 | foreach ($topic_id as $id) { |
175 | - echo "<input type='hidden' name='topic_id[]' value='" . $id . "' />"; |
|
175 | + echo "<input type='hidden' name='topic_id[]' value='".$id."' />"; |
|
176 | 176 | } |
177 | - echo "<input type='submit' name='submit' value='" . _SUBMIT . "' />"; |
|
177 | + echo "<input type='submit' name='submit' value='"._SUBMIT."' />"; |
|
178 | 178 | echo '</td></tr></table></td></tr></table>'; |
179 | 179 | echo '</form>'; |
180 | 180 | include $GLOBALS['xoops']->path('footer.php'); |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | //$statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
187 | 187 | $statsHandler->reset(); |
188 | 188 | if (empty($forum_id)) { |
189 | - redirect_header(XOOPS_URL . '/modules/newbb/list.topic.php', 2, _MD_NEWBB_DBUPDATED); |
|
189 | + redirect_header(XOOPS_URL.'/modules/newbb/list.topic.php', 2, _MD_NEWBB_DBUPDATED); |
|
190 | 190 | } else { |
191 | - redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?forum={$forum_id}", 2, _MD_NEWBB_DBUPDATED); |
|
191 | + redirect_header(XOOPS_URL."/modules/newbb/viewforum.php?forum={$forum_id}", 2, _MD_NEWBB_DBUPDATED); |
|
192 | 192 | } |
193 | 193 | // irmtfan move to footer.php |
194 | -require_once __DIR__ . '/footer.php'; |
|
194 | +require_once __DIR__.'/footer.php'; |
|
195 | 195 | include $GLOBALS['xoops']->path('footer.php'); |
@@ -22,15 +22,15 @@ |
||
22 | 22 | require_once __DIR__ . '/header.php'; |
23 | 23 | |
24 | 24 | foreach ([ |
25 | - 'forum', |
|
26 | - 'topic_id', |
|
27 | - 'post_id', |
|
28 | - 'order', |
|
29 | - 'pid', |
|
30 | - 'start', |
|
31 | - 'isreply', |
|
32 | - 'isedit' |
|
33 | - ] as $getint) { |
|
25 | + 'forum', |
|
26 | + 'topic_id', |
|
27 | + 'post_id', |
|
28 | + 'order', |
|
29 | + 'pid', |
|
30 | + 'start', |
|
31 | + 'isreply', |
|
32 | + 'isedit' |
|
33 | + ] as $getint) { |
|
34 | 34 | ${$getint} = Request::getInt($getint, 0, 'POST'); |
35 | 35 | } |
36 | 36 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | use Xmf\Request; |
20 | 20 | use XoopsModules\Newbb; |
21 | 21 | |
22 | -require_once __DIR__ . '/header.php'; |
|
22 | +require_once __DIR__.'/header.php'; |
|
23 | 23 | |
24 | 24 | foreach ([ |
25 | 25 | 'forum', |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | || ($postObject->checkTimelimit('edit_timelimit') |
148 | 148 | && $postObject->checkIdentity()))) { |
149 | 149 | } else { |
150 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum={$forum_id}&topic_id={$topic_id}&post_id={$post_id}&order={$order}&viewmode={$viewmode}", 2, _MD_NEWBB_NORIGHTTOEDIT); |
|
150 | + redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?forum={$forum_id}&topic_id={$topic_id}&post_id={$post_id}&order={$order}&viewmode={$viewmode}", 2, _MD_NEWBB_NORIGHTTOEDIT); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $delete_attach = Request::getArray('delete_attach', [], 'POST'); |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | if ($topic_id) { |
159 | 159 | $topic_status = $topicObject->getVar('topic_status'); |
160 | 160 | if (!$topicHandler->getPermission($forumObject, $topic_status, 'reply')) { |
161 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum={$forum_id}&topic_id={$topic_id}&post_id={$post_id}&order={$order}&viewmode={$viewmode}", 2, _MD_NEWBB_NORIGHTTOREPLY); |
|
161 | + redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?forum={$forum_id}&topic_id={$topic_id}&post_id={$post_id}&order={$order}&viewmode={$viewmode}", 2, _MD_NEWBB_NORIGHTTOREPLY); |
|
162 | 162 | } |
163 | 163 | } else { |
164 | 164 | $topic_status = 0; |
165 | 165 | if (!$topicHandler->getPermission($forumObject, $topic_status, 'post')) { |
166 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum={$forum_id}", 2, _MD_NEWBB_NORIGHTTOPOST); |
|
166 | + redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?forum={$forum_id}", 2, _MD_NEWBB_NORIGHTTOPOST); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $doxcode = Request::getInt('doxcode', 0, 'POST') ? 1 : 0; |
203 | 203 | $dobr = Request::getInt('dobr', 0, 'POST') ? 1 : 0; |
204 | 204 | $icon = (Request::getString('icon', '', 'POST') |
205 | - && is_file($GLOBALS['xoops']->path('images/subject/' . Request::getString('icon', '', 'POST'))) ? Request::getString('icon', '', 'POST') : ''); |
|
205 | + && is_file($GLOBALS['xoops']->path('images/subject/'.Request::getString('icon', '', 'POST'))) ? Request::getString('icon', '', 'POST') : ''); |
|
206 | 206 | $attachsig = Request::getBool('attachsig', false, 'POST') |
207 | 207 | && $topicHandler->getPermission($forumObject, $topic_status, 'signature'); |
208 | 208 | $view_require = Request::getString('view_require', '', 'POST'); |
@@ -235,14 +235,14 @@ discard block |
||
235 | 235 | $attachments_tmp = unserialize(base64_decode(Request::getString('attachments_tmp', '', 'POST'))); |
236 | 236 | if (Request::getArray('delete_tmp', null, 'POST') && count(Request::getArray('delete_tmp', null, 'POST')) > 1) { |
237 | 237 | foreach (Request::getArray('delete_tmp', null, 'POST') as $key) { |
238 | - unlink($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attachments_tmp[$key][0])); |
|
238 | + unlink($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'].'/'.$attachments_tmp[$key][0])); |
|
239 | 239 | unset($attachments_tmp[$key]); |
240 | 240 | } |
241 | 241 | } |
242 | 242 | } |
243 | 243 | if (isset($attachments_tmp) && count($attachments_tmp)) { |
244 | 244 | foreach ($attachments_tmp as $key => $attach) { |
245 | - if (rename(XOOPS_CACHE_PATH . '/' . $attachments_tmp[$key][0], $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attachments_tmp[$key][0]))) { |
|
245 | + if (rename(XOOPS_CACHE_PATH.'/'.$attachments_tmp[$key][0], $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'].'/'.$attachments_tmp[$key][0]))) { |
|
246 | 246 | $postObject->setAttachment($attach[0], $attach[1], $attach[2]); |
247 | 247 | } |
248 | 248 | } |
@@ -273,13 +273,13 @@ discard block |
||
273 | 273 | $uploader->setCheckMediaTypeByExt(); |
274 | 274 | $temp = Request::getArray('xoops_upload_file', [], 'POST'); |
275 | 275 | if ($uploader->fetchMedia($temp[0])) { |
276 | - $prefix = is_object($GLOBALS['xoopsUser']) ? (string)$GLOBALS['xoopsUser']->uid() . '_' : 'newbb_'; |
|
276 | + $prefix = is_object($GLOBALS['xoopsUser']) ? (string)$GLOBALS['xoopsUser']->uid().'_' : 'newbb_'; |
|
277 | 277 | $uploader->setPrefix($prefix); |
278 | 278 | if (!$uploader->upload()) { |
279 | 279 | $error_message[] = $error_upload = $uploader->getErrors(); |
280 | 280 | } else { |
281 | 281 | if (is_file($uploader->getSavedDestination())) { |
282 | - if (rename(XOOPS_CACHE_PATH . '/' . $uploader->getSavedFileName(), $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $uploader->getSavedFileName()))) { |
|
282 | + if (rename(XOOPS_CACHE_PATH.'/'.$uploader->getSavedFileName(), $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'].'/'.$uploader->getSavedFileName()))) { |
|
283 | 283 | $postObject->setAttachment($uploader->getSavedFileName(), $uploader->getMediaName(), $uploader->getMediaType()); |
284 | 284 | } |
285 | 285 | } |
@@ -327,9 +327,9 @@ discard block |
||
327 | 327 | if (!empty($isnew) && $approved && !empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) { |
328 | 328 | $tags = []; |
329 | 329 | $tags['THREAD_NAME'] = Request::getString('subject', '', 'POST'); |
330 | - $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?post_id=' . $postid; |
|
330 | + $tags['THREAD_URL'] = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/viewtopic.php?post_id='.$postid; |
|
331 | 331 | $tags['POST_URL'] = $tags['THREAD_URL']; // . '#forumpost' . $postid; |
332 | - require_once __DIR__ . '/include/notification.inc.php'; |
|
332 | + require_once __DIR__.'/include/notification.inc.php'; |
|
333 | 333 | $forum_info = newbb_notify_iteminfo('forum', $forumObject->getVar('forum_id')); |
334 | 334 | $tags['FORUM_NAME'] = $forum_info['name']; |
335 | 335 | $tags['FORUM_URL'] = $forum_info['url']; |
@@ -368,34 +368,34 @@ discard block |
||
368 | 368 | |
369 | 369 | if ($approved) { |
370 | 370 | if (!empty($GLOBALS['xoopsModuleConfig']['cache_enabled'])) { |
371 | - newbbSetSession('t' . $postObject->getVar('topic_id'), null); |
|
371 | + newbbSetSession('t'.$postObject->getVar('topic_id'), null); |
|
372 | 372 | } |
373 | 373 | // Update user |
374 | 374 | if ($uid > 0) { |
375 | - $sql = 'SELECT count(*)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE approved=1 AND topic_poster =' . $uid; |
|
375 | + $sql = 'SELECT count(*)'.' FROM '.$GLOBALS['xoopsDB']->prefix('newbb_topics').' WHERE approved=1 AND topic_poster ='.$uid; |
|
376 | 376 | $ret = $GLOBALS['xoopsDB']->query($sql); |
377 | 377 | list($topics) = $GLOBALS['xoopsDB']->fetchRow($ret); |
378 | 378 | |
379 | - $sql = ' SELECT count(*)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE approved=1 AND topic_digest > 0 AND topic_poster =' . $uid; |
|
379 | + $sql = ' SELECT count(*)'.' FROM '.$GLOBALS['xoopsDB']->prefix('newbb_topics').' WHERE approved=1 AND topic_digest > 0 AND topic_poster ='.$uid; |
|
380 | 380 | $ret = $GLOBALS['xoopsDB']->query($sql); |
381 | 381 | list($digests) = $GLOBALS['xoopsDB']->fetchRow($ret); |
382 | 382 | |
383 | - $sql = ' SELECT count(*), MAX(post_time)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE approved=1 AND uid =' . $uid; |
|
383 | + $sql = ' SELECT count(*), MAX(post_time)'.' FROM '.$GLOBALS['xoopsDB']->prefix('newbb_posts').' WHERE approved=1 AND uid ='.$uid; |
|
384 | 384 | $ret = $GLOBALS['xoopsDB']->query($sql); |
385 | 385 | list($posts, $lastpost) = $GLOBALS['xoopsDB']->fetchRow($ret); |
386 | 386 | |
387 | - $GLOBALS['xoopsDB']->queryF(' REPLACE INTO ' . $GLOBALS['xoopsDB']->prefix('newbb_user_stats') . " SET uid = '{$uid}', user_topics = '{$topics}', user_posts = '{$posts}', user_digests = '{$digests}', user_lastpost = '{$lastpost}'"); |
|
387 | + $GLOBALS['xoopsDB']->queryF(' REPLACE INTO '.$GLOBALS['xoopsDB']->prefix('newbb_user_stats')." SET uid = '{$uid}', user_topics = '{$topics}', user_posts = '{$posts}', user_digests = '{$digests}', user_lastpost = '{$lastpost}'"); |
|
388 | 388 | } |
389 | 389 | |
390 | - $redirect = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $postid; |
|
391 | - $message = _MD_NEWBB_THANKSSUBMIT . '<br>' . $error_upload; |
|
390 | + $redirect = XOOPS_URL.'/modules/newbb/viewtopic.php?post_id='.$postid; |
|
391 | + $message = _MD_NEWBB_THANKSSUBMIT.'<br>'.$error_upload; |
|
392 | 392 | } else { |
393 | - $redirect = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $postObject->getVar('forum_id'); |
|
394 | - $message = _MD_NEWBB_THANKSSUBMIT . '<br>' . _MD_NEWBB_WAITFORAPPROVAL . '<br>' . $error_upload; |
|
393 | + $redirect = XOOPS_URL.'/modules/newbb/viewforum.php?forum='.$postObject->getVar('forum_id'); |
|
394 | + $message = _MD_NEWBB_THANKSSUBMIT.'<br>'._MD_NEWBB_WAITFORAPPROVAL.'<br>'.$error_upload; |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | if ('add' === $op) { |
398 | - redirect_header(XOOPS_URL . '/modules/newbb/polls.php?op=add&forum=' . $postObject->getVar('forum_id') . '&topic_id=' . $postObject->getVar('topic_id'), 1, _MD_NEWBB_ADDPOLL); |
|
398 | + redirect_header(XOOPS_URL.'/modules/newbb/polls.php?op=add&forum='.$postObject->getVar('forum_id').'&topic_id='.$postObject->getVar('topic_id'), 1, _MD_NEWBB_ADDPOLL); |
|
399 | 399 | } else { |
400 | 400 | redirect_header($redirect, 2, $message); |
401 | 401 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | $attachments_tmp = unserialize(base64_decode(Request::getArray('attachments_tmp', [], 'POST'))); |
416 | 416 | if (Request::getArray('delete_tmp', null, 'POST') && count(Request::getArray('delete_tmp', null, 'POST'))) { |
417 | 417 | foreach (Request::getArray('delete_tmp', '', 'POST') as $key) { |
418 | - unlink($uploaddir = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attachments_tmp[$key][0])); |
|
418 | + unlink($uploaddir = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'].'/'.$attachments_tmp[$key][0])); |
|
419 | 419 | unset($attachments_tmp[$key]); |
420 | 420 | } |
421 | 421 | } |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | $uploader->setCheckMediaTypeByExt(); |
445 | 445 | $temp = Request::getArray('xoops_upload_file', [], 'POST'); |
446 | 446 | if ($uploader->fetchMedia($temp[0])) { |
447 | - $prefix = is_object($GLOBALS['xoopsUser']) ? (string)$GLOBALS['xoopsUser']->uid() . '_' : 'newbb_'; |
|
447 | + $prefix = is_object($GLOBALS['xoopsUser']) ? (string)$GLOBALS['xoopsUser']->uid().'_' : 'newbb_'; |
|
448 | 448 | $uploader->setPrefix($prefix); |
449 | 449 | if (!$uploader->upload()) { |
450 | 450 | $error_message[] = $error_upload = $uploader->getErrors(); |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | |
494 | 494 | $post_preview = [ |
495 | 495 | 'subject' => $p_subject, |
496 | - 'meta' => _MD_NEWBB_BY . ' ' . $p_name . ' ' . _MD_NEWBB_ON . ' ' . $p_date, |
|
496 | + 'meta' => _MD_NEWBB_BY.' '.$p_name.' '._MD_NEWBB_ON.' '.$p_date, |
|
497 | 497 | 'content' => $p_message |
498 | 498 | ]; |
499 | 499 | $xoopsTpl->assign_by_ref('post_preview', $post_preview); |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | $poster_name = Request::getString('poster_name', '', 'POST'); |
513 | 513 | $hidden = Request::getString('hidden', '', 'POST'); |
514 | 514 | $notify = Request::getInt('notify', 0, 'POST'); |
515 | - $attachsig = Request::getInt('attachsig', 0, 'POST');//!empty($_POST['attachsig']) ? 1 : 0; |
|
515 | + $attachsig = Request::getInt('attachsig', 0, 'POST'); //!empty($_POST['attachsig']) ? 1 : 0; |
|
516 | 516 | $isreply = Request::getInt('isreply', 0, 'POST'); //!empty($_POST['isreply']) ? 1 : 0; |
517 | 517 | $isedit = Request::getInt('isedit', 0, 'POST'); //!empty($_POST['isedit']) ? 1 : 0; |
518 | 518 | $icon = (Request::getString('icon', '', 'POST') |
519 | - && is_file($GLOBALS['xoops']->path('images/subject/' . Request::getString('icon', '', 'POST'))) ? Request::getString('icon', '', 'POST') : ''); |
|
519 | + && is_file($GLOBALS['xoops']->path('images/subject/'.Request::getString('icon', '', 'POST'))) ? Request::getString('icon', '', 'POST') : ''); |
|
520 | 520 | $view_require = Request::getString('view_require', '', 'POST'); |
521 | 521 | $post_karma = (('require_karma' === $view_require) |
522 | 522 | && !Request::getInt('post_karma', 0, 'POST')) ? Request::getInt('post_karma', 0, 'POST') : 0; |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | $attachments = $postObject->getAttachment(); |
529 | 529 | $xoopsTpl->assign('error_message', implode('<br>', $error_message)); |
530 | 530 | |
531 | - include __DIR__ . '/include/form.post.php'; |
|
531 | + include __DIR__.'/include/form.post.php'; |
|
532 | 532 | } |
533 | 533 | // irmtfan move to footer.php |
534 | -require_once __DIR__ . '/footer.php'; |
|
534 | +require_once __DIR__.'/footer.php'; |
|
535 | 535 | include $GLOBALS['xoops']->path('footer.php'); |