2011-08-02 20:19:49 +04:00
|
|
|
<?php
|
2011-10-04 17:58:54 +04:00
|
|
|
//$RUNTIME_NOAPPS = true;
|
2011-08-02 20:19:49 +04:00
|
|
|
|
2012-04-17 21:31:29 +04:00
|
|
|
|
2011-10-01 01:05:10 +04:00
|
|
|
OC_JSON::checkAppEnabled('files_sharing');
|
2012-04-28 01:12:11 +04:00
|
|
|
require_once(OC::$APPSROOT . '/apps/files_sharing/lib_share.php');
|
2011-08-02 20:19:49 +04:00
|
|
|
|
2012-05-01 20:50:31 +04:00
|
|
|
$userDirectory = "/".OCP\USER::getUser()."/files";
|
2011-08-07 23:20:57 +04:00
|
|
|
$source = $userDirectory.$_GET['source'];
|
2011-08-19 20:47:00 +04:00
|
|
|
$path = $source;
|
2012-02-19 04:30:35 +04:00
|
|
|
$users = array();
|
2011-08-25 02:41:36 +04:00
|
|
|
if ($users = OC_Share::getMySharedItem($source)) {
|
|
|
|
for ($i = 0; $i < count($users); $i++) {
|
|
|
|
if ($users[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) {
|
|
|
|
$users[$i]['token'] = OC_Share::getTokenFromSource($source);
|
|
|
|
}
|
2011-08-19 20:47:00 +04:00
|
|
|
}
|
|
|
|
}
|
2011-08-07 23:20:57 +04:00
|
|
|
$source = dirname($source);
|
|
|
|
while ($source != "" && $source != "/" && $source != "." && $source != $userDirectory) {
|
2011-08-25 02:41:36 +04:00
|
|
|
if ($values = OC_Share::getMySharedItem($source)) {
|
|
|
|
$values = array_values($values);
|
2011-08-08 23:49:16 +04:00
|
|
|
$parentUsers = array();
|
|
|
|
for ($i = 0; $i < count($values); $i++) {
|
2011-08-19 20:47:00 +04:00
|
|
|
if ($values[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) {
|
|
|
|
$values[$i]['token'] = OC_Share::getTokenFromSource($source)."&path=".substr($path, strlen($source));
|
|
|
|
}
|
2011-08-08 23:49:16 +04:00
|
|
|
$parentUsers[basename($source)."-".$i] = $values[$i];
|
|
|
|
}
|
|
|
|
$users = array_merge($users, $parentUsers);
|
2011-08-07 23:20:57 +04:00
|
|
|
}
|
|
|
|
$source = dirname($source);
|
|
|
|
}
|
2011-08-19 20:47:00 +04:00
|
|
|
if (!empty($users)) {
|
2011-09-24 00:22:59 +04:00
|
|
|
OC_JSON::encodedPrint($users);
|
2011-08-19 20:47:00 +04:00
|
|
|
}
|