Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix namespaces in OCS
Browse files Browse the repository at this point in the history
Add WebDAV methods
  • Loading branch information
cdujeu committed May 25, 2016
1 parent f6c8ec6 commit 890a3b3
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 21 deletions.
4 changes: 2 additions & 2 deletions core/src/core/src/pydio/Core/Http/TopLevelRouter.php
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/core.ajaxplorer/manifest.xml
Expand Up @@ -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"/>
Expand Down
4 changes: 3 additions & 1 deletion core/src/plugins/core.ocs/src/Client/OCSClient.php
Expand Up @@ -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'], '/'), [
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion core/src/plugins/core.ocs/src/Model/RemoteShare.php
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/core.ocs/src/OCSPlugin.php
Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions core/src/plugins/core.ocs/src/Server/Dav/AuthSharingBackend.php
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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');
Expand Down
16 changes: 9 additions & 7 deletions core/src/plugins/core.ocs/src/Server/Dav/Server.php
Expand Up @@ -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
Expand All @@ -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();
}
Expand All @@ -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")) {
Expand All @@ -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);
Expand All @@ -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());
}
}

Expand All @@ -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"));
}
Expand Down
Expand Up @@ -20,6 +20,8 @@
*/

namespace Pydio\OCS\Server\Dav;
use Sabre\DAV\SimpleCollection;

defined('AJXP_EXEC') or die('Access not allowed');


Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/core.ocs/src/Server/Federated/Server.php
Expand Up @@ -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;
Expand Down

0 comments on commit 890a3b3

Please sign in to comment.