diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2013-03-05 21:54:32 -0500 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2013-03-05 21:54:32 -0500 |
commit | 4dcbaa1d7bf3c94a92ac8a848305913e57a17ec5 (patch) | |
tree | 59113a180157e2037f3c127489e735bba173ccd6 /lib/public | |
parent | ee0c38bb5112af4aa491b526ca390de52dd3ab7e (diff) | |
parent | c1a32b50735b0a8558823d111e546865ddcba790 (diff) | |
download | nextcloud-server-4dcbaa1d7bf3c94a92ac8a848305913e57a17ec5.tar.gz nextcloud-server-4dcbaa1d7bf3c94a92ac8a848305913e57a17ec5.zip |
Merge branch 'master' into shared-folder-etags
Conflicts:
apps/files_sharing/appinfo/app.php
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/share.php | 26 | ||||
-rw-r--r-- | lib/public/util.php | 11 |
2 files changed, 31 insertions, 6 deletions
diff --git a/lib/public/share.php b/lib/public/share.php index eadf24b14eb..57fcd936ac6 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -61,6 +61,7 @@ class Share { private static $shareTypeGroupUserUnique = 2; private static $backends = array(); private static $backendTypes = array(); + private static $isResharingAllowed; /** * @brief Register a sharing backend class that implements OCP\Share_Backend for an item type @@ -591,6 +592,24 @@ class Share { } /** + * @brief Check if resharing is allowed + * @return Returns true if allowed or false + * + * Resharing is allowed by default if not configured + * + */ + private static function isResharingAllowed() { + if (!isset(self::$isResharingAllowed)) { + if (\OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes') == 'yes') { + self::$isResharingAllowed = true; + } else { + self::$isResharingAllowed = false; + } + } + return self::$isResharingAllowed; + } + + /** * @brief Get a list of collection item types for the specified item type * @param string Item type * @return array @@ -863,7 +882,10 @@ class Share { continue; } } - + // Check if resharing is allowed, if not remove share permission + if (isset($row['permissions']) && !self::isResharingAllowed()) { + $row['permissions'] &= ~PERMISSION_SHARE; + } // Add display names to result if ( isset($row['share_with']) && $row['share_with'] != '') { $row['share_with_displayname'] = \OCP\User::getDisplayName($row['share_with']); @@ -1001,7 +1023,7 @@ class Share { throw new \Exception($message); } // Check if share permissions is granted - if ((int)$checkReshare['permissions'] & PERMISSION_SHARE) { + if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & PERMISSION_SHARE) { if (~(int)$checkReshare['permissions'] & $permissions) { $message = 'Sharing '.$itemSource .' failed, because the permissions exceed permissions granted to '.$uidOwner; diff --git a/lib/public/util.php b/lib/public/util.php index 13498b260ef..db07cbcfff3 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -217,11 +217,14 @@ class Util { */ public static function getDefaultEmailAddress($user_part) { $host_name = self::getServerHostName(); - // handle localhost installations - if ($host_name === 'localhost') { - $host_name = "example.com"; + $defaultEmailAddress = $user_part.'@'.$host_name; + + if (\OC_Mail::ValidateAddress($defaultEmailAddress)) { + return $defaultEmailAddress; } - return $user_part.'@'.$host_name; + + // in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain' + return $user_part.'@localhost.localdomain'; } /** |