Passed
Push — master ( 7742f2...4200a0 )
by Michael
02:27
created
index.php 2 patches
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
 
48 48
 #var_dump($_REQUEST);#*#DEBUG#
49 49
 
50
-    global $xoopsDB, $xoopsTpl;
50
+	global $xoopsDB, $xoopsTpl;
51 51
 
52
-    // ----------
52
+	// ----------
53 53
 
54
-    // user input
54
+	// user input
55 55
 
56
-    // ----------
56
+	// ----------
57 57
 
58 58
 // offset of first row of challenges table to display (default to 0)
59 59
 $cstart = Request::getInt('cstart', 0);
@@ -71,70 +71,70 @@  discard block
 block discarded – undo
71 71
 $gshow2 = Request::getInt('gshow2', 0);
72 72
 //$gshow2 = intval(isset($_POST['gshow2']) ? $_POST['gshow2'] : @$_GET['gshow2']);
73 73
 
74
-    // set show-options to default if undefined
74
+	// set show-options to default if undefined
75 75
 
76
-    if (!$cshow) {
77
-        $cshow = _CHESS_SHOW_CHALLENGES_BOTH;
78
-    }
76
+	if (!$cshow) {
77
+		$cshow = _CHESS_SHOW_CHALLENGES_BOTH;
78
+	}
79 79
 
80
-    if (!$gshow1) {
81
-        $gshow1 = _CHESS_SHOW_GAMES_BOTH;
82
-    }
80
+	if (!$gshow1) {
81
+		$gshow1 = _CHESS_SHOW_GAMES_BOTH;
82
+	}
83 83
 
84
-    if (!$gshow2) {
85
-        $gshow2 = _CHESS_SHOW_GAMES_UNRATED;
86
-    }
84
+	if (!$gshow2) {
85
+		$gshow2 = _CHESS_SHOW_GAMES_UNRATED;
86
+	}
87 87
 
88
-    // get maximum number of items to display on a page, and constrain it to a reasonable value
88
+	// get maximum number of items to display on a page, and constrain it to a reasonable value
89 89
 
90
-    $max_items_to_display = chess_moduleConfig('max_items');
90
+	$max_items_to_display = chess_moduleConfig('max_items');
91 91
 
92
-    $max_items_to_display = min(max($max_items_to_display, 1), 1000);
92
+	$max_items_to_display = min(max($max_items_to_display, 1), 1000);
93 93
 
94
-    $xoopsTpl->assign('chess_date_format', _MEDIUMDATESTRING);
94
+	$xoopsTpl->assign('chess_date_format', _MEDIUMDATESTRING);
95 95
 
96
-    // user IDs that will require mapping to usernames
96
+	// user IDs that will require mapping to usernames
97 97
 
98
-    $userids = [];
98
+	$userids = [];
99 99
 
100
-    // -----
100
+	// -----
101 101
 
102
-    // games
102
+	// games
103 103
 
104
-    // -----
104
+	// -----
105 105
 
106
-    // Two queries are performed, one without a limit clause to count the total number of rows for the page navigator,
106
+	// Two queries are performed, one without a limit clause to count the total number of rows for the page navigator,
107 107
 
108
-    // and one with a limit clause to get the data for display on the current page.
108
+	// and one with a limit clause to get the data for display on the current page.
109 109
 
110
-    // SQL_CALC_FOUND_ROWS and FOUND_ROWS(), available in MySQL 4.0.0, provide a more efficient way of doing this.
110
+	// SQL_CALC_FOUND_ROWS and FOUND_ROWS(), available in MySQL 4.0.0, provide a more efficient way of doing this.
111 111
 
112
-    $games_table = $xoopsDB->prefix('chess_games');
112
+	$games_table = $xoopsDB->prefix('chess_games');
113 113
 
114
-    $where = 'white_uid != black_uid';
114
+	$where = 'white_uid != black_uid';
115 115
 
116
-    switch ($gshow1) {
117
-        case 1:
118
-            $where .= " AND pgn_result = '*'";
119
-            break;
120
-        case 2:
121
-            $where .= " AND pgn_result != '*'";
122
-            break;
123
-    }
116
+	switch ($gshow1) {
117
+		case 1:
118
+			$where .= " AND pgn_result = '*'";
119
+			break;
120
+		case 2:
121
+			$where .= " AND pgn_result != '*'";
122
+			break;
123
+	}
124 124
 
125
-    if (1 == $gshow2) {
126
-        $where .= " AND is_rated = '1'";
127
-    }
125
+	if (1 == $gshow2) {
126
+		$where .= " AND is_rated = '1'";
127
+	}
128 128
 
129
-    $result = $xoopsDB->query("SELECT COUNT(*) FROM $games_table WHERE $where");
129
+	$result = $xoopsDB->query("SELECT COUNT(*) FROM $games_table WHERE $where");
130 130
 
131
-    [$num_games] = $xoopsDB->fetchRow($result);
131
+	[$num_games] = $xoopsDB->fetchRow($result);
132 132
 
133
-    $xoopsDB->freeRecordSet($result);
133
+	$xoopsDB->freeRecordSet($result);
134 134
 
135
-    $result = $xoopsDB->query(
136
-        trim(
137
-            "
135
+	$result = $xoopsDB->query(
136
+		trim(
137
+			"
138 138
 		SELECT   game_id, fen_active_color, white_uid, black_uid, pgn_result, is_rated,
139 139
 			UNIX_TIMESTAMP(GREATEST(create_date,start_date,last_date)) AS last_activity
140 140
 		FROM     $games_table
@@ -142,211 +142,211 @@  discard block
 block discarded – undo
142 142
 		ORDER BY last_activity DESC
143 143
 		LIMIT    $gstart, $max_items_to_display
144 144
 	"
145
-        )
146
-    );
145
+		)
146
+	);
147 147
 
148
-    $games = [];
148
+	$games = [];
149 149
 
150
-    while (false !== ($row = $xoopsDB->fetchArray($result))) {
151
-        $games[] = [
152
-            'game_id'          => $row['game_id'],
153
-            'white_uid'        => $row['white_uid'],
154
-            'black_uid'        => $row['black_uid'],
155
-            'last_activity'    => $row['last_activity'],
156
-            'fen_active_color' => $row['fen_active_color'],
157
-            'pgn_result'       => $row['pgn_result'],
158
-            'is_rated'         => $row['is_rated'],
159
-        ];
150
+	while (false !== ($row = $xoopsDB->fetchArray($result))) {
151
+		$games[] = [
152
+			'game_id'          => $row['game_id'],
153
+			'white_uid'        => $row['white_uid'],
154
+			'black_uid'        => $row['black_uid'],
155
+			'last_activity'    => $row['last_activity'],
156
+			'fen_active_color' => $row['fen_active_color'],
157
+			'pgn_result'       => $row['pgn_result'],
158
+			'is_rated'         => $row['is_rated'],
159
+		];
160 160
 
161
-        // save user IDs that will require mapping to usernames
161
+		// save user IDs that will require mapping to usernames
162 162
 
163
-        if ($row['white_uid']) {
164
-            $userids[$row['white_uid']] = 1;
165
-        }
163
+		if ($row['white_uid']) {
164
+			$userids[$row['white_uid']] = 1;
165
+		}
166 166
 
167
-        if ($row['black_uid']) {
168
-            $userids[$row['black_uid']] = 1;
169
-        }
170
-    }
167
+		if ($row['black_uid']) {
168
+			$userids[$row['black_uid']] = 1;
169
+		}
170
+	}
171 171
 
172
-    $xoopsDB->freeRecordSet($result);
172
+	$xoopsDB->freeRecordSet($result);
173 173
 
174
-    $games_pagenav = new XoopsPageNav($num_games, $max_items_to_display, $gstart, 'gstart', "cstart=$cstart&cshow=$cshow&gshow1=$gshow1&gshow2=$gshow2");
174
+	$games_pagenav = new XoopsPageNav($num_games, $max_items_to_display, $gstart, 'gstart', "cstart=$cstart&cshow=$cshow&gshow1=$gshow1&gshow2=$gshow2");
175 175
 
176
-    $xoopsTpl->assign('chess_games_pagenav', $games_pagenav->renderNav());
176
+	$xoopsTpl->assign('chess_games_pagenav', $games_pagenav->renderNav());
177 177
 
178
-    // ----------
178
+	// ----------
179 179
 
180
-    // challenges
180
+	// challenges
181 181
 
182
-    // ----------
182
+	// ----------
183 183
 
184
-    // Two queries are performed, one without a limit clause to count the total number of rows for the page navigator,
184
+	// Two queries are performed, one without a limit clause to count the total number of rows for the page navigator,
185 185
 
186
-    // and one with a limit clause to get the data for display on the current page.
186
+	// and one with a limit clause to get the data for display on the current page.
187 187
 
188
-    // SQL_CALC_FOUND_ROWS and FOUND_ROWS(), available in MySQL 4.0.0, provide a more efficient way of doing this.
188
+	// SQL_CALC_FOUND_ROWS and FOUND_ROWS(), available in MySQL 4.0.0, provide a more efficient way of doing this.
189 189
 
190
-    $challenges_table = $xoopsDB->prefix('chess_challenges');
190
+	$challenges_table = $xoopsDB->prefix('chess_challenges');
191 191
 
192
-    switch ($cshow) {
193
-        case _CHESS_SHOW_CHALLENGES_OPEN:
194
-            $where = "game_type = 'open'";
195
-            break;
196
-        case _CHESS_SHOW_CHALLENGES_USER:
197
-            $where = "game_type = 'user'";
198
-            break;
199
-        default:
200
-            $where = 1;
201
-            break;
202
-    }
192
+	switch ($cshow) {
193
+		case _CHESS_SHOW_CHALLENGES_OPEN:
194
+			$where = "game_type = 'open'";
195
+			break;
196
+		case _CHESS_SHOW_CHALLENGES_USER:
197
+			$where = "game_type = 'user'";
198
+			break;
199
+		default:
200
+			$where = 1;
201
+			break;
202
+	}
203 203
 
204
-    $result = $xoopsDB->query("SELECT COUNT(*) FROM $challenges_table WHERE $where");
204
+	$result = $xoopsDB->query("SELECT COUNT(*) FROM $challenges_table WHERE $where");
205 205
 
206
-    [$num_challenges] = $xoopsDB->fetchRow($result);
206
+	[$num_challenges] = $xoopsDB->fetchRow($result);
207 207
 
208
-    $xoopsDB->freeRecordSet($result);
208
+	$xoopsDB->freeRecordSet($result);
209 209
 
210
-    $result = $xoopsDB->query(
211
-        trim(
212
-            "
210
+	$result = $xoopsDB->query(
211
+		trim(
212
+			"
213 213
 		SELECT   challenge_id, game_type, color_option, player1_uid, player2_uid, UNIX_TIMESTAMP(create_date) AS create_date, is_rated
214 214
 		FROM     $challenges_table
215 215
 		WHERE    $where
216 216
 		ORDER BY create_date DESC
217 217
 		LIMIT    $cstart, $max_items_to_display
218 218
 	"
219
-        )
220
-    );
219
+		)
220
+	);
221 221
 
222
-    $challenges = [];
222
+	$challenges = [];
223 223
 
224
-    while (false !== ($row = $xoopsDB->fetchArray($result))) {
225
-        $challenges[] = [
226
-            'challenge_id' => $row['challenge_id'],
227
-            'game_type'    => $row['game_type'],
228
-            'color_option' => $row['color_option'],
229
-            'player1_uid'  => $row['player1_uid'],
230
-            'player2_uid'  => $row['player2_uid'],
231
-            'create_date'  => $row['create_date'],
232
-            'is_rated'     => $row['is_rated'],
233
-        ];
224
+	while (false !== ($row = $xoopsDB->fetchArray($result))) {
225
+		$challenges[] = [
226
+			'challenge_id' => $row['challenge_id'],
227
+			'game_type'    => $row['game_type'],
228
+			'color_option' => $row['color_option'],
229
+			'player1_uid'  => $row['player1_uid'],
230
+			'player2_uid'  => $row['player2_uid'],
231
+			'create_date'  => $row['create_date'],
232
+			'is_rated'     => $row['is_rated'],
233
+		];
234 234
 
235
-        // save user IDs that will require mapping to usernames
235
+		// save user IDs that will require mapping to usernames
236 236
 
237
-        if ($row['player1_uid']) {
238
-            $userids[$row['player1_uid']] = 1;
239
-        }
237
+		if ($row['player1_uid']) {
238
+			$userids[$row['player1_uid']] = 1;
239
+		}
240 240
 
241
-        if ($row['player2_uid']) {
242
-            $userids[$row['player2_uid']] = 1;
243
-        }
244
-    }
241
+		if ($row['player2_uid']) {
242
+			$userids[$row['player2_uid']] = 1;
243
+		}
244
+	}
245 245
 
246
-    $xoopsDB->freeRecordSet($result);
246
+	$xoopsDB->freeRecordSet($result);
247 247
 
248
-    $challenges_pagenav = new XoopsPageNav($num_challenges, $max_items_to_display, $cstart, 'cstart', "gstart=$gstart&cshow=$cshow&gshow1=$gshow1&gshow2=$gshow2");
248
+	$challenges_pagenav = new XoopsPageNav($num_challenges, $max_items_to_display, $cstart, 'cstart', "gstart=$gstart&cshow=$cshow&gshow1=$gshow1&gshow2=$gshow2");
249 249
 
250
-    $xoopsTpl->assign('chess_challenges_pagenav', $challenges_pagenav->renderNav());
250
+	$xoopsTpl->assign('chess_challenges_pagenav', $challenges_pagenav->renderNav());
251 251
 
252
-    // ---------
252
+	// ---------
253 253
 
254
-    // usernames
254
+	// usernames
255 255
 
256
-    // ---------
256
+	// ---------
257 257
 
258
-    // get mapping of user IDs to usernames
258
+	// get mapping of user IDs to usernames
259 259
 
260
-    $memberHandler = xoops_getHandler('member');
260
+	$memberHandler = xoops_getHandler('member');
261 261
 
262
-    $criteria = new \Criteria('uid', '(' . implode(',', array_keys($userids)) . ')', 'IN');
262
+	$criteria = new \Criteria('uid', '(' . implode(',', array_keys($userids)) . ')', 'IN');
263 263
 
264
-    $usernames = $memberHandler->getUserList($criteria);
264
+	$usernames = $memberHandler->getUserList($criteria);
265 265
 
266
-    // add usernames to $games
266
+	// add usernames to $games
267 267
 
268
-    foreach ($games as $k => $game) {
269
-        $games[$k]['username_white'] = $usernames[$game['white_uid']] ?? '?';
268
+	foreach ($games as $k => $game) {
269
+		$games[$k]['username_white'] = $usernames[$game['white_uid']] ?? '?';
270 270
 
271
-        $games[$k]['username_black'] = $usernames[$game['black_uid']] ?? '?';
272
-    }
271
+		$games[$k]['username_black'] = $usernames[$game['black_uid']] ?? '?';
272
+	}
273 273
 
274
-    // add usernames to $challenges
274
+	// add usernames to $challenges
275 275
 
276
-    foreach ($challenges as $k => $challenge) {
277
-        $challenges[$k]['username_player1'] = $usernames[$challenge['player1_uid']] ?? '?';
276
+	foreach ($challenges as $k => $challenge) {
277
+		$challenges[$k]['username_player1'] = $usernames[$challenge['player1_uid']] ?? '?';
278 278
 
279
-        $challenges[$k]['username_player2'] = $usernames[$challenge['player2_uid']] ?? '?';
280
-    }
279
+		$challenges[$k]['username_player2'] = $usernames[$challenge['player2_uid']] ?? '?';
280
+	}
281 281
 
282
-    $xoopsTpl->assign('chess_games', $games);
282
+	$xoopsTpl->assign('chess_games', $games);
283 283
 
284
-    $xoopsTpl->assign('chess_challenges', $challenges);
284
+	$xoopsTpl->assign('chess_challenges', $challenges);
285 285
 
286
-    $xoopsTpl->assign('chess_rating_system', chess_moduleConfig('rating_system'));
286
+	$xoopsTpl->assign('chess_rating_system', chess_moduleConfig('rating_system'));
287 287
 
288
-    // -----
288
+	// -----
289 289
 
290
-    // forms
290
+	// forms
291 291
 
292
-    // -----
292
+	// -----
293 293
 
294
-    // security token not needed for this form
294
+	// security token not needed for this form
295 295
 
296
-    $form1 = new XoopsThemeForm('', 'form1', 'index.php');
296
+	$form1 = new XoopsThemeForm('', 'form1', 'index.php');
297 297
 
298
-    $form1->addElement(new XoopsFormButton('', 'submit', _MD_CHESS_SUBMIT_BUTTON, 'submit'));
298
+	$form1->addElement(new XoopsFormButton('', 'submit', _MD_CHESS_SUBMIT_BUTTON, 'submit'));
299 299
 
300
-    $menu_cshow = new XoopsFormSelect('', 'cshow', $cshow, 1, false);
300
+	$menu_cshow = new XoopsFormSelect('', 'cshow', $cshow, 1, false);
301 301
 
302
-    $menu_cshow->addOption(_CHESS_SHOW_CHALLENGES_OPEN, _MD_CHESS_SHOW_CHALLENGES_OPEN);
302
+	$menu_cshow->addOption(_CHESS_SHOW_CHALLENGES_OPEN, _MD_CHESS_SHOW_CHALLENGES_OPEN);
303 303
 
304
-    $menu_cshow->addOption(_CHESS_SHOW_CHALLENGES_USER, _MD_CHESS_SHOW_CHALLENGES_USER);
304
+	$menu_cshow->addOption(_CHESS_SHOW_CHALLENGES_USER, _MD_CHESS_SHOW_CHALLENGES_USER);
305 305
 
306
-    $menu_cshow->addOption(_CHESS_SHOW_CHALLENGES_BOTH, _MD_CHESS_SHOW_CHALLENGES_BOTH);
306
+	$menu_cshow->addOption(_CHESS_SHOW_CHALLENGES_BOTH, _MD_CHESS_SHOW_CHALLENGES_BOTH);
307 307
 
308
-    $form1->addElement($menu_cshow);
308
+	$form1->addElement($menu_cshow);
309 309
 
310
-    $form1->addElement(new XoopsFormHidden('gstart', $gstart));
310
+	$form1->addElement(new XoopsFormHidden('gstart', $gstart));
311 311
 
312
-    $form1->addElement(new XoopsFormHidden('gshow1', $gshow1));
312
+	$form1->addElement(new XoopsFormHidden('gshow1', $gshow1));
313 313
 
314
-    $form1->addElement(new XoopsFormHidden('gshow2', $gshow2));
314
+	$form1->addElement(new XoopsFormHidden('gshow2', $gshow2));
315 315
 
316
-    $form1->assign($xoopsTpl);
316
+	$form1->assign($xoopsTpl);
317 317
 
318
-    // security token not needed for this form
318
+	// security token not needed for this form
319 319
 
320
-    $form2 = new XoopsThemeForm('', 'form2', 'index.php');
320
+	$form2 = new XoopsThemeForm('', 'form2', 'index.php');
321 321
 
322
-    $form2->addElement(new XoopsFormButton('', 'submit', _MD_CHESS_SUBMIT_BUTTON, 'submit'));
322
+	$form2->addElement(new XoopsFormButton('', 'submit', _MD_CHESS_SUBMIT_BUTTON, 'submit'));
323 323
 
324
-    $menu_gshow1 = new XoopsFormSelect('', 'gshow1', $gshow1, 1, false);
324
+	$menu_gshow1 = new XoopsFormSelect('', 'gshow1', $gshow1, 1, false);
325 325
 
326
-    $menu_gshow1->addOption(_CHESS_SHOW_GAMES_INPLAY, _MD_CHESS_SHOW_GAMES_INPLAY);
326
+	$menu_gshow1->addOption(_CHESS_SHOW_GAMES_INPLAY, _MD_CHESS_SHOW_GAMES_INPLAY);
327 327
 
328
-    $menu_gshow1->addOption(_CHESS_SHOW_GAMES_CONCLUDED, _MD_CHESS_SHOW_GAMES_CONCLUDED);
328
+	$menu_gshow1->addOption(_CHESS_SHOW_GAMES_CONCLUDED, _MD_CHESS_SHOW_GAMES_CONCLUDED);
329 329
 
330
-    $menu_gshow1->addOption(_CHESS_SHOW_GAMES_BOTH, _MD_CHESS_SHOW_GAMES_BOTH);
330
+	$menu_gshow1->addOption(_CHESS_SHOW_GAMES_BOTH, _MD_CHESS_SHOW_GAMES_BOTH);
331 331
 
332
-    $form2->addElement($menu_gshow1);
332
+	$form2->addElement($menu_gshow1);
333 333
 
334
-    $menu_gshow2 = new XoopsFormSelect('', 'gshow2', $gshow2, 1, false);
334
+	$menu_gshow2 = new XoopsFormSelect('', 'gshow2', $gshow2, 1, false);
335 335
 
336
-    $menu_gshow2->addOption(_CHESS_SHOW_GAMES_RATED, _MD_CHESS_SHOW_GAMES_RATED);
336
+	$menu_gshow2->addOption(_CHESS_SHOW_GAMES_RATED, _MD_CHESS_SHOW_GAMES_RATED);
337 337
 
338
-    $menu_gshow2->addOption(_CHESS_SHOW_GAMES_UNRATED, _MD_CHESS_SHOW_GAMES_UNRATED);
338
+	$menu_gshow2->addOption(_CHESS_SHOW_GAMES_UNRATED, _MD_CHESS_SHOW_GAMES_UNRATED);
339 339
 
340
-    $form2->addElement($menu_gshow2);
340
+	$form2->addElement($menu_gshow2);
341 341
 
342
-    $form2->addElement(new XoopsFormHidden('cstart', $cstart));
342
+	$form2->addElement(new XoopsFormHidden('cstart', $cstart));
343 343
 
344
-    $form2->addElement(new XoopsFormHidden('cshow', $cshow));
344
+	$form2->addElement(new XoopsFormHidden('cshow', $cshow));
345 345
 
346
-    $form2->assign($xoopsTpl);
346
+	$form2->assign($xoopsTpl);
347 347
 
348
-    #*#DEBUG# - trying something unrelated to the chess module
349
-    /***
348
+	#*#DEBUG# - trying something unrelated to the chess module
349
+	/***
350 350
      * $configHandler = xoops_getHandler('config');
351 351
      * $clist = $configHandler->getConfigList(18);
352 352
      * var_dump('clist', $clist);
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
 
38 38
 /**#@+
39 39
  */
40
-require dirname(__DIR__, 2) . '/mainfile.php';
40
+require dirname(__DIR__, 2).'/mainfile.php';
41 41
 $GLOBALS['xoopsOption']['template_main'] = 'chess_games.tpl';
42
-require_once XOOPS_ROOT_PATH . '/header.php';
43
-require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
44
-require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
45
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/constants.inc.php';
46
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/functions.php';
42
+require_once XOOPS_ROOT_PATH.'/header.php';
43
+require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
44
+require_once XOOPS_ROOT_PATH.'/class/pagenav.php';
45
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/constants.inc.php';
46
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/functions.php';
47 47
 
48 48
 #var_dump($_REQUEST);#*#DEBUG#
49 49
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 
260 260
     $memberHandler = xoops_getHandler('member');
261 261
 
262
-    $criteria = new \Criteria('uid', '(' . implode(',', array_keys($userids)) . ')', 'IN');
262
+    $criteria = new \Criteria('uid', '('.implode(',', array_keys($userids)).')', 'IN');
263 263
 
264 264
     $usernames = $memberHandler->getUserList($criteria);
265 265
 
@@ -351,4 +351,4 @@  discard block
 block discarded – undo
351 351
      * $clist = $configHandler->getConfigList(18);
352 352
      * var_dump('clist', $clist);
353 353
      ***/
354
-include_once XOOPS_ROOT_PATH . '/footer.php';
354
+include_once XOOPS_ROOT_PATH.'/footer.php';
Please login to merge, or discard this patch.