Welcome to mirror list, hosted at ThFree Co, Russian Federation.

share.php « ajax « files_sharing « apps - github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fe1c9e07984b5086dc920b6711ba10b6bf9fdd45 (plain)
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
<?php
//$RUNTIME_NOAPPS = true;

 
OC_JSON::checkAppEnabled('files_sharing');
require_once(OC::$APPSROOT . '/apps/files_sharing/lib_share.php');

$userDirectory = "/".OCP\USER::getUser()."/files";
$sources = explode(";", $_POST['sources']);
$uid_shared_with = $_POST['uid_shared_with'];
$permissions = $_POST['permissions'];
foreach ($sources as $source) {
	// Make sure file exists and can be shared
	if ($source && OC_FILESYSTEM::file_exists($source) && OC_FILESYSTEM::is_readable($source)) {
		$source = $userDirectory.$source;
	// If the file doesn't exist, it may be shared with the current user
	} else if (!$source = OC_Share::getSource($userDirectory.$source)) {
		OCP\Util::writeLog('files_sharing',"Shared file doesn't exists :".$source,OCP\Util::ERROR);
		echo "false";
	}
	try {
		$shared = new OC_Share($source, $uid_shared_with, $permissions);
		if ($uid_shared_with == OC_Share::PUBLICLINK) {
			echo $shared->getToken();
		}
	} catch (Exception $exception) {
		OC\Util::writeLog('files_sharing',"Unexpected Error : ".$exception->getMessage(),OCP\Util::ERROR);
		echo "false";
	}
}

?>