gallery.php
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
* Copyright (c) 2012 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::checkLoggedIn();
OCP\JSON::checkAppEnabled('gallery');
$split = explode('/', $_GET['gallery'], 2);
$owner = $split[0];
$gallery = array_key_exists(1, $split) ? $split[1] : NULL;
$ownerView = new \OC\Files\View('/' . $owner . '/files');
if ($owner !== OCP\User::getUser()) {
\OC\Files\Filesystem::initMountPoints($owner);
list($shareId, , $gallery) = explode('/', $gallery, 3);
if (OCP\Share::getItemSharedWith('file', $shareId)) {
$sharedGallery = $ownerView->getPath($shareId);
if ($gallery) {
$gallery = $sharedGallery . '/' . $gallery;
} else {
$gallery = $sharedGallery;
}
} else {
OCP\JSON::error(array( 'message' => 'no such file'));
}
}
$meta = $ownerView->getFileInfo($gallery);
$data = array();
$data['fileid'] = $meta['fileid'];
$data['permissions'] = $meta['permissions'];
OCP\JSON::setContentTypeHeader();
echo json_encode($data);