2011-07-20 17:34:16 +00:00
|
|
|
<?php
|
2011-11-29 22:11:42 +00:00
|
|
|
//$RUNTIME_NOAPPS = true;
|
2011-07-20 17:34:16 +00:00
|
|
|
|
2012-04-17 17:31:29 +00:00
|
|
|
|
2011-09-30 21:05:10 +00:00
|
|
|
OC_JSON::checkAppEnabled('files_sharing');
|
2011-07-20 17:34:16 +00:00
|
|
|
require_once('../lib_share.php');
|
|
|
|
|
2011-08-24 16:32:02 +00:00
|
|
|
$userDirectory = "/".OC_User::getUser()."/files";
|
2011-08-01 00:47:53 +00:00
|
|
|
$sources = explode(";", $_POST['sources']);
|
|
|
|
$uid_shared_with = $_POST['uid_shared_with'];
|
|
|
|
$permissions = $_POST['permissions'];
|
2011-07-28 19:31:52 +00:00
|
|
|
foreach ($sources as $source) {
|
2011-08-24 16:32:02 +00:00
|
|
|
// Make sure file exists and can be shared
|
2011-08-12 21:22:32 +00:00
|
|
|
if ($source && OC_FILESYSTEM::file_exists($source) && OC_FILESYSTEM::is_readable($source)) {
|
2011-08-24 16:32:02 +00:00
|
|
|
$source = $userDirectory.$source;
|
|
|
|
// If the file doesn't exist, it may be shared with the current user
|
2011-08-24 22:41:36 +00:00
|
|
|
} else if (!$source = OC_Share::getSource($userDirectory.$source)) {
|
2011-10-18 19:29:48 +00:00
|
|
|
OC_Log::write('files_sharing',"Shared file doesn't exists :".$source,OC_Log::ERROR);
|
2011-08-24 22:41:36 +00:00
|
|
|
echo "false";
|
2011-08-12 21:22:32 +00:00
|
|
|
}
|
2011-08-24 16:32:02 +00:00
|
|
|
try {
|
|
|
|
$shared = new OC_Share($source, $uid_shared_with, $permissions);
|
|
|
|
if ($uid_shared_with == OC_Share::PUBLICLINK) {
|
|
|
|
echo $shared->getToken();
|
|
|
|
}
|
|
|
|
} catch (Exception $exception) {
|
2011-10-18 19:29:48 +00:00
|
|
|
OC_Log::write('files_sharing',"Unexpected Error : ".$exception->getMessage(),OC_Log::ERROR);
|
2011-08-24 16:32:02 +00:00
|
|
|
echo "false";
|
|
|
|
}
|
2011-07-28 19:31:52 +00:00
|
|
|
}
|
2011-07-20 17:34:16 +00:00
|
|
|
|
2011-09-30 21:05:10 +00:00
|
|
|
?>
|