From 9be59b55bf7a5519ae43876608a4a4d0254e2b0f Mon Sep 17 00:00:00 2001 From: nathangray Date: Mon, 15 Oct 2018 14:57:24 -0600 Subject: [PATCH] - Accept an extra array from ajax_create - Filter extra array by db columns --- api/src/Sharing.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/api/src/Sharing.php b/api/src/Sharing.php index 2e63bfce5a..4de8785aad 100644 --- a/api/src/Sharing.php +++ b/api/src/Sharing.php @@ -520,6 +520,9 @@ class Sharing if (empty($name)) $name = $path; + $table_def = static::$db->get_table_definitions(false,static::TABLE); + $extra = array_intersect_key($extra, $table_def['fd']); + // check if file has been shared before, with identical attributes if (($share = static::$db->select(static::TABLE, '*', $extra+array( 'share_path' => $path, @@ -594,18 +597,19 @@ class Sharing * @param boolean $writable * @param boolean $files */ - public static function ajax_create($action, $path, $writable = false, $files = false) + public static function ajax_create($action, $path, $writable = false, $files = false, $extra = array()) { $class = self::get_share_class(array('share_path' => $path)); + $extra = $extra + array( + 'share_writable' => $writable, + 'include_files' => $files + ); $share = $class::create( $path, - $action == $writable ? Sharing::WRITABLE : Sharing::READONLY, + $writable ? Sharing::WRITABLE : Sharing::READONLY, basename($path), array(), - array( - 'share_writable' => $writable, - 'include_files' => $files - ) + $extra ); // Store share in session so Merge can find this one and not create a read-only one