/** * @Ajax */ public function manageGroup() { \OC_Util::checkAdminUser(); $params = $this->request->post; $id = isset($params['group']) ? $params['group'] : null; $name = isset($params['name']) ? $params['name'] : null; $action = isset($params['action']) ? $params['action'] : null; $groupType = isset($params['gt']) ? $params['gt'] : null; if (is_null($action) || is_null($groupType)) { return new JSONResponse(array("msg" => "Not specified action or group type"), Http::STATUS_BAD_REQUEST); } if (!GK::checkGroupType($groupType)) { return new JSONResponse(array("msg" => "Group type {$groupType} is not valid"), Http::STATUS_BAD_REQUEST); } switch ($action) { case 'rm': if (is_null($id)) { return new JSONResponse(array("msg" => "Not specified id"), Http::STATUS_BAD_REQUEST); } $ao = AccessObject::fromParams(array('id' => $id)); $this->accessObjectMapper->delete($ao); break; case 'add': if (is_null($name)) { return new JSONResponse(array("msg" => "Not specified name"), Http::STATUS_BAD_REQUEST); } if ($this->accessObjectMapper->isGroupInMode($name, $groupType)) { return new JSONResponse(array("msg" => "Group {$name} already exists in this list"), Http::STATUS_BAD_REQUEST); } else { $ao = AccessObject::fromParams(array('name' => $name, 'mode' => $groupType)); $this->accessObjectMapper->insert($ao); $id = $ao->getId(); } break; default: # code... break; } return new JSONResponse(array('id' => $id)); }