public function switchActions($actionName, $httpVars, $fileVars) { switch ($actionName) { case "accept_invitation": $remoteShareId = \AJXP_Utils::sanitize($httpVars["remote_share_id"], AJXP_SANITIZE_ALPHANUM); $store = new SQLStore(); $remoteShare = $store->remoteShareById($remoteShareId); if ($remoteShare !== null) { $client = new OCSClient(); $client->acceptInvitation($remoteShare); $remoteShare->setStatus(OCS_INVITATION_STATUS_ACCEPTED); $store->storeRemoteShare($remoteShare); } break; case "reject_invitation": $remoteShareId = \AJXP_Utils::sanitize($httpVars["remote_share_id"], AJXP_SANITIZE_ALPHANUM); $store = new SQLStore(); $remoteShare = $store->remoteShareById($remoteShareId); if ($remoteShare !== null) { $client = new OCSClient(); $client->declineInvitation($remoteShare); $store->deleteRemoteShare($remoteShare); \ConfService::getInstance()->invalidateLoadedRepositories(); } break; default: break; } return null; }
public function remoteRepositoryById($repositoryId, &$repoObject) { if (strpos($repositoryId, "ocs_remote_share_") !== 0) { return; } $store = new Model\SQLStore(); $remoteShareId = str_replace("ocs_remote_share_", "", $repositoryId); $share = $store->remoteShareById($remoteShareId); if ($share != null) { $repoObject = $share->buildVirtualRepository(); $loggedUser = \AuthService::getLoggedUser(); if ($loggedUser != null) { $loggedUser->personalRole->setAcl($repoObject->getId(), "rw"); $loggedUser->recomputeMergedRole(); \AuthService::updateUser($loggedUser); } } }
protected function actionUnshare($remoteId, $token, $parameters) { $token = \AJXP_Utils::sanitize($token, AJXP_SANITIZE_ALPHANUM); $remoteId = \AJXP_Utils::sanitize($remoteId, AJXP_SANITIZE_ALPHANUM); $store = new SQLStore(); $remoteShare = $store->remoteShareForOcsRemoteId($remoteId); if (empty($remoteShare)) { throw new InvalidArgumentsException(); } if ($token !== $remoteShare->getOcsToken()) { throw new InvalidArgumentsException(); } $targetUser = $remoteShare->getUser(); $store->deleteRemoteShare($remoteShare); $response = $this->buildResponse("ok", 200, "Successfully removed share."); $this->sendResponse($response, $this->getFormat($parameters)); $userRole = \AuthService::getRole("AJXP_USR_/" . $targetUser); if ($userRole !== false) { // Artificially "touch" user role // to force repositories reload if he is logged in \AuthService::updateRole($userRole); } }