Merge pull request #19510 from owncloud/json-grouplist-sharing-exclude

save excluded groups in json format
This commit is contained in:
Thomas Müller 2015-10-02 12:14:36 +02:00
commit 8944cb539e
4 changed files with 9 additions and 8 deletions

View File

@ -223,7 +223,12 @@ class OC_Util {
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', '');
$excludedGroups = explode(',', $groupsList);
$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);
}
$usersGroups = \OC_Group::getUserGroups($user);
if (!empty($usersGroups)) {
$remainingGroups = array_diff($usersGroups, $excludedGroups);

View File

@ -87,7 +87,7 @@ $template->assign('shareEnforceExpireDate', $appConfig->getValue('core', 'sharea
$excludeGroups = $appConfig->getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false;
$template->assign('shareExcludeGroups', $excludeGroups);
$excludedGroupsList = $appConfig->getValue('core', 'shareapi_exclude_groups_list', '');
$excludedGroupsList = explode(',', $excludedGroupsList); // FIXME: this should be JSON!
$excludedGroupsList = json_decode($excludedGroupsList);
$template->assign('shareExcludedGroupsList', implode('|', $excludedGroupsList));
$template->assign('encryptionEnabled', \OC::$server->getEncryptionManager()->isEnabled());
$backends = \OC::$server->getUserManager()->getBackends();

View File

@ -23,11 +23,7 @@ $(document).ready(function(){
OC.Settings.setupGroupsSelect($(element));
$(element).change(function(ev) {
var groups = ev.val || [];
if (groups.length > 0) {
groups = ev.val.join(','); // FIXME: make this JSON
} else {
groups = '';
}
groups = JSON.stringify(groups);
OC.AppConfig.setValue('core', $(this).attr('name'), groups);
});
});

View File

@ -303,7 +303,7 @@ class Test_Util extends \Test\TestCase {
}
$appConfig = \OC::$server->getAppConfig();
$appConfig->setValue('core', 'shareapi_exclude_groups_list', implode(',', $excludedGroups));
$appConfig->setValue('core', 'shareapi_exclude_groups_list', json_encode($excludedGroups));
$appConfig->setValue('core', 'shareapi_exclude_groups', 'yes');
$result = \OCP\Util::isSharingDisabledForUser();