Cast types directly

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-03-23 18:12:23 +01:00
parent f4e84e1727
commit 4011ea97b1
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
1 changed files with 9 additions and 27 deletions

View File

@ -86,14 +86,7 @@ class GroupsController extends OCSController {
* @param int $offset
* @return DataResponse
*/
public function getGroups(string $search = '', $limit = null, $offset = null): DataResponse {
if ($limit !== null) {
$limit = (int)$limit;
}
if ($offset !== null) {
$offset = (int)$offset;
}
public function getGroups(string $search = '', int $limit = null, int $offset = 0): DataResponse {
$groups = $this->groupManager->search($search, $limit, $offset);
$groups = array_map(function($group) {
/** @var IGroup $group */
@ -113,14 +106,7 @@ class GroupsController extends OCSController {
* @param int $offset
* @return DataResponse
*/
public function getGroupsDetails(string $search = '', $limit = null, $offset = null): DataResponse {
if ($limit !== null) {
$limit = (int)$limit;
}
if ($offset !== null) {
$offset = (int)$offset;
}
public function getGroupsDetails(string $search = '', int $limit = null, int $offset = null): DataResponse {
$groups = $this->groupManager->search($search, $limit, $offset);
$groups = array_map(function($group) {
/** @var IGroup $group */
@ -154,16 +140,14 @@ class GroupsController extends OCSController {
*/
public function getGroupUsers(string $groupId): DataResponse {
$user = $this->userSession->getUser();
$isSubadminOfGroup = false;
// Check the group exists
if(!$this->groupManager->groupExists($groupId)) {
throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND);
}
$isSubadminOfGroup = false;
$group = $this->groupManager->get($groupId);
if ($group !== null) {
$isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group);
} else {
throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND);
}
// Check subadmin has access to this group
@ -192,18 +176,16 @@ class GroupsController extends OCSController {
* @return DataResponse
* @throws OCSException
*/
public function getGroupUsersDetails(string $groupId, $limit = null, $offset = 0): DataResponse {
public function getGroupUsersDetails(string $groupId, int $limit = null, int $offset = 0): DataResponse {
$user = $this->userSession->getUser();
$isSubadminOfGroup = false;
// Check the group exists
if(!$this->groupManager->groupExists($groupId)) {
throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND);
}
$isSubadminOfGroup = false;
$group = $this->groupManager->get($groupId);
if ($group !== null) {
$isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group);
} else {
throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND);
}
// Check subadmin has access to this group