Files
projectsend/app/Modules/Comments/CommentAuthors.php
ignacionelson 6e47d76ba6 ProjectSend 2.0.0
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.
2026-08-14 01:38:12 -03:00

52 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Modules\Comments;
use App\Modules\Identity\UserType;
/**
* Who may write a comment (Setting::CommentsAuthors).
*
* This is a setting rather than a permission on purpose. Roles are only
* editable in the community edition — the cloud edition gates the whole
* roles screen behind Capability::UsersManage — so a permission key would
* be unconfigurable for half our installs. It also expresses something a
* permission structurally cannot: `Everyone` includes anonymous visitors,
* who have no account and therefore no role to hold a key.
*/
enum CommentAuthors: string
{
case Staff = 'staff';
case Clients = 'clients';
case StaffAndClients = 'staff_and_clients';
case Everyone = 'everyone';
/**
* @param UserType|null $type Null means an anonymous visitor.
*/
public function allows(?UserType $type): bool
{
return match ($this) {
self::Staff => $type === UserType::Staff,
self::Clients => $type === UserType::Client,
self::StaffAndClients => $type !== null,
self::Everyone => true,
};
}
/**
* English label — also the translation key.
*/
public function label(): string
{
return match ($this) {
self::Staff => 'Staff only',
self::Clients => 'Clients only',
self::StaffAndClients => 'Staff and clients',
self::Everyone => 'Anyone, including visitors who are not logged in',
};
}
}