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 | |
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')
-rw-r--r-- | lib/private/share/share.php | 16 | ||||
-rw-r--r-- | lib/private/updater.php | 11 |
2 files changed, 22 insertions, 5 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; + } + } diff --git a/lib/private/updater.php b/lib/private/updater.php index 106970c4121..29923d76294 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -53,7 +53,7 @@ class Updater extends BasicEmitter { $version = \OC_Util::getVersion(); $version['installed'] = \OC_Appconfig::getValue('core', 'installedat'); $version['updated'] = \OC_Appconfig::getValue('core', 'lastupdatedat'); - $version['updatechannel'] = \OC_Util::getChannel(); + $version['updatechannel'] = \OC_Util::getChannel(); $version['edition'] = \OC_Util::getEditionString(); $version['build'] = \OC_Util::getBuild(); $versionString = implode('x', $version); @@ -119,7 +119,7 @@ class Updater extends BasicEmitter { if (!\OC::$CLI && version_compare($installedVersion, '6.90.1', '<')) { // Add the trusted_domains config if it is not existant // This is added to prevent host header poisoning - \OC_Config::setValue('trusted_domains', \OC_Config::getValue('trusted_domains', array(\OC_Request::serverHost()))); + \OC_Config::setValue('trusted_domains', \OC_Config::getValue('trusted_domains', array(\OC_Request::serverHost()))); } /* * STOP CONFIG CHANGES FOR OLDER VERSIONS @@ -151,6 +151,13 @@ class Updater extends BasicEmitter { $this->emit('\OC\Updater', 'failure', array($exception->getMessage())); } + // upgrade from OC6 to OC7 + // TODO removed it again for OC8 + $sharePolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global'); + if ($sharePolicy === 'groups_only') { + \OC_Appconfig::setValue('core', 'shareapi_only_share_with_group_members', 'yes'); + } + if ($canUpgrade) { // proceed with real upgrade try { |