From 698ecbf308d1eae950138bff9edbb0d542c391d0 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Mon, 24 Nov 2014 15:31:52 +0100 Subject: OCS API for server-to-server sharing --- apps/files_sharing/lib/helper.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'apps/files_sharing/lib/helper.php') diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php index f7204a8db8f..c83debe952f 100644 --- a/apps/files_sharing/lib/helper.php +++ b/apps/files_sharing/lib/helper.php @@ -20,6 +20,30 @@ class Helper { \OCP\Util::connectHook('OCP\Share', 'post_unshareFromSelf', '\OC\Files\Cache\Shared_Updater', 'postUnshareFromSelfHook'); } + /** + * add server-to-server share to database + * + * @param string $remote + * @param string $token + * @param string $name + * @param string $mountPoint + * @param string $owner + * @param string $user + * @param string $password + * @param int $remoteId + * @param bool $accepted + */ + public static function addServer2ServerShare($remote, $token, $name, $mountPoint, $owner, $user, $password='', $remoteId=-1, $accepted = false) { + $accepted = $accepted ? 1 : 0; + $query = \OCP\DB::prepare(' + INSERT INTO `*PREFIX*share_external` + (`remote`, `share_token`, `password`, `name`, `owner`, `user`, `mountpoint`, `mountpoint_hash`, `accepted`, `remote_id`) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + '); + $hash = md5($mountPoint); + $query->execute(array($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId)); + } + /** * Sets up the filesystem and user for public sharing * @param string $token string share token -- cgit v1.2.3