From 935cf28b35003d01d07b85be2e55723bd49dbac8 Mon Sep 17 00:00:00 2001 From: Sascha Egerer Date: Sun, 13 Jan 2019 15:05:34 +0100 Subject: [PATCH 1/7] Add ext-json to composer require --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 57ebf64..63373ac 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ } ], "require": { + "ext-json": "*", "php": ">=7.0.0", "dkd/enumeration": "~0.1", "dkd/php-populate": "^1", From 0ccc1977a30eb041f227496d12938b0f4fc04013 Mon Sep 17 00:00:00 2001 From: Sascha Egerer Date: Sun, 13 Jan 2019 15:05:59 +0100 Subject: [PATCH 2/7] [CLEANUP] Fix invalid php-doc return annotation --- src/DataObjects/Folder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataObjects/Folder.php b/src/DataObjects/Folder.php index 71d3914..d5632c2 100644 --- a/src/DataObjects/Folder.php +++ b/src/DataObjects/Folder.php @@ -355,7 +355,7 @@ public function getChildren(OperationContextInterface $context = null) * * @param integer $depth * @param OperationContextInterface|null $context - * @return TreeInterface A tree that contains FileableCmisObject objects + * @return TreeInterface[] A tree that contains FileableCmisObject objects * @see FileableCmisObject FileableCmisObject contained in returned TreeInterface */ public function getDescendants($depth, OperationContextInterface $context = null) From 8b5f0bc0a8dd8de9acfa69a0cc183be2adbf8cd7 Mon Sep 17 00:00:00 2001 From: Sascha Egerer Date: Sun, 13 Jan 2019 15:07:17 +0100 Subject: [PATCH 3/7] Add example for getAcl Add an example for getting ACL. This feature is not yet implemented but pending in #69 --- examples/GetAcl.php | 86 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 examples/GetAcl.php diff --git a/examples/GetAcl.php b/examples/GetAcl.php new file mode 100644 index 0000000..512a0dd --- /dev/null +++ b/examples/GetAcl.php @@ -0,0 +1,86 @@ + [ + CMIS_BROWSER_USER, + CMIS_BROWSER_PASSWORD + ] + ] +); + +$parameters = [ + \Dkd\PhpCmis\SessionParameter::BINDING_TYPE => \Dkd\PhpCmis\Enum\BindingType::BROWSER, + \Dkd\PhpCmis\SessionParameter::BROWSER_URL => CMIS_BROWSER_URL, + \Dkd\PhpCmis\SessionParameter::BROWSER_SUCCINCT => false, + \Dkd\PhpCmis\SessionParameter::HTTP_INVOKER_OBJECT => $httpInvoker, +]; + +$sessionFactory = new \Dkd\PhpCmis\SessionFactory(); + +// If no repository id is defined use the first repository +if (CMIS_REPOSITORY_ID === null) { + $repositories = $sessionFactory->getRepositories($parameters); + $parameters[\Dkd\PhpCmis\SessionParameter::REPOSITORY_ID] = $repositories[0]->getId(); +} else { + $parameters[\Dkd\PhpCmis\SessionParameter::REPOSITORY_ID] = CMIS_REPOSITORY_ID; +} + +$session = $sessionFactory->createSession($parameters); + +// Get the root folder of the repository +$rootFolder = $session->getRootFolder(); + +echo '+ [ROOT FOLDER]: ' . $rootFolder->getName() . "\n"; + +printFolderContent($rootFolder); + +function printFolderContent(\Dkd\PhpCmis\Data\FolderInterface $folder, $levelIndention = ' ') +{ + $i = 0; + foreach ($folder->getChildren() as $children) { + echo $levelIndention; + $i++; + if ($i > 10) { + echo "| ...\n"; + break; + } + + if ($children instanceof \Dkd\PhpCmis\Data\FolderInterface) { + echo '+ [FOLDER]: ' . $children->getName() . "\n"; + printAcl($children, $levelIndention); + } elseif ($children instanceof \Dkd\PhpCmis\Data\DocumentInterface) { + echo '- [DOCUMENT]: ' . $children->getName() . "\n"; + printAcl($children, $levelIndention); + } else { + echo '- [ITEM]: ' . $children->getName() . "\n"; + printAcl($children, $levelIndention); + } + } +} + +function printAcl(\Dkd\PhpCmis\CmisObject\CmisObjectInterface $item, $levelIndention) +{ + $acl = $item->getAcl(); + if ($acl !== null) { + foreach ($acl->getAces() as $ace) { + printf( + "%s - [ACE]: Principal ID = %s, Permissions = %s\n", + $levelIndention, + $ace->getPrincipalId(), + implode(',', $ace->getPermissions()) + ); + } + } +} From 2f8ec736b6e6633a593e8bbfc9ad43c97e2c8a95 Mon Sep 17 00:00:00 2001 From: Sascha Egerer Date: Sun, 13 Jan 2019 15:13:03 +0100 Subject: [PATCH 4/7] Adjust getAcl example to output info if no acl exists --- examples/GetAcl.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/GetAcl.php b/examples/GetAcl.php index 512a0dd..5308890 100644 --- a/examples/GetAcl.php +++ b/examples/GetAcl.php @@ -43,6 +43,7 @@ $rootFolder = $session->getRootFolder(); echo '+ [ROOT FOLDER]: ' . $rootFolder->getName() . "\n"; +printAcl($rootFolder); printFolderContent($rootFolder); @@ -70,17 +71,19 @@ function printFolderContent(\Dkd\PhpCmis\Data\FolderInterface $folder, $levelInd } } -function printAcl(\Dkd\PhpCmis\CmisObject\CmisObjectInterface $item, $levelIndention) +function printAcl(\Dkd\PhpCmis\CmisObject\CmisObjectInterface $item, $levelIndention = '') { $acl = $item->getAcl(); if ($acl !== null) { foreach ($acl->getAces() as $ace) { printf( - "%s - [ACE]: Principal ID = %s, Permissions = %s\n", + "%s > [ACE]: Principal ID = %s, Permissions = %s\n", $levelIndention, $ace->getPrincipalId(), implode(',', $ace->getPermissions()) ); } + } else { + echo $levelIndention . " > [ACE]: Nothing found. Maybe ACE could not be loaded or does not exist\n"; } } From 25fa600bd88e328aeb9fef2c44da4f445f875a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Wuttig?= Date: Fri, 23 Nov 2018 14:47:43 +0100 Subject: [PATCH 5/7] [FEATURE] adds getAcl feature to retrieve the ACL for an object --- src/Bindings/Browser/AclService.php | 5 ++++- src/DataObjects/AbstractCmisObject.php | 6 +++++- src/Session.php | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Bindings/Browser/AclService.php b/src/Bindings/Browser/AclService.php index 61c52c8..d8a85cd 100644 --- a/src/Bindings/Browser/AclService.php +++ b/src/Bindings/Browser/AclService.php @@ -11,6 +11,7 @@ */ use Dkd\PhpCmis\AclServiceInterface; +use Dkd\PhpCmis\Constants; use Dkd\PhpCmis\Data\AclInterface; use Dkd\PhpCmis\Data\ExtensionDataInterface; use Dkd\PhpCmis\Enum\AclPropagation; @@ -62,6 +63,8 @@ public function getAcl( $onlyBasicPermissions = true, ExtensionDataInterface $extension = null ) { - // TODO: Implement getAcl() method. + $url = $this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_ACL); + $responseData = $this->read($url)->json(); + return $this->getJsonConverter()->convertAcl($responseData); } } diff --git a/src/DataObjects/AbstractCmisObject.php b/src/DataObjects/AbstractCmisObject.php index 727807e..79fbe99 100644 --- a/src/DataObjects/AbstractCmisObject.php +++ b/src/DataObjects/AbstractCmisObject.php @@ -747,7 +747,11 @@ public function setAcl(array $aces) */ public function getAcl() { - return $this->acl; + $result = $this->getSession()->getAcl($this, false); + + $this->refresh(); + + return $result; } /** diff --git a/src/Session.php b/src/Session.php index b34ca8e..fa36bdd 100644 --- a/src/Session.php +++ b/src/Session.php @@ -752,7 +752,7 @@ public function deleteType($typeId) */ public function getAcl(ObjectIdInterface $objectId, $onlyBasicPermissions) { - // TODO: Implement getAcl() method. + return $this->getBinding()->getAclService()->getAcl($this->getRepositoryId(), $objectId->getId(), $onlyBasicPermissions); } /** From d6d1187cd564ee4f153428fcb64883ce048a9c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Wuttig?= Date: Fri, 23 Nov 2018 18:00:25 +0100 Subject: [PATCH 6/7] [BUGFIX] uses readJson() instead of read() for getting rsponseData from getAcl request --- src/Bindings/Browser/AclService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bindings/Browser/AclService.php b/src/Bindings/Browser/AclService.php index d8a85cd..7536174 100644 --- a/src/Bindings/Browser/AclService.php +++ b/src/Bindings/Browser/AclService.php @@ -64,7 +64,7 @@ public function getAcl( ExtensionDataInterface $extension = null ) { $url = $this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_ACL); - $responseData = $this->read($url)->json(); + $responseData = $this->readJson($url); return $this->getJsonConverter()->convertAcl($responseData); } } From d9ebce7c1618f36c78cae32bc2c7ba973dcd563c Mon Sep 17 00:00:00 2001 From: Sascha Egerer Date: Tue, 18 Aug 2020 08:09:32 +0200 Subject: [PATCH 7/7] Remove superfluous refresh call in getAcl method --- README.md | 2 +- src/DataObjects/AbstractCmisObject.php | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f279673..a7375ae 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Currently implemented Services - [ ] removePolicy - [ ] getAppliedPolicies - AclSservice - - [ ] getACL + - [x] getACL - [ ] applyACL diff --git a/src/DataObjects/AbstractCmisObject.php b/src/DataObjects/AbstractCmisObject.php index 79fbe99..727807e 100644 --- a/src/DataObjects/AbstractCmisObject.php +++ b/src/DataObjects/AbstractCmisObject.php @@ -747,11 +747,7 @@ public function setAcl(array $aces) */ public function getAcl() { - $result = $this->getSession()->getAcl($this, false); - - $this->refresh(); - - return $result; + return $this->acl; } /**