-
Notifications
You must be signed in to change notification settings - Fork 6
/
Model.php
165 lines (138 loc) · 4.04 KB
/
Model.php
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
/**
* Matomo - free/libre analytics platform
*
* @link http://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\GroupPermissions;
use Piwik\Plugins\GroupPermissions\Dao\Group;
use Piwik\Plugins\GroupPermissions\Dao\GroupPermission;
use Piwik\Plugins\GroupPermissions\Dao\GroupUser;
use Piwik\Plugins\GroupPermissions\Dao\MultiTable;
class Model
{
public function install()
{
$group = new Group();
$group->install();
$permission = new GroupPermission();
$permission->install();
$user = new GroupUser();
$user->install();
}
public function uninstall()
{
$group = new Group();
$group->uninstall();
$permission = new GroupPermission();
$permission->uninstall();
$user = new GroupUser();
$user->uninstall();
}
// Group
public function createGroup($name)
{
$group = new Group();
return $group->createGroup($name);
}
public function getAllGroups()
{
$group = new Group();
return $group->getAllGroups();
}
public function getGroupWithId($idGroup)
{
$group = new Group();
return $group->getGroupWithId($idGroup);
}
public function getGroupWithName($name)
{
$group = new Group();
return $group->getGroupWithName($name);
}
public function renameGroup($idGroup, $newName)
{
$group = new Group();
return $group->renameGroup($idGroup, $newName);
}
public function deleteGroup($idGroup)
{
$group = new Group();
return $group->deleteGroup($idGroup);
}
// GroupUser
public function addUserToGroup($idGroup, $login)
{
$user = new GroupUser();
return $user->addUserToGroup($idGroup, $login);
}
public function getMembersOfGroup($idGroup)
{
$user = new GroupUser();
return $user->getMembersOfGroup($idGroup);
}
public function isUserInGroup($login, $idGroup)
{
$user = new GroupUser();
return $user->isUserInGroup($login, $idGroup);
}
public function getGroupsOfUser($login)
{
$user = new GroupUser();
return $user->getGroupsOfUser($login);
}
public function removeUserFromGroup($idGroup, $login)
{
$user = new GroupUser();
return $user->removeUserFromGroup($idGroup, $login);
}
public function removeAllUsersOfGroup($idGroup)
{
$user = new GroupUser();
return $user->removeAllUsersOfGroup($idGroup);
}
public function removeUserFromAllGroups($login)
{
$user = new GroupUser();
return $user->removeUserFromAllGroups($login);
}
// GroupPermission
public function createPermission($idGroup, $idSite, $access)
{
$permission = new GroupPermission();
return $permission->createPermission($idGroup, $idSite, $access);
}
public function getPermissionsOfGroup($idGroup)
{
$permission = new GroupPermission();
return $permission->getPermissionsOfGroup($idGroup);
}
public function getPermissionsOfSite($idSite)
{
$permission = new GroupPermission();
return $permission->getPermissionsOfSite($idSite);
}
public function removePermission($idGroup, $idSite)
{
$permission = new GroupPermission();
return $permission->removePermission($idGroup, $idSite);
}
public function removeAllPermissionsOfGroup($idGroup)
{
$permission = new GroupPermission();
return $permission->removeAllPermissionsOfGroup($idGroup);
}
public function removeAllPermissionsForSite($idSite)
{
$permission = new GroupPermission();
return $permission->removeAllPermissionsForSite($idSite);
}
// MultiTable
public function getPermissionsOfUser($login)
{
$multiTable = new MultiTable();
return $multiTable->getPermissionsOfUser($login);
}
}