if ( $user->isAllowed( 'deleterevision' ) ) {
$actionButtons .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' );
}
- if ( $user->isAllowed( 'changetags' ) ) {
+ if ( ChangeTags::showTagEditingUI( $user ) ) {
$actionButtons .= $this->getRevisionButton( 'editchangetags', 'history-edit-tags' );
}
if ( $actionButtons ) {
$del = '';
$user = $this->getUser();
$canRevDelete = $user->isAllowed( 'deleterevision' );
- $canModifyTags = $user->isAllowed( 'changetags' );
+ $showTagEditUI = ChangeTags::showTagEditingUI( $user );
// Show checkboxes for each revision, to allow for revision deletion and
// change tags
- if ( $canRevDelete || $canModifyTags ) {
+ if ( $canRevDelete || $showTagEditUI ) {
$this->preventClickjacking();
// If revision was hidden from sysops and we don't need the checkbox
// for anything else, disable it
- if ( !$canModifyTags && !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
+ if ( !$showTagEditUI && !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
$del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) );
// Otherwise, enable the checkbox...
} else {
$wgMemc->set( $key, $out, 300 );
return $out;
}
+
+ /**
+ * Indicate whether change tag editing UI is relevant
+ *
+ * Returns true if the user has the necessary right and there are any
+ * editable tags defined.
+ *
+ * This intentionally doesn't check "any addable || any deletable", because
+ * it seems like it would be more confusing than useful if the checkboxes
+ * suddenly showed up because some abuse filter stopped defining a tag and
+ * then suddenly disappeared when someone deleted all uses of that tag.
+ *
+ * @param User $user
+ * @return bool
+ */
+ public static function showTagEditingUI( User $user ) {
+ return $user->isAllowed( 'changetags' ) && (bool)self::listExplicitlyDefinedTags();
+ }
}
$user = $this->getUser();
// If change tag editing is available to this user, return the checkbox
- if ( $this->flags & self::USE_CHECKBOXES && $user->isAllowed( 'changetags' ) ) {
+ if ( $this->flags & self::USE_CHECKBOXES && ChangeTags::showTagEditingUI( $user ) ) {
return Xml::check(
'showhiderevisions',
false,
private function getActionButtons( $formcontents ) {
$user = $this->getUser();
$canRevDelete = $user->isAllowedAll( 'deletedhistory', 'deletelogentry' );
- $canModifyTags = $user->isAllowed( 'changetags' );
+ $showTagEditUI = ChangeTags::showTagEditingUI( $user );
# If the user doesn't have the ability to delete log entries nor edit tags,
# don't bother showing them the button(s).
- if ( !$canRevDelete && !$canModifyTags ) {
+ if ( !$canRevDelete && !$showTagEditUI ) {
return $formcontents;
}
$this->msg( 'showhideselectedlogentries' )->text()
) . "\n";
}
- if ( $canModifyTags ) {
+ if ( $showTagEditUI ) {
$buttons .= Html::element(
'button',
array(