Manual:フック/UserGetRights

From mediawiki.org
This page is a translated version of the page Manual:Hooks/UserGetRights and the translation is 28% complete.
UserGetRights
バージョン 1.11.0 から利用可能
Dynamically adds to or removes from a user the rights implied by their group membership
関数の定義:
public static function onUserGetRights( User $user, array &$aRights ) { ... }
フックのアタッチ: extension.json 内:
{
	"Hooks": {
		"UserGetRights": "MediaWiki\\Extension\\MyExtension\\Hooks::onUserGetRights"
	}
}
呼び出し元: ファイル: Permissions/PermissionManager.php
関数: getUserPermissions
インターフェイス: UserGetRightsHook.php

フックの設定についての詳細情報は Manual:フック を参照してください。
このフックを使用する拡張機能の例については、Category:UserGetRights extensions/ja を参照してください。

詳細

  • $user - User オブジェクト
  • $aRights - 利用者権限の配列

Use cases

The UserGetRights hook permits the implementation of a user rights scheme along side of MediaWiki's built-in group-based permissions architecture. It can be used to create extensions that

  • implement a hierarchical group system where groups can inherit rights from a collection of groups.
  • implement an exclude rights rule - users are associated with groups whose rights the do not have.
  • add or exclude rights associated with a user rather than a group
  • define context based rights - e.g. the same user might have different rights depending on whether they are accessing the wiki via :localhost:, via a VPN, or via the public internet.
  • any other scheme available to the programmer's imagination

背景

MediaWiki's built-in permissions architecture uses group-based permissions. Users are assigned to groups; groups are assigned rights; users inherit rights from every group to which they are assigned. This hook can be used to override or supplement the core permissions architecture.

使用法

Hooks modify the rights available to the user by adding or removing elements to $aRights. The hook should always return true so that other functions attached to this hook will have a chance to run.

Removing rights with this hook can be problematic as there is no guarantee another hook handler won't re-add them. The UserGetRightsRemove hook, called immediately after UserGetRights, can be used for that.

関連項目