function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } $create = $this->repository->getOption("CREATE"); $path = $this->repository->getOption("PATH"); $recycle = $this->repository->getOption("RECYCLE_BIN"); if ($create == true) { if (!is_dir($path)) { @mkdir($path); } if (!is_dir($path)) { throw new AJXP_Exception("Cannot create root path for repository (" . $this->repository->getDisplay() . "). Please check repository configuration or that your folder is writeable!"); } if ($recycle != "" && !is_dir($path . "/" . $recycle)) { @mkdir($path . "/" . $recycle); if (!is_dir($path . "/" . $recycle)) { throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!"); } } } else { if (!is_dir($path)) { throw new AJXP_Exception("Cannot find base path for your repository! Please check the configuration!"); } } $wrapperData = $this->detectStreamWrapper(true); $this->wrapperClassName = $wrapperData["classname"]; $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
public function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } if ($this->getFilteredOption("PROBE_REAL_SIZE", $this->repository->getId()) == true) { // PASS IT TO THE WRAPPER ConfService::setConf("PROBE_REAL_SIZE", $this->getFilteredOption("PROBE_REAL_SIZE", $this->repository->getId())); } $create = $this->repository->getOption("CREATE"); $path = SystemTextEncoding::toStorageEncoding($this->repository->getOption("PATH")); $recycle = $this->repository->getOption("RECYCLE_BIN"); $chmod = $this->repository->getOption("CHMOD_VALUE"); $wrapperData = $this->detectStreamWrapper(true); $this->wrapperClassName = $wrapperData["classname"]; $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); if ($create == true) { if (!is_dir($path)) { @mkdir($path, 0755, true); } if (!is_dir($path)) { throw new AJXP_Exception("Cannot create root path for repository (" . $this->repository->getDisplay() . "). Please check repository configuration or that your folder is writeable!"); } if ($recycle != "" && !is_dir($path . "/" . $recycle)) { @mkdir($path . "/" . $recycle); if (!is_dir($path . "/" . $recycle)) { throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!"); } elseif (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { AJXP_Utils::winSetHidden($path . "/" . $recycle); } } $dataTemplate = $this->repository->getOption("DATA_TEMPLATE"); if (!empty($dataTemplate) && is_dir($dataTemplate) && !is_file($path . "/.ajxp_template")) { $errs = array(); $succ = array(); $repoData = array('base_url' => $this->urlBase, 'wrapper_name' => $this->wrapperClassName, 'chmod' => $chmod, 'recycle' => $recycle); $this->dircopy($dataTemplate, $path, $succ, $errs, false, false, $repoData, $repoData); touch($path . "/.ajxp_template"); } } else { if (!is_dir($path)) { throw new AJXP_Exception("Cannot find base path for your repository! Please check the configuration!"); } } if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } if (isset($this->pluginConf["PROBE_REAL_SIZE"])) { // PASS IT TO THE WRAPPER ConfService::setConf("PROBE_REAL_SIZE", $this->pluginConf["PROBE_REAL_SIZE"]); } $create = $this->repository->getOption("CREATE"); $path = $this->repository->getOption("PATH"); $recycle = $this->repository->getOption("RECYCLE_BIN"); if ($create == true) { if (!is_dir($path)) { @mkdir($path, 0755, true); } if (!is_dir($path)) { throw new AJXP_Exception("Cannot create root path for repository (" . $this->repository->getDisplay() . "). Please check repository configuration or that your folder is writeable!"); } if ($recycle != "" && !is_dir($path . "/" . $recycle)) { @mkdir($path . "/" . $recycle); if (!is_dir($path . "/" . $recycle)) { throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!"); } } $dataTemplate = $this->repository->getOption("DATA_TEMPLATE"); if (!empty($dataTemplate) && is_dir($dataTemplate) && !is_file($path . "/.ajxp_template")) { $errs = array(); $succ = array(); $this->dircopy($dataTemplate, $path, $succ, $errs, false, false); touch($path . "/.ajxp_template"); } } else { if (!is_dir($path)) { throw new AJXP_Exception("Cannot find base path for your repository! Please check the configuration!"); } } $wrapperData = $this->detectStreamWrapper(true); $this->wrapperClassName = $wrapperData["classname"]; $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
/** * @param string $repoId * @param Repository $repoObject * @param array $exposed * @param array $streams * @param AbstractAjxpUser $loggedUser * @param string $accessStatus * @return string * @throws Exception */ public static function repositoryToXML($repoId, $repoObject, $exposed, $streams, $loggedUser, $accessStatus = "") { $statusString = " repository_type=\"" . $repoObject->getRepositoryType() . "\""; if (empty($accessStatus)) { $accessStatus = $repoObject->getAccessStatus(); } if (!empty($accessStatus)) { $statusString .= " access_status=\"{$accessStatus}\" "; } else { if ($loggedUser != null) { $lastConnected = $loggedUser->getArrayPref("repository_last_connected", $repoId); if (!empty($lastConnected)) { $statusString .= " last_connection=\"{$lastConnected}\" "; } } } $streamString = ""; if (in_array($repoObject->accessType, $streams)) { $streamString = "allowCrossRepositoryCopy=\"true\""; } if ($repoObject->getUniqueUser()) { $streamString .= " user_editable_repository=\"true\" "; } if ($repoObject->hasContentFilter()) { $streamString .= " hasContentFilter=\"true\""; } $slugString = ""; $slug = $repoObject->getSlug(); if (!empty($slug)) { $slugString = "repositorySlug=\"{$slug}\""; } $isSharedString = ""; $currentUserIsOwner = false; $ownerLabel = null; if ($repoObject->hasOwner()) { $uId = $repoObject->getOwner(); if (AuthService::usersEnabled() && AuthService::getLoggedUser()->getId() == $uId) { $currentUserIsOwner = true; } $label = ConfService::getUserPersonalParameter("USER_DISPLAY_NAME", $uId, "core.conf", $uId); $ownerLabel = $label; $isSharedString = 'owner="' . AJXP_Utils::xmlEntities($label) . '"'; } if ($repoObject->securityScope() == "USER" || $currentUserIsOwner) { $streamString .= " userScope=\"true\""; } $descTag = ""; $public = false; if (!empty($_SESSION["CURRENT_MINISITE"])) { $public = true; } $description = $repoObject->getDescription($public, $ownerLabel); if (!empty($description)) { $descTag = '<description>' . AJXP_Utils::xmlEntities($description, true) . '</description>'; } $roleString = ""; if ($loggedUser != null) { $merged = $loggedUser->mergedRole; $params = array(); foreach ($exposed as $exposed_prop) { $metaOptions = $repoObject->getOption("META_SOURCES"); if (!isset($metaOptions[$exposed_prop["PLUGIN_ID"]])) { continue; } $value = $exposed_prop["DEFAULT"]; if (isset($metaOptions[$exposed_prop["PLUGIN_ID"]][$exposed_prop["NAME"]])) { $value = $metaOptions[$exposed_prop["PLUGIN_ID"]][$exposed_prop["NAME"]]; } $value = $merged->filterParameterValue($exposed_prop["PLUGIN_ID"], $exposed_prop["NAME"], $repoId, $value); if ($value !== null) { if ($value === true || $value === false) { $value = $value === true ? "true" : "false"; } $params[] = '<repository_plugin_param plugin_id="' . $exposed_prop["PLUGIN_ID"] . '" name="' . $exposed_prop["NAME"] . '" value="' . AJXP_Utils::xmlEntities($value) . '"/>'; $roleString .= str_replace(".", "_", $exposed_prop["PLUGIN_ID"]) . "_" . $exposed_prop["NAME"] . '="' . AJXP_Utils::xmlEntities($value) . '" '; } } $roleString .= 'acl="' . $merged->getAcl($repoId) . '"'; if ($merged->hasMask($repoId)) { $roleString .= ' hasMask="true" '; } } return "<repo access_type=\"" . $repoObject->accessType . "\" id=\"" . $repoId . "\"{$statusString} {$streamString} {$slugString} {$isSharedString} {$roleString}><label>" . SystemTextEncoding::toUTF8(AJXP_Utils::xmlEntities($repoObject->getDisplay())) . "</label>" . $descTag . $repoObject->getClientSettings() . "</repo>"; }
/** * @param Repository $a * @param Repository $b * @return integer */ public function sortReposByLabel($a, $b) { return strcasecmp($a->getDisplay(), $b->getDisplay()); }
/** * @param Repository $parentRepository * @param Repository $childRepository * @param bool $isUpdate * @param array $users * @param array $groups * @param UserSelection $selection * @param bool|false $disableDownload * @throws Exception */ public function assignSharedRepositoryPermissions($parentRepository, $childRepository, $isUpdate, $users, $groups, $selection) { $childRepoId = $childRepository->getId(); if ($isUpdate) { $this->unregisterRemovedUsers($childRepoId, $users, $groups, $selection->getUniqueNode()); } $confDriver = ConfService::getConfStorageImpl(); $loggedUser = AuthService::getLoggedUser(); foreach ($users as $userName => $userEntry) { if (AuthService::userExists($userName, "r")) { $userObject = $confDriver->createUserObject($userName); if (isset($userEntry["HIDDEN"]) && isset($userEntry["UPDATE_PASSWORD"])) { AuthService::updatePassword($userName, $userEntry["UPDATE_PASSWORD"]); } } else { $mess = ConfService::getMessages(); $hiddenUserLabel = "[" . $mess["share_center.109"] . "] " . AJXP_Utils::sanitize($childRepository->getDisplay(), AJXP_SANITIZE_EMAILCHARS); $userObject = $this->createNewUser($loggedUser, $userName, $userEntry["PASSWORD"], isset($userEntry["HIDDEN"]), $hiddenUserLabel); } // ASSIGN NEW REPO RIGHTS $userObject->personalRole->setAcl($childRepoId, $userEntry["RIGHT"]); // FORK MASK IF THERE IS ANY $childMask = $this->forkMaskIfAny($loggedUser, $parentRepository->getId(), $selection->getUniqueNode()); if ($childMask != null) { $userObject->personalRole->setMask($childRepoId, $childMask); } // CREATE A MINISITE-LIKE ROLE FOR THIS REPOSITORY if (isset($userEntry["HIDDEN"]) && !isset($userEntry["REMOTE"])) { $minisiteRole = $this->createRoleForMinisite($childRepoId, $userEntry["DISABLE_DOWNLOAD"], $isUpdate); if ($minisiteRole != null) { $userObject->addRole($minisiteRole); } } // ADD "my shared files" REPO OTHERWISE SOME USER CANNOT ACCESS if (!isset($userEntry["HIDDEN"]) && $childRepository->hasContentFilter()) { $inboxRepo = ConfService::getRepositoryById("inbox"); $currentAcl = $userObject->mergedRole->getAcl("inbox"); if ($inboxRepo !== null && empty($currentAcl)) { $userObject->personalRole->setAcl("inbox", "rw"); } } $userObject->save("superuser"); } foreach ($groups as $group => $groupEntry) { $r = $groupEntry["RIGHT"]; $grRole = AuthService::getRole($group, true); $grRole->setAcl($childRepoId, $r); AuthService::updateRole($grRole); } }