@@ -35,25 +35,25 @@ discard block |
||
35 | 35 | require_once __DIR__ . '/header.php'; |
36 | 36 | |
37 | 37 | if (Request::getString('submit', '', 'POST')) { |
38 | - foreach (['forum', 'newforum', 'newtopic'] as $getint) { |
|
39 | - ${$getint} = Request::getInt($getint, 0, 'POST');// (int)(@$_POST[$getint]); |
|
40 | - } |
|
41 | - foreach (['topic_id'] as $getint) { |
|
42 | - ${$getint} = Request::getInt($getint, 0, 'POST');// (int)(@$_POST[$getint]); |
|
43 | - } |
|
44 | - if (!is_array($topic_id)) { |
|
45 | - $topic_id = [$topic_id]; |
|
46 | - } |
|
38 | + foreach (['forum', 'newforum', 'newtopic'] as $getint) { |
|
39 | + ${$getint} = Request::getInt($getint, 0, 'POST');// (int)(@$_POST[$getint]); |
|
40 | + } |
|
41 | + foreach (['topic_id'] as $getint) { |
|
42 | + ${$getint} = Request::getInt($getint, 0, 'POST');// (int)(@$_POST[$getint]); |
|
43 | + } |
|
44 | + if (!is_array($topic_id)) { |
|
45 | + $topic_id = [$topic_id]; |
|
46 | + } |
|
47 | 47 | } else { |
48 | - foreach (['forum', 'topic_id'] as $getint) { |
|
49 | - ${$getint} = Request::getInt($getint, 0, 'GET');// (int)(@$_GET[$getint]); |
|
50 | - } |
|
48 | + foreach (['forum', 'topic_id'] as $getint) { |
|
49 | + ${$getint} = Request::getInt($getint, 0, 'GET');// (int)(@$_GET[$getint]); |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | if (empty($topic_id)) { |
54 | - $redirect = empty($forum_id) ? 'index.php' : 'viewforum.php?forum={$forum}'; |
|
55 | - $redirect = XOOPS_URL . '/modules/newbb/' . $redirect; |
|
56 | - redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
|
54 | + $redirect = empty($forum_id) ? 'index.php' : 'viewforum.php?forum={$forum}'; |
|
55 | + $redirect = XOOPS_URL . '/modules/newbb/' . $redirect; |
|
56 | + redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | ///** @var Newbb\TopicHandler $topicHandler */ |
@@ -62,43 +62,43 @@ discard block |
||
62 | 62 | //$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
63 | 63 | |
64 | 64 | if (!$forum) { |
65 | - /** @var Newbb\Topic $topicObject */ |
|
66 | - $topicObject = $topicHandler->get((int)$topic_id); |
|
67 | - if (is_object($topicObject)) { |
|
68 | - $forum = $topicObject->getVar('forum_id'); |
|
69 | - } else { |
|
70 | - $redirect = XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $topic_id; |
|
71 | - redirect_header($redirect, 2, _MD_NEWBB_FORUMNOEXIST); |
|
72 | - } |
|
73 | - unset($topicObject); |
|
65 | + /** @var Newbb\Topic $topicObject */ |
|
66 | + $topicObject = $topicHandler->get((int)$topic_id); |
|
67 | + if (is_object($topicObject)) { |
|
68 | + $forum = $topicObject->getVar('forum_id'); |
|
69 | + } else { |
|
70 | + $redirect = XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $topic_id; |
|
71 | + redirect_header($redirect, 2, _MD_NEWBB_FORUMNOEXIST); |
|
72 | + } |
|
73 | + unset($topicObject); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
77 | - // /** @var Newbb\OnlineHandler $onlineHandler */ |
|
78 | - // $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
79 | - $onlineHandler->init($forum); |
|
77 | + // /** @var Newbb\OnlineHandler $onlineHandler */ |
|
78 | + // $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
79 | + $onlineHandler->init($forum); |
|
80 | 80 | } |
81 | 81 | // irmtfan add restore to viewtopic |
82 | 82 | $action_array = [ |
83 | - 'merge', |
|
84 | - 'delete', |
|
85 | - 'restore', |
|
86 | - 'move', |
|
87 | - 'lock', |
|
88 | - 'unlock', |
|
89 | - 'sticky', |
|
90 | - 'unsticky', |
|
91 | - 'digest', |
|
92 | - 'undigest' |
|
83 | + 'merge', |
|
84 | + 'delete', |
|
85 | + 'restore', |
|
86 | + 'move', |
|
87 | + 'lock', |
|
88 | + 'unlock', |
|
89 | + 'sticky', |
|
90 | + 'unsticky', |
|
91 | + 'digest', |
|
92 | + 'undigest' |
|
93 | 93 | ]; |
94 | 94 | foreach ($action_array as $_action) { |
95 | - $action[$_action] = [ |
|
96 | - 'name' => $_action, |
|
97 | - 'desc' => constant(strtoupper("_MD_NEWBB_DESC_{$_action}")), |
|
98 | - 'submit' => constant(strtoupper("_MD_NEWBB_{$_action}")), |
|
99 | - 'sql' => "topic_{$_action}=1", |
|
100 | - 'msg' => constant(strtoupper("_MD_NEWBB_TOPIC{$_action}")) |
|
101 | - ]; |
|
95 | + $action[$_action] = [ |
|
96 | + 'name' => $_action, |
|
97 | + 'desc' => constant(strtoupper("_MD_NEWBB_DESC_{$_action}")), |
|
98 | + 'submit' => constant(strtoupper("_MD_NEWBB_{$_action}")), |
|
99 | + 'sql' => "topic_{$_action}=1", |
|
100 | + 'msg' => constant(strtoupper("_MD_NEWBB_TOPIC{$_action}")) |
|
101 | + ]; |
|
102 | 102 | } |
103 | 103 | $action['lock']['sql'] = 'topic_status = 1'; |
104 | 104 | $action['unlock']['sql'] = 'topic_status = 0'; |
@@ -112,269 +112,269 @@ discard block |
||
112 | 112 | require_once $GLOBALS['xoops']->path('header.php'); |
113 | 113 | |
114 | 114 | if (Request::getString('submit', '', 'POST')) { |
115 | - $mode = Request::getString('mode', '', 'POST');// $_POST['mode']; |
|
115 | + $mode = Request::getString('mode', '', 'POST');// $_POST['mode']; |
|
116 | 116 | |
117 | - if ('delete' === $mode) { |
|
118 | - foreach ($topic_id as $tid) { |
|
119 | - $topicObject = $topicHandler->get($tid); |
|
120 | - $topicHandler->delete($topicObject, false); |
|
121 | - // irmtfan - sync topic after delete |
|
122 | - $topicHandler->synchronization($topicObject); |
|
123 | - $forumHandler->synchronization($forum); |
|
124 | - //$topicObject->loadFilters("delete"); |
|
125 | - //sync($topic_id, "topic"); |
|
126 | - //xoops_notification_deletebyitem ($xoopsModule->getVar('mid'), 'thread', $topic_id); |
|
127 | - } |
|
128 | - // irmtfan full URL |
|
129 | - echo $action[$mode]['msg'] . "<p><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum=$forum'>" . _MD_NEWBB_RETURNTOTHEFORUM . "</a></p><p><a href='index.php'>" . _MD_NEWBB_RETURNFORUMINDEX . '</a></p>'; |
|
130 | - } elseif ('restore' === $mode) { |
|
131 | - //$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
132 | - $forums = []; |
|
133 | - $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
|
134 | - foreach (array_keys($topicsObject) as $id) { |
|
135 | - $topicObject = $topicsObject[$id]; |
|
136 | - $topicHandler->approve($topicObject); |
|
137 | - $topicHandler->synchronization($topicObject); |
|
138 | - $forums[$topicObject->getVar('forum_id')] = 1; |
|
139 | - } |
|
140 | - //irmtfan remove - no need to approve posts manually - see class/post.php approve function |
|
141 | - $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
142 | - $forumsObject = $forumHandler->getAll($criteria_forum); |
|
143 | - foreach (array_keys($forumsObject) as $id) { |
|
144 | - $forumHandler->synchronization($forumsObject[$id]); |
|
145 | - } |
|
146 | - unset($topicsObject, $forumsObject); |
|
147 | - // irmtfan add restore to viewtopic |
|
148 | - $restoretopic_id = $topicObject->getVar('topic_id'); |
|
149 | - // irmtfan / missing in URL |
|
150 | - echo $action[$mode]['msg'] |
|
151 | - . "<p><a href='" |
|
152 | - . XOOPS_URL |
|
153 | - . '/modules/' |
|
154 | - . $xoopsModule->getVar('dirname') |
|
155 | - . "/viewtopic.php?topic_id=$restoretopic_id'>" |
|
156 | - . _MD_NEWBB_VIEWTHETOPIC |
|
157 | - . '</a></p>' |
|
158 | - . "<p><a href='" |
|
159 | - . XOOPS_URL |
|
160 | - . '/modules/' |
|
161 | - . $xoopsModule->getVar('dirname') |
|
162 | - . "/viewforum.php?forum=$forum'>" |
|
163 | - . _MD_NEWBB_RETURNTOTHEFORUM |
|
164 | - . '</a></p>' |
|
165 | - . "<p><a href='index.php'>" |
|
166 | - . _MD_NEWBB_RETURNFORUMINDEX |
|
167 | - . '</a></p>'; |
|
168 | - } elseif ('merge' === $mode) { |
|
169 | - // /** @var PostHandler $postHandler */ |
|
170 | - // $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
171 | - // /** @var Newbb\RateHandler $rateHandler */ |
|
172 | - // $rateHandler = Newbb\Helper::getInstance()->getHandler('Rate'); |
|
117 | + if ('delete' === $mode) { |
|
118 | + foreach ($topic_id as $tid) { |
|
119 | + $topicObject = $topicHandler->get($tid); |
|
120 | + $topicHandler->delete($topicObject, false); |
|
121 | + // irmtfan - sync topic after delete |
|
122 | + $topicHandler->synchronization($topicObject); |
|
123 | + $forumHandler->synchronization($forum); |
|
124 | + //$topicObject->loadFilters("delete"); |
|
125 | + //sync($topic_id, "topic"); |
|
126 | + //xoops_notification_deletebyitem ($xoopsModule->getVar('mid'), 'thread', $topic_id); |
|
127 | + } |
|
128 | + // irmtfan full URL |
|
129 | + echo $action[$mode]['msg'] . "<p><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum=$forum'>" . _MD_NEWBB_RETURNTOTHEFORUM . "</a></p><p><a href='index.php'>" . _MD_NEWBB_RETURNFORUMINDEX . '</a></p>'; |
|
130 | + } elseif ('restore' === $mode) { |
|
131 | + //$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
132 | + $forums = []; |
|
133 | + $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
|
134 | + foreach (array_keys($topicsObject) as $id) { |
|
135 | + $topicObject = $topicsObject[$id]; |
|
136 | + $topicHandler->approve($topicObject); |
|
137 | + $topicHandler->synchronization($topicObject); |
|
138 | + $forums[$topicObject->getVar('forum_id')] = 1; |
|
139 | + } |
|
140 | + //irmtfan remove - no need to approve posts manually - see class/post.php approve function |
|
141 | + $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
|
142 | + $forumsObject = $forumHandler->getAll($criteria_forum); |
|
143 | + foreach (array_keys($forumsObject) as $id) { |
|
144 | + $forumHandler->synchronization($forumsObject[$id]); |
|
145 | + } |
|
146 | + unset($topicsObject, $forumsObject); |
|
147 | + // irmtfan add restore to viewtopic |
|
148 | + $restoretopic_id = $topicObject->getVar('topic_id'); |
|
149 | + // irmtfan / missing in URL |
|
150 | + echo $action[$mode]['msg'] |
|
151 | + . "<p><a href='" |
|
152 | + . XOOPS_URL |
|
153 | + . '/modules/' |
|
154 | + . $xoopsModule->getVar('dirname') |
|
155 | + . "/viewtopic.php?topic_id=$restoretopic_id'>" |
|
156 | + . _MD_NEWBB_VIEWTHETOPIC |
|
157 | + . '</a></p>' |
|
158 | + . "<p><a href='" |
|
159 | + . XOOPS_URL |
|
160 | + . '/modules/' |
|
161 | + . $xoopsModule->getVar('dirname') |
|
162 | + . "/viewforum.php?forum=$forum'>" |
|
163 | + . _MD_NEWBB_RETURNTOTHEFORUM |
|
164 | + . '</a></p>' |
|
165 | + . "<p><a href='index.php'>" |
|
166 | + . _MD_NEWBB_RETURNFORUMINDEX |
|
167 | + . '</a></p>'; |
|
168 | + } elseif ('merge' === $mode) { |
|
169 | + // /** @var PostHandler $postHandler */ |
|
170 | + // $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
171 | + // /** @var Newbb\RateHandler $rateHandler */ |
|
172 | + // $rateHandler = Newbb\Helper::getInstance()->getHandler('Rate'); |
|
173 | 173 | |
174 | - foreach ($topic_id as $tid) { |
|
175 | - $topicObject = $topicHandler->get($tid); |
|
176 | - $newtopicObject = $topicHandler->get($newtopic); |
|
174 | + foreach ($topic_id as $tid) { |
|
175 | + $topicObject = $topicHandler->get($tid); |
|
176 | + $newtopicObject = $topicHandler->get($newtopic); |
|
177 | 177 | |
178 | - /* return false if destination topic is not existing */ |
|
179 | - // irmtfan bug fix: the old topic will be deleted if user input a not exist new topic |
|
180 | - if (!is_object($newtopicObject)) { |
|
181 | - $redirect = XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $tid; |
|
182 | - redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
|
183 | - } |
|
184 | - $criteria_topic = new \Criteria('topic_id', $tid); |
|
185 | - $criteria = new \CriteriaCompo($criteria_topic); |
|
186 | - $criteria->add(new \Criteria('pid', 0)); |
|
187 | - // irmtfan OR change to this for less query?: |
|
188 | - // $postHandler->updateAll("pid", $newtopicObject->getVar("topic_last_post_id"), $criteria, true); |
|
189 | - $postHandler->updateAll('pid', $topicHandler->getTopPostId($newtopic), $criteria, true); |
|
190 | - $postHandler->updateAll('topic_id', $newtopic, $criteria_topic, true); |
|
191 | - // irmtfan update vote data instead of deleting them |
|
192 | - $rateHandler->updateAll('topic_id', $newtopic, $criteria_topic, true); |
|
178 | + /* return false if destination topic is not existing */ |
|
179 | + // irmtfan bug fix: the old topic will be deleted if user input a not exist new topic |
|
180 | + if (!is_object($newtopicObject)) { |
|
181 | + $redirect = XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $tid; |
|
182 | + redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
|
183 | + } |
|
184 | + $criteria_topic = new \Criteria('topic_id', $tid); |
|
185 | + $criteria = new \CriteriaCompo($criteria_topic); |
|
186 | + $criteria->add(new \Criteria('pid', 0)); |
|
187 | + // irmtfan OR change to this for less query?: |
|
188 | + // $postHandler->updateAll("pid", $newtopicObject->getVar("topic_last_post_id"), $criteria, true); |
|
189 | + $postHandler->updateAll('pid', $topicHandler->getTopPostId($newtopic), $criteria, true); |
|
190 | + $postHandler->updateAll('topic_id', $newtopic, $criteria_topic, true); |
|
191 | + // irmtfan update vote data instead of deleting them |
|
192 | + $rateHandler->updateAll('topic_id', $newtopic, $criteria_topic, true); |
|
193 | 193 | |
194 | - $topic_views = $topicObject->getVar('topic_views') + $newtopicObject->getVar('topic_views'); |
|
195 | - // irmtfan better method to update topic_views in new topic |
|
196 | - //$criteria_newtopic = new \Criteria('topic_id', $newtopic); |
|
197 | - //$topicHandler->updateAll('topic_views', $topic_views, $criteria_newtopic, true); |
|
198 | - $newtopicObject->setVar('topic_views', $topic_views); |
|
199 | - // START irmtfan poll_module and rewrite the method |
|
200 | - // irmtfan only move poll in old topic to new topic if new topic has not a poll |
|
201 | - $poll_id = $topicObject->getVar('poll_id'); |
|
202 | - if ($poll_id > 0 && (0 == $newtopicObject->getVar('poll_id'))) { |
|
203 | - $newtopicObject->setVar('topic_haspoll', 1); |
|
204 | - $newtopicObject->setVar('poll_id', $poll_id); |
|
205 | - $poll_id = 0;// set to not delete the poll |
|
206 | - $topicObject->setVar('topic_haspoll', 0); // set to not delete the poll |
|
207 | - $topicObject->setVar('poll_id', 0);// set to not delete the poll |
|
208 | - } |
|
209 | - //update and sync newtopic after merge |
|
210 | - //$topicHandler->insert($newtopicObject, true); |
|
211 | - $topicHandler->synchronization($newtopicObject); // very important: only use object |
|
212 | - //sync newforum after merge |
|
213 | - $newforum = $newtopicObject->getVar('forum_id'); |
|
214 | - $forumHandler->synchronization($newforum); |
|
215 | - //hardcode remove force to delete old topic from database |
|
216 | - //$topicHandler->delete($topicObject,true); // cannot use this |
|
217 | - $topicHandler->deleteAll($criteria_topic, true); // $force = true |
|
218 | - //delete poll if old topic had a poll |
|
219 | - $topicObject->deletePoll($poll_id); |
|
220 | - //sync forum after delete old topic |
|
221 | - $forumHandler->synchronization($forum); |
|
222 | - // END irmtfan poll_module and rewrite the method |
|
223 | - } |
|
224 | - echo $action[$mode]['msg'] |
|
225 | - . // irmtfan full URL |
|
226 | - "<p><a href='" |
|
227 | - . XOOPS_URL |
|
228 | - . '/modules/' |
|
229 | - . $xoopsModule->getVar('dirname') |
|
230 | - . "/viewtopic.php?topic_id=$newtopic'>" |
|
231 | - . _MD_NEWBB_VIEWTHETOPIC |
|
232 | - . '</a></p>' |
|
233 | - . "<p><a href='" |
|
234 | - . XOOPS_URL |
|
235 | - . '/modules/' |
|
236 | - . $xoopsModule->getVar('dirname') |
|
237 | - . "/viewforum.php?forum=$forum'>" |
|
238 | - . _MD_NEWBB_RETURNTOTHEFORUM |
|
239 | - . '</a></p>' |
|
240 | - . "<p><a href='" |
|
241 | - . XOOPS_URL |
|
242 | - . '/modules/' |
|
243 | - . $xoopsModule->getVar('dirname') |
|
244 | - . "/index.php'>" |
|
245 | - . _MD_NEWBB_RETURNFORUMINDEX |
|
246 | - . '</a></p>'; |
|
247 | - } elseif ('move' === $mode) { |
|
248 | - if ($newforum > 0) { |
|
249 | - $topic_id = $topic_id[0]; |
|
250 | - $topicObject = $topicHandler->get($topic_id); |
|
251 | - $topicObject->loadFilters('update'); |
|
252 | - $topicObject->setVar('forum_id', $newforum, true); |
|
253 | - $topicHandler->insert($topicObject, true); |
|
254 | - $topicObject->loadFilters('update'); |
|
194 | + $topic_views = $topicObject->getVar('topic_views') + $newtopicObject->getVar('topic_views'); |
|
195 | + // irmtfan better method to update topic_views in new topic |
|
196 | + //$criteria_newtopic = new \Criteria('topic_id', $newtopic); |
|
197 | + //$topicHandler->updateAll('topic_views', $topic_views, $criteria_newtopic, true); |
|
198 | + $newtopicObject->setVar('topic_views', $topic_views); |
|
199 | + // START irmtfan poll_module and rewrite the method |
|
200 | + // irmtfan only move poll in old topic to new topic if new topic has not a poll |
|
201 | + $poll_id = $topicObject->getVar('poll_id'); |
|
202 | + if ($poll_id > 0 && (0 == $newtopicObject->getVar('poll_id'))) { |
|
203 | + $newtopicObject->setVar('topic_haspoll', 1); |
|
204 | + $newtopicObject->setVar('poll_id', $poll_id); |
|
205 | + $poll_id = 0;// set to not delete the poll |
|
206 | + $topicObject->setVar('topic_haspoll', 0); // set to not delete the poll |
|
207 | + $topicObject->setVar('poll_id', 0);// set to not delete the poll |
|
208 | + } |
|
209 | + //update and sync newtopic after merge |
|
210 | + //$topicHandler->insert($newtopicObject, true); |
|
211 | + $topicHandler->synchronization($newtopicObject); // very important: only use object |
|
212 | + //sync newforum after merge |
|
213 | + $newforum = $newtopicObject->getVar('forum_id'); |
|
214 | + $forumHandler->synchronization($newforum); |
|
215 | + //hardcode remove force to delete old topic from database |
|
216 | + //$topicHandler->delete($topicObject,true); // cannot use this |
|
217 | + $topicHandler->deleteAll($criteria_topic, true); // $force = true |
|
218 | + //delete poll if old topic had a poll |
|
219 | + $topicObject->deletePoll($poll_id); |
|
220 | + //sync forum after delete old topic |
|
221 | + $forumHandler->synchronization($forum); |
|
222 | + // END irmtfan poll_module and rewrite the method |
|
223 | + } |
|
224 | + echo $action[$mode]['msg'] |
|
225 | + . // irmtfan full URL |
|
226 | + "<p><a href='" |
|
227 | + . XOOPS_URL |
|
228 | + . '/modules/' |
|
229 | + . $xoopsModule->getVar('dirname') |
|
230 | + . "/viewtopic.php?topic_id=$newtopic'>" |
|
231 | + . _MD_NEWBB_VIEWTHETOPIC |
|
232 | + . '</a></p>' |
|
233 | + . "<p><a href='" |
|
234 | + . XOOPS_URL |
|
235 | + . '/modules/' |
|
236 | + . $xoopsModule->getVar('dirname') |
|
237 | + . "/viewforum.php?forum=$forum'>" |
|
238 | + . _MD_NEWBB_RETURNTOTHEFORUM |
|
239 | + . '</a></p>' |
|
240 | + . "<p><a href='" |
|
241 | + . XOOPS_URL |
|
242 | + . '/modules/' |
|
243 | + . $xoopsModule->getVar('dirname') |
|
244 | + . "/index.php'>" |
|
245 | + . _MD_NEWBB_RETURNFORUMINDEX |
|
246 | + . '</a></p>'; |
|
247 | + } elseif ('move' === $mode) { |
|
248 | + if ($newforum > 0) { |
|
249 | + $topic_id = $topic_id[0]; |
|
250 | + $topicObject = $topicHandler->get($topic_id); |
|
251 | + $topicObject->loadFilters('update'); |
|
252 | + $topicObject->setVar('forum_id', $newforum, true); |
|
253 | + $topicHandler->insert($topicObject, true); |
|
254 | + $topicObject->loadFilters('update'); |
|
255 | 255 | |
256 | - $sql = sprintf('UPDATE "%s" SET forum_id = "%u" WHERE topic_id = "%u"', $GLOBALS['xoopsDB']->prefix('newbb_posts'), $newforum, $topic_id); |
|
257 | - if (!$r = $GLOBALS['xoopsDB']->query($sql)) { |
|
258 | - return false; |
|
259 | - } |
|
260 | - $forumHandler->synchronization($forum); |
|
261 | - $forumHandler->synchronization($newforum); |
|
262 | - // irmtfan full URL |
|
263 | - echo $action[$mode]['msg'] |
|
264 | - . "<p><a href='" |
|
265 | - . XOOPS_URL |
|
266 | - . '/modules/' |
|
267 | - . $xoopsModule->getVar('dirname') |
|
268 | - . "/viewtopic.php?topic_id=$topic_id&forum=$newforum'>" |
|
269 | - . _MD_NEWBB_GOTONEWFORUM |
|
270 | - . "</a></p><p><a href='" |
|
271 | - . XOOPS_URL |
|
272 | - . "/modules/newbb/index.php'>" |
|
273 | - . _MD_NEWBB_RETURNFORUMINDEX |
|
274 | - . '</a></p>'; |
|
275 | - } else { |
|
276 | - // irmtfan - issue with javascript:history.go(-1) |
|
277 | - redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERRORFORUM); |
|
278 | - } |
|
279 | - } else { |
|
280 | - $topic_id = $topic_id[0]; |
|
281 | - $forum = $topicHandler->get($topic_id, 'forum_id'); |
|
282 | - $forum_new = !empty($newtopic) ? $topicHandler->get($newtopic, 'forum_id') : 0; |
|
256 | + $sql = sprintf('UPDATE "%s" SET forum_id = "%u" WHERE topic_id = "%u"', $GLOBALS['xoopsDB']->prefix('newbb_posts'), $newforum, $topic_id); |
|
257 | + if (!$r = $GLOBALS['xoopsDB']->query($sql)) { |
|
258 | + return false; |
|
259 | + } |
|
260 | + $forumHandler->synchronization($forum); |
|
261 | + $forumHandler->synchronization($newforum); |
|
262 | + // irmtfan full URL |
|
263 | + echo $action[$mode]['msg'] |
|
264 | + . "<p><a href='" |
|
265 | + . XOOPS_URL |
|
266 | + . '/modules/' |
|
267 | + . $xoopsModule->getVar('dirname') |
|
268 | + . "/viewtopic.php?topic_id=$topic_id&forum=$newforum'>" |
|
269 | + . _MD_NEWBB_GOTONEWFORUM |
|
270 | + . "</a></p><p><a href='" |
|
271 | + . XOOPS_URL |
|
272 | + . "/modules/newbb/index.php'>" |
|
273 | + . _MD_NEWBB_RETURNFORUMINDEX |
|
274 | + . '</a></p>'; |
|
275 | + } else { |
|
276 | + // irmtfan - issue with javascript:history.go(-1) |
|
277 | + redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERRORFORUM); |
|
278 | + } |
|
279 | + } else { |
|
280 | + $topic_id = $topic_id[0]; |
|
281 | + $forum = $topicHandler->get($topic_id, 'forum_id'); |
|
282 | + $forum_new = !empty($newtopic) ? $topicHandler->get($newtopic, 'forum_id') : 0; |
|
283 | 283 | |
284 | - if (!$forumHandler->getPermission($forum, 'moderate') |
|
285 | - || (!empty($forum_new) |
|
286 | - && !$forumHandler->getPermission($forum_new, 'reply')) // The forum for the topic to be merged to |
|
287 | - || (!empty($newforum) && !$forumHandler->getPermission($newforum, 'post')) // The forum to be moved to |
|
288 | - ) { |
|
289 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id", 2, _NOPERM); |
|
290 | - } |
|
284 | + if (!$forumHandler->getPermission($forum, 'moderate') |
|
285 | + || (!empty($forum_new) |
|
286 | + && !$forumHandler->getPermission($forum_new, 'reply')) // The forum for the topic to be merged to |
|
287 | + || (!empty($newforum) && !$forumHandler->getPermission($newforum, 'post')) // The forum to be moved to |
|
288 | + ) { |
|
289 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id", 2, _NOPERM); |
|
290 | + } |
|
291 | 291 | |
292 | - if (!empty($action[$mode]['sql'])) { |
|
293 | - $sql = sprintf('UPDATE `%s` SET ' . $action[$mode]['sql'] . ' WHERE topic_id = %u', $GLOBALS['xoopsDB']->prefix('newbb_topics'), $topic_id); |
|
294 | - if (!$r = $GLOBALS['xoopsDB']->query($sql)) { |
|
295 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id&order=$order&viewmode=$viewmode", 2, _MD_NEWBB_ERROR_BACK . '<br>sql: ' . $sql); |
|
296 | - } |
|
297 | - } else { |
|
298 | - redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id", 2, _MD_NEWBB_ERROR_BACK); |
|
299 | - } |
|
300 | - if ('digest' === $mode && $GLOBALS['xoopsDB']->getAffectedRows()) { |
|
301 | - $topicObject = $topicHandler->get($topic_id); |
|
302 | - // /** @var Newbb\StatsHandler $statsHandler */ |
|
303 | - // $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
304 | - $statsHandler->update($topicObject->getVar('forum_id'), 'digest'); |
|
305 | - // /** @var Newbb\UserstatsHandler $userstatsHandler */ |
|
306 | - // $userstatsHandler = Newbb\Helper::getInstance()->getHandler('Userstats'); |
|
307 | - if ($user_stat = $userstatsHandler->get($topicObject->getVar('topic_poster'))) { |
|
308 | - $z = $user_stat->getVar('user_digests') + 1; |
|
309 | - $user_stat->setVar('user_digests', (int)$z); |
|
310 | - $userstatsHandler->insert($user_stat); |
|
311 | - } |
|
312 | - } |
|
313 | - // irmtfan full URL |
|
314 | - echo $action[$mode]['msg'] |
|
315 | - . "<p><a href='" |
|
316 | - . XOOPS_URL |
|
317 | - . '/modules/' |
|
318 | - . $xoopsModule->getVar('dirname') |
|
319 | - . "/viewtopic.php?topic_id=$topic_id&forum=$forum'>" |
|
320 | - . _MD_NEWBB_VIEWTHETOPIC |
|
321 | - . "</a></p><p><a href='" |
|
322 | - . XOOPS_URL |
|
323 | - . "/modules/newbb/viewforum.php?forum=$forum'>" |
|
324 | - . _MD_NEWBB_RETURNFORUMINDEX |
|
325 | - . '</a></p>'; |
|
326 | - } |
|
292 | + if (!empty($action[$mode]['sql'])) { |
|
293 | + $sql = sprintf('UPDATE `%s` SET ' . $action[$mode]['sql'] . ' WHERE topic_id = %u', $GLOBALS['xoopsDB']->prefix('newbb_topics'), $topic_id); |
|
294 | + if (!$r = $GLOBALS['xoopsDB']->query($sql)) { |
|
295 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id&order=$order&viewmode=$viewmode", 2, _MD_NEWBB_ERROR_BACK . '<br>sql: ' . $sql); |
|
296 | + } |
|
297 | + } else { |
|
298 | + redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id", 2, _MD_NEWBB_ERROR_BACK); |
|
299 | + } |
|
300 | + if ('digest' === $mode && $GLOBALS['xoopsDB']->getAffectedRows()) { |
|
301 | + $topicObject = $topicHandler->get($topic_id); |
|
302 | + // /** @var Newbb\StatsHandler $statsHandler */ |
|
303 | + // $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
304 | + $statsHandler->update($topicObject->getVar('forum_id'), 'digest'); |
|
305 | + // /** @var Newbb\UserstatsHandler $userstatsHandler */ |
|
306 | + // $userstatsHandler = Newbb\Helper::getInstance()->getHandler('Userstats'); |
|
307 | + if ($user_stat = $userstatsHandler->get($topicObject->getVar('topic_poster'))) { |
|
308 | + $z = $user_stat->getVar('user_digests') + 1; |
|
309 | + $user_stat->setVar('user_digests', (int)$z); |
|
310 | + $userstatsHandler->insert($user_stat); |
|
311 | + } |
|
312 | + } |
|
313 | + // irmtfan full URL |
|
314 | + echo $action[$mode]['msg'] |
|
315 | + . "<p><a href='" |
|
316 | + . XOOPS_URL |
|
317 | + . '/modules/' |
|
318 | + . $xoopsModule->getVar('dirname') |
|
319 | + . "/viewtopic.php?topic_id=$topic_id&forum=$forum'>" |
|
320 | + . _MD_NEWBB_VIEWTHETOPIC |
|
321 | + . "</a></p><p><a href='" |
|
322 | + . XOOPS_URL |
|
323 | + . "/modules/newbb/viewforum.php?forum=$forum'>" |
|
324 | + . _MD_NEWBB_RETURNFORUMINDEX |
|
325 | + . '</a></p>'; |
|
326 | + } |
|
327 | 327 | } else { // No submit |
328 | - $mode = Request::getString('mode', '', 'GET'); //$_GET['mode']; |
|
329 | - echo "<form action='" . Request::getString('PHP_SELF', '', 'SERVER') . "' method='post'>"; |
|
330 | - echo "<table border='0' cellpadding='1' cellspacing='0' align='center' width='95%'>"; |
|
331 | - echo "<tr><td class='bg2'>"; |
|
332 | - echo "<table border='0' cellpadding='1' cellspacing='1' width='100%'>"; |
|
333 | - echo "<tr class='bg3' align='left'>"; |
|
334 | - echo "<td colspan='2' align='center'>" . $action[$mode]['desc'] . '</td></tr>'; |
|
328 | + $mode = Request::getString('mode', '', 'GET'); //$_GET['mode']; |
|
329 | + echo "<form action='" . Request::getString('PHP_SELF', '', 'SERVER') . "' method='post'>"; |
|
330 | + echo "<table border='0' cellpadding='1' cellspacing='0' align='center' width='95%'>"; |
|
331 | + echo "<tr><td class='bg2'>"; |
|
332 | + echo "<table border='0' cellpadding='1' cellspacing='1' width='100%'>"; |
|
333 | + echo "<tr class='bg3' align='left'>"; |
|
334 | + echo "<td colspan='2' align='center'>" . $action[$mode]['desc'] . '</td></tr>'; |
|
335 | 335 | |
336 | - if ('move' === $mode) { |
|
337 | - echo '<tr><td class="bg3">' . _MD_NEWBB_MOVETOPICTO . '</td><td class="bg1">'; |
|
338 | - $box = '<select name="newforum" size="1">'; |
|
336 | + if ('move' === $mode) { |
|
337 | + echo '<tr><td class="bg3">' . _MD_NEWBB_MOVETOPICTO . '</td><td class="bg1">'; |
|
338 | + $box = '<select name="newforum" size="1">'; |
|
339 | 339 | |
340 | - // /** @var Newbb\CategoryHandler $categoryHandler */ |
|
341 | - // $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
|
342 | - $categories = $categoryHandler->getByPermission('access'); |
|
343 | - $forums = $forumHandler->getForumsByCategory(array_keys($categories), 'post', false); |
|
340 | + // /** @var Newbb\CategoryHandler $categoryHandler */ |
|
341 | + // $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
|
342 | + $categories = $categoryHandler->getByPermission('access'); |
|
343 | + $forums = $forumHandler->getForumsByCategory(array_keys($categories), 'post', false); |
|
344 | 344 | |
345 | - if (count($categories) > 0 && count($forums) > 0) { |
|
346 | - foreach (array_keys($forums) as $key) { |
|
347 | - /** @var Newbb\Category[] $categories */ |
|
348 | - $box .= "<option value='-1'>[" . $categories[$key]->getVar('cat_title') . ']</option>'; |
|
349 | - foreach ($forums[$key] as $forumid => $_forum) { |
|
350 | - $box .= "<option value='" . $forumid . "'>-- " . $_forum['title'] . '</option>'; |
|
351 | - if (!isset($_forum['sub'])) { |
|
352 | - continue; |
|
353 | - } |
|
354 | - foreach (array_keys($_forum['sub']) as $fid) { |
|
355 | - $box .= "<option value='" . $fid . "'>---- " . $_forum['sub'][$fid]['title'] . '</option>'; |
|
356 | - } |
|
357 | - } |
|
358 | - } |
|
359 | - } else { |
|
360 | - $box .= "<option value='-1'>" . _MD_NEWBB_NOFORUMINDB . '</option>'; |
|
361 | - } |
|
362 | - unset($forums, $categories); |
|
345 | + if (count($categories) > 0 && count($forums) > 0) { |
|
346 | + foreach (array_keys($forums) as $key) { |
|
347 | + /** @var Newbb\Category[] $categories */ |
|
348 | + $box .= "<option value='-1'>[" . $categories[$key]->getVar('cat_title') . ']</option>'; |
|
349 | + foreach ($forums[$key] as $forumid => $_forum) { |
|
350 | + $box .= "<option value='" . $forumid . "'>-- " . $_forum['title'] . '</option>'; |
|
351 | + if (!isset($_forum['sub'])) { |
|
352 | + continue; |
|
353 | + } |
|
354 | + foreach (array_keys($_forum['sub']) as $fid) { |
|
355 | + $box .= "<option value='" . $fid . "'>---- " . $_forum['sub'][$fid]['title'] . '</option>'; |
|
356 | + } |
|
357 | + } |
|
358 | + } |
|
359 | + } else { |
|
360 | + $box .= "<option value='-1'>" . _MD_NEWBB_NOFORUMINDB . '</option>'; |
|
361 | + } |
|
362 | + unset($forums, $categories); |
|
363 | 363 | |
364 | - echo $box; |
|
365 | - echo '</select></td></tr>'; |
|
366 | - } |
|
367 | - if ('merge' === $mode) { |
|
368 | - echo '<tr><td class="bg3">' . _MD_NEWBB_MERGETOPICTO . '</td><td class="bg1">'; |
|
369 | - echo _MD_NEWBB_TOPIC . " ID-$topic_id -> ID: <input name='newtopic' value='' />"; |
|
370 | - echo '</td></tr>'; |
|
371 | - } |
|
372 | - echo '<tr class="bg3"><td colspan="2" align="center">'; |
|
373 | - echo "<input type='hidden' name='mode' value='" . $action[$mode]['name'] . "' />"; |
|
374 | - echo "<input type='hidden' name='topic_id' value='" . $topic_id . "' />"; |
|
375 | - echo "<input type='hidden' name='forum' value='" . $forum . "' />"; |
|
376 | - echo "<input type='submit' name='submit' value='" . $action[$mode]['submit'] . "' />"; |
|
377 | - echo '</td></tr></form></table></td></tr></table>'; |
|
364 | + echo $box; |
|
365 | + echo '</select></td></tr>'; |
|
366 | + } |
|
367 | + if ('merge' === $mode) { |
|
368 | + echo '<tr><td class="bg3">' . _MD_NEWBB_MERGETOPICTO . '</td><td class="bg1">'; |
|
369 | + echo _MD_NEWBB_TOPIC . " ID-$topic_id -> ID: <input name='newtopic' value='' />"; |
|
370 | + echo '</td></tr>'; |
|
371 | + } |
|
372 | + echo '<tr class="bg3"><td colspan="2" align="center">'; |
|
373 | + echo "<input type='hidden' name='mode' value='" . $action[$mode]['name'] . "' />"; |
|
374 | + echo "<input type='hidden' name='topic_id' value='" . $topic_id . "' />"; |
|
375 | + echo "<input type='hidden' name='forum' value='" . $forum . "' />"; |
|
376 | + echo "<input type='submit' name='submit' value='" . $action[$mode]['submit'] . "' />"; |
|
377 | + echo '</td></tr></form></table></td></tr></table>'; |
|
378 | 378 | } |
379 | 379 | // irmtfan move to footer.php |
380 | 380 | require_once __DIR__ . '/footer.php'; |
@@ -8,81 +8,81 @@ |
||
8 | 8 | */ |
9 | 9 | class GroupPermForm extends \XoopsGroupPermForm |
10 | 10 | { |
11 | - /** |
|
12 | - * @param $title |
|
13 | - * @param $modid |
|
14 | - * @param $permname |
|
15 | - * @param $permdesc |
|
16 | - * @param string $url |
|
17 | - */ |
|
11 | + /** |
|
12 | + * @param $title |
|
13 | + * @param $modid |
|
14 | + * @param $permname |
|
15 | + * @param $permdesc |
|
16 | + * @param string $url |
|
17 | + */ |
|
18 | 18 | |
19 | - public function __construct($title, $modid, $permname, $permdesc, $url = '') |
|
20 | - { |
|
21 | - parent::__construct($title, $modid, $permname, $permdesc, $url); |
|
22 | - } |
|
19 | + public function __construct($title, $modid, $permname, $permdesc, $url = '') |
|
20 | + { |
|
21 | + parent::__construct($title, $modid, $permname, $permdesc, $url); |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * @param $title |
|
26 | - * @param $modid |
|
27 | - * @param $permname |
|
28 | - * @param $permdesc |
|
29 | - * @param string $url |
|
30 | - */ |
|
24 | + /** |
|
25 | + * @param $title |
|
26 | + * @param $modid |
|
27 | + * @param $permname |
|
28 | + * @param $permdesc |
|
29 | + * @param string $url |
|
30 | + */ |
|
31 | 31 | |
32 | - /* |
|
32 | + /* |
|
33 | 33 | public function newbb_XoopsGroupPermForm($title, $modid, $permname, $permdesc, $url = "") |
34 | 34 | { |
35 | 35 | // $this->XoopsGroupPermForm($title, $modid, $permname, $permdesc, $url); |
36 | 36 | self::__construct($title, $modid, $permname, $permdesc, $url); |
37 | 37 | } |
38 | 38 | */ |
39 | - /** |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function render() |
|
43 | - { |
|
44 | - // load all child ids for javascript codes |
|
45 | - foreach (array_keys($this->_itemTree) as $item_id) { |
|
46 | - $this->_itemTree[$item_id]['allchild'] = []; |
|
47 | - $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']); |
|
48 | - } |
|
49 | - /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
50 | - $grouppermHandler = xoops_getHandler('groupperm'); |
|
51 | - /** @var \XoopsMemberHandler $memberHandler */ |
|
52 | - $memberHandler = xoops_getHandler('member'); |
|
53 | - $glist = $memberHandler->getGroupList(); |
|
54 | - foreach (array_keys($glist) as $i) { |
|
55 | - // get selected item id(s) for each group |
|
56 | - $selected = $grouppermHandler->getItemIds($this->_permName, $i, $this->_modid); |
|
57 | - $ele = new Newbb\GroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected); |
|
58 | - $ele->setOptionTree($this->_itemTree); |
|
59 | - $this->addElement($ele); |
|
60 | - unset($ele); |
|
61 | - } |
|
62 | - $tray = new \XoopsFormElementTray(''); |
|
63 | - $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
64 | - $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
65 | - $this->addElement($tray); |
|
66 | - $ret = '<br><strong>' . $this->getTitle() . '</strong><br>' . $this->_permDesc . '<br>'; |
|
67 | - $ret .= "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n<table width='100%' class='outer' cellspacing='1' valign='top'>\n"; |
|
68 | - $elements = $this->getElements(); |
|
69 | - $hidden = ''; |
|
70 | - foreach (array_keys($elements) as $i) { |
|
71 | - if (!is_object($elements[$i])) { |
|
72 | - $ret .= $elements[$i]; |
|
73 | - } elseif (!$elements[$i]->isHidden()) { |
|
74 | - $ret .= "<tr valign='top' align='left'><td class='head'>" . $elements[$i]->getCaption(); |
|
75 | - if ('' !== $elements[$i]->getDescription()) { |
|
76 | - $ret .= '<br><br><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>'; |
|
77 | - } |
|
78 | - $ret .= "</td>\n<td class='even' style='text-align:center;'>\n" . $elements[$i]->render() . "\n</td></tr>\n"; |
|
79 | - } else { |
|
80 | - $hidden .= $elements[$i]->render(); |
|
81 | - } |
|
82 | - } |
|
83 | - $ret .= "</table>$hidden</form>"; |
|
84 | - $ret .= $this->renderValidationJS(true); |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function render() |
|
43 | + { |
|
44 | + // load all child ids for javascript codes |
|
45 | + foreach (array_keys($this->_itemTree) as $item_id) { |
|
46 | + $this->_itemTree[$item_id]['allchild'] = []; |
|
47 | + $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']); |
|
48 | + } |
|
49 | + /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
50 | + $grouppermHandler = xoops_getHandler('groupperm'); |
|
51 | + /** @var \XoopsMemberHandler $memberHandler */ |
|
52 | + $memberHandler = xoops_getHandler('member'); |
|
53 | + $glist = $memberHandler->getGroupList(); |
|
54 | + foreach (array_keys($glist) as $i) { |
|
55 | + // get selected item id(s) for each group |
|
56 | + $selected = $grouppermHandler->getItemIds($this->_permName, $i, $this->_modid); |
|
57 | + $ele = new Newbb\GroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected); |
|
58 | + $ele->setOptionTree($this->_itemTree); |
|
59 | + $this->addElement($ele); |
|
60 | + unset($ele); |
|
61 | + } |
|
62 | + $tray = new \XoopsFormElementTray(''); |
|
63 | + $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
64 | + $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
65 | + $this->addElement($tray); |
|
66 | + $ret = '<br><strong>' . $this->getTitle() . '</strong><br>' . $this->_permDesc . '<br>'; |
|
67 | + $ret .= "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n<table width='100%' class='outer' cellspacing='1' valign='top'>\n"; |
|
68 | + $elements = $this->getElements(); |
|
69 | + $hidden = ''; |
|
70 | + foreach (array_keys($elements) as $i) { |
|
71 | + if (!is_object($elements[$i])) { |
|
72 | + $ret .= $elements[$i]; |
|
73 | + } elseif (!$elements[$i]->isHidden()) { |
|
74 | + $ret .= "<tr valign='top' align='left'><td class='head'>" . $elements[$i]->getCaption(); |
|
75 | + if ('' !== $elements[$i]->getDescription()) { |
|
76 | + $ret .= '<br><br><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>'; |
|
77 | + } |
|
78 | + $ret .= "</td>\n<td class='even' style='text-align:center;'>\n" . $elements[$i]->render() . "\n</td></tr>\n"; |
|
79 | + } else { |
|
80 | + $hidden .= $elements[$i]->render(); |
|
81 | + } |
|
82 | + } |
|
83 | + $ret .= "</table>$hidden</form>"; |
|
84 | + $ret .= $this->renderValidationJS(true); |
|
85 | 85 | |
86 | - return $ret; |
|
87 | - } |
|
86 | + return $ret; |
|
87 | + } |
|
88 | 88 | } |
@@ -22,68 +22,68 @@ |
||
22 | 22 | */ |
23 | 23 | class GroupFormCheckBox extends \XoopsGroupFormCheckBox |
24 | 24 | { |
25 | - /** |
|
26 | - * @param $caption |
|
27 | - * @param $name |
|
28 | - * @param $groupId |
|
29 | - * @param null $values |
|
30 | - */ |
|
31 | - public function __construct($caption, $name, $groupId, $values = null) |
|
32 | - { |
|
33 | - parent::__construct($caption, $name, $groupId, $values); |
|
34 | - } |
|
25 | + /** |
|
26 | + * @param $caption |
|
27 | + * @param $name |
|
28 | + * @param $groupId |
|
29 | + * @param null $values |
|
30 | + */ |
|
31 | + public function __construct($caption, $name, $groupId, $values = null) |
|
32 | + { |
|
33 | + parent::__construct($caption, $name, $groupId, $values); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param string $tree |
|
38 | - * @param array $option |
|
39 | - * @param string $prefix |
|
40 | - * @param array $parentIds |
|
41 | - */ |
|
42 | - public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = []) |
|
43 | - { |
|
44 | - if ($option['id'] > 0) { |
|
45 | - $tree .= $prefix . '<input type="checkbox" name="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" id="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" onclick="'; |
|
46 | - foreach ($parentIds as $pid) { |
|
47 | - if ($pid <= 0) { |
|
48 | - continue; |
|
49 | - } |
|
50 | - $parent_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $pid . ']'; |
|
51 | - $tree .= "var ele = xoopsGetElementById('" . $parent_ele . "'); if (ele.checked !== true) {ele.checked = this.checked;}"; |
|
52 | - } |
|
53 | - foreach ($option['allchild'] as $cid) { |
|
54 | - $child_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $cid . ']'; |
|
55 | - $tree .= "var ele = xoopsGetElementById('" . $child_ele . "'); if (this.checked !== true) {ele.checked = false;}"; |
|
56 | - } |
|
57 | - $tree .= '" value="1"'; |
|
58 | - if (in_array($option['id'], $this->_value)) { |
|
59 | - $tree .= ' checked'; |
|
60 | - } |
|
61 | - $tree .= ' />' |
|
62 | - . $option['name'] |
|
63 | - . '<input type="hidden" name="' |
|
64 | - . $this->getName() |
|
65 | - . '[parents][' |
|
66 | - . $option['id'] |
|
67 | - . ']" value="' |
|
68 | - . implode(':', $parentIds) |
|
69 | - . '" /><input type="hidden" name="' |
|
70 | - . $this->getName() |
|
71 | - . '[itemname][' |
|
72 | - . $option['id'] |
|
73 | - . ']" value="' |
|
74 | - . htmlspecialchars($option['name'], ENT_QUOTES | ENT_HTML5) |
|
75 | - . "\" /><br>\n"; |
|
76 | - } else { |
|
77 | - $tree .= $prefix . $option['name'] . '<input type="hidden" id="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . "]\" /><br>\n"; |
|
78 | - } |
|
79 | - if (isset($option['children'])) { |
|
80 | - foreach ($option['children'] as $child) { |
|
81 | - if ($option['id'] > 0) { |
|
82 | - // array_push($parentIds, $option['id']); |
|
83 | - $parentIds[] = $option['id']; |
|
84 | - } |
|
85 | - $this->_renderOptionTree($tree, $this->_optionTree[$child], $prefix . ' -', $parentIds); |
|
86 | - } |
|
87 | - } |
|
88 | - } |
|
36 | + /** |
|
37 | + * @param string $tree |
|
38 | + * @param array $option |
|
39 | + * @param string $prefix |
|
40 | + * @param array $parentIds |
|
41 | + */ |
|
42 | + public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = []) |
|
43 | + { |
|
44 | + if ($option['id'] > 0) { |
|
45 | + $tree .= $prefix . '<input type="checkbox" name="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" id="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" onclick="'; |
|
46 | + foreach ($parentIds as $pid) { |
|
47 | + if ($pid <= 0) { |
|
48 | + continue; |
|
49 | + } |
|
50 | + $parent_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $pid . ']'; |
|
51 | + $tree .= "var ele = xoopsGetElementById('" . $parent_ele . "'); if (ele.checked !== true) {ele.checked = this.checked;}"; |
|
52 | + } |
|
53 | + foreach ($option['allchild'] as $cid) { |
|
54 | + $child_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $cid . ']'; |
|
55 | + $tree .= "var ele = xoopsGetElementById('" . $child_ele . "'); if (this.checked !== true) {ele.checked = false;}"; |
|
56 | + } |
|
57 | + $tree .= '" value="1"'; |
|
58 | + if (in_array($option['id'], $this->_value)) { |
|
59 | + $tree .= ' checked'; |
|
60 | + } |
|
61 | + $tree .= ' />' |
|
62 | + . $option['name'] |
|
63 | + . '<input type="hidden" name="' |
|
64 | + . $this->getName() |
|
65 | + . '[parents][' |
|
66 | + . $option['id'] |
|
67 | + . ']" value="' |
|
68 | + . implode(':', $parentIds) |
|
69 | + . '" /><input type="hidden" name="' |
|
70 | + . $this->getName() |
|
71 | + . '[itemname][' |
|
72 | + . $option['id'] |
|
73 | + . ']" value="' |
|
74 | + . htmlspecialchars($option['name'], ENT_QUOTES | ENT_HTML5) |
|
75 | + . "\" /><br>\n"; |
|
76 | + } else { |
|
77 | + $tree .= $prefix . $option['name'] . '<input type="hidden" id="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . "]\" /><br>\n"; |
|
78 | + } |
|
79 | + if (isset($option['children'])) { |
|
80 | + foreach ($option['children'] as $child) { |
|
81 | + if ($option['id'] > 0) { |
|
82 | + // array_push($parentIds, $option['id']); |
|
83 | + $parentIds[] = $option['id']; |
|
84 | + } |
|
85 | + $this->_renderOptionTree($tree, $this->_optionTree[$child], $prefix . ' -', $parentIds); |
|
86 | + } |
|
87 | + } |
|
88 | + } |
|
89 | 89 | } |
@@ -19,16 +19,16 @@ |
||
19 | 19 | */ |
20 | 20 | class Userstats extends \XoopsObject |
21 | 21 | { |
22 | - /** |
|
23 | - * |
|
24 | - */ |
|
25 | - public function __construct() |
|
26 | - { |
|
27 | - parent::__construct(); |
|
28 | - $this->initVar('uid', XOBJ_DTYPE_INT); |
|
29 | - $this->initVar('user_topics', XOBJ_DTYPE_INT); |
|
30 | - $this->initVar('user_digests', XOBJ_DTYPE_INT); |
|
31 | - $this->initVar('user_posts', XOBJ_DTYPE_INT); |
|
32 | - $this->initVar('user_lastpost', XOBJ_DTYPE_INT); |
|
33 | - } |
|
22 | + /** |
|
23 | + * |
|
24 | + */ |
|
25 | + public function __construct() |
|
26 | + { |
|
27 | + parent::__construct(); |
|
28 | + $this->initVar('uid', XOBJ_DTYPE_INT); |
|
29 | + $this->initVar('user_topics', XOBJ_DTYPE_INT); |
|
30 | + $this->initVar('user_digests', XOBJ_DTYPE_INT); |
|
31 | + $this->initVar('user_posts', XOBJ_DTYPE_INT); |
|
32 | + $this->initVar('user_lastpost', XOBJ_DTYPE_INT); |
|
33 | + } |
|
34 | 34 | } |
@@ -48,340 +48,340 @@ |
||
48 | 48 | */ |
49 | 49 | class ReadHandler extends \XoopsPersistableObjectHandler |
50 | 50 | { |
51 | - /** |
|
52 | - * Object type. |
|
53 | - * <ul> |
|
54 | - * <li>forum</li> |
|
55 | - * <li>topic</li> |
|
56 | - * </ul> |
|
57 | - * |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - public $type; |
|
61 | - |
|
62 | - /** |
|
63 | - * seconds records will persist. |
|
64 | - * assigned from $GLOBALS['xoopsModuleConfig']["read_expire"] |
|
65 | - * <ul> |
|
66 | - * <li>positive days = delete all read records exist in the tables before expire time // irmtfan add comment</li> |
|
67 | - * <li>0 = never expires // irmtfan change comment</li> |
|
68 | - * <li>-1 or any negative days = never records // irmtfan change comment</li> |
|
69 | - * </ul> |
|
70 | - * |
|
71 | - * @var integer |
|
72 | - */ |
|
73 | - public $lifetime; |
|
74 | - |
|
75 | - /** |
|
76 | - * storage mode for records. |
|
77 | - * assigned from $GLOBALS['xoopsModuleConfig']["read_mode"] |
|
78 | - * <ul> |
|
79 | - * <li>0 = never records</li> |
|
80 | - * <li>1 = uses cookie</li> |
|
81 | - * <li>2 = stores in database</li> |
|
82 | - * </ul> |
|
83 | - * |
|
84 | - * @var integer |
|
85 | - */ |
|
86 | - public $mode; |
|
87 | - |
|
88 | - /** |
|
89 | - * @param \XoopsDatabase $db |
|
90 | - * @param $type |
|
91 | - */ |
|
92 | - public function __construct(\XoopsDatabase $db, $type) |
|
93 | - { |
|
94 | - $type = ('forum' === $type) ? 'forum' : 'topic'; |
|
95 | - parent::__construct($db, 'newbb_reads_' . $type, Read::class . $type, 'read_id', 'post_id'); |
|
96 | - $this->type = $type; |
|
97 | - $newbbConfig = newbbLoadConfig(); |
|
98 | - // irmtfan if read_expire = 0 dont clean |
|
99 | - $this->lifetime = isset($newbbConfig['read_expire']) ? (int)$newbbConfig['read_expire'] * 24 * 3600 : 30 * 24 * 3600; |
|
100 | - $this->mode = isset($newbbConfig['read_mode']) ? $newbbConfig['read_mode'] : 2; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Clear garbage |
|
105 | - * |
|
106 | - * Delete all expired and duplicated records |
|
107 | - */ |
|
108 | - // START irmtfan rephrase function to 1- add clearDuplicate and 2- dont clean when read_expire = 0 |
|
109 | - public function clearGarbage() |
|
110 | - { |
|
111 | - // irmtfan clear duplicaed rows |
|
112 | - if (!$result = $this->clearDuplicate()) { |
|
113 | - return false; |
|
114 | - } |
|
115 | - |
|
116 | - $sql = 'DELETE bb FROM ' . $this->table . ' AS bb' . ' LEFT JOIN ' . $this->table . ' AS aa ON bb.read_item = aa.read_item ' . ' WHERE aa.post_id > bb.post_id'; |
|
117 | - if (!$result = $this->db->queryF($sql)) { |
|
118 | - //xoops_error($this->db->error()); |
|
119 | - return false; |
|
120 | - } |
|
121 | - // irmtfan if read_expire = 0 dont clean |
|
122 | - if (empty($this->lifetime)) { |
|
123 | - return true; |
|
124 | - } |
|
125 | - // irmtfan move here and rephrase |
|
126 | - $expire = time() - (int)$this->lifetime; |
|
127 | - $sql = 'DELETE FROM ' . $this->table . ' WHERE read_time < ' . $expire; |
|
128 | - if (!$result = $this->db->queryF($sql)) { |
|
129 | - //xoops_error($this->db->error()); |
|
130 | - return false; |
|
131 | - } |
|
132 | - |
|
133 | - return true; |
|
134 | - } |
|
135 | - |
|
136 | - // END irmtfan rephrase function to 1- add clearDuplicate and 2- dont clean when read_expire = 0 |
|
137 | - |
|
138 | - /** |
|
139 | - * @param $read_item |
|
140 | - * @param null $uid |
|
141 | - * @return bool|mixed|null |
|
142 | - */ |
|
143 | - public function getRead($read_item, $uid = null) |
|
144 | - { |
|
145 | - if (empty($this->mode)) { |
|
146 | - return null; |
|
147 | - } |
|
148 | - if (1 == $this->mode) { |
|
149 | - return $this->getReadCookie($read_item); |
|
150 | - } |
|
151 | - |
|
152 | - return $this->getReadDb($read_item, $uid); |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * @param $item_id |
|
157 | - * @return mixed |
|
158 | - */ |
|
159 | - public function getReadCookie($item_id) |
|
160 | - { |
|
161 | - $cookie_name = ('forum' === $this->type) ? 'LF' : 'LT'; |
|
162 | - $cookie_var = $item_id; |
|
163 | - // irmtfan set true to return array |
|
164 | - $lastview = newbbGetCookie($cookie_name, true); |
|
165 | - |
|
166 | - return @$lastview[$cookie_var]; |
|
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * @param $read_item |
|
171 | - * @param $uid |
|
172 | - * @return bool|null |
|
173 | - */ |
|
174 | - public function getReadDb($read_item, $uid) |
|
175 | - { |
|
176 | - if (empty($uid)) { |
|
177 | - if (is_object($GLOBALS['xoopsUser'])) { |
|
178 | - $uid = $GLOBALS['xoopsUser']->getVar('uid'); |
|
179 | - } else { |
|
180 | - return false; |
|
181 | - } |
|
182 | - } |
|
183 | - $sql = 'SELECT post_id ' . ' FROM ' . $this->table . ' WHERE read_item = ' . (int)$read_item . ' AND uid = ' . (int)$uid; |
|
184 | - if (!$result = $this->db->queryF($sql, 1)) { |
|
185 | - return null; |
|
186 | - } |
|
187 | - list($post_id) = $this->db->fetchRow($result); |
|
188 | - |
|
189 | - return $post_id; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * @param $read_item |
|
194 | - * @param $post_id |
|
195 | - * @param null $uid |
|
196 | - * @return bool|mixed|void |
|
197 | - */ |
|
198 | - public function setRead($read_item, $post_id, $uid = null) |
|
199 | - { |
|
200 | - if (empty($this->mode)) { |
|
201 | - return true; |
|
202 | - } |
|
203 | - |
|
204 | - if (1 == $this->mode) { |
|
205 | - return $this->setReadCookie($read_item, $post_id); |
|
206 | - } |
|
207 | - |
|
208 | - return $this->setReadDb($read_item, $post_id, $uid); |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * @param $read_item |
|
213 | - * @param $post_id |
|
214 | - */ |
|
215 | - public function setReadCookie($read_item, $post_id) |
|
216 | - { |
|
217 | - $cookie_name = ('forum' === $this->type) ? 'LF' : 'LT'; |
|
218 | - $lastview = newbbGetCookie($cookie_name, true); |
|
219 | - $lastview[$read_item] = time(); |
|
220 | - newbbSetCookie($cookie_name, $lastview); |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * @param $read_item |
|
225 | - * @param $post_id |
|
226 | - * @param $uid |
|
227 | - * @return bool|mixed |
|
228 | - */ |
|
229 | - public function setReadDb($read_item, $post_id, $uid) |
|
230 | - { |
|
231 | - if (empty($uid)) { |
|
232 | - if (is_object($GLOBALS['xoopsUser'])) { |
|
233 | - $uid = $GLOBALS['xoopsUser']->getVar('uid'); |
|
234 | - } else { |
|
235 | - return false; |
|
236 | - } |
|
237 | - } |
|
238 | - |
|
239 | - $sql = 'UPDATE ' . $this->table . ' SET post_id = ' . (int)$post_id . ',' . ' read_time =' . time() . ' WHERE read_item = ' . (int)$read_item . ' AND uid = ' . (int)$uid; |
|
240 | - if ($this->db->queryF($sql) && $this->db->getAffectedRows()) { |
|
241 | - return true; |
|
242 | - } |
|
243 | - $object = $this->create(); |
|
244 | - $object->setVar('read_item', $read_item); |
|
245 | - $object->setVar('post_id', $post_id); |
|
246 | - $object->setVar('uid', $uid); |
|
247 | - $object->setVar('read_time', time()); |
|
248 | - |
|
249 | - return parent::insert($object); |
|
250 | - } |
|
251 | - |
|
252 | - /** |
|
253 | - * @param $items |
|
254 | - * @param null $uid |
|
255 | - * @return array|null |
|
256 | - */ |
|
257 | - public function isReadItems(&$items, $uid = null) |
|
258 | - { |
|
259 | - $ret = null; |
|
260 | - if (empty($this->mode)) { |
|
261 | - return $ret; |
|
262 | - } |
|
263 | - |
|
264 | - if (1 == $this->mode) { |
|
265 | - $ret = $this->isReadItemsCookie($items); |
|
266 | - } else { |
|
267 | - $ret = $this->isReadItemsDb($items, $uid); |
|
268 | - } |
|
269 | - |
|
270 | - return $ret; |
|
271 | - } |
|
272 | - |
|
273 | - /** |
|
274 | - * @param $items |
|
275 | - * @return array |
|
276 | - */ |
|
277 | - public function isReadItemsCookie(&$items) |
|
278 | - { |
|
279 | - $cookie_name = ('forum' === $this->type) ? 'LF' : 'LT'; |
|
280 | - $cookie_vars = newbbGetCookie($cookie_name, true); |
|
281 | - |
|
282 | - $ret = []; |
|
283 | - foreach ($items as $key => $last_update) { |
|
284 | - $ret[$key] = (max(@$GLOBALS['last_visit'], @$cookie_vars[$key]) >= $last_update); |
|
285 | - } |
|
286 | - |
|
287 | - return $ret; |
|
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * @param $items |
|
292 | - * @param $uid |
|
293 | - * @return array |
|
294 | - */ |
|
295 | - public function isReadItemsDb(&$items, $uid) |
|
296 | - { |
|
297 | - $ret = []; |
|
298 | - if (empty($items)) { |
|
299 | - return $ret; |
|
300 | - } |
|
301 | - |
|
302 | - if (empty($uid)) { |
|
303 | - if (is_object($GLOBALS['xoopsUser'])) { |
|
304 | - $uid = $GLOBALS['xoopsUser']->getVar('uid'); |
|
305 | - } else { |
|
306 | - return $ret; |
|
307 | - } |
|
308 | - } |
|
309 | - |
|
310 | - $criteria = new \CriteriaCompo(new \Criteria('uid', $uid)); |
|
311 | - $criteria->add(new \Criteria('read_item', '(' . implode(', ', array_map('intval', array_keys($items))) . ')', 'IN')); |
|
312 | - $itemsObject = $this->getAll($criteria, ['read_item', 'post_id']); |
|
313 | - |
|
314 | - $items_list = []; |
|
315 | - foreach (array_keys($itemsObject) as $key) { |
|
316 | - $items_list[$itemsObject[$key]->getVar('read_item')] = $itemsObject[$key]->getVar('post_id'); |
|
317 | - } |
|
318 | - unset($itemsObject); |
|
319 | - |
|
320 | - foreach ($items as $key => $last_update) { |
|
321 | - $ret[$key] = (@$items_list[$key] >= $last_update); |
|
322 | - } |
|
323 | - |
|
324 | - return $ret; |
|
325 | - } |
|
326 | - |
|
327 | - // START irmtfan add clear duplicated rows function |
|
328 | - |
|
329 | - /** |
|
330 | - * @return bool |
|
331 | - */ |
|
332 | - public function clearDuplicate() |
|
333 | - { |
|
334 | - /** |
|
335 | - * This is needed for the following query GROUP BY clauses to work in MySQL 5.7. |
|
336 | - * This is a TEMPORARY fix. Needing this function is bad in the first place, but |
|
337 | - * needing sloppy SQL to make it work is worse. |
|
338 | - * @todo The schema itself should preclude the duplicates |
|
339 | - */ |
|
340 | - $sql = "SET sql_mode=(SELECT REPLACE(@@sql_mode, 'ONLY_FULL_GROUP_BY', ''))"; |
|
341 | - $this->db->queryF($sql); |
|
342 | - |
|
343 | - $sql = 'CREATE TABLE ' . $this->table . '_duplicate LIKE ' . $this->table . '; '; |
|
344 | - if (!$result = $this->db->queryF($sql)) { |
|
345 | - xoops_error($this->db->error() . '<br>' . $sql); |
|
346 | - |
|
347 | - return false; |
|
348 | - } |
|
349 | - $sql = 'INSERT ' . $this->table . '_duplicate SELECT * FROM ' . $this->table . ' GROUP BY read_item, uid; '; |
|
350 | - if (!$result = $this->db->queryF($sql)) { |
|
351 | - xoops_error($this->db->error() . '<br>' . $sql); |
|
352 | - |
|
353 | - return false; |
|
354 | - } |
|
355 | - $sql = 'RENAME TABLE ' . $this->table . ' TO ' . $this->table . '_with_duplicate; '; |
|
356 | - if (!$result = $this->db->queryF($sql)) { |
|
357 | - xoops_error($this->db->error() . '<br>' . $sql); |
|
358 | - |
|
359 | - return false; |
|
360 | - } |
|
361 | - $sql = 'RENAME TABLE ' . $this->table . '_duplicate TO ' . $this->table . '; '; |
|
362 | - if (!$result = $this->db->queryF($sql)) { |
|
363 | - xoops_error($this->db->error() . '<br>' . $sql); |
|
364 | - |
|
365 | - return false; |
|
366 | - } |
|
367 | - $sql = 'SHOW INDEX FROM ' . $this->table . " WHERE KEY_NAME = 'read_item_uid'"; |
|
368 | - $result = $this->db->queryF($sql); |
|
369 | - if (empty($result)) { |
|
370 | - $sql .= 'ALTER TABLE ' . $this->table . ' ADD INDEX read_item_uid ( read_item, uid ); '; |
|
371 | - if (!$result = $this->db->queryF($sql)) { |
|
372 | - xoops_error($this->db->error() . '<br>' . $sql); |
|
373 | - |
|
374 | - return false; |
|
375 | - } |
|
376 | - } |
|
377 | - $sql = 'DROP TABLE ' . $this->table . '_with_duplicate; '; |
|
378 | - if (!$result = $this->db->queryF($sql)) { |
|
379 | - xoops_error($this->db->error() . '<br>' . $sql); |
|
380 | - |
|
381 | - return false; |
|
382 | - } |
|
383 | - |
|
384 | - return true; |
|
385 | - } |
|
386 | - // END irmtfan add clear duplicated rows function |
|
51 | + /** |
|
52 | + * Object type. |
|
53 | + * <ul> |
|
54 | + * <li>forum</li> |
|
55 | + * <li>topic</li> |
|
56 | + * </ul> |
|
57 | + * |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + public $type; |
|
61 | + |
|
62 | + /** |
|
63 | + * seconds records will persist. |
|
64 | + * assigned from $GLOBALS['xoopsModuleConfig']["read_expire"] |
|
65 | + * <ul> |
|
66 | + * <li>positive days = delete all read records exist in the tables before expire time // irmtfan add comment</li> |
|
67 | + * <li>0 = never expires // irmtfan change comment</li> |
|
68 | + * <li>-1 or any negative days = never records // irmtfan change comment</li> |
|
69 | + * </ul> |
|
70 | + * |
|
71 | + * @var integer |
|
72 | + */ |
|
73 | + public $lifetime; |
|
74 | + |
|
75 | + /** |
|
76 | + * storage mode for records. |
|
77 | + * assigned from $GLOBALS['xoopsModuleConfig']["read_mode"] |
|
78 | + * <ul> |
|
79 | + * <li>0 = never records</li> |
|
80 | + * <li>1 = uses cookie</li> |
|
81 | + * <li>2 = stores in database</li> |
|
82 | + * </ul> |
|
83 | + * |
|
84 | + * @var integer |
|
85 | + */ |
|
86 | + public $mode; |
|
87 | + |
|
88 | + /** |
|
89 | + * @param \XoopsDatabase $db |
|
90 | + * @param $type |
|
91 | + */ |
|
92 | + public function __construct(\XoopsDatabase $db, $type) |
|
93 | + { |
|
94 | + $type = ('forum' === $type) ? 'forum' : 'topic'; |
|
95 | + parent::__construct($db, 'newbb_reads_' . $type, Read::class . $type, 'read_id', 'post_id'); |
|
96 | + $this->type = $type; |
|
97 | + $newbbConfig = newbbLoadConfig(); |
|
98 | + // irmtfan if read_expire = 0 dont clean |
|
99 | + $this->lifetime = isset($newbbConfig['read_expire']) ? (int)$newbbConfig['read_expire'] * 24 * 3600 : 30 * 24 * 3600; |
|
100 | + $this->mode = isset($newbbConfig['read_mode']) ? $newbbConfig['read_mode'] : 2; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Clear garbage |
|
105 | + * |
|
106 | + * Delete all expired and duplicated records |
|
107 | + */ |
|
108 | + // START irmtfan rephrase function to 1- add clearDuplicate and 2- dont clean when read_expire = 0 |
|
109 | + public function clearGarbage() |
|
110 | + { |
|
111 | + // irmtfan clear duplicaed rows |
|
112 | + if (!$result = $this->clearDuplicate()) { |
|
113 | + return false; |
|
114 | + } |
|
115 | + |
|
116 | + $sql = 'DELETE bb FROM ' . $this->table . ' AS bb' . ' LEFT JOIN ' . $this->table . ' AS aa ON bb.read_item = aa.read_item ' . ' WHERE aa.post_id > bb.post_id'; |
|
117 | + if (!$result = $this->db->queryF($sql)) { |
|
118 | + //xoops_error($this->db->error()); |
|
119 | + return false; |
|
120 | + } |
|
121 | + // irmtfan if read_expire = 0 dont clean |
|
122 | + if (empty($this->lifetime)) { |
|
123 | + return true; |
|
124 | + } |
|
125 | + // irmtfan move here and rephrase |
|
126 | + $expire = time() - (int)$this->lifetime; |
|
127 | + $sql = 'DELETE FROM ' . $this->table . ' WHERE read_time < ' . $expire; |
|
128 | + if (!$result = $this->db->queryF($sql)) { |
|
129 | + //xoops_error($this->db->error()); |
|
130 | + return false; |
|
131 | + } |
|
132 | + |
|
133 | + return true; |
|
134 | + } |
|
135 | + |
|
136 | + // END irmtfan rephrase function to 1- add clearDuplicate and 2- dont clean when read_expire = 0 |
|
137 | + |
|
138 | + /** |
|
139 | + * @param $read_item |
|
140 | + * @param null $uid |
|
141 | + * @return bool|mixed|null |
|
142 | + */ |
|
143 | + public function getRead($read_item, $uid = null) |
|
144 | + { |
|
145 | + if (empty($this->mode)) { |
|
146 | + return null; |
|
147 | + } |
|
148 | + if (1 == $this->mode) { |
|
149 | + return $this->getReadCookie($read_item); |
|
150 | + } |
|
151 | + |
|
152 | + return $this->getReadDb($read_item, $uid); |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * @param $item_id |
|
157 | + * @return mixed |
|
158 | + */ |
|
159 | + public function getReadCookie($item_id) |
|
160 | + { |
|
161 | + $cookie_name = ('forum' === $this->type) ? 'LF' : 'LT'; |
|
162 | + $cookie_var = $item_id; |
|
163 | + // irmtfan set true to return array |
|
164 | + $lastview = newbbGetCookie($cookie_name, true); |
|
165 | + |
|
166 | + return @$lastview[$cookie_var]; |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * @param $read_item |
|
171 | + * @param $uid |
|
172 | + * @return bool|null |
|
173 | + */ |
|
174 | + public function getReadDb($read_item, $uid) |
|
175 | + { |
|
176 | + if (empty($uid)) { |
|
177 | + if (is_object($GLOBALS['xoopsUser'])) { |
|
178 | + $uid = $GLOBALS['xoopsUser']->getVar('uid'); |
|
179 | + } else { |
|
180 | + return false; |
|
181 | + } |
|
182 | + } |
|
183 | + $sql = 'SELECT post_id ' . ' FROM ' . $this->table . ' WHERE read_item = ' . (int)$read_item . ' AND uid = ' . (int)$uid; |
|
184 | + if (!$result = $this->db->queryF($sql, 1)) { |
|
185 | + return null; |
|
186 | + } |
|
187 | + list($post_id) = $this->db->fetchRow($result); |
|
188 | + |
|
189 | + return $post_id; |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * @param $read_item |
|
194 | + * @param $post_id |
|
195 | + * @param null $uid |
|
196 | + * @return bool|mixed|void |
|
197 | + */ |
|
198 | + public function setRead($read_item, $post_id, $uid = null) |
|
199 | + { |
|
200 | + if (empty($this->mode)) { |
|
201 | + return true; |
|
202 | + } |
|
203 | + |
|
204 | + if (1 == $this->mode) { |
|
205 | + return $this->setReadCookie($read_item, $post_id); |
|
206 | + } |
|
207 | + |
|
208 | + return $this->setReadDb($read_item, $post_id, $uid); |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * @param $read_item |
|
213 | + * @param $post_id |
|
214 | + */ |
|
215 | + public function setReadCookie($read_item, $post_id) |
|
216 | + { |
|
217 | + $cookie_name = ('forum' === $this->type) ? 'LF' : 'LT'; |
|
218 | + $lastview = newbbGetCookie($cookie_name, true); |
|
219 | + $lastview[$read_item] = time(); |
|
220 | + newbbSetCookie($cookie_name, $lastview); |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * @param $read_item |
|
225 | + * @param $post_id |
|
226 | + * @param $uid |
|
227 | + * @return bool|mixed |
|
228 | + */ |
|
229 | + public function setReadDb($read_item, $post_id, $uid) |
|
230 | + { |
|
231 | + if (empty($uid)) { |
|
232 | + if (is_object($GLOBALS['xoopsUser'])) { |
|
233 | + $uid = $GLOBALS['xoopsUser']->getVar('uid'); |
|
234 | + } else { |
|
235 | + return false; |
|
236 | + } |
|
237 | + } |
|
238 | + |
|
239 | + $sql = 'UPDATE ' . $this->table . ' SET post_id = ' . (int)$post_id . ',' . ' read_time =' . time() . ' WHERE read_item = ' . (int)$read_item . ' AND uid = ' . (int)$uid; |
|
240 | + if ($this->db->queryF($sql) && $this->db->getAffectedRows()) { |
|
241 | + return true; |
|
242 | + } |
|
243 | + $object = $this->create(); |
|
244 | + $object->setVar('read_item', $read_item); |
|
245 | + $object->setVar('post_id', $post_id); |
|
246 | + $object->setVar('uid', $uid); |
|
247 | + $object->setVar('read_time', time()); |
|
248 | + |
|
249 | + return parent::insert($object); |
|
250 | + } |
|
251 | + |
|
252 | + /** |
|
253 | + * @param $items |
|
254 | + * @param null $uid |
|
255 | + * @return array|null |
|
256 | + */ |
|
257 | + public function isReadItems(&$items, $uid = null) |
|
258 | + { |
|
259 | + $ret = null; |
|
260 | + if (empty($this->mode)) { |
|
261 | + return $ret; |
|
262 | + } |
|
263 | + |
|
264 | + if (1 == $this->mode) { |
|
265 | + $ret = $this->isReadItemsCookie($items); |
|
266 | + } else { |
|
267 | + $ret = $this->isReadItemsDb($items, $uid); |
|
268 | + } |
|
269 | + |
|
270 | + return $ret; |
|
271 | + } |
|
272 | + |
|
273 | + /** |
|
274 | + * @param $items |
|
275 | + * @return array |
|
276 | + */ |
|
277 | + public function isReadItemsCookie(&$items) |
|
278 | + { |
|
279 | + $cookie_name = ('forum' === $this->type) ? 'LF' : 'LT'; |
|
280 | + $cookie_vars = newbbGetCookie($cookie_name, true); |
|
281 | + |
|
282 | + $ret = []; |
|
283 | + foreach ($items as $key => $last_update) { |
|
284 | + $ret[$key] = (max(@$GLOBALS['last_visit'], @$cookie_vars[$key]) >= $last_update); |
|
285 | + } |
|
286 | + |
|
287 | + return $ret; |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * @param $items |
|
292 | + * @param $uid |
|
293 | + * @return array |
|
294 | + */ |
|
295 | + public function isReadItemsDb(&$items, $uid) |
|
296 | + { |
|
297 | + $ret = []; |
|
298 | + if (empty($items)) { |
|
299 | + return $ret; |
|
300 | + } |
|
301 | + |
|
302 | + if (empty($uid)) { |
|
303 | + if (is_object($GLOBALS['xoopsUser'])) { |
|
304 | + $uid = $GLOBALS['xoopsUser']->getVar('uid'); |
|
305 | + } else { |
|
306 | + return $ret; |
|
307 | + } |
|
308 | + } |
|
309 | + |
|
310 | + $criteria = new \CriteriaCompo(new \Criteria('uid', $uid)); |
|
311 | + $criteria->add(new \Criteria('read_item', '(' . implode(', ', array_map('intval', array_keys($items))) . ')', 'IN')); |
|
312 | + $itemsObject = $this->getAll($criteria, ['read_item', 'post_id']); |
|
313 | + |
|
314 | + $items_list = []; |
|
315 | + foreach (array_keys($itemsObject) as $key) { |
|
316 | + $items_list[$itemsObject[$key]->getVar('read_item')] = $itemsObject[$key]->getVar('post_id'); |
|
317 | + } |
|
318 | + unset($itemsObject); |
|
319 | + |
|
320 | + foreach ($items as $key => $last_update) { |
|
321 | + $ret[$key] = (@$items_list[$key] >= $last_update); |
|
322 | + } |
|
323 | + |
|
324 | + return $ret; |
|
325 | + } |
|
326 | + |
|
327 | + // START irmtfan add clear duplicated rows function |
|
328 | + |
|
329 | + /** |
|
330 | + * @return bool |
|
331 | + */ |
|
332 | + public function clearDuplicate() |
|
333 | + { |
|
334 | + /** |
|
335 | + * This is needed for the following query GROUP BY clauses to work in MySQL 5.7. |
|
336 | + * This is a TEMPORARY fix. Needing this function is bad in the first place, but |
|
337 | + * needing sloppy SQL to make it work is worse. |
|
338 | + * @todo The schema itself should preclude the duplicates |
|
339 | + */ |
|
340 | + $sql = "SET sql_mode=(SELECT REPLACE(@@sql_mode, 'ONLY_FULL_GROUP_BY', ''))"; |
|
341 | + $this->db->queryF($sql); |
|
342 | + |
|
343 | + $sql = 'CREATE TABLE ' . $this->table . '_duplicate LIKE ' . $this->table . '; '; |
|
344 | + if (!$result = $this->db->queryF($sql)) { |
|
345 | + xoops_error($this->db->error() . '<br>' . $sql); |
|
346 | + |
|
347 | + return false; |
|
348 | + } |
|
349 | + $sql = 'INSERT ' . $this->table . '_duplicate SELECT * FROM ' . $this->table . ' GROUP BY read_item, uid; '; |
|
350 | + if (!$result = $this->db->queryF($sql)) { |
|
351 | + xoops_error($this->db->error() . '<br>' . $sql); |
|
352 | + |
|
353 | + return false; |
|
354 | + } |
|
355 | + $sql = 'RENAME TABLE ' . $this->table . ' TO ' . $this->table . '_with_duplicate; '; |
|
356 | + if (!$result = $this->db->queryF($sql)) { |
|
357 | + xoops_error($this->db->error() . '<br>' . $sql); |
|
358 | + |
|
359 | + return false; |
|
360 | + } |
|
361 | + $sql = 'RENAME TABLE ' . $this->table . '_duplicate TO ' . $this->table . '; '; |
|
362 | + if (!$result = $this->db->queryF($sql)) { |
|
363 | + xoops_error($this->db->error() . '<br>' . $sql); |
|
364 | + |
|
365 | + return false; |
|
366 | + } |
|
367 | + $sql = 'SHOW INDEX FROM ' . $this->table . " WHERE KEY_NAME = 'read_item_uid'"; |
|
368 | + $result = $this->db->queryF($sql); |
|
369 | + if (empty($result)) { |
|
370 | + $sql .= 'ALTER TABLE ' . $this->table . ' ADD INDEX read_item_uid ( read_item, uid ); '; |
|
371 | + if (!$result = $this->db->queryF($sql)) { |
|
372 | + xoops_error($this->db->error() . '<br>' . $sql); |
|
373 | + |
|
374 | + return false; |
|
375 | + } |
|
376 | + } |
|
377 | + $sql = 'DROP TABLE ' . $this->table . '_with_duplicate; '; |
|
378 | + if (!$result = $this->db->queryF($sql)) { |
|
379 | + xoops_error($this->db->error() . '<br>' . $sql); |
|
380 | + |
|
381 | + return false; |
|
382 | + } |
|
383 | + |
|
384 | + return true; |
|
385 | + } |
|
386 | + // END irmtfan add clear duplicated rows function |
|
387 | 387 | } |
@@ -17,60 +17,60 @@ |
||
17 | 17 | */ |
18 | 18 | trait ServerStats |
19 | 19 | { |
20 | - /** |
|
21 | - * serverStats() |
|
22 | - * |
|
23 | - * @return string |
|
24 | - */ |
|
25 | - public static function getServerStats() |
|
26 | - { |
|
27 | - //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); |
|
28 | - $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
29 | - $moduleDirNameUpper = strtoupper($moduleDirName); |
|
30 | - xoops_loadLanguage('common', $moduleDirName); |
|
31 | - $html = ''; |
|
32 | - // $sql = 'SELECT metavalue'; |
|
33 | - // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); |
|
34 | - // $sql .= " WHERE metakey='version' LIMIT 1"; |
|
35 | - // $query = $GLOBALS['xoopsDB']->query($sql); |
|
36 | - // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
|
37 | - $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
38 | - $html .= "<div style='padding: 8px;'>\n"; |
|
39 | - // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
|
40 | - // $html .= "<br>\n"; |
|
41 | - // $html .= "<br>\n"; |
|
42 | - $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
43 | - $html .= "<ul>\n"; |
|
44 | - // |
|
45 | - $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
46 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
47 | - if (function_exists('gd_info')) { |
|
48 | - if (true === ($gdlib = gd_info())) { |
|
49 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
50 | - } |
|
51 | - } |
|
52 | - // |
|
53 | - // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF'); |
|
54 | - // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode; |
|
55 | - // |
|
56 | - // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
|
57 | - // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
|
58 | - // |
|
59 | - $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
60 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
61 | - // |
|
62 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n"; |
|
63 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n"; |
|
64 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n"; |
|
65 | - $html .= "</ul>\n"; |
|
66 | - $html .= "<ul>\n"; |
|
67 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
68 | - $html .= "</ul>\n"; |
|
69 | - $html .= "<br>\n"; |
|
70 | - $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
71 | - $html .= '</div>'; |
|
72 | - $html .= '</fieldset><br>'; |
|
20 | + /** |
|
21 | + * serverStats() |
|
22 | + * |
|
23 | + * @return string |
|
24 | + */ |
|
25 | + public static function getServerStats() |
|
26 | + { |
|
27 | + //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); |
|
28 | + $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
29 | + $moduleDirNameUpper = strtoupper($moduleDirName); |
|
30 | + xoops_loadLanguage('common', $moduleDirName); |
|
31 | + $html = ''; |
|
32 | + // $sql = 'SELECT metavalue'; |
|
33 | + // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); |
|
34 | + // $sql .= " WHERE metakey='version' LIMIT 1"; |
|
35 | + // $query = $GLOBALS['xoopsDB']->query($sql); |
|
36 | + // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
|
37 | + $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
38 | + $html .= "<div style='padding: 8px;'>\n"; |
|
39 | + // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
|
40 | + // $html .= "<br>\n"; |
|
41 | + // $html .= "<br>\n"; |
|
42 | + $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
43 | + $html .= "<ul>\n"; |
|
44 | + // |
|
45 | + $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
46 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
47 | + if (function_exists('gd_info')) { |
|
48 | + if (true === ($gdlib = gd_info())) { |
|
49 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
50 | + } |
|
51 | + } |
|
52 | + // |
|
53 | + // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF'); |
|
54 | + // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode; |
|
55 | + // |
|
56 | + // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
|
57 | + // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
|
58 | + // |
|
59 | + $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
60 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
61 | + // |
|
62 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n"; |
|
63 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n"; |
|
64 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n"; |
|
65 | + $html .= "</ul>\n"; |
|
66 | + $html .= "<ul>\n"; |
|
67 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
68 | + $html .= "</ul>\n"; |
|
69 | + $html .= "<br>\n"; |
|
70 | + $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
71 | + $html .= '</div>'; |
|
72 | + $html .= '</fieldset><br>'; |
|
73 | 73 | |
74 | - return $html; |
|
75 | - } |
|
74 | + return $html; |
|
75 | + } |
|
76 | 76 | } |
@@ -17,229 +17,229 @@ |
||
17 | 17 | */ |
18 | 18 | trait FilesManagement |
19 | 19 | { |
20 | - /** |
|
21 | - * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
22 | - * |
|
23 | - * @param string $folder The full path of the directory to check |
|
24 | - * |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public static function createFolder($folder) |
|
28 | - { |
|
29 | - try { |
|
30 | - if (!file_exists($folder)) { |
|
31 | - if (!is_dir($folder) && !mkdir($folder) && !is_dir($folder)) { |
|
32 | - throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
33 | - } |
|
34 | - |
|
35 | - file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
36 | - } |
|
37 | - } catch (\Exception $e) { |
|
38 | - echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
39 | - } |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @param $file |
|
44 | - * @param $folder |
|
45 | - * @return bool |
|
46 | - */ |
|
47 | - public static function copyFile($file, $folder) |
|
48 | - { |
|
49 | - return copy($file, $folder); |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @param $src |
|
54 | - * @param $dst |
|
55 | - */ |
|
56 | - public static function recurseCopy($src, $dst) |
|
57 | - { |
|
58 | - $dir = opendir($src); |
|
59 | - // @mkdir($dst); |
|
60 | - if (!@mkdir($dst) && !is_dir($dst)) { |
|
61 | - throw new \RuntimeException('The directory ' . $dst . ' could not be created.'); |
|
62 | - } |
|
63 | - while (false !== ($file = readdir($dir))) { |
|
64 | - if (('.' !== $file) && ('..' !== $file)) { |
|
65 | - if (is_dir($src . '/' . $file)) { |
|
66 | - self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
67 | - } else { |
|
68 | - copy($src . '/' . $file, $dst . '/' . $file); |
|
69 | - } |
|
70 | - } |
|
71 | - } |
|
72 | - closedir($dir); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * |
|
77 | - * Remove files and (sub)directories |
|
78 | - * |
|
79 | - * @param string $src source directory to delete |
|
80 | - * |
|
81 | - * @uses \Xmf\Module\Helper::getHelper() |
|
82 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
83 | - * |
|
84 | - * @return bool true on success |
|
85 | - */ |
|
86 | - public static function deleteDirectory($src) |
|
87 | - { |
|
88 | - // Only continue if user is a 'global' Admin |
|
89 | - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
90 | - return false; |
|
91 | - } |
|
92 | - |
|
93 | - $success = true; |
|
94 | - // remove old files |
|
95 | - $dirInfo = new \SplFileInfo($src); |
|
96 | - // validate is a directory |
|
97 | - if ($dirInfo->isDir()) { |
|
98 | - $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); |
|
99 | - foreach ($fileList as $k => $v) { |
|
100 | - $fileInfo = new \SplFileInfo("{$src}/{$v}"); |
|
101 | - if ($fileInfo->isDir()) { |
|
102 | - // recursively handle subdirectories |
|
103 | - if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
104 | - break; |
|
105 | - } |
|
106 | - } else { |
|
107 | - // delete the file |
|
108 | - if (!($success = unlink($fileInfo->getRealPath()))) { |
|
109 | - break; |
|
110 | - } |
|
111 | - } |
|
112 | - } |
|
113 | - // now delete this (sub)directory if all the files are gone |
|
114 | - if ($success) { |
|
115 | - $success = rmdir($dirInfo->getRealPath()); |
|
116 | - } |
|
117 | - } else { |
|
118 | - // input is not a valid directory |
|
119 | - $success = false; |
|
120 | - } |
|
121 | - return $success; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * |
|
126 | - * Recursively remove directory |
|
127 | - * |
|
128 | - * @todo currently won't remove directories with hidden files, should it? |
|
129 | - * |
|
130 | - * @param string $src directory to remove (delete) |
|
131 | - * |
|
132 | - * @return bool true on success |
|
133 | - */ |
|
134 | - public static function rrmdir($src) |
|
135 | - { |
|
136 | - // Only continue if user is a 'global' Admin |
|
137 | - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
138 | - return false; |
|
139 | - } |
|
140 | - |
|
141 | - // If source is not a directory stop processing |
|
142 | - if (!is_dir($src)) { |
|
143 | - return false; |
|
144 | - } |
|
145 | - |
|
146 | - $success = true; |
|
147 | - |
|
148 | - // Open the source directory to read in files |
|
149 | - $iterator = new \DirectoryIterator($src); |
|
150 | - foreach ($iterator as $fObj) { |
|
151 | - if ($fObj->isFile()) { |
|
152 | - $filename = $fObj->getPathname(); |
|
153 | - $fObj = null; // clear this iterator object to close the file |
|
154 | - if (!unlink($filename)) { |
|
155 | - return false; // couldn't delete the file |
|
156 | - } |
|
157 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
158 | - // Try recursively on directory |
|
159 | - self::rrmdir($fObj->getPathname()); |
|
160 | - } |
|
161 | - } |
|
162 | - $iterator = null; // clear iterator Obj to close file/directory |
|
163 | - return rmdir($src); // remove the directory & return results |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * Recursively move files from one directory to another |
|
168 | - * |
|
169 | - * @param string $src - Source of files being moved |
|
170 | - * @param string $dest - Destination of files being moved |
|
171 | - * |
|
172 | - * @return bool true on success |
|
173 | - */ |
|
174 | - public static function rmove($src, $dest) |
|
175 | - { |
|
176 | - // Only continue if user is a 'global' Admin |
|
177 | - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
178 | - return false; |
|
179 | - } |
|
180 | - |
|
181 | - // If source is not a directory stop processing |
|
182 | - if (!is_dir($src)) { |
|
183 | - return false; |
|
184 | - } |
|
185 | - |
|
186 | - // If the destination directory does not exist and could not be created stop processing |
|
187 | - if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) { |
|
188 | - return false; |
|
189 | - } |
|
190 | - |
|
191 | - // Open the source directory to read in files |
|
192 | - $iterator = new \DirectoryIterator($src); |
|
193 | - foreach ($iterator as $fObj) { |
|
194 | - if ($fObj->isFile()) { |
|
195 | - rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
196 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
197 | - // Try recursively on directory |
|
198 | - self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
199 | - // rmdir($fObj->getPath()); // now delete the directory |
|
200 | - } |
|
201 | - } |
|
202 | - $iterator = null; // clear iterator Obj to close file/directory |
|
203 | - return rmdir($src); // remove the directory & return results |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * Recursively copy directories and files from one directory to another |
|
208 | - * |
|
209 | - * @param string $src - Source of files being moved |
|
210 | - * @param string $dest - Destination of files being moved |
|
211 | - * |
|
212 | - * @uses \Xmf\Module\Helper::getHelper() |
|
213 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
214 | - * |
|
215 | - * @return bool true on success |
|
216 | - */ |
|
217 | - public static function rcopy($src, $dest) |
|
218 | - { |
|
219 | - // Only continue if user is a 'global' Admin |
|
220 | - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
221 | - return false; |
|
222 | - } |
|
223 | - |
|
224 | - // If source is not a directory stop processing |
|
225 | - if (!is_dir($src)) { |
|
226 | - return false; |
|
227 | - } |
|
228 | - |
|
229 | - // If the destination directory does not exist and could not be created stop processing |
|
230 | - if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) { |
|
231 | - return false; |
|
232 | - } |
|
233 | - |
|
234 | - // Open the source directory to read in files |
|
235 | - $iterator = new \DirectoryIterator($src); |
|
236 | - foreach ($iterator as $fObj) { |
|
237 | - if ($fObj->isFile()) { |
|
238 | - copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
239 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
240 | - self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
241 | - } |
|
242 | - } |
|
243 | - return true; |
|
244 | - } |
|
20 | + /** |
|
21 | + * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
22 | + * |
|
23 | + * @param string $folder The full path of the directory to check |
|
24 | + * |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public static function createFolder($folder) |
|
28 | + { |
|
29 | + try { |
|
30 | + if (!file_exists($folder)) { |
|
31 | + if (!is_dir($folder) && !mkdir($folder) && !is_dir($folder)) { |
|
32 | + throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
33 | + } |
|
34 | + |
|
35 | + file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
36 | + } |
|
37 | + } catch (\Exception $e) { |
|
38 | + echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
39 | + } |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @param $file |
|
44 | + * @param $folder |
|
45 | + * @return bool |
|
46 | + */ |
|
47 | + public static function copyFile($file, $folder) |
|
48 | + { |
|
49 | + return copy($file, $folder); |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @param $src |
|
54 | + * @param $dst |
|
55 | + */ |
|
56 | + public static function recurseCopy($src, $dst) |
|
57 | + { |
|
58 | + $dir = opendir($src); |
|
59 | + // @mkdir($dst); |
|
60 | + if (!@mkdir($dst) && !is_dir($dst)) { |
|
61 | + throw new \RuntimeException('The directory ' . $dst . ' could not be created.'); |
|
62 | + } |
|
63 | + while (false !== ($file = readdir($dir))) { |
|
64 | + if (('.' !== $file) && ('..' !== $file)) { |
|
65 | + if (is_dir($src . '/' . $file)) { |
|
66 | + self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
67 | + } else { |
|
68 | + copy($src . '/' . $file, $dst . '/' . $file); |
|
69 | + } |
|
70 | + } |
|
71 | + } |
|
72 | + closedir($dir); |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * |
|
77 | + * Remove files and (sub)directories |
|
78 | + * |
|
79 | + * @param string $src source directory to delete |
|
80 | + * |
|
81 | + * @uses \Xmf\Module\Helper::getHelper() |
|
82 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
83 | + * |
|
84 | + * @return bool true on success |
|
85 | + */ |
|
86 | + public static function deleteDirectory($src) |
|
87 | + { |
|
88 | + // Only continue if user is a 'global' Admin |
|
89 | + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
90 | + return false; |
|
91 | + } |
|
92 | + |
|
93 | + $success = true; |
|
94 | + // remove old files |
|
95 | + $dirInfo = new \SplFileInfo($src); |
|
96 | + // validate is a directory |
|
97 | + if ($dirInfo->isDir()) { |
|
98 | + $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); |
|
99 | + foreach ($fileList as $k => $v) { |
|
100 | + $fileInfo = new \SplFileInfo("{$src}/{$v}"); |
|
101 | + if ($fileInfo->isDir()) { |
|
102 | + // recursively handle subdirectories |
|
103 | + if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
104 | + break; |
|
105 | + } |
|
106 | + } else { |
|
107 | + // delete the file |
|
108 | + if (!($success = unlink($fileInfo->getRealPath()))) { |
|
109 | + break; |
|
110 | + } |
|
111 | + } |
|
112 | + } |
|
113 | + // now delete this (sub)directory if all the files are gone |
|
114 | + if ($success) { |
|
115 | + $success = rmdir($dirInfo->getRealPath()); |
|
116 | + } |
|
117 | + } else { |
|
118 | + // input is not a valid directory |
|
119 | + $success = false; |
|
120 | + } |
|
121 | + return $success; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * |
|
126 | + * Recursively remove directory |
|
127 | + * |
|
128 | + * @todo currently won't remove directories with hidden files, should it? |
|
129 | + * |
|
130 | + * @param string $src directory to remove (delete) |
|
131 | + * |
|
132 | + * @return bool true on success |
|
133 | + */ |
|
134 | + public static function rrmdir($src) |
|
135 | + { |
|
136 | + // Only continue if user is a 'global' Admin |
|
137 | + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
138 | + return false; |
|
139 | + } |
|
140 | + |
|
141 | + // If source is not a directory stop processing |
|
142 | + if (!is_dir($src)) { |
|
143 | + return false; |
|
144 | + } |
|
145 | + |
|
146 | + $success = true; |
|
147 | + |
|
148 | + // Open the source directory to read in files |
|
149 | + $iterator = new \DirectoryIterator($src); |
|
150 | + foreach ($iterator as $fObj) { |
|
151 | + if ($fObj->isFile()) { |
|
152 | + $filename = $fObj->getPathname(); |
|
153 | + $fObj = null; // clear this iterator object to close the file |
|
154 | + if (!unlink($filename)) { |
|
155 | + return false; // couldn't delete the file |
|
156 | + } |
|
157 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
158 | + // Try recursively on directory |
|
159 | + self::rrmdir($fObj->getPathname()); |
|
160 | + } |
|
161 | + } |
|
162 | + $iterator = null; // clear iterator Obj to close file/directory |
|
163 | + return rmdir($src); // remove the directory & return results |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Recursively move files from one directory to another |
|
168 | + * |
|
169 | + * @param string $src - Source of files being moved |
|
170 | + * @param string $dest - Destination of files being moved |
|
171 | + * |
|
172 | + * @return bool true on success |
|
173 | + */ |
|
174 | + public static function rmove($src, $dest) |
|
175 | + { |
|
176 | + // Only continue if user is a 'global' Admin |
|
177 | + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
178 | + return false; |
|
179 | + } |
|
180 | + |
|
181 | + // If source is not a directory stop processing |
|
182 | + if (!is_dir($src)) { |
|
183 | + return false; |
|
184 | + } |
|
185 | + |
|
186 | + // If the destination directory does not exist and could not be created stop processing |
|
187 | + if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) { |
|
188 | + return false; |
|
189 | + } |
|
190 | + |
|
191 | + // Open the source directory to read in files |
|
192 | + $iterator = new \DirectoryIterator($src); |
|
193 | + foreach ($iterator as $fObj) { |
|
194 | + if ($fObj->isFile()) { |
|
195 | + rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
196 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
197 | + // Try recursively on directory |
|
198 | + self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
199 | + // rmdir($fObj->getPath()); // now delete the directory |
|
200 | + } |
|
201 | + } |
|
202 | + $iterator = null; // clear iterator Obj to close file/directory |
|
203 | + return rmdir($src); // remove the directory & return results |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * Recursively copy directories and files from one directory to another |
|
208 | + * |
|
209 | + * @param string $src - Source of files being moved |
|
210 | + * @param string $dest - Destination of files being moved |
|
211 | + * |
|
212 | + * @uses \Xmf\Module\Helper::getHelper() |
|
213 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
214 | + * |
|
215 | + * @return bool true on success |
|
216 | + */ |
|
217 | + public static function rcopy($src, $dest) |
|
218 | + { |
|
219 | + // Only continue if user is a 'global' Admin |
|
220 | + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
221 | + return false; |
|
222 | + } |
|
223 | + |
|
224 | + // If source is not a directory stop processing |
|
225 | + if (!is_dir($src)) { |
|
226 | + return false; |
|
227 | + } |
|
228 | + |
|
229 | + // If the destination directory does not exist and could not be created stop processing |
|
230 | + if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) { |
|
231 | + return false; |
|
232 | + } |
|
233 | + |
|
234 | + // Open the source directory to read in files |
|
235 | + $iterator = new \DirectoryIterator($src); |
|
236 | + foreach ($iterator as $fObj) { |
|
237 | + if ($fObj->isFile()) { |
|
238 | + copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
239 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
240 | + self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
241 | + } |
|
242 | + } |
|
243 | + return true; |
|
244 | + } |
|
245 | 245 | } |
@@ -12,96 +12,96 @@ |
||
12 | 12 | |
13 | 13 | class Digest extends \XoopsObject |
14 | 14 | { |
15 | - public $digest_id; |
|
16 | - public $digest_time; |
|
17 | - public $digest_content; |
|
15 | + public $digest_id; |
|
16 | + public $digest_time; |
|
17 | + public $digest_content; |
|
18 | 18 | |
19 | - public $items; |
|
20 | - public $isHtml = false; |
|
21 | - public $isSummary = true; |
|
19 | + public $items; |
|
20 | + public $isHtml = false; |
|
21 | + public $isSummary = true; |
|
22 | 22 | |
23 | - /** |
|
24 | - * |
|
25 | - */ |
|
26 | - public function __construct() |
|
27 | - { |
|
28 | - parent::__construct(); |
|
29 | - $this->initVar('digest_id', XOBJ_DTYPE_INT); |
|
30 | - $this->initVar('digest_time', XOBJ_DTYPE_INT); |
|
31 | - $this->initVar('digest_content', XOBJ_DTYPE_TXTAREA); |
|
32 | - $this->items = []; |
|
33 | - } |
|
23 | + /** |
|
24 | + * |
|
25 | + */ |
|
26 | + public function __construct() |
|
27 | + { |
|
28 | + parent::__construct(); |
|
29 | + $this->initVar('digest_id', XOBJ_DTYPE_INT); |
|
30 | + $this->initVar('digest_time', XOBJ_DTYPE_INT); |
|
31 | + $this->initVar('digest_content', XOBJ_DTYPE_TXTAREA); |
|
32 | + $this->items = []; |
|
33 | + } |
|
34 | 34 | |
35 | - public function setHtml() |
|
36 | - { |
|
37 | - $this->isHtml = true; |
|
38 | - } |
|
35 | + public function setHtml() |
|
36 | + { |
|
37 | + $this->isHtml = true; |
|
38 | + } |
|
39 | 39 | |
40 | - public function setSummary() |
|
41 | - { |
|
42 | - $this->isSummary = true; |
|
43 | - } |
|
40 | + public function setSummary() |
|
41 | + { |
|
42 | + $this->isSummary = true; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param $title |
|
47 | - * @param $link |
|
48 | - * @param $author |
|
49 | - * @param string $summary |
|
50 | - */ |
|
51 | - public function addItem($title, $link, $author, $summary = '') |
|
52 | - { |
|
53 | - $title = $this->cleanup($title); |
|
54 | - $author = $this->cleanup($author); |
|
55 | - if (!empty($summary)) { |
|
56 | - $summary = $this->cleanup($summary); |
|
57 | - } |
|
58 | - $this->items[] = ['title' => $title, 'link' => $link, 'author' => $author, 'summary' => $summary]; |
|
59 | - } |
|
45 | + /** |
|
46 | + * @param $title |
|
47 | + * @param $link |
|
48 | + * @param $author |
|
49 | + * @param string $summary |
|
50 | + */ |
|
51 | + public function addItem($title, $link, $author, $summary = '') |
|
52 | + { |
|
53 | + $title = $this->cleanup($title); |
|
54 | + $author = $this->cleanup($author); |
|
55 | + if (!empty($summary)) { |
|
56 | + $summary = $this->cleanup($summary); |
|
57 | + } |
|
58 | + $this->items[] = ['title' => $title, 'link' => $link, 'author' => $author, 'summary' => $summary]; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param $text |
|
63 | - * @return mixed|string |
|
64 | - */ |
|
65 | - public function cleanup($text) |
|
66 | - { |
|
67 | - global $myts; |
|
61 | + /** |
|
62 | + * @param $text |
|
63 | + * @return mixed|string |
|
64 | + */ |
|
65 | + public function cleanup($text) |
|
66 | + { |
|
67 | + global $myts; |
|
68 | 68 | |
69 | - $clean = stripslashes($text); |
|
70 | - $clean =& $myts->displayTarea($clean, 1, 0, 1); |
|
71 | - $clean = strip_tags($clean); |
|
72 | - $clean = htmlspecialchars($clean, ENT_QUOTES); |
|
69 | + $clean = stripslashes($text); |
|
70 | + $clean =& $myts->displayTarea($clean, 1, 0, 1); |
|
71 | + $clean = strip_tags($clean); |
|
72 | + $clean = htmlspecialchars($clean, ENT_QUOTES); |
|
73 | 73 | |
74 | 74 | |
75 | - return $clean; |
|
76 | - } |
|
75 | + return $clean; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param bool $isSummary |
|
80 | - * @param bool $isHtml |
|
81 | - * @return bool |
|
82 | - */ |
|
83 | - public function buildContent($isSummary = true, $isHtml = false) |
|
84 | - { |
|
85 | - $digest_count = count($this->items); |
|
86 | - $content = ''; |
|
87 | - if ($digest_count > 0) { |
|
88 | - $linebreak = $isHtml ? '<br>' : "\n"; |
|
89 | - for ($i = 0; $i < $digest_count; ++$i) { |
|
90 | - if ($isHtml) { |
|
91 | - $content .= ($i + 1) . '. <a href=' . $this->items[$i]['link'] . '>' . $this->items[$i]['title'] . '</a>'; |
|
92 | - } else { |
|
93 | - $content .= ($i + 1) . '. ' . $this->items[$i]['title'] . $linebreak . $this->items[$i]['link']; |
|
94 | - } |
|
78 | + /** |
|
79 | + * @param bool $isSummary |
|
80 | + * @param bool $isHtml |
|
81 | + * @return bool |
|
82 | + */ |
|
83 | + public function buildContent($isSummary = true, $isHtml = false) |
|
84 | + { |
|
85 | + $digest_count = count($this->items); |
|
86 | + $content = ''; |
|
87 | + if ($digest_count > 0) { |
|
88 | + $linebreak = $isHtml ? '<br>' : "\n"; |
|
89 | + for ($i = 0; $i < $digest_count; ++$i) { |
|
90 | + if ($isHtml) { |
|
91 | + $content .= ($i + 1) . '. <a href=' . $this->items[$i]['link'] . '>' . $this->items[$i]['title'] . '</a>'; |
|
92 | + } else { |
|
93 | + $content .= ($i + 1) . '. ' . $this->items[$i]['title'] . $linebreak . $this->items[$i]['link']; |
|
94 | + } |
|
95 | 95 | |
96 | - $content .= $linebreak . $this->items[$i]['author']; |
|
97 | - if ($isSummary) { |
|
98 | - $content .= $linebreak . $this->items[$i]['summary']; |
|
99 | - } |
|
100 | - $content .= $linebreak . $linebreak; |
|
101 | - } |
|
102 | - } |
|
103 | - $this->setVar('digest_content', $content); |
|
96 | + $content .= $linebreak . $this->items[$i]['author']; |
|
97 | + if ($isSummary) { |
|
98 | + $content .= $linebreak . $this->items[$i]['summary']; |
|
99 | + } |
|
100 | + $content .= $linebreak . $linebreak; |
|
101 | + } |
|
102 | + } |
|
103 | + $this->setVar('digest_content', $content); |
|
104 | 104 | |
105 | - return true; |
|
106 | - } |
|
105 | + return true; |
|
106 | + } |
|
107 | 107 | } |
@@ -45,11 +45,11 @@ |
||
45 | 45 | */ |
46 | 46 | class ReadForum extends Newbb\Read |
47 | 47 | { |
48 | - /** |
|
49 | - * |
|
50 | - */ |
|
51 | - public function __construct() |
|
52 | - { |
|
53 | - parent::__construct(); |
|
54 | - } |
|
48 | + /** |
|
49 | + * |
|
50 | + */ |
|
51 | + public function __construct() |
|
52 | + { |
|
53 | + parent::__construct(); |
|
54 | + } |
|
55 | 55 | } |