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; }
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); } }