protected function reallyDoCheckParameters()
 {
     # WMF temp hack...protection limit quota
     global $wgFlaggedRevsProtectQuota;
     $oldConfig = $this->getOldConfig();
     if (isset($wgFlaggedRevsProtectQuota) && $this->autoreview != '' && FRPageConfig::getProtectionLevel($oldConfig) == 'none') {
         $dbw = wfGetDB(DB_MASTER);
         $count = $dbw->selectField('flaggedpage_config', 'COUNT(*)', '', __METHOD__);
         if ($count >= $wgFlaggedRevsProtectQuota) {
             return 'stabilize_protect_quota';
         }
     }
     # Autoreview only when protecting currently unprotected pages
     $this->reviewThis = FRPageConfig::getProtectionLevel($oldConfig) == 'none';
     # Autoreview restriction => use stable
     # No autoreview restriction => site default
     $this->override = $this->autoreview != '' ? 1 : (int) FlaggedRevs::isStableShownByDefault();
     // site default
     # Check that settings are a valid protection level...
     $newConfig = array('override' => $this->override, 'autoreview' => $this->autoreview);
     if (FRPageConfig::getProtectionLevel($newConfig) == 'invalid') {
         return 'stabilize_invalid_level';
         // double-check configuration
     }
     # Check autoreview restriction setting
     if (!FlaggedRevs::userCanSetAutoreviewLevel($this->user, $this->autoreview)) {
         return 'stabilize_denied';
         // invalid value
     }
     return true;
 }
    public static function onProtectionForm(Page $article, &$output)
    {
        global $wgUser, $wgOut, $wgRequest, $wgLang;
        if (!$article->exists()) {
            return true;
            // nothing to do
        } elseif (!FlaggedRevs::inReviewNamespace($article->getTitle())) {
            return true;
            // not a reviewable page
        }
        $form = new PageStabilityProtectForm($wgUser);
        $form->setPage($article->getTitle());
        # Can the user actually do anything?
        $isAllowed = $form->isAllowed();
        $disabledAttrib = $isAllowed ? array() : array('disabled' => 'disabled');
        # Get the current config/expiry
        $config = FRPageConfig::getStabilitySettings($article->getTitle(), FR_MASTER);
        $oldExpirySelect = $config['expiry'] == 'infinity' ? 'infinite' : 'existing';
        # Load requested restriction level, default to current level...
        $restriction = $wgRequest->getVal('mwStabilityLevel', FRPageConfig::getProtectionLevel($config));
        # Load the requested expiry time (dropdown)
        $expirySelect = $wgRequest->getVal('mwStabilizeExpirySelection', $oldExpirySelect);
        # Load the requested expiry time (field)
        $expiryOther = $wgRequest->getVal('mwStabilizeExpiryOther', '');
        if ($expiryOther != '') {
            $expirySelect = 'othertime';
        }
        // mutual exclusion
        # Add an extra row to the protection fieldset tables.
        # Includes restriction dropdown and expiry dropdown & field.
        $output .= "<tr><td>";
        $output .= Xml::openElement('fieldset');
        $legendMsg = wfMsgExt('flaggedrevs-protect-legend', 'parseinline');
        $output .= "<legend>{$legendMsg}</legend>";
        # Add a "no restrictions" level
        $effectiveLevels = FlaggedRevs::getRestrictionLevels();
        array_unshift($effectiveLevels, "none");
        # Show all restriction levels in a <select>...
        $attribs = array('id' => 'mwStabilityLevel', 'name' => 'mwStabilityLevel', 'size' => count($effectiveLevels)) + $disabledAttrib;
        $output .= Xml::openElement('select', $attribs);
        foreach ($effectiveLevels as $limit) {
            if ($limit == 'none') {
                $label = wfMsg('flaggedrevs-protect-none');
            } else {
                $label = wfMsg('flaggedrevs-protect-' . $limit);
            }
            // Default to the key itself if no UI message
            if (wfEmptyMsg('flaggedrevs-protect-' . $limit, $label)) {
                $label = 'flaggedrevs-protect-' . $limit;
            }
            $output .= Xml::option($label, $limit, $limit == $restriction);
        }
        $output .= Xml::closeElement('select');
        # Get expiry dropdown <select>...
        $scExpiryOptions = wfMsgForContent('protect-expiry-options');
        $showProtectOptions = $scExpiryOptions !== '-' && $isAllowed;
        # Add the current expiry as an option
        $expiryFormOptions = '';
        if ($config['expiry'] != 'infinity') {
            $timestamp = $wgLang->timeanddate($config['expiry']);
            $d = $wgLang->date($config['expiry']);
            $t = $wgLang->time($config['expiry']);
            $expiryFormOptions .= Xml::option(wfMsg('protect-existing-expiry', $timestamp, $d, $t), 'existing', $expirySelect == 'existing') . "\n";
        }
        $expiryFormOptions .= Xml::option(wfMsg('protect-othertime-op'), 'othertime') . "\n";
        # Add custom dropdown levels (from MediaWiki message)
        foreach (explode(',', $scExpiryOptions) as $option) {
            if (strpos($option, ":") === false) {
                $show = $value = $option;
            } else {
                list($show, $value) = explode(":", $option);
            }
            $show = htmlspecialchars($show);
            $value = htmlspecialchars($value);
            $expiryFormOptions .= Xml::option($show, $value, $expirySelect == $value) . "\n";
        }
        # Actually add expiry dropdown to form
        $output .= "<table>";
        // expiry table start
        if ($showProtectOptions && $isAllowed) {
            $output .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('stabilization-expiry'), 'mwStabilizeExpirySelection') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::tags('select', array('id' => 'mwStabilizeExpirySelection', 'name' => 'mwStabilizeExpirySelection', 'onchange' => 'onFRChangeExpiryDropdown()') + $disabledAttrib, $expiryFormOptions) . "</td>\n\t\t\t\t</tr>";
        }
        # Add custom expiry field to form
        $attribs = array('id' => 'mwStabilizeExpiryOther', 'onkeyup' => 'onFRChangeExpiryField()') + $disabledAttrib;
        $output .= "\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('stabilization-othertime'), 'mwStabilizeExpiryOther') . '</td>
				<td class="mw-input">' . Xml::input('mwStabilizeExpiryOther', 50, $expiryOther, $attribs) . '</td>
			</tr>';
        $output .= "</table>";
        // expiry table end
        # Close field set and table row
        $output .= Xml::closeElement('fieldset');
        $output .= "</td></tr>";
        # Add some javascript for expiry dropdowns
        $wgOut->addScript("<script type=\"text/javascript\">\n\t\t\t\tfunction onFRChangeExpiryDropdown() {\n\t\t\t\t\tdocument.getElementById('mwStabilizeExpiryOther').value = '';\n\t\t\t\t}\n\t\t\t\tfunction onFRChangeExpiryField() {\n\t\t\t\t\tdocument.getElementById('mwStabilizeExpirySelection').value = 'othertime';\n\t\t\t\t}\n\t\t\t</script>");
        return true;
    }