Index: trunk/extensions/CheckUser/CheckUser_body.php |
— | — | @@ -11,11 +11,7 @@ |
12 | 12 | */ |
13 | 13 | public function __construct() { |
14 | 14 | global $wgUser; |
15 | | - if ( $wgUser->isAllowed( 'checkuser' ) || !$wgUser->isAllowed( 'checkuser-log' ) ) { |
16 | | - parent::__construct( 'CheckUser', 'checkuser' ); |
17 | | - } else { |
18 | | - parent::__construct( 'CheckUser', 'checkuser-log' ); |
19 | | - } |
| 15 | + parent::__construct( 'CheckUser', 'checkuser' ); |
20 | 16 | |
21 | 17 | $this->sk = $wgUser->getSkin(); |
22 | 18 | } |
— | — | @@ -25,37 +21,6 @@ |
26 | 22 | |
27 | 23 | $this->setHeaders(); |
28 | 24 | |
29 | | - // This is horribly shitty. |
30 | | - // Lacking formal aliases, it's tough to ensure we have compatibility. |
31 | | - // Links may break, which sucks. |
32 | | - // Language fallbacks will not always be properly utilized. |
33 | | - $logMatches = array( |
34 | | - wfMsgForContent( 'checkuser-log-subpage' ), |
35 | | - 'Log' |
36 | | - ); |
37 | | - |
38 | | - foreach ( $logMatches as $log ) { |
39 | | - if ( str_replace( '_', ' ', $wgContLang->lc( $subpage ) ) |
40 | | - == str_replace( '_ ', ' ', $wgContLang->lc( $log ) ) ) { |
41 | | - if ( !$wgUser->isAllowed( 'checkuser-log' ) ) { |
42 | | - $wgOut->permissionRequired( 'checkuser-log' ); |
43 | | - return; |
44 | | - } |
45 | | - |
46 | | - $this->showLog(); |
47 | | - return; |
48 | | - } |
49 | | - } |
50 | | - |
51 | | - if ( !$wgUser->isAllowed( 'checkuser' ) ) { |
52 | | - if ( $wgUser->isAllowed( 'checkuser-log' ) ) { |
53 | | - $this->showGuide(); |
54 | | - } else { |
55 | | - $wgOut->permissionRequired( 'checkuser' ); |
56 | | - } |
57 | | - return; |
58 | | - } |
59 | | - |
60 | 25 | $user = $wgRequest->getText( 'user' ) ? |
61 | 26 | $wgRequest->getText( 'user' ) : $wgRequest->getText( 'ip' ); |
62 | 27 | $user = trim( $user ); |
— | — | @@ -130,17 +95,17 @@ |
131 | 96 | /** |
132 | 97 | * @return Title |
133 | 98 | */ |
134 | | - public function getLogSubpageTitle() { |
| 99 | + public function getLogTitle() { |
135 | 100 | if ( !isset( $this->logSubpageTitle ) ) { |
136 | | - $this->logSubpageTitle = $this->getTitle( wfMsgForContent( 'checkuser-log-subpage' ) ); |
| 101 | + $this->logTitle = Title::makeTitle( NS_SPECIAL, 'CheckUserLog' ); |
137 | 102 | } |
138 | | - return $this->logSubpageTitle; |
| 103 | + return $this->logTitle; |
139 | 104 | } |
140 | 105 | |
141 | 106 | protected function showGuide() { |
142 | 107 | global $wgOut; |
143 | 108 | $wgOut->addWikiText( wfMsg( 'checkuser-summary' ) . |
144 | | - "\n\n[[" . $this->getLogSubpageTitle()->getPrefixedText() . |
| 109 | + "\n\n[[" . $this->getLogTitle()->getPrefixedText() . |
145 | 110 | '|' . wfMsg( 'checkuser-showlog' ) . ']]' |
146 | 111 | ); |
147 | 112 | } |
— | — | @@ -1325,133 +1290,6 @@ |
1326 | 1291 | return "cuc_timestamp > $cutoff"; |
1327 | 1292 | } |
1328 | 1293 | |
1329 | | - protected function showLog() { |
1330 | | - global $wgRequest, $wgOut; |
1331 | | - $type = $wgRequest->getVal( 'cuSearchType' ); |
1332 | | - $target = $wgRequest->getVal( 'cuSearch' ); |
1333 | | - $year = $wgRequest->getIntOrNull( 'year' ); |
1334 | | - $month = $wgRequest->getIntOrNull( 'month' ); |
1335 | | - $error = false; |
1336 | | - $dbr = wfGetDB( DB_SLAVE ); |
1337 | | - $searchConds = false; |
1338 | | - |
1339 | | - $wgOut->setPageTitle( wfMsg( 'checkuser-log' ) ); |
1340 | | - |
1341 | | - $wgOut->addHTML( $this->sk->makeKnownLinkObj( $this->getTitle(), wfMsgHtml( 'checkuser-log-return' ) ) ); |
1342 | | - |
1343 | | - if ( $type === null ) { |
1344 | | - $type = 'target'; |
1345 | | - } elseif ( $type == 'initiator' ) { |
1346 | | - $user = User::newFromName( $target ); |
1347 | | - if ( !$user || !$user->getID() ) { |
1348 | | - $error = 'checkuser-user-nonexistent'; |
1349 | | - } else { |
1350 | | - $searchConds = array( 'cul_user' => $user->getID() ); |
1351 | | - } |
1352 | | - } else /* target */ { |
1353 | | - $type = 'target'; |
1354 | | - // Is it an IP? |
1355 | | - list( $start, $end ) = IP::parseRange( $target ); |
1356 | | - if ( $start !== false ) { |
1357 | | - if ( $start == $end ) { |
1358 | | - $searchConds = array( 'cul_target_hex = ' . $dbr->addQuotes( $start ) . ' OR ' . |
1359 | | - '(cul_range_end >= ' . $dbr->addQuotes( $start ) . ' AND ' . |
1360 | | - 'cul_range_start <= ' . $dbr->addQuotes( $end ) . ')' |
1361 | | - ); |
1362 | | - } else { |
1363 | | - $searchConds = array( |
1364 | | - '(cul_target_hex >= ' . $dbr->addQuotes( $start ) . ' AND ' . |
1365 | | - 'cul_target_hex <= ' . $dbr->addQuotes( $end ) . ') OR ' . |
1366 | | - '(cul_range_end >= ' . $dbr->addQuotes( $start ) . ' AND ' . |
1367 | | - 'cul_range_start <= ' . $dbr->addQuotes( $end ) . ')' |
1368 | | - ); |
1369 | | - } |
1370 | | - } else { |
1371 | | - // Is it a user? |
1372 | | - $user = User::newFromName( $target ); |
1373 | | - if ( $user && $user->getID() ) { |
1374 | | - $searchConds = array( |
1375 | | - 'cul_type' => array( 'userips', 'useredits' ), |
1376 | | - 'cul_target_id' => $user->getID(), |
1377 | | - ); |
1378 | | - } elseif ( $target ) { |
1379 | | - $error = 'checkuser-user-nonexistent'; |
1380 | | - } |
1381 | | - } |
1382 | | - } |
1383 | | - |
1384 | | - $searchTypes = array( 'initiator', 'target' ); |
1385 | | - $select = "<select name=\"cuSearchType\" style='margin-top:.2em;'>\n"; |
1386 | | - foreach ( $searchTypes as $searchType ) { |
1387 | | - if ( $type == $searchType ) { |
1388 | | - $checked = 'selected="selected"'; |
1389 | | - } else { |
1390 | | - $checked = ''; |
1391 | | - } |
1392 | | - $caption = wfMsgHtml( 'checkuser-search-' . $searchType ); |
1393 | | - $select .= "<option value=\"$searchType\" $checked>$caption</option>\n"; |
1394 | | - } |
1395 | | - $select .= '</select>'; |
1396 | | - |
1397 | | - $encTarget = htmlspecialchars( $target ); |
1398 | | - $msgSearch = wfMsgHtml( 'checkuser-search' ); |
1399 | | - $input = "<input type=\"text\" name=\"cuSearch\" value=\"$encTarget\" size=\"40\"/>"; |
1400 | | - $msgSearchForm = wfMsgHtml( 'checkuser-search-form', $select, $input ); |
1401 | | - $formAction = $this->getLogSubpageTitle()->escapeLocalURL(); |
1402 | | - $msgSearchSubmit = '  ' . wfMsgHtml( 'checkuser-search-submit' ) . '  '; |
1403 | | - |
1404 | | - $s = "<form method='get' action=\"$formAction\">\n" . |
1405 | | - "<fieldset><legend>$msgSearch</legend>\n" . |
1406 | | - "<p>$msgSearchForm</p>\n" . |
1407 | | - "<p>" . $this->getDateMenu( $year, $month ) . "   \n" . |
1408 | | - "<input type=\"submit\" name=\"cuSearchSubmit\" value=\"$msgSearchSubmit\"/></p>\n" . |
1409 | | - "</fieldset></form>\n"; |
1410 | | - $wgOut->addHTML( $s ); |
1411 | | - |
1412 | | - if ( $error !== false ) { |
1413 | | - $wgOut->wrapWikiMsg( '<div class="errorbox">$1</div>', $error ); |
1414 | | - return; |
1415 | | - } |
1416 | | - |
1417 | | - $pager = new CheckUserLogPager( $this, $searchConds, $year, $month ); |
1418 | | - $wgOut->addHTML( |
1419 | | - $pager->getNavigationBar() . |
1420 | | - $pager->getBody() . |
1421 | | - $pager->getNavigationBar() |
1422 | | - ); |
1423 | | - } |
1424 | | - |
1425 | | - /** |
1426 | | - * @return string Formatted HTML |
1427 | | - * @param int $year |
1428 | | - * @param int $month |
1429 | | - */ |
1430 | | - protected function getDateMenu( $year, $month ) { |
1431 | | - # Offset overrides year/month selection |
1432 | | - if ( $month && $month !== - 1 ) { |
1433 | | - $encMonth = intval( $month ); |
1434 | | - } else { |
1435 | | - $encMonth = ''; |
1436 | | - } |
1437 | | - if ( $year ) { |
1438 | | - $encYear = intval( $year ); |
1439 | | - } elseif ( $encMonth ) { |
1440 | | - $thisMonth = intval( gmdate( 'n' ) ); |
1441 | | - $thisYear = intval( gmdate( 'Y' ) ); |
1442 | | - if ( intval( $encMonth ) > $thisMonth ) { |
1443 | | - $thisYear--; |
1444 | | - } |
1445 | | - $encYear = $thisYear; |
1446 | | - } else { |
1447 | | - $encYear = ''; |
1448 | | - } |
1449 | | - return Xml::label( wfMsg( 'year' ), 'year' ) . ' ' . |
1450 | | - Xml::input( 'year', 4, $encYear, array( 'id' => 'year', 'maxlength' => 4 ) ) . |
1451 | | - ' ' . |
1452 | | - Xml::label( wfMsg( 'month' ), 'month' ) . ' ' . |
1453 | | - Xml::monthSelector( $encMonth, - 1 ); |
1454 | | - } |
1455 | | - |
1456 | 1294 | public static function addLogEntry( $logType, $targetType, $target, $reason, $targetID = 0 ) { |
1457 | 1295 | global $wgUser; |
1458 | 1296 | |
— | — | @@ -1485,94 +1323,3 @@ |
1486 | 1324 | } |
1487 | 1325 | } |
1488 | 1326 | |
1489 | | -class CheckUserLogPager extends ReverseChronologicalPager { |
1490 | | - var $searchConds, $specialPage, $y, $m; |
1491 | | - |
1492 | | - function __construct( $specialPage, $searchConds, $y, $m ) { |
1493 | | - parent::__construct(); |
1494 | | - /* |
1495 | | - $this->messages = array_map( 'wfMsg', |
1496 | | - array( 'comma-separator', 'checkuser-log-userips', 'checkuser-log-ipedits', 'checkuser-log-ipusers', |
1497 | | - 'checkuser-log-ipedits-xff', 'checkuser-log-ipusers-xff' ) );*/ |
1498 | | - |
1499 | | - $this->getDateCond( $y, $m ); |
1500 | | - $this->searchConds = $searchConds ? $searchConds : array(); |
1501 | | - $this->specialPage = $specialPage; |
1502 | | - } |
1503 | | - |
1504 | | - function formatRow( $row ) { |
1505 | | - global $wgLang; |
1506 | | - |
1507 | | - $skin = $this->getSkin(); |
1508 | | - |
1509 | | - if ( $row->cul_reason === '' ) { |
1510 | | - $comment = ''; |
1511 | | - } else { |
1512 | | - $comment = $skin->commentBlock( $row->cul_reason ); |
1513 | | - } |
1514 | | - |
1515 | | - $user = $skin->userLink( $row->cul_user, $row->user_name ); |
1516 | | - |
1517 | | - if ( $row->cul_type == 'userips' || $row->cul_type == 'useredits' ) { |
1518 | | - $target = $skin->userLink( $row->cul_target_id, $row->cul_target_text ) . |
1519 | | - $skin->userToolLinks( $row->cul_target_id, $row->cul_target_text ); |
1520 | | - } else { |
1521 | | - $target = $row->cul_target_text; |
1522 | | - } |
1523 | | - |
1524 | | - return '<li>' . |
1525 | | - $wgLang->timeanddate( wfTimestamp( TS_MW, $row->cul_timestamp ), true ) . |
1526 | | - wfMsg( 'comma-separator' ) . |
1527 | | - wfMsg( |
1528 | | - 'checkuser-log-' . $row->cul_type, |
1529 | | - $user, |
1530 | | - $target |
1531 | | - ) . |
1532 | | - $comment . |
1533 | | - '</li>'; |
1534 | | - } |
1535 | | - |
1536 | | - function getStartBody() { |
1537 | | - if ( $this->getNumRows() ) { |
1538 | | - return '<ul>'; |
1539 | | - } else { |
1540 | | - return ''; |
1541 | | - } |
1542 | | - } |
1543 | | - |
1544 | | - function getEndBody() { |
1545 | | - if ( $this->getNumRows() ) { |
1546 | | - return '</ul>'; |
1547 | | - } else { |
1548 | | - return ''; |
1549 | | - } |
1550 | | - } |
1551 | | - |
1552 | | - function getEmptyBody() { |
1553 | | - return '<p>' . wfMsgHtml( 'checkuser-empty' ) . '</p>'; |
1554 | | - } |
1555 | | - |
1556 | | - function getQueryInfo() { |
1557 | | - $this->searchConds[] = 'user_id = cul_user'; |
1558 | | - return array( |
1559 | | - 'tables' => array( 'cu_log', 'user' ), |
1560 | | - 'fields' => $this->selectFields(), |
1561 | | - 'conds' => $this->searchConds |
1562 | | - ); |
1563 | | - } |
1564 | | - |
1565 | | - function getIndexField() { |
1566 | | - return 'cul_timestamp'; |
1567 | | - } |
1568 | | - |
1569 | | - function getTitle() { |
1570 | | - return $this->specialPage->getLogSubpageTitle(); |
1571 | | - } |
1572 | | - |
1573 | | - function selectFields() { |
1574 | | - return array( |
1575 | | - 'cul_id', 'cul_timestamp', 'cul_user', 'cul_reason', 'cul_type', |
1576 | | - 'cul_target_id', 'cul_target_text', 'user_name' |
1577 | | - ); |
1578 | | - } |
1579 | | -} |
Index: trunk/extensions/CheckUser/CheckUser.i18n.php |
— | — | @@ -20,6 +20,7 @@ |
21 | 21 | 'checkuser-desc' => 'Grants users with the appropriate permission the ability to check user\'s IP addresses and other information', |
22 | 22 | 'checkuser-logcase' => 'The log search is case sensitive.', |
23 | 23 | 'checkuser' => 'Check user', |
| 24 | + 'checkuserlog' => 'Check user log', |
24 | 25 | 'checkuser-contribs' => 'check user IP addresses', |
25 | 26 | 'group-checkuser' => 'Check users', |
26 | 27 | 'group-checkuser-member' => '{{GENDER:$1|check user}}', |
— | — | @@ -29,7 +30,6 @@ |
30 | 31 | 'checkuser-reason' => 'Reason:', |
31 | 32 | 'checkuser-reason-api' => 'API: $1', |
32 | 33 | 'checkuser-showlog' => 'Show log', |
33 | | - 'checkuser-log' => 'CheckUser log', |
34 | 34 | 'checkuser-query' => 'Query recent changes', |
35 | 35 | 'checkuser-target' => 'IP address or username:', |
36 | 36 | 'checkuser-users' => 'Get users', |
— | — | @@ -124,6 +124,7 @@ |
125 | 125 | 'checkuser' => 'Check user extension. The name of the special page where checkusers can check the IP addresses of users. The message is used in the list of special pages, and at the top of [[Special:Checkuser]]. |
126 | 126 | |
127 | 127 | {{Identical|Check user}}', |
| 128 | + 'checkuserlog' => 'The name of the special page where checkusers can look at a log of past checkuser actions. The message is used in the list of special pages, and at the top of [[Special:CheckUserLog]].', |
128 | 129 | 'group-checkuser' => '{{doc-group|checkuser}} |
129 | 130 | check is a noun, not a verb here |
130 | 131 | |
Index: trunk/extensions/CheckUser/CheckUserLogPager.php |
— | — | @@ -0,0 +1,89 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class CheckUserLogPager extends ReverseChronologicalPager { |
| 5 | + var $searchConds, $specialPage, $y, $m; |
| 6 | + |
| 7 | + function __construct( $specialPage, $searchConds, $y, $m ) { |
| 8 | + parent::__construct(); |
| 9 | + /* |
| 10 | + $this->messages = array_map( 'wfMsg', |
| 11 | + array( 'comma-separator', 'checkuser-log-userips', 'checkuser-log-ipedits', 'checkuser-log-ipusers', |
| 12 | + 'checkuser-log-ipedits-xff', 'checkuser-log-ipusers-xff' ) );*/ |
| 13 | + |
| 14 | + $this->getDateCond( $y, $m ); |
| 15 | + $this->searchConds = $searchConds ? $searchConds : array(); |
| 16 | + $this->specialPage = $specialPage; |
| 17 | + } |
| 18 | + |
| 19 | + function formatRow( $row ) { |
| 20 | + global $wgLang; |
| 21 | + |
| 22 | + $skin = $this->getSkin(); |
| 23 | + |
| 24 | + if ( $row->cul_reason === '' ) { |
| 25 | + $comment = ''; |
| 26 | + } else { |
| 27 | + $comment = $skin->commentBlock( $row->cul_reason ); |
| 28 | + } |
| 29 | + |
| 30 | + $user = $skin->userLink( $row->cul_user, $row->user_name ); |
| 31 | + |
| 32 | + if ( $row->cul_type == 'userips' || $row->cul_type == 'useredits' ) { |
| 33 | + $target = $skin->userLink( $row->cul_target_id, $row->cul_target_text ) . |
| 34 | + $skin->userToolLinks( $row->cul_target_id, $row->cul_target_text ); |
| 35 | + } else { |
| 36 | + $target = $row->cul_target_text; |
| 37 | + } |
| 38 | + |
| 39 | + return '<li>' . |
| 40 | + $wgLang->timeanddate( wfTimestamp( TS_MW, $row->cul_timestamp ), true ) . |
| 41 | + wfMsg( 'comma-separator' ) . |
| 42 | + wfMsg( |
| 43 | + 'checkuser-log-' . $row->cul_type, |
| 44 | + $user, |
| 45 | + $target |
| 46 | + ) . |
| 47 | + $comment . |
| 48 | + '</li>'; |
| 49 | + } |
| 50 | + |
| 51 | + function getStartBody() { |
| 52 | + if ( $this->getNumRows() ) { |
| 53 | + return '<ul>'; |
| 54 | + } else { |
| 55 | + return ''; |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + function getEndBody() { |
| 60 | + if ( $this->getNumRows() ) { |
| 61 | + return '</ul>'; |
| 62 | + } else { |
| 63 | + return ''; |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + function getEmptyBody() { |
| 68 | + return '<p>' . wfMsgHtml( 'checkuser-empty' ) . '</p>'; |
| 69 | + } |
| 70 | + |
| 71 | + function getQueryInfo() { |
| 72 | + $this->searchConds[] = 'user_id = cul_user'; |
| 73 | + return array( |
| 74 | + 'tables' => array( 'cu_log', 'user' ), |
| 75 | + 'fields' => $this->selectFields(), |
| 76 | + 'conds' => $this->searchConds |
| 77 | + ); |
| 78 | + } |
| 79 | + |
| 80 | + function getIndexField() { |
| 81 | + return 'cul_timestamp'; |
| 82 | + } |
| 83 | + |
| 84 | + function selectFields() { |
| 85 | + return array( |
| 86 | + 'cul_id', 'cul_timestamp', 'cul_user', 'cul_reason', 'cul_type', |
| 87 | + 'cul_target_id', 'cul_target_text', 'user_name' |
| 88 | + ); |
| 89 | + } |
| 90 | +} |
Index: trunk/extensions/CheckUser/CheckUser.alias.php |
— | — | @@ -11,6 +11,7 @@ |
12 | 12 | /** English (English) */ |
13 | 13 | $specialPageAliases['en'] = array( |
14 | 14 | 'CheckUser' => array( 'CheckUser' ), |
| 15 | + 'CheckUserLog' => array( 'CheckUserLog' ), |
15 | 16 | ); |
16 | 17 | |
17 | 18 | /** Arabic (العربية) */ |
Index: trunk/extensions/CheckUser/CheckUser.php |
— | — | @@ -81,9 +81,13 @@ |
82 | 82 | // Set up the new special page |
83 | 83 | $wgSpecialPages['CheckUser'] = 'CheckUser'; |
84 | 84 | $wgSpecialPageGroups['CheckUser'] = 'users'; |
| 85 | +$wgSpecialPages['CheckUserLog'] = 'SpecialCheckUserLog'; |
| 86 | +$wgSpecialPageGroups['CheckUserLog'] = 'changes'; |
85 | 87 | |
86 | 88 | $wgAutoloadClasses['CheckUser'] = $dir . '/CheckUser_body.php'; |
87 | 89 | $wgAutoloadClasses['CheckUserHooks'] = $dir . '/CheckUser.hooks.php'; |
| 90 | +$wgAutoloadClasses['CheckUserLogPager'] = $dir . '/CheckUserLogPager.php'; |
| 91 | +$wgAutoloadClasses['SpecialCheckUserLog'] = $dir . '/SpecialCheckUserLog.php'; |
88 | 92 | |
89 | 93 | // API modules |
90 | 94 | $wgAutoloadClasses['ApiQueryCheckUser'] = "$dir/api/ApiQueryCheckUser.php"; |
Index: trunk/extensions/CheckUser/SpecialCheckUserLog.php |
— | — | @@ -0,0 +1,133 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class SpecialCheckUserLog extends SpecialPage { |
| 5 | + public function __construct() { |
| 6 | + parent::__construct( 'CheckUserLog', 'checkuser-log' ); |
| 7 | + } |
| 8 | + |
| 9 | + function execute( $par ) { |
| 10 | + $out = $this->getOutput(); |
| 11 | + $request = $this->getRequest(); |
| 12 | + $this->setHeaders(); |
| 13 | + |
| 14 | + $type = $request->getVal( 'cuSearchType' ); |
| 15 | + $target = $request->getVal( 'cuSearch' ); |
| 16 | + $year = $request->getIntOrNull( 'year' ); |
| 17 | + $month = $request->getIntOrNull( 'month' ); |
| 18 | + $error = false; |
| 19 | + $dbr = wfGetDB( DB_SLAVE ); |
| 20 | + $searchConds = false; |
| 21 | + |
| 22 | + if ( $type === null ) { |
| 23 | + $type = 'target'; |
| 24 | + } elseif ( $type == 'initiator' ) { |
| 25 | + $user = User::newFromName( $target ); |
| 26 | + if ( !$user || !$user->getID() ) { |
| 27 | + $error = 'checkuser-user-nonexistent'; |
| 28 | + } else { |
| 29 | + $searchConds = array( 'cul_user' => $user->getID() ); |
| 30 | + } |
| 31 | + } else /* target */ { |
| 32 | + $type = 'target'; |
| 33 | + // Is it an IP? |
| 34 | + list( $start, $end ) = IP::parseRange( $target ); |
| 35 | + if ( $start !== false ) { |
| 36 | + if ( $start == $end ) { |
| 37 | + $searchConds = array( 'cul_target_hex = ' . $dbr->addQuotes( $start ) . ' OR ' . |
| 38 | + '(cul_range_end >= ' . $dbr->addQuotes( $start ) . ' AND ' . |
| 39 | + 'cul_range_start <= ' . $dbr->addQuotes( $end ) . ')' |
| 40 | + ); |
| 41 | + } else { |
| 42 | + $searchConds = array( |
| 43 | + '(cul_target_hex >= ' . $dbr->addQuotes( $start ) . ' AND ' . |
| 44 | + 'cul_target_hex <= ' . $dbr->addQuotes( $end ) . ') OR ' . |
| 45 | + '(cul_range_end >= ' . $dbr->addQuotes( $start ) . ' AND ' . |
| 46 | + 'cul_range_start <= ' . $dbr->addQuotes( $end ) . ')' |
| 47 | + ); |
| 48 | + } |
| 49 | + } else { |
| 50 | + // Is it a user? |
| 51 | + $user = User::newFromName( $target ); |
| 52 | + if ( $user && $user->getID() ) { |
| 53 | + $searchConds = array( |
| 54 | + 'cul_type' => array( 'userips', 'useredits' ), |
| 55 | + 'cul_target_id' => $user->getID(), |
| 56 | + ); |
| 57 | + } elseif ( $target ) { |
| 58 | + $error = 'checkuser-user-nonexistent'; |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + $searchTypes = array( 'initiator', 'target' ); |
| 64 | + $select = "<select name=\"cuSearchType\" style='margin-top:.2em;'>\n"; |
| 65 | + foreach ( $searchTypes as $searchType ) { |
| 66 | + if ( $type == $searchType ) { |
| 67 | + $checked = 'selected="selected"'; |
| 68 | + } else { |
| 69 | + $checked = ''; |
| 70 | + } |
| 71 | + $caption = wfMsgHtml( 'checkuser-search-' . $searchType ); |
| 72 | + $select .= "<option value=\"$searchType\" $checked>$caption</option>\n"; |
| 73 | + } |
| 74 | + $select .= '</select>'; |
| 75 | + |
| 76 | + $encTarget = htmlspecialchars( $target ); |
| 77 | + $msgSearch = wfMsgHtml( 'checkuser-search' ); |
| 78 | + $input = "<input type=\"text\" name=\"cuSearch\" value=\"$encTarget\" size=\"40\"/>"; |
| 79 | + $msgSearchForm = wfMsgHtml( 'checkuser-search-form', $select, $input ); |
| 80 | + $formAction = $this->getTitle()->escapeLocalURL(); |
| 81 | + $msgSearchSubmit = '  ' . wfMsgHtml( 'checkuser-search-submit' ) . '  '; |
| 82 | + |
| 83 | + $s = "<form method='get' action=\"$formAction\">\n" . |
| 84 | + "<fieldset><legend>$msgSearch</legend>\n" . |
| 85 | + "<p>$msgSearchForm</p>\n" . |
| 86 | + "<p>" . $this->getDateMenu( $year, $month ) . "   \n" . |
| 87 | + "<input type=\"submit\" name=\"cuSearchSubmit\" value=\"$msgSearchSubmit\"/></p>\n" . |
| 88 | + "</fieldset></form>\n"; |
| 89 | + $out->addHTML( $s ); |
| 90 | + |
| 91 | + if ( $error !== false ) { |
| 92 | + $out->wrapWikiMsg( '<div class="errorbox">$1</div>', $error ); |
| 93 | + return; |
| 94 | + } |
| 95 | + |
| 96 | + $pager = new CheckUserLogPager( $this, $searchConds, $year, $month ); |
| 97 | + $out->addHTML( |
| 98 | + $pager->getNavigationBar() . |
| 99 | + $pager->getBody() . |
| 100 | + $pager->getNavigationBar() |
| 101 | + ); |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * @return string Formatted HTML |
| 106 | + * @param int $year |
| 107 | + * @param int $month |
| 108 | + */ |
| 109 | + protected function getDateMenu( $year, $month ) { |
| 110 | + # Offset overrides year/month selection |
| 111 | + if ( $month && $month !== - 1 ) { |
| 112 | + $encMonth = intval( $month ); |
| 113 | + } else { |
| 114 | + $encMonth = ''; |
| 115 | + } |
| 116 | + if ( $year ) { |
| 117 | + $encYear = intval( $year ); |
| 118 | + } elseif ( $encMonth ) { |
| 119 | + $thisMonth = intval( gmdate( 'n' ) ); |
| 120 | + $thisYear = intval( gmdate( 'Y' ) ); |
| 121 | + if ( intval( $encMonth ) > $thisMonth ) { |
| 122 | + $thisYear--; |
| 123 | + } |
| 124 | + $encYear = $thisYear; |
| 125 | + } else { |
| 126 | + $encYear = ''; |
| 127 | + } |
| 128 | + return Xml::label( wfMsg( 'year' ), 'year' ) . ' ' . |
| 129 | + Xml::input( 'year', 4, $encYear, array( 'id' => 'year', 'maxlength' => 4 ) ) . |
| 130 | + ' ' . |
| 131 | + Xml::label( wfMsg( 'month' ), 'month' ) . ' ' . |
| 132 | + Xml::monthSelector( $encMonth, - 1 ); |
| 133 | + } |
| 134 | +} |