diff -iEbdu -r ./includes/Article.php ./includes/Article.php --- ./includes/Article.php 2006-10-14 02:06:32.000000000 +0200 +++ ./includes/Article.php 2006-12-07 15:30:54.340034100 +0100 @@ -644,7 +644,6 @@ # If we got diff and oldid in the query, we want to see a # diff page instead of the article. - if ( !is_null( $diff ) ) { $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); diff -iEbdu -r ./includes/CategoryPage.php ./includes/CategoryPage.php --- ./includes/CategoryPage.php 2006-11-21 16:36:14.472026700 +0100 +++ ./includes/CategoryPage.php 2006-12-07 15:22:52.721070900 +0100 @@ -175,6 +175,7 @@ } function doCategoryQuery() { + global $wgUser; $dbr =& wfGetDB( DB_SLAVE ); if( $this->from != '' ) { $pageCondition = 'cl_sortkey >= ' . $dbr->addQuotes( $this->from ); @@ -210,6 +211,11 @@ $title = Title::makeTitle( $x->page_namespace, $x->page_title ); + # If this page is inside a restricted namespace, skip the result... + if(!$wgUser->canAccessNamespace($title->getNamespace())) { + continue; + } + if( $title->getNamespace() == NS_CATEGORY ) { $this->addSubcategory( $title, $x->cl_sortkey, $x->page_len ); } elseif( $title->getNamespace() == NS_IMAGE ) { diff -iEbdu -r ./includes/DefaultSettings.php ./includes/DefaultSettings.php --- ./includes/DefaultSettings.php 2006-10-14 02:06:34.000000000 +0200 +++ ./includes/DefaultSettings.php 2006-12-07 15:30:58.121429300 +0100 @@ -914,6 +914,13 @@ $wgGroupPermissions['bot' ]['autoconfirmed'] = true; // Most extra permission abilities go to this group +$wgGroupPermissions['sysop']['createpage'] = true; +$wgGroupPermissions['sysop']['createtalk'] = true; +$wgGroupPermissions['sysop']['read'] = true; +$wgGroupPermissions['sysop']['edit'] = true; +$wgGroupPermissions['sysop']['minoredit'] = true; +$wgGroupPermissions['sysop']['roread'] = true; +$wgGroupPermissions['sysop']['roedit'] = true; $wgGroupPermissions['sysop']['block'] = true; $wgGroupPermissions['sysop']['createaccount'] = true; $wgGroupPermissions['sysop']['delete'] = true; @@ -1747,6 +1754,96 @@ $wgExtraNamespaces = NULL; /** + * Hidden namespaces. If you include a namespace in this array, only users with + * the matching priviledges will be able to see and edit pages in this + * namespace. + * + * The form is " namespace => 'priviledge' " e.g. + * + * $wgRestrictedNamespaces = + * array(100 => 'coolguy', + * 101 => 'coolguy' + * ); + * + * where 100 is the namespace id and 'coolguy' is the priviledge. + * + * Each priv. is a string in an array, you can add as many as you like + * in the $wgGroupPermitions array e.g. + * + *$wgGroupPermissions['allowed']['coolguy'] = true; + * + * In this example you asigned the 'coolguy' priviledge to the 'allowed' group. + * + */ +$wgRestrictedNamespaces = NULL; + +/** + * In case you want only to deny the edit right on a namespace, you may put it + * in this array. You also need to asign the 'roread' right to the usergroup you + * want to be able to read and the 'roedit' right to the usergroup you want to be + * able to edit. Read only namespaces are not hiden (nor their logs etc). + * + * Example: $wgReadOnlyNSes = array(100,101); + * + */ +$wgReadOnlyNSes = NULL; + +/** + * In case you have categories of pages located on a restricted namespaces + * those categories will appear empty and might be comfusing. Setting this + * var to true, (all) categories will be hidden in the Recent changes. + */ +$wgHideCategoriesinRC = false; + +/** + * Logs in Recent Changes are treated all the same, so normaly users will be able + * to see moves, protects and deletes of pages in restricted namespaces. Setting + * this var to true will hide all logs in Recent Changes and only those for restricted + * namespaces in Special:Log. + */ +$wgHideLogs = false; + +/** + * In case you want to customize what logs the user can see both in Recent Changes + * and Special:Log, modify this array to include the log types you want to hide. This is + * overriden by $wgHideLogs for Recent Changes and those logs for restricted + * namespaces in Special:Log. This feature lets you hide also the 'block' and 'rights' + * log types that are namespace independed in Special:Log, or show them in RC while + * hiding the rest. + * + * This example shows how to hide all log types in RC, and (block/rights) in Special:Log + * (the others in Special:Log are are filtered based on namespace access rights so they + * apply only for restricted namespaces). + * + *$wgHidenLogs = array('block','protect', 'rights', 'delete','upload', 'move'); + */ +$wgHidenLogs = NULL; + +/** + * In case some user tries to create a link from some namespace to an other restricted + * namespace, while the page gets parsed, instead of the link, a warning message will appear + * ('restrlink') to let the user know. If the link is in the same namespace as the edited page, + * no check will be done. + */ +$wgLinkWarn = true; + +/** + * In case you want to hide logs about User Talk pages (namespace 3) fromnrecent changes + * set this to true. + * + */ +$wgHideUtalk = false; + +/** + * You can use this array to alter wiki's upper left logo depending on the namespace + * you are in. + * + * Example: + * $wgNamespaceLogos = array ( 100 => '/url_path_to/logo.gif'); + **/ +$wgNamespaceLogos = NULL; + +/** * Limit images on image description pages to a user-selectable limit. In order * to reduce disk usage, limits can only be selected from a list. This is the * list of settings the user can choose from: diff -iEbdu -r ./includes/Export.php ./includes/Export.php --- ./includes/Export.php 2006-10-14 02:06:32.000000000 +0200 +++ ./includes/Export.php 2006-12-07 15:30:56.355736500 +0100 @@ -256,7 +256,13 @@ */ function outputStream( $resultset ) { $last = null; + global $wgUser; while( $row = $resultset->fetchObject() ) { + #If page is in a secured namespace, skip the row. + if(!$wgUser->canAccessNamespace($row->page_namespace) ){ + continue; + } + if( is_null( $last ) || $last->page_namespace != $row->page_namespace || $last->page_title != $row->page_title ) { @@ -349,11 +355,14 @@ } function namespaces() { - global $wgContLang; - $spaces = " \n"; + global $wgContLang, $wgUser; + $spaces = "\n"; foreach( $wgContLang->getFormattedNamespaces() as $ns => $title ) { + if($wgUser->canAccessNamespace($ns)) + { $spaces .= ' ' . wfElement( 'namespace', array( 'key' => $ns ), $title ) . "\n"; } + } $spaces .= " "; return $spaces; } diff -iEbdu -r ./includes/OutputPage.php ./includes/OutputPage.php --- ./includes/OutputPage.php 2006-10-14 02:06:34.000000000 +0200 +++ ./includes/OutputPage.php 2006-12-07 15:30:56.636997300 +0100 @@ -236,7 +236,7 @@ foreach ( $categories as $category => $arbitrary ) { $title = Title::makeTitleSafe( NS_CATEGORY, $category ); $text = $wgContLang->convertHtml( $title->getText() ); - $this->mCategoryLinks[] = $sk->makeLinkObj( $title, $text ); + $this->mCategoryLinks[] = $sk->makeKnownLinkObj( $title, $text ); } } @@ -723,6 +723,7 @@ $this->mBodytext = ''; $groups = array(); + foreach( $wgGroupPermissions as $key => $value ) { if( isset( $value[$permission] ) && $value[$permission] == true ) { $groupName = User::getGroupName( $key ); @@ -777,6 +778,21 @@ $skin = $wgUser->getSkin(); + if($wgTitle->getNamespace() >= 100){ + $usersNamespaces = $wgUser->getAllowedRNSes(); + $usersNamespacesArray = explode("\n", $usersNamespaces); + $currentNamespace = Namespace::getCanonicalName($wgTitle->getNamespace()); + + if (!in_array($currentNamespace, $usersNamespacesArray)) { + $this->setPageTitle( wfMsg( 'noaccesstitle' ) ); + $this->setHtmlTitle( wfMsg( 'errorpagetitle' ) ); + $this->setRobotPolicy( 'noindex,nofollow' ); + $this->setArticleFlag( false ); + $this->addHTML( wfMsgHtml( 'noaccesstext') ); + } else { + // Should never reach here. + } + } else { $this->setPageTitle( wfMsg( 'loginreqtitle' ) ); $this->setHtmlTitle( wfMsg( 'errorpagetitle' ) ); $this->setRobotPolicy( 'noindex,nofollow' ); @@ -793,6 +809,7 @@ if( $mainPage->userCanRead() ) $this->returnToMain( true, $mainPage ); } + } /** @obsolete */ function databaseError( $fname, $sql, $error, $errno ) { diff -iEbdu -r ./includes/Parser.php ./includes/Parser.php --- ./includes/Parser.php 2006-10-14 02:06:32.000000000 +0200 +++ ./includes/Parser.php 2006-12-07 16:39:15.760002900 +0100 @@ -1463,6 +1463,7 @@ */ function replaceInternalLinks( $s ) { global $wgContLang; + global $wgUser; static $fname = 'Parser::replaceInternalLinks' ; wfProfileIn( $fname ); @@ -1604,6 +1605,17 @@ $ns = $nt->getNamespace(); $iw = $nt->getInterWiki(); + + #If the link points to a restricted namespace outside the + #parent namespace warn the user. + global $wgRestrictedNamespaces, $wgLinkWarn ; + if( $wgLinkWarn && is_array( $wgRestrictedNamespaces )) { + if( array_key_exists( $ns, $wgRestrictedNamespaces ) && !$wgUser->canAccessNamespace( $ns )) {/*($this->mTitle->getNamespace() != $ns)) {*/ + $s .=wfMsg( 'restrlink' ). $trail; + continue; + } + } + wfProfileOut( "$fname-title" ); if ($might_be_img) { # if this is actually an invalid link @@ -2826,7 +2838,7 @@ * @private */ function braceSubstitution( $piece ) { - global $wgContLang, $wgLang, $wgAllowDisplayTitle, $action; + global $wgContLang, $wgLang, $wgAllowDisplayTitle, $action, $wgRestrictedNamespaces; $fname = __METHOD__ /*. '-L' . count( $this->mArgStack )*/; wfProfileIn( $fname ); wfProfileIn( __METHOD__.'-setup' ); @@ -2994,6 +3006,15 @@ } if ( !$title->isExternal() ) { + # Articles from restricted namespaces can't be used in templates. + # They would appear or disappear based on the rights of the user + # that refreshes the cache... + if( is_array( $wgRestrictedNamespaces ) ) { + if( array_key_exists( $title->getNamespace(), $wgRestrictedNamespaces ) ) { + $found = true; + $text = $linestart . wfMsg( 'templatenotincluded' ); + } + } if ( $title->getNamespace() == NS_SPECIAL && $this->mOptions->getAllowSpecialInclusion() && $this->ot['html'] ) { $text = SpecialPage::capturePath( $title ); if ( is_string( $text ) ) { diff -iEbdu -r ./includes/QueryPage.php ./includes/QueryPage.php --- ./includes/QueryPage.php 2006-10-14 02:06:34.000000000 +0200 +++ ./includes/QueryPage.php 2006-12-07 15:30:58.355813300 +0100 @@ -474,8 +474,14 @@ class PageQueryPage extends QueryPage { function formatResult( $skin, $result ) { - global $wgContLang; + global $wgContLang, $wgUser; $nt = Title::makeTitle( $result->namespace, $result->title ); + + # Don't show wanted pages in restricted namespaces + if( !$wgUser->canAccessNamespace( $nt->getNamespace() ) ) { + return ""; + } + return $skin->makeKnownLinkObj( $nt, htmlspecialchars( $wgContLang->convert( $nt->getPrefixedText() ) ) ); } } diff -iEbdu -r ./includes/SearchEngine.php ./includes/SearchEngine.php --- ./includes/SearchEngine.php 2006-10-14 02:06:32.000000000 +0200 +++ ./includes/SearchEngine.php 2006-12-07 16:12:19.098684900 +0100 @@ -167,10 +167,10 @@ * @access public */ function searchableNamespaces() { - global $wgContLang; + global $wgContLang, $wgUser; $arr = array(); foreach( $wgContLang->getNamespaces() as $ns => $name ) { - if( $ns >= NS_MAIN ) { + if( $ns >= NS_MAIN && $wgUser->canAccessNamespace($ns)) { $arr[$ns] = $name; } } diff -iEbdu -r ./includes/Skin.php ./includes/Skin.php --- ./includes/Skin.php 2006-10-14 02:06:34.000000000 +0200 +++ ./includes/Skin.php 2006-12-07 15:41:43.918198000 +0100 @@ -121,7 +121,6 @@ include_once( "{$wgStyleDirectory}/{$skinName}.deps.php" ); wfRestoreWarnings(); require_once( "{$wgStyleDirectory}/{$skinName}.php" ); - # Check if we got if not failback to default skin $className = 'Skin'.$skinName; if( !class_exists( $className ) ) { @@ -1511,11 +1510,22 @@ */ function buildSidebar() { global $parserMemc, $wgEnableSidebarCache; - global $wgLang, $wgContLang; + global $wgLang, $wgContLang, $wgUser, $wgTitle; + global $wgExtraNamespaces, $wgRestrictedNamespaces; $fname = 'SkinTemplate::buildSidebar'; wfProfileIn( $fname ); + $nsname = ''; + if(is_object($wgTitle)) + { + $nsid = $wgTitle->getNamespace(); + if(in_array($nsid, array_keys($wgExtraNamespaces)) && + in_array($nsid, array_keys($wgRestrictedNamespaces))) + { + $nsname = $wgExtraNamespaces[$nsid].":"; + } + } $key = wfMemcKey( 'sidebar' ); $cacheSidebar = $wgEnableSidebarCache && @@ -1550,13 +1560,28 @@ $href = self::makeInternalOrExternalUrl( $link ); $bar[$heading][] = array( 'text' => $text, - 'href' => $href, + 'href' => preg_replace('/Main_Page$/', $nsname."Main_Page", $href), 'id' => 'n-' . strtr($line[1], ' ', '-'), 'active' => false ); } else { continue; } } } + $heading = 'your namespaces'; + $lines = explode( "\n", $wgUser->getAllowedRNSes() ); + if (count($lines) > 0 && $lines[0] != '') { + foreach ($lines as $line) { + $bar[$heading][] = array( + 'text' => $line, + 'href' => $this->makeInternalOrExternalUrl( $line . ':' . wfMsgForContent( 'mainpage' ) ), + 'id' => 'n-' . strtr($line, ' ', '-'), + 'active' => false + ); + } + } + if ($cacheSidebar) $cachednotice = $parserMemc->set( $key, $bar, 86400 ); wfProfileOut( $fname ); diff -iEbdu -r ./includes/SpecialAllpages.php ./includes/SpecialAllpages.php --- ./includes/SpecialAllpages.php 2006-10-14 02:06:32.000000000 +0200 +++ ./includes/SpecialAllpages.php 2006-12-07 15:21:46.970229300 +0100 @@ -10,17 +10,24 @@ * @param $specialPage @see SpecialPage object. */ function wfSpecialAllpages( $par=NULL, $specialPage ) { - global $wgRequest, $wgOut, $wgContLang; + global $wgRequest, $wgOut, $wgContLang, $wgUser; # GET values $from = $wgRequest->getVal( 'from' ); $namespace = $wgRequest->getInt( 'namespace' ); $namespaces = $wgContLang->getNamespaces(); + if ( isset($par) ) { + foreach ($namespaces as $ns_id => $ns_name) { + if ($par == $ns_name) { + $namespace = $ns_id; + } + } + } $indexPage = new SpecialAllpages(); - if( !in_array($namespace, array_keys($namespaces)) ) + if( !in_array($namespace, array_keys($namespaces)) || !$wgUser->canAccessNamespace( $namespace)) $namespace = 0; $wgOut->setPagetitle( $namespace > 0 ? @@ -28,9 +35,7 @@ wfMsg( 'allarticles' ) ); - if ( isset($par) ) { - $indexPage->showChunk( $namespace, $par, $specialPage->including() ); - } elseif ( isset($from) ) { + if ( isset($from) ) { $indexPage->showChunk( $namespace, $from, $specialPage->including() ); } else { $indexPage->showToplevel ( $namespace, $specialPage->including() ); diff -iEbdu -r ./includes/SpecialContributions.php ./includes/SpecialContributions.php --- ./includes/SpecialContributions.php 2006-10-14 02:06:32.000000000 +0200 +++ ./includes/SpecialContributions.php 2006-12-07 15:30:56.136978100 +0100 @@ -16,7 +16,14 @@ } function setNamespace( $ns ) { + global $wgUser; + # If the namespace asked is restricted return + # to the main namespace. + if($wgUser->canAccessNamespace($ns)) { $this->namespace = $ns; + }else{ + $this->namespace = 0; + } } function setLimit( $limit ) { @@ -72,15 +79,30 @@ } function getNamespaceCond() { - if ( $this->namespace !== false ) + global $wgUser; + # Include the namespace in the querry only if it's not restricted to the user. + if (($this->namespace !== false) && ($wgUser->canAccessNamespace($this->namespace))) { return ' AND page_namespace = ' . (int)$this->namespace; + } else { return ''; } + } function getPreviousOffsetForPaging() { list( $index, $usercond ) = $this->getUserCond(); $nscond = $this->getNamespaceCond(); + # Exclude all namespaces that are restricted to this user + global $wgRestrictedNamespaces; + global $wgUser; + if( is_array( $wgRestrictedNamespaces )) { + foreach( $wgRestrictedNamespaces as $key => $value ) { + if( ! $wgUser->canAccessNamespace( $key )) { + $nscond .= ' AND page_namespace <>' . $key; + } + } + } + $use_index = $this->dbr->useIndexClause( $index ); extract( $this->dbr->tableNames( 'page', 'revision' ) ); @@ -137,6 +159,16 @@ $offsetQuery = "AND rev_timestamp <= '{$this->offset}'"; $nscond = $this->getNamespaceCond(); + # Exclude all namespaces that are restricted to this user + global $wgRestrictedNamespaces; + global $wgUser; + if( is_array( $wgRestrictedNamespaces )) { + foreach( $wgRestrictedNamespaces as $key => $value ) { + if( ! $wgUser->canAccessNamespace( $key )) { + $nscond .= ' AND page_namespace <>' . $key; + } + } + } $use_index = $this->dbr->useIndexClause( $index ); $sql = "SELECT page_namespace,page_title,page_is_new,page_latest, diff -iEbdu -r ./includes/SpecialLog.php ./includes/SpecialLog.php --- ./includes/SpecialLog.php 2006-10-14 02:06:34.000000000 +0200 +++ ./includes/SpecialLog.php 2006-12-07 15:30:57.433902900 +0100 @@ -302,11 +302,42 @@ * @private */ function logLine( $s ) { - global $wgLang; + global $wgLang, $wgUser; + global $wgHideLogs, $wgHidenLogs; $title = Title::makeTitle( $s->log_namespace, $s->log_title ); $user = Title::makeTitleSafe( NS_USER, $s->user_name ); $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $s->log_timestamp), true ); + # Hide all logs or the log types in $wgHidenLogs. + # Block and rights are namespace independed. + if((is_array($wgHidenLogs) && + ((in_array('block', $wgHidenLogs) && $s->log_type =='block' ) + ||(in_array('rights', $wgHidenLogs) && $s->log_type=='rights')) + ||($wgHideLogs && ($s->log_type=='block' ||$s->log_type=='rights')))){ + return; + } + + # Upload namespaces are public. + if(is_array($wgHidenLogs) && + (in_array('upload', $wgHidenLogs) && $s->log_type=='upload') || + ($wgHideLogs && $s->log_type=='upload')) { + return; + } + + # We hide the rest only for the restricted namespaces. + if(!$wgUser->canAccessNamespace($s->log_namespace)){ + if($wgHideLogs){ + return; + } + if(is_array($wgHidenLogs)){ + if((in_array('protect', $wgHidenLogs) && $s->log_type=='protect') + ||(in_array('delete', $wgHidenLogs) && $s->log_type=='delete') + ||(in_array('move', $wgHidenLogs) && $s->log_type=='move')){ + return; + } + } + } + // Enter the existence or non-existence of this page into the link cache, // for faster makeLinkObj() in LogPage::actionText() $linkCache =& LinkCache::singleton(); diff -iEbdu -r ./includes/SpecialPreferences.php ./includes/SpecialPreferences.php --- ./includes/SpecialPreferences.php 2006-12-07 11:51:17.164600800 +0100 +++ ./includes/SpecialPreferences.php 2006-12-07 15:30:57.730789300 +0100 @@ -88,7 +88,7 @@ if ( $this->mPosted ) { $namespaces = $wgContLang->getNamespaces(); foreach ( $namespaces as $i => $namespace ) { - if ( $i >= 0 ) { + if ( $i >= 0 && $wgUser->canAccessNamespace( $i) ) { $this->mSearchNs[$i] = $request->getCheck( "wpNs$i" ) ? 1 : 0; } } @@ -384,7 +384,7 @@ $namespaces = $wgContLang->getNamespaces(); foreach ( $namespaces as $i => $namespace ) { - if ( $i >= NS_MAIN ) { + if ( $i >= NS_MAIN && $wgUser->canAccessNamespace( $i) ) { $this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i ); } } @@ -394,14 +394,14 @@ * @access private */ function namespacesCheckboxes() { - global $wgContLang; + global $wgContLang, $wgUser; # Determine namespace checkboxes $namespaces = $wgContLang->getNamespaces(); $r1 = null; foreach ( $namespaces as $i => $name ) { - if ($i < 0) + if ($i < 0 || !$wgUser->canAccessNamespace( $i) ) continue; $checked = $this->mSearchNs[$i] ? "checked='checked'" : ''; $name = str_replace( '_', ' ', $namespaces[$i] ); diff -iEbdu -r ./includes/SpecialRandompage.php ./includes/SpecialRandompage.php --- ./includes/SpecialRandompage.php 2006-10-14 02:06:36.000000000 +0200 +++ ./includes/SpecialRandompage.php 2006-12-07 15:30:59.058965300 +0100 @@ -11,12 +11,15 @@ * used as e.g. Special:Randompage/Category */ function wfSpecialRandompage( $par = NS_MAIN ) { - global $wgOut, $wgExtraRandompageSQL, $wgContLang, $wgLang; + global $wgOut, $wgExtraRandompageSQL, $wgContLang, $wgLang, $wgUser; $fname = 'wfSpecialRandompage'; # Determine namespace $t = Title::newFromText ( $par . ":Dummy" ) ; $namespace = $t->getNamespace () ; + if ($namespace === false || $namespace < NS_MAIN || !$wgUser->canAccessNamespace($namespace)) { + $namespace = NS_MAIN; + } # NOTE! We use a literal constant in the SQL instead of the RAND() # function because RAND() will return a different value for every row diff -iEbdu -r ./includes/SpecialRecentchanges.php ./includes/SpecialRecentchanges.php --- ./includes/SpecialRecentchanges.php 2006-10-14 02:06:32.000000000 +0200 +++ ./includes/SpecialRecentchanges.php 2006-12-07 15:30:55.011934900 +0100 @@ -17,6 +17,7 @@ global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol, $wgDBtype; global $wgRCShowWatchingUsers, $wgShowUpdatedMarker; global $wgAllowCategorizedRecentChanges ; + global $wgRestrictedNamespaces, $wgHideCategoriesinRC, $wgHidenLogs, $wgHideLogs, $wgHideUtalk; $fname = 'wfSpecialRecentchanges'; # Get query parameters @@ -124,8 +125,9 @@ # Get last modified date, for client caching # Don't use this if we are using the patrol feature, patrol changes don't update the timestamp + # Don't use it if there are hidden namespaces, as the feed must be different for the users $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, $fname ); - if ( $feedFormat || !$wgUseRCPatrol ) { + if ( !is_array( $wgRestrictedNamespaces ) && ($feedFormat || !$wgUseRCPatrol) ) { if( $lastmod && $wgOut->checkLastModified( $lastmod ) ){ # Client cache fresh and headers sent, nothing more to do. return; @@ -152,6 +154,32 @@ } } + # Hide all categories if $wgHideCategoriesinRC is set + $hidem .= $wgHideCategoriesinRC ? ' AND rc_namespace <> 14':''; + # Hide all User_talk pages if $wgHideUtalk is set + $hidem .= $wgHideUtalk ? ' AND rc_namespace <> 3':''; + # Hide all logs if $wgHideRCLogs is set + $hidem .= $wgHideLogs ? ' AND rc_type <> 3':''; + # Hide all logs or the log types in $wgHidenLogs. + if(!$wgHideLogs && is_array($wgHidenLogs)){ + # Block and rights are namespace independed. + $hidem .= in_array('block', $wgHidenLogs) ? ' AND rc_title <> "Log/block"':''; + $hidem .= in_array('rights', $wgHidenLogs) ? ' AND rc_title <> "Log/rights"':''; + # Hide the log types set in $wgHidenLogs + $hidem .= in_array('protect', $wgHidenLogs) ? ' AND rc_title <> "Log/protect"':''; + $hidem .= in_array('delete', $wgHidenLogs) ? ' AND rc_title <> "Log/delete"':''; + $hidem .= in_array('upload', $wgHidenLogs) ? ' AND rc_title <> "Log/upload"':''; + $hidem .= in_array('move', $wgHidenLogs) ? ' AND rc_title <> "Log/move"':''; + } + # Exclude all namespaces that are restricted to this user + if( is_array( $wgRestrictedNamespaces )) { + foreach( $wgRestrictedNamespaces as $key => $value ) { + if( ! $wgUser->canAccessNamespace( $key )) { + $hidem .= ' AND rc_namespace <>' . $key; + } + } + } + # Namespace filtering $hidem .= is_null( $namespace ) ? '' : ' AND rc_namespace' . ($invert ? '!=' : '=') . $namespace; @@ -349,8 +377,13 @@ * go ahead and use it even if there have been edits made * since it was rendered. This keeps a swarm of requests * from being too bad on a super-frequently edited wiki. + * + * Using restricted namespaces forbids caching the feed, + * however, since it must be rendered according to user + * rights. */ - if( time() - wfTimestamp( TS_UNIX, $feedLastmod ) + if( !is_array( $wgRestrictedNamespaces ) + && time() - wfTimestamp( TS_UNIX, $feedLastmod ) < $wgFeedCacheTimeout || wfTimestamp( TS_UNIX, $feedLastmod ) > wfTimestamp( TS_UNIX, $lastmod ) ) { diff -iEbdu -r ./includes/SpecialRecentchangeslinked.php ./includes/SpecialRecentchangeslinked.php --- ./includes/SpecialRecentchangeslinked.php 2006-10-14 02:06:32.000000000 +0200 +++ ./includes/SpecialRecentchangeslinked.php 2006-12-07 15:22:21.173792100 +0100 @@ -67,6 +67,16 @@ $cmq = 'AND rc_minor=0'; } else { $cmq = ''; } + # Exclude all namespaces that are restricted to this user + global $wgRestrictedNamespaces; + if( is_array( $wgRestrictedNamespaces )) { + foreach( $wgRestrictedNamespaces as $key => $value ) { + if( ! $wgUser->canAccessNamespace( $key )) { + $cmq .= ' AND page_namespace <>' . $key; + } + } + } + extract( $dbr->tableNames( 'recentchanges', 'categorylinks', 'pagelinks', 'revision', 'page' , "watchlist" ) ); $uid = $wgUser->getID(); diff -iEbdu -r ./includes/SpecialUserlogin.php ./includes/SpecialUserlogin.php --- ./includes/SpecialUserlogin.php 2006-10-14 02:06:32.000000000 +0200 +++ ./includes/SpecialUserlogin.php 2006-12-07 15:30:54.574418100 +0100 @@ -475,6 +475,7 @@ function successfulLogin( $msg, $auto = true ) { global $wgUser; global $wgOut; + global $wgLinkWarn; # Run any hooks; ignore results @@ -484,12 +485,20 @@ $wgOut->setRobotpolicy( 'noindex,nofollow' ); $wgOut->setArticleRelated( false ); $wgOut->addWikiText( $msg ); + if($wgUser->getRMainPages() != NULL) { + # We are going to put some links to restricted namespaces + # that the user has access to, so we disable the warning. + $wgLinkWarn = false; + $wgOut->addWikiText(wfMsg('RNSlist')."
".str_replace( '_', ' ',$wgUser->getRMainPages())); + $wgOut->returnToMain(false); + } else { if ( !empty( $this->mReturnTo ) ) { $wgOut->returnToMain( $auto, $this->mReturnTo ); } else { $wgOut->returnToMain( $auto ); } } + } /** */ function userNotPrivilegedMessage() { diff -iEbdu -r ./includes/SpecialWantedpages.php ./includes/SpecialWantedpages.php --- ./includes/SpecialWantedpages.php 2006-10-14 02:06:36.000000000 +0200 +++ ./includes/SpecialWantedpages.php 2006-12-07 15:30:58.871458100 +0100 @@ -67,10 +67,15 @@ function formatResult( $skin, $result ) { - global $wgLang; + global $wgLang, $wgUser; $title = Title::makeTitleSafe( $result->namespace, $result->title ); + # Don't show wanted pages in restricted namespaces + if( !$wgUser->canAccessNamespace( $title->getNamespace() ) ) { + return ""; + } + if( $this->isCached() ) { # Check existence; which is stored in the link cache if( !$title->exists() ) { diff -iEbdu -r ./includes/SpecialWhatlinkshere.php ./includes/SpecialWhatlinkshere.php --- ./includes/SpecialWhatlinkshere.php 2006-10-14 02:06:32.000000000 +0200 +++ ./includes/SpecialWhatlinkshere.php 2006-12-07 15:30:54.761925300 +0100 @@ -73,7 +73,7 @@ * @private */ function showIndirectLinks( $level, $target, $limit, $from = 0, $dir = 'next' ) { - global $wgOut; + global $wgOut, $wgUser; $fname = 'WhatLinksHerePage::showIndirectLinks'; $dbr =& wfGetDB( DB_READ ); @@ -199,6 +199,11 @@ $wgOut->addHTML( '