-
Notifications
You must be signed in to change notification settings - Fork 11
remove duplicated code from UnityGroup/UnityOrg #393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d152bc3
remove duplicated code from UnityGroup/UnityOrg
simonLeary42 6a1b956
change function names
simonLeary42 b97ff20
require
simonLeary42 a26cad7
keep base class in this repo
simonLeary42 216db6f
add comment
simonLeary42 7d41fbf
reorder autoload
simonLeary42 101de31
construct PosixGroup
simonLeary42 ab87238
fix attributes
simonLeary42 42c7a08
fix premature access
simonLeary42 0da224d
add batch member add/rm functions
simonLeary42 ece216f
remove $gid from PosixGroup
simonLeary42 fc32696
mermber -> member
simonLeary42 8cd8026
forgot to set attribute
simonLeary42 a28ff42
fix function name
simonLeary42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| <?php | ||
|
|
||
| namespace UnityWebPortal\lib; | ||
|
|
||
| use PHPOpenLDAPer\LDAPEntry; | ||
| use \Exception; | ||
|
|
||
| /* | ||
| does not extend LDAPEntry because UnityGroup extends this and I don't want UnityGroup | ||
| to extend LDAPEntry because the functions from LDAPEntry should not be exposed there | ||
| */ | ||
| class PosixGroup | ||
| { | ||
| protected LDAPEntry $entry; | ||
|
|
||
| public function __construct(LDAPEntry $entry) | ||
| { | ||
| $this->entry = $entry; | ||
| } | ||
|
|
||
| public function getDN(): string | ||
| { | ||
| return $this->entry->getDN(); | ||
| } | ||
|
|
||
| public function equals(PosixGroup $other_group): bool | ||
| { | ||
| if (!is_a($other_group, self::class)) { | ||
| throw new Exception( | ||
| "Unable to check equality because the parameter is not a " . | ||
| self::class . | ||
| " object", | ||
| ); | ||
| } | ||
| return $this->getDN() == $other_group->getDN(); | ||
| } | ||
|
|
||
| public function exists(): bool | ||
| { | ||
| return $this->entry->exists(); | ||
| } | ||
|
|
||
| public function getMemberUIDs(): array | ||
| { | ||
| $members = $this->entry->getAttribute("memberuid"); | ||
| sort($members); | ||
| return $members; | ||
| } | ||
|
|
||
| public function addMemberUID(string $uid): void | ||
| { | ||
| $this->entry->appendAttribute("memberuid", $uid); | ||
| $this->entry->write(); | ||
| } | ||
|
|
||
| public function addMemberUIDs(array $uids): void | ||
| { | ||
| foreach ($uids as $uid) { | ||
| $this->entry->appendAttribute("memberuid", $uid); | ||
| } | ||
| $this->entry->write(); | ||
| } | ||
|
|
||
| public function removeMemberUID(string $uid): void | ||
| { | ||
| $this->entry->removeAttributeEntryByValue("memberuid", $uid); | ||
| $this->entry->write(); | ||
| } | ||
|
|
||
| public function removeMemberUIDs(array $uids): void | ||
| { | ||
| foreach ($uids as $uid) { | ||
| $this->entry->removeAttributeEntryByValue("memberuid", $uid); | ||
| } | ||
| $this->entry->write(); | ||
| } | ||
|
|
||
| public function mermberUIDExists(string $uid): bool | ||
| { | ||
| return in_array($uid, $this->getMemberUIDs()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.