summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2012-10-28 11:16:04 +0000
committerTom Needham <needham.thomas@gmail.com>2012-10-28 11:16:04 +0000
commitbcdf3a23db6867332232f8c1b69ba3fa394e191a (patch)
tree20be51b4a2e5f1c7f8bc3a50ca3fb9571e972af3 /apps/files_sharing
parentb07944798848bc5196dc75e8d8caea5ca71b0f15 (diff)
parent22dcd3b6a691c7a245e4d1de30f09bb17efdfceb (diff)
downloadnextcloud-server-bcdf3a23db6867332232f8c1b69ba3fa394e191a.tar.gz
nextcloud-server-bcdf3a23db6867332232f8c1b69ba3fa394e191a.zip
Merge master into ocs_api
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/appinfo/info.xml2
-rw-r--r--apps/files_sharing/appinfo/update.php32
-rw-r--r--apps/files_sharing/appinfo/version2
-rw-r--r--apps/files_sharing/css/public.css78
-rw-r--r--apps/files_sharing/js/public.js29
-rw-r--r--apps/files_sharing/js/share.js10
-rw-r--r--apps/files_sharing/l10n/ca.php2
-rw-r--r--apps/files_sharing/l10n/cs_CZ.php2
-rw-r--r--apps/files_sharing/l10n/da.php2
-rw-r--r--apps/files_sharing/l10n/de.php4
-rw-r--r--apps/files_sharing/l10n/de_DE.php9
-rw-r--r--apps/files_sharing/l10n/el.php7
-rw-r--r--apps/files_sharing/l10n/eo.php2
-rw-r--r--apps/files_sharing/l10n/es.php2
-rw-r--r--apps/files_sharing/l10n/es_AR.php9
-rw-r--r--apps/files_sharing/l10n/eu.php2
-rw-r--r--apps/files_sharing/l10n/fi_FI.php2
-rw-r--r--apps/files_sharing/l10n/fr.php2
-rw-r--r--apps/files_sharing/l10n/gl.php7
-rw-r--r--apps/files_sharing/l10n/he.php2
-rw-r--r--apps/files_sharing/l10n/id.php9
-rw-r--r--apps/files_sharing/l10n/it.php2
-rw-r--r--apps/files_sharing/l10n/ja_JP.php2
-rw-r--r--apps/files_sharing/l10n/ka_GE.php6
-rw-r--r--apps/files_sharing/l10n/ku_IQ.php9
-rw-r--r--apps/files_sharing/l10n/nl.php2
-rw-r--r--apps/files_sharing/l10n/pl.php2
-rw-r--r--apps/files_sharing/l10n/pt_BR.php9
-rw-r--r--apps/files_sharing/l10n/pt_PT.php9
-rw-r--r--apps/files_sharing/l10n/ro.php9
-rw-r--r--apps/files_sharing/l10n/ru.php2
-rw-r--r--apps/files_sharing/l10n/ru_RU.php9
-rw-r--r--apps/files_sharing/l10n/si_LK.php9
-rw-r--r--apps/files_sharing/l10n/sk_SK.php2
-rw-r--r--apps/files_sharing/l10n/sl.php4
-rw-r--r--apps/files_sharing/l10n/sv.php2
-rw-r--r--apps/files_sharing/l10n/th_TH.php2
-rw-r--r--apps/files_sharing/l10n/vi.php2
-rw-r--r--apps/files_sharing/l10n/zh_CN.GB2312.php9
-rw-r--r--apps/files_sharing/l10n/zh_CN.php9
-rw-r--r--apps/files_sharing/lib/share/file.php14
-rw-r--r--apps/files_sharing/lib/share/folder.php2
-rw-r--r--apps/files_sharing/lib/sharedstorage.php8
-rw-r--r--apps/files_sharing/public.php297
-rw-r--r--[-rwxr-xr-x]apps/files_sharing/templates/public.php36
45 files changed, 559 insertions, 114 deletions
diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml
index 6a8fc89adae..a44d0338bb6 100644
--- a/apps/files_sharing/appinfo/info.xml
+++ b/apps/files_sharing/appinfo/info.xml
@@ -5,7 +5,7 @@
<description>File sharing between users</description>
<licence>AGPL</licence>
<author>Michael Gapczynski</author>
- <require>4</require>
+ <require>4.9</require>
<shipped>true</shipped>
<default_enable/>
<types>
diff --git a/apps/files_sharing/appinfo/update.php b/apps/files_sharing/appinfo/update.php
index eabd1167c97..e75c538b150 100644
--- a/apps/files_sharing/appinfo/update.php
+++ b/apps/files_sharing/appinfo/update.php
@@ -1,9 +1,14 @@
<?php
$installedVersion = OCP\Config::getAppValue('files_sharing', 'installed_version');
if (version_compare($installedVersion, '0.3', '<')) {
+ $update_error = false;
$query = OCP\DB::prepare('SELECT * FROM `*PREFIX*sharing`');
$result = $query->execute();
$groupShares = array();
+ //we need to set up user backends, otherwise creating the shares will fail with "because user does not exist"
+ OC_User::useBackend(new OC_User_Database());
+ OC_Group::useBackend(new OC_Group_Database());
+ OC_App::loadApps(array('authentication'));
while ($row = $result->fetchRow()) {
$itemSource = OC_FileCache::getId($row['source'], '');
if ($itemSource != -1) {
@@ -14,9 +19,9 @@ if (version_compare($installedVersion, '0.3', '<')) {
$itemType = 'file';
}
if ($row['permissions'] == 0) {
- $permissions = OCP\Share::PERMISSION_READ;
+ $permissions = OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_SHARE;
} else {
- $permissions = OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_UPDATE;
+ $permissions = OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_UPDATE | OCP\Share::PERMISSION_SHARE;
if ($itemType == 'folder') {
$permissions |= OCP\Share::PERMISSION_CREATE;
}
@@ -38,10 +43,31 @@ if (version_compare($installedVersion, '0.3', '<')) {
$shareWith = $row['uid_shared_with'];
}
OC_User::setUserId($row['uid_owner']);
- OCP\Share::shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions);
+ //we need to setup the filesystem for the user, otherwise OC_FileSystem::getRoot will fail and break
+ OC_Util::setupFS($row['uid_owner']);
+ try {
+ OCP\Share::shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions);
+ }
+ catch (Exception $e) {
+ $update_error = true;
+ OCP\Util::writeLog('files_sharing', 'Upgrade Routine: Skipping sharing "'.$row['source'].'" to "'.$shareWith.'" (error is "'.$e->getMessage().'")', OCP\Util::WARN);
+ }
+ OC_Util::tearDownFS();
}
}
+ OC_User::setUserId(null);
+ if ($update_error) {
+ OCP\Util::writeLog('files_sharing', 'There were some problems upgrading the sharing of files', OCP\Util::ERROR);
+ }
// NOTE: Let's drop the table after more testing
// $query = OCP\DB::prepare('DROP TABLE `*PREFIX*sharing`');
// $query->execute();
+}
+if (version_compare($installedVersion, '0.3.3', '<')) {
+ OC_User::useBackend(new OC_User_Database());
+ OC_App::loadApps(array('authentication'));
+ $users = OC_User::getUsers();
+ foreach ($users as $user) {
+ OC_FileCache::delete('Shared', '/'.$user.'/files/');
+ }
} \ No newline at end of file
diff --git a/apps/files_sharing/appinfo/version b/apps/files_sharing/appinfo/version
index 9fc80f937fa..87a0871112f 100644
--- a/apps/files_sharing/appinfo/version
+++ b/apps/files_sharing/appinfo/version
@@ -1 +1 @@
-0.3.2 \ No newline at end of file
+0.3.3 \ No newline at end of file
diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css
index a700cc2169b..492014344f7 100644
--- a/apps/files_sharing/css/public.css
+++ b/apps/files_sharing/css/public.css
@@ -1,8 +1,70 @@
-body { background:#ddd; }
-#header { position:fixed; top:0; left:0; right:0; z-index:100; height:2.5em; line-height:2.5em; padding:.5em; background:#1d2d44; -moz-box-shadow:0 0 10px rgba(0, 0, 0, .5), inset 0 -2px 10px #222; -webkit-box-shadow:0 0 10px rgba(0, 0, 0, .5), inset 0 -2px 10px #222; box-shadow:0 0 10px rgba(0, 0, 0, .5), inset 0 -2px 10px #222; }
-#details { color:#fff; }
-#header #download { margin-left:2em; font-weight:bold; color:#fff; }
-#preview { min-height:30em; margin:50px auto; padding-top:2em; border-bottom:1px solid #f8f8f8; background:#eee; text-align:center; }
-#noPreview { display:none; padding-top:5em; }
-p.info { width:22em; text-align: center; margin:2em auto; color:#777; text-shadow:#fff 0 1px 0; }
-p.info a { font-weight:bold; color:#777; } \ No newline at end of file
+body {
+ background:#ddd;
+}
+
+#header {
+ background:#1d2d44;
+ box-shadow:0 0 10px rgba(0,0,0,.5), inset 0 -2px 10px #222;
+ height:2.5em;
+ left:0;
+ line-height:2.5em;
+ position:fixed;
+ right:0;
+ top:0;
+ z-index:100;
+ padding:.5em;
+}
+
+#details {
+ color:#fff;
+}
+
+#header #download {
+ font-weight:700;
+ margin-left:2em;
+}
+
+#header #download img {
+ padding-left:.1em;
+ padding-right:.3em;
+ vertical-align:text-bottom;
+}
+
+#preview {
+ background:#eee;
+ border-bottom:1px solid #f8f8f8;
+ min-height:30em;
+ padding-top:2em;
+ text-align:center;
+ margin:50px auto;
+}
+
+#noPreview {
+ display:none;
+ padding-top:5em;
+}
+
+p.info {
+ color:#777;
+ text-align:center;
+ text-shadow:#fff 0 1px 0;
+ width:22em;
+ margin:2em auto;
+}
+
+p.info a {
+ color:#777;
+ font-weight:700;
+}
+
+#imgframe {
+ height:75%;
+ padding-bottom:2em;
+ width:80%;
+ margin:0 auto;
+}
+
+#imgframe img {
+ max-height:100%;
+ max-width:100%;
+} \ No newline at end of file
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index 92b626bba18..916e35419c1 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -1,6 +1,10 @@
// Override download path to files_sharing/public.php
function fileDownloadPath(dir, file) {
- return $('#downloadURL').val();
+ var url = $('#downloadURL').val();
+ if (url.indexOf('&path=') != -1) {
+ url += '/'+file;
+ }
+ return url;
}
$(document).ready(function() {
@@ -13,10 +17,33 @@ $(document).ready(function() {
var action = FileActions.getDefault(mimetype, 'file', OC.PERMISSION_READ);
if (typeof action === 'undefined') {
$('#noPreview').show();
+ if (mimetype != 'httpd/unix-directory') {
+ // NOTE: Remove when a better file previewer solution exists
+ $('#content').remove();
+ $('table').remove();
+ }
} else {
action($('#filename').val());
}
}
+ FileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function(filename) {
+ var tr = $('tr').filterAttr('data-file', filename)
+ if (tr.length > 0) {
+ window.location = $(tr).find('a.name').attr('href');
+ }
+ });
+ FileActions.register('file', 'Download', OC.PERMISSION_READ, '', function(filename) {
+ var tr = $('tr').filterAttr('data-file', filename)
+ if (tr.length > 0) {
+ window.location = $(tr).find('a.name').attr('href');
+ }
+ });
+ FileActions.register('dir', 'Download', OC.PERMISSION_READ, '', function(filename) {
+ var tr = $('tr').filterAttr('data-file', filename)
+ if (tr.length > 0) {
+ window.location = $(tr).find('a.name').attr('href')+'&download';
+ }
+ });
}
}); \ No newline at end of file
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index 9d0e2c90f88..72663c068c9 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -1,6 +1,6 @@
$(document).ready(function() {
- if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined') {
+ if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !publicListView) {
OC.Share.loadIcons('file');
FileActions.register('all', 'Share', OC.PERMISSION_READ, function(filename) {
// Return the correct sharing icon
@@ -39,26 +39,24 @@ $(document).ready(function() {
var tr = $('tr').filterAttr('data-file', filename);
if ($(tr).data('type') == 'dir') {
var itemType = 'folder';
- var link = false;
} else {
var itemType = 'file';
- var link = true;
}
var possiblePermissions = $(tr).data('permissions');
var appendTo = $(tr).find('td.filename');
// Check if drop down is already visible for a different file
if (OC.Share.droppedDown) {
- if (item != $('#dropdown').data('item')) {
+ if ($(tr).data('id') != $('#dropdown').attr('data-item-source')) {
OC.Share.hideDropDown(function () {
$(tr).addClass('mouseOver');
- OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, link, possiblePermissions);
+ OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions);
});
} else {
OC.Share.hideDropDown();
}
} else {
$(tr).addClass('mouseOver');
- OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, link, possiblePermissions);
+ OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions);
}
});
}
diff --git a/apps/files_sharing/l10n/ca.php b/apps/files_sharing/l10n/ca.php
index f00d0d72632..223495455f0 100644
--- a/apps/files_sharing/l10n/ca.php
+++ b/apps/files_sharing/l10n/ca.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Contrasenya",
"Submit" => "Envia",
+"%s shared the folder %s with you" => "%s ha compartit la carpeta %s amb vós",
+"%s shared the file %s with you" => "%s ha compartit el fitxer %s amb vós",
"Download" => "Baixa",
"No preview available for" => "No hi ha vista prèvia disponible per a",
"web services under your control" => "controleu els vostres serveis web"
diff --git a/apps/files_sharing/l10n/cs_CZ.php b/apps/files_sharing/l10n/cs_CZ.php
index e9185e979cd..9889fae488a 100644
--- a/apps/files_sharing/l10n/cs_CZ.php
+++ b/apps/files_sharing/l10n/cs_CZ.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Heslo",
"Submit" => "Odeslat",
+"%s shared the folder %s with you" => "%s s Vámi sdílí složku %s",
+"%s shared the file %s with you" => "%s s Vámi sdílí soubor %s",
"Download" => "Stáhnout",
"No preview available for" => "Náhled není dostupný pro",
"web services under your control" => "služby webu pod Vaší kontrolou"
diff --git a/apps/files_sharing/l10n/da.php b/apps/files_sharing/l10n/da.php
index 1fd9f774a96..75fbdabe16f 100644
--- a/apps/files_sharing/l10n/da.php
+++ b/apps/files_sharing/l10n/da.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Kodeord",
"Submit" => "Send",
+"%s shared the folder %s with you" => "%s delte mappen %s med dig",
+"%s shared the file %s with you" => "%s delte filen %s med dig",
"Download" => "Download",
"No preview available for" => "Forhåndsvisning ikke tilgængelig for",
"web services under your control" => "Webtjenester under din kontrol"
diff --git a/apps/files_sharing/l10n/de.php b/apps/files_sharing/l10n/de.php
index 90dce8ec623..7f4cbb1adad 100644
--- a/apps/files_sharing/l10n/de.php
+++ b/apps/files_sharing/l10n/de.php
@@ -1,7 +1,9 @@
<?php $TRANSLATIONS = array(
"Password" => "Passwort",
"Submit" => "Absenden",
+"%s shared the folder %s with you" => "%s hat den Ordner %s mit Dir geteilt",
+"%s shared the file %s with you" => "%s hat die Datei %s mit Dir geteilt",
"Download" => "Download",
"No preview available for" => "Es ist keine Vorschau verfügbar für",
-"web services under your control" => "Web-Services unter Ihrer Kontrolle"
+"web services under your control" => "Web-Services unter Deiner Kontrolle"
);
diff --git a/apps/files_sharing/l10n/de_DE.php b/apps/files_sharing/l10n/de_DE.php
new file mode 100644
index 00000000000..b92d6d478c9
--- /dev/null
+++ b/apps/files_sharing/l10n/de_DE.php
@@ -0,0 +1,9 @@
+<?php $TRANSLATIONS = array(
+"Password" => "Passwort",
+"Submit" => "Absenden",
+"%s shared the folder %s with you" => "%s hat den Ordner %s mit Ihnen geteilt",
+"%s shared the file %s with you" => "%s hat die Datei %s mit Ihnen geteilt",
+"Download" => "Download",
+"No preview available for" => "Es ist keine Vorschau verfügbar für",
+"web services under your control" => "Web-Services unter Ihrer Kontrolle"
+);
diff --git a/apps/files_sharing/l10n/el.php b/apps/files_sharing/l10n/el.php
index 123a008e554..5305eedd484 100644
--- a/apps/files_sharing/l10n/el.php
+++ b/apps/files_sharing/l10n/el.php
@@ -1,4 +1,9 @@
<?php $TRANSLATIONS = array(
"Password" => "Συνθηματικό",
-"Submit" => "Καταχώρηση"
+"Submit" => "Καταχώρηση",
+"%s shared the folder %s with you" => "%s μοιράστηκε τον φάκελο %s μαζί σας",
+"%s shared the file %s with you" => "%s μοιράστηκε το αρχείο %s μαζί σας",
+"Download" => "Λήψη",
+"No preview available for" => "Δεν υπάρχει διαθέσιμη προεπισκόπηση για",
+"web services under your control" => "υπηρεσίες δικτύου υπό τον έλεγχό σας"
);
diff --git a/apps/files_sharing/l10n/eo.php b/apps/files_sharing/l10n/eo.php
index e71715f0f1f..c598d3aa2c4 100644
--- a/apps/files_sharing/l10n/eo.php
+++ b/apps/files_sharing/l10n/eo.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Pasvorto",
"Submit" => "Sendi",
+"%s shared the folder %s with you" => "%s kunhavigis la dosierujon %s kun vi",
+"%s shared the file %s with you" => "%s kunhavigis la dosieron %s kun vi",
"Download" => "Elŝuti",
"No preview available for" => "Ne haveblas antaŭvido por",
"web services under your control" => "TTT-servoj regataj de vi"
diff --git a/apps/files_sharing/l10n/es.php b/apps/files_sharing/l10n/es.php
index b1d44e5485e..2023d35903e 100644
--- a/apps/files_sharing/l10n/es.php
+++ b/apps/files_sharing/l10n/es.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Contraseña",
"Submit" => "Enviar",
+"%s shared the folder %s with you" => "%s compartió la carpeta %s contigo",
+"%s shared the file %s with you" => "%s compartió el fichero %s contigo",
"Download" => "Descargar",
"No preview available for" => "No hay vista previa disponible para",
"web services under your control" => "Servicios web bajo su control"
diff --git a/apps/files_sharing/l10n/es_AR.php b/apps/files_sharing/l10n/es_AR.php
new file mode 100644
index 00000000000..a2d6e232f20
--- /dev/null
+++ b/apps/files_sharing/l10n/es_AR.php
@@ -0,0 +1,9 @@
+<?php $TRANSLATIONS = array(
+"Password" => "Contraseña",
+"Submit" => "Enviar",
+"%s shared the folder %s with you" => "%s compartió la carpeta %s con vos",
+"%s shared the file %s with you" => "%s compartió el archivo %s con vos",
+"Download" => "Descargar",
+"No preview available for" => "La vista preliminar no está disponible para",
+"web services under your control" => "servicios web controlados por vos"
+);
diff --git a/apps/files_sharing/l10n/eu.php b/apps/files_sharing/l10n/eu.php
index 70ff2e8876c..ebef0f445ed 100644
--- a/apps/files_sharing/l10n/eu.php
+++ b/apps/files_sharing/l10n/eu.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Pasahitza",
"Submit" => "Bidali",
+"%s shared the folder %s with you" => "%sk zurekin %s karpeta elkarbanatu du",
+"%s shared the file %s with you" => "%sk zurekin %s fitxategia elkarbanatu du",
"Download" => "Deskargatu",
"No preview available for" => "Ez dago aurrebista eskuragarririk hauentzat ",
"web services under your control" => "web zerbitzuak zure kontrolpean"
diff --git a/apps/files_sharing/l10n/fi_FI.php b/apps/files_sharing/l10n/fi_FI.php
index 85c6c7a7132..6c441342133 100644
--- a/apps/files_sharing/l10n/fi_FI.php
+++ b/apps/files_sharing/l10n/fi_FI.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Salasana",
"Submit" => "Lähetä",
+"%s shared the folder %s with you" => "%s jakoi kansion %s kanssasi",
+"%s shared the file %s with you" => "%s jakoi tiedoston %s kanssasi",
"Download" => "Lataa",
"No preview available for" => "Ei esikatselua kohteelle",
"web services under your control" => "verkkopalvelut hallinnassasi"
diff --git a/apps/files_sharing/l10n/fr.php b/apps/files_sharing/l10n/fr.php
index 54d9e9ec567..1038d819330 100644
--- a/apps/files_sharing/l10n/fr.php
+++ b/apps/files_sharing/l10n/fr.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Mot de passe",
"Submit" => "Envoyer",
+"%s shared the folder %s with you" => "%s a partagé le répertoire %s avec vous",
+"%s shared the file %s with you" => "%s a partagé le fichier %s avec vous",
"Download" => "Télécharger",
"No preview available for" => "Pas d'aperçu disponible pour",
"web services under your control" => "services web sous votre contrôle"
diff --git a/apps/files_sharing/l10n/gl.php b/apps/files_sharing/l10n/gl.php
new file mode 100644
index 00000000000..c9644d720e3
--- /dev/null
+++ b/apps/files_sharing/l10n/gl.php
@@ -0,0 +1,7 @@
+<?php $TRANSLATIONS = array(
+"Password" => "Contrasinal",
+"Submit" => "Enviar",
+"Download" => "Baixar",
+"No preview available for" => "Sen vista previa dispoñible para ",
+"web services under your control" => "servizos web baixo o seu control"
+);
diff --git a/apps/files_sharing/l10n/he.php b/apps/files_sharing/l10n/he.php
index 68a337241da..ff7be88af87 100644
--- a/apps/files_sharing/l10n/he.php
+++ b/apps/files_sharing/l10n/he.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "ססמה",
"Submit" => "שליחה",
+"%s shared the folder %s with you" => "%s שיתף עמך את התיקייה %s",
+"%s shared the file %s with you" => "%s שיתף עמך את הקובץ %s",
"Download" => "הורדה",
"No preview available for" => "אין תצוגה מקדימה זמינה עבור",
"web services under your control" => "שירותי רשת תחת השליטה שלך"
diff --git a/apps/files_sharing/l10n/id.php b/apps/files_sharing/l10n/id.php
new file mode 100644
index 00000000000..8897269d989
--- /dev/null
+++ b/apps/files_sharing/l10n/id.php
@@ -0,0 +1,9 @@
+<?php $TRANSLATIONS = array(
+"Password" => "kata kunci",
+"Submit" => "kirim",
+"%s shared the folder %s with you" => "%s membagikan folder %s dengan anda",
+"%s shared the file %s with you" => "%s membagikan file %s dengan anda",
+"Download" => "unduh",
+"No preview available for" => "tidak ada pratinjau tersedia untuk",
+"web services under your control" => "servis web dibawah kendali anda"
+);
diff --git a/apps/files_sharing/l10n/it.php b/apps/files_sharing/l10n/it.php
index 5bedabde9bb..f83ca1446d6 100644
--- a/apps/files_sharing/l10n/it.php
+++ b/apps/files_sharing/l10n/it.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Password",
"Submit" => "Invia",
+"%s shared the folder %s with you" => "%s ha condiviso la cartella %s con te",
+"%s shared the file %s with you" => "%s ha condiviso il file %s con te",
"Download" => "Scarica",
"No preview available for" => "Nessuna anteprima disponibile per",
"web services under your control" => "servizi web nelle tue mani"
diff --git a/apps/files_sharing/l10n/ja_JP.php b/apps/files_sharing/l10n/ja_JP.php
index 5d63f371d56..02142e2879a 100644
--- a/apps/files_sharing/l10n/ja_JP.php
+++ b/apps/files_sharing/l10n/ja_JP.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "パスワード",
"Submit" => "送信",
+"%s shared the folder %s with you" => "%s はフォルダー %s をあなたと共有中です",
+"%s shared the file %s with you" => "%s はファイル %s をあなたと共有中です",
"Download" => "ダウンロード",
"No preview available for" => "プレビューはありません",
"web services under your control" => "管理下のウェブサービス"
diff --git a/apps/files_sharing/l10n/ka_GE.php b/apps/files_sharing/l10n/ka_GE.php
new file mode 100644
index 00000000000..ef42196d2cb
--- /dev/null
+++ b/apps/files_sharing/l10n/ka_GE.php
@@ -0,0 +1,6 @@
+<?php $TRANSLATIONS = array(
+"Password" => "პაროლი",
+"Submit" => "გაგზავნა",
+"Download" => "ჩამოტვირთვა",
+"web services under your control" => "web services under your control"
+);
diff --git a/apps/files_sharing/l10n/ku_IQ.php b/apps/files_sharing/l10n/ku_IQ.php
new file mode 100644
index 00000000000..f139b0a0643
--- /dev/null
+++ b/apps/files_sharing/l10n/ku_IQ.php
@@ -0,0 +1,9 @@
+<?php $TRANSLATIONS = array(
+"Password" => "تێپه‌ڕه‌وشه",
+"Submit" => "ناردن",
+"%s shared the folder %s with you" => "%s دابه‌شی کردووه‌ بوخچه‌ی %s له‌گه‌ڵ تۆ",
+"%s shared the file %s with you" => "%s دابه‌شی کردووه‌ په‌ڕگه‌یی %s له‌گه‌ڵ تۆ",
+"Download" => "داگرتن",
+"No preview available for" => "هیچ پێشبینیه‌ك ئاماده‌ نیه بۆ",
+"web services under your control" => "ڕاژه‌ی وێب له‌ژێر چاودێریت دایه"
+);
diff --git a/apps/files_sharing/l10n/nl.php b/apps/files_sharing/l10n/nl.php
index 2f732ed662f..2cef0254398 100644
--- a/apps/files_sharing/l10n/nl.php
+++ b/apps/files_sharing/l10n/nl.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Wachtwoord",
"Submit" => "Verzenden",
+"%s shared the folder %s with you" => "%s deelt de map %s met u",
+"%s shared the file %s with you" => "%s deelt het bestand %s met u",
"Download" => "Downloaden",
"No preview available for" => "Geen voorbeeldweergave beschikbaar voor",
"web services under your control" => "Webdiensten in eigen beheer"
diff --git a/apps/files_sharing/l10n/pl.php b/apps/files_sharing/l10n/pl.php
index 1d5e6261ef0..9db5e87c9ba 100644
--- a/apps/files_sharing/l10n/pl.php
+++ b/apps/files_sharing/l10n/pl.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Hasło",
"Submit" => "Wyślij",
+"%s shared the folder %s with you" => "%s współdzieli folder z tobą %s",
+"%s shared the file %s with you" => "%s współdzieli z tobą plik %s",
"Download" => "Pobierz",
"No preview available for" => "Podgląd nie jest dostępny dla",
"web services under your control" => "Kontrolowane serwisy"
diff --git a/apps/files_sharing/l10n/pt_BR.php b/apps/files_sharing/l10n/pt_BR.php
new file mode 100644
index 00000000000..4dde4bb5ad5
--- /dev/null
+++ b/apps/files_sharing/l10n/pt_BR.php
@@ -0,0 +1,9 @@
+<?php $TRANSLATIONS = array(
+"Password" => "Senha",
+"Submit" => "Submeter",
+"%s shared the folder %s with you" => "%s compartilhou a pasta %s com você",
+"%s shared the file %s with you" => "%s compartilhou o arquivo %s com você",
+"Download" => "Baixar",
+"No preview available for" => "Nenhuma visualização disponível para",
+"web services under your control" => "web services sob seu controle"
+);
diff --git a/apps/files_sharing/l10n/pt_PT.php b/apps/files_sharing/l10n/pt_PT.php
new file mode 100644
index 00000000000..b8e700e3802
--- /dev/null
+++ b/apps/files_sharing/l10n/pt_PT.php
@@ -0,0 +1,9 @@
+<?php $TRANSLATIONS = array(
+"Password" => "Palavra-Passe",
+"Submit" => "Submeter",
+"%s shared the folder %s with you" => "%s partilhou a pasta %s consigo",
+"%s shared the file %s with you" => "%s partilhou o ficheiro %s consigo",
+"Download" => "Descarregar",
+"No preview available for" => "Não há pré-visualização para",
+"web services under your control" => "serviços web sob o seu controlo"
+);
diff --git a/apps/files_sharing/l10n/ro.php b/apps/files_sharing/l10n/ro.php
new file mode 100644
index 00000000000..eb9977dc585
--- /dev/null
+++ b/apps/files_sharing/l10n/ro.php
@@ -0,0 +1,9 @@
+<?php $TRANSLATIONS = array(
+"Password" => "Parolă",
+"Submit" => "Trimite",
+"%s shared the folder %s with you" => "%s a partajat directorul %s cu tine",
+"%s shared the file %s with you" => "%s a partajat fișierul %s cu tine",
+"Download" => "Descarcă",
+"No preview available for" => "Nici o previzualizare disponibilă pentru ",
+"web services under your control" => "servicii web controlate de tine"
+);
diff --git a/apps/files_sharing/l10n/ru.php b/apps/files_sharing/l10n/ru.php
index 398d9a8bbc3..7fd116e0aae 100644
--- a/apps/files_sharing/l10n/ru.php
+++ b/apps/files_sharing/l10n/ru.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Пароль",
"Submit" => "Отправить",
+"%s shared the folder %s with you" => "%s открыл доступ к папке %s для Вас",
+"%s shared the file %s with you" => "%s открыл доступ к файлу %s для Вас",
"Download" => "Скачать",
"No preview available for" => "Предпросмотр недоступен для",
"web services under your control" => "веб-сервисы под вашим управлением"
diff --git a/apps/files_sharing/l10n/ru_RU.php b/apps/files_sharing/l10n/ru_RU.php
new file mode 100644
index 00000000000..36e4b2fd0e1
--- /dev/null
+++ b/apps/files_sharing/l10n/ru_RU.php
@@ -0,0 +1,9 @@
+<?php $TRANSLATIONS = array(
+"Password" => "Пароль",
+"Submit" => "Передать",
+"%s shared the folder %s with you" => "%s имеет общий с Вами доступ к папке %s ",
+"%s shared the file %s with you" => "%s имеет общий с Вами доступ к файлу %s ",
+"Download" => "Загрузка",
+"No preview available for" => "Предварительный просмотр недоступен",
+"web services under your control" => "веб-сервисы под Вашим контролем"
+);
diff --git a/apps/files_sharing/l10n/si_LK.php b/apps/files_sharing/l10n/si_LK.php
new file mode 100644
index 00000000000..1c69c608178
--- /dev/null
+++ b/apps/files_sharing/l10n/si_LK.php
@@ -0,0 +1,9 @@
+<?php $TRANSLATIONS = array(
+"Password" => "මුරපදය",
+"Submit" => "යොමු කරන්න",
+"%s shared the folder %s with you" => "%s ඔබව %s ෆෝල්ඩරයට හවුල් කරගත්තේය",
+"%s shared the file %s with you" => "%s ඔබ සමඟ %s ගොනුව බෙදාහදාගත්තේය",
+"Download" => "භාගත කරන්න",
+"No preview available for" => "පූර්වදර්ශනයක් නොමැත",
+"web services under your control" => "ඔබට පාලනය කළ හැකි වෙබ් සේවාවන්"
+);
diff --git a/apps/files_sharing/l10n/sk_SK.php b/apps/files_sharing/l10n/sk_SK.php
index ec9fc31c878..2e781f76f38 100644
--- a/apps/files_sharing/l10n/sk_SK.php
+++ b/apps/files_sharing/l10n/sk_SK.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Heslo",
"Submit" => "Odoslať",
+"%s shared the folder %s with you" => "%s zdieľa s vami priečinok %s",
+"%s shared the file %s with you" => "%s zdieľa s vami súbor %s",
"Download" => "Stiahnuť",
"No preview available for" => "Žiaden náhľad k dispozícii pre",
"web services under your control" => "webové služby pod Vašou kontrolou"
diff --git a/apps/files_sharing/l10n/sl.php b/apps/files_sharing/l10n/sl.php
index 5e7d2d5004b..6bcbb0070b3 100644
--- a/apps/files_sharing/l10n/sl.php
+++ b/apps/files_sharing/l10n/sl.php
@@ -1,7 +1,9 @@
<?php $TRANSLATIONS = array(
"Password" => "Geslo",
"Submit" => "Pošlji",
-"Download" => "Prenesi",
+"%s shared the folder %s with you" => "Oseba %s je določila mapo %s za souporabo",
+"%s shared the file %s with you" => "Oseba %s je določila datoteko %s za souporabo",
+"Download" => "Prejmi",
"No preview available for" => "Predogled ni na voljo za",
"web services under your control" => "spletne storitve pod vašim nadzorom"
);
diff --git a/apps/files_sharing/l10n/sv.php b/apps/files_sharing/l10n/sv.php
index 78b19836497..d1c9afff07c 100644
--- a/apps/files_sharing/l10n/sv.php
+++ b/apps/files_sharing/l10n/sv.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Lösenord",
"Submit" => "Skicka",
+"%s shared the folder %s with you" => "%s delade mappen %s med dig",
+"%s shared the file %s with you" => "%s delade filen %s med dig",
"Download" => "Ladda ner",
"No preview available for" => "Ingen förhandsgranskning tillgänglig för",
"web services under your control" => "webbtjänster under din kontroll"
diff --git a/apps/files_sharing/l10n/th_TH.php b/apps/files_sharing/l10n/th_TH.php
index 8a3f1207db4..9d53d65f8ab 100644
--- a/apps/files_sharing/l10n/th_TH.php
+++ b/apps/files_sharing/l10n/th_TH.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "รหัสผ่าน",
"Submit" => "ส่ง",
+"%s shared the folder %s with you" => "%s ได้แชร์โฟลเดอร์ %s ให้กับคุณ",
+"%s shared the file %s with you" => "%s ได้แชร์ไฟล์ %s ให้กับคุณ",
"Download" => "ดาวน์โหลด",
"No preview available for" => "ไม่สามารถดูตัวอย่างได้สำหรับ",
"web services under your control" => "เว็บเซอร์วิสที่คุณควบคุมการใช้งานได้"
diff --git a/apps/files_sharing/l10n/vi.php b/apps/files_sharing/l10n/vi.php
index d4faee06bf2..6a36f11899e 100644
--- a/apps/files_sharing/l10n/vi.php
+++ b/apps/files_sharing/l10n/vi.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
"Password" => "Mật khẩu",
"Submit" => "Xác nhận",
+"%s shared the folder %s with you" => "%s đã chia sẽ thư mục %s với bạn",
+"%s shared the file %s with you" => "%s đã chia sẽ tập tin %s với bạn",
"Download" => "Tải về",
"No preview available for" => "Không có xem trước cho",
"web services under your control" => "dịch vụ web dưới sự kiểm soát của bạn"
diff --git a/apps/files_sharing/l10n/zh_CN.GB2312.php b/apps/files_sharing/l10n/zh_CN.GB2312.php
new file mode 100644
index 00000000000..117ec8f4065
--- /dev/null
+++ b/apps/files_sharing/l10n/zh_CN.GB2312.php
@@ -0,0 +1,9 @@
+<?php $TRANSLATIONS = array(
+"Password" => "密码",
+"Submit" => "提交",
+"%s shared the folder %s with you" => "%s 与您分享了文件夹 %s",
+"%s shared the file %s with you" => "%s 与您分享了文件 %s",
+"Download" => "下载",
+"No preview available for" => "没有预览可用于",
+"web services under your control" => "您控制的网络服务"
+);
diff --git a/apps/files_sharing/l10n/zh_CN.php b/apps/files_sharing/l10n/zh_CN.php
new file mode 100644
index 00000000000..64e7af3e0cd
--- /dev/null
+++ b/apps/files_sharing/l10n/zh_CN.php
@@ -0,0 +1,9 @@
+<?php $TRANSLATIONS = array(
+"Password" => "密码",
+"Submit" => "提交",
+"%s shared the folder %s with you" => "%s与您共享了%s文件夹",
+"%s shared the file %s with you" => "%s与您共享了%s文件",
+"Download" => "下载",
+"No preview available for" => "没有预览",
+"web services under your control" => "您控制的web服务"
+);
diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php
index 2149da1d731..9a880505926 100644
--- a/apps/files_sharing/lib/share/file.php
+++ b/apps/files_sharing/lib/share/file.php
@@ -47,13 +47,13 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
}
public function generateTarget($filePath, $shareWith, $exclude = null) {
- $target = $filePath;
+ $target = '/'.basename($filePath);
if (isset($exclude)) {
if ($pos = strrpos($target, '.')) {
$name = substr($target, 0, $pos);
$ext = substr($target, $pos);
} else {
- $name = $filePath;
+ $name = $target;
$ext = '';
}
$i = 2;
@@ -72,8 +72,16 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
// Only 1 item should come through for this format call
return array('path' => $items[key($items)]['path'], 'permissions' => $items[key($items)]['permissions']);
} else if ($format == self::FORMAT_FILE_APP) {
+ if (isset($parameters['mimetype_filter']) && $parameters['mimetype_filter']) {
+ $mimetype_filter = $parameters['mimetype_filter'];
+ }
$files = array();
foreach ($items as $item) {
+ if (isset($mimetype_filter)
+ && strpos($item['mimetype'], $mimetype_filter) !== 0
+ && $item['mimetype'] != 'httpd/unix-directory') {
+ continue;
+ }
$file = array();
$file['id'] = $item['file_source'];
$file['path'] = $item['file_target'];
@@ -116,4 +124,4 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
return array();
}
-} \ No newline at end of file
+}
diff --git a/apps/files_sharing/lib/share/folder.php b/apps/files_sharing/lib/share/folder.php
index e29e9b7e002..bddda99f8bb 100644
--- a/apps/files_sharing/lib/share/folder.php
+++ b/apps/files_sharing/lib/share/folder.php
@@ -59,7 +59,7 @@ class OC_Share_Backend_Folder extends OC_Share_Backend_File implements OCP\Share
$parents = array();
while ($file = $result->fetchRow()) {
$children[] = array('source' => $file['id'], 'file_path' => $file['name']);
- // If a child folder is found look inside it
+ // If a child folder is found look inside it
if ($file['mimetype'] == 'httpd/unix-directory') {
$parents[] = $file['id'];
}
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 6dba76955a0..7271dcc930b 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -108,6 +108,14 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
return $internalPath;
}
+ public function getOwner($target) {
+ $shared_item = OCP\Share::getItemSharedWith('folder', $target, OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
+ if ($shared_item) {
+ return $shared_item[0]["uid_owner"];
+ }
+ return null;
+ }
+
public function mkdir($path) {
if ($path == '' || $path == '/' || !$this->isCreatable(dirname($path))) {
return false;
diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php
index 010f6b9de18..105e94f1140 100644
--- a/apps/files_sharing/public.php
+++ b/apps/files_sharing/public.php
@@ -1,74 +1,223 @@
-<?php
-// Load other apps for file previews
-OC_App::loadApps();
-if (isset($_GET['file'])) {
- $pos = strpos($_GET['file'], '/', 1);
- $uidOwner = substr($_GET['file'], 1, $pos - 1);
- if (OCP\User::userExists($uidOwner)) {
- OC_Util::setupFS($uidOwner);
- $fileSource = OC_Filecache::getId($_GET['file'], '');
- if ($fileSource != -1 && ($linkItem = OCP\Share::getItemSharedWithByLink('file', $fileSource, $uidOwner))) {
- if (isset($linkItem['share_with'])) {
- // Check password
- if (isset($_POST['password'])) {
- $password = $_POST['password'];
- $storedHash = $linkItem['share_with'];
- $forcePortable = (CRYPT_BLOWFISH != 1);
- $hasher = new PasswordHash(8, $forcePortable);
- if (!($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash))) {
- $tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest');
- $tmpl->assign('URL', OCP\Util::linkToPublic('files').'&file='.$_GET['file']);
- $tmpl->assign('error', true);
- $tmpl->printPage();
- exit();
- } else {
- // Save item id in session for future requests
- $_SESSION['public_link_authenticated'] = $linkItem['id'];
- }
- // Check if item id is set in session
- } else if (!isset($_SESSION['public_link_authenticated']) || $_SESSION['public_link_authenticated'] !== $linkItem['id']) {
- // Prompt for password
- $tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest');
- $tmpl->assign('URL', OCP\Util::linkToPublic('files').'&file='.$_GET['file']);
- $tmpl->printPage();
- exit();
- }
- }
- $path = $linkItem['path'];
- // Download the file
- if (isset($_GET['download'])) {
- $mimetype = OC_Filesystem::getMimeType($path);
- header('Content-Transfer-Encoding: binary');
- header('Content-Disposition: attachment; filename="'.basename($path).'"');
- header('Content-Type: '.$mimetype);
- header('Content-Length: '.OC_Filesystem::filesize($path));
- OCP\Response::disableCaching();
- @ob_clean();
- OC_Filesystem::readfile($path);
- } else {
- OCP\Util::addStyle('files_sharing', 'public');
- OCP\Util::addScript('files_sharing', 'public');
- OCP\Util::addScript('files', 'fileactions');
- $tmpl = new OCP\Template('files_sharing', 'public', 'base');
- $tmpl->assign('details', $uidOwner.' shared the file '.basename($path).' with you');
- $tmpl->assign('owner', $uidOwner);
- $tmpl->assign('name', basename($path));
- // Show file list
- if (OC_Filesystem::is_dir($path)) {
- // TODO
- } else {
- // Show file preview if viewer is available
- $tmpl->assign('dir', dirname($path));
- $tmpl->assign('filename', basename($path));
- $tmpl->assign('mimetype', OC_Filesystem::getMimeType($path));
- $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&file='.$_GET['file'].'&download');
- }
- $tmpl->printPage();
- }
- exit();
- }
- }
-}
-header('HTTP/1.0 404 Not Found');
-$tmpl = new OCP\Template('', '404', 'guest');
-$tmpl->printPage();
+<?php
+// Load other apps for file previews
+OC_App::loadApps();
+
+// Compatibility with shared-by-link items from ownCloud 4.0
+// requires old Sharing table !
+// support will be removed in OC 5.0,a
+if (isset($_GET['token'])) {
+ unset($_GET['file']);
+ $qry = \OC_DB::prepare('SELECT `source` FROM `*PREFIX*sharing` WHERE `target` = ? LIMIT 1');
+ $filepath = $qry->execute(array($_GET['token']))->fetchOne();
+ if(isset($filepath)) {
+ $info = OC_FileCache_Cached::get($filepath, '');
+ if(strtolower($info['mimetype']) == 'httpd/unix-directory') {
+ $_GET['dir'] = $filepath;
+ } else {
+ $_GET['file'] = $filepath;
+ }
+ \OCP\Util::writeLog('files_sharing', 'You have files that are shared by link originating from ownCloud 4.0. Redistribute the new links, because backwards compatibility will be removed in ownCloud 5.', \OCP\Util::WARN);
+ }
+}
+// Enf of backward compatibility
+
+function getID($path) {
+ // use the share table from the db to find the item source if the file was reshared because shared files
+ //are not stored in the file cache.
+ if (substr(OC_Filesystem::getMountPoint($path), -7, 6) == "Shared") {
+ $path_parts = explode('/', $path, 5);
+ $user = $path_parts[1];
+ $intPath = '/'.$path_parts[4];
+ $query = \OC_DB::prepare('SELECT item_source FROM *PREFIX*share WHERE uid_owner = ? AND file_target = ? ');
+ $result = $query->execute(array($user, $intPath));
+ $row = $result->fetchRow();
+ $fileSource = $row['item_source'];
+ } else {
+ $fileSource = OC_Filecache::getId($path, '');
+ }
+
+ return $fileSource;
+}
+
+if (isset($_GET['file']) || isset($_GET['dir'])) {
+ if (isset($_GET['dir'])) {
+ $type = 'folder';
+ $path = $_GET['dir'];
+ if(strlen($path)>1 and substr($path, -1, 1)==='/') {
+ $path=substr($path, 0, -1);
+ }
+ $baseDir = $path;
+ $dir = $baseDir;
+ } else {
+ $type = 'file';
+ $path = $_GET['file'];
+ if(strlen($path)>1 and substr($path, -1, 1)==='/') {
+ $path=substr($path, 0, -1);
+ }
+ }
+ $uidOwner = substr($path, 1, strpos($path, '/', 1) - 1);
+ if (OCP\User::userExists($uidOwner)) {
+ OC_Util::setupFS($uidOwner);
+ $fileSource = getId($path);
+ if ($fileSource != -1 && ($linkItem = OCP\Share::getItemSharedWithByLink($type, $fileSource, $uidOwner))) {
+ // TODO Fix in the getItems
+ if (!isset($linkItem['item_type']) || $linkItem['item_type'] != $type) {
+ header('HTTP/1.0 404 Not Found');
+ $tmpl = new OCP\Template('', '404', 'guest');
+ $tmpl->printPage();
+ exit();
+ }
+ if (isset($linkItem['share_with'])) {
+ // Check password
+ if (isset($_GET['file'])) {
+ $url = OCP\Util::linkToPublic('files').'&file='.$_GET['file'];
+ } else {
+ $url = OCP\Util::linkToPublic('files').'&dir='.$_GET['dir'];
+ }
+ if (isset($_POST['password'])) {
+ $password = $_POST['password'];
+ $storedHash = $linkItem['share_with'];
+ $forcePortable = (CRYPT_BLOWFISH != 1);
+ $hasher = new PasswordHash(8, $forcePortable);
+ if (!($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash))) {
+ $tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest');
+ $tmpl->assign('URL', $url);
+ $tmpl->assign('error', true);
+ $tmpl->printPage();
+ exit();
+ } else {
+ // Save item id in session for future requests
+ $_SESSION['public_link_authenticated'] = $linkItem['id'];
+ }
+ // Check if item id is set in session
+ } else if (!isset($_SESSION['public_link_authenticated']) || $_SESSION['public_link_authenticated'] !== $linkItem['id']) {
+ // Prompt for password
+ $tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest');
+ $tmpl->assign('URL', $url);
+ $tmpl->printPage();
+ exit();
+ }
+ }
+ $path = $linkItem['path'];
+ if (isset($_GET['path'])) {
+ $path .= $_GET['path'];
+ $dir .= $_GET['path'];
+ if (!OC_Filesystem::file_exists($path)) {
+ header('HTTP/1.0 404 Not Found');
+ $tmpl = new OCP\Template('', '404', 'guest');
+ $tmpl->printPage();
+ exit();
+ }
+ }
+ // Download the file
+ if (isset($_GET['download'])) {
+ if (isset($_GET['dir'])) {
+ if ( isset($_GET['files']) ) { // download selected files
+ OC_Files::get($path, $_GET['files'], $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
+ } else if (isset($_GET['path']) && $_GET['path'] != '' ) { // download a file from a shared directory
+ OC_Files::get('', $path, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
+ } else { // download the whole shared directory
+ OC_Files::get($path, '', $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
+ }
+ } else { // download a single shared file
+ OC_Files::get("", $path, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
+ }
+
+ } else {
+ OCP\Util::addStyle('files_sharing', 'public');
+ OCP\Util::addScript('files_sharing', 'public');
+ OCP\Util::addScript('files', 'fileactions');
+ $tmpl = new OCP\Template('files_sharing', 'public', 'base');
+ $tmpl->assign('owner', $uidOwner);
+ // Show file list
+ if (OC_Filesystem::is_dir($path)) {
+ OCP\Util::addStyle('files', 'files');
+ OCP\Util::addScript('files', 'files');
+ OCP\Util::addScript('files', 'filelist');
+ $files = array();
+ $rootLength = strlen($baseDir) + 1;
+ foreach (OC_Files::getDirectoryContent($path) as $i) {
+ $i['date'] = OCP\Util::formatDate($i['mtime']);
+ if ($i['type'] == 'file') {
+ $fileinfo = pathinfo($i['name']);
+ $i['basename'] = $fileinfo['filename'];
+ $i['extension'] = isset($fileinfo['extension']) ? ('.'.$fileinfo['extension']) : '';
+ }
+ $i['directory'] = '/'.substr('/'.$uidOwner.'/files'.$i['directory'], $rootLength);
+ if ($i['directory'] == '/') {
+ $i['directory'] = '';
+ }
+ $i['permissions'] = OCP\Share::PERMISSION_READ;
+ $files[] = $i;
+ }
+ // Make breadcrumb
+ $breadcrumb = array();
+ $pathtohere = '';
+ $count = 1;
+ foreach (explode('/', $dir) as $i) {
+ if ($i != '') {
+ if ($i != $baseDir) {
+ $pathtohere .= '/'.$i;
+ }
+ if ( strlen($pathtohere) < strlen($_GET['dir'])) {
+ continue;
+ }
+ $breadcrumb[] = array('dir' => str_replace($_GET['dir'], "", $pathtohere, $count), 'name' => $i);
+ }
+ }
+ $list = new OCP\Template('files', 'part.list', '');
+ $list->assign('files', $files, false);
+ $list->assign('publicListView', true);
+ $list->assign('baseURL', OCP\Util::linkToPublic('files').'&dir='.urlencode($_GET['dir']).'&path=', false);
+ $list->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path=', false);
+ $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '' );
+ $breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
+ $breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files').'&dir='.urlencode($_GET['dir']).'&path=', false);
+ $folder = new OCP\Template('files', 'index', '');
+ $folder->assign('fileList', $list->fetchPage(), false);
+ $folder->assign('breadcrumb', $breadcrumbNav->fetchPage(), false);
+ $folder->assign('dir', basename($dir));
+ $folder->assign('isCreatable', false);
+ $folder->assign('permissions', 0);
+ $folder->assign('files', $files);
+ $folder->assign('uploadMaxFilesize', 0);
+ $folder->assign('uploadMaxHumanFilesize', 0);
+ $folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
+ $tmpl->assign('folder', $folder->fetchPage(), false);
+ $tmpl->assign('uidOwner', $uidOwner);
+ $tmpl->assign('dir', basename($dir));
+ $tmpl->assign('filename', basename($path));
+ $tmpl->assign('mimetype', OC_Filesystem::getMimeType($path));
+ $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
+ if (isset($_GET['path'])) {
+ $getPath = $_GET['path'];
+ } else {
+ $getPath = '';
+ }
+ $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path='.urlencode($getPath), false);
+ } else {
+ // Show file preview if viewer is available
+ $tmpl->assign('uidOwner', $uidOwner);
+ $tmpl->assign('dir', dirname($path));
+ $tmpl->assign('filename', basename($path));
+ $tmpl->assign('mimetype', OC_Filesystem::getMimeType($path));
+ if ($type == 'file') {
+ $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&file='.urlencode($_GET['file']).'&download', false);
+ } else {
+ if (isset($_GET['path'])) {
+ $getPath = $_GET['path'];
+ } else {
+ $getPath = '';
+ }
+ $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path='.urlencode($getPath), false);
+ }
+ }
+ $tmpl->printPage();
+ }
+ exit();
+ }
+ }
+}
+header('HTTP/1.0 404 Not Found');
+$tmpl = new OCP\Template('', '404', 'guest');
+$tmpl->printPage();
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index ca48a35575e..35cca7c42dc 100755..100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -5,21 +5,31 @@
<header><div id="header">
<a href="<?php echo link_to('', 'index.php'); ?>" title="" id="owncloud"><img class="svg" src="<?php echo image_path('', 'logo-wide.svg'); ?>" alt="ownCloud" /></a>
<div class="header-right">
- <span id="details"><?php echo $_['details']; ?></span>
- <a href="<?php echo $_['downloadURL']; ?>" id="download"><img class="svg" alt="Download" src="<?php echo OCP\image_path("core", "actions/download.svg"); ?>" /><?php echo $l->t('Download')?></a>
+ <?php if (isset($_['folder'])): ?>
+ <span id="details"><?php echo $l->t('%s shared the folder %s with you', array($_['uidOwner'], $_['filename'])) ?></span>
+ <?php else: ?>
+ <span id="details"><?php echo $l->t('%s shared the file %s with you', array($_['uidOwner'], $_['filename'])) ?></span>
+ <?php endif; ?>
+ <?php if (!isset($_['folder']) || $_['allowZipDownload']): ?>
+ <a href="<?php echo $_['downloadURL']; ?>" class="button" id="download"><img class="svg" alt="Download" src="<?php echo OCP\image_path("core", "actions/download.svg"); ?>" /><?php echo $l->t('Download')?></a>
+ <?php endif; ?>
</div>
</div></header>
<div id="preview">
- <?php if (substr($_['mimetype'], 0 , strpos($_['mimetype'], '/')) == 'image'): ?>
- <img src="<?php echo $_['downloadURL']; ?>" />
+ <?php if (isset($_['folder'])): ?>
+ <?php echo $_['folder']; ?>
+ <?php else: ?>
+ <?php if (substr($_['mimetype'], 0, strpos($_['mimetype'], '/')) == 'image'): ?>
+ <div id="imgframe">
+ <img src="<?php echo $_['downloadURL']; ?>" />
+ </div>
+ <?php endif; ?>
+ <ul id="noPreview">
+ <li class="error">
+ <?php echo $l->t('No preview available for').' '.$_['filename']; ?><br />
+ <a href="<?php echo $_['downloadURL']; ?>" id="download"><img class="svg" alt="Download" src="<?php echo OCP\image_path("core", "actions/download.svg"); ?>" /><?php echo $l->t('Download')?></a>
+ </li>
+ </ul>
<?php endif; ?>
- <ul id="noPreview">
- <li class="error">
- <?php echo $l->t('No preview available for').' '.$_['filename']; ?><br />
- <a href="<?php echo $_['downloadURL']; ?>" id="download"><img class="svg" alt="Download" src="<?php echo OCP\image_path("core", "actions/download.svg"); ?>" /><?php echo $l->t('Download')?></a>
- </li>
- </ul>
- <div id="content"></div>
- <table></table>
</div>
-<footer><p class="info"><a href="http://owncloud.org/">ownCloud</a> &ndash; <?php echo $l->t('web services under your control'); ?></p></footer> \ No newline at end of file
+<footer><p class="info"><a href="http://owncloud.org/">ownCloud</a> &ndash; <?php echo $l->t('web services under your control'); ?></p></footer>