userHistory, one event a line

This commit is contained in:
Fred Tempez 2023-12-09 17:51:36 +01:00
parent d59062cd46
commit 103991b2be

View File

@ -970,20 +970,22 @@ class course extends common
if (is_array($times)) { if (is_array($times)) {
$d = array(); $d = array();
foreach ($times as $time) { foreach ($times as $time) {
$d[] = helper::dateUTF8('%d %B %Y - %H:%M:%S', $time); self::$userHistory[] = [
$pages[$pageId]['number'],
html_entity_decode($pages[$pageId]['title']),
helper::dateUTF8('%d %B %Y %H:%M:%S', $time)
];
} }
$dates = implode('<br />', $d);
} else { } else {
$dates = helper::dateUTF8('%d %B %Y - %H:%M:%S', $times); self::$userHistory[] = [
$pages[$pageId]['number'],
html_entity_decode($pages[$pageId]['title']),
helper::dateUTF8('%d %B %Y %H:%M:%S', $times)
];
} }
self::$userHistory[$pageId] = [
$pages[$pageId]['number'],
$pages[$pageId]['title'],
$dates,
];
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => helper::translate('Historique ') . $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']), 'title' => helper::translate('Historique ') . $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
@ -1110,8 +1112,6 @@ class course extends common
helper::dateUTF8('%d %B %Y %H:%M:%S', $times) helper::dateUTF8('%d %B %Y %H:%M:%S', $times)
]; ];
} }
} }
// Dossier temporaire // Dossier temporaire
@ -1124,7 +1124,7 @@ class course extends common
$path = self::FILE_DIR . 'source/export/'; $path = self::FILE_DIR . 'source/export/';
$filename = $path . $courseId . '/' . $userId . '.csv'; $filename = $path . $courseId . '/' . $userId . '.csv';
$file = fopen($filename, 'w'); $file = fopen($filename, 'w');
foreach (self::$userHistory as $keys => $values) { foreach (self::$userHistory as $keys => $values) {
$data = $values; $data = $values;
// Écrire la ligne dans le fichier CSV // Écrire la ligne dans le fichier CSV