forked from enterprisemediawiki/TalkRight
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTalkRight.class.php
More file actions
28 lines (27 loc) · 925 Bytes
/
TalkRight.class.php
File metadata and controls
28 lines (27 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
class TalkRight
{
/**
* Dynamically adjust user rights
* Grant 'edit' right if the user has 'talk' permission and is trying to edit a talk page.
* @param User $user User object
* @param array &$rights Array of rights
*/
public static function onUserGetRights(User $user, array &$rights)
{
$title = RequestContext::getMain()->getTitle();
if (($title && $title->getSubjectPage()->exists() && $title->isTalkPage()) ||
($title->getText() === $user->getName() &&
((in_array($title->getNamespace(), [NS_USER, NS_USER_TALK]))))
) {
if (in_array('talk', $rights)) {
if (!in_array('edit', $rights)) {
$rights[] = 'edit';
}
if (!in_array('createpage', $rights)) {
$rights[] = 'createpage';
}
}
}
}
}