diff options
author | Sam Tuke <samtuke@owncloud.com> | 2013-02-09 18:39:32 +0000 |
---|---|---|
committer | Sam Tuke <samtuke@owncloud.com> | 2013-02-09 18:39:32 +0000 |
commit | b3e59ca1e31f162d7ac720d8729958f438b23a02 (patch) | |
tree | 97a87081392554086ce010d603125cba9f8ea9e3 /lib/public | |
parent | 1aba986d9f219a872c83b5f8b46f641e2699a222 (diff) | |
download | nextcloud-server-b3e59ca1e31f162d7ac720d8729958f438b23a02.tar.gz nextcloud-server-b3e59ca1e31f162d7ac720d8729958f438b23a02.zip |
Work on post_share hook for files_encryption
New method in OCP\Share{}:: getUsersSharingFile()
Development shapshot
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/share.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/public/share.php b/lib/public/share.php index af2a538e252..936f85021c0 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -91,6 +91,60 @@ class Share { } return false; } + + /** + * @brief Find which users can access a shared item + * @param string Item type + * @param int Format (optional) Format type must be defined by the backend + * @param int Number of items to return (optional) Returns all by default + * @return Return depends on format + */ + public static function getUsersSharingFile( $path ) { + + // Fetch all shares of this file path from DB + $query = \OC_DB::prepare( + 'SELECT + share_type + , share_with + , permissions + FROM + `*PREFIX*share` + WHERE + file_target = ?' + ); + + $result = $query->execute( array( $path ) ); + + if ( \OC_DB::isError( $result ) ) { + + \OC_Log::write( 'OCP\Share', \OC_DB::getErrorMessage($result) . ', path=' . $path, \OC_Log::ERROR ); + + } + + $shares = array(); + + while( $row = $result->fetchRow() ) { + + // Set helpful array keys + $shares[] = array( + 'userId' => $row['share_with'] + , 'shareType' => $row['share_type'] + , 'permissions' => $row['permissions'] + ); + + } + + if ( ! empty( $shares ) ) { + + return $shares; + + } else { + + return false; + + } + + } /** * @brief Get the items of item type shared with the current user |