File tree Expand file tree Collapse file tree 6 files changed +72
-5
lines changed
Expand file tree Collapse file tree 6 files changed +72
-5
lines changed Original file line number Diff line number Diff line change 1010// submodule
1111require_once __DIR__ . "/lib/phpopenldaper/src/PHPOpenLDAPer/LDAPEntry.php " ;
1212require_once __DIR__ . "/lib/phpopenldaper/src/PHPOpenLDAPer/LDAPConn.php " ;
13- require_once __DIR__ . "/lib/phpopenldaper/src/PHPOpenLDAPer/PosixGroup.php " ;
1413
1514// load libs
1615require_once __DIR__ . "/lib/UnityLDAP.php " ;
2524require_once __DIR__ . "/lib/UnityWebhook.php " ;
2625require_once __DIR__ . "/lib/UnityGithub.php " ;
2726require_once __DIR__ . "/lib/utils.php " ;
27+ require_once __DIR__ . "/lib/PosixGroup.php " ;
2828require_once __DIR__ . "/lib/exceptions/NoDieException.php " ;
2929require_once __DIR__ . "/lib/exceptions/SSOException.php " ;
3030require_once __DIR__ . "/lib/exceptions/ArrayKeyException.php " ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace UnityWebPortal \lib ;
4+
5+ use PHPOpenLDAPer \LDAPEntry ;
6+ use \Exception ;
7+
8+ class PosixGroup
9+ {
10+ private LDAPEntry $ entry ;
11+ private string $ gid ;
12+
13+ public function __construct (LDAPEntry $ entry , string $ gid )
14+ {
15+ $ this ->gid = $ gid ;
16+ $ this ->entry = $ entry ;
17+ }
18+
19+ public function getDN (): string
20+ {
21+ return $ this ->entry ->getDN ();
22+ }
23+
24+ public function equals (PosixGroup $ other_group ): bool
25+ {
26+ if (!is_a ($ other_group , self ::class)) {
27+ throw new Exception (
28+ "Unable to check equality because the parameter is not a " .
29+ self ::class .
30+ " object " ,
31+ );
32+ }
33+ return $ this ->getDN () == $ other_group ->getDN ();
34+ }
35+
36+ public function __toString (): string
37+ {
38+ return $ this ->gid ;
39+ }
40+
41+ public function exists (): bool
42+ {
43+ return $ this ->entry ->exists ();
44+ }
45+
46+ public function getMemberUIDs (): array
47+ {
48+ $ members = $ this ->entry ->getAttribute ("memberuid " );
49+ sort ($ members );
50+ return $ members ;
51+ }
52+
53+ public function addMemberUID (string $ uid ): void
54+ {
55+ $ this ->entry ->appendAttribute ("memberuid " , $ uid );
56+ $ this ->entry ->write ();
57+ }
58+
59+ public function removeMemberUID (string $ uid ): void
60+ {
61+ $ this ->entry ->removeAttributeEntryByValue ("memberuid " , $ uid );
62+ $ this ->entry ->write ();
63+ }
64+
65+ public function mermberUIDExists (string $ uid ): bool
66+ {
67+ return in_array ($ uid , $ this ->getMemberUIDs ());
68+ }
69+ }
Original file line number Diff line number Diff line change 44use PHPOpenLDAPer \LDAPEntry ;
55
66use Exception ;
7- use PHPOpenLDAPer \PosixGroup ;
87
98/**
109 * Class that represents a single PI group in the Unity Cluster.
Original file line number Diff line number Diff line change 22
33namespace UnityWebPortal \lib ;
44use PHPOpenLDAPer \LDAPEntry ;
5- use PHPOpenLDAPer \PosixGroup ;
65
76class UnityOrg extends PosixGroup
87{
Original file line number Diff line number Diff line change 22// submodule
33require_once __DIR__ . "/../resources/lib/phpopenldaper/src/PHPOpenLDAPer/LDAPEntry.php " ;
44require_once __DIR__ . "/../resources/lib/phpopenldaper/src/PHPOpenLDAPer/LDAPConn.php " ;
5- require_once __DIR__ . "/../resources/lib/phpopenldaper/src/PHPOpenLDAPer/PosixGroup.php " ;
65
76require_once __DIR__ . "/../resources/lib/UnityLDAP.php " ;
87require_once __DIR__ . "/../resources/lib/UnityUser.php " ;
1615require_once __DIR__ . "/../resources/lib/UnityWebhook.php " ;
1716require_once __DIR__ . "/../resources/lib/UnityGithub.php " ;
1817require_once __DIR__ . "/../resources/lib/utils.php " ;
18+ require_once __DIR__ . "/../resources/lib/PosixGroup.php " ;
1919require_once __DIR__ . "/../resources/lib/exceptions/NoDieException.php " ;
2020require_once __DIR__ . "/../resources/lib/exceptions/SSOException.php " ;
2121require_once __DIR__ . "/../resources/lib/exceptions/ArrayKeyException.php " ;
You can’t perform that action at this time.
0 commit comments