Permalink
Browse files

Changing the Stream wrappers way

  • Loading branch information...
1 parent 7ec6edf commit f90150f76fc7b283a5a657b8fe4c212bbfd7f567 @ghecquet ghecquet committed Jun 22, 2016
Showing with 2,473 additions and 3,055 deletions.
  1. +0 −163 core/src/plugins/access.dropbox/class.dropboxAccessDriver.php
  2. +0 −315 core/src/plugins/access.dropbox/class.dropboxWrapper.php
  3. +11 −0 core/src/plugins/access.dropbox/composer.json
  4. +0 −346 core/src/plugins/access.dropbox/dropbox-php/API.php
  5. +0 −15 core/src/plugins/access.dropbox/dropbox-php/Exception.php
  6. +0 −18 core/src/plugins/access.dropbox/dropbox-php/Exception/Forbidden.php
  7. +0 −20 core/src/plugins/access.dropbox/dropbox-php/Exception/NotFound.php
  8. +0 −20 core/src/plugins/access.dropbox/dropbox-php/Exception/OverQuota.php
  9. +0 −18 core/src/plugins/access.dropbox/dropbox-php/Exception/RequestToken.php
  10. +0 −151 core/src/plugins/access.dropbox/dropbox-php/OAuth.php
  11. +0 −198 core/src/plugins/access.dropbox/dropbox-php/OAuth/PEAR.php
  12. +0 −147 core/src/plugins/access.dropbox/dropbox-php/OAuth/PHP.php
  13. +0 −223 core/src/plugins/access.dropbox/dropbox-php/OAuth/Wordpress.php
  14. +0 −244 core/src/plugins/access.dropbox/dropbox-php/OAuth/Zend.php
  15. +0 −29 core/src/plugins/access.dropbox/dropbox-php/autoload.php
  16. +13 −3 core/src/plugins/access.dropbox/manifest.xml
  17. +116 −0 core/src/plugins/access.dropbox/src/Driver.php
  18. +141 −0 core/src/plugins/access.dropbox/src/Listener/DropBoxSubscriber.php
  19. +192 −0 core/src/plugins/access.dropbox/src/Resources/dropbox.json
  20. +7 −0 core/src/plugins/access.dropbox/vendor/autoload.php
  21. +413 −0 core/src/plugins/access.dropbox/vendor/composer/ClassLoader.php
  22. +7 −5 core/src/plugins/access.dropbox/{dropbox-php → vendor/composer}/LICENSE
  23. +9 −0 core/src/plugins/access.dropbox/vendor/composer/autoload_classmap.php
  24. +9 −0 core/src/plugins/access.dropbox/vendor/composer/autoload_namespaces.php
  25. +11 −0 core/src/plugins/access.dropbox/vendor/composer/autoload_psr4.php
  26. +45 −0 core/src/plugins/access.dropbox/vendor/composer/autoload_real.php
  27. +1 −0 core/src/plugins/access.dropbox/vendor/composer/installed.json
  28. +3 −1 core/src/plugins/access.webdav/manifest.xml
  29. +4 −4 core/src/plugins/access.webdav/src/Client.php
  30. +53 −41 core/src/plugins/access.webdav/src/Driver.php
  31. +188 −0 core/src/plugins/access.webdav/src/Listener/WebDAVSubscriber.php
  32. +123 −18 core/src/plugins/access.webdav/src/Resources/dav.json
  33. +9 −4 core/src/plugins/core.access/src/AJXP_MetaStreamWrapper.php
  34. +0 −2 core/src/plugins/core.access/src/AbstractAccessDriver.php
  35. +51 −0 core/src/plugins/core.access/src/Stream/AuthStream.php
  36. +0 −114 core/src/plugins/core.access/src/Stream/Client.php
  37. +0 −73 core/src/plugins/core.access/src/Stream/ClientInterface.php
  38. +89 −0 core/src/plugins/core.access/src/Stream/MetadataCachingStream.php
  39. +197 −0 core/src/plugins/core.access/src/Stream/OAuthStream.php
  40. +0 −195 core/src/plugins/core.access/src/Stream/OAuthWrapper.php
  41. +0 −96 core/src/plugins/core.access/src/Stream/PathWrapper.php
  42. +125 −0 core/src/plugins/core.access/src/Stream/PydioStreamWrapper.php
  43. +417 −0 core/src/plugins/core.access/src/Stream/Stream.php
  44. +96 −591 core/src/plugins/core.access/src/Stream/StreamWrapper.php
  45. +94 −0 core/src/plugins/core.access/tests/Stream/StreamTest.php
  46. +46 −0 core/src/plugins/core.access/tests/Stream/test.json
  47. +3 −1 core/src/plugins/core.ajaxplorer/ajxp_mixins.xml
@@ -1,163 +0,0 @@
-<?php
-/*
- * Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
- * This file is part of Pydio.
- *
- * Pydio is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Pydio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with Pydio. If not, see <http://www.gnu.org/licenses/>.
- *
- * The latest code can be found at <http://pyd.io/>.
- *
- */
-namespace Pydio\Access\Driver\StreamProvider\Dropbox;
-
-use Pydio\Access\Core\Model\Repository;
-use Pydio\Access\Driver\StreamProvider\FS\fsAccessDriver;
-use Pydio\Core\Exception\PydioUserAlertException;
-use Pydio\Core\Model\ContextInterface;
-
-use Pydio\Core\Services\UsersService;
-use Pydio\Core\Utils\Utils;
-
-defined('AJXP_EXEC') or die( 'Access not allowed');
-
-/**
- * Plugin to access a dropbox account
- * @package AjaXplorer_Plugins
- * @subpackage Access
- */
-class dropboxAccessDriver extends fsAccessDriver
-{
- /**
- * @var Repository
- */
- public $repository;
- public $driverConf;
- protected $wrapperClassName;
- protected $urlBase;
-
- /**
- * @param ContextInterface $contextInterface
- * @throws PydioUserAlertException
- * @throws \Exception
- */
- protected function initRepository(ContextInterface $contextInterface)
- {
- if (is_array($this->pluginConf)) {
- $this->driverConf = $this->pluginConf;
- } else {
- $this->driverConf = array();
- }
-
- $this->urlBase =$contextInterface->getUrlBase();
-
- if (!Utils::searchIncludePath('HTTP/OAuth/Consumer.php')) {
- $this->logError("Dropbox", "The PEAR HTTP_OAuth package must be installed!");
- return;
- }
-
- $consumerKey = $this->repository->getContextOption($contextInterface, "CONSUMER_KEY");
- $consumerSecret = $this->repository->getContextOption($contextInterface, "CONSUMER_SECRET");
- $oauth = new \Dropbox_OAuth_PEAR($consumerKey, $consumerSecret);
-
- // TOKENS IN SESSION?
- if(!empty($_SESSION["OAUTH_DROPBOX_TOKENS"])) return;
-
- // TOKENS IN FILE ?
- $tokens = $this->getTokens($contextInterface);
- if (!empty($tokens)) {
- $_SESSION["OAUTH_DROPBOX_TOKENS"] = $tokens;
- return;
- }
-
- // OAUTH NEGOCIATION
- if (isset($_SESSION['DROPBOX_NEGOCIATION_STATE'])) {
- $state = $_SESSION['DROPBOX_NEGOCIATION_STATE'];
- } else {
- $state = 1;
- }
- switch ($state) {
-
- case 1 :
- $tokens = $oauth->getRequestToken();
- //print_r($tokens);
-
- // Note that if you want the user to automatically redirect back, you can
- // add the 'callback' argument to getAuthorizeUrl.
- //echo "Step 2: You must now redirect the user to:\n";
- $_SESSION['DROPBOX_NEGOCIATION_STATE'] = 2;
- $_SESSION['oauth_tokens'] = $tokens;
- throw new PydioUserAlertException("Please go to <a style=\"text-decoration:underline;\" target=\"_blank\" href=\"".$oauth->getAuthorizeUrl()."\">".$oauth->getAuthorizeUrl()."</a> to authorize the access to your dropbox. Then try again to switch to this workspace.");
-
- case 2 :
- $oauth->setToken($_SESSION['oauth_tokens']);
- try{
- $tokens = $oauth->getAccessToken();
- }catch(\Exception $oauthEx){
- throw new PydioUserAlertException($oauthEx->getMessage() . ". Please go to <a style=\"text-decoration:underline;\" target=\"_blank\" href=\"".$oauth->getAuthorizeUrl()."\">".$oauth->getAuthorizeUrl()."</a> to authorize the access to your dropbox. Then try again to switch to this workspace.");
- }
- $_SESSION['DROPBOX_NEGOCIATION_STATE'] = 3;
- $_SESSION['OAUTH_DROPBOX_TOKENS'] = $tokens;
- $this->setTokens($contextInterface, $tokens);
- return;
- }
-
- throw new \Exception("Impossible to find the dropbox tokens for accessing this workspace");
-
- }
-
- public function performChecks()
- {
- if (!Utils::searchIncludePath('HTTP/OAuth/Consumer.php')) {
- throw new \Exception("The PEAR HTTP_OAuth package must be installed!");
- }
- }
-
- public function isWriteable($dir, $type = "dir")
- {
- return true;
- }
-
- public function getTokens(ContextInterface $ctx)
- {
- $repo = $ctx->getRepository();
- if($repo->getContextOption($ctx, "DROPBOX_OAUTH_TOKENS") !== null && is_array($repo->getContextOption($ctx, "DROPBOX_OAUTH_TOKENS"))){
- return $repo->getContextOption($ctx, "DROPBOX_OAUTH_TOKENS");
- }
- $repositoryId = $repo->getId();
- if(UsersService::usersEnabled()) {
- $u = $ctx->getUser();
- $userId = $u->getId();
- }else {
- $userId = "shared";
- }
- return Utils::loadSerialFile(AJXP_DATA_PATH."/plugins/access.dropbox/".$repositoryId."_".$userId."_tokens");
- }
-
- public function setTokens(ContextInterface $ctx, $oauth_tokens)
- {
- $repositoryId = $ctx->getUser()->getId();
- if(UsersService::usersEnabled()) $userId = $ctx->getUser()->getId();
- else $userId = "shared";
- Utils::saveSerialFile(AJXP_DATA_PATH."/plugins/access.dropbox/".$repositoryId."_".$userId."_tokens", $oauth_tokens, true);
- }
-
- public function makeSharedRepositoryOptions(ContextInterface $ctx, $httpVars)
- {
- $newOptions = parent::makeSharedRepositoryOptions($ctx, $httpVars);
- $newOptions["DROPBOX_OAUTH_TOKENS"] = $this->getTokens($ctx);
- return $newOptions;
- }
-
-
-}
Oops, something went wrong.

0 comments on commit f90150f

Please sign in to comment.