Initial work on public links

pull/1/head
Victor Dubiniuk 11 years ago
parent e1b06e715b
commit 20da92fc4e

@ -35,11 +35,7 @@ class SessionController extends Controller{
$session = Session::add($genesisPath, $hash, $fileId);
}
$session['permissions'] = \OCP\PERMISSION_READ;
if (\OC\Files\Filesystem::isSharable($path)) {
$session['permissions'] |= \OCP\PERMISSION_SHARE;
}
$session['permissions'] = View::getFilePermissions($path);
$session['member_id'] = (string) Member::add($session['es_id'], $uid, Helper::getRandomColor());
\OCP\JSON::success($session);
exit();

@ -7,4 +7,7 @@
<author>Frank Karlitschek</author>
<require>5.0.19</require>
<shipped>true</shipped>
<public>
<documents>public.php</documents>
</public>
</info>

@ -1 +1 @@
0.6
0.6.1

@ -30,7 +30,7 @@ namespace OCA\Documents;
\OCP\Util::addStyle( 'documents', 'style' );
\OCP\Util::addStyle( 'documents', '3rdparty/webodf/dojo-app');
\OCP\Util::addStyle( 'documents', '3rdparty/webodf/editor' );
\OCP\Util::addStyle( 'documents', '3rdparty/webodf/editor');
\OCP\Util::addScript('documents', 'documents');
\OCP\Util::addScript('files', 'file-upload');

@ -90,7 +90,9 @@ var documentsMain = {
documentsMain.UI.init();
// Does anything indicate that we need to autostart a session?
var fileId = parent.location.hash.replace(/\W*/g, '');
var fileId = parent.location.hash.replace(/\W*/g, '')
|| $("[name='document']").val()
;
if (!fileId){
documentsMain.show();
} else {
@ -231,6 +233,10 @@ var documentsMain = {
},
show: function(){
if (!OC.currentUser){
return;
}
jQuery.when(documentsMain.loadDocuments())
.then(function(){
documentsMain.renderDocuments();

@ -58,7 +58,7 @@ class Storage {
throw new \Exception($fileId . ' can not be resolved');
}
$internalPath = preg_replace('/^\/?files/', '', $path);
$internalPath = preg_replace('/^\/?files\//', '', $path);
if (!\OC\Files\Filesystem::file_exists($internalPath)){
$sharedInfo = \OCP\Share::getItemSharedWithBySource(
'file',

@ -30,6 +30,18 @@ class View extends \OC\Files\View{
return new \OC\Files\View('/' . $uid . self::DOCUMENTS_DIRNAME);
}
public static function getFilePermissions($path){
$view = new \OC\Files\View('/' . \OCP\User::getUser());
$permissions = 0;
if ($view->isReadable($path)) {
$permissions |= \OCP\PERMISSION_READ;
}
if ($view->isSharable($path)) {
$permissions |= \OCP\PERMISSION_SHARE;
}
return $permissions;
}
public static function storeDocument($uid, $filePath){
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;

@ -0,0 +1,46 @@
<?php
/**
* ownCloud - Documents App
*
* @author Victor Dubiniuk
* @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
*
* This file is licensed under the Affero General Public License version 3 or
* later.
*/
namespace OCA\Documents;
\OCP\JSON::checkAppEnabled('documents');
\OCP\Util::addStyle( 'documents', 'style' );
if (isset($_GET['t'])) {
$token = $_GET['t'];
$linkItem = \OCP\Share::getShareByToken($token);
if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
// seems to be a valid share
$type = $linkItem['item_type'];
$fileSource = $linkItem['file_source'];
$shareOwner = $linkItem['uid_owner'];
$path = null;
$rootLinkItem = \OCP\Share::resolveReShare($linkItem);
$fileOwner = $rootLinkItem['uid_owner'];
}
}
$tmpl = new \OCP\Template('documents', 'public', 'guest');
if (isset($fileOwner)) {
\OCP\Util::addStyle( 'documents', '3rdparty/webodf/dojo-app');
\OCP\Util::addStyle( 'documents', '3rdparty/webodf/editor' );
\OCP\Util::addScript('documents', 'documents');
$tmpl->assign('document', $rootLinkItem['file_source']);
} else {
// TODO: show nice 404 page
}
$tmpl->printPage();

@ -0,0 +1,5 @@
<div id="documents-content">
<?php if (isset($_['document'])): ?>
<input type="hidden" name="document" value ="<?php p($_['document']) ?>" />
<?php endif; ?>
</div>
Loading…
Cancel
Save