/**
  * Modify an array of action links, as used by SkinTemplateNavigation and
  * SkinTemplateTabs, to inlude flagged revs UI elements
  */
 public function setActionTabs($skin, array &$actions)
 {
     $reqUser = $this->getUser();
     $this->load();
     if (FlaggedRevs::useProtectionLevels()) {
         return true;
         // simple custom levels set for action=protect
     }
     $title = $this->article->getTitle()->getSubjectPage();
     if (!FlaggedRevs::inReviewNamespace($title)) {
         return true;
         // Only reviewable pages need these tabs
     }
     // Check if we should show a stabilization tab
     if (!$this->article->getTitle()->isTalkPage() && is_array($actions) && !isset($actions['protect']) && !isset($actions['unprotect']) && $reqUser->isAllowed('stablesettings') && $title->exists()) {
         $stableTitle = SpecialPage::getTitleFor('Stabilization');
         // Add the tab
         $actions['default'] = array('class' => false, 'text' => wfMsg('stabilization-tab'), 'href' => $stableTitle->getLocalUrl('page=' . $title->getPrefixedUrl()));
     }
     return true;
 }
 /**
  * Get a <select> of options of 'autoreview' restriction levels. Used for filters.
  * @param string $selected ('' for "any", 'none' for none)
  * @return string
  */
 public static function getRestrictionFilterMenu($selected = '')
 {
     if (is_null($selected)) {
         $selected = '';
         // "all"
     }
     $s = Xml::label(wfMsg('revreview-restrictfilter'), 'wpRestriction') . "\n";
     $s .= Xml::openElement('select', array('name' => 'restriction', 'id' => 'wpRestriction'));
     $s .= Xml::option(wfMsg('revreview-restriction-any'), '', $selected == '');
     if (!FlaggedRevs::useProtectionLevels()) {
         # All "protected" pages have a protection level, not "none"
         $s .= Xml::option(wfMsg('revreview-restriction-none'), 'none', $selected == 'none');
     }
     foreach (FlaggedRevs::getRestrictionLevels() as $perm) {
         $key = "revreview-restriction-{$perm}";
         $msg = wfMsg($key);
         if (wfEmptyMsg($key, $msg)) {
             $msg = $perm;
             // fallback to user right key
         }
         $s .= Xml::option($msg, $perm, $selected == $perm);
     }
     $s .= Xml::closeElement('select') . "\n";
     return $s;
 }
Exemplo n.º 3
0
 /**
  * Find what protection level a config is in
  * @param array $config
  * @return string
  */
 public static function getProtectionLevel(array $config)
 {
     if (!FlaggedRevs::useProtectionLevels()) {
         throw new MWException('$wgFlaggedRevsProtection is disabled');
     }
     $defaultConfig = self::getDefaultVisibilitySettings();
     # Check if the page is not protected at all...
     if ($config['override'] == $defaultConfig['override'] && $config['autoreview'] == '') {
         return "none";
         // not protected
     }
     # All protection levels have 'override' on
     if ($config['override']) {
         # The levels are defined by the 'autoreview' settings
         if (in_array($config['autoreview'], FlaggedRevs::getRestrictionLevels())) {
             return $config['autoreview'];
         }
     }
     return "invalid";
 }
Exemplo n.º 4
0
 /**
  * Get a <select> of options of 'autoreview' restriction levels. Used for filters.
  * @param string $selected ('' for "any", 'none' for none)
  * @return string
  */
 public static function getRestrictionFilterMenu($selected = '')
 {
     if (is_null($selected)) {
         $selected = '';
         // "all"
     }
     $s = Xml::label(wfMessage('revreview-restrictfilter')->text(), 'wpRestriction') . "\n";
     $s .= Xml::openElement('select', array('name' => 'restriction', 'id' => 'wpRestriction'));
     $s .= Xml::option(wfMessage('revreview-restriction-any')->text(), '', $selected == '');
     if (!FlaggedRevs::useProtectionLevels()) {
         # All "protected" pages have a protection level, not "none"
         $s .= Xml::option(wfMessage('revreview-restriction-none')->text(), 'none', $selected == 'none');
     }
     foreach (FlaggedRevs::getRestrictionLevels() as $perm) {
         // Give grep a chance to find the usages:
         // revreview-restriction-any, revreview-restriction-none
         $key = "revreview-restriction-{$perm}";
         if (wfMessage($key)->isDisabled()) {
             $msg = $perm;
             // fallback to user right key
         } else {
             $msg = wfMessage($key)->text();
         }
         $s .= Xml::option($msg, $perm, $selected == $perm);
     }
     $s .= Xml::closeElement('select') . "\n";
     return $s;
 }