v26 désinscription

This commit is contained in:
Fred Tempez 2023-10-07 18:30:43 +02:00
parent d76b0295df
commit b85327491d
4 changed files with 71 additions and 22 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.0.25'; const ZWII_VERSION = '1.0.26';
// URL autoupdate // URL autoupdate
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/lms/'; const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/lms/';

View File

@ -28,6 +28,7 @@ class course extends common
'categoryDelete' => self::GROUP_ADMIN, 'categoryDelete' => self::GROUP_ADMIN,
'user' => self::GROUP_ADMIN, 'user' => self::GROUP_ADMIN,
'userAdd' => self::GROUP_ADMIN, 'userAdd' => self::GROUP_ADMIN,
'userDelete' => self::GROUP_ADMIN,
]; ];
public static $courseAccess = [ public static $courseAccess = [
@ -340,23 +341,34 @@ class course extends common
public function categoryDelete() public function categoryDelete()
{ {
$categories = helper::arrayColumn($this->getData(['course']), 'category', 'SORT_ASC'); // Accès refusé
$courseId = $this->getUrl(2); if (
$message = helper::translate('Une catégorie affectée ne peut pas être effacée'); $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
$state = false; ) {
if (in_array($courseId, $categories) === false) {
$this->deleteData(['category', $this->getUrl(2)]);
// Valeurs en sortie // Valeurs en sortie
$message = helper::translate('Catégorie effacée'); $this->addOutput([
$state = true; 'access' => false
]);
} else {
$categories = helper::arrayColumn($this->getData(['course']), 'category', 'SORT_ASC');
$courseId = $this->getUrl(2);
$message = helper::translate('Une catégorie affectée ne peut pas être effacée');
$state = false;
if (in_array($courseId, $categories) === false) {
$this->deleteData(['category', $this->getUrl(2)]);
// Valeurs en sortie
$message = helper::translate('Catégorie effacée');
$state = true;
}
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'course/category',
'notification' => $message,
'state' => $state
]);
} }
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'course/category',
'notification' => $message,
'state' => $state
]);
} }
public function user() public function user()
@ -369,11 +381,11 @@ class course extends common
$this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']), $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
$userValue['lastPageId'], $userValue['lastPageId'],
helper::dateUTF8('%d %B %Y - %H:%M', $userValue['dateVisit']), helper::dateUTF8('%d %B %Y - %H:%M', $userValue['dateVisit']),
template::button('courseDelete' . $userId, [ template::button('userDelete' . $userId, [
'class' => 'categoryDelete buttonRed', 'class' => 'userDelete buttonRed',
'href' => helper::baseUrl() . 'course/userDelete/' . $userId, 'href' => helper::baseUrl() . 'course/userDelete/'. $this->getUrl(2) . '/' . $userId,
'value' => template::ico('trash'), 'value' => template::ico('minus'),
'help' => 'Supprimer' 'help' => 'Désinscrire'
]) ])
]; ];
} }
@ -394,6 +406,30 @@ class course extends common
]); ]);
} }
/**
* Désinscription d'un utilisateur
*/
public function userDelete()
{
// Accès refusé
if (
$this->getUser('permission', __CLASS__, __FUNCTION__) !== true
) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
} else {
$this->deleteData(['enrolment', $this->getUrl(2), $this->getUrl(3)]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'course/user/' . $this->getUrl(2),
'notification' => sprintf(helper::translate('%s est désinscrit'), $this->getUrl(3)),
'state' => true
]);
}
}
/* /*
* Traitement du changement de langue * Traitement du changement de langue
*/ */

View File

@ -0,0 +1,13 @@
/**
* This file is part of Zwii.
* For full copyright and license information, please see the LICENSE
* file that was distributed with this source code.
*
* @author Rémi Jean <remi.jean@outlook.com>
* @copyright Copyright (C) 2008-2018, Rémi Jean
* @author Frédéric Tempez <frederic.tempez@outlook.com>
* @copyright Copyright (C) 2018-2023, Frédéric Tempez
* @license CC Attribution-NonCommercial-NoDerivatives 4.0 International
* @link http://zwiicms.fr/
*/
$(".userDelete").on("click", (function () { var _this = $(this); return message = "<?php echo helper::translate('Confirmer la désinscription de cet utilisateur');?>", core.confirm(message, (function () { $(location).attr("href", _this.attr("href")) })) }));

View File

@ -7,11 +7,11 @@
]); ?> ]); ?>
</div> </div>
<div class="col1 offset10"> <div class="col1 offset10">
<?php echo template::button('courseUserAdd', [ <?php /*echo template::button('courseUserAdd', [
'class' => 'buttonGreen', 'class' => 'buttonGreen',
'href' => helper::baseUrl() . 'course/userAdd', 'href' => helper::baseUrl() . 'course/userAdd',
'value' => template::ico('plus') 'value' => template::ico('plus')
]); ?> ]); */?>
</div> </div>
</div> </div>