2017-01-08 02:37:29 +00:00
|
|
|
<?php
|
2017-12-28 15:17:33 +00:00
|
|
|
|
2017-01-08 02:37:29 +00:00
|
|
|
namespace MediaWiki\Widget;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Widget to select multiple users.
|
2017-12-28 15:17:33 +00:00
|
|
|
*
|
2018-01-24 19:59:05 +00:00
|
|
|
* @copyright 2017 MediaWiki Widgets Team and others; see AUTHORS.txt
|
2017-12-28 15:17:33 +00:00
|
|
|
* @license MIT
|
2017-01-08 02:37:29 +00:00
|
|
|
*/
|
2018-12-12 15:57:57 +00:00
|
|
|
class UsersMultiselectWidget extends TagMultiselectWidget {
|
2019-11-14 12:34:24 +00:00
|
|
|
/** @var bool */
|
|
|
|
|
protected $ipAllowed;
|
|
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
|
protected $ipRangeAllowed;
|
|
|
|
|
|
|
|
|
|
/** @var array */
|
|
|
|
|
protected $ipRangeLimits;
|
2017-01-08 02:37:29 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array $config Configuration options
|
2019-11-14 12:34:24 +00:00
|
|
|
* - bool $config['ipAllowed'] Accept valid IP addresses
|
|
|
|
|
* - bool $config['ipRangeAllowed'] Accept valid IP ranges
|
|
|
|
|
* - array $config['ipRangeLimits'] Maximum allowed IP range sizes
|
2017-01-08 02:37:29 +00:00
|
|
|
*/
|
|
|
|
|
public function __construct( array $config = [] ) {
|
|
|
|
|
parent::__construct( $config );
|
2019-11-14 12:34:24 +00:00
|
|
|
|
|
|
|
|
if ( isset( $config['ipAllowed'] ) ) {
|
|
|
|
|
$this->ipAllowed = $config['ipAllowed'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( isset( $config['ipRangeAllowed'] ) ) {
|
|
|
|
|
$this->ipRangeAllowed = $config['ipRangeAllowed'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( isset( $config['ipRangeLimits'] ) ) {
|
|
|
|
|
$this->ipRangeLimits = $config['ipRangeLimits'];
|
|
|
|
|
}
|
2017-01-08 02:37:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getJavaScriptClassName() {
|
|
|
|
|
return 'mw.widgets.UsersMultiselectWidget';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getConfig( &$config ) {
|
2019-11-14 12:34:24 +00:00
|
|
|
if ( $this->ipAllowed !== null ) {
|
|
|
|
|
$config['ipAllowed'] = $this->ipAllowed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $this->ipRangeAllowed !== null ) {
|
|
|
|
|
$config['ipRangeAllowed'] = $this->ipRangeAllowed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $this->ipRangeLimits !== null ) {
|
|
|
|
|
$config['ipRangeLimits'] = $this->ipRangeLimits;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-08 02:37:29 +00:00
|
|
|
return parent::getConfig( $config );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|