forked from mfreiholz/iF.SVNAdmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
userview.php
145 lines (134 loc) · 4.69 KB
/
userview.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
<?php
/**
* iF.SVNAdmin
* Copyright (c) 2010 by Manuel Freiholz
* http://www.insanefactory.com/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.
*/
include("include/config.inc.php");
$appEngine->checkUserAuthentication(true, ACL_MOD_USER, ACL_ACTION_VIEW);
if( !$appEngine->isGroupViewActive() && !$appEngine->isAccessPathViewActive() )
{
$appEngine->forwardInvalidModule( true );
}
$appTR->loadModule("userview");
$appTR->loadModule("roles");
// Action handling.
if (check_request_var('unassign'))
{
$appEngine->handleAction('unassign_usergroup');
}
else if (check_request_var('unassign_permission'))
{
$appEngine->handleAction('unassign_permission');
}
else if (check_request_var('assign_role'))
{
$appEngine->handleAction('assign_userrole');
}
else if (check_request_var('unassign_role'))
{
$appEngine->handleAction('unassign_userrole');
}
else if(check_request_var('unassign_projectmanager'))
{
$appEngine->handleAction('unassign_projectmanager');
}
else if(check_request_var('assign_usergroup'))
{
$appEngine->handleAction('assign_usertogroup');
}
// Get required variables.
$usernameEnc = get_request_var('username');
$username = rawurldecode( $usernameEnc );
// The current selected user.
$oUser = new \svnadmin\core\entities\User;
$oUser->id = $username;
$oUser->name = $username;
// Roles of the current user.
$allroles=null;
$rolesOfUser=null;
if ($appEngine->isAclManagerActive() && $appEngine->checkUserAuthentication(false, ACL_MOD_ROLE, ACL_ACTION_VIEW))
{
$rolesOfUser = $appEngine->getAclManager()->getRolesOfUser($oUser);
// Get all roles to assign the user to a new role.
if ($appEngine->checkUserAuthentication(false, ACL_MOD_ROLE, ACL_ACTION_ASSIGN))
{
// All existing roles.
$allroles = $appEngine->getAclManager()->getRoles();
usort($allroles, array('\svnadmin\core\entities\Role',"compare"));
// Remove all roles from array, which are already assigned to the user.
$rolesOfUserLen = count($rolesOfUser);
for ($i=0; $i<$rolesOfUserLen; $i++)
{
if_array_remove_object_element($allroles, $rolesOfUser[$i], "name");
}
$allroles = array_values($allroles); // This step is important, to recreate the indexes.
}
}
// Groups of the user.
$groups=null;
$allgroups=null;
if ($appEngine->isGroupViewActive() && $appEngine->checkUserAuthentication(false, ACL_MOD_GROUP, ACL_ACTION_VIEW))
{
$groups = $appEngine->getGroupViewProvider()->getGroupsOfUser( $oUser );
usort( $groups, array('\svnadmin\core\entities\Group',"compare") );
// Get all existing groups and remove the groups in which the user is already in.
if ($appEngine->isGroupViewActive() && $appEngine->checkUserAuthentication(false, ACL_MOD_GROUP, ACL_ACTION_ASSIGN))
{
$allgroups = $appEngine->getGroupViewProvider()->getGroups();
usort($allgroups, array('\svnadmin\core\entities\Group',"compare"));
$len = count($groups);
for ($i=0; $i<$len; $i++)
{
if_array_remove_object_element($allgroups, $groups[$i], "name");
}
$allgroups = array_values($allgroups);
}
}
// Access-Path permissions of the current group.
$paths=null;
if ($appEngine->isAccessPathViewActive() && $appEngine->checkUserAuthentication(false, ACL_MOD_ACCESSPATH, ACL_ACTION_VIEW))
{
$paths = $appEngine->getAccessPathViewProvider()->getPathsOfUser( $oUser );
usort( $paths, array('\svnadmin\core\entities\AccessPath',"compare") );
}
// Check whether the user is an project administrator.
$restricted_paths=null;
$isprojectmanager=false;
if ($appEngine->isAuthenticationActive())
{
$uname = $username;
if ($appEngine->getAclManager()->isUserAccessPathManager($uname))
{
$restricted_paths = $appEngine->getAclManager()->getAccessPathsOfUser($uname);
if (count($restricted_paths) > 0)
{
usort($restricted_paths, array('\svnadmin\core\entities\AccessPath',"compare"));
$isprojectmanager=true;
}
}
}
SetValue("RoleList", $rolesOfUser);
SetValue("RoleListAll", $allroles);
SetValue("GroupList", $groups);
SetValue("GroupListAll", $allgroups);
SetValue("PathList", $paths);
SetValue("RestrictedPathList", $restricted_paths);
SetValue("ProjectManager", $isprojectmanager);
SetValue("Username", $username);
SetValue("UsernameEncoded", rawurlencode($username));
ProcessTemplate("user/userview.html.php");
?>