* @file
*/
-use MediaWiki\MediaWikiServices;
-
/**
* Form to edit user preferences.
*
// Override default value from HTMLForm
protected $mSubSectionBeforeFields = false;
+ /** @var User|null */
private $modifiedUser;
+ /** @var bool */
+ private $privateInfoEditable = true;
+
+ /** @var bool */
+ private $optionsEditable = true;
+
/**
* @param User $user
*/
}
}
+ /**
+ * @return bool
+ */
+ public function isPrivateInfoEditable() {
+ return $this->privateInfoEditable;
+ }
+
+ /**
+ * Whether the
+ * @param bool $editable
+ */
+ public function setPrivateInfoEditable( $editable ) {
+ $this->privateInfoEditable = $editable;
+ }
+
+ /**
+ * @return bool
+ */
+ public function areOptionsEditable() {
+ return $this->optionsEditable;
+ }
+
+ /**
+ * @param bool $optionsEditable
+ */
+ public function setOptionsEditable( $optionsEditable ) {
+ $this->optionsEditable = $optionsEditable;
+ }
+
/**
* Get extra parameters for the query string when redirecting after
* successful save.
* @return string
*/
function getButtons() {
- $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
- if ( !$permissionManager->userHasAnyRight(
- $this->getModifiedUser(),
- 'editmyprivateinfo',
- 'editmyoptions'
- ) ) {
+ if ( !$this->areOptionsEditable() && !$this->isPrivateInfoEditable() ) {
return '';
}
$html = parent::getButtons();
- if ( $permissionManager->userHasRight( $this->getModifiedUser(), 'editmyoptions' ) ) {
+ if ( $this->areOptionsEditable() ) {
$t = $this->getTitle()->getSubpage( 'reset' );
$html .= new OOUI\ButtonWidget( [