/
UserInfoResponse.php
51 lines (42 loc) · 1.23 KB
/
UserInfoResponse.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
<?php
namespace Concrete\Core\Permission\Response;
use Concrete\Core\User\User;
use Concrete\Core\Support\Facade\Application;
use Group;
use PermissionKey;
use Permissions;
class UserInfoResponse extends Response
{
public function canViewUser()
{
$ui = $this->getPermissionObject();
$u = $ui->getUserObject();
if (!$u->isRegistered()) {
return true;
}
$groups = $u->getUserGroups();
// note, this will require users to have access to search
// "registered users" explicitly
foreach ($groups as $gID => $gName) {
$g = Group::getByID($gID);
if (is_object($g)) {
$gp = new Permissions($g);
if ($gp->canSearchUsersInGroup()) {
return true;
}
}
}
return false;
}
public function canEditUser()
{
$app = Application::getFacadeApplication();
$ui = $this->getPermissionObject();
$u = $app->make(User::class);
if ($ui->getUserID() == USER_SUPER_ID && !$u->isSuperUser()) {
return false;
}
$pk = PermissionKey::getByHandle('edit_user_properties');
return $pk->validate();
}
}