Permalink
Browse files

Fix namespaces in OCS

Add WebDAV methods
  • Loading branch information...
1 parent f6c8ec6 commit 890a3b310c1b0c3b20aba06dd87aeaac60233d1a @cdujeu cdujeu committed May 25, 2016
@@ -63,7 +63,7 @@ public function __construct($cacheOptions = []){
*/
public function configureRoutes($base, \FastRoute\RouteCollector &$r){
- $allMethods = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'CONNECT', 'PATCH'];
+ $allMethods = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'CONNECT', 'PATCH', 'PROPFIND', 'PROPPATCH', 'MKCOL', 'COPY', 'MOVE', 'LOCK', 'UNLOCK'];
$file = AJXP_DATA_PATH."/".AJXP_PLUGINS_FOLDER."/boot.conf/routes.json";
if(!file_exists($file)){
$file = AJXP_INSTALL_PATH."/".AJXP_PLUGINS_FOLDER."/core.ajaxplorer/routes.json";
@@ -120,7 +120,7 @@ public function route(){
break;
case \FastRoute\Dispatcher::NOT_FOUND:
default:
- throw new PydioException("Oups, could not find any valid route for ".$uri);
+ throw new PydioException("Oups, could not find any valid route for ".$uri.", method was was ".$httpMethod);
break;
}
@@ -19,7 +19,7 @@
<global_param name="APPLICATION_TITLE" group="CONF_MESSAGE[Main]" type="string" label="CONF_MESSAGE[App Title]" description="CONF_MESSAGE[Your application title]" mandatory="true" default="Pydio" expose="true"/>
<global_param name="DEFAULT_LANGUAGE" group="CONF_MESSAGE[Main]" type="select" choices="AJXP_AVAILABLE_LANGUAGES" label="CONF_MESSAGE[Default Language]" description="CONF_MESSAGE[Default language when a user does not have set his/her own.]" mandatory="true" default="en"/>
<global_param name="SERVER_URL" group="CONF_MESSAGE[Main]" type="string" label="CONF_MESSAGE[Server URL]" description="CONF_MESSAGE[Server URL used to build share links and notifications. It will be detected if empty.]" mandatory="false"/>
- <global_param name="PUBLIC_DOWNLOAD_FOLDER" group="CONF_MESSAGE[Sharing]" type="string" label="CONF_MESSAGE[Download Folder]" description="CONF_MESSAGE[Absolute path to the public folder where temporary download links will be created. Setting this empty will disable the sharing feature.]" mandatory="false" default="AJXP_INSTALL_PATH/data/public"/>
+ <global_param name="PUBLIC_DOWNLOAD_FOLDER" group="CONF_MESSAGE[Sharing]" type="string" label="CONF_MESSAGE[Download Folder]" description="CONF_MESSAGE[Absolute path to the public folder where temporary download links will be created. Setting this empty will disable the sharing feature.]" mandatory="false" default="AJXP_INSTALL_PATH/public"/>
<!-- MAKE SURE NOT TO CHANGE ORDER OF name AND default ATTRIBUTES, CAN BE REPLACED BY INSTALLERS -->
<global_param name="PUBLIC_DOWNLOAD_URL" default="" group="CONF_MESSAGE[Sharing]" type="string" label="CONF_MESSAGE[Download URL]" description="CONF_MESSAGE[If not inferred directly from the current ajaxplorer URI plus the public download folder name, replace the public access URL here.]" mandatory="false"/>
<global_param name="WEBDAV_ENABLE" group="CONF_MESSAGE[WebDAV Server]" type="boolean" label="CONF_MESSAGE[Enable WebDAV]" description="CONF_MESSAGE[Enable the webDAV support. Please READ THE DOC to safely use this feature.]" mandatory="false" default="false"/>
@@ -53,7 +53,7 @@ public function sendInvitation(ShareInvitation $invitation)
'name' => $invitation->getDocumentName(),
'remoteId' => $invitation->getId(),
'owner' => $invitation->getOwner(),
- 'remote' => Utils::detectServerUrl(true)
+ 'remote' => Utils::detectServerURL(true)
];
$response = $client->post(ltrim($endpoints['share'], '/'), [
@@ -150,7 +150,9 @@ public function declineInvitation(RemoteShare $remoteShare)
/**
*
* Retrieves the OCS Provider endpoints for the URL
+ * @param string $url
*
+ * @return array
*/
public static function findEndpointsForURL($url) {
$client = self::getClient($url);
@@ -21,7 +21,6 @@
namespace Pydio\OCS\Model;
use Pydio\Access\Core\Filter\ContentFilter;
-use Pydio\Access\Core\Model\Repository;
use Pydio\Core\Services\ConfService;
use Sabre\DAV;
use Sabre\DAV\Exception;
@@ -175,15 +175,15 @@ public static function startServer($base, $route){
}
if(count($parts) < 2){
- $d = new \Pydio\OCS\Server\Dummy();
+ $d = new Dummy();
$response = $d->buildResponse("fail", "400", "Wrong URI");
$d->sendResponse($response);
return;
}
$version = array_shift($parts);
if($version != "v2"){
- $d = new \Pydio\OCS\Server\Dummy();
+ $d = new Dummy();
$response = $d->buildResponse("fail", "400", "Api version not supported - Please switch to v2.");
$d->sendResponse($response);
return;
@@ -22,6 +22,8 @@
defined('AJXP_EXEC') or die('Access not allowed');
+use Pydio\Core\Services\AuthService;
+use Pydio\Core\Services\ConfService;
use Sabre\DAV;
use Sabre\HTTP;
@@ -60,9 +62,9 @@ public function __construct($rootCollection){
protected function validateUserPass($username, $password)
{
if(isSet($this->shareData["PRESET_LOGIN"])){
- $res = \AuthService::logUser($this->shareData["PRESET_LOGIN"], $password, false, false, -1);
+ $res = AuthService::logUser($this->shareData["PRESET_LOGIN"], $password, false, false, -1);
}else{
- $res = \AuthService::logUser($this->shareData["PRELOG_USER"], "", true);
+ $res = AuthService::logUser($this->shareData["PRELOG_USER"], "", true);
}
return $res === 1;
}
@@ -93,7 +95,7 @@ public function authenticate(DAV\Server $server, $realm) {
// Authenticates the user
$token = $userpass[0];
- $shareStore = new \ShareStore(\ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"));
+ $shareStore = new \ShareStore(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"));
$shareData = $shareStore->loadShare($token);
if(is_array($shareData)){
$this->shareData = $shareData;
@@ -107,9 +109,9 @@ public function authenticate(DAV\Server $server, $realm) {
}
$repositoryId = $this->shareData["REPOSITORY"];
- $repository = \ConfService::getRepositoryById($repositoryId);
+ $repository = ConfService::getRepositoryById($repositoryId);
if ($repository == null) {
- $repository = \ConfService::getRepositoryByAlias($repositoryId);
+ $repository = ConfService::getRepositoryByAlias($repositoryId);
}
if ($repository == null) {
throw new DAV\Exception\NotAuthenticated('Username cannot access any repository');
@@ -24,6 +24,8 @@
defined('AJXP_EXEC') or die('Access not allowed');
require_once(AJXP_INSTALL_PATH."/".AJXP_PLUGINS_FOLDER."/action.share/class.ShareStore.php");
+use Pydio\Core\Services\ConfService;
+use Pydio\Log\Core\AJXP_Logger;
use Sabre;
class Server extends Sabre\DAV\Server
@@ -45,10 +47,10 @@ protected function pointToBaseFile(){
$testBackend = new BasicAuthNoPass();
$userPass = $testBackend->getUserPass();
if(isSet($userPass[0])){
- $shareStore = new \ShareStore(\ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"));
+ $shareStore = new \ShareStore(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"));
$shareData = $shareStore->loadShare($userPass[0]);
if(isSet($shareData) && isSet($shareData["REPOSITORY"])){
- $repo = \ConfService::getRepositoryById($shareData["REPOSITORY"]);
+ $repo = ConfService::getRepositoryById($shareData["REPOSITORY"]);
if(!empty($repo) && $repo->hasContentFilter()){
return "/".$repo->getContentFilter()->getUniquePath();
}
@@ -72,7 +74,7 @@ public function start($baseUri = "/"){
$this->setBaseUri($baseUri);
$authBackend = new AuthSharingBackend($this->rootCollection);
- $authPlugin = new Sabre\DAV\Auth\Plugin($authBackend, \ConfService::getCoreConf("WEBDAV_DIGESTREALM"));
+ $authPlugin = new Sabre\DAV\Auth\Plugin($authBackend, ConfService::getCoreConf("WEBDAV_DIGESTREALM"));
$this->addPlugin($authPlugin);
if (!is_dir(AJXP_DATA_PATH."/plugins/server.sabredav")) {
@@ -86,7 +88,7 @@ public function start($baseUri = "/"){
$lockPlugin = new Sabre\DAV\Locks\Plugin($lockBackend);
$this->addPlugin($lockPlugin);
- if (\ConfService::getCoreConf("WEBDAV_BROWSER_LISTING")) {
+ if (ConfService::getCoreConf("WEBDAV_BROWSER_LISTING")) {
$browerPlugin = new \AJXP_Sabre_BrowserPlugin((isSet($repository)?$repository->getDisplay():null));
$extPlugin = new Sabre\DAV\Browser\GuessContentType();
$this->addPlugin($browerPlugin);
@@ -95,7 +97,7 @@ public function start($baseUri = "/"){
try {
$this->exec();
} catch ( \Exception $e ) {
- \AJXP_Logger::error(__CLASS__,"Exception",$e->getMessage());
+ AJXP_Logger::error(__CLASS__,"Exception",$e->getMessage());
}
}
@@ -112,10 +114,10 @@ protected function initCollectionForFileOrFolderAsUniqueItem(&$baseUri){
$testBackend = new BasicAuthNoPass();
$userPass = $testBackend->getUserPass();
if(isSet($userPass[0])){
- $shareStore = new \ShareStore(\ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"));
+ $shareStore = new \ShareStore(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"));
$shareData = $shareStore->loadShare($userPass[0]);
if(isSet($shareData) && isSet($shareData["REPOSITORY"])){
- $repo = \ConfService::getRepositoryById($shareData["REPOSITORY"]);
+ $repo = ConfService::getRepositoryById($shareData["REPOSITORY"]);
if(!empty($repo) && !$repo->hasContentFilter()){
$baseDir = basename($repo->getOption("PATH"));
}
@@ -20,6 +20,8 @@
*/
namespace Pydio\OCS\Server\Dav;
+use Sabre\DAV\SimpleCollection;
+
defined('AJXP_EXEC') or die('Access not allowed');
@@ -30,7 +32,7 @@ public function getChildren()
if($this->path == "/" && !$this->repository->hasContentFilter()){
$basePath = $this->repository->getOption("PATH");
$dirName = basename($basePath);
- $this->children[$dirName] = new \Sabre\DAV\SimpleCollection($dirName);
+ $this->children[$dirName] = new SimpleCollection($dirName);
return $this->children;
}else{
return parent::getChildren();
@@ -20,7 +20,7 @@
*/
namespace Pydio\OCS\Server\Federated;
-use Pydio\Auth\Core\AuthService;
+use Pydio\Core\Services\AuthService;
use Pydio\Core\Utils\Utils;
use Pydio\OCS\Model\RemoteShare;
use Pydio\OCS\Model\SQLStore;

0 comments on commit 890a3b3

Please sign in to comment.