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> </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> </div>
</div> </div>

View File

@ -1,102 +1,106 @@
<?php $startRow = 0; ?> <?php $startRow = 0; ?>
<?php foreach ($this->getData(['course']) as $courseId => $courseValue): ?> <?php foreach ($this->getData(['course']) as $courseId => $courseValue): ?>
<!-- Filtre de catégorie --> <!-- 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 continue; ?>
<?php endif; ?> <?php endif; ?>
<?php if ($startRow === 0): ?> <?php if ($startRow === 0): ?>
<div class="row workshopRowContainer"> <div class="row workshopRowContainer">
<?php endif; ?> <?php endif; ?>
<!-- Layout en colonnes --> <!-- Layout en colonnes -->
<div class="workshopItemContainer col<?php echo $this->getData(['module', $this->getUrl(0), 'config', 'layout']); ?>"> <div
<!-- Affchage par bloc et bordure --> class="workshopItemContainer col<?php echo $this->getData(['module', $this->getUrl(0), 'config', 'layout']); ?>">
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'template']) === true): ?> <!-- Affchage par bloc et bordure -->
<div class="block"> <?php if ($this->getData(['module', $this->getUrl(0), 'config', 'template']) === true): ?>
<h4> <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: ?> <?php else: ?>
<p> <p>
<?php endif; ?> <?php endif; ?>
<!-- Description -->
<!-- Insère le titre court dans tous les cas --> <?php if ($this->getData(['module', $this->getUrl(0), 'config', 'description']) === true): ?>
<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">
<p> <p>
<span class="workshopAccess"> <span class="workshopDescription">
<?php echo sprintf(helper::translate($module::$coursesAccess[$courseValue['access']] ), helper::dateUTF8('%d %B %Y', $courseValue['openingDate']), helper::dateUTF8('%d %B %Y', $courseValue['closingDate'])) ?> <?php echo $courseValue['description']; ?>
</span> </span>
</p> </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> </div>
<?php endif; ?> <?php endif; ?>
</div>
<!-- Modalité d'inscription --> <?php $startRow = $startRow + $this->getData(['module', $this->getUrl(0), 'config', 'layout']); ?>
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'enrolment']) === true): ?> <?php if ($startRow === 12): ?>
<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> </div>
<?php $startRow = 0; ?> <?php $startRow = 0; ?>
<?php endif; ?> <?php endif; ?>

View File

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