mirror of
https://github.com/projectsend/projectsend.git
synced 2026-09-18 09:35:07 +00:00
6e47d76ba6
Client file sharing, rebuilt from the ground up: a private area per client, resumable uploads, folders, groups and categories, sharing with expiry dates and download limits, comments, file versions, an activity log, a REST API, and sixteen languages. This repository begins here. ProjectSend 2 was developed privately, and that development history is not published — the previous generation remains available, with its own history, at projectsend/legacy. Free software under the GNU General Public License v2, or (at your option) any later version.
64 lines
2.9 KiB
PHP
64 lines
2.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Clients\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Modules\Audit\Action;
|
|
use App\Modules\Audit\ActivityLogger;
|
|
use App\Modules\Groups\Models\Group;
|
|
use App\Modules\Platform\Settings\Setting;
|
|
use App\Modules\Platform\Settings\Settings;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Validation\Rule;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class ClientSettingsController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly Settings $settings,
|
|
private readonly ActivityLogger $activity,
|
|
) {}
|
|
|
|
public function edit(): Response
|
|
{
|
|
return Inertia::render('system/settings/clients', [
|
|
'clients_can_register' => $this->settings->get(Setting::ClientsCanRegister),
|
|
'clients_auto_approve' => $this->settings->get(Setting::ClientsAutoApprove),
|
|
'clients_auto_group' => $this->settings->get(Setting::ClientsAutoGroup),
|
|
'clients_can_select_group' => $this->settings->get(Setting::ClientsCanSelectGroup),
|
|
'clients_membership_deny_cooldown_days' => $this->settings->get(Setting::ClientsMembershipDenyCooldownDays),
|
|
'default_client_storage_quota_mb' => (int) $this->settings->get(Setting::DefaultClientStorageQuotaMb),
|
|
'groups' => Group::query()->orderBy('name')->get()
|
|
->map(fn (Group $group): array => ['id' => $group->id, 'name' => $group->name])
|
|
->all(),
|
|
]);
|
|
}
|
|
|
|
public function update(Request $request): RedirectResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'clients_can_register' => ['required', 'boolean'],
|
|
'clients_auto_approve' => ['required', 'boolean'],
|
|
'clients_auto_group' => ['required', 'integer', Rule::in([0, ...Group::query()->pluck('id')->all()])],
|
|
'clients_can_select_group' => ['required', Rule::in(['none', 'public'])],
|
|
'clients_membership_deny_cooldown_days' => ['required', 'integer', 'min:0', 'max:365'],
|
|
'default_client_storage_quota_mb' => ['required', 'integer', 'min:0'],
|
|
]);
|
|
|
|
$this->settings->set(Setting::ClientsCanRegister, $validated['clients_can_register']);
|
|
$this->settings->set(Setting::ClientsAutoApprove, $validated['clients_auto_approve']);
|
|
$this->settings->set(Setting::ClientsAutoGroup, (int) $validated['clients_auto_group']);
|
|
$this->settings->set(Setting::ClientsCanSelectGroup, $validated['clients_can_select_group']);
|
|
$this->settings->set(Setting::ClientsMembershipDenyCooldownDays, (int) $validated['clients_membership_deny_cooldown_days']);
|
|
$this->settings->set(Setting::DefaultClientStorageQuotaMb, (int) $validated['default_client_storage_quota_mb']);
|
|
|
|
$this->activity->log(Action::SettingsUpdated, context: ['section' => 'clients']);
|
|
|
|
return back();
|
|
}
|
|
}
|