From 66d6a6c88381c0f7b57c16f818f8ce0fbc054985 Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 4 Apr 2019 10:28:20 -0600 Subject: [PATCH] Break out merge share creation so it can be overridden --- api/src/Storage/Merge.php | 52 ++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/api/src/Storage/Merge.php b/api/src/Storage/Merge.php index 4908086538..4034d62e47 100644 --- a/api/src/Storage/Merge.php +++ b/api/src/Storage/Merge.php @@ -485,26 +485,7 @@ abstract class Merge } // Get or create the share - // Check if some other process created the share (with custom options) - // and put it in the session cache for us - $path = "$app::$id"; - $session = \EGroupware\Api\Cache::getSession(Api\Sharing::class, $path); - if($session && $session['share_path'] == $path) - { - $share = $session; - } - else - { - // Need to create the share here. - // No way to know here if it should be writable, or who it's going to - $mode = /* ? ? Sharing::WRITABLE :*/ Api\Sharing::READONLY; - $recipients = array(); - $extra = array(); - - //$extra['share_writable'] |= ($mode == Sharing::WRITABLE ? 1 : 0); - - $share = \EGroupware\Stylite\Link\Sharing::create($path, $mode, NULL, $recipients, $extra); - } + $share = $this->create_share($app, $id, $content); if($share) { @@ -514,6 +495,37 @@ abstract class Merge return $replacements; } + /** + * Create a share for an entry + * + * @param string $app + * @param string $id + * @param string $path + * @param type $content + * @return type + */ + protected function create_share($app, $id, &$content) + { + // Check if some other process created the share (with custom options) + // and put it in the session cache for us + $path = "$app::$id"; + $session = \EGroupware\Api\Cache::getSession(Api\Sharing::class, $path); + if($session && $session['share_path'] == $path) + { + return $session; + } + + // Need to create the share here. + // No way to know here if it should be writable, or who it's going to + $mode = /* ? ? Sharing::WRITABLE :*/ Api\Sharing::READONLY; + $recipients = array(); + $extra = array(); + + //$extra['share_writable'] |= ($mode == Sharing::WRITABLE ? 1 : 0); + + return \EGroupware\Stylite\Link\Sharing::create($path, $mode, NULL, $recipients, $extra); + } + /** * Format a datetime *