Skip to content

Commit 5e587f3

Browse files
committedJul 17, 2023
changes
1 parent 8696b97 commit 5e587f3

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed
 

‎resources/lib/UnityPerms.php

+8
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ public function checkGrantRole($uid, $group, $role)
7575

7676
$user_role = $this->SQL->getRole($uid, $group);
7777

78+
if ($this->SQL->hasPerm($user_role, 'unity.admin_no_grant') && $role == 'unity.admin') {
79+
return false;
80+
}
81+
7882
if ($this->SQL->hasPerm($user_role, 'unity.admin') || $this->SQL->hasPerm($user_role, 'unity.admin_no_grant')) {
7983
return true;
8084
}
@@ -104,6 +108,10 @@ public function checkRevokeRole($uid, $group, $role)
104108

105109
$user_role = $this->SQL->getRole($uid, $group);
106110

111+
if ($this->SQL->hasPerm($user_role, 'unity.admin_no_grant') && $role == 'unity.admin') {
112+
return false;
113+
}
114+
107115
if ($this->SQL->hasPerm($user_role, 'unity.admin') || $this->SQL->hasPerm($user_role, 'unity.admin_no_grant')) {
108116
return true;
109117
}

‎resources/lib/UnityUser.php

+16-9
Original file line numberDiff line numberDiff line change
@@ -674,19 +674,26 @@ public function hasRequestedAccountDeletion()
674674

675675
/**
676676
* Checks whether a user is in a group or not
677+
* @param string $uid uid of the user
678+
* @param string or object $group group to check
679+
* @return boolean true if user is in group, false if not
677680
*/
678681

679682
public function isInGroup($uid, $group)
680683
{
681-
$group = new UnityGroup(
682-
$group,
683-
$this->LDAP,
684-
$this->SQL,
685-
$this->MAILER,
686-
$this->REDIS,
687-
$this->WEBHOOK
688-
);
684+
if (gettype($group) == "string") {
685+
$group_checked = new UnityGroup(
686+
$group,
687+
$this->LDAP,
688+
$this->SQL,
689+
$this->MAILER,
690+
$this->REDIS,
691+
$this->WEBHOOK
692+
);
693+
} else {
694+
$group_checked = $group;
695+
}
689696

690-
return in_array($uid, $group->getGroupMemberUIDs());
697+
return in_array($uid, $group_checked->getGroupMemberUIDs());
691698
}
692699
}

0 commit comments

Comments
 (0)