@@ -39,136 +39,136 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | class SystemTagsObjectTypeCollection implements ICollection { |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var string |
|
| 44 | - */ |
|
| 45 | - private $objectType; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var ISystemTagManager |
|
| 49 | - */ |
|
| 50 | - private $tagManager; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @var ISystemTagObjectMapper |
|
| 54 | - */ |
|
| 55 | - private $tagMapper; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @var IGroupManager |
|
| 59 | - */ |
|
| 60 | - private $groupManager; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @var IUserSession |
|
| 64 | - */ |
|
| 65 | - private $userSession; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @var \Closure |
|
| 69 | - **/ |
|
| 70 | - protected $childExistsFunction; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Constructor |
|
| 74 | - * |
|
| 75 | - * @param string $objectType object type |
|
| 76 | - * @param ISystemTagManager $tagManager |
|
| 77 | - * @param ISystemTagObjectMapper $tagMapper |
|
| 78 | - * @param IUserSession $userSession |
|
| 79 | - * @param IGroupManager $groupManager |
|
| 80 | - * @param \Closure $childExistsFunction |
|
| 81 | - */ |
|
| 82 | - public function __construct( |
|
| 83 | - $objectType, |
|
| 84 | - ISystemTagManager $tagManager, |
|
| 85 | - ISystemTagObjectMapper $tagMapper, |
|
| 86 | - IUserSession $userSession, |
|
| 87 | - IGroupManager $groupManager, |
|
| 88 | - \Closure $childExistsFunction |
|
| 89 | - ) { |
|
| 90 | - $this->tagManager = $tagManager; |
|
| 91 | - $this->tagMapper = $tagMapper; |
|
| 92 | - $this->objectType = $objectType; |
|
| 93 | - $this->userSession = $userSession; |
|
| 94 | - $this->groupManager = $groupManager; |
|
| 95 | - $this->childExistsFunction = $childExistsFunction; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @param string $name |
|
| 100 | - * @param resource|string $data Initial payload |
|
| 101 | - * @return null|string |
|
| 102 | - * @throws Forbidden |
|
| 103 | - */ |
|
| 104 | - function createFile($name, $data = null) { |
|
| 105 | - throw new Forbidden('Permission denied to create nodes'); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * @param string $name |
|
| 110 | - * @throws Forbidden |
|
| 111 | - */ |
|
| 112 | - function createDirectory($name) { |
|
| 113 | - throw new Forbidden('Permission denied to create collections'); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * @param string $objectId |
|
| 118 | - * @return SystemTagsObjectMappingCollection |
|
| 119 | - * @throws NotFound |
|
| 120 | - */ |
|
| 121 | - function getChild($objectId) { |
|
| 122 | - // make sure the object exists and is reachable |
|
| 123 | - if(!$this->childExists($objectId)) { |
|
| 124 | - throw new NotFound('Entity does not exist or is not available'); |
|
| 125 | - } |
|
| 126 | - return new SystemTagsObjectMappingCollection( |
|
| 127 | - $objectId, |
|
| 128 | - $this->objectType, |
|
| 129 | - $this->userSession->getUser(), |
|
| 130 | - $this->tagManager, |
|
| 131 | - $this->tagMapper |
|
| 132 | - ); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - function getChildren() { |
|
| 136 | - // do not list object ids |
|
| 137 | - throw new MethodNotAllowed(); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Checks if a child-node with the specified name exists |
|
| 142 | - * |
|
| 143 | - * @param string $name |
|
| 144 | - * @return bool |
|
| 145 | - */ |
|
| 146 | - function childExists($name) { |
|
| 147 | - return call_user_func($this->childExistsFunction, $name); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - function delete() { |
|
| 151 | - throw new Forbidden('Permission denied to delete this collection'); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - function getName() { |
|
| 155 | - return $this->objectType; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * @param string $name |
|
| 160 | - * @throws Forbidden |
|
| 161 | - */ |
|
| 162 | - function setName($name) { |
|
| 163 | - throw new Forbidden('Permission denied to rename this collection'); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * Returns the last modification time, as a unix timestamp |
|
| 168 | - * |
|
| 169 | - * @return int |
|
| 170 | - */ |
|
| 171 | - function getLastModified() { |
|
| 172 | - return null; |
|
| 173 | - } |
|
| 42 | + /** |
|
| 43 | + * @var string |
|
| 44 | + */ |
|
| 45 | + private $objectType; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var ISystemTagManager |
|
| 49 | + */ |
|
| 50 | + private $tagManager; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @var ISystemTagObjectMapper |
|
| 54 | + */ |
|
| 55 | + private $tagMapper; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @var IGroupManager |
|
| 59 | + */ |
|
| 60 | + private $groupManager; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @var IUserSession |
|
| 64 | + */ |
|
| 65 | + private $userSession; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @var \Closure |
|
| 69 | + **/ |
|
| 70 | + protected $childExistsFunction; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Constructor |
|
| 74 | + * |
|
| 75 | + * @param string $objectType object type |
|
| 76 | + * @param ISystemTagManager $tagManager |
|
| 77 | + * @param ISystemTagObjectMapper $tagMapper |
|
| 78 | + * @param IUserSession $userSession |
|
| 79 | + * @param IGroupManager $groupManager |
|
| 80 | + * @param \Closure $childExistsFunction |
|
| 81 | + */ |
|
| 82 | + public function __construct( |
|
| 83 | + $objectType, |
|
| 84 | + ISystemTagManager $tagManager, |
|
| 85 | + ISystemTagObjectMapper $tagMapper, |
|
| 86 | + IUserSession $userSession, |
|
| 87 | + IGroupManager $groupManager, |
|
| 88 | + \Closure $childExistsFunction |
|
| 89 | + ) { |
|
| 90 | + $this->tagManager = $tagManager; |
|
| 91 | + $this->tagMapper = $tagMapper; |
|
| 92 | + $this->objectType = $objectType; |
|
| 93 | + $this->userSession = $userSession; |
|
| 94 | + $this->groupManager = $groupManager; |
|
| 95 | + $this->childExistsFunction = $childExistsFunction; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @param string $name |
|
| 100 | + * @param resource|string $data Initial payload |
|
| 101 | + * @return null|string |
|
| 102 | + * @throws Forbidden |
|
| 103 | + */ |
|
| 104 | + function createFile($name, $data = null) { |
|
| 105 | + throw new Forbidden('Permission denied to create nodes'); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * @param string $name |
|
| 110 | + * @throws Forbidden |
|
| 111 | + */ |
|
| 112 | + function createDirectory($name) { |
|
| 113 | + throw new Forbidden('Permission denied to create collections'); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * @param string $objectId |
|
| 118 | + * @return SystemTagsObjectMappingCollection |
|
| 119 | + * @throws NotFound |
|
| 120 | + */ |
|
| 121 | + function getChild($objectId) { |
|
| 122 | + // make sure the object exists and is reachable |
|
| 123 | + if(!$this->childExists($objectId)) { |
|
| 124 | + throw new NotFound('Entity does not exist or is not available'); |
|
| 125 | + } |
|
| 126 | + return new SystemTagsObjectMappingCollection( |
|
| 127 | + $objectId, |
|
| 128 | + $this->objectType, |
|
| 129 | + $this->userSession->getUser(), |
|
| 130 | + $this->tagManager, |
|
| 131 | + $this->tagMapper |
|
| 132 | + ); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + function getChildren() { |
|
| 136 | + // do not list object ids |
|
| 137 | + throw new MethodNotAllowed(); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Checks if a child-node with the specified name exists |
|
| 142 | + * |
|
| 143 | + * @param string $name |
|
| 144 | + * @return bool |
|
| 145 | + */ |
|
| 146 | + function childExists($name) { |
|
| 147 | + return call_user_func($this->childExistsFunction, $name); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + function delete() { |
|
| 151 | + throw new Forbidden('Permission denied to delete this collection'); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + function getName() { |
|
| 155 | + return $this->objectType; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * @param string $name |
|
| 160 | + * @throws Forbidden |
|
| 161 | + */ |
|
| 162 | + function setName($name) { |
|
| 163 | + throw new Forbidden('Permission denied to rename this collection'); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * Returns the last modification time, as a unix timestamp |
|
| 168 | + * |
|
| 169 | + * @return int |
|
| 170 | + */ |
|
| 171 | + function getLastModified() { |
|
| 172 | + return null; |
|
| 173 | + } |
|
| 174 | 174 | } |
@@ -37,134 +37,134 @@ |
||
| 37 | 37 | * Mapping node for system tag to object id |
| 38 | 38 | */ |
| 39 | 39 | class SystemTagMappingNode implements \Sabre\DAV\INode { |
| 40 | - /** |
|
| 41 | - * @var ISystemTag |
|
| 42 | - */ |
|
| 43 | - protected $tag; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 48 | - private $objectId; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @var string |
|
| 52 | - */ |
|
| 53 | - private $objectType; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * User |
|
| 57 | - * |
|
| 58 | - * @var IUser |
|
| 59 | - */ |
|
| 60 | - protected $user; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @var ISystemTagManager |
|
| 64 | - */ |
|
| 65 | - protected $tagManager; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @var ISystemTagObjectMapper |
|
| 69 | - */ |
|
| 70 | - private $tagMapper; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Sets up the node, expects a full path name |
|
| 74 | - * |
|
| 75 | - * @param ISystemTag $tag system tag |
|
| 76 | - * @param string $objectId |
|
| 77 | - * @param string $objectType |
|
| 78 | - * @param IUser $user user |
|
| 79 | - * @param ISystemTagManager $tagManager |
|
| 80 | - * @param ISystemTagObjectMapper $tagMapper |
|
| 81 | - */ |
|
| 82 | - public function __construct( |
|
| 83 | - ISystemTag $tag, |
|
| 84 | - $objectId, |
|
| 85 | - $objectType, |
|
| 86 | - IUser $user, |
|
| 87 | - ISystemTagManager $tagManager, |
|
| 88 | - ISystemTagObjectMapper $tagMapper |
|
| 89 | - ) { |
|
| 90 | - $this->tag = $tag; |
|
| 91 | - $this->objectId = $objectId; |
|
| 92 | - $this->objectType = $objectType; |
|
| 93 | - $this->user = $user; |
|
| 94 | - $this->tagManager = $tagManager; |
|
| 95 | - $this->tagMapper = $tagMapper; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Returns the object id of the relationship |
|
| 100 | - * |
|
| 101 | - * @return string object id |
|
| 102 | - */ |
|
| 103 | - public function getObjectId() { |
|
| 104 | - return $this->objectId; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Returns the object type of the relationship |
|
| 109 | - * |
|
| 110 | - * @return string object type |
|
| 111 | - */ |
|
| 112 | - public function getObjectType() { |
|
| 113 | - return $this->objectType; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Returns the system tag represented by this node |
|
| 118 | - * |
|
| 119 | - * @return ISystemTag system tag |
|
| 120 | - */ |
|
| 121 | - public function getSystemTag() { |
|
| 122 | - return $this->tag; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Returns the id of the tag |
|
| 127 | - * |
|
| 128 | - * @return string |
|
| 129 | - */ |
|
| 130 | - public function getName() { |
|
| 131 | - return $this->tag->getId(); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * Renames the node |
|
| 136 | - * |
|
| 137 | - * @param string $name The new name |
|
| 138 | - * |
|
| 139 | - * @throws MethodNotAllowed not allowed to rename node |
|
| 140 | - */ |
|
| 141 | - public function setName($name) { |
|
| 142 | - throw new MethodNotAllowed(); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Returns null, not supported |
|
| 147 | - * |
|
| 148 | - */ |
|
| 149 | - public function getLastModified() { |
|
| 150 | - return null; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Delete tag to object association |
|
| 155 | - */ |
|
| 156 | - public function delete() { |
|
| 157 | - try { |
|
| 158 | - if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
|
| 159 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found'); |
|
| 160 | - } |
|
| 161 | - if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) { |
|
| 162 | - throw new Forbidden('No permission to unassign tag ' . $this->tag->getId()); |
|
| 163 | - } |
|
| 164 | - $this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId()); |
|
| 165 | - } catch (TagNotFoundException $e) { |
|
| 166 | - // can happen if concurrent deletion occurred |
|
| 167 | - throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e); |
|
| 168 | - } |
|
| 169 | - } |
|
| 40 | + /** |
|
| 41 | + * @var ISystemTag |
|
| 42 | + */ |
|
| 43 | + protected $tag; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | + private $objectId; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @var string |
|
| 52 | + */ |
|
| 53 | + private $objectType; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * User |
|
| 57 | + * |
|
| 58 | + * @var IUser |
|
| 59 | + */ |
|
| 60 | + protected $user; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @var ISystemTagManager |
|
| 64 | + */ |
|
| 65 | + protected $tagManager; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @var ISystemTagObjectMapper |
|
| 69 | + */ |
|
| 70 | + private $tagMapper; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Sets up the node, expects a full path name |
|
| 74 | + * |
|
| 75 | + * @param ISystemTag $tag system tag |
|
| 76 | + * @param string $objectId |
|
| 77 | + * @param string $objectType |
|
| 78 | + * @param IUser $user user |
|
| 79 | + * @param ISystemTagManager $tagManager |
|
| 80 | + * @param ISystemTagObjectMapper $tagMapper |
|
| 81 | + */ |
|
| 82 | + public function __construct( |
|
| 83 | + ISystemTag $tag, |
|
| 84 | + $objectId, |
|
| 85 | + $objectType, |
|
| 86 | + IUser $user, |
|
| 87 | + ISystemTagManager $tagManager, |
|
| 88 | + ISystemTagObjectMapper $tagMapper |
|
| 89 | + ) { |
|
| 90 | + $this->tag = $tag; |
|
| 91 | + $this->objectId = $objectId; |
|
| 92 | + $this->objectType = $objectType; |
|
| 93 | + $this->user = $user; |
|
| 94 | + $this->tagManager = $tagManager; |
|
| 95 | + $this->tagMapper = $tagMapper; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Returns the object id of the relationship |
|
| 100 | + * |
|
| 101 | + * @return string object id |
|
| 102 | + */ |
|
| 103 | + public function getObjectId() { |
|
| 104 | + return $this->objectId; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Returns the object type of the relationship |
|
| 109 | + * |
|
| 110 | + * @return string object type |
|
| 111 | + */ |
|
| 112 | + public function getObjectType() { |
|
| 113 | + return $this->objectType; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Returns the system tag represented by this node |
|
| 118 | + * |
|
| 119 | + * @return ISystemTag system tag |
|
| 120 | + */ |
|
| 121 | + public function getSystemTag() { |
|
| 122 | + return $this->tag; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Returns the id of the tag |
|
| 127 | + * |
|
| 128 | + * @return string |
|
| 129 | + */ |
|
| 130 | + public function getName() { |
|
| 131 | + return $this->tag->getId(); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * Renames the node |
|
| 136 | + * |
|
| 137 | + * @param string $name The new name |
|
| 138 | + * |
|
| 139 | + * @throws MethodNotAllowed not allowed to rename node |
|
| 140 | + */ |
|
| 141 | + public function setName($name) { |
|
| 142 | + throw new MethodNotAllowed(); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Returns null, not supported |
|
| 147 | + * |
|
| 148 | + */ |
|
| 149 | + public function getLastModified() { |
|
| 150 | + return null; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Delete tag to object association |
|
| 155 | + */ |
|
| 156 | + public function delete() { |
|
| 157 | + try { |
|
| 158 | + if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) { |
|
| 159 | + throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found'); |
|
| 160 | + } |
|
| 161 | + if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) { |
|
| 162 | + throw new Forbidden('No permission to unassign tag ' . $this->tag->getId()); |
|
| 163 | + } |
|
| 164 | + $this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId()); |
|
| 165 | + } catch (TagNotFoundException $e) { |
|
| 166 | + // can happen if concurrent deletion occurred |
|
| 167 | + throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | 170 | } |
@@ -39,169 +39,169 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | class SystemTagsObjectMappingCollection implements ICollection { |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var string |
|
| 44 | - */ |
|
| 45 | - private $objectId; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var string |
|
| 49 | - */ |
|
| 50 | - private $objectType; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @var ISystemTagManager |
|
| 54 | - */ |
|
| 55 | - private $tagManager; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @var ISystemTagObjectMapper |
|
| 59 | - */ |
|
| 60 | - private $tagMapper; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * User |
|
| 64 | - * |
|
| 65 | - * @var IUser |
|
| 66 | - */ |
|
| 67 | - private $user; |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Constructor |
|
| 72 | - * |
|
| 73 | - * @param string $objectId object id |
|
| 74 | - * @param string $objectType object type |
|
| 75 | - * @param IUser $user user |
|
| 76 | - * @param ISystemTagManager $tagManager tag manager |
|
| 77 | - * @param ISystemTagObjectMapper $tagMapper tag mapper |
|
| 78 | - */ |
|
| 79 | - public function __construct( |
|
| 80 | - $objectId, |
|
| 81 | - $objectType, |
|
| 82 | - IUser $user, |
|
| 83 | - ISystemTagManager $tagManager, |
|
| 84 | - ISystemTagObjectMapper $tagMapper |
|
| 85 | - ) { |
|
| 86 | - $this->tagManager = $tagManager; |
|
| 87 | - $this->tagMapper = $tagMapper; |
|
| 88 | - $this->objectId = $objectId; |
|
| 89 | - $this->objectType = $objectType; |
|
| 90 | - $this->user = $user; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - function createFile($tagId, $data = null) { |
|
| 94 | - try { |
|
| 95 | - $tags = $this->tagManager->getTagsByIds([$tagId]); |
|
| 96 | - $tag = current($tags); |
|
| 97 | - if (!$this->tagManager->canUserSeeTag($tag, $this->user)) { |
|
| 98 | - throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign'); |
|
| 99 | - } |
|
| 100 | - if (!$this->tagManager->canUserAssignTag($tag, $this->user)) { |
|
| 101 | - throw new Forbidden('No permission to assign tag ' . $tagId); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - $this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId); |
|
| 105 | - } catch (TagNotFoundException $e) { |
|
| 106 | - throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign'); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - function createDirectory($name) { |
|
| 111 | - throw new Forbidden('Permission denied to create collections'); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - function getChild($tagId) { |
|
| 115 | - try { |
|
| 116 | - if ($this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true)) { |
|
| 117 | - $tag = $this->tagManager->getTagsByIds([$tagId]); |
|
| 118 | - $tag = current($tag); |
|
| 119 | - if ($this->tagManager->canUserSeeTag($tag, $this->user)) { |
|
| 120 | - return $this->makeNode($tag); |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId); |
|
| 124 | - } catch (\InvalidArgumentException $e) { |
|
| 125 | - throw new BadRequest('Invalid tag id', 0, $e); |
|
| 126 | - } catch (TagNotFoundException $e) { |
|
| 127 | - throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e); |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - function getChildren() { |
|
| 132 | - $tagIds = current($this->tagMapper->getTagIdsForObjects([$this->objectId], $this->objectType)); |
|
| 133 | - if (empty($tagIds)) { |
|
| 134 | - return []; |
|
| 135 | - } |
|
| 136 | - $tags = $this->tagManager->getTagsByIds($tagIds); |
|
| 137 | - |
|
| 138 | - // filter out non-visible tags |
|
| 139 | - $tags = array_filter($tags, function($tag) { |
|
| 140 | - return $this->tagManager->canUserSeeTag($tag, $this->user); |
|
| 141 | - }); |
|
| 142 | - |
|
| 143 | - return array_values(array_map(function($tag) { |
|
| 144 | - return $this->makeNode($tag); |
|
| 145 | - }, $tags)); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - function childExists($tagId) { |
|
| 149 | - try { |
|
| 150 | - $result = ($this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true)); |
|
| 151 | - |
|
| 152 | - if ($result) { |
|
| 153 | - $tags = $this->tagManager->getTagsByIds([$tagId]); |
|
| 154 | - $tag = current($tags); |
|
| 155 | - if (!$this->tagManager->canUserSeeTag($tag, $this->user)) { |
|
| 156 | - return false; |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - return $result; |
|
| 161 | - } catch (\InvalidArgumentException $e) { |
|
| 162 | - throw new BadRequest('Invalid tag id', 0, $e); |
|
| 163 | - } catch (TagNotFoundException $e) { |
|
| 164 | - return false; |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - function delete() { |
|
| 169 | - throw new Forbidden('Permission denied to delete this collection'); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - function getName() { |
|
| 173 | - return $this->objectId; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - function setName($name) { |
|
| 177 | - throw new Forbidden('Permission denied to rename this collection'); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * Returns the last modification time, as a unix timestamp |
|
| 182 | - * |
|
| 183 | - * @return int |
|
| 184 | - */ |
|
| 185 | - function getLastModified() { |
|
| 186 | - return null; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Create a sabre node for the mapping of the |
|
| 191 | - * given system tag to the collection's object |
|
| 192 | - * |
|
| 193 | - * @param ISystemTag $tag |
|
| 194 | - * |
|
| 195 | - * @return SystemTagMappingNode |
|
| 196 | - */ |
|
| 197 | - private function makeNode(ISystemTag $tag) { |
|
| 198 | - return new SystemTagMappingNode( |
|
| 199 | - $tag, |
|
| 200 | - $this->objectId, |
|
| 201 | - $this->objectType, |
|
| 202 | - $this->user, |
|
| 203 | - $this->tagManager, |
|
| 204 | - $this->tagMapper |
|
| 205 | - ); |
|
| 206 | - } |
|
| 42 | + /** |
|
| 43 | + * @var string |
|
| 44 | + */ |
|
| 45 | + private $objectId; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var string |
|
| 49 | + */ |
|
| 50 | + private $objectType; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @var ISystemTagManager |
|
| 54 | + */ |
|
| 55 | + private $tagManager; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @var ISystemTagObjectMapper |
|
| 59 | + */ |
|
| 60 | + private $tagMapper; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * User |
|
| 64 | + * |
|
| 65 | + * @var IUser |
|
| 66 | + */ |
|
| 67 | + private $user; |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Constructor |
|
| 72 | + * |
|
| 73 | + * @param string $objectId object id |
|
| 74 | + * @param string $objectType object type |
|
| 75 | + * @param IUser $user user |
|
| 76 | + * @param ISystemTagManager $tagManager tag manager |
|
| 77 | + * @param ISystemTagObjectMapper $tagMapper tag mapper |
|
| 78 | + */ |
|
| 79 | + public function __construct( |
|
| 80 | + $objectId, |
|
| 81 | + $objectType, |
|
| 82 | + IUser $user, |
|
| 83 | + ISystemTagManager $tagManager, |
|
| 84 | + ISystemTagObjectMapper $tagMapper |
|
| 85 | + ) { |
|
| 86 | + $this->tagManager = $tagManager; |
|
| 87 | + $this->tagMapper = $tagMapper; |
|
| 88 | + $this->objectId = $objectId; |
|
| 89 | + $this->objectType = $objectType; |
|
| 90 | + $this->user = $user; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + function createFile($tagId, $data = null) { |
|
| 94 | + try { |
|
| 95 | + $tags = $this->tagManager->getTagsByIds([$tagId]); |
|
| 96 | + $tag = current($tags); |
|
| 97 | + if (!$this->tagManager->canUserSeeTag($tag, $this->user)) { |
|
| 98 | + throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign'); |
|
| 99 | + } |
|
| 100 | + if (!$this->tagManager->canUserAssignTag($tag, $this->user)) { |
|
| 101 | + throw new Forbidden('No permission to assign tag ' . $tagId); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + $this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId); |
|
| 105 | + } catch (TagNotFoundException $e) { |
|
| 106 | + throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign'); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + function createDirectory($name) { |
|
| 111 | + throw new Forbidden('Permission denied to create collections'); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + function getChild($tagId) { |
|
| 115 | + try { |
|
| 116 | + if ($this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true)) { |
|
| 117 | + $tag = $this->tagManager->getTagsByIds([$tagId]); |
|
| 118 | + $tag = current($tag); |
|
| 119 | + if ($this->tagManager->canUserSeeTag($tag, $this->user)) { |
|
| 120 | + return $this->makeNode($tag); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId); |
|
| 124 | + } catch (\InvalidArgumentException $e) { |
|
| 125 | + throw new BadRequest('Invalid tag id', 0, $e); |
|
| 126 | + } catch (TagNotFoundException $e) { |
|
| 127 | + throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e); |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + function getChildren() { |
|
| 132 | + $tagIds = current($this->tagMapper->getTagIdsForObjects([$this->objectId], $this->objectType)); |
|
| 133 | + if (empty($tagIds)) { |
|
| 134 | + return []; |
|
| 135 | + } |
|
| 136 | + $tags = $this->tagManager->getTagsByIds($tagIds); |
|
| 137 | + |
|
| 138 | + // filter out non-visible tags |
|
| 139 | + $tags = array_filter($tags, function($tag) { |
|
| 140 | + return $this->tagManager->canUserSeeTag($tag, $this->user); |
|
| 141 | + }); |
|
| 142 | + |
|
| 143 | + return array_values(array_map(function($tag) { |
|
| 144 | + return $this->makeNode($tag); |
|
| 145 | + }, $tags)); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + function childExists($tagId) { |
|
| 149 | + try { |
|
| 150 | + $result = ($this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true)); |
|
| 151 | + |
|
| 152 | + if ($result) { |
|
| 153 | + $tags = $this->tagManager->getTagsByIds([$tagId]); |
|
| 154 | + $tag = current($tags); |
|
| 155 | + if (!$this->tagManager->canUserSeeTag($tag, $this->user)) { |
|
| 156 | + return false; |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + return $result; |
|
| 161 | + } catch (\InvalidArgumentException $e) { |
|
| 162 | + throw new BadRequest('Invalid tag id', 0, $e); |
|
| 163 | + } catch (TagNotFoundException $e) { |
|
| 164 | + return false; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + function delete() { |
|
| 169 | + throw new Forbidden('Permission denied to delete this collection'); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + function getName() { |
|
| 173 | + return $this->objectId; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + function setName($name) { |
|
| 177 | + throw new Forbidden('Permission denied to rename this collection'); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * Returns the last modification time, as a unix timestamp |
|
| 182 | + * |
|
| 183 | + * @return int |
|
| 184 | + */ |
|
| 185 | + function getLastModified() { |
|
| 186 | + return null; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Create a sabre node for the mapping of the |
|
| 191 | + * given system tag to the collection's object |
|
| 192 | + * |
|
| 193 | + * @param ISystemTag $tag |
|
| 194 | + * |
|
| 195 | + * @return SystemTagMappingNode |
|
| 196 | + */ |
|
| 197 | + private function makeNode(ISystemTag $tag) { |
|
| 198 | + return new SystemTagMappingNode( |
|
| 199 | + $tag, |
|
| 200 | + $this->objectId, |
|
| 201 | + $this->objectType, |
|
| 202 | + $this->user, |
|
| 203 | + $this->tagManager, |
|
| 204 | + $this->tagMapper |
|
| 205 | + ); |
|
| 206 | + } |
|
| 207 | 207 | } |
@@ -36,59 +36,59 @@ |
||
| 36 | 36 | |
| 37 | 37 | class SystemTagsRelationsCollection extends SimpleCollection { |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * SystemTagsRelationsCollection constructor. |
|
| 41 | - * |
|
| 42 | - * @param ISystemTagManager $tagManager |
|
| 43 | - * @param ISystemTagObjectMapper $tagMapper |
|
| 44 | - * @param IUserSession $userSession |
|
| 45 | - * @param IGroupManager $groupManager |
|
| 46 | - * @param EventDispatcherInterface $dispatcher |
|
| 47 | - */ |
|
| 48 | - public function __construct( |
|
| 49 | - ISystemTagManager $tagManager, |
|
| 50 | - ISystemTagObjectMapper $tagMapper, |
|
| 51 | - IUserSession $userSession, |
|
| 52 | - IGroupManager $groupManager, |
|
| 53 | - EventDispatcherInterface $dispatcher |
|
| 54 | - ) { |
|
| 55 | - $children = [ |
|
| 56 | - new SystemTagsObjectTypeCollection( |
|
| 57 | - 'files', |
|
| 58 | - $tagManager, |
|
| 59 | - $tagMapper, |
|
| 60 | - $userSession, |
|
| 61 | - $groupManager, |
|
| 62 | - function($name) { |
|
| 63 | - $nodes = \OC::$server->getUserFolder()->getById(intval($name)); |
|
| 64 | - return !empty($nodes); |
|
| 65 | - } |
|
| 66 | - ), |
|
| 67 | - ]; |
|
| 39 | + /** |
|
| 40 | + * SystemTagsRelationsCollection constructor. |
|
| 41 | + * |
|
| 42 | + * @param ISystemTagManager $tagManager |
|
| 43 | + * @param ISystemTagObjectMapper $tagMapper |
|
| 44 | + * @param IUserSession $userSession |
|
| 45 | + * @param IGroupManager $groupManager |
|
| 46 | + * @param EventDispatcherInterface $dispatcher |
|
| 47 | + */ |
|
| 48 | + public function __construct( |
|
| 49 | + ISystemTagManager $tagManager, |
|
| 50 | + ISystemTagObjectMapper $tagMapper, |
|
| 51 | + IUserSession $userSession, |
|
| 52 | + IGroupManager $groupManager, |
|
| 53 | + EventDispatcherInterface $dispatcher |
|
| 54 | + ) { |
|
| 55 | + $children = [ |
|
| 56 | + new SystemTagsObjectTypeCollection( |
|
| 57 | + 'files', |
|
| 58 | + $tagManager, |
|
| 59 | + $tagMapper, |
|
| 60 | + $userSession, |
|
| 61 | + $groupManager, |
|
| 62 | + function($name) { |
|
| 63 | + $nodes = \OC::$server->getUserFolder()->getById(intval($name)); |
|
| 64 | + return !empty($nodes); |
|
| 65 | + } |
|
| 66 | + ), |
|
| 67 | + ]; |
|
| 68 | 68 | |
| 69 | - $event = new SystemTagsEntityEvent(SystemTagsEntityEvent::EVENT_ENTITY); |
|
| 70 | - $dispatcher->dispatch(SystemTagsEntityEvent::EVENT_ENTITY, $event); |
|
| 69 | + $event = new SystemTagsEntityEvent(SystemTagsEntityEvent::EVENT_ENTITY); |
|
| 70 | + $dispatcher->dispatch(SystemTagsEntityEvent::EVENT_ENTITY, $event); |
|
| 71 | 71 | |
| 72 | - foreach ($event->getEntityCollections() as $entity => $entityExistsFunction) { |
|
| 73 | - $children[] = new SystemTagsObjectTypeCollection( |
|
| 74 | - $entity, |
|
| 75 | - $tagManager, |
|
| 76 | - $tagMapper, |
|
| 77 | - $userSession, |
|
| 78 | - $groupManager, |
|
| 79 | - $entityExistsFunction |
|
| 80 | - ); |
|
| 81 | - } |
|
| 72 | + foreach ($event->getEntityCollections() as $entity => $entityExistsFunction) { |
|
| 73 | + $children[] = new SystemTagsObjectTypeCollection( |
|
| 74 | + $entity, |
|
| 75 | + $tagManager, |
|
| 76 | + $tagMapper, |
|
| 77 | + $userSession, |
|
| 78 | + $groupManager, |
|
| 79 | + $entityExistsFunction |
|
| 80 | + ); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - parent::__construct('root', $children); |
|
| 84 | - } |
|
| 83 | + parent::__construct('root', $children); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - function getName() { |
|
| 87 | - return 'systemtags-relations'; |
|
| 88 | - } |
|
| 86 | + function getName() { |
|
| 87 | + return 'systemtags-relations'; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - function setName($name) { |
|
| 91 | - throw new Forbidden('Permission denied to rename this collection'); |
|
| 92 | - } |
|
| 90 | + function setName($name) { |
|
| 91 | + throw new Forbidden('Permission denied to rename this collection'); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | 94 | } |
@@ -33,17 +33,17 @@ discard block |
||
| 33 | 33 | use OCA\DAV\Connector\Sabre\Principal; |
| 34 | 34 | |
| 35 | 35 | $authBackend = new Auth( |
| 36 | - \OC::$server->getSession(), |
|
| 37 | - \OC::$server->getUserSession(), |
|
| 38 | - \OC::$server->getRequest(), |
|
| 39 | - \OC::$server->getTwoFactorAuthManager(), |
|
| 40 | - \OC::$server->getBruteForceThrottler(), |
|
| 41 | - 'principals/' |
|
| 36 | + \OC::$server->getSession(), |
|
| 37 | + \OC::$server->getUserSession(), |
|
| 38 | + \OC::$server->getRequest(), |
|
| 39 | + \OC::$server->getTwoFactorAuthManager(), |
|
| 40 | + \OC::$server->getBruteForceThrottler(), |
|
| 41 | + 'principals/' |
|
| 42 | 42 | ); |
| 43 | 43 | $principalBackend = new Principal( |
| 44 | - \OC::$server->getUserManager(), |
|
| 45 | - \OC::$server->getGroupManager(), |
|
| 46 | - 'principals/' |
|
| 44 | + \OC::$server->getUserManager(), |
|
| 45 | + \OC::$server->getGroupManager(), |
|
| 46 | + 'principals/' |
|
| 47 | 47 | ); |
| 48 | 48 | $db = \OC::$server->getDatabaseConnection(); |
| 49 | 49 | $userManager = \OC::$server->getUserManager(); |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | $addressBookRoot->disableListing = !$debugging; // Disable listing |
| 62 | 62 | |
| 63 | 63 | $nodes = array( |
| 64 | - $principalCollection, |
|
| 65 | - $addressBookRoot, |
|
| 64 | + $principalCollection, |
|
| 65 | + $addressBookRoot, |
|
| 66 | 66 | ); |
| 67 | 67 | |
| 68 | 68 | // Fire up server |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $server->addPlugin(new LegacyDAVACL()); |
| 80 | 80 | if ($debugging) { |
| 81 | - $server->addPlugin(new Sabre\DAV\Browser\Plugin()); |
|
| 81 | + $server->addPlugin(new Sabre\DAV\Browser\Plugin()); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | require '../../../../3rdparty/autoload.php'; |
| 24 | 24 | |
| 25 | 25 | if ($argc !== 6) { |
| 26 | - echo "Invalid number of arguments" . PHP_EOL; |
|
| 27 | - exit; |
|
| 26 | + echo "Invalid number of arguments" . PHP_EOL; |
|
| 27 | + exit; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -33,15 +33,15 @@ discard block |
||
| 33 | 33 | * @return mixed |
| 34 | 34 | */ |
| 35 | 35 | function request($client, $method, $uploadUrl, $data = null, $headers = []) { |
| 36 | - echo "$method $uploadUrl ... "; |
|
| 37 | - $t0 = microtime(true); |
|
| 38 | - $result = $client->request($method, $uploadUrl, $data, $headers); |
|
| 39 | - $t1 = microtime(true); |
|
| 40 | - echo $result['statusCode'] . " - " . ($t1 - $t0) . ' seconds' . PHP_EOL; |
|
| 41 | - if (!in_array($result['statusCode'], [200, 201])) { |
|
| 42 | - echo $result['body'] . PHP_EOL; |
|
| 43 | - } |
|
| 44 | - return $result; |
|
| 36 | + echo "$method $uploadUrl ... "; |
|
| 37 | + $t0 = microtime(true); |
|
| 38 | + $result = $client->request($method, $uploadUrl, $data, $headers); |
|
| 39 | + $t1 = microtime(true); |
|
| 40 | + echo $result['statusCode'] . " - " . ($t1 - $t0) . ' seconds' . PHP_EOL; |
|
| 41 | + if (!in_array($result['statusCode'], [200, 201])) { |
|
| 42 | + echo $result['body'] . PHP_EOL; |
|
| 43 | + } |
|
| 44 | + return $result; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $baseUri = $argv[1]; |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | $chunkSize = $argv[5] * 1024 * 1024; |
| 52 | 52 | |
| 53 | 53 | $client = new \Sabre\DAV\Client([ |
| 54 | - 'baseUri' => $baseUri, |
|
| 55 | - 'userName' => $userName, |
|
| 56 | - 'password' => $password |
|
| 54 | + 'baseUri' => $baseUri, |
|
| 55 | + 'userName' => $userName, |
|
| 56 | + 'password' => $password |
|
| 57 | 57 | ]); |
| 58 | 58 | |
| 59 | 59 | $transfer = uniqid('transfer', true); |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | $index = 0; |
| 68 | 68 | while(!feof($stream)) { |
| 69 | - request($client, 'PUT', "$uploadUrl/$index", fread($stream, $chunkSize)); |
|
| 70 | - $index++; |
|
| 69 | + request($client, 'PUT', "$uploadUrl/$index", fread($stream, $chunkSize)); |
|
| 70 | + $index++; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $destination = pathinfo($file, PATHINFO_BASENAME); |
| 74 | 74 | //echo "Moving $uploadUrl/.file to it's final destination $baseUri/files/$userName/$destination" . PHP_EOL; |
| 75 | 75 | request($client, 'MOVE', "$uploadUrl/.file", null, [ |
| 76 | - 'Destination' => "$baseUri/files/$userName/$destination" |
|
| 76 | + 'Destination' => "$baseUri/files/$userName/$destination" |
|
| 77 | 77 | ]); |
@@ -35,22 +35,22 @@ |
||
| 35 | 35 | $versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $source); |
| 36 | 36 | if( $versions ) { |
| 37 | 37 | |
| 38 | - $endReached = false; |
|
| 39 | - if (count($versions) <= $start+$count) { |
|
| 40 | - $endReached = true; |
|
| 41 | - } |
|
| 38 | + $endReached = false; |
|
| 39 | + if (count($versions) <= $start+$count) { |
|
| 40 | + $endReached = true; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - $versions = array_slice($versions, $start, $count); |
|
| 43 | + $versions = array_slice($versions, $start, $count); |
|
| 44 | 44 | |
| 45 | - // remove owner path from request to not disclose it to the recipient |
|
| 46 | - foreach ($versions as $version) { |
|
| 47 | - unset($version['path']); |
|
| 48 | - } |
|
| 45 | + // remove owner path from request to not disclose it to the recipient |
|
| 46 | + foreach ($versions as $version) { |
|
| 47 | + unset($version['path']); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - \OCP\JSON::success(array('data' => array('versions' => $versions, 'endReached' => $endReached))); |
|
| 50 | + \OCP\JSON::success(array('data' => array('versions' => $versions, 'endReached' => $endReached))); |
|
| 51 | 51 | |
| 52 | 52 | } else { |
| 53 | 53 | |
| 54 | - \OCP\JSON::success(array('data' => array('versions' => [], 'endReached' => true))); |
|
| 54 | + \OCP\JSON::success(array('data' => array('versions' => [], 'endReached' => true))); |
|
| 55 | 55 | |
| 56 | 56 | } |
@@ -34,8 +34,8 @@ |
||
| 34 | 34 | $revision=(int)$_GET['revision']; |
| 35 | 35 | |
| 36 | 36 | if(OCA\Files_Versions\Storage::rollback( $file, $revision )) { |
| 37 | - OCP\JSON::success(array("data" => array( "revision" => $revision, "file" => $file ))); |
|
| 37 | + OCP\JSON::success(array("data" => array( "revision" => $revision, "file" => $file ))); |
|
| 38 | 38 | }else{ |
| 39 | - $l = \OC::$server->getL10N('files_versions'); |
|
| 40 | - OCP\JSON::error(array("data" => array( "message" => $l->t("Could not revert: %s", array($file) )))); |
|
| 39 | + $l = \OC::$server->getL10N('files_versions'); |
|
| 40 | + OCP\JSON::error(array("data" => array( "message" => $l->t("Could not revert: %s", array($file) )))); |
|
| 41 | 41 | } |
@@ -27,24 +27,24 @@ |
||
| 27 | 27 | use OCA\Files_Versions\Expiration; |
| 28 | 28 | |
| 29 | 29 | class Application extends App { |
| 30 | - public function __construct(array $urlParams = array()) { |
|
| 31 | - parent::__construct('files_versions', $urlParams); |
|
| 30 | + public function __construct(array $urlParams = array()) { |
|
| 31 | + parent::__construct('files_versions', $urlParams); |
|
| 32 | 32 | |
| 33 | - $container = $this->getContainer(); |
|
| 33 | + $container = $this->getContainer(); |
|
| 34 | 34 | |
| 35 | - /* |
|
| 35 | + /* |
|
| 36 | 36 | * Register capabilities |
| 37 | 37 | */ |
| 38 | - $container->registerCapability('OCA\Files_Versions\Capabilities'); |
|
| 38 | + $container->registerCapability('OCA\Files_Versions\Capabilities'); |
|
| 39 | 39 | |
| 40 | - /* |
|
| 40 | + /* |
|
| 41 | 41 | * Register expiration |
| 42 | 42 | */ |
| 43 | - $container->registerService('Expiration', function($c) { |
|
| 44 | - return new Expiration( |
|
| 45 | - $c->query('ServerContainer')->getConfig(), |
|
| 46 | - $c->query('OCP\AppFramework\Utility\ITimeFactory') |
|
| 47 | - ); |
|
| 48 | - }); |
|
| 49 | - } |
|
| 43 | + $container->registerService('Expiration', function($c) { |
|
| 44 | + return new Expiration( |
|
| 45 | + $c->query('ServerContainer')->getConfig(), |
|
| 46 | + $c->query('OCP\AppFramework\Utility\ITimeFactory') |
|
| 47 | + ); |
|
| 48 | + }); |
|
| 49 | + } |
|
| 50 | 50 | } |