Passed
Branch master (565d4a)
by Michael
15:11 queued 01:11
created
newtopic.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
 require_once __DIR__ . '/header.php';
15 15
 
16 16
 if (!$forum = Request::getString('forum', '', 'GET')) {
17
-    redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_ERRORFORUM);
17
+	redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_ERRORFORUM);
18 18
 }
19 19
 
20 20
 ///** @var Newbb\ForumHandler $forumHandler */
21 21
 //$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
22 22
 $forumObject = $forumHandler->get($forum);
23 23
 if (!$forumHandler->getPermission($forumObject)) {
24
-    redirect_header(XOOPS_URL . '/index.php', 2, _NOPERM);
24
+	redirect_header(XOOPS_URL . '/index.php', 2, _NOPERM);
25 25
 }
26 26
 
27 27
 ///** @var Newbb\TopicHandler $topicHandler */
@@ -29,25 +29,25 @@  discard block
 block discarded – undo
29 29
 $topicObject = $topicHandler->create();
30 30
 $topicObject->setVar('forum_id', $forum);
31 31
 if (!$topicHandler->getPermission($forumObject, 0, 'post')) {
32
-    /*
32
+	/*
33 33
      * Build the page query
34 34
      */
35
-    $query_vars  = ['forum', 'order', 'mode', 'viewmode'];
36
-    $query_array = [];
37
-    foreach ($query_vars as $var) {
38
-        if (Request::getString($var, '', 'GET')) {
39
-            $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET');
40
-        }
41
-    }
42
-    $page_query = htmlspecialchars(implode('&', array_values($query_array)), ENT_QUOTES | ENT_HTML5);
43
-    unset($query_array);
44
-    redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query}", 2, _MD_NEWBB_NORIGHTTOPOST);
35
+	$query_vars  = ['forum', 'order', 'mode', 'viewmode'];
36
+	$query_array = [];
37
+	foreach ($query_vars as $var) {
38
+		if (Request::getString($var, '', 'GET')) {
39
+			$query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET');
40
+		}
41
+	}
42
+	$page_query = htmlspecialchars(implode('&', array_values($query_array)), ENT_QUOTES | ENT_HTML5);
43
+	unset($query_array);
44
+	redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query}", 2, _MD_NEWBB_NORIGHTTOPOST);
45 45
 }
46 46
 
47 47
 if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) {
48
-    //    /** @var Newbb\OnlineHandler $onlineHandler */
49
-    //    $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online');
50
-    $onlineHandler->init($forumObject);
48
+	//    /** @var Newbb\OnlineHandler $onlineHandler */
49
+	//    $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online');
50
+	$onlineHandler->init($forumObject);
51 51
 }
52 52
 
53 53
 $xoopsOption['template_main']                                        = 'newbb_edit_post.tpl';
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 require_once $GLOBALS['xoops']->path('header.php');
56 56
 
57 57
 if (1 == $GLOBALS['xoopsModuleConfig']['disc_show'] || 3 == $GLOBALS['xoopsModuleConfig']['disc_show']) {
58
-    $xoopsTpl->assign('disclaimer', $GLOBALS['xoopsModuleConfig']['disclaimer']);
58
+	$xoopsTpl->assign('disclaimer', $GLOBALS['xoopsModuleConfig']['disclaimer']);
59 59
 }
60 60
 
61 61
 $subject       = '';
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@  discard block
 block discarded – undo
11 11
 
12 12
 use Xmf\Request;
13 13
 
14
-require_once __DIR__ . '/header.php';
14
+require_once __DIR__.'/header.php';
15 15
 
16 16
 if (!$forum = Request::getString('forum', '', 'GET')) {
17
-    redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_ERRORFORUM);
17
+    redirect_header(XOOPS_URL.'/index.php', 2, _MD_NEWBB_ERRORFORUM);
18 18
 }
19 19
 
20 20
 ///** @var Newbb\ForumHandler $forumHandler */
21 21
 //$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
22 22
 $forumObject = $forumHandler->get($forum);
23 23
 if (!$forumHandler->getPermission($forumObject)) {
24
-    redirect_header(XOOPS_URL . '/index.php', 2, _NOPERM);
24
+    redirect_header(XOOPS_URL.'/index.php', 2, _NOPERM);
25 25
 }
26 26
 
27 27
 ///** @var Newbb\TopicHandler $topicHandler */
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
     $query_array = [];
37 37
     foreach ($query_vars as $var) {
38 38
         if (Request::getString($var, '', 'GET')) {
39
-            $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET');
39
+            $query_array[$var] = "{$var}=".Request::getString($var, '', 'GET');
40 40
         }
41 41
     }
42 42
     $page_query = htmlspecialchars(implode('&', array_values($query_array)), ENT_QUOTES | ENT_HTML5);
43 43
     unset($query_array);
44
-    redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?{$page_query}", 2, _MD_NEWBB_NORIGHTTOPOST);
44
+    redirect_header(XOOPS_URL."/modules/newbb/viewforum.php?{$page_query}", 2, _MD_NEWBB_NORIGHTTOPOST);
45 45
 }
46 46
 
47 47
 if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) {
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 $attachsig     = (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->getVar('attachsig')) ? 1 : 0;
71 71
 $post_id       = 0;
72 72
 $topic_id      = 0;
73
-require_once __DIR__   . '/include/form.post.php';
73
+require_once __DIR__.'/include/form.post.php';
74 74
 
75
-require_once __DIR__ . '/footer.php';
75
+require_once __DIR__.'/footer.php';
76 76
 require_once $GLOBALS['xoops']->path('footer.php');
Please login to merge, or discard this patch.
topicmanager.php 2 patches
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -35,25 +35,25 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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&amp;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&amp;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&amp;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&amp;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&amp;topic_id=$topic_id&amp;order=$order&amp;viewmode=$viewmode", 2, _MD_NEWBB_ERROR_BACK . '<br>sql: ' . $sql);
296
-            }
297
-        } else {
298
-            redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&amp;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&amp;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&amp;topic_id=$topic_id&amp;order=$order&amp;viewmode=$viewmode", 2, _MD_NEWBB_ERROR_BACK . '<br>sql: ' . $sql);
296
+			}
297
+		} else {
298
+			redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&amp;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&amp;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 . "&nbsp;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 . "&nbsp;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';
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -32,27 +32,27 @@  discard block
 block discarded – undo
32 32
 //  URL: https://xoops.org                                                    //
33 33
 //  Project: Article Project                                                 //
34 34
 //  ------------------------------------------------------------------------ //
35
-require_once __DIR__ . '/header.php';
35
+require_once __DIR__.'/header.php';
36 36
 
37 37
 if (Request::getString('submit', '', 'POST')) {
38 38
     foreach (['forum', 'newforum', 'newtopic'] as $getint) {
39
-        ${$getint} = Request::getInt($getint, 0, 'POST');// (int)(@$_POST[$getint]);
39
+        ${$getint} = Request::getInt($getint, 0, 'POST'); // (int)(@$_POST[$getint]);
40 40
     }
41 41
     foreach (['topic_id'] as $getint) {
42
-        ${$getint} = Request::getInt($getint, 0, 'POST');// (int)(@$_POST[$getint]);
42
+        ${$getint} = Request::getInt($getint, 0, 'POST'); // (int)(@$_POST[$getint]);
43 43
     }
44 44
     if (!is_array($topic_id)) {
45 45
         $topic_id = [$topic_id];
46 46
     }
47 47
 } else {
48 48
     foreach (['forum', 'topic_id'] as $getint) {
49
-        ${$getint} = Request::getInt($getint, 0, 'GET');// (int)(@$_GET[$getint]);
49
+        ${$getint} = Request::getInt($getint, 0, 'GET'); // (int)(@$_GET[$getint]);
50 50
     }
51 51
 }
52 52
 
53 53
 if (empty($topic_id)) {
54 54
     $redirect = empty($forum_id) ? 'index.php' : 'viewforum.php?forum={$forum}';
55
-    $redirect = XOOPS_URL . '/modules/newbb/' . $redirect;
55
+    $redirect = XOOPS_URL.'/modules/newbb/'.$redirect;
56 56
     redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
57 57
 }
58 58
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     if (is_object($topicObject)) {
68 68
         $forum = $topicObject->getVar('forum_id');
69 69
     } else {
70
-        $redirect = XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $topic_id;
70
+        $redirect = XOOPS_URL.'/modules/newbb/viewtopic.php?topic_id='.$topic_id;
71 71
         redirect_header($redirect, 2, _MD_NEWBB_FORUMNOEXIST);
72 72
     }
73 73
     unset($topicObject);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 $action['unlock']['sql']   = 'topic_status = 0';
105 105
 $action['unsticky']['sql'] = 'topic_sticky = 0';
106 106
 $action['undigest']['sql'] = 'topic_digest = 0';
107
-$action['digest']['sql']   = 'topic_digest = 1, digest_time = ' . time();
107
+$action['digest']['sql']   = 'topic_digest = 1, digest_time = '.time();
108 108
 
109 109
 // Disable cache
110 110
 $GLOBALS['xoopsConfig']['module_cache'][$xoopsModule->getVar('mid')] = 0;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
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 117
     if ('delete' === $mode) {
118 118
         foreach ($topic_id as $tid) {
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
             //xoops_notification_deletebyitem ($xoopsModule->getVar('mid'), 'thread', $topic_id);
127 127
         }
128 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>';
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 130
     } elseif ('restore' === $mode) {
131 131
         //$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
132 132
         $forums       = [];
133
-        $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN'));
133
+        $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '('.implode(',', $topic_id).')', 'IN'));
134 134
         foreach (array_keys($topicsObject) as $id) {
135 135
             $topicObject = $topicsObject[$id];
136 136
             $topicHandler->approve($topicObject);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             $forums[$topicObject->getVar('forum_id')] = 1;
139 139
         }
140 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');
141
+        $criteria_forum = new \Criteria('forum_id', '('.implode(',', array_keys($forums)).')', 'IN');
142 142
         $forumsObject   = $forumHandler->getAll($criteria_forum);
143 143
         foreach (array_keys($forumsObject) as $id) {
144 144
             $forumHandler->synchronization($forumsObject[$id]);
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             /* return false if destination topic is not existing */
179 179
             // irmtfan bug fix: the old topic will be deleted if user input a not exist new topic
180 180
             if (!is_object($newtopicObject)) {
181
-                $redirect = XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $tid;
181
+                $redirect = XOOPS_URL.'/modules/newbb/viewtopic.php?topic_id='.$tid;
182 182
                 redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
183 183
             }
184 184
             $criteria_topic = new \Criteria('topic_id', $tid);
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
             if ($poll_id > 0 && (0 == $newtopicObject->getVar('poll_id'))) {
203 203
                 $newtopicObject->setVar('topic_haspoll', 1);
204 204
                 $newtopicObject->setVar('poll_id', $poll_id);
205
-                $poll_id = 0;// set to not delete the poll
205
+                $poll_id = 0; // set to not delete the poll
206 206
                 $topicObject->setVar('topic_haspoll', 0); // set to not delete the poll
207
-                $topicObject->setVar('poll_id', 0);// set to not delete the poll
207
+                $topicObject->setVar('poll_id', 0); // set to not delete the poll
208 208
             }
209 209
             //update and sync newtopic after merge
210 210
             //$topicHandler->insert($newtopicObject, true);
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
                 && !$forumHandler->getPermission($forum_new, 'reply'))        // The forum for the topic to be merged to
287 287
             || (!empty($newforum) && !$forumHandler->getPermission($newforum, 'post')) // The forum to be moved to
288 288
         ) {
289
-            redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&amp;topic_id=$topic_id", 2, _NOPERM);
289
+            redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?forum=$forum&amp;topic_id=$topic_id", 2, _NOPERM);
290 290
         }
291 291
 
292 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);
293
+            $sql = sprintf('UPDATE `%s` SET '.$action[$mode]['sql'].' WHERE topic_id = %u', $GLOBALS['xoopsDB']->prefix('newbb_topics'), $topic_id);
294 294
             if (!$r = $GLOBALS['xoopsDB']->query($sql)) {
295
-                redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&amp;topic_id=$topic_id&amp;order=$order&amp;viewmode=$viewmode", 2, _MD_NEWBB_ERROR_BACK . '<br>sql: ' . $sql);
295
+                redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?forum=$forum&amp;topic_id=$topic_id&amp;order=$order&amp;viewmode=$viewmode", 2, _MD_NEWBB_ERROR_BACK.'<br>sql: '.$sql);
296 296
             }
297 297
         } else {
298
-            redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&amp;topic_id=$topic_id", 2, _MD_NEWBB_ERROR_BACK);
298
+            redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?forum=$forum&amp;topic_id=$topic_id", 2, _MD_NEWBB_ERROR_BACK);
299 299
         }
300 300
         if ('digest' === $mode && $GLOBALS['xoopsDB']->getAffectedRows()) {
301 301
             $topicObject = $topicHandler->get($topic_id);
@@ -326,15 +326,15 @@  discard block
 block discarded – undo
326 326
     }
327 327
 } else {  // No submit
328 328
     $mode = Request::getString('mode', '', 'GET'); //$_GET['mode'];
329
-    echo "<form action='" . Request::getString('PHP_SELF', '', 'SERVER') . "' method='post'>";
329
+    echo "<form action='".Request::getString('PHP_SELF', '', 'SERVER')."' method='post'>";
330 330
     echo "<table border='0' cellpadding='1' cellspacing='0' align='center' width='95%'>";
331 331
     echo "<tr><td class='bg2'>";
332 332
     echo "<table border='0' cellpadding='1' cellspacing='1' width='100%'>";
333 333
     echo "<tr class='bg3' align='left'>";
334
-    echo "<td colspan='2' align='center'>" . $action[$mode]['desc'] . '</td></tr>';
334
+    echo "<td colspan='2' align='center'>".$action[$mode]['desc'].'</td></tr>';
335 335
 
336 336
     if ('move' === $mode) {
337
-        echo '<tr><td class="bg3">' . _MD_NEWBB_MOVETOPICTO . '</td><td class="bg1">';
337
+        echo '<tr><td class="bg3">'._MD_NEWBB_MOVETOPICTO.'</td><td class="bg1">';
338 338
         $box = '<select name="newforum" size="1">';
339 339
 
340 340
         //        /** @var Newbb\CategoryHandler $categoryHandler */
@@ -345,19 +345,19 @@  discard block
 block discarded – undo
345 345
         if (count($categories) > 0 && count($forums) > 0) {
346 346
             foreach (array_keys($forums) as $key) {
347 347
                 /** @var Newbb\Category[] $categories */
348
-                $box .= "<option value='-1'>[" . $categories[$key]->getVar('cat_title') . ']</option>';
348
+                $box .= "<option value='-1'>[".$categories[$key]->getVar('cat_title').']</option>';
349 349
                 foreach ($forums[$key] as $forumid => $_forum) {
350
-                    $box .= "<option value='" . $forumid . "'>-- " . $_forum['title'] . '</option>';
350
+                    $box .= "<option value='".$forumid."'>-- ".$_forum['title'].'</option>';
351 351
                     if (!isset($_forum['sub'])) {
352 352
                         continue;
353 353
                     }
354 354
                     foreach (array_keys($_forum['sub']) as $fid) {
355
-                        $box .= "<option value='" . $fid . "'>---- " . $_forum['sub'][$fid]['title'] . '</option>';
355
+                        $box .= "<option value='".$fid."'>---- ".$_forum['sub'][$fid]['title'].'</option>';
356 356
                     }
357 357
                 }
358 358
             }
359 359
         } else {
360
-            $box .= "<option value='-1'>" . _MD_NEWBB_NOFORUMINDB . '</option>';
360
+            $box .= "<option value='-1'>"._MD_NEWBB_NOFORUMINDB.'</option>';
361 361
         }
362 362
         unset($forums, $categories);
363 363
 
@@ -365,17 +365,17 @@  discard block
 block discarded – undo
365 365
         echo '</select></td></tr>';
366 366
     }
367 367
     if ('merge' === $mode) {
368
-        echo '<tr><td class="bg3">' . _MD_NEWBB_MERGETOPICTO . '</td><td class="bg1">';
369
-        echo _MD_NEWBB_TOPIC . "&nbsp;ID-$topic_id -> ID: <input name='newtopic' value='' />";
368
+        echo '<tr><td class="bg3">'._MD_NEWBB_MERGETOPICTO.'</td><td class="bg1">';
369
+        echo _MD_NEWBB_TOPIC."&nbsp;ID-$topic_id -> ID: <input name='newtopic' value='' />";
370 370
         echo '</td></tr>';
371 371
     }
372 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'] . "' />";
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 377
     echo '</td></tr></form></table></td></tr></table>';
378 378
 }
379 379
 // irmtfan move to footer.php
380
-require_once __DIR__ . '/footer.php';
380
+require_once __DIR__.'/footer.php';
381 381
 require_once $GLOBALS['xoops']->path('footer.php');
Please login to merge, or discard this patch.
notification_update.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,5 +28,5 @@
 block discarded – undo
28 28
 // URL: http://www.myweb.ne.jp/, https://xoops.org/, http://jp.xoops.org/ //
29 29
 // Project: XOOPS Project                                                    //
30 30
 // ------------------------------------------------------------------------- //
31
-require_once dirname(dirname(__DIR__)) . '/mainfile.php';
31
+require_once dirname(dirname(__DIR__)).'/mainfile.php';
32 32
 require_once $GLOBALS['xoops']->path('include/notification_update.php');
Please login to merge, or discard this patch.
class/GroupPermForm.php 2 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -8,81 +8,81 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         foreach (array_keys($glist) as $i) {
55 55
             // get selected item id(s) for each group
56 56
             $selected = $grouppermHandler->getItemIds($this->_permName, $i, $this->_modid);
57
-            $ele      = new Newbb\GroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected);
57
+            $ele      = new Newbb\GroupFormCheckBox($glist[$i], 'perms['.$this->_permName.']', $i, $selected);
58 58
             $ele->setOptionTree($this->_itemTree);
59 59
             $this->addElement($ele);
60 60
             unset($ele);
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
         $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
64 64
         $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset'));
65 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";
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 68
         $elements = $this->getElements();
69 69
         $hidden   = '';
70 70
         foreach (array_keys($elements) as $i) {
71 71
             if (!is_object($elements[$i])) {
72 72
                 $ret .= $elements[$i];
73 73
             } elseif (!$elements[$i]->isHidden()) {
74
-                $ret .= "<tr valign='top' align='left'><td class='head'>" . $elements[$i]->getCaption();
74
+                $ret .= "<tr valign='top' align='left'><td class='head'>".$elements[$i]->getCaption();
75 75
                 if ('' !== $elements[$i]->getDescription()) {
76
-                    $ret .= '<br><br><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>';
76
+                    $ret .= '<br><br><span style="font-weight: normal;">'.$elements[$i]->getDescription().'</span>';
77 77
                 }
78
-                $ret .= "</td>\n<td class='even' style='text-align:center;'>\n" . $elements[$i]->render() . "\n</td></tr>\n";
78
+                $ret .= "</td>\n<td class='even' style='text-align:center;'>\n".$elements[$i]->render()."\n</td></tr>\n";
79 79
             } else {
80 80
                 $hidden .= $elements[$i]->render();
81 81
             }
Please login to merge, or discard this patch.
class/Userstats.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
class/PermissionCategoryHandler.php 2 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -23,82 +23,82 @@
 block discarded – undo
23 23
  */
24 24
 class PermissionCategoryHandler extends Newbb\PermissionHandler
25 25
 {
26
-    /**
27
-     * @param \XoopsDatabase $db
28
-     */
29
-    public function __construct(\XoopsDatabase $db)
30
-    {
31
-        //        $this->PermissionHandler($db);
32
-        parent::__construct($db);
33
-    }
26
+	/**
27
+	 * @param \XoopsDatabase $db
28
+	 */
29
+	public function __construct(\XoopsDatabase $db)
30
+	{
31
+		//        $this->PermissionHandler($db);
32
+		parent::__construct($db);
33
+	}
34 34
 
35
-    /**
36
-     * @param        $mid
37
-     * @param  int   $id
38
-     * @return array
39
-     */
40
-    public function getValidItems($mid, $id = 0)
41
-    {
42
-        $full_items = [];
43
-        if (empty($mid)) {
44
-            return $full_items;
45
-        }
35
+	/**
36
+	 * @param        $mid
37
+	 * @param  int   $id
38
+	 * @return array
39
+	 */
40
+	public function getValidItems($mid, $id = 0)
41
+	{
42
+		$full_items = [];
43
+		if (empty($mid)) {
44
+			return $full_items;
45
+		}
46 46
 
47
-        $full_items[] = "'category_access'";
47
+		$full_items[] = "'category_access'";
48 48
 
49
-        return $full_items;
50
-    }
49
+		return $full_items;
50
+	}
51 51
 
52
-    /**
53
-     * @param $cat_id
54
-     * @return bool
55
-     */
56
-    public function deleteByCategory($cat_id)
57
-    {
58
-        $cat_id = (int)$cat_id;
59
-        if (empty($cat_id)) {
60
-            return false;
61
-        }
62
-        /** @var \XoopsGroupPermHandler $grouppermHandler */
63
-        $grouppermHandler = xoops_getHandler('groupperm');
64
-        $criteria     = new \CriteriaCompo(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid')));
65
-        $criteria->add(new \Criteria('gperm_name', 'category_access'));
66
-        $criteria->add(new \Criteria('gperm_itemid', $cat_id));
52
+	/**
53
+	 * @param $cat_id
54
+	 * @return bool
55
+	 */
56
+	public function deleteByCategory($cat_id)
57
+	{
58
+		$cat_id = (int)$cat_id;
59
+		if (empty($cat_id)) {
60
+			return false;
61
+		}
62
+		/** @var \XoopsGroupPermHandler $grouppermHandler */
63
+		$grouppermHandler = xoops_getHandler('groupperm');
64
+		$criteria     = new \CriteriaCompo(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid')));
65
+		$criteria->add(new \Criteria('gperm_name', 'category_access'));
66
+		$criteria->add(new \Criteria('gperm_itemid', $cat_id));
67 67
 
68
-        return $grouppermHandler->deleteAll($criteria);
69
-    }
68
+		return $grouppermHandler->deleteAll($criteria);
69
+	}
70 70
 
71
-    /**
72
-     * @param        $category
73
-     * @param  array $groups
74
-     * @return bool
75
-     */
76
-    public function setCategoryPermission($category, array $groups = [])
77
-    {
78
-        if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
79
-            $mid = $GLOBALS['xoopsModule']->getVar('mid');
80
-        } else {
81
-            /** @var \XoopsModuleHandler $moduleHandler */
82
-            $moduleHandler = xoops_getHandler('module');
83
-            $newbb         = $moduleHandler->getByDirname('newbb');
84
-            $mid           = $newbb->getVar('mid');
85
-        }
86
-        if (empty($groups)) {
87
-            /** @var \XoopsMemberHandler $memberHandler */
88
-            $memberHandler = xoops_getHandler('member');
89
-            $glist         = $memberHandler->getGroupList();
90
-            $groups        = array_keys($glist);
91
-        }
92
-        $ids     = $this->getGroupIds('category_access', $category, $mid);
93
-        $ids_add = array_diff($groups, $ids);
94
-        $ids_rmv = array_diff($ids, $groups);
95
-        foreach ($ids_add as $group) {
96
-            $this->addRight('category_access', $category, $group, $mid);
97
-        }
98
-        foreach ($ids_rmv as $group) {
99
-            $this->deleteRight('category_access', $category, $group, $mid);
100
-        }
71
+	/**
72
+	 * @param        $category
73
+	 * @param  array $groups
74
+	 * @return bool
75
+	 */
76
+	public function setCategoryPermission($category, array $groups = [])
77
+	{
78
+		if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
79
+			$mid = $GLOBALS['xoopsModule']->getVar('mid');
80
+		} else {
81
+			/** @var \XoopsModuleHandler $moduleHandler */
82
+			$moduleHandler = xoops_getHandler('module');
83
+			$newbb         = $moduleHandler->getByDirname('newbb');
84
+			$mid           = $newbb->getVar('mid');
85
+		}
86
+		if (empty($groups)) {
87
+			/** @var \XoopsMemberHandler $memberHandler */
88
+			$memberHandler = xoops_getHandler('member');
89
+			$glist         = $memberHandler->getGroupList();
90
+			$groups        = array_keys($glist);
91
+		}
92
+		$ids     = $this->getGroupIds('category_access', $category, $mid);
93
+		$ids_add = array_diff($groups, $ids);
94
+		$ids_rmv = array_diff($ids, $groups);
95
+		foreach ($ids_add as $group) {
96
+			$this->addRight('category_access', $category, $group, $mid);
97
+		}
98
+		foreach ($ids_rmv as $group) {
99
+			$this->deleteRight('category_access', $category, $group, $mid);
100
+		}
101 101
 
102
-        return true;
103
-    }
102
+		return true;
103
+	}
104 104
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
         }
62 62
         /** @var \XoopsGroupPermHandler $grouppermHandler */
63 63
         $grouppermHandler = xoops_getHandler('groupperm');
64
-        $criteria     = new \CriteriaCompo(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid')));
64
+        $criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid')));
65 65
         $criteria->add(new \Criteria('gperm_name', 'category_access'));
66 66
         $criteria->add(new \Criteria('gperm_itemid', $cat_id));
67 67
 
Please login to merge, or discard this patch.
class/ReadHandler.php 1 patch
Indentation   +336 added lines, -336 removed lines patch added patch discarded remove patch
@@ -48,340 +48,340 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
class/Common/VersionChecks.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -17,63 +17,63 @@
 block discarded – undo
17 17
  */
18 18
 trait VersionChecks
19 19
 {
20
-    /**
21
-     *
22
-     * Verifies XOOPS version meets minimum requirements for this module
23
-     * @static
24
-     * @param \XoopsModule $module
25
-     *
26
-     * @param null|string  $requiredVer
27
-     * @return bool true if meets requirements, false if not
28
-     */
29
-    public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null)
30
-    {
31
-        $moduleDirName = basename(dirname(dirname(__DIR__)));
32
-        $moduleDirNameUpper   = strtoupper($moduleDirName);
33
-        if (null === $module) {
34
-            $module = \XoopsModule::getByDirname($moduleDirName);
35
-        }
36
-        xoops_loadLanguage('admin', $moduleDirName);
20
+	/**
21
+	 *
22
+	 * Verifies XOOPS version meets minimum requirements for this module
23
+	 * @static
24
+	 * @param \XoopsModule $module
25
+	 *
26
+	 * @param null|string  $requiredVer
27
+	 * @return bool true if meets requirements, false if not
28
+	 */
29
+	public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null)
30
+	{
31
+		$moduleDirName = basename(dirname(dirname(__DIR__)));
32
+		$moduleDirNameUpper   = strtoupper($moduleDirName);
33
+		if (null === $module) {
34
+			$module = \XoopsModule::getByDirname($moduleDirName);
35
+		}
36
+		xoops_loadLanguage('admin', $moduleDirName);
37 37
 
38
-        //check for minimum XOOPS version
39
-        $currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string
40
-        if (null === $requiredVer) {
41
-            $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
42
-        }
43
-        $success = true;
38
+		//check for minimum XOOPS version
39
+		$currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string
40
+		if (null === $requiredVer) {
41
+			$requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
42
+		}
43
+		$success = true;
44 44
 
45
-        if (version_compare($currentVer, $requiredVer, '<')) {
46
-            $success = false;
47
-            $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
48
-        }
45
+		if (version_compare($currentVer, $requiredVer, '<')) {
46
+			$success = false;
47
+			$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
48
+		}
49 49
 
50
-        return $success;
51
-    }
50
+		return $success;
51
+	}
52 52
 
53
-    /**
54
-     *
55
-     * Verifies PHP version meets minimum requirements for this module
56
-     * @static
57
-     * @param \XoopsModule $module
58
-     *
59
-     * @return bool true if meets requirements, false if not
60
-     */
61
-    public static function checkVerPhp(\XoopsModule $module)
62
-    {
63
-        $moduleDirName = basename(dirname(__DIR__));
64
-        $moduleDirNameUpper   = strtoupper($moduleDirName);
65
-        xoops_loadLanguage('admin', $module->dirname());
66
-        // check for minimum PHP version
67
-        $success = true;
68
-        $verNum  = PHP_VERSION;
69
-        $reqVer  = $module->getInfo('min_php');
70
-        if (false !== $reqVer && '' !== $reqVer) {
71
-            if (version_compare($verNum, $reqVer, '<')) {
72
-                $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
73
-                $success = false;
74
-            }
75
-        }
53
+	/**
54
+	 *
55
+	 * Verifies PHP version meets minimum requirements for this module
56
+	 * @static
57
+	 * @param \XoopsModule $module
58
+	 *
59
+	 * @return bool true if meets requirements, false if not
60
+	 */
61
+	public static function checkVerPhp(\XoopsModule $module)
62
+	{
63
+		$moduleDirName = basename(dirname(__DIR__));
64
+		$moduleDirNameUpper   = strtoupper($moduleDirName);
65
+		xoops_loadLanguage('admin', $module->dirname());
66
+		// check for minimum PHP version
67
+		$success = true;
68
+		$verNum  = PHP_VERSION;
69
+		$reqVer  = $module->getInfo('min_php');
70
+		if (false !== $reqVer && '' !== $reqVer) {
71
+			if (version_compare($verNum, $reqVer, '<')) {
72
+				$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
73
+				$success = false;
74
+			}
75
+		}
76 76
 
77
-        return $success;
78
-    }
77
+		return $success;
78
+	}
79 79
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null)
30 30
     {
31 31
         $moduleDirName = basename(dirname(dirname(__DIR__)));
32
-        $moduleDirNameUpper   = strtoupper($moduleDirName);
32
+        $moduleDirNameUpper = strtoupper($moduleDirName);
33 33
         if (null === $module) {
34 34
             $module = \XoopsModule::getByDirname($moduleDirName);
35 35
         }
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
         //check for minimum XOOPS version
39 39
         $currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string
40 40
         if (null === $requiredVer) {
41
-            $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
41
+            $requiredVer = ''.$module->getInfo('min_xoops'); //making sure it's a string
42 42
         }
43 43
         $success = true;
44 44
 
45 45
         if (version_compare($currentVer, $requiredVer, '<')) {
46 46
             $success = false;
47
-            $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
47
+            $module->setErrors(sprintf(constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
48 48
         }
49 49
 
50 50
         return $success;
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     public static function checkVerPhp(\XoopsModule $module)
62 62
     {
63 63
         $moduleDirName = basename(dirname(__DIR__));
64
-        $moduleDirNameUpper   = strtoupper($moduleDirName);
64
+        $moduleDirNameUpper = strtoupper($moduleDirName);
65 65
         xoops_loadLanguage('admin', $module->dirname());
66 66
         // check for minimum PHP version
67 67
         $success = true;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $reqVer  = $module->getInfo('min_php');
70 70
         if (false !== $reqVer && '' !== $reqVer) {
71 71
             if (version_compare($verNum, $reqVer, '<')) {
72
-                $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
72
+                $module->setErrors(sprintf(constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_PHP'), $reqVer, $verNum));
73 73
                 $success = false;
74 74
             }
75 75
         }
Please login to merge, or discard this patch.
class/Common/Configurator.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -27,35 +27,35 @@
 block discarded – undo
27 27
  */
28 28
 class Configurator
29 29
 {
30
-    public $name;
31
-    public $paths           = [];
32
-    public $uploadFolders   = [];
33
-    public $copyBlankFiles  = [];
34
-    public $copyTestFolders = [];
35
-    public $templateFolders = [];
36
-    public $oldFiles        = [];
37
-    public $oldFolders      = [];
38
-    public $modCopyright;
30
+	public $name;
31
+	public $paths           = [];
32
+	public $uploadFolders   = [];
33
+	public $copyBlankFiles  = [];
34
+	public $copyTestFolders = [];
35
+	public $templateFolders = [];
36
+	public $oldFiles        = [];
37
+	public $oldFolders      = [];
38
+	public $modCopyright;
39 39
 
40
-    /**
41
-     * Configurator constructor.
42
-     */
43
-    public function __construct()
44
-    {
45
-        $moduleDirName = basename(dirname(__DIR__));
46
-        $capsDirName   = strtoupper($moduleDirName);
40
+	/**
41
+	 * Configurator constructor.
42
+	 */
43
+	public function __construct()
44
+	{
45
+		$moduleDirName = basename(dirname(__DIR__));
46
+		$capsDirName   = strtoupper($moduleDirName);
47 47
 
48
-        require_once  dirname(dirname(__DIR__)) . '/include/config.php';
49
-        $config = getConfig();
48
+		require_once  dirname(dirname(__DIR__)) . '/include/config.php';
49
+		$config = getConfig();
50 50
 
51
-        $this->name            = $config->name;
52
-        $this->paths           = $config->paths;
53
-        $this->uploadFolders   = $config->uploadFolders;
54
-        $this->copyBlankFiles  = $config->copyBlankFiles;
55
-        $this->copyTestFolders = $config->copyTestFolders;
56
-        $this->templateFolders = $config->templateFolders;
57
-        $this->oldFiles        = $config->oldFiles;
58
-        $this->oldFolders      = $config->oldFolders;
59
-        $this->modCopyright    = $config->modCopyright;
60
-    }
51
+		$this->name            = $config->name;
52
+		$this->paths           = $config->paths;
53
+		$this->uploadFolders   = $config->uploadFolders;
54
+		$this->copyBlankFiles  = $config->copyBlankFiles;
55
+		$this->copyTestFolders = $config->copyTestFolders;
56
+		$this->templateFolders = $config->templateFolders;
57
+		$this->oldFiles        = $config->oldFiles;
58
+		$this->oldFolders      = $config->oldFolders;
59
+		$this->modCopyright    = $config->modCopyright;
60
+	}
61 61
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  *
21 21
  */
22 22
 
23
-require_once  dirname(dirname(__DIR__)) . '/include/common.php';
23
+require_once  dirname(dirname(__DIR__)).'/include/common.php';
24 24
 
25 25
 /**
26 26
  * Class Configurator
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         $moduleDirName = basename(dirname(__DIR__));
46 46
         $capsDirName   = strtoupper($moduleDirName);
47 47
 
48
-        require_once  dirname(dirname(__DIR__)) . '/include/config.php';
48
+        require_once  dirname(dirname(__DIR__)).'/include/config.php';
49 49
         $config = getConfig();
50 50
 
51 51
         $this->name            = $config->name;
Please login to merge, or discard this patch.