Corrected grammatical error.
[lhc/web/wiklou.git] / includes / api / ApiBlockInfoTrait.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 /**
22 * @ingroup API
23 */
24 trait ApiBlockInfoTrait {
25
26 /**
27 * Get basic info about a given block
28 * @param Block $block
29 * @return array Array containing several keys:
30 * - blockid - ID of the block
31 * - blockedby - username of the blocker
32 * - blockedbyid - user ID of the blocker
33 * - blockreason - reason provided for the block
34 * - blockedtimestamp - timestamp for when the block was placed/modified
35 * - blockexpiry - expiry time of the block
36 * - systemblocktype - system block type, if any
37 */
38 private function getBlockInfo( Block $block ) {
39 $vals = [];
40 $vals['blockid'] = $block->getId();
41 $vals['blockedby'] = $block->getByName();
42 $vals['blockedbyid'] = $block->getBy();
43 $vals['blockreason'] = $block->getReason();
44 $vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->getTimestamp() );
45 $vals['blockexpiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
46 $vals['blockpartial'] = !$block->isSitewide();
47 if ( $block->getSystemBlockType() !== null ) {
48 $vals['systemblocktype'] = $block->getSystemBlockType();
49 }
50 return $vals;
51 }
52
53 }