From b4841ed400a6b2302af1a7e8b4ec5888453f8089 Mon Sep 17 00:00:00 2001 From: Rotem Liss Date: Sun, 7 Sep 2008 08:24:00 +0000 Subject: [PATCH] Show properly-sized select elements in protection form when the user does not have a specific permission. --- includes/ProtectionForm.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index d05042bfed..738d55da99 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -389,15 +389,8 @@ class ProtectionForm { function buildSelector( $action, $selected ) { global $wgRestrictionLevels, $wgUser; - $id = 'mwProtect-level-' . $action; - $attribs = array( - 'id' => $id, - 'name' => $id, - 'size' => count( $wgRestrictionLevels ), - 'onchange' => 'protectLevelsUpdate(this)', - ) + $this->disabledAttrib; - $out = Xml::openElement( 'select', $attribs ); + $levels = array(); foreach( $wgRestrictionLevels as $key ) { //don't let them choose levels above their own (aka so they can still unprotect and edit the page). but only when the form isn't disabled if( $key == 'sysop' ) { @@ -408,6 +401,19 @@ class ProtectionForm { if( !$wgUser->isAllowed($key) && !$this->disabled ) continue; } + $levels[] = $key; + } + + $id = 'mwProtect-level-' . $action; + $attribs = array( + 'id' => $id, + 'name' => $id, + 'size' => count( $levels ), + 'onchange' => 'protectLevelsUpdate(this)', + ) + $this->disabledAttrib; + + $out = Xml::openElement( 'select', $attribs ); + foreach( $levels as $key ) { $out .= Xml::option( $this->getOptionLabel( $key ), $key, $key == $selected ); } $out .= Xml::closeElement( 'select' ); -- 2.20.1