/** * @param array $httpVars * @param ShareLink $shareObject * @param bool $update * @param null $guestUserPass * @return array * @throws Exception */ public function prepareSharedUserEntry($httpVars, &$shareObject, $update, $guestUserPass = null) { $userPass = null; $forcePassword = $this->options["SHARE_FORCE_PASSWORD"]; if ($forcePassword && (isset($httpVars["create_guest_user"]) && $httpVars["create_guest_user"] == "true" && empty($guestUserPass) || isset($httpVars["guest_user_id"]) && isset($guestUserPass) && strlen($guestUserPass) == 0)) { $mess = ConfService::getMessages(); throw new Exception($mess["share_center.175"]); } if ($update) { // THIS IS AN EXISTING SHARE // FIND SHARE AND EXISTING HIDDEN USER ID if ($shareObject->isAttachedToRepository()) { $existingRepo = $shareObject->getRepository(); $this->store->testUserCanEditShare($existingRepo->getOwner(), $existingRepo->options); } $uniqueUser = $shareObject->getUniqueUser(); if ($guestUserPass !== null && strlen($guestUserPass)) { $userPass = $guestUserPass; $shareObject->setUniqueUser($uniqueUser, true); } else { if (!$shareObject->shouldRequirePassword() || $guestUserPass !== null && $guestUserPass == "") { $shareObject->setUniqueUser($uniqueUser, false); } } if ($update && $forcePassword && !$shareObject instanceof \Pydio\OCS\Model\TargettedLink && !$shareObject->shouldRequirePassword() && empty($guestUserPass)) { $mess = ConfService::getMessages(); throw new Exception($mess["share_center.175"]); } } else { $update = false; $shareObject->createHiddenUserId($this->options["SHARED_USERS_TMP_PREFIX"], !empty($guestUserPass)); if (!empty($guestUserPass)) { $userPass = $guestUserPass; } else { $userPass = $shareObject->createHiddenUserPassword(); } $uniqueUser = $shareObject->getUniqueUser(); } $hiddenUserEntry = $this->createHiddenUserEntry($httpVars, $uniqueUser, $userPass, $update); if (empty($hiddenUserEntry["RIGHT"])) { $mess = ConfService::getMessages(); throw new Exception($mess["share_center.58"]); } $hiddenUserEntry["DISABLE_DOWNLOAD"] = $shareObject->disableDownload(); if ($shareObject instanceof \Pydio\OCS\Model\TargettedLink) { $hiddenUserEntry["REMOTE"] = true; } return $hiddenUserEntry; }