Limitation de date d'nscription

This commit is contained in:
Fred Tempez 2023-11-18 16:14:19 +01:00
parent a4d4f9cce4
commit 3c4e5f7d05
5 changed files with 58 additions and 13 deletions

View File

@ -50,7 +50,7 @@ class common
const ACCESS_TIMER = 1800; const ACCESS_TIMER = 1800;
// Numéro de version // Numéro de version
const ZWII_VERSION = '1.1.03'; const ZWII_VERSION = '1.1.04';
// URL autoupdate // URL autoupdate
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/campus-update/raw/branch/master/'; const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/campus-update/raw/branch/master/';

View File

@ -162,6 +162,8 @@ class course extends common
'closingDate' => $this->getInput('courseAddClosingDate', helper::FILTER_DATETIME), 'closingDate' => $this->getInput('courseAddClosingDate', helper::FILTER_DATETIME),
'enrolment' => $this->getInput('courseAddEnrolment', helper::FILTER_INT), 'enrolment' => $this->getInput('courseAddEnrolment', helper::FILTER_INT),
'enrolmentKey' => $this->getInput('courseAddEnrolmentKey'), 'enrolmentKey' => $this->getInput('courseAddEnrolmentKey'),
'limitEnrolment' => $this->getInput('courseAddEnrolmentLimit', helper::FILTER_BOOLEAN),
'limitEnrolmentDate' => $this->getInput('courseAddEnrolmentLimitDate', helper::FILTER_DATETIME),
] ]
]); ]);
@ -227,6 +229,8 @@ class course extends common
'closingDate' => $this->getInput('courseClosingDate', helper::FILTER_DATETIME), 'closingDate' => $this->getInput('courseClosingDate', helper::FILTER_DATETIME),
'enrolment' => $this->getInput('courseEditEnrolment', helper::FILTER_INT), 'enrolment' => $this->getInput('courseEditEnrolment', helper::FILTER_INT),
'enrolmentKey' => $this->getInput('courseEditEnrolmentKey'), 'enrolmentKey' => $this->getInput('courseEditEnrolmentKey'),
'limitEnrolment' => $this->getInput('courseEditEnrolmentLimit', helper::FILTER_BOOLEAN),
'limitEnrolmentDate' => $this->getInput('courseEditEnrolmentLimitDate', helper::FILTER_DATETIME),
] ]
]); ]);
@ -863,12 +867,15 @@ class course extends common
} }
$file = fopen($filename, 'w'); $file = fopen($filename, 'w');
foreach ($history['history'] as $pageId => $time) { foreach ($history['history'] as $pageId => $time) {
$data = array_map('html_entity_decode', array( $data = array_map(
$pageId, 'html_entity_decode',
$pages[$pageId]['title'], array(
$pages[$pageId]['number'], $pageId,
helper::dateUTF8('%d %B %Y - %H:%M:%S', $time), $pages[$pageId]['title'],
)); $pages[$pageId]['number'],
helper::dateUTF8('%d %B %Y - %H:%M:%S', $time),
)
);
// Écrire la ligne dans le fichier CSV // Écrire la ligne dans le fichier CSV
fputcsv($file, $data, ';'); fputcsv($file, $data, ';');

View File

@ -86,6 +86,19 @@
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row">
<div class="col4">
<?php echo template::checkbox('courseAddEnrolmentLimit', true, 'Date de fin d\'inscription', [
'help' => 'Ne s\'applique pas à l\'inscription anonyme',
]); ?>
</div>
<div class="col4">
<?php echo template::date('courseAddEnrolmentLimitDate', [
'type' => 'datetime-local',
'label' => 'Fermeture',
]); ?>
</div>
</div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -76,19 +76,34 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col6"> <div class="col4">
<?php echo template::select('courseEditEnrolment', $module::$courseEnrolment, [ <?php echo template::select('courseEditEnrolment', $module::$courseEnrolment, [
'label' => 'Inscription', 'label' => 'Inscription',
'selected' => $this->getdata(['course', $this->getUrl(2), 'enrolment']) 'selected' => $this->getdata(['course', $this->getUrl(2), 'enrolment'])
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col4">
<?php echo template::text('courseEditEnrolmentKey', [ <?php echo template::text('courseEditEnrolmentKey', [
'label' => 'Clé', 'label' => 'Clé',
'value' => $this->getdata(['course', $this->getUrl(2), 'enrolmentKey']) 'value' => $this->getdata(['course', $this->getUrl(2), 'enrolmentKey'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row">
<div class="col4">
<?php echo template::checkbox('courseEditEnrolmentLimit', true, 'Date de fin d\'inscription', [
'checked' => $this->getdata(['course', $this->getUrl(2), 'limitEnrolment']),
'help' => 'Ne s\'applique pas à l\'inscription anonyme',
]); ?>
</div>
<div class="col4">
<?php echo template::date('courseEditEnrolmentLimitDate', [
'type' => 'datetime-local',
'label' => 'Fermeture',
'value' => is_null($this->getdata(['course', $this->getUrl(2), 'limitEnrolmentDate'])) ? '' : floor($this->getdata(['course', $this->getUrl(2), 'limitEnrolmentDate']) / 60) * 60
]); ?>
</div>
</div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -1,15 +1,23 @@
<?php echo template::formOpen('courseSwapForm'); ?> <?php echo template::formOpen('courseSwapForm'); ?>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo "<h3>Auteur : " . $this->signature($this->getData(['course', $this->getUrl(2), 'author'])). "</h3>"; ?> <?php echo "<h3>Auteur : " . $this->signature($this->getData(['course', $this->getUrl(2), 'author'])) . "</h3>"; ?>
<?php echo "<p>Description : " . $this->getData(['course', $this->getUrl(2), 'description']) . "</p>"; ?> <?php echo "<p>Description : " . $this->getData(['course', $this->getUrl(2), 'description']) . "</p>"; ?>
<!--Restriction de date limite d'ouverture-->
<?php echo "<p>Disponibilité : " . $module::$courseAccess[$this->getData(['course', $this->getUrl(2), 'access'])]; ?> <?php echo "<p>Disponibilité : " . $module::$courseAccess[$this->getData(['course', $this->getUrl(2), 'access'])]; ?>
<?php if ($this->getData(['course', $this->getUrl(2), 'access']) === $module::COURSE_ACCESS_DATE): ?> <?php if ($this->getData(['course', $this->getUrl(2), 'access']) === $module::COURSE_ACCESS_DATE): ?>
<?php $from = helper::dateUTF8('%d %B %Y', $this->getData(['course', $this->getUrl(2), 'openingDate']), self::$i18nUI) . helper::translate(' à ') . helper::dateUTF8('%H:%M', $this->getData(['course', $this->getUrl(2), 'openingDate']), self::$i18nUI); ?> <?php $from = helper::dateUTF8('%d %B %Y', $this->getData(['course', $this->getUrl(2), 'openingDate']), self::$i18nUI) . helper::translate(' à ') . helper::dateUTF8('%H:%M', $this->getData(['course', $this->getUrl(2), 'openingDate']), self::$i18nUI); ?>
<?php $to = helper::dateUTF8('%d %B %Y', $this->getData(['course', $this->getUrl(2), 'closingDate']), self::$i18nUI) . helper::translate(' à ') . helper::dateUTF8('%H:%M', $this->getData(['course', $this->getUrl(2), 'closingDate']), self::$i18nUI); ?> <?php $to = helper::dateUTF8('%d %B %Y', $this->getData(['course', $this->getUrl(2), 'closingDate']), self::$i18nUI) . helper::translate(' à ') . helper::dateUTF8('%H:%M', $this->getData(['course', $this->getUrl(2), 'closingDate']), self::$i18nUI); ?>
<?php echo sprintf(helper::translate(' du %s au %s'), $from, $to); ?> <?php echo sprintf(helper::translate(' du %s au %s'), $from, $to); ?>
<?php endif; ?> <?php endif; ?>
<?php echo "</p><p>Inscription : " . $module::$courseEnrolment[$this->getData(['course', $this->getUrl(2), 'enrolment'])] . "</p>"; ?> <?php echo '</p>'; ?>
<?php echo "<p>Inscription : " . $module::$courseEnrolment[$this->getData(['course', $this->getUrl(2), 'enrolment'])] . '.'; ?>
<!--Restriction de date limite d'insription-->
<?php if ($this->getData(['course', $this->getUrl(2), 'limitEnrolment']) === true && $this->getData(['course', $this->getUrl(2), 'limitEnrolmentDate']) <= time()):?>
<?php echo helper::translate(' Les inscriptions sont closes depuis le ') ?>
<?php echo helper::dateUTF8('%d %B %Y', $this->getData(['course', $this->getUrl(2), 'limitEnrolmentDate']), self::$i18nUI) . helper::translate(' à ') . helper::dateUTF8('%H:%M', $this->getData(['course', $this->getUrl(2), 'limitEnrolmentDate']), self::$i18nUI); ?>
<?php endif; ?>
<?php echo '</p>'; ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -44,8 +52,10 @@
<div class="col3 offset7"> <div class="col3 offset7">
<?php echo template::submit('courseSwapSubmit', [ <?php echo template::submit('courseSwapSubmit', [
'value' => $module::$swapMessage['submitLabel'], 'value' => $module::$swapMessage['submitLabel'],
'disabled' => !$module->courseIsAvailable($this->getUrl(2)), 'disabled' => !($module->courseIsAvailable($this->getUrl(2))
'ico' => '' && !($this->getData(['course', $this->getUrl(2), 'limitEnrolment']) === true
&& $this->getData(['course', $this->getUrl(2), 'limitEnrolmentDate']) <= time())
),
]); ?> ]); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>