*/
public static function canAddTagsAccompanyingChange( array $tags, User $user = null ) {
if ( !is_null( $user ) ) {
- if ( !$user->isAllowed( 'applychangetags' ) ) {
+ if ( !MediaWikiServices::getInstance()->getPermissionManager()
+ ->userHasRight( $user, 'applychangetags' )
+ ) {
return Status::newFatal( 'tags-apply-no-permission' );
- } elseif ( $user->getBlock() ) {
- // @TODO Ensure that the block does not apply to the `applychangetags`
- // right.
+ } elseif ( $user->getBlock() && $user->getBlock()->isSitewide() ) {
return Status::newFatal( 'tags-apply-blocked', $user->getName() );
}
}
User $user = null
) {
if ( !is_null( $user ) ) {
- if ( !$user->isAllowed( 'changetags' ) ) {
+ if ( !MediaWikiServices::getInstance()->getPermissionManager()
+ ->userHasRight( $user, 'changetags' )
+ ) {
return Status::newFatal( 'tags-update-no-permission' );
- } elseif ( $user->getBlock() ) {
- // @TODO Ensure that the block does not apply to the `changetags`
- // right.
+ } elseif ( $user->getBlock() && $user->getBlock()->isSitewide() ) {
return Status::newFatal( 'tags-update-blocked', $user->getName() );
}
}
}
$logEntry->setParameters( $params );
$logEntry->setRelations( [ 'Tag' => $tag ] );
- $logEntry->setTags( $logEntryTags );
+ $logEntry->addTags( $logEntryTags );
$logId = $logEntry->insert( $dbw );
$logEntry->publish( $logId );
*/
public static function canActivateTag( $tag, User $user = null ) {
if ( !is_null( $user ) ) {
- if ( !$user->isAllowed( 'managechangetags' ) ) {
+ if ( !MediaWikiServices::getInstance()->getPermissionManager()
+ ->userHasRight( $user, 'managechangetags' )
+ ) {
return Status::newFatal( 'tags-manage-no-permission' );
- } elseif ( $user->getBlock() ) {
- // @TODO Ensure that the block does not apply to the `managechangetags`
- // right.
+ } elseif ( $user->getBlock() && $user->getBlock()->isSitewide() ) {
return Status::newFatal( 'tags-manage-blocked', $user->getName() );
}
}
*/
public static function canDeactivateTag( $tag, User $user = null ) {
if ( !is_null( $user ) ) {
- if ( !$user->isAllowed( 'managechangetags' ) ) {
+ if ( !MediaWikiServices::getInstance()->getPermissionManager()
+ ->userHasRight( $user, 'managechangetags' )
+ ) {
return Status::newFatal( 'tags-manage-no-permission' );
- } elseif ( $user->getBlock() ) {
- // @TODO Ensure that the block does not apply to the `managechangetags`
- // right.
+ } elseif ( $user->getBlock() && $user->getBlock()->isSitewide() ) {
return Status::newFatal( 'tags-manage-blocked', $user->getName() );
}
}
*/
public static function canCreateTag( $tag, User $user = null ) {
if ( !is_null( $user ) ) {
- if ( !$user->isAllowed( 'managechangetags' ) ) {
+ if ( !MediaWikiServices::getInstance()->getPermissionManager()
+ ->userHasRight( $user, 'managechangetags' )
+ ) {
return Status::newFatal( 'tags-manage-no-permission' );
- } elseif ( $user->getBlock() ) {
- // @TODO Ensure that the block does not apply to the `managechangetags`
- // right.
+ } elseif ( $user->getBlock() && $user->getBlock()->isSitewide() ) {
return Status::newFatal( 'tags-manage-blocked', $user->getName() );
}
}
$tagUsage = self::tagUsageStatistics();
if ( !is_null( $user ) ) {
- if ( !$user->isAllowed( 'deletechangetags' ) ) {
+ if ( !MediaWikiServices::getInstance()->getPermissionManager()
+ ->userHasRight( $user, 'deletechangetags' )
+ ) {
return Status::newFatal( 'tags-delete-no-permission' );
- } elseif ( $user->getBlock() ) {
- // @TODO Ensure that the block does not apply to the `deletechangetags`
- // right.
+ } elseif ( $user->getBlock() && $user->getBlock()->isSitewide() ) {
return Status::newFatal( 'tags-manage-blocked', $user->getName() );
}
}
* @return bool
*/
public static function showTagEditingUI( User $user ) {
- return $user->isAllowed( 'changetags' ) && (bool)self::listExplicitlyDefinedTags();
+ return MediaWikiServices::getInstance()->getPermissionManager()
+ ->userHasRight( $user, 'changetags' ) &&
+ (bool)self::listExplicitlyDefinedTags();
}
}