diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/Article.php ./includes/Article.php --- ../mediawiki-1.5.8/includes/Article.php 2006-02-14 22:49:25.000000000 +0100 +++ ./includes/Article.php 2006-04-21 16:44:46.000000000 +0200 @@ -746,7 +746,12 @@ # Another whitelist check in case oldid or redirects are altering the title if ( !$this->mTitle->userCanRead() ) { - $wgOut->loginToUse(); + if ( $this->mTitle->isRestricted() ) { + $wgOut->restrictGroupRequired(); + } else { + $wgOut->loginToUse(); + } + $wgOut->output(); exit; } @@ -1034,7 +1039,7 @@ */ function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false ) { global $wgOut, $wgUser; - global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer; + global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer, $wgRestrictNewPages; $fname = 'Article::insertNewArticle'; wfProfileIn( $fname ); @@ -1056,7 +1061,7 @@ $dbw =& wfGetDB( DB_MASTER ); # Add the page record; stake our claim on this title! - $newid = $this->insertOn( $dbw ); + $newid = $this->insertOn( $dbw, ($wgRestrictNewPages && $wgUser->isAllowed('restrict') ? 'view=1' : '') ); # Save the revision text... $revision = new Revision( array( @@ -1193,7 +1198,7 @@ * first set $wgUser, and clean up $wgDeferredUpdates after each edit. */ function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) { - global $wgOut, $wgUser; + global $wgOut, $wgUser, $wgEnableRestrict, $wgNoRecentChangesRestrict; global $wgDBtransactions, $wgMwRedir; global $wgUseSquid, $wgInternalServer, $wgPostCommitUpdateList, $wgUseFileCache; @@ -1262,9 +1267,10 @@ } else { # Update recentchanges and purge cache and whatnot $bot = (int)($wgUser->isBot() || $forceBot); - RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $wgUser, $summary, - $lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize, - $revisionId ); + if (!$wgEnableRestrict || !$wgNoRecentChangesRestrict || !$this->mTitle->isRestricted()) + RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $wgUser, $summary, + $lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize, + $revisionId ); Article::onArticleEdit( $this->mTitle ); $dbw->commit(); } @@ -1552,6 +1558,9 @@ if( !$moveonly ) { $restrictions .= ":edit=" . $limit; } + if(current($this->mTitle->getRestrictions('view'))) { + $restrictions .= ":view=1"; + } if (wfRunHooks('ArticleProtect', array(&$this, &$wgUser, $limit == 'sysop', $reason, $moveonly))) { $dbw =& wfGetDB( DB_MASTER ); @@ -1658,6 +1667,143 @@ function unprotect() { return $this->protect( '' ); } + + + /** + * Restrict a page + * (restrict-patch by Jerome Combaz) + */ + function restrict( $limit = true ) { + global $wgUser, $wgOut, $wgRequest, $wgEnableRestrict; + + if ( ! $wgEnableRestrict == true ) return; + + if ( ! $wgUser->isAllowed('restrict') ) { + $wgOut->restrictGroupRequired(); + return; + } + if ( wfReadOnly() ) { + $wgOut->readOnlyPage(); + return; + } + $id = $this->mTitle->getArticleID(); + if ( 0 == $id ) { + $wgOut->fatalError( wfMsg( 'badarticleerror' ) ); + return; + } + + $confirm = $wgRequest->wasPosted() && + $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ); + $reason = $wgRequest->getText( 'wpReasonRestrict' ); + + if ( $confirm ) { + $dbw =& wfGetDB( DB_MASTER ); + $dbw->update( 'page', + array( /* SET */ + 'page_touched' => $dbw->timestamp(), + 'page_restrictions' => (string)$limit + ), array( /* WHERE */ + 'page_id' => $id + ), 'Article::restrict' + ); + + $getredit = $this->mTitle->getRestrictions('edit'); + $edit = "edit=".current($getredit); + $getrmove = $this->mTitle->getRestrictions('move'); + $move = "move=".current($getrmove); + $view = ($limit ? 'view=1' : 'view=0'); + $restrictions = implode(':', array($edit, $move, $view)); + + if (wfRunHooks('ArticleRestrict', array(&$this, &$wgUser, $limit == true, $reason))) { + + $dbw =& wfGetDB( DB_MASTER ); + $dbw->update( 'page', + array( /* SET */ + 'page_touched' => $dbw->timestamp(), + 'page_restrictions' => $restrictions + ), array( /* WHERE */ + 'page_id' => $id + ), 'Article::restrict' + ); + + wfRunHooks('ArticleRestrictComplete', array(&$this, &$wgUser, $limit == true, $reason, $moveonly)); + + $log = new LogPage( 'restrict' ); + if ( $limit === '' ) { + $log->addEntry( 'unrestrict', $this->mTitle, $reason ); + } else { + $log->addEntry( 'restrict', $this->mTitle, $reason ); + } + $wgOut->redirect( $this->mTitle->getFullURL() ); + } + return; + } else { + return $this->confirmRestrict( '', '', $limit ); + } + } + + /** + * Output restriction confirmation dialog + */ + function confirmRestrict( $par, $reason, $limit ) { + global $wgOut, $wgUser; + + wfDebug( "Article::confirmRestrict\n" ); + + $sub = htmlspecialchars( $this->mTitle->getPrefixedText() ); + $wgOut->setRobotpolicy( 'noindex,nofollow' ); + + $check = ''; + $protcom = ''; + $moveonly = ''; + + if ( $limit === '' ) { + $wgOut->setPageTitle( wfMsg( 'confirmunrestrict' ) ); + $wgOut->setSubtitle( wfMsg( 'unrestrictsub', $sub ) ); + $wgOut->addWikiText( wfMsg( 'confirmrestricttext' ) ); + $protcom = htmlspecialchars( wfMsg( 'unrestrictcomment' ) ); + $formaction = $this->mTitle->escapeLocalURL( 'action=unrestrict' . $par ); + } else { + $wgOut->setPageTitle( wfMsg( 'confirmrestrict' ) ); + $wgOut->setSubtitle( wfMsg( 'restrictsub', $sub ) ); + $wgOut->addWikiText( wfMsg( 'confirmrestricttext' ) ); + $protcom = htmlspecialchars( wfMsg( 'restrictcomment' ) ); + $formaction = $this->mTitle->escapeLocalURL( 'action=restrict' . $par ); + } + + $confirm = htmlspecialchars( wfMsg( 'confirm' ) ); + $token = htmlspecialchars( $wgUser->editToken() ); + + $wgOut->addHTML( " +
+ + + + + + + + + +
+ + + +
  + +
+ +
" ); + + $wgOut->returnToMain( false ); + } + + /** + * Unrestrict the pages + */ + function unrestrict() { + return $this->restrict( '' ); + } /* * UI entry point for page deletion diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/DefaultSettings.php ./includes/DefaultSettings.php --- ../mediawiki-1.5.8/includes/DefaultSettings.php 2006-03-26 21:38:24.000000000 +0200 +++ ./includes/DefaultSettings.php 2006-04-21 16:44:46.000000000 +0200 @@ -1672,4 +1672,50 @@ */ $wgUseTrackbacks = false; + +/** + * + * Restriction patch (by Jerome Combaz) + * see http://meta.wikimedia.org/wiki/Page_access_restriction_with_MediaWiki + * + */ + +/** + * If true, a new menu action allows to restrict pages access to 'restrict' group users + */ +$wgEnableRestrict = false; + +/** + * If true, new pages are restricted by default for 'restrict' group users + */ +$wgRestrictNewPages = false; + +/** + * Restrict user pages to their owner (as well as viewrestrict/restrict members) + */ +$wgUserPageRestrict = false; + +/** + * Regular expression array to restrict matching pages + * eg. $wgRegexRestrict = array("^Secure:", "^Secret "); // restrict all pages where title is like 'Secure:...' or 'Secret ...' + */ +$wgRegexRestrict = array(); + +/** + * Hide recent changes entry for restricted pages + */ +$wgNoRecentChangesRestrict = true; + +/** + * Hide log entries related to restriction except for 'restrict' or 'viewrestrict' users (Special:Log page) + */ +$wgHideRestrictLog = true; + +/** + * MediaWiki permissions setup + */ +$wgGroupPermissions['restrict']['restrict'] = +$wgGroupPermissions['restrict']['viewrestrict'] = true; +$wgGroupPermissions['viewrestrict']['viewrestrict'] = true; + ?> diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/Defines.php ./includes/Defines.php --- ../mediawiki-1.5.8/includes/Defines.php 2005-09-13 09:04:42.000000000 +0200 +++ ./includes/Defines.php 2006-04-21 16:44:46.000000000 +0200 @@ -76,7 +76,7 @@ * @todo Is this necessary? */ $wgAvailableRights = array('read', 'edit', 'move', 'delete', 'undelete', -'protect', 'block', 'userrights', 'createaccount', 'upload', +'protect', 'restrict', 'block', 'userrights', 'createaccount', 'upload', 'rollback', 'patrol', 'editinterface', 'siteadmin', 'bot', 'validate', 'import', 'importupload', 'renameuser' ); diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/LogPage.php ./includes/LogPage.php --- ../mediawiki-1.5.8/includes/LogPage.php 2005-07-22 20:55:58.000000000 +0200 +++ ./includes/LogPage.php 2006-04-21 16:44:46.000000000 +0200 @@ -39,7 +39,7 @@ * Constructor * * @param string $type One of '', 'block', 'protect', 'rights', 'delete', - * 'upload', 'move' + * 'upload', 'move', 'restrict' */ function LogPage( $type ) { $this->type = $type; @@ -88,7 +88,7 @@ * @static */ function validTypes() { - static $types = array( '', 'block', 'protect', 'rights', 'delete', 'upload', 'move' ); + static $types = array( '', 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'restrict' ); wfRunHooks( 'LogPageValidTypes', array( &$types) ); return $types; } @@ -101,6 +101,7 @@ '' => NULL, 'block' => array( 'block', 'unblock' ), 'protect' => array( 'protect', 'unprotect' ), + 'restrict'=> array( 'restrict', 'unrestrict' ), 'rights' => array( 'rights' ), 'delete' => array( 'delete', 'restore' ), 'upload' => array( 'upload' ), @@ -124,6 +125,7 @@ '' => 'log', 'block' => 'blocklogpage', 'protect' => 'protectlogpage', + 'restrict'=> 'restrictlogpage', 'rights' => 'bureaucratlog', 'delete' => 'dellogpage', 'upload' => 'uploadlogpage', @@ -142,6 +144,7 @@ '' => 'alllogstext', 'block' => 'blocklogtext', 'protect' => 'protectlogtext', + 'restrict'=> 'restrictlogtext', 'rights' => 'rightslogtext', 'delete' => 'dellogpagetext', 'upload' => 'uploadlogpagetext', @@ -161,6 +164,8 @@ 'block/unblock' => 'unblocklogentry', 'protect/protect' => 'protectedarticle', 'protect/unprotect' => 'unprotectedarticle', + 'restrict/restrict' => 'restrictedarticle', + 'restrict/unrestrict'=> 'unrestrictedarticle', 'rights/rights' => 'bureaucratlogentry', 'rights/addgroup' => 'addgrouplogentry', 'rights/rngroup' => 'renamegrouplogentry', @@ -209,7 +214,7 @@ /** * Add a log entry - * @param string $action one of '', 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'move_redir' + * @param string $action one of '', 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'move_redir', 'restrict' * @param object &$target A title object. * @param string $comment Description associated * @param array $params Parameters passed later to wfMsg.* functions diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/OutputPage.php ./includes/OutputPage.php --- ../mediawiki-1.5.8/includes/OutputPage.php 2005-08-18 18:06:20.000000000 +0200 +++ ./includes/OutputPage.php 2006-04-21 16:44:46.000000000 +0200 @@ -147,6 +147,10 @@ return wfMsg('protect'); case 'unprotect': return wfMsg('unprotect'); + case 'restrict': + return wfMsg('restrict'); + case 'unrestrict': + return wfMsg('unrestrict'); case 'delete': return wfMsg('delete'); case 'watch': @@ -632,6 +636,21 @@ $this->returnToMain(); } + function restrictGroupRequired() { + global $wgUser, $wgTitle; + + $this->setPageTitle( wfMsg( 'restricttitle' ) ); + $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) ); + $this->setRobotpolicy( 'noindex,nofollow' ); + $this->setArticleRelated( false ); + $this->mBodytext = ''; + + $sk = $wgUser->getSkin(); + $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' ); + $this->addHTML( wfMsg( 'restricttext', $ap ) ); + $this->returnToMain( false ); + } + function loginToUse() { global $wgUser, $wgTitle, $wgContLang; diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/Parser.php ./includes/Parser.php --- ../mediawiki-1.5.8/includes/Parser.php 2006-03-26 21:38:24.000000000 +0200 +++ ./includes/Parser.php 2006-04-21 16:44:46.000000000 +0200 @@ -2249,7 +2249,15 @@ } } else { $article = new Article( $title ); - $articleContent = $article->getContentWithoutUsingSoManyDamnGlobals(); + + /** + * remplace with an empty string if the template is a restricted page + * (restriction-patch) + */ + if (!$title->userCanRead()) + $articleContent = ""; + else + $articleContent = $article->getContentWithoutUsingSoManyDamnGlobals(); if ( $articleContent !== false ) { $found = true; $text = $articleContent; diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/QueryPage.php ./includes/QueryPage.php --- ../mediawiki-1.5.8/includes/QueryPage.php 2005-08-15 05:03:19.000000000 +0200 +++ ./includes/QueryPage.php 2006-04-21 16:44:46.000000000 +0200 @@ -325,11 +325,16 @@ * feedItemDesc() */ function feedResult( $row ) { + global $wgEnableRestrict, $wgUser; + if( !isset( $row->title ) ) { return NULL; } $title = Title::MakeTitle( IntVal( $row->namespace ), $row->title ); if( $title ) { + if ( $wgEnableRestrict == true && $title->isRestricted() && ! $wgUser->isAllowed('viewrestrict')) + return NULL; + if( isset( $row->timestamp ) ) { $date = $row->timestamp; } else { diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SearchMySQL.php ./includes/SearchMySQL.php --- ../mediawiki-1.5.8/includes/SearchMySQL.php 2005-08-10 23:13:49.000000000 +0200 +++ ./includes/SearchMySQL.php 2006-04-21 16:44:46.000000000 +0200 @@ -100,6 +100,22 @@ } /** + * Return a partial WHERE clause to limit the search to + * the unrestricted pages if user not in 'restrict' group + * (restrict-patch by Jerome Combaz) + * @return string + * @access private + */ + function queryRestricted() { + global $wgUser, $wgEnableRestrict; + + if ( $wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) + return 'AND page_restrictions NOT LIKE "%view=1%"'; + else + return ''; + } + + /** * Construct the full SQL query to do the search. * The guts shoulds be constructed in queryMain() * @param string $filteredTerm @@ -110,6 +126,7 @@ return $this->queryMain( $filteredTerm, $fulltext ) . ' ' . $this->queryRedirect() . ' ' . $this->queryNamespaces() . ' ' . + $this->queryRestricted() . ' ' . $this->queryRanking( $filteredTerm, $fulltext ) . ' ' . $this->queryLimit(); } diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/Skin.php ./includes/Skin.php --- ../mediawiki-1.5.8/includes/Skin.php 2005-08-25 02:45:45.000000000 +0200 +++ ./includes/Skin.php 2006-04-21 16:44:46.000000000 +0200 @@ -740,7 +740,7 @@ } function bottomLinks() { - global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks; + global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks, $wgEnableRestrict; $sep = " |\n"; $s = ''; @@ -775,6 +775,8 @@ $s .= "\n
"; if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); } if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); } + if( $wgEnableRestrict == true + && $wgUser->isAllowed('viewrestrict')) { $s .= $sep . $this->restrictThisPage(); } if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); } } $s .= "
\n" . $this->otherLanguages(); @@ -1043,6 +1045,31 @@ return $s; } + /** + * (restrict-patch by Jerome Combaz) + * @access private + */ + function restrictThisPage() { + global $wgUser, $wgOut, $wgTitle, $wgRequest; + + $diff = $wgRequest->getVal( 'diff' ); + if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('restrict') ) { + $n = $wgTitle->getPrefixedText(); + + if ( $wgTitle->isRestricted() ) { + $t = wfMsg( 'unrestrictthispage' ); + $q = 'action=unrestrict'; + } else { + $t = wfMsg( 'restrictthispage' ); + $q = 'action=restrict'; + } + $s = $this->makeKnownLink( $n, $t, $q ); + } else { + $s = ''; + } + return $s; + } + function watchThisPage() { global $wgUser, $wgOut, $wgTitle; diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SkinTemplate.php ./includes/SkinTemplate.php --- ../mediawiki-1.5.8/includes/SkinTemplate.php 2006-02-14 23:39:39.000000000 +0100 +++ ./includes/SkinTemplate.php 2006-04-21 16:44:46.000000000 +0200 @@ -547,7 +547,7 @@ * @access private */ function buildContentActionUrls () { - global $wgContLang, $wgUseValidation, $wgDBprefix, $wgValidationForAnons; + global $wgContLang, $wgUseValidation, $wgDBprefix, $wgValidationForAnons, $wgEnableRestrict; $fname = 'SkinTemplate::buildContentActionUrls'; wfProfileIn( $fname ); @@ -627,6 +627,42 @@ ); } } + if($wgEnableRestrict == true){ + if($wgUser->isAllowed('restrict')){ + if(!$this->mTitle->isRestricted()){ + $content_actions['restrict'] = array( + 'class' => ($action == 'restrict') ? 'selected' : false, + 'text' => wfMsg('restrict'), + 'href' => $this->mTitle->getLocalUrl( 'action=restrict' ) + ); + + } else { + if ($this->mTitle->isRegexRestricted()){ + $content_actions['unrestrict'] = array( + 'class' => ($action == 'unrestrict') ? 'selected' : false, + 'text' => wfMsg('restricttitle'), + 'href' => $this->mTitle->getLocalUrl( '' ) + ); + } else { + $content_actions['unrestrict'] = array( + 'class' => ($action == 'unrestrict') ? 'selected' : false, + 'text' => wfMsg('unrestrict'), + 'href' => $this->mTitle->getLocalUrl( 'action=unrestrict' ) + ); + } + } + } else { + if($wgUser->isAllowed('viewrestrict')){ + if($this->mTitle->isRestricted()){ + $content_actions['unrestrict'] = array( + 'class' => ($action == 'unrestrict') ? 'selected' : false, + 'text' => wfMsg('restricttitle'), + 'href' => $this->mTitle->getLocalUrl( '' ) + ); + } + } + } + } if($wgUser->isAllowed('delete')){ $content_actions['delete'] = array( 'class' => ($action == 'delete') ? 'selected' : false, diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialAllpages.php ./includes/SpecialAllpages.php --- ../mediawiki-1.5.8/includes/SpecialAllpages.php 2005-08-02 13:08:19.000000000 +0200 +++ ./includes/SpecialAllpages.php 2006-04-21 16:44:46.000000000 +0200 @@ -75,7 +75,7 @@ * @param integer $namespace (default NS_MAIN) */ function indexShowToplevel ( $namespace = NS_MAIN, $including = false ) { - global $wgOut, $indexMaxperpage, $toplevelMaxperpage, $wgContLang, $wgRequest, $wgUser; + global $wgOut, $indexMaxperpage, $toplevelMaxperpage, $wgContLang, $wgRequest, $wgUser, $wgEnableRestrict; $sk = $wgUser->getSkin(); $fname = "indexShowToplevel"; @@ -85,6 +85,11 @@ $dbr =& wfGetDB( DB_SLAVE ); $page = $dbr->tableName( 'page' ); $fromwhere = "FROM $page WHERE page_namespace=$namespace"; + + if ( $wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) { + $fromwhere .= " AND page_restrictions NOT LIKE '%view=1%'"; + } + $order_arr = array ( 'ORDER BY' => 'page_title' ); $order_str = 'ORDER BY page_title'; $out = ""; @@ -201,7 +206,7 @@ * @param string $from list all pages from this name (default FALSE) */ function indexShowChunk( $namespace = NS_MAIN, $from, $including = false ) { - global $wgOut, $wgUser, $indexMaxperpage, $wgContLang; + global $wgOut, $wgUser, $indexMaxperpage, $wgContLang, $wgEnableRestrict; $fname = 'indexShowChunk'; @@ -215,7 +220,8 @@ array( 'page_namespace', 'page_title', 'page_is_redirect' ), array( 'page_namespace' => $namespace, - 'page_title >= ' . $dbr->addQuotes( $fromKey ) + 'page_title >= ' . $dbr->addQuotes( $fromKey ), + ( $wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? 'page_restrictions NOT LIKE "%view=1%"' : '1', ), $fname, array( diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialAncientpages.php ./includes/SpecialAncientpages.php --- ../mediawiki-1.5.8/includes/SpecialAncientpages.php 2005-06-28 07:47:36.000000000 +0200 +++ ./includes/SpecialAncientpages.php 2006-04-21 16:44:46.000000000 +0200 @@ -28,6 +28,8 @@ function isSyndicated() { return false; } function getSQL() { + global $wgEnableRestrict, $wgUser; + $db =& wfGetDB( DB_SLAVE ); $page = $db->tableName( 'page' ); $revision = $db->tableName( 'revision' ); @@ -39,7 +41,8 @@ UNIX_TIMESTAMP(rev_timestamp) as value FROM $page, $revision WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0 - AND page_latest=rev_id"; + AND page_latest=rev_id" . + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND page_restrictions NOT LIKE '%view=1%'" : ""); } function sortDescending() { diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialBrokenRedirects.php ./includes/SpecialBrokenRedirects.php --- ../mediawiki-1.5.8/includes/SpecialBrokenRedirects.php 2005-10-26 23:32:11.000000000 +0200 +++ ./includes/SpecialBrokenRedirects.php 2006-04-21 16:44:46.000000000 +0200 @@ -30,6 +30,8 @@ } function getSQL() { + global $wgEnableRestrict, $wgUser; + $dbr =& wfGetDB( DB_SLAVE ); extract( $dbr->tableNames( 'page', 'pagelinks' ) ); @@ -43,7 +45,8 @@ ON pl_namespace=p2.page_namespace AND pl_title=p2.page_title WHERE p1.page_is_redirect=1 AND pl_from=p1.page_id - AND p2.page_namespace IS NULL"; + AND p2.page_namespace IS NULL". + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND p2.page_restrictions NOT LIKE '%view=1%'" : ""); return $sql; } diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialCategories.php ./includes/SpecialCategories.php --- ../mediawiki-1.5.8/includes/SpecialCategories.php 2004-11-13 21:40:28.000000000 +0100 +++ ./includes/SpecialCategories.php 2006-04-21 16:44:46.000000000 +0200 @@ -31,6 +31,8 @@ return '

'.wfMsg('categoriespagetext')."


\n"; } function getSQL() { + global $wgUser, $wgEnableRestrict; + $NScat = NS_CATEGORY; $dbr =& wfGetDB( DB_SLAVE ); $categorylinks = $dbr->tableName( 'categorylinks' ); @@ -38,7 +40,8 @@ {$NScat} as namespace, cl_to as title, 1 as value - FROM $categorylinks"; + FROM $categorylinks". + (( $wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? ", ".($page = $dbr->tableName( 'page' ))." WHERE cl_to = {$page}.page_title AND {$page}.page_restrictions NOT LIKE '%view=1%'" : ''); } function sortDescending() { diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialContributions.php ./includes/SpecialContributions.php --- ../mediawiki-1.5.8/includes/SpecialContributions.php 2005-11-27 15:57:04.000000000 +0100 +++ ./includes/SpecialContributions.php 2006-04-21 16:44:46.000000000 +0200 @@ -113,6 +113,8 @@ } /* private */ function make_sql() { + global $wgUser, $wgEnableRestrict; + $userCond = $condition = $index = $offsetQuery = $limitQuery = ""; extract($this->dbr->tableNames('page', 'revision')); @@ -129,7 +131,8 @@ rev_id,rev_timestamp,rev_comment,rev_minor_edit,rev_user_text, rev_deleted FROM $page,$revision $use_index - WHERE page_id=rev_page AND $userCond $nscond $offsetQuery + WHERE page_id=rev_page AND $userCond $nscond $offsetQuery". + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND page_restrictions NOT LIKE '%view=1%' " : " ")." ORDER BY rev_timestamp DESC $limitQuery"; return $sql; } diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialDeadendpages.php ./includes/SpecialDeadendpages.php --- ../mediawiki-1.5.8/includes/SpecialDeadendpages.php 2005-05-26 12:23:35.000000000 +0200 +++ ./includes/SpecialDeadendpages.php 2006-04-21 16:44:46.000000000 +0200 @@ -43,13 +43,16 @@ * @return string an sqlquery */ function getSQL() { + global $wgEnableRestrict, $wgUser; + $dbr =& wfGetDB( DB_SLAVE ); extract( $dbr->tableNames( 'page', 'pagelinks' ) ); return "SELECT 'Deadendpages' as type, page_namespace AS namespace, page_title as title, page_title AS value " . "FROM $page LEFT JOIN $pagelinks ON page_id = pl_from " . "WHERE pl_from IS NULL " . "AND page_namespace = 0 " . - "AND page_is_redirect = 0"; + "AND page_is_redirect = 0" . + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND page_restrictions NOT LIKE '%view=1%'" : ""); } } diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialDisambiguations.php ./includes/SpecialDisambiguations.php --- ../mediawiki-1.5.8/includes/SpecialDisambiguations.php 2005-07-11 22:47:34.000000000 +0200 +++ ./includes/SpecialDisambiguations.php 2006-04-21 16:44:46.000000000 +0200 @@ -33,6 +33,8 @@ } function getSQL() { + global $wgEnableRestrict, $wgUser; + $dbr =& wfGetDB( DB_SLAVE ); extract( $dbr->tableNames( 'page', 'pagelinks' ) ); @@ -47,7 +49,8 @@ ." WHERE lb.pl_namespace = $dns AND lb.pl_title = $dtitle" # disambiguation template ." AND pa.page_id = lb.pl_from" ." AND pa.page_namespace = la.pl_namespace" - ." AND pa.page_title = la.pl_title"; + ." AND pa.page_title = la.pl_title" + .(($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND page_restrictions NOT LIKE '%view=1%'" : ""); return $sql; } diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialDoubleRedirects.php ./includes/SpecialDoubleRedirects.php --- ../mediawiki-1.5.8/includes/SpecialDoubleRedirects.php 2005-05-26 12:23:35.000000000 +0200 +++ ./includes/SpecialDoubleRedirects.php 2006-04-21 16:44:46.000000000 +0200 @@ -30,6 +30,8 @@ } function getSQL() { + global $wgEnableRestrict, $wgUser; + $dbr =& wfGetDB( DB_SLAVE ); extract( $dbr->tableNames( 'page', 'pagelinks' ) ); @@ -44,7 +46,8 @@ " AND la.pl_title=pb.page_title" . " AND lb.pl_from=pb.page_id" . " AND lb.pl_namespace=pc.page_namespace" . - " AND lb.pl_title=pc.page_title"; + " AND lb.pl_title=pc.page_title" . + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND page_restrictions NOT LIKE '%view=1%'" : ""); return $sql; } diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialExport.php ./includes/SpecialExport.php --- ../mediawiki-1.5.8/includes/SpecialExport.php 2006-01-27 23:11:45.000000000 +0100 +++ ./includes/SpecialExport.php 2006-04-21 16:44:46.000000000 +0200 @@ -252,6 +252,8 @@ // -------------------- private implementation below -------------------- function dumpFrom( $cond = '' ) { + global $wgEnableRestrict, $wgUser; + $fname = 'WikiExporter::dumpFrom'; wfProfileIn( $fname ); @@ -285,7 +287,8 @@ $page $pageindex, $revision $revindex, $text - WHERE $where $join AND rev_text_id=old_id + WHERE $where $join AND rev_text_id=old_id". + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND page_restrictions NOT LIKE '%view=1%'" : "")." ORDER BY page_id", $fname ); $wrapper = $this->db->resultObject( $result ); $this->outputStream( $wrapper ); diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialLog.php ./includes/SpecialLog.php --- ../mediawiki-1.5.8/includes/SpecialLog.php 2005-06-27 11:14:32.000000000 +0200 +++ ./includes/SpecialLog.php 2006-04-21 16:44:47.000000000 +0200 @@ -59,10 +59,16 @@ * @private */ function setupQuery( $request ) { + global $wgUser, $wgEnableRestrict, $wgHideRestrictLog; + $page = $this->db->tableName( 'page' ); $user = $this->db->tableName( 'user' ); $this->joinClauses = array( "LEFT OUTER JOIN $page ON log_namespace=page_namespace AND log_title=page_title" ); $this->whereClauses = array( 'user_id=log_user' ); + + if ( ($wgEnableRestrict and $wgHideRestrictLog == true and !($wgUser->isAllowed('restrict') || $wgUser->isAllowed('viewrestrict'))) + or ! $wgEnableRestrict ) + $this->whereClauses[] = 'log_type != "restrict"'; $this->limitType( $request->getVal( 'type' ) ); $this->limitUser( $request->getText( 'user' ) ); diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialLonelypages.php ./includes/SpecialLonelypages.php --- ../mediawiki-1.5.8/includes/SpecialLonelypages.php 2005-05-26 12:23:35.000000000 +0200 +++ ./includes/SpecialLonelypages.php 2006-04-21 16:44:47.000000000 +0200 @@ -31,6 +31,8 @@ function isSyndicated() { return false; } function getSQL() { + global $wgEnableRestrict, $wgUser; + $dbr =& wfGetDB( DB_SLAVE ); extract( $dbr->tableNames( 'page', 'pagelinks' ) ); @@ -44,7 +46,8 @@ ON page_namespace=pl_namespace AND page_title=pl_title WHERE pl_namespace IS NULL AND page_namespace=".NS_MAIN." - AND page_is_redirect=0"; + AND page_is_redirect=0" . + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND page_restrictions NOT LIKE '%view=1%'" : ""); } } diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialMostlinked.php ./includes/SpecialMostlinked.php --- ../mediawiki-1.5.8/includes/SpecialMostlinked.php 2005-08-15 05:03:19.000000000 +0200 +++ ./includes/SpecialMostlinked.php 2006-04-21 16:44:47.000000000 +0200 @@ -24,6 +24,8 @@ function isSyndicated() { return false; } function getSQL() { + global $wgEnableRestrict, $wgUser; + $dbr =& wfGetDB( DB_SLAVE ); extract( $dbr->tableNames( 'pagelinks', 'page' ) ); return @@ -33,7 +35,8 @@ COUNT(*) AS value, page_namespace FROM $pagelinks - LEFT JOIN $page ON pl_namespace=page_namespace AND pl_title=page_title + LEFT JOIN $page ON pl_namespace=page_namespace AND pl_title=page_title". + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " WHERE page_restrictions NOT LIKE '%view=1%'" : "")." GROUP BY pl_namespace,pl_title HAVING COUNT(*) > 1"; } diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialMovepage.php ./includes/SpecialMovepage.php --- ../mediawiki-1.5.8/includes/SpecialMovepage.php 2005-10-22 18:15:17.000000000 +0200 +++ ./includes/SpecialMovepage.php 2006-04-21 16:44:47.000000000 +0200 @@ -59,7 +59,7 @@ } function showForm( $err ) { - global $wgOut, $wgUser, $wgLang; + global $wgOut, $wgUser, $wgLang, $wgEnableRestrict; $wgOut->setPagetitle( wfMsg( 'movepage' ) ); @@ -68,6 +68,10 @@ $wgOut->errorpage( 'notargettitle', 'notargettext' ); return; } + if( $wgEnableRestrict == true and $ot->isRestricted() and ! $wgUser->isAllowed('restrict') ) { + $wgOut->errorpage( 'restricttitle', 'notallowedtomoverestrictedpagetext' ); + return; + } $oldTitle = $ot->getPrefixedText(); $encOldTitle = htmlspecialchars( $oldTitle ); diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialNewpages.php ./includes/SpecialNewpages.php --- ../mediawiki-1.5.8/includes/SpecialNewpages.php 2005-09-16 07:16:30.000000000 +0200 +++ ./includes/SpecialNewpages.php 2006-04-21 16:44:47.000000000 +0200 @@ -28,7 +28,7 @@ } function getSQL() { - global $wgUser, $wgOnlySysopsCanPatrol, $wgUseRCPatrol; + global $wgUser, $wgOnlySysopsCanPatrol, $wgUseRCPatrol, $wgEnableRestrict; $usepatrol = ( $wgUseRCPatrol && $wgUser->isLoggedIn() && ( $wgUser->isAllowed('patrol') || !$wgOnlySysopsCanPatrol ) ) ? 1 : 0; $dbr =& wfGetDB( DB_SLAVE ); @@ -51,7 +51,8 @@ page_latest as rev_id FROM $recentchanges,$page WHERE rc_cur_id=page_id AND rc_new=1 - AND rc_namespace=".NS_MAIN." AND page_is_redirect=0"; + AND rc_namespace=".NS_MAIN." AND page_is_redirect=0". + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND page_restrictions NOT LIKE '%view=1%'" : ""); } function formatResult( $skin, $result ) { diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialPage.php ./includes/SpecialPage.php --- ../mediawiki-1.5.8/includes/SpecialPage.php 2005-08-15 05:04:06.000000000 +0200 +++ ./includes/SpecialPage.php 2006-04-21 16:44:47.000000000 +0200 @@ -86,6 +86,10 @@ $wgSpecialPages['Confirmemail'] = new UnlistedSpecialPage( 'Confirmemail' ); } +if( $wgEnableRestrict ) { + $wgSpecialPages['Restrictedpages'] = new SpecialPage( 'Restrictedpages', 'restrict' ); +} + /** * Parent special page class, also static functions for handling the special * page list diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialPopularpages.php ./includes/SpecialPopularpages.php --- ../mediawiki-1.5.8/includes/SpecialPopularpages.php 2005-06-05 09:55:54.000000000 +0200 +++ ./includes/SpecialPopularpages.php 2006-04-21 16:44:47.000000000 +0200 @@ -28,6 +28,8 @@ function isSyndicated() { return false; } function getSQL() { + global $wgEnableRestrict, $wgUser; + $dbr =& wfGetDB( DB_SLAVE ); $page = $dbr->tableName( 'page' ); @@ -37,7 +39,8 @@ page_title as title, page_counter as value FROM $page - WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0"; + WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0" . + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND page_restrictions NOT LIKE '%view=1%'" : ""); } function formatResult( $skin, $result ) { diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialRandompage.php ./includes/SpecialRandompage.php --- ../mediawiki-1.5.8/includes/SpecialRandompage.php 2005-08-02 02:01:45.000000000 +0200 +++ ./includes/SpecialRandompage.php 2006-04-21 16:44:47.000000000 +0200 @@ -11,7 +11,7 @@ * used as e.g. Special:Randompage/Category */ function wfSpecialRandompage( $par = NS_MAIN ) { - global $wgOut, $wgTitle, $wgArticle, $wgExtraRandompageSQL, $wgContLang; + global $wgOut, $wgTitle, $wgArticle, $wgExtraRandompageSQL, $wgContLang, $wgEnableRestrict, $wgUser; $fname = 'wfSpecialRandompage'; # Determine the namespace to get a random page from. @@ -40,7 +40,8 @@ $sql = "SELECT page_id,page_title FROM $page $use_index WHERE page_namespace=$namespace AND page_is_redirect=0 $extra - AND page_random>$randstr + AND page_random>$randstr" . + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND page_restrictions NOT LIKE '%view=1%'" : "") . " ORDER BY page_random LIMIT 1"; $res = $db->query( $sql, $fname ); diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialRecentchangeslinked.php ./includes/SpecialRecentchangeslinked.php --- ../mediawiki-1.5.8/includes/SpecialRecentchangeslinked.php 2005-08-25 06:32:20.000000000 +0200 +++ ./includes/SpecialRecentchangeslinked.php 2006-04-21 16:44:47.000000000 +0200 @@ -15,7 +15,7 @@ * @param string $par parent page we will look at */ function wfSpecialRecentchangeslinked( $par = NULL ) { - global $wgUser, $wgOut, $wgLang, $wgContLang, $wgTitle, $wgRequest; + global $wgUser, $wgOut, $wgLang, $wgContLang, $wgTitle, $wgRequest, $wgEnableRestrict; $fname = 'wfSpecialRecentchangeslinked'; $days = $wgRequest->getInt( 'days' ); @@ -93,7 +93,8 @@ AND rev_page=page_id AND pl_namespace=page_namespace AND pl_title=page_title - AND pl_from=$id + AND pl_from=$id". + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND page_restrictions NOT LIKE '%view=1%'" : "")." GROUP BY page_id,page_namespace,page_title, rev_user,rev_comment,rev_user_text,rev_timestamp,rev_minor_edit, page_is_new diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialRestrictedpages.php ./includes/SpecialRestrictedpages.php --- ../mediawiki-1.5.8/includes/SpecialRestrictedpages.php 1970-01-01 01:00:00.000000000 +0100 +++ ./includes/SpecialRestrictedpages.php 2006-04-21 16:44:47.000000000 +0200 @@ -0,0 +1,80 @@ +'.wfMsg('restrictedpagespagetext'); + if (! empty($wgRegexRestrict) ) { + $string .= "

\n

".wfMsg('regexrestrictedpagespagetext'); + foreach( $wgRegexRestrict as $k => $v ) $string .= "{$v}, "; + $string = substr( $string, 0, -2); + } + + $string .= "

\n
"; + + return $string; + } + + function getSQL() { + global $wgEnableRestrict, $wgUser; + + $db =& wfGetDB( DB_SLAVE ); + $page = $db->tableName( 'page' ); + return + "SELECT 'Restrictedpages' as type, + page_namespace as namespace, + page_title as title, + page_title as value + FROM $page + WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0 AND page_restrictions LIKE '%view=1%'"; + } + + function sortDescending() { + return false; + } + + function formatResult( $skin, $result ) { + global $wgLang, $wgContLang; + + $d = $wgLang->timeanddate( wfTimestamp( TS_MW, $result->value ), true ); + $link = $skin->makeKnownLink( $result->title, $wgContLang->convert( $result->title) ); + return "{$link} ({$d})"; + } +} + +function wfSpecialRestrictedpages() { + list( $limit, $offset ) = wfCheckLimits(); + + $app = new RestrictedPagesPage(); + + $app->doQuery( $offset, $limit ); +} + +?> diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialShortpages.php ./includes/SpecialShortpages.php --- ../mediawiki-1.5.8/includes/SpecialShortpages.php 2005-03-12 12:51:01.000000000 +0100 +++ ./includes/SpecialShortpages.php 2006-04-21 16:44:47.000000000 +0200 @@ -34,6 +34,8 @@ } function getSQL() { + global $wgEnableRestrict, $wgUser; + $dbr =& wfGetDB( DB_SLAVE ); $page = $dbr->tableName( 'page' ); $name = $dbr->addQuotes( $this->getName() ); @@ -44,7 +46,8 @@ page_title as title, page_len AS value FROM $page - WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0"; + WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0" . + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND page_restrictions NOT LIKE '%view=1%'" : ""); } function sortDescending() { diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialUncategorizedpages.php ./includes/SpecialUncategorizedpages.php --- ../mediawiki-1.5.8/includes/SpecialUncategorizedpages.php 2005-07-20 01:43:35.000000000 +0200 +++ ./includes/SpecialUncategorizedpages.php 2006-04-21 16:44:47.000000000 +0200 @@ -32,13 +32,16 @@ function isSyndicated() { return false; } function getSQL() { + global $wgEnableRestrict, $wgUser; + $dbr =& wfGetDB( DB_SLAVE ); extract( $dbr->tableNames( 'page', 'categorylinks' ) ); $name = $dbr->addQuotes( $this->getName() ); return "SELECT $name as type, page_namespace AS namespace, page_title AS title, page_title AS value " . "FROM $page LEFT JOIN $categorylinks ON page_id=cl_from ". - "WHERE cl_from IS NULL AND page_namespace=$this->requestedNamespace AND page_is_redirect=0"; + "WHERE cl_from IS NULL AND page_namespace=$this->requestedNamespace AND page_is_redirect=0". + (($wgEnableRestrict == true and ! $wgUser->isAllowed('viewrestrict') ) ? " AND page_restrictions NOT LIKE '%view=1%'" : ""); } } diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/SpecialWhatlinkshere.php ./includes/SpecialWhatlinkshere.php --- ../mediawiki-1.5.8/includes/SpecialWhatlinkshere.php 2005-12-11 19:50:16.000000000 +0100 +++ ./includes/SpecialWhatlinkshere.php 2006-04-21 16:44:47.000000000 +0200 @@ -10,7 +10,7 @@ * @param string $par An article name ?? */ function wfSpecialWhatlinkshere($par = NULL) { - global $wgUser, $wgOut, $wgRequest; + global $wgUser, $wgOut, $wgRequest, $wgEnableRestrict; $fname = 'wfSpecialWhatlinkshere'; $target = isset($par) ? $par : $wgRequest->getVal( 'target' ); @@ -26,6 +26,10 @@ $wgOut->errorpage( 'notargettitle', 'notargettext' ); return; } + if( $wgEnableRestrict == true and $nt->isRestricted() and ! $wgUser->isAllowed('viewrestrict') ) { + $wgOut->errorpage( 'restricttitle', 'restricttext' ); + return; + } $wgOut->setPagetitle( $nt->getPrefixedText() ); $wgOut->setSubtitle( wfMsg( 'linklistsub' ) ); diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/includes/Title.php ./includes/Title.php --- ../mediawiki-1.5.8/includes/Title.php 2005-10-30 02:30:44.000000000 +0100 +++ ./includes/Title.php 2006-04-21 16:44:47.000000000 +0200 @@ -877,6 +877,36 @@ } /** + * Does the title correspond to a restricted article? + * (restrict-patch by Jerome Combaz) + * @return boolean + * @access public + */ + function isRestricted() { + global $wgEnableRestrict; + + if ( $wgEnableRestrict == true ) { + $a = $this->getRestrictions("view"); + if ( $this->isRegexRestricted() || (!empty($a) && $a[0] == true) ) return true; + } + + return false; + } + + function isRegexRestricted() { + global $wgEnableRestrict, $wgRegexRestrict; + + if ( $wgEnableRestrict == true ) { + foreach ( $wgRegexRestrict as $k=>$v ) { + if ( ereg ( $v, $this->mTextform ) ) return true; + } + } + + return false; + } + + + /** * Is $wgUser is watching this page? * @return boolean * @access public @@ -996,7 +1026,22 @@ * @access public */ function userCanRead() { - global $wgUser; + global $wgUser, $wgUserPageRestrict; + + // restricted page ? + if ( $this->isRestricted() && ! $wgUser->isAllowed('viewrestrict') ) { + return false; + } + + // restricted user pages ? + if ( $wgUserPageRestrict == true ) { + if ( $this->getNamespace() == NS_USER + && $wgUser->getName() != $this->getText() ) { + if ( ! $wgUser->isAllowed('viewrestrict') ) { + return false; + } + }; + } if( $wgUser->isAllowed('read') ) { return true; diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/index.php ./index.php --- ../mediawiki-1.5.8/index.php 2005-11-16 22:29:24.000000000 +0100 +++ ./index.php 2006-04-21 16:44:47.000000000 +0200 @@ -103,7 +103,11 @@ # the Read array in order for the user to see it. (We have to check here to # catch special pages etc. We check again in Article::view()) if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) { - $wgOut->loginToUse(); + if ( $wgTitle->isRestricted() ) { + $wgOut->restrictGroupRequired(); + } else { + $wgOut->loginToUse(); + } $wgOut->output(); exit; } @@ -171,6 +175,8 @@ case 'rollback': case 'protect': case 'unprotect': + case 'restrict': + case 'unrestrict': case 'info': case 'markpatrolled': case 'validate': diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/languages/LanguageCa.php ./languages/LanguageCa.php --- ../mediawiki-1.5.8/languages/LanguageCa.php 2005-08-18 18:01:12.000000000 +0200 +++ ./languages/LanguageCa.php 2006-04-21 16:44:47.000000000 +0200 @@ -798,6 +798,36 @@ 'mw_math_html' => "HTML si és possible, si no PNG", 'mw_math_source' => "Deixa com a TeX (per a navegadors de text)", +# Traducció del pedaç de les restriccions +# http://meta.wikimedia.org/wiki/Page_access_restriction_with_MediaWiki +# http://conseil-recherche-innovation.net/index.php/1974/04/11/41-restrict-pages-under-mediawiki-15 +# Pau 05-02-06 + +'restrict' => 'Restringeix', +'restrictthispage' => 'Restringeix aquesta pàgina', +'unrestrict' => 'Desrentringeix', +'unrestrictthispage' => 'Permet el lliure accés aquesta pàgina', +'restricttitle' => 'Pàgina restringida', +'restricttext' => 'Aquesta pàgina és restringida. Per veure-la, heu d\'esser membres del grup \'restrict\' o del grup \'viewrestrict\'.', +'restrictedpages' => 'Pàgines restringides', +'restrictlogpage' => 'Log_restriccions', +'restrictlogtext' => 'A continuació, teniu una llista de restriccions de pàgina. Vegeu [[{{ns:4}}:Restricted page]] per més informació.', +'restrictedarticle' => '[[$1]] restringida', +'unrestrictedarticle' => '[[$1]] desrentringida', +'restrictsub' => '(Restringeix \'[[$1]]\')', +'confirmrestrict' => 'Confirma la restricció', +'confirmrestricttext' => 'Segur que voleu restringir aquesta pàgina?', +'restrictcomment' => 'Raó per la restricció', +'unrestrictsub' => '(Desrestringeix \'[[$1]]\')', +'confirmunrestricttext' => 'Segur que voleu desrestringir aquesta pàgina?', +'confirmunrestrict' => 'Confirmeu la desrestricció', +'unrestrictcomment' => 'Raó per la desrestricció', +'restrictreason' => '(doneu una raó)', +'tooltip-restrict' => 'Restringeix aquesta pàgina', +'notallowedtomoverestrictedpagetext' => 'Per moure aquesta pàgina, heu de ser membre del grup \'restrict\'.', +'restrictedpagespagetext' => 'Aquesta pàgina llista totes les pàgines restringides del wiki. ', +'regexrestrictedpagespagetext' => 'Totes les pàgines amb títols que compleixin aquesta/aquestes expressió(ns) regulars també seran restringides: ', + ); /** This is an UTF8 language */ diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/languages/LanguageDe.php ./languages/LanguageDe.php --- ../mediawiki-1.5.8/languages/LanguageDe.php 2005-10-11 23:25:21.000000000 +0200 +++ ./languages/LanguageDe.php 2006-04-21 16:44:47.000000000 +0200 @@ -1255,7 +1255,31 @@ Wenn Sie *nicht* $2 sind, folgen Sie dem Link bitte nicht. Der Bestätigungskode läuft am $4 ab. -" +", + +#Restrict patch (http://meta.wikimedia.org/wiki/Page_access_restriction_with_MediaWiki) +'restrict' => 'Sperren', +'restrictthispage' => 'Diese Seite sperren', +'unrestrict' => 'Sperrung aufheben', +'unrestrictthispage' => 'Sperrung der Seite aufheben', +'restricttitle' => 'Gesperrte Seite', +'restricttext' => 'Diese Seite ist gesperrt. Um sie zu betrachten, musst du ein Mitglied der Gruppe \'restrict\' oder \'viewrestrict\' sein.', +'restrictedpages' => 'Gesperrte Seiten', +'restrictlogpage' => 'Log der Sperrungen', +'restrictlogtext' => 'Unten folgt eine Liste mit gesperrten Seiten. Vgl. [[{{ns:4}}:Gesperrte Seiten]] für mehr Information.', +'restrictedarticle' => 'Gesperrt: [[$1]]', +'unrestrictedarticle' => 'Ungesperrt: [[$1]]', +'restrictsub' => '(Gesperrt: \'[[$1]]\')', +'confirmrestrict' => 'Sperrung bestätigen', +'confirmrestricttext' => 'Willst du die Seite wirklich sperren?', +'restrictcomment' => 'Grund für die Sperrung', +'unrestrictsub' => '(Entsperren \'[[$1]]\')', +'confirmunrestricttext' => 'Willst du die Seite wirklich entsperren?', +'confirmunrestrict' => 'Entsperrung bestätigen', +'unrestrictcomment' => 'Grund für Entsperrung', +'restrictreason' => '(einen Grund angeben)', +'tooltip-restrict' => 'Diese Seite sperren', +'notallowedtomoverestrictedpagetext' => 'Um diese Seite zu verschieben, musst du ein Mitglied der Gruppe \'restrict\' sein.', ); diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/languages/LanguageFr.php ./languages/LanguageFr.php --- ../mediawiki-1.5.8/languages/LanguageFr.php 2006-02-27 10:14:30.000000000 +0100 +++ ./languages/LanguageFr.php 2006-04-21 16:44:47.000000000 +0200 @@ -1171,7 +1171,29 @@ 'exif-orientation-8' => 'Tournée de 90° à gauche', 'exif-componentsconfiguration-0' => 'n\'existe pas', - +#Restrict patch (http://meta.wikimedia.org/wiki/Page_access_restriction_with_MediaWiki) +'restrict' => 'Restreindre', +'restrictthispage' => 'Restreindre cette page', +'unrestrict' => 'Autoriser', +'unrestrictthispage' => 'Autoriser cette page', +'restricttitle' => 'Page restreinte', +'restricttext' => 'L\'accès à cette page a été restreint. Pour pouvoir y accéder vous devez être membre du groupe \'restrict\' ou \'viewrestrict\'', +'restrictedpages' => 'Pages restreintes', +'restrictlogpage' => 'Log_de_restriction', +'restrictlogtext' => 'Voir les [[{{ns:4}}:Page restreinte|directives concernant les pages restreintes]].', +'restrictedarticle' => 'a restreint [[$1]]', +'unrestrictedarticle' => 'a autorisé [[$1]]', +'restrictsub' => '(Restreint \'[[$1]]\')', +'confirmrestrict' => 'Confirmer la restriction', +'confirmrestricttext' => 'Voulez vous vraiment restreindre l\'accès à cette page ?', +'restrictcomment' => 'Raison de la restriction', +'unrestrictsub' => '(Autorise \'[[$1]]\')', +'confirmunrestricttext' => 'Voulez-vous vraiment autoriser l\'accès à cette page ?', +'confirmunrestrict' => 'Confirmer l\'autorisation', +'unrestrictcomment' => 'Raison de l\'autorisation', +'restrictreason' => '(indiquez une raison)', +'tooltip-restrict' => 'Restreindre cette page', +'notallowedtomoverestrictedpagetext' => 'Pour pouvoir déplacer cette page, vous devez être membre du groupe \'restrict\'', // exifgps: ); diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/languages/LanguageNl.php ./languages/LanguageNl.php --- ../mediawiki-1.5.8/languages/LanguageNl.php 2005-08-18 18:01:17.000000000 +0200 +++ ./languages/LanguageNl.php 2006-04-21 16:44:47.000000000 +0200 @@ -751,6 +751,33 @@ 'mw_math_source' => "Laat de TeX broncode staan (voor tekstbrowsers)", 'mw_math_modern' => "Aanbevolen methode voor recente browsers", 'mw_math_mathml' => 'MathML', + +#Restrict patch (http://meta.wikimedia.org/wiki/Page_access_restriction_with_MediaWiki) +'restrict' => 'Beperk', +'restrictthispage' => 'Beperk deze pagina', +'unrestrict' => 'Onbeperk', +'unrestrictthispage' => 'Onbeperk deze pagina', +'restricttitle' => 'Beperkte pagina', +'restricttext' => 'Deze pagina is beperkt. Om deze te zien moet u lid zijn van de \'restrict\' groep of \'viewrestrict\' groep.', +'restrictedpages' => 'Beperkte paginas', +'restrictlogpage' => 'Beperkingen_log', +'restrictlogtext' => 'Hier is een lijst met pagina beperkingen. Zie [[{{ns:4}}:Restricted page]] voor meer informatie.', +'restrictedarticle' => 'beperkt [[$1]]', +'unrestrictedarticle' => 'onbeperkt [[$1]]', +'restrictsub' => '(Beperk \'[[$1]]\')', +'confirmrestrict' => 'Bevestig de beperking', +'confirmrestricttext' => 'Wilt u deze pagina echt beperken?', +'restrictcomment' => 'Reden voor de beperking', +'unrestrictsub' => '(Unrestrict \'[[$1]]\')', +'confirmunrestricttext' => 'Wilt u deze pagina echt onbeperken?', +'confirmunrestrict' => 'Bevestig de onbeperking', +'unrestrictcomment' => 'Reden voor de onbeperking', +'restrictreason' => '(geef een reden)', +'tooltip-restrict' => 'Beperk deze pagina', +'notallowedtomoverestrictedpagetext' => 'Om de locatie van deze pagina te veranderen, moet u lid zijn van de \'restrict\' groep.', +'restrictedpagespagetext' => 'Deze pagina geeft een lijst van alle beperkte paginas in deze wiki. ', +'regexrestrictedpagespagetext' => 'Alle pagina titels die aan deze uitdrukking voldoen zijn ook beperkt : ', + ); class LanguageNl extends LanguageUtf8 { diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/languages/Language.php ./languages/Language.php --- ../mediawiki-1.5.8/languages/Language.php 2006-03-25 20:57:16.000000000 +0100 +++ ./languages/Language.php 2006-04-21 16:44:47.000000000 +0200 @@ -2134,6 +2134,33 @@ 'youhavenewmessagesmulti' => "You have new messages on $1", 'newtalkseperator' => ',_', + +#Restrict patch (http://meta.wikimedia.org/wiki/Page_access_restriction_with_MediaWiki) +'restrict' => 'Restrict', +'restrictthispage' => 'Restrict this page', +'unrestrict' => 'Unrestrict', +'unrestrictthispage' => 'Unrestrict this page', +'restricttitle' => 'Restricted page', +'restricttext' => 'This page is restricted. To view it you have to be member of the \'restrict\' group or \'viewrestrict\' group.', +'restrictedpages' => 'Restricted pages', +'restrictlogpage' => 'Restriction_log', +'restrictlogtext' => 'Below is a list of page restrictions. See [[{{ns:4}}:Restricted page]] for more information.', +'restrictedarticle' => 'restricted [[$1]]', +'unrestrictedarticle' => 'unrestricted [[$1]]', +'restrictsub' => '(Restrict \'[[$1]]\')', +'confirmrestrict' => 'Confirm the restriction', +'confirmrestricttext' => 'Do you really want to restrict this page?', +'restrictcomment' => 'Reason for restricting', +'unrestrictsub' => '(Unrestrict \'[[$1]]\')', +'confirmunrestricttext' => 'Do you really want to unrestrict this page?', +'confirmunrestrict' => 'Confirm unrestriction', +'unrestrictcomment' => 'Reason for unrestricting', +'restrictreason' => '(give a reason)', +'tooltip-restrict' => 'Restrict this page', +'notallowedtomoverestrictedpagetext' => 'To move this page, you have to be member of the \'restrict\' group.', +'restrictedpagespagetext' => 'This page lists all restricted pages in the wiki. ', +'regexrestrictedpagespagetext' => 'All page titles matching this/these regular expression(s) are also restricted : ', + ); /* a fake language converter */ diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/languages/LanguageSv.php ./languages/LanguageSv.php --- ../mediawiki-1.5.8/languages/LanguageSv.php 2006-02-09 14:28:31.000000000 +0100 +++ ./languages/LanguageSv.php 2006-04-21 16:44:47.000000000 +0200 @@ -889,7 +889,33 @@ "lastmodifiedby" => "Den här sidan var senaste ändrad $1 av $2.", "and" => "och", "othercontribs" => "Baserad på arbete utfört av $1.", -"siteusers" => "{{SITENAME}} användare $1" +"siteusers" => "{{SITENAME}} användare $1", + +#Restrict patch (http://meta.wikimedia.org/wiki/Page_access_restriction_with_MediaWiki) +'restrict' => 'Begränsa åtkomst', +'restrictthispage' => "Begränsa åtkomst för denna sida", +'unrestrict' => 'Upphäv begränsning av åtkomst', +'unrestrictthispage' => 'Upphäv begränsning av åtkomst för denna sida', +'restricttitle' => 'Åtkomstbegränsad', +'restricttext' => 'Denna sida har begränsad åtkomst. För att visa sidan måste du vara medlem i \'åtkomstbegränsa\' - eller \'visaåtkomstbegränsade\' - gruppen.', +'restrictedpages' => 'Sidor med begränsad åtkomst', +'restrictlogpage' => 'Logg för åtkomstbegränsning', +'restrictlogtext' => 'Nedan finns en lista över åtkomstbegränsade sidor. Se [[{{ns:4}}:Åtkomstbegränsadesidor]] för ytterligare information.', +'restrictedarticle' => 'Begränsade åtkomst för [[$1]]', +'unrestrictedarticle' => 'Upphävde åtkomstbegränsning för [[$1]]', +'restrictsub' => '(Begränsa åtkomst för \'[[$1]]\')', +'confirmrestrict' => 'Bekräfta begränsning av åtkomst', +'confirmrestricttext' => 'Är du säker på att du vill begränsa åtkomsten för denna sida?', +'restrictcomment' => 'Orsak till begränsning av åtkomst', +'unrestrictsub' => '(Upphäv begränsning av åtkomst för \'[[$1]]\')', +'confirmunrestricttext' => 'Är du säker på att du vill upphäva åtkomstbegränsningen för denna sida?', +'confirmunrestrict' => 'Bekräfta upphävning av åtkomstbegränsning', +'unrestrictcomment' => 'Orsak till upphävning av åtkomstbegränsning', +'restrictreason' => '(ange orsak)', +'tooltip-restrict' => 'Begränsa åtkomst för denna sida', +'notallowedtomoverestrictedpagetext' => 'För att kunna flytta denna sida måste du vara medlem i \'åtkomstbegränsa\' - gruppen.', +'restrictedpagespagetext' => 'Denna sida listar alla sidor med begränsad åtkomst i hela wikin. ', +'regexrestrictedpagespagetext' => 'Alla titlar som matchar denna/dessa regular expression(s) begränsas också: ', ); diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/README.restriction-patch ./README.restriction-patch --- ../mediawiki-1.5.8/README.restriction-patch 1970-01-01 01:00:00.000000000 +0100 +++ ./README.restriction-patch 2006-04-21 16:47:26.000000000 +0200 @@ -0,0 +1,100 @@ + +Article restriction patch for MediaWiki +--------------------------------------- + +Here is a patch to enable article restriction under MediaWiki. Pages can be articles or categories. It adds a new |restrict| tab link allowing members of the group ''restrict'' to restrict pages. Users member of the group ''viewrestrict'' can read (and modify) the restricted pages. Others users cannot see, search, export, etc, the restricted pages. You can still |protect| them for editing. A restricted page is distinguished by a red background tab, and you have a special page (Special:Restrictedpages) to list the restricted pages. All restriction/unrestriction actions are loggued in the wiki log. It is also possible to restrict pages by providing a regular expression array matching titles. Optionaly the user's pages can be restricted to their owner. Currently it is localized in English, German, Dutch, Swedish and French. + +This feature is mainly useful for intranet relying on WikiMedia as a non-encyclopedic content management system, like e-learning platforms or informational systems. To respect the wiki philosophy, it is not appropriate to use it to restrict public access! + +To install restriction-patch, download MediaWiki (do a security backup if you patch your own installation). + +- Apply patch : + + mv restriction-version.mediawiki-version.patch ./mediawiki-version + cd ./mediawiki-version + patch -p0 < restriction-version.mediawiki-version.patch + +- Configure : + +Restriction is disabled by default. Add in your ''./LocalSettings.php'' file (below require_once( "includes/DefaultSettings.php" );) : + + /** + * If true, a new menu action allows to restrict pages access to 'restrict' group users. If false, all previously restricted pages are accessible again. + */ + $wgEnableRestrict = true; + + /** + * If true, new pages are restricted by default for 'restrict' group users. + */ + $wgRestrictNewPages = false; + + /** + * If true restrict user pages to their owner (as well as viewrestrict/restrict members) + */ + $wgUserPageRestrict = false; + + /** + * Regular expression array to restrict matching pages + * eg. $wgRegexRestrict = array("^Secure:", "^Secret "); // restrict all pages where title is like 'Secure:...' or 'Secret ...' + */ + $wgRegexRestrict = array(); + + /** + * If true do not add recent changes entry for restricted pages + */ + $wgNoRecentChangesRestrict = true; + + /** + * If true hide log entries related to restriction, except for 'restrict' or 'viewrestrict' users (Special:Log page) + */ + $wgHideRestrictLog = true; + + +Go to the ''User rights management'' page (in special pages) and add users in group ''restrict'' (allow to view and restrict pages) or ''viewrestrict'' (allow only to view restricted pages). If $wgUserPageRestrict is true, user pages are restricted to their respective owner, as well as members of the ''viewrestrict'' group. + +Don't write sensible information in page titles, they could be retrieved in some cases. This is beta and GPL, test and feedback welcome ! + + +Jerome Combaz (restrict-mediawiki/at/conseil-recherche-innovation.net) + + + Download patch, updates, screenshots and comments here : + http://conseil-recherche-innovation.net/index.php/1974/04/11/41-restrict-pages-under-mediawiki-15 + + +ChangeLog +--------- + +Version beta-0.62 for MW 1.5.5/1.5.6 (02-13-2006) 1.5.7 (03-05-2006) 1.5.8 (04-21-2006) +- Catalan translation (thanks to Pau Cabot) +- Small mistake (comma) in swedish translation + +Version beta-0.61 for MW 1.5.5/1.5.6 (01-18-2006) +- Swedish translation (thanks to Samuel Lampa) +- Dutch translation (thanks to Peter De Baets) + +Version beta-0.6 for MW 1.5.3 (12-15-2005) +- $wgHideRestrictLog option is back + +Version beta-0.59 for MW 1.5.1/1.5.2 (10-31-2005) +- Allow to restrict new pages by default ($wgRestrictNewPages option) +- Bug : 'ArticleProtectComplete' hook function remplaced by 'ArticleRestrictComplete' (stupid mistake !) + +Version beta-0.58 for MW 1.5.0 (10-07-2005) +- Restriction by regular expression test on title. +- Bug which avoided to view restricted pages in special pages (only 'restrict' group can see it, not possible to add 'viewrestrict' group) (thanks to Karen O'Flaherty) +- German translation updated (thanks to Hugo Wirz) +- French and english translations updated. +- Bug in Broken Redirects special page SQL request +- Categories special page hide restricted categories for non allowed users +- No more modifications in monobook stylesheet than one style added (see bottom of /skins/monobook/main.css file). + +Version beta-0.57 for MW 1.5.0 (09-18-2005) +- Stupid cosmetic bug which avoid patch working if user page restriction enabled (thanks to Christophe Berger) + +Version beta-0.56 for MW 1.5.0 (09-11-2005) +- Bug "variables can be passed by reference in [mediawiki]\includes\Article.php on line 1703" with some PHP configurations (thanks to Chunho Lee) + +Version beta-0.55 for MW 1.5.0 (09-07-2005) +- First public release for MediaWiki 1.5 + diff -x '*~' -x LocalSettings.php -x '*.orig' -x '*.patch' -x .cvsignore -Naur ../mediawiki-1.5.8/skins/monobook/main.css ./skins/monobook/main.css --- ../mediawiki-1.5.8/skins/monobook/main.css 2005-08-03 00:37:50.000000000 +0200 +++ ./skins/monobook/main.css 2006-04-21 16:44:47.000000000 +0200 @@ -1207,3 +1207,8 @@ background-color: #f0f0ff; } +/* restriction patch tab style (white link on red background) */ +li#ca-unrestrict a { + color: white !important; + background-color: #ba0000 !important; +}