Il problema è che nella lista corsi nel catalogo il link per l'autodisiscrizione non tiene (e non può tenere) conto delle eventuali edizioni a cui l'utente è iscritto, per cui NON passa il parametro relativo all'edizione.
Bisognerebbe ragionare sulla logica con cui è stata fatta questa cosa.
In teoria un utente potrebbe essere iscritto a più edizioni dello stesso corso.
Se diamo possibilità di disiscriversi vogliamo che l'utente si disiscriva a TUTTE le edizioni del corso?
In questo caso il fix è facile.
In /appLms/controllers/ElearningLmsController.php, prova a riscrivere così la funzione self_unsubscribe:
Code: Select all
public function self_unsubscribe() {
$id_user = Docebo::user()->idst;//Get::req('id_user', DOTY_INT, Docebo::user()->idst);
$id_course = Get::req('id_course', DOTY_INT, 0);
$id_edition = Get::req('id_edition', DOTY_INT, 0);
$id_date = Get::req('id_date', DOTY_INT, 0);
$cmodel = new CourseAlms();
$cinfo = $cmodel->getCourseModDetails($id_course);
//index.php?r=elearning/show
$back = Get::req('back', DOTY_STRING, "");
if ($back != "") {
$parts = explode('/', $back);
$length = count($parts);
if ($length > 0) {
$parts[$length -1] = 'show';
$back = implode('/', $parts);
}
}
$jump_url = 'index.php?r='.($back ? $back : 'lms/elearning/show');
if ($cinfo['auto_unsubscribe'] == 0) {
//no self unsubscribe possible for this course
Util::jump_to($jump_url.'&res=err_unsub');
}
$date_ok = TRUE;
if ($cinfo['unsubscribe_date_limit'] != "" && $cinfo['unsubscribe_date_limit'] != "0000-00-00 00:00:00") {
if ($cinfo['unsubscribe_date_limit'] < date("Y-m-d H:i:s")) {
//self unsubscribing is no more allowed, go back to courselist page
Util::jump_to($jump_url.'&res=err_unsub');
}
}
$smodel = new SubscriptionAlms();
$param = '';
if ($cinfo['auto_unsubscribe'] == 1) {
//moderated self unsubscribe
$res = $smodel->setUnsubscribeRequest($id_user, $id_course, $id_edition, $id_date);
$param .= $res ? '&res=ok_unsub' : '&res=err_unsub';
}
if ($cinfo['auto_unsubscribe'] == 2) {
//directly unsubscribe user
if($id_edition == 0 && $cinfo['course_edition'] == 1 )
{
require_once(_lms_.'/lib/lib.edition.php');
$edition_man = new EditionManager();
$user_edition = $edition_man->getUserEdition($id_user);
$res = true;
foreach($user_edition as $id_edition)
{
if (!$smodel->unsubscribeUser($id_user, $id_course, $id_edition, $id_date))
{
$res = false;
break;
}
}
}
else
$res = $smodel->unsubscribeUser($id_user, $id_course, $id_edition, $id_date);
$param .= $res ? '&res=ok_unsub' : '&res=err_unsub';
}
Util::jump_to($jump_url);
}