From: Bjoern Schiessle Date: Mon, 23 Sep 2013 09:18:00 +0000 (+0200) Subject: Merge branch 'master' into sharing_mail_notification_master X-Git-Tag: v6.0.0alpha2~101^2~16 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fc76a13c520d1d5345c721e0616d770e1fd344ea;p=nextcloud-server.git Merge branch 'master' into sharing_mail_notification_master Conflicts: lib/public/share.php --- fc76a13c520d1d5345c721e0616d770e1fd344ea diff --cc lib/public/share.php index 759848488ad,91b0ef6dc69..0dfbbef0a73 --- a/lib/public/share.php +++ b/lib/public/share.php @@@ -257,56 -257,6 +257,55 @@@ class Share $parameters, 1, $includeCollections); } + /** + * @brief Get the item of item type shared with a given user by source + * @param string Item type + * @param string Item source + * @param string User user to whom the item was shared + * @return Return list of items with file_target, permissions and expiration + */ + public static function getItemSharedWithUser($itemType, $itemSource, $user) { + + $shares = array(); + + // first check if there is a db entry for the specific user + $query = \OC_DB::prepare( + 'SELECT `file_target`, `permissions`, `expiration` + FROM + `*PREFIX*share` + WHERE + `item_source` = ? AND `item_type` = ? AND `share_with` = ?' + ); + + $result = $query->execute(array($itemSource, $itemType, $user)); + + while ($row = $result->fetchRow()) { + $shares[] = $row; + } + + //if didn't found a result than let's look for a group share. + if(empty($shares)) { + $groups = \OC_Group::getUserGroups($user); + + $query = \OC_DB::prepare( + 'SELECT `file_target`, `permissions`, `expiration` + FROM + `*PREFIX*share` + WHERE + `item_source` = ? AND `item_type` = ? AND `share_with` in (?)' + ); + + $result = $query->execute(array($itemSource, $itemType, implode(',', $groups))); + + while ($row = $result->fetchRow()) { + $shares[] = $row; + } + } + + return $shares; + + } + - /** * @brief Get the item of item type shared with the current user by source * @param string Item type