Index: trunk/extensions/AutomaticBoardWelcome/AutomaticBoardWelcome.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | * @file |
10 | 10 | * @ingroup Extensions |
11 | 11 | * @version 0.1 |
12 | | - * @date 20 July 2011 |
| 12 | + * @date 30 July 2011 |
13 | 13 | * @author Jack Phoenix <jack@countervandalism.net> |
14 | 14 | * @license http://en.wikipedia.org/wiki/Public_domain Public domain |
15 | 15 | */ |
— | — | @@ -43,13 +43,23 @@ |
44 | 44 | return true; |
45 | 45 | } |
46 | 46 | |
| 47 | + // Just quit if we're in read-only mode |
| 48 | + if ( wfReadOnly() ) { |
| 49 | + return true; |
| 50 | + } |
| 51 | + |
47 | 52 | $dbr = wfGetDB( DB_SLAVE ); |
48 | | - // Get all users who are in the 'sysop' group from the database |
| 53 | + // Get all users who are in the 'sysop' group and aren't blocked from |
| 54 | + // the database |
49 | 55 | $res = $dbr->select( |
50 | | - 'user_groups', |
| 56 | + array( 'user_groups', 'ipblocks' ), |
51 | 57 | array( 'ug_group', 'ug_user' ), |
52 | | - array( 'ug_group' => 'sysop' ), |
53 | | - __METHOD__ |
| 58 | + array( 'ug_group' => 'sysop', 'ipb_user' => null ), |
| 59 | + __METHOD__, |
| 60 | + array(), |
| 61 | + array( |
| 62 | + 'ipblocks' => array( 'LEFT JOIN', 'ipb_user = ug_user' ) |
| 63 | + ) |
54 | 64 | ); |
55 | 65 | |
56 | 66 | $adminUids = array(); |
— | — | @@ -61,24 +71,21 @@ |
62 | 72 | $random = array_rand( array_flip( $adminUids ), 1 ); |
63 | 73 | $sender = User::newFromId( $random ); |
64 | 74 | |
65 | | - // Ignore blocked users who have +sysop and only send out the message |
66 | | - // when we can, i.e. when the DB is *not* locked |
67 | | - if ( !$sender->isBlocked() && !wfReadOnly() ) { |
68 | | - $senderUid = $sender->getId(); |
69 | | - $senderName = $sender->getName(); |
| 75 | + $senderUid = $sender->getId(); |
| 76 | + $senderName = $sender->getName(); |
70 | 77 | |
71 | | - $b = new UserBoard(); |
72 | | - $b->sendBoardMessage( |
73 | | - $senderUid, // sender's UID |
74 | | - $senderName, // sender's name |
75 | | - $user->getId(), |
76 | | - $user->getName(), |
77 | | - // passing the senderName as an argument here so that we can do |
78 | | - // stuff like [[User talk:$1|contact me]] or w/e in the message |
79 | | - wfMsgForContent( 'user-board-welcome-message', $senderName ) |
80 | | - // the final argument is message type: 0 (default) for public |
81 | | - ); |
82 | | - } |
| 78 | + // Send the message |
| 79 | + $b = new UserBoard(); |
| 80 | + $b->sendBoardMessage( |
| 81 | + $senderUid, // sender's UID |
| 82 | + $senderName, // sender's name |
| 83 | + $user->getId(), |
| 84 | + $user->getName(), |
| 85 | + // passing the senderName as an argument here so that we can do |
| 86 | + // stuff like [[User talk:$1|contact me]] or w/e in the message |
| 87 | + wfMsgForContent( 'user-board-welcome-message', $senderName ) |
| 88 | + // the final argument is message type: 0 (default) for public |
| 89 | + ); |
83 | 90 | } |
84 | 91 | return true; |
85 | 92 | } |
\ No newline at end of file |