Plugin: Resubscription: Fix SQL query using old end date field name - refs #4825

pull/4863/head
Yannick Warnier 2 years ago
parent 0cb5a5eb5a
commit 342c2d54f3
  1. 7
      plugin/resubscription/README.md
  2. 13
      plugin/resubscription/lang/french.php
  3. 12
      plugin/resubscription/src/HookResubscription.php

@ -3,4 +3,9 @@ Resubscription
Limit session re-subscriptions by checking whether the user was already
subscribed to a specific course *through a session* over the last 12
months or the last calendar year.
months or the last calendar year (from 1st of January to 31st of December).
This plugin does not support sessions by "duration" at this time, so the
date of last access is based on the session's access_end_date field, which
defines when student access is removed (not the "display" end date, which
is the date that shows in the session's public details).

@ -0,0 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Strings to French L10n.
*
* @package chamilo.plugin.resubscription
*/
$strings['plugin_title'] = 'Réinscription';
$strings['plugin_comment'] = 'Ce plugin permet de limiter les réinscriptions à des sessions qui contiennent des cours que les utilisateurs ont déjà suivi moins d\'un an auparavant.';
$strings['resubscription_limit'] = 'Limite de réinscription';
$strings['resubscription_limit_help'] = 'Type de limite (calendrier : du 1/1 au 31/12, ou naturelle : 365 jours après la fin de la session précédente.';
$strings['CanResubscribeFromX'] = 'Réinscription possible à partir du %s';

@ -45,20 +45,20 @@ class HookResubscription extends HookObserver implements HookResubscribeObserver
$limitDate = gmdate($limitDateFormat, strtotime("$limitDate -$resubscriptionOffset"));
}
$join = " INNER JOIN ".Database::get_main_table(TABLE_MAIN_SESSION)." ON id = session_id";
$join = " INNER JOIN ".Database::get_main_table(TABLE_MAIN_SESSION)." s ON s.id = su.session_id";
// User sessions and courses
$userSessions = Database::select(
'session_id, date_end',
Database::get_main_table(TABLE_MAIN_SESSION_USER).$join,
'su.session_id, s.access_end_date',
Database::get_main_table(TABLE_MAIN_SESSION_USER).' su '.$join,
[
'where' => [
'user_id = ? AND date_end >= ?' => [
'su.user_id = ? AND s.access_end_date >= ?' => [
api_get_user_id(),
$limitDate,
],
],
'order' => 'date_end DESC',
'order' => 'access_end_date DESC',
]
);
$userSessionCourses = [];
@ -76,7 +76,7 @@ class HookResubscription extends HookObserver implements HookResubscribeObserver
);
foreach ($userSessionCourseResult as $userSessionCourse) {
if (!isset($userSessionCourses[$userSessionCourse['c_id']])) {
$userSessionCourses[$userSessionCourse['c_id']] = $userSession['date_end'];
$userSessionCourses[$userSessionCourse['c_id']] = $userSession['access_end_date'];
}
}
}

Loading…
Cancel
Save