This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 910
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
the-djmaze
committed
Aug 20, 2024
1 parent
5987ccd
commit e5a176f
Showing
7 changed files
with
263 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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 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,58 @@ | ||
import { AbstractViewPopup } from 'Knoin/AbstractViews'; | ||
import { addObservablesTo } from 'External/ko'; | ||
import Remote from 'Remote/User/Fetch'; | ||
|
||
export class FolderACLPopupView extends AbstractViewPopup { | ||
constructor() { | ||
super('FolderACL'); | ||
addObservablesTo(this, { | ||
create: false, | ||
mine: false, | ||
folderName: '', | ||
identifier: '' | ||
}); | ||
this.rights = ko.observableArray(); | ||
} | ||
|
||
submitForm(/*form*/) { | ||
if (!this.mine()) { | ||
const rights = this.rights(); | ||
Remote.request('FolderSetACL', | ||
(iError, data) => { | ||
if (!iError && data.Result) { | ||
const acl = this.acl; | ||
if (!acl.identifier) { | ||
this.folder.ACL.push(acl); | ||
} | ||
acl.rights = rights; | ||
} | ||
}, { | ||
folder: this.folderName(), | ||
identifier: this.identifier(), | ||
rights: rights.join('') | ||
} | ||
); | ||
} | ||
this.close(); | ||
} | ||
|
||
beforeShow(folder, acl) { | ||
this.folder = folder; | ||
this.create(!acl.identifier()); | ||
this.mine(acl.mine()); | ||
this.acl = acl; | ||
/* | ||
this.ACLAllowed && Remote.request('FolderIdentifierRights', (iError, data) => { | ||
if (!iError && data.Result) { | ||
this.rights(data.Result.rights.split('')); | ||
} | ||
}, { | ||
folder: folder.fullName, | ||
identifier: acl.identifier | ||
}); | ||
*/ | ||
this.folderName(folder.fullName); | ||
this.identifier(acl.identifier()); | ||
this.rights(acl.rights()); | ||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -91,6 +91,7 @@ public function ACLAllow(string $sFolderName, string $command) : bool | |
private function FolderACLRequest(string $sFolderName, string $sCommand, array $aParams) : \MailSo\Imap\ResponseCollection | ||
{ | ||
if ($this->ACLAllow($sFolderName, $sCommand)) try { | ||
// \array_unshift($aParams, $this->EscapeFolderName($sFolderName)); | ||
return $this->SendRequestGetResponse($sCommand, $aParams); | ||
} catch (\Throwable $oException) { | ||
// Error in IMAP command $sCommand: ACLs disabled | ||
|
@@ -119,21 +120,29 @@ public function FolderDeleteACL(string $sFolderName, string $sIdentifier) : void | |
public function FolderGetACL(string $sFolderName) : array | ||
{ | ||
$aResult = array(); | ||
$oResponses = $this->FolderACLRequest($sFolderName, 'GETACL', array($this->EscapeFolderName($sFolderName))); | ||
foreach ($oResponses as $oResponse) { | ||
// * ACL INBOX.shared [email protected] akxeilprwtscd [email protected] akxeilprwtscd [email protected] lrwstipekxacd | ||
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType | ||
&& isset($oResponse->ResponseList[4]) | ||
&& 'ACL' === $oResponse->ResponseList[1] | ||
&& $sFolderName === $oResponse->ResponseList[2] | ||
) | ||
{ | ||
$c = \count($oResponse->ResponseList); | ||
for ($i = 3; $i < $c; $i += 2) { | ||
$aResult[] = new ACLResponse( | ||
$oResponse->ResponseList[$i], | ||
$oResponse->ResponseList[$i+1] | ||
); | ||
$response = $this->FolderMyRights($sFolderName); | ||
$aResult[] = $response; | ||
if ($response->hasRight('a')) { | ||
// Else error: "NOPERM You lack administrator privileges on this mailbox." | ||
$oResponses = $this->FolderACLRequest($sFolderName, 'GETACL', array($this->EscapeFolderName($sFolderName))); | ||
foreach ($oResponses as $oResponse) { | ||
// * ACL INBOX.shared [email protected] akxeilprwtscd [email protected] lrwstipekxacd | ||
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType | ||
&& isset($oResponse->ResponseList[4]) | ||
&& 'ACL' === $oResponse->ResponseList[1] | ||
&& $sFolderName === $oResponse->ResponseList[2] | ||
) | ||
{ | ||
$c = \count($oResponse->ResponseList); | ||
for ($i = 3; $i < $c; $i += 2) { | ||
$response = new ACLResponse( | ||
$oResponse->ResponseList[$i], | ||
$oResponse->ResponseList[$i+1] | ||
); | ||
if ($response->identifier() != $this->Settings->username) { | ||
$aResult[] = $response; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -163,19 +172,23 @@ public function FolderListRights(string $sFolderName, string $sIdentifier) : ?AC | |
return null; | ||
} | ||
|
||
public function FolderMyRights(string $sFolderName) : ?ACLResponse | ||
public function FolderMyRights(string $sFolderName) : ACLResponse | ||
{ | ||
$oResponses = $this->FolderACLRequest($sFolderName, 'MYRIGHTS', array($this->EscapeFolderName($sFolderName))); | ||
$rights = ''; | ||
foreach ($oResponses as $oResponse) { | ||
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType | ||
&& isset($oResponse->ResponseList[3]) | ||
&& 'MYRIGHTS' === $oResponse->ResponseList[1] | ||
&& $sFolderName === $oResponse->ResponseList[2] | ||
) | ||
{ | ||
return new ACLResponse('', $oResponse->ResponseList[3]); | ||
$rights = $oResponse->ResponseList[3]; | ||
break; | ||
} | ||
} | ||
return null; | ||
$response = new ACLResponse($this->Settings->username, $rights); | ||
$response->mine = true; | ||
return $response; | ||
} | ||
} |
This file contains 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 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 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.