mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
feat: add objet field (tfe/thèse/frart) with share-link restriction and site-settings toggles
This commit is contained in:
@@ -48,16 +48,20 @@ class ShareLink
|
||||
* @param string|null $expiresAt ISO-8601 expiration date, null = never expires
|
||||
* @return array The created link row
|
||||
*/
|
||||
public function create(int $createdBy, ?string $password = null, ?string $expiresAt = null): array
|
||||
public function create(int $createdBy, ?string $password = null, ?string $expiresAt = null, ?string $objetRestriction = null): array
|
||||
{
|
||||
$slug = self::generateSlug();
|
||||
$passwordHash = $password !== null ? password_hash($password, PASSWORD_BCRYPT) : null;
|
||||
$validObjet = ['tfe', 'thèse', 'frart'];
|
||||
$objetRestriction = ($objetRestriction !== null && in_array($objetRestriction, $validObjet, true))
|
||||
? $objetRestriction
|
||||
: null;
|
||||
|
||||
$stmt = $this->db->getConnection()->prepare(
|
||||
"INSERT INTO share_links (slug, password_hash, is_active, created_by, expires_at)
|
||||
VALUES (?, ?, 1, ?, ?)"
|
||||
"INSERT INTO share_links (slug, objet_restriction, password_hash, is_active, created_by, expires_at)
|
||||
VALUES (?, ?, ?, 1, ?, ?)"
|
||||
);
|
||||
$stmt->execute([$slug, $passwordHash, $createdBy, $expiresAt]);
|
||||
$stmt->execute([$slug, $objetRestriction, $passwordHash, $createdBy, $expiresAt]);
|
||||
|
||||
return $this->findBySlug($slug);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user