summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/dav/lib/CalDAV/Activity/Provider/Base.php67
-rw-r--r--apps/dav/lib/CalDAV/Activity/Provider/Calendar.php6
-rw-r--r--apps/dav/lib/CalDAV/Activity/Provider/Event.php6
-rw-r--r--apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php8
-rw-r--r--apps/files_sharing/lib/Activity/Providers/Groups.php64
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php7
-rw-r--r--apps/workflowengine/js/admin.js23
-rw-r--r--apps/workflowengine/js/usergroupmembershipplugin.js56
-rw-r--r--lib/private/Group/Manager.php11
-rw-r--r--lib/private/Group/MetaData.php2
-rw-r--r--lib/private/Settings/Personal/PersonalInfo.php2
-rw-r--r--lib/private/SubAdmin.php19
-rw-r--r--settings/Controller/GroupsController.php15
-rw-r--r--settings/Controller/UsersController.php9
-rw-r--r--settings/js/apps.js7
-rw-r--r--settings/js/settings.js121
-rw-r--r--settings/js/users/groups.js19
-rw-r--r--settings/js/users/users.js72
-rw-r--r--settings/templates/users/main.php4
-rw-r--r--settings/templates/users/part.grouplist.php2
-rw-r--r--tests/Settings/Controller/GroupsControllerTest.php51
-rw-r--r--tests/Settings/Controller/UsersControllerTest.php146
-rw-r--r--tests/lib/Group/MetaDataTest.php15
23 files changed, 466 insertions, 266 deletions
diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Base.php b/apps/dav/lib/CalDAV/Activity/Provider/Base.php
index b6d8a5be736..99ad903f247 100644
--- a/apps/dav/lib/CalDAV/Activity/Provider/Base.php
+++ b/apps/dav/lib/CalDAV/Activity/Provider/Base.php
@@ -26,6 +26,8 @@ namespace OCA\DAV\CalDAV\Activity\Provider;
use OCA\DAV\CalDAV\CalDavBackend;
use OCP\Activity\IEvent;
use OCP\Activity\IProvider;
+use OCP\IGroup;
+use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IUser;
use OCP\IUserManager;
@@ -35,14 +37,22 @@ abstract class Base implements IProvider {
/** @var IUserManager */
protected $userManager;
- /** @var string[] cached displayNames - key is the UID and value the displayname */
- protected $displayNames = [];
+ /** @var string[] */
+ protected $userDisplayNames = [];
+
+ /** @var IGroupManager */
+ protected $groupManager;
+
+ /** @var string[] */
+ protected $groupDisplayNames = [];
/**
* @param IUserManager $userManager
+ * @param IGroupManager $groupManager
*/
- public function __construct(IUserManager $userManager) {
+ public function __construct(IUserManager $userManager, IGroupManager $groupManager) {
$this->userManager = $userManager;
+ $this->groupManager = $groupManager;
}
/**
@@ -113,30 +123,18 @@ abstract class Base implements IProvider {
}
/**
- * @param string $id
- * @return array
- */
- protected function generateGroupParameter($id) {
- return [
- 'type' => 'group',
- 'id' => $id,
- 'name' => $id,
- ];
- }
-
- /**
* @param string $uid
* @return array
*/
protected function generateUserParameter($uid) {
- if (!isset($this->displayNames[$uid])) {
- $this->displayNames[$uid] = $this->getDisplayName($uid);
+ if (!isset($this->userDisplayNames[$uid])) {
+ $this->userDisplayNames[$uid] = $this->getUserDisplayName($uid);
}
return [
'type' => 'user',
'id' => $uid,
- 'name' => $this->displayNames[$uid],
+ 'name' => $this->userDisplayNames[$uid],
];
}
@@ -144,12 +142,39 @@ abstract class Base implements IProvider {
* @param string $uid
* @return string
*/
- protected function getDisplayName($uid) {
+ protected function getUserDisplayName($uid) {
$user = $this->userManager->get($uid);
if ($user instanceof IUser) {
return $user->getDisplayName();
- } else {
- return $uid;
}
+ return $uid;
+ }
+
+ /**
+ * @param string $gid
+ * @return array
+ */
+ protected function generateGroupParameter($gid) {
+ if (!isset($this->groupDisplayNames[$gid])) {
+ $this->groupDisplayNames[$gid] = $this->getGroupDisplayName($gid);
+ }
+
+ return [
+ 'type' => 'group',
+ 'id' => $gid,
+ 'name' => $this->groupDisplayNames[$gid],
+ ];
+ }
+
+ /**
+ * @param string $gid
+ * @return string
+ */
+ protected function getGroupDisplayName($gid) {
+ $group = $this->groupManager->get($gid);
+ if ($group instanceof IGroup) {
+ return $group->getDisplayName();
+ }
+ return $gid;
}
}
diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php
index ff129144285..db79b0f6656 100644
--- a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php
+++ b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php
@@ -26,6 +26,7 @@ namespace OCA\DAV\CalDAV\Activity\Provider;
use OCP\Activity\IEvent;
use OCP\Activity\IEventMerger;
use OCP\Activity\IManager;
+use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUserManager;
@@ -63,10 +64,11 @@ class Calendar extends Base {
* @param IURLGenerator $url
* @param IManager $activityManager
* @param IUserManager $userManager
+ * @param IGroupManager $groupManager
* @param IEventMerger $eventMerger
*/
- public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IEventMerger $eventMerger) {
- parent::__construct($userManager);
+ public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IGroupManager $groupManager, IEventMerger $eventMerger) {
+ parent::__construct($userManager, $groupManager);
$this->languageFactory = $languageFactory;
$this->url = $url;
$this->activityManager = $activityManager;
diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Event.php b/apps/dav/lib/CalDAV/Activity/Provider/Event.php
index eabd2e517c0..f13cb0c266b 100644
--- a/apps/dav/lib/CalDAV/Activity/Provider/Event.php
+++ b/apps/dav/lib/CalDAV/Activity/Provider/Event.php
@@ -26,6 +26,7 @@ namespace OCA\DAV\CalDAV\Activity\Provider;
use OCP\Activity\IEvent;
use OCP\Activity\IEventMerger;
use OCP\Activity\IManager;
+use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUserManager;
@@ -57,10 +58,11 @@ class Event extends Base {
* @param IURLGenerator $url
* @param IManager $activityManager
* @param IUserManager $userManager
+ * @param IGroupManager $groupManager
* @param IEventMerger $eventMerger
*/
- public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IEventMerger $eventMerger) {
- parent::__construct($userManager);
+ public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IGroupManager $groupManager, IEventMerger $eventMerger) {
+ parent::__construct($userManager, $groupManager);
$this->languageFactory = $languageFactory;
$this->url = $url;
$this->activityManager = $activityManager;
diff --git a/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php b/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php
index affc1909e3f..37a56f88042 100644
--- a/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php
+++ b/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php
@@ -29,6 +29,7 @@ use OCP\Activity\IProvider;
use OCP\IL10N;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\IGroupManager;
use Test\TestCase;
class BaseTest extends TestCase {
@@ -36,15 +37,20 @@ class BaseTest extends TestCase {
/** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */
protected $userManager;
+ /** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
+ protected $groupManager;
+
/** @var IProvider|Base|\PHPUnit_Framework_MockObject_MockObject */
protected $provider;
protected function setUp() {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
+ $this->groupManager = $this->createMock(IGroupManager::class);
$this->provider = $this->getMockBuilder(Base::class)
->setConstructorArgs([
- $this->userManager
+ $this->userManager,
+ $this->groupManager
])
->setMethods(['parse'])
->getMock();
diff --git a/apps/files_sharing/lib/Activity/Providers/Groups.php b/apps/files_sharing/lib/Activity/Providers/Groups.php
index 53262e19311..9a8f7164c55 100644
--- a/apps/files_sharing/lib/Activity/Providers/Groups.php
+++ b/apps/files_sharing/lib/Activity/Providers/Groups.php
@@ -24,6 +24,12 @@
namespace OCA\Files_Sharing\Activity\Providers;
use OCP\Activity\IEvent;
+use OCP\Activity\IManager;
+use OCP\IGroup;
+use OCP\IGroupManager;
+use OCP\IURLGenerator;
+use OCP\IUserManager;
+use OCP\L10N\IFactory;
class Groups extends Base {
@@ -32,6 +38,24 @@ class Groups extends Base {
const SUBJECT_UNSHARED_GROUP_SELF = 'unshared_group_self';
const SUBJECT_UNSHARED_GROUP_BY = 'unshared_group_by';
+ /** @var IGroupManager */
+ protected $groupManager;
+
+ /** @var string[] */
+ protected $groupDisplayNames = [];
+
+ /**
+ * @param IFactory $languageFactory
+ * @param IURLGenerator $url
+ * @param IManager $activityManager
+ * @param IUserManager $userManager
+ * @param IGroupManager $groupManager
+ */
+ public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IGroupManager $groupManager) {
+ parent::__construct($languageFactory, $url, $activityManager, $userManager);
+ $this->groupManager = $groupManager;
+ }
+
/**
* @param IEvent $event
* @return IEvent
@@ -103,24 +127,44 @@ class Groups extends Base {
case self::SUBJECT_UNSHARED_GROUP_BY:
return [
'file' => $this->getFile($parameters[0], $event),
- 'group' => [
- 'type' => 'group',
- 'id' => $parameters[2],
- 'name' => $parameters[2],
- ],
+ 'group' => $this->generateGroupParameter($parameters[2]),
'actor' => $this->getUser($parameters[1]),
];
case self::SUBJECT_SHARED_GROUP_SELF:
case self::SUBJECT_UNSHARED_GROUP_SELF:
return [
'file' => $this->getFile($parameters[0], $event),
- 'group' => [
- 'type' => 'group',
- 'id' => $parameters[1],
- 'name' => $parameters[1],
- ],
+ 'group' => $this->generateGroupParameter($parameters[1]),
];
}
return [];
}
+
+ /**
+ * @param string $gid
+ * @return array
+ */
+ protected function generateGroupParameter($gid) {
+ if (!isset($this->groupDisplayNames[$gid])) {
+ $this->groupDisplayNames[$gid] = $this->getGroupDisplayName($gid);
+ }
+
+ return [
+ 'type' => 'group',
+ 'id' => $gid,
+ 'name' => $this->groupDisplayNames[$gid],
+ ];
+ }
+
+ /**
+ * @param string $gid
+ * @return string
+ */
+ protected function getGroupDisplayName($gid) {
+ $group = $this->groupManager->get($gid);
+ if ($group instanceof IGroup) {
+ return $group->getDisplayName();
+ }
+ return $gid;
+ }
}
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index 60b8393e1e4..087e65a1bca 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -790,9 +790,10 @@ class UsersController extends OCSController {
}
// Get the subadmin groups
- $groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user);
- foreach ($groups as $key => $group) {
- $groups[$key] = $group->getGID();
+ $subAdminGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user);
+ $groups = [];
+ foreach ($subAdminGroups as $key => $group) {
+ $groups[] = $group->getGID();
}
if(!$groups) {
diff --git a/apps/workflowengine/js/admin.js b/apps/workflowengine/js/admin.js
index ab122a8cd65..891e50c4189 100644
--- a/apps/workflowengine/js/admin.js
+++ b/apps/workflowengine/js/admin.js
@@ -149,6 +149,7 @@
message: '',
errorMessage: '',
saving: false,
+ groups: [],
initialize: function() {
// this creates a new copy of the object to definitely have a new reference and being able to reset the model
this.originalModel = JSON.parse(JSON.stringify(this.model));
@@ -161,6 +162,25 @@
if (this.model.get('id') === undefined) {
this.hasChanged = true;
}
+ var self = this;
+ $.ajax({
+ url: OC.generateUrl('settings/users/groups'),
+ dataType: 'json',
+ quietMillis: 100,
+ }).success(function(response) {
+ // add admin groups
+ $.each(response.data.adminGroups, function(id, group) {
+ self.groups.push({ id: group.id, displayname: group.name });
+ });
+ // add groups
+ $.each(response.data.groups, function(id, group) {
+ self.groups.push({ id: group.id, displayname: group.name });
+ });
+ self.render();
+ }).error(function(data) {
+ OC.Notification.error(t('workflowengine', 'Unable to retrieve the group list'), {type: 'error'});
+ console.log(data);
+ });
},
delete: function() {
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
@@ -304,10 +324,11 @@
id = $element.data('id'),
check = checks[id],
valueElement = $element.find('.check-value').first();
+ var self = this;
_.each(OCA.WorkflowEngine.availablePlugins, function(plugin) {
if (_.isFunction(plugin.render)) {
- plugin.render(valueElement, check);
+ plugin.render(valueElement, check, self.groups);
}
});
}, this);
diff --git a/apps/workflowengine/js/usergroupmembershipplugin.js b/apps/workflowengine/js/usergroupmembershipplugin.js
index 1c09e7d5ccd..53f35fedf2d 100644
--- a/apps/workflowengine/js/usergroupmembershipplugin.js
+++ b/apps/workflowengine/js/usergroupmembershipplugin.js
@@ -34,7 +34,7 @@
]
};
},
- render: function(element, check) {
+ render: function(element, check, groups) {
if (check['class'] !== 'OCA\\WorkflowEngine\\Check\\UserGroupMembership') {
return;
}
@@ -42,50 +42,30 @@
$(element).css('width', '400px');
$(element).select2({
- ajax: {
- url: OC.generateUrl('settings/users/groups'),
- dataType: 'json',
- quietMillis: 100,
- data: function (term) {
- return {
- pattern: term, //search term
- filterGroups: true,
- sortGroups: 2 // by groupname
- };
- },
- results: function (response) {
- // TODO improve error case
- if (response.data === undefined) {
- console.error('Failure happened', response);
- return;
- }
-
- var results = [];
-
- // add admin groups
- $.each(response.data.adminGroups, function(id, group) {
- results.push({ id: group.id });
+ data: { results: groups, text: 'displayname' },
+ initSelection: function (element, callback) {
+ var groupId = element.val();
+ if (groupId && groups.length > 0) {
+ callback({
+ id: groupId,
+ displayname: groups.find(function (group) {
+ return group.id === groupId;
+ }).displayname
});
- // add groups
- $.each(response.data.groups, function(id, group) {
- results.push({ id: group.id });
+ } else if (groupId) {
+ callback({
+ id: groupId,
+ displayname: groupId
});
-
- // TODO once limit and offset is implemented for groups we should paginate the search results
- return {
- results: results,
- more: false
- };
+ } else {
+ callback();
}
},
- initSelection: function (element, callback) {
- callback({id: element.val()});
- },
formatResult: function (element) {
- return '<span>' + escapeHTML(element.id) + '</span>';
+ return '<span>' + escapeHTML(element.displayname) + '</span>';
},
formatSelection: function (element) {
- return '<span title="'+escapeHTML(element.id)+'">'+escapeHTML(element.id)+'</span>';
+ return '<span title="'+escapeHTML(element.id)+'">'+escapeHTML(element.displayname)+'</span>';
}
});
}
diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php
index 2d40b447996..1dd951a1078 100644
--- a/lib/private/Group/Manager.php
+++ b/lib/private/Group/Manager.php
@@ -330,6 +330,17 @@ class Manager extends PublicEmitter implements IGroupManager {
}
/**
+ * get an array of groupid and displayName for a user
+ * @param IUser $user
+ * @return array ['displayName' => displayname]
+ */
+ public function getUserGroupNames(IUser $user) {
+ return array_map(function($group) {
+ return array('displayName' => $group->getDisplayName());
+ }, $this->getUserGroups($user));
+ }
+
+ /**
* get a list of all display names in a group
* @param string $gid
* @param string $search
diff --git a/lib/private/Group/MetaData.php b/lib/private/Group/MetaData.php
index d5c8b581f8b..99594301990 100644
--- a/lib/private/Group/MetaData.php
+++ b/lib/private/Group/MetaData.php
@@ -160,7 +160,7 @@ class MetaData {
private function generateGroupMetaData(\OCP\IGroup $group, $userSearch) {
return array(
'id' => $group->getGID(),
- 'name' => $group->getGID(),
+ 'name' => $group->getDisplayName(),
'usercount' => $this->sorting === self::SORT_USERCOUNT ? $group->count($userSearch) : 0,
);
}
diff --git a/lib/private/Settings/Personal/PersonalInfo.php b/lib/private/Settings/Personal/PersonalInfo.php
index 6411912513f..813d06195b5 100644
--- a/lib/private/Settings/Personal/PersonalInfo.php
+++ b/lib/private/Settings/Personal/PersonalInfo.php
@@ -174,7 +174,7 @@ class PersonalInfo implements ISettings {
private function getGroups(IUser $user) {
$groups = array_map(
function(IGroup $group) {
- return $group->getGID();
+ return $group->getDisplayName();
},
$this->groupManager->getUserGroups($user)
);
diff --git a/lib/private/SubAdmin.php b/lib/private/SubAdmin.php
index cd16d07e43d..44d79d8994e 100644
--- a/lib/private/SubAdmin.php
+++ b/lib/private/SubAdmin.php
@@ -62,7 +62,7 @@ class SubAdmin extends PublicEmitter {
$this->post_deleteUser($user);
});
$this->groupManager->listen('\OC\Group', 'postDelete', function($group) {
- $this->post_deleteGroup($group);
+ $this->post_deleteGroup($group);
});
}
@@ -123,7 +123,7 @@ class SubAdmin extends PublicEmitter {
while($row = $result->fetch()) {
$group = $this->groupManager->get($row['gid']);
if(!is_null($group)) {
- $groups[] = $group;
+ $groups[$group->getGID()] = $group;
}
}
$result->closeCursor();
@@ -132,6 +132,17 @@ class SubAdmin extends PublicEmitter {
}
/**
+ * get an array of groupid and displayName for a user
+ * @param IUser $user
+ * @return array ['displayName' => displayname]
+ */
+ public function getSubAdminsGroupsName(IUser $user) {
+ return array_map(function($group) {
+ return array('displayName' => $group->getDisplayName());
+ }, $this->getSubAdminsGroups($user));
+ }
+
+ /**
* get SubAdmins of a group
* @param IGroup $group the group
* @return IUser[]
@@ -185,7 +196,7 @@ class SubAdmin extends PublicEmitter {
/**
* checks if a user is a SubAdmin of a group
- * @param IUser $user
+ * @param IUser $user
* @param IGroup $group
* @return bool
*/
@@ -210,7 +221,7 @@ class SubAdmin extends PublicEmitter {
/**
* checks if a user is a SubAdmin
- * @param IUser $user
+ * @param IUser $user
* @return bool
*/
public function isSubAdmin(IUser $user) {
diff --git a/settings/Controller/GroupsController.php b/settings/Controller/GroupsController.php
index 8985a76ec95..19b7c53f8b9 100644
--- a/settings/Controller/GroupsController.php
+++ b/settings/Controller/GroupsController.php
@@ -28,6 +28,7 @@ use OC\AppFramework\Http;
use OC\Group\MetaData;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
+use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IRequest;
@@ -108,13 +109,9 @@ class GroupsController extends Controller {
Http::STATUS_CONFLICT
);
}
- if($this->groupManager->createGroup($id)) {
- return new DataResponse(
- array(
- 'groupname' => $id
- ),
- Http::STATUS_CREATED
- );
+ $group = $this->groupManager->createGroup($id);
+ if($group instanceof IGroup) {
+ return new DataResponse(['groupname' => $group->getDisplayName()], Http::STATUS_CREATED);
}
return new DataResponse(
@@ -140,9 +137,7 @@ class GroupsController extends Controller {
return new DataResponse(
array(
'status' => 'success',
- 'data' => array(
- 'groupname' => $id
- )
+ 'data' => ['groupname' => $group->getDisplayName()]
),
Http::STATUS_NO_CONTENT
);
diff --git a/settings/Controller/UsersController.php b/settings/Controller/UsersController.php
index 956403f143c..c56f0e70604 100644
--- a/settings/Controller/UsersController.php
+++ b/settings/Controller/UsersController.php
@@ -203,10 +203,7 @@ class UsersController extends Controller {
$restorePossible = true;
}
- $subAdminGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user);
- foreach ($subAdminGroups as $key => $subAdminGroup) {
- $subAdminGroups[$key] = $subAdminGroup->getGID();
- }
+ $subAdminGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroupsName($user);
$displayName = $user->getEMailAddress();
if (is_null($displayName)) {
@@ -223,7 +220,7 @@ class UsersController extends Controller {
return [
'name' => $user->getUID(),
'displayname' => $user->getDisplayName(),
- 'groups' => empty($userGroups) ? $this->groupManager->getUserGroupIds($user) : $userGroups,
+ 'groups' => empty($userGroups) ? $this->groupManager->getUserGroupNames($user) : $userGroups,
'subadmin' => $subAdminGroups,
'quota' => $user->getQuota(),
'quota_bytes' => Util::computerFileSize($user->getQuota()),
@@ -464,7 +461,7 @@ class UsersController extends Controller {
}
}
// fetch users groups
- $userGroups = $this->groupManager->getUserGroupIds($user);
+ $userGroups = $this->groupManager->getUserGroupNames($user);
return new DataResponse(
$this->formatUserForIndex($user, $userGroups),
diff --git a/settings/js/apps.js b/settings/js/apps.js
index f8db5088af0..0e5d7308e40 100644
--- a/settings/js/apps.js
+++ b/settings/js/apps.js
@@ -641,14 +641,13 @@ OC.Settings.Apps = OC.Settings.Apps || {
$('#navigation li[data-id=' + previousEntry.id + ']').after(li);
// draw attention to the newly added app entry
- // by flashing it twice
+ // by flashing twice the more apps menu
if(addedApps[entry.id]) {
- $('#header .menutoggle')
+ $('#header #more-apps')
.animate({opacity: 0.5})
.animate({opacity: 1})
.animate({opacity: 0.5})
- .animate({opacity: 1})
- .animate({opacity: 0.75});
+ .animate({opacity: 1});
}
}
diff --git a/settings/js/settings.js b/settings/js/settings.js
index 3a1e67f41cd..16718bd5cbe 100644
--- a/settings/js/settings.js
+++ b/settings/js/settings.js
@@ -24,77 +24,68 @@ OC.Settings = _.extend(OC.Settings, {
var self = this;
options = options || {};
if ($elements.length > 0) {
- // note: settings are saved through a "change" event registered
- // on all input fields
- $elements.select2(_.extend({
- placeholder: t('core', 'Groups'),
- allowClear: true,
- multiple: true,
- toggleSelect: true,
- separator: '|',
- query: _.debounce(function(query) {
- var queryData = {};
- if (self._cachedGroups && query.term === '') {
- query.callback({results: self._cachedGroups});
- return;
- }
- if (query.term !== '') {
- queryData = {
- pattern: query.term,
- filterGroups: 1
- };
- }
- $.ajax({
- url: OC.generateUrl('/settings/users/groups'),
- data: queryData,
- dataType: 'json',
- success: function(data) {
- var results = [];
+ // Let's load the data and THEN init our select
+ $.ajax({
+ url: OC.generateUrl('/settings/users/groups'),
+ dataType: 'json',
+ success: function(data) {
+ var results = [];
- // add groups
- if (!options.excludeAdmins) {
- $.each(data.data.adminGroups, function(i, group) {
- results.push({id:group.id, displayname:group.name});
+ // add groups
+ if (!options.excludeAdmins) {
+ $.each(data.data.adminGroups, function(i, group) {
+ results.push({id:group.id, displayname:group.name});
+ });
+ }
+ $.each(data.data.groups, function(i, group) {
+ results.push({id:group.id, displayname:group.name});
+ });
+ // note: settings are saved through a "change" event registered
+ // on all input fields
+ $elements.select2(_.extend({
+ placeholder: t('core', 'Groups'),
+ allowClear: true,
+ multiple: true,
+ toggleSelect: true,
+ separator: '|',
+ data: { results: results, text: 'displayname' },
+ initSelection: function(element, callback) {
+ var groups = $(element).val();
+ var selection;
+ if (groups && results.length > 0) {
+ selection = _.map((groups || []).split('|').sort(), function(groupId) {
+ return {
+ id: groupId,
+ displayname: results.find(group =>group.id === groupId).displayname
+ };
+ });
+ } else if (groups) {
+ selection = _.map((groups || []).split('|').sort(), function(groupId) {
+ return {
+ id: groupId,
+ displayname: groupId
+ };
});
}
- $.each(data.data.groups, function(i, group) {
- results.push({id:group.id, displayname:group.name});
- });
-
- if (query.term === '') {
- // cache full list
- self._cachedGroups = results;
- }
- query.callback({results: results});
+ callback(selection);
+ },
+ formatResult: function (element) {
+ return escapeHTML(element.displayname);
+ },
+ formatSelection: function (element) {
+ return escapeHTML(element.displayname);
+ },
+ escapeMarkup: function(m) {
+ // prevent double markup escape
+ return m;
}
- });
- }, 100, true),
- id: function(element) {
- return element.id;
- },
- initSelection: function(element, callback) {
- var selection =
- _.map(($(element).val() || []).split('|').sort(),
- function(groupName) {
- return {
- id: groupName,
- displayname: groupName
- };
- });
- callback(selection);
+ }, extraOptions || {}));
},
- formatResult: function (element) {
- return escapeHTML(element.displayname);
- },
- formatSelection: function (element) {
- return escapeHTML(element.displayname);
- },
- escapeMarkup: function(m) {
- // prevent double markup escape
- return m;
+ error : function(data) {
+ OC.Notification.show(t('settings', 'Unable to retrieve the group list'), {type: 'error'});
+ console.log(data);
}
- }, extraOptions || {}));
+ });
}
}
});
-
diff --git a/settings/js/users/groups.js b/settings/js/users/groups.js
index 522291a00d7..08bd26b230e 100644
--- a/settings/js/users/groups.js
+++ b/settings/js/users/groups.js
@@ -17,11 +17,14 @@ GroupList = {
filter: '',
filterGroups: false,
- addGroup: function (gid, usercount) {
+ addGroup: function (gid, displayName, usercount) {
+ if (_.isUndefined(displayName)) {
+ displayName = gid;
+ }
var $li = $userGroupList.find('.isgroup:last-child').clone();
$li
.data('gid', gid)
- .find('.groupname').text(gid);
+ .find('.groupname').text(displayName);
GroupList.setUserCount($li, usercount);
$li.appendTo($userGroupList);
@@ -128,22 +131,22 @@ GroupList = {
}
},
- createGroup: function (groupname) {
+ createGroup: function (groupid) {
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
- OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.createGroup, this, groupname));
+ OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.createGroup, this, groupid));
return;
}
$.post(
OC.generateUrl('/settings/users/groups'),
{
- id: groupname
+ id: groupid
},
function (result) {
if (result.groupname) {
var addedGroup = result.groupname;
- UserList.availableGroups = $.unique($.merge(UserList.availableGroups, [addedGroup]));
- GroupList.addGroup(result.groupname);
+ UserList.availableGroups[groupid] = {displayName: result.groupname};
+ GroupList.addGroup(groupid, result.groupname);
}
GroupList.toggleAddGroup();
}).fail(function(result) {
@@ -173,7 +176,7 @@ GroupList = {
GroupList.setUserCount(GroupList.getGroupLI(group.name).first(), group.usercount);
}
else {
- var $li = GroupList.addGroup(group.name, group.usercount);
+ var $li = GroupList.addGroup(group.id, group.name, group.usercount);
$li.addClass('appear transparent');
lis.push($li);
diff --git a/settings/js/users/users.js b/settings/js/users/users.js
index 9bbdd48e99e..847cceb8cc3 100644
--- a/settings/js/users/users.js
+++ b/settings/js/users/users.js
@@ -52,8 +52,8 @@ var UserList = {
* {
* 'name': 'username',
* 'displayname': 'Users display name',
- * 'groups': ['group1', 'group2'],
- * 'subadmin': ['group4', 'group5'],
+ * 'groups': {group1: {displayName: 'Group 1'}, group2: {displayName: 'Group 2'}}
+ * 'subadmin': {group5: {displayName: 'Group 5'}, group6: {displayName: 'Group 6'}}
* 'quota': '10 GB',
* 'quota_bytes': '10737418240',
* 'storageLocation': '/srv/www/owncloud/data/username',
@@ -66,7 +66,7 @@ var UserList = {
* }
*/
add: function (user) {
- if (this.currentGid && this.currentGid !== '_everyone' && this.currentGid !== '_disabledUsers' && _.indexOf(user.groups, this.currentGid) < 0) {
+ if (this.currentGid && this.currentGid !== '_everyone' && this.currentGid !== '_disabledUsers' && Object.keys(user.groups).indexOf(this.currentGid) < 0) {
return false;
}
@@ -454,11 +454,10 @@ var UserList = {
if (!OC.isUserAdmin() && checked.length === 1 && checked[0] === group) {
return false;
}
-
- if (add && OC.isUserAdmin() && UserList.availableGroups.indexOf(group) === -1) {
+ if (add && OC.isUserAdmin() && _.isUndefined(UserList.availableGroups[group])) {
GroupList.createGroup(group);
- if (UserList.availableGroups.indexOf(group) === -1) {
- UserList.availableGroups.push(group);
+ if (_.isUndefined(UserList.availableGroups[group])) {
+ UserList.availableGroups[group] = {displayName: group};
}
}
@@ -473,8 +472,8 @@ var UserList = {
},
success: function () {
GroupList.update();
- if (add && UserList.availableGroups.indexOf(group) === -1) {
- UserList.availableGroups.push(group);
+ if (add && _.isUndefined(UserList.availableGroups[group])) {
+ UserList.availableGroups[group] = {displayName: group};
}
if (add) {
@@ -647,11 +646,12 @@ var UserList = {
* Creates a temporary jquery.multiselect selector on the given group field
*/
_triggerGroupEdit: function ($td, isSubadminSelect) {
+ var self = this;
var $groupsListContainer = $td.find('.groupsListContainer');
- var placeholder = $groupsListContainer.attr('data-placeholder') || t('settings', 'no group');
+ var placeholder = $groupsListContainer.data('placeholder') || t('settings', 'no group');
var user = UserList.getUID($td);
- var checked = $td.data('groups') || [];
- var extraGroups = [].concat(checked);
+ var checked = $td.data('groups') || {};
+ var extraGroups = Object.assign({}, checked);
$td.find('.multiselectoptions').remove();
@@ -663,22 +663,21 @@ var UserList = {
$groupsSelect = $('<select multiple="multiple" class="subadminsselect multiselect button" title="' + placeholder + '"></select>')
}
- function createItem (group) {
- if (isSubadminSelect && group === 'admin') {
+ function createItem (gid, group) {
+ if (isSubadminSelect && group.displayName === 'admin') {
// can't become subadmin of "admin" group
return;
}
- $groupsSelect.append($('<option value="' + escapeHTML(group) + '">' + escapeHTML(group) + '</option>'));
+ $groupsSelect.append($('<option value="' + escapeHTML(gid) + '">' + escapeHTML(group.displayName) + '</option>'));
}
- $.each(this.availableGroups, function (i, group) {
+ $.each(this.availableGroups, function (gid, group) {
// some new groups might be selected but not in the available groups list yet
- var extraIndex = extraGroups.indexOf(group);
- if (extraIndex >= 0) {
+ if (extraGroups[gid] !== undefined) {
// remove extra group as it was found
- extraGroups.splice(extraIndex, 1);
+ delete extraGroups[gid];
}
- createItem(group);
+ createItem(gid, group);
});
$.each(extraGroups, function (i, group) {
createItem(group);
@@ -686,10 +685,13 @@ var UserList = {
$td.append($groupsSelect);
+ var checkedIds = Object.keys(checked).map(function(group, gid) {
+ return checked[group].displayName;
+ });
if (isSubadminSelect) {
- UserList.applySubadminSelect($groupsSelect, user, checked);
+ UserList.applySubadminSelect($groupsSelect, user, checkedIds);
} else {
- UserList.applyGroupSelect($groupsSelect, user, checked);
+ UserList.applyGroupSelect($groupsSelect, user, checkedIds);
}
$groupsListContainer.addClass('hidden');
@@ -699,7 +701,15 @@ var UserList = {
$td.find('.multiselect:not(.groupsListContainer)').parent().remove();
$td.find('.multiselectoptions').remove();
$groupsListContainer.removeClass('hidden');
- UserList._updateGroupListLabel($td, e.checked);
+ // Pull all checked groups from this.availableGroups
+ var checked = Object.keys(self.availableGroups).reduce(function (previous, key) {
+ if(e.checked.indexOf(key) >= 0) {
+ return Object.assign(previous, {[key]:self.availableGroups[key]});
+ } else {
+ return previous;
+ }
+ }, {});
+ UserList._updateGroupListLabel($td, checked);
});
},
@@ -707,9 +717,12 @@ var UserList = {
* Updates the groups list td with the given groups selection
*/
_updateGroupListLabel: function ($td, groups) {
- var placeholder = $td.find('.groupsListContainer').attr('data-placeholder');
+ var placeholder = $td.find('.groupsListContainer').data('placeholder');
var $groupsEl = $td.find('.groupsList');
- $groupsEl.text(groups.join(', ') || placeholder || t('settings', 'no group'));
+ var grouptext = Object.keys(groups).map(function(group, gid) {
+ return groups[group].displayName;
+ });
+ $groupsEl.text(grouptext.join(', ') || placeholder || t('settings', 'no group'));
$td.data('groups', groups);
}
};
@@ -1029,7 +1042,7 @@ $(document).ready(function () {
OC.Search.clear();
});
- UserList._updateGroupListLabel($('#newuser .groups'), []);
+ UserList._updateGroupListLabel($('#newuser .groups'), {});
var _submitNewUserForm = function (event) {
event.preventDefault();
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
@@ -1057,7 +1070,8 @@ $(document).ready(function () {
}
promise.then(function () {
- var groups = $('#newuser .groups').data('groups') || [];
+ var groups = $('#newuser .groups').data('groups') || {};
+ groups = Object.keys(groups);
$.post(
OC.generateUrl('/settings/users/users'),
{
@@ -1070,8 +1084,8 @@ $(document).ready(function () {
if (result.groups) {
for (var i in result.groups) {
var gid = result.groups[i];
- if (UserList.availableGroups.indexOf(gid) === -1) {
- UserList.availableGroups.push(gid);
+ if (_.isUndefined(UserList.availableGroups[gid])) {
+ UserList.availableGroups[gid] = {displayName: gid};
}
var $li = GroupList.getGroupLI(gid);
var userCount = GroupList.getUserCount($li);
diff --git a/settings/templates/users/main.php b/settings/templates/users/main.php
index 3fc80fca0b9..2d40f0fbb64 100644
--- a/settings/templates/users/main.php
+++ b/settings/templates/users/main.php
@@ -21,10 +21,10 @@ style('settings', 'settings');
$userlistParams = array();
$allGroups=array();
foreach($_["adminGroup"] as $group) {
- $allGroups[] = $group['name'];
+ $allGroups[$group['id']] = array('displayName' => $group['name']);
}
foreach($_["groups"] as $group) {
- $allGroups[] = $group['name'];
+ $allGroups[$group['id']] = array('displayName' => $group['name']);
}
$userlistParams['subadmingroups'] = $allGroups;
$userlistParams['allGroups'] = json_encode($allGroups);
diff --git a/settings/templates/users/part.grouplist.php b/settings/templates/users/part.grouplist.php
index 469ed94adb3..4128a6b76e4 100644
--- a/settings/templates/users/part.grouplist.php
+++ b/settings/templates/users/part.grouplist.php
@@ -50,7 +50,7 @@
<!--List of Groups-->
<?php foreach($_["groups"] as $group): ?>
- <li data-gid="<?php p($group['name']) ?>" data-usercount="<?php p($group['usercount']) ?>" class="isgroup">
+ <li data-gid="<?php p($group['id']) ?>" data-usercount="<?php p($group['usercount']) ?>" class="isgroup">
<a href="#" class="dorename">
<span class="groupname"><?php p($group['name']); ?></span>
</a>
diff --git a/tests/Settings/Controller/GroupsControllerTest.php b/tests/Settings/Controller/GroupsControllerTest.php
index ecbfa9ea05e..d43d4faf218 100644
--- a/tests/Settings/Controller/GroupsControllerTest.php
+++ b/tests/Settings/Controller/GroupsControllerTest.php
@@ -67,6 +67,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('firstGroup'));
$firstGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('First group'));
+ $firstGroup
->method('count')
->will($this->returnValue(12));
$secondGroup = $this->getMockBuilder(Group::class)
@@ -75,6 +78,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('secondGroup'));
$secondGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('Second group'));
+ $secondGroup
->method('count')
->will($this->returnValue(25));
$thirdGroup = $this->getMockBuilder(Group::class)
@@ -83,6 +89,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('thirdGroup'));
$thirdGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('Third group'));
+ $thirdGroup
->method('count')
->will($this->returnValue(14));
$fourthGroup = $this->getMockBuilder(Group::class)
@@ -91,6 +100,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('admin'));
$fourthGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('Admin'));
+ $fourthGroup
->method('count')
->will($this->returnValue(18));
/** @var \OC\Group\Group[] $groups */
@@ -119,7 +131,7 @@ class GroupsControllerTest extends \Test\TestCase {
'adminGroups' => array(
0 => array(
'id' => 'admin',
- 'name' => 'admin',
+ 'name' => 'Admin',
'usercount' => 0,//User count disabled 18,
)
),
@@ -127,17 +139,17 @@ class GroupsControllerTest extends \Test\TestCase {
array(
0 => array(
'id' => 'firstGroup',
- 'name' => 'firstGroup',
+ 'name' => 'First group',
'usercount' => 0,//User count disabled 12,
),
1 => array(
'id' => 'secondGroup',
- 'name' => 'secondGroup',
+ 'name' => 'Second group',
'usercount' => 0,//User count disabled 25,
),
2 => array(
'id' => 'thirdGroup',
- 'name' => 'thirdGroup',
+ 'name' => 'Third group',
'usercount' => 0,//User count disabled 14,
),
)
@@ -159,6 +171,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('firstGroup'));
$firstGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('First group'));
+ $firstGroup
->method('count')
->will($this->returnValue(12));
$secondGroup = $this->getMockBuilder(Group::class)
@@ -167,6 +182,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('secondGroup'));
$secondGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('Second group'));
+ $secondGroup
->method('count')
->will($this->returnValue(25));
$thirdGroup = $this->getMockBuilder(Group::class)
@@ -175,6 +193,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('thirdGroup'));
$thirdGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('Third group'));
+ $thirdGroup
->method('count')
->will($this->returnValue(14));
$fourthGroup = $this->getMockBuilder(Group::class)
@@ -183,6 +204,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('admin'));
$fourthGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('Admin'));
+ $fourthGroup
->method('count')
->will($this->returnValue(18));
/** @var \OC\Group\Group[] $groups */
@@ -212,7 +236,7 @@ class GroupsControllerTest extends \Test\TestCase {
'adminGroups' => array(
0 => array(
'id' => 'admin',
- 'name' => 'admin',
+ 'name' => 'Admin',
'usercount' => 18,
)
),
@@ -220,17 +244,17 @@ class GroupsControllerTest extends \Test\TestCase {
array(
0 => array(
'id' => 'secondGroup',
- 'name' => 'secondGroup',
+ 'name' => 'Second group',
'usercount' => 25,
),
1 => array(
'id' => 'thirdGroup',
- 'name' => 'thirdGroup',
+ 'name' => 'Third group',
'usercount' => 14,
),
2 => array(
'id' => 'firstGroup',
- 'name' => 'firstGroup',
+ 'name' => 'First group',
'usercount' => 12,
),
)
@@ -259,6 +283,8 @@ class GroupsControllerTest extends \Test\TestCase {
}
public function testCreateSuccessful() {
+ $group = $this->getMockBuilder(Group::class)
+ ->disableOriginalConstructor()->getMock();
$this->groupManager
->expects($this->once())
->method('groupExists')
@@ -268,7 +294,11 @@ class GroupsControllerTest extends \Test\TestCase {
->expects($this->once())
->method('createGroup')
->with('NewGroup')
- ->will($this->returnValue(true));
+ ->will($this->returnValue($group));
+ $group
+ ->expects($this->once())
+ ->method('getDisplayName')
+ ->will($this->returnValue('NewGroup'));
$expectedResponse = new DataResponse(
array(
@@ -315,6 +345,9 @@ class GroupsControllerTest extends \Test\TestCase {
->expects($this->once())
->method('delete')
->will($this->returnValue(true));
+ $group
+ ->method('getDisplayName')
+ ->will($this->returnValue('ExistingGroup'));
$expectedResponse = new DataResponse(
array(
diff --git a/tests/Settings/Controller/UsersControllerTest.php b/tests/Settings/Controller/UsersControllerTest.php
index 4d8ee15f9eb..4cfec07f78b 100644
--- a/tests/Settings/Controller/UsersControllerTest.php
+++ b/tests/Settings/Controller/UsersControllerTest.php
@@ -206,7 +206,7 @@ class UsersControllerTest extends \Test\TestCase {
$foo
->expects($this->exactly(2))
->method('getQuota')
- ->will($this->returnValue('1024'));
+ ->will($this->returnValue(1024));
$foo
->method('getLastLogin')
->will($this->returnValue(500));
@@ -236,7 +236,7 @@ class UsersControllerTest extends \Test\TestCase {
$admin
->expects($this->exactly(2))
->method('getQuota')
- ->will($this->returnValue('404'));
+ ->will($this->returnValue(404));
$admin
->expects($this->once())
->method('getLastLogin')
@@ -268,7 +268,7 @@ class UsersControllerTest extends \Test\TestCase {
$bar
->expects($this->exactly(2))
->method('getQuota')
- ->will($this->returnValue('2323'));
+ ->will($this->returnValue(2323));
$bar
->method('getLastLogin')
->will($this->returnValue(3999));
@@ -296,8 +296,20 @@ class UsersControllerTest extends \Test\TestCase {
->will($this->returnValue(array('foo' => 'M. Foo', 'admin' => 'S. Admin', 'bar' => 'B. Ar')));
$this->groupManager
->expects($this->exactly(3))
- ->method('getUserGroupIds')
- ->will($this->onConsecutiveCalls(array('Users', 'Support'), array('admins', 'Support'), array('External Users')));
+ ->method('getUserGroupNames')
+ ->will($this->onConsecutiveCalls(
+ array(
+ 'Users' => array('displayName' => 'Users'),
+ 'Support' => array('displayName' => 'Support')
+ ),
+ array(
+ 'admins' => array('displayName' => 'admins'),
+ 'Support' => array('displayName' => 'Support')
+ ),
+ array(
+ 'External Users' => array('displayName' => 'External Users')
+ )
+ ));
$this->userManager
->expects($this->at(0))
->method('get')
@@ -319,17 +331,17 @@ class UsersControllerTest extends \Test\TestCase {
->getMock();
$subadmin
->expects($this->any())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->with($foo)
->will($this->returnValue([]));
$subadmin
->expects($this->any())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->with($admin)
->will($this->returnValue([]));
$subadmin
->expects($this->any())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->with($bar)
->will($this->returnValue([]));
$this->groupManager
@@ -347,10 +359,13 @@ class UsersControllerTest extends \Test\TestCase {
0 => array(
'name' => 'foo',
'displayname' => 'M. Foo',
- 'groups' => array('Users', 'Support'),
+ 'groups' => array(
+ 'Users' => array('displayName' => 'Users'),
+ 'Support' => array('displayName' => 'Support')
+ ),
'subadmin' => array(),
'quota' => 1024,
- 'quota_bytes' => 1024,
+ 'quota_bytes' => 1024.0,
'storageLocation' => '/home/foo',
'lastLogin' => 500000,
'backend' => 'OC_User_Database',
@@ -363,10 +378,13 @@ class UsersControllerTest extends \Test\TestCase {
1 => array(
'name' => 'admin',
'displayname' => 'S. Admin',
- 'groups' => array('admins', 'Support'),
+ 'groups' => array(
+ 'admins' => array('displayName' => 'admins'),
+ 'Support' => array('displayName' => 'Support')
+ ),
'subadmin' => array(),
'quota' => 404,
- 'quota_bytes' => 404,
+ 'quota_bytes' => 404.0,
'storageLocation' => '/home/admin',
'lastLogin' => 12000,
'backend' => Dummy::class,
@@ -379,10 +397,12 @@ class UsersControllerTest extends \Test\TestCase {
2 => array(
'name' => 'bar',
'displayname' => 'B. Ar',
- 'groups' => array('External Users'),
+ 'groups' => array(
+ 'External Users' => array('displayName' => 'External Users')
+ ),
'subadmin' => array(),
'quota' => 2323,
- 'quota_bytes' => 2323,
+ 'quota_bytes' => 2323.0,
'storageLocation' => '/home/bar',
'lastLogin' => 3999000,
'backend' => Dummy::class,
@@ -555,6 +575,10 @@ class UsersControllerTest extends \Test\TestCase {
->will($this->returnValue([$subgroup1, $subgroup2]));
$subadmin
->expects($this->any())
+ ->method('getSubAdminsGroupsName')
+ ->will($this->returnValue([]));
+ $subadmin
+ ->expects($this->any())
->method('getSubAdminsGroups')
->will($this->returnValue([]));
$this->groupManager
@@ -574,8 +598,8 @@ class UsersControllerTest extends \Test\TestCase {
'displayname' => 'B. Ar',
'groups' => ['SubGroup1'],
'subadmin' => [],
- 'quota' => 2323,
- 'quota_bytes' => 2323,
+ 'quota' => '2323',
+ 'quota_bytes' => 2323.0,
'storageLocation' => '/home/bar',
'lastLogin' => 3999000,
'backend' => Dummy::class,
@@ -590,8 +614,8 @@ class UsersControllerTest extends \Test\TestCase {
'displayname' => 'M. Foo',
'groups' => ['SubGroup2', 'SubGroup1'],
'subadmin' => [],
- 'quota' => 1024,
- 'quota_bytes' => 1024,
+ 'quota' => '1024',
+ 'quota_bytes' => 1024.0,
'storageLocation' => '/home/foo',
'lastLogin' => 500000,
'backend' => 'OC_User_Database',
@@ -606,8 +630,8 @@ class UsersControllerTest extends \Test\TestCase {
'displayname' => 'S. Admin',
'groups' => ['SubGroup2'],
'subadmin' => [],
- 'quota' => 404,
- 'quota_bytes' => 404,
+ 'quota' => '404',
+ 'quota_bytes' => 404.0,
'storageLocation' => '/home/admin',
'lastLogin' => 12000,
'backend' => Dummy::class,
@@ -731,14 +755,26 @@ class UsersControllerTest extends \Test\TestCase {
->will($this->returnValue([$foo, $admin, $bar]));
$this->groupManager
->expects($this->exactly(3))
- ->method('getUserGroupIds')
- ->will($this->onConsecutiveCalls(array('Users', 'Support'), array('admins', 'Support'), array('External Users')));
+ ->method('getUserGroupNames')
+ ->will($this->onConsecutiveCalls(
+ array(
+ 'Users' => array('displayName' => 'Users'),
+ 'Support' => array('displayName' => 'Support')
+ ),
+ array(
+ 'admins' => array('displayName' => 'admins'),
+ 'Support' => array('displayName' => 'Support')
+ ),
+ array(
+ 'External Users' => array('displayName' => 'External Users')
+ )
+ ));
$subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->any())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->will($this->returnValue([]));
$this->groupManager
->expects($this->any())
@@ -755,7 +791,10 @@ class UsersControllerTest extends \Test\TestCase {
0 => array(
'name' => 'foo',
'displayname' => 'M. Foo',
- 'groups' => array('Users', 'Support'),
+ 'groups' => array(
+ 'Users' => array('displayName' => 'Users'),
+ 'Support' => array('displayName' => 'Support')
+ ),
'subadmin' => array(),
'quota' => 1024,
'quota_bytes' => 1024,
@@ -771,7 +810,10 @@ class UsersControllerTest extends \Test\TestCase {
1 => array(
'name' => 'admin',
'displayname' => 'S. Admin',
- 'groups' => array('admins', 'Support'),
+ 'groups' => array(
+ 'admins' => array('displayName' => 'admins'),
+ 'Support' => array('displayName' => 'Support')
+ ),
'subadmin' => array(),
'quota' => 404,
'quota_bytes' => 404,
@@ -787,7 +829,9 @@ class UsersControllerTest extends \Test\TestCase {
2 => array(
'name' => 'bar',
'displayname' => 'B. Ar',
- 'groups' => array('External Users'),
+ 'groups' => array(
+ 'External Users' => array('displayName' => 'External Users')
+ ),
'subadmin' => array(),
'quota' => 2323,
'quota_bytes' => 2323,
@@ -857,7 +901,7 @@ class UsersControllerTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->will($this->returnValue([]));
$this->groupManager
->expects($this->any())
@@ -944,7 +988,7 @@ class UsersControllerTest extends \Test\TestCase {
->getMock();
$subadmin
->expects($this->any())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->with($user)
->will($this->returnValue([]));
$this->groupManager
@@ -1022,16 +1066,21 @@ class UsersControllerTest extends \Test\TestCase {
->will($this->onConsecutiveCalls($newGroup));
$this->groupManager
->expects($this->once())
- ->method('getUserGroupIds')
+ ->method('getUserGroupNames')
->with($user)
- ->will($this->onConsecutiveCalls(array('NewGroup', 'ExistingGroup')));
+ ->will($this->onConsecutiveCalls(
+ array(
+ 'NewGroup' => array('displayName' => 'NewGroup'),
+ 'ExistingGroup' => array('displayName' => 'ExistingGroup')
+ )
+ ));
$subadmin = $this->getMockBuilder(SubAdmin::class)
->disableOriginalConstructor()
->getMock();
$subadmin
->expects($this->once())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->with($user)
->will($this->returnValue([]));
$this->groupManager
@@ -1042,7 +1091,10 @@ class UsersControllerTest extends \Test\TestCase {
$expectedResponse = new DataResponse(
array(
'name' => 'foo',
- 'groups' => array('NewGroup', 'ExistingGroup'),
+ 'groups' => array(
+ 'NewGroup' => array('displayName' => 'NewGroup'),
+ 'ExistingGroup' => array('displayName' => 'ExistingGroup')
+ ),
'storageLocation' => '/home/user',
'backend' => 'bar',
'lastLogin' => null,
@@ -1100,18 +1152,20 @@ class UsersControllerTest extends \Test\TestCase {
->will($this->returnValue($newUser));
$this->groupManager
->expects($this->once())
- ->method('getUserGroupIds')
+ ->method('getUserGroupNames')
->with($user)
- ->will($this->onConsecutiveCalls(['SubGroup1']));
+ ->will($this->onConsecutiveCalls(array('SubGroup1' =>
+ array('displayName' => 'SubGroup1')
+ )));
$this->groupManager
->expects($this->once())
- ->method('getUserGroupIds')
+ ->method('getUserGroupNames')
->with($newUser)
->will($this->onConsecutiveCalls(['SubGroup1']));
$subadmin = $this->createMock(\OC\SubAdmin::class);
$subadmin->expects($this->atLeastOnce())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->with($user)
->willReturnMap([
[$user, [$subGroup1]],
@@ -1135,7 +1189,7 @@ class UsersControllerTest extends \Test\TestCase {
$expectedResponse = new DataResponse(
array(
'name' => 'foo',
- 'groups' => ['SubGroup1'],
+ 'groups' => array('SubGroup1' => array('displayName' => 'SubGroup1')),
'storageLocation' => '/home/user',
'backend' => 'bar',
'lastLogin' => 0,
@@ -1563,7 +1617,7 @@ class UsersControllerTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->with($user)
->will($this->returnValue([]));
$this->groupManager
@@ -1629,7 +1683,7 @@ class UsersControllerTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->with($user)
->will($this->returnValue([]));
$this->groupManager
@@ -1676,7 +1730,7 @@ class UsersControllerTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->with($user)
->will($this->returnValue([]));
$this->groupManager
@@ -1714,7 +1768,7 @@ class UsersControllerTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->with($user)
->will($this->returnValue([]));
$this->groupManager
@@ -1771,7 +1825,7 @@ class UsersControllerTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->with($user)
->will($this->returnValue([]));
$this->groupManager
@@ -1793,7 +1847,7 @@ class UsersControllerTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$subadmin->expects($this->once())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->with($user)
->will($this->returnValue([]));
$this->groupManager
@@ -1860,6 +1914,10 @@ class UsersControllerTest extends \Test\TestCase {
->getMock();
$subadmin
->expects($this->at(0))
+ ->method('getSubAdminsGroupsName')
+ ->will($this->returnValue([$group1, $group2]));
+ $subadmin
+ ->expects($this->at(0))
->method('getSubAdminsGroups')
->will($this->returnValue([$group1, $group2]));
@@ -2407,7 +2465,7 @@ class UsersControllerTest extends \Test\TestCase {
->getMock();
$subadmin
->expects($this->any())
- ->method('getSubAdminsGroups')
+ ->method('getSubAdminsGroupsName')
->with($user)
->will($this->returnValue([]));
$this->groupManager
diff --git a/tests/lib/Group/MetaDataTest.php b/tests/lib/Group/MetaDataTest.php
index 04d2ff807b4..c24155aef37 100644
--- a/tests/lib/Group/MetaDataTest.php
+++ b/tests/lib/Group/MetaDataTest.php
@@ -53,12 +53,19 @@ class MetaDataTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
- $group->expects($this->exactly(9))
+ $group->expects($this->exactly(6))
->method('getGID')
->will($this->onConsecutiveCalls(
- 'admin', 'admin', 'admin',
- 'g2', 'g2', 'g2',
- 'g3', 'g3', 'g3'));
+ 'admin', 'admin',
+ 'g2', 'g2',
+ 'g3', 'g3'));
+
+ $group->expects($this->exactly(3))
+ ->method('getDisplayName')
+ ->will($this->onConsecutiveCalls(
+ 'admin',
+ 'g2',
+ 'g3'));
$group->expects($this->exactly($countCallCount))
->method('count')