| @@ -32,22 +32,22 @@ | ||
| 32 | 32 | */ | 
| 33 | 33 |  class ShareCreatedEvent extends Event { | 
| 34 | 34 | |
| 35 | - /** @var IShare */ | |
| 36 | - private $share; | |
| 35 | + /** @var IShare */ | |
| 36 | + private $share; | |
| 37 | 37 | |
| 38 | - /** | |
| 39 | - * @since 18.0.0 | |
| 40 | - */ | |
| 41 | -	public function __construct(IShare $share) { | |
| 42 | - parent::__construct(); | |
| 38 | + /** | |
| 39 | + * @since 18.0.0 | |
| 40 | + */ | |
| 41 | +    public function __construct(IShare $share) { | |
| 42 | + parent::__construct(); | |
| 43 | 43 | |
| 44 | - $this->share = $share; | |
| 45 | - } | |
| 44 | + $this->share = $share; | |
| 45 | + } | |
| 46 | 46 | |
| 47 | - /** | |
| 48 | - * @since 18.0.0 | |
| 49 | - */ | |
| 50 | -	public function getShare(): IShare { | |
| 51 | - return $this->share; | |
| 52 | - } | |
| 47 | + /** | |
| 48 | + * @since 18.0.0 | |
| 49 | + */ | |
| 50 | +    public function getShare(): IShare { | |
| 51 | + return $this->share; | |
| 52 | + } | |
| 53 | 53 | } | 
| @@ -77,1760 +77,1760 @@ | ||
| 77 | 77 | */ | 
| 78 | 78 |  class Manager implements IManager { | 
| 79 | 79 | |
| 80 | - /** @var IProviderFactory */ | |
| 81 | - private $factory; | |
| 82 | - /** @var ILogger */ | |
| 83 | - private $logger; | |
| 84 | - /** @var IConfig */ | |
| 85 | - private $config; | |
| 86 | - /** @var ISecureRandom */ | |
| 87 | - private $secureRandom; | |
| 88 | - /** @var IHasher */ | |
| 89 | - private $hasher; | |
| 90 | - /** @var IMountManager */ | |
| 91 | - private $mountManager; | |
| 92 | - /** @var IGroupManager */ | |
| 93 | - private $groupManager; | |
| 94 | - /** @var IL10N */ | |
| 95 | - private $l; | |
| 96 | - /** @var IFactory */ | |
| 97 | - private $l10nFactory; | |
| 98 | - /** @var IUserManager */ | |
| 99 | - private $userManager; | |
| 100 | - /** @var IRootFolder */ | |
| 101 | - private $rootFolder; | |
| 102 | - /** @var CappedMemoryCache */ | |
| 103 | - private $sharingDisabledForUsersCache; | |
| 104 | - /** @var EventDispatcherInterface */ | |
| 105 | - private $legacyDispatcher; | |
| 106 | - /** @var LegacyHooks */ | |
| 107 | - private $legacyHooks; | |
| 108 | - /** @var IMailer */ | |
| 109 | - private $mailer; | |
| 110 | - /** @var IURLGenerator */ | |
| 111 | - private $urlGenerator; | |
| 112 | - /** @var \OC_Defaults */ | |
| 113 | - private $defaults; | |
| 114 | - /** @var IEventDispatcher */ | |
| 115 | - private $dispatcher; | |
| 116 | - | |
| 117 | - | |
| 118 | - /** | |
| 119 | - * Manager constructor. | |
| 120 | - * | |
| 121 | - * @param ILogger $logger | |
| 122 | - * @param IConfig $config | |
| 123 | - * @param ISecureRandom $secureRandom | |
| 124 | - * @param IHasher $hasher | |
| 125 | - * @param IMountManager $mountManager | |
| 126 | - * @param IGroupManager $groupManager | |
| 127 | - * @param IL10N $l | |
| 128 | - * @param IFactory $l10nFactory | |
| 129 | - * @param IProviderFactory $factory | |
| 130 | - * @param IUserManager $userManager | |
| 131 | - * @param IRootFolder $rootFolder | |
| 132 | - * @param EventDispatcherInterface $eventDispatcher | |
| 133 | - * @param IMailer $mailer | |
| 134 | - * @param IURLGenerator $urlGenerator | |
| 135 | - * @param \OC_Defaults $defaults | |
| 136 | - */ | |
| 137 | - public function __construct( | |
| 138 | - ILogger $logger, | |
| 139 | - IConfig $config, | |
| 140 | - ISecureRandom $secureRandom, | |
| 141 | - IHasher $hasher, | |
| 142 | - IMountManager $mountManager, | |
| 143 | - IGroupManager $groupManager, | |
| 144 | - IL10N $l, | |
| 145 | - IFactory $l10nFactory, | |
| 146 | - IProviderFactory $factory, | |
| 147 | - IUserManager $userManager, | |
| 148 | - IRootFolder $rootFolder, | |
| 149 | - EventDispatcherInterface $legacyDispatcher, | |
| 150 | - IMailer $mailer, | |
| 151 | - IURLGenerator $urlGenerator, | |
| 152 | - \OC_Defaults $defaults, | |
| 153 | - IEventDispatcher $dispatcher | |
| 154 | -	) { | |
| 155 | - $this->logger = $logger; | |
| 156 | - $this->config = $config; | |
| 157 | - $this->secureRandom = $secureRandom; | |
| 158 | - $this->hasher = $hasher; | |
| 159 | - $this->mountManager = $mountManager; | |
| 160 | - $this->groupManager = $groupManager; | |
| 161 | - $this->l = $l; | |
| 162 | - $this->l10nFactory = $l10nFactory; | |
| 163 | - $this->factory = $factory; | |
| 164 | - $this->userManager = $userManager; | |
| 165 | - $this->rootFolder = $rootFolder; | |
| 166 | - $this->legacyDispatcher = $legacyDispatcher; | |
| 167 | - $this->sharingDisabledForUsersCache = new CappedMemoryCache(); | |
| 168 | - $this->legacyHooks = new LegacyHooks($this->legacyDispatcher); | |
| 169 | - $this->mailer = $mailer; | |
| 170 | - $this->urlGenerator = $urlGenerator; | |
| 171 | - $this->defaults = $defaults; | |
| 172 | - $this->dispatcher = $dispatcher; | |
| 173 | - } | |
| 174 | - | |
| 175 | - /** | |
| 176 | - * Convert from a full share id to a tuple (providerId, shareId) | |
| 177 | - * | |
| 178 | - * @param string $id | |
| 179 | - * @return string[] | |
| 180 | - */ | |
| 181 | -	private function splitFullId($id) { | |
| 182 | -		return explode(':', $id, 2); | |
| 183 | - } | |
| 184 | - | |
| 185 | - /** | |
| 186 | - * Verify if a password meets all requirements | |
| 187 | - * | |
| 188 | - * @param string $password | |
| 189 | - * @throws \Exception | |
| 190 | - */ | |
| 191 | -	protected function verifyPassword($password) { | |
| 192 | -		if ($password === null) { | |
| 193 | - // No password is set, check if this is allowed. | |
| 194 | -			if ($this->shareApiLinkEnforcePassword()) { | |
| 195 | -				throw new \InvalidArgumentException('Passwords are enforced for link shares'); | |
| 196 | - } | |
| 197 | - | |
| 198 | - return; | |
| 199 | - } | |
| 200 | - | |
| 201 | - // Let others verify the password | |
| 202 | -		try { | |
| 203 | - $this->legacyDispatcher->dispatch(new ValidatePasswordPolicyEvent($password)); | |
| 204 | -		} catch (HintException $e) { | |
| 205 | - throw new \Exception($e->getHint()); | |
| 206 | - } | |
| 207 | - } | |
| 208 | - | |
| 209 | - /** | |
| 210 | - * Check for generic requirements before creating a share | |
| 211 | - * | |
| 212 | - * @param \OCP\Share\IShare $share | |
| 213 | - * @throws \InvalidArgumentException | |
| 214 | - * @throws GenericShareException | |
| 215 | - * | |
| 216 | - * @suppress PhanUndeclaredClassMethod | |
| 217 | - */ | |
| 218 | -	protected function generalCreateChecks(\OCP\Share\IShare $share) { | |
| 219 | -		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { | |
| 220 | - // We expect a valid user as sharedWith for user shares | |
| 221 | -			if (!$this->userManager->userExists($share->getSharedWith())) { | |
| 222 | -				throw new \InvalidArgumentException('SharedWith is not a valid user'); | |
| 223 | - } | |
| 224 | -		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { | |
| 225 | - // We expect a valid group as sharedWith for group shares | |
| 226 | -			if (!$this->groupManager->groupExists($share->getSharedWith())) { | |
| 227 | -				throw new \InvalidArgumentException('SharedWith is not a valid group'); | |
| 228 | - } | |
| 229 | -		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { | |
| 230 | -			if ($share->getSharedWith() !== null) { | |
| 231 | -				throw new \InvalidArgumentException('SharedWith should be empty'); | |
| 232 | - } | |
| 233 | -		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) { | |
| 234 | -			if ($share->getSharedWith() === null) { | |
| 235 | -				throw new \InvalidArgumentException('SharedWith should not be empty'); | |
| 236 | - } | |
| 237 | -		}  else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) { | |
| 238 | -			if ($share->getSharedWith() === null) { | |
| 239 | -				throw new \InvalidArgumentException('SharedWith should not be empty'); | |
| 240 | - } | |
| 241 | -		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { | |
| 242 | -			if ($share->getSharedWith() === null) { | |
| 243 | -				throw new \InvalidArgumentException('SharedWith should not be empty'); | |
| 244 | - } | |
| 245 | -		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) { | |
| 246 | - $circle = \OCA\Circles\Api\v1\Circles::detailsCircle($share->getSharedWith()); | |
| 247 | -			if ($circle === null) { | |
| 248 | -				throw new \InvalidArgumentException('SharedWith is not a valid circle'); | |
| 249 | - } | |
| 250 | -		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_ROOM) { | |
| 251 | -		} else { | |
| 252 | - // We can't handle other types yet | |
| 253 | -			throw new \InvalidArgumentException('unknown share type'); | |
| 254 | - } | |
| 255 | - | |
| 256 | - // Verify the initiator of the share is set | |
| 257 | -		if ($share->getSharedBy() === null) { | |
| 258 | -			throw new \InvalidArgumentException('SharedBy should be set'); | |
| 259 | - } | |
| 260 | - | |
| 261 | - // Cannot share with yourself | |
| 262 | - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && | |
| 263 | -			$share->getSharedWith() === $share->getSharedBy()) { | |
| 264 | -			throw new \InvalidArgumentException('Can’t share with yourself'); | |
| 265 | - } | |
| 266 | - | |
| 267 | - // The path should be set | |
| 268 | -		if ($share->getNode() === null) { | |
| 269 | -			throw new \InvalidArgumentException('Path should be set'); | |
| 270 | - } | |
| 271 | - | |
| 272 | - // And it should be a file or a folder | |
| 273 | - if (!($share->getNode() instanceof \OCP\Files\File) && | |
| 274 | -				!($share->getNode() instanceof \OCP\Files\Folder)) { | |
| 275 | -			throw new \InvalidArgumentException('Path should be either a file or a folder'); | |
| 276 | - } | |
| 277 | - | |
| 278 | - // And you can't share your rootfolder | |
| 279 | -		if ($this->userManager->userExists($share->getSharedBy())) { | |
| 280 | - $userFolder = $this->rootFolder->getUserFolder($share->getSharedBy()); | |
| 281 | - $userFolderPath = $userFolder->getPath(); | |
| 282 | -		} else { | |
| 283 | - $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner()); | |
| 284 | - $userFolderPath = $userFolder->getPath(); | |
| 285 | - } | |
| 286 | -		if ($userFolderPath === $share->getNode()->getPath()) { | |
| 287 | -			throw new \InvalidArgumentException('You can’t share your root folder'); | |
| 288 | - } | |
| 289 | - | |
| 290 | - // Check if we actually have share permissions | |
| 291 | -		if (!$share->getNode()->isShareable()) { | |
| 292 | -			$message_t = $this->l->t('You are not allowed to share %s', [$share->getNode()->getPath()]); | |
| 293 | - throw new GenericShareException($message_t, $message_t, 404); | |
| 294 | - } | |
| 295 | - | |
| 296 | - // Permissions should be set | |
| 297 | -		if ($share->getPermissions() === null) { | |
| 298 | -			throw new \InvalidArgumentException('A share requires permissions'); | |
| 299 | - } | |
| 300 | - | |
| 301 | -		$isFederatedShare = $share->getNode()->getStorage()->instanceOfStorage('\OCA\Files_Sharing\External\Storage'); | |
| 302 | - $permissions = 0; | |
| 303 | - $mount = $share->getNode()->getMountPoint(); | |
| 304 | -		if (!$isFederatedShare && $share->getNode()->getOwner()->getUID() !== $share->getSharedBy()) { | |
| 305 | - // When it's a reshare use the parent share permissions as maximum | |
| 306 | - $userMountPointId = $mount->getStorageRootId(); | |
| 307 | - $userMountPoints = $userFolder->getById($userMountPointId); | |
| 308 | - $userMountPoint = array_shift($userMountPoints); | |
| 309 | - | |
| 310 | - /* Check if this is an incoming share */ | |
| 311 | - $incomingShares = $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_USER, $userMountPoint, -1, 0); | |
| 312 | - $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_GROUP, $userMountPoint, -1, 0)); | |
| 313 | - $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_CIRCLE, $userMountPoint, -1, 0)); | |
| 314 | - $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_ROOM, $userMountPoint, -1, 0)); | |
| 315 | - | |
| 316 | - /** @var \OCP\Share\IShare[] $incomingShares */ | |
| 317 | -			if (!empty($incomingShares)) { | |
| 318 | -				foreach ($incomingShares as $incomingShare) { | |
| 319 | - $permissions |= $incomingShare->getPermissions(); | |
| 320 | - } | |
| 321 | - } | |
| 322 | -		} else { | |
| 323 | - /* | |
| 80 | + /** @var IProviderFactory */ | |
| 81 | + private $factory; | |
| 82 | + /** @var ILogger */ | |
| 83 | + private $logger; | |
| 84 | + /** @var IConfig */ | |
| 85 | + private $config; | |
| 86 | + /** @var ISecureRandom */ | |
| 87 | + private $secureRandom; | |
| 88 | + /** @var IHasher */ | |
| 89 | + private $hasher; | |
| 90 | + /** @var IMountManager */ | |
| 91 | + private $mountManager; | |
| 92 | + /** @var IGroupManager */ | |
| 93 | + private $groupManager; | |
| 94 | + /** @var IL10N */ | |
| 95 | + private $l; | |
| 96 | + /** @var IFactory */ | |
| 97 | + private $l10nFactory; | |
| 98 | + /** @var IUserManager */ | |
| 99 | + private $userManager; | |
| 100 | + /** @var IRootFolder */ | |
| 101 | + private $rootFolder; | |
| 102 | + /** @var CappedMemoryCache */ | |
| 103 | + private $sharingDisabledForUsersCache; | |
| 104 | + /** @var EventDispatcherInterface */ | |
| 105 | + private $legacyDispatcher; | |
| 106 | + /** @var LegacyHooks */ | |
| 107 | + private $legacyHooks; | |
| 108 | + /** @var IMailer */ | |
| 109 | + private $mailer; | |
| 110 | + /** @var IURLGenerator */ | |
| 111 | + private $urlGenerator; | |
| 112 | + /** @var \OC_Defaults */ | |
| 113 | + private $defaults; | |
| 114 | + /** @var IEventDispatcher */ | |
| 115 | + private $dispatcher; | |
| 116 | + | |
| 117 | + | |
| 118 | + /** | |
| 119 | + * Manager constructor. | |
| 120 | + * | |
| 121 | + * @param ILogger $logger | |
| 122 | + * @param IConfig $config | |
| 123 | + * @param ISecureRandom $secureRandom | |
| 124 | + * @param IHasher $hasher | |
| 125 | + * @param IMountManager $mountManager | |
| 126 | + * @param IGroupManager $groupManager | |
| 127 | + * @param IL10N $l | |
| 128 | + * @param IFactory $l10nFactory | |
| 129 | + * @param IProviderFactory $factory | |
| 130 | + * @param IUserManager $userManager | |
| 131 | + * @param IRootFolder $rootFolder | |
| 132 | + * @param EventDispatcherInterface $eventDispatcher | |
| 133 | + * @param IMailer $mailer | |
| 134 | + * @param IURLGenerator $urlGenerator | |
| 135 | + * @param \OC_Defaults $defaults | |
| 136 | + */ | |
| 137 | + public function __construct( | |
| 138 | + ILogger $logger, | |
| 139 | + IConfig $config, | |
| 140 | + ISecureRandom $secureRandom, | |
| 141 | + IHasher $hasher, | |
| 142 | + IMountManager $mountManager, | |
| 143 | + IGroupManager $groupManager, | |
| 144 | + IL10N $l, | |
| 145 | + IFactory $l10nFactory, | |
| 146 | + IProviderFactory $factory, | |
| 147 | + IUserManager $userManager, | |
| 148 | + IRootFolder $rootFolder, | |
| 149 | + EventDispatcherInterface $legacyDispatcher, | |
| 150 | + IMailer $mailer, | |
| 151 | + IURLGenerator $urlGenerator, | |
| 152 | + \OC_Defaults $defaults, | |
| 153 | + IEventDispatcher $dispatcher | |
| 154 | +    ) { | |
| 155 | + $this->logger = $logger; | |
| 156 | + $this->config = $config; | |
| 157 | + $this->secureRandom = $secureRandom; | |
| 158 | + $this->hasher = $hasher; | |
| 159 | + $this->mountManager = $mountManager; | |
| 160 | + $this->groupManager = $groupManager; | |
| 161 | + $this->l = $l; | |
| 162 | + $this->l10nFactory = $l10nFactory; | |
| 163 | + $this->factory = $factory; | |
| 164 | + $this->userManager = $userManager; | |
| 165 | + $this->rootFolder = $rootFolder; | |
| 166 | + $this->legacyDispatcher = $legacyDispatcher; | |
| 167 | + $this->sharingDisabledForUsersCache = new CappedMemoryCache(); | |
| 168 | + $this->legacyHooks = new LegacyHooks($this->legacyDispatcher); | |
| 169 | + $this->mailer = $mailer; | |
| 170 | + $this->urlGenerator = $urlGenerator; | |
| 171 | + $this->defaults = $defaults; | |
| 172 | + $this->dispatcher = $dispatcher; | |
| 173 | + } | |
| 174 | + | |
| 175 | + /** | |
| 176 | + * Convert from a full share id to a tuple (providerId, shareId) | |
| 177 | + * | |
| 178 | + * @param string $id | |
| 179 | + * @return string[] | |
| 180 | + */ | |
| 181 | +    private function splitFullId($id) { | |
| 182 | +        return explode(':', $id, 2); | |
| 183 | + } | |
| 184 | + | |
| 185 | + /** | |
| 186 | + * Verify if a password meets all requirements | |
| 187 | + * | |
| 188 | + * @param string $password | |
| 189 | + * @throws \Exception | |
| 190 | + */ | |
| 191 | +    protected function verifyPassword($password) { | |
| 192 | +        if ($password === null) { | |
| 193 | + // No password is set, check if this is allowed. | |
| 194 | +            if ($this->shareApiLinkEnforcePassword()) { | |
| 195 | +                throw new \InvalidArgumentException('Passwords are enforced for link shares'); | |
| 196 | + } | |
| 197 | + | |
| 198 | + return; | |
| 199 | + } | |
| 200 | + | |
| 201 | + // Let others verify the password | |
| 202 | +        try { | |
| 203 | + $this->legacyDispatcher->dispatch(new ValidatePasswordPolicyEvent($password)); | |
| 204 | +        } catch (HintException $e) { | |
| 205 | + throw new \Exception($e->getHint()); | |
| 206 | + } | |
| 207 | + } | |
| 208 | + | |
| 209 | + /** | |
| 210 | + * Check for generic requirements before creating a share | |
| 211 | + * | |
| 212 | + * @param \OCP\Share\IShare $share | |
| 213 | + * @throws \InvalidArgumentException | |
| 214 | + * @throws GenericShareException | |
| 215 | + * | |
| 216 | + * @suppress PhanUndeclaredClassMethod | |
| 217 | + */ | |
| 218 | +    protected function generalCreateChecks(\OCP\Share\IShare $share) { | |
| 219 | +        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { | |
| 220 | + // We expect a valid user as sharedWith for user shares | |
| 221 | +            if (!$this->userManager->userExists($share->getSharedWith())) { | |
| 222 | +                throw new \InvalidArgumentException('SharedWith is not a valid user'); | |
| 223 | + } | |
| 224 | +        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { | |
| 225 | + // We expect a valid group as sharedWith for group shares | |
| 226 | +            if (!$this->groupManager->groupExists($share->getSharedWith())) { | |
| 227 | +                throw new \InvalidArgumentException('SharedWith is not a valid group'); | |
| 228 | + } | |
| 229 | +        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { | |
| 230 | +            if ($share->getSharedWith() !== null) { | |
| 231 | +                throw new \InvalidArgumentException('SharedWith should be empty'); | |
| 232 | + } | |
| 233 | +        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) { | |
| 234 | +            if ($share->getSharedWith() === null) { | |
| 235 | +                throw new \InvalidArgumentException('SharedWith should not be empty'); | |
| 236 | + } | |
| 237 | +        }  else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) { | |
| 238 | +            if ($share->getSharedWith() === null) { | |
| 239 | +                throw new \InvalidArgumentException('SharedWith should not be empty'); | |
| 240 | + } | |
| 241 | +        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { | |
| 242 | +            if ($share->getSharedWith() === null) { | |
| 243 | +                throw new \InvalidArgumentException('SharedWith should not be empty'); | |
| 244 | + } | |
| 245 | +        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) { | |
| 246 | + $circle = \OCA\Circles\Api\v1\Circles::detailsCircle($share->getSharedWith()); | |
| 247 | +            if ($circle === null) { | |
| 248 | +                throw new \InvalidArgumentException('SharedWith is not a valid circle'); | |
| 249 | + } | |
| 250 | +        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_ROOM) { | |
| 251 | +        } else { | |
| 252 | + // We can't handle other types yet | |
| 253 | +            throw new \InvalidArgumentException('unknown share type'); | |
| 254 | + } | |
| 255 | + | |
| 256 | + // Verify the initiator of the share is set | |
| 257 | +        if ($share->getSharedBy() === null) { | |
| 258 | +            throw new \InvalidArgumentException('SharedBy should be set'); | |
| 259 | + } | |
| 260 | + | |
| 261 | + // Cannot share with yourself | |
| 262 | + if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && | |
| 263 | +            $share->getSharedWith() === $share->getSharedBy()) { | |
| 264 | +            throw new \InvalidArgumentException('Can’t share with yourself'); | |
| 265 | + } | |
| 266 | + | |
| 267 | + // The path should be set | |
| 268 | +        if ($share->getNode() === null) { | |
| 269 | +            throw new \InvalidArgumentException('Path should be set'); | |
| 270 | + } | |
| 271 | + | |
| 272 | + // And it should be a file or a folder | |
| 273 | + if (!($share->getNode() instanceof \OCP\Files\File) && | |
| 274 | +                !($share->getNode() instanceof \OCP\Files\Folder)) { | |
| 275 | +            throw new \InvalidArgumentException('Path should be either a file or a folder'); | |
| 276 | + } | |
| 277 | + | |
| 278 | + // And you can't share your rootfolder | |
| 279 | +        if ($this->userManager->userExists($share->getSharedBy())) { | |
| 280 | + $userFolder = $this->rootFolder->getUserFolder($share->getSharedBy()); | |
| 281 | + $userFolderPath = $userFolder->getPath(); | |
| 282 | +        } else { | |
| 283 | + $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner()); | |
| 284 | + $userFolderPath = $userFolder->getPath(); | |
| 285 | + } | |
| 286 | +        if ($userFolderPath === $share->getNode()->getPath()) { | |
| 287 | +            throw new \InvalidArgumentException('You can’t share your root folder'); | |
| 288 | + } | |
| 289 | + | |
| 290 | + // Check if we actually have share permissions | |
| 291 | +        if (!$share->getNode()->isShareable()) { | |
| 292 | +            $message_t = $this->l->t('You are not allowed to share %s', [$share->getNode()->getPath()]); | |
| 293 | + throw new GenericShareException($message_t, $message_t, 404); | |
| 294 | + } | |
| 295 | + | |
| 296 | + // Permissions should be set | |
| 297 | +        if ($share->getPermissions() === null) { | |
| 298 | +            throw new \InvalidArgumentException('A share requires permissions'); | |
| 299 | + } | |
| 300 | + | |
| 301 | +        $isFederatedShare = $share->getNode()->getStorage()->instanceOfStorage('\OCA\Files_Sharing\External\Storage'); | |
| 302 | + $permissions = 0; | |
| 303 | + $mount = $share->getNode()->getMountPoint(); | |
| 304 | +        if (!$isFederatedShare && $share->getNode()->getOwner()->getUID() !== $share->getSharedBy()) { | |
| 305 | + // When it's a reshare use the parent share permissions as maximum | |
| 306 | + $userMountPointId = $mount->getStorageRootId(); | |
| 307 | + $userMountPoints = $userFolder->getById($userMountPointId); | |
| 308 | + $userMountPoint = array_shift($userMountPoints); | |
| 309 | + | |
| 310 | + /* Check if this is an incoming share */ | |
| 311 | + $incomingShares = $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_USER, $userMountPoint, -1, 0); | |
| 312 | + $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_GROUP, $userMountPoint, -1, 0)); | |
| 313 | + $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_CIRCLE, $userMountPoint, -1, 0)); | |
| 314 | + $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_ROOM, $userMountPoint, -1, 0)); | |
| 315 | + | |
| 316 | + /** @var \OCP\Share\IShare[] $incomingShares */ | |
| 317 | +            if (!empty($incomingShares)) { | |
| 318 | +                foreach ($incomingShares as $incomingShare) { | |
| 319 | + $permissions |= $incomingShare->getPermissions(); | |
| 320 | + } | |
| 321 | + } | |
| 322 | +        } else { | |
| 323 | + /* | |
| 324 | 324 | * Quick fix for #23536 | 
| 325 | 325 | * Non moveable mount points do not have update and delete permissions | 
| 326 | 326 | * while we 'most likely' do have that on the storage. | 
| 327 | 327 | */ | 
| 328 | - $permissions = $share->getNode()->getPermissions(); | |
| 329 | -			if (!($mount instanceof MoveableMount)) { | |
| 330 | - $permissions |= \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_UPDATE; | |
| 331 | - } | |
| 332 | - } | |
| 333 | - | |
| 334 | - // Check that we do not share with more permissions than we have | |
| 335 | -		if ($share->getPermissions() & ~$permissions) { | |
| 336 | -			$message_t = $this->l->t('Can’t increase permissions of %s', [$share->getNode()->getPath()]); | |
| 337 | - throw new GenericShareException($message_t, $message_t, 404); | |
| 338 | - } | |
| 339 | - | |
| 340 | - | |
| 341 | - // Check that read permissions are always set | |
| 342 | - // Link shares are allowed to have no read permissions to allow upload to hidden folders | |
| 343 | - $noReadPermissionRequired = $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK | |
| 344 | - || $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL; | |
| 345 | - if (!$noReadPermissionRequired && | |
| 346 | -			($share->getPermissions() & \OCP\Constants::PERMISSION_READ) === 0) { | |
| 347 | -			throw new \InvalidArgumentException('Shares need at least read permissions'); | |
| 348 | - } | |
| 349 | - | |
| 350 | -		if ($share->getNode() instanceof \OCP\Files\File) { | |
| 351 | -			if ($share->getPermissions() & \OCP\Constants::PERMISSION_DELETE) { | |
| 352 | -				$message_t = $this->l->t('Files can’t be shared with delete permissions'); | |
| 353 | - throw new GenericShareException($message_t); | |
| 354 | - } | |
| 355 | -			if ($share->getPermissions() & \OCP\Constants::PERMISSION_CREATE) { | |
| 356 | -				$message_t = $this->l->t('Files can’t be shared with create permissions'); | |
| 357 | - throw new GenericShareException($message_t); | |
| 358 | - } | |
| 359 | - } | |
| 360 | - } | |
| 361 | - | |
| 362 | - /** | |
| 363 | - * Validate if the expiration date fits the system settings | |
| 364 | - * | |
| 365 | - * @param \OCP\Share\IShare $share The share to validate the expiration date of | |
| 366 | - * @return \OCP\Share\IShare The modified share object | |
| 367 | - * @throws GenericShareException | |
| 368 | - * @throws \InvalidArgumentException | |
| 369 | - * @throws \Exception | |
| 370 | - */ | |
| 371 | -	protected function validateExpirationDateInternal(\OCP\Share\IShare $share) { | |
| 372 | - $expirationDate = $share->getExpirationDate(); | |
| 373 | - | |
| 374 | -		if ($expirationDate !== null) { | |
| 375 | - //Make sure the expiration date is a date | |
| 376 | - $expirationDate->setTime(0, 0, 0); | |
| 377 | - | |
| 378 | - $date = new \DateTime(); | |
| 379 | - $date->setTime(0, 0, 0); | |
| 380 | -			if ($date >= $expirationDate) { | |
| 381 | -				$message = $this->l->t('Expiration date is in the past'); | |
| 382 | - throw new GenericShareException($message, $message, 404); | |
| 383 | - } | |
| 384 | - } | |
| 385 | - | |
| 386 | - // If expiredate is empty set a default one if there is a default | |
| 387 | - $fullId = null; | |
| 388 | -		try { | |
| 389 | - $fullId = $share->getFullId(); | |
| 390 | -		} catch (\UnexpectedValueException $e) { | |
| 391 | - // This is a new share | |
| 392 | - } | |
| 393 | - | |
| 394 | -		if ($fullId === null && $expirationDate === null && $this->shareApiInternalDefaultExpireDate()) { | |
| 395 | - $expirationDate = new \DateTime(); | |
| 396 | - $expirationDate->setTime(0,0,0); | |
| 397 | -			$expirationDate->add(new \DateInterval('P'.$this->shareApiInternalDefaultExpireDays().'D')); | |
| 398 | - } | |
| 399 | - | |
| 400 | - // If we enforce the expiration date check that is does not exceed | |
| 401 | -		if ($this->shareApiInternalDefaultExpireDateEnforced()) { | |
| 402 | -			if ($expirationDate === null) { | |
| 403 | -				throw new \InvalidArgumentException('Expiration date is enforced'); | |
| 404 | - } | |
| 405 | - | |
| 406 | - $date = new \DateTime(); | |
| 407 | - $date->setTime(0, 0, 0); | |
| 408 | -			$date->add(new \DateInterval('P' . $this->shareApiInternalDefaultExpireDays() . 'D')); | |
| 409 | -			if ($date < $expirationDate) { | |
| 410 | -				$message = $this->l->t('Can’t set expiration date more than %s days in the future', [$this->shareApiInternalDefaultExpireDays()]); | |
| 411 | - throw new GenericShareException($message, $message, 404); | |
| 412 | - } | |
| 413 | - } | |
| 414 | - | |
| 415 | - $accepted = true; | |
| 416 | - $message = ''; | |
| 417 | -		\OCP\Util::emitHook('\OC\Share', 'verifyExpirationDate', [ | |
| 418 | - 'expirationDate' => &$expirationDate, | |
| 419 | - 'accepted' => &$accepted, | |
| 420 | - 'message' => &$message, | |
| 421 | - 'passwordSet' => $share->getPassword() !== null, | |
| 422 | - ]); | |
| 423 | - | |
| 424 | -		if (!$accepted) { | |
| 425 | - throw new \Exception($message); | |
| 426 | - } | |
| 427 | - | |
| 428 | - $share->setExpirationDate($expirationDate); | |
| 429 | - | |
| 430 | - return $share; | |
| 431 | - } | |
| 432 | - | |
| 433 | - /** | |
| 434 | - * Validate if the expiration date fits the system settings | |
| 435 | - * | |
| 436 | - * @param \OCP\Share\IShare $share The share to validate the expiration date of | |
| 437 | - * @return \OCP\Share\IShare The modified share object | |
| 438 | - * @throws GenericShareException | |
| 439 | - * @throws \InvalidArgumentException | |
| 440 | - * @throws \Exception | |
| 441 | - */ | |
| 442 | -	protected function validateExpirationDate(\OCP\Share\IShare $share) { | |
| 443 | - | |
| 444 | - $expirationDate = $share->getExpirationDate(); | |
| 445 | - | |
| 446 | -		if ($expirationDate !== null) { | |
| 447 | - //Make sure the expiration date is a date | |
| 448 | - $expirationDate->setTime(0, 0, 0); | |
| 449 | - | |
| 450 | - $date = new \DateTime(); | |
| 451 | - $date->setTime(0, 0, 0); | |
| 452 | -			if ($date >= $expirationDate) { | |
| 453 | -				$message = $this->l->t('Expiration date is in the past'); | |
| 454 | - throw new GenericShareException($message, $message, 404); | |
| 455 | - } | |
| 456 | - } | |
| 457 | - | |
| 458 | - // If expiredate is empty set a default one if there is a default | |
| 459 | - $fullId = null; | |
| 460 | -		try { | |
| 461 | - $fullId = $share->getFullId(); | |
| 462 | -		} catch (\UnexpectedValueException $e) { | |
| 463 | - // This is a new share | |
| 464 | - } | |
| 465 | - | |
| 466 | -		if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) { | |
| 467 | - $expirationDate = new \DateTime(); | |
| 468 | - $expirationDate->setTime(0,0,0); | |
| 469 | -			$expirationDate->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D')); | |
| 470 | - } | |
| 471 | - | |
| 472 | - // If we enforce the expiration date check that is does not exceed | |
| 473 | -		if ($this->shareApiLinkDefaultExpireDateEnforced()) { | |
| 474 | -			if ($expirationDate === null) { | |
| 475 | -				throw new \InvalidArgumentException('Expiration date is enforced'); | |
| 476 | - } | |
| 477 | - | |
| 478 | - $date = new \DateTime(); | |
| 479 | - $date->setTime(0, 0, 0); | |
| 480 | -			$date->add(new \DateInterval('P' . $this->shareApiLinkDefaultExpireDays() . 'D')); | |
| 481 | -			if ($date < $expirationDate) { | |
| 482 | -				$message = $this->l->t('Can’t set expiration date more than %s days in the future', [$this->shareApiLinkDefaultExpireDays()]); | |
| 483 | - throw new GenericShareException($message, $message, 404); | |
| 484 | - } | |
| 485 | - } | |
| 486 | - | |
| 487 | - $accepted = true; | |
| 488 | - $message = ''; | |
| 489 | -		\OCP\Util::emitHook('\OC\Share', 'verifyExpirationDate', [ | |
| 490 | - 'expirationDate' => &$expirationDate, | |
| 491 | - 'accepted' => &$accepted, | |
| 492 | - 'message' => &$message, | |
| 493 | - 'passwordSet' => $share->getPassword() !== null, | |
| 494 | - ]); | |
| 495 | - | |
| 496 | -		if (!$accepted) { | |
| 497 | - throw new \Exception($message); | |
| 498 | - } | |
| 499 | - | |
| 500 | - $share->setExpirationDate($expirationDate); | |
| 501 | - | |
| 502 | - return $share; | |
| 503 | - } | |
| 504 | - | |
| 505 | - /** | |
| 506 | - * Check for pre share requirements for user shares | |
| 507 | - * | |
| 508 | - * @param \OCP\Share\IShare $share | |
| 509 | - * @throws \Exception | |
| 510 | - */ | |
| 511 | -	protected function userCreateChecks(\OCP\Share\IShare $share) { | |
| 512 | - // Check if we can share with group members only | |
| 513 | -		if ($this->shareWithGroupMembersOnly()) { | |
| 514 | - $sharedBy = $this->userManager->get($share->getSharedBy()); | |
| 515 | - $sharedWith = $this->userManager->get($share->getSharedWith()); | |
| 516 | - // Verify we can share with this user | |
| 517 | - $groups = array_intersect( | |
| 518 | - $this->groupManager->getUserGroupIds($sharedBy), | |
| 519 | - $this->groupManager->getUserGroupIds($sharedWith) | |
| 520 | - ); | |
| 521 | -			if (empty($groups)) { | |
| 522 | -				throw new \Exception('Sharing is only allowed with group members'); | |
| 523 | - } | |
| 524 | - } | |
| 525 | - | |
| 526 | - /* | |
| 328 | + $permissions = $share->getNode()->getPermissions(); | |
| 329 | +            if (!($mount instanceof MoveableMount)) { | |
| 330 | + $permissions |= \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_UPDATE; | |
| 331 | + } | |
| 332 | + } | |
| 333 | + | |
| 334 | + // Check that we do not share with more permissions than we have | |
| 335 | +        if ($share->getPermissions() & ~$permissions) { | |
| 336 | +            $message_t = $this->l->t('Can’t increase permissions of %s', [$share->getNode()->getPath()]); | |
| 337 | + throw new GenericShareException($message_t, $message_t, 404); | |
| 338 | + } | |
| 339 | + | |
| 340 | + | |
| 341 | + // Check that read permissions are always set | |
| 342 | + // Link shares are allowed to have no read permissions to allow upload to hidden folders | |
| 343 | + $noReadPermissionRequired = $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK | |
| 344 | + || $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL; | |
| 345 | + if (!$noReadPermissionRequired && | |
| 346 | +            ($share->getPermissions() & \OCP\Constants::PERMISSION_READ) === 0) { | |
| 347 | +            throw new \InvalidArgumentException('Shares need at least read permissions'); | |
| 348 | + } | |
| 349 | + | |
| 350 | +        if ($share->getNode() instanceof \OCP\Files\File) { | |
| 351 | +            if ($share->getPermissions() & \OCP\Constants::PERMISSION_DELETE) { | |
| 352 | +                $message_t = $this->l->t('Files can’t be shared with delete permissions'); | |
| 353 | + throw new GenericShareException($message_t); | |
| 354 | + } | |
| 355 | +            if ($share->getPermissions() & \OCP\Constants::PERMISSION_CREATE) { | |
| 356 | +                $message_t = $this->l->t('Files can’t be shared with create permissions'); | |
| 357 | + throw new GenericShareException($message_t); | |
| 358 | + } | |
| 359 | + } | |
| 360 | + } | |
| 361 | + | |
| 362 | + /** | |
| 363 | + * Validate if the expiration date fits the system settings | |
| 364 | + * | |
| 365 | + * @param \OCP\Share\IShare $share The share to validate the expiration date of | |
| 366 | + * @return \OCP\Share\IShare The modified share object | |
| 367 | + * @throws GenericShareException | |
| 368 | + * @throws \InvalidArgumentException | |
| 369 | + * @throws \Exception | |
| 370 | + */ | |
| 371 | +    protected function validateExpirationDateInternal(\OCP\Share\IShare $share) { | |
| 372 | + $expirationDate = $share->getExpirationDate(); | |
| 373 | + | |
| 374 | +        if ($expirationDate !== null) { | |
| 375 | + //Make sure the expiration date is a date | |
| 376 | + $expirationDate->setTime(0, 0, 0); | |
| 377 | + | |
| 378 | + $date = new \DateTime(); | |
| 379 | + $date->setTime(0, 0, 0); | |
| 380 | +            if ($date >= $expirationDate) { | |
| 381 | +                $message = $this->l->t('Expiration date is in the past'); | |
| 382 | + throw new GenericShareException($message, $message, 404); | |
| 383 | + } | |
| 384 | + } | |
| 385 | + | |
| 386 | + // If expiredate is empty set a default one if there is a default | |
| 387 | + $fullId = null; | |
| 388 | +        try { | |
| 389 | + $fullId = $share->getFullId(); | |
| 390 | +        } catch (\UnexpectedValueException $e) { | |
| 391 | + // This is a new share | |
| 392 | + } | |
| 393 | + | |
| 394 | +        if ($fullId === null && $expirationDate === null && $this->shareApiInternalDefaultExpireDate()) { | |
| 395 | + $expirationDate = new \DateTime(); | |
| 396 | + $expirationDate->setTime(0,0,0); | |
| 397 | +            $expirationDate->add(new \DateInterval('P'.$this->shareApiInternalDefaultExpireDays().'D')); | |
| 398 | + } | |
| 399 | + | |
| 400 | + // If we enforce the expiration date check that is does not exceed | |
| 401 | +        if ($this->shareApiInternalDefaultExpireDateEnforced()) { | |
| 402 | +            if ($expirationDate === null) { | |
| 403 | +                throw new \InvalidArgumentException('Expiration date is enforced'); | |
| 404 | + } | |
| 405 | + | |
| 406 | + $date = new \DateTime(); | |
| 407 | + $date->setTime(0, 0, 0); | |
| 408 | +            $date->add(new \DateInterval('P' . $this->shareApiInternalDefaultExpireDays() . 'D')); | |
| 409 | +            if ($date < $expirationDate) { | |
| 410 | +                $message = $this->l->t('Can’t set expiration date more than %s days in the future', [$this->shareApiInternalDefaultExpireDays()]); | |
| 411 | + throw new GenericShareException($message, $message, 404); | |
| 412 | + } | |
| 413 | + } | |
| 414 | + | |
| 415 | + $accepted = true; | |
| 416 | + $message = ''; | |
| 417 | +        \OCP\Util::emitHook('\OC\Share', 'verifyExpirationDate', [ | |
| 418 | + 'expirationDate' => &$expirationDate, | |
| 419 | + 'accepted' => &$accepted, | |
| 420 | + 'message' => &$message, | |
| 421 | + 'passwordSet' => $share->getPassword() !== null, | |
| 422 | + ]); | |
| 423 | + | |
| 424 | +        if (!$accepted) { | |
| 425 | + throw new \Exception($message); | |
| 426 | + } | |
| 427 | + | |
| 428 | + $share->setExpirationDate($expirationDate); | |
| 429 | + | |
| 430 | + return $share; | |
| 431 | + } | |
| 432 | + | |
| 433 | + /** | |
| 434 | + * Validate if the expiration date fits the system settings | |
| 435 | + * | |
| 436 | + * @param \OCP\Share\IShare $share The share to validate the expiration date of | |
| 437 | + * @return \OCP\Share\IShare The modified share object | |
| 438 | + * @throws GenericShareException | |
| 439 | + * @throws \InvalidArgumentException | |
| 440 | + * @throws \Exception | |
| 441 | + */ | |
| 442 | +    protected function validateExpirationDate(\OCP\Share\IShare $share) { | |
| 443 | + | |
| 444 | + $expirationDate = $share->getExpirationDate(); | |
| 445 | + | |
| 446 | +        if ($expirationDate !== null) { | |
| 447 | + //Make sure the expiration date is a date | |
| 448 | + $expirationDate->setTime(0, 0, 0); | |
| 449 | + | |
| 450 | + $date = new \DateTime(); | |
| 451 | + $date->setTime(0, 0, 0); | |
| 452 | +            if ($date >= $expirationDate) { | |
| 453 | +                $message = $this->l->t('Expiration date is in the past'); | |
| 454 | + throw new GenericShareException($message, $message, 404); | |
| 455 | + } | |
| 456 | + } | |
| 457 | + | |
| 458 | + // If expiredate is empty set a default one if there is a default | |
| 459 | + $fullId = null; | |
| 460 | +        try { | |
| 461 | + $fullId = $share->getFullId(); | |
| 462 | +        } catch (\UnexpectedValueException $e) { | |
| 463 | + // This is a new share | |
| 464 | + } | |
| 465 | + | |
| 466 | +        if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) { | |
| 467 | + $expirationDate = new \DateTime(); | |
| 468 | + $expirationDate->setTime(0,0,0); | |
| 469 | +            $expirationDate->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D')); | |
| 470 | + } | |
| 471 | + | |
| 472 | + // If we enforce the expiration date check that is does not exceed | |
| 473 | +        if ($this->shareApiLinkDefaultExpireDateEnforced()) { | |
| 474 | +            if ($expirationDate === null) { | |
| 475 | +                throw new \InvalidArgumentException('Expiration date is enforced'); | |
| 476 | + } | |
| 477 | + | |
| 478 | + $date = new \DateTime(); | |
| 479 | + $date->setTime(0, 0, 0); | |
| 480 | +            $date->add(new \DateInterval('P' . $this->shareApiLinkDefaultExpireDays() . 'D')); | |
| 481 | +            if ($date < $expirationDate) { | |
| 482 | +                $message = $this->l->t('Can’t set expiration date more than %s days in the future', [$this->shareApiLinkDefaultExpireDays()]); | |
| 483 | + throw new GenericShareException($message, $message, 404); | |
| 484 | + } | |
| 485 | + } | |
| 486 | + | |
| 487 | + $accepted = true; | |
| 488 | + $message = ''; | |
| 489 | +        \OCP\Util::emitHook('\OC\Share', 'verifyExpirationDate', [ | |
| 490 | + 'expirationDate' => &$expirationDate, | |
| 491 | + 'accepted' => &$accepted, | |
| 492 | + 'message' => &$message, | |
| 493 | + 'passwordSet' => $share->getPassword() !== null, | |
| 494 | + ]); | |
| 495 | + | |
| 496 | +        if (!$accepted) { | |
| 497 | + throw new \Exception($message); | |
| 498 | + } | |
| 499 | + | |
| 500 | + $share->setExpirationDate($expirationDate); | |
| 501 | + | |
| 502 | + return $share; | |
| 503 | + } | |
| 504 | + | |
| 505 | + /** | |
| 506 | + * Check for pre share requirements for user shares | |
| 507 | + * | |
| 508 | + * @param \OCP\Share\IShare $share | |
| 509 | + * @throws \Exception | |
| 510 | + */ | |
| 511 | +    protected function userCreateChecks(\OCP\Share\IShare $share) { | |
| 512 | + // Check if we can share with group members only | |
| 513 | +        if ($this->shareWithGroupMembersOnly()) { | |
| 514 | + $sharedBy = $this->userManager->get($share->getSharedBy()); | |
| 515 | + $sharedWith = $this->userManager->get($share->getSharedWith()); | |
| 516 | + // Verify we can share with this user | |
| 517 | + $groups = array_intersect( | |
| 518 | + $this->groupManager->getUserGroupIds($sharedBy), | |
| 519 | + $this->groupManager->getUserGroupIds($sharedWith) | |
| 520 | + ); | |
| 521 | +            if (empty($groups)) { | |
| 522 | +                throw new \Exception('Sharing is only allowed with group members'); | |
| 523 | + } | |
| 524 | + } | |
| 525 | + | |
| 526 | + /* | |
| 527 | 527 | * TODO: Could be costly, fix | 
| 528 | 528 | * | 
| 529 | 529 | * Also this is not what we want in the future.. then we want to squash identical shares. | 
| 530 | 530 | */ | 
| 531 | - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_USER); | |
| 532 | - $existingShares = $provider->getSharesByPath($share->getNode()); | |
| 533 | -		foreach($existingShares as $existingShare) { | |
| 534 | - // Ignore if it is the same share | |
| 535 | -			try { | |
| 536 | -				if ($existingShare->getFullId() === $share->getFullId()) { | |
| 537 | - continue; | |
| 538 | - } | |
| 539 | -			} catch (\UnexpectedValueException $e) { | |
| 540 | - //Shares are not identical | |
| 541 | - } | |
| 542 | - | |
| 543 | - // Identical share already existst | |
| 544 | -			if ($existingShare->getSharedWith() === $share->getSharedWith() && $existingShare->getShareType() === $share->getShareType()) { | |
| 545 | -				throw new \Exception('Path is already shared with this user'); | |
| 546 | - } | |
| 547 | - | |
| 548 | - // The share is already shared with this user via a group share | |
| 549 | -			if ($existingShare->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { | |
| 550 | - $group = $this->groupManager->get($existingShare->getSharedWith()); | |
| 551 | -				if (!is_null($group)) { | |
| 552 | - $user = $this->userManager->get($share->getSharedWith()); | |
| 553 | - | |
| 554 | -					if ($group->inGroup($user) && $existingShare->getShareOwner() !== $share->getShareOwner()) { | |
| 555 | -						throw new \Exception('Path is already shared with this user'); | |
| 556 | - } | |
| 557 | - } | |
| 558 | - } | |
| 559 | - } | |
| 560 | - } | |
| 561 | - | |
| 562 | - /** | |
| 563 | - * Check for pre share requirements for group shares | |
| 564 | - * | |
| 565 | - * @param \OCP\Share\IShare $share | |
| 566 | - * @throws \Exception | |
| 567 | - */ | |
| 568 | -	protected function groupCreateChecks(\OCP\Share\IShare $share) { | |
| 569 | - // Verify group shares are allowed | |
| 570 | -		if (!$this->allowGroupSharing()) { | |
| 571 | -			throw new \Exception('Group sharing is now allowed'); | |
| 572 | - } | |
| 573 | - | |
| 574 | - // Verify if the user can share with this group | |
| 575 | -		if ($this->shareWithGroupMembersOnly()) { | |
| 576 | - $sharedBy = $this->userManager->get($share->getSharedBy()); | |
| 577 | - $sharedWith = $this->groupManager->get($share->getSharedWith()); | |
| 578 | -			if (is_null($sharedWith) || !$sharedWith->inGroup($sharedBy)) { | |
| 579 | -				throw new \Exception('Sharing is only allowed within your own groups'); | |
| 580 | - } | |
| 581 | - } | |
| 582 | - | |
| 583 | - /* | |
| 531 | + $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_USER); | |
| 532 | + $existingShares = $provider->getSharesByPath($share->getNode()); | |
| 533 | +        foreach($existingShares as $existingShare) { | |
| 534 | + // Ignore if it is the same share | |
| 535 | +            try { | |
| 536 | +                if ($existingShare->getFullId() === $share->getFullId()) { | |
| 537 | + continue; | |
| 538 | + } | |
| 539 | +            } catch (\UnexpectedValueException $e) { | |
| 540 | + //Shares are not identical | |
| 541 | + } | |
| 542 | + | |
| 543 | + // Identical share already existst | |
| 544 | +            if ($existingShare->getSharedWith() === $share->getSharedWith() && $existingShare->getShareType() === $share->getShareType()) { | |
| 545 | +                throw new \Exception('Path is already shared with this user'); | |
| 546 | + } | |
| 547 | + | |
| 548 | + // The share is already shared with this user via a group share | |
| 549 | +            if ($existingShare->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { | |
| 550 | + $group = $this->groupManager->get($existingShare->getSharedWith()); | |
| 551 | +                if (!is_null($group)) { | |
| 552 | + $user = $this->userManager->get($share->getSharedWith()); | |
| 553 | + | |
| 554 | +                    if ($group->inGroup($user) && $existingShare->getShareOwner() !== $share->getShareOwner()) { | |
| 555 | +                        throw new \Exception('Path is already shared with this user'); | |
| 556 | + } | |
| 557 | + } | |
| 558 | + } | |
| 559 | + } | |
| 560 | + } | |
| 561 | + | |
| 562 | + /** | |
| 563 | + * Check for pre share requirements for group shares | |
| 564 | + * | |
| 565 | + * @param \OCP\Share\IShare $share | |
| 566 | + * @throws \Exception | |
| 567 | + */ | |
| 568 | +    protected function groupCreateChecks(\OCP\Share\IShare $share) { | |
| 569 | + // Verify group shares are allowed | |
| 570 | +        if (!$this->allowGroupSharing()) { | |
| 571 | +            throw new \Exception('Group sharing is now allowed'); | |
| 572 | + } | |
| 573 | + | |
| 574 | + // Verify if the user can share with this group | |
| 575 | +        if ($this->shareWithGroupMembersOnly()) { | |
| 576 | + $sharedBy = $this->userManager->get($share->getSharedBy()); | |
| 577 | + $sharedWith = $this->groupManager->get($share->getSharedWith()); | |
| 578 | +            if (is_null($sharedWith) || !$sharedWith->inGroup($sharedBy)) { | |
| 579 | +                throw new \Exception('Sharing is only allowed within your own groups'); | |
| 580 | + } | |
| 581 | + } | |
| 582 | + | |
| 583 | + /* | |
| 584 | 584 | * TODO: Could be costly, fix | 
| 585 | 585 | * | 
| 586 | 586 | * Also this is not what we want in the future.. then we want to squash identical shares. | 
| 587 | 587 | */ | 
| 588 | - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP); | |
| 589 | - $existingShares = $provider->getSharesByPath($share->getNode()); | |
| 590 | -		foreach($existingShares as $existingShare) { | |
| 591 | -			try { | |
| 592 | -				if ($existingShare->getFullId() === $share->getFullId()) { | |
| 593 | - continue; | |
| 594 | - } | |
| 595 | -			} catch (\UnexpectedValueException $e) { | |
| 596 | - //It is a new share so just continue | |
| 597 | - } | |
| 598 | - | |
| 599 | -			if ($existingShare->getSharedWith() === $share->getSharedWith() && $existingShare->getShareType() === $share->getShareType()) { | |
| 600 | -				throw new \Exception('Path is already shared with this group'); | |
| 601 | - } | |
| 602 | - } | |
| 603 | - } | |
| 604 | - | |
| 605 | - /** | |
| 606 | - * Check for pre share requirements for link shares | |
| 607 | - * | |
| 608 | - * @param \OCP\Share\IShare $share | |
| 609 | - * @throws \Exception | |
| 610 | - */ | |
| 611 | -	protected function linkCreateChecks(\OCP\Share\IShare $share) { | |
| 612 | - // Are link shares allowed? | |
| 613 | -		if (!$this->shareApiAllowLinks()) { | |
| 614 | -			throw new \Exception('Link sharing is not allowed'); | |
| 615 | - } | |
| 616 | - | |
| 617 | - // Link shares by definition can't have share permissions | |
| 618 | -		if ($share->getPermissions() & \OCP\Constants::PERMISSION_SHARE) { | |
| 619 | -			throw new \InvalidArgumentException('Link shares can’t have reshare permissions'); | |
| 620 | - } | |
| 621 | - | |
| 622 | - // Check if public upload is allowed | |
| 623 | - if (!$this->shareApiLinkAllowPublicUpload() && | |
| 624 | -			($share->getPermissions() & (\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE))) { | |
| 625 | -			throw new \InvalidArgumentException('Public upload is not allowed'); | |
| 626 | - } | |
| 627 | - } | |
| 628 | - | |
| 629 | - /** | |
| 630 | - * To make sure we don't get invisible link shares we set the parent | |
| 631 | - * of a link if it is a reshare. This is a quick word around | |
| 632 | - * until we can properly display multiple link shares in the UI | |
| 633 | - * | |
| 634 | - * See: https://github.com/owncloud/core/issues/22295 | |
| 635 | - * | |
| 636 | - * FIXME: Remove once multiple link shares can be properly displayed | |
| 637 | - * | |
| 638 | - * @param \OCP\Share\IShare $share | |
| 639 | - */ | |
| 640 | -	protected function setLinkParent(\OCP\Share\IShare $share) { | |
| 641 | - | |
| 642 | - // No sense in checking if the method is not there. | |
| 643 | -		if (method_exists($share, 'setParent')) { | |
| 644 | - $storage = $share->getNode()->getStorage(); | |
| 645 | -			if ($storage->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) { | |
| 646 | - /** @var \OCA\Files_Sharing\SharedStorage $storage */ | |
| 647 | - $share->setParent($storage->getShareId()); | |
| 648 | - } | |
| 649 | - } | |
| 650 | - } | |
| 651 | - | |
| 652 | - /** | |
| 653 | - * @param File|Folder $path | |
| 654 | - */ | |
| 655 | -	protected function pathCreateChecks($path) { | |
| 656 | - // Make sure that we do not share a path that contains a shared mountpoint | |
| 657 | -		if ($path instanceof \OCP\Files\Folder) { | |
| 658 | - $mounts = $this->mountManager->findIn($path->getPath()); | |
| 659 | -			foreach($mounts as $mount) { | |
| 660 | -				if ($mount->getStorage()->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) { | |
| 661 | -					throw new \InvalidArgumentException('Path contains files shared with you'); | |
| 662 | - } | |
| 663 | - } | |
| 664 | - } | |
| 665 | - } | |
| 666 | - | |
| 667 | - /** | |
| 668 | - * Check if the user that is sharing can actually share | |
| 669 | - * | |
| 670 | - * @param \OCP\Share\IShare $share | |
| 671 | - * @throws \Exception | |
| 672 | - */ | |
| 673 | -	protected function canShare(\OCP\Share\IShare $share) { | |
| 674 | -		if (!$this->shareApiEnabled()) { | |
| 675 | -			throw new \Exception('Sharing is disabled'); | |
| 676 | - } | |
| 677 | - | |
| 678 | -		if ($this->sharingDisabledForUser($share->getSharedBy())) { | |
| 679 | -			throw new \Exception('Sharing is disabled for you'); | |
| 680 | - } | |
| 681 | - } | |
| 682 | - | |
| 683 | - /** | |
| 684 | - * Share a path | |
| 685 | - * | |
| 686 | - * @param \OCP\Share\IShare $share | |
| 687 | - * @return Share The share object | |
| 688 | - * @throws \Exception | |
| 689 | - * | |
| 690 | - * TODO: handle link share permissions or check them | |
| 691 | - */ | |
| 692 | -	public function createShare(\OCP\Share\IShare $share) { | |
| 693 | - $this->canShare($share); | |
| 694 | - | |
| 695 | - $this->generalCreateChecks($share); | |
| 696 | - | |
| 697 | - // Verify if there are any issues with the path | |
| 698 | - $this->pathCreateChecks($share->getNode()); | |
| 699 | - | |
| 700 | - /* | |
| 588 | + $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP); | |
| 589 | + $existingShares = $provider->getSharesByPath($share->getNode()); | |
| 590 | +        foreach($existingShares as $existingShare) { | |
| 591 | +            try { | |
| 592 | +                if ($existingShare->getFullId() === $share->getFullId()) { | |
| 593 | + continue; | |
| 594 | + } | |
| 595 | +            } catch (\UnexpectedValueException $e) { | |
| 596 | + //It is a new share so just continue | |
| 597 | + } | |
| 598 | + | |
| 599 | +            if ($existingShare->getSharedWith() === $share->getSharedWith() && $existingShare->getShareType() === $share->getShareType()) { | |
| 600 | +                throw new \Exception('Path is already shared with this group'); | |
| 601 | + } | |
| 602 | + } | |
| 603 | + } | |
| 604 | + | |
| 605 | + /** | |
| 606 | + * Check for pre share requirements for link shares | |
| 607 | + * | |
| 608 | + * @param \OCP\Share\IShare $share | |
| 609 | + * @throws \Exception | |
| 610 | + */ | |
| 611 | +    protected function linkCreateChecks(\OCP\Share\IShare $share) { | |
| 612 | + // Are link shares allowed? | |
| 613 | +        if (!$this->shareApiAllowLinks()) { | |
| 614 | +            throw new \Exception('Link sharing is not allowed'); | |
| 615 | + } | |
| 616 | + | |
| 617 | + // Link shares by definition can't have share permissions | |
| 618 | +        if ($share->getPermissions() & \OCP\Constants::PERMISSION_SHARE) { | |
| 619 | +            throw new \InvalidArgumentException('Link shares can’t have reshare permissions'); | |
| 620 | + } | |
| 621 | + | |
| 622 | + // Check if public upload is allowed | |
| 623 | + if (!$this->shareApiLinkAllowPublicUpload() && | |
| 624 | +            ($share->getPermissions() & (\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE))) { | |
| 625 | +            throw new \InvalidArgumentException('Public upload is not allowed'); | |
| 626 | + } | |
| 627 | + } | |
| 628 | + | |
| 629 | + /** | |
| 630 | + * To make sure we don't get invisible link shares we set the parent | |
| 631 | + * of a link if it is a reshare. This is a quick word around | |
| 632 | + * until we can properly display multiple link shares in the UI | |
| 633 | + * | |
| 634 | + * See: https://github.com/owncloud/core/issues/22295 | |
| 635 | + * | |
| 636 | + * FIXME: Remove once multiple link shares can be properly displayed | |
| 637 | + * | |
| 638 | + * @param \OCP\Share\IShare $share | |
| 639 | + */ | |
| 640 | +    protected function setLinkParent(\OCP\Share\IShare $share) { | |
| 641 | + | |
| 642 | + // No sense in checking if the method is not there. | |
| 643 | +        if (method_exists($share, 'setParent')) { | |
| 644 | + $storage = $share->getNode()->getStorage(); | |
| 645 | +            if ($storage->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) { | |
| 646 | + /** @var \OCA\Files_Sharing\SharedStorage $storage */ | |
| 647 | + $share->setParent($storage->getShareId()); | |
| 648 | + } | |
| 649 | + } | |
| 650 | + } | |
| 651 | + | |
| 652 | + /** | |
| 653 | + * @param File|Folder $path | |
| 654 | + */ | |
| 655 | +    protected function pathCreateChecks($path) { | |
| 656 | + // Make sure that we do not share a path that contains a shared mountpoint | |
| 657 | +        if ($path instanceof \OCP\Files\Folder) { | |
| 658 | + $mounts = $this->mountManager->findIn($path->getPath()); | |
| 659 | +            foreach($mounts as $mount) { | |
| 660 | +                if ($mount->getStorage()->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) { | |
| 661 | +                    throw new \InvalidArgumentException('Path contains files shared with you'); | |
| 662 | + } | |
| 663 | + } | |
| 664 | + } | |
| 665 | + } | |
| 666 | + | |
| 667 | + /** | |
| 668 | + * Check if the user that is sharing can actually share | |
| 669 | + * | |
| 670 | + * @param \OCP\Share\IShare $share | |
| 671 | + * @throws \Exception | |
| 672 | + */ | |
| 673 | +    protected function canShare(\OCP\Share\IShare $share) { | |
| 674 | +        if (!$this->shareApiEnabled()) { | |
| 675 | +            throw new \Exception('Sharing is disabled'); | |
| 676 | + } | |
| 677 | + | |
| 678 | +        if ($this->sharingDisabledForUser($share->getSharedBy())) { | |
| 679 | +            throw new \Exception('Sharing is disabled for you'); | |
| 680 | + } | |
| 681 | + } | |
| 682 | + | |
| 683 | + /** | |
| 684 | + * Share a path | |
| 685 | + * | |
| 686 | + * @param \OCP\Share\IShare $share | |
| 687 | + * @return Share The share object | |
| 688 | + * @throws \Exception | |
| 689 | + * | |
| 690 | + * TODO: handle link share permissions or check them | |
| 691 | + */ | |
| 692 | +    public function createShare(\OCP\Share\IShare $share) { | |
| 693 | + $this->canShare($share); | |
| 694 | + | |
| 695 | + $this->generalCreateChecks($share); | |
| 696 | + | |
| 697 | + // Verify if there are any issues with the path | |
| 698 | + $this->pathCreateChecks($share->getNode()); | |
| 699 | + | |
| 700 | + /* | |
| 701 | 701 | * On creation of a share the owner is always the owner of the path | 
| 702 | 702 | * Except for mounted federated shares. | 
| 703 | 703 | */ | 
| 704 | - $storage = $share->getNode()->getStorage(); | |
| 705 | -		if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) { | |
| 706 | - $parent = $share->getNode()->getParent(); | |
| 707 | -			while($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) { | |
| 708 | - $parent = $parent->getParent(); | |
| 709 | - } | |
| 710 | - $share->setShareOwner($parent->getOwner()->getUID()); | |
| 711 | -		} else { | |
| 712 | - $share->setShareOwner($share->getNode()->getOwner()->getUID()); | |
| 713 | - } | |
| 714 | - | |
| 715 | - //Verify share type | |
| 716 | -		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { | |
| 717 | - $this->userCreateChecks($share); | |
| 718 | - | |
| 719 | - //Verify the expiration date | |
| 720 | - $share = $this->validateExpirationDateInternal($share); | |
| 721 | - | |
| 722 | -		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { | |
| 723 | - $this->groupCreateChecks($share); | |
| 724 | - | |
| 725 | - //Verify the expiration date | |
| 726 | - $share = $this->validateExpirationDateInternal($share); | |
| 727 | - | |
| 728 | -		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { | |
| 729 | - $this->linkCreateChecks($share); | |
| 730 | - $this->setLinkParent($share); | |
| 731 | - | |
| 732 | - /* | |
| 704 | + $storage = $share->getNode()->getStorage(); | |
| 705 | +        if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) { | |
| 706 | + $parent = $share->getNode()->getParent(); | |
| 707 | +            while($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) { | |
| 708 | + $parent = $parent->getParent(); | |
| 709 | + } | |
| 710 | + $share->setShareOwner($parent->getOwner()->getUID()); | |
| 711 | +        } else { | |
| 712 | + $share->setShareOwner($share->getNode()->getOwner()->getUID()); | |
| 713 | + } | |
| 714 | + | |
| 715 | + //Verify share type | |
| 716 | +        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { | |
| 717 | + $this->userCreateChecks($share); | |
| 718 | + | |
| 719 | + //Verify the expiration date | |
| 720 | + $share = $this->validateExpirationDateInternal($share); | |
| 721 | + | |
| 722 | +        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { | |
| 723 | + $this->groupCreateChecks($share); | |
| 724 | + | |
| 725 | + //Verify the expiration date | |
| 726 | + $share = $this->validateExpirationDateInternal($share); | |
| 727 | + | |
| 728 | +        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { | |
| 729 | + $this->linkCreateChecks($share); | |
| 730 | + $this->setLinkParent($share); | |
| 731 | + | |
| 732 | + /* | |
| 733 | 733 | * For now ignore a set token. | 
| 734 | 734 | */ | 
| 735 | - $share->setToken( | |
| 736 | - $this->secureRandom->generate( | |
| 737 | - \OC\Share\Constants::TOKEN_LENGTH, | |
| 738 | - \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE | |
| 739 | - ) | |
| 740 | - ); | |
| 741 | - | |
| 742 | - //Verify the expiration date | |
| 743 | - $share = $this->validateExpirationDate($share); | |
| 744 | - | |
| 745 | - //Verify the password | |
| 746 | - $this->verifyPassword($share->getPassword()); | |
| 747 | - | |
| 748 | - // If a password is set. Hash it! | |
| 749 | -			if ($share->getPassword() !== null) { | |
| 750 | - $share->setPassword($this->hasher->hash($share->getPassword())); | |
| 751 | - } | |
| 752 | -		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { | |
| 753 | - $share->setToken( | |
| 754 | - $this->secureRandom->generate( | |
| 755 | - \OC\Share\Constants::TOKEN_LENGTH, | |
| 756 | - \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE | |
| 757 | - ) | |
| 758 | - ); | |
| 759 | - } | |
| 760 | - | |
| 761 | - // Cannot share with the owner | |
| 762 | - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && | |
| 763 | -			$share->getSharedWith() === $share->getShareOwner()) { | |
| 764 | -			throw new \InvalidArgumentException('Can’t share with the share owner'); | |
| 765 | - } | |
| 766 | - | |
| 767 | - // Generate the target | |
| 768 | -		$target = $this->config->getSystemValue('share_folder', '/') .'/'. $share->getNode()->getName(); | |
| 769 | - $target = \OC\Files\Filesystem::normalizePath($target); | |
| 770 | - $share->setTarget($target); | |
| 771 | - | |
| 772 | - // Pre share event | |
| 773 | - $event = new GenericEvent($share); | |
| 774 | -		$this->legacyDispatcher->dispatch('OCP\Share::preShare', $event); | |
| 775 | -		if ($event->isPropagationStopped() && $event->hasArgument('error')) { | |
| 776 | -			throw new \Exception($event->getArgument('error')); | |
| 777 | - } | |
| 778 | - | |
| 779 | - $oldShare = $share; | |
| 780 | - $provider = $this->factory->getProviderForType($share->getShareType()); | |
| 781 | - $share = $provider->create($share); | |
| 782 | - //reuse the node we already have | |
| 783 | - $share->setNode($oldShare->getNode()); | |
| 784 | - | |
| 785 | - // Post share event | |
| 786 | - $event = new GenericEvent($share); | |
| 787 | -		$this->legacyDispatcher->dispatch('OCP\Share::postShare', $event); | |
| 788 | - | |
| 789 | - $this->dispatcher->dispatchTyped(new Share\Events\ShareCreatedEvent($share)); | |
| 790 | - | |
| 791 | -		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { | |
| 792 | - $mailSend = $share->getMailSend(); | |
| 793 | -			if($mailSend === true) { | |
| 794 | - $user = $this->userManager->get($share->getSharedWith()); | |
| 795 | -				if ($user !== null) { | |
| 796 | - $emailAddress = $user->getEMailAddress(); | |
| 797 | -					if ($emailAddress !== null && $emailAddress !== '') { | |
| 798 | - $userLang = $this->config->getUserValue($share->getSharedWith(), 'core', 'lang', null); | |
| 799 | -						$l = $this->l10nFactory->get('lib', $userLang); | |
| 800 | - $this->sendMailNotification( | |
| 801 | - $l, | |
| 802 | - $share->getNode()->getName(), | |
| 803 | -							$this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $share->getNode()->getId()]), | |
| 804 | - $share->getSharedBy(), | |
| 805 | - $emailAddress, | |
| 806 | - $share->getExpirationDate() | |
| 807 | - ); | |
| 808 | -						$this->logger->debug('Sent share notification to ' . $emailAddress . ' for share with ID ' . $share->getId(), ['app' => 'share']); | |
| 809 | -					} else { | |
| 810 | -						$this->logger->debug('Share notification not sent to ' . $share->getSharedWith() . ' because email address is not set.', ['app' => 'share']); | |
| 811 | - } | |
| 812 | -				} else { | |
| 813 | -					$this->logger->debug('Share notification not sent to ' . $share->getSharedWith() . ' because user could not be found.', ['app' => 'share']); | |
| 814 | - } | |
| 815 | -			} else { | |
| 816 | -				$this->logger->debug('Share notification not sent because mailsend is false.', ['app' => 'share']); | |
| 817 | - } | |
| 818 | - } | |
| 819 | - | |
| 820 | - return $share; | |
| 821 | - } | |
| 822 | - | |
| 823 | - /** | |
| 824 | - * Send mail notifications | |
| 825 | - * | |
| 826 | - * This method will catch and log mail transmission errors | |
| 827 | - * | |
| 828 | - * @param IL10N $l Language of the recipient | |
| 829 | - * @param string $filename file/folder name | |
| 830 | - * @param string $link link to the file/folder | |
| 831 | - * @param string $initiator user ID of share sender | |
| 832 | - * @param string $shareWith email address of share receiver | |
| 833 | - * @param \DateTime|null $expiration | |
| 834 | - */ | |
| 835 | - protected function sendMailNotification(IL10N $l, | |
| 836 | - $filename, | |
| 837 | - $link, | |
| 838 | - $initiator, | |
| 839 | - $shareWith, | |
| 840 | -											\DateTime $expiration = null) { | |
| 841 | - $initiatorUser = $this->userManager->get($initiator); | |
| 842 | - $initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator; | |
| 843 | - | |
| 844 | - $message = $this->mailer->createMessage(); | |
| 845 | - | |
| 846 | -		$emailTemplate = $this->mailer->createEMailTemplate('files_sharing.RecipientNotification', [ | |
| 847 | - 'filename' => $filename, | |
| 848 | - 'link' => $link, | |
| 849 | - 'initiator' => $initiatorDisplayName, | |
| 850 | - 'expiration' => $expiration, | |
| 851 | - 'shareWith' => $shareWith, | |
| 852 | - ]); | |
| 853 | - | |
| 854 | -		$emailTemplate->setSubject($l->t('%1$s shared »%2$s« with you', array($initiatorDisplayName, $filename))); | |
| 855 | - $emailTemplate->addHeader(); | |
| 856 | -		$emailTemplate->addHeading($l->t('%1$s shared »%2$s« with you', [$initiatorDisplayName, $filename]), false); | |
| 857 | -		$text = $l->t('%1$s shared »%2$s« with you.', [$initiatorDisplayName, $filename]); | |
| 858 | - | |
| 859 | - $emailTemplate->addBodyText( | |
| 860 | -			htmlspecialchars($text . ' ' . $l->t('Click the button below to open it.')), | |
| 861 | - $text | |
| 862 | - ); | |
| 863 | - $emailTemplate->addBodyButton( | |
| 864 | -			$l->t('Open »%s«', [$filename]), | |
| 865 | - $link | |
| 866 | - ); | |
| 867 | - | |
| 868 | - $message->setTo([$shareWith]); | |
| 869 | - | |
| 870 | - // The "From" contains the sharers name | |
| 871 | - $instanceName = $this->defaults->getName(); | |
| 872 | - $senderName = $l->t( | |
| 873 | - '%1$s via %2$s', | |
| 874 | - [ | |
| 875 | - $initiatorDisplayName, | |
| 876 | - $instanceName | |
| 877 | - ] | |
| 878 | - ); | |
| 879 | - $message->setFrom([\OCP\Util::getDefaultEmailAddress($instanceName) => $senderName]); | |
| 880 | - | |
| 881 | - // The "Reply-To" is set to the sharer if an mail address is configured | |
| 882 | - // also the default footer contains a "Do not reply" which needs to be adjusted. | |
| 883 | - $initiatorEmail = $initiatorUser->getEMailAddress(); | |
| 884 | -		if($initiatorEmail !== null) { | |
| 885 | - $message->setReplyTo([$initiatorEmail => $initiatorDisplayName]); | |
| 886 | - $emailTemplate->addFooter($instanceName . ($this->defaults->getSlogan() !== '' ? ' - ' . $this->defaults->getSlogan() : '')); | |
| 887 | -		} else { | |
| 888 | - $emailTemplate->addFooter(); | |
| 889 | - } | |
| 890 | - | |
| 891 | - $message->useTemplate($emailTemplate); | |
| 892 | -		try { | |
| 893 | - $failedRecipients = $this->mailer->send($message); | |
| 894 | -			if(!empty($failedRecipients)) { | |
| 895 | -				$this->logger->error('Share notification mail could not be sent to: ' . implode(', ', $failedRecipients)); | |
| 896 | - return; | |
| 897 | - } | |
| 898 | -		} catch (\Exception $e) { | |
| 899 | - $this->logger->logException($e, ['message' => 'Share notification mail could not be sent']); | |
| 900 | - } | |
| 901 | - } | |
| 902 | - | |
| 903 | - /** | |
| 904 | - * Update a share | |
| 905 | - * | |
| 906 | - * @param \OCP\Share\IShare $share | |
| 907 | - * @return \OCP\Share\IShare The share object | |
| 908 | - * @throws \InvalidArgumentException | |
| 909 | - */ | |
| 910 | -	public function updateShare(\OCP\Share\IShare $share) { | |
| 911 | - $expirationDateUpdated = false; | |
| 912 | - | |
| 913 | - $this->canShare($share); | |
| 914 | - | |
| 915 | -		try { | |
| 916 | - $originalShare = $this->getShareById($share->getFullId()); | |
| 917 | -		} catch (\UnexpectedValueException $e) { | |
| 918 | -			throw new \InvalidArgumentException('Share does not have a full id'); | |
| 919 | - } | |
| 920 | - | |
| 921 | - // We can't change the share type! | |
| 922 | -		if ($share->getShareType() !== $originalShare->getShareType()) { | |
| 923 | -			throw new \InvalidArgumentException('Can’t change share type'); | |
| 924 | - } | |
| 925 | - | |
| 926 | - // We can only change the recipient on user shares | |
| 927 | - if ($share->getSharedWith() !== $originalShare->getSharedWith() && | |
| 928 | -		    $share->getShareType() !== \OCP\Share::SHARE_TYPE_USER) { | |
| 929 | -			throw new \InvalidArgumentException('Can only update recipient on user shares'); | |
| 930 | - } | |
| 931 | - | |
| 932 | - // Cannot share with the owner | |
| 933 | - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && | |
| 934 | -			$share->getSharedWith() === $share->getShareOwner()) { | |
| 935 | -			throw new \InvalidArgumentException('Can’t share with the share owner'); | |
| 936 | - } | |
| 937 | - | |
| 938 | - $this->generalCreateChecks($share); | |
| 939 | - | |
| 940 | -		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { | |
| 941 | - $this->userCreateChecks($share); | |
| 942 | - | |
| 943 | -			if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { | |
| 944 | - //Verify the expiration date | |
| 945 | - $this->validateExpirationDate($share); | |
| 946 | - $expirationDateUpdated = true; | |
| 947 | - } | |
| 948 | -		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { | |
| 949 | - $this->groupCreateChecks($share); | |
| 950 | - | |
| 951 | -			if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { | |
| 952 | - //Verify the expiration date | |
| 953 | - $this->validateExpirationDate($share); | |
| 954 | - $expirationDateUpdated = true; | |
| 955 | - } | |
| 956 | -		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { | |
| 957 | - $this->linkCreateChecks($share); | |
| 958 | - | |
| 959 | - $this->updateSharePasswordIfNeeded($share, $originalShare); | |
| 960 | - | |
| 961 | -			if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { | |
| 962 | - //Verify the expiration date | |
| 963 | - $this->validateExpirationDate($share); | |
| 964 | - $expirationDateUpdated = true; | |
| 965 | - } | |
| 966 | -		} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { | |
| 967 | - // The new password is not set again if it is the same as the old | |
| 968 | - // one, unless when switching from sending by Talk to sending by | |
| 969 | - // mail. | |
| 970 | - $plainTextPassword = $share->getPassword(); | |
| 971 | - if (!empty($plainTextPassword) && !$this->updateSharePasswordIfNeeded($share, $originalShare) && | |
| 972 | -					!($originalShare->getSendPasswordByTalk() && !$share->getSendPasswordByTalk())) { | |
| 973 | - $plainTextPassword = null; | |
| 974 | - } | |
| 975 | -			if (empty($plainTextPassword) && !$originalShare->getSendPasswordByTalk() && $share->getSendPasswordByTalk()) { | |
| 976 | - // If the same password was already sent by mail the recipient | |
| 977 | - // would already have access to the share without having to call | |
| 978 | - // the sharer to verify her identity | |
| 979 | -				throw new \InvalidArgumentException('Can’t enable sending the password by Talk without setting a new password'); | |
| 980 | - } | |
| 981 | - } | |
| 982 | - | |
| 983 | - $this->pathCreateChecks($share->getNode()); | |
| 984 | - | |
| 985 | - // Now update the share! | |
| 986 | - $provider = $this->factory->getProviderForType($share->getShareType()); | |
| 987 | -		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { | |
| 988 | - $share = $provider->update($share, $plainTextPassword); | |
| 989 | -		} else { | |
| 990 | - $share = $provider->update($share); | |
| 991 | - } | |
| 992 | - | |
| 993 | -		if ($expirationDateUpdated === true) { | |
| 994 | - \OC_Hook::emit(Share::class, 'post_set_expiration_date', [ | |
| 995 | - 'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder', | |
| 996 | - 'itemSource' => $share->getNode()->getId(), | |
| 997 | - 'date' => $share->getExpirationDate(), | |
| 998 | - 'uidOwner' => $share->getSharedBy(), | |
| 999 | - ]); | |
| 1000 | - } | |
| 1001 | - | |
| 1002 | -		if ($share->getPassword() !== $originalShare->getPassword()) { | |
| 1003 | - \OC_Hook::emit(Share::class, 'post_update_password', [ | |
| 1004 | - 'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder', | |
| 1005 | - 'itemSource' => $share->getNode()->getId(), | |
| 1006 | - 'uidOwner' => $share->getSharedBy(), | |
| 1007 | - 'token' => $share->getToken(), | |
| 1008 | - 'disabled' => is_null($share->getPassword()), | |
| 1009 | - ]); | |
| 1010 | - } | |
| 1011 | - | |
| 1012 | -		if ($share->getPermissions() !== $originalShare->getPermissions()) { | |
| 1013 | -			if ($this->userManager->userExists($share->getShareOwner())) { | |
| 1014 | - $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner()); | |
| 1015 | -			} else { | |
| 1016 | - $userFolder = $this->rootFolder->getUserFolder($share->getSharedBy()); | |
| 1017 | - } | |
| 1018 | - \OC_Hook::emit(Share::class, 'post_update_permissions', array( | |
| 1019 | - 'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder', | |
| 1020 | - 'itemSource' => $share->getNode()->getId(), | |
| 1021 | - 'shareType' => $share->getShareType(), | |
| 1022 | - 'shareWith' => $share->getSharedWith(), | |
| 1023 | - 'uidOwner' => $share->getSharedBy(), | |
| 1024 | - 'permissions' => $share->getPermissions(), | |
| 1025 | - 'path' => $userFolder->getRelativePath($share->getNode()->getPath()), | |
| 1026 | - )); | |
| 1027 | - } | |
| 1028 | - | |
| 1029 | - return $share; | |
| 1030 | - } | |
| 1031 | - | |
| 1032 | - /** | |
| 1033 | - * Accept a share. | |
| 1034 | - * | |
| 1035 | - * @param IShare $share | |
| 1036 | - * @param string $recipientId | |
| 1037 | - * @return IShare The share object | |
| 1038 | - * @throws \InvalidArgumentException | |
| 1039 | - * @since 9.0.0 | |
| 1040 | - */ | |
| 1041 | -	public function acceptShare(IShare $share, string $recipientId): IShare { | |
| 1042 | - [$providerId, ] = $this->splitFullId($share->getFullId()); | |
| 1043 | - $provider = $this->factory->getProvider($providerId); | |
| 1044 | - | |
| 1045 | -		if (!method_exists($provider, 'acceptShare')) { | |
| 1046 | - // TODO FIX ME | |
| 1047 | -			throw new \InvalidArgumentException('Share provider does not support accepting'); | |
| 1048 | - } | |
| 1049 | - $provider->acceptShare($share, $recipientId); | |
| 1050 | - $event = new GenericEvent($share); | |
| 1051 | -		$this->legacyDispatcher->dispatch('OCP\Share::postAcceptShare', $event); | |
| 1052 | - | |
| 1053 | - return $share; | |
| 1054 | - } | |
| 1055 | - | |
| 1056 | - /** | |
| 1057 | - * Updates the password of the given share if it is not the same as the | |
| 1058 | - * password of the original share. | |
| 1059 | - * | |
| 1060 | - * @param \OCP\Share\IShare $share the share to update its password. | |
| 1061 | - * @param \OCP\Share\IShare $originalShare the original share to compare its | |
| 1062 | - * password with. | |
| 1063 | - * @return boolean whether the password was updated or not. | |
| 1064 | - */ | |
| 1065 | -	private function updateSharePasswordIfNeeded(\OCP\Share\IShare $share, \OCP\Share\IShare $originalShare) { | |
| 1066 | - // Password updated. | |
| 1067 | -		if ($share->getPassword() !== $originalShare->getPassword()) { | |
| 1068 | - //Verify the password | |
| 1069 | - $this->verifyPassword($share->getPassword()); | |
| 1070 | - | |
| 1071 | - // If a password is set. Hash it! | |
| 1072 | -			if ($share->getPassword() !== null) { | |
| 1073 | - $share->setPassword($this->hasher->hash($share->getPassword())); | |
| 1074 | - | |
| 1075 | - return true; | |
| 1076 | - } | |
| 1077 | - } | |
| 1078 | - | |
| 1079 | - return false; | |
| 1080 | - } | |
| 1081 | - | |
| 1082 | - /** | |
| 1083 | - * Delete all the children of this share | |
| 1084 | - * FIXME: remove once https://github.com/owncloud/core/pull/21660 is in | |
| 1085 | - * | |
| 1086 | - * @param \OCP\Share\IShare $share | |
| 1087 | - * @return \OCP\Share\IShare[] List of deleted shares | |
| 1088 | - */ | |
| 1089 | -	protected function deleteChildren(\OCP\Share\IShare $share) { | |
| 1090 | - $deletedShares = []; | |
| 1091 | - | |
| 1092 | - $provider = $this->factory->getProviderForType($share->getShareType()); | |
| 1093 | - | |
| 1094 | -		foreach ($provider->getChildren($share) as $child) { | |
| 1095 | - $deletedChildren = $this->deleteChildren($child); | |
| 1096 | - $deletedShares = array_merge($deletedShares, $deletedChildren); | |
| 1097 | - | |
| 1098 | - $provider->delete($child); | |
| 1099 | - $deletedShares[] = $child; | |
| 1100 | - } | |
| 1101 | - | |
| 1102 | - return $deletedShares; | |
| 1103 | - } | |
| 1104 | - | |
| 1105 | - /** | |
| 1106 | - * Delete a share | |
| 1107 | - * | |
| 1108 | - * @param \OCP\Share\IShare $share | |
| 1109 | - * @throws ShareNotFound | |
| 1110 | - * @throws \InvalidArgumentException | |
| 1111 | - */ | |
| 1112 | -	public function deleteShare(\OCP\Share\IShare $share) { | |
| 1113 | - | |
| 1114 | -		try { | |
| 1115 | - $share->getFullId(); | |
| 1116 | -		} catch (\UnexpectedValueException $e) { | |
| 1117 | -			throw new \InvalidArgumentException('Share does not have a full id'); | |
| 1118 | - } | |
| 1119 | - | |
| 1120 | - $event = new GenericEvent($share); | |
| 1121 | -		$this->legacyDispatcher->dispatch('OCP\Share::preUnshare', $event); | |
| 1122 | - | |
| 1123 | - // Get all children and delete them as well | |
| 1124 | - $deletedShares = $this->deleteChildren($share); | |
| 1125 | - | |
| 1126 | - // Do the actual delete | |
| 1127 | - $provider = $this->factory->getProviderForType($share->getShareType()); | |
| 1128 | - $provider->delete($share); | |
| 1129 | - | |
| 1130 | - // All the deleted shares caused by this delete | |
| 1131 | - $deletedShares[] = $share; | |
| 1132 | - | |
| 1133 | - // Emit post hook | |
| 1134 | -		$event->setArgument('deletedShares', $deletedShares); | |
| 1135 | -		$this->legacyDispatcher->dispatch('OCP\Share::postUnshare', $event); | |
| 1136 | - } | |
| 1137 | - | |
| 1138 | - | |
| 1139 | - /** | |
| 1140 | - * Unshare a file as the recipient. | |
| 1141 | - * This can be different from a regular delete for example when one of | |
| 1142 | - * the users in a groups deletes that share. But the provider should | |
| 1143 | - * handle this. | |
| 1144 | - * | |
| 1145 | - * @param \OCP\Share\IShare $share | |
| 1146 | - * @param string $recipientId | |
| 1147 | - */ | |
| 1148 | -	public function deleteFromSelf(\OCP\Share\IShare $share, $recipientId) { | |
| 1149 | - list($providerId, ) = $this->splitFullId($share->getFullId()); | |
| 1150 | - $provider = $this->factory->getProvider($providerId); | |
| 1151 | - | |
| 1152 | - $provider->deleteFromSelf($share, $recipientId); | |
| 1153 | - $event = new GenericEvent($share); | |
| 1154 | -		$this->legacyDispatcher->dispatch('OCP\Share::postUnshareFromSelf', $event); | |
| 1155 | - } | |
| 1156 | - | |
| 1157 | -	public function restoreShare(IShare $share, string $recipientId): IShare { | |
| 1158 | - list($providerId, ) = $this->splitFullId($share->getFullId()); | |
| 1159 | - $provider = $this->factory->getProvider($providerId); | |
| 1160 | - | |
| 1161 | - return $provider->restore($share, $recipientId); | |
| 1162 | - } | |
| 1163 | - | |
| 1164 | - /** | |
| 1165 | - * @inheritdoc | |
| 1166 | - */ | |
| 1167 | -	public function moveShare(\OCP\Share\IShare $share, $recipientId) { | |
| 1168 | -		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { | |
| 1169 | -			throw new \InvalidArgumentException('Can’t change target of link share'); | |
| 1170 | - } | |
| 1171 | - | |
| 1172 | -		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && $share->getSharedWith() !== $recipientId) { | |
| 1173 | -			throw new \InvalidArgumentException('Invalid recipient'); | |
| 1174 | - } | |
| 1175 | - | |
| 1176 | -		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { | |
| 1177 | - $sharedWith = $this->groupManager->get($share->getSharedWith()); | |
| 1178 | -			if (is_null($sharedWith)) { | |
| 1179 | -				throw new \InvalidArgumentException('Group "' . $share->getSharedWith() . '" does not exist'); | |
| 1180 | - } | |
| 1181 | - $recipient = $this->userManager->get($recipientId); | |
| 1182 | -			if (!$sharedWith->inGroup($recipient)) { | |
| 1183 | -				throw new \InvalidArgumentException('Invalid recipient'); | |
| 1184 | - } | |
| 1185 | - } | |
| 1186 | - | |
| 1187 | - list($providerId, ) = $this->splitFullId($share->getFullId()); | |
| 1188 | - $provider = $this->factory->getProvider($providerId); | |
| 1189 | - | |
| 1190 | - $provider->move($share, $recipientId); | |
| 1191 | - } | |
| 1192 | - | |
| 1193 | -	public function getSharesInFolder($userId, Folder $node, $reshares = false) { | |
| 1194 | - $providers = $this->factory->getAllProviders(); | |
| 1195 | - | |
| 1196 | -		return array_reduce($providers, function($shares, IShareProvider $provider) use ($userId, $node, $reshares) { | |
| 1197 | - $newShares = $provider->getSharesInFolder($userId, $node, $reshares); | |
| 1198 | -			foreach ($newShares as $fid => $data) { | |
| 1199 | -				if (!isset($shares[$fid])) { | |
| 1200 | - $shares[$fid] = []; | |
| 1201 | - } | |
| 1202 | - | |
| 1203 | - $shares[$fid] = array_merge($shares[$fid], $data); | |
| 1204 | - } | |
| 1205 | - return $shares; | |
| 1206 | - }, []); | |
| 1207 | - } | |
| 1208 | - | |
| 1209 | - /** | |
| 1210 | - * @inheritdoc | |
| 1211 | - */ | |
| 1212 | -	public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0) { | |
| 1213 | - if ($path !== null && | |
| 1214 | - !($path instanceof \OCP\Files\File) && | |
| 1215 | -				!($path instanceof \OCP\Files\Folder)) { | |
| 1216 | -			throw new \InvalidArgumentException('invalid path'); | |
| 1217 | - } | |
| 1218 | - | |
| 1219 | -		try { | |
| 1220 | - $provider = $this->factory->getProviderForType($shareType); | |
| 1221 | -		} catch (ProviderException $e) { | |
| 1222 | - return []; | |
| 1223 | - } | |
| 1224 | - | |
| 1225 | - $shares = $provider->getSharesBy($userId, $shareType, $path, $reshares, $limit, $offset); | |
| 1226 | - | |
| 1227 | - /* | |
| 735 | + $share->setToken( | |
| 736 | + $this->secureRandom->generate( | |
| 737 | + \OC\Share\Constants::TOKEN_LENGTH, | |
| 738 | + \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE | |
| 739 | + ) | |
| 740 | + ); | |
| 741 | + | |
| 742 | + //Verify the expiration date | |
| 743 | + $share = $this->validateExpirationDate($share); | |
| 744 | + | |
| 745 | + //Verify the password | |
| 746 | + $this->verifyPassword($share->getPassword()); | |
| 747 | + | |
| 748 | + // If a password is set. Hash it! | |
| 749 | +            if ($share->getPassword() !== null) { | |
| 750 | + $share->setPassword($this->hasher->hash($share->getPassword())); | |
| 751 | + } | |
| 752 | +        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { | |
| 753 | + $share->setToken( | |
| 754 | + $this->secureRandom->generate( | |
| 755 | + \OC\Share\Constants::TOKEN_LENGTH, | |
| 756 | + \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE | |
| 757 | + ) | |
| 758 | + ); | |
| 759 | + } | |
| 760 | + | |
| 761 | + // Cannot share with the owner | |
| 762 | + if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && | |
| 763 | +            $share->getSharedWith() === $share->getShareOwner()) { | |
| 764 | +            throw new \InvalidArgumentException('Can’t share with the share owner'); | |
| 765 | + } | |
| 766 | + | |
| 767 | + // Generate the target | |
| 768 | +        $target = $this->config->getSystemValue('share_folder', '/') .'/'. $share->getNode()->getName(); | |
| 769 | + $target = \OC\Files\Filesystem::normalizePath($target); | |
| 770 | + $share->setTarget($target); | |
| 771 | + | |
| 772 | + // Pre share event | |
| 773 | + $event = new GenericEvent($share); | |
| 774 | +        $this->legacyDispatcher->dispatch('OCP\Share::preShare', $event); | |
| 775 | +        if ($event->isPropagationStopped() && $event->hasArgument('error')) { | |
| 776 | +            throw new \Exception($event->getArgument('error')); | |
| 777 | + } | |
| 778 | + | |
| 779 | + $oldShare = $share; | |
| 780 | + $provider = $this->factory->getProviderForType($share->getShareType()); | |
| 781 | + $share = $provider->create($share); | |
| 782 | + //reuse the node we already have | |
| 783 | + $share->setNode($oldShare->getNode()); | |
| 784 | + | |
| 785 | + // Post share event | |
| 786 | + $event = new GenericEvent($share); | |
| 787 | +        $this->legacyDispatcher->dispatch('OCP\Share::postShare', $event); | |
| 788 | + | |
| 789 | + $this->dispatcher->dispatchTyped(new Share\Events\ShareCreatedEvent($share)); | |
| 790 | + | |
| 791 | +        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { | |
| 792 | + $mailSend = $share->getMailSend(); | |
| 793 | +            if($mailSend === true) { | |
| 794 | + $user = $this->userManager->get($share->getSharedWith()); | |
| 795 | +                if ($user !== null) { | |
| 796 | + $emailAddress = $user->getEMailAddress(); | |
| 797 | +                    if ($emailAddress !== null && $emailAddress !== '') { | |
| 798 | + $userLang = $this->config->getUserValue($share->getSharedWith(), 'core', 'lang', null); | |
| 799 | +                        $l = $this->l10nFactory->get('lib', $userLang); | |
| 800 | + $this->sendMailNotification( | |
| 801 | + $l, | |
| 802 | + $share->getNode()->getName(), | |
| 803 | +                            $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $share->getNode()->getId()]), | |
| 804 | + $share->getSharedBy(), | |
| 805 | + $emailAddress, | |
| 806 | + $share->getExpirationDate() | |
| 807 | + ); | |
| 808 | +                        $this->logger->debug('Sent share notification to ' . $emailAddress . ' for share with ID ' . $share->getId(), ['app' => 'share']); | |
| 809 | +                    } else { | |
| 810 | +                        $this->logger->debug('Share notification not sent to ' . $share->getSharedWith() . ' because email address is not set.', ['app' => 'share']); | |
| 811 | + } | |
| 812 | +                } else { | |
| 813 | +                    $this->logger->debug('Share notification not sent to ' . $share->getSharedWith() . ' because user could not be found.', ['app' => 'share']); | |
| 814 | + } | |
| 815 | +            } else { | |
| 816 | +                $this->logger->debug('Share notification not sent because mailsend is false.', ['app' => 'share']); | |
| 817 | + } | |
| 818 | + } | |
| 819 | + | |
| 820 | + return $share; | |
| 821 | + } | |
| 822 | + | |
| 823 | + /** | |
| 824 | + * Send mail notifications | |
| 825 | + * | |
| 826 | + * This method will catch and log mail transmission errors | |
| 827 | + * | |
| 828 | + * @param IL10N $l Language of the recipient | |
| 829 | + * @param string $filename file/folder name | |
| 830 | + * @param string $link link to the file/folder | |
| 831 | + * @param string $initiator user ID of share sender | |
| 832 | + * @param string $shareWith email address of share receiver | |
| 833 | + * @param \DateTime|null $expiration | |
| 834 | + */ | |
| 835 | + protected function sendMailNotification(IL10N $l, | |
| 836 | + $filename, | |
| 837 | + $link, | |
| 838 | + $initiator, | |
| 839 | + $shareWith, | |
| 840 | +                                            \DateTime $expiration = null) { | |
| 841 | + $initiatorUser = $this->userManager->get($initiator); | |
| 842 | + $initiatorDisplayName = ($initiatorUser instanceof IUser) ? $initiatorUser->getDisplayName() : $initiator; | |
| 843 | + | |
| 844 | + $message = $this->mailer->createMessage(); | |
| 845 | + | |
| 846 | +        $emailTemplate = $this->mailer->createEMailTemplate('files_sharing.RecipientNotification', [ | |
| 847 | + 'filename' => $filename, | |
| 848 | + 'link' => $link, | |
| 849 | + 'initiator' => $initiatorDisplayName, | |
| 850 | + 'expiration' => $expiration, | |
| 851 | + 'shareWith' => $shareWith, | |
| 852 | + ]); | |
| 853 | + | |
| 854 | +        $emailTemplate->setSubject($l->t('%1$s shared »%2$s« with you', array($initiatorDisplayName, $filename))); | |
| 855 | + $emailTemplate->addHeader(); | |
| 856 | +        $emailTemplate->addHeading($l->t('%1$s shared »%2$s« with you', [$initiatorDisplayName, $filename]), false); | |
| 857 | +        $text = $l->t('%1$s shared »%2$s« with you.', [$initiatorDisplayName, $filename]); | |
| 858 | + | |
| 859 | + $emailTemplate->addBodyText( | |
| 860 | +            htmlspecialchars($text . ' ' . $l->t('Click the button below to open it.')), | |
| 861 | + $text | |
| 862 | + ); | |
| 863 | + $emailTemplate->addBodyButton( | |
| 864 | +            $l->t('Open »%s«', [$filename]), | |
| 865 | + $link | |
| 866 | + ); | |
| 867 | + | |
| 868 | + $message->setTo([$shareWith]); | |
| 869 | + | |
| 870 | + // The "From" contains the sharers name | |
| 871 | + $instanceName = $this->defaults->getName(); | |
| 872 | + $senderName = $l->t( | |
| 873 | + '%1$s via %2$s', | |
| 874 | + [ | |
| 875 | + $initiatorDisplayName, | |
| 876 | + $instanceName | |
| 877 | + ] | |
| 878 | + ); | |
| 879 | + $message->setFrom([\OCP\Util::getDefaultEmailAddress($instanceName) => $senderName]); | |
| 880 | + | |
| 881 | + // The "Reply-To" is set to the sharer if an mail address is configured | |
| 882 | + // also the default footer contains a "Do not reply" which needs to be adjusted. | |
| 883 | + $initiatorEmail = $initiatorUser->getEMailAddress(); | |
| 884 | +        if($initiatorEmail !== null) { | |
| 885 | + $message->setReplyTo([$initiatorEmail => $initiatorDisplayName]); | |
| 886 | + $emailTemplate->addFooter($instanceName . ($this->defaults->getSlogan() !== '' ? ' - ' . $this->defaults->getSlogan() : '')); | |
| 887 | +        } else { | |
| 888 | + $emailTemplate->addFooter(); | |
| 889 | + } | |
| 890 | + | |
| 891 | + $message->useTemplate($emailTemplate); | |
| 892 | +        try { | |
| 893 | + $failedRecipients = $this->mailer->send($message); | |
| 894 | +            if(!empty($failedRecipients)) { | |
| 895 | +                $this->logger->error('Share notification mail could not be sent to: ' . implode(', ', $failedRecipients)); | |
| 896 | + return; | |
| 897 | + } | |
| 898 | +        } catch (\Exception $e) { | |
| 899 | + $this->logger->logException($e, ['message' => 'Share notification mail could not be sent']); | |
| 900 | + } | |
| 901 | + } | |
| 902 | + | |
| 903 | + /** | |
| 904 | + * Update a share | |
| 905 | + * | |
| 906 | + * @param \OCP\Share\IShare $share | |
| 907 | + * @return \OCP\Share\IShare The share object | |
| 908 | + * @throws \InvalidArgumentException | |
| 909 | + */ | |
| 910 | +    public function updateShare(\OCP\Share\IShare $share) { | |
| 911 | + $expirationDateUpdated = false; | |
| 912 | + | |
| 913 | + $this->canShare($share); | |
| 914 | + | |
| 915 | +        try { | |
| 916 | + $originalShare = $this->getShareById($share->getFullId()); | |
| 917 | +        } catch (\UnexpectedValueException $e) { | |
| 918 | +            throw new \InvalidArgumentException('Share does not have a full id'); | |
| 919 | + } | |
| 920 | + | |
| 921 | + // We can't change the share type! | |
| 922 | +        if ($share->getShareType() !== $originalShare->getShareType()) { | |
| 923 | +            throw new \InvalidArgumentException('Can’t change share type'); | |
| 924 | + } | |
| 925 | + | |
| 926 | + // We can only change the recipient on user shares | |
| 927 | + if ($share->getSharedWith() !== $originalShare->getSharedWith() && | |
| 928 | +            $share->getShareType() !== \OCP\Share::SHARE_TYPE_USER) { | |
| 929 | +            throw new \InvalidArgumentException('Can only update recipient on user shares'); | |
| 930 | + } | |
| 931 | + | |
| 932 | + // Cannot share with the owner | |
| 933 | + if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && | |
| 934 | +            $share->getSharedWith() === $share->getShareOwner()) { | |
| 935 | +            throw new \InvalidArgumentException('Can’t share with the share owner'); | |
| 936 | + } | |
| 937 | + | |
| 938 | + $this->generalCreateChecks($share); | |
| 939 | + | |
| 940 | +        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { | |
| 941 | + $this->userCreateChecks($share); | |
| 942 | + | |
| 943 | +            if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { | |
| 944 | + //Verify the expiration date | |
| 945 | + $this->validateExpirationDate($share); | |
| 946 | + $expirationDateUpdated = true; | |
| 947 | + } | |
| 948 | +        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { | |
| 949 | + $this->groupCreateChecks($share); | |
| 950 | + | |
| 951 | +            if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { | |
| 952 | + //Verify the expiration date | |
| 953 | + $this->validateExpirationDate($share); | |
| 954 | + $expirationDateUpdated = true; | |
| 955 | + } | |
| 956 | +        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { | |
| 957 | + $this->linkCreateChecks($share); | |
| 958 | + | |
| 959 | + $this->updateSharePasswordIfNeeded($share, $originalShare); | |
| 960 | + | |
| 961 | +            if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { | |
| 962 | + //Verify the expiration date | |
| 963 | + $this->validateExpirationDate($share); | |
| 964 | + $expirationDateUpdated = true; | |
| 965 | + } | |
| 966 | +        } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { | |
| 967 | + // The new password is not set again if it is the same as the old | |
| 968 | + // one, unless when switching from sending by Talk to sending by | |
| 969 | + // mail. | |
| 970 | + $plainTextPassword = $share->getPassword(); | |
| 971 | + if (!empty($plainTextPassword) && !$this->updateSharePasswordIfNeeded($share, $originalShare) && | |
| 972 | +                    !($originalShare->getSendPasswordByTalk() && !$share->getSendPasswordByTalk())) { | |
| 973 | + $plainTextPassword = null; | |
| 974 | + } | |
| 975 | +            if (empty($plainTextPassword) && !$originalShare->getSendPasswordByTalk() && $share->getSendPasswordByTalk()) { | |
| 976 | + // If the same password was already sent by mail the recipient | |
| 977 | + // would already have access to the share without having to call | |
| 978 | + // the sharer to verify her identity | |
| 979 | +                throw new \InvalidArgumentException('Can’t enable sending the password by Talk without setting a new password'); | |
| 980 | + } | |
| 981 | + } | |
| 982 | + | |
| 983 | + $this->pathCreateChecks($share->getNode()); | |
| 984 | + | |
| 985 | + // Now update the share! | |
| 986 | + $provider = $this->factory->getProviderForType($share->getShareType()); | |
| 987 | +        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { | |
| 988 | + $share = $provider->update($share, $plainTextPassword); | |
| 989 | +        } else { | |
| 990 | + $share = $provider->update($share); | |
| 991 | + } | |
| 992 | + | |
| 993 | +        if ($expirationDateUpdated === true) { | |
| 994 | + \OC_Hook::emit(Share::class, 'post_set_expiration_date', [ | |
| 995 | + 'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder', | |
| 996 | + 'itemSource' => $share->getNode()->getId(), | |
| 997 | + 'date' => $share->getExpirationDate(), | |
| 998 | + 'uidOwner' => $share->getSharedBy(), | |
| 999 | + ]); | |
| 1000 | + } | |
| 1001 | + | |
| 1002 | +        if ($share->getPassword() !== $originalShare->getPassword()) { | |
| 1003 | + \OC_Hook::emit(Share::class, 'post_update_password', [ | |
| 1004 | + 'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder', | |
| 1005 | + 'itemSource' => $share->getNode()->getId(), | |
| 1006 | + 'uidOwner' => $share->getSharedBy(), | |
| 1007 | + 'token' => $share->getToken(), | |
| 1008 | + 'disabled' => is_null($share->getPassword()), | |
| 1009 | + ]); | |
| 1010 | + } | |
| 1011 | + | |
| 1012 | +        if ($share->getPermissions() !== $originalShare->getPermissions()) { | |
| 1013 | +            if ($this->userManager->userExists($share->getShareOwner())) { | |
| 1014 | + $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner()); | |
| 1015 | +            } else { | |
| 1016 | + $userFolder = $this->rootFolder->getUserFolder($share->getSharedBy()); | |
| 1017 | + } | |
| 1018 | + \OC_Hook::emit(Share::class, 'post_update_permissions', array( | |
| 1019 | + 'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder', | |
| 1020 | + 'itemSource' => $share->getNode()->getId(), | |
| 1021 | + 'shareType' => $share->getShareType(), | |
| 1022 | + 'shareWith' => $share->getSharedWith(), | |
| 1023 | + 'uidOwner' => $share->getSharedBy(), | |
| 1024 | + 'permissions' => $share->getPermissions(), | |
| 1025 | + 'path' => $userFolder->getRelativePath($share->getNode()->getPath()), | |
| 1026 | + )); | |
| 1027 | + } | |
| 1028 | + | |
| 1029 | + return $share; | |
| 1030 | + } | |
| 1031 | + | |
| 1032 | + /** | |
| 1033 | + * Accept a share. | |
| 1034 | + * | |
| 1035 | + * @param IShare $share | |
| 1036 | + * @param string $recipientId | |
| 1037 | + * @return IShare The share object | |
| 1038 | + * @throws \InvalidArgumentException | |
| 1039 | + * @since 9.0.0 | |
| 1040 | + */ | |
| 1041 | +    public function acceptShare(IShare $share, string $recipientId): IShare { | |
| 1042 | + [$providerId, ] = $this->splitFullId($share->getFullId()); | |
| 1043 | + $provider = $this->factory->getProvider($providerId); | |
| 1044 | + | |
| 1045 | +        if (!method_exists($provider, 'acceptShare')) { | |
| 1046 | + // TODO FIX ME | |
| 1047 | +            throw new \InvalidArgumentException('Share provider does not support accepting'); | |
| 1048 | + } | |
| 1049 | + $provider->acceptShare($share, $recipientId); | |
| 1050 | + $event = new GenericEvent($share); | |
| 1051 | +        $this->legacyDispatcher->dispatch('OCP\Share::postAcceptShare', $event); | |
| 1052 | + | |
| 1053 | + return $share; | |
| 1054 | + } | |
| 1055 | + | |
| 1056 | + /** | |
| 1057 | + * Updates the password of the given share if it is not the same as the | |
| 1058 | + * password of the original share. | |
| 1059 | + * | |
| 1060 | + * @param \OCP\Share\IShare $share the share to update its password. | |
| 1061 | + * @param \OCP\Share\IShare $originalShare the original share to compare its | |
| 1062 | + * password with. | |
| 1063 | + * @return boolean whether the password was updated or not. | |
| 1064 | + */ | |
| 1065 | +    private function updateSharePasswordIfNeeded(\OCP\Share\IShare $share, \OCP\Share\IShare $originalShare) { | |
| 1066 | + // Password updated. | |
| 1067 | +        if ($share->getPassword() !== $originalShare->getPassword()) { | |
| 1068 | + //Verify the password | |
| 1069 | + $this->verifyPassword($share->getPassword()); | |
| 1070 | + | |
| 1071 | + // If a password is set. Hash it! | |
| 1072 | +            if ($share->getPassword() !== null) { | |
| 1073 | + $share->setPassword($this->hasher->hash($share->getPassword())); | |
| 1074 | + | |
| 1075 | + return true; | |
| 1076 | + } | |
| 1077 | + } | |
| 1078 | + | |
| 1079 | + return false; | |
| 1080 | + } | |
| 1081 | + | |
| 1082 | + /** | |
| 1083 | + * Delete all the children of this share | |
| 1084 | + * FIXME: remove once https://github.com/owncloud/core/pull/21660 is in | |
| 1085 | + * | |
| 1086 | + * @param \OCP\Share\IShare $share | |
| 1087 | + * @return \OCP\Share\IShare[] List of deleted shares | |
| 1088 | + */ | |
| 1089 | +    protected function deleteChildren(\OCP\Share\IShare $share) { | |
| 1090 | + $deletedShares = []; | |
| 1091 | + | |
| 1092 | + $provider = $this->factory->getProviderForType($share->getShareType()); | |
| 1093 | + | |
| 1094 | +        foreach ($provider->getChildren($share) as $child) { | |
| 1095 | + $deletedChildren = $this->deleteChildren($child); | |
| 1096 | + $deletedShares = array_merge($deletedShares, $deletedChildren); | |
| 1097 | + | |
| 1098 | + $provider->delete($child); | |
| 1099 | + $deletedShares[] = $child; | |
| 1100 | + } | |
| 1101 | + | |
| 1102 | + return $deletedShares; | |
| 1103 | + } | |
| 1104 | + | |
| 1105 | + /** | |
| 1106 | + * Delete a share | |
| 1107 | + * | |
| 1108 | + * @param \OCP\Share\IShare $share | |
| 1109 | + * @throws ShareNotFound | |
| 1110 | + * @throws \InvalidArgumentException | |
| 1111 | + */ | |
| 1112 | +    public function deleteShare(\OCP\Share\IShare $share) { | |
| 1113 | + | |
| 1114 | +        try { | |
| 1115 | + $share->getFullId(); | |
| 1116 | +        } catch (\UnexpectedValueException $e) { | |
| 1117 | +            throw new \InvalidArgumentException('Share does not have a full id'); | |
| 1118 | + } | |
| 1119 | + | |
| 1120 | + $event = new GenericEvent($share); | |
| 1121 | +        $this->legacyDispatcher->dispatch('OCP\Share::preUnshare', $event); | |
| 1122 | + | |
| 1123 | + // Get all children and delete them as well | |
| 1124 | + $deletedShares = $this->deleteChildren($share); | |
| 1125 | + | |
| 1126 | + // Do the actual delete | |
| 1127 | + $provider = $this->factory->getProviderForType($share->getShareType()); | |
| 1128 | + $provider->delete($share); | |
| 1129 | + | |
| 1130 | + // All the deleted shares caused by this delete | |
| 1131 | + $deletedShares[] = $share; | |
| 1132 | + | |
| 1133 | + // Emit post hook | |
| 1134 | +        $event->setArgument('deletedShares', $deletedShares); | |
| 1135 | +        $this->legacyDispatcher->dispatch('OCP\Share::postUnshare', $event); | |
| 1136 | + } | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + /** | |
| 1140 | + * Unshare a file as the recipient. | |
| 1141 | + * This can be different from a regular delete for example when one of | |
| 1142 | + * the users in a groups deletes that share. But the provider should | |
| 1143 | + * handle this. | |
| 1144 | + * | |
| 1145 | + * @param \OCP\Share\IShare $share | |
| 1146 | + * @param string $recipientId | |
| 1147 | + */ | |
| 1148 | +    public function deleteFromSelf(\OCP\Share\IShare $share, $recipientId) { | |
| 1149 | + list($providerId, ) = $this->splitFullId($share->getFullId()); | |
| 1150 | + $provider = $this->factory->getProvider($providerId); | |
| 1151 | + | |
| 1152 | + $provider->deleteFromSelf($share, $recipientId); | |
| 1153 | + $event = new GenericEvent($share); | |
| 1154 | +        $this->legacyDispatcher->dispatch('OCP\Share::postUnshareFromSelf', $event); | |
| 1155 | + } | |
| 1156 | + | |
| 1157 | +    public function restoreShare(IShare $share, string $recipientId): IShare { | |
| 1158 | + list($providerId, ) = $this->splitFullId($share->getFullId()); | |
| 1159 | + $provider = $this->factory->getProvider($providerId); | |
| 1160 | + | |
| 1161 | + return $provider->restore($share, $recipientId); | |
| 1162 | + } | |
| 1163 | + | |
| 1164 | + /** | |
| 1165 | + * @inheritdoc | |
| 1166 | + */ | |
| 1167 | +    public function moveShare(\OCP\Share\IShare $share, $recipientId) { | |
| 1168 | +        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { | |
| 1169 | +            throw new \InvalidArgumentException('Can’t change target of link share'); | |
| 1170 | + } | |
| 1171 | + | |
| 1172 | +        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && $share->getSharedWith() !== $recipientId) { | |
| 1173 | +            throw new \InvalidArgumentException('Invalid recipient'); | |
| 1174 | + } | |
| 1175 | + | |
| 1176 | +        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { | |
| 1177 | + $sharedWith = $this->groupManager->get($share->getSharedWith()); | |
| 1178 | +            if (is_null($sharedWith)) { | |
| 1179 | +                throw new \InvalidArgumentException('Group "' . $share->getSharedWith() . '" does not exist'); | |
| 1180 | + } | |
| 1181 | + $recipient = $this->userManager->get($recipientId); | |
| 1182 | +            if (!$sharedWith->inGroup($recipient)) { | |
| 1183 | +                throw new \InvalidArgumentException('Invalid recipient'); | |
| 1184 | + } | |
| 1185 | + } | |
| 1186 | + | |
| 1187 | + list($providerId, ) = $this->splitFullId($share->getFullId()); | |
| 1188 | + $provider = $this->factory->getProvider($providerId); | |
| 1189 | + | |
| 1190 | + $provider->move($share, $recipientId); | |
| 1191 | + } | |
| 1192 | + | |
| 1193 | +    public function getSharesInFolder($userId, Folder $node, $reshares = false) { | |
| 1194 | + $providers = $this->factory->getAllProviders(); | |
| 1195 | + | |
| 1196 | +        return array_reduce($providers, function($shares, IShareProvider $provider) use ($userId, $node, $reshares) { | |
| 1197 | + $newShares = $provider->getSharesInFolder($userId, $node, $reshares); | |
| 1198 | +            foreach ($newShares as $fid => $data) { | |
| 1199 | +                if (!isset($shares[$fid])) { | |
| 1200 | + $shares[$fid] = []; | |
| 1201 | + } | |
| 1202 | + | |
| 1203 | + $shares[$fid] = array_merge($shares[$fid], $data); | |
| 1204 | + } | |
| 1205 | + return $shares; | |
| 1206 | + }, []); | |
| 1207 | + } | |
| 1208 | + | |
| 1209 | + /** | |
| 1210 | + * @inheritdoc | |
| 1211 | + */ | |
| 1212 | +    public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0) { | |
| 1213 | + if ($path !== null && | |
| 1214 | + !($path instanceof \OCP\Files\File) && | |
| 1215 | +                !($path instanceof \OCP\Files\Folder)) { | |
| 1216 | +            throw new \InvalidArgumentException('invalid path'); | |
| 1217 | + } | |
| 1218 | + | |
| 1219 | +        try { | |
| 1220 | + $provider = $this->factory->getProviderForType($shareType); | |
| 1221 | +        } catch (ProviderException $e) { | |
| 1222 | + return []; | |
| 1223 | + } | |
| 1224 | + | |
| 1225 | + $shares = $provider->getSharesBy($userId, $shareType, $path, $reshares, $limit, $offset); | |
| 1226 | + | |
| 1227 | + /* | |
| 1228 | 1228 | * Work around so we don't return expired shares but still follow | 
| 1229 | 1229 | * proper pagination. | 
| 1230 | 1230 | */ | 
| 1231 | 1231 | |
| 1232 | - $shares2 = []; | |
| 1233 | - | |
| 1234 | -		while(true) { | |
| 1235 | - $added = 0; | |
| 1236 | -			foreach ($shares as $share) { | |
| 1237 | - | |
| 1238 | -				try { | |
| 1239 | - $this->checkExpireDate($share); | |
| 1240 | -				} catch (ShareNotFound $e) { | |
| 1241 | - //Ignore since this basically means the share is deleted | |
| 1242 | - continue; | |
| 1243 | - } | |
| 1244 | - | |
| 1245 | - $added++; | |
| 1246 | - $shares2[] = $share; | |
| 1247 | - | |
| 1248 | -				if (count($shares2) === $limit) { | |
| 1249 | - break; | |
| 1250 | - } | |
| 1251 | - } | |
| 1252 | - | |
| 1253 | - // If we did not fetch more shares than the limit then there are no more shares | |
| 1254 | -			if (count($shares) < $limit) { | |
| 1255 | - break; | |
| 1256 | - } | |
| 1257 | - | |
| 1258 | -			if (count($shares2) === $limit) { | |
| 1259 | - break; | |
| 1260 | - } | |
| 1261 | - | |
| 1262 | - // If there was no limit on the select we are done | |
| 1263 | -			if ($limit === -1) { | |
| 1264 | - break; | |
| 1265 | - } | |
| 1266 | - | |
| 1267 | - $offset += $added; | |
| 1268 | - | |
| 1269 | - // Fetch again $limit shares | |
| 1270 | - $shares = $provider->getSharesBy($userId, $shareType, $path, $reshares, $limit, $offset); | |
| 1271 | - | |
| 1272 | - // No more shares means we are done | |
| 1273 | -			if (empty($shares)) { | |
| 1274 | - break; | |
| 1275 | - } | |
| 1276 | - } | |
| 1277 | - | |
| 1278 | - $shares = $shares2; | |
| 1279 | - | |
| 1280 | - return $shares; | |
| 1281 | - } | |
| 1282 | - | |
| 1283 | - /** | |
| 1284 | - * @inheritdoc | |
| 1285 | - */ | |
| 1286 | -	public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0) { | |
| 1287 | -		try { | |
| 1288 | - $provider = $this->factory->getProviderForType($shareType); | |
| 1289 | -		} catch (ProviderException $e) { | |
| 1290 | - return []; | |
| 1291 | - } | |
| 1292 | - | |
| 1293 | - $shares = $provider->getSharedWith($userId, $shareType, $node, $limit, $offset); | |
| 1294 | - | |
| 1295 | - // remove all shares which are already expired | |
| 1296 | -		foreach ($shares as $key => $share) { | |
| 1297 | -			try { | |
| 1298 | - $this->checkExpireDate($share); | |
| 1299 | -			} catch (ShareNotFound $e) { | |
| 1300 | - unset($shares[$key]); | |
| 1301 | - } | |
| 1302 | - } | |
| 1303 | - | |
| 1304 | - return $shares; | |
| 1305 | - } | |
| 1306 | - | |
| 1307 | - /** | |
| 1308 | - * @inheritdoc | |
| 1309 | - */ | |
| 1310 | -	public function getDeletedSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0) { | |
| 1311 | - $shares = $this->getSharedWith($userId, $shareType, $node, $limit, $offset); | |
| 1312 | - | |
| 1313 | - // Only get deleted shares | |
| 1314 | -		$shares = array_filter($shares, function(IShare $share) { | |
| 1315 | - return $share->getPermissions() === 0; | |
| 1316 | - }); | |
| 1317 | - | |
| 1318 | - // Only get shares where the owner still exists | |
| 1319 | -		$shares = array_filter($shares, function (IShare $share) { | |
| 1320 | - return $this->userManager->userExists($share->getShareOwner()); | |
| 1321 | - }); | |
| 1322 | - | |
| 1323 | - return $shares; | |
| 1324 | - } | |
| 1325 | - | |
| 1326 | - /** | |
| 1327 | - * @inheritdoc | |
| 1328 | - */ | |
| 1329 | -	public function getShareById($id, $recipient = null) { | |
| 1330 | -		if ($id === null) { | |
| 1331 | - throw new ShareNotFound(); | |
| 1332 | - } | |
| 1333 | - | |
| 1334 | - list($providerId, $id) = $this->splitFullId($id); | |
| 1335 | - | |
| 1336 | -		try { | |
| 1337 | - $provider = $this->factory->getProvider($providerId); | |
| 1338 | -		} catch (ProviderException $e) { | |
| 1339 | - throw new ShareNotFound(); | |
| 1340 | - } | |
| 1341 | - | |
| 1342 | - $share = $provider->getShareById($id, $recipient); | |
| 1343 | - | |
| 1344 | - $this->checkExpireDate($share); | |
| 1345 | - | |
| 1346 | - return $share; | |
| 1347 | - } | |
| 1348 | - | |
| 1349 | - /** | |
| 1350 | - * Get all the shares for a given path | |
| 1351 | - * | |
| 1352 | - * @param \OCP\Files\Node $path | |
| 1353 | - * @param int $page | |
| 1354 | - * @param int $perPage | |
| 1355 | - * | |
| 1356 | - * @return Share[] | |
| 1357 | - */ | |
| 1358 | -	public function getSharesByPath(\OCP\Files\Node $path, $page=0, $perPage=50) { | |
| 1359 | - return []; | |
| 1360 | - } | |
| 1361 | - | |
| 1362 | - /** | |
| 1363 | - * Get the share by token possible with password | |
| 1364 | - * | |
| 1365 | - * @param string $token | |
| 1366 | - * @return Share | |
| 1367 | - * | |
| 1368 | - * @throws ShareNotFound | |
| 1369 | - */ | |
| 1370 | -	public function getShareByToken($token) { | |
| 1371 | - // tokens can't be valid local user names | |
| 1372 | -		if ($this->userManager->userExists($token)) { | |
| 1373 | - throw new ShareNotFound(); | |
| 1374 | - } | |
| 1375 | - $share = null; | |
| 1376 | -		try { | |
| 1377 | -			if($this->shareApiAllowLinks()) { | |
| 1378 | - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_LINK); | |
| 1379 | - $share = $provider->getShareByToken($token); | |
| 1380 | - } | |
| 1381 | -		} catch (ProviderException $e) { | |
| 1382 | -		} catch (ShareNotFound $e) { | |
| 1383 | - } | |
| 1384 | - | |
| 1385 | - | |
| 1386 | - // If it is not a link share try to fetch a federated share by token | |
| 1387 | -		if ($share === null) { | |
| 1388 | -			try { | |
| 1389 | - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_REMOTE); | |
| 1390 | - $share = $provider->getShareByToken($token); | |
| 1391 | -			} catch (ProviderException $e) { | |
| 1392 | -			} catch (ShareNotFound $e) { | |
| 1393 | - } | |
| 1394 | - } | |
| 1395 | - | |
| 1396 | - // If it is not a link share try to fetch a mail share by token | |
| 1397 | -		if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) { | |
| 1398 | -			try { | |
| 1399 | - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_EMAIL); | |
| 1400 | - $share = $provider->getShareByToken($token); | |
| 1401 | -			} catch (ProviderException $e) { | |
| 1402 | -			} catch (ShareNotFound $e) { | |
| 1403 | - } | |
| 1404 | - } | |
| 1405 | - | |
| 1406 | -		if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_CIRCLE)) { | |
| 1407 | -			try { | |
| 1408 | - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_CIRCLE); | |
| 1409 | - $share = $provider->getShareByToken($token); | |
| 1410 | -			} catch (ProviderException $e) { | |
| 1411 | -			} catch (ShareNotFound $e) { | |
| 1412 | - } | |
| 1413 | - } | |
| 1414 | - | |
| 1415 | -		if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_ROOM)) { | |
| 1416 | -			try { | |
| 1417 | - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_ROOM); | |
| 1418 | - $share = $provider->getShareByToken($token); | |
| 1419 | -			} catch (ProviderException $e) { | |
| 1420 | -			} catch (ShareNotFound $e) { | |
| 1421 | - } | |
| 1422 | - } | |
| 1423 | - | |
| 1424 | -		if ($share === null) { | |
| 1425 | -			throw new ShareNotFound($this->l->t('The requested share does not exist anymore')); | |
| 1426 | - } | |
| 1427 | - | |
| 1428 | - $this->checkExpireDate($share); | |
| 1429 | - | |
| 1430 | - /* | |
| 1232 | + $shares2 = []; | |
| 1233 | + | |
| 1234 | +        while(true) { | |
| 1235 | + $added = 0; | |
| 1236 | +            foreach ($shares as $share) { | |
| 1237 | + | |
| 1238 | +                try { | |
| 1239 | + $this->checkExpireDate($share); | |
| 1240 | +                } catch (ShareNotFound $e) { | |
| 1241 | + //Ignore since this basically means the share is deleted | |
| 1242 | + continue; | |
| 1243 | + } | |
| 1244 | + | |
| 1245 | + $added++; | |
| 1246 | + $shares2[] = $share; | |
| 1247 | + | |
| 1248 | +                if (count($shares2) === $limit) { | |
| 1249 | + break; | |
| 1250 | + } | |
| 1251 | + } | |
| 1252 | + | |
| 1253 | + // If we did not fetch more shares than the limit then there are no more shares | |
| 1254 | +            if (count($shares) < $limit) { | |
| 1255 | + break; | |
| 1256 | + } | |
| 1257 | + | |
| 1258 | +            if (count($shares2) === $limit) { | |
| 1259 | + break; | |
| 1260 | + } | |
| 1261 | + | |
| 1262 | + // If there was no limit on the select we are done | |
| 1263 | +            if ($limit === -1) { | |
| 1264 | + break; | |
| 1265 | + } | |
| 1266 | + | |
| 1267 | + $offset += $added; | |
| 1268 | + | |
| 1269 | + // Fetch again $limit shares | |
| 1270 | + $shares = $provider->getSharesBy($userId, $shareType, $path, $reshares, $limit, $offset); | |
| 1271 | + | |
| 1272 | + // No more shares means we are done | |
| 1273 | +            if (empty($shares)) { | |
| 1274 | + break; | |
| 1275 | + } | |
| 1276 | + } | |
| 1277 | + | |
| 1278 | + $shares = $shares2; | |
| 1279 | + | |
| 1280 | + return $shares; | |
| 1281 | + } | |
| 1282 | + | |
| 1283 | + /** | |
| 1284 | + * @inheritdoc | |
| 1285 | + */ | |
| 1286 | +    public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0) { | |
| 1287 | +        try { | |
| 1288 | + $provider = $this->factory->getProviderForType($shareType); | |
| 1289 | +        } catch (ProviderException $e) { | |
| 1290 | + return []; | |
| 1291 | + } | |
| 1292 | + | |
| 1293 | + $shares = $provider->getSharedWith($userId, $shareType, $node, $limit, $offset); | |
| 1294 | + | |
| 1295 | + // remove all shares which are already expired | |
| 1296 | +        foreach ($shares as $key => $share) { | |
| 1297 | +            try { | |
| 1298 | + $this->checkExpireDate($share); | |
| 1299 | +            } catch (ShareNotFound $e) { | |
| 1300 | + unset($shares[$key]); | |
| 1301 | + } | |
| 1302 | + } | |
| 1303 | + | |
| 1304 | + return $shares; | |
| 1305 | + } | |
| 1306 | + | |
| 1307 | + /** | |
| 1308 | + * @inheritdoc | |
| 1309 | + */ | |
| 1310 | +    public function getDeletedSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0) { | |
| 1311 | + $shares = $this->getSharedWith($userId, $shareType, $node, $limit, $offset); | |
| 1312 | + | |
| 1313 | + // Only get deleted shares | |
| 1314 | +        $shares = array_filter($shares, function(IShare $share) { | |
| 1315 | + return $share->getPermissions() === 0; | |
| 1316 | + }); | |
| 1317 | + | |
| 1318 | + // Only get shares where the owner still exists | |
| 1319 | +        $shares = array_filter($shares, function (IShare $share) { | |
| 1320 | + return $this->userManager->userExists($share->getShareOwner()); | |
| 1321 | + }); | |
| 1322 | + | |
| 1323 | + return $shares; | |
| 1324 | + } | |
| 1325 | + | |
| 1326 | + /** | |
| 1327 | + * @inheritdoc | |
| 1328 | + */ | |
| 1329 | +    public function getShareById($id, $recipient = null) { | |
| 1330 | +        if ($id === null) { | |
| 1331 | + throw new ShareNotFound(); | |
| 1332 | + } | |
| 1333 | + | |
| 1334 | + list($providerId, $id) = $this->splitFullId($id); | |
| 1335 | + | |
| 1336 | +        try { | |
| 1337 | + $provider = $this->factory->getProvider($providerId); | |
| 1338 | +        } catch (ProviderException $e) { | |
| 1339 | + throw new ShareNotFound(); | |
| 1340 | + } | |
| 1341 | + | |
| 1342 | + $share = $provider->getShareById($id, $recipient); | |
| 1343 | + | |
| 1344 | + $this->checkExpireDate($share); | |
| 1345 | + | |
| 1346 | + return $share; | |
| 1347 | + } | |
| 1348 | + | |
| 1349 | + /** | |
| 1350 | + * Get all the shares for a given path | |
| 1351 | + * | |
| 1352 | + * @param \OCP\Files\Node $path | |
| 1353 | + * @param int $page | |
| 1354 | + * @param int $perPage | |
| 1355 | + * | |
| 1356 | + * @return Share[] | |
| 1357 | + */ | |
| 1358 | +    public function getSharesByPath(\OCP\Files\Node $path, $page=0, $perPage=50) { | |
| 1359 | + return []; | |
| 1360 | + } | |
| 1361 | + | |
| 1362 | + /** | |
| 1363 | + * Get the share by token possible with password | |
| 1364 | + * | |
| 1365 | + * @param string $token | |
| 1366 | + * @return Share | |
| 1367 | + * | |
| 1368 | + * @throws ShareNotFound | |
| 1369 | + */ | |
| 1370 | +    public function getShareByToken($token) { | |
| 1371 | + // tokens can't be valid local user names | |
| 1372 | +        if ($this->userManager->userExists($token)) { | |
| 1373 | + throw new ShareNotFound(); | |
| 1374 | + } | |
| 1375 | + $share = null; | |
| 1376 | +        try { | |
| 1377 | +            if($this->shareApiAllowLinks()) { | |
| 1378 | + $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_LINK); | |
| 1379 | + $share = $provider->getShareByToken($token); | |
| 1380 | + } | |
| 1381 | +        } catch (ProviderException $e) { | |
| 1382 | +        } catch (ShareNotFound $e) { | |
| 1383 | + } | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + // If it is not a link share try to fetch a federated share by token | |
| 1387 | +        if ($share === null) { | |
| 1388 | +            try { | |
| 1389 | + $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_REMOTE); | |
| 1390 | + $share = $provider->getShareByToken($token); | |
| 1391 | +            } catch (ProviderException $e) { | |
| 1392 | +            } catch (ShareNotFound $e) { | |
| 1393 | + } | |
| 1394 | + } | |
| 1395 | + | |
| 1396 | + // If it is not a link share try to fetch a mail share by token | |
| 1397 | +        if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) { | |
| 1398 | +            try { | |
| 1399 | + $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_EMAIL); | |
| 1400 | + $share = $provider->getShareByToken($token); | |
| 1401 | +            } catch (ProviderException $e) { | |
| 1402 | +            } catch (ShareNotFound $e) { | |
| 1403 | + } | |
| 1404 | + } | |
| 1405 | + | |
| 1406 | +        if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_CIRCLE)) { | |
| 1407 | +            try { | |
| 1408 | + $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_CIRCLE); | |
| 1409 | + $share = $provider->getShareByToken($token); | |
| 1410 | +            } catch (ProviderException $e) { | |
| 1411 | +            } catch (ShareNotFound $e) { | |
| 1412 | + } | |
| 1413 | + } | |
| 1414 | + | |
| 1415 | +        if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_ROOM)) { | |
| 1416 | +            try { | |
| 1417 | + $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_ROOM); | |
| 1418 | + $share = $provider->getShareByToken($token); | |
| 1419 | +            } catch (ProviderException $e) { | |
| 1420 | +            } catch (ShareNotFound $e) { | |
| 1421 | + } | |
| 1422 | + } | |
| 1423 | + | |
| 1424 | +        if ($share === null) { | |
| 1425 | +            throw new ShareNotFound($this->l->t('The requested share does not exist anymore')); | |
| 1426 | + } | |
| 1427 | + | |
| 1428 | + $this->checkExpireDate($share); | |
| 1429 | + | |
| 1430 | + /* | |
| 1431 | 1431 | * Reduce the permissions for link shares if public upload is not enabled | 
| 1432 | 1432 | */ | 
| 1433 | - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && | |
| 1434 | -			!$this->shareApiLinkAllowPublicUpload()) { | |
| 1435 | - $share->setPermissions($share->getPermissions() & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE)); | |
| 1436 | - } | |
| 1437 | - | |
| 1438 | - return $share; | |
| 1439 | - } | |
| 1440 | - | |
| 1441 | -	protected function checkExpireDate($share) { | |
| 1442 | -		if ($share->isExpired()) { | |
| 1443 | - $this->deleteShare($share); | |
| 1444 | -			throw new ShareNotFound($this->l->t('The requested share does not exist anymore')); | |
| 1445 | - } | |
| 1446 | - | |
| 1447 | - } | |
| 1448 | - | |
| 1449 | - /** | |
| 1450 | - * Verify the password of a public share | |
| 1451 | - * | |
| 1452 | - * @param \OCP\Share\IShare $share | |
| 1453 | - * @param string $password | |
| 1454 | - * @return bool | |
| 1455 | - */ | |
| 1456 | -	public function checkPassword(\OCP\Share\IShare $share, $password) { | |
| 1457 | - $passwordProtected = $share->getShareType() !== IShare::TYPE_LINK | |
| 1458 | - || $share->getShareType() !== IShare::TYPE_EMAIL | |
| 1459 | - || $share->getShareType() !== IShare::TYPE_CIRCLE; | |
| 1460 | -		if (!$passwordProtected) { | |
| 1461 | - //TODO maybe exception? | |
| 1462 | - return false; | |
| 1463 | - } | |
| 1464 | - | |
| 1465 | -		if ($password === null || $share->getPassword() === null) { | |
| 1466 | - return false; | |
| 1467 | - } | |
| 1468 | - | |
| 1469 | - $newHash = ''; | |
| 1470 | -		if (!$this->hasher->verify($password, $share->getPassword(), $newHash)) { | |
| 1471 | - return false; | |
| 1472 | - } | |
| 1473 | - | |
| 1474 | -		if (!empty($newHash)) { | |
| 1475 | - $share->setPassword($newHash); | |
| 1476 | - $provider = $this->factory->getProviderForType($share->getShareType()); | |
| 1477 | - $provider->update($share); | |
| 1478 | - } | |
| 1479 | - | |
| 1480 | - return true; | |
| 1481 | - } | |
| 1482 | - | |
| 1483 | - /** | |
| 1484 | - * @inheritdoc | |
| 1485 | - */ | |
| 1486 | -	public function userDeleted($uid) { | |
| 1487 | - $types = [\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK, \OCP\Share::SHARE_TYPE_REMOTE, \OCP\Share::SHARE_TYPE_EMAIL]; | |
| 1488 | - | |
| 1489 | -		foreach ($types as $type) { | |
| 1490 | -			try { | |
| 1491 | - $provider = $this->factory->getProviderForType($type); | |
| 1492 | -			} catch (ProviderException $e) { | |
| 1493 | - continue; | |
| 1494 | - } | |
| 1495 | - $provider->userDeleted($uid, $type); | |
| 1496 | - } | |
| 1497 | - } | |
| 1498 | - | |
| 1499 | - /** | |
| 1500 | - * @inheritdoc | |
| 1501 | - */ | |
| 1502 | -	public function groupDeleted($gid) { | |
| 1503 | - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP); | |
| 1504 | - $provider->groupDeleted($gid); | |
| 1505 | - } | |
| 1506 | - | |
| 1507 | - /** | |
| 1508 | - * @inheritdoc | |
| 1509 | - */ | |
| 1510 | -	public function userDeletedFromGroup($uid, $gid) { | |
| 1511 | - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP); | |
| 1512 | - $provider->userDeletedFromGroup($uid, $gid); | |
| 1513 | - } | |
| 1514 | - | |
| 1515 | - /** | |
| 1516 | - * Get access list to a path. This means | |
| 1517 | - * all the users that can access a given path. | |
| 1518 | - * | |
| 1519 | - * Consider: | |
| 1520 | - * -root | |
| 1521 | - * |-folder1 (23) | |
| 1522 | - * |-folder2 (32) | |
| 1523 | - * |-fileA (42) | |
| 1524 | - * | |
| 1525 | - * fileA is shared with user1 and user1@server1 | |
| 1526 | - * folder2 is shared with group2 (user4 is a member of group2) | |
| 1527 | - * folder1 is shared with user2 (renamed to "folder (1)") and user2@server2 | |
| 1528 | - * | |
| 1529 | - * Then the access list to '/folder1/folder2/fileA' with $currentAccess is: | |
| 1530 | - * [ | |
| 1531 | - * users => [ | |
| 1532 | - * 'user1' => ['node_id' => 42, 'node_path' => '/fileA'], | |
| 1533 | - * 'user4' => ['node_id' => 32, 'node_path' => '/folder2'], | |
| 1534 | - * 'user2' => ['node_id' => 23, 'node_path' => '/folder (1)'], | |
| 1535 | - * ], | |
| 1536 | - * remote => [ | |
| 1537 | - * 'user1@server1' => ['node_id' => 42, 'token' => 'SeCr3t'], | |
| 1538 | - * 'user2@server2' => ['node_id' => 23, 'token' => 'FooBaR'], | |
| 1539 | - * ], | |
| 1540 | - * public => bool | |
| 1541 | - * mail => bool | |
| 1542 | - * ] | |
| 1543 | - * | |
| 1544 | - * The access list to '/folder1/folder2/fileA' **without** $currentAccess is: | |
| 1545 | - * [ | |
| 1546 | - * users => ['user1', 'user2', 'user4'], | |
| 1547 | - * remote => bool, | |
| 1548 | - * public => bool | |
| 1549 | - * mail => bool | |
| 1550 | - * ] | |
| 1551 | - * | |
| 1552 | - * This is required for encryption/activity | |
| 1553 | - * | |
| 1554 | - * @param \OCP\Files\Node $path | |
| 1555 | - * @param bool $recursive Should we check all parent folders as well | |
| 1556 | - * @param bool $currentAccess Ensure the recipient has access to the file (e.g. did not unshare it) | |
| 1557 | - * @return array | |
| 1558 | - */ | |
| 1559 | -	public function getAccessList(\OCP\Files\Node $path, $recursive = true, $currentAccess = false) { | |
| 1560 | - $owner = $path->getOwner(); | |
| 1561 | - | |
| 1562 | -		if ($owner === null) { | |
| 1563 | - return []; | |
| 1564 | - } | |
| 1565 | - | |
| 1566 | - $owner = $owner->getUID(); | |
| 1567 | - | |
| 1568 | -		if ($currentAccess) { | |
| 1569 | - $al = ['users' => [], 'remote' => [], 'public' => false]; | |
| 1570 | -		} else { | |
| 1571 | - $al = ['users' => [], 'remote' => false, 'public' => false]; | |
| 1572 | - } | |
| 1573 | -		if (!$this->userManager->userExists($owner)) { | |
| 1574 | - return $al; | |
| 1575 | - } | |
| 1576 | - | |
| 1577 | - //Get node for the owner and correct the owner in case of external storages | |
| 1578 | - $userFolder = $this->rootFolder->getUserFolder($owner); | |
| 1579 | -		if ($path->getId() !== $userFolder->getId() && !$userFolder->isSubNode($path)) { | |
| 1580 | - $nodes = $userFolder->getById($path->getId()); | |
| 1581 | - $path = array_shift($nodes); | |
| 1582 | -			if ($path->getOwner() === null) { | |
| 1583 | - return []; | |
| 1584 | - } | |
| 1585 | - $owner = $path->getOwner()->getUID(); | |
| 1586 | - } | |
| 1587 | - | |
| 1588 | - $providers = $this->factory->getAllProviders(); | |
| 1589 | - | |
| 1590 | - /** @var Node[] $nodes */ | |
| 1591 | - $nodes = []; | |
| 1592 | - | |
| 1593 | - | |
| 1594 | -		if ($currentAccess) { | |
| 1595 | - $ownerPath = $path->getPath(); | |
| 1596 | -			$ownerPath = explode('/', $ownerPath, 4); | |
| 1597 | -			if (count($ownerPath) < 4) { | |
| 1598 | - $ownerPath = ''; | |
| 1599 | -			} else { | |
| 1600 | - $ownerPath = $ownerPath[3]; | |
| 1601 | - } | |
| 1602 | - $al['users'][$owner] = [ | |
| 1603 | - 'node_id' => $path->getId(), | |
| 1604 | - 'node_path' => '/' . $ownerPath, | |
| 1605 | - ]; | |
| 1606 | -		} else { | |
| 1607 | - $al['users'][] = $owner; | |
| 1608 | - } | |
| 1609 | - | |
| 1610 | - // Collect all the shares | |
| 1611 | -		while ($path->getPath() !== $userFolder->getPath()) { | |
| 1612 | - $nodes[] = $path; | |
| 1613 | -			if (!$recursive) { | |
| 1614 | - break; | |
| 1615 | - } | |
| 1616 | - $path = $path->getParent(); | |
| 1617 | - } | |
| 1618 | - | |
| 1619 | -		foreach ($providers as $provider) { | |
| 1620 | - $tmp = $provider->getAccessList($nodes, $currentAccess); | |
| 1621 | - | |
| 1622 | -			foreach ($tmp as $k => $v) { | |
| 1623 | -				if (isset($al[$k])) { | |
| 1624 | -					if (is_array($al[$k])) { | |
| 1625 | -						if ($currentAccess) { | |
| 1626 | - $al[$k] += $v; | |
| 1627 | -						} else { | |
| 1628 | - $al[$k] = array_merge($al[$k], $v); | |
| 1629 | - $al[$k] = array_unique($al[$k]); | |
| 1630 | - $al[$k] = array_values($al[$k]); | |
| 1631 | - } | |
| 1632 | -					} else { | |
| 1633 | - $al[$k] = $al[$k] || $v; | |
| 1634 | - } | |
| 1635 | -				} else { | |
| 1636 | - $al[$k] = $v; | |
| 1637 | - } | |
| 1638 | - } | |
| 1639 | - } | |
| 1640 | - | |
| 1641 | - return $al; | |
| 1642 | - } | |
| 1643 | - | |
| 1644 | - /** | |
| 1645 | - * Create a new share | |
| 1646 | - * @return \OCP\Share\IShare | |
| 1647 | - */ | |
| 1648 | -	public function newShare() { | |
| 1649 | - return new \OC\Share20\Share($this->rootFolder, $this->userManager); | |
| 1650 | - } | |
| 1651 | - | |
| 1652 | - /** | |
| 1653 | - * Is the share API enabled | |
| 1654 | - * | |
| 1655 | - * @return bool | |
| 1656 | - */ | |
| 1657 | -	public function shareApiEnabled() { | |
| 1658 | -		return $this->config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes'; | |
| 1659 | - } | |
| 1660 | - | |
| 1661 | - /** | |
| 1662 | - * Is public link sharing enabled | |
| 1663 | - * | |
| 1664 | - * @return bool | |
| 1665 | - */ | |
| 1666 | -	public function shareApiAllowLinks() { | |
| 1667 | -		return $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes'; | |
| 1668 | - } | |
| 1669 | - | |
| 1670 | - /** | |
| 1671 | - * Is password on public link requires | |
| 1672 | - * | |
| 1673 | - * @return bool | |
| 1674 | - */ | |
| 1675 | -	public function shareApiLinkEnforcePassword() { | |
| 1676 | -		return $this->config->getAppValue('core', 'shareapi_enforce_links_password', 'no') === 'yes'; | |
| 1677 | - } | |
| 1678 | - | |
| 1679 | - /** | |
| 1680 | - * Is default link expire date enabled | |
| 1681 | - * | |
| 1682 | - * @return bool | |
| 1683 | - */ | |
| 1684 | -	public function shareApiLinkDefaultExpireDate() { | |
| 1685 | -		return $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; | |
| 1686 | - } | |
| 1687 | - | |
| 1688 | - /** | |
| 1689 | - * Is default link expire date enforced | |
| 1690 | - *` | |
| 1691 | - * @return bool | |
| 1692 | - */ | |
| 1693 | -	public function shareApiLinkDefaultExpireDateEnforced() { | |
| 1694 | - return $this->shareApiLinkDefaultExpireDate() && | |
| 1695 | -			$this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; | |
| 1696 | - } | |
| 1697 | - | |
| 1698 | - | |
| 1699 | - /** | |
| 1700 | - * Number of default link expire days | |
| 1701 | - * @return int | |
| 1702 | - */ | |
| 1703 | -	public function shareApiLinkDefaultExpireDays() { | |
| 1704 | -		return (int)$this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); | |
| 1705 | - } | |
| 1706 | - | |
| 1707 | - /** | |
| 1708 | - * Is default internal expire date enabled | |
| 1709 | - * | |
| 1710 | - * @return bool | |
| 1711 | - */ | |
| 1712 | -	public function shareApiInternalDefaultExpireDate(): bool { | |
| 1713 | -		return $this->config->getAppValue('core', 'shareapi_default_internal_expire_date', 'no') === 'yes'; | |
| 1714 | - } | |
| 1715 | - | |
| 1716 | - /** | |
| 1717 | - * Is default expire date enforced | |
| 1718 | - *` | |
| 1719 | - * @return bool | |
| 1720 | - */ | |
| 1721 | -	public function shareApiInternalDefaultExpireDateEnforced(): bool { | |
| 1722 | - return $this->shareApiInternalDefaultExpireDate() && | |
| 1723 | -			$this->config->getAppValue('core', 'shareapi_enforce_internal_expire_date', 'no') === 'yes'; | |
| 1724 | - } | |
| 1725 | - | |
| 1726 | - | |
| 1727 | - /** | |
| 1728 | - * Number of default expire days | |
| 1729 | - * @return int | |
| 1730 | - */ | |
| 1731 | -	public function shareApiInternalDefaultExpireDays(): int { | |
| 1732 | -		return (int)$this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'); | |
| 1733 | - } | |
| 1734 | - | |
| 1735 | - /** | |
| 1736 | - * Allow public upload on link shares | |
| 1737 | - * | |
| 1738 | - * @return bool | |
| 1739 | - */ | |
| 1740 | -	public function shareApiLinkAllowPublicUpload() { | |
| 1741 | -		return $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes') === 'yes'; | |
| 1742 | - } | |
| 1743 | - | |
| 1744 | - /** | |
| 1745 | - * check if user can only share with group members | |
| 1746 | - * @return bool | |
| 1747 | - */ | |
| 1748 | -	public function shareWithGroupMembersOnly() { | |
| 1749 | -		return $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes'; | |
| 1750 | - } | |
| 1751 | - | |
| 1752 | - /** | |
| 1753 | - * Check if users can share with groups | |
| 1754 | - * @return bool | |
| 1755 | - */ | |
| 1756 | -	public function allowGroupSharing() { | |
| 1757 | -		return $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes'; | |
| 1758 | - } | |
| 1759 | - | |
| 1760 | - /** | |
| 1761 | - * Copied from \OC_Util::isSharingDisabledForUser | |
| 1762 | - * | |
| 1763 | - * TODO: Deprecate fuction from OC_Util | |
| 1764 | - * | |
| 1765 | - * @param string $userId | |
| 1766 | - * @return bool | |
| 1767 | - */ | |
| 1768 | -	public function sharingDisabledForUser($userId) { | |
| 1769 | -		if ($userId === null) { | |
| 1770 | - return false; | |
| 1771 | - } | |
| 1772 | - | |
| 1773 | -		if (isset($this->sharingDisabledForUsersCache[$userId])) { | |
| 1774 | - return $this->sharingDisabledForUsersCache[$userId]; | |
| 1775 | - } | |
| 1776 | - | |
| 1777 | -		if ($this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes') { | |
| 1778 | -			$groupsList = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', ''); | |
| 1779 | - $excludedGroups = json_decode($groupsList); | |
| 1780 | -			if (is_null($excludedGroups)) { | |
| 1781 | -				$excludedGroups = explode(',', $groupsList); | |
| 1782 | - $newValue = json_encode($excludedGroups); | |
| 1783 | -				$this->config->setAppValue('core', 'shareapi_exclude_groups_list', $newValue); | |
| 1784 | - } | |
| 1785 | - $user = $this->userManager->get($userId); | |
| 1786 | - $usersGroups = $this->groupManager->getUserGroupIds($user); | |
| 1787 | -			if (!empty($usersGroups)) { | |
| 1788 | - $remainingGroups = array_diff($usersGroups, $excludedGroups); | |
| 1789 | - // if the user is only in groups which are disabled for sharing then | |
| 1790 | - // sharing is also disabled for the user | |
| 1791 | -				if (empty($remainingGroups)) { | |
| 1792 | - $this->sharingDisabledForUsersCache[$userId] = true; | |
| 1793 | - return true; | |
| 1794 | - } | |
| 1795 | - } | |
| 1796 | - } | |
| 1797 | - | |
| 1798 | - $this->sharingDisabledForUsersCache[$userId] = false; | |
| 1799 | - return false; | |
| 1800 | - } | |
| 1801 | - | |
| 1802 | - /** | |
| 1803 | - * @inheritdoc | |
| 1804 | - */ | |
| 1805 | -	public function outgoingServer2ServerSharesAllowed() { | |
| 1806 | -		return $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes'; | |
| 1807 | - } | |
| 1808 | - | |
| 1809 | - /** | |
| 1810 | - * @inheritdoc | |
| 1811 | - */ | |
| 1812 | -	public function outgoingServer2ServerGroupSharesAllowed() { | |
| 1813 | -		return $this->config->getAppValue('files_sharing', 'outgoing_server2server_group_share_enabled', 'no') === 'yes'; | |
| 1814 | - } | |
| 1815 | - | |
| 1816 | - /** | |
| 1817 | - * @inheritdoc | |
| 1818 | - */ | |
| 1819 | -	public function shareProviderExists($shareType) { | |
| 1820 | -		try { | |
| 1821 | - $this->factory->getProviderForType($shareType); | |
| 1822 | -		} catch (ProviderException $e) { | |
| 1823 | - return false; | |
| 1824 | - } | |
| 1825 | - | |
| 1826 | - return true; | |
| 1827 | - } | |
| 1828 | - | |
| 1829 | -	public function getAllShares(): iterable { | |
| 1830 | - $providers = $this->factory->getAllProviders(); | |
| 1831 | - | |
| 1832 | -		foreach ($providers as $provider) { | |
| 1833 | - yield from $provider->getAllShares(); | |
| 1834 | - } | |
| 1835 | - } | |
| 1433 | + if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && | |
| 1434 | +            !$this->shareApiLinkAllowPublicUpload()) { | |
| 1435 | + $share->setPermissions($share->getPermissions() & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE)); | |
| 1436 | + } | |
| 1437 | + | |
| 1438 | + return $share; | |
| 1439 | + } | |
| 1440 | + | |
| 1441 | +    protected function checkExpireDate($share) { | |
| 1442 | +        if ($share->isExpired()) { | |
| 1443 | + $this->deleteShare($share); | |
| 1444 | +            throw new ShareNotFound($this->l->t('The requested share does not exist anymore')); | |
| 1445 | + } | |
| 1446 | + | |
| 1447 | + } | |
| 1448 | + | |
| 1449 | + /** | |
| 1450 | + * Verify the password of a public share | |
| 1451 | + * | |
| 1452 | + * @param \OCP\Share\IShare $share | |
| 1453 | + * @param string $password | |
| 1454 | + * @return bool | |
| 1455 | + */ | |
| 1456 | +    public function checkPassword(\OCP\Share\IShare $share, $password) { | |
| 1457 | + $passwordProtected = $share->getShareType() !== IShare::TYPE_LINK | |
| 1458 | + || $share->getShareType() !== IShare::TYPE_EMAIL | |
| 1459 | + || $share->getShareType() !== IShare::TYPE_CIRCLE; | |
| 1460 | +        if (!$passwordProtected) { | |
| 1461 | + //TODO maybe exception? | |
| 1462 | + return false; | |
| 1463 | + } | |
| 1464 | + | |
| 1465 | +        if ($password === null || $share->getPassword() === null) { | |
| 1466 | + return false; | |
| 1467 | + } | |
| 1468 | + | |
| 1469 | + $newHash = ''; | |
| 1470 | +        if (!$this->hasher->verify($password, $share->getPassword(), $newHash)) { | |
| 1471 | + return false; | |
| 1472 | + } | |
| 1473 | + | |
| 1474 | +        if (!empty($newHash)) { | |
| 1475 | + $share->setPassword($newHash); | |
| 1476 | + $provider = $this->factory->getProviderForType($share->getShareType()); | |
| 1477 | + $provider->update($share); | |
| 1478 | + } | |
| 1479 | + | |
| 1480 | + return true; | |
| 1481 | + } | |
| 1482 | + | |
| 1483 | + /** | |
| 1484 | + * @inheritdoc | |
| 1485 | + */ | |
| 1486 | +    public function userDeleted($uid) { | |
| 1487 | + $types = [\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK, \OCP\Share::SHARE_TYPE_REMOTE, \OCP\Share::SHARE_TYPE_EMAIL]; | |
| 1488 | + | |
| 1489 | +        foreach ($types as $type) { | |
| 1490 | +            try { | |
| 1491 | + $provider = $this->factory->getProviderForType($type); | |
| 1492 | +            } catch (ProviderException $e) { | |
| 1493 | + continue; | |
| 1494 | + } | |
| 1495 | + $provider->userDeleted($uid, $type); | |
| 1496 | + } | |
| 1497 | + } | |
| 1498 | + | |
| 1499 | + /** | |
| 1500 | + * @inheritdoc | |
| 1501 | + */ | |
| 1502 | +    public function groupDeleted($gid) { | |
| 1503 | + $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP); | |
| 1504 | + $provider->groupDeleted($gid); | |
| 1505 | + } | |
| 1506 | + | |
| 1507 | + /** | |
| 1508 | + * @inheritdoc | |
| 1509 | + */ | |
| 1510 | +    public function userDeletedFromGroup($uid, $gid) { | |
| 1511 | + $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP); | |
| 1512 | + $provider->userDeletedFromGroup($uid, $gid); | |
| 1513 | + } | |
| 1514 | + | |
| 1515 | + /** | |
| 1516 | + * Get access list to a path. This means | |
| 1517 | + * all the users that can access a given path. | |
| 1518 | + * | |
| 1519 | + * Consider: | |
| 1520 | + * -root | |
| 1521 | + * |-folder1 (23) | |
| 1522 | + * |-folder2 (32) | |
| 1523 | + * |-fileA (42) | |
| 1524 | + * | |
| 1525 | + * fileA is shared with user1 and user1@server1 | |
| 1526 | + * folder2 is shared with group2 (user4 is a member of group2) | |
| 1527 | + * folder1 is shared with user2 (renamed to "folder (1)") and user2@server2 | |
| 1528 | + * | |
| 1529 | + * Then the access list to '/folder1/folder2/fileA' with $currentAccess is: | |
| 1530 | + * [ | |
| 1531 | + * users => [ | |
| 1532 | + * 'user1' => ['node_id' => 42, 'node_path' => '/fileA'], | |
| 1533 | + * 'user4' => ['node_id' => 32, 'node_path' => '/folder2'], | |
| 1534 | + * 'user2' => ['node_id' => 23, 'node_path' => '/folder (1)'], | |
| 1535 | + * ], | |
| 1536 | + * remote => [ | |
| 1537 | + * 'user1@server1' => ['node_id' => 42, 'token' => 'SeCr3t'], | |
| 1538 | + * 'user2@server2' => ['node_id' => 23, 'token' => 'FooBaR'], | |
| 1539 | + * ], | |
| 1540 | + * public => bool | |
| 1541 | + * mail => bool | |
| 1542 | + * ] | |
| 1543 | + * | |
| 1544 | + * The access list to '/folder1/folder2/fileA' **without** $currentAccess is: | |
| 1545 | + * [ | |
| 1546 | + * users => ['user1', 'user2', 'user4'], | |
| 1547 | + * remote => bool, | |
| 1548 | + * public => bool | |
| 1549 | + * mail => bool | |
| 1550 | + * ] | |
| 1551 | + * | |
| 1552 | + * This is required for encryption/activity | |
| 1553 | + * | |
| 1554 | + * @param \OCP\Files\Node $path | |
| 1555 | + * @param bool $recursive Should we check all parent folders as well | |
| 1556 | + * @param bool $currentAccess Ensure the recipient has access to the file (e.g. did not unshare it) | |
| 1557 | + * @return array | |
| 1558 | + */ | |
| 1559 | +    public function getAccessList(\OCP\Files\Node $path, $recursive = true, $currentAccess = false) { | |
| 1560 | + $owner = $path->getOwner(); | |
| 1561 | + | |
| 1562 | +        if ($owner === null) { | |
| 1563 | + return []; | |
| 1564 | + } | |
| 1565 | + | |
| 1566 | + $owner = $owner->getUID(); | |
| 1567 | + | |
| 1568 | +        if ($currentAccess) { | |
| 1569 | + $al = ['users' => [], 'remote' => [], 'public' => false]; | |
| 1570 | +        } else { | |
| 1571 | + $al = ['users' => [], 'remote' => false, 'public' => false]; | |
| 1572 | + } | |
| 1573 | +        if (!$this->userManager->userExists($owner)) { | |
| 1574 | + return $al; | |
| 1575 | + } | |
| 1576 | + | |
| 1577 | + //Get node for the owner and correct the owner in case of external storages | |
| 1578 | + $userFolder = $this->rootFolder->getUserFolder($owner); | |
| 1579 | +        if ($path->getId() !== $userFolder->getId() && !$userFolder->isSubNode($path)) { | |
| 1580 | + $nodes = $userFolder->getById($path->getId()); | |
| 1581 | + $path = array_shift($nodes); | |
| 1582 | +            if ($path->getOwner() === null) { | |
| 1583 | + return []; | |
| 1584 | + } | |
| 1585 | + $owner = $path->getOwner()->getUID(); | |
| 1586 | + } | |
| 1587 | + | |
| 1588 | + $providers = $this->factory->getAllProviders(); | |
| 1589 | + | |
| 1590 | + /** @var Node[] $nodes */ | |
| 1591 | + $nodes = []; | |
| 1592 | + | |
| 1593 | + | |
| 1594 | +        if ($currentAccess) { | |
| 1595 | + $ownerPath = $path->getPath(); | |
| 1596 | +            $ownerPath = explode('/', $ownerPath, 4); | |
| 1597 | +            if (count($ownerPath) < 4) { | |
| 1598 | + $ownerPath = ''; | |
| 1599 | +            } else { | |
| 1600 | + $ownerPath = $ownerPath[3]; | |
| 1601 | + } | |
| 1602 | + $al['users'][$owner] = [ | |
| 1603 | + 'node_id' => $path->getId(), | |
| 1604 | + 'node_path' => '/' . $ownerPath, | |
| 1605 | + ]; | |
| 1606 | +        } else { | |
| 1607 | + $al['users'][] = $owner; | |
| 1608 | + } | |
| 1609 | + | |
| 1610 | + // Collect all the shares | |
| 1611 | +        while ($path->getPath() !== $userFolder->getPath()) { | |
| 1612 | + $nodes[] = $path; | |
| 1613 | +            if (!$recursive) { | |
| 1614 | + break; | |
| 1615 | + } | |
| 1616 | + $path = $path->getParent(); | |
| 1617 | + } | |
| 1618 | + | |
| 1619 | +        foreach ($providers as $provider) { | |
| 1620 | + $tmp = $provider->getAccessList($nodes, $currentAccess); | |
| 1621 | + | |
| 1622 | +            foreach ($tmp as $k => $v) { | |
| 1623 | +                if (isset($al[$k])) { | |
| 1624 | +                    if (is_array($al[$k])) { | |
| 1625 | +                        if ($currentAccess) { | |
| 1626 | + $al[$k] += $v; | |
| 1627 | +                        } else { | |
| 1628 | + $al[$k] = array_merge($al[$k], $v); | |
| 1629 | + $al[$k] = array_unique($al[$k]); | |
| 1630 | + $al[$k] = array_values($al[$k]); | |
| 1631 | + } | |
| 1632 | +                    } else { | |
| 1633 | + $al[$k] = $al[$k] || $v; | |
| 1634 | + } | |
| 1635 | +                } else { | |
| 1636 | + $al[$k] = $v; | |
| 1637 | + } | |
| 1638 | + } | |
| 1639 | + } | |
| 1640 | + | |
| 1641 | + return $al; | |
| 1642 | + } | |
| 1643 | + | |
| 1644 | + /** | |
| 1645 | + * Create a new share | |
| 1646 | + * @return \OCP\Share\IShare | |
| 1647 | + */ | |
| 1648 | +    public function newShare() { | |
| 1649 | + return new \OC\Share20\Share($this->rootFolder, $this->userManager); | |
| 1650 | + } | |
| 1651 | + | |
| 1652 | + /** | |
| 1653 | + * Is the share API enabled | |
| 1654 | + * | |
| 1655 | + * @return bool | |
| 1656 | + */ | |
| 1657 | +    public function shareApiEnabled() { | |
| 1658 | +        return $this->config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes'; | |
| 1659 | + } | |
| 1660 | + | |
| 1661 | + /** | |
| 1662 | + * Is public link sharing enabled | |
| 1663 | + * | |
| 1664 | + * @return bool | |
| 1665 | + */ | |
| 1666 | +    public function shareApiAllowLinks() { | |
| 1667 | +        return $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes'; | |
| 1668 | + } | |
| 1669 | + | |
| 1670 | + /** | |
| 1671 | + * Is password on public link requires | |
| 1672 | + * | |
| 1673 | + * @return bool | |
| 1674 | + */ | |
| 1675 | +    public function shareApiLinkEnforcePassword() { | |
| 1676 | +        return $this->config->getAppValue('core', 'shareapi_enforce_links_password', 'no') === 'yes'; | |
| 1677 | + } | |
| 1678 | + | |
| 1679 | + /** | |
| 1680 | + * Is default link expire date enabled | |
| 1681 | + * | |
| 1682 | + * @return bool | |
| 1683 | + */ | |
| 1684 | +    public function shareApiLinkDefaultExpireDate() { | |
| 1685 | +        return $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; | |
| 1686 | + } | |
| 1687 | + | |
| 1688 | + /** | |
| 1689 | + * Is default link expire date enforced | |
| 1690 | + *` | |
| 1691 | + * @return bool | |
| 1692 | + */ | |
| 1693 | +    public function shareApiLinkDefaultExpireDateEnforced() { | |
| 1694 | + return $this->shareApiLinkDefaultExpireDate() && | |
| 1695 | +            $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; | |
| 1696 | + } | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + /** | |
| 1700 | + * Number of default link expire days | |
| 1701 | + * @return int | |
| 1702 | + */ | |
| 1703 | +    public function shareApiLinkDefaultExpireDays() { | |
| 1704 | +        return (int)$this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); | |
| 1705 | + } | |
| 1706 | + | |
| 1707 | + /** | |
| 1708 | + * Is default internal expire date enabled | |
| 1709 | + * | |
| 1710 | + * @return bool | |
| 1711 | + */ | |
| 1712 | +    public function shareApiInternalDefaultExpireDate(): bool { | |
| 1713 | +        return $this->config->getAppValue('core', 'shareapi_default_internal_expire_date', 'no') === 'yes'; | |
| 1714 | + } | |
| 1715 | + | |
| 1716 | + /** | |
| 1717 | + * Is default expire date enforced | |
| 1718 | + *` | |
| 1719 | + * @return bool | |
| 1720 | + */ | |
| 1721 | +    public function shareApiInternalDefaultExpireDateEnforced(): bool { | |
| 1722 | + return $this->shareApiInternalDefaultExpireDate() && | |
| 1723 | +            $this->config->getAppValue('core', 'shareapi_enforce_internal_expire_date', 'no') === 'yes'; | |
| 1724 | + } | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + /** | |
| 1728 | + * Number of default expire days | |
| 1729 | + * @return int | |
| 1730 | + */ | |
| 1731 | +    public function shareApiInternalDefaultExpireDays(): int { | |
| 1732 | +        return (int)$this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'); | |
| 1733 | + } | |
| 1734 | + | |
| 1735 | + /** | |
| 1736 | + * Allow public upload on link shares | |
| 1737 | + * | |
| 1738 | + * @return bool | |
| 1739 | + */ | |
| 1740 | +    public function shareApiLinkAllowPublicUpload() { | |
| 1741 | +        return $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes') === 'yes'; | |
| 1742 | + } | |
| 1743 | + | |
| 1744 | + /** | |
| 1745 | + * check if user can only share with group members | |
| 1746 | + * @return bool | |
| 1747 | + */ | |
| 1748 | +    public function shareWithGroupMembersOnly() { | |
| 1749 | +        return $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes'; | |
| 1750 | + } | |
| 1751 | + | |
| 1752 | + /** | |
| 1753 | + * Check if users can share with groups | |
| 1754 | + * @return bool | |
| 1755 | + */ | |
| 1756 | +    public function allowGroupSharing() { | |
| 1757 | +        return $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes'; | |
| 1758 | + } | |
| 1759 | + | |
| 1760 | + /** | |
| 1761 | + * Copied from \OC_Util::isSharingDisabledForUser | |
| 1762 | + * | |
| 1763 | + * TODO: Deprecate fuction from OC_Util | |
| 1764 | + * | |
| 1765 | + * @param string $userId | |
| 1766 | + * @return bool | |
| 1767 | + */ | |
| 1768 | +    public function sharingDisabledForUser($userId) { | |
| 1769 | +        if ($userId === null) { | |
| 1770 | + return false; | |
| 1771 | + } | |
| 1772 | + | |
| 1773 | +        if (isset($this->sharingDisabledForUsersCache[$userId])) { | |
| 1774 | + return $this->sharingDisabledForUsersCache[$userId]; | |
| 1775 | + } | |
| 1776 | + | |
| 1777 | +        if ($this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes') { | |
| 1778 | +            $groupsList = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', ''); | |
| 1779 | + $excludedGroups = json_decode($groupsList); | |
| 1780 | +            if (is_null($excludedGroups)) { | |
| 1781 | +                $excludedGroups = explode(',', $groupsList); | |
| 1782 | + $newValue = json_encode($excludedGroups); | |
| 1783 | +                $this->config->setAppValue('core', 'shareapi_exclude_groups_list', $newValue); | |
| 1784 | + } | |
| 1785 | + $user = $this->userManager->get($userId); | |
| 1786 | + $usersGroups = $this->groupManager->getUserGroupIds($user); | |
| 1787 | +            if (!empty($usersGroups)) { | |
| 1788 | + $remainingGroups = array_diff($usersGroups, $excludedGroups); | |
| 1789 | + // if the user is only in groups which are disabled for sharing then | |
| 1790 | + // sharing is also disabled for the user | |
| 1791 | +                if (empty($remainingGroups)) { | |
| 1792 | + $this->sharingDisabledForUsersCache[$userId] = true; | |
| 1793 | + return true; | |
| 1794 | + } | |
| 1795 | + } | |
| 1796 | + } | |
| 1797 | + | |
| 1798 | + $this->sharingDisabledForUsersCache[$userId] = false; | |
| 1799 | + return false; | |
| 1800 | + } | |
| 1801 | + | |
| 1802 | + /** | |
| 1803 | + * @inheritdoc | |
| 1804 | + */ | |
| 1805 | +    public function outgoingServer2ServerSharesAllowed() { | |
| 1806 | +        return $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes'; | |
| 1807 | + } | |
| 1808 | + | |
| 1809 | + /** | |
| 1810 | + * @inheritdoc | |
| 1811 | + */ | |
| 1812 | +    public function outgoingServer2ServerGroupSharesAllowed() { | |
| 1813 | +        return $this->config->getAppValue('files_sharing', 'outgoing_server2server_group_share_enabled', 'no') === 'yes'; | |
| 1814 | + } | |
| 1815 | + | |
| 1816 | + /** | |
| 1817 | + * @inheritdoc | |
| 1818 | + */ | |
| 1819 | +    public function shareProviderExists($shareType) { | |
| 1820 | +        try { | |
| 1821 | + $this->factory->getProviderForType($shareType); | |
| 1822 | +        } catch (ProviderException $e) { | |
| 1823 | + return false; | |
| 1824 | + } | |
| 1825 | + | |
| 1826 | + return true; | |
| 1827 | + } | |
| 1828 | + | |
| 1829 | +    public function getAllShares(): iterable { | |
| 1830 | + $providers = $this->factory->getAllProviders(); | |
| 1831 | + | |
| 1832 | +        foreach ($providers as $provider) { | |
| 1833 | + yield from $provider->getAllShares(); | |
| 1834 | + } | |
| 1835 | + } | |
| 1836 | 1836 | } | 
| @@ -194,1986 +194,1986 @@ | ||
| 194 | 194 | * TODO: hookup all manager classes | 
| 195 | 195 | */ | 
| 196 | 196 |  class Server extends ServerContainer implements IServerContainer { | 
| 197 | - /** @var string */ | |
| 198 | - private $webRoot; | |
| 199 | - | |
| 200 | - /** | |
| 201 | - * @param string $webRoot | |
| 202 | - * @param \OC\Config $config | |
| 203 | - */ | |
| 204 | -	public function __construct($webRoot, \OC\Config $config) { | |
| 205 | - parent::__construct(); | |
| 206 | - $this->webRoot = $webRoot; | |
| 207 | - | |
| 208 | - // To find out if we are running from CLI or not | |
| 209 | -		$this->registerParameter('isCLI', \OC::$CLI); | |
| 210 | - | |
| 211 | -		$this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { | |
| 212 | - return $c; | |
| 213 | - }); | |
| 214 | - | |
| 215 | - $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); | |
| 216 | -		$this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); | |
| 217 | - | |
| 218 | - $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); | |
| 219 | -		$this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); | |
| 220 | - | |
| 221 | - $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); | |
| 222 | -		$this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); | |
| 223 | - | |
| 224 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); | |
| 225 | -		$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); | |
| 226 | - | |
| 227 | - $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class); | |
| 228 | - | |
| 229 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); | |
| 230 | - | |
| 231 | - | |
| 232 | -		$this->registerService(\OCP\IPreview::class, function (Server $c) { | |
| 233 | - return new PreviewManager( | |
| 234 | - $c->getConfig(), | |
| 235 | - $c->getRootFolder(), | |
| 236 | -				$c->getAppDataDir('preview'), | |
| 237 | - $c->getEventDispatcher(), | |
| 238 | - $c->getGeneratorHelper(), | |
| 239 | -				$c->getSession()->get('user_id') | |
| 240 | - ); | |
| 241 | - }); | |
| 242 | -		$this->registerAlias('PreviewManager', \OCP\IPreview::class); | |
| 243 | - | |
| 244 | -		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) { | |
| 245 | - return new \OC\Preview\Watcher( | |
| 246 | -				$c->getAppDataDir('preview') | |
| 247 | - ); | |
| 248 | - }); | |
| 249 | - | |
| 250 | -		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { | |
| 251 | - $view = new View(); | |
| 252 | - $util = new Encryption\Util( | |
| 253 | - $view, | |
| 254 | - $c->getUserManager(), | |
| 255 | - $c->getGroupManager(), | |
| 256 | - $c->getConfig() | |
| 257 | - ); | |
| 258 | - return new Encryption\Manager( | |
| 259 | - $c->getConfig(), | |
| 260 | - $c->getLogger(), | |
| 261 | -				$c->getL10N('core'), | |
| 262 | - new View(), | |
| 263 | - $util, | |
| 264 | - new ArrayCache() | |
| 265 | - ); | |
| 266 | - }); | |
| 267 | -		$this->registerAlias('EncryptionManager', \OCP\Encryption\IManager::class); | |
| 268 | - | |
| 269 | -		$this->registerService('EncryptionFileHelper', function (Server $c) { | |
| 270 | - $util = new Encryption\Util( | |
| 271 | - new View(), | |
| 272 | - $c->getUserManager(), | |
| 273 | - $c->getGroupManager(), | |
| 274 | - $c->getConfig() | |
| 275 | - ); | |
| 276 | - return new Encryption\File( | |
| 277 | - $util, | |
| 278 | - $c->getRootFolder(), | |
| 279 | - $c->getShareManager() | |
| 280 | - ); | |
| 281 | - }); | |
| 282 | - | |
| 283 | -		$this->registerService('EncryptionKeyStorage', function (Server $c) { | |
| 284 | - $view = new View(); | |
| 285 | - $util = new Encryption\Util( | |
| 286 | - $view, | |
| 287 | - $c->getUserManager(), | |
| 288 | - $c->getGroupManager(), | |
| 289 | - $c->getConfig() | |
| 290 | - ); | |
| 291 | - | |
| 292 | - return new Encryption\Keys\Storage($view, $util); | |
| 293 | - }); | |
| 294 | -		$this->registerService('TagMapper', function (Server $c) { | |
| 295 | - return new TagMapper($c->getDatabaseConnection()); | |
| 296 | - }); | |
| 297 | - | |
| 298 | -		$this->registerService(\OCP\ITagManager::class, function (Server $c) { | |
| 299 | -			$tagMapper = $c->query('TagMapper'); | |
| 300 | - return new TagManager($tagMapper, $c->getUserSession()); | |
| 301 | - }); | |
| 302 | -		$this->registerAlias('TagManager', \OCP\ITagManager::class); | |
| 303 | - | |
| 304 | -		$this->registerService('SystemTagManagerFactory', function (Server $c) { | |
| 305 | - $config = $c->getConfig(); | |
| 306 | -			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); | |
| 307 | - return new $factoryClass($this); | |
| 308 | - }); | |
| 309 | -		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { | |
| 310 | -			return $c->query('SystemTagManagerFactory')->getManager(); | |
| 311 | - }); | |
| 312 | -		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); | |
| 313 | - | |
| 314 | -		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { | |
| 315 | -			return $c->query('SystemTagManagerFactory')->getObjectMapper(); | |
| 316 | - }); | |
| 317 | -		$this->registerService('RootFolder', function (Server $c) { | |
| 318 | - $manager = \OC\Files\Filesystem::getMountManager(null); | |
| 319 | - $view = new View(); | |
| 320 | - $root = new Root( | |
| 321 | - $manager, | |
| 322 | - $view, | |
| 323 | - null, | |
| 324 | - $c->getUserMountCache(), | |
| 325 | - $this->getLogger(), | |
| 326 | - $this->getUserManager() | |
| 327 | - ); | |
| 328 | - $connector = new HookConnector($root, $view, $c->getEventDispatcher()); | |
| 329 | - $connector->viewToNode(); | |
| 330 | - | |
| 331 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); | |
| 332 | - $previewConnector->connectWatcher(); | |
| 333 | - | |
| 334 | - return $root; | |
| 335 | - }); | |
| 336 | -		$this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); | |
| 337 | - | |
| 338 | -		$this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { | |
| 339 | -			return new LazyRoot(function () use ($c) { | |
| 340 | -				return $c->query('RootFolder'); | |
| 341 | - }); | |
| 342 | - }); | |
| 343 | -		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); | |
| 344 | - | |
| 345 | -		$this->registerAlias('UserManager', \OC\User\Manager::class); | |
| 346 | - $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); | |
| 347 | - | |
| 348 | -		$this->registerService(\OCP\IGroupManager::class, function (Server $c) { | |
| 349 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger()); | |
| 350 | -			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) { | |
| 351 | -				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); | |
| 352 | - | |
| 353 | - /** @var IEventDispatcher $dispatcher */ | |
| 354 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 355 | - $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid)); | |
| 356 | - }); | |
| 357 | -			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) { | |
| 358 | -				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $group->getGID())); | |
| 359 | - | |
| 360 | - /** @var IEventDispatcher $dispatcher */ | |
| 361 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 362 | - $dispatcher->dispatchTyped(new GroupCreatedEvent($group)); | |
| 363 | - }); | |
| 364 | -			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { | |
| 365 | -				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); | |
| 366 | - | |
| 367 | - /** @var IEventDispatcher $dispatcher */ | |
| 368 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 369 | - $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group)); | |
| 370 | - }); | |
| 371 | -			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { | |
| 372 | -				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); | |
| 373 | - | |
| 374 | - /** @var IEventDispatcher $dispatcher */ | |
| 375 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 376 | - $dispatcher->dispatchTyped(new GroupDeletedEvent($group)); | |
| 377 | - }); | |
| 378 | -			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { | |
| 379 | -				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); | |
| 380 | - | |
| 381 | - /** @var IEventDispatcher $dispatcher */ | |
| 382 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 383 | - $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user)); | |
| 384 | - }); | |
| 385 | -			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { | |
| 386 | -				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); | |
| 387 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks | |
| 388 | -				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); | |
| 389 | - | |
| 390 | - /** @var IEventDispatcher $dispatcher */ | |
| 391 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 392 | - $dispatcher->dispatchTyped(new UserAddedEvent($group, $user)); | |
| 393 | - }); | |
| 394 | -			$groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { | |
| 395 | - /** @var IEventDispatcher $dispatcher */ | |
| 396 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 397 | - $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user)); | |
| 398 | - }); | |
| 399 | -			$groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { | |
| 400 | - /** @var IEventDispatcher $dispatcher */ | |
| 401 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 402 | - $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user)); | |
| 403 | - }); | |
| 404 | - return $groupManager; | |
| 405 | - }); | |
| 406 | -		$this->registerAlias('GroupManager', \OCP\IGroupManager::class); | |
| 407 | - | |
| 408 | -		$this->registerService(Store::class, function (Server $c) { | |
| 409 | - $session = $c->getSession(); | |
| 410 | -			if (\OC::$server->getSystemConfig()->getValue('installed', false)) { | |
| 411 | - $tokenProvider = $c->query(IProvider::class); | |
| 412 | -			} else { | |
| 413 | - $tokenProvider = null; | |
| 414 | - } | |
| 415 | - $logger = $c->getLogger(); | |
| 416 | - return new Store($session, $logger, $tokenProvider); | |
| 417 | - }); | |
| 418 | - $this->registerAlias(IStore::class, Store::class); | |
| 419 | -		$this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { | |
| 420 | - $dbConnection = $c->getDatabaseConnection(); | |
| 421 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); | |
| 422 | - }); | |
| 423 | - $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); | |
| 424 | - | |
| 425 | -		$this->registerService(\OC\User\Session::class, function (Server $c) { | |
| 426 | - $manager = $c->getUserManager(); | |
| 427 | -			$session = new \OC\Session\Memory(''); | |
| 428 | - $timeFactory = new TimeFactory(); | |
| 429 | - // Token providers might require a working database. This code | |
| 430 | - // might however be called when ownCloud is not yet setup. | |
| 431 | -			if (\OC::$server->getSystemConfig()->getValue('installed', false)) { | |
| 432 | - $defaultTokenProvider = $c->query(IProvider::class); | |
| 433 | -			} else { | |
| 434 | - $defaultTokenProvider = null; | |
| 435 | - } | |
| 436 | - | |
| 437 | - $legacyDispatcher = $c->getEventDispatcher(); | |
| 438 | - | |
| 439 | - $userSession = new \OC\User\Session( | |
| 440 | - $manager, | |
| 441 | - $session, | |
| 442 | - $timeFactory, | |
| 443 | - $defaultTokenProvider, | |
| 444 | - $c->getConfig(), | |
| 445 | - $c->getSecureRandom(), | |
| 446 | - $c->getLockdownManager(), | |
| 447 | - $c->getLogger(), | |
| 448 | - $c->query(IEventDispatcher::class) | |
| 449 | - ); | |
| 450 | -			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { | |
| 451 | -				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); | |
| 452 | - | |
| 453 | - /** @var IEventDispatcher $dispatcher */ | |
| 454 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 455 | - $dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password)); | |
| 456 | - }); | |
| 457 | -			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { | |
| 458 | - /** @var $user \OC\User\User */ | |
| 459 | -				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); | |
| 460 | - | |
| 461 | - /** @var IEventDispatcher $dispatcher */ | |
| 462 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 463 | - $dispatcher->dispatchTyped(new UserCreatedEvent($user, $password)); | |
| 464 | - }); | |
| 465 | -			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) { | |
| 466 | - /** @var $user \OC\User\User */ | |
| 467 | -				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); | |
| 468 | -				$legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); | |
| 469 | - | |
| 470 | - /** @var IEventDispatcher $dispatcher */ | |
| 471 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 472 | - $dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user)); | |
| 473 | - }); | |
| 474 | -			$userSession->listen('\OC\User', 'postDelete', function ($user) { | |
| 475 | - /** @var $user \OC\User\User */ | |
| 476 | -				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); | |
| 477 | - | |
| 478 | - /** @var IEventDispatcher $dispatcher */ | |
| 479 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 480 | - $dispatcher->dispatchTyped(new UserDeletedEvent($user)); | |
| 481 | - }); | |
| 482 | -			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { | |
| 483 | - /** @var $user \OC\User\User */ | |
| 484 | -				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); | |
| 485 | - | |
| 486 | - /** @var IEventDispatcher $dispatcher */ | |
| 487 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 488 | - $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword)); | |
| 489 | - }); | |
| 490 | -			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { | |
| 491 | - /** @var $user \OC\User\User */ | |
| 492 | -				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); | |
| 493 | - | |
| 494 | - /** @var IEventDispatcher $dispatcher */ | |
| 495 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 496 | - $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword)); | |
| 497 | - }); | |
| 498 | -			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { | |
| 499 | -				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); | |
| 500 | - | |
| 501 | - /** @var IEventDispatcher $dispatcher */ | |
| 502 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 503 | - $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password)); | |
| 504 | - }); | |
| 505 | -			$userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { | |
| 506 | - /** @var $user \OC\User\User */ | |
| 507 | -				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin)); | |
| 508 | - | |
| 509 | - /** @var IEventDispatcher $dispatcher */ | |
| 510 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 511 | - $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin)); | |
| 512 | - }); | |
| 513 | -			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) { | |
| 514 | - /** @var IEventDispatcher $dispatcher */ | |
| 515 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 516 | - $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid)); | |
| 517 | - }); | |
| 518 | -			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { | |
| 519 | - /** @var $user \OC\User\User */ | |
| 520 | -				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); | |
| 521 | - | |
| 522 | - /** @var IEventDispatcher $dispatcher */ | |
| 523 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 524 | - $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password)); | |
| 525 | - }); | |
| 526 | -			$userSession->listen('\OC\User', 'logout', function ($user) { | |
| 527 | -				\OC_Hook::emit('OC_User', 'logout', array()); | |
| 528 | - | |
| 529 | - /** @var IEventDispatcher $dispatcher */ | |
| 530 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 531 | - $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user)); | |
| 532 | - }); | |
| 533 | -			$userSession->listen('\OC\User', 'postLogout', function ($user) { | |
| 534 | - /** @var IEventDispatcher $dispatcher */ | |
| 535 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 536 | - $dispatcher->dispatchTyped(new UserLoggedOutEvent($user)); | |
| 537 | - }); | |
| 538 | -			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { | |
| 539 | - /** @var $user \OC\User\User */ | |
| 540 | -				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); | |
| 541 | - | |
| 542 | - /** @var IEventDispatcher $dispatcher */ | |
| 543 | - $dispatcher = $this->query(IEventDispatcher::class); | |
| 544 | - $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue)); | |
| 545 | - }); | |
| 546 | - return $userSession; | |
| 547 | - }); | |
| 548 | - $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class); | |
| 549 | -		$this->registerAlias('UserSession', \OC\User\Session::class); | |
| 550 | - | |
| 551 | - $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); | |
| 552 | - | |
| 553 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); | |
| 554 | -		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class); | |
| 555 | - | |
| 556 | -		$this->registerService(\OC\AllConfig::class, function (Server $c) { | |
| 557 | - return new \OC\AllConfig( | |
| 558 | - $c->getSystemConfig() | |
| 559 | - ); | |
| 560 | - }); | |
| 561 | -		$this->registerAlias('AllConfig', \OC\AllConfig::class); | |
| 562 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); | |
| 563 | - | |
| 564 | -		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) { | |
| 565 | - return new \OC\SystemConfig($config); | |
| 566 | - }); | |
| 567 | -		$this->registerAlias('SystemConfig', \OC\SystemConfig::class); | |
| 568 | - | |
| 569 | -		$this->registerService(\OC\AppConfig::class, function (Server $c) { | |
| 570 | - return new \OC\AppConfig($c->getDatabaseConnection()); | |
| 571 | - }); | |
| 572 | -		$this->registerAlias('AppConfig', \OC\AppConfig::class); | |
| 573 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); | |
| 574 | - | |
| 575 | -		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { | |
| 576 | - return new \OC\L10N\Factory( | |
| 577 | - $c->getConfig(), | |
| 578 | - $c->getRequest(), | |
| 579 | - $c->getUserSession(), | |
| 580 | - \OC::$SERVERROOT | |
| 581 | - ); | |
| 582 | - }); | |
| 583 | -		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); | |
| 584 | - | |
| 585 | -		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) { | |
| 586 | - $config = $c->getConfig(); | |
| 587 | - $cacheFactory = $c->getMemCacheFactory(); | |
| 588 | - $request = $c->getRequest(); | |
| 589 | - return new \OC\URLGenerator( | |
| 590 | - $config, | |
| 591 | - $cacheFactory, | |
| 592 | - $request | |
| 593 | - ); | |
| 594 | - }); | |
| 595 | -		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); | |
| 596 | - | |
| 597 | -		$this->registerAlias('AppFetcher', AppFetcher::class); | |
| 598 | -		$this->registerAlias('CategoryFetcher', CategoryFetcher::class); | |
| 599 | - | |
| 600 | -		$this->registerService(\OCP\ICache::class, function ($c) { | |
| 601 | - return new Cache\File(); | |
| 602 | - }); | |
| 603 | -		$this->registerAlias('UserCache', \OCP\ICache::class); | |
| 604 | - | |
| 605 | -		$this->registerService(Factory::class, function (Server $c) { | |
| 606 | - | |
| 607 | -			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), | |
| 608 | - ArrayCache::class, | |
| 609 | - ArrayCache::class, | |
| 610 | - ArrayCache::class | |
| 611 | - ); | |
| 612 | - $config = $c->getConfig(); | |
| 613 | - | |
| 614 | -			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { | |
| 615 | - $v = \OC_App::getAppVersions(); | |
| 616 | -				$v['core'] = implode(',', \OC_Util::getVersion()); | |
| 617 | -				$version = implode(',', $v); | |
| 618 | - $instanceId = \OC_Util::getInstanceId(); | |
| 619 | - $path = \OC::$SERVERROOT; | |
| 620 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); | |
| 621 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), | |
| 622 | -					$config->getSystemValue('memcache.local', null), | |
| 623 | -					$config->getSystemValue('memcache.distributed', null), | |
| 624 | -					$config->getSystemValue('memcache.locking', null) | |
| 625 | - ); | |
| 626 | - } | |
| 627 | - return $arrayCacheFactory; | |
| 628 | - | |
| 629 | - }); | |
| 630 | -		$this->registerAlias('MemCacheFactory', Factory::class); | |
| 631 | - $this->registerAlias(ICacheFactory::class, Factory::class); | |
| 632 | - | |
| 633 | -		$this->registerService('RedisFactory', function (Server $c) { | |
| 634 | - $systemConfig = $c->getSystemConfig(); | |
| 635 | - return new RedisFactory($systemConfig); | |
| 636 | - }); | |
| 637 | - | |
| 638 | -		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) { | |
| 639 | - return new \OC\Activity\Manager( | |
| 640 | - $c->getRequest(), | |
| 641 | - $c->getUserSession(), | |
| 642 | - $c->getConfig(), | |
| 643 | - $c->query(IValidator::class) | |
| 644 | - ); | |
| 645 | - }); | |
| 646 | -		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); | |
| 647 | - | |
| 648 | -		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { | |
| 649 | - return new \OC\Activity\EventMerger( | |
| 650 | -				$c->getL10N('lib') | |
| 651 | - ); | |
| 652 | - }); | |
| 653 | - $this->registerAlias(IValidator::class, Validator::class); | |
| 654 | - | |
| 655 | -		$this->registerService(AvatarManager::class, function(Server $c) { | |
| 656 | - return new AvatarManager( | |
| 657 | - $c->query(\OC\User\Manager::class), | |
| 658 | -				$c->getAppDataDir('avatar'), | |
| 659 | -				$c->getL10N('lib'), | |
| 660 | - $c->getLogger(), | |
| 661 | - $c->getConfig() | |
| 662 | - ); | |
| 663 | - }); | |
| 664 | - $this->registerAlias(\OCP\IAvatarManager::class, AvatarManager::class); | |
| 665 | -		$this->registerAlias('AvatarManager', AvatarManager::class); | |
| 666 | - | |
| 667 | - $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); | |
| 668 | - $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class); | |
| 669 | - | |
| 670 | -		$this->registerService(\OC\Log::class, function (Server $c) { | |
| 671 | -			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); | |
| 672 | - $factory = new LogFactory($c, $this->getSystemConfig()); | |
| 673 | - $logger = $factory->get($logType); | |
| 674 | - $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); | |
| 675 | - | |
| 676 | - return new Log($logger, $this->getSystemConfig(), null, $registry); | |
| 677 | - }); | |
| 678 | - $this->registerAlias(\OCP\ILogger::class, \OC\Log::class); | |
| 679 | -		$this->registerAlias('Logger', \OC\Log::class); | |
| 680 | - | |
| 681 | -		$this->registerService(ILogFactory::class, function (Server $c) { | |
| 682 | - return new LogFactory($c, $this->getSystemConfig()); | |
| 683 | - }); | |
| 684 | - | |
| 685 | -		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { | |
| 686 | - $config = $c->getConfig(); | |
| 687 | - return new \OC\BackgroundJob\JobList( | |
| 688 | - $c->getDatabaseConnection(), | |
| 689 | - $config, | |
| 690 | - new TimeFactory() | |
| 691 | - ); | |
| 692 | - }); | |
| 693 | -		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); | |
| 694 | - | |
| 695 | -		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) { | |
| 696 | - $cacheFactory = $c->getMemCacheFactory(); | |
| 697 | - $logger = $c->getLogger(); | |
| 698 | -			if ($cacheFactory->isLocalCacheAvailable()) { | |
| 699 | -				$router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); | |
| 700 | -			} else { | |
| 701 | - $router = new \OC\Route\Router($logger); | |
| 702 | - } | |
| 703 | - return $router; | |
| 704 | - }); | |
| 705 | -		$this->registerAlias('Router', \OCP\Route\IRouter::class); | |
| 706 | - | |
| 707 | -		$this->registerService(\OCP\ISearch::class, function ($c) { | |
| 708 | - return new Search(); | |
| 709 | - }); | |
| 710 | -		$this->registerAlias('Search', \OCP\ISearch::class); | |
| 711 | - | |
| 712 | -		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { | |
| 713 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( | |
| 714 | - $this->getMemCacheFactory(), | |
| 715 | - new \OC\AppFramework\Utility\TimeFactory() | |
| 716 | - ); | |
| 717 | - }); | |
| 718 | - | |
| 719 | -		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { | |
| 720 | - return new SecureRandom(); | |
| 721 | - }); | |
| 722 | -		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); | |
| 723 | - | |
| 724 | -		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { | |
| 725 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); | |
| 726 | - }); | |
| 727 | -		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class); | |
| 728 | - | |
| 729 | -		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) { | |
| 730 | - return new Hasher($c->getConfig()); | |
| 731 | - }); | |
| 732 | -		$this->registerAlias('Hasher', \OCP\Security\IHasher::class); | |
| 733 | - | |
| 734 | -		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { | |
| 735 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); | |
| 736 | - }); | |
| 737 | -		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); | |
| 738 | - | |
| 739 | -		$this->registerService(IDBConnection::class, function (Server $c) { | |
| 740 | - $systemConfig = $c->getSystemConfig(); | |
| 741 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); | |
| 742 | -			$type = $systemConfig->getValue('dbtype', 'sqlite'); | |
| 743 | -			if (!$factory->isValidType($type)) { | |
| 744 | -				throw new \OC\DatabaseException('Invalid database type'); | |
| 745 | - } | |
| 746 | - $connectionParams = $factory->createConnectionParams(); | |
| 747 | - $connection = $factory->getConnection($type, $connectionParams); | |
| 748 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); | |
| 749 | - return $connection; | |
| 750 | - }); | |
| 751 | -		$this->registerAlias('DatabaseConnection', IDBConnection::class); | |
| 752 | - | |
| 753 | - | |
| 754 | -		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { | |
| 755 | - $user = \OC_User::getUser(); | |
| 756 | - $uid = $user ? $user : null; | |
| 757 | - return new ClientService( | |
| 758 | - $c->getConfig(), | |
| 759 | - new \OC\Security\CertificateManager( | |
| 760 | - $uid, | |
| 761 | - new View(), | |
| 762 | - $c->getConfig(), | |
| 763 | - $c->getLogger(), | |
| 764 | - $c->getSecureRandom() | |
| 765 | - ) | |
| 766 | - ); | |
| 767 | - }); | |
| 768 | -		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); | |
| 769 | -		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { | |
| 770 | - $eventLogger = new EventLogger(); | |
| 771 | -			if ($c->getSystemConfig()->getValue('debug', false)) { | |
| 772 | - // In debug mode, module is being activated by default | |
| 773 | - $eventLogger->activate(); | |
| 774 | - } | |
| 775 | - return $eventLogger; | |
| 776 | - }); | |
| 777 | -		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); | |
| 778 | - | |
| 779 | -		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { | |
| 780 | - $queryLogger = new QueryLogger(); | |
| 781 | -			if ($c->getSystemConfig()->getValue('debug', false)) { | |
| 782 | - // In debug mode, module is being activated by default | |
| 783 | - $queryLogger->activate(); | |
| 784 | - } | |
| 785 | - return $queryLogger; | |
| 786 | - }); | |
| 787 | -		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); | |
| 788 | - | |
| 789 | -		$this->registerService(TempManager::class, function (Server $c) { | |
| 790 | - return new TempManager( | |
| 791 | - $c->getLogger(), | |
| 792 | - $c->getConfig() | |
| 793 | - ); | |
| 794 | - }); | |
| 795 | -		$this->registerAlias('TempManager', TempManager::class); | |
| 796 | - $this->registerAlias(ITempManager::class, TempManager::class); | |
| 797 | - | |
| 798 | -		$this->registerService(AppManager::class, function (Server $c) { | |
| 799 | - return new \OC\App\AppManager( | |
| 800 | - $c->getUserSession(), | |
| 801 | - $c->query(\OC\AppConfig::class), | |
| 802 | - $c->getGroupManager(), | |
| 803 | - $c->getMemCacheFactory(), | |
| 804 | - $c->getEventDispatcher(), | |
| 805 | - $c->getLogger() | |
| 806 | - ); | |
| 807 | - }); | |
| 808 | -		$this->registerAlias('AppManager', AppManager::class); | |
| 809 | - $this->registerAlias(IAppManager::class, AppManager::class); | |
| 810 | - | |
| 811 | -		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { | |
| 812 | - return new DateTimeZone( | |
| 813 | - $c->getConfig(), | |
| 814 | - $c->getSession() | |
| 815 | - ); | |
| 816 | - }); | |
| 817 | -		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); | |
| 818 | - | |
| 819 | -		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { | |
| 820 | -			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); | |
| 821 | - | |
| 822 | - return new DateTimeFormatter( | |
| 823 | - $c->getDateTimeZone()->getTimeZone(), | |
| 824 | -				$c->getL10N('lib', $language) | |
| 825 | - ); | |
| 826 | - }); | |
| 827 | -		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); | |
| 828 | - | |
| 829 | -		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { | |
| 830 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); | |
| 831 | - $listener = new UserMountCacheListener($mountCache); | |
| 832 | - $listener->listen($c->getUserManager()); | |
| 833 | - return $mountCache; | |
| 834 | - }); | |
| 835 | -		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); | |
| 836 | - | |
| 837 | -		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { | |
| 838 | - $loader = \OC\Files\Filesystem::getLoader(); | |
| 839 | -			$mountCache = $c->query('UserMountCache'); | |
| 840 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); | |
| 841 | - | |
| 842 | - // builtin providers | |
| 843 | - | |
| 844 | - $config = $c->getConfig(); | |
| 845 | - $manager->registerProvider(new CacheMountProvider($config)); | |
| 846 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); | |
| 847 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); | |
| 848 | - | |
| 849 | - return $manager; | |
| 850 | - }); | |
| 851 | -		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); | |
| 852 | - | |
| 853 | -		$this->registerService('IniWrapper', function ($c) { | |
| 854 | - return new IniGetWrapper(); | |
| 855 | - }); | |
| 856 | -		$this->registerService('AsyncCommandBus', function (Server $c) { | |
| 857 | -			$busClass = $c->getConfig()->getSystemValue('commandbus'); | |
| 858 | -			if ($busClass) { | |
| 859 | -				list($app, $class) = explode('::', $busClass, 2); | |
| 860 | -				if ($c->getAppManager()->isInstalled($app)) { | |
| 861 | - \OC_App::loadApp($app); | |
| 862 | - return $c->query($class); | |
| 863 | -				} else { | |
| 864 | -					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); | |
| 865 | - } | |
| 866 | -			} else { | |
| 867 | - $jobList = $c->getJobList(); | |
| 868 | - return new CronBus($jobList); | |
| 869 | - } | |
| 870 | - }); | |
| 871 | -		$this->registerService('TrustedDomainHelper', function ($c) { | |
| 872 | - return new TrustedDomainHelper($this->getConfig()); | |
| 873 | - }); | |
| 874 | -		$this->registerService(Throttler::class, function (Server $c) { | |
| 875 | - return new Throttler( | |
| 876 | - $c->getDatabaseConnection(), | |
| 877 | - new TimeFactory(), | |
| 878 | - $c->getLogger(), | |
| 879 | - $c->getConfig() | |
| 880 | - ); | |
| 881 | - }); | |
| 882 | -		$this->registerAlias('Throttler', Throttler::class); | |
| 883 | -		$this->registerService('IntegrityCodeChecker', function (Server $c) { | |
| 884 | - // IConfig and IAppManager requires a working database. This code | |
| 885 | - // might however be called when ownCloud is not yet setup. | |
| 886 | -			if (\OC::$server->getSystemConfig()->getValue('installed', false)) { | |
| 887 | - $config = $c->getConfig(); | |
| 888 | - $appManager = $c->getAppManager(); | |
| 889 | -			} else { | |
| 890 | - $config = null; | |
| 891 | - $appManager = null; | |
| 892 | - } | |
| 893 | - | |
| 894 | - return new Checker( | |
| 895 | - new EnvironmentHelper(), | |
| 896 | - new FileAccessHelper(), | |
| 897 | - new AppLocator(), | |
| 898 | - $config, | |
| 899 | - $c->getMemCacheFactory(), | |
| 900 | - $appManager, | |
| 901 | - $c->getTempManager(), | |
| 902 | - $c->getMimeTypeDetector() | |
| 903 | - ); | |
| 904 | - }); | |
| 905 | -		$this->registerService(\OCP\IRequest::class, function ($c) { | |
| 906 | -			if (isset($this['urlParams'])) { | |
| 907 | - $urlParams = $this['urlParams']; | |
| 908 | -			} else { | |
| 909 | - $urlParams = []; | |
| 910 | - } | |
| 911 | - | |
| 912 | -			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN | |
| 913 | -				&& in_array('fakeinput', stream_get_wrappers()) | |
| 914 | -			) { | |
| 915 | - $stream = 'fakeinput://data'; | |
| 916 | -			} else { | |
| 917 | - $stream = 'php://input'; | |
| 918 | - } | |
| 919 | - | |
| 920 | - return new Request( | |
| 921 | - [ | |
| 922 | - 'get' => $_GET, | |
| 923 | - 'post' => $_POST, | |
| 924 | - 'files' => $_FILES, | |
| 925 | - 'server' => $_SERVER, | |
| 926 | - 'env' => $_ENV, | |
| 927 | - 'cookies' => $_COOKIE, | |
| 928 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) | |
| 929 | - ? $_SERVER['REQUEST_METHOD'] | |
| 930 | - : '', | |
| 931 | - 'urlParams' => $urlParams, | |
| 932 | - ], | |
| 933 | - $this->getSecureRandom(), | |
| 934 | - $this->getConfig(), | |
| 935 | - $this->getCsrfTokenManager(), | |
| 936 | - $stream | |
| 937 | - ); | |
| 938 | - }); | |
| 939 | -		$this->registerAlias('Request', \OCP\IRequest::class); | |
| 940 | - | |
| 941 | -		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { | |
| 942 | - return new Mailer( | |
| 943 | - $c->getConfig(), | |
| 944 | - $c->getLogger(), | |
| 945 | - $c->query(Defaults::class), | |
| 946 | - $c->getURLGenerator(), | |
| 947 | -				$c->getL10N('lib') | |
| 948 | - ); | |
| 949 | - }); | |
| 950 | -		$this->registerAlias('Mailer', \OCP\Mail\IMailer::class); | |
| 951 | - | |
| 952 | -		$this->registerService('LDAPProvider', function (Server $c) { | |
| 953 | - $config = $c->getConfig(); | |
| 954 | -			$factoryClass = $config->getSystemValue('ldapProviderFactory', null); | |
| 955 | -			if (is_null($factoryClass)) { | |
| 956 | -				throw new \Exception('ldapProviderFactory not set'); | |
| 957 | - } | |
| 958 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ | |
| 959 | - $factory = new $factoryClass($this); | |
| 960 | - return $factory->getLDAPProvider(); | |
| 961 | - }); | |
| 962 | -		$this->registerService(ILockingProvider::class, function (Server $c) { | |
| 963 | - $ini = $c->getIniWrapper(); | |
| 964 | - $config = $c->getConfig(); | |
| 965 | -			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); | |
| 966 | -			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { | |
| 967 | - /** @var \OC\Memcache\Factory $memcacheFactory */ | |
| 968 | - $memcacheFactory = $c->getMemCacheFactory(); | |
| 969 | -				$memcache = $memcacheFactory->createLocking('lock'); | |
| 970 | -				if (!($memcache instanceof \OC\Memcache\NullCache)) { | |
| 971 | - return new MemcacheLockingProvider($memcache, $ttl); | |
| 972 | - } | |
| 973 | - return new DBLockingProvider( | |
| 974 | - $c->getDatabaseConnection(), | |
| 975 | - $c->getLogger(), | |
| 976 | - new TimeFactory(), | |
| 977 | - $ttl, | |
| 978 | - !\OC::$CLI | |
| 979 | - ); | |
| 980 | - } | |
| 981 | - return new NoopLockingProvider(); | |
| 982 | - }); | |
| 983 | -		$this->registerAlias('LockingProvider', ILockingProvider::class); | |
| 984 | - | |
| 985 | -		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () { | |
| 986 | - return new \OC\Files\Mount\Manager(); | |
| 987 | - }); | |
| 988 | -		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); | |
| 989 | - | |
| 990 | -		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { | |
| 991 | - return new \OC\Files\Type\Detection( | |
| 992 | - $c->getURLGenerator(), | |
| 993 | - $c->getLogger(), | |
| 994 | - \OC::$configDir, | |
| 995 | - \OC::$SERVERROOT . '/resources/config/' | |
| 996 | - ); | |
| 997 | - }); | |
| 998 | -		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); | |
| 999 | - | |
| 1000 | -		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { | |
| 1001 | - return new \OC\Files\Type\Loader( | |
| 1002 | - $c->getDatabaseConnection() | |
| 1003 | - ); | |
| 1004 | - }); | |
| 1005 | -		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); | |
| 1006 | -		$this->registerService(BundleFetcher::class, function () { | |
| 1007 | -			return new BundleFetcher($this->getL10N('lib')); | |
| 1008 | - }); | |
| 1009 | -		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) { | |
| 1010 | - return new Manager( | |
| 1011 | - $c->query(IValidator::class), | |
| 1012 | - $c->getLogger() | |
| 1013 | - ); | |
| 1014 | - }); | |
| 1015 | -		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); | |
| 1016 | - | |
| 1017 | -		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { | |
| 1018 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); | |
| 1019 | -			$manager->registerCapability(function () use ($c) { | |
| 1020 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); | |
| 1021 | - }); | |
| 1022 | -			$manager->registerCapability(function () use ($c) { | |
| 1023 | - return $c->query(\OC\Security\Bruteforce\Capabilities::class); | |
| 1024 | - }); | |
| 1025 | - return $manager; | |
| 1026 | - }); | |
| 1027 | -		$this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); | |
| 1028 | - | |
| 1029 | -		$this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { | |
| 1030 | - $config = $c->getConfig(); | |
| 1031 | -			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); | |
| 1032 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ | |
| 1033 | - $factory = new $factoryClass($this); | |
| 1034 | - $manager = $factory->getManager(); | |
| 1035 | - | |
| 1036 | -			$manager->registerDisplayNameResolver('user', function($id) use ($c) { | |
| 1037 | - $manager = $c->getUserManager(); | |
| 1038 | - $user = $manager->get($id); | |
| 1039 | -				if(is_null($user)) { | |
| 1040 | -					$l = $c->getL10N('core'); | |
| 1041 | -					$displayName = $l->t('Unknown user'); | |
| 1042 | -				} else { | |
| 1043 | - $displayName = $user->getDisplayName(); | |
| 1044 | - } | |
| 1045 | - return $displayName; | |
| 1046 | - }); | |
| 1047 | - | |
| 1048 | - return $manager; | |
| 1049 | - }); | |
| 1050 | -		$this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); | |
| 1051 | - | |
| 1052 | -		$this->registerService('ThemingDefaults', function (Server $c) { | |
| 1053 | - /* | |
| 197 | + /** @var string */ | |
| 198 | + private $webRoot; | |
| 199 | + | |
| 200 | + /** | |
| 201 | + * @param string $webRoot | |
| 202 | + * @param \OC\Config $config | |
| 203 | + */ | |
| 204 | +    public function __construct($webRoot, \OC\Config $config) { | |
| 205 | + parent::__construct(); | |
| 206 | + $this->webRoot = $webRoot; | |
| 207 | + | |
| 208 | + // To find out if we are running from CLI or not | |
| 209 | +        $this->registerParameter('isCLI', \OC::$CLI); | |
| 210 | + | |
| 211 | +        $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { | |
| 212 | + return $c; | |
| 213 | + }); | |
| 214 | + | |
| 215 | + $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); | |
| 216 | +        $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); | |
| 217 | + | |
| 218 | + $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); | |
| 219 | +        $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); | |
| 220 | + | |
| 221 | + $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); | |
| 222 | +        $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); | |
| 223 | + | |
| 224 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); | |
| 225 | +        $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); | |
| 226 | + | |
| 227 | + $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class); | |
| 228 | + | |
| 229 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); | |
| 230 | + | |
| 231 | + | |
| 232 | +        $this->registerService(\OCP\IPreview::class, function (Server $c) { | |
| 233 | + return new PreviewManager( | |
| 234 | + $c->getConfig(), | |
| 235 | + $c->getRootFolder(), | |
| 236 | +                $c->getAppDataDir('preview'), | |
| 237 | + $c->getEventDispatcher(), | |
| 238 | + $c->getGeneratorHelper(), | |
| 239 | +                $c->getSession()->get('user_id') | |
| 240 | + ); | |
| 241 | + }); | |
| 242 | +        $this->registerAlias('PreviewManager', \OCP\IPreview::class); | |
| 243 | + | |
| 244 | +        $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { | |
| 245 | + return new \OC\Preview\Watcher( | |
| 246 | +                $c->getAppDataDir('preview') | |
| 247 | + ); | |
| 248 | + }); | |
| 249 | + | |
| 250 | +        $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) { | |
| 251 | + $view = new View(); | |
| 252 | + $util = new Encryption\Util( | |
| 253 | + $view, | |
| 254 | + $c->getUserManager(), | |
| 255 | + $c->getGroupManager(), | |
| 256 | + $c->getConfig() | |
| 257 | + ); | |
| 258 | + return new Encryption\Manager( | |
| 259 | + $c->getConfig(), | |
| 260 | + $c->getLogger(), | |
| 261 | +                $c->getL10N('core'), | |
| 262 | + new View(), | |
| 263 | + $util, | |
| 264 | + new ArrayCache() | |
| 265 | + ); | |
| 266 | + }); | |
| 267 | +        $this->registerAlias('EncryptionManager', \OCP\Encryption\IManager::class); | |
| 268 | + | |
| 269 | +        $this->registerService('EncryptionFileHelper', function (Server $c) { | |
| 270 | + $util = new Encryption\Util( | |
| 271 | + new View(), | |
| 272 | + $c->getUserManager(), | |
| 273 | + $c->getGroupManager(), | |
| 274 | + $c->getConfig() | |
| 275 | + ); | |
| 276 | + return new Encryption\File( | |
| 277 | + $util, | |
| 278 | + $c->getRootFolder(), | |
| 279 | + $c->getShareManager() | |
| 280 | + ); | |
| 281 | + }); | |
| 282 | + | |
| 283 | +        $this->registerService('EncryptionKeyStorage', function (Server $c) { | |
| 284 | + $view = new View(); | |
| 285 | + $util = new Encryption\Util( | |
| 286 | + $view, | |
| 287 | + $c->getUserManager(), | |
| 288 | + $c->getGroupManager(), | |
| 289 | + $c->getConfig() | |
| 290 | + ); | |
| 291 | + | |
| 292 | + return new Encryption\Keys\Storage($view, $util); | |
| 293 | + }); | |
| 294 | +        $this->registerService('TagMapper', function (Server $c) { | |
| 295 | + return new TagMapper($c->getDatabaseConnection()); | |
| 296 | + }); | |
| 297 | + | |
| 298 | +        $this->registerService(\OCP\ITagManager::class, function (Server $c) { | |
| 299 | +            $tagMapper = $c->query('TagMapper'); | |
| 300 | + return new TagManager($tagMapper, $c->getUserSession()); | |
| 301 | + }); | |
| 302 | +        $this->registerAlias('TagManager', \OCP\ITagManager::class); | |
| 303 | + | |
| 304 | +        $this->registerService('SystemTagManagerFactory', function (Server $c) { | |
| 305 | + $config = $c->getConfig(); | |
| 306 | +            $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); | |
| 307 | + return new $factoryClass($this); | |
| 308 | + }); | |
| 309 | +        $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { | |
| 310 | +            return $c->query('SystemTagManagerFactory')->getManager(); | |
| 311 | + }); | |
| 312 | +        $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); | |
| 313 | + | |
| 314 | +        $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { | |
| 315 | +            return $c->query('SystemTagManagerFactory')->getObjectMapper(); | |
| 316 | + }); | |
| 317 | +        $this->registerService('RootFolder', function (Server $c) { | |
| 318 | + $manager = \OC\Files\Filesystem::getMountManager(null); | |
| 319 | + $view = new View(); | |
| 320 | + $root = new Root( | |
| 321 | + $manager, | |
| 322 | + $view, | |
| 323 | + null, | |
| 324 | + $c->getUserMountCache(), | |
| 325 | + $this->getLogger(), | |
| 326 | + $this->getUserManager() | |
| 327 | + ); | |
| 328 | + $connector = new HookConnector($root, $view, $c->getEventDispatcher()); | |
| 329 | + $connector->viewToNode(); | |
| 330 | + | |
| 331 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); | |
| 332 | + $previewConnector->connectWatcher(); | |
| 333 | + | |
| 334 | + return $root; | |
| 335 | + }); | |
| 336 | +        $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); | |
| 337 | + | |
| 338 | +        $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { | |
| 339 | +            return new LazyRoot(function () use ($c) { | |
| 340 | +                return $c->query('RootFolder'); | |
| 341 | + }); | |
| 342 | + }); | |
| 343 | +        $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); | |
| 344 | + | |
| 345 | +        $this->registerAlias('UserManager', \OC\User\Manager::class); | |
| 346 | + $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); | |
| 347 | + | |
| 348 | +        $this->registerService(\OCP\IGroupManager::class, function (Server $c) { | |
| 349 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger()); | |
| 350 | +            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { | |
| 351 | +                \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); | |
| 352 | + | |
| 353 | + /** @var IEventDispatcher $dispatcher */ | |
| 354 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 355 | + $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid)); | |
| 356 | + }); | |
| 357 | +            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) { | |
| 358 | +                \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $group->getGID())); | |
| 359 | + | |
| 360 | + /** @var IEventDispatcher $dispatcher */ | |
| 361 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 362 | + $dispatcher->dispatchTyped(new GroupCreatedEvent($group)); | |
| 363 | + }); | |
| 364 | +            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { | |
| 365 | +                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); | |
| 366 | + | |
| 367 | + /** @var IEventDispatcher $dispatcher */ | |
| 368 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 369 | + $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group)); | |
| 370 | + }); | |
| 371 | +            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { | |
| 372 | +                \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); | |
| 373 | + | |
| 374 | + /** @var IEventDispatcher $dispatcher */ | |
| 375 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 376 | + $dispatcher->dispatchTyped(new GroupDeletedEvent($group)); | |
| 377 | + }); | |
| 378 | +            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { | |
| 379 | +                \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); | |
| 380 | + | |
| 381 | + /** @var IEventDispatcher $dispatcher */ | |
| 382 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 383 | + $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user)); | |
| 384 | + }); | |
| 385 | +            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { | |
| 386 | +                \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); | |
| 387 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks | |
| 388 | +                \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); | |
| 389 | + | |
| 390 | + /** @var IEventDispatcher $dispatcher */ | |
| 391 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 392 | + $dispatcher->dispatchTyped(new UserAddedEvent($group, $user)); | |
| 393 | + }); | |
| 394 | +            $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { | |
| 395 | + /** @var IEventDispatcher $dispatcher */ | |
| 396 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 397 | + $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user)); | |
| 398 | + }); | |
| 399 | +            $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) { | |
| 400 | + /** @var IEventDispatcher $dispatcher */ | |
| 401 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 402 | + $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user)); | |
| 403 | + }); | |
| 404 | + return $groupManager; | |
| 405 | + }); | |
| 406 | +        $this->registerAlias('GroupManager', \OCP\IGroupManager::class); | |
| 407 | + | |
| 408 | +        $this->registerService(Store::class, function (Server $c) { | |
| 409 | + $session = $c->getSession(); | |
| 410 | +            if (\OC::$server->getSystemConfig()->getValue('installed', false)) { | |
| 411 | + $tokenProvider = $c->query(IProvider::class); | |
| 412 | +            } else { | |
| 413 | + $tokenProvider = null; | |
| 414 | + } | |
| 415 | + $logger = $c->getLogger(); | |
| 416 | + return new Store($session, $logger, $tokenProvider); | |
| 417 | + }); | |
| 418 | + $this->registerAlias(IStore::class, Store::class); | |
| 419 | +        $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { | |
| 420 | + $dbConnection = $c->getDatabaseConnection(); | |
| 421 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); | |
| 422 | + }); | |
| 423 | + $this->registerAlias(IProvider::class, Authentication\Token\Manager::class); | |
| 424 | + | |
| 425 | +        $this->registerService(\OC\User\Session::class, function (Server $c) { | |
| 426 | + $manager = $c->getUserManager(); | |
| 427 | +            $session = new \OC\Session\Memory(''); | |
| 428 | + $timeFactory = new TimeFactory(); | |
| 429 | + // Token providers might require a working database. This code | |
| 430 | + // might however be called when ownCloud is not yet setup. | |
| 431 | +            if (\OC::$server->getSystemConfig()->getValue('installed', false)) { | |
| 432 | + $defaultTokenProvider = $c->query(IProvider::class); | |
| 433 | +            } else { | |
| 434 | + $defaultTokenProvider = null; | |
| 435 | + } | |
| 436 | + | |
| 437 | + $legacyDispatcher = $c->getEventDispatcher(); | |
| 438 | + | |
| 439 | + $userSession = new \OC\User\Session( | |
| 440 | + $manager, | |
| 441 | + $session, | |
| 442 | + $timeFactory, | |
| 443 | + $defaultTokenProvider, | |
| 444 | + $c->getConfig(), | |
| 445 | + $c->getSecureRandom(), | |
| 446 | + $c->getLockdownManager(), | |
| 447 | + $c->getLogger(), | |
| 448 | + $c->query(IEventDispatcher::class) | |
| 449 | + ); | |
| 450 | +            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { | |
| 451 | +                \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); | |
| 452 | + | |
| 453 | + /** @var IEventDispatcher $dispatcher */ | |
| 454 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 455 | + $dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password)); | |
| 456 | + }); | |
| 457 | +            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { | |
| 458 | + /** @var $user \OC\User\User */ | |
| 459 | +                \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); | |
| 460 | + | |
| 461 | + /** @var IEventDispatcher $dispatcher */ | |
| 462 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 463 | + $dispatcher->dispatchTyped(new UserCreatedEvent($user, $password)); | |
| 464 | + }); | |
| 465 | +            $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) { | |
| 466 | + /** @var $user \OC\User\User */ | |
| 467 | +                \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); | |
| 468 | +                $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); | |
| 469 | + | |
| 470 | + /** @var IEventDispatcher $dispatcher */ | |
| 471 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 472 | + $dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user)); | |
| 473 | + }); | |
| 474 | +            $userSession->listen('\OC\User', 'postDelete', function ($user) { | |
| 475 | + /** @var $user \OC\User\User */ | |
| 476 | +                \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); | |
| 477 | + | |
| 478 | + /** @var IEventDispatcher $dispatcher */ | |
| 479 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 480 | + $dispatcher->dispatchTyped(new UserDeletedEvent($user)); | |
| 481 | + }); | |
| 482 | +            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { | |
| 483 | + /** @var $user \OC\User\User */ | |
| 484 | +                \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); | |
| 485 | + | |
| 486 | + /** @var IEventDispatcher $dispatcher */ | |
| 487 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 488 | + $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword)); | |
| 489 | + }); | |
| 490 | +            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { | |
| 491 | + /** @var $user \OC\User\User */ | |
| 492 | +                \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); | |
| 493 | + | |
| 494 | + /** @var IEventDispatcher $dispatcher */ | |
| 495 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 496 | + $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword)); | |
| 497 | + }); | |
| 498 | +            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { | |
| 499 | +                \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); | |
| 500 | + | |
| 501 | + /** @var IEventDispatcher $dispatcher */ | |
| 502 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 503 | + $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password)); | |
| 504 | + }); | |
| 505 | +            $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) { | |
| 506 | + /** @var $user \OC\User\User */ | |
| 507 | +                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin)); | |
| 508 | + | |
| 509 | + /** @var IEventDispatcher $dispatcher */ | |
| 510 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 511 | + $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin)); | |
| 512 | + }); | |
| 513 | +            $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) { | |
| 514 | + /** @var IEventDispatcher $dispatcher */ | |
| 515 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 516 | + $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid)); | |
| 517 | + }); | |
| 518 | +            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { | |
| 519 | + /** @var $user \OC\User\User */ | |
| 520 | +                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); | |
| 521 | + | |
| 522 | + /** @var IEventDispatcher $dispatcher */ | |
| 523 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 524 | + $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password)); | |
| 525 | + }); | |
| 526 | +            $userSession->listen('\OC\User', 'logout', function ($user) { | |
| 527 | +                \OC_Hook::emit('OC_User', 'logout', array()); | |
| 528 | + | |
| 529 | + /** @var IEventDispatcher $dispatcher */ | |
| 530 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 531 | + $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user)); | |
| 532 | + }); | |
| 533 | +            $userSession->listen('\OC\User', 'postLogout', function ($user) { | |
| 534 | + /** @var IEventDispatcher $dispatcher */ | |
| 535 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 536 | + $dispatcher->dispatchTyped(new UserLoggedOutEvent($user)); | |
| 537 | + }); | |
| 538 | +            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { | |
| 539 | + /** @var $user \OC\User\User */ | |
| 540 | +                \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); | |
| 541 | + | |
| 542 | + /** @var IEventDispatcher $dispatcher */ | |
| 543 | + $dispatcher = $this->query(IEventDispatcher::class); | |
| 544 | + $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue)); | |
| 545 | + }); | |
| 546 | + return $userSession; | |
| 547 | + }); | |
| 548 | + $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class); | |
| 549 | +        $this->registerAlias('UserSession', \OC\User\Session::class); | |
| 550 | + | |
| 551 | + $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); | |
| 552 | + | |
| 553 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); | |
| 554 | +        $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); | |
| 555 | + | |
| 556 | +        $this->registerService(\OC\AllConfig::class, function (Server $c) { | |
| 557 | + return new \OC\AllConfig( | |
| 558 | + $c->getSystemConfig() | |
| 559 | + ); | |
| 560 | + }); | |
| 561 | +        $this->registerAlias('AllConfig', \OC\AllConfig::class); | |
| 562 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); | |
| 563 | + | |
| 564 | +        $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) { | |
| 565 | + return new \OC\SystemConfig($config); | |
| 566 | + }); | |
| 567 | +        $this->registerAlias('SystemConfig', \OC\SystemConfig::class); | |
| 568 | + | |
| 569 | +        $this->registerService(\OC\AppConfig::class, function (Server $c) { | |
| 570 | + return new \OC\AppConfig($c->getDatabaseConnection()); | |
| 571 | + }); | |
| 572 | +        $this->registerAlias('AppConfig', \OC\AppConfig::class); | |
| 573 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); | |
| 574 | + | |
| 575 | +        $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { | |
| 576 | + return new \OC\L10N\Factory( | |
| 577 | + $c->getConfig(), | |
| 578 | + $c->getRequest(), | |
| 579 | + $c->getUserSession(), | |
| 580 | + \OC::$SERVERROOT | |
| 581 | + ); | |
| 582 | + }); | |
| 583 | +        $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); | |
| 584 | + | |
| 585 | +        $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { | |
| 586 | + $config = $c->getConfig(); | |
| 587 | + $cacheFactory = $c->getMemCacheFactory(); | |
| 588 | + $request = $c->getRequest(); | |
| 589 | + return new \OC\URLGenerator( | |
| 590 | + $config, | |
| 591 | + $cacheFactory, | |
| 592 | + $request | |
| 593 | + ); | |
| 594 | + }); | |
| 595 | +        $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); | |
| 596 | + | |
| 597 | +        $this->registerAlias('AppFetcher', AppFetcher::class); | |
| 598 | +        $this->registerAlias('CategoryFetcher', CategoryFetcher::class); | |
| 599 | + | |
| 600 | +        $this->registerService(\OCP\ICache::class, function ($c) { | |
| 601 | + return new Cache\File(); | |
| 602 | + }); | |
| 603 | +        $this->registerAlias('UserCache', \OCP\ICache::class); | |
| 604 | + | |
| 605 | +        $this->registerService(Factory::class, function (Server $c) { | |
| 606 | + | |
| 607 | +            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), | |
| 608 | + ArrayCache::class, | |
| 609 | + ArrayCache::class, | |
| 610 | + ArrayCache::class | |
| 611 | + ); | |
| 612 | + $config = $c->getConfig(); | |
| 613 | + | |
| 614 | +            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { | |
| 615 | + $v = \OC_App::getAppVersions(); | |
| 616 | +                $v['core'] = implode(',', \OC_Util::getVersion()); | |
| 617 | +                $version = implode(',', $v); | |
| 618 | + $instanceId = \OC_Util::getInstanceId(); | |
| 619 | + $path = \OC::$SERVERROOT; | |
| 620 | + $prefix = md5($instanceId . '-' . $version . '-' . $path); | |
| 621 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), | |
| 622 | +                    $config->getSystemValue('memcache.local', null), | |
| 623 | +                    $config->getSystemValue('memcache.distributed', null), | |
| 624 | +                    $config->getSystemValue('memcache.locking', null) | |
| 625 | + ); | |
| 626 | + } | |
| 627 | + return $arrayCacheFactory; | |
| 628 | + | |
| 629 | + }); | |
| 630 | +        $this->registerAlias('MemCacheFactory', Factory::class); | |
| 631 | + $this->registerAlias(ICacheFactory::class, Factory::class); | |
| 632 | + | |
| 633 | +        $this->registerService('RedisFactory', function (Server $c) { | |
| 634 | + $systemConfig = $c->getSystemConfig(); | |
| 635 | + return new RedisFactory($systemConfig); | |
| 636 | + }); | |
| 637 | + | |
| 638 | +        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { | |
| 639 | + return new \OC\Activity\Manager( | |
| 640 | + $c->getRequest(), | |
| 641 | + $c->getUserSession(), | |
| 642 | + $c->getConfig(), | |
| 643 | + $c->query(IValidator::class) | |
| 644 | + ); | |
| 645 | + }); | |
| 646 | +        $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); | |
| 647 | + | |
| 648 | +        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { | |
| 649 | + return new \OC\Activity\EventMerger( | |
| 650 | +                $c->getL10N('lib') | |
| 651 | + ); | |
| 652 | + }); | |
| 653 | + $this->registerAlias(IValidator::class, Validator::class); | |
| 654 | + | |
| 655 | +        $this->registerService(AvatarManager::class, function(Server $c) { | |
| 656 | + return new AvatarManager( | |
| 657 | + $c->query(\OC\User\Manager::class), | |
| 658 | +                $c->getAppDataDir('avatar'), | |
| 659 | +                $c->getL10N('lib'), | |
| 660 | + $c->getLogger(), | |
| 661 | + $c->getConfig() | |
| 662 | + ); | |
| 663 | + }); | |
| 664 | + $this->registerAlias(\OCP\IAvatarManager::class, AvatarManager::class); | |
| 665 | +        $this->registerAlias('AvatarManager', AvatarManager::class); | |
| 666 | + | |
| 667 | + $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); | |
| 668 | + $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class); | |
| 669 | + | |
| 670 | +        $this->registerService(\OC\Log::class, function (Server $c) { | |
| 671 | +            $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); | |
| 672 | + $factory = new LogFactory($c, $this->getSystemConfig()); | |
| 673 | + $logger = $factory->get($logType); | |
| 674 | + $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); | |
| 675 | + | |
| 676 | + return new Log($logger, $this->getSystemConfig(), null, $registry); | |
| 677 | + }); | |
| 678 | + $this->registerAlias(\OCP\ILogger::class, \OC\Log::class); | |
| 679 | +        $this->registerAlias('Logger', \OC\Log::class); | |
| 680 | + | |
| 681 | +        $this->registerService(ILogFactory::class, function (Server $c) { | |
| 682 | + return new LogFactory($c, $this->getSystemConfig()); | |
| 683 | + }); | |
| 684 | + | |
| 685 | +        $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { | |
| 686 | + $config = $c->getConfig(); | |
| 687 | + return new \OC\BackgroundJob\JobList( | |
| 688 | + $c->getDatabaseConnection(), | |
| 689 | + $config, | |
| 690 | + new TimeFactory() | |
| 691 | + ); | |
| 692 | + }); | |
| 693 | +        $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); | |
| 694 | + | |
| 695 | +        $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { | |
| 696 | + $cacheFactory = $c->getMemCacheFactory(); | |
| 697 | + $logger = $c->getLogger(); | |
| 698 | +            if ($cacheFactory->isLocalCacheAvailable()) { | |
| 699 | +                $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); | |
| 700 | +            } else { | |
| 701 | + $router = new \OC\Route\Router($logger); | |
| 702 | + } | |
| 703 | + return $router; | |
| 704 | + }); | |
| 705 | +        $this->registerAlias('Router', \OCP\Route\IRouter::class); | |
| 706 | + | |
| 707 | +        $this->registerService(\OCP\ISearch::class, function ($c) { | |
| 708 | + return new Search(); | |
| 709 | + }); | |
| 710 | +        $this->registerAlias('Search', \OCP\ISearch::class); | |
| 711 | + | |
| 712 | +        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { | |
| 713 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( | |
| 714 | + $this->getMemCacheFactory(), | |
| 715 | + new \OC\AppFramework\Utility\TimeFactory() | |
| 716 | + ); | |
| 717 | + }); | |
| 718 | + | |
| 719 | +        $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { | |
| 720 | + return new SecureRandom(); | |
| 721 | + }); | |
| 722 | +        $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); | |
| 723 | + | |
| 724 | +        $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { | |
| 725 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); | |
| 726 | + }); | |
| 727 | +        $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); | |
| 728 | + | |
| 729 | +        $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { | |
| 730 | + return new Hasher($c->getConfig()); | |
| 731 | + }); | |
| 732 | +        $this->registerAlias('Hasher', \OCP\Security\IHasher::class); | |
| 733 | + | |
| 734 | +        $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { | |
| 735 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); | |
| 736 | + }); | |
| 737 | +        $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); | |
| 738 | + | |
| 739 | +        $this->registerService(IDBConnection::class, function (Server $c) { | |
| 740 | + $systemConfig = $c->getSystemConfig(); | |
| 741 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); | |
| 742 | +            $type = $systemConfig->getValue('dbtype', 'sqlite'); | |
| 743 | +            if (!$factory->isValidType($type)) { | |
| 744 | +                throw new \OC\DatabaseException('Invalid database type'); | |
| 745 | + } | |
| 746 | + $connectionParams = $factory->createConnectionParams(); | |
| 747 | + $connection = $factory->getConnection($type, $connectionParams); | |
| 748 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); | |
| 749 | + return $connection; | |
| 750 | + }); | |
| 751 | +        $this->registerAlias('DatabaseConnection', IDBConnection::class); | |
| 752 | + | |
| 753 | + | |
| 754 | +        $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { | |
| 755 | + $user = \OC_User::getUser(); | |
| 756 | + $uid = $user ? $user : null; | |
| 757 | + return new ClientService( | |
| 758 | + $c->getConfig(), | |
| 759 | + new \OC\Security\CertificateManager( | |
| 760 | + $uid, | |
| 761 | + new View(), | |
| 762 | + $c->getConfig(), | |
| 763 | + $c->getLogger(), | |
| 764 | + $c->getSecureRandom() | |
| 765 | + ) | |
| 766 | + ); | |
| 767 | + }); | |
| 768 | +        $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); | |
| 769 | +        $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { | |
| 770 | + $eventLogger = new EventLogger(); | |
| 771 | +            if ($c->getSystemConfig()->getValue('debug', false)) { | |
| 772 | + // In debug mode, module is being activated by default | |
| 773 | + $eventLogger->activate(); | |
| 774 | + } | |
| 775 | + return $eventLogger; | |
| 776 | + }); | |
| 777 | +        $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); | |
| 778 | + | |
| 779 | +        $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { | |
| 780 | + $queryLogger = new QueryLogger(); | |
| 781 | +            if ($c->getSystemConfig()->getValue('debug', false)) { | |
| 782 | + // In debug mode, module is being activated by default | |
| 783 | + $queryLogger->activate(); | |
| 784 | + } | |
| 785 | + return $queryLogger; | |
| 786 | + }); | |
| 787 | +        $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); | |
| 788 | + | |
| 789 | +        $this->registerService(TempManager::class, function (Server $c) { | |
| 790 | + return new TempManager( | |
| 791 | + $c->getLogger(), | |
| 792 | + $c->getConfig() | |
| 793 | + ); | |
| 794 | + }); | |
| 795 | +        $this->registerAlias('TempManager', TempManager::class); | |
| 796 | + $this->registerAlias(ITempManager::class, TempManager::class); | |
| 797 | + | |
| 798 | +        $this->registerService(AppManager::class, function (Server $c) { | |
| 799 | + return new \OC\App\AppManager( | |
| 800 | + $c->getUserSession(), | |
| 801 | + $c->query(\OC\AppConfig::class), | |
| 802 | + $c->getGroupManager(), | |
| 803 | + $c->getMemCacheFactory(), | |
| 804 | + $c->getEventDispatcher(), | |
| 805 | + $c->getLogger() | |
| 806 | + ); | |
| 807 | + }); | |
| 808 | +        $this->registerAlias('AppManager', AppManager::class); | |
| 809 | + $this->registerAlias(IAppManager::class, AppManager::class); | |
| 810 | + | |
| 811 | +        $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { | |
| 812 | + return new DateTimeZone( | |
| 813 | + $c->getConfig(), | |
| 814 | + $c->getSession() | |
| 815 | + ); | |
| 816 | + }); | |
| 817 | +        $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); | |
| 818 | + | |
| 819 | +        $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { | |
| 820 | +            $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); | |
| 821 | + | |
| 822 | + return new DateTimeFormatter( | |
| 823 | + $c->getDateTimeZone()->getTimeZone(), | |
| 824 | +                $c->getL10N('lib', $language) | |
| 825 | + ); | |
| 826 | + }); | |
| 827 | +        $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); | |
| 828 | + | |
| 829 | +        $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { | |
| 830 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); | |
| 831 | + $listener = new UserMountCacheListener($mountCache); | |
| 832 | + $listener->listen($c->getUserManager()); | |
| 833 | + return $mountCache; | |
| 834 | + }); | |
| 835 | +        $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); | |
| 836 | + | |
| 837 | +        $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { | |
| 838 | + $loader = \OC\Files\Filesystem::getLoader(); | |
| 839 | +            $mountCache = $c->query('UserMountCache'); | |
| 840 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); | |
| 841 | + | |
| 842 | + // builtin providers | |
| 843 | + | |
| 844 | + $config = $c->getConfig(); | |
| 845 | + $manager->registerProvider(new CacheMountProvider($config)); | |
| 846 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); | |
| 847 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); | |
| 848 | + | |
| 849 | + return $manager; | |
| 850 | + }); | |
| 851 | +        $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); | |
| 852 | + | |
| 853 | +        $this->registerService('IniWrapper', function ($c) { | |
| 854 | + return new IniGetWrapper(); | |
| 855 | + }); | |
| 856 | +        $this->registerService('AsyncCommandBus', function (Server $c) { | |
| 857 | +            $busClass = $c->getConfig()->getSystemValue('commandbus'); | |
| 858 | +            if ($busClass) { | |
| 859 | +                list($app, $class) = explode('::', $busClass, 2); | |
| 860 | +                if ($c->getAppManager()->isInstalled($app)) { | |
| 861 | + \OC_App::loadApp($app); | |
| 862 | + return $c->query($class); | |
| 863 | +                } else { | |
| 864 | +                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); | |
| 865 | + } | |
| 866 | +            } else { | |
| 867 | + $jobList = $c->getJobList(); | |
| 868 | + return new CronBus($jobList); | |
| 869 | + } | |
| 870 | + }); | |
| 871 | +        $this->registerService('TrustedDomainHelper', function ($c) { | |
| 872 | + return new TrustedDomainHelper($this->getConfig()); | |
| 873 | + }); | |
| 874 | +        $this->registerService(Throttler::class, function (Server $c) { | |
| 875 | + return new Throttler( | |
| 876 | + $c->getDatabaseConnection(), | |
| 877 | + new TimeFactory(), | |
| 878 | + $c->getLogger(), | |
| 879 | + $c->getConfig() | |
| 880 | + ); | |
| 881 | + }); | |
| 882 | +        $this->registerAlias('Throttler', Throttler::class); | |
| 883 | +        $this->registerService('IntegrityCodeChecker', function (Server $c) { | |
| 884 | + // IConfig and IAppManager requires a working database. This code | |
| 885 | + // might however be called when ownCloud is not yet setup. | |
| 886 | +            if (\OC::$server->getSystemConfig()->getValue('installed', false)) { | |
| 887 | + $config = $c->getConfig(); | |
| 888 | + $appManager = $c->getAppManager(); | |
| 889 | +            } else { | |
| 890 | + $config = null; | |
| 891 | + $appManager = null; | |
| 892 | + } | |
| 893 | + | |
| 894 | + return new Checker( | |
| 895 | + new EnvironmentHelper(), | |
| 896 | + new FileAccessHelper(), | |
| 897 | + new AppLocator(), | |
| 898 | + $config, | |
| 899 | + $c->getMemCacheFactory(), | |
| 900 | + $appManager, | |
| 901 | + $c->getTempManager(), | |
| 902 | + $c->getMimeTypeDetector() | |
| 903 | + ); | |
| 904 | + }); | |
| 905 | +        $this->registerService(\OCP\IRequest::class, function ($c) { | |
| 906 | +            if (isset($this['urlParams'])) { | |
| 907 | + $urlParams = $this['urlParams']; | |
| 908 | +            } else { | |
| 909 | + $urlParams = []; | |
| 910 | + } | |
| 911 | + | |
| 912 | +            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN | |
| 913 | +                && in_array('fakeinput', stream_get_wrappers()) | |
| 914 | +            ) { | |
| 915 | + $stream = 'fakeinput://data'; | |
| 916 | +            } else { | |
| 917 | + $stream = 'php://input'; | |
| 918 | + } | |
| 919 | + | |
| 920 | + return new Request( | |
| 921 | + [ | |
| 922 | + 'get' => $_GET, | |
| 923 | + 'post' => $_POST, | |
| 924 | + 'files' => $_FILES, | |
| 925 | + 'server' => $_SERVER, | |
| 926 | + 'env' => $_ENV, | |
| 927 | + 'cookies' => $_COOKIE, | |
| 928 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) | |
| 929 | + ? $_SERVER['REQUEST_METHOD'] | |
| 930 | + : '', | |
| 931 | + 'urlParams' => $urlParams, | |
| 932 | + ], | |
| 933 | + $this->getSecureRandom(), | |
| 934 | + $this->getConfig(), | |
| 935 | + $this->getCsrfTokenManager(), | |
| 936 | + $stream | |
| 937 | + ); | |
| 938 | + }); | |
| 939 | +        $this->registerAlias('Request', \OCP\IRequest::class); | |
| 940 | + | |
| 941 | +        $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { | |
| 942 | + return new Mailer( | |
| 943 | + $c->getConfig(), | |
| 944 | + $c->getLogger(), | |
| 945 | + $c->query(Defaults::class), | |
| 946 | + $c->getURLGenerator(), | |
| 947 | +                $c->getL10N('lib') | |
| 948 | + ); | |
| 949 | + }); | |
| 950 | +        $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); | |
| 951 | + | |
| 952 | +        $this->registerService('LDAPProvider', function (Server $c) { | |
| 953 | + $config = $c->getConfig(); | |
| 954 | +            $factoryClass = $config->getSystemValue('ldapProviderFactory', null); | |
| 955 | +            if (is_null($factoryClass)) { | |
| 956 | +                throw new \Exception('ldapProviderFactory not set'); | |
| 957 | + } | |
| 958 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ | |
| 959 | + $factory = new $factoryClass($this); | |
| 960 | + return $factory->getLDAPProvider(); | |
| 961 | + }); | |
| 962 | +        $this->registerService(ILockingProvider::class, function (Server $c) { | |
| 963 | + $ini = $c->getIniWrapper(); | |
| 964 | + $config = $c->getConfig(); | |
| 965 | +            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); | |
| 966 | +            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { | |
| 967 | + /** @var \OC\Memcache\Factory $memcacheFactory */ | |
| 968 | + $memcacheFactory = $c->getMemCacheFactory(); | |
| 969 | +                $memcache = $memcacheFactory->createLocking('lock'); | |
| 970 | +                if (!($memcache instanceof \OC\Memcache\NullCache)) { | |
| 971 | + return new MemcacheLockingProvider($memcache, $ttl); | |
| 972 | + } | |
| 973 | + return new DBLockingProvider( | |
| 974 | + $c->getDatabaseConnection(), | |
| 975 | + $c->getLogger(), | |
| 976 | + new TimeFactory(), | |
| 977 | + $ttl, | |
| 978 | + !\OC::$CLI | |
| 979 | + ); | |
| 980 | + } | |
| 981 | + return new NoopLockingProvider(); | |
| 982 | + }); | |
| 983 | +        $this->registerAlias('LockingProvider', ILockingProvider::class); | |
| 984 | + | |
| 985 | +        $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { | |
| 986 | + return new \OC\Files\Mount\Manager(); | |
| 987 | + }); | |
| 988 | +        $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); | |
| 989 | + | |
| 990 | +        $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { | |
| 991 | + return new \OC\Files\Type\Detection( | |
| 992 | + $c->getURLGenerator(), | |
| 993 | + $c->getLogger(), | |
| 994 | + \OC::$configDir, | |
| 995 | + \OC::$SERVERROOT . '/resources/config/' | |
| 996 | + ); | |
| 997 | + }); | |
| 998 | +        $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); | |
| 999 | + | |
| 1000 | +        $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { | |
| 1001 | + return new \OC\Files\Type\Loader( | |
| 1002 | + $c->getDatabaseConnection() | |
| 1003 | + ); | |
| 1004 | + }); | |
| 1005 | +        $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); | |
| 1006 | +        $this->registerService(BundleFetcher::class, function () { | |
| 1007 | +            return new BundleFetcher($this->getL10N('lib')); | |
| 1008 | + }); | |
| 1009 | +        $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { | |
| 1010 | + return new Manager( | |
| 1011 | + $c->query(IValidator::class), | |
| 1012 | + $c->getLogger() | |
| 1013 | + ); | |
| 1014 | + }); | |
| 1015 | +        $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); | |
| 1016 | + | |
| 1017 | +        $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { | |
| 1018 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); | |
| 1019 | +            $manager->registerCapability(function () use ($c) { | |
| 1020 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); | |
| 1021 | + }); | |
| 1022 | +            $manager->registerCapability(function () use ($c) { | |
| 1023 | + return $c->query(\OC\Security\Bruteforce\Capabilities::class); | |
| 1024 | + }); | |
| 1025 | + return $manager; | |
| 1026 | + }); | |
| 1027 | +        $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); | |
| 1028 | + | |
| 1029 | +        $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { | |
| 1030 | + $config = $c->getConfig(); | |
| 1031 | +            $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); | |
| 1032 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ | |
| 1033 | + $factory = new $factoryClass($this); | |
| 1034 | + $manager = $factory->getManager(); | |
| 1035 | + | |
| 1036 | +            $manager->registerDisplayNameResolver('user', function($id) use ($c) { | |
| 1037 | + $manager = $c->getUserManager(); | |
| 1038 | + $user = $manager->get($id); | |
| 1039 | +                if(is_null($user)) { | |
| 1040 | +                    $l = $c->getL10N('core'); | |
| 1041 | +                    $displayName = $l->t('Unknown user'); | |
| 1042 | +                } else { | |
| 1043 | + $displayName = $user->getDisplayName(); | |
| 1044 | + } | |
| 1045 | + return $displayName; | |
| 1046 | + }); | |
| 1047 | + | |
| 1048 | + return $manager; | |
| 1049 | + }); | |
| 1050 | +        $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); | |
| 1051 | + | |
| 1052 | +        $this->registerService('ThemingDefaults', function (Server $c) { | |
| 1053 | + /* | |
| 1054 | 1054 | * Dark magic for autoloader. | 
| 1055 | 1055 | * If we do a class_exists it will try to load the class which will | 
| 1056 | 1056 | * make composer cache the result. Resulting in errors when enabling | 
| 1057 | 1057 | * the theming app. | 
| 1058 | 1058 | */ | 
| 1059 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); | |
| 1060 | -			if (isset($prefixes['OCA\\Theming\\'])) { | |
| 1061 | - $classExists = true; | |
| 1062 | -			} else { | |
| 1063 | - $classExists = false; | |
| 1064 | - } | |
| 1065 | - | |
| 1066 | -			if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { | |
| 1067 | - return new ThemingDefaults( | |
| 1068 | - $c->getConfig(), | |
| 1069 | -					$c->getL10N('theming'), | |
| 1070 | - $c->getURLGenerator(), | |
| 1071 | - $c->getMemCacheFactory(), | |
| 1072 | -					new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), | |
| 1073 | -					new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), | |
| 1074 | - $c->getAppManager(), | |
| 1075 | - $c->getNavigationManager() | |
| 1076 | - ); | |
| 1077 | - } | |
| 1078 | - return new \OC_Defaults(); | |
| 1079 | - }); | |
| 1080 | -		$this->registerService(SCSSCacher::class, function (Server $c) { | |
| 1081 | - return new SCSSCacher( | |
| 1082 | - $c->getLogger(), | |
| 1083 | - $c->query(\OC\Files\AppData\Factory::class), | |
| 1084 | - $c->getURLGenerator(), | |
| 1085 | - $c->getConfig(), | |
| 1086 | - $c->getThemingDefaults(), | |
| 1087 | - \OC::$SERVERROOT, | |
| 1088 | - $this->getMemCacheFactory(), | |
| 1089 | - $c->query(IconsCacher::class), | |
| 1090 | - new TimeFactory() | |
| 1091 | - ); | |
| 1092 | - }); | |
| 1093 | -		$this->registerService(JSCombiner::class, function (Server $c) { | |
| 1094 | - return new JSCombiner( | |
| 1095 | -				$c->getAppDataDir('js'), | |
| 1096 | - $c->getURLGenerator(), | |
| 1097 | - $this->getMemCacheFactory(), | |
| 1098 | - $c->getSystemConfig(), | |
| 1099 | - $c->getLogger() | |
| 1100 | - ); | |
| 1101 | - }); | |
| 1102 | - $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class); | |
| 1103 | -		$this->registerAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class); | |
| 1104 | - $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class); | |
| 1105 | - | |
| 1106 | -		$this->registerService('CryptoWrapper', function (Server $c) { | |
| 1107 | - // FIXME: Instantiiated here due to cyclic dependency | |
| 1108 | - $request = new Request( | |
| 1109 | - [ | |
| 1110 | - 'get' => $_GET, | |
| 1111 | - 'post' => $_POST, | |
| 1112 | - 'files' => $_FILES, | |
| 1113 | - 'server' => $_SERVER, | |
| 1114 | - 'env' => $_ENV, | |
| 1115 | - 'cookies' => $_COOKIE, | |
| 1116 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) | |
| 1117 | - ? $_SERVER['REQUEST_METHOD'] | |
| 1118 | - : null, | |
| 1119 | - ], | |
| 1120 | - $c->getSecureRandom(), | |
| 1121 | - $c->getConfig() | |
| 1122 | - ); | |
| 1123 | - | |
| 1124 | - return new CryptoWrapper( | |
| 1125 | - $c->getConfig(), | |
| 1126 | - $c->getCrypto(), | |
| 1127 | - $c->getSecureRandom(), | |
| 1128 | - $request | |
| 1129 | - ); | |
| 1130 | - }); | |
| 1131 | -		$this->registerService(CsrfTokenManager::class, function (Server $c) { | |
| 1132 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); | |
| 1133 | - | |
| 1134 | - return new CsrfTokenManager( | |
| 1135 | - $tokenGenerator, | |
| 1136 | - $c->query(SessionStorage::class) | |
| 1137 | - ); | |
| 1138 | - }); | |
| 1139 | -		$this->registerAlias('CsrfTokenManager', CsrfTokenManager::class); | |
| 1140 | -		$this->registerService(SessionStorage::class, function (Server $c) { | |
| 1141 | - return new SessionStorage($c->getSession()); | |
| 1142 | - }); | |
| 1143 | - $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, \OC\Security\CSP\ContentSecurityPolicyManager::class); | |
| 1144 | -		$this->registerAlias('ContentSecurityPolicyManager', \OC\Security\CSP\ContentSecurityPolicyManager::class); | |
| 1145 | - | |
| 1146 | -		$this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { | |
| 1147 | - return new ContentSecurityPolicyNonceManager( | |
| 1148 | - $c->getCsrfTokenManager(), | |
| 1149 | - $c->getRequest() | |
| 1150 | - ); | |
| 1151 | - }); | |
| 1152 | - | |
| 1153 | -		$this->registerService(\OCP\Share\IManager::class, function (Server $c) { | |
| 1154 | - $config = $c->getConfig(); | |
| 1155 | -			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); | |
| 1156 | - /** @var \OCP\Share\IProviderFactory $factory */ | |
| 1157 | - $factory = new $factoryClass($this); | |
| 1158 | - | |
| 1159 | - $manager = new \OC\Share20\Manager( | |
| 1160 | - $c->getLogger(), | |
| 1161 | - $c->getConfig(), | |
| 1162 | - $c->getSecureRandom(), | |
| 1163 | - $c->getHasher(), | |
| 1164 | - $c->getMountManager(), | |
| 1165 | - $c->getGroupManager(), | |
| 1166 | -				$c->getL10N('lib'), | |
| 1167 | - $c->getL10NFactory(), | |
| 1168 | - $factory, | |
| 1169 | - $c->getUserManager(), | |
| 1170 | - $c->getLazyRootFolder(), | |
| 1171 | - $c->getEventDispatcher(), | |
| 1172 | - $c->getMailer(), | |
| 1173 | - $c->getURLGenerator(), | |
| 1174 | - $c->getThemingDefaults(), | |
| 1175 | - $c->query(IEventDispatcher::class) | |
| 1176 | - ); | |
| 1177 | - | |
| 1178 | - return $manager; | |
| 1179 | - }); | |
| 1180 | -		$this->registerAlias('ShareManager', \OCP\Share\IManager::class); | |
| 1181 | - | |
| 1182 | -		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { | |
| 1183 | - $instance = new Collaboration\Collaborators\Search($c); | |
| 1184 | - | |
| 1185 | - // register default plugins | |
| 1186 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); | |
| 1187 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); | |
| 1188 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); | |
| 1189 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); | |
| 1190 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]); | |
| 1191 | - | |
| 1192 | - return $instance; | |
| 1193 | - }); | |
| 1194 | -		$this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); | |
| 1195 | - $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class); | |
| 1196 | - | |
| 1197 | - $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); | |
| 1198 | - | |
| 1199 | - $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class); | |
| 1200 | - $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class); | |
| 1201 | - | |
| 1202 | -		$this->registerService('SettingsManager', function (Server $c) { | |
| 1203 | - $manager = new \OC\Settings\Manager( | |
| 1204 | - $c->getLogger(), | |
| 1205 | - $c->getL10NFactory(), | |
| 1206 | - $c->getURLGenerator(), | |
| 1207 | - $c | |
| 1208 | - ); | |
| 1209 | - return $manager; | |
| 1210 | - }); | |
| 1211 | -		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { | |
| 1212 | - return new \OC\Files\AppData\Factory( | |
| 1213 | - $c->getRootFolder(), | |
| 1214 | - $c->getSystemConfig() | |
| 1215 | - ); | |
| 1216 | - }); | |
| 1217 | - | |
| 1218 | -		$this->registerService('LockdownManager', function (Server $c) { | |
| 1219 | -			return new LockdownManager(function () use ($c) { | |
| 1220 | - return $c->getSession(); | |
| 1221 | - }); | |
| 1222 | - }); | |
| 1223 | - | |
| 1224 | -		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { | |
| 1225 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); | |
| 1226 | - }); | |
| 1227 | - | |
| 1228 | -		$this->registerService(ICloudIdManager::class, function (Server $c) { | |
| 1229 | - return new CloudIdManager(); | |
| 1230 | - }); | |
| 1231 | - | |
| 1232 | -		$this->registerService(IConfig::class, function (Server $c) { | |
| 1233 | - return new GlobalScale\Config($c->getConfig()); | |
| 1234 | - }); | |
| 1235 | - | |
| 1236 | -		$this->registerService(ICloudFederationProviderManager::class, function (Server $c) { | |
| 1237 | - return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); | |
| 1238 | - }); | |
| 1239 | - | |
| 1240 | -		$this->registerService(ICloudFederationFactory::class, function (Server $c) { | |
| 1241 | - return new CloudFederationFactory(); | |
| 1242 | - }); | |
| 1243 | - | |
| 1244 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); | |
| 1245 | -		$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); | |
| 1246 | - | |
| 1247 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); | |
| 1248 | -		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); | |
| 1249 | - | |
| 1250 | -		$this->registerService(Defaults::class, function (Server $c) { | |
| 1251 | - return new Defaults( | |
| 1252 | - $c->getThemingDefaults() | |
| 1253 | - ); | |
| 1254 | - }); | |
| 1255 | -		$this->registerAlias('Defaults', \OCP\Defaults::class); | |
| 1256 | - | |
| 1257 | -		$this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { | |
| 1258 | - return $c->query(\OCP\IUserSession::class)->getSession(); | |
| 1259 | - }); | |
| 1260 | - | |
| 1261 | -		$this->registerService(IShareHelper::class, function (Server $c) { | |
| 1262 | - return new ShareHelper( | |
| 1263 | - $c->query(\OCP\Share\IManager::class) | |
| 1264 | - ); | |
| 1265 | - }); | |
| 1266 | - | |
| 1267 | -		$this->registerService(Installer::class, function(Server $c) { | |
| 1268 | - return new Installer( | |
| 1269 | - $c->getAppFetcher(), | |
| 1270 | - $c->getHTTPClientService(), | |
| 1271 | - $c->getTempManager(), | |
| 1272 | - $c->getLogger(), | |
| 1273 | - $c->getConfig() | |
| 1274 | - ); | |
| 1275 | - }); | |
| 1276 | - | |
| 1277 | -		$this->registerService(IApiFactory::class, function(Server $c) { | |
| 1278 | - return new ApiFactory($c->getHTTPClientService()); | |
| 1279 | - }); | |
| 1280 | - | |
| 1281 | -		$this->registerService(IInstanceFactory::class, function(Server $c) { | |
| 1282 | - $memcacheFactory = $c->getMemCacheFactory(); | |
| 1283 | -			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); | |
| 1284 | - }); | |
| 1285 | - | |
| 1286 | -		$this->registerService(IContactsStore::class, function(Server $c) { | |
| 1287 | - return new ContactsStore( | |
| 1288 | - $c->getContactsManager(), | |
| 1289 | - $c->getConfig(), | |
| 1290 | - $c->getUserManager(), | |
| 1291 | - $c->getGroupManager() | |
| 1292 | - ); | |
| 1293 | - }); | |
| 1294 | - $this->registerAlias(IContactsStore::class, ContactsStore::class); | |
| 1295 | - $this->registerAlias(IAccountManager::class, AccountManager::class); | |
| 1296 | - | |
| 1297 | -		$this->registerService(IStorageFactory::class, function() { | |
| 1298 | - return new StorageFactory(); | |
| 1299 | - }); | |
| 1300 | - | |
| 1301 | - $this->registerAlias(IDashboardManager::class, DashboardManager::class); | |
| 1302 | - $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); | |
| 1303 | - | |
| 1304 | - $this->registerAlias(ISubAdmin::class, SubAdmin::class); | |
| 1305 | - | |
| 1306 | - $this->registerAlias(IInitialStateService::class, InitialStateService::class); | |
| 1307 | - | |
| 1308 | - $this->connectDispatcher(); | |
| 1309 | - } | |
| 1310 | - | |
| 1311 | - /** | |
| 1312 | - * @return \OCP\Calendar\IManager | |
| 1313 | - */ | |
| 1314 | -	public function getCalendarManager() { | |
| 1315 | -		return $this->query('CalendarManager'); | |
| 1316 | - } | |
| 1317 | - | |
| 1318 | - /** | |
| 1319 | - * @return \OCP\Calendar\Resource\IManager | |
| 1320 | - */ | |
| 1321 | -	public function getCalendarResourceBackendManager() { | |
| 1322 | -		return $this->query('CalendarResourceBackendManager'); | |
| 1323 | - } | |
| 1324 | - | |
| 1325 | - /** | |
| 1326 | - * @return \OCP\Calendar\Room\IManager | |
| 1327 | - */ | |
| 1328 | -	public function getCalendarRoomBackendManager() { | |
| 1329 | -		return $this->query('CalendarRoomBackendManager'); | |
| 1330 | - } | |
| 1331 | - | |
| 1332 | -	private function connectDispatcher() { | |
| 1333 | - $dispatcher = $this->getEventDispatcher(); | |
| 1334 | - | |
| 1335 | - // Delete avatar on user deletion | |
| 1336 | -		$dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { | |
| 1337 | - $logger = $this->getLogger(); | |
| 1338 | - $manager = $this->getAvatarManager(); | |
| 1339 | - /** @var IUser $user */ | |
| 1340 | - $user = $e->getSubject(); | |
| 1341 | - | |
| 1342 | -			try { | |
| 1343 | - $avatar = $manager->getAvatar($user->getUID()); | |
| 1344 | - $avatar->remove(); | |
| 1345 | -			} catch (NotFoundException $e) { | |
| 1346 | - // no avatar to remove | |
| 1347 | -			} catch (\Exception $e) { | |
| 1348 | - // Ignore exceptions | |
| 1349 | -				$logger->info('Could not cleanup avatar of ' . $user->getUID()); | |
| 1350 | - } | |
| 1351 | - }); | |
| 1352 | - | |
| 1353 | -		$dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { | |
| 1354 | - $manager = $this->getAvatarManager(); | |
| 1355 | - /** @var IUser $user */ | |
| 1356 | - $user = $e->getSubject(); | |
| 1357 | -			$feature = $e->getArgument('feature'); | |
| 1358 | -			$oldValue = $e->getArgument('oldValue'); | |
| 1359 | -			$value = $e->getArgument('value'); | |
| 1360 | - | |
| 1361 | - // We only change the avatar on display name changes | |
| 1362 | -			if ($feature !== 'displayName') { | |
| 1363 | - return; | |
| 1364 | - } | |
| 1365 | - | |
| 1366 | -			try { | |
| 1367 | - $avatar = $manager->getAvatar($user->getUID()); | |
| 1368 | - $avatar->userChanged($feature, $oldValue, $value); | |
| 1369 | -			} catch (NotFoundException $e) { | |
| 1370 | - // no avatar to remove | |
| 1371 | - } | |
| 1372 | - }); | |
| 1373 | - } | |
| 1374 | - | |
| 1375 | - /** | |
| 1376 | - * @return \OCP\Contacts\IManager | |
| 1377 | - */ | |
| 1378 | -	public function getContactsManager() { | |
| 1379 | -		return $this->query('ContactsManager'); | |
| 1380 | - } | |
| 1381 | - | |
| 1382 | - /** | |
| 1383 | - * @return \OC\Encryption\Manager | |
| 1384 | - */ | |
| 1385 | -	public function getEncryptionManager() { | |
| 1386 | -		return $this->query('EncryptionManager'); | |
| 1387 | - } | |
| 1388 | - | |
| 1389 | - /** | |
| 1390 | - * @return \OC\Encryption\File | |
| 1391 | - */ | |
| 1392 | -	public function getEncryptionFilesHelper() { | |
| 1393 | -		return $this->query('EncryptionFileHelper'); | |
| 1394 | - } | |
| 1395 | - | |
| 1396 | - /** | |
| 1397 | - * @return \OCP\Encryption\Keys\IStorage | |
| 1398 | - */ | |
| 1399 | -	public function getEncryptionKeyStorage() { | |
| 1400 | -		return $this->query('EncryptionKeyStorage'); | |
| 1401 | - } | |
| 1402 | - | |
| 1403 | - /** | |
| 1404 | - * The current request object holding all information about the request | |
| 1405 | - * currently being processed is returned from this method. | |
| 1406 | - * In case the current execution was not initiated by a web request null is returned | |
| 1407 | - * | |
| 1408 | - * @return \OCP\IRequest | |
| 1409 | - */ | |
| 1410 | -	public function getRequest() { | |
| 1411 | -		return $this->query('Request'); | |
| 1412 | - } | |
| 1413 | - | |
| 1414 | - /** | |
| 1415 | - * Returns the preview manager which can create preview images for a given file | |
| 1416 | - * | |
| 1417 | - * @return \OCP\IPreview | |
| 1418 | - */ | |
| 1419 | -	public function getPreviewManager() { | |
| 1420 | -		return $this->query('PreviewManager'); | |
| 1421 | - } | |
| 1422 | - | |
| 1423 | - /** | |
| 1424 | - * Returns the tag manager which can get and set tags for different object types | |
| 1425 | - * | |
| 1426 | - * @see \OCP\ITagManager::load() | |
| 1427 | - * @return \OCP\ITagManager | |
| 1428 | - */ | |
| 1429 | -	public function getTagManager() { | |
| 1430 | -		return $this->query('TagManager'); | |
| 1431 | - } | |
| 1432 | - | |
| 1433 | - /** | |
| 1434 | - * Returns the system-tag manager | |
| 1435 | - * | |
| 1436 | - * @return \OCP\SystemTag\ISystemTagManager | |
| 1437 | - * | |
| 1438 | - * @since 9.0.0 | |
| 1439 | - */ | |
| 1440 | -	public function getSystemTagManager() { | |
| 1441 | -		return $this->query('SystemTagManager'); | |
| 1442 | - } | |
| 1443 | - | |
| 1444 | - /** | |
| 1445 | - * Returns the system-tag object mapper | |
| 1446 | - * | |
| 1447 | - * @return \OCP\SystemTag\ISystemTagObjectMapper | |
| 1448 | - * | |
| 1449 | - * @since 9.0.0 | |
| 1450 | - */ | |
| 1451 | -	public function getSystemTagObjectMapper() { | |
| 1452 | -		return $this->query('SystemTagObjectMapper'); | |
| 1453 | - } | |
| 1454 | - | |
| 1455 | - /** | |
| 1456 | - * Returns the avatar manager, used for avatar functionality | |
| 1457 | - * | |
| 1458 | - * @return \OCP\IAvatarManager | |
| 1459 | - */ | |
| 1460 | -	public function getAvatarManager() { | |
| 1461 | -		return $this->query('AvatarManager'); | |
| 1462 | - } | |
| 1463 | - | |
| 1464 | - /** | |
| 1465 | - * Returns the root folder of ownCloud's data directory | |
| 1466 | - * | |
| 1467 | - * @return \OCP\Files\IRootFolder | |
| 1468 | - */ | |
| 1469 | -	public function getRootFolder() { | |
| 1470 | -		return $this->query('LazyRootFolder'); | |
| 1471 | - } | |
| 1472 | - | |
| 1473 | - /** | |
| 1474 | - * Returns the root folder of ownCloud's data directory | |
| 1475 | - * This is the lazy variant so this gets only initialized once it | |
| 1476 | - * is actually used. | |
| 1477 | - * | |
| 1478 | - * @return \OCP\Files\IRootFolder | |
| 1479 | - */ | |
| 1480 | -	public function getLazyRootFolder() { | |
| 1481 | -		return $this->query('LazyRootFolder'); | |
| 1482 | - } | |
| 1483 | - | |
| 1484 | - /** | |
| 1485 | - * Returns a view to ownCloud's files folder | |
| 1486 | - * | |
| 1487 | - * @param string $userId user ID | |
| 1488 | - * @return \OCP\Files\Folder|null | |
| 1489 | - */ | |
| 1490 | -	public function getUserFolder($userId = null) { | |
| 1491 | -		if ($userId === null) { | |
| 1492 | - $user = $this->getUserSession()->getUser(); | |
| 1493 | -			if (!$user) { | |
| 1494 | - return null; | |
| 1495 | - } | |
| 1496 | - $userId = $user->getUID(); | |
| 1497 | - } | |
| 1498 | - $root = $this->getRootFolder(); | |
| 1499 | - return $root->getUserFolder($userId); | |
| 1500 | - } | |
| 1501 | - | |
| 1502 | - /** | |
| 1503 | - * Returns an app-specific view in ownClouds data directory | |
| 1504 | - * | |
| 1505 | - * @return \OCP\Files\Folder | |
| 1506 | - * @deprecated since 9.2.0 use IAppData | |
| 1507 | - */ | |
| 1508 | -	public function getAppFolder() { | |
| 1509 | - $dir = '/' . \OC_App::getCurrentApp(); | |
| 1510 | - $root = $this->getRootFolder(); | |
| 1511 | -		if (!$root->nodeExists($dir)) { | |
| 1512 | - $folder = $root->newFolder($dir); | |
| 1513 | -		} else { | |
| 1514 | - $folder = $root->get($dir); | |
| 1515 | - } | |
| 1516 | - return $folder; | |
| 1517 | - } | |
| 1518 | - | |
| 1519 | - /** | |
| 1520 | - * @return \OC\User\Manager | |
| 1521 | - */ | |
| 1522 | -	public function getUserManager() { | |
| 1523 | -		return $this->query('UserManager'); | |
| 1524 | - } | |
| 1525 | - | |
| 1526 | - /** | |
| 1527 | - * @return \OC\Group\Manager | |
| 1528 | - */ | |
| 1529 | -	public function getGroupManager() { | |
| 1530 | -		return $this->query('GroupManager'); | |
| 1531 | - } | |
| 1532 | - | |
| 1533 | - /** | |
| 1534 | - * @return \OC\User\Session | |
| 1535 | - */ | |
| 1536 | -	public function getUserSession() { | |
| 1537 | -		return $this->query('UserSession'); | |
| 1538 | - } | |
| 1539 | - | |
| 1540 | - /** | |
| 1541 | - * @return \OCP\ISession | |
| 1542 | - */ | |
| 1543 | -	public function getSession() { | |
| 1544 | -		return $this->query('UserSession')->getSession(); | |
| 1545 | - } | |
| 1546 | - | |
| 1547 | - /** | |
| 1548 | - * @param \OCP\ISession $session | |
| 1549 | - */ | |
| 1550 | -	public function setSession(\OCP\ISession $session) { | |
| 1551 | - $this->query(SessionStorage::class)->setSession($session); | |
| 1552 | -		$this->query('UserSession')->setSession($session); | |
| 1553 | - $this->query(Store::class)->setSession($session); | |
| 1554 | - } | |
| 1555 | - | |
| 1556 | - /** | |
| 1557 | - * @return \OC\Authentication\TwoFactorAuth\Manager | |
| 1558 | - */ | |
| 1559 | -	public function getTwoFactorAuthManager() { | |
| 1560 | -		return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); | |
| 1561 | - } | |
| 1562 | - | |
| 1563 | - /** | |
| 1564 | - * @return \OC\NavigationManager | |
| 1565 | - */ | |
| 1566 | -	public function getNavigationManager() { | |
| 1567 | -		return $this->query('NavigationManager'); | |
| 1568 | - } | |
| 1569 | - | |
| 1570 | - /** | |
| 1571 | - * @return \OCP\IConfig | |
| 1572 | - */ | |
| 1573 | -	public function getConfig() { | |
| 1574 | -		return $this->query('AllConfig'); | |
| 1575 | - } | |
| 1576 | - | |
| 1577 | - /** | |
| 1578 | - * @return \OC\SystemConfig | |
| 1579 | - */ | |
| 1580 | -	public function getSystemConfig() { | |
| 1581 | -		return $this->query('SystemConfig'); | |
| 1582 | - } | |
| 1583 | - | |
| 1584 | - /** | |
| 1585 | - * Returns the app config manager | |
| 1586 | - * | |
| 1587 | - * @return \OCP\IAppConfig | |
| 1588 | - */ | |
| 1589 | -	public function getAppConfig() { | |
| 1590 | -		return $this->query('AppConfig'); | |
| 1591 | - } | |
| 1592 | - | |
| 1593 | - /** | |
| 1594 | - * @return \OCP\L10N\IFactory | |
| 1595 | - */ | |
| 1596 | -	public function getL10NFactory() { | |
| 1597 | -		return $this->query('L10NFactory'); | |
| 1598 | - } | |
| 1599 | - | |
| 1600 | - /** | |
| 1601 | - * get an L10N instance | |
| 1602 | - * | |
| 1603 | - * @param string $app appid | |
| 1604 | - * @param string $lang | |
| 1605 | - * @return IL10N | |
| 1606 | - */ | |
| 1607 | -	public function getL10N($app, $lang = null) { | |
| 1608 | - return $this->getL10NFactory()->get($app, $lang); | |
| 1609 | - } | |
| 1610 | - | |
| 1611 | - /** | |
| 1612 | - * @return \OCP\IURLGenerator | |
| 1613 | - */ | |
| 1614 | -	public function getURLGenerator() { | |
| 1615 | -		return $this->query('URLGenerator'); | |
| 1616 | - } | |
| 1617 | - | |
| 1618 | - /** | |
| 1619 | - * @return AppFetcher | |
| 1620 | - */ | |
| 1621 | -	public function getAppFetcher() { | |
| 1622 | - return $this->query(AppFetcher::class); | |
| 1623 | - } | |
| 1624 | - | |
| 1625 | - /** | |
| 1626 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use | |
| 1627 | - * getMemCacheFactory() instead. | |
| 1628 | - * | |
| 1629 | - * @return \OCP\ICache | |
| 1630 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache | |
| 1631 | - */ | |
| 1632 | -	public function getCache() { | |
| 1633 | -		return $this->query('UserCache'); | |
| 1634 | - } | |
| 1635 | - | |
| 1636 | - /** | |
| 1637 | - * Returns an \OCP\CacheFactory instance | |
| 1638 | - * | |
| 1639 | - * @return \OCP\ICacheFactory | |
| 1640 | - */ | |
| 1641 | -	public function getMemCacheFactory() { | |
| 1642 | -		return $this->query('MemCacheFactory'); | |
| 1643 | - } | |
| 1644 | - | |
| 1645 | - /** | |
| 1646 | - * Returns an \OC\RedisFactory instance | |
| 1647 | - * | |
| 1648 | - * @return \OC\RedisFactory | |
| 1649 | - */ | |
| 1650 | -	public function getGetRedisFactory() { | |
| 1651 | -		return $this->query('RedisFactory'); | |
| 1652 | - } | |
| 1653 | - | |
| 1654 | - | |
| 1655 | - /** | |
| 1656 | - * Returns the current session | |
| 1657 | - * | |
| 1658 | - * @return \OCP\IDBConnection | |
| 1659 | - */ | |
| 1660 | -	public function getDatabaseConnection() { | |
| 1661 | -		return $this->query('DatabaseConnection'); | |
| 1662 | - } | |
| 1663 | - | |
| 1664 | - /** | |
| 1665 | - * Returns the activity manager | |
| 1666 | - * | |
| 1667 | - * @return \OCP\Activity\IManager | |
| 1668 | - */ | |
| 1669 | -	public function getActivityManager() { | |
| 1670 | -		return $this->query('ActivityManager'); | |
| 1671 | - } | |
| 1672 | - | |
| 1673 | - /** | |
| 1674 | - * Returns an job list for controlling background jobs | |
| 1675 | - * | |
| 1676 | - * @return \OCP\BackgroundJob\IJobList | |
| 1677 | - */ | |
| 1678 | -	public function getJobList() { | |
| 1679 | -		return $this->query('JobList'); | |
| 1680 | - } | |
| 1681 | - | |
| 1682 | - /** | |
| 1683 | - * Returns a logger instance | |
| 1684 | - * | |
| 1685 | - * @return \OCP\ILogger | |
| 1686 | - */ | |
| 1687 | -	public function getLogger() { | |
| 1688 | -		return $this->query('Logger'); | |
| 1689 | - } | |
| 1690 | - | |
| 1691 | - /** | |
| 1692 | - * @return ILogFactory | |
| 1693 | - * @throws \OCP\AppFramework\QueryException | |
| 1694 | - */ | |
| 1695 | -	public function getLogFactory() { | |
| 1696 | - return $this->query(ILogFactory::class); | |
| 1697 | - } | |
| 1698 | - | |
| 1699 | - /** | |
| 1700 | - * Returns a router for generating and matching urls | |
| 1701 | - * | |
| 1702 | - * @return \OCP\Route\IRouter | |
| 1703 | - */ | |
| 1704 | -	public function getRouter() { | |
| 1705 | -		return $this->query('Router'); | |
| 1706 | - } | |
| 1707 | - | |
| 1708 | - /** | |
| 1709 | - * Returns a search instance | |
| 1710 | - * | |
| 1711 | - * @return \OCP\ISearch | |
| 1712 | - */ | |
| 1713 | -	public function getSearch() { | |
| 1714 | -		return $this->query('Search'); | |
| 1715 | - } | |
| 1716 | - | |
| 1717 | - /** | |
| 1718 | - * Returns a SecureRandom instance | |
| 1719 | - * | |
| 1720 | - * @return \OCP\Security\ISecureRandom | |
| 1721 | - */ | |
| 1722 | -	public function getSecureRandom() { | |
| 1723 | -		return $this->query('SecureRandom'); | |
| 1724 | - } | |
| 1725 | - | |
| 1726 | - /** | |
| 1727 | - * Returns a Crypto instance | |
| 1728 | - * | |
| 1729 | - * @return \OCP\Security\ICrypto | |
| 1730 | - */ | |
| 1731 | -	public function getCrypto() { | |
| 1732 | -		return $this->query('Crypto'); | |
| 1733 | - } | |
| 1734 | - | |
| 1735 | - /** | |
| 1736 | - * Returns a Hasher instance | |
| 1737 | - * | |
| 1738 | - * @return \OCP\Security\IHasher | |
| 1739 | - */ | |
| 1740 | -	public function getHasher() { | |
| 1741 | -		return $this->query('Hasher'); | |
| 1742 | - } | |
| 1743 | - | |
| 1744 | - /** | |
| 1745 | - * Returns a CredentialsManager instance | |
| 1746 | - * | |
| 1747 | - * @return \OCP\Security\ICredentialsManager | |
| 1748 | - */ | |
| 1749 | -	public function getCredentialsManager() { | |
| 1750 | -		return $this->query('CredentialsManager'); | |
| 1751 | - } | |
| 1752 | - | |
| 1753 | - /** | |
| 1754 | - * Get the certificate manager for the user | |
| 1755 | - * | |
| 1756 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager | |
| 1757 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in | |
| 1758 | - */ | |
| 1759 | -	public function getCertificateManager($userId = '') { | |
| 1760 | -		if ($userId === '') { | |
| 1761 | - $userSession = $this->getUserSession(); | |
| 1762 | - $user = $userSession->getUser(); | |
| 1763 | -			if (is_null($user)) { | |
| 1764 | - return null; | |
| 1765 | - } | |
| 1766 | - $userId = $user->getUID(); | |
| 1767 | - } | |
| 1768 | - return new CertificateManager( | |
| 1769 | - $userId, | |
| 1770 | - new View(), | |
| 1771 | - $this->getConfig(), | |
| 1772 | - $this->getLogger(), | |
| 1773 | - $this->getSecureRandom() | |
| 1774 | - ); | |
| 1775 | - } | |
| 1776 | - | |
| 1777 | - /** | |
| 1778 | - * Returns an instance of the HTTP client service | |
| 1779 | - * | |
| 1780 | - * @return \OCP\Http\Client\IClientService | |
| 1781 | - */ | |
| 1782 | -	public function getHTTPClientService() { | |
| 1783 | -		return $this->query('HttpClientService'); | |
| 1784 | - } | |
| 1785 | - | |
| 1786 | - /** | |
| 1787 | - * Create a new event source | |
| 1788 | - * | |
| 1789 | - * @return \OCP\IEventSource | |
| 1790 | - */ | |
| 1791 | -	public function createEventSource() { | |
| 1792 | - return new \OC_EventSource(); | |
| 1793 | - } | |
| 1794 | - | |
| 1795 | - /** | |
| 1796 | - * Get the active event logger | |
| 1797 | - * | |
| 1798 | - * The returned logger only logs data when debug mode is enabled | |
| 1799 | - * | |
| 1800 | - * @return \OCP\Diagnostics\IEventLogger | |
| 1801 | - */ | |
| 1802 | -	public function getEventLogger() { | |
| 1803 | -		return $this->query('EventLogger'); | |
| 1804 | - } | |
| 1805 | - | |
| 1806 | - /** | |
| 1807 | - * Get the active query logger | |
| 1808 | - * | |
| 1809 | - * The returned logger only logs data when debug mode is enabled | |
| 1810 | - * | |
| 1811 | - * @return \OCP\Diagnostics\IQueryLogger | |
| 1812 | - */ | |
| 1813 | -	public function getQueryLogger() { | |
| 1814 | -		return $this->query('QueryLogger'); | |
| 1815 | - } | |
| 1816 | - | |
| 1817 | - /** | |
| 1818 | - * Get the manager for temporary files and folders | |
| 1819 | - * | |
| 1820 | - * @return \OCP\ITempManager | |
| 1821 | - */ | |
| 1822 | -	public function getTempManager() { | |
| 1823 | -		return $this->query('TempManager'); | |
| 1824 | - } | |
| 1825 | - | |
| 1826 | - /** | |
| 1827 | - * Get the app manager | |
| 1828 | - * | |
| 1829 | - * @return \OCP\App\IAppManager | |
| 1830 | - */ | |
| 1831 | -	public function getAppManager() { | |
| 1832 | -		return $this->query('AppManager'); | |
| 1833 | - } | |
| 1834 | - | |
| 1835 | - /** | |
| 1836 | - * Creates a new mailer | |
| 1837 | - * | |
| 1838 | - * @return \OCP\Mail\IMailer | |
| 1839 | - */ | |
| 1840 | -	public function getMailer() { | |
| 1841 | -		return $this->query('Mailer'); | |
| 1842 | - } | |
| 1843 | - | |
| 1844 | - /** | |
| 1845 | - * Get the webroot | |
| 1846 | - * | |
| 1847 | - * @return string | |
| 1848 | - */ | |
| 1849 | -	public function getWebRoot() { | |
| 1850 | - return $this->webRoot; | |
| 1851 | - } | |
| 1852 | - | |
| 1853 | - /** | |
| 1854 | - * @return \OC\OCSClient | |
| 1855 | - */ | |
| 1856 | -	public function getOcsClient() { | |
| 1857 | -		return $this->query('OcsClient'); | |
| 1858 | - } | |
| 1859 | - | |
| 1860 | - /** | |
| 1861 | - * @return \OCP\IDateTimeZone | |
| 1862 | - */ | |
| 1863 | -	public function getDateTimeZone() { | |
| 1864 | -		return $this->query('DateTimeZone'); | |
| 1865 | - } | |
| 1866 | - | |
| 1867 | - /** | |
| 1868 | - * @return \OCP\IDateTimeFormatter | |
| 1869 | - */ | |
| 1870 | -	public function getDateTimeFormatter() { | |
| 1871 | -		return $this->query('DateTimeFormatter'); | |
| 1872 | - } | |
| 1873 | - | |
| 1874 | - /** | |
| 1875 | - * @return \OCP\Files\Config\IMountProviderCollection | |
| 1876 | - */ | |
| 1877 | -	public function getMountProviderCollection() { | |
| 1878 | -		return $this->query('MountConfigManager'); | |
| 1879 | - } | |
| 1880 | - | |
| 1881 | - /** | |
| 1882 | - * Get the IniWrapper | |
| 1883 | - * | |
| 1884 | - * @return IniGetWrapper | |
| 1885 | - */ | |
| 1886 | -	public function getIniWrapper() { | |
| 1887 | -		return $this->query('IniWrapper'); | |
| 1888 | - } | |
| 1889 | - | |
| 1890 | - /** | |
| 1891 | - * @return \OCP\Command\IBus | |
| 1892 | - */ | |
| 1893 | -	public function getCommandBus() { | |
| 1894 | -		return $this->query('AsyncCommandBus'); | |
| 1895 | - } | |
| 1896 | - | |
| 1897 | - /** | |
| 1898 | - * Get the trusted domain helper | |
| 1899 | - * | |
| 1900 | - * @return TrustedDomainHelper | |
| 1901 | - */ | |
| 1902 | -	public function getTrustedDomainHelper() { | |
| 1903 | -		return $this->query('TrustedDomainHelper'); | |
| 1904 | - } | |
| 1905 | - | |
| 1906 | - /** | |
| 1907 | - * Get the locking provider | |
| 1908 | - * | |
| 1909 | - * @return \OCP\Lock\ILockingProvider | |
| 1910 | - * @since 8.1.0 | |
| 1911 | - */ | |
| 1912 | -	public function getLockingProvider() { | |
| 1913 | -		return $this->query('LockingProvider'); | |
| 1914 | - } | |
| 1915 | - | |
| 1916 | - /** | |
| 1917 | - * @return \OCP\Files\Mount\IMountManager | |
| 1918 | - **/ | |
| 1919 | -	function getMountManager() { | |
| 1920 | -		return $this->query('MountManager'); | |
| 1921 | - } | |
| 1922 | - | |
| 1923 | - /** @return \OCP\Files\Config\IUserMountCache */ | |
| 1924 | -	function getUserMountCache() { | |
| 1925 | -		return $this->query('UserMountCache'); | |
| 1926 | - } | |
| 1927 | - | |
| 1928 | - /** | |
| 1929 | - * Get the MimeTypeDetector | |
| 1930 | - * | |
| 1931 | - * @return \OCP\Files\IMimeTypeDetector | |
| 1932 | - */ | |
| 1933 | -	public function getMimeTypeDetector() { | |
| 1934 | -		return $this->query('MimeTypeDetector'); | |
| 1935 | - } | |
| 1936 | - | |
| 1937 | - /** | |
| 1938 | - * Get the MimeTypeLoader | |
| 1939 | - * | |
| 1940 | - * @return \OCP\Files\IMimeTypeLoader | |
| 1941 | - */ | |
| 1942 | -	public function getMimeTypeLoader() { | |
| 1943 | -		return $this->query('MimeTypeLoader'); | |
| 1944 | - } | |
| 1945 | - | |
| 1946 | - /** | |
| 1947 | - * Get the manager of all the capabilities | |
| 1948 | - * | |
| 1949 | - * @return \OC\CapabilitiesManager | |
| 1950 | - */ | |
| 1951 | -	public function getCapabilitiesManager() { | |
| 1952 | -		return $this->query('CapabilitiesManager'); | |
| 1953 | - } | |
| 1954 | - | |
| 1955 | - /** | |
| 1956 | - * Get the EventDispatcher | |
| 1957 | - * | |
| 1958 | - * @return EventDispatcherInterface | |
| 1959 | - * @since 8.2.0 | |
| 1960 | - * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher | |
| 1961 | - */ | |
| 1962 | -	public function getEventDispatcher() { | |
| 1963 | - return $this->query(\OC\EventDispatcher\SymfonyAdapter::class); | |
| 1964 | - } | |
| 1965 | - | |
| 1966 | - /** | |
| 1967 | - * Get the Notification Manager | |
| 1968 | - * | |
| 1969 | - * @return \OCP\Notification\IManager | |
| 1970 | - * @since 8.2.0 | |
| 1971 | - */ | |
| 1972 | -	public function getNotificationManager() { | |
| 1973 | -		return $this->query('NotificationManager'); | |
| 1974 | - } | |
| 1975 | - | |
| 1976 | - /** | |
| 1977 | - * @return \OCP\Comments\ICommentsManager | |
| 1978 | - */ | |
| 1979 | -	public function getCommentsManager() { | |
| 1980 | -		return $this->query('CommentsManager'); | |
| 1981 | - } | |
| 1982 | - | |
| 1983 | - /** | |
| 1984 | - * @return \OCA\Theming\ThemingDefaults | |
| 1985 | - */ | |
| 1986 | -	public function getThemingDefaults() { | |
| 1987 | -		return $this->query('ThemingDefaults'); | |
| 1988 | - } | |
| 1989 | - | |
| 1990 | - /** | |
| 1991 | - * @return \OC\IntegrityCheck\Checker | |
| 1992 | - */ | |
| 1993 | -	public function getIntegrityCodeChecker() { | |
| 1994 | -		return $this->query('IntegrityCodeChecker'); | |
| 1995 | - } | |
| 1996 | - | |
| 1997 | - /** | |
| 1998 | - * @return \OC\Session\CryptoWrapper | |
| 1999 | - */ | |
| 2000 | -	public function getSessionCryptoWrapper() { | |
| 2001 | -		return $this->query('CryptoWrapper'); | |
| 2002 | - } | |
| 2003 | - | |
| 2004 | - /** | |
| 2005 | - * @return CsrfTokenManager | |
| 2006 | - */ | |
| 2007 | -	public function getCsrfTokenManager() { | |
| 2008 | - return $this->query(CsrfTokenManager::class); | |
| 2009 | - } | |
| 2010 | - | |
| 2011 | - /** | |
| 2012 | - * @return Throttler | |
| 2013 | - */ | |
| 2014 | -	public function getBruteForceThrottler() { | |
| 2015 | -		return $this->query('Throttler'); | |
| 2016 | - } | |
| 2017 | - | |
| 2018 | - /** | |
| 2019 | - * @return IContentSecurityPolicyManager | |
| 2020 | - */ | |
| 2021 | -	public function getContentSecurityPolicyManager() { | |
| 2022 | -		return $this->query('ContentSecurityPolicyManager'); | |
| 2023 | - } | |
| 2024 | - | |
| 2025 | - /** | |
| 2026 | - * @return ContentSecurityPolicyNonceManager | |
| 2027 | - */ | |
| 2028 | -	public function getContentSecurityPolicyNonceManager() { | |
| 2029 | -		return $this->query('ContentSecurityPolicyNonceManager'); | |
| 2030 | - } | |
| 2031 | - | |
| 2032 | - /** | |
| 2033 | - * Not a public API as of 8.2, wait for 9.0 | |
| 2034 | - * | |
| 2035 | - * @return \OCA\Files_External\Service\BackendService | |
| 2036 | - */ | |
| 2037 | -	public function getStoragesBackendService() { | |
| 2038 | -		return $this->query('OCA\\Files_External\\Service\\BackendService'); | |
| 2039 | - } | |
| 2040 | - | |
| 2041 | - /** | |
| 2042 | - * Not a public API as of 8.2, wait for 9.0 | |
| 2043 | - * | |
| 2044 | - * @return \OCA\Files_External\Service\GlobalStoragesService | |
| 2045 | - */ | |
| 2046 | -	public function getGlobalStoragesService() { | |
| 2047 | -		return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); | |
| 2048 | - } | |
| 2049 | - | |
| 2050 | - /** | |
| 2051 | - * Not a public API as of 8.2, wait for 9.0 | |
| 2052 | - * | |
| 2053 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService | |
| 2054 | - */ | |
| 2055 | -	public function getUserGlobalStoragesService() { | |
| 2056 | -		return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); | |
| 2057 | - } | |
| 2058 | - | |
| 2059 | - /** | |
| 2060 | - * Not a public API as of 8.2, wait for 9.0 | |
| 2061 | - * | |
| 2062 | - * @return \OCA\Files_External\Service\UserStoragesService | |
| 2063 | - */ | |
| 2064 | -	public function getUserStoragesService() { | |
| 2065 | -		return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); | |
| 2066 | - } | |
| 2067 | - | |
| 2068 | - /** | |
| 2069 | - * @return \OCP\Share\IManager | |
| 2070 | - */ | |
| 2071 | -	public function getShareManager() { | |
| 2072 | -		return $this->query('ShareManager'); | |
| 2073 | - } | |
| 2074 | - | |
| 2075 | - /** | |
| 2076 | - * @return \OCP\Collaboration\Collaborators\ISearch | |
| 2077 | - */ | |
| 2078 | -	public function getCollaboratorSearch() { | |
| 2079 | -		return $this->query('CollaboratorSearch'); | |
| 2080 | - } | |
| 2081 | - | |
| 2082 | - /** | |
| 2083 | - * @return \OCP\Collaboration\AutoComplete\IManager | |
| 2084 | - */ | |
| 2085 | -	public function getAutoCompleteManager(){ | |
| 2086 | - return $this->query(IManager::class); | |
| 2087 | - } | |
| 2088 | - | |
| 2089 | - /** | |
| 2090 | - * Returns the LDAP Provider | |
| 2091 | - * | |
| 2092 | - * @return \OCP\LDAP\ILDAPProvider | |
| 2093 | - */ | |
| 2094 | -	public function getLDAPProvider() { | |
| 2095 | -		return $this->query('LDAPProvider'); | |
| 2096 | - } | |
| 2097 | - | |
| 2098 | - /** | |
| 2099 | - * @return \OCP\Settings\IManager | |
| 2100 | - */ | |
| 2101 | -	public function getSettingsManager() { | |
| 2102 | -		return $this->query('SettingsManager'); | |
| 2103 | - } | |
| 2104 | - | |
| 2105 | - /** | |
| 2106 | - * @return \OCP\Files\IAppData | |
| 2107 | - */ | |
| 2108 | -	public function getAppDataDir($app) { | |
| 2109 | - /** @var \OC\Files\AppData\Factory $factory */ | |
| 2110 | - $factory = $this->query(\OC\Files\AppData\Factory::class); | |
| 2111 | - return $factory->get($app); | |
| 2112 | - } | |
| 2113 | - | |
| 2114 | - /** | |
| 2115 | - * @return \OCP\Lockdown\ILockdownManager | |
| 2116 | - */ | |
| 2117 | -	public function getLockdownManager() { | |
| 2118 | -		return $this->query('LockdownManager'); | |
| 2119 | - } | |
| 2120 | - | |
| 2121 | - /** | |
| 2122 | - * @return \OCP\Federation\ICloudIdManager | |
| 2123 | - */ | |
| 2124 | -	public function getCloudIdManager() { | |
| 2125 | - return $this->query(ICloudIdManager::class); | |
| 2126 | - } | |
| 2127 | - | |
| 2128 | - /** | |
| 2129 | - * @return \OCP\GlobalScale\IConfig | |
| 2130 | - */ | |
| 2131 | -	public function getGlobalScaleConfig() { | |
| 2132 | - return $this->query(IConfig::class); | |
| 2133 | - } | |
| 2134 | - | |
| 2135 | - /** | |
| 2136 | - * @return \OCP\Federation\ICloudFederationProviderManager | |
| 2137 | - */ | |
| 2138 | -	public function getCloudFederationProviderManager() { | |
| 2139 | - return $this->query(ICloudFederationProviderManager::class); | |
| 2140 | - } | |
| 2141 | - | |
| 2142 | - /** | |
| 2143 | - * @return \OCP\Remote\Api\IApiFactory | |
| 2144 | - */ | |
| 2145 | -	public function getRemoteApiFactory() { | |
| 2146 | - return $this->query(IApiFactory::class); | |
| 2147 | - } | |
| 2148 | - | |
| 2149 | - /** | |
| 2150 | - * @return \OCP\Federation\ICloudFederationFactory | |
| 2151 | - */ | |
| 2152 | -	public function getCloudFederationFactory() { | |
| 2153 | - return $this->query(ICloudFederationFactory::class); | |
| 2154 | - } | |
| 2155 | - | |
| 2156 | - /** | |
| 2157 | - * @return \OCP\Remote\IInstanceFactory | |
| 2158 | - */ | |
| 2159 | -	public function getRemoteInstanceFactory() { | |
| 2160 | - return $this->query(IInstanceFactory::class); | |
| 2161 | - } | |
| 2162 | - | |
| 2163 | - /** | |
| 2164 | - * @return IStorageFactory | |
| 2165 | - */ | |
| 2166 | -	public function getStorageFactory() { | |
| 2167 | - return $this->query(IStorageFactory::class); | |
| 2168 | - } | |
| 2169 | - | |
| 2170 | - /** | |
| 2171 | - * Get the Preview GeneratorHelper | |
| 2172 | - * | |
| 2173 | - * @return GeneratorHelper | |
| 2174 | - * @since 17.0.0 | |
| 2175 | - */ | |
| 2176 | -	public function getGeneratorHelper() { | |
| 2177 | - return $this->query(\OC\Preview\GeneratorHelper::class); | |
| 2178 | - } | |
| 1059 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); | |
| 1060 | +            if (isset($prefixes['OCA\\Theming\\'])) { | |
| 1061 | + $classExists = true; | |
| 1062 | +            } else { | |
| 1063 | + $classExists = false; | |
| 1064 | + } | |
| 1065 | + | |
| 1066 | +            if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { | |
| 1067 | + return new ThemingDefaults( | |
| 1068 | + $c->getConfig(), | |
| 1069 | +                    $c->getL10N('theming'), | |
| 1070 | + $c->getURLGenerator(), | |
| 1071 | + $c->getMemCacheFactory(), | |
| 1072 | +                    new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), | |
| 1073 | +                    new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()), | |
| 1074 | + $c->getAppManager(), | |
| 1075 | + $c->getNavigationManager() | |
| 1076 | + ); | |
| 1077 | + } | |
| 1078 | + return new \OC_Defaults(); | |
| 1079 | + }); | |
| 1080 | +        $this->registerService(SCSSCacher::class, function (Server $c) { | |
| 1081 | + return new SCSSCacher( | |
| 1082 | + $c->getLogger(), | |
| 1083 | + $c->query(\OC\Files\AppData\Factory::class), | |
| 1084 | + $c->getURLGenerator(), | |
| 1085 | + $c->getConfig(), | |
| 1086 | + $c->getThemingDefaults(), | |
| 1087 | + \OC::$SERVERROOT, | |
| 1088 | + $this->getMemCacheFactory(), | |
| 1089 | + $c->query(IconsCacher::class), | |
| 1090 | + new TimeFactory() | |
| 1091 | + ); | |
| 1092 | + }); | |
| 1093 | +        $this->registerService(JSCombiner::class, function (Server $c) { | |
| 1094 | + return new JSCombiner( | |
| 1095 | +                $c->getAppDataDir('js'), | |
| 1096 | + $c->getURLGenerator(), | |
| 1097 | + $this->getMemCacheFactory(), | |
| 1098 | + $c->getSystemConfig(), | |
| 1099 | + $c->getLogger() | |
| 1100 | + ); | |
| 1101 | + }); | |
| 1102 | + $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class); | |
| 1103 | +        $this->registerAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class); | |
| 1104 | + $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class); | |
| 1105 | + | |
| 1106 | +        $this->registerService('CryptoWrapper', function (Server $c) { | |
| 1107 | + // FIXME: Instantiiated here due to cyclic dependency | |
| 1108 | + $request = new Request( | |
| 1109 | + [ | |
| 1110 | + 'get' => $_GET, | |
| 1111 | + 'post' => $_POST, | |
| 1112 | + 'files' => $_FILES, | |
| 1113 | + 'server' => $_SERVER, | |
| 1114 | + 'env' => $_ENV, | |
| 1115 | + 'cookies' => $_COOKIE, | |
| 1116 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) | |
| 1117 | + ? $_SERVER['REQUEST_METHOD'] | |
| 1118 | + : null, | |
| 1119 | + ], | |
| 1120 | + $c->getSecureRandom(), | |
| 1121 | + $c->getConfig() | |
| 1122 | + ); | |
| 1123 | + | |
| 1124 | + return new CryptoWrapper( | |
| 1125 | + $c->getConfig(), | |
| 1126 | + $c->getCrypto(), | |
| 1127 | + $c->getSecureRandom(), | |
| 1128 | + $request | |
| 1129 | + ); | |
| 1130 | + }); | |
| 1131 | +        $this->registerService(CsrfTokenManager::class, function (Server $c) { | |
| 1132 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); | |
| 1133 | + | |
| 1134 | + return new CsrfTokenManager( | |
| 1135 | + $tokenGenerator, | |
| 1136 | + $c->query(SessionStorage::class) | |
| 1137 | + ); | |
| 1138 | + }); | |
| 1139 | +        $this->registerAlias('CsrfTokenManager', CsrfTokenManager::class); | |
| 1140 | +        $this->registerService(SessionStorage::class, function (Server $c) { | |
| 1141 | + return new SessionStorage($c->getSession()); | |
| 1142 | + }); | |
| 1143 | + $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, \OC\Security\CSP\ContentSecurityPolicyManager::class); | |
| 1144 | +        $this->registerAlias('ContentSecurityPolicyManager', \OC\Security\CSP\ContentSecurityPolicyManager::class); | |
| 1145 | + | |
| 1146 | +        $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { | |
| 1147 | + return new ContentSecurityPolicyNonceManager( | |
| 1148 | + $c->getCsrfTokenManager(), | |
| 1149 | + $c->getRequest() | |
| 1150 | + ); | |
| 1151 | + }); | |
| 1152 | + | |
| 1153 | +        $this->registerService(\OCP\Share\IManager::class, function (Server $c) { | |
| 1154 | + $config = $c->getConfig(); | |
| 1155 | +            $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); | |
| 1156 | + /** @var \OCP\Share\IProviderFactory $factory */ | |
| 1157 | + $factory = new $factoryClass($this); | |
| 1158 | + | |
| 1159 | + $manager = new \OC\Share20\Manager( | |
| 1160 | + $c->getLogger(), | |
| 1161 | + $c->getConfig(), | |
| 1162 | + $c->getSecureRandom(), | |
| 1163 | + $c->getHasher(), | |
| 1164 | + $c->getMountManager(), | |
| 1165 | + $c->getGroupManager(), | |
| 1166 | +                $c->getL10N('lib'), | |
| 1167 | + $c->getL10NFactory(), | |
| 1168 | + $factory, | |
| 1169 | + $c->getUserManager(), | |
| 1170 | + $c->getLazyRootFolder(), | |
| 1171 | + $c->getEventDispatcher(), | |
| 1172 | + $c->getMailer(), | |
| 1173 | + $c->getURLGenerator(), | |
| 1174 | + $c->getThemingDefaults(), | |
| 1175 | + $c->query(IEventDispatcher::class) | |
| 1176 | + ); | |
| 1177 | + | |
| 1178 | + return $manager; | |
| 1179 | + }); | |
| 1180 | +        $this->registerAlias('ShareManager', \OCP\Share\IManager::class); | |
| 1181 | + | |
| 1182 | +        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { | |
| 1183 | + $instance = new Collaboration\Collaborators\Search($c); | |
| 1184 | + | |
| 1185 | + // register default plugins | |
| 1186 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); | |
| 1187 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); | |
| 1188 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); | |
| 1189 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); | |
| 1190 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]); | |
| 1191 | + | |
| 1192 | + return $instance; | |
| 1193 | + }); | |
| 1194 | +        $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); | |
| 1195 | + $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class); | |
| 1196 | + | |
| 1197 | + $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); | |
| 1198 | + | |
| 1199 | + $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class); | |
| 1200 | + $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class); | |
| 1201 | + | |
| 1202 | +        $this->registerService('SettingsManager', function (Server $c) { | |
| 1203 | + $manager = new \OC\Settings\Manager( | |
| 1204 | + $c->getLogger(), | |
| 1205 | + $c->getL10NFactory(), | |
| 1206 | + $c->getURLGenerator(), | |
| 1207 | + $c | |
| 1208 | + ); | |
| 1209 | + return $manager; | |
| 1210 | + }); | |
| 1211 | +        $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { | |
| 1212 | + return new \OC\Files\AppData\Factory( | |
| 1213 | + $c->getRootFolder(), | |
| 1214 | + $c->getSystemConfig() | |
| 1215 | + ); | |
| 1216 | + }); | |
| 1217 | + | |
| 1218 | +        $this->registerService('LockdownManager', function (Server $c) { | |
| 1219 | +            return new LockdownManager(function () use ($c) { | |
| 1220 | + return $c->getSession(); | |
| 1221 | + }); | |
| 1222 | + }); | |
| 1223 | + | |
| 1224 | +        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { | |
| 1225 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); | |
| 1226 | + }); | |
| 1227 | + | |
| 1228 | +        $this->registerService(ICloudIdManager::class, function (Server $c) { | |
| 1229 | + return new CloudIdManager(); | |
| 1230 | + }); | |
| 1231 | + | |
| 1232 | +        $this->registerService(IConfig::class, function (Server $c) { | |
| 1233 | + return new GlobalScale\Config($c->getConfig()); | |
| 1234 | + }); | |
| 1235 | + | |
| 1236 | +        $this->registerService(ICloudFederationProviderManager::class, function (Server $c) { | |
| 1237 | + return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger()); | |
| 1238 | + }); | |
| 1239 | + | |
| 1240 | +        $this->registerService(ICloudFederationFactory::class, function (Server $c) { | |
| 1241 | + return new CloudFederationFactory(); | |
| 1242 | + }); | |
| 1243 | + | |
| 1244 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); | |
| 1245 | +        $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); | |
| 1246 | + | |
| 1247 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); | |
| 1248 | +        $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); | |
| 1249 | + | |
| 1250 | +        $this->registerService(Defaults::class, function (Server $c) { | |
| 1251 | + return new Defaults( | |
| 1252 | + $c->getThemingDefaults() | |
| 1253 | + ); | |
| 1254 | + }); | |
| 1255 | +        $this->registerAlias('Defaults', \OCP\Defaults::class); | |
| 1256 | + | |
| 1257 | +        $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { | |
| 1258 | + return $c->query(\OCP\IUserSession::class)->getSession(); | |
| 1259 | + }); | |
| 1260 | + | |
| 1261 | +        $this->registerService(IShareHelper::class, function (Server $c) { | |
| 1262 | + return new ShareHelper( | |
| 1263 | + $c->query(\OCP\Share\IManager::class) | |
| 1264 | + ); | |
| 1265 | + }); | |
| 1266 | + | |
| 1267 | +        $this->registerService(Installer::class, function(Server $c) { | |
| 1268 | + return new Installer( | |
| 1269 | + $c->getAppFetcher(), | |
| 1270 | + $c->getHTTPClientService(), | |
| 1271 | + $c->getTempManager(), | |
| 1272 | + $c->getLogger(), | |
| 1273 | + $c->getConfig() | |
| 1274 | + ); | |
| 1275 | + }); | |
| 1276 | + | |
| 1277 | +        $this->registerService(IApiFactory::class, function(Server $c) { | |
| 1278 | + return new ApiFactory($c->getHTTPClientService()); | |
| 1279 | + }); | |
| 1280 | + | |
| 1281 | +        $this->registerService(IInstanceFactory::class, function(Server $c) { | |
| 1282 | + $memcacheFactory = $c->getMemCacheFactory(); | |
| 1283 | +            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); | |
| 1284 | + }); | |
| 1285 | + | |
| 1286 | +        $this->registerService(IContactsStore::class, function(Server $c) { | |
| 1287 | + return new ContactsStore( | |
| 1288 | + $c->getContactsManager(), | |
| 1289 | + $c->getConfig(), | |
| 1290 | + $c->getUserManager(), | |
| 1291 | + $c->getGroupManager() | |
| 1292 | + ); | |
| 1293 | + }); | |
| 1294 | + $this->registerAlias(IContactsStore::class, ContactsStore::class); | |
| 1295 | + $this->registerAlias(IAccountManager::class, AccountManager::class); | |
| 1296 | + | |
| 1297 | +        $this->registerService(IStorageFactory::class, function() { | |
| 1298 | + return new StorageFactory(); | |
| 1299 | + }); | |
| 1300 | + | |
| 1301 | + $this->registerAlias(IDashboardManager::class, DashboardManager::class); | |
| 1302 | + $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); | |
| 1303 | + | |
| 1304 | + $this->registerAlias(ISubAdmin::class, SubAdmin::class); | |
| 1305 | + | |
| 1306 | + $this->registerAlias(IInitialStateService::class, InitialStateService::class); | |
| 1307 | + | |
| 1308 | + $this->connectDispatcher(); | |
| 1309 | + } | |
| 1310 | + | |
| 1311 | + /** | |
| 1312 | + * @return \OCP\Calendar\IManager | |
| 1313 | + */ | |
| 1314 | +    public function getCalendarManager() { | |
| 1315 | +        return $this->query('CalendarManager'); | |
| 1316 | + } | |
| 1317 | + | |
| 1318 | + /** | |
| 1319 | + * @return \OCP\Calendar\Resource\IManager | |
| 1320 | + */ | |
| 1321 | +    public function getCalendarResourceBackendManager() { | |
| 1322 | +        return $this->query('CalendarResourceBackendManager'); | |
| 1323 | + } | |
| 1324 | + | |
| 1325 | + /** | |
| 1326 | + * @return \OCP\Calendar\Room\IManager | |
| 1327 | + */ | |
| 1328 | +    public function getCalendarRoomBackendManager() { | |
| 1329 | +        return $this->query('CalendarRoomBackendManager'); | |
| 1330 | + } | |
| 1331 | + | |
| 1332 | +    private function connectDispatcher() { | |
| 1333 | + $dispatcher = $this->getEventDispatcher(); | |
| 1334 | + | |
| 1335 | + // Delete avatar on user deletion | |
| 1336 | +        $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { | |
| 1337 | + $logger = $this->getLogger(); | |
| 1338 | + $manager = $this->getAvatarManager(); | |
| 1339 | + /** @var IUser $user */ | |
| 1340 | + $user = $e->getSubject(); | |
| 1341 | + | |
| 1342 | +            try { | |
| 1343 | + $avatar = $manager->getAvatar($user->getUID()); | |
| 1344 | + $avatar->remove(); | |
| 1345 | +            } catch (NotFoundException $e) { | |
| 1346 | + // no avatar to remove | |
| 1347 | +            } catch (\Exception $e) { | |
| 1348 | + // Ignore exceptions | |
| 1349 | +                $logger->info('Could not cleanup avatar of ' . $user->getUID()); | |
| 1350 | + } | |
| 1351 | + }); | |
| 1352 | + | |
| 1353 | +        $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { | |
| 1354 | + $manager = $this->getAvatarManager(); | |
| 1355 | + /** @var IUser $user */ | |
| 1356 | + $user = $e->getSubject(); | |
| 1357 | +            $feature = $e->getArgument('feature'); | |
| 1358 | +            $oldValue = $e->getArgument('oldValue'); | |
| 1359 | +            $value = $e->getArgument('value'); | |
| 1360 | + | |
| 1361 | + // We only change the avatar on display name changes | |
| 1362 | +            if ($feature !== 'displayName') { | |
| 1363 | + return; | |
| 1364 | + } | |
| 1365 | + | |
| 1366 | +            try { | |
| 1367 | + $avatar = $manager->getAvatar($user->getUID()); | |
| 1368 | + $avatar->userChanged($feature, $oldValue, $value); | |
| 1369 | +            } catch (NotFoundException $e) { | |
| 1370 | + // no avatar to remove | |
| 1371 | + } | |
| 1372 | + }); | |
| 1373 | + } | |
| 1374 | + | |
| 1375 | + /** | |
| 1376 | + * @return \OCP\Contacts\IManager | |
| 1377 | + */ | |
| 1378 | +    public function getContactsManager() { | |
| 1379 | +        return $this->query('ContactsManager'); | |
| 1380 | + } | |
| 1381 | + | |
| 1382 | + /** | |
| 1383 | + * @return \OC\Encryption\Manager | |
| 1384 | + */ | |
| 1385 | +    public function getEncryptionManager() { | |
| 1386 | +        return $this->query('EncryptionManager'); | |
| 1387 | + } | |
| 1388 | + | |
| 1389 | + /** | |
| 1390 | + * @return \OC\Encryption\File | |
| 1391 | + */ | |
| 1392 | +    public function getEncryptionFilesHelper() { | |
| 1393 | +        return $this->query('EncryptionFileHelper'); | |
| 1394 | + } | |
| 1395 | + | |
| 1396 | + /** | |
| 1397 | + * @return \OCP\Encryption\Keys\IStorage | |
| 1398 | + */ | |
| 1399 | +    public function getEncryptionKeyStorage() { | |
| 1400 | +        return $this->query('EncryptionKeyStorage'); | |
| 1401 | + } | |
| 1402 | + | |
| 1403 | + /** | |
| 1404 | + * The current request object holding all information about the request | |
| 1405 | + * currently being processed is returned from this method. | |
| 1406 | + * In case the current execution was not initiated by a web request null is returned | |
| 1407 | + * | |
| 1408 | + * @return \OCP\IRequest | |
| 1409 | + */ | |
| 1410 | +    public function getRequest() { | |
| 1411 | +        return $this->query('Request'); | |
| 1412 | + } | |
| 1413 | + | |
| 1414 | + /** | |
| 1415 | + * Returns the preview manager which can create preview images for a given file | |
| 1416 | + * | |
| 1417 | + * @return \OCP\IPreview | |
| 1418 | + */ | |
| 1419 | +    public function getPreviewManager() { | |
| 1420 | +        return $this->query('PreviewManager'); | |
| 1421 | + } | |
| 1422 | + | |
| 1423 | + /** | |
| 1424 | + * Returns the tag manager which can get and set tags for different object types | |
| 1425 | + * | |
| 1426 | + * @see \OCP\ITagManager::load() | |
| 1427 | + * @return \OCP\ITagManager | |
| 1428 | + */ | |
| 1429 | +    public function getTagManager() { | |
| 1430 | +        return $this->query('TagManager'); | |
| 1431 | + } | |
| 1432 | + | |
| 1433 | + /** | |
| 1434 | + * Returns the system-tag manager | |
| 1435 | + * | |
| 1436 | + * @return \OCP\SystemTag\ISystemTagManager | |
| 1437 | + * | |
| 1438 | + * @since 9.0.0 | |
| 1439 | + */ | |
| 1440 | +    public function getSystemTagManager() { | |
| 1441 | +        return $this->query('SystemTagManager'); | |
| 1442 | + } | |
| 1443 | + | |
| 1444 | + /** | |
| 1445 | + * Returns the system-tag object mapper | |
| 1446 | + * | |
| 1447 | + * @return \OCP\SystemTag\ISystemTagObjectMapper | |
| 1448 | + * | |
| 1449 | + * @since 9.0.0 | |
| 1450 | + */ | |
| 1451 | +    public function getSystemTagObjectMapper() { | |
| 1452 | +        return $this->query('SystemTagObjectMapper'); | |
| 1453 | + } | |
| 1454 | + | |
| 1455 | + /** | |
| 1456 | + * Returns the avatar manager, used for avatar functionality | |
| 1457 | + * | |
| 1458 | + * @return \OCP\IAvatarManager | |
| 1459 | + */ | |
| 1460 | +    public function getAvatarManager() { | |
| 1461 | +        return $this->query('AvatarManager'); | |
| 1462 | + } | |
| 1463 | + | |
| 1464 | + /** | |
| 1465 | + * Returns the root folder of ownCloud's data directory | |
| 1466 | + * | |
| 1467 | + * @return \OCP\Files\IRootFolder | |
| 1468 | + */ | |
| 1469 | +    public function getRootFolder() { | |
| 1470 | +        return $this->query('LazyRootFolder'); | |
| 1471 | + } | |
| 1472 | + | |
| 1473 | + /** | |
| 1474 | + * Returns the root folder of ownCloud's data directory | |
| 1475 | + * This is the lazy variant so this gets only initialized once it | |
| 1476 | + * is actually used. | |
| 1477 | + * | |
| 1478 | + * @return \OCP\Files\IRootFolder | |
| 1479 | + */ | |
| 1480 | +    public function getLazyRootFolder() { | |
| 1481 | +        return $this->query('LazyRootFolder'); | |
| 1482 | + } | |
| 1483 | + | |
| 1484 | + /** | |
| 1485 | + * Returns a view to ownCloud's files folder | |
| 1486 | + * | |
| 1487 | + * @param string $userId user ID | |
| 1488 | + * @return \OCP\Files\Folder|null | |
| 1489 | + */ | |
| 1490 | +    public function getUserFolder($userId = null) { | |
| 1491 | +        if ($userId === null) { | |
| 1492 | + $user = $this->getUserSession()->getUser(); | |
| 1493 | +            if (!$user) { | |
| 1494 | + return null; | |
| 1495 | + } | |
| 1496 | + $userId = $user->getUID(); | |
| 1497 | + } | |
| 1498 | + $root = $this->getRootFolder(); | |
| 1499 | + return $root->getUserFolder($userId); | |
| 1500 | + } | |
| 1501 | + | |
| 1502 | + /** | |
| 1503 | + * Returns an app-specific view in ownClouds data directory | |
| 1504 | + * | |
| 1505 | + * @return \OCP\Files\Folder | |
| 1506 | + * @deprecated since 9.2.0 use IAppData | |
| 1507 | + */ | |
| 1508 | +    public function getAppFolder() { | |
| 1509 | + $dir = '/' . \OC_App::getCurrentApp(); | |
| 1510 | + $root = $this->getRootFolder(); | |
| 1511 | +        if (!$root->nodeExists($dir)) { | |
| 1512 | + $folder = $root->newFolder($dir); | |
| 1513 | +        } else { | |
| 1514 | + $folder = $root->get($dir); | |
| 1515 | + } | |
| 1516 | + return $folder; | |
| 1517 | + } | |
| 1518 | + | |
| 1519 | + /** | |
| 1520 | + * @return \OC\User\Manager | |
| 1521 | + */ | |
| 1522 | +    public function getUserManager() { | |
| 1523 | +        return $this->query('UserManager'); | |
| 1524 | + } | |
| 1525 | + | |
| 1526 | + /** | |
| 1527 | + * @return \OC\Group\Manager | |
| 1528 | + */ | |
| 1529 | +    public function getGroupManager() { | |
| 1530 | +        return $this->query('GroupManager'); | |
| 1531 | + } | |
| 1532 | + | |
| 1533 | + /** | |
| 1534 | + * @return \OC\User\Session | |
| 1535 | + */ | |
| 1536 | +    public function getUserSession() { | |
| 1537 | +        return $this->query('UserSession'); | |
| 1538 | + } | |
| 1539 | + | |
| 1540 | + /** | |
| 1541 | + * @return \OCP\ISession | |
| 1542 | + */ | |
| 1543 | +    public function getSession() { | |
| 1544 | +        return $this->query('UserSession')->getSession(); | |
| 1545 | + } | |
| 1546 | + | |
| 1547 | + /** | |
| 1548 | + * @param \OCP\ISession $session | |
| 1549 | + */ | |
| 1550 | +    public function setSession(\OCP\ISession $session) { | |
| 1551 | + $this->query(SessionStorage::class)->setSession($session); | |
| 1552 | +        $this->query('UserSession')->setSession($session); | |
| 1553 | + $this->query(Store::class)->setSession($session); | |
| 1554 | + } | |
| 1555 | + | |
| 1556 | + /** | |
| 1557 | + * @return \OC\Authentication\TwoFactorAuth\Manager | |
| 1558 | + */ | |
| 1559 | +    public function getTwoFactorAuthManager() { | |
| 1560 | +        return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); | |
| 1561 | + } | |
| 1562 | + | |
| 1563 | + /** | |
| 1564 | + * @return \OC\NavigationManager | |
| 1565 | + */ | |
| 1566 | +    public function getNavigationManager() { | |
| 1567 | +        return $this->query('NavigationManager'); | |
| 1568 | + } | |
| 1569 | + | |
| 1570 | + /** | |
| 1571 | + * @return \OCP\IConfig | |
| 1572 | + */ | |
| 1573 | +    public function getConfig() { | |
| 1574 | +        return $this->query('AllConfig'); | |
| 1575 | + } | |
| 1576 | + | |
| 1577 | + /** | |
| 1578 | + * @return \OC\SystemConfig | |
| 1579 | + */ | |
| 1580 | +    public function getSystemConfig() { | |
| 1581 | +        return $this->query('SystemConfig'); | |
| 1582 | + } | |
| 1583 | + | |
| 1584 | + /** | |
| 1585 | + * Returns the app config manager | |
| 1586 | + * | |
| 1587 | + * @return \OCP\IAppConfig | |
| 1588 | + */ | |
| 1589 | +    public function getAppConfig() { | |
| 1590 | +        return $this->query('AppConfig'); | |
| 1591 | + } | |
| 1592 | + | |
| 1593 | + /** | |
| 1594 | + * @return \OCP\L10N\IFactory | |
| 1595 | + */ | |
| 1596 | +    public function getL10NFactory() { | |
| 1597 | +        return $this->query('L10NFactory'); | |
| 1598 | + } | |
| 1599 | + | |
| 1600 | + /** | |
| 1601 | + * get an L10N instance | |
| 1602 | + * | |
| 1603 | + * @param string $app appid | |
| 1604 | + * @param string $lang | |
| 1605 | + * @return IL10N | |
| 1606 | + */ | |
| 1607 | +    public function getL10N($app, $lang = null) { | |
| 1608 | + return $this->getL10NFactory()->get($app, $lang); | |
| 1609 | + } | |
| 1610 | + | |
| 1611 | + /** | |
| 1612 | + * @return \OCP\IURLGenerator | |
| 1613 | + */ | |
| 1614 | +    public function getURLGenerator() { | |
| 1615 | +        return $this->query('URLGenerator'); | |
| 1616 | + } | |
| 1617 | + | |
| 1618 | + /** | |
| 1619 | + * @return AppFetcher | |
| 1620 | + */ | |
| 1621 | +    public function getAppFetcher() { | |
| 1622 | + return $this->query(AppFetcher::class); | |
| 1623 | + } | |
| 1624 | + | |
| 1625 | + /** | |
| 1626 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use | |
| 1627 | + * getMemCacheFactory() instead. | |
| 1628 | + * | |
| 1629 | + * @return \OCP\ICache | |
| 1630 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache | |
| 1631 | + */ | |
| 1632 | +    public function getCache() { | |
| 1633 | +        return $this->query('UserCache'); | |
| 1634 | + } | |
| 1635 | + | |
| 1636 | + /** | |
| 1637 | + * Returns an \OCP\CacheFactory instance | |
| 1638 | + * | |
| 1639 | + * @return \OCP\ICacheFactory | |
| 1640 | + */ | |
| 1641 | +    public function getMemCacheFactory() { | |
| 1642 | +        return $this->query('MemCacheFactory'); | |
| 1643 | + } | |
| 1644 | + | |
| 1645 | + /** | |
| 1646 | + * Returns an \OC\RedisFactory instance | |
| 1647 | + * | |
| 1648 | + * @return \OC\RedisFactory | |
| 1649 | + */ | |
| 1650 | +    public function getGetRedisFactory() { | |
| 1651 | +        return $this->query('RedisFactory'); | |
| 1652 | + } | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + /** | |
| 1656 | + * Returns the current session | |
| 1657 | + * | |
| 1658 | + * @return \OCP\IDBConnection | |
| 1659 | + */ | |
| 1660 | +    public function getDatabaseConnection() { | |
| 1661 | +        return $this->query('DatabaseConnection'); | |
| 1662 | + } | |
| 1663 | + | |
| 1664 | + /** | |
| 1665 | + * Returns the activity manager | |
| 1666 | + * | |
| 1667 | + * @return \OCP\Activity\IManager | |
| 1668 | + */ | |
| 1669 | +    public function getActivityManager() { | |
| 1670 | +        return $this->query('ActivityManager'); | |
| 1671 | + } | |
| 1672 | + | |
| 1673 | + /** | |
| 1674 | + * Returns an job list for controlling background jobs | |
| 1675 | + * | |
| 1676 | + * @return \OCP\BackgroundJob\IJobList | |
| 1677 | + */ | |
| 1678 | +    public function getJobList() { | |
| 1679 | +        return $this->query('JobList'); | |
| 1680 | + } | |
| 1681 | + | |
| 1682 | + /** | |
| 1683 | + * Returns a logger instance | |
| 1684 | + * | |
| 1685 | + * @return \OCP\ILogger | |
| 1686 | + */ | |
| 1687 | +    public function getLogger() { | |
| 1688 | +        return $this->query('Logger'); | |
| 1689 | + } | |
| 1690 | + | |
| 1691 | + /** | |
| 1692 | + * @return ILogFactory | |
| 1693 | + * @throws \OCP\AppFramework\QueryException | |
| 1694 | + */ | |
| 1695 | +    public function getLogFactory() { | |
| 1696 | + return $this->query(ILogFactory::class); | |
| 1697 | + } | |
| 1698 | + | |
| 1699 | + /** | |
| 1700 | + * Returns a router for generating and matching urls | |
| 1701 | + * | |
| 1702 | + * @return \OCP\Route\IRouter | |
| 1703 | + */ | |
| 1704 | +    public function getRouter() { | |
| 1705 | +        return $this->query('Router'); | |
| 1706 | + } | |
| 1707 | + | |
| 1708 | + /** | |
| 1709 | + * Returns a search instance | |
| 1710 | + * | |
| 1711 | + * @return \OCP\ISearch | |
| 1712 | + */ | |
| 1713 | +    public function getSearch() { | |
| 1714 | +        return $this->query('Search'); | |
| 1715 | + } | |
| 1716 | + | |
| 1717 | + /** | |
| 1718 | + * Returns a SecureRandom instance | |
| 1719 | + * | |
| 1720 | + * @return \OCP\Security\ISecureRandom | |
| 1721 | + */ | |
| 1722 | +    public function getSecureRandom() { | |
| 1723 | +        return $this->query('SecureRandom'); | |
| 1724 | + } | |
| 1725 | + | |
| 1726 | + /** | |
| 1727 | + * Returns a Crypto instance | |
| 1728 | + * | |
| 1729 | + * @return \OCP\Security\ICrypto | |
| 1730 | + */ | |
| 1731 | +    public function getCrypto() { | |
| 1732 | +        return $this->query('Crypto'); | |
| 1733 | + } | |
| 1734 | + | |
| 1735 | + /** | |
| 1736 | + * Returns a Hasher instance | |
| 1737 | + * | |
| 1738 | + * @return \OCP\Security\IHasher | |
| 1739 | + */ | |
| 1740 | +    public function getHasher() { | |
| 1741 | +        return $this->query('Hasher'); | |
| 1742 | + } | |
| 1743 | + | |
| 1744 | + /** | |
| 1745 | + * Returns a CredentialsManager instance | |
| 1746 | + * | |
| 1747 | + * @return \OCP\Security\ICredentialsManager | |
| 1748 | + */ | |
| 1749 | +    public function getCredentialsManager() { | |
| 1750 | +        return $this->query('CredentialsManager'); | |
| 1751 | + } | |
| 1752 | + | |
| 1753 | + /** | |
| 1754 | + * Get the certificate manager for the user | |
| 1755 | + * | |
| 1756 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager | |
| 1757 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in | |
| 1758 | + */ | |
| 1759 | +    public function getCertificateManager($userId = '') { | |
| 1760 | +        if ($userId === '') { | |
| 1761 | + $userSession = $this->getUserSession(); | |
| 1762 | + $user = $userSession->getUser(); | |
| 1763 | +            if (is_null($user)) { | |
| 1764 | + return null; | |
| 1765 | + } | |
| 1766 | + $userId = $user->getUID(); | |
| 1767 | + } | |
| 1768 | + return new CertificateManager( | |
| 1769 | + $userId, | |
| 1770 | + new View(), | |
| 1771 | + $this->getConfig(), | |
| 1772 | + $this->getLogger(), | |
| 1773 | + $this->getSecureRandom() | |
| 1774 | + ); | |
| 1775 | + } | |
| 1776 | + | |
| 1777 | + /** | |
| 1778 | + * Returns an instance of the HTTP client service | |
| 1779 | + * | |
| 1780 | + * @return \OCP\Http\Client\IClientService | |
| 1781 | + */ | |
| 1782 | +    public function getHTTPClientService() { | |
| 1783 | +        return $this->query('HttpClientService'); | |
| 1784 | + } | |
| 1785 | + | |
| 1786 | + /** | |
| 1787 | + * Create a new event source | |
| 1788 | + * | |
| 1789 | + * @return \OCP\IEventSource | |
| 1790 | + */ | |
| 1791 | +    public function createEventSource() { | |
| 1792 | + return new \OC_EventSource(); | |
| 1793 | + } | |
| 1794 | + | |
| 1795 | + /** | |
| 1796 | + * Get the active event logger | |
| 1797 | + * | |
| 1798 | + * The returned logger only logs data when debug mode is enabled | |
| 1799 | + * | |
| 1800 | + * @return \OCP\Diagnostics\IEventLogger | |
| 1801 | + */ | |
| 1802 | +    public function getEventLogger() { | |
| 1803 | +        return $this->query('EventLogger'); | |
| 1804 | + } | |
| 1805 | + | |
| 1806 | + /** | |
| 1807 | + * Get the active query logger | |
| 1808 | + * | |
| 1809 | + * The returned logger only logs data when debug mode is enabled | |
| 1810 | + * | |
| 1811 | + * @return \OCP\Diagnostics\IQueryLogger | |
| 1812 | + */ | |
| 1813 | +    public function getQueryLogger() { | |
| 1814 | +        return $this->query('QueryLogger'); | |
| 1815 | + } | |
| 1816 | + | |
| 1817 | + /** | |
| 1818 | + * Get the manager for temporary files and folders | |
| 1819 | + * | |
| 1820 | + * @return \OCP\ITempManager | |
| 1821 | + */ | |
| 1822 | +    public function getTempManager() { | |
| 1823 | +        return $this->query('TempManager'); | |
| 1824 | + } | |
| 1825 | + | |
| 1826 | + /** | |
| 1827 | + * Get the app manager | |
| 1828 | + * | |
| 1829 | + * @return \OCP\App\IAppManager | |
| 1830 | + */ | |
| 1831 | +    public function getAppManager() { | |
| 1832 | +        return $this->query('AppManager'); | |
| 1833 | + } | |
| 1834 | + | |
| 1835 | + /** | |
| 1836 | + * Creates a new mailer | |
| 1837 | + * | |
| 1838 | + * @return \OCP\Mail\IMailer | |
| 1839 | + */ | |
| 1840 | +    public function getMailer() { | |
| 1841 | +        return $this->query('Mailer'); | |
| 1842 | + } | |
| 1843 | + | |
| 1844 | + /** | |
| 1845 | + * Get the webroot | |
| 1846 | + * | |
| 1847 | + * @return string | |
| 1848 | + */ | |
| 1849 | +    public function getWebRoot() { | |
| 1850 | + return $this->webRoot; | |
| 1851 | + } | |
| 1852 | + | |
| 1853 | + /** | |
| 1854 | + * @return \OC\OCSClient | |
| 1855 | + */ | |
| 1856 | +    public function getOcsClient() { | |
| 1857 | +        return $this->query('OcsClient'); | |
| 1858 | + } | |
| 1859 | + | |
| 1860 | + /** | |
| 1861 | + * @return \OCP\IDateTimeZone | |
| 1862 | + */ | |
| 1863 | +    public function getDateTimeZone() { | |
| 1864 | +        return $this->query('DateTimeZone'); | |
| 1865 | + } | |
| 1866 | + | |
| 1867 | + /** | |
| 1868 | + * @return \OCP\IDateTimeFormatter | |
| 1869 | + */ | |
| 1870 | +    public function getDateTimeFormatter() { | |
| 1871 | +        return $this->query('DateTimeFormatter'); | |
| 1872 | + } | |
| 1873 | + | |
| 1874 | + /** | |
| 1875 | + * @return \OCP\Files\Config\IMountProviderCollection | |
| 1876 | + */ | |
| 1877 | +    public function getMountProviderCollection() { | |
| 1878 | +        return $this->query('MountConfigManager'); | |
| 1879 | + } | |
| 1880 | + | |
| 1881 | + /** | |
| 1882 | + * Get the IniWrapper | |
| 1883 | + * | |
| 1884 | + * @return IniGetWrapper | |
| 1885 | + */ | |
| 1886 | +    public function getIniWrapper() { | |
| 1887 | +        return $this->query('IniWrapper'); | |
| 1888 | + } | |
| 1889 | + | |
| 1890 | + /** | |
| 1891 | + * @return \OCP\Command\IBus | |
| 1892 | + */ | |
| 1893 | +    public function getCommandBus() { | |
| 1894 | +        return $this->query('AsyncCommandBus'); | |
| 1895 | + } | |
| 1896 | + | |
| 1897 | + /** | |
| 1898 | + * Get the trusted domain helper | |
| 1899 | + * | |
| 1900 | + * @return TrustedDomainHelper | |
| 1901 | + */ | |
| 1902 | +    public function getTrustedDomainHelper() { | |
| 1903 | +        return $this->query('TrustedDomainHelper'); | |
| 1904 | + } | |
| 1905 | + | |
| 1906 | + /** | |
| 1907 | + * Get the locking provider | |
| 1908 | + * | |
| 1909 | + * @return \OCP\Lock\ILockingProvider | |
| 1910 | + * @since 8.1.0 | |
| 1911 | + */ | |
| 1912 | +    public function getLockingProvider() { | |
| 1913 | +        return $this->query('LockingProvider'); | |
| 1914 | + } | |
| 1915 | + | |
| 1916 | + /** | |
| 1917 | + * @return \OCP\Files\Mount\IMountManager | |
| 1918 | + **/ | |
| 1919 | +    function getMountManager() { | |
| 1920 | +        return $this->query('MountManager'); | |
| 1921 | + } | |
| 1922 | + | |
| 1923 | + /** @return \OCP\Files\Config\IUserMountCache */ | |
| 1924 | +    function getUserMountCache() { | |
| 1925 | +        return $this->query('UserMountCache'); | |
| 1926 | + } | |
| 1927 | + | |
| 1928 | + /** | |
| 1929 | + * Get the MimeTypeDetector | |
| 1930 | + * | |
| 1931 | + * @return \OCP\Files\IMimeTypeDetector | |
| 1932 | + */ | |
| 1933 | +    public function getMimeTypeDetector() { | |
| 1934 | +        return $this->query('MimeTypeDetector'); | |
| 1935 | + } | |
| 1936 | + | |
| 1937 | + /** | |
| 1938 | + * Get the MimeTypeLoader | |
| 1939 | + * | |
| 1940 | + * @return \OCP\Files\IMimeTypeLoader | |
| 1941 | + */ | |
| 1942 | +    public function getMimeTypeLoader() { | |
| 1943 | +        return $this->query('MimeTypeLoader'); | |
| 1944 | + } | |
| 1945 | + | |
| 1946 | + /** | |
| 1947 | + * Get the manager of all the capabilities | |
| 1948 | + * | |
| 1949 | + * @return \OC\CapabilitiesManager | |
| 1950 | + */ | |
| 1951 | +    public function getCapabilitiesManager() { | |
| 1952 | +        return $this->query('CapabilitiesManager'); | |
| 1953 | + } | |
| 1954 | + | |
| 1955 | + /** | |
| 1956 | + * Get the EventDispatcher | |
| 1957 | + * | |
| 1958 | + * @return EventDispatcherInterface | |
| 1959 | + * @since 8.2.0 | |
| 1960 | + * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher | |
| 1961 | + */ | |
| 1962 | +    public function getEventDispatcher() { | |
| 1963 | + return $this->query(\OC\EventDispatcher\SymfonyAdapter::class); | |
| 1964 | + } | |
| 1965 | + | |
| 1966 | + /** | |
| 1967 | + * Get the Notification Manager | |
| 1968 | + * | |
| 1969 | + * @return \OCP\Notification\IManager | |
| 1970 | + * @since 8.2.0 | |
| 1971 | + */ | |
| 1972 | +    public function getNotificationManager() { | |
| 1973 | +        return $this->query('NotificationManager'); | |
| 1974 | + } | |
| 1975 | + | |
| 1976 | + /** | |
| 1977 | + * @return \OCP\Comments\ICommentsManager | |
| 1978 | + */ | |
| 1979 | +    public function getCommentsManager() { | |
| 1980 | +        return $this->query('CommentsManager'); | |
| 1981 | + } | |
| 1982 | + | |
| 1983 | + /** | |
| 1984 | + * @return \OCA\Theming\ThemingDefaults | |
| 1985 | + */ | |
| 1986 | +    public function getThemingDefaults() { | |
| 1987 | +        return $this->query('ThemingDefaults'); | |
| 1988 | + } | |
| 1989 | + | |
| 1990 | + /** | |
| 1991 | + * @return \OC\IntegrityCheck\Checker | |
| 1992 | + */ | |
| 1993 | +    public function getIntegrityCodeChecker() { | |
| 1994 | +        return $this->query('IntegrityCodeChecker'); | |
| 1995 | + } | |
| 1996 | + | |
| 1997 | + /** | |
| 1998 | + * @return \OC\Session\CryptoWrapper | |
| 1999 | + */ | |
| 2000 | +    public function getSessionCryptoWrapper() { | |
| 2001 | +        return $this->query('CryptoWrapper'); | |
| 2002 | + } | |
| 2003 | + | |
| 2004 | + /** | |
| 2005 | + * @return CsrfTokenManager | |
| 2006 | + */ | |
| 2007 | +    public function getCsrfTokenManager() { | |
| 2008 | + return $this->query(CsrfTokenManager::class); | |
| 2009 | + } | |
| 2010 | + | |
| 2011 | + /** | |
| 2012 | + * @return Throttler | |
| 2013 | + */ | |
| 2014 | +    public function getBruteForceThrottler() { | |
| 2015 | +        return $this->query('Throttler'); | |
| 2016 | + } | |
| 2017 | + | |
| 2018 | + /** | |
| 2019 | + * @return IContentSecurityPolicyManager | |
| 2020 | + */ | |
| 2021 | +    public function getContentSecurityPolicyManager() { | |
| 2022 | +        return $this->query('ContentSecurityPolicyManager'); | |
| 2023 | + } | |
| 2024 | + | |
| 2025 | + /** | |
| 2026 | + * @return ContentSecurityPolicyNonceManager | |
| 2027 | + */ | |
| 2028 | +    public function getContentSecurityPolicyNonceManager() { | |
| 2029 | +        return $this->query('ContentSecurityPolicyNonceManager'); | |
| 2030 | + } | |
| 2031 | + | |
| 2032 | + /** | |
| 2033 | + * Not a public API as of 8.2, wait for 9.0 | |
| 2034 | + * | |
| 2035 | + * @return \OCA\Files_External\Service\BackendService | |
| 2036 | + */ | |
| 2037 | +    public function getStoragesBackendService() { | |
| 2038 | +        return $this->query('OCA\\Files_External\\Service\\BackendService'); | |
| 2039 | + } | |
| 2040 | + | |
| 2041 | + /** | |
| 2042 | + * Not a public API as of 8.2, wait for 9.0 | |
| 2043 | + * | |
| 2044 | + * @return \OCA\Files_External\Service\GlobalStoragesService | |
| 2045 | + */ | |
| 2046 | +    public function getGlobalStoragesService() { | |
| 2047 | +        return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); | |
| 2048 | + } | |
| 2049 | + | |
| 2050 | + /** | |
| 2051 | + * Not a public API as of 8.2, wait for 9.0 | |
| 2052 | + * | |
| 2053 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService | |
| 2054 | + */ | |
| 2055 | +    public function getUserGlobalStoragesService() { | |
| 2056 | +        return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); | |
| 2057 | + } | |
| 2058 | + | |
| 2059 | + /** | |
| 2060 | + * Not a public API as of 8.2, wait for 9.0 | |
| 2061 | + * | |
| 2062 | + * @return \OCA\Files_External\Service\UserStoragesService | |
| 2063 | + */ | |
| 2064 | +    public function getUserStoragesService() { | |
| 2065 | +        return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); | |
| 2066 | + } | |
| 2067 | + | |
| 2068 | + /** | |
| 2069 | + * @return \OCP\Share\IManager | |
| 2070 | + */ | |
| 2071 | +    public function getShareManager() { | |
| 2072 | +        return $this->query('ShareManager'); | |
| 2073 | + } | |
| 2074 | + | |
| 2075 | + /** | |
| 2076 | + * @return \OCP\Collaboration\Collaborators\ISearch | |
| 2077 | + */ | |
| 2078 | +    public function getCollaboratorSearch() { | |
| 2079 | +        return $this->query('CollaboratorSearch'); | |
| 2080 | + } | |
| 2081 | + | |
| 2082 | + /** | |
| 2083 | + * @return \OCP\Collaboration\AutoComplete\IManager | |
| 2084 | + */ | |
| 2085 | +    public function getAutoCompleteManager(){ | |
| 2086 | + return $this->query(IManager::class); | |
| 2087 | + } | |
| 2088 | + | |
| 2089 | + /** | |
| 2090 | + * Returns the LDAP Provider | |
| 2091 | + * | |
| 2092 | + * @return \OCP\LDAP\ILDAPProvider | |
| 2093 | + */ | |
| 2094 | +    public function getLDAPProvider() { | |
| 2095 | +        return $this->query('LDAPProvider'); | |
| 2096 | + } | |
| 2097 | + | |
| 2098 | + /** | |
| 2099 | + * @return \OCP\Settings\IManager | |
| 2100 | + */ | |
| 2101 | +    public function getSettingsManager() { | |
| 2102 | +        return $this->query('SettingsManager'); | |
| 2103 | + } | |
| 2104 | + | |
| 2105 | + /** | |
| 2106 | + * @return \OCP\Files\IAppData | |
| 2107 | + */ | |
| 2108 | +    public function getAppDataDir($app) { | |
| 2109 | + /** @var \OC\Files\AppData\Factory $factory */ | |
| 2110 | + $factory = $this->query(\OC\Files\AppData\Factory::class); | |
| 2111 | + return $factory->get($app); | |
| 2112 | + } | |
| 2113 | + | |
| 2114 | + /** | |
| 2115 | + * @return \OCP\Lockdown\ILockdownManager | |
| 2116 | + */ | |
| 2117 | +    public function getLockdownManager() { | |
| 2118 | +        return $this->query('LockdownManager'); | |
| 2119 | + } | |
| 2120 | + | |
| 2121 | + /** | |
| 2122 | + * @return \OCP\Federation\ICloudIdManager | |
| 2123 | + */ | |
| 2124 | +    public function getCloudIdManager() { | |
| 2125 | + return $this->query(ICloudIdManager::class); | |
| 2126 | + } | |
| 2127 | + | |
| 2128 | + /** | |
| 2129 | + * @return \OCP\GlobalScale\IConfig | |
| 2130 | + */ | |
| 2131 | +    public function getGlobalScaleConfig() { | |
| 2132 | + return $this->query(IConfig::class); | |
| 2133 | + } | |
| 2134 | + | |
| 2135 | + /** | |
| 2136 | + * @return \OCP\Federation\ICloudFederationProviderManager | |
| 2137 | + */ | |
| 2138 | +    public function getCloudFederationProviderManager() { | |
| 2139 | + return $this->query(ICloudFederationProviderManager::class); | |
| 2140 | + } | |
| 2141 | + | |
| 2142 | + /** | |
| 2143 | + * @return \OCP\Remote\Api\IApiFactory | |
| 2144 | + */ | |
| 2145 | +    public function getRemoteApiFactory() { | |
| 2146 | + return $this->query(IApiFactory::class); | |
| 2147 | + } | |
| 2148 | + | |
| 2149 | + /** | |
| 2150 | + * @return \OCP\Federation\ICloudFederationFactory | |
| 2151 | + */ | |
| 2152 | +    public function getCloudFederationFactory() { | |
| 2153 | + return $this->query(ICloudFederationFactory::class); | |
| 2154 | + } | |
| 2155 | + | |
| 2156 | + /** | |
| 2157 | + * @return \OCP\Remote\IInstanceFactory | |
| 2158 | + */ | |
| 2159 | +    public function getRemoteInstanceFactory() { | |
| 2160 | + return $this->query(IInstanceFactory::class); | |
| 2161 | + } | |
| 2162 | + | |
| 2163 | + /** | |
| 2164 | + * @return IStorageFactory | |
| 2165 | + */ | |
| 2166 | +    public function getStorageFactory() { | |
| 2167 | + return $this->query(IStorageFactory::class); | |
| 2168 | + } | |
| 2169 | + | |
| 2170 | + /** | |
| 2171 | + * Get the Preview GeneratorHelper | |
| 2172 | + * | |
| 2173 | + * @return GeneratorHelper | |
| 2174 | + * @since 17.0.0 | |
| 2175 | + */ | |
| 2176 | +    public function getGeneratorHelper() { | |
| 2177 | + return $this->query(\OC\Preview\GeneratorHelper::class); | |
| 2178 | + } | |
| 2179 | 2179 | } | 
| @@ -33,29 +33,29 @@ | ||
| 33 | 33 | |
| 34 | 34 |  class GlobalShareAcceptanceListener implements IEventListener { | 
| 35 | 35 | |
| 36 | - /** @var IConfig */ | |
| 37 | - private $config; | |
| 38 | - /** @var IManager */ | |
| 39 | - private $shareManager; | |
| 40 | - | |
| 41 | -	public function __construct(IConfig $config, IManager $shareManager) { | |
| 42 | - $this->config = $config; | |
| 43 | - $this->shareManager = $shareManager; | |
| 44 | - } | |
| 45 | - | |
| 46 | -	public function handle(Event $event): void { | |
| 47 | -		if (!($event instanceof ShareCreatedEvent)) { | |
| 48 | - return; | |
| 49 | - } | |
| 50 | - | |
| 51 | -		if ($this->config->getSystemValueBool('sharing.interal_shares_accepted', false)) { | |
| 52 | - $share = $event->getShare(); | |
| 53 | - | |
| 54 | -			if ($share->getShareType() === IShare::TYPE_USER || $share->getShareType() === IShare::TYPE_GROUP) { | |
| 55 | - $share->setStatus(IShare::STATUS_ACCEPTED); | |
| 56 | - $this->shareManager->updateShare($share); | |
| 57 | - } | |
| 58 | - } | |
| 59 | - } | |
| 36 | + /** @var IConfig */ | |
| 37 | + private $config; | |
| 38 | + /** @var IManager */ | |
| 39 | + private $shareManager; | |
| 40 | + | |
| 41 | +    public function __construct(IConfig $config, IManager $shareManager) { | |
| 42 | + $this->config = $config; | |
| 43 | + $this->shareManager = $shareManager; | |
| 44 | + } | |
| 45 | + | |
| 46 | +    public function handle(Event $event): void { | |
| 47 | +        if (!($event instanceof ShareCreatedEvent)) { | |
| 48 | + return; | |
| 49 | + } | |
| 50 | + | |
| 51 | +        if ($this->config->getSystemValueBool('sharing.interal_shares_accepted', false)) { | |
| 52 | + $share = $event->getShare(); | |
| 53 | + | |
| 54 | +            if ($share->getShareType() === IShare::TYPE_USER || $share->getShareType() === IShare::TYPE_GROUP) { | |
| 55 | + $share->setStatus(IShare::STATUS_ACCEPTED); | |
| 56 | + $this->shareManager->updateShare($share); | |
| 57 | + } | |
| 58 | + } | |
| 59 | + } | |
| 60 | 60 | |
| 61 | 61 | } | 
| @@ -61,231 +61,231 @@ | ||
| 61 | 61 | |
| 62 | 62 |  class Application extends App { | 
| 63 | 63 | |
| 64 | - const APP_ID = 'files_sharing'; | |
| 64 | + const APP_ID = 'files_sharing'; | |
| 65 | 65 | |
| 66 | -	public function __construct(array $urlParams = []) { | |
| 67 | - parent::__construct(self::APP_ID, $urlParams); | |
| 66 | +    public function __construct(array $urlParams = []) { | |
| 67 | + parent::__construct(self::APP_ID, $urlParams); | |
| 68 | 68 | |
| 69 | - $container = $this->getContainer(); | |
| 69 | + $container = $this->getContainer(); | |
| 70 | 70 | |
| 71 | - /** @var IServerContainer $server */ | |
| 72 | - $server = $container->getServer(); | |
| 71 | + /** @var IServerContainer $server */ | |
| 72 | + $server = $container->getServer(); | |
| 73 | 73 | |
| 74 | - /** @var IEventDispatcher $dispatcher */ | |
| 75 | - $dispatcher = $container->query(IEventDispatcher::class); | |
| 76 | - $mountProviderCollection = $server->getMountProviderCollection(); | |
| 77 | - $notifications = $server->getNotificationManager(); | |
| 74 | + /** @var IEventDispatcher $dispatcher */ | |
| 75 | + $dispatcher = $container->query(IEventDispatcher::class); | |
| 76 | + $mountProviderCollection = $server->getMountProviderCollection(); | |
| 77 | + $notifications = $server->getNotificationManager(); | |
| 78 | 78 | |
| 79 | - /** | |
| 80 | - * Controllers | |
| 81 | - */ | |
| 82 | -		$container->registerService('ShareController', function (SimpleContainer $c) use ($server) { | |
| 83 | - $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); | |
| 84 | - return new ShareController( | |
| 85 | -				$c->query('AppName'), | |
| 86 | -				$c->query('Request'), | |
| 87 | - $server->getConfig(), | |
| 88 | - $server->getURLGenerator(), | |
| 89 | - $server->getUserManager(), | |
| 90 | - $server->getLogger(), | |
| 91 | - $server->getActivityManager(), | |
| 92 | - $server->getShareManager(), | |
| 93 | - $server->getSession(), | |
| 94 | - $server->getPreviewManager(), | |
| 95 | - $server->getRootFolder(), | |
| 96 | - $federatedSharingApp->getFederatedShareProvider(), | |
| 97 | - $server->getEventDispatcher(), | |
| 98 | -				$server->getL10N($c->query('AppName')), | |
| 99 | - $server->query(Defaults::class) | |
| 100 | - ); | |
| 101 | - }); | |
| 102 | -		$container->registerService('ExternalSharesController', function (SimpleContainer $c) { | |
| 103 | - return new ExternalSharesController( | |
| 104 | -				$c->query('AppName'), | |
| 105 | -				$c->query('Request'), | |
| 106 | -				$c->query('ExternalManager'), | |
| 107 | -				$c->query('HttpClientService') | |
| 108 | - ); | |
| 109 | - }); | |
| 79 | + /** | |
| 80 | + * Controllers | |
| 81 | + */ | |
| 82 | +        $container->registerService('ShareController', function (SimpleContainer $c) use ($server) { | |
| 83 | + $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); | |
| 84 | + return new ShareController( | |
| 85 | +                $c->query('AppName'), | |
| 86 | +                $c->query('Request'), | |
| 87 | + $server->getConfig(), | |
| 88 | + $server->getURLGenerator(), | |
| 89 | + $server->getUserManager(), | |
| 90 | + $server->getLogger(), | |
| 91 | + $server->getActivityManager(), | |
| 92 | + $server->getShareManager(), | |
| 93 | + $server->getSession(), | |
| 94 | + $server->getPreviewManager(), | |
| 95 | + $server->getRootFolder(), | |
| 96 | + $federatedSharingApp->getFederatedShareProvider(), | |
| 97 | + $server->getEventDispatcher(), | |
| 98 | +                $server->getL10N($c->query('AppName')), | |
| 99 | + $server->query(Defaults::class) | |
| 100 | + ); | |
| 101 | + }); | |
| 102 | +        $container->registerService('ExternalSharesController', function (SimpleContainer $c) { | |
| 103 | + return new ExternalSharesController( | |
| 104 | +                $c->query('AppName'), | |
| 105 | +                $c->query('Request'), | |
| 106 | +                $c->query('ExternalManager'), | |
| 107 | +                $c->query('HttpClientService') | |
| 108 | + ); | |
| 109 | + }); | |
| 110 | 110 | |
| 111 | - /** | |
| 112 | - * Core class wrappers | |
| 113 | - */ | |
| 114 | -		$container->registerService('HttpClientService', function (SimpleContainer $c) use ($server) { | |
| 115 | - return $server->getHTTPClientService(); | |
| 116 | - }); | |
| 117 | -		$container->registerService(ICloudIdManager::class, function (SimpleContainer $c) use ($server) { | |
| 118 | - return $server->getCloudIdManager(); | |
| 119 | - }); | |
| 120 | -		$container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) { | |
| 121 | - $user = $server->getUserSession()->getUser(); | |
| 122 | - $uid = $user ? $user->getUID() : null; | |
| 123 | - return new \OCA\Files_Sharing\External\Manager( | |
| 124 | - $server->getDatabaseConnection(), | |
| 125 | - \OC\Files\Filesystem::getMountManager(), | |
| 126 | - \OC\Files\Filesystem::getLoader(), | |
| 127 | - $server->getHTTPClientService(), | |
| 128 | - $server->getNotificationManager(), | |
| 129 | - $server->query(\OCP\OCS\IDiscoveryService::class), | |
| 130 | - $server->getCloudFederationProviderManager(), | |
| 131 | - $server->getCloudFederationFactory(), | |
| 132 | - $server->getGroupManager(), | |
| 133 | - $server->getUserManager(), | |
| 134 | - $uid | |
| 135 | - ); | |
| 136 | - }); | |
| 137 | - $container->registerAlias(Manager::class, 'ExternalManager'); | |
| 111 | + /** | |
| 112 | + * Core class wrappers | |
| 113 | + */ | |
| 114 | +        $container->registerService('HttpClientService', function (SimpleContainer $c) use ($server) { | |
| 115 | + return $server->getHTTPClientService(); | |
| 116 | + }); | |
| 117 | +        $container->registerService(ICloudIdManager::class, function (SimpleContainer $c) use ($server) { | |
| 118 | + return $server->getCloudIdManager(); | |
| 119 | + }); | |
| 120 | +        $container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) { | |
| 121 | + $user = $server->getUserSession()->getUser(); | |
| 122 | + $uid = $user ? $user->getUID() : null; | |
| 123 | + return new \OCA\Files_Sharing\External\Manager( | |
| 124 | + $server->getDatabaseConnection(), | |
| 125 | + \OC\Files\Filesystem::getMountManager(), | |
| 126 | + \OC\Files\Filesystem::getLoader(), | |
| 127 | + $server->getHTTPClientService(), | |
| 128 | + $server->getNotificationManager(), | |
| 129 | + $server->query(\OCP\OCS\IDiscoveryService::class), | |
| 130 | + $server->getCloudFederationProviderManager(), | |
| 131 | + $server->getCloudFederationFactory(), | |
| 132 | + $server->getGroupManager(), | |
| 133 | + $server->getUserManager(), | |
| 134 | + $uid | |
| 135 | + ); | |
| 136 | + }); | |
| 137 | + $container->registerAlias(Manager::class, 'ExternalManager'); | |
| 138 | 138 | |
| 139 | - /** | |
| 140 | - * Middleware | |
| 141 | - */ | |
| 142 | -		$container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use ($server) { | |
| 143 | - return new SharingCheckMiddleware( | |
| 144 | -				$c->query('AppName'), | |
| 145 | - $server->getConfig(), | |
| 146 | - $server->getAppManager(), | |
| 147 | - $server->query(IControllerMethodReflector::class), | |
| 148 | - $server->getShareManager(), | |
| 149 | - $server->getRequest() | |
| 150 | - ); | |
| 151 | - }); | |
| 139 | + /** | |
| 140 | + * Middleware | |
| 141 | + */ | |
| 142 | +        $container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use ($server) { | |
| 143 | + return new SharingCheckMiddleware( | |
| 144 | +                $c->query('AppName'), | |
| 145 | + $server->getConfig(), | |
| 146 | + $server->getAppManager(), | |
| 147 | + $server->query(IControllerMethodReflector::class), | |
| 148 | + $server->getShareManager(), | |
| 149 | + $server->getRequest() | |
| 150 | + ); | |
| 151 | + }); | |
| 152 | 152 | |
| 153 | -		$container->registerService(ShareInfoMiddleware::class, function () use ($server) { | |
| 154 | - return new ShareInfoMiddleware( | |
| 155 | - $server->getShareManager() | |
| 156 | - ); | |
| 157 | - }); | |
| 153 | +        $container->registerService(ShareInfoMiddleware::class, function () use ($server) { | |
| 154 | + return new ShareInfoMiddleware( | |
| 155 | + $server->getShareManager() | |
| 156 | + ); | |
| 157 | + }); | |
| 158 | 158 | |
| 159 | - // Execute middlewares | |
| 160 | -		$container->registerMiddleWare('SharingCheckMiddleware'); | |
| 161 | - $container->registerMiddleWare(OCSShareAPIMiddleware::class); | |
| 162 | - $container->registerMiddleWare(ShareInfoMiddleware::class); | |
| 159 | + // Execute middlewares | |
| 160 | +        $container->registerMiddleWare('SharingCheckMiddleware'); | |
| 161 | + $container->registerMiddleWare(OCSShareAPIMiddleware::class); | |
| 162 | + $container->registerMiddleWare(ShareInfoMiddleware::class); | |
| 163 | 163 | |
| 164 | -		$container->registerService('MountProvider', function (IContainer $c) { | |
| 165 | - /** @var \OCP\IServerContainer $server */ | |
| 166 | -			$server = $c->query('ServerContainer'); | |
| 167 | - return new MountProvider( | |
| 168 | - $server->getConfig(), | |
| 169 | - $server->getShareManager(), | |
| 170 | - $server->getLogger() | |
| 171 | - ); | |
| 172 | - }); | |
| 164 | +        $container->registerService('MountProvider', function (IContainer $c) { | |
| 165 | + /** @var \OCP\IServerContainer $server */ | |
| 166 | +            $server = $c->query('ServerContainer'); | |
| 167 | + return new MountProvider( | |
| 168 | + $server->getConfig(), | |
| 169 | + $server->getShareManager(), | |
| 170 | + $server->getLogger() | |
| 171 | + ); | |
| 172 | + }); | |
| 173 | 173 | |
| 174 | -		$container->registerService('ExternalMountProvider', function (IContainer $c) { | |
| 175 | - /** @var \OCP\IServerContainer $server */ | |
| 176 | -			$server = $c->query('ServerContainer'); | |
| 177 | - return new \OCA\Files_Sharing\External\MountProvider( | |
| 178 | - $server->getDatabaseConnection(), | |
| 179 | -				function() use ($c) { | |
| 180 | -					return $c->query('ExternalManager'); | |
| 181 | - }, | |
| 182 | - $server->getCloudIdManager() | |
| 183 | - ); | |
| 184 | - }); | |
| 174 | +        $container->registerService('ExternalMountProvider', function (IContainer $c) { | |
| 175 | + /** @var \OCP\IServerContainer $server */ | |
| 176 | +            $server = $c->query('ServerContainer'); | |
| 177 | + return new \OCA\Files_Sharing\External\MountProvider( | |
| 178 | + $server->getDatabaseConnection(), | |
| 179 | +                function() use ($c) { | |
| 180 | +                    return $c->query('ExternalManager'); | |
| 181 | + }, | |
| 182 | + $server->getCloudIdManager() | |
| 183 | + ); | |
| 184 | + }); | |
| 185 | 185 | |
| 186 | - /** | |
| 187 | - * Register capabilities | |
| 188 | - */ | |
| 189 | - $container->registerCapability(Capabilities::class); | |
| 186 | + /** | |
| 187 | + * Register capabilities | |
| 188 | + */ | |
| 189 | + $container->registerCapability(Capabilities::class); | |
| 190 | 190 | |
| 191 | - $notifications->registerNotifierService(Notifier::class); | |
| 191 | + $notifications->registerNotifierService(Notifier::class); | |
| 192 | 192 | |
| 193 | - $this->registerMountProviders($mountProviderCollection); | |
| 194 | - $this->registerEventsScripts($dispatcher); | |
| 195 | - $this->setupSharingMenus(); | |
| 193 | + $this->registerMountProviders($mountProviderCollection); | |
| 194 | + $this->registerEventsScripts($dispatcher); | |
| 195 | + $this->setupSharingMenus(); | |
| 196 | 196 | |
| 197 | - /** | |
| 198 | - * Always add main sharing script | |
| 199 | - */ | |
| 200 | - Util::addScript(self::APP_ID, 'dist/main'); | |
| 201 | - } | |
| 197 | + /** | |
| 198 | + * Always add main sharing script | |
| 199 | + */ | |
| 200 | + Util::addScript(self::APP_ID, 'dist/main'); | |
| 201 | + } | |
| 202 | 202 | |
| 203 | -	protected function registerMountProviders(IMountProviderCollection $mountProviderCollection) { | |
| 204 | -		$mountProviderCollection->registerProvider($this->getContainer()->query('MountProvider')); | |
| 205 | -		$mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider')); | |
| 206 | - } | |
| 203 | +    protected function registerMountProviders(IMountProviderCollection $mountProviderCollection) { | |
| 204 | +        $mountProviderCollection->registerProvider($this->getContainer()->query('MountProvider')); | |
| 205 | +        $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider')); | |
| 206 | + } | |
| 207 | 207 | |
| 208 | -	protected function registerEventsScripts(IEventDispatcher $dispatcher) { | |
| 209 | - // sidebar and files scripts | |
| 210 | - $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); | |
| 211 | - $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class); | |
| 212 | -		$dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function() { | |
| 213 | -			\OCP\Util::addScript('files_sharing', 'dist/collaboration'); | |
| 214 | - }); | |
| 215 | - $dispatcher->addServiceListener(ShareCreatedEvent::class, GlobalShareAcceptanceListener::class); | |
| 208 | +    protected function registerEventsScripts(IEventDispatcher $dispatcher) { | |
| 209 | + // sidebar and files scripts | |
| 210 | + $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); | |
| 211 | + $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class); | |
| 212 | +        $dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function() { | |
| 213 | +            \OCP\Util::addScript('files_sharing', 'dist/collaboration'); | |
| 214 | + }); | |
| 215 | + $dispatcher->addServiceListener(ShareCreatedEvent::class, GlobalShareAcceptanceListener::class); | |
| 216 | 216 | |
| 217 | - // notifications api to accept incoming user shares | |
| 218 | -		$dispatcher->addListener('OCP\Share::postShare', function(GenericEvent $event) { | |
| 219 | - /** @var Listener $listener */ | |
| 220 | - $listener = $this->getContainer()->query(Listener::class); | |
| 221 | - $listener->shareNotification($event); | |
| 222 | - }); | |
| 223 | -		$dispatcher->addListener(IGroup::class . '::postAddUser', function(GenericEvent $event) { | |
| 224 | - /** @var Listener $listener */ | |
| 225 | - $listener = $this->getContainer()->query(Listener::class); | |
| 226 | - $listener->userAddedToGroup($event); | |
| 227 | - }); | |
| 228 | - } | |
| 217 | + // notifications api to accept incoming user shares | |
| 218 | +        $dispatcher->addListener('OCP\Share::postShare', function(GenericEvent $event) { | |
| 219 | + /** @var Listener $listener */ | |
| 220 | + $listener = $this->getContainer()->query(Listener::class); | |
| 221 | + $listener->shareNotification($event); | |
| 222 | + }); | |
| 223 | +        $dispatcher->addListener(IGroup::class . '::postAddUser', function(GenericEvent $event) { | |
| 224 | + /** @var Listener $listener */ | |
| 225 | + $listener = $this->getContainer()->query(Listener::class); | |
| 226 | + $listener->userAddedToGroup($event); | |
| 227 | + }); | |
| 228 | + } | |
| 229 | 229 | |
| 230 | -	protected function setupSharingMenus() { | |
| 231 | - $config = \OC::$server->getConfig(); | |
| 232 | -		$l = \OC::$server->getL10N('files_sharing'); | |
| 230 | +    protected function setupSharingMenus() { | |
| 231 | + $config = \OC::$server->getConfig(); | |
| 232 | +        $l = \OC::$server->getL10N('files_sharing'); | |
| 233 | 233 | |
| 234 | -		if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { | |
| 235 | - return; | |
| 236 | - } | |
| 234 | +        if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { | |
| 235 | + return; | |
| 236 | + } | |
| 237 | 237 | |
| 238 | - $sharingSublistArray = []; | |
| 238 | + $sharingSublistArray = []; | |
| 239 | 239 | |
| 240 | -		if (\OCP\Util::isSharingDisabledForUser() === false) { | |
| 241 | - array_push($sharingSublistArray, [ | |
| 242 | - 'id' => 'sharingout', | |
| 243 | - 'appname' => 'files_sharing', | |
| 244 | - 'script' => 'list.php', | |
| 245 | - 'order' => 16, | |
| 246 | -				'name' => $l->t('Shared with others'), | |
| 247 | - ]); | |
| 248 | - } | |
| 240 | +        if (\OCP\Util::isSharingDisabledForUser() === false) { | |
| 241 | + array_push($sharingSublistArray, [ | |
| 242 | + 'id' => 'sharingout', | |
| 243 | + 'appname' => 'files_sharing', | |
| 244 | + 'script' => 'list.php', | |
| 245 | + 'order' => 16, | |
| 246 | +                'name' => $l->t('Shared with others'), | |
| 247 | + ]); | |
| 248 | + } | |
| 249 | 249 | |
| 250 | - array_push($sharingSublistArray, [ | |
| 251 | - 'id' => 'sharingin', | |
| 252 | - 'appname' => 'files_sharing', | |
| 253 | - 'script' => 'list.php', | |
| 254 | - 'order' => 15, | |
| 255 | -			'name' => $l->t('Shared with you'), | |
| 256 | - ]); | |
| 250 | + array_push($sharingSublistArray, [ | |
| 251 | + 'id' => 'sharingin', | |
| 252 | + 'appname' => 'files_sharing', | |
| 253 | + 'script' => 'list.php', | |
| 254 | + 'order' => 15, | |
| 255 | +            'name' => $l->t('Shared with you'), | |
| 256 | + ]); | |
| 257 | 257 | |
| 258 | -		if (\OCP\Util::isSharingDisabledForUser() === false) { | |
| 259 | - // Check if sharing by link is enabled | |
| 260 | -			if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') { | |
| 261 | - array_push($sharingSublistArray, [ | |
| 262 | - 'id' => 'sharinglinks', | |
| 263 | - 'appname' => 'files_sharing', | |
| 264 | - 'script' => 'list.php', | |
| 265 | - 'order' => 17, | |
| 266 | -					'name' => $l->t('Shared by link'), | |
| 267 | - ]); | |
| 268 | - } | |
| 269 | - } | |
| 258 | +        if (\OCP\Util::isSharingDisabledForUser() === false) { | |
| 259 | + // Check if sharing by link is enabled | |
| 260 | +            if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') { | |
| 261 | + array_push($sharingSublistArray, [ | |
| 262 | + 'id' => 'sharinglinks', | |
| 263 | + 'appname' => 'files_sharing', | |
| 264 | + 'script' => 'list.php', | |
| 265 | + 'order' => 17, | |
| 266 | +                    'name' => $l->t('Shared by link'), | |
| 267 | + ]); | |
| 268 | + } | |
| 269 | + } | |
| 270 | 270 | |
| 271 | - array_push($sharingSublistArray, [ | |
| 272 | - 'id' => 'deletedshares', | |
| 273 | - 'appname' => 'files_sharing', | |
| 274 | - 'script' => 'list.php', | |
| 275 | - 'order' => 19, | |
| 276 | -			'name' => $l->t('Deleted shares'), | |
| 277 | - ]); | |
| 271 | + array_push($sharingSublistArray, [ | |
| 272 | + 'id' => 'deletedshares', | |
| 273 | + 'appname' => 'files_sharing', | |
| 274 | + 'script' => 'list.php', | |
| 275 | + 'order' => 19, | |
| 276 | +            'name' => $l->t('Deleted shares'), | |
| 277 | + ]); | |
| 278 | 278 | |
| 279 | - // show_Quick_Access stored as string | |
| 280 | - \OCA\Files\App::getNavigationManager()->add([ | |
| 281 | - 'id' => 'shareoverview', | |
| 282 | - 'appname' => 'files_sharing', | |
| 283 | - 'script' => 'list.php', | |
| 284 | - 'order' => 18, | |
| 285 | -			'name' => $l->t('Shares'), | |
| 286 | - 'classes' => 'collapsible', | |
| 287 | - 'sublist' => $sharingSublistArray, | |
| 288 | - 'expandedState' => 'show_sharing_menu' | |
| 289 | - ]); | |
| 290 | - } | |
| 279 | + // show_Quick_Access stored as string | |
| 280 | + \OCA\Files\App::getNavigationManager()->add([ | |
| 281 | + 'id' => 'shareoverview', | |
| 282 | + 'appname' => 'files_sharing', | |
| 283 | + 'script' => 'list.php', | |
| 284 | + 'order' => 18, | |
| 285 | +            'name' => $l->t('Shares'), | |
| 286 | + 'classes' => 'collapsible', | |
| 287 | + 'sublist' => $sharingSublistArray, | |
| 288 | + 'expandedState' => 'show_sharing_menu' | |
| 289 | + ]); | |
| 290 | + } | |
| 291 | 291 | } | 
| @@ -6,84 +6,84 @@ | ||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInitFiles_Sharing | 
| 8 | 8 |  { | 
| 9 | - public static $prefixLengthsPsr4 = array ( | |
| 9 | + public static $prefixLengthsPsr4 = array( | |
| 10 | 10 | 'O' => | 
| 11 | - array ( | |
| 11 | + array( | |
| 12 | 12 | 'OCA\\Files_Sharing\\' => 18, | 
| 13 | 13 | ), | 
| 14 | 14 | ); | 
| 15 | 15 | |
| 16 | - public static $prefixDirsPsr4 = array ( | |
| 16 | + public static $prefixDirsPsr4 = array( | |
| 17 | 17 | 'OCA\\Files_Sharing\\' => | 
| 18 | - array ( | |
| 19 | - 0 => __DIR__ . '/..' . '/../lib', | |
| 18 | + array( | |
| 19 | + 0 => __DIR__.'/..'.'/../lib', | |
| 20 | 20 | ), | 
| 21 | 21 | ); | 
| 22 | 22 | |
| 23 | - public static $classMap = array ( | |
| 24 | - 'OCA\\Files_Sharing\\Activity\\Filter' => __DIR__ . '/..' . '/../lib/Activity/Filter.php', | |
| 25 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Base' => __DIR__ . '/..' . '/../lib/Activity/Providers/Base.php', | |
| 26 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => __DIR__ . '/..' . '/../lib/Activity/Providers/Downloads.php', | |
| 27 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => __DIR__ . '/..' . '/../lib/Activity/Providers/Groups.php', | |
| 28 | - 'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => __DIR__ . '/..' . '/../lib/Activity/Providers/PublicLinks.php', | |
| 29 | - 'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => __DIR__ . '/..' . '/../lib/Activity/Providers/RemoteShares.php', | |
| 30 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Users' => __DIR__ . '/..' . '/../lib/Activity/Providers/Users.php', | |
| 31 | - 'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => __DIR__ . '/..' . '/../lib/Activity/Settings/PublicLinks.php', | |
| 32 | - 'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => __DIR__ . '/..' . '/../lib/Activity/Settings/RemoteShare.php', | |
| 33 | - 'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => __DIR__ . '/..' . '/../lib/Activity/Settings/Shared.php', | |
| 34 | - 'OCA\\Files_Sharing\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', | |
| 35 | - 'OCA\\Files_Sharing\\BackgroundJob\\FederatedSharesDiscoverJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/FederatedSharesDiscoverJob.php', | |
| 36 | - 'OCA\\Files_Sharing\\Cache' => __DIR__ . '/..' . '/../lib/Cache.php', | |
| 37 | - 'OCA\\Files_Sharing\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php', | |
| 38 | - 'OCA\\Files_Sharing\\Collaboration\\ShareRecipientSorter' => __DIR__ . '/..' . '/../lib/Collaboration/ShareRecipientSorter.php', | |
| 39 | - 'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => __DIR__ . '/..' . '/../lib/Command/CleanupRemoteStorages.php', | |
| 40 | - 'OCA\\Files_Sharing\\Command\\ExiprationNotification' => __DIR__ . '/..' . '/../lib/Command/ExiprationNotification.php', | |
| 41 | - 'OCA\\Files_Sharing\\Controller\\DeletedShareAPIController' => __DIR__ . '/..' . '/../lib/Controller/DeletedShareAPIController.php', | |
| 42 | - 'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => __DIR__ . '/..' . '/../lib/Controller/ExternalSharesController.php', | |
| 43 | - 'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => __DIR__ . '/..' . '/../lib/Controller/PublicPreviewController.php', | |
| 44 | - 'OCA\\Files_Sharing\\Controller\\RemoteController' => __DIR__ . '/..' . '/../lib/Controller/RemoteController.php', | |
| 45 | - 'OCA\\Files_Sharing\\Controller\\ShareAPIController' => __DIR__ . '/..' . '/../lib/Controller/ShareAPIController.php', | |
| 46 | - 'OCA\\Files_Sharing\\Controller\\ShareController' => __DIR__ . '/..' . '/../lib/Controller/ShareController.php', | |
| 47 | - 'OCA\\Files_Sharing\\Controller\\ShareInfoController' => __DIR__ . '/..' . '/../lib/Controller/ShareInfoController.php', | |
| 48 | - 'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => __DIR__ . '/..' . '/../lib/Controller/ShareesAPIController.php', | |
| 49 | - 'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => __DIR__ . '/..' . '/../lib/DeleteOrphanedSharesJob.php', | |
| 50 | - 'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => __DIR__ . '/..' . '/../lib/Exceptions/BrokenPath.php', | |
| 51 | - 'OCA\\Files_Sharing\\Exceptions\\S2SException' => __DIR__ . '/..' . '/../lib/Exceptions/S2SException.php', | |
| 52 | - 'OCA\\Files_Sharing\\Exceptions\\SharingRightsException' => __DIR__ . '/..' . '/../lib/Exceptions/SharingRightsException.php', | |
| 53 | - 'OCA\\Files_Sharing\\ExpireSharesJob' => __DIR__ . '/..' . '/../lib/ExpireSharesJob.php', | |
| 54 | - 'OCA\\Files_Sharing\\External\\Cache' => __DIR__ . '/..' . '/../lib/External/Cache.php', | |
| 55 | - 'OCA\\Files_Sharing\\External\\Manager' => __DIR__ . '/..' . '/../lib/External/Manager.php', | |
| 56 | - 'OCA\\Files_Sharing\\External\\Mount' => __DIR__ . '/..' . '/../lib/External/Mount.php', | |
| 57 | - 'OCA\\Files_Sharing\\External\\MountProvider' => __DIR__ . '/..' . '/../lib/External/MountProvider.php', | |
| 58 | - 'OCA\\Files_Sharing\\External\\Scanner' => __DIR__ . '/..' . '/../lib/External/Scanner.php', | |
| 59 | - 'OCA\\Files_Sharing\\External\\Storage' => __DIR__ . '/..' . '/../lib/External/Storage.php', | |
| 60 | - 'OCA\\Files_Sharing\\External\\Watcher' => __DIR__ . '/..' . '/../lib/External/Watcher.php', | |
| 61 | - 'OCA\\Files_Sharing\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php', | |
| 62 | - 'OCA\\Files_Sharing\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php', | |
| 63 | - 'OCA\\Files_Sharing\\ISharedStorage' => __DIR__ . '/..' . '/../lib/ISharedStorage.php', | |
| 64 | - 'OCA\\Files_Sharing\\Listener\\GlobalShareAcceptanceListener' => __DIR__ . '/..' . '/../lib/Listener/GlobalShareAcceptanceListener.php', | |
| 65 | - 'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalListener.php', | |
| 66 | - 'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarListener.php', | |
| 67 | - 'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/OCSShareAPIMiddleware.php', | |
| 68 | - 'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/ShareInfoMiddleware.php', | |
| 69 | - 'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/SharingCheckMiddleware.php', | |
| 70 | - 'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => __DIR__ . '/..' . '/../lib/Migration/OwncloudGuestShareType.php', | |
| 71 | - 'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => __DIR__ . '/..' . '/../lib/Migration/SetAcceptedStatus.php', | |
| 72 | - 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => __DIR__ . '/..' . '/../lib/Migration/SetPasswordColumn.php', | |
| 73 | - 'OCA\\Files_Sharing\\MountProvider' => __DIR__ . '/..' . '/../lib/MountProvider.php', | |
| 74 | - 'OCA\\Files_Sharing\\Notification\\Listener' => __DIR__ . '/..' . '/../lib/Notification/Listener.php', | |
| 75 | - 'OCA\\Files_Sharing\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php', | |
| 76 | - 'OCA\\Files_Sharing\\Scanner' => __DIR__ . '/..' . '/../lib/Scanner.php', | |
| 77 | - 'OCA\\Files_Sharing\\ShareBackend\\File' => __DIR__ . '/..' . '/../lib/ShareBackend/File.php', | |
| 78 | - 'OCA\\Files_Sharing\\ShareBackend\\Folder' => __DIR__ . '/..' . '/../lib/ShareBackend/Folder.php', | |
| 79 | - 'OCA\\Files_Sharing\\SharedMount' => __DIR__ . '/..' . '/../lib/SharedMount.php', | |
| 80 | - 'OCA\\Files_Sharing\\SharedStorage' => __DIR__ . '/..' . '/../lib/SharedStorage.php', | |
| 81 | - 'OCA\\Files_Sharing\\Updater' => __DIR__ . '/..' . '/../lib/Updater.php', | |
| 23 | + public static $classMap = array( | |
| 24 | + 'OCA\\Files_Sharing\\Activity\\Filter' => __DIR__.'/..'.'/../lib/Activity/Filter.php', | |
| 25 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Base' => __DIR__.'/..'.'/../lib/Activity/Providers/Base.php', | |
| 26 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => __DIR__.'/..'.'/../lib/Activity/Providers/Downloads.php', | |
| 27 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => __DIR__.'/..'.'/../lib/Activity/Providers/Groups.php', | |
| 28 | + 'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => __DIR__.'/..'.'/../lib/Activity/Providers/PublicLinks.php', | |
| 29 | + 'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => __DIR__.'/..'.'/../lib/Activity/Providers/RemoteShares.php', | |
| 30 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Users' => __DIR__.'/..'.'/../lib/Activity/Providers/Users.php', | |
| 31 | + 'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => __DIR__.'/..'.'/../lib/Activity/Settings/PublicLinks.php', | |
| 32 | + 'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => __DIR__.'/..'.'/../lib/Activity/Settings/RemoteShare.php', | |
| 33 | + 'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => __DIR__.'/..'.'/../lib/Activity/Settings/Shared.php', | |
| 34 | + 'OCA\\Files_Sharing\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', | |
| 35 | + 'OCA\\Files_Sharing\\BackgroundJob\\FederatedSharesDiscoverJob' => __DIR__.'/..'.'/../lib/BackgroundJob/FederatedSharesDiscoverJob.php', | |
| 36 | + 'OCA\\Files_Sharing\\Cache' => __DIR__.'/..'.'/../lib/Cache.php', | |
| 37 | + 'OCA\\Files_Sharing\\Capabilities' => __DIR__.'/..'.'/../lib/Capabilities.php', | |
| 38 | + 'OCA\\Files_Sharing\\Collaboration\\ShareRecipientSorter' => __DIR__.'/..'.'/../lib/Collaboration/ShareRecipientSorter.php', | |
| 39 | + 'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => __DIR__.'/..'.'/../lib/Command/CleanupRemoteStorages.php', | |
| 40 | + 'OCA\\Files_Sharing\\Command\\ExiprationNotification' => __DIR__.'/..'.'/../lib/Command/ExiprationNotification.php', | |
| 41 | + 'OCA\\Files_Sharing\\Controller\\DeletedShareAPIController' => __DIR__.'/..'.'/../lib/Controller/DeletedShareAPIController.php', | |
| 42 | + 'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => __DIR__.'/..'.'/../lib/Controller/ExternalSharesController.php', | |
| 43 | + 'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => __DIR__.'/..'.'/../lib/Controller/PublicPreviewController.php', | |
| 44 | + 'OCA\\Files_Sharing\\Controller\\RemoteController' => __DIR__.'/..'.'/../lib/Controller/RemoteController.php', | |
| 45 | + 'OCA\\Files_Sharing\\Controller\\ShareAPIController' => __DIR__.'/..'.'/../lib/Controller/ShareAPIController.php', | |
| 46 | + 'OCA\\Files_Sharing\\Controller\\ShareController' => __DIR__.'/..'.'/../lib/Controller/ShareController.php', | |
| 47 | + 'OCA\\Files_Sharing\\Controller\\ShareInfoController' => __DIR__.'/..'.'/../lib/Controller/ShareInfoController.php', | |
| 48 | + 'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => __DIR__.'/..'.'/../lib/Controller/ShareesAPIController.php', | |
| 49 | + 'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => __DIR__.'/..'.'/../lib/DeleteOrphanedSharesJob.php', | |
| 50 | + 'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => __DIR__.'/..'.'/../lib/Exceptions/BrokenPath.php', | |
| 51 | + 'OCA\\Files_Sharing\\Exceptions\\S2SException' => __DIR__.'/..'.'/../lib/Exceptions/S2SException.php', | |
| 52 | + 'OCA\\Files_Sharing\\Exceptions\\SharingRightsException' => __DIR__.'/..'.'/../lib/Exceptions/SharingRightsException.php', | |
| 53 | + 'OCA\\Files_Sharing\\ExpireSharesJob' => __DIR__.'/..'.'/../lib/ExpireSharesJob.php', | |
| 54 | + 'OCA\\Files_Sharing\\External\\Cache' => __DIR__.'/..'.'/../lib/External/Cache.php', | |
| 55 | + 'OCA\\Files_Sharing\\External\\Manager' => __DIR__.'/..'.'/../lib/External/Manager.php', | |
| 56 | + 'OCA\\Files_Sharing\\External\\Mount' => __DIR__.'/..'.'/../lib/External/Mount.php', | |
| 57 | + 'OCA\\Files_Sharing\\External\\MountProvider' => __DIR__.'/..'.'/../lib/External/MountProvider.php', | |
| 58 | + 'OCA\\Files_Sharing\\External\\Scanner' => __DIR__.'/..'.'/../lib/External/Scanner.php', | |
| 59 | + 'OCA\\Files_Sharing\\External\\Storage' => __DIR__.'/..'.'/../lib/External/Storage.php', | |
| 60 | + 'OCA\\Files_Sharing\\External\\Watcher' => __DIR__.'/..'.'/../lib/External/Watcher.php', | |
| 61 | + 'OCA\\Files_Sharing\\Helper' => __DIR__.'/..'.'/../lib/Helper.php', | |
| 62 | + 'OCA\\Files_Sharing\\Hooks' => __DIR__.'/..'.'/../lib/Hooks.php', | |
| 63 | + 'OCA\\Files_Sharing\\ISharedStorage' => __DIR__.'/..'.'/../lib/ISharedStorage.php', | |
| 64 | + 'OCA\\Files_Sharing\\Listener\\GlobalShareAcceptanceListener' => __DIR__.'/..'.'/../lib/Listener/GlobalShareAcceptanceListener.php', | |
| 65 | + 'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => __DIR__.'/..'.'/../lib/Listener/LoadAdditionalListener.php', | |
| 66 | + 'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => __DIR__.'/..'.'/../lib/Listener/LoadSidebarListener.php', | |
| 67 | + 'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => __DIR__.'/..'.'/../lib/Middleware/OCSShareAPIMiddleware.php', | |
| 68 | + 'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => __DIR__.'/..'.'/../lib/Middleware/ShareInfoMiddleware.php', | |
| 69 | + 'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => __DIR__.'/..'.'/../lib/Middleware/SharingCheckMiddleware.php', | |
| 70 | + 'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => __DIR__.'/..'.'/../lib/Migration/OwncloudGuestShareType.php', | |
| 71 | + 'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => __DIR__.'/..'.'/../lib/Migration/SetAcceptedStatus.php', | |
| 72 | + 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => __DIR__.'/..'.'/../lib/Migration/SetPasswordColumn.php', | |
| 73 | + 'OCA\\Files_Sharing\\MountProvider' => __DIR__.'/..'.'/../lib/MountProvider.php', | |
| 74 | + 'OCA\\Files_Sharing\\Notification\\Listener' => __DIR__.'/..'.'/../lib/Notification/Listener.php', | |
| 75 | + 'OCA\\Files_Sharing\\Notification\\Notifier' => __DIR__.'/..'.'/../lib/Notification/Notifier.php', | |
| 76 | + 'OCA\\Files_Sharing\\Scanner' => __DIR__.'/..'.'/../lib/Scanner.php', | |
| 77 | + 'OCA\\Files_Sharing\\ShareBackend\\File' => __DIR__.'/..'.'/../lib/ShareBackend/File.php', | |
| 78 | + 'OCA\\Files_Sharing\\ShareBackend\\Folder' => __DIR__.'/..'.'/../lib/ShareBackend/Folder.php', | |
| 79 | + 'OCA\\Files_Sharing\\SharedMount' => __DIR__.'/..'.'/../lib/SharedMount.php', | |
| 80 | + 'OCA\\Files_Sharing\\SharedStorage' => __DIR__.'/..'.'/../lib/SharedStorage.php', | |
| 81 | + 'OCA\\Files_Sharing\\Updater' => __DIR__.'/..'.'/../lib/Updater.php', | |
| 82 | 82 | ); | 
| 83 | 83 | |
| 84 | 84 | public static function getInitializer(ClassLoader $loader) | 
| 85 | 85 |      { | 
| 86 | -        return \Closure::bind(function () use ($loader) { | |
| 86 | +        return \Closure::bind(function() use ($loader) { | |
| 87 | 87 | $loader->prefixLengthsPsr4 = ComposerStaticInitFiles_Sharing::$prefixLengthsPsr4; | 
| 88 | 88 | $loader->prefixDirsPsr4 = ComposerStaticInitFiles_Sharing::$prefixDirsPsr4; | 
| 89 | 89 | $loader->classMap = ComposerStaticInitFiles_Sharing::$classMap; | 
| @@ -6,62 +6,62 @@ | ||
| 6 | 6 | $baseDir = $vendorDir; | 
| 7 | 7 | |
| 8 | 8 | return array( | 
| 9 | - 'OCA\\Files_Sharing\\Activity\\Filter' => $baseDir . '/../lib/Activity/Filter.php', | |
| 10 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Base' => $baseDir . '/../lib/Activity/Providers/Base.php', | |
| 11 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => $baseDir . '/../lib/Activity/Providers/Downloads.php', | |
| 12 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => $baseDir . '/../lib/Activity/Providers/Groups.php', | |
| 13 | - 'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => $baseDir . '/../lib/Activity/Providers/PublicLinks.php', | |
| 14 | - 'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => $baseDir . '/../lib/Activity/Providers/RemoteShares.php', | |
| 15 | - 'OCA\\Files_Sharing\\Activity\\Providers\\Users' => $baseDir . '/../lib/Activity/Providers/Users.php', | |
| 16 | - 'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => $baseDir . '/../lib/Activity/Settings/PublicLinks.php', | |
| 17 | - 'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => $baseDir . '/../lib/Activity/Settings/RemoteShare.php', | |
| 18 | - 'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => $baseDir . '/../lib/Activity/Settings/Shared.php', | |
| 19 | - 'OCA\\Files_Sharing\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', | |
| 20 | - 'OCA\\Files_Sharing\\BackgroundJob\\FederatedSharesDiscoverJob' => $baseDir . '/../lib/BackgroundJob/FederatedSharesDiscoverJob.php', | |
| 21 | - 'OCA\\Files_Sharing\\Cache' => $baseDir . '/../lib/Cache.php', | |
| 22 | - 'OCA\\Files_Sharing\\Capabilities' => $baseDir . '/../lib/Capabilities.php', | |
| 23 | - 'OCA\\Files_Sharing\\Collaboration\\ShareRecipientSorter' => $baseDir . '/../lib/Collaboration/ShareRecipientSorter.php', | |
| 24 | - 'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => $baseDir . '/../lib/Command/CleanupRemoteStorages.php', | |
| 25 | - 'OCA\\Files_Sharing\\Command\\ExiprationNotification' => $baseDir . '/../lib/Command/ExiprationNotification.php', | |
| 26 | - 'OCA\\Files_Sharing\\Controller\\DeletedShareAPIController' => $baseDir . '/../lib/Controller/DeletedShareAPIController.php', | |
| 27 | - 'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => $baseDir . '/../lib/Controller/ExternalSharesController.php', | |
| 28 | - 'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => $baseDir . '/../lib/Controller/PublicPreviewController.php', | |
| 29 | - 'OCA\\Files_Sharing\\Controller\\RemoteController' => $baseDir . '/../lib/Controller/RemoteController.php', | |
| 30 | - 'OCA\\Files_Sharing\\Controller\\ShareAPIController' => $baseDir . '/../lib/Controller/ShareAPIController.php', | |
| 31 | - 'OCA\\Files_Sharing\\Controller\\ShareController' => $baseDir . '/../lib/Controller/ShareController.php', | |
| 32 | - 'OCA\\Files_Sharing\\Controller\\ShareInfoController' => $baseDir . '/../lib/Controller/ShareInfoController.php', | |
| 33 | - 'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => $baseDir . '/../lib/Controller/ShareesAPIController.php', | |
| 34 | - 'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => $baseDir . '/../lib/DeleteOrphanedSharesJob.php', | |
| 35 | - 'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => $baseDir . '/../lib/Exceptions/BrokenPath.php', | |
| 36 | - 'OCA\\Files_Sharing\\Exceptions\\S2SException' => $baseDir . '/../lib/Exceptions/S2SException.php', | |
| 37 | - 'OCA\\Files_Sharing\\Exceptions\\SharingRightsException' => $baseDir . '/../lib/Exceptions/SharingRightsException.php', | |
| 38 | - 'OCA\\Files_Sharing\\ExpireSharesJob' => $baseDir . '/../lib/ExpireSharesJob.php', | |
| 39 | - 'OCA\\Files_Sharing\\External\\Cache' => $baseDir . '/../lib/External/Cache.php', | |
| 40 | - 'OCA\\Files_Sharing\\External\\Manager' => $baseDir . '/../lib/External/Manager.php', | |
| 41 | - 'OCA\\Files_Sharing\\External\\Mount' => $baseDir . '/../lib/External/Mount.php', | |
| 42 | - 'OCA\\Files_Sharing\\External\\MountProvider' => $baseDir . '/../lib/External/MountProvider.php', | |
| 43 | - 'OCA\\Files_Sharing\\External\\Scanner' => $baseDir . '/../lib/External/Scanner.php', | |
| 44 | - 'OCA\\Files_Sharing\\External\\Storage' => $baseDir . '/../lib/External/Storage.php', | |
| 45 | - 'OCA\\Files_Sharing\\External\\Watcher' => $baseDir . '/../lib/External/Watcher.php', | |
| 46 | - 'OCA\\Files_Sharing\\Helper' => $baseDir . '/../lib/Helper.php', | |
| 47 | - 'OCA\\Files_Sharing\\Hooks' => $baseDir . '/../lib/Hooks.php', | |
| 48 | - 'OCA\\Files_Sharing\\ISharedStorage' => $baseDir . '/../lib/ISharedStorage.php', | |
| 49 | - 'OCA\\Files_Sharing\\Listener\\GlobalShareAcceptanceListener' => $baseDir . '/../lib/Listener/GlobalShareAcceptanceListener.php', | |
| 50 | - 'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => $baseDir . '/../lib/Listener/LoadAdditionalListener.php', | |
| 51 | - 'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => $baseDir . '/../lib/Listener/LoadSidebarListener.php', | |
| 52 | - 'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => $baseDir . '/../lib/Middleware/OCSShareAPIMiddleware.php', | |
| 53 | - 'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => $baseDir . '/../lib/Middleware/ShareInfoMiddleware.php', | |
| 54 | - 'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => $baseDir . '/../lib/Middleware/SharingCheckMiddleware.php', | |
| 55 | - 'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => $baseDir . '/../lib/Migration/OwncloudGuestShareType.php', | |
| 56 | - 'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => $baseDir . '/../lib/Migration/SetAcceptedStatus.php', | |
| 57 | - 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => $baseDir . '/../lib/Migration/SetPasswordColumn.php', | |
| 58 | - 'OCA\\Files_Sharing\\MountProvider' => $baseDir . '/../lib/MountProvider.php', | |
| 59 | - 'OCA\\Files_Sharing\\Notification\\Listener' => $baseDir . '/../lib/Notification/Listener.php', | |
| 60 | - 'OCA\\Files_Sharing\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php', | |
| 61 | - 'OCA\\Files_Sharing\\Scanner' => $baseDir . '/../lib/Scanner.php', | |
| 62 | - 'OCA\\Files_Sharing\\ShareBackend\\File' => $baseDir . '/../lib/ShareBackend/File.php', | |
| 63 | - 'OCA\\Files_Sharing\\ShareBackend\\Folder' => $baseDir . '/../lib/ShareBackend/Folder.php', | |
| 64 | - 'OCA\\Files_Sharing\\SharedMount' => $baseDir . '/../lib/SharedMount.php', | |
| 65 | - 'OCA\\Files_Sharing\\SharedStorage' => $baseDir . '/../lib/SharedStorage.php', | |
| 66 | - 'OCA\\Files_Sharing\\Updater' => $baseDir . '/../lib/Updater.php', | |
| 9 | + 'OCA\\Files_Sharing\\Activity\\Filter' => $baseDir.'/../lib/Activity/Filter.php', | |
| 10 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Base' => $baseDir.'/../lib/Activity/Providers/Base.php', | |
| 11 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => $baseDir.'/../lib/Activity/Providers/Downloads.php', | |
| 12 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => $baseDir.'/../lib/Activity/Providers/Groups.php', | |
| 13 | + 'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => $baseDir.'/../lib/Activity/Providers/PublicLinks.php', | |
| 14 | + 'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => $baseDir.'/../lib/Activity/Providers/RemoteShares.php', | |
| 15 | + 'OCA\\Files_Sharing\\Activity\\Providers\\Users' => $baseDir.'/../lib/Activity/Providers/Users.php', | |
| 16 | + 'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => $baseDir.'/../lib/Activity/Settings/PublicLinks.php', | |
| 17 | + 'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => $baseDir.'/../lib/Activity/Settings/RemoteShare.php', | |
| 18 | + 'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => $baseDir.'/../lib/Activity/Settings/Shared.php', | |
| 19 | + 'OCA\\Files_Sharing\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php', | |
| 20 | + 'OCA\\Files_Sharing\\BackgroundJob\\FederatedSharesDiscoverJob' => $baseDir.'/../lib/BackgroundJob/FederatedSharesDiscoverJob.php', | |
| 21 | + 'OCA\\Files_Sharing\\Cache' => $baseDir.'/../lib/Cache.php', | |
| 22 | + 'OCA\\Files_Sharing\\Capabilities' => $baseDir.'/../lib/Capabilities.php', | |
| 23 | + 'OCA\\Files_Sharing\\Collaboration\\ShareRecipientSorter' => $baseDir.'/../lib/Collaboration/ShareRecipientSorter.php', | |
| 24 | + 'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => $baseDir.'/../lib/Command/CleanupRemoteStorages.php', | |
| 25 | + 'OCA\\Files_Sharing\\Command\\ExiprationNotification' => $baseDir.'/../lib/Command/ExiprationNotification.php', | |
| 26 | + 'OCA\\Files_Sharing\\Controller\\DeletedShareAPIController' => $baseDir.'/../lib/Controller/DeletedShareAPIController.php', | |
| 27 | + 'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => $baseDir.'/../lib/Controller/ExternalSharesController.php', | |
| 28 | + 'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => $baseDir.'/../lib/Controller/PublicPreviewController.php', | |
| 29 | + 'OCA\\Files_Sharing\\Controller\\RemoteController' => $baseDir.'/../lib/Controller/RemoteController.php', | |
| 30 | + 'OCA\\Files_Sharing\\Controller\\ShareAPIController' => $baseDir.'/../lib/Controller/ShareAPIController.php', | |
| 31 | + 'OCA\\Files_Sharing\\Controller\\ShareController' => $baseDir.'/../lib/Controller/ShareController.php', | |
| 32 | + 'OCA\\Files_Sharing\\Controller\\ShareInfoController' => $baseDir.'/../lib/Controller/ShareInfoController.php', | |
| 33 | + 'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => $baseDir.'/../lib/Controller/ShareesAPIController.php', | |
| 34 | + 'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => $baseDir.'/../lib/DeleteOrphanedSharesJob.php', | |
| 35 | + 'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => $baseDir.'/../lib/Exceptions/BrokenPath.php', | |
| 36 | + 'OCA\\Files_Sharing\\Exceptions\\S2SException' => $baseDir.'/../lib/Exceptions/S2SException.php', | |
| 37 | + 'OCA\\Files_Sharing\\Exceptions\\SharingRightsException' => $baseDir.'/../lib/Exceptions/SharingRightsException.php', | |
| 38 | + 'OCA\\Files_Sharing\\ExpireSharesJob' => $baseDir.'/../lib/ExpireSharesJob.php', | |
| 39 | + 'OCA\\Files_Sharing\\External\\Cache' => $baseDir.'/../lib/External/Cache.php', | |
| 40 | + 'OCA\\Files_Sharing\\External\\Manager' => $baseDir.'/../lib/External/Manager.php', | |
| 41 | + 'OCA\\Files_Sharing\\External\\Mount' => $baseDir.'/../lib/External/Mount.php', | |
| 42 | + 'OCA\\Files_Sharing\\External\\MountProvider' => $baseDir.'/../lib/External/MountProvider.php', | |
| 43 | + 'OCA\\Files_Sharing\\External\\Scanner' => $baseDir.'/../lib/External/Scanner.php', | |
| 44 | + 'OCA\\Files_Sharing\\External\\Storage' => $baseDir.'/../lib/External/Storage.php', | |
| 45 | + 'OCA\\Files_Sharing\\External\\Watcher' => $baseDir.'/../lib/External/Watcher.php', | |
| 46 | + 'OCA\\Files_Sharing\\Helper' => $baseDir.'/../lib/Helper.php', | |
| 47 | + 'OCA\\Files_Sharing\\Hooks' => $baseDir.'/../lib/Hooks.php', | |
| 48 | + 'OCA\\Files_Sharing\\ISharedStorage' => $baseDir.'/../lib/ISharedStorage.php', | |
| 49 | + 'OCA\\Files_Sharing\\Listener\\GlobalShareAcceptanceListener' => $baseDir.'/../lib/Listener/GlobalShareAcceptanceListener.php', | |
| 50 | + 'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => $baseDir.'/../lib/Listener/LoadAdditionalListener.php', | |
| 51 | + 'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => $baseDir.'/../lib/Listener/LoadSidebarListener.php', | |
| 52 | + 'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => $baseDir.'/../lib/Middleware/OCSShareAPIMiddleware.php', | |
| 53 | + 'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => $baseDir.'/../lib/Middleware/ShareInfoMiddleware.php', | |
| 54 | + 'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => $baseDir.'/../lib/Middleware/SharingCheckMiddleware.php', | |
| 55 | + 'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => $baseDir.'/../lib/Migration/OwncloudGuestShareType.php', | |
| 56 | + 'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => $baseDir.'/../lib/Migration/SetAcceptedStatus.php', | |
| 57 | + 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => $baseDir.'/../lib/Migration/SetPasswordColumn.php', | |
| 58 | + 'OCA\\Files_Sharing\\MountProvider' => $baseDir.'/../lib/MountProvider.php', | |
| 59 | + 'OCA\\Files_Sharing\\Notification\\Listener' => $baseDir.'/../lib/Notification/Listener.php', | |
| 60 | + 'OCA\\Files_Sharing\\Notification\\Notifier' => $baseDir.'/../lib/Notification/Notifier.php', | |
| 61 | + 'OCA\\Files_Sharing\\Scanner' => $baseDir.'/../lib/Scanner.php', | |
| 62 | + 'OCA\\Files_Sharing\\ShareBackend\\File' => $baseDir.'/../lib/ShareBackend/File.php', | |
| 63 | + 'OCA\\Files_Sharing\\ShareBackend\\Folder' => $baseDir.'/../lib/ShareBackend/Folder.php', | |
| 64 | + 'OCA\\Files_Sharing\\SharedMount' => $baseDir.'/../lib/SharedMount.php', | |
| 65 | + 'OCA\\Files_Sharing\\SharedStorage' => $baseDir.'/../lib/SharedStorage.php', | |
| 66 | + 'OCA\\Files_Sharing\\Updater' => $baseDir.'/../lib/Updater.php', | |
| 67 | 67 | ); |