Jump to content
MediaWiki

Extension:PublicCat

From mediawiki.org
Revision as of 01:20, 5 May 2019 by Shirayuki (talk | contribs) (translation tweaks)
MediaWiki was not designed to support per-page or partial-page access restrictions. If you require this level of control, you are strongly advised to use a content management system that supports it natively.

Patches or third-party extensions claiming to provide access control, when in use with MediaWiki, may not work in all cases, potentially exposing confidential data. Use them at your own risk. Neither the MediaWiki developers nor the Wikimedia Foundation are responsible for any data leaks that may result. This message is added to all extensions of this nature and may not reflect the actual security status of this extension.

For more information, see Security issues with authorization extensions .
MediaWiki extensions manual
PublicCat
Release status: stable
Implementation User rights
Description Divides wiki into private and public by domain name, but allows unrestricted access to articles in a public category.
Author(s) User:Nad
Latest version 1.0.4 (2008年02月12日)
MediaWiki all versions
Licence No licence specified
Download PublicCat.php

A lot of the MediaWiki's we maintain at OrganicDesign:OrganicDesign are mainly for internal document management use for intranets. But often it's convenient to have a single category available publically which looks like a normal website (having none of the usual wiki links for editing and history etc).

This extension divides the site into public and private based on the domain that the requests originate from (we use www.domain for public and wiki.domain for private.

The private domain has all the normal wiki functionality, but is completely inaccessible unless logged in. If not logged in then all requests to the private wiki domain will take you to the login page.

Requests to the public domain results in the usual content but only articles which are members of a specified public category are available and all other requests will result in a 404 not found error. Also only view, raw or render actions are allowed from the public domain, all other actions will be changed to view.

The removal of the wiki content-actions and personal links etc is not handled by this extension, we use Extension:WikiSkin to render the skin aspects conditionally.

Installation

The extension is a single script which you can obtain from OrganicDesign:Extension:PublicCat.php and save into your extensions directory and include in your LocalSettings.php file as in the following example,

include("$IP/extensions/PublicCat.php");

Usage

A useful wikitext expression is shown below which allows content to be displayed only if the user is accessing the wiki from the private domain.

{{#if:{{#pos:{{SERVER}}|wiki}}|Private content here}}

Configuration

Configuration of this extension is done via two global variables which can be set in your LocalSettings file after the include of the PublicCat.php script. NOTE: to change the default values of these variables, you must set them before the include line.

Variable Default value Meaning
$wgPublicCat Public This is the name of the category which articles must be a member of to be accessible from the public site. Any requests from the public domain for article which are not in this category will result in a 404 not found error.
$wgPublicCatPrivatePattern /^wiki\\./ This is a regular expression which will be matched against the domain name of the requested URL to determine if the request is private or public. The default value specifies that if the domain starts with "wiki." then it is private, anything else is considered to be a public site request.

Changes

  • 1.0.4 (2008年02月12日): 1.0.4 - bug fix - couldn't change defaults
  • 1.0.3 (2007年09月22日): use $wgOut->disable() instead of die
  • 1.0.2 (2007年09月14日): fixed warning messages in MW1.11

AltStyle によって変換されたページ (->オリジナル) /