Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1964
RS.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 8:20 PM
2014-11-21 20:20:17 (UTC+0)
Size
39 KB
Referenced Files
None
Subscribers
None
RS.patch
View Options
diff -r -c mediawiki-1.7.1/includes/CategoryPage.php ../curwiki/includes/CategoryPage.php
*** mediawiki-1.7.1/includes/CategoryPage.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/CategoryPage.php Thu Jul 13 12:50:14 2006
***************
*** 107,112 ****
--- 107,117 ----
$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 ) {
// Subcategory; strip the 'Category' namespace from the link text.
array_push( $children, $sk->makeKnownLinkObj( $title, $wgContLang->convertHtml( $title->getText() ) ) );
diff -r -c mediawiki-1.7.1/includes/DefaultSettings.php ../curwiki/includes/DefaultSettings.php
*** mediawiki-1.7.1/includes/DefaultSettings.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/DefaultSettings.php Thu Jul 13 12:52:55 2006
***************
*** 1693,1698 ****
--- 1693,1788 ----
$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 -r -c mediawiki-1.7.1/includes/Export.php ../curwiki/includes/Export.php
*** mediawiki-1.7.1/includes/Export.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/Export.php Thu Jul 13 12:55:52 2006
***************
*** 237,243 ****
--- 237,249 ----
*/
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 ) {
***************
*** 330,338 ****
}
function namespaces() {
! global $wgContLang;
! $spaces = " <namespaces>\n";
! foreach( $wgContLang->getFormattedNamespaces() as $ns => $title ) {
$spaces .= ' ' . wfElement( 'namespace', array( 'key' => $ns ), $title ) . "\n";
}
$spaces .= " </namespaces>";
--- 336,348 ----
}
function namespaces() {
! global $wgContLang, $wgUser;
! $spaces = "<namespaces>\n";
! # Don't display restricted namespaces.
! foreach( $wgContLang->getNamespaces() as $ns => $title ) {
! if(!$wgUser->canAccessNamespace($ns) ){
! continue;
! }
$spaces .= ' ' . wfElement( 'namespace', array( 'key' => $ns ), $title ) . "\n";
}
$spaces .= " </namespaces>";
diff -r -c mediawiki-1.7.1/includes/OutputPage.php ../curwiki/includes/OutputPage.php
*** mediawiki-1.7.1/includes/OutputPage.php Thu Jul 13 10:15:14 2006
--- ../curwiki/includes/OutputPage.php Thu Jul 13 13:03:07 2006
***************
*** 236,242 ****
foreach ( $categories as $category => $arbitrary ) {
$title = Title::makeTitleSafe( NS_CATEGORY, $category );
$text = $wgContLang->convertHtml( $title->getText() );
! $this->mCategoryLinks[] = $sk->makeLinkObj( $title, $text );
}
}
--- 236,242 ----
foreach ( $categories as $category => $arbitrary ) {
$title = Title::makeTitleSafe( NS_CATEGORY, $category );
$text = $wgContLang->convertHtml( $title->getText() );
! $this->mCategoryLinks[] = $sk->makeKnownLinkObj( $title, $text );
}
}
***************
*** 776,792 ****
global $wgUser, $wgTitle, $wgContLang;
$skin = $wgUser->getSkin();
! $this->setPageTitle( wfMsg( 'loginreqtitle' ) );
! $this->setHtmlTitle( wfMsg( 'errorpagetitle' ) );
! $this->setRobotPolicy( 'noindex,nofollow' );
! $this->setArticleFlag( false );
! $loginTitle = Title::makeTitle( NS_SPECIAL, 'Userlogin' );
! $loginLink = $skin->makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $wgTitle->getPrefixedUrl() );
! $this->addHtml( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) );
! $this->addHtml( "\n<!--" . $wgTitle->getPrefixedUrl() . "-->" );
! $this->returnToMain();
}
/** @obsolete */
--- 776,809 ----
global $wgUser, $wgTitle, $wgContLang;
$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' );
! $this->setArticleFlag( false );
! $loginTitle = Title::makeTitle( NS_SPECIAL, 'Userlogin' );
! $loginLink = $skin->makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ),
! 'returnto=' . $wgTitle->getPrefixedUrl() );
! $this->addHtml( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) );
! $this->addHtml( "\n<!--" . $wgTitle->getPrefixedUrl() . "-->" );
! $this->returnToMain();
! }
}
/** @obsolete */
diff -r -c mediawiki-1.7.1/includes/Parser.php ../curwiki/includes/Parser.php
*** mediawiki-1.7.1/includes/Parser.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/Parser.php Thu Jul 13 13:11:48 2006
***************
*** 1508,1513 ****
--- 1508,1523 ----
$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 ) && ($this->mTitle->getNamespace() != $ns)) {
+ $s .=wfMsg( 'restrlink' ). $trail;
+ continue;
+ }
+ }
+
if ($might_be_img) { # if this is actually an invalid link
if ($ns == NS_IMAGE && $noforce) { #but might be an image
$found = false;
***************
*** 2816,2821 ****
--- 2826,2840 ----
# Check for excessive inclusion
$dbk = $title->getPrefixedDBkey();
if ( $this->incrementIncludeCount( $dbk ) ) {
+ # 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->mOutputType != OT_WIKI ) {
$text = SpecialPage::capturePath( $title );
if ( is_string( $text ) ) {
diff -r -c mediawiki-1.7.1/includes/QueryPage.php ../curwiki/includes/QueryPage.php
*** mediawiki-1.7.1/includes/QueryPage.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/QueryPage.php Thu Jul 13 13:13:20 2006
***************
*** 474,481 ****
class PageQueryPage extends QueryPage {
function formatResult( $skin, $result ) {
! global $wgContLang;
$nt = Title::makeTitle( $result->namespace, $result->title );
return $skin->makeKnownLinkObj( $nt, htmlspecialchars( $wgContLang->convert( $nt->getPrefixedText() ) ) );
}
}
--- 474,487 ----
class PageQueryPage extends QueryPage {
function formatResult( $skin, $result ) {
! 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 -r -c mediawiki-1.7.1/includes/SearchEngine.php ../curwiki/includes/SearchEngine.php
*** mediawiki-1.7.1/includes/SearchEngine.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/SearchEngine.php Thu Jul 13 13:14:28 2006
***************
*** 162,171 ****
* @access public
*/
function searchableNamespaces() {
! global $wgContLang;
$arr = array();
foreach( $wgContLang->getNamespaces() as $ns => $name ) {
! if( $ns >= NS_MAIN ) {
$arr[$ns] = $name;
}
}
--- 162,171 ----
* @access public
*/
function searchableNamespaces() {
! global $wgContLang, $wgUser;
$arr = array();
foreach( $wgContLang->getNamespaces() as $ns => $name ) {
! if( $ns >= NS_MAIN && $wgUser->canAccessNamespace( $ns )) {
$arr[$ns] = $name;
}
}
diff -r -c mediawiki-1.7.1/includes/SpecialAllpages.php ../curwiki/includes/SpecialAllpages.php
*** mediawiki-1.7.1/includes/SpecialAllpages.php Thu Jul 13 10:12:00 2006
--- ../curwiki/includes/SpecialAllpages.php Thu Jul 13 13:15:46 2006
***************
*** 10,26 ****
* @param $specialPage @see SpecialPage object.
*/
function wfSpecialAllpages( $par=NULL, $specialPage ) {
! global $wgRequest, $wgOut, $wgContLang;
# GET values
$from = $wgRequest->getVal( 'from' );
$namespace = $wgRequest->getInt( 'namespace' );
$namespaces = $wgContLang->getNamespaces();
$indexPage = new SpecialAllpages();
! if( !in_array($namespace, array_keys($namespaces)) )
$namespace = 0;
$wgOut->setPagetitle( $namespace > 0 ?
--- 10,33 ----
* @param $specialPage @see SpecialPage object.
*/
function wfSpecialAllpages( $par=NULL, $specialPage ) {
! 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)) || !$wgUser->canAccessNamespace( $namespace))
$namespace = 0;
$wgOut->setPagetitle( $namespace > 0 ?
***************
*** 28,36 ****
wfMsg( 'allarticles' )
);
! if ( isset($par) ) {
! $indexPage->showChunk( $namespace, $par, $specialPage->including() );
! } elseif ( isset($from) ) {
$indexPage->showChunk( $namespace, $from, $specialPage->including() );
} else {
$indexPage->showToplevel ( $namespace, $specialPage->including() );
--- 35,41 ----
wfMsg( 'allarticles' )
);
! if ( isset($from) ) {
$indexPage->showChunk( $namespace, $from, $specialPage->including() );
} else {
$indexPage->showToplevel ( $namespace, $specialPage->including() );
diff -r -c mediawiki-1.7.1/includes/SpecialContributions.php ../curwiki/includes/SpecialContributions.php
*** mediawiki-1.7.1/includes/SpecialContributions.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/SpecialContributions.php Thu Jul 13 13:19:16 2006
***************
*** 16,22 ****
}
function setNamespace( $ns ) {
! $this->namespace = $ns;
}
function setLimit( $limit ) {
--- 16,29 ----
}
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,86 ****
}
function getNamespaceCond() {
! if ( $this->namespace !== false )
return ' AND page_namespace = ' . (int)$this->namespace;
! return '';
}
function getPreviousOffsetForPaging() {
list( $index, $usercond ) = $this->getUserCond();
$nscond = $this->getNamespaceCond();
$use_index = $this->dbr->useIndexClause( $index );
extract( $this->dbr->tableNames( 'page', 'revision' ) );
--- 79,108 ----
}
function getNamespaceCond() {
! 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,142 ****
--- 159,174 ----
$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 -r -c mediawiki-1.7.1/includes/SpecialLog.php ../curwiki/includes/SpecialLog.php
*** mediawiki-1.7.1/includes/SpecialLog.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/SpecialLog.php Thu Jul 13 13:22:44 2006
***************
*** 302,312 ****
* @private
*/
function logLine( $s ) {
! global $wgLang;
$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 );
// Enter the existence or non-existence of this page into the link cache,
// for faster makeLinkObj() in LogPage::actionText()
$linkCache =& LinkCache::singleton();
--- 302,343 ----
* @private
*/
function logLine( $s ) {
! 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 -r -c mediawiki-1.7.1/includes/SpecialPreferences.php ../curwiki/includes/SpecialPreferences.php
*** mediawiki-1.7.1/includes/SpecialPreferences.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/SpecialPreferences.php Thu Jul 13 13:26:09 2006
***************
*** 88,94 ****
if ( $this->mPosted ) {
$namespaces = $wgContLang->getNamespaces();
foreach ( $namespaces as $i => $namespace ) {
! if ( $i >= 0 ) {
$this->mSearchNs[$i] = $request->getCheck( "wpNs$i" ) ? 1 : 0;
}
}
--- 88,94 ----
if ( $this->mPosted ) {
$namespaces = $wgContLang->getNamespaces();
foreach ( $namespaces as $i => $namespace ) {
! if ( $i >= 0 && $wgUser->canAccessNamespace( $i) ) {
$this->mSearchNs[$i] = $request->getCheck( "wpNs$i" ) ? 1 : 0;
}
}
***************
*** 379,385 ****
$namespaces = $wgContLang->getNamespaces();
foreach ( $namespaces as $i => $namespace ) {
! if ( $i >= NS_MAIN ) {
$this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i );
}
}
--- 379,385 ----
$namespaces = $wgContLang->getNamespaces();
foreach ( $namespaces as $i => $namespace ) {
! if ( $i >= NS_MAIN && $wgUser->canAccessNamespace( $i) ) {
$this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i );
}
}
***************
*** 389,402 ****
* @access private
*/
function namespacesCheckboxes() {
! global $wgContLang;
# Determine namespace checkboxes
$namespaces = $wgContLang->getNamespaces();
$r1 = null;
foreach ( $namespaces as $i => $name ) {
! if ($i < 0)
continue;
$checked = $this->mSearchNs[$i] ? "checked='checked'" : '';
$name = str_replace( '_', ' ', $namespaces[$i] );
--- 389,402 ----
* @access private
*/
function namespacesCheckboxes() {
! global $wgContLang, $wgUser;
# Determine namespace checkboxes
$namespaces = $wgContLang->getNamespaces();
$r1 = null;
foreach ( $namespaces as $i => $name ) {
! if ($i < 0 || !$wgUser->canAccessNamespace( $i) )
continue;
$checked = $this->mSearchNs[$i] ? "checked='checked'" : '';
$name = str_replace( '_', ' ', $namespaces[$i] );
diff -r -c mediawiki-1.7.1/includes/SpecialRandompage.php ../curwiki/includes/SpecialRandompage.php
*** mediawiki-1.7.1/includes/SpecialRandompage.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/SpecialRandompage.php Thu Jul 13 13:28:34 2006
***************
*** 11,22 ****
* used as e.g. Special:Randompage/Category
*/
function wfSpecialRandompage( $par = NS_MAIN ) {
! global $wgOut, $wgExtraRandompageSQL, $wgContLang, $wgLang;
$fname = 'wfSpecialRandompage';
# Determine namespace
$t = Title::newFromText ( $par . ":Dummy" ) ;
$namespace = $t->getNamespace () ;
# NOTE! We use a literal constant in the SQL instead of the RAND()
# function because RAND() will return a different value for every row
--- 11,25 ----
* used as e.g. Special:Randompage/Category
*/
function wfSpecialRandompage( $par = NS_MAIN ) {
! 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 -r -c mediawiki-1.7.1/includes/SpecialRecentchanges.php ../curwiki/includes/SpecialRecentchanges.php
*** mediawiki-1.7.1/includes/SpecialRecentchanges.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/SpecialRecentchanges.php Thu Jul 13 13:33:05 2006
***************
*** 17,22 ****
--- 17,23 ----
global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol, $wgDBtype;
global $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
global $wgAllowCategorizedRecentChanges ;
+ global $wgRestrictedNamespaces, $wgHideCategoriesinRC, $wgHidenLogs, $wgHideLogs, $wgHideUtalk;
$fname = 'wfSpecialRecentchanges';
# Get query parameters
***************
*** 124,131 ****
# 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
$lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, $fname );
! if ( $feedFormat || !$wgUseRCPatrol ) {
if( $lastmod && $wgOut->checkLastModified( $lastmod ) ){
# Client cache fresh and headers sent, nothing more to do.
return;
--- 125,133 ----
# 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 ( !is_array( $wgRestrictedNamespaces ) && ($feedFormat || !$wgUseRCPatrol) ) {
if( $lastmod && $wgOut->checkLastModified( $lastmod ) ){
# Client cache fresh and headers sent, nothing more to do.
return;
***************
*** 152,157 ****
--- 154,185 ----
}
}
+ # 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,356 ****
* 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.
*/
! if( time() - wfTimestamp( TS_UNIX, $feedLastmod )
< $wgFeedCacheTimeout
|| wfTimestamp( TS_UNIX, $feedLastmod )
> wfTimestamp( TS_UNIX, $lastmod ) ) {
--- 377,389 ----
* 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( !is_array( $wgRestrictedNamespaces )
! && time() - wfTimestamp( TS_UNIX, $feedLastmod )
< $wgFeedCacheTimeout
|| wfTimestamp( TS_UNIX, $feedLastmod )
> wfTimestamp( TS_UNIX, $lastmod ) ) {
diff -r -c mediawiki-1.7.1/includes/SpecialRecentchangeslinked.php ../curwiki/includes/SpecialRecentchangeslinked.php
*** mediawiki-1.7.1/includes/SpecialRecentchangeslinked.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/SpecialRecentchangeslinked.php Thu Jul 13 13:33:54 2006
***************
*** 67,72 ****
--- 67,82 ----
$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 -r -c mediawiki-1.7.1/includes/SpecialUserlogin.php ../curwiki/includes/SpecialUserlogin.php
*** mediawiki-1.7.1/includes/SpecialUserlogin.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/SpecialUserlogin.php Thu Jul 13 13:35:55 2006
***************
*** 441,446 ****
--- 441,447 ----
function successfulLogin( $msg, $auto = true ) {
global $wgUser;
global $wgOut;
+ global $wgLinkWarn;
# Run any hooks; ignore results
***************
*** 450,459 ****
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
$wgOut->addWikiText( $msg );
! if ( !empty( $this->mReturnTo ) ) {
! $wgOut->returnToMain( $auto, $this->mReturnTo );
} else {
! $wgOut->returnToMain( $auto );
}
}
--- 451,468 ----
$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 );
! }
}
}
diff -r -c mediawiki-1.7.1/includes/SpecialWantedpages.php ../curwiki/includes/SpecialWantedpages.php
*** mediawiki-1.7.1/includes/SpecialWantedpages.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/SpecialWantedpages.php Thu Jul 13 13:37:25 2006
***************
*** 67,75 ****
function formatResult( $skin, $result ) {
! global $wgLang;
$title = Title::makeTitleSafe( $result->namespace, $result->title );
if( $this->isCached() ) {
# Check existence; which is stored in the link cache
--- 67,80 ----
function formatResult( $skin, $result ) {
! 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
diff -r -c mediawiki-1.7.1/includes/SpecialWhatlinkshere.php ../curwiki/includes/SpecialWhatlinkshere.php
*** mediawiki-1.7.1/includes/SpecialWhatlinkshere.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/SpecialWhatlinkshere.php Thu Jul 13 13:38:02 2006
***************
*** 199,204 ****
--- 199,209 ----
$wgOut->addHTML( '<ul>' );
foreach ( $rows as $row ) {
+ #If the linking page is located in a secured namespace, skip it.
+ if(!$wgUser->canAccessNamespace($row->page_namespace)) {
+ continue;
+ }
+
$nt = Title::makeTitle( $row->page_namespace, $row->page_title );
if ( $row->page_is_redirect ) {
diff -r -c mediawiki-1.7.1/includes/Title.php ../curwiki/includes/Title.php
*** mediawiki-1.7.1/includes/Title.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/Title.php Thu Jul 13 13:41:49 2006
***************
*** 1030,1035 ****
--- 1030,1039 ----
wfProfileOut( $fname );
return false;
}
+ if( !$wgUser->canAccessNamespace( $this->mNamespace )) {
+ wfProfileOut( $fname );
+ return false;
+ }
// XXX: This is the code that prevents unprotecting a page in NS_MEDIAWIKI
// from taking effect -ævar
if( NS_MEDIAWIKI == $this->mNamespace &&
***************
*** 1136,1142 ****
return $result;
}
! if( $wgUser->isAllowed('read') ) {
return true;
} else {
global $wgWhitelistRead;
--- 1140,1146 ----
return $result;
}
! if( $wgUser->isAllowed('read', $this) ) {
return true;
} else {
global $wgWhitelistRead;
***************
*** 1150,1165 ****
}
/** some pages are explicitly allowed */
! $name = $this->getPrefixedText();
! if( $wgWhitelistRead && in_array( $name, $wgWhitelistRead ) ) {
! return true;
! }
!
! # Compatibility with old settings
! if( $wgWhitelistRead && $this->getNamespace() == NS_MAIN ) {
! if( in_array( ':' . $name, $wgWhitelistRead ) ) {
return true;
}
}
}
return false;
--- 1154,1171 ----
}
/** some pages are explicitly allowed */
! if( is_array( $wgWhitelistRead )) {
! $name = $this->getPrefixedText();
! if( in_array( $name, $wgWhitelistRead ) ) {
return true;
}
+
+ # Compatibility with old settings
+ if( $this->getNamespace() == NS_MAIN ) {
+ if( in_array( ':' . $name, $wgWhitelistRead ) ) {
+ return true;
+ }
+ }
}
}
return false;
diff -r -c mediawiki-1.7.1/includes/User.php ../curwiki/includes/User.php
*** mediawiki-1.7.1/includes/User.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/User.php Thu Jul 13 13:51:10 2006
***************
*** 1237,1252 ****
/**
* Check if user is allowed to access a feature / make an action
* @param string $action Action to be checked (see $wgAvailableRights in Defines.php for possible actions).
* @return boolean True: action is allowed, False: action should not be allowed
*/
! function isAllowed($action='') {
if ( $action === '' )
// In the spirit of DWIM
return true;
$this->loadFromDatabase();
return in_array( $action , $this->mRights );
}
/**
* Load a skin if it doesn't exist or return it
--- 1237,1392 ----
/**
* Check if user is allowed to access a feature / make an action
* @param string $action Action to be checked (see $wgAvailableRights in Defines.php for possible actions).
+ * @param string $title Title of the article (so we can check if it's namespace is restricted to the user).
* @return boolean True: action is allowed, False: action should not be allowed
*/
! function isAllowed($action='',$title=NULL) {
! global $wgRestrictedNamespaces, $wgReadOnlyNSes;
if ( $action === '' )
// In the spirit of DWIM
return true;
$this->loadFromDatabase();
+ if( $title == NULL ) {
+ global $wgTitle;
+ $title = $wgTitle;
+ }
+ $ns = $title->getNamespace();
+
+ // If user wants to read a page, that page is in a read only namespace
+ // and the user has the 'roread' right, allow him to read it. If it has
+ // the 'roedit' right allow him to edit it.
+ if( is_array($wgReadOnlyNSes)) {
+ if( $action == 'read' && in_array($ns, $wgReadOnlyNSes) &&
+ in_array('roread', $this->mRights) && !$this->isBlocked() ) {
+ return true;
+ }
+ if( $action == 'edit' && !$title->isProtected() &&
+ in_array($ns, $wgReadOnlyNSes) && in_array('roedit', $this->mRights) && !$this->isBlocked()) {
+ return true;
+ }
+ }
+
+ // Prevent access to restricted namespaces if the user does not have all
+ // required rights.
+ if( !$this->canAccessNamespace($ns) ) {
+ return false;
+ }
+
+ // If we are in user's page, allow him to do everything...
+ if ( $action == 'edit' && ($ns == NS_USER_TALK || $ns == NS_USER) &&
+ $title->getText() == $this->getName() && !$this->isBlocked() && !$title->isProtected() ) {
+ return true;
+ }
+
+ if ( $action == 'protect' && ($ns == NS_USER_TALK || $ns == NS_USER) &&
+ $title->getText() == $this->getName() && !$this->isBlocked() ){
+ return true;
+ }
+
+ // If user wants to edit a talk page and has the talk right, allow him to do so...
+ if( $title->isTalkPage() && $action == 'edit' && in_array('talk', $this->mRights) &&
+ !$this->isBlocked() && !$title->isProtected() ){
+ return true;
+ }
+
+ // If user wants to leave a mesage on another's user talk page and that page is unprotected, allow him to do so...
+ if( $action == 'edit' && $ns == NS_USER_TALK && !$this->isBlocked() && !$title->isProtected() ){
+ return true;
+ }
+
+ // If user has the sedit right, allow him to edit pages in the restricted namespaces
+ // he has access.
+ if( is_array($wgRestrictedNamespaces) && array_key_exists($ns, $wgRestrictedNamespaces)
+ && $this->canAccessNamespace($ns) && !$this->isBlocked() ){
+ if( $action == 'edit' && in_array('sedit', $this->mRights) && !$title->isProtected() ) {
+ return true;
+ }
+
+ // If user has the sprotect right, allow him to edit pages in the in the restricted namespaces
+ // he has access.
+ if(($action == 'protect' || $action == 'unprotect') && in_array('sprotect', $this->mRights)) {
+ return true;
+ }
+
+ // If user has the sdelete right, allow him to edit pages in the in the restricted namespaces
+ // he has access.
+ if( !$title->isProtected() && ($action == 'delete' || $action == 'undelete') &&
+ (in_array('sdelete', $this->mRights)) ) {
+ return true;
+ }
+ }
+
+ //If the user wants to delete or undelete a page and it's blocked don't allow him to do so.
+ if( ($action == 'delete' || $action == 'undelete') && ($title->isProtected() || $this->isBlocked()) ){
+ return false;
+ }
+
+ //If the user wants to protect or unprotect a page and it's blocked don't allow him to do so.
+ if( ($action == 'protect' || $action == 'unprotect') && $this->isBlocked() ){
+ return false;
+ }
+
return in_array( $action , $this->mRights );
}
+
+ /**
+ * Check if user is allowed to access a given namespace
+ * @param string $namespace ID of the namespace that needs to be checked.
+ * @return boolean True: access is allowed, False: access is denied
+ */
+ function canAccessNamespace( $namespace='' ) {
+ global $wgRestrictedNamespaces;
+ $this->loadFromDatabase();
+ if( is_array( $wgRestrictedNamespaces )) {
+ if( array_key_exists( $namespace, $wgRestrictedNamespaces ) ) {
+ if( in_array($wgRestrictedNamespaces[$namespace], $this->mRights)){
+ return true;
+ }
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Get the restricted namespaces the user has access to (talk namespaces not included).
+ * @return string with the namespace names seperated by the "\n" character/
+ */
+ function getAllowedRNSes() {
+ global $wgRestrictedNamespaces;
+ $this->loadFromDatabase();
+ $names = NULL;
+ if( is_array( $wgRestrictedNamespaces ) ) {
+ foreach ($wgRestrictedNamespaces as $nsid => $ugroup) {
+ if( $this->canAccessNamespace($nsid) && !($nsid %2) ) {
+ $names .= Namespace::getCanonicalName($nsid)."\n";
+ }
+ }
+ }
+ return $names;
+ }
+
+ /**
+ * Get the main page title of each restricted namespace (talk namespaces not included)
+ * the user has access to.
+ * @return string: The titles seperated by the "\n" character.
+ */
+ function getRMainPages() {
+ global $wgRestrictedNamespaces;
+ $titles = NULL;
+ if( is_array( $wgRestrictedNamespaces ) ) {
+ $namespaces = $this->getAllowedRNSes();
+ $nsarray = explode("\n",$namespaces);
+ foreach ($nsarray as $index => $nsname) {
+ if($nsname != ""){
+ $titles .= "[[".$nsname.":".wfMsgForContent( 'mainpage' )."|".$nsname."]]"."<br/>\n";
+ }
+ }
+ }
+ return $titles;
+ }
+
/**
* Load a skin if it doesn't exist or return it
diff -r -c mediawiki-1.7.1/includes/Skin.php ../curwiki/includes/Skin.php
*** mediawiki-1.7.1/includes/Skin.php Thu Jul 13 12:48:25 2006
--- ../curwiki/includes/Skin.php Thu Jul 13 13:54:36 2006
***************
*** 1445,1450 ****
--- 1445,1451 ----
function buildSidebar() {
global $wgDBname, $parserMemc, $wgEnableSidebarCache;
global $wgLanguageCode, $wgContLanguageCode;
+ global $wgUser;
$fname = 'SkinTemplate::buildSidebar';
***************
*** 1490,1495 ****
--- 1491,1509 ----
} 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 );
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1467
Default Alt Text
RS.patch (39 KB)
Attached To
Mode
T3924: Restricted read access for subset of wiki
Attached
Detach File
Event Timeline
Log In to Comment