当前位置: 首页>>代码示例>>PHP>>正文


PHP Title::purgeExpiredRestrictions方法代码示例

本文整理汇总了PHP中Title::purgeExpiredRestrictions方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::purgeExpiredRestrictions方法的具体用法?PHP Title::purgeExpiredRestrictions怎么用?PHP Title::purgeExpiredRestrictions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Title的用法示例。


在下文中一共展示了Title::purgeExpiredRestrictions方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

	function execute( $par ) {
		$this->setHeaders();
		$this->outputHeader();

		// Purge expired entries on one in every 10 queries
		if ( !mt_rand( 0, 10 ) ) {
			Title::purgeExpiredRestrictions();
		}

		$request = $this->getRequest();
		$type = $request->getVal( $this->IdType );
		$level = $request->getVal( $this->IdLevel );
		$sizetype = $request->getVal( 'sizetype' );
		$size = $request->getIntOrNull( 'size' );
		$NS = $request->getIntOrNull( 'namespace' );

		$pager = new ProtectedTitlesPager( $this, array(), $type, $level, $NS, $sizetype, $size );

		$this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level ) );

		if ( $pager->getNumRows() ) {
			$this->getOutput()->addHTML(
				$pager->getNavigationBar() .
					'<ul>' . $pager->getBody() . '</ul>' .
					$pager->getNavigationBar()
			);
		} else {
			$this->getOutput()->addWikiMsg( 'protectedtitlesempty' );
		}
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:30,代码来源:SpecialProtectedtitles.php

示例2: execute

 function execute($par)
 {
     global $wgOut, $wgRequest;
     $this->setHeaders();
     $this->outputHeader();
     // Purge expired entries on one in every 10 queries
     if (!mt_rand(0, 10)) {
         Title::purgeExpiredRestrictions();
     }
     $type = $wgRequest->getVal($this->IdType);
     $level = $wgRequest->getVal($this->IdLevel);
     $sizetype = $wgRequest->getVal('sizetype');
     $size = $wgRequest->getIntOrNull('size');
     $NS = $wgRequest->getIntOrNull('namespace');
     $pager = new ProtectedTitlesPager($this, array(), $type, $level, $NS, $sizetype, $size);
     $wgOut->addHTML($this->showOptions($NS, $type, $level));
     if ($pager->getNumRows()) {
         $s = $pager->getNavigationBar();
         $s .= "<ul>" . $pager->getBody() . "</ul>";
         $s .= $pager->getNavigationBar();
     } else {
         $s = '<p>' . wfMsgHtml('protectedtitlesempty') . '</p>';
     }
     $wgOut->addHTML($s);
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:25,代码来源:SpecialProtectedtitles.php

示例3: execute

 public function execute($par)
 {
     $this->setHeaders();
     $this->outputHeader();
     $this->getOutput()->addModuleStyles('mediawiki.special');
     // Purge expired entries on one in every 10 queries
     if (!mt_rand(0, 10)) {
         Title::purgeExpiredRestrictions();
     }
     $request = $this->getRequest();
     $type = $request->getVal($this->IdType);
     $level = $request->getVal($this->IdLevel);
     $sizetype = $request->getVal('sizetype');
     $size = $request->getIntOrNull('size');
     $ns = $request->getIntOrNull('namespace');
     $indefOnly = $request->getBool('indefonly') ? 1 : 0;
     $cascadeOnly = $request->getBool('cascadeonly') ? 1 : 0;
     $noRedirect = $request->getBool('noredirect') ? 1 : 0;
     $pager = new ProtectedPagesPager($this, array(), $type, $level, $ns, $sizetype, $size, $indefOnly, $cascadeOnly, $noRedirect);
     $this->getOutput()->addHTML($this->showOptions($ns, $type, $level, $sizetype, $size, $indefOnly, $cascadeOnly, $noRedirect));
     if ($pager->getNumRows()) {
         $this->getOutput()->addHTML($pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
     } else {
         $this->getOutput()->addWikiMsg('protectedpagesempty');
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:26,代码来源:SpecialProtectedpages.php

示例4: showList

 public function showList($msg = '')
 {
     global $wgOut, $wgRequest;
     if ("" != $msg) {
         $wgOut->setSubtitle($msg);
     }
     // Purge expired entries on one in every 10 queries
     if (!mt_rand(0, 10)) {
         Title::purgeExpiredRestrictions();
     }
     $type = $wgRequest->getVal($this->IdType);
     $level = $wgRequest->getVal($this->IdLevel);
     $sizetype = $wgRequest->getVal('sizetype');
     $size = $wgRequest->getIntOrNull('size');
     $NS = $wgRequest->getIntOrNull('namespace');
     $indefOnly = $wgRequest->getBool('indefonly') ? 1 : 0;
     $cascadeOnly = $wgRequest->getBool('cascadeonly') ? 1 : 0;
     $pager = new ProtectedPagesPager($this, array(), $type, $level, $NS, $sizetype, $size, $indefOnly, $cascadeOnly);
     $wgOut->addHTML($this->showOptions($NS, $type, $level, $sizetype, $size, $indefOnly, $cascadeOnly));
     if ($pager->getNumRows()) {
         $s = $pager->getNavigationBar();
         $s .= "<ul>" . $pager->getBody() . "</ul>";
         $s .= $pager->getNavigationBar();
     } else {
         $s = '<p>' . wfMsgHtml('protectedpagesempty') . '</p>';
     }
     $wgOut->addHTML($s);
 }
开发者ID:ruizrube,项目名称:spdef,代码行数:28,代码来源:SpecialProtectedpages.php

示例5: doUpdateRestrictions

	/**
	 * Update the article's restriction field, and leave a log entry.
	 * This works for protection both existing and non-existing pages.
	 *
	 * @param array $limit set of restriction keys
	 * @param array $expiry per restriction type expiration
	 * @param int &$cascade Set to false if cascading protection isn't allowed.
	 * @param string $reason
	 * @param User $user The user updating the restrictions
	 * @return Status
	 */
	public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User $user ) {
		global $wgCascadingRestrictionLevels;

		if ( wfReadOnly() ) {
			return Status::newFatal( 'readonlytext', wfReadOnlyReason() );
		}

		$restrictionTypes = $this->mTitle->getRestrictionTypes();

		$id = $this->getId();

		if ( !$cascade ) {
			$cascade = false;
		}

		// Take this opportunity to purge out expired restrictions
		Title::purgeExpiredRestrictions();

		// @todo FIXME: Same limitations as described in ProtectionForm.php (line 37);
		// we expect a single selection, but the schema allows otherwise.
		$isProtected = false;
		$protect = false;
		$changed = false;

		$dbw = wfGetDB( DB_MASTER );

		foreach ( $restrictionTypes as $action ) {
			if ( !isset( $expiry[$action] ) ) {
				$expiry[$action] = $dbw->getInfinity();
			}
			if ( !isset( $limit[$action] ) ) {
				$limit[$action] = '';
			} elseif ( $limit[$action] != '' ) {
				$protect = true;
			}

			// Get current restrictions on $action
			$current = implode( '', $this->mTitle->getRestrictions( $action ) );
			if ( $current != '' ) {
				$isProtected = true;
			}

			if ( $limit[$action] != $current ) {
				$changed = true;
			} elseif ( $limit[$action] != '' ) {
				// Only check expiry change if the action is actually being
				// protected, since expiry does nothing on an not-protected
				// action.
				if ( $this->mTitle->getRestrictionExpiry( $action ) != $expiry[$action] ) {
					$changed = true;
				}
			}
		}

		if ( !$changed && $protect && $this->mTitle->areRestrictionsCascading() != $cascade ) {
			$changed = true;
		}

		// If nothing has changed, do nothing
		if ( !$changed ) {
			return Status::newGood();
		}

		if ( !$protect ) { // No protection at all means unprotection
			$revCommentMsg = 'unprotectedarticle';
			$logAction = 'unprotect';
		} elseif ( $isProtected ) {
			$revCommentMsg = 'modifiedarticleprotection';
			$logAction = 'modify';
		} else {
			$revCommentMsg = 'protectedarticle';
			$logAction = 'protect';
		}

		if ( $id ) { // Protection of existing page
			if ( !wfRunHooks( 'ArticleProtect', array( &$this, &$user, $limit, $reason ) ) ) {
				return Status::newGood();
			}

			// Only certain restrictions can cascade...
			$editrestriction = isset( $limit['edit'] ) ? array( $limit['edit'] ) : $this->mTitle->getRestrictions( 'edit' );
			foreach ( array_keys( $editrestriction, 'sysop' ) as $key ) {
				$editrestriction[$key] = 'editprotected'; // backwards compatibility
			}
			foreach ( array_keys( $editrestriction, 'autoconfirmed' ) as $key ) {
				$editrestriction[$key] = 'editsemiprotected'; // backwards compatibility
			}

			$cascadingRestrictionLevels = $wgCascadingRestrictionLevels;
//.........这里部分代码省略.........
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:101,代码来源:WikiPage.php

示例6: doUpdateRestrictions

 /**
  * Update the article's restriction field, and leave a log entry.
  * This works for protection both existing and non-existing pages.
  *
  * @param array $limit Set of restriction keys
  * @param array $expiry Per restriction type expiration
  * @param int &$cascade Set to false if cascading protection isn't allowed.
  * @param string $reason
  * @param User $user The user updating the restrictions
  * @param string|string[] $tags Change tags to add to the pages and protection log entries
  *   ($user should be able to add the specified tags before this is called)
  * @return Status Status object; if action is taken, $status->value is the log_id of the
  *   protection log entry.
  */
 public function doUpdateRestrictions(array $limit, array $expiry, &$cascade, $reason, User $user, $tags = null)
 {
     global $wgCascadingRestrictionLevels, $wgContLang;
     if (wfReadOnly()) {
         return Status::newFatal('readonlytext', wfReadOnlyReason());
     }
     $this->loadPageData('fromdbmaster');
     $restrictionTypes = $this->mTitle->getRestrictionTypes();
     $id = $this->getId();
     if (!$cascade) {
         $cascade = false;
     }
     // Take this opportunity to purge out expired restrictions
     Title::purgeExpiredRestrictions();
     // @todo FIXME: Same limitations as described in ProtectionForm.php (line 37);
     // we expect a single selection, but the schema allows otherwise.
     $isProtected = false;
     $protect = false;
     $changed = false;
     $dbw = wfGetDB(DB_MASTER);
     foreach ($restrictionTypes as $action) {
         if (!isset($expiry[$action]) || $expiry[$action] === $dbw->getInfinity()) {
             $expiry[$action] = 'infinity';
         }
         if (!isset($limit[$action])) {
             $limit[$action] = '';
         } elseif ($limit[$action] != '') {
             $protect = true;
         }
         // Get current restrictions on $action
         $current = implode('', $this->mTitle->getRestrictions($action));
         if ($current != '') {
             $isProtected = true;
         }
         if ($limit[$action] != $current) {
             $changed = true;
         } elseif ($limit[$action] != '') {
             // Only check expiry change if the action is actually being
             // protected, since expiry does nothing on an not-protected
             // action.
             if ($this->mTitle->getRestrictionExpiry($action) != $expiry[$action]) {
                 $changed = true;
             }
         }
     }
     if (!$changed && $protect && $this->mTitle->areRestrictionsCascading() != $cascade) {
         $changed = true;
     }
     // If nothing has changed, do nothing
     if (!$changed) {
         return Status::newGood();
     }
     if (!$protect) {
         // No protection at all means unprotection
         $revCommentMsg = 'unprotectedarticle';
         $logAction = 'unprotect';
     } elseif ($isProtected) {
         $revCommentMsg = 'modifiedarticleprotection';
         $logAction = 'modify';
     } else {
         $revCommentMsg = 'protectedarticle';
         $logAction = 'protect';
     }
     // Truncate for whole multibyte characters
     $reason = $wgContLang->truncate($reason, 255);
     $logRelationsValues = [];
     $logRelationsField = null;
     $logParamsDetails = [];
     // Null revision (used for change tag insertion)
     $nullRevision = null;
     if ($id) {
         // Protection of existing page
         if (!Hooks::run('ArticleProtect', [&$this, &$user, $limit, $reason])) {
             return Status::newGood();
         }
         // Only certain restrictions can cascade...
         $editrestriction = isset($limit['edit']) ? [$limit['edit']] : $this->mTitle->getRestrictions('edit');
         foreach (array_keys($editrestriction, 'sysop') as $key) {
             $editrestriction[$key] = 'editprotected';
             // backwards compatibility
         }
         foreach (array_keys($editrestriction, 'autoconfirmed') as $key) {
             $editrestriction[$key] = 'editsemiprotected';
             // backwards compatibility
         }
         $cascadingRestrictionLevels = $wgCascadingRestrictionLevels;
//.........这里部分代码省略.........
开发者ID:paladox,项目名称:mediawiki,代码行数:101,代码来源:WikiPage.php

示例7: loadRestrictionsFromRow

 /**
  * Loads a string into mRestrictions array
  * @param resource $res restrictions as an SQL result.
  */
 private function loadRestrictionsFromRow($res, $oldFashionedRestrictions = NULL)
 {
     $dbr = wfGetDb(DB_SLAVE);
     $this->mRestrictions['edit'] = array();
     $this->mRestrictions['move'] = array();
     # Backwards-compatibility: also load the restrictions from the page record (old format).
     if ($oldFashionedRestrictions == NULL) {
         $oldFashionedRestrictions = $dbr->selectField('page', 'page_restrictions', array('page_id' => $this->getArticleId()), __METHOD__);
     }
     if ($oldFashionedRestrictions != '') {
         foreach (explode(':', trim($oldFashionedRestrictions)) as $restrict) {
             $temp = explode('=', trim($restrict));
             if (count($temp) == 1) {
                 // old old format should be treated as edit/move restriction
                 $this->mRestrictions["edit"] = explode(',', trim($temp[0]));
                 $this->mRestrictions["move"] = explode(',', trim($temp[0]));
             } else {
                 $this->mRestrictions[$temp[0]] = explode(',', trim($temp[1]));
             }
         }
         $this->mOldRestrictions = true;
         $this->mCascadeRestriction = false;
         $this->mRestrictionsExpiry = Block::decodeExpiry('');
     }
     if ($dbr->numRows($res)) {
         # Current system - load second to make them override.
         $now = wfTimestampNow();
         $purgeExpired = false;
         while ($row = $dbr->fetchObject($res)) {
             # Cycle through all the restrictions.
             // This code should be refactored, now that it's being used more generally,
             // But I don't really see any harm in leaving it in Block for now -werdna
             $expiry = Block::decodeExpiry($row->pr_expiry);
             // Only apply the restrictions if they haven't expired!
             if (!$expiry || $expiry > $now) {
                 $this->mRestrictionsExpiry = $expiry;
                 $this->mRestrictions[$row->pr_type] = explode(',', trim($row->pr_level));
                 $this->mCascadeRestriction |= $row->pr_cascade;
             } else {
                 // Trigger a lazy purge of expired restrictions
                 $purgeExpired = true;
             }
         }
         if ($purgeExpired) {
             Title::purgeExpiredRestrictions();
         }
     }
     $this->mRestrictionsLoaded = true;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:53,代码来源:Title.php

示例8: updateRestrictions

 /**
  * Update the article's restriction field, and leave a log entry.
  *
  * @param $limit Array: set of restriction keys
  * @param $reason String
  * @param &$cascade Integer. Set to false if cascading protection isn't allowed.
  * @param $expiry Array: per restriction type expiration
  * @return bool true on success
  */
 public function updateRestrictions($limit = array(), $reason = '', &$cascade = 0, $expiry = array())
 {
     global $wgUser, $wgContLang;
     $restrictionTypes = $this->mTitle->getRestrictionTypes();
     $id = $this->mTitle->getArticleID();
     if ($id <= 0) {
         wfDebug("updateRestrictions failed: article id {$id} <= 0\n");
         return false;
     }
     if (wfReadOnly()) {
         wfDebug("updateRestrictions failed: read-only\n");
         return false;
     }
     if (!$this->mTitle->userCan('protect')) {
         wfDebug("updateRestrictions failed: insufficient permissions\n");
         return false;
     }
     if (!$cascade) {
         $cascade = false;
     }
     // Take this opportunity to purge out expired restrictions
     Title::purgeExpiredRestrictions();
     # FIXME: Same limitations as described in ProtectionForm.php (line 37);
     # we expect a single selection, but the schema allows otherwise.
     $current = array();
     $updated = Article::flattenRestrictions($limit);
     $changed = false;
     foreach ($restrictionTypes as $action) {
         if (isset($expiry[$action])) {
             # Get current restrictions on $action
             $aLimits = $this->mTitle->getRestrictions($action);
             $current[$action] = implode('', $aLimits);
             # Are any actual restrictions being dealt with here?
             $aRChanged = count($aLimits) || !empty($limit[$action]);
             # If something changed, we need to log it. Checking $aRChanged
             # assures that "unprotecting" a page that is not protected does
             # not log just because the expiry was "changed".
             if ($aRChanged && $this->mTitle->mRestrictionsExpiry[$action] != $expiry[$action]) {
                 $changed = true;
             }
         }
     }
     $current = Article::flattenRestrictions($current);
     $changed = $changed || $current != $updated;
     $changed = $changed || $updated && $this->mTitle->areRestrictionsCascading() != $cascade;
     $protect = $updated != '';
     # If nothing's changed, do nothing
     if ($changed) {
         if (wfRunHooks('ArticleProtect', array(&$this, &$wgUser, $limit, $reason))) {
             $dbw = wfGetDB(DB_MASTER);
             # Prepare a null revision to be added to the history
             $modified = $current != '' && $protect;
             if ($protect) {
                 $comment_type = $modified ? 'modifiedarticleprotection' : 'protectedarticle';
             } else {
                 $comment_type = 'unprotectedarticle';
             }
             $comment = $wgContLang->ucfirst(wfMsgForContent($comment_type, $this->mTitle->getPrefixedText()));
             # Only restrictions with the 'protect' right can cascade...
             # Otherwise, people who cannot normally protect can "protect" pages via transclusion
             $editrestriction = isset($limit['edit']) ? array($limit['edit']) : $this->mTitle->getRestrictions('edit');
             # The schema allows multiple restrictions
             if (!in_array('protect', $editrestriction) && !in_array('sysop', $editrestriction)) {
                 $cascade = false;
             }
             $cascade_description = '';
             if ($cascade) {
                 $cascade_description = ' [' . wfMsgForContent('protect-summary-cascade') . ']';
             }
             if ($reason) {
                 $comment .= ": {$reason}";
             }
             $editComment = $comment;
             $encodedExpiry = array();
             $protect_description = '';
             foreach ($limit as $action => $restrictions) {
                 if (!isset($expiry[$action])) {
                     $expiry[$action] = Block::infinity();
                 }
                 $encodedExpiry[$action] = Block::encodeExpiry($expiry[$action], $dbw);
                 if ($restrictions != '') {
                     $protect_description .= "[{$action}={$restrictions}] (";
                     if ($encodedExpiry[$action] != 'infinity') {
                         $protect_description .= wfMsgForContent('protect-expiring', $wgContLang->timeanddate($expiry[$action], false, false), $wgContLang->date($expiry[$action], false, false), $wgContLang->time($expiry[$action], false, false));
                     } else {
                         $protect_description .= wfMsgForContent('protect-expiry-indefinite');
                     }
                     $protect_description .= ') ';
                 }
             }
             $protect_description = trim($protect_description);
//.........这里部分代码省略.........
开发者ID:GodelDesign,项目名称:Godel,代码行数:101,代码来源:Article.php

示例9: loadRestrictions

 /**
  * Load restrictions from the page_restrictions table
  *
  * @param $oldFashionedRestrictions String comma-separated list of page
  *        restrictions from page table (pre 1.10)
  */
 public function loadRestrictions($oldFashionedRestrictions = null)
 {
     global $wgContLang;
     if (!$this->mRestrictionsLoaded) {
         if ($this->exists()) {
             $dbr = wfGetDB(DB_SLAVE);
             $res = $dbr->select('page_restrictions', '*', array('pr_page' => $this->getArticleId()), __METHOD__);
             $this->loadRestrictionsFromResultWrapper($res, $oldFashionedRestrictions);
         } else {
             $title_protection = $this->getTitleProtection();
             if ($title_protection) {
                 $now = wfTimestampNow();
                 $expiry = $wgContLang->formatExpiry($title_protection['pt_expiry'], TS_MW);
                 if (!$expiry || $expiry > $now) {
                     // Apply the restrictions
                     $this->mRestrictionsExpiry['create'] = $expiry;
                     $this->mRestrictions['create'] = explode(',', trim($title_protection['pt_create_perm']));
                 } else {
                     // Get rid of the old restrictions
                     Title::purgeExpiredRestrictions();
                     $this->mTitleProtection = false;
                 }
             } else {
                 $this->mRestrictionsExpiry['create'] = $wgContLang->formatExpiry('', TS_MW);
             }
             $this->mRestrictionsLoaded = true;
         }
     }
 }
开发者ID:namrenni,项目名称:mediawiki,代码行数:35,代码来源:Title.php

示例10: doUpdateRestrictions

 /**
  * Update the article's restriction field, and leave a log entry.
  * This works for protection both existing and non-existing pages.
  *
  * @param $limit Array: set of restriction keys
  * @param $reason String
  * @param &$cascade Integer. Set to false if cascading protection isn't allowed.
  * @param $expiry Array: per restriction type expiration
  * @param $user User The user updating the restrictions
  * @return Status
  */
 public function doUpdateRestrictions(array $limit, array $expiry, &$cascade, $reason, User $user)
 {
     global $wgContLang;
     if (wfReadOnly()) {
         return Status::newFatal('readonlytext', wfReadOnlyReason());
     }
     $restrictionTypes = $this->mTitle->getRestrictionTypes();
     $id = $this->mTitle->getArticleID();
     if (!$cascade) {
         $cascade = false;
     }
     // Take this opportunity to purge out expired restrictions
     Title::purgeExpiredRestrictions();
     # @todo FIXME: Same limitations as described in ProtectionForm.php (line 37);
     # we expect a single selection, but the schema allows otherwise.
     $isProtected = false;
     $protect = false;
     $changed = false;
     $dbw = wfGetDB(DB_MASTER);
     foreach ($restrictionTypes as $action) {
         if (!isset($expiry[$action])) {
             $expiry[$action] = $dbw->getInfinity();
         }
         if (!isset($limit[$action])) {
             $limit[$action] = '';
         } elseif ($limit[$action] != '') {
             $protect = true;
         }
         # Get current restrictions on $action
         $current = implode('', $this->mTitle->getRestrictions($action));
         if ($current != '') {
             $isProtected = true;
         }
         if ($limit[$action] != $current) {
             $changed = true;
         } elseif ($limit[$action] != '') {
             # Only check expiry change if the action is actually being
             # protected, since expiry does nothing on an not-protected
             # action.
             if ($this->mTitle->getRestrictionExpiry($action) != $expiry[$action]) {
                 $changed = true;
             }
         }
     }
     if (!$changed && $protect && $this->mTitle->areRestrictionsCascading() != $cascade) {
         $changed = true;
     }
     # If nothing's changed, do nothing
     if (!$changed) {
         return Status::newGood();
     }
     if (!$protect) {
         # No protection at all means unprotection
         $revCommentMsg = 'unprotectedarticle';
         $logAction = 'unprotect';
     } elseif ($isProtected) {
         $revCommentMsg = 'modifiedarticleprotection';
         $logAction = 'modify';
     } else {
         $revCommentMsg = 'protectedarticle';
         $logAction = 'protect';
     }
     $encodedExpiry = array();
     $protectDescription = '';
     foreach ($limit as $action => $restrictions) {
         $encodedExpiry[$action] = $dbw->encodeExpiry($expiry[$action]);
         if ($restrictions != '') {
             $protectDescription .= $wgContLang->getDirMark() . "[{$action}={$restrictions}] (";
             if ($encodedExpiry[$action] != 'infinity') {
                 $protectDescription .= wfMessage('protect-expiring', $wgContLang->timeanddate($expiry[$action], false, false), $wgContLang->date($expiry[$action], false, false), $wgContLang->time($expiry[$action], false, false))->inContentLanguage()->text();
             } else {
                 $protectDescription .= wfMessage('protect-expiry-indefinite')->inContentLanguage()->text();
             }
             $protectDescription .= ') ';
         }
     }
     $protectDescription = trim($protectDescription);
     if ($id) {
         # Protection of existing page
         if (!wfRunHooks('ArticleProtect', array(&$this, &$user, $limit, $reason))) {
             return Status::newGood();
         }
         # Only restrictions with the 'protect' right can cascade...
         # Otherwise, people who cannot normally protect can "protect" pages via transclusion
         $editrestriction = isset($limit['edit']) ? array($limit['edit']) : $this->mTitle->getRestrictions('edit');
         # The schema allows multiple restrictions
         if (!in_array('protect', $editrestriction) && !in_array('sysop', $editrestriction)) {
             $cascade = false;
         }
//.........这里部分代码省略.........
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:101,代码来源:WikiPage.php

示例11: loadRestrictions

 public function loadRestrictions($oldFashionedRestrictions = NULL)
 {
     if (!$this->mRestrictionsLoaded) {
         if ($this->exists()) {
             $dbr = wfGetDB(DB_SLAVE);
             $res = $dbr->select('page_restrictions', '*', array('pr_page' => $this->getArticleId()), __METHOD__);
             $this->loadRestrictionsFromRow($res, $oldFashionedRestrictions);
         } else {
             $title_protection = $this->getTitleProtection();
             if (is_array($title_protection)) {
                 extract($title_protection);
                 $now = wfTimestampNow();
                 $expiry = Block::decodeExpiry($pt_expiry);
                 if (!$expiry || $expiry > $now) {
                     // Apply the restrictions
                     $this->mRestrictionsExpiry = $expiry;
                     $this->mRestrictions['create'] = explode(',', trim($pt_create_perm));
                 } else {
                     // Get rid of the old restrictions
                     Title::purgeExpiredRestrictions();
                 }
             }
             $this->mRestrictionsLoaded = true;
         }
     }
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:26,代码来源:Title.php

示例12: doProtect

function doProtect($limit = array(), $reason = '', &$expiry = '')
{
    global $wgUser, $wgRestrictionTypes, $wgContLang, $wgTitle;
    $id = $wgTitle->getArticleID();
    if (wfReadOnly() || $id == 0) {
        return false;
    }
    if (strlen($expiry) == 0) {
        $expiry = 'infinite';
    }
    if ($expiry == 'infinite' || $expiry == 'indefinite') {
        $expiry = Block::infinity();
    } else {
        # Convert GNU-style date, on error returns -1 for PHP <5.1 and false for PHP >=5.1
        $expiry = strtotime($expiry);
        if ($expiry < 0 || $expiry === false) {
            //invalid expiry, rewrite to infinity
            $expiry = Block::infinity();
        } else {
            // Fixme: non-qualified absolute times are not in users specified timezone
            // and there isn't notice about it in the ui
            $expiry = wfTimestamp(TS_MW, $expiry);
        }
    }
    // Take this opportunity to purge out expired restrictions
    Title::purgeExpiredRestrictions();
    # FIXME: Same limitations as described in ProtectionForm.php (line 37);
    # we expect a single selection, but the schema allows otherwise.
    $current = array();
    foreach ($wgRestrictionTypes as $action) {
        $current[$action] = implode('', $wgTitle->getRestrictions($action));
    }
    $current = Article::flattenRestrictions($current);
    $updated = Article::flattenRestrictions($limit);
    $changed = $current != $updated;
    $changed = $changed || $wgTitle->mRestrictionsExpiry != $expiry;
    $protect = $updated != '';
    # If nothing's changed, do nothing
    if ($changed) {
        global $wgGroupPermissions;
        $dbw = wfGetDB(DB_MASTER);
        $encodedExpiry = Block::encodeExpiry($expiry, $dbw);
        $expiry_description = '';
        if ($encodedExpiry != 'infinity') {
            $expiry_description = ' (' . wfMsgForContent('protect-expiring', $wgContLang->timeanddate($expiry, false, false)) . ')';
        }
        # Prepare a null revision to be added to the history
        $modified = $current != '' && $protect;
        if ($protect) {
            $comment_type = $modified ? 'modifiedarticleprotection' : 'protectedarticle';
        } else {
            $comment_type = 'unprotectedarticle';
        }
        $comment = $wgContLang->ucfirst(wfMsgForContent($comment_type, $wgTitle->getPrefixedText()));
        if ($reason) {
            $comment .= ": {$reason}";
        }
        if ($protect) {
            $comment .= " [{$updated}]";
        }
        if ($expiry_description && $protect) {
            $comment .= "{$expiry_description}";
        }
        # Update restrictions table
        foreach ($limit as $action => $restrictions) {
            if ($restrictions != '') {
                $dbw->replace('page_restrictions', array(array('pr_page', 'pr_type')), array('pr_page' => $id, 'pr_type' => $action, 'pr_level' => $restrictions, 'pr_cascade' => 0, 'pr_expiry' => $encodedExpiry), __METHOD__);
            } else {
                $dbw->delete('page_restrictions', array('pr_page' => $id, 'pr_type' => $action), __METHOD__);
            }
        }
        # Insert a null revision
        $nullRevision = Revision::newNullRevision($dbw, $id, $comment, true);
        $nullRevId = $nullRevision->insertOn($dbw);
        # Update page record
        $dbw->update('page', array('page_touched' => $dbw->timestamp(), 'page_restrictions' => '', 'page_latest' => $nullRevId), array('page_id' => $id), 'Article::protect');
        # Update the protection log
        $log = new LogPage('protect');
        if ($protect) {
            $log->addEntry($modified ? 'modify' : 'protect', $wgTitle, trim($reason . " [{$updated}]{$expiry_description}"));
        } else {
            $log->addEntry('unprotect', $wgTitle, $reason);
        }
    }
    # End "changed" check
    return true;
}
开发者ID:ui-libraries,项目名称:TIRW,代码行数:87,代码来源:AuthorProtect.php

示例13: doUpdateRestrictions

 /**
  * Update the article's restriction field, and leave a log entry.
  * This works for protection both existing and non-existing pages.
  *
  * @param array $limit set of restriction keys
  * @param $reason String
  * @param &$cascade Integer. Set to false if cascading protection isn't allowed.
  * @param array $expiry per restriction type expiration
  * @param $user User The user updating the restrictions
  * @return Status
  */
 public function doUpdateRestrictions(array $limit, array $expiry, &$cascade, $reason, User $user)
 {
     global $wgContLang, $wgCascadingRestrictionLevels;
     if (wfReadOnly()) {
         return Status::newFatal('readonlytext', wfReadOnlyReason());
     }
     $restrictionTypes = $this->mTitle->getRestrictionTypes();
     $id = $this->getId();
     if (!$cascade) {
         $cascade = false;
     }
     // Take this opportunity to purge out expired restrictions
     Title::purgeExpiredRestrictions();
     // @todo FIXME: Same limitations as described in ProtectionForm.php (line 37);
     // we expect a single selection, but the schema allows otherwise.
     $isProtected = false;
     $protect = false;
     $changed = false;
     $dbw = wfGetDB(DB_MASTER);
     foreach ($restrictionTypes as $action) {
         if (!isset($expiry[$action])) {
             $expiry[$action] = $dbw->getInfinity();
         }
         if (!isset($limit[$action])) {
             $limit[$action] = '';
         } elseif ($limit[$action] != '') {
             $protect = true;
         }
         // Get current restrictions on $action
         $current = implode('', $this->mTitle->getRestrictions($action));
         if ($current != '') {
             $isProtected = true;
         }
         if ($limit[$action] != $current) {
             $changed = true;
         } elseif ($limit[$action] != '') {
             // Only check expiry change if the action is actually being
             // protected, since expiry does nothing on an not-protected
             // action.
             if ($this->mTitle->getRestrictionExpiry($action) != $expiry[$action]) {
                 $changed = true;
             }
         }
     }
     if (!$changed && $protect && $this->mTitle->areRestrictionsCascading() != $cascade) {
         $changed = true;
     }
     // If nothing has changed, do nothing
     if (!$changed) {
         return Status::newGood();
     }
     if (!$protect) {
         // No protection at all means unprotection
         $revCommentMsg = 'unprotectedarticle';
         $logAction = 'unprotect';
     } elseif ($isProtected) {
         $revCommentMsg = 'modifiedarticleprotection';
         $logAction = 'modify';
     } else {
         $revCommentMsg = 'protectedarticle';
         $logAction = 'protect';
     }
     $encodedExpiry = array();
     $protectDescription = '';
     # Some bots may parse IRC lines, which are generated from log entries which contain plain
     # protect description text. Keep them in old format to avoid breaking compatibility.
     # TODO: Fix protection log to store structured description and format it on-the-fly.
     $protectDescriptionLog = '';
     foreach ($limit as $action => $restrictions) {
         $encodedExpiry[$action] = $dbw->encodeExpiry($expiry[$action]);
         if ($restrictions != '') {
             $protectDescriptionLog .= $wgContLang->getDirMark() . "[{$action}={$restrictions}] (";
             # $action is one of $wgRestrictionTypes = array( 'create', 'edit', 'move', 'upload' ).
             # All possible message keys are listed here for easier grepping:
             # * restriction-create
             # * restriction-edit
             # * restriction-move
             # * restriction-upload
             $actionText = wfMessage('restriction-' . $action)->inContentLanguage()->text();
             # $restrictions is one of $wgRestrictionLevels = array( '', 'autoconfirmed', 'sysop' ),
             # with '' filtered out. All possible message keys are listed below:
             # * protect-level-autoconfirmed
             # * protect-level-sysop
             $restrictionsText = wfMessage('protect-level-' . $restrictions)->inContentLanguage()->text();
             if ($encodedExpiry[$action] != 'infinity') {
                 $expiryText = wfMessage('protect-expiring', $wgContLang->timeanddate($expiry[$action], false, false), $wgContLang->date($expiry[$action], false, false), $wgContLang->time($expiry[$action], false, false))->inContentLanguage()->text();
             } else {
                 $expiryText = wfMessage('protect-expiry-indefinite')->inContentLanguage()->text();
             }
//.........这里部分代码省略.........
开发者ID:mangowi,项目名称:mediawiki,代码行数:101,代码来源:WikiPage.php

示例14: updateRestrictions

 /**
  * Update the article's restriction field, and leave a log entry.
  *
  * @param array $limit set of restriction keys
  * @param string $reason
  * @return bool true on success
  */
 function updateRestrictions($limit = array(), $reason = '', $cascade = 0, $expiry = null)
 {
     global $wgUser, $wgRestrictionTypes, $wgContLang;
     $id = $this->mTitle->getArticleID();
     if (array() != $this->mTitle->getUserPermissionsErrors('protect', $wgUser) || wfReadOnly() || $id == 0) {
         return false;
     }
     if (!$cascade) {
         $cascade = false;
     }
     // Take this opportunity to purge out expired restrictions
     Title::purgeExpiredRestrictions();
     # FIXME: Same limitations as described in ProtectionForm.php (line 37);
     # we expect a single selection, but the schema allows otherwise.
     $current = array();
     foreach ($wgRestrictionTypes as $action) {
         $current[$action] = implode('', $this->mTitle->getRestrictions($action));
     }
     $current = Article::flattenRestrictions($current);
     $updated = Article::flattenRestrictions($limit);
     $changed = $current != $updated;
     $changed = $changed || $this->mTitle->areRestrictionsCascading() != $cascade;
     $changed = $changed || $this->mTitle->mRestrictionsExpiry != $expiry;
     $protect = $updated != '';
     # If nothing's changed, do nothing
     if ($changed) {
         global $wgGroupPermissions;
         if (wfRunHooks('ArticleProtect', array(&$this, &$wgUser, $limit, $reason))) {
             $dbw = wfGetDB(DB_MASTER);
             $encodedExpiry = Block::encodeExpiry($expiry, $dbw);
             $expiry_description = '';
             if ($encodedExpiry != 'infinity') {
                 $expiry_description = ' (' . wfMsgForContent('protect-expiring', $wgContLang->timeanddate($expiry, false, false)) . ')';
             }
             # Prepare a null revision to be added to the history
             $modified = $current != '' && $protect;
             if ($protect) {
                 $comment_type = $modified ? 'modifiedarticleprotection' : 'protectedarticle';
             } else {
                 $comment_type = 'unprotectedarticle';
             }
             $comment = $wgContLang->ucfirst(wfMsgForContent($comment_type, $this->mTitle->getPrefixedText()));
             foreach ($limit as $action => $restrictions) {
                 # Check if the group level required to edit also can protect pages
                 # Otherwise, people who cannot normally protect can "protect" pages via transclusion
                 $cascade = $cascade && isset($wgGroupPermissions[$restrictions]['protect']) && $wgGroupPermissions[$restrictions]['protect'];
             }
             $cascade_description = '';
             if ($cascade) {
                 $cascade_description = ' [' . wfMsg('protect-summary-cascade') . ']';
             }
             if ($reason) {
                 $comment .= ": {$reason}";
             }
             if ($protect) {
                 $comment .= " [{$updated}]";
             }
             if ($expiry_description && $protect) {
                 $comment .= "{$expiry_description}";
             }
             if ($cascade) {
                 $comment .= "{$cascade_description}";
             }
             $rowsAffected = false;
             # Update restrictions table
             foreach ($limit as $action => $restrictions) {
                 if ($restrictions != '') {
                     $dbw->replace('page_restrictions', array(array('pr_page', 'pr_type')), array('pr_page' => $id, 'pr_type' => $action, 'pr_level' => $restrictions, 'pr_cascade' => $cascade ? 1 : 0, 'pr_expiry' => $encodedExpiry), __METHOD__);
                     if ($dbw->affectedRows() != 0) {
                         $rowsAffected = true;
                     }
                 } else {
                     $dbw->delete('page_restrictions', array('pr_page' => $id, 'pr_type' => $action), __METHOD__);
                     if ($dbw->affectedRows() != 0) {
                         $rowsAffected = true;
                     }
                 }
             }
             if (!$rowsAffected) {
                 // No change
                 return true;
             }
             # Insert a null revision
             $nullRevision = Revision::newNullRevision($dbw, $id, $comment, true);
             $nullRevId = $nullRevision->insertOn($dbw);
             # Update page record
             $dbw->update('page', array('page_touched' => $dbw->timestamp(), 'page_restrictions' => '', 'page_catinfo' => $this->mTitle->getCategoryMask(), 'page_latest' => $nullRevId), array('page_id' => $id), 'Article::protect');
             wfRunHooks('ArticleProtectComplete', array(&$this, &$wgUser, $limit, $reason));
             # Update the protection log
             $log = new LogPage('protect');
             if ($protect) {
                 $log->addEntry($modified ? 'modify' : 'protect', $this->mTitle, trim($reason . " [{$updated}]{$cascade_description}{$expiry_description}"));
             } else {
//.........这里部分代码省略.........
开发者ID:ErdemA,项目名称:wikihow,代码行数:101,代码来源:Article.php


注:本文中的Title::purgeExpiredRestrictions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。