}
}
- /**
- * @deprecated
- */
- function getURL() {
- die( 'Call to obsolete obsolete function Title::getURL()' );
- }
-
/**
* Get a URL with no fragment or server name
* @param string $query an optional query string; if not specified,
if ( $query == '-' ) {
$query = '';
}
- if ( $wgScript != '' ) {
- $url = "{$wgScript}?title={$dbkey}&{$query}";
- } else {
- # Top level wiki
- $url = "/{$dbkey}?{$query}";
- }
+ $url = "{$wgScript}?title={$dbkey}&{$query}";
}
return $url;
}
*/
function userCanEdit() {
global $wgUser;
- if ( -1 == $this->mNamespace ) { return false; }
- if ( NS_MEDIAWIKI == $this->mNamespace && !$wgUser->isSysop() ) { return false; }
- # if ( 0 == $this->getArticleID() ) { return false; }
- if ( $this->mDbkeyform == '_' ) { return false; }
+ if( NS_SPECIAL == $this->mNamespace ) {
+ return false;
+ }
+ if( NS_MEDIAWIKI == $this->mNamespace &&
+ !$wgUser->isAllowed('editinterface') ) {
+ return false;
+ }
+ if( $this->mDbkeyform == '_' ) {
+ # FIXME: Is this necessary? Shouldn't be allowed anyway...
+ return false;
+ }
+
# protect global styles and js
if ( NS_MEDIAWIKI == $this->mNamespace
- && preg_match("/\\.(css|js)$/", $this->mTextform )
- && !$wgUser->isSysop() )
- { return false; }
- //if ( $this->isCssJsSubpage() and !$this->userCanEditCssJsSubpage() ) { return false; }
+ && preg_match("/\\.(css|js)$/", $this->mTextform )
+ && !$wgUser->isAllowed('editinterface') ) {
+ return false;
+ }
+
# protect css/js subpages of user pages
# XXX: this might be better using restrictions
# XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssJsSubpage() from working
- if( Namespace::getUser() == $this->mNamespace
- and preg_match("/\\.(css|js)$/", $this->mTextform )
- and !$wgUser->isSysop()
- and !preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) )
- { return false; }
- $ur = $wgUser->getRights();
- foreach ( $this->getRestrictions() as $r ) {
- if ( '' != $r && ( ! in_array( $r, $ur ) ) ) {
+ if( NS_USER == $this->mNamespace
+ && preg_match("/\\.(css|js)$/", $this->mTextform )
+ && !$wgUser->isAllowed('editinterface')
+ && !preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) ) {
+ return false;
+ }
+
+ foreach( $this->getRestrictions() as $right ) {
+ if( '' != $right && !$wgUser->isAllowed( $right ) ) {
return false;
}
}
*/
function userCanRead() {
global $wgUser;
- global $wgWhitelistRead;
- if( 0 != $wgUser->getID() ) return true;
- if( !is_array( $wgWhitelistRead ) ) return true;
-
- $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;
+ if( $wgUser->isAllowed('read') ) {
+ return true;
+ } else {
+ global $wgWhitelistRead;
+
+ /** If anon users can create an account,
+ they need to reach the login page first! */
+ if( $wgUser->isAllowed( 'createaccount' )
+ && $this->mId == NS_SPECIAL
+ && $this->getText() == 'Userlogin' ) {
+ return true;
+ }
+
+ /** some pages are explicitly allowed */
+ $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;
}
*/
function userCanEditCssJsSubpage() {
global $wgUser;
- return ( $wgUser->isSysop() or preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) );
+ return ( $wgUser->isAllowed('editinterface') or preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) );
}
/**
$sk =& $wgUser->getSkin();
$parents = array();
$dbr =& wfGetDB( DB_SLAVE );
- $cur = $dbr->tableName( 'cur' );
$categorylinks = $dbr->tableName( 'categorylinks' );
# NEW SQL
- $sql = "SELECT * FROM categorylinks"
+ $sql = "SELECT * FROM $categorylinks"
." WHERE cl_from='$titlekey'"
." AND cl_from <> '0'"
." ORDER BY cl_sortkey";
}
/**
- * Go through all parent categories of this Title
+ * Get a tree of parent categories
+ * @param array $children an array with the children in the keys, to check for circular refs
* @return array
* @access public
*/
- function getCategorieBrowser() {
+ function getParentCategoryTree( $children = array() ) {
$parents = $this->getParentCategories();
if($parents != '') {
foreach($parents as $parent => $current)
{
- $nt = Title::newFromText($parent);
- $stack[$parent] = $nt->getCategorieBrowser();
+ if ( array_key_exists( $parent, $children ) ) {
+ # Circular reference
+ $stack[$parent] = array();
+ } else {
+ $nt = Title::newFromText($parent);
+ $stack[$parent] = $nt->getParentCategoryTree( $children + array($parent => 1) );
+ }
}
return $stack;
} else {