diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-19 15:35:58 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-19 15:36:16 +0100 |
commit | 9ec2850c78e673a4aa1c4af97aa5be4414bd438f (patch) | |
tree | 6d127c4443d5fd6a69f7577dfd0dc8c3d01e9f26 /lib/private/util.php | |
parent | 58eaeb267c60ed2aed4b5592a28d16f5453bb773 (diff) | |
download | nextcloud-server-9ec2850c78e673a4aa1c4af97aa5be4414bd438f.tar.gz nextcloud-server-9ec2850c78e673a4aa1c4af97aa5be4414bd438f.zip |
Use mocks when testing isSharingDisabledForUser
Diffstat (limited to 'lib/private/util.php')
-rw-r--r-- | lib/private/util.php | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/private/util.php b/lib/private/util.php index 4c151d63639..8e3a0302513 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -54,6 +54,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + +use OCP\IConfig; +use OCP\IGroupManager; +use OCP\IUser; + class OC_Util { public static $scripts = array(); public static $styles = array(); @@ -218,20 +223,21 @@ class OC_Util { /** * check if sharing is disabled for the current user - * - * @return boolean + * @param IConfig $config + * @param IGroupManager $groupManager + * @param IUser|null $user + * @return bool */ - public static function isSharingDisabledForUser() { - if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_exclude_groups', 'no') === 'yes') { - $user = \OCP\User::getUser(); - $groupsList = \OC::$server->getAppConfig()->getValue('core', 'shareapi_exclude_groups_list', ''); + public static function isSharingDisabledForUser(IConfig $config, IGroupManager $groupManager, $user) { + if ($config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes') { + $groupsList = $config->getAppValue('core', 'shareapi_exclude_groups_list', ''); $excludedGroups = json_decode($groupsList); if (is_null($excludedGroups)) { $excludedGroups = explode(',', $groupsList); $newValue = json_encode($excludedGroups); - \OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups_list', $newValue); + $config->setAppValue('core', 'shareapi_exclude_groups_list', $newValue); } - $usersGroups = \OC_Group::getUserGroups($user); + $usersGroups = $groupManager->getUserGroups($user); if (!empty($usersGroups)) { $remainingGroups = array_diff($usersGroups, $excludedGroups); // if the user is only in groups which are disabled for sharing then |