From 6578f00b4bcfbd5bc44bc12e341506f922498d7b Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Wed, 4 Jun 2014 11:07:31 +0200 Subject: unify share settings --- lib/private/share/share.php | 16 +++++++++++++--- lib/private/updater.php | 11 +++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) (limited to 'lib') 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 { -- cgit v1.2.3