diff --git a/class.groups.plugin.php b/class.groups.plugin.php
index e022d72..6924458 100644
--- a/class.groups.plugin.php
+++ b/class.groups.plugin.php
@@ -407,7 +407,7 @@ private function getTopcoderRoles($user, $resources = null, $roleResources = nul
*/
private function addGroupLinkToMenu() {
if(Gdn::session()->isValid()) {
- echo '
'. anchor('Groups', GroupsPlugin::GROUPS_ROUTE).'';
+ echo ''. anchor('Challenges', GroupsPlugin::GROUPS_ROUTE).'';
}
}
diff --git a/controllers/api/GroupsApiController.php b/controllers/api/GroupsApiController.php
index e041775..4a68840 100644
--- a/controllers/api/GroupsApiController.php
+++ b/controllers/api/GroupsApiController.php
@@ -135,6 +135,31 @@ public function post(array $body) {
return $result;
}
+ /**
+ * Update a group.
+ *
+ * @param array $body The request body.
+ * @throws ServerException if the group could not be updated.
+ * @return array
+ */
+ public function patch($id, array $body) {
+ $in = $this->groupPatchSchema()->setDescription('Update a group.');
+ $out = $this->groupSchema('out');
+ $body = $in->validate($body);
+ $group = $this->groupModel->getByGroupID($id);
+ if(!$group) {
+ throw new NotFoundException('Group');
+ }
+ $group->Name = $body['name'];
+ $result = $this->groupModel->save($group);
+ $this->validateModel($this->groupModel);
+ if ($result == false) {
+ throw new ServerException('Unable to update a group.', 500);
+ }
+ $row = $this->groupModel->getID($id, DATASET_TYPE_ARRAY);
+ return $out->validate($row);
+ }
+
/**
* Add participants to a group.
*
@@ -251,7 +276,7 @@ public function groupSchema($type = '') {
}
/**
- * Get a group schema with minimal add/edit fields.
+ * Get a group schema with minimal add fields.
*
* @param string $type The type of schema.
* @return Schema Returns a schema object.
@@ -268,6 +293,17 @@ public function groupPostSchema() {
]), 'GroupPost');
}
+ /**
+ * Get a group schema with minimal edit fields.
+ *
+ * @param string $type The type of schema.
+ * @return Schema Returns a schema object.
+ */
+ public function groupPatchSchema() {
+ return $this->schema(Schema::parse([
+ 'name:s' => 'The name of the group.',
+ ]), 'GroupPatch');
+ }
/**
* Get a schema instance comprised of all available group fields.
diff --git a/openapi/groups.yml b/openapi/groups.yml
index c3a380a..3576132 100644
--- a/openapi/groups.yml
+++ b/openapi/groups.yml
@@ -82,6 +82,30 @@ paths:
tags:
- Groups
summary: Get a group.
+ patch:
+ parameters:
+ - description: The group ID.
+ in: path
+ name: id
+ required: true
+ schema:
+ type: integer
+ responses:
+ '200':
+ content:
+ 'application/json':
+ schema:
+ $ref: '#/components/schemas/Group'
+ description: Success
+ tags:
+ - Groups
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/GroupPatch'
+ required: true
+ summary: Update a group.
'/groups/{id}/members/{userid}':
delete:
parameters:
@@ -132,6 +156,12 @@ components:
schema:
$ref: '#/components/schemas/GroupPost'
required: true
+ GroupPatch:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/GroupPatch'
+ required: true
schemas:
Group:
properties:
@@ -195,6 +225,15 @@ components:
- challengeID
- challengeUrl
type: object
+ GroupPatch:
+ properties:
+ name:
+ description: The name of the group.
+ minLength: 1
+ type: string
+ required:
+ - name
+ type: object
GroupMemberPost:
description: Add a member to a group
properties: