workshop tient compte des restrictions d'inscriptions

This commit is contained in:
Fred Tempez 2023-11-18 16:34:49 +01:00
parent 3c4e5f7d05
commit 9c23902d63
3 changed files with 119 additions and 104 deletions

View File

@ -165,6 +165,15 @@
]); ?>
</div>
</div>
<div class="row">
<div class="col4">
<?php echo template::text('coursesCaptionEnrolmentLimit', [
'label' => 'Limitation date inscription',
'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'enrolmentLimit']),
'help' => 'Classe CSS de la division : workshopEnrolmentLimit'
]); ?>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,102 +1,106 @@
<?php $startRow = 0; ?>
<?php foreach ($this->getData(['course']) as $courseId => $courseValue): ?>
<!-- Filtre de catégorie -->
<?php if ($courseValue['category'] !== $this->getData(['module', $this->getUrl(0), 'config', 'category'])):?>
<?php if ($courseValue['category'] !== $this->getData(['module', $this->getUrl(0), 'config', 'category'])): ?>
<?php continue; ?>
<?php endif; ?>
<?php if ($startRow === 0): ?>
<div class="row workshopRowContainer">
<?php endif; ?>
<!-- Layout en colonnes -->
<div class="workshopItemContainer col<?php echo $this->getData(['module', $this->getUrl(0), 'config', 'layout']); ?>">
<!-- Affchage par bloc et bordure -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'template']) === true): ?>
<div class="block">
<h4>
<?php endif; ?>
<!-- Layout en colonnes -->
<div
class="workshopItemContainer col<?php echo $this->getData(['module', $this->getUrl(0), 'config', 'layout']); ?>">
<!-- Affchage par bloc et bordure -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'template']) === true): ?>
<div class="block">
<h4>
<?php else: ?>
<p>
<?php endif; ?>
<!-- Insère le titre court dans tous les cas -->
<span class="workshopTitle">
<?php echo $courseValue['title']; ?>
</span>
<!-- Fin du bloc et bordure titre 4 -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'template']) === true): ?>
</h4>
<?php else: ?>
<p>
<?php endif; ?>
<!-- Insère le titre court dans tous les cas -->
<span class="workshopTitle">
<?php echo $courseValue['title']; ?>
</span>
<!-- Fin du bloc et bordure titre 4 -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'template']) === true): ?>
</h4>
<?php else: ?>
<p>
<?php endif; ?>
<!-- Description -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'description']) === true): ?>
<p>
<span class="workshopDescription">
<?php echo $courseValue['description']; ?>
</span>
</p>
<?php endif; ?>
<!-- Author -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'author']) === true): ?>
<p>
<span class="workshopAuthor">
<?php echo $this->signature($courseValue['author']); ?>
</span>
</p>
<?php endif; ?>
<!-- Modalité d'ouverture -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'access']) === true): ?>
<div class="workshopAccessContainer">
<?php endif; ?>
<!-- Description -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'description']) === true): ?>
<p>
<span class="workshopAccess">
<?php echo sprintf(helper::translate($module::$coursesAccess[$courseValue['access']] ), helper::dateUTF8('%d %B %Y', $courseValue['openingDate']), helper::dateUTF8('%d %B %Y', $courseValue['closingDate'])) ?>
<span class="workshopDescription">
<?php echo $courseValue['description']; ?>
</span>
</p>
<?php endif; ?>
<!-- Author -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'author']) === true): ?>
<p>
<span class="workshopAuthor">
<?php echo $this->signature($courseValue['author']); ?>
</span>
</p>
<?php endif; ?>
<!-- Modalité d'ouverture -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'access']) === true): ?>
<div class="workshopAccessContainer">
<p>
<span class="workshopAccess">
<?php echo sprintf(helper::translate($module::$coursesAccess[$courseValue['access']]), helper::dateUTF8('%d %B %Y', $courseValue['openingDate']), helper::dateUTF8('%d %B %Y', $courseValue['closingDate'])) ?>
</span>
</p>
</div>
<?php endif; ?>
<!-- Modalité d'inscription -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'enrolment']) === true): ?>
<p>
<span class="workshopEnrolment">
<?php echo $module::$coursesEnrolment[$courseValue['enrolment']]; ?>
</span>
</p>
<?php if ($this->getData(['course', $courseId, 'limitEnrolment']) === true ):?>
<?php echo $this->getData(['module', $this->getUrl(0), 'caption', 'enrolmentLimit']); ?>
<?php echo helper::dateUTF8(' %d %B %Y', $this->getData(['course', $courseId, 'limitEnrolmentDate']), self::$i18nUI) . helper::translate(' à ') . helper::dateUTF8('%H:%M', $this->getData(['course', $courseId, 'limitEnrolmentDate']), self::$i18nUI); ?>
<?php endif; ?>
<?php endif; ?>
<!-- Lien accès au contenu-->
<div class="row">
<div class="col6 workshopLinkContainer">
<?php if (
$courseValue['access'] === self::COURSE_ACCESS_OPEN
||
($courseValue['access'] === self::COURSE_ACCESS_DATE && time() >= $courseValue['openingDate'] && time() <= $courseValue['closingDate'])
): ?>
<span class="workshopSuscribe">
<a href="<?php echo helper::baseUrl(); ?>course/swap/<?php echo $courseId; ?>">
<?php echo $this->getData(['module', $this->getUrl(0), 'caption', 'url']); ?>
</a>
</span>
<?php endif; ?>
</div>
<div class="col6 textAlignRight">
<!-- Lien désinscription-->
<?php if ($this->getData(['enrolment', $courseId, $this->getUser('id')])): ?>
<span class="workshopUnsuscribe">
<a href="<?php echo helper::baseUrl(); ?>course/unsuscribe/<?php echo $courseId; ?>">
<?php echo $this->getData(['module', $this->getUrl(0), 'caption', 'unsuscribe']); ?>
</a>
</span>
<?php endif; ?>
</div>
</div>
<!-- Fin du bloc et bordure -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'template']) === true): ?>
</div>
<?php endif; ?>
<!-- Modalité d'inscription -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'enrolment']) === true): ?>
<p>
<span class="workshopEnrolment">
<?php echo $module::$coursesEnrolment[$courseValue['enrolment']]; ?>
</span>
</p>
<?php endif; ?>
<!-- Lien accès au contenu-->
<div class="row">
<div class="col6 workshopLinkContainer">
<?php if (
$courseValue['access'] === self::COURSE_ACCESS_OPEN
||
($courseValue['access'] === self::COURSE_ACCESS_DATE && time() >= $courseValue['openingDate'] && time() <= $courseValue['closingDate'])
): ?>
<span class="workshopSuscribe">
<a href="<?php echo helper::baseUrl(); ?>course/swap/<?php echo $courseId; ?>">
<?php echo $this->getData(['module', $this->getUrl(0), 'caption', 'url']); ?>
</a>
</span>
<?php endif; ?>
</div>
<div class="col6 textAlignRight">
<!-- Lien désinscription-->
<?php if ($this->getData(['enrolment', $courseId, $this->getUser('id')])): ?>
<span class="workshopUnsuscribe">
<a href="<?php echo helper::baseUrl(); ?>course/unsuscribe/<?php echo $courseId; ?>">
<?php echo $this->getData(['module', $this->getUrl(0), 'caption', 'unsuscribe']); ?>
</a>
</span>
<?php endif; ?>
</div>
</div>
<!-- Fin du bloc et bordure -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'template']) === true): ?>
</div>
<?php endif; ?>
</div>
<?php $startRow = $startRow + $this->getData(['module', $this->getUrl(0), 'config', 'layout']); ?>
<?php if ($startRow === 12): ?>
</div>
<?php $startRow = $startRow + $this->getData(['module', $this->getUrl(0), 'config', 'layout']); ?>
<?php if ($startRow === 12): ?>
</div>
<?php $startRow = 0; ?>
<?php endif; ?>

View File

@ -41,25 +41,26 @@ class workshop extends common
public static $coursesEnrolment = [];
public static $default = [
"config" => array(
"category" => "general",
"title" => true,
"author" => true,
"description" => true,
"access" => true,
"enrolment" => true,
"layout" => 6,
"template" => true
'config' => array(
'category' => 'general',
'title' => true,
'author' => true,
'description' => true,
'access' => true,
'enrolment' => true,
'layout' => 6,
'template' => true
),
"caption" => array(
"accessopen" => "Ouvert",
"accessdate" => "P&eacute;riode d&#039;ouverture du %s au %s",
"accessclose" => "Ferm&eacute;",
"enrolguest" => "Anonyme",
"enrolself" => "Membres",
"enrolselfkey" => "Membres avec cl&eacute;",
"url" => "Acc&eacute;der au contenu",
"unsuscribe" => "Me d&eacute;sinscrire"
'caption' => array(
'accessopen' => 'Ouvert',
'accessdate' => 'P&eacute;riode d&#039;ouverture du %s au %s',
'accessclose' => 'Ferm&eacute;',
'enrolguest' => 'Anonyme',
'enrolself' => 'Membres',
'enrolselfkey' => 'Membres avec cl&eacute;',
'url' => 'Acc&eacute;der au contenu',
'unsuscribe' => 'Me d&eacute;sinscrire',
'enrolmentLimit' => 'Date limite des inscriptions',
)
];
@ -71,7 +72,7 @@ class workshop extends common
// Contrôle de la configuration par défaut
$this->update();
// Soumission du formulaire
if (
$this->getUser('permission', __CLASS__, __FUNCTION__) === true &&
@ -108,6 +109,7 @@ class workshop extends common
'enrolselfkey' => $this->getInput('coursesCaptionSelfKey', helper::FILTER_STRING_SHORT),
'url' => $this->getInput('coursesCaptionUrl', helper::FILTER_STRING_SHORT),
'unsuscribe' => $this->getInput('coursesCaptionUnsuscribe', helper::FILTER_STRING_SHORT),
'enrolmentLimit' => $this->getInput('coursesCaptionEnrolmentLimit', helper::FILTER_STRING_SHORT),
]
]);
// Valeurs en sortie