-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pagination/search through REPORT #27
Conversation
6e6e790
to
58f7ef4
Compare
Do we agree on the general approach so I can solidify this with unit tests ? |
lib/CustomGroupsDatabaseHandler.php
Outdated
public function getGroups() { | ||
return $this->searchGroups(); | ||
public function getGroups($pattern = null, $offset = 0, $limit = -1) { | ||
return $this->searchGroups($pattern, $offset, $limit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be changed
lib/CustomGroupsDatabaseHandler.php
Outdated
if ($search !== null) { | ||
if ($search->getPattern() !== null && $property !== null) { | ||
$likeString = '%' . $this->dbConn->escapeLikeParameter(strtolower($search->getPattern())) . '%'; | ||
$qb->andWhere($qb->expr()->like($qb->createFunction('LOWER(`' . $property . '`)'), $qb->createNamedParameter($likeString))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that lower
function is strictly needed?. Although it might not be risky, the behaviour isn't optional and isn't documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how we did search in the default group backend. I think it makes sense to keep it.
lib/CustomGroupsDatabaseHandler.php
Outdated
* @return array an array of member info | ||
* @throws \Doctrine\DBAL\Exception\DriverException in case of database exception | ||
*/ | ||
public function getUserMemberships($uid, $roleFilter = null) { | ||
public function getUserMemberships($uid, $roleFilter = null, Search $search = null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we can switch the roleFilter
and search
parameters at this point. I've seen too much getUserMembership(uid, null, search)
. A getUserMembership(uid, search)
with the roleFilter
as null by default looks better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also hesitated to maybe put the role filter as a member of the Search
class, what do you think ?
The approach looks good to me. |
@jvillafanez thanks a lot for your feedback ! I have the feeling that having a |
|
|
Ok, I'll try adding |
e31f275
to
7ddc303
Compare
This is ready for review now |
Unit tests added + a few tweaks |
lib/CustomGroupsBackend.php
Outdated
@@ -79,7 +79,7 @@ public function inGroup($uid, $gid) { | |||
* @return array an array of group names | |||
*/ | |||
public function getUserGroups($uid) { | |||
$memberInfos = $this->handler->getUserMemberships($uid, null); | |||
$memberInfos = $this->handler->getUserMemberships($uid, null, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many nulls here
$groupId = $this->groupInfo['group_id']; | ||
if (!$this->helper->isUserMember($groupId) | ||
&& !$this->helper->isUserAdmin($groupId)) { | ||
throw new Forbidden("No permission to list members of group \"$groupId\""); | ||
} | ||
$members = $this->groupsHandler->getGroupMembers($groupId); | ||
$members = $this->groupsHandler->getGroupMembers($groupId, null, $search); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are the parameters correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh oh... why didn't the tests explode... I'll recheck
7ddc303
to
fdab5a5
Compare
@jvillafanez fixed now... The reason why tests passed is because the expectation was also wrong... |
👍 |
and now Travis is imitating Jenkins it seems. It's been an hour and I still can't see any results (loading forever) |
|
Going to merge this anyway now and resolve conflicts and integration tests as part of #26 |
Fixes #16
Example report:
You can apply this to the following URLs:
curl -i --data-binary "@report-customgroups.xml" -X REPORT -H "Content-Type: text/xml" http://admin:admin@localhost/owncloud/remote.php/dav/customgroups/groups
curl -i --data-binary "@report-customgroups.xml" -X REPORT -H "Content-Type: text/xml" http://admin:admin@localhost/owncloud/remote.php/dav/customgroups/groups/group1
curl -i --data-binary "@report-customgroups.xml" -X REPORT -H "Content-Type: text/xml" http://admin:admin@localhost/owncloud/remote.php/dav/customgroups/users/user1/
@DeepDiver1975 @jvillafanez please review.
If the implementation style is ok I'll add matching unit tests.