|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* ownCloud - Documents App |
|
5
|
|
|
* |
|
6
|
|
|
* @author Victor Dubiniuk |
|
7
|
|
|
* @copyright 2013 Victor Dubiniuk [email protected] |
|
8
|
|
|
* |
|
9
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
10
|
|
|
* later. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
namespace OCA\Documents; |
|
15
|
|
|
|
|
16
|
|
|
\OCP\JSON::checkAppEnabled('documents'); |
|
17
|
|
|
|
|
18
|
|
|
if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { |
|
19
|
|
|
header('HTTP/1.0 404 Not Found'); |
|
20
|
|
|
$tmpl = new OCP\Template('', '404', 'guest'); |
|
21
|
|
|
$tmpl->printPage(); |
|
22
|
|
|
exit(); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
if (isset($_GET['t'])) { |
|
26
|
|
|
$token = $_GET['t']; |
|
27
|
|
|
$tmpl = new \OCP\Template('documents', 'public', 'guest'); |
|
28
|
|
|
try { |
|
29
|
|
|
$file = File::getByShareToken($token); |
|
30
|
|
|
if ($file->isPasswordProtected() && !$file->checkPassword(@$_POST['password'])){ |
|
31
|
|
|
if (isset($_POST['password'])){ |
|
32
|
|
|
$tmpl->assign('wrongpw', true); |
|
33
|
|
|
} |
|
34
|
|
|
$tmpl->assign('hasPassword', true); |
|
35
|
|
|
} else { |
|
36
|
|
|
\OCP\Util::addStyle( 'documents', '3rdparty/webodf/dojo-app'); |
|
37
|
|
|
\OCP\Util::addScript('documents', 'documents'); |
|
38
|
|
|
if ($file->getFileId()){ |
|
39
|
|
|
$session = new Db\Session(); |
|
40
|
|
|
$session->loadBy('file_id', $file->getFileId()); |
|
41
|
|
|
|
|
42
|
|
|
if ($session->getEsId()){ |
|
43
|
|
|
$member = new Db\Member(); |
|
44
|
|
|
$members = $member->getCollectionBy('es_id', $session->getEsId()); |
|
45
|
|
|
} else { |
|
46
|
|
|
$members = 0; |
|
47
|
|
|
} |
|
48
|
|
|
$tmpl->assign('total', count($members)+1); |
|
49
|
|
|
} else { |
|
50
|
|
|
$tmpl->assign('total', 1); |
|
51
|
|
|
} |
|
52
|
|
|
$tmpl->assign('document', $token); |
|
53
|
|
|
} |
|
54
|
|
|
} catch (\Exception $e){ |
|
55
|
|
|
$tmpl->assign('notFound', true); |
|
56
|
|
|
} |
|
57
|
|
|
$tmpl->printPage(); |
|
58
|
|
|
} |
|
59
|
|
|
|