diff --git a/net/xenapi/XenAPI/api.php b/net/xenapi/XenAPI/api.php index fa1ddb8..843ce1b 100644 --- a/net/xenapi/XenAPI/api.php +++ b/net/xenapi/XenAPI/api.php @@ -106,7 +106,8 @@ class RestAPI { 'getavatar' => 'public', 'getconversation' => 'private', 'getconversations' => 'private', - 'getgroup' => 'public', + 'getgroup' => 'public', + 'getgroups' => 'public', 'getnode' => 'public', 'getnodes' => 'public', 'getpost' => 'public', @@ -1926,6 +1927,16 @@ public function processRequest() { // Group was found, send response. $this->sendResponse($group); } + case 'getgroups': + // Get the groups from XenForo. + $groups = $this->getXenAPI()->getGroups(); + if (!$groups) { + // Could not find any group, throw error. + $this->throwError(4, 'group', $string); + } else { + // Groups were found, send response. + $this->sendResponse($groups); + } case 'getconversations': /** * Grabs the conversations from the specified user. @@ -2631,7 +2642,7 @@ public function processRequest() { * - api.php?action=getUsers&value=C* */ - if ($this->hasRequest('value') && strpos($this->getRequest('value', ',')) !== false) { + if ($this->hasRequest('value') && strpos($this->getRequest('value'), ',') !== false) { $userIds = explode(',', $this->getRequest('value')); $results = []; foreach ($userIds as $userId) { @@ -4097,6 +4108,11 @@ public function getGroup($group) { . " OR `title` = " . $this->getDatabase()->quote($group) . " OR `user_title` = " . $this->getDatabase()->quote($group)); } + public function getGroups() { + // Get the groups list from the database. + return $this->getDatabase()->fetchAll("SELECT * FROM `xf_user_group`"); + } + /** * Returns a list of resources. */