|
1
|
|
|
<?php |
|
2
|
|
|
/****************************************************************************** |
|
3
|
|
|
* Wikipedia Account Creation Assistance tool * |
|
4
|
|
|
* * |
|
5
|
|
|
* All code in this file is released into the public domain by the ACC * |
|
6
|
|
|
* Development Team. Please see team.json for a list of contributors. * |
|
7
|
|
|
******************************************************************************/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Waca\Fragments; |
|
10
|
|
|
|
|
11
|
|
|
use Waca\Pages\PageBan; |
|
12
|
|
|
use Waca\Pages\PageEmailManagement; |
|
13
|
|
|
use Waca\Pages\PageLog; |
|
14
|
|
|
use Waca\Pages\PageMain; |
|
15
|
|
|
use Waca\Pages\PageSearch; |
|
16
|
|
|
use Waca\Pages\PageSiteNotice; |
|
17
|
|
|
use Waca\Pages\PageUserManagement; |
|
18
|
|
|
use Waca\Pages\PageViewRequest; |
|
19
|
|
|
use Waca\Pages\PageWelcomeTemplateManagement; |
|
20
|
|
|
use Waca\Pages\Statistics\StatsMain; |
|
21
|
|
|
use Waca\Pages\Statistics\StatsUsers; |
|
22
|
|
|
use Waca\Security\RoleConfiguration; |
|
23
|
|
|
use Waca\Security\SecurityManager; |
|
24
|
|
|
|
|
25
|
|
|
trait NavigationMenuAccessControl |
|
26
|
|
|
{ |
|
27
|
|
|
protected abstract function assign($name, $value); |
|
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @return SecurityManager |
|
31
|
|
|
*/ |
|
32
|
|
|
protected abstract function getSecurityManager(); |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param $currentUser |
|
36
|
|
|
*/ |
|
37
|
|
|
protected function setupNavMenuAccess($currentUser) |
|
38
|
|
|
{ |
|
39
|
|
|
$this->assign('nav__canRequests', $this->getSecurityManager() |
|
40
|
|
|
->allows(PageMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
41
|
|
|
|
|
42
|
|
|
$this->assign('nav__canLogs', $this->getSecurityManager() |
|
43
|
|
|
->allows(PageLog::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
44
|
|
|
$this->assign('nav__canUsers', $this->getSecurityManager() |
|
45
|
|
|
->allows(StatsUsers::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
46
|
|
|
$this->assign('nav__canSearch', $this->getSecurityManager() |
|
47
|
|
|
->allows(PageSearch::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
48
|
|
|
$this->assign('nav__canStats', $this->getSecurityManager() |
|
49
|
|
|
->allows(StatsMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
50
|
|
|
|
|
51
|
|
|
$this->assign('nav__canBan', $this->getSecurityManager() |
|
52
|
|
|
->allows(PageBan::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
53
|
|
|
$this->assign('nav__canEmailMgmt', $this->getSecurityManager() |
|
54
|
|
|
->allows(PageEmailManagement::class, RoleConfiguration::MAIN, |
|
55
|
|
|
$currentUser) === SecurityManager::ALLOWED); |
|
56
|
|
|
$this->assign('nav__canWelcomeMgmt', $this->getSecurityManager() |
|
57
|
|
|
->allows(PageWelcomeTemplateManagement::class, RoleConfiguration::MAIN, |
|
58
|
|
|
$currentUser) === SecurityManager::ALLOWED); |
|
59
|
|
|
$this->assign('nav__canSiteNoticeMgmt', $this->getSecurityManager() |
|
60
|
|
|
->allows(PageSiteNotice::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
61
|
|
|
$this->assign('nav__canUserMgmt', $this->getSecurityManager() |
|
62
|
|
|
->allows(PageUserManagement::class, RoleConfiguration::MAIN, |
|
63
|
|
|
$currentUser) === SecurityManager::ALLOWED); |
|
64
|
|
|
|
|
65
|
|
|
$this->assign('nav__canViewRequest', $this->getSecurityManager() |
|
66
|
|
|
->allows(PageViewRequest::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
67
|
|
|
} |
|
68
|
|
|
} |
For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a
@returndoc comment to communicate to implementors of these methods what they are expected to return.