/**
  * Protects a message entry in the PRAd namespace.
  * The protection lasts for infinity and acts for group
  * @ref $wgPromoterProtectGroup
  *
  * This really is intended only for use on the original source language
  * because those messages are set via the PR UI; not the translate UI.
  *
  * @param WikiPage $page Page containing the message to protect
  * @param User     $user User doing the protection (ie: the last one to edit the page)
  */
 protected function protectMessageInPrNamespaces($page, $user)
 {
     global $wgPromoterProtectGroup;
     if (!$page->getTitle()->getRestrictions('edit')) {
         $var = false;
         $page->doUpdateRestrictions(array('edit' => $wgPromoterProtectGroup, 'move' => $wgPromoterProtectGroup), array('edit' => 'infinity', 'move' => 'infinity'), $var, 'Auto protected by Promoter -- Only edit via Special:Promoter.', $user);
     }
 }
Beispiel #2
0
	/**
	 * @param $limit array
	 * @param $reason string
	 * @param $cascade int
	 * @param $expiry array
	 * @return bool
	 */
	public function updateRestrictions( $limit = array(), $reason = '', &$cascade = 0, $expiry = array() ) {
		return $this->mPage->doUpdateRestrictions(
			$limit,
			$expiry,
			$cascade,
			$reason,
			$this->getContext()->getUser()
		);
	}
Beispiel #3
0
 /**
  * @param $limit array
  * @param $expiry array
  * @param $cascade bool
  * @param $reason string
  * @param $user User
  * @return Status
  */
 public function doUpdateRestrictions(array $limit, array $expiry, &$cascade, $reason, User $user)
 {
     return $this->mPage->doUpdateRestrictions($limit, $expiry, $cascade, $reason, $user);
 }
 protected function flag_to_semi_protect(User $user, $reason)
 {
     global $wgFlaggedRevsNamespaces;
     $this->output("Semi-protecting all flag-protected pages...\n");
     if (!$wgFlaggedRevsNamespaces) {
         $this->output("\$wgFlaggedRevsNamespaces is empty.\n");
         return;
     }
     $db = wfGetDB(DB_MASTER);
     $start = $db->selectField('flaggedpage_config', 'MIN(fpc_page_id)', false, __FUNCTION__);
     $end = $db->selectField('flaggedpage_config', 'MAX(fpc_page_id)', false, __FUNCTION__);
     if (is_null($start) || is_null($end)) {
         $this->output("...flaggedpage_config table seems to be empty.\n");
         return;
     }
     # Do remaining chunk
     $end += $this->mBatchSize - 1;
     $blockStart = $start;
     $blockEnd = $start + $this->mBatchSize - 1;
     $count = 0;
     while ($blockEnd <= $end) {
         $this->output("...doing fpc_page_id from {$blockStart} to {$blockEnd}\n");
         $res = $db->select(array('flaggedpage_config', 'page'), array('fpc_page_id', 'fpc_level', 'fpc_expiry'), array("fpc_page_id BETWEEN {$blockStart} AND {$blockEnd}", 'page_namespace' => $wgFlaggedRevsNamespaces, 'page_id = fpc_page_id', "fpc_level != ''"), __FUNCTION__);
         # Go through and protect each page...
         foreach ($res as $row) {
             $title = Title::newFromId($row->fpc_page_id);
             if ($title->isProtected('edit')) {
                 continue;
                 // page already has edit protection - skip it
             }
             # Flagged protection settings
             $frLimit = trim($row->fpc_level);
             $frExpiry = $row->fpc_expiry === $db->getInfinity() ? 'infinity' : wfTimestamp(TS_MW, $row->fpc_expiry);
             # Build the new protection settings
             $cascade = 0;
             $limit = $expiry = array();
             $desc = array();
             // for output
             foreach ($title->getRestrictionTypes() as $type) {
                 # Get existing restrictions for this action
                 $oldLimit = $title->getRestrictions($type);
                 // array
                 $oldExpiry = $title->getRestrictionExpiry($type);
                 // MW_TS
                 # Move or Edit rights - take highest of (flag,type) settings
                 if ($type == 'edit' || $type == 'move') {
                     # Sysop flag-protect -> full protect
                     if ($frLimit == 'sysop' || in_array('sysop', $oldLimit)) {
                         $newLimit = 'sysop';
                         # Reviewer/autoconfirmed flag-protect -> semi-protect
                     } else {
                         $newLimit = 'autoconfirmed';
                     }
                     # Take highest expiry of (flag,type) settings
                     $newExpiry = !$oldLimit || $frExpiry >= $oldExpiry ? $frExpiry : $oldExpiry;
                     # Otherwise - maintain original limits
                 } else {
                     $newLimit = $oldLimit;
                     $newExpiry = $oldExpiry;
                 }
                 $limit[$type] = $newLimit;
                 $expiry[$type] = $newExpiry;
                 $desc[] = "{$type}={$newLimit}: {$newExpiry}";
             }
             $db->begin();
             $article = new WikiPage($title);
             $ok = $article->doUpdateRestrictions($limit, $reason, $cascade, $expiry, $user);
             if ($ok) {
                 $count++;
             } else {
                 $this->output("Could not protect: " . $title->getPrefixedText() . "\n");
             }
             $db->commit();
         }
         $db->freeResult($res);
         $blockStart += $this->mBatchSize - 1;
         $blockEnd += $this->mBatchSize - 1;
         wfWaitForSlaves(5);
     }
     $this->output("Protection of all flag-protected pages complete ... {$count} pages\n");
 }