Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit d2c65fe

Browse files
committed
Add groups endpoint
1 parent 35eabe7 commit d2c65fe

File tree

8 files changed

+70
-2
lines changed

8 files changed

+70
-2
lines changed

Api/Controller/Groups.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace YogstationPermissions\Api\Controller;
4+
5+
use XF\Api\Controller\AbstractController;
6+
use XF\Mvc\ParameterBag;
7+
8+
/**
9+
* @api-group Groups
10+
*/
11+
12+
class Groups extends AbstractController
13+
{
14+
/**
15+
* @api-desc Get list of user groups sorted by display rank.
16+
*
17+
*
18+
* @api-out str $key the linking key generated.
19+
* @api-out str $url the url the end user needs to access to link.
20+
*/
21+
public function actionGet(ParameterBag $params)
22+
{
23+
$this->assertSuperUserKey();
24+
25+
$groups = $this->finder('XF:UserGroup')->order('display_style_priority')->fetch();
26+
27+
return $this->apiSuccess([
28+
'groups' => $groups
29+
]);
30+
}
31+
32+
}

XF/Entity/UserGroup.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace YogstationPermissions\XF\Entity;
4+
5+
class UserGroup extends XFCP_UserGroup {
6+
protected function setupApiResultData(
7+
\XF\Api\Result\EntityResult $result, $verbosity = self::VERBOSITY_NORMAL, array $options = [])
8+
{
9+
$result->title = $this->title;
10+
$result->display_priority = $this->display_style_priority;
11+
}
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"from_class": "XF\\Entity\\UserGroup",
3+
"to_class": "YogstationPermissions\\XF\\Entity\\UserGroup",
4+
"execute_order": 10,
5+
"active": true
6+
}

_output/class_extensions/_metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"XF-Entity-UserGroup_YogstationPermissions-XF-Entity-UserGroup.json": {
3+
"hash": "68f5eff9b6a0fe9735f6633c26aad323"
4+
},
25
"XF-Entity-User_YogstationPermissions-XF-Entity-User.json": {
36
"hash": "2c81c2cf6835563462e9b5630856842a"
47
}

_output/extension_hint.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
namespace YogstationPermissions\XF\Entity
77
{
88
class XFCP_User extends \XF\Entity\User {}
9+
class XFCP_UserGroup extends \XF\Entity\UserGroup {}
910
}

_output/routes/_metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"api_groups_.json": {
3+
"hash": "cd3636cd893aa6db95981fb5f4cc3548"
4+
},
25
"api_linking_.json": {
36
"hash": "8746785f7f0cde8a03be2abafa5d6751"
47
},

_output/routes/api_groups_.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"route_type": "api",
3+
"route_prefix": "groups",
4+
"sub_name": "",
5+
"format": "",
6+
"build_class": "",
7+
"build_method": "",
8+
"controller": "YogstationPermissions:Groups",
9+
"context": "",
10+
"action_prefix": ""
11+
}

addon.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"legacy_addon_id": "",
33
"title": "Yogstation Permissions",
44
"description": "",
5-
"version_id": 20201010,
6-
"version_string": "20201010",
5+
"version_id": 20201130,
6+
"version_string": "20201130",
77
"dev": "",
88
"dev_url": "",
99
"faq_url": "",

0 commit comments

Comments
 (0)