Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/GroupsController.php
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | public function index() | ||||
$data = array_merge($data, self::groupStatuses($group)); | $data = array_merge($data, self::groupStatuses($group)); | ||||
return $data; | return $data; | ||||
}); | }); | ||||
return response()->json($result); | return response()->json($result); | ||||
} | } | ||||
/** | /** | ||||
* Set the group configuration. | |||||
* | |||||
* @param int $id Group identifier | |||||
* | |||||
* @return \Illuminate\Http\JsonResponse|void | |||||
*/ | |||||
public function setConfig($id) | |||||
{ | |||||
$group = Group::find($id); | |||||
if (!$this->checkTenant($group)) { | |||||
return $this->errorResponse(404); | |||||
} | |||||
if (!$this->guard()->user()->canUpdate($group)) { | |||||
return $this->errorResponse(403); | |||||
} | |||||
$errors = $group->setConfig(request()->input()); | |||||
if (!empty($errors)) { | |||||
return response()->json(['status' => 'error', 'errors' => $errors], 422); | |||||
} | |||||
return response()->json([ | |||||
'status' => 'success', | |||||
'message' => \trans('app.distlist-setconfig-success'), | |||||
]); | |||||
} | |||||
/** | |||||
* Display information of a group specified by $id. | * Display information of a group specified by $id. | ||||
* | * | ||||
* @param int $id The group to show information for. | * @param int $id The group to show information for. | ||||
* | * | ||||
* @return \Illuminate\Http\JsonResponse | * @return \Illuminate\Http\JsonResponse | ||||
*/ | */ | ||||
public function show($id) | public function show($id) | ||||
{ | { | ||||
$group = Group::find($id); | $group = Group::find($id); | ||||
if (!$this->checkTenant($group)) { | if (!$this->checkTenant($group)) { | ||||
return $this->errorResponse(404); | return $this->errorResponse(404); | ||||
} | } | ||||
if (!$this->guard()->user()->canRead($group)) { | if (!$this->guard()->user()->canRead($group)) { | ||||
return $this->errorResponse(403); | return $this->errorResponse(403); | ||||
} | } | ||||
$response = $group->toArray(); | $response = $group->toArray(); | ||||
$response = array_merge($response, self::groupStatuses($group)); | $response = array_merge($response, self::groupStatuses($group)); | ||||
$response['statusInfo'] = self::statusInfo($group); | $response['statusInfo'] = self::statusInfo($group); | ||||
// Group configuration, e.g. sender_policy | |||||
$response['config'] = $group->getConfig(); | |||||
return response()->json($response); | return response()->json($response); | ||||
} | } | ||||
/** | /** | ||||
* Fetch group status (and reload setup process) | * Fetch group status (and reload setup process) | ||||
* | * | ||||
* @param int $id Group identifier | * @param int $id Group identifier | ||||
* | * | ||||
▲ Show 20 Lines • Show All 386 Lines • Show Last 20 Lines |