/** * @param MetaWatchRegister|false $watcher * @param ShareRightsManager $rightsManager * @param PublicAccessManager $publicAccessManager * @param array $messages * @return array|false */ public function toJson($watcher, $rightsManager, $publicAccessManager, $messages) { $repoRootNode = new AJXP_Node("pydio://" . $this->getRepositoryId() . "/"); $elementWatch = false; if ($watcher != false) { $elementWatch = $watcher->hasWatchOnNode($repoRootNode, AuthService::getLoggedUser()->getId(), MetaWatchRegister::$META_WATCH_NAMESPACE); } $sharedEntries = $rightsManager->computeSharedRepositoryAccessRights($this->getRepositoryId(), true, $repoRootNode); if (empty($sharedEntries)) { return false; } $cFilter = $this->getRepository()->getContentFilter(); if (!empty($cFilter)) { $cFilter = $cFilter->toArray(); } $jsonData = array("repositoryId" => $this->getRepositoryId(), "users_number" => AuthService::countUsersForRepository($this->getRepositoryId()), "label" => $this->getRepository()->getDisplay(), "description" => $this->getRepository()->getDescription(), "entries" => $sharedEntries, "element_watch" => $elementWatch, "repository_url" => AJXP_Utils::getWorkspaceShortcutURL($this->getRepository()) . "/", "content_filter" => $cFilter, "share_owner" => $this->getOwner(), "share_scope" => $this->getVisibilityScope()); $jsonData["links"] = array(); foreach ($this->shareLinks as $shareLink) { $uniqueUser = $shareLink->getUniqueUser(); $found = false; foreach ($sharedEntries as $entry) { if ($entry["ID"] == $uniqueUser) { $found = true; } } if (!$found) { // STRANGE, THE ASSOCIATED USER IS MISSING error_log("Found shareLink orphan with uniqueUser " . $uniqueUser); continue; } $jsonData["links"][$shareLink->getHash()] = $shareLink->getJsonData($publicAccessManager, $messages); } return $jsonData; }