diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-06-05 17:23:42 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-06-05 17:23:42 +0200 |
commit | 1c598085176e4bef12f5fbcd221ef6b832b734bb (patch) | |
tree | edf58b2d3ed7e4fa4e187740ecf01485098a792b /lib/private/share/share.php | |
parent | 4b650a20a42b70412cee9dd835e096e16da6d530 (diff) | |
parent | 6578f00b4bcfbd5bc44bc12e341506f922498d7b (diff) | |
download | nextcloud-server-1c598085176e4bef12f5fbcd221ef6b832b734bb.tar.gz nextcloud-server-1c598085176e4bef12f5fbcd221ef6b832b734bb.zip |
Merge pull request #8865 from owncloud/improve_share_settings
Improve share settings
Diffstat (limited to 'lib/private/share/share.php')
-rw-r--r-- | lib/private/share/share.php | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 189be2363ea..2126a1d2dd4 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -478,7 +478,7 @@ class Share extends \OC\Share\Constants { */ public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName = null, \DateTime $expirationDate = null) { $uidOwner = \OC_User::getUser(); - $sharingPolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global'); + $shareWithinGroupOnly = self::shareWithGroupMembersOnly(); $l = \OC_L10N::get('lib'); if (is_null($itemSourceName)) { @@ -533,7 +533,7 @@ class Share extends \OC\Share\Constants { \OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OC_Log::ERROR); throw new \Exception($message_t); } - if ($sharingPolicy == 'groups_only') { + if ($shareWithinGroupOnly) { $inGroup = array_intersect(\OC_Group::getUserGroups($uidOwner), \OC_Group::getUserGroups($shareWith)); if (empty($inGroup)) { $message = 'Sharing %s failed, because the user ' @@ -563,7 +563,7 @@ class Share extends \OC\Share\Constants { \OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OC_Log::ERROR); throw new \Exception($message_t); } - if ($sharingPolicy == 'groups_only' && !\OC_Group::inGroup($uidOwner, $shareWith)) { + if ($shareWithinGroupOnly && !\OC_Group::inGroup($uidOwner, $shareWith)) { $message = 'Sharing %s failed, because ' .'%s is not a member of the group %s'; $message_t = $l->t('Sharing %s failed, because %s is not a member of the group %s', array($itemSourceName, $uidOwner, $shareWith)); @@ -1829,4 +1829,14 @@ class Share extends \OC\Share\Constants { return $backend->formatItems($items, $format, $parameters); } } + + /** + * check if user can only share with group members + * @return bool + */ + public static function shareWithGroupMembersOnly() { + $value = \OC_Appconfig::getValue('core', 'shareapi_only_share_with_group_members', 'no'); + return ($value === 'yes') ? true : false; + } + } |