diff options
Diffstat (limited to 'apps')
46 files changed, 1198 insertions, 89 deletions
diff --git a/apps/files/appinfo/remote.php b/apps/files/appinfo/remote.php index 92c76183876..dd5c470431a 100644 --- a/apps/files/appinfo/remote.php +++ b/apps/files/appinfo/remote.php @@ -49,8 +49,9 @@ $server->subscribeEvent('beforeMethod', function () use ($server, $objectTree) { $rootInfo = $view->getFileInfo(''); // Create ownCloud Dir + $mountManager = \OC\Files\Filesystem::getMountManager(); $rootDir = new OC_Connector_Sabre_Directory($view, $rootInfo); - $objectTree->init($rootDir, $view); + $objectTree->init($rootDir, $view, $mountManager); $server->addPlugin(new OC_Connector_Sabre_AbortedUploadDetectionPlugin($view)); $server->addPlugin(new OC_Connector_Sabre_QuotaPlugin($view)); diff --git a/apps/files/css/mobile.css b/apps/files/css/mobile.css index 5e7d3875536..a0b92ca6949 100644 --- a/apps/files/css/mobile.css +++ b/apps/files/css/mobile.css @@ -62,4 +62,9 @@ table td.filename .nametext .innernametext { display: -webkit-flex; display: flex; } + +/* shorten elements for mobile */ +#uploadprogressbar { + width: 50px; +} } diff --git a/apps/files/css/upload.css b/apps/files/css/upload.css index b28f2eac4ac..bdc258b5064 100644 --- a/apps/files/css/upload.css +++ b/apps/files/css/upload.css @@ -37,22 +37,26 @@ overflow: hidden; } -#uploadprogresswrapper { +#uploadprogresswrapper, #uploadprogresswrapper * { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; +} + +#uploadprogresswrapper { display: inline-block; vertical-align: top; height: 36px; + margin-left: 3px; } #uploadprogresswrapper > input[type='button'] { height: 36px; + margin-left: 3px; } #uploadprogressbar { position:relative; float: left; - margin-left: 12px; - width: 100%; + width: 200px; height: 36px; display:inline-block; } diff --git a/apps/files/l10n/pt_PT.php b/apps/files/l10n/pt_PT.php index ac12e047c54..a0b12db02c1 100644 --- a/apps/files/l10n/pt_PT.php +++ b/apps/files/l10n/pt_PT.php @@ -1,10 +1,10 @@ <?php $TRANSLATIONS = array( -"Could not move %s - File with this name already exists" => "Não pôde mover o ficheiro %s - Já existe um ficheiro com esse nome", -"Could not move %s" => "Não foi possível move o ficheiro %s", -"File name cannot be empty." => "O nome do ficheiro não pode estar vazio.", +"Could not move %s - File with this name already exists" => "Não foi possível mover %s - Já existe um ficheiro com este nome", +"Could not move %s" => "Não foi possível mover %s", +"File name cannot be empty." => "O nome do ficheiro não pode estar em branco.", "\"%s\" is an invalid file name." => "\"%s\" é um nome de ficheiro inválido.", -"Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed." => "Nome Inválido, os caracteres '\\', '/', '<', '>', ':', '\"', '|', '?' e '*' não são permitidos.", +"Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed." => "Nome Inválido, Não são permitidos os carateres '\\', '/', '<', '>', ':', '\"', '|', '?' e '*'.", "The target folder has been moved or deleted." => "A pasta de destino foi movida ou eliminada.", "The name %s is already used in the folder %s. Please choose a different name." => "O nome %s já está em uso na pasta %s. Por favor escolha um nome diferente.", "Not a valid source" => "Não é uma fonte válida", @@ -15,18 +15,18 @@ $TRANSLATIONS = array( "Error when creating the folder" => "Erro ao criar a pasta", "Unable to set upload directory." => "Não foi possível criar o diretório de upload", "Invalid Token" => "Token inválido", -"No file was uploaded. Unknown error" => "Nenhum ficheiro foi carregado. Erro desconhecido", -"There is no error, the file uploaded with success" => "Não ocorreram erros, o ficheiro foi submetido com sucesso", -"The uploaded file exceeds the upload_max_filesize directive in php.ini: " => "O ficheiro enviado excede o limite permitido na directiva do php.ini upload_max_filesize", -"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form" => "O tamanho do ficheiro carregado ultrapassa o valor MAX_FILE_SIZE definido no formulário HTML", -"The uploaded file was only partially uploaded" => "O ficheiro seleccionado foi apenas carregado parcialmente", -"No file was uploaded" => "Nenhum ficheiro foi submetido", -"Missing a temporary folder" => "Está a faltar a pasta temporária", -"Failed to write to disk" => "Falhou a escrita no disco", +"No file was uploaded. Unknown error" => "Não foi enviado nenhum ficheiro. Erro desconhecido", +"There is no error, the file uploaded with success" => "Não ocorreram erros, o ficheiro foi enviado com sucesso", +"The uploaded file exceeds the upload_max_filesize directive in php.ini: " => "O ficheiro enviado excede a diretiva php.ini upload_max_filesize no php.ini", +"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form" => "O tamanho do ficheiro enviado excede a diretiva MAX_FILE_SIZE definida no formulário HTML", +"The uploaded file was only partially uploaded" => "O ficheiro submetido só foi parcialmente enviado", +"No file was uploaded" => "Não foi enviado nenhum ficheiro", +"Missing a temporary folder" => "A pasta temporária está em falta", +"Failed to write to disk" => "Não foi possível gravar no disco", "Not enough storage available" => "Não há espaço suficiente em disco", "Upload failed. Could not find uploaded file" => "Falhou o envio. Não conseguiu encontrar o ficheiro enviado", "Upload failed. Could not get file info." => "O carregamento falhou. Não foi possível obter a informação do ficheiro.", -"Invalid directory." => "Directório Inválido", +"Invalid directory." => "Diretoria inválida.", "Files" => "Ficheiros", "All files" => "Todos os ficheiros", "Unable to upload {filename} as it is a directory or has 0 bytes" => "Incapaz de enviar {filename}, dado que é uma pasta, ou tem 0 bytes", @@ -34,17 +34,17 @@ $TRANSLATIONS = array( "Not enough free space, you are uploading {size1} but only {size2} is left" => "Não existe espaço suficiente. Está a enviar {size1} mas apenas existe {size2} disponível", "Upload cancelled." => "Envio cancelado.", "Could not get result from server." => "Não foi possível obter o resultado do servidor.", -"File upload is in progress. Leaving the page now will cancel the upload." => "Envio de ficheiro em progresso. Irá cancelar o envio se sair da página agora.", +"File upload is in progress. Leaving the page now will cancel the upload." => "Envio de ficheiro em progresso. Se deixar a página agora, irá cancelar o envio.", "URL cannot be empty" => "URL não pode estar vazio", "{new_name} already exists" => "O nome {new_name} já existe", "Could not create file" => "Não pôde criar ficheiro", "Could not create folder" => "Não pôde criar pasta", "Error fetching URL" => "Erro ao obter URL", -"Share" => "Partilhar", -"Delete permanently" => "Eliminar permanentemente", -"Delete" => "Eliminar", +"Share" => "Compartilhar", +"Delete permanently" => "Apagar Para Sempre", +"Delete" => "Apagar", "Rename" => "Renomear", -"Your download is being prepared. This might take some time if the files are big." => "O seu download está a ser preparado. Este processo pode demorar algum tempo se os ficheiros forem grandes.", +"Your download is being prepared. This might take some time if the files are big." => "A sua transferência está a ser preparada. Isto poderá demorar algum tempo, se os seus ficheiros forem grandes.", "Pending" => "Pendente", "Error moving file." => "Erro a mover o ficheiro.", "Error moving file" => "Erro ao mover o ficheiro", @@ -58,26 +58,26 @@ $TRANSLATIONS = array( "_%n file_::_%n files_" => array("%n ficheiro","%n ficheiros"), "_Uploading %n file_::_Uploading %n files_" => array("A carregar %n ficheiro","A carregar %n ficheiros"), "\"{name}\" is an invalid file name." => "\"{name}\" é um nome de ficheiro inválido.", -"Your storage is full, files can not be updated or synced anymore!" => "O seu armazenamento está cheio, os ficheiros não podem ser sincronizados.", -"Your storage is almost full ({usedSpacePercent}%)" => "O seu espaço de armazenamento está quase cheiro ({usedSpacePercent}%)", +"Your storage is full, files can not be updated or synced anymore!" => "O seu armazenamento está cheio, os ficheiros já não podem ser atualizados ou sincronizados.", +"Your storage is almost full ({usedSpacePercent}%)" => "O seu armazenamento está quase cheiro ({usedSpacePercent}%)", "Encryption App is enabled but your keys are not initialized, please log-out and log-in again" => "A Aplicação de Encriptação está ativada, mas as suas chaves não inicializaram. Por favor termine e inicie a sessão novamente", "Invalid private key for Encryption App. Please update your private key password in your personal settings to recover access to your encrypted files." => "Chave privada inválida da Aplicação de Encriptação. Por favor atualize a sua senha de chave privada nas definições pessoais, para recuperar o acesso aos seus ficheiros encriptados.", "Encryption was disabled but your files are still encrypted. Please go to your personal settings to decrypt your files." => "A encriptação foi desactivada mas os seus ficheiros continuam encriptados. Por favor consulte as suas definições pessoais para desencriptar os ficheiros.", "{dirs} and {files}" => "{dirs} e {files}", "%s could not be renamed" => "%s não pode ser renomeada", "Upload (max. %s)" => "Enviar (max. %s)", -"File handling" => "Manuseamento de ficheiros", +"File handling" => "Manuseamento do ficheiro", "Maximum upload size" => "Tamanho máximo de envio", -"max. possible: " => "max. possivel: ", +"max. possible: " => "Máx. possível: ", "Save" => "Guardar", "WebDAV" => "WebDAV", "Use this address to <a href=\"%s\" target=\"_blank\">access your Files via WebDAV</a>" => "Utilize esta ligação para <a href=\"%s\" target=\"_blank\">aceder aos seus ficheiros via WebDAV</a>", "New" => "Novo", "New text file" => "Novo ficheiro de texto", -"Text file" => "Ficheiro de texto", +"Text file" => "Ficheiro de Texto", "New folder" => "Nova Pasta", "Folder" => "Pasta", -"From link" => "Da ligação", +"From link" => "Da hiperligação", "Cancel upload" => "Cancelar envio", "You don’t have permission to upload or create files here" => "Você não tem permissão para enviar ou criar ficheiros aqui", "Nothing in here. Upload something!" => "Vazio. Envie alguma coisa!", diff --git a/apps/files_encryption/l10n/en_GB.php b/apps/files_encryption/l10n/en_GB.php index 150173da63b..b2da4f2acdf 100644 --- a/apps/files_encryption/l10n/en_GB.php +++ b/apps/files_encryption/l10n/en_GB.php @@ -17,6 +17,7 @@ $TRANSLATIONS = array( "Following users are not set up for encryption:" => "Following users are not set up for encryption:", "Initial encryption started... This can take some time. Please wait." => "Initial encryption started... This can take some time. Please wait.", "Initial encryption running... Please try again later." => "Initial encryption running... Please try again later.", +"Go directly to your %spersonal settings%s." => "Go directly to your %spersonal settings%s.", "Encryption" => "Encryption", "Enable recovery key (allow to recover users files in case of password loss):" => "Enable recovery key (allow to recover users files in case of password loss):", "Recovery key password" => "Recovery key password", diff --git a/apps/files_encryption/l10n/sv.php b/apps/files_encryption/l10n/sv.php index 76ed616ca5c..2360f8ff8cc 100644 --- a/apps/files_encryption/l10n/sv.php +++ b/apps/files_encryption/l10n/sv.php @@ -17,6 +17,7 @@ $TRANSLATIONS = array( "Following users are not set up for encryption:" => "Följande användare har inte aktiverat kryptering:", "Initial encryption started... This can take some time. Please wait." => "Initiala krypteringen har påbörjats... Detta kan ta lite tid. Var god vänta.", "Initial encryption running... Please try again later." => "Initiala krypteringen körs... Var god försök igen senare.", +"Go directly to your %spersonal settings%s." => "Gå direkt till dina %segna inställningar%s.", "Encryption" => "Kryptering", "Enable recovery key (allow to recover users files in case of password loss):" => "Aktivera återställningsnyckel (för att kunna återfå användarens filer vid glömt eller förlorat lösenord):", "Recovery key password" => "Lösenord för återställningsnyckel", diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index fd91073b8de..b1af4676852 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -41,6 +41,39 @@ class Proxy extends \OC_FileProxy { private static $fopenMode = array(); // remember the fopen mode private static $enableEncryption = false; // Enable encryption for the given path + + /** + * check if path is excluded from encryption + * + * @param string $path relative to data/ + * @param string $uid user + * @return boolean + */ + private function isExcludedPath($path, $uid) { + + $view = new \OC\Files\View(); + + // files outside of the files-folder are excluded + if(strpos($path, '/' . $uid . '/files') !== 0) { + return true; + } + + if (!$view->file_exists($path)) { + $path = dirname($path); + } + + // we don't encrypt server-to-server shares + list($storage, ) = \OC\Files\Filesystem::resolvePath($path); + /** + * @var \OCP\Files\Storage $storage + */ + if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) { + return true; + } + + return false; + } + /** * Check if a file requires encryption * @param string $path @@ -50,7 +83,7 @@ class Proxy extends \OC_FileProxy { * Tests if server side encryption is enabled, and if we should call the * crypt stream wrapper for the given file */ - private static function shouldEncrypt($path, $mode = 'w') { + private function shouldEncrypt($path, $mode = 'w') { $userId = Helper::getUser($path); $session = new Session(new \OC\Files\View()); @@ -59,7 +92,7 @@ class Proxy extends \OC_FileProxy { if ( $session->getInitialized() !== Session::INIT_SUCCESSFUL // encryption successful initialized || Crypt::mode() !== 'server' // we are not in server-side-encryption mode - || strpos($path, '/' . $userId . '/files') !== 0 // path is not in files/ + || $this->isExcludedPath($path, $userId) // if path is excluded from encryption || substr($path, 0, 8) === 'crypt://' // we are already in crypt mode ) { return false; @@ -85,7 +118,7 @@ class Proxy extends \OC_FileProxy { */ public function preFile_put_contents($path, &$data) { - if (self::shouldEncrypt($path)) { + if ($this->shouldEncrypt($path)) { if (!is_resource($data)) { @@ -219,7 +252,7 @@ class Proxy extends \OC_FileProxy { public function preFopen($path, $mode) { self::$fopenMode[$path] = $mode; - self::$enableEncryption = self::shouldEncrypt($path, $mode); + self::$enableEncryption = $this->shouldEncrypt($path, $mode); } diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php index 93be6691f96..ef18b924dd8 100644 --- a/apps/files_encryption/lib/session.php +++ b/apps/files_encryption/lib/session.php @@ -100,6 +100,8 @@ class Session { $privateKey = Crypt::decryptPrivateKey($encryptedKey, ''); $this->setPublicSharePrivateKey($privateKey); + $this->setInitialized(\OCA\Encryption\Session::INIT_SUCCESSFUL); + \OC_FileProxy::$enabled = $proxyStatus; } } diff --git a/apps/files_encryption/tests/webdav.php b/apps/files_encryption/tests/webdav.php index 84db54ff30b..73bc9ce08de 100755 --- a/apps/files_encryption/tests/webdav.php +++ b/apps/files_encryption/tests/webdav.php @@ -235,7 +235,8 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase { $view = new \OC\Files\View($root); $publicDir = new OC_Connector_Sabre_Directory($view, $view->getFileInfo('')); $objectTree = new \OC\Connector\Sabre\ObjectTree(); - $objectTree->init($publicDir, $view); + $mountManager = \OC\Files\Filesystem::getMountManager(); + $objectTree->init($publicDir, $view, $mountManager); // Fire up server $server = new \Sabre\DAV\Server($publicDir); diff --git a/apps/files_external/css/settings.css b/apps/files_external/css/settings.css index 01dd5aece8c..758c52ae852 100644 --- a/apps/files_external/css/settings.css +++ b/apps/files_external/css/settings.css @@ -25,3 +25,7 @@ tr:hover>td.remove>img { visibility:visible; cursor:pointer; } #externalStorage td.status .success { border-radius: 50%; } + +#userMountingBackends { + padding-left: 25px; +} diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index 00793a614c2..348fecf0648 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -310,19 +310,28 @@ $(document).ready(function() { OC.msg.startSaving('#userMountingMsg'); if (this.checked) { OC.AppConfig.setValue('files_external', 'allow_user_mounting', 'yes'); - $('#userMountingBackups').removeClass('hidden'); + $('input[name="allowUserMountingBackends\\[\\]"]').prop('checked', true); + $('#userMountingBackends').removeClass('hidden'); + $('input[name="allowUserMountingBackends\\[\\]"]').eq(0).trigger('change'); } else { OC.AppConfig.setValue('files_external', 'allow_user_mounting', 'no'); - $('#userMountingBackups').addClass('hidden'); + $('#userMountingBackends').addClass('hidden'); } OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('settings', 'Saved')}}); }); $('input[name="allowUserMountingBackends\\[\\]"]').bind('change', function() { OC.msg.startSaving('#userMountingMsg'); - var user_mounting_backends = $('input[name="allowUserMountingBackends\\[\\]"]:checked').map(function(){return $(this).val();}).get(); - OC.AppConfig.setValue('files_external', 'user_mounting_backends', user_mounting_backends.join()); + var userMountingBackends = $('input[name="allowUserMountingBackends\\[\\]"]:checked').map(function(){return $(this).val();}).get(); + OC.AppConfig.setValue('files_external', 'user_mounting_backends', userMountingBackends.join()); OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('settings', 'Saved')}}); + + // disable allowUserMounting + if(userMountingBackends.length === 0) { + $('#allowUserMounting').prop('checked', false); + $('#allowUserMounting').trigger('change'); + + } }); }); diff --git a/apps/files_external/l10n/en_GB.php b/apps/files_external/l10n/en_GB.php index 74b53a867cc..e36c9496e42 100644 --- a/apps/files_external/l10n/en_GB.php +++ b/apps/files_external/l10n/en_GB.php @@ -46,13 +46,17 @@ $TRANSLATIONS = array( "Please provide a valid Dropbox app key and secret." => "Please provide a valid Dropbox app key and secret.", "Error configuring Google Drive storage" => "Error configuring Google Drive storage", "Personal" => "Personal", +"System" => "System", "Saved" => "Saved", "<b>Note:</b> " => "<b>Note:</b> ", " and " => " and ", "<b>Note:</b> The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." => "<b>Note:</b> The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.", "<b>Note:</b> The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." => "<b>Note:</b> The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it.", "<b>Note:</b> \"%s\" is not installed. Mounting of %s is not possible. Please ask your system administrator to install it." => "<b>Note:</b> \"%s\" is not installed. Mounting of %s is not possible. Please ask your system administrator to install it.", +"You don't have any external storages" => "You don't have any external storage", "Name" => "Name", +"Storage type" => "Storage type", +"Scope" => "Scope", "External Storage" => "External Storage", "Folder name" => "Folder name", "Configuration" => "Configuration", diff --git a/apps/files_external/l10n/pt_PT.php b/apps/files_external/l10n/pt_PT.php index af4f50d0243..244fc0464b4 100644 --- a/apps/files_external/l10n/pt_PT.php +++ b/apps/files_external/l10n/pt_PT.php @@ -8,9 +8,11 @@ $TRANSLATIONS = array( "Secret" => "Secreto", "Access Key" => "Chave de acesso", "Secret Key" => "Chave Secreta", +"Hostname (optional)" => "Nome do Hospedeiro (opcional)", "Port (optional)" => "Porta (opcional)", "Region (optional)" => "Região (opcional)", "Enable SSL" => "Activar SSL", +"Enable Path Style" => "Ativar Estilo do Caminho", "App key" => "Chave da aplicação", "App secret" => "Chave secreta da aplicação", "Host" => "Endereço", @@ -21,7 +23,11 @@ $TRANSLATIONS = array( "Client ID" => "ID Cliente", "Client secret" => "Segredo do cliente", "Username (required)" => "Utilizador (requerido)", +"Region (optional for OpenStack Object Storage)" => "Região (opcional para OpenStack Object Storage)", +"Password (required for OpenStack Object Storage)" => "Senha (necessária para OpenStack Object Storage)", +"Service Name (required for OpenStack Object Storage)" => "Nome do Serviço (necessário para OpenStack Object Storage)", "Share" => "Partilhar", +"SMB / CIFS using OC login" => "SMB / CIFS utilizando o início de sessão OC", "Username as share" => "Utilizar nome de utilizador como partilha", "URL" => "URL", "Secure https://" => "https:// Seguro", @@ -32,13 +38,16 @@ $TRANSLATIONS = array( "Please provide a valid Dropbox app key and secret." => "Por favor forneça uma \"app key\" e \"secret\" do Dropbox válidas.", "Error configuring Google Drive storage" => "Erro ao configurar o armazenamento do Google Drive", "Personal" => "Pessoal", +"System" => "Sistema", "Saved" => "Guardado", "<b>Note:</b> " => "<b>Aviso:</b> ", " and " => "e", "<b>Note:</b> The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." => "<b>Aviso:</b> O suporte cURL no PHP não está activo ou instalado. Não é possível montar %s. Peça ao seu administrador para instalar.", "<b>Note:</b> The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." => "<b>Aviso:</b> O suporte FTP no PHP não está activo ou instalado. Não é possível montar %s. Peça ao seu administrador para instalar.", "<b>Note:</b> \"%s\" is not installed. Mounting of %s is not possible. Please ask your system administrator to install it." => "<b>Aviso:</b> O cliente\"%s\" não está instalado. Não é possível montar \"%s\" . Peça ao seu administrador para instalar.", +"You don't have any external storages" => "Não possui quaisquer armazenamentos externos", "Name" => "Nome", +"Storage type" => "Tipo de Armazenamento", "External Storage" => "Armazenamento Externo", "Folder name" => "Nome da pasta", "Configuration" => "Configuração", diff --git a/apps/files_external/l10n/sv.php b/apps/files_external/l10n/sv.php index 9abead46222..7f45817c7e7 100644 --- a/apps/files_external/l10n/sv.php +++ b/apps/files_external/l10n/sv.php @@ -32,6 +32,7 @@ $TRANSLATIONS = array( "Tenantname (required for OpenStack Object Storage)" => "Tenantname (krävs för OpenStack Object Storage)", "Password (required for OpenStack Object Storage)" => "Lösenord (krävs för OpenStack Object Storage)", "Service Name (required for OpenStack Object Storage)" => "Tjänstens namn (krävs för OpenStack Object Storage)", +"URL of identity endpoint (required for OpenStack Object Storage)" => "URL för identitetens slutpunkt (krävs för OpenStack Object Storage)", "Timeout of HTTP requests in seconds (optional)" => "Timeout för HTTP-förfrågningar i sekunder (tillval)", "Share" => "Dela", "SMB / CIFS using OC login" => "SMB / CIFS använder OC inloggning", @@ -45,13 +46,17 @@ $TRANSLATIONS = array( "Please provide a valid Dropbox app key and secret." => "Ange en giltig Dropbox nyckel och hemlighet.", "Error configuring Google Drive storage" => "Fel vid konfigurering av Google Drive", "Personal" => "Personligt", +"System" => "System", "Saved" => "Sparad", "<b>Note:</b> " => "<b> OBS: </ b>", " and " => "och", "<b>Note:</b> The cURL support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." => "<b> OBS: </ b> cURL stöd i PHP inte är aktiverat eller installeras. Montering av %s är inte möjlig. Be din systemadministratör att installera det.", "<b>Note:</b> The FTP support in PHP is not enabled or installed. Mounting of %s is not possible. Please ask your system administrator to install it." => "<b> OBS: </ b> Den FTP-stöd i PHP inte är aktiverat eller installeras. Montering av %s är inte möjlig. Be din systemadministratör att installera det.", "<b>Note:</b> \"%s\" is not installed. Mounting of %s is not possible. Please ask your system administrator to install it." => "<b> OBS: </ b> \"%s\" är inte installerat. Montering av %s är inte möjlig. Be din systemadministratör att installera det.", +"You don't have any external storages" => "Du har ingen extern extern lagring", "Name" => "Namn", +"Storage type" => "Lagringstyp", +"Scope" => "Scope", "External Storage" => "Extern lagring", "Folder name" => "Mappnamn", "Configuration" => "Konfiguration", diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 525f41c1276..c532c5eaa7d 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -9,13 +9,13 @@ namespace OC\Files\Storage; class DAV extends \OC\Files\Storage\Common { - private $password; - private $user; - private $host; - private $secure; - private $root; - private $certPath; - private $ready; + protected $password; + protected $user; + protected $host; + protected $secure; + protected $root; + protected $certPath; + protected $ready; /** * @var \Sabre\DAV\Client */ @@ -355,6 +355,9 @@ class DAV extends \OC\Files\Storage\Common { * @param string $path */ public function cleanPath($path) { + if ($path === "") { + return $path; + } $path = \OC\Files\Filesystem::normalizePath($path); // remove leading slash return substr($path, 1); @@ -397,11 +400,27 @@ class DAV extends \OC\Files\Storage\Common { } } + public function isUpdatable($path) { + return (bool)($this->getPermissions($path) & \OCP\PERMISSION_UPDATE); + } + + public function isCreatable($path) { + return (bool)($this->getPermissions($path) & \OCP\PERMISSION_CREATE); + } + + public function isSharable($path) { + return (bool)($this->getPermissions($path) & \OCP\PERMISSION_SHARE); + } + + public function isDeletable($path) { + return (bool)($this->getPermissions($path) & \OCP\PERMISSION_DELETE); + } + public function getPermissions($path) { $this->init(); $response = $this->client->propfind($this->encodePath($path), array('{http://owncloud.org/ns}permissions')); if (isset($response['{http://owncloud.org/ns}permissions'])) { - $permissions = 0; + $permissions = \OCP\PERMISSION_READ; $permissionsString = $response['{http://owncloud.org/ns}permissions']; if (strpos($permissionsString, 'R') !== false) { $permissions |= \OCP\PERMISSION_SHARE; @@ -416,8 +435,12 @@ class DAV extends \OC\Files\Storage\Common { $permissions |= \OCP\PERMISSION_CREATE; } return $permissions; + } else if ($this->is_dir($path)) { + return \OCP\PERMISSION_ALL; + } else if ($this->file_exists($path)) { + return \OCP\PERMISSION_ALL - \OCP\PERMISSION_CREATE; } else { - return parent::getPermissions($path); + return 0; } } } diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index df80ed10993..98fcf4a0ed4 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -131,7 +131,7 @@ value="1" <?php if ($_['allowUserMounting'] == 'yes') print_unescaped(' checked="checked"'); ?> /> <label for="allowUserMounting"><?php p($l->t('Enable User External Storage')); ?></label> <span id="userMountingMsg" class="msg"></span> - <p id="userMountingBackups"<?php if ($_['allowUserMounting'] != 'yes'): ?> class="hidden"<?php endif; ?>> + <p id="userMountingBackends"<?php if ($_['allowUserMounting'] != 'yes'): ?> class="hidden"<?php endif; ?>> <?php p($l->t('Allow users to mount the following external storage')); ?><br /> <?php $i = 0; foreach ($_['personal_backends'] as $class => $backend): ?> <input type="checkbox" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($class); ?>" <?php if ($backend['enabled']) print_unescaped(' checked="checked"'); ?> /> diff --git a/apps/files_sharing/ajax/external.php b/apps/files_sharing/ajax/external.php new file mode 100644 index 00000000000..52c84b7babb --- /dev/null +++ b/apps/files_sharing/ajax/external.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +OCP\JSON::callCheck(); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('files_sharing'); + +$l = OC_L10N::get('files_sharing'); + +// check if server admin allows to mount public links from other servers +// check if files_external is enabled +// FIXME file_external check no longer needed if we use the webdav implementation from core +if (OCA\Files_Sharing\Helper::isIncomingServer2serverShareEnabled() === false || + \OC_App::isEnabled('files_external') === false) { + \OCP\JSON::error(array('data' => array('message' => $l->t('Server to server sharing is not enabled on this server')))); + exit(); +} + +$token = $_POST['token']; +$remote = $_POST['remote']; +$owner = $_POST['owner']; +$name = $_POST['name']; +$password = $_POST['password']; + +$externalManager = new \OCA\Files_Sharing\External\Manager( + \OC::$server->getDatabaseConnection(), + \OC\Files\Filesystem::getMountManager(), + \OC\Files\Filesystem::getLoader(), + \OC::$server->getUserSession() +); + +$name = OCP\Files::buildNotExistingFileName('/', $name); + +$mount = $externalManager->addShare($remote, $token, $password, $name, $owner); +/** + * @var \OCA\Files_Sharing\External\Storage $storage + */ +$storage = $mount->getStorage(); +$result = $storage->file_exists(''); +if($result){ + $storage->getScanner()->scanAll(); + \OCP\JSON::success(); +} else { + $externalManager->removeShare($mount->getMountPoint()); + \OCP\JSON::error(array('data' => array('message' => $l->t("Couldn't add remote share")))); +} diff --git a/apps/files_sharing/ajax/shareinfo.php b/apps/files_sharing/ajax/shareinfo.php new file mode 100644 index 00000000000..e87b0779e8d --- /dev/null +++ b/apps/files_sharing/ajax/shareinfo.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +OCP\JSON::checkAppEnabled('files_sharing'); + +if (!isset($_GET['t'])) { + \OC_Response::setStatus(400); //400 Bad Request + exit; +} + +$token = $_GET['t']; + +$password = null; +if (isset($_POST['password'])) { + $password = $_POST['password']; +} + +$relativePath = null; +if (isset($_GET['dir'])) { + $relativePath = $_GET['dir']; +} + +$data = \OCA\Files_Sharing\Helper::setupFromToken($token, $relativePath, $password); + +$linkItem = $data['linkItem']; +// Load the files +$path = $data['realPath']; + +$isWritable = $linkItem['permissions'] & (\OCP\PERMISSION_UPDATE | \OCP\PERMISSION_CREATE); +if (!$isWritable) { + \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { + return new \OCA\Files_Sharing\ReadOnlyWrapper(array('storage' => $storage)); + }); +} + +$rootInfo = \OC\Files\Filesystem::getFileInfo($path); +$rootView = new \OC\Files\View(''); + +/** + * @param \OCP\Files\FileInfo $dir + * @param \OC\Files\View $view + * @return array + */ +function getChildInfo($dir, $view) { + $children = $view->getDirectoryContent($dir->getPath()); + $result = array(); + foreach ($children as $child) { + $formated = \OCA\Files\Helper::formatFileInfo($child); + if ($child->getType() === 'dir') { + $formated['children'] = getChildInfo($child, $view); + } + $formated['mtime'] = $formated['mtime'] / 1000; + $result[] = $formated; + } + return $result; +} + +$result = \OCA\Files\Helper::formatFileInfo($rootInfo); +$result['mtime'] = $result['mtime'] / 1000; +if ($rootInfo->getType() === 'dir') { + $result['children'] = getChildInfo($rootInfo, $rootView); +} + +OCP\JSON::success(array('data' => $result)); diff --git a/apps/files_sharing/ajax/testremote.php b/apps/files_sharing/ajax/testremote.php new file mode 100644 index 00000000000..89581794698 --- /dev/null +++ b/apps/files_sharing/ajax/testremote.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +OCP\JSON::checkAppEnabled('files_sharing'); + +$remote = $_GET['remote']; + +function testUrl($url) { + try { + $result = file_get_contents($url); + $data = json_decode($result); + return is_object($data) and !empty($data->version); + } catch (Exception $e) { + return false; + } +} + +if (testUrl('https://' . $remote . '/status.php')) { + echo 'https'; +} elseif (testUrl('http://' . $remote . '/status.php')) { + echo 'http'; +} else { + echo 'false'; +} diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index 6b40ba921cc..a9f4ff5089b 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -11,10 +11,24 @@ OC::$CLASSPATH['OC\Files\Cache\Shared_Watcher'] = 'files_sharing/lib/watcher.php OC::$CLASSPATH['OCA\Files\Share\Api'] = 'files_sharing/lib/api.php'; OC::$CLASSPATH['OCA\Files\Share\Maintainer'] = 'files_sharing/lib/maintainer.php'; OC::$CLASSPATH['OCA\Files\Share\Proxy'] = 'files_sharing/lib/proxy.php'; + +\OCP\App::registerAdmin('files_sharing', 'settings-admin'); + +$externalManager = new \OCA\Files_Sharing\External\Manager( + \OC::$server->getDatabaseConnection(), + \OC\Files\Filesystem::getMountManager(), + \OC\Files\Filesystem::getLoader(), + \OC::$server->getUserSession() +); +$externalManager->setup(); + OCP\Util::connectHook('OC_Filesystem', 'setup', '\OC\Files\Storage\Shared', 'setup'); OCP\Share::registerBackend('file', 'OC_Share_Backend_File'); OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file'); + OCP\Util::addScript('files_sharing', 'share'); +OCP\Util::addScript('files_sharing', 'external'); + \OC_Hook::connect('OC_Filesystem', 'post_write', '\OC\Files\Cache\Shared_Updater', 'writeHook'); \OC_Hook::connect('OC_Filesystem', 'post_delete', '\OC\Files\Cache\Shared_Updater', 'postDeleteHook'); \OC_Hook::connect('OC_Filesystem', 'delete', '\OC\Files\Cache\Shared_Updater', 'deleteHook'); diff --git a/apps/files_sharing/appinfo/database.xml b/apps/files_sharing/appinfo/database.xml new file mode 100644 index 00000000000..73d64c527b7 --- /dev/null +++ b/apps/files_sharing/appinfo/database.xml @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<database> + <name>*dbname*</name> + <create>true</create> + <overwrite>false</overwrite> + <charset>utf8</charset> + <table> + <name>*dbprefix*share_external</name> + <declaration> + <field> + <name>id</name> + <type>integer</type> + <default>0</default> + <notnull>true</notnull> + <autoincrement>1</autoincrement> + <length>4</length> + </field> + <field> + <name>remote</name> + <type>text</type> + <notnull>true</notnull> + <length>512</length> + <comments>Url of the remove owncloud instance</comments> + </field> + <field> + <name>share_token</name> + <type>text</type> + <notnull>true</notnull> + <length>64</length> + <comments>Public share token</comments> + </field> + <field> + <name>password</name> + <type>text</type> + <notnull>true</notnull> + <length>64</length> + <comments>Optional password for the public share</comments> + </field> + <field> + <name>name</name> + <type>text</type> + <notnull>true</notnull> + <length>64</length> + <comments>Original name on the remote server</comments> + </field> + <field> + <name>owner</name> + <type>text</type> + <notnull>true</notnull> + <length>64</length> + <comments>User that owns the public share on the remote server</comments> + </field> + <field> + <name>user</name> + <type>text</type> + <notnull>true</notnull> + <length>64</length> + <comments>Local user which added the external share</comments> + </field> + <field> + <name>mountpoint</name> + <type>text</type> + <notnull>true</notnull> + <length>4000</length> + <comments>Full path where the share is mounted</comments> + </field> + <field> + <name>mountpoint_hash</name> + <type>text</type> + <notnull>true</notnull> + <length>32</length> + <comments>md5 hash of the mountpoint</comments> + </field> + <index> + <name>sh_external_user</name> + <field> + <name>user</name> + <sorting>ascending</sorting> + </field> + </index> + <index> + <name>sh_external_mp</name> + <unique>true</unique> + <field> + <name>user</name> + <sorting>ascending</sorting> + </field> + <field> + <name>mountpoint_hash</name> + <sorting>ascending</sorting> + </field> + </index> + </declaration> + </table> +</database> diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php index 7c2834dc9c2..e68b953fc05 100644 --- a/apps/files_sharing/appinfo/routes.php +++ b/apps/files_sharing/appinfo/routes.php @@ -5,6 +5,10 @@ $this->create('core_ajax_public_preview', '/publicpreview')->action( require_once __DIR__ . '/../ajax/publicpreview.php'; }); +$this->create('sharing_external_shareinfo', '/shareinfo')->actionInclude('files_sharing/ajax/shareinfo.php'); +$this->create('sharing_external_add', '/external')->actionInclude('files_sharing/ajax/external.php'); +$this->create('sharing_external_test_remote', '/testremote')->actionInclude('files_sharing/ajax/testremote.php'); + // OCS API //TODO: SET: mail notification, waiting for PR #4689 to be accepted diff --git a/apps/files_sharing/appinfo/version b/apps/files_sharing/appinfo/version index 2eb3c4fe4ee..cb0c939a936 100644 --- a/apps/files_sharing/appinfo/version +++ b/apps/files_sharing/appinfo/version @@ -1 +1 @@ -0.5 +0.5.2 diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css index 1bafb780744..31c3bca8748 100644 --- a/apps/files_sharing/css/public.css +++ b/apps/files_sharing/css/public.css @@ -87,3 +87,38 @@ thead { width: 300px; max-width: 90%; } + +.header-right { + transition: opacity 500ms ease 0s; + -moz-transition: opacity 500ms ease 0s; + -ms-transition: opacity 500ms ease 0s; + -o-transition: opacity 500ms ease 0s; + -webkit-transition: opacity 500ms ease 0s; +} + +.header-right:hover, .header-right.active { + opacity: 1; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; + filter: alpha(opacity=100); +} + +/* within #save */ +#remote_address { + margin: 0; + height: 14px; + line-height: 16px; + padding: 6px; +} + +#save button { + margin: 0 5px; + height: 28px; + padding-bottom: 4px; + line-height: 14px; +} + +#save .save-form [type="submit"] { + margin: 0 5px; + height: 28px; + padding-bottom: 4px; +} diff --git a/apps/files_sharing/js/external.js b/apps/files_sharing/js/external.js new file mode 100644 index 00000000000..5c476b2d43d --- /dev/null +++ b/apps/files_sharing/js/external.js @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ +(function () { + var getParameterByName = function (query, name) { + name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); + var regex = new RegExp("[\\#&]" + name + "=([^&#]*)"), + results = regex.exec(query); + return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); + }; + + var addExternalShare = function (remote, token, owner, name, password) { + return $.post(OC.generateUrl('apps/files_sharing/external'), { + remote: remote, + token: token, + owner: owner, + name: name, + password: password + }); + }; + + var showAddExternalDialog = function (remote, token, owner, name, passwordProtected) { + var remoteClean = (remote.substr(0, 8) === 'https://') ? remote.substr(8) : remote.substr(7); + var callback = function (add, password) { + password = password || ''; + if (add) { + addExternalShare(remote, token, owner, name, password).then(function (result) { + if (result.status === 'error') { + OC.Notification.show(result.data.message); + } else { + FileList.reload(); + } + }); + } + }; + if (!passwordProtected) { + OC.dialogs.confirm(t('files_sharing', 'Add {name} from {owner}@{remote}', {name: name, owner: owner, remote: remoteClean}) + , 'Add Share', callback, true); + } else { + OC.dialogs.prompt(t('files_sharing', 'Add {name} from {owner}@{remote}', {name: name, owner: owner, remote: remoteClean}) + , 'Add Share', callback, true, 'Password', true); + } + }; + + OCA.Sharing.showAddExternalDialog = function (hash) { + var remote = getParameterByName(hash, 'remote'); + var owner = getParameterByName(hash, 'owner'); + var name = getParameterByName(hash, 'name'); + var token = getParameterByName(hash, 'token'); + var passwordProtected = parseInt(getParameterByName(hash, 'protected'), 10); + + if (remote && token && owner && name) { + showAddExternalDialog(remote, token, owner, name, passwordProtected); + } + }; +})(); + +$(document).ready(function () { + // FIXME: HACK: do not init when running unit tests, need a better way + if (!window.TESTING && OCA.Files) {// only run in the files app + var hash = location.hash; + location.hash = ''; + OCA.Sharing.showAddExternalDialog(hash); + } +}); diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index a2248405d22..80631908d24 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -19,7 +19,7 @@ if (!OCA.Files) { OCA.Sharing.PublicApp = { _initialized: false, - initialize: function($el) { + initialize: function ($el) { var self = this; var fileActions; if (this._initialized) { @@ -65,7 +65,7 @@ OCA.Sharing.PublicApp = { } // dynamically load image previews - if (mimetype.substr(0, mimetype.indexOf('/')) === 'image' ) { + if (mimetype.substr(0, mimetype.indexOf('/')) === 'image') { var params = { x: $(document).width() * window.devicePixelRatio, @@ -82,7 +82,7 @@ OCA.Sharing.PublicApp = { if (this.fileList) { // TODO: move this to a separate PublicFileList class that extends OCA.Files.FileList (+ unit tests) - this.fileList.getDownloadUrl = function(filename, dir) { + this.fileList.getDownloadUrl = function (filename, dir) { if ($.isArray(filename)) { filename = JSON.stringify(filename); } @@ -97,13 +97,13 @@ OCA.Sharing.PublicApp = { return OC.filePath('', '', 'public.php') + '?' + OC.buildQueryString(params); }; - this.fileList.getAjaxUrl = function(action, params) { + this.fileList.getAjaxUrl = function (action, params) { params = params || {}; params.t = $('#sharingToken').val(); return OC.filePath('files_sharing', 'ajax', action + '.php') + '?' + OC.buildQueryString(params); }; - this.fileList.linkTo = function(dir) { + this.fileList.linkTo = function (dir) { var params = { service: 'files', t: $('#sharingToken').val(), @@ -112,15 +112,15 @@ OCA.Sharing.PublicApp = { return OC.filePath('', '', 'public.php') + '?' + OC.buildQueryString(params); }; - this.fileList.generatePreviewUrl = function(urlSpec) { + this.fileList.generatePreviewUrl = function (urlSpec) { urlSpec.t = $('#dirToken').val(); return OC.generateUrl('/apps/files_sharing/ajax/publicpreview.php?') + $.param(urlSpec); }; var file_upload_start = $('#file_upload_start'); - file_upload_start.on('fileuploadadd', function(e, data) { + file_upload_start.on('fileuploadadd', function (e, data) { var fileDirectory = ''; - if(typeof data.files[0].relativePath !== 'undefined') { + if (typeof data.files[0].relativePath !== 'undefined') { fileDirectory = data.files[0].relativePath; } @@ -143,16 +143,34 @@ OCA.Sharing.PublicApp = { OC.Util.History.addOnPopStateHandler(_.bind(this._onUrlChanged, this)); } - $(document).on('click', '#directLink', function() { + $(document).on('click', '#directLink', function () { $(this).focus(); $(this).select(); }); + $('.save-form').submit(function (event) { + event.preventDefault(); + + var remote = $(this).find('input[type="text"]').val(); + var token = $('#sharingToken').val(); + var owner = $('#save').data('owner'); + var name = $('#save').data('name'); + var isProtected = $('#save').data('protected') ? 1 : 0; + OCA.Sharing.PublicApp._saveToOwnCloud(remote, token, owner, name, isProtected); + }); + + $('#save > button').click(function () { + $(this).hide(); + $('.header-right').addClass('active'); + $('.save-form').css('display', 'inline'); + $('#remote_address').focus(); + }); + // legacy window.FileList = this.fileList; }, - _onDirectoryChanged: function(e) { + _onDirectoryChanged: function (e) { OC.Util.History.pushState({ service: 'files', t: $('#sharingToken').val(), @@ -161,21 +179,44 @@ OCA.Sharing.PublicApp = { }); }, - _onUrlChanged: function(params) { + _onUrlChanged: function (params) { this.fileList.changeDirectory(params.path || params.dir, false, true); + }, + + _saveToOwnCloud: function(remote, token, owner, name, isProtected) { + var location = window.location.protocol + '//' + window.location.host + OC.webroot; + + var url = remote + '/index.php/apps/files#' + 'remote=' + encodeURIComponent(location) // our location is the remote for the other server + + "&token=" + encodeURIComponent(token) + "&owner=" + encodeURIComponent(owner) + "&name=" + encodeURIComponent(name) + "&protected=" + isProtected; + + + if (remote.indexOf('://') > 0) { + OC.redirect(url); + } else { + // if no protocol is specified, we automatically detect it by testing https and http + // this check needs to happen on the server due to the Content Security Policy directive + $.get(OC.generateUrl('apps/files_sharing/testremote'), {remote: remote}).then(function (protocol) { + if (protocol !== 'http' && protocol !== 'https') { + OC.dialogs.alert(t('files_sharing', 'No ownCloud installation found at {remote}', {remote: remote}), + t('files_sharing', 'Invalid ownCloud url')); + } else { + OC.redirect(protocol + '://' + url); + } + }); + } } }; -$(document).ready(function() { +$(document).ready(function () { var App = OCA.Sharing.PublicApp; // defer app init, to give a chance to plugins to register file actions - _.defer(function() { + _.defer(function () { App.initialize($('#preview')); }); if (window.Files) { // HACK: for oc-dialogs previews that depends on Files: - Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) { + Files.lazyLoadPreview = function (path, mime, ready, width, height, etag) { return App.fileList.lazyLoadPreview({ path: path, mime: mime, diff --git a/apps/files_sharing/js/settings-admin.js b/apps/files_sharing/js/settings-admin.js new file mode 100644 index 00000000000..257c864b04f --- /dev/null +++ b/apps/files_sharing/js/settings-admin.js @@ -0,0 +1,11 @@ +$(document).ready(function() { + + $('#fileSharingSettings input').change(function() { + var value = 'no'; + if (this.checked) { + value = 'yes'; + } + OC.AppConfig.setValue('files_sharing', $(this).attr('name'), value); + }); + +}); diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 47fe0bd2c57..0999bfd6bed 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -57,7 +57,7 @@ ' data-action="Share-Notification" href="#" original-title="">' + ' <img class="svg" src="' + OC.imagePath('core', 'actions/share') + '"></img>'; $tr.find('.fileactions').append(function() { - var shareBy = t('files_sharing', 'Shared by {owner}', {owner: fileData.shareOwner}); + var shareBy = t('files_sharing', 'Shared by {owner}', {owner: escapeHTML(fileData.shareOwner)}); var $result = $(shareNotification + '<span> ' + shareBy + '</span></span>'); $result.on('click', function() { return false; diff --git a/apps/files_sharing/l10n/pt_PT.php b/apps/files_sharing/l10n/pt_PT.php index 03c57847d85..1af1f023fd7 100644 --- a/apps/files_sharing/l10n/pt_PT.php +++ b/apps/files_sharing/l10n/pt_PT.php @@ -2,21 +2,25 @@ $TRANSLATIONS = array( "Shared with you" => "Partilhado consigo ", "Shared with others" => "Partilhado com outros", -"Shared by {owner}" => "Partilhado por {owner}", +"Shared by link" => "Partilhado pela hiperligação", +"No files have been shared with you yet." => "Ainda não partilhados quaisquer ficheuiros consigo.", +"You haven't shared any files yet." => "Ainda não partilhou quaisquer ficheiros.", +"You haven't shared any files by link yet." => "Ainda não partilhou quaisquer ficheiros por hiperligação.", +"Shared by {owner}" => "Partilhado por {dono}", "Shared by" => "Partilhado por", -"This share is password-protected" => "Esta partilha está protegida por palavra-chave", -"The password is wrong. Try again." => "Password errada, por favor tente de novo", -"Password" => "Palavra-passe", +"This share is password-protected" => "Esta partilha está protegida por senha", +"The password is wrong. Try again." => "A senha está errada. Por favor, tente de novo.", +"Password" => "Senha", "Name" => "Nome", -"Share time" => "Partilhar hora", -"Sorry, this link doesn’t seem to work anymore." => "Desculpe, mas este link parece não estar a funcionar.", +"Share time" => "Hora da Partilha", +"Sorry, this link doesn’t seem to work anymore." => "Desculpe, mas esta hiperligação parece já não estar a funcionar.", "Reasons might be:" => "As razões poderão ser:", -"the item was removed" => "O item foi removido", -"the link expired" => "O link expirou", -"sharing is disabled" => "A partilha está desativada", -"For more info, please ask the person who sent this link." => "Para mais informações, por favor questione a pessoa que lhe enviou este link", +"the item was removed" => "o item foi removido", +"the link expired" => "A hiperligação expirou", +"sharing is disabled" => "a partilha está desativada", +"For more info, please ask the person who sent this link." => "Para mais informação, por favor, pergunte à pessoa que lhe enviou esta hiperligação.", "Download" => "Transferir", -"Download %s" => "Download %s", -"Direct link" => "Link direto" +"Download %s" => "Transferir %s", +"Direct link" => "Hiperligação direta" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/apps/files_sharing/l10n/sv.php b/apps/files_sharing/l10n/sv.php index e5fbd7a90af..19430c1ff95 100644 --- a/apps/files_sharing/l10n/sv.php +++ b/apps/files_sharing/l10n/sv.php @@ -2,8 +2,10 @@ $TRANSLATIONS = array( "Shared with you" => "Delat med dig", "Shared with others" => "Delat med andra", +"Shared by link" => "Delad som länk", "No files have been shared with you yet." => "Inga filer har ännu delats med dig.", "You haven't shared any files yet." => "Du har inte delat några filer ännu.", +"You haven't shared any files by link yet." => "Du har inte delat några filer som länk ännu.", "Shared by {owner}" => "Delad av {owner}", "Shared by" => "Delad av", "This share is password-protected" => "Den här delningen är lösenordsskyddad", diff --git a/apps/files_sharing/lib/connector/publicauth.php b/apps/files_sharing/lib/connector/publicauth.php index ec7b68ba69c..c9d545180b3 100644 --- a/apps/files_sharing/lib/connector/publicauth.php +++ b/apps/files_sharing/lib/connector/publicauth.php @@ -38,6 +38,7 @@ class PublicAuth extends \Sabre\DAV\Auth\Backend\AbstractBasic { */ protected function validateUserPass($username, $password) { $linkItem = \OCP\Share::getShareByToken($username, false); + \OC_User::setIncognitoMode(true); $this->share = $linkItem; if (!$linkItem) { return false; diff --git a/apps/files_sharing/lib/external/cache.php b/apps/files_sharing/lib/external/cache.php new file mode 100644 index 00000000000..cd06bfb1272 --- /dev/null +++ b/apps/files_sharing/lib/external/cache.php @@ -0,0 +1,47 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCA\Files_Sharing\External; + +class Cache extends \OC\Files\Cache\Cache { + private $remote; + private $remoteUser; + private $storage; + + /** + * @param \OCA\Files_Sharing\External\Storage $storage + * @param string $remote + * @param string $remoteUser + */ + public function __construct($storage, $remote, $remoteUser) { + $this->storage = $storage; + list(, $remote) = explode('://', $remote, 2); + $this->remote = $remote; + $this->remoteUser = $remoteUser; + parent::__construct($storage); + } + + public function get($file) { + $result = parent::get($file); + $result['displayname_owner'] = $this->remoteUser . '@' . $this->remote; + if (!$file || $file === '') { + $result['is_share_mount_point'] = true; + $mountPoint = rtrim($this->storage->getMountPoint()); + $result['name'] = basename($mountPoint); + } + return $result; + } + + public function getFolderContentsById($id) { + $results = parent::getFolderContentsById($id); + foreach ($results as &$file) { + $file['displayname_owner'] = $this->remoteUser . '@' . $this->remote; + } + return $results; + } +} diff --git a/apps/files_sharing/lib/external/manager.php b/apps/files_sharing/lib/external/manager.php new file mode 100644 index 00000000000..70a0e98ebd5 --- /dev/null +++ b/apps/files_sharing/lib/external/manager.php @@ -0,0 +1,140 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCA\Files_Sharing\External; + +use OC\Files\Filesystem; + +class Manager { + const STORAGE = '\OCA\Files_Sharing\External\Storage'; + + /** + * @var \OCP\IDBConnection + */ + private $connection; + + /** + * @var \OC\Files\Mount\Manager + */ + private $mountManager; + + /** + * @var \OC\Files\Storage\Loader + */ + private $storageLoader; + + /** + * @var \OC\User\Session + */ + private $userSession; + + /** + * @param \OCP\IDBConnection $connection + * @param \OC\Files\Mount\Manager $mountManager + * @param \OC\User\Session $userSession + * @param \OC\Files\Storage\Loader $storageLoader + */ + public function __construct(\OCP\IDBConnection $connection, \OC\Files\Mount\Manager $mountManager, + \OC\Files\Storage\Loader $storageLoader, \OC\User\Session $userSession) { + $this->connection = $connection; + $this->mountManager = $mountManager; + $this->userSession = $userSession; + $this->storageLoader = $storageLoader; + } + + public function addShare($remote, $token, $password, $name, $owner) { + $user = $this->userSession->getUser(); + if ($user) { + $query = $this->connection->prepare('INSERT INTO *PREFIX*share_external(`remote`, `share_token`, `password`, + `name`, `owner`, `user`, `mountpoint`, `mountpoint_hash`) VALUES(?, ?, ?, ?, ?, ?, ?, ?)'); + $mountPoint = Filesystem::normalizePath('/' . $name); + $hash = md5($mountPoint); + $query->execute(array($remote, $token, $password, $name, $owner, $user->getUID(), $mountPoint, $hash)); + + $options = array( + 'remote' => $remote, + 'token' => $token, + 'password' => $password, + 'mountpoint' => $mountPoint, + 'owner' => $owner + ); + return $this->mountShare($options); + } + } + + public function setup() { + // don't setup server-to-server shares if the file_external app is disabled + // FIXME no longer needed if we use the webdav implementation from core + if (\OC_App::isEnabled('files_external') === false) { + return false; + } + + $user = $this->userSession->getUser(); + if ($user) { + $query = $this->connection->prepare('SELECT `remote`, `share_token`, `password`, `mountpoint`, `owner` + FROM *PREFIX*share_external WHERE `user` = ?'); + $query->execute(array($user->getUID())); + + while ($row = $query->fetch()) { + $row['manager'] = $this; + $row['token'] = $row['share_token']; + $this->mountShare($row); + } + } + } + + protected function stripPath($path) { + $prefix = '/' . $this->userSession->getUser()->getUID() . '/files'; + return rtrim(substr($path, strlen($prefix)), '/'); + } + + /** + * @param array $data + * @return Mount + */ + protected function mountShare($data) { + $mountPoint = '/' . $this->userSession->getUser()->getUID() . '/files' . $data['mountpoint']; + $mount = new Mount(self::STORAGE, $mountPoint, $data, $this, $this->storageLoader); + $this->mountManager->addMount($mount); + return $mount; + } + + /** + * @return \OC\Files\Mount\Manager + */ + public function getMountManager() { + return $this->mountManager; + } + + /** + * @param string $source + * @param string $target + * @return bool + */ + public function setMountPoint($source, $target) { + $user = $this->userSession->getUser(); + $source = $this->stripPath($source); + $target = $this->stripPath($target); + $sourceHash = md5($source); + $targetHash = md5($target); + + $query = $this->connection->prepare('UPDATE *PREFIX*share_external SET + `mountpoint` = ?, `mountpoint_hash` = ? WHERE `mountpoint_hash` = ? AND `user` = ?'); + $result = (bool)$query->execute(array($target, $targetHash, $sourceHash, $user->getUID())); + + return $result; + } + + public function removeShare($mountPoint) { + $user = $this->userSession->getUser(); + $mountPoint = $this->stripPath($mountPoint); + $hash = md5($mountPoint); + $query = $this->connection->prepare('DELETE FROM *PREFIX*share_external WHERE `mountpoint_hash` = ? AND `user` = ?'); + return (bool)$query->execute(array($hash, $user->getUID())); + } +} diff --git a/apps/files_sharing/lib/external/mount.php b/apps/files_sharing/lib/external/mount.php new file mode 100644 index 00000000000..a42a12f9b9a --- /dev/null +++ b/apps/files_sharing/lib/external/mount.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCA\Files_Sharing\External; + +use OC\Files\Mount\MoveableMount; + +class Mount extends \OC\Files\Mount\Mount implements MoveableMount { + + /** + * @var \OCA\Files_Sharing\External\Manager + */ + protected $manager; + + /** + * @param string|\OC\Files\Storage\Storage $storage + * @param string $mountpoint + * @param array $options + * @param \OCA\Files_Sharing\External\Manager $manager + * @param \OC\Files\Storage\Loader $loader + */ + public function __construct($storage, $mountpoint, $options, $manager, $loader = null) { + parent::__construct($storage, $mountpoint, $options, $loader); + $this->manager = $manager; + } + + /** + * Move the mount point to $target + * + * @param string $target the target mount point + * @return bool + */ + public function moveMount($target) { + $result = $this->manager->setMountPoint($this->mountPoint, $target); + $this->setMountPoint($target); + return $result; + } + + /** + * Remove the mount points + * + * @return mixed + * @return bool + */ + public function removeMount() { + return $this->manager->removeShare($this->mountPoint); + } +} diff --git a/apps/files_sharing/lib/external/scanner.php b/apps/files_sharing/lib/external/scanner.php new file mode 100644 index 00000000000..8921dd1a4c0 --- /dev/null +++ b/apps/files_sharing/lib/external/scanner.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCA\Files_Sharing\External; + +class Scanner extends \OC\Files\Cache\Scanner { + /** + * @var \OCA\Files_Sharing\External\Storage + */ + protected $storage; + + public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1) { + $this->scanAll(); + } + + public function scanAll() { + $remote = $this->storage->getRemote(); + $token = $this->storage->getToken(); + $password = $this->storage->getPassword(); + $url = $remote . '/index.php/apps/files_sharing/shareinfo?t=' . $token; + + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, + http_build_query(array('password' => $password))); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + $result = curl_exec($ch); + curl_close($ch); + + $data = json_decode($result, true); + if ($data['status'] === 'success') { + $this->addResult($data['data'], ''); + } else { + throw new \Exception('Error while scanning remote share'); + } + } + + private function addResult($data, $path) { + $this->cache->put($path, $data); + if (isset($data['children'])) { + foreach ($data['children'] as $child) { + $this->addResult($child, ltrim($path . '/' . $child['name'], '/')); + } + } + } +} diff --git a/apps/files_sharing/lib/external/storage.php b/apps/files_sharing/lib/external/storage.php new file mode 100644 index 00000000000..cd04841bb09 --- /dev/null +++ b/apps/files_sharing/lib/external/storage.php @@ -0,0 +1,103 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCA\Files_Sharing\External; + +use OC\Files\Filesystem; +use OC\Files\Storage\DAV; +use OCA\Files_Sharing\ISharedStorage; + +class Storage extends DAV implements ISharedStorage { + /** + * @var string + */ + private $remoteUser; + + /** + * @var string + */ + private $remote; + + /** + * @var string + */ + private $mountPoint; + + /** + * @var string + */ + private $token; + + public function __construct($options) { + $this->remote = $options['remote']; + $this->remoteUser = $options['owner']; + list($protocol, $remote) = explode('://', $this->remote); + list($host, $root) = explode('/', $remote); + $secure = $protocol === 'https'; + $root .= '/public.php/webdav'; + $this->mountPoint = $options['mountpoint']; + $this->token = $options['token']; + parent::__construct(array( + 'secure' => $secure, + 'host' => $host, + 'root' => $root, + 'user' => $options['token'], + 'password' => $options['password'] + )); + } + + public function getRemoteUser() { + return $this->remoteUser; + } + + public function getRemote() { + return $this->remote; + } + + public function getMountPoint() { + return $this->mountPoint; + } + + public function getToken() { + return $this->token; + } + + public function getPassword() { + return $this->password; + } + + /** + * @brief get id of the mount point + * @return string + */ + public function getId() { + return 'shared::' . md5($this->token . '@' . $this->remote); + } + + public function getCache($path = '', $storage = null) { + if (!$storage) { + $this->cache = new Cache($this, $this->remote, $this->remoteUser); + } + return $this->cache; + } + + /** + * @param string $path + * @param \OC\Files\Storage\Storage $storage + * @return \OCA\Files_Sharing\External\Scanner + */ + public function getScanner($path = '', $storage = null) { + if (!$storage) { + $storage = $this; + } + if (!isset($this->scanner)) { + $this->scanner = new Scanner($storage); + } + return $this->scanner; + } +} diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php index 49546f012a6..34de3a915ab 100644 --- a/apps/files_sharing/lib/helper.php +++ b/apps/files_sharing/lib/helper.php @@ -16,7 +16,7 @@ class Helper { public static function setupFromToken($token, $relativePath = null, $password = null) { \OC_User::setIncognitoMode(true); - $linkItem = \OCP\Share::getShareByToken($token); + $linkItem = \OCP\Share::getShareByToken($token, !$password); if($linkItem === false || ($linkItem['item_type'] !== 'file' && $linkItem['item_type'] !== 'folder')) { \OC_Response::setStatus(404); \OC_Log::write('core-preview', 'Passed token parameter is not valid', \OC_Log::DEBUG); @@ -202,4 +202,24 @@ class Helper { return $path; } + + /** + * allow users from other ownCloud instances to mount public links share by this instance + * @return bool + */ + public static function isOutgoingServer2serverShareEnabled() { + $appConfig = \OC::$server->getAppConfig(); + $result = $appConfig->getValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes'); + return ($result === 'yes') ? true : false; + } + + /** + * allow user to mount public links from onther ownClouds + * @return bool + */ + public static function isIncomingServer2serverShareEnabled() { + $appConfig = \OC::$server->getAppConfig(); + $result = $appConfig->getValue('files_sharing', 'incoming_server2server_share_enabled', 'yes'); + return ($result === 'yes') ? true : false; + } } diff --git a/apps/files_sharing/lib/isharedstorage.php b/apps/files_sharing/lib/isharedstorage.php new file mode 100644 index 00000000000..75e0afef394 --- /dev/null +++ b/apps/files_sharing/lib/isharedstorage.php @@ -0,0 +1,13 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCA\Files_Sharing; + +interface ISharedStorage{ + +} diff --git a/apps/files_sharing/lib/readonlycache.php b/apps/files_sharing/lib/readonlycache.php new file mode 100644 index 00000000000..f129ca49433 --- /dev/null +++ b/apps/files_sharing/lib/readonlycache.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCA\Files_Sharing; + +use OC\Files\Cache\Cache; + +class ReadOnlyCache extends Cache { + public function get($path) { + $data = parent::get($path); + $data['permissions'] &= (\OCP\PERMISSION_READ | \OCP\PERMISSION_SHARE); + return $data; + } + + public function getFolderContents($path) { + $content = parent::getFolderContents($path); + foreach ($content as &$data) { + $data['permissions'] &= (\OCP\PERMISSION_READ | \OCP\PERMISSION_SHARE); + } + return $content; + } +} diff --git a/apps/files_sharing/lib/readonlywrapper.php b/apps/files_sharing/lib/readonlywrapper.php new file mode 100644 index 00000000000..45ed3fd68bb --- /dev/null +++ b/apps/files_sharing/lib/readonlywrapper.php @@ -0,0 +1,56 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCA\Files_Sharing; + +use OC\Files\Storage\Wrapper\Wrapper; + +class ReadOnlyWrapper extends Wrapper { + public function isUpdatable($path) { + return false; + } + + public function isCreatable($path) { + return false; + } + + public function isDeletable($path) { + return false; + } + + public function getPermissions($path) { + return $this->storage->getPermissions($path) & (\OCP\PERMISSION_READ | \OCP\PERMISSION_SHARE); + } + + public function rename($path1, $path2) { + return false; + } + + public function touch($path, $mtime = null) { + return false; + } + + public function mkdir($path) { + return false; + } + + public function rmdir($path) { + return false; + } + + public function unlink($path) { + return false; + } + + public function getCache($path = '', $storage = null) { + if (!$storage) { + $storage = $this; + } + return new ReadOnlyCache($storage); + } +} diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index 59de2dfa4c4..8d5b22dc283 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -23,12 +23,13 @@ namespace OC\Files\Storage; use OC\Files\Filesystem; +use OCA\Files_Sharing\ISharedStorage; use OCA\Files_Sharing\SharedMount; /** * Convert target path to source path and pass the function call to the correct storage provider */ -class Shared extends \OC\Files\Storage\Common { +class Shared extends \OC\Files\Storage\Common implements ISharedStorage { private $share; // the shared resource private $files = array(); @@ -488,16 +489,25 @@ class Shared extends \OC\Files\Storage\Common { return $this->filemtime($path) > $time; } - public function getCache($path = '') { - return new \OC\Files\Cache\Shared_Cache($this); + public function getCache($path = '', $storage = null) { + if (!$storage) { + $storage = $this; + } + return new \OC\Files\Cache\Shared_Cache($storage); } - public function getScanner($path = '') { - return new \OC\Files\Cache\Scanner($this); + public function getScanner($path = '', $storage = null) { + if (!$storage) { + $storage = $this; + } + return new \OC\Files\Cache\Scanner($storage); } - public function getWatcher($path = '') { - return new \OC\Files\Cache\Shared_Watcher($this); + public function getWatcher($path = '', $storage = null) { + if (!$storage) { + $storage = $this; + } + return new \OC\Files\Cache\Shared_Watcher($storage); } public function getOwner($path) { diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 4782c4dbe32..ec7c80f3316 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -128,6 +128,7 @@ if (isset($path)) { $tmpl->assign('mimetype', \OC\Files\Filesystem::getMimeType($path)); $tmpl->assign('dirToken', $linkItem['token']); $tmpl->assign('sharingToken', $token); + $tmpl->assign('protected', isset($linkItem['share_with']) ? 'true' : 'false'); $urlLinkIdentifiers= (isset($token)?'&t='.$token:'') .(isset($_GET['dir'])?'&dir='.$_GET['dir']:'') diff --git a/apps/files_sharing/publicwebdav.php b/apps/files_sharing/publicwebdav.php index df2c04cf45c..684edd97670 100644 --- a/apps/files_sharing/publicwebdav.php +++ b/apps/files_sharing/publicwebdav.php @@ -6,6 +6,10 @@ * See the COPYING-README file. */ +if (OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled() === false) { + return false; +} + // load needed apps $RUNTIME_APPTYPES = array('filesystem', 'authentication', 'logging'); @@ -37,7 +41,15 @@ $server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('webdav')); $server->subscribeEvent('beforeMethod', function () use ($server, $objectTree, $authBackend) { $share = $authBackend->getShare(); $owner = $share['uid_owner']; + $isWritable = $share['permissions'] & (\OCP\PERMISSION_UPDATE | \OCP\PERMISSION_CREATE); $fileId = $share['file_source']; + + if (!$isWritable) { + \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { + return new \OCA\Files_Sharing\ReadOnlyWrapper(array('storage' => $storage)); + }); + } + OC_Util::setupFS($owner); $ownerView = \OC\Files\Filesystem::getView(); $path = $ownerView->getPath($fileId); @@ -47,8 +59,13 @@ $server->subscribeEvent('beforeMethod', function () use ($server, $objectTree, $ $rootInfo = $view->getFileInfo(''); // Create ownCloud Dir - $rootDir = new OC_Connector_Sabre_Directory($view, $rootInfo); - $objectTree->init($rootDir, $view); + if ($rootInfo->getType() === 'dir') { + $root = new OC_Connector_Sabre_Directory($view, $rootInfo); + } else { + $root = new OC_Connector_Sabre_File($view, $rootInfo); + } + $mountManager = \OC\Files\Filesystem::getMountManager(); + $objectTree->init($root, $view, $mountManager); $server->addPlugin(new OC_Connector_Sabre_AbortedUploadDetectionPlugin($view)); $server->addPlugin(new OC_Connector_Sabre_QuotaPlugin($view)); diff --git a/apps/files_sharing/settings-admin.php b/apps/files_sharing/settings-admin.php new file mode 100644 index 00000000000..9c630b6a911 --- /dev/null +++ b/apps/files_sharing/settings-admin.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright (c) 2011 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +\OC_Util::checkAdminUser(); + +\OCP\Util::addScript('files_sharing', 'settings-admin'); + +$tmpl = new OCP\Template('files_sharing', 'settings-admin'); +$tmpl->assign('outgoingServer2serverShareEnabled', OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled()); +$tmpl->assign('incomingServer2serverShareEnabled', OCA\Files_Sharing\Helper::isIncomingServer2serverShareEnabled()); + +return $tmpl->fetchPage(); diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 7b5f603a105..c053aaabece 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -15,10 +15,19 @@ src="<?php print_unescaped(image_path('', 'logo-wide.svg')); ?>" alt="<?php p($theme->getName()); ?>" /></a> <div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div> <div class="header-right"> - <a href="<?php p($_['downloadURL']); ?>" id="download" class="button"> - <img class="svg" alt="" src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>"/> - <?php p($l->t('Download'))?> - </a> + <span id="details"> + <span id="save" data-protected="<?php p($_['protected'])?>" data-owner="<?php p($_['displayName'])?>" data-name="<?php p($_['filename'])?>"> + <button><?php p($l->t('Save to ownCloud')) ?></button> + <form class="save-form hidden" action="#"> + <input type="text" id="remote_address" placeholder="<?php p($l->t('example.com/owncloud')) ?>"/> + <input type="submit" value="<?php p($l->t('Save')) ?>"/> + </form> + </span> + <a href="<?php p($_['downloadURL']); ?>" id="download" class="button"> + <img class="svg" alt="" src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>"/> + <?php p($l->t('Download'))?> + </a> + </span> </div> </div></header> <div id="content"> diff --git a/apps/files_sharing/templates/settings-admin.php b/apps/files_sharing/templates/settings-admin.php new file mode 100644 index 00000000000..18cf2276701 --- /dev/null +++ b/apps/files_sharing/templates/settings-admin.php @@ -0,0 +1,13 @@ +<div class="section" id="fileSharingSettings" > + + <h2><?php p($l->t('File Sharing'));?></h2> + + <input type="checkbox" name="outgoing_server2server_share_enabled" id="outgoingServer2serverShareEnabled" + value="1" <?php if ($_['outgoingServer2serverShareEnabled']) print_unescaped('checked="checked"'); ?> /> + <label for="outgoingServer2serverShareEnabled"><?php p($l->t('Allow other instances to mount public links shared from this server'));?></label><br/> + + <input type="checkbox" name="incoming_server2server_share_enabled" id="incomingServer2serverShareEnabled" + value="1" <?php if ($_['incomingServer2serverShareEnabled']) print_unescaped('checked="checked"'); ?> /> + <label for="incomingServer2serverShareEnabled"><?php p($l->t('Allow users to mount public link shares'));?></label><br/> + +</div> |