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:
@@ -127,6 +127,7 @@ class ThesisCreateController
|
||||
'baiu_link' => $data['lien'],
|
||||
'license_id' => $data['licenseId'],
|
||||
'access_type_id' => $data['accessTypeId'],
|
||||
'objet' => $data['objet'],
|
||||
'author_id' => $authorId,
|
||||
]);
|
||||
|
||||
@@ -275,6 +276,10 @@ class ThesisCreateController
|
||||
$accessTypeId = 2; // Interne
|
||||
}
|
||||
|
||||
// Objet — restricted to valid values
|
||||
$validObjet = ['tfe', 'thèse', 'frart'];
|
||||
$objet = in_array($post['objet'] ?? '', $validObjet, true) ? $post['objet'] : 'tfe';
|
||||
|
||||
// External link (optional)
|
||||
$lien = '';
|
||||
if (!empty($post['lien'])) {
|
||||
@@ -298,7 +303,7 @@ class ThesisCreateController
|
||||
'auteurName', 'mail', 'showContact', 'confirmationEmail', 'annee', 'orientationId', 'apProgramId',
|
||||
'finalityId', 'titre', 'subtitle', 'synopsis', 'durationInfo',
|
||||
'juryMembers', 'keywords', 'languageIds', 'formatIds',
|
||||
'licenseId', 'lien', 'accessTypeId'
|
||||
'licenseId', 'lien', 'accessTypeId', 'objet'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1566,11 +1566,15 @@ class Database {
|
||||
synopsis, file_size_info,
|
||||
baiu_link, license_id,
|
||||
access_type_id,
|
||||
objet,
|
||||
is_published,
|
||||
submitted_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, CURRENT_TIMESTAMP)
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, CURRENT_TIMESTAMP)
|
||||
");
|
||||
|
||||
$validObjet = ['tfe', 'thèse', 'frart'];
|
||||
$objet = in_array($data['objet'] ?? '', $validObjet, true) ? $data['objet'] : 'tfe';
|
||||
|
||||
$stmt->execute([
|
||||
$identifier,
|
||||
$data['title'],
|
||||
@@ -1584,6 +1588,7 @@ class Database {
|
||||
!empty($data['baiu_link']) ? $data['baiu_link'] : null,
|
||||
isset($data['license_id']) ? $data['license_id'] : null,
|
||||
isset($data['access_type_id']) ? (int)$data['access_type_id'] : 2, // default: Interne
|
||||
$objet,
|
||||
]);
|
||||
|
||||
$thesisId = (int)$this->pdo->lastInsertId();
|
||||
|
||||
@@ -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