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