manque la fonction de désincription

This commit is contained in:
Fred Tempez 2023-10-19 22:48:57 +02:00
parent 9a21f8c5d1
commit 851f6421d6
3 changed files with 179 additions and 38 deletions

View File

@ -12,21 +12,101 @@
</div>
</div>
<div class="row">
<div class="col8">
<div class="col6">
<?php echo template::select('coursesConfigCategories', $module::$courseCategories, [
'label' => 'Catégorie à afficher',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'category'])
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo helper::translate('Disponibilité du cours'); ?>
</h4>
<div class="row">
<div class="col4">
<?php echo template::text('coursesCaptionAccessOpen', [
'label' => 'Ouvert',
'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'accessopen'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('coursesCaptionAccessDate', [
'label' => 'Période',
'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'accessdate'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('coursesCaptionAccessClose', [
'label' => 'Fermé',
'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'accessclose'])
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<h4>
<?php echo helper::translate('Modalité d\'accès'); ?>
</h4>
</div>
</div>
<div class="row">
<div class="col4">
<?php echo template::text('coursesCaptionGuest', [
'label' => 'Anonyme',
'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'enrolguest'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('coursesCaptionSelf', [
'label' => 'Membre',
'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'enrolself'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('coursesCaptionSelfKey', [
'label' => 'Membre avec clé',
'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'enrolselfkey'])
]); ?>
</div>
</div>
<div class="row">
<div class="col4">
<?php echo template::text('coursesCaptionUrl', [
'label' => 'Lien vers le cours',
'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'url'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('coursesCaptionUnsuscribe', [
'label' => 'Désinscription',
'value' => $this->getData(['module', $this->getUrl(0), 'caption', 'unsuscribe'])
]); ?>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col6">
<div class="block">
<h4>
<?php echo helper::translate('Elements à afficher'); ?>
</h4>
<div class="row">
<div class="col12">
<?php echo template::checkbox('coursesConfigShowTitle', true, 'Titre Long', [
<?php echo template::checkbox('coursesConfigShowTitle', true, 'Titre', [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'title'])
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::checkbox('coursesConfigShowAuthor', true, 'Nom de l\'auteur', [
<?php echo template::checkbox('coursesConfigShowAuthor', true, 'Signature de l\'auteur', [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'author'])
]); ?>
</div>
@ -64,29 +144,14 @@
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::text('coursesConfigCaption', [
'label' => 'Texte du lien vers le cours',
'value' => $this->getData(['module', $this->getUrl(0), 'config', 'caption'])
]); ?>
</div>
</div>
</div>
</div>
<div class="col4">
<div class="col6">
<div class="block">
<h4>
<?php echo helper::translate('Paramètres'); ?>
<?php echo helper::translate('Thème'); ?>
</h4>
<div class="row">
<div class="col12">
<?php echo template::select('coursesConfigCategories', $module::$courseCategories, [
'label' => 'Catégorie à afficher',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'category'])
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::select('coursesConfigLayout', $module::$coursesLayout, [

View File

@ -55,17 +55,28 @@
</p>
<?php endif; ?>
<!-- Lien -->
<!-- Lien accès au cours-->
<div class="row">
<div class="col6">
<?php if (
$courseValue['access'] === self::COURSE_ACCESS_OPEN
||
($courseValue['access'] === self::COURSE_ACCESS_DATE && time() >= $courseValue['openingDate'] && time() <= $courseValue['closingDate'])
): ?>
<a href="<?php echo helper::baseUrl(); ?>course/swap/<?php echo $courseId; ?>">
<?php echo $this->getData(['module', $this->getUrl(0), 'config', 'caption']); ?>
<?php echo $this->getData(['module', $this->getUrl(0), 'caption', 'url']); ?>
</a>
<?php endif; ?>
</div>
<div class="col6 textAlignRight">
<!-- Lien désinscription-->
<?php if ($this->getData(['enrolment', $courseId, $this->getUser('id')])): ?>
<a href="<?php echo helper::baseUrl(); ?>course/unsuscribe/<?php echo $courseId; ?>">
<?php echo $this->getData(['module', $this->getUrl(0), 'caption', 'unsuscribe']); ?>
</a>
<?php endif; ?>
</div>
</div>
<!-- Fin du bloc et bordure -->
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'template']) === true): ?>
</div>

View File

@ -36,26 +36,44 @@ class workshop extends common
2 => 'Six cours par ligne',
];
public static $coursesAccess = [];
public static $coursesAccess = [
self::COURSE_ACCESS_OPEN => 'ouvert',
self::COURSE_ACCESS_DATE => 'période d\'ouverture',
self::COURSE_ACCESS_CLOSE => 'fermé',
public static $coursesEnrolment = [];
public static $default = [
"config" => array(
"category" => "general",
"title" => true,
"author" => true,
"description" => true,
"access" => true,
"openingdate" => true,
"closingdate" => true,
"enrolment" => true,
"layout" => 6,
"template" => true
),
"caption" => array(
"accessopen" => "ouvert",
"accessdate" => "p&eacute;riode d&#039;ouverture",
"accessclose" => "ferm&eacute;",
"enrolguest" => "anonyme",
"enrolself" => "membres",
"enrolselfkey" => "membres avec cl&eacute;",
"url" => "Acc&eacute;der au cours",
"unsuscribe" => "Me d&eacute;sinscrire"
)
];
public static $coursesEnrolment = [
self::COURSE_ENROLMENT_GUEST => 'anonyme, sans inscription',
self::COURSE_ENROLMENT_SELF => 'réservée aux membres inscrits',
self::COURSE_ENROLMENT_SELF_KEY => 'réservé aux membres et avec une clé d\'inscription ',
//self::COURSE_ENROLMENT_MANUAL => 'Manuelle'
];
public static $coursesDetails = [];
/**
* Configuration
*/
public function config()
{
// Contrôle de la configuration par défaut
$this->update();
// Soumission du formulaire
if (
$this->getUser('permission', __CLASS__, __FUNCTION__) === true &&
@ -79,6 +97,21 @@ class workshop extends common
'template' => $this->getInput('coursesConfigTemplate', helper::FILTER_BOOLEAN),
]
]);
$this->setData([
'module',
$this->getUrl(0),
'caption',
[
'accessopen' => $this->getInput('coursesCaptionAccessOpen', helper::FILTER_STRING_SHORT),
'accessdate' => $this->getInput('coursesCaptionAccessDate', helper::FILTER_STRING_SHORT),
'accessclose' => $this->getInput('coursesCaptionAccessClose', helper::FILTER_STRING_SHORT),
'enrolguest' => $this->getInput('coursesCaptionGuest', helper::FILTER_STRING_SHORT),
'enrolself' => $this->getInput('coursesCaptionSelf', helper::FILTER_STRING_SHORT),
'enrolselfkey' => $this->getInput('coursesCaptionSelfKey', helper::FILTER_STRING_SHORT),
'url' => $this->getInput('coursesCaptionUrl', helper::FILTER_STRING_SHORT),
'unsuscribe' => $this->getInput('coursesCaptionUnsuscribe', helper::FILTER_STRING_SHORT),
]
]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(),
@ -97,6 +130,17 @@ class workshop extends common
}
public function index()
{
// Contrôle de la configuration par défaut
$this->update();
// Mise à jour des étiquettes
self::$coursesAccess[self::COURSE_ACCESS_OPEN] = $this->getData(['module', $this->getUrl(0), 'caption', 'accessopen']);
self::$coursesAccess[self::COURSE_ACCESS_DATE] = $this->getData(['module', $this->getUrl(0), 'caption', 'accessdate']);
self::$coursesAccess[self::COURSE_ACCESS_CLOSE] = $this->getData(['module', $this->getUrl(0), 'caption', 'accessclose']);
self::$coursesEnrolment[self::COURSE_ENROLMENT_GUEST] = $this->getData(['module', $this->getUrl(0), 'caption', 'enrolguest']);
self::$coursesEnrolment[self::COURSE_ENROLMENT_SELF] = $this->getData(['module', $this->getUrl(0), 'caption', 'enrolself']);
self::$coursesEnrolment[self::COURSE_ENROLMENT_SELF_KEY] = $this->getData(['module', $this->getUrl(0), 'caption', 'enrolselfkey']);
// Valeurs en sortie
$this->addOutput([
'showBarEditButton' => true,
@ -112,4 +156,25 @@ class workshop extends common
'view' => 'index',
]);
}
// Initialise avec des valeurs par défaut
private function update()
{
$check = false;
foreach (self::$default['config'] as $key => $value) {
if (is_null($this->getData(['module', $this->getUrl(0), 'config', $key]))) {
$this->setData(['module', $this->getUrl(0), 'config', $key, $value]);
$check = true;
}
}
foreach (self::$default['caption'] as $key => $value) {
if (is_null($this->getData(['module', $this->getUrl(0), 'caption', $key]))) {
$this->setData(['module', $this->getUrl(0), 'caption', $key, $value]);
$check = true;
}
}
if ($check) {
header('refresh:0');
}
}
}